[Question]
  [
Given a string as input find the longest *contiguous* substring that does not have any character twice or more. If there are multiple such substrings you may output either. You may assume that the input is on the printable ASCII range if you wish.
## Scoring
Answers will first be ranked by the length of their own longest non-repeating substring, and then by their total length. Lower scores will be better for both criteria. Depending on the language this will probably feel like a [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") challenge with a source restriction.
## Triviality
In some languages achieving a score of **1, x** (lenguage) or **2, x** (Brain-flak and other turing tarpits) is pretty easy, however there are other languages in which minimizing the longest non-repeating substring is a challenge. I had a lot of fun getting a score of 2 in Haskell, so I encourage you to seek out languages where this task is fun.
## Test cases
```
"Good morning, Green orb!" -> "ing, Gre"
"fffffffffff" -> "f"
"oiiiiioiiii" -> "io", "oi"
"1234567890"  -> "1234567890"
"11122324455" -> "324"
```
## Scoring submission
You can score your programs using the following snippet:
```
input.addEventListener("input", change);
// note: intentionally verbose :)
function isUnique(str) {
  var maxCount = 0;
  var counts = {};
  for(var i = 0; i < str.length; i++) {
    var c = str.charAt(i);
    counts[c] |= 0;
    counts[c]++;
    if(maxCount < counts[c]) {
      maxCount = counts[c];
    }
  }
  return maxCount <= 1;
}
function maximizeSubstring(str, pred, cost) {
  var mostExpensive = -1;
  // iterate over substrings
  function iterate(start, end) {
    var slice = str.slice(start, end);
    if(pred(slice)) {
      var profit = cost(slice);
      if(profit > mostExpensive) {
        mostExpensive = profit;
      }
    }
    end++;
    if(start >= str.length) {
      return;
    }
    else if(end > str.length) {
      start++;
      iterate(start, start);
    }
    else {
      iterate(start, end);
    }
  }
  iterate(0, 0);
  return mostExpensive;
}
function size(x) {
  return x.length;
}
function longestNonRepeatingSize(str) {
  return maximizeSubstring(str, isUnique, size);
}
function change() {
  var code = input.value;
  output.value = "Your score is: " + longestNonRepeatingSize(code);
}
change();
```
```
* {
  font-family: monospace;
}
```
```
Input code here:
<br>
<textarea id="input"></textarea>
<br>
<textarea id="output"></textarea>
```
  
[Answer]
# C, score 2, ~~747~~ ~~720~~ 662 bytes
```
L  [  1  <<  7  ]  ,  *  q  ,  *  r  ,  l  ,  d  ,  i  ,  c  ,  j  ,  s  ,  t  ,  k  =  1  <<  7  ;  h  (  )  {  q  =  s  +  i  +  j  ++  ;  *  q  %  k  &&  !  L  [  *  q  %  k  ]  ++  &&  h  (  ++  c  )  ;  }  g  (  )  {  q  =  s  +  i  ;  *  q  %  k  ?  z  (  k  )  ,  h  (  j  =  c  =  0  )  ,  c  >  d  &&  (  d  =  c  )  &&  (  l  =  i  )  ,  g  (  ++  i  )  :  0  ;  }  f  (  S  ,  T  )  {  s  =  S  ;  l  =  i  =  d  =  0  ;  g  (  t  =  T  )  ;  p  (  i  =  0  )  ;  }  p  (  )  {  q  =  s  +  l  +  i  ;  r  =  t  +  i  ;  i  ++  <  d  ?  p  (  *  r  =  *  q  )  :  (  *  r  =  0  )  ;  }  z  (  i  )  {  L  [  --  i  ]  =  0  ;  i  &&  z  (  i  )  ;  }
```
Works at least on 32-bit MinGW (with optimizations disabled). Doesn't use a single keyword.
Works apparently on TIO with gcc and clang, too: [Try it online!](https://tio.run/##7VM9b8IwFNz5FQdSUSCJxFdLW0gZWbrBhjJQQ4IhJDRJFxB/vSk519RqhVg74OHJvnfv7vklFm4oRFG8AjOgDQyHQB/wAQdoAu96k3ITMS4YJaNgXDNmjDnjBvBMxQGwAiygARyo67HAppBNCdsmT9neUaNeB6qA6s9M@Ipe5pVueRKUP0kcgfCy2y@PEbAneUO@oxXXrBKMLZ06HV84gdLZ4s7Txt9QREjqivDcnoKeqaaaDJibkDfV3Wasn5Bz1vK0lapVojmRqb71jqA0GlYuuwujiIyBpMRzA5Gq6SGNR1qlqalqguo@Jm4a73VDylt9Rdcl5Bu3kWp2Jr0UKGScYzuXsdWoHCo4LbGap8jydNZudXr@oEIwsGrjJFlgm6SxjEMH43S5jJGkb9WaU7IbA/J2H3lmqaOuC37WNWoiy8V4jdrudHv3D/3Hp9Y15u3d3d7d/3t3tb8/7LH4FEE0D7PC3XY7Xw) (Thanks @Dennis!)
**Call with:**
```
int main()
{
    char str[1024];
    f("Good morning, Green orb!", str);
    puts(str);
    f("fffffffffff", str);
    puts(str);
    f("oiiiiioiiii", str);
    puts(str);
    f("1234567890", str);
    puts(str);
    f("L  [  1  <<  7  ]  ,  *  q  ,  *  r  ,  l  ,  d  ,  i  ,  c  ,  j  ,  s  ,  t  ,  k  =  1  <<  7  ;  h  (  )  {  q  =  s  +  i  +  j  ++  ;  *  q  %  k  &&  !  L  [  *  q  %  k  ]  ++  &&  h  (  ++  c  )  ;  }  g  (  )  {  q  =  s  +  i  ;  *  q  %  k  ?  z  (  k  )  ,  h  (  j  =  c  =  0  )  ,  c  >  d  &&  (  d  =  c  )  &&  (  l  =  i  )  ,  g  (  ++  i  )  :  0  ;  }  f  (  S  ,  T  )  {  s  =  S  ;  l  =  i  =  d  =  0  ;  g  (  t  =  T  )  ;  p  (  i  =  0  )  ;  }  p  (  )  {  q  =  s  +  l  +  i  ;  r  =  t  +  i  ;  i  ++  <  d  ?  p  (  *  r  =  *  q  )  :  (  *  r  =  0  )  ;  }  z  (  i  )  {  L  [  --  i  ]  =  0  ;  i  &&  z  (  i  )  ;  }");
    puts(str);
}
```
**Output:**
[![](https://i.stack.imgur.com/M8KyW.png)](https://i.stack.imgur.com/M8KyW.png)
**The code with slightly more readable formatting:**
```
L[1<<7],
*q, *r, l, d, i, c, j, s, t, k=1<<7;
h()
{
    q = s+i+j++;
    *q%k && !L[*q%k]++ && h(++c);
}
g()
{
    q = s+i;
    *q%k ? z(k), h(j=c=0), c>d && (d=c) && (l=i), g(++i) : 0;
}
f(S, T)
{
    s = S;
    l = i = d = 0;
    g(t=T);
    p(i=0);
}
p()
{
    q = s+l+i;
    r = t+i;
    i++<d ? p(*r=*q) : (*r=0);
}
z(i)
{
    L[--i] = 0;
    i && z(i);
}
```
And this can be used to generate proper spacing to get to the formatting with score 2: [Try it online!](https://tio.run/##XVFNb8IwDL3nV3hIIKcxUrcdJg0Cf4Ab3BAHlEJr6FBbOk1i4rd3dkthwlJafzw/vzhhnIbQNHyq4WvLJ7Tm14BYyLaVfAiKyseTNvWTcb4DxJCBh3RXKwSthdFIgDCD2Lawrl@N94Bt5f3N3pNqRfXipSCNRTWLYS4/EbDHAcAwDEjoLHxC8d2NkGhiHq0yPGRd4mquTbNYv06nHxsyUUkQVQQ5QULAQkNwIDgT1ARHr6iJMdn9iqUwnR27g3MdXVQOjyrqZbFWd@OcRhk6F0TB1Zj0ufdf3xwueLQk8IMPPhYvzBLtx8SHdkmYe5Z0Knys94tbzj0uCVY971l4lx1rLi7LSeTcXiDF2q9uyyiQZUpLUTzJynthuqu6D9i5aaK7xqjyUakK1LtxXJB7ksV6PObNYyqreK0L8A8)
---
# C, score 3, 309 bytes
```
i
,
j
,
l
,
c
,
d
;
f
(
\
c\
\
h\
\
a\
\
r
*
s
)
{
\
f\
\
o\
\
r
\
(
i
=
l
=
d
=
0
;
s
[
i
]
;
c
>
d
&&
(
d
=
c
)
&&
(
l
=
i
)
,
++
i
)
\
f\
\
o\
\
r
(
\
c\
\
h\
\
a\
\
r
L
[
\
1\
\
2\
\
8
\
]
=
{
j
=
c
=
0
}
;
s
[
i
+
j
]
&&
!
L
[
s
[
i
+
j
++
]
]
++
;
++
c
)
;
\
w\
\
r\
\
i\
\
t\
\
e
(
1
,
s
+
l
,
d
)
;
}
```
[Try it online!](https://tio.run/##jVFNT8JAEL3PrygcSLGYUPzCNPXqxX/g9IAL1TU4NS3GA@lvxzezLqDBxIV9O1/73szWnT87t9t5mtAr9hrbYS@poJpSYnIMeFFYKLR0Rh2NaQu71kATooxiTyUISlwuaQqCjh4Rq2A5ukN0NEKRJh0IzNFqD2dCWWbGT9KT@vQAWqZcvZnCHLsC0RYTKLeK93v5DNFK1QZ28RCEYoUfjkJBeyrA9GkqCl5ho7BCJzma7HBxba@jtf3OyyZ5W3hJ9T0SrDod3jfNMnlrWvHyPEnu29VKkqZ9GgzHxfvHpkuHMGJtfVin0o3XZXgqnc8uLq@ub@a3032WheXcFstRpWeZsLwarg2d4ZKlYKlZUlxkjXIwXqKxiEbLcsbSsYxZtiFUx1xzVKQH2KBYmlZpKsCpaYHg0bKVuWjjzgpGI7sWSp2pfIcCh7cQWs6y6PzZwr@GYXmwVtTNY3wWjXk4KtPe2tOFvsIg/c9ZMiuoQsuDyPwrrY1X9lerCEeYtAhqn4f2vg0fjU00VjZebk/RGfU6fslA1Otn73df)
[Answer]
# [Haskell](https://www.haskell.org/), score 2, ~~492~~ ... ~~307~~ ~~224~~ ~~212~~ ~~209~~ 207 bytes
```
((yy:yyy))??ss|ss==yy  =  ""  |  yy==yy=yy:yyy??ss
ss??sss=ss
ss""=""
ss((ff:fff))  =  ff  :  ss  fff??ff
ff""=""
ff((xxx:xx))  =  ss((xxx:xx))##ff  xx
xx##xxx  |  ((((xx>>xx))<))  $  xxx>>xx=xxx|xx==xx=xx
```
[Try it online!](https://tio.run/##3Y9RasRADEP/cwoz6YcD7R4g1MlZQoh2lqbpUgdqQ87edDzdXqJfEuJJ2HnSt2VdzyzAyezeu3vXjaPqoSriTiREKREdRO6RyC8VTKMaolJtSpJSUwwz0APoutoGiHoi1bAYR6ABHjDAbGa92QOO9l/QtlE1a8zatoT1COYAhiGA1yg9BVIDKXoUkWrP9@m2lcnbti@f07wXUPPHF12I12W77nkYhJ/LwoXyf/v9e8Y6XfV8me/3Hw "Haskell – Try It Online")
Golfed literally hundreds of bytes thanks to [W W](https://codegolf.stackexchange.com/users/56656/heeby-jeeby-man) and [Ørjan Johansen](https://codegolf.stackexchange.com/users/66041/%c3%98rjan-johansen)!
### Explanation
The function `(??)` takes a character `c` and a string `s` and returns the longest prefix of `s` that does not contain `c`. Ungolfed and not optimized for score:
```
c ?? (y:s)  
    | c==y = ""
    | True = y : c ?? s
c ?? s = s
```
The function `ss` uses `(??)` to find the longest prefix of unique chars of a given string:
```
ss (x:r) = x : (x ?? ss r)
ss "" = ""
```
`(##)` is a function which takes two strings and returns the longer one. The length comparison works by repeating the string `x` as often as `x` is long (`x>>y`) and as `y` is long (`y>>x`) and checking which of the resulting strings is lexicographically larger.
```
x ## y
  | (x>>x) < (y>>x) = y
  | True = x
```
Finally `ff` recurses over the input string, generates the longest prefix with `ss`, recursively determines the longest non-repeating substring of the tail of the string and returns the longer of the two with `(##)`:
```
ff "" = ""
ff (x:r) = ss(x:r) ## ff r
```
[Answer]
# Lua, score 3, 274 bytes
```
g='g'..'s'..'u'..'b'  _G  [  'l'..'o'..'a'..'d'  ](  g[g  ](  "s  =...f  o  r d = # s - 1 , 0 , - 1 d  o f  or r = 1 , # s - d d  o t = s :s  ub  (r  ,r  +d  )i  f n  ot t:  fi  nd  '(  .)  .*  %1  't  he  n p  ri  nt  (t  )r  et  ur  n en  d e  n  d e  nd  ","  ",""))(...)
```
Note: Lua 5.2 or Lua 5.3 is required
Usage:
```
$ lua lnrs.lua "Good morning, Green orb!"
ing, Gre
$ lua lnrs.lua "fffffffffff"
f
$ lua lnrs.lua "oiiiiioiiii"
oi
$ lua lnrs.lua "1234567890"
1234567890
$ lua lnrs.lua "11122324455"
324
```
Main idea: interleave everything with spaces, insert `" "` (two spaces) to split long identifiers
Ungolfed code:
```
g = "gsub"
_G["load"](
   g[g](      -- g[g] == string.gsub - a function for substitution of substrings
      "The source of actual program, but two-space sequences were inserted in some places", 
      "  ",   -- we are replacing all two-space substrings
      ""      -- with an empty string
   )
)(...)
```
Actual program (after removing all pairs of spaces):
```
s = ...
for d = #s - 1, 0, -1 do
   for r = 1, #s - d do
      t = s:sub(r, r+d)
      if not t:find"(.).*%1" then
         print(t)
         return
      end
   end
end
```
BTW, the JS snippet for calculating the score fails on my code.
[Answer]
# [Retina 0.8.2](https://github.com/m-ender/retina/wiki/The-Language/a950ad7d925ec9316e3e2fb2cf5d49fd15d23e3d), 37 bytes, score 9
```
.
$&$'¶
(.)(?<=\1.+).*
O#$^`
$.&
1G`
```
[Try it online!](https://tio.run/##K0otycxL/H9oG1f8fz0uFTUVdSBTQ09Tw97GNsZQT1tTT4uLy19ZJS6BS0VPjcvQPeF/PNehbUSqBQA "Retina 0.8.2 – Try It Online") The direct translation of this answer to Retina 1 saves a byte by using `N` instead of `O#`. However, if you naïvely golf the Retina 1 answer down to 28 bytes, its score actually rises to 10! Explanation:
```
.
$&$'¶
```
Generate all suffixes of the input.
```
(.)(?<=\1.+).*
```
For each suffix, take the prefix up to the first duplicated character.
```
O#$^`
$.&
```
Sort the remaining strings in reverse order of length (i.e. longest first).
```
1G`
```
Take the longest.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), score 2, 14 bytes
```
Ẇµµff  Q  €  Ṫ
```
*Thanks to @JonathanAllan for score -1, +7 bytes and for noticing a bug.*
[Try it online!](https://tio.run/##y0rNyan8///hrrZDWw9tTUtTUAhUUHjUtEZB4eHOVf8f7t5yuB3Ii/z/3z0/P0UhN78oLzMvXUfBvSg1NU8hvyhJkSsNAbjyM0EATHIZGhmbmJqZW1gacBkaGhoZGRuZmJiacmG3CQA "Jelly – Try It Online")
### How it works
```
Ẇµµff  Q  €  Ṫ  Main link. Argument: s (string)
Ẇ               Window; yield all substrings of s, sorted by length.
 µ              Begin a new chain. Argument: A (array of substrings)
  µ             Begin a new chain. Argument: A (array of substrings)
   f            Filter A by presence in itself. Does nothing.
       Q  €     Unique each; deduplicate all strings in A.
    f           Filter A by presence in the array of deduplicated substrings,
                keeping only substrings composed of unique characters.
             Ṫ  Tail; take the last (longest) kept substring.
```
[Answer]
# [Clean](https://clean.cs.ru.nl), score ~~7~~ 5, 276 bytes
```
@[ss:s]=rr(pp[][ss:s])((@s))
@s=s
ee x[rr:xx]|e x rr=True=ee x xx
ee x xx=f
f=e'e'' '
e::!  Char  !  Char  ->Bool
e  _ _=  code  {
eqC
}
pp p[r:rr]|ee r p=p=pp(a r p)rr
pp a _=a
a  x[ll:l]=[ll:a x  l]
a l ll=[l]
l[]rr=e'l''l'
l ff[]=f
l[r:rr][ss:ll]=l rr ll
rr x y|l x y=y=x
```
[Try it online!](https://tio.run/##PU/RasMwDHzXV9yenMD6AwGPsA7KYA@D7c2Y4qVOV1BiT2nBZd2vL1PWMSSk05mzTh3HMM5D2p04YgiHcW7dNDWTtyJVzs5fp7qq2qmuqZ3sRDGiOJGmFH9RCBH7KqdoFx6l0F@3PfU2mmgMDMWmuQHW70GAf7C6u0@JKQJbbC3QpZ3iT6L4saYvyhnZSSOiayIE2WrkKiywFlneg@oCBagh5oa9XVrQ9WCvNINZKU/svLqMho0mMfreefWn/O//y5GsatZbVEJaC84XXqo92zK/HIMcYdHCmU1KOwxJxsO4v8VGYhyR5O3G@Pm76znsp3n1@DQ/nMcwHLrr8Mzh2CcZfgA "Clean – Try It Online") Thanks to [@Οurous](https://codegolf.stackexchange.com/users/18730/%ce%9furous) for showing me that it is possible to call ABC machine code directly from within Clean. This allows to get rid of the previous bottle-neck `import` which set the minimal score to 7, but needs the keyword `code` which sets the minimal score to 5 for this approach.
An ungolfed and not score-optimized version of the above code can be found here: [Try it online!](https://tio.run/##RVHBasMwDL37K9RTW1jpPdCtrGNlsMNgu4UQvERJDY6dyg4kbPv1ZbLjshxkPVl61nupNEozd7YeNEInlZn3@3hCM5jKK2vEEfICDhxCNmYuANr0eRHBdnMEtxWCx1BjJxBhhHzKqBDA3zcEPPHIBw0YSweIPbS0loyfpXYYKaqLJMDrILXyk0DIMlidQm2Ju3t4tFbzRRkHK1sjfEVWvJ7ET@TQ1rToPAxGXQeEnrBRo@jBhe3/1wqPO@Zwaal@I0NlS7G1jDeBTvY9mlrIm6xgxZQFyFwyKcjHIjYrBxpN6y98OAc2iXkQOphY3mzQnEZTF@V8WQZmjtFdDZQeJ/QDmUUS1zwp0woKjiYZOrk7JRXj/O4lec74Z63P1tbQWTI8dgdnQjS80@dqXcy/VaNl6@bdy@v8NBnZqWoBb1r6xlL3Bw "Clean – Try It Online")
---
### Previous version with score 7, ~~158~~ ~~154~~ 130 bytes
```
import  StdEnv  
@[xx:rr]=c(%[][xx:rr])(@rr)
@e=e
c s b|  length  s<  length  b=b=s
%s[xx:r]|  isMember xx s=s= %(s++[xx])r
%r _=r
```
[Try it online!](https://tio.run/##RY7NSsQwFIX3eYrjokzLjC8gBrpQBmEEYZYlSJLeqYH8yL1RKvjsxqKCu/NxvgPHR7K5pTK/RUKyIbeQXgtX4Fzn@/wOqHFa1xtmo33fTeYPhn5kHtRImpSHwH0CkfJSXwC5/c9OOy2qk5@Z2aQgj5QcMdYVokWj62W/32ozsOoYz5rbudrtgcaIaXcsZUYqnENeDjgyUUZhd7Uz7ctfol2kXT@c2t1Htin4X3iKtl4Kp28 "Clean – Try It Online")
With the `import` the score cannot go below 7. Without the import one would need to implement equality on strings or chars without any library functions which is ~~probably not~~ possible, as can be seen in the new version above.
[Answer]
# [Python 3](https://docs.python.org/3/), score 4, 155 bytes
```
exec(('l=la''mbd''a f'',e=en''ume''rat''e:m''ax''([f[ j  :k]  for  j,i in e ( f)f''or  k,i in e ( f )if  len  ( { *''f[j'':k]''})==k-''j],''key''=le''n)'))
```
This defines a function `l`.
*Thanks to @xnor for pointing out that strings of length 3 don't raise the score, saving 32 bytes.*
[Try it online!](https://tio.run/##TY/LbsIwEEXX5Sumi@jayKASHm0jpVs@oEvEIiRjcB52ZIIEqvrt1I5Q21lYOtf2mZn@NpycXd7vfOVSCLR5WwDdoQIK0oDinC1w6RjwxQBw1oWrKyB2ekc1UdbsibTzRLUyZCwxCdIy/I1Z8y8jaTRRy5YCfdEU0LsaCALgW@Z5MwPqvQIavgF5G1paCSnv0X6OGmydq6hz3hp7VLT1HGTOH56hCPqvIjoTazwjLtLlar15fXt/GWmxSNNlulqt18gmT703dhBIZunG0@yDEg9KSJwVteIspZxMumIoT5QHdj1bgXnpKp4PxkHOPRdVayyL@PCh@iyd54ySSxSFlcUokIo89/4XtGk5SB/Kig@X4@gMExZx8R8 "Python 3 – Try It Online")
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), score 2, 19 bytes
```
s  ᶠ  l  ᵒ  ≠  ˢ  t
```
[Try it online!](https://tio.run/##SypKTM6ozMlPN/pf/ahtw6Ompoe7Omsfbp3wv1hB4eG2BQoKOUB66yQFhUedQM7pRQoKJf//Ryu55@enKOTmF@Vl5qXrKLgXpabmKeQXJSkq6SgopSEAiJufCQJgEsQ1NDI2MTUzt7A0APMMDY2MjI1MTExNQVzclirFAgA "Brachylog – Try It Online")
Just a boring old "space everything out" answer. At least I learnt that metapredicates can be spaced away from the predicates and still work (and the (parametric) subscripts and superscripts can't).
`s ᶠ` - find all substrings of the given string
`l ᵒ` - order them by their length (ascending by default)
`≠ ˢ` - select those that have all distinct elements
`t` - get the tail (last element) of that - the one with the biggest length
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 11 bytes, score 4
-4 score thanks to Dennis
```
e lD {I# .:
```
---
```
elD{I#.:Q      Full program, inputs "string" from stdin and outputs to stdout
e              The last element of the list generated by taking
      .:Q      All substrings of the input
     #         Filtered for
   {I          Being invariant over deduplicate i.e. being "non-repeating"
 lD            and sorted by length
```
[Try it online!](https://tio.run/##K6gsyfj/P1Uhx0Wh2lNZQc/q/3@ljMzKxEQlAA "Pyth – Try It Online")
[Answer]
# [Husk](https://github.com/barbuz/Husk), score 2, 10 bytes
```
►IIËII≠IIQ
```
[Try it online!](https://tio.run/##yygtzv7//9G0XZ6eh7s9PR91LvD0DPz//7@SoaGhkZGxkYmJqakSAA "Husk – Try It Online")
## Explanation
The program is equivalent to this:
```
►Ë≠Q  Implicit input.
   Q  List of substrings.
►     Find one that maximizes:
 Ë    all ordered pairs
  ≠   are inequal.
```
The built-in `Ë` evaluates `≠` on all ordered pairs of its argument `x`, and returns `length(x)+1` if every result is truthy, otherwise `0`.
When we maximize this, we find the longest string that has no repeated characters.
In the submission, I just insert the identity function `I` between each function, twice.
Since `IË` is the same as `Ë`, `I≠` is the same as `≠` and so on, this does not change the semantics.
The only danger is that a higher order function could decide to use one of the `I`s as its argument, but luckily that leads to a type error in our program, so it doesn't happen.
[Answer]
## Clojure, score 4
```
#(  let  [N  (fn  [[_ & r]] r) R  (fn  R [f v c]  (if  c (R f (f v (  nth  c 0))  ( N  c)) v)) C  (fn  C  (  [i]  (C (  seq  i) 0)) ( [i  n]  (if i (C ( N  i )  (  inc n)) n)))  J  (fn  [c  i]  (assoc c (C  c) i)) I  (fn  F [f i n R]  (if ( =  (C  R) n) R (F f (f  i) n ( J  R (f  i)))))] ( apply  str  (R ( fn  [a  b] ( if  (< (C  a)  (C  b)) b a )) "" (  for  [k  (I N % (C  % ) [])]  (R  ( fn [ t  c ] ( if ( or ( = t (  str t) ) ((  set t)c))(apply  str t) ( J  t c)))[]k)))))
```
Oh man this was painful! `N` implements `next`, `R` is `reduce`, `C` is `count`, `J` is `conj` (works only for vectors) and `I` is `iterate`. `apply str` is there twice because otherwise "aaaa" input wouldn't return a string but a vector `[\a]`. Luckily I got to use `apply` and `assoc`, I didn't know you could assoc one index beyond a vector's last element :o
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), score 5, 10 bytes
```
ẆµQQ⁼µÐfµṪ
```
[Try it online!](https://tio.run/##y0rNyan8///hrrZDWwMDHzXuObT18IS0Q1sf7lz1/3D7o6Y1kf//Ryu55@enKOTmF@Vl5qXrKLgXpabmKeQXJSkq6XApKKUhAJifnwkCYBLMNzQyNjE1M7ewNABzsVmlFAsA "Jelly – Try It Online")
[Answer]
# [Python 3](https://docs.python.org/3/), score 4, 317 bytes
```
exec(('%s'  *58  %(  's=','in','pu','t(',');','pr','in','t(','so','rt','ed','((s','[i',':j',']f','or',' j',' i','n ','ra','ng','e(','1,','le','n(','s)','+1',')f','or',' i',' i','n ','ra','ng','e(','j)','if',' l','en','(s','et','(s','[i',':j',']))','==l','en','(s','[i',':j',']))',',k','ey','=l','en',')[','-1','])')))
```
[Try it online!](https://tio.run/##7ZDNCsIwEIRfZS8lWa2HIIIofZLiQTRqaklLk4J9@roTqH8HL169fGx2ZybLtkO8NH45jvZmD1qrLCii2WpNlGkiFQqVK@cFbS@IWsBbPLtpkHqhEXRRYI8CrYOwdIJNJdidBA0shCdh4AmWPaozfIgxuaC26KVUFswN/nwGuG8BFRwOYqrRw4JpFxun6mUrhroo3pWf8/yK8QDlQ8ilYGGSRjHz/3w/ne8O)
Unexeced code:
```
s=input();print(sorted((s[i:j]for j in range(1,len(s)+1)for i in range(j)if len(set(s[i:j]))==len(s[i:j])),key=len)[-1])
```
`lambda a` contains `mbda`  which has score 5, and a function needs `return` which apparently can't be `exec`ed (so takes a score of at least 5 for `eturn`), so a full program was necessary. It's probably possible to golf down the unexeced code size quite a bit, but I can't see a quick clear improvement.
[Answer]
# [Alice](https://github.com/m-ender/alice), 40 bytes
```
/ii..nn$$@@BBww..DD~~FF..!!nn$$KK??oo@@
```
(Trailing newline)
[Try it online!](https://tio.run/##S8zJTE79/18/M1NPLy9PRcXBwcmpvFxPz8Wlrs7NTU9PUREk6u1tb5@f7@DA9f@/e35@ikJuflFeZl66joJ7UWpqnkJ@UZIiAA "Alice – Try It Online")
The instruction pointer moves diagonally in ordinal mode, so only every other character is executed.
```
[[email protected]](/cdn-cgi/l/email-protection)~F.!n$K?o@
i     take input
.n$@  terminate if empty
B     push all nonempty substrings, with the longest on the top of the stack
w     push return address (start main loop)
.     make copy of current substring
D     deduplicate characters
~     swap: this places the original above the deduplicated copy
F     Push the original string if it is a substring of the deduplicated copy
      (which can only happen if they're equal); otherwise push empty string
.!    place a copy on the tape
n$K   if the empty string was pushed, return to start of loop
o     output
@     terminate
```
[Answer]
# [Perl 6](https://perl6.org), score: ~~15 10~~ 8, length: ~~46 55~~ 62 bytes
```
{~m:ov/(.+)<!{$0.comb.repeated}>/.max(&chars)}
```
[Test it](https://tio.run/##fVBLbsIwEN37FIOVQtL8SPi0JRB1xwW6oyxCYtpIiW05AYFQcph2yRnY9EIcIXUMpV11FqOn9@Zp3gwnIhs3m4LAduzEAcr30I1ZQmDWHOp8wrau7pjGtHPQ@k7M8pUjCCdRSZIqdJ082und@D0ShVE10vlckqKEGWQpJYVuSJ1P4IAAclc2gPPpA59Pn1DfkD61F3gZmobSXwsTenbYa4EiFv84libcwQJ6Vjt@D0tpcAPZaq1vQUT3UH8dNQ9VqD3uRQYLEM8iCqZKGaA1E9fAdgi6llK@KS2N7DiJ5XmGyp0WdkIIz/bQ/uQ6ZFhwG5NQcQ6XfwxQ1eA5YwnkTNCUvlkwF4RQYGLVwe0a/ENihNe/ddHWkmRpW6pfDQxbIGmpef5gOBo/PD71MSjtDyFVz/P9gT8cjkYXp8T4Gw "Perl 6 – Try It Online")
```
{~m:ov/(..*)<!{(($0)).comb.repeated}>{{}}/.max(&chars)}
```
[Test it](https://tio.run/##fVBLcoJAEN3PKdopIozAIPhJIkpl5wWyMy4QxoQqYKYALS0KDpMscwY3uZBHIAMak1V60fXqvX4zr1uwLJ42u5zBfkoDFyVH6Ac8ZLBoyjqZ8b2lUTog816pacqQEBrwZEMzJphfsLDyyrKqLJr4B60fvPlZTqpGPvFUsLyABcRRynKNSF3MoEQAiSUbwPn0js@nD6hvSJubK7z2dNLpL7kOqumpLeiI1T@OtQ53sALVaMcHsJYGy5WtVoYG@OkR6q9PxUYVard8lsFcJGI/Bb1L6aItz66BTQ80JUrFrjAUdhAskCuSLneUmyFjIj5Ce5zrEDHgNiZhx1EhD@qiqsFLzkNIeJZG6asBy4yxFHi26eH2G/xDYoS3v3XRtpLkUVtdvxo4NkDSUrOd0XgyvX94HGLotD@EVG3bcUbOeDyZXJwS428 "Perl 6 – Try It Online")
```
{m:ov:i/(..*)<!{(($0)).comb.repeated}>{{}}/.max((&chars)).Str}
```
[Test it](https://tio.run/##fVBLbsIwEN37FFMrBYf8SPi0JRB1xwHaHWUREtNGSmLLCQgUhcO0y56BTS/EEVLHUNpVZzF6eu@N/WY4Fem42RQUtmM78lG2h07EYgqzpsombDtJHGLbPX16UxGi9XXdjli2sgXlNCxpXAdVVdeOnYU7QjrRWygKaXkqRd3Ilx5LWpQwgzTJaUF06eITqBBA5sgGcDq@49PxAw5XRKbWAi8DQ1f6S2FA1wq6LVDE4p@JpQG3sICu2dp7sJQDji/bQeubEOZ7OHx9ai6qUbvsswzmI56GORgqpY/WTFwCWwEQLcn5pjQ1uuM0kovqKndSWDGlPN1De6OLSTfhapNQcTaXd/VR3eA5YzFkTORJ/mrCXFCaAxOrG9x@g39IjPD6t87aWpIsaUv1ywDDJkhaaq43GI7Gd/cPfQxK@0NI1XU9b@ANh6PReVJi/A0 "Perl 6 – Try It Online")
## Expanded:
```
{    # bare block lambda with implicit parameter ｢$_｣
    m                          # match (implicitly against ｢$_｣)
    :overlap                   # in every single way possible
    :ignorecase                # add a ｢:｣ to break up substring
    /
      (..*)                    # match at least one character
      <!{
        (($0)).comb.repeated  # backtrack if there were repeats
      }>
      {{}}                    # anon hash in code block (no-op)
    /
    .max((&chars))            # get the longest
    .Str                      # coerce to a Str (from a Match object)
}
```
[Answer]
# Java 8, score ~~9 (384 B)~~ 7 (401 B)
```
S -> { int s = 0 , e = 0 , l = 0 , x = 0 , y = 0 , b [ ] = new int [ 256 ] ; for ( ; x <S.  length  & y <S.  length  & l <S.  length  - x ; x ++ ) { b [S[x]] = 1 ; for ( y ++ ; y <S.  length  && b [S[y]] < 1 ; b [S[y ++]] = 1 ) ; if ( l < y - x ) { s = x ; e = y ; l = y - x ; } for ( ; y <S.  length  && x < y & S[x] != S[y  ];)b [S[x ++]] = 0 ; }  String g=""; for( ; s<e ; g+= S[s++]);  return  g;}
```
* ~~Initial version. Will go down from here. Score is 9 due to `"ubstring "`, so `substring` will be the first part to replace.~~
* Score is now 7 due to `" length"`, which I probably won't be able to reduce further.. I doubt it is possible to drop the four uses of `length`. If it is possible, `" eturn"` (6) might lower the score by 1 as final improvement, but I guess this is it (except maybe a small reduce in byte-count..)
[Try it online.](https://tio.run/##7VTBbptAEL33K172YLEiRjaxk7bYlaqoyqmpVI42B0zWhJTsWss6NYr87c4MkLRJFClceipid9jZee/NMgw36V06NBulb65@HbIyrSp8Twt9/wEotFN2nWYKl7wEYmcLnSPzsuvULhJUMiL/ngbdlUtdkeESGnMcYgy/4J4pUNF6hGOozpad3XW27uwKCyT0rNXvBrdAOD0lT4S1sfDI7jCLA6BUOnfXwICgLxzlc8eQIAzzfUjKhhTixS5hkfETbc270SuqQRtdU/SsiW6XFNzhJfmKNRGQJqFZijX4tCzKp63Jlo1tE9k/neS12q5hGYATxNEcrIUkkm3Oj7KjhuWxEPlciOYYTFnNFM25z9CKwmUEWOW2VgN5tD9EbZk221VJZeqqdWeKK9xSvb2WcpGksqt1XTl1G5itCza040rt6SDzxIUxhDBWU/QxLqxSGsaujkTgzDl9Fl@tTWtPyubTeJtm/efqiTQFX83cEzkOTybT07OPn0Z9geNxGJ6Ek8l02hNJb0nx6AkrTVnxeD@Mdv5uUct9xEz/@/Cf9OFSLN/diS@L@mZNRXz@4@e3zxC@DdoMPekLeEtBHp8Upeh@wPvDAw)
[Answer]
# [Haskell](https://www.haskell.org/), score 7
*-4 thanks to Laikoni.*
```
import  Data.List  
f s=snd $ maximum [ (0<$i ,i)|i<-  tails  =<<inits s, nub i==i]
```
[Try it online!](https://tio.run/##pY0xDsIwEAR7XrGKUiSSQTzA7ij5AaE4REJW2EeUcyQK/m78ADq6WWm0M4s9xxhLYVpeawZOkuVwplXcTbBgekeLJG@mLeGC7uhbwrH/0O@BLIwGBO@pzAZz0O0GhsBrSUJFwLJScz3pXF@9OOojz3VOaH5EB/2z2pQv "Haskell – Try It Online")
[Answer]
## Mathematica, score ~~11~~ 9
```
Length@Last@Select[Subsequences[Characters@#],#==DeleteDuplicates  @#&]&
```
Shaving a couple of bytes off of the longest nonrepeating string by obscuring the function's name:
```
Length@Last@Select[Subsequences[Characters  @#],#==(  ToExpression@ 
StringJoin@@FromCharacterCode@{{68},{101},{108},{101},{116},{101},{68},{117},
{112},{108},{105},{99},{97},{116},{101},{115}}))@#&]&
```
[Answer]
# [Kotlin](https://kotlinlang.org), score: ~~11~~ ~~10~~ 9 bytes, length: ~~227~~ ~~246~~ 245 bytes
```
indices
  .flatMap { p -> indices . map { p to p + it } }
  .  filter { (r,i) -> i < length  }
  .map { ( s , a )->substring  (  s,  a  ) }
  .  filter { it  .  groupBy  { it } .  none { ( k , v )->v . size>1 } }
  .maxBy { it.length }
```
The longest is `ubstring`, which is 9 chars
It is called like this:
```
val c = "Good morning, Green orb!"
fun String.c(): String? = indices
    .flatMap { p -> indices . map { p to p + it } }
    .  filter { (r,i) -> i < length  }
    .map { ( s , a )->substring  (  s,  a  ) }
    .  filter { it  .  groupBy  { it } .  none { ( k , v )->v . size>1 } }
    .maxBy { it.length }
fun main(args: Array<String>) {
    val text = """indices
    .flatMap { p -> indices . map { p to p + it } }
    .  filter { (r,i) -> i < length  }
    .map { ( s , a )->substring  (  s,  a  ) }
    .  filter { it  .  groupBy  { it } .  none { ( k , v )->v . size>1 } }
    .maxBy { it.length }"""
    val message = text.c()!!
    println(message)
    println(text.length)
    println(message.length)
    println(c.c())
}
```
[Answer]
# [Pyth](https://pyth.readthedocs.io), score 3 (~~18~~ 14 bytes)
```
e  fq  T{T  .:
```
**[Try it online!](https://pyth.herokuapp.com/?code=e++fq++T%7BT++.%3A&input=%22Good+morning%2C+Green+orb%21%22&debug=0)**
The longest non-repeating substrings is `.:`.
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 22 bytes | Score: 2
```
Œ  ʒ  D  Ù  Q  }  é  ¤
```
*-1 score + 7 bytes thanks to HeebyJeeby*
[Try it online!](https://tio.run/##MzBNTDJM/f//6CQFhVNA7KKgcHimgkKggkItkLVSQeHQkv//DQ0NjYyMjUxMTE0B "05AB1E – Try It Online")
---
# [05AB1E](https://github.com/Adriandmen/05AB1E), 15 bytes | Score: 3
```
Œ ʒ D Ù Q } é ¤
```
[Try it online!](https://tio.run/##MzBNTDJM/f//6CSFU5MUXBQOz1QIVKhVOLxS4dCS//8NDQ2NjIyNTExMTQE "05AB1E – Try It Online")
---
# [05AB1E](https://github.com/Adriandmen/05AB1E), 8 bytes | Score: 8
```
ŒʒDÙQ}é¤
```
[Try it online!](https://tio.run/##MzBNTDJM/f//6KRTk1wOzwysPbzy0JL//w0NDY2MjI1MTExNAQ "05AB1E – Try It Online")
---
05AB1E can actually do something rather cheap... adding whitespace into 05AB1E does nothing.
If there is a rule against this, I can also use `´` and like 7 other chars.
]