text:
Radiation Detector!
A radiation-hardened program is a program where, if any character of the code is removed, the program will still function the same. For this question, we'll be writing a program that detects when it is irradiated.
Write a program or function that, when any single byte is removed, the resulting program will output that byte and only that byte. (You may output that byte multiple times, as long as you don't output any other byte)
Rules:

The program has to contain at least 2 distinct bytes. (No solutions of just 0s ;)
It doesn't matter what the original program does
No reading your own source code.
The code will be scored on the number of distinct bytes, where the highest amount wins. For example, abc = 3 points, ababba = 2 points, abc wins.

Tie-breaker is the smaller byte count, followed by the earlier submission time

Good luck!

Sandbox Post (deleted)
Related, related, related

I missed that line. Shame on me!

"The code will be scored on the number of distinct characters, where the highest amount wins." I expect that most (if not all) solutions will have some form of string somewhere which they can just pad with arbitrary characters without actually changing the solution (so it just comes down to whether your language is restricted to ASCII, extended ASCII or Unicode).

ASCII only has 128 characters.

... The sandbox is not perfect. :( / You can just measure "distinct bytes" instead of "distinct characters", because characters are related to encoding and other problems.

Must the original program/function work or can that be a syntax error?

@StewieGriffin Uh, I'd assume It doesn't matter what the original program does means that it can be a syntax error, however it's not very clear.

can we output the numerical value of the removed byte, or should the output be strictly a character?

when using UTF-8, should we consider a byte missing or a character missing?

@Uriel byte missing.

This should just be code-golf.

Can output from a brainfuck program, be the memory dump? :) Makes for an easy solution.

@HåvardNygård What do you mean? Just to clarify, a program should only output a single byte

@JoKing Does the memory dump of a program, post execution, count as program output? - If it is a single byte

@HåvardNygård. If you can manage it, go for it. But I'm pretty sure there's no way to do a brainfuck program for this challenge, given you can't have loops.

Smallest codepage wins!

Can the program take any input?

Can the program output a single byte more than one time. Eg 22 or aa but not a2?

@gggg I'll allow it

I really am starting to doubt that there are any answers in 05AB1E that don't use ', +200 to anyone who proves me wrong lol.

@JoKing what is the tie-breaker? Byte-count? Time posted?

@MagicOctopusUrn Found one!

05AB1E, 9 7 bytes (Score of 3)
22'''rr

Try it online!
Removing a '
With any ' removed, 22''rr will result in 22 being the first thing on the stack and a ' being the last thing on the stack, which when reversed twice results in '.
Removing an r
With any r removed, 22'''r results in 22 being the first thing on the stack, a ' being the second thing on stack, and an r being the last thing on the stack. This r, however, was preceeded by a ' which makes it the literal string "r" (as opposed to the command reverse stack), which is implicitly printed.
Removing a 2
With any 2 removed, 2'''rr will result in a 2 being the 1st thing on the stack, ' being the 2nd thing on the stack and finally r being the last thing on the stack, which when reversed once results in 2.
Therefore, this answer is valid. With nothing removed it outputs ', which is irrelevant. This works for any number other than 2 as well.

Created a validity checker, you can use it to compete in 05AB1E*.
*I'm not 100% sure how many solutions are even possible in 05AB1E...

More valid solutions that are Worse or the Same

1-Point (invalid)

Any number of ' above 2 will work...

2-Point

'''''''VV, '''''''XX or '''''''<any command that pops a without pushing>x2
Any odd # of ' above 3 followed by any even # of s above 1 (E.G. '''''''''ssss).
'''.. with any number of periods above 1 and any odd number of ' above 2.

3-Point

'\\'''rr - same idea as 22'''rr but \ is 'remove last stack item'.

Normal output of ' is irrelevant by the rules, as you say. But it does invalidate the nominal goal of detecting anomalies, which is a bit funny.

@gggg I'm fairly certain at least ONE of my alternatives prints nothing lol.

@MagicOctopusUrn You're welcome. Just thought I may as well edit instead of commenting.

@boboquack did my original tag (@boboquack) work, or did you find it by viewing the post again? I'm trying to figure out how tags work when the user never commented lol.

@boboquack I meant did you get a notification from my "thank you"? Also, we should probably delete this thread up until my +1 for your "You're welcome".

Brainfuck, Score 3
May be noncompeting as output is only seen through a memory dump.
+++++++++++++++++++++++++++++++++++++++++++++,-

Assuming input is empty and EOF leaves the cell unchanged. Uses an interpreter that dumps the memory to an output, such as this one.
Remove a plus, and the memory is the unicode value for "+" , else it is the unicode value for ",". Its more of a rule bender than a answer though. Pretty much the same with "-". Abuses the fact that these three characters are after each other in the unicode-characterset.

Smart, to be entirely honest, don't think it's a loophole.

You're assuming EOF leaves the cell unchanged, yes?

Yeah, and as long as there is no input, it should be fine

I'm tempted to allow this, but do you have an interpreter that has a memory dump that would output only changed cells and leaves the cell unchanged on EOF?

https://copy.sh/brainfuck/ This one should work fine. Just run it and hit "view memory".

Personally i would rather see a full answer, which actually prints something. This is just all that i could come up with..

Won't +++++++++++++++++++++++++++++++++++++++++++++,- work too?

@JoKing Yeah it does. :) Want to post it yourself, or should i modify my answer?

All yours buddy

A Pear Tree, 256 distinct bytes, 975 bytes
Unfortunately, the question pretty much requires an optimal solution to contain a NUL byte somewhere (as it needs to contain all 256 bytes somewhere). This means that a) I can't give you a TIO link (because TIO dislikes NUL in programs, or at the least, I haven't figured out a way to type it that my browser can cope with), and b) I can't paste the program into Stack Exchange literally. Instead, I've placed an xxd reversible hexdump hidden behind the "code snippet" link beneath.

00000000: 0a24 7a7b 242f 7d2b 2b3b 242f 3d24 5c3d  .$z{$/}++;$/=$\=
00000010: 2440 3b21 247a 7b24 5f7d 3f24 7a7b 245f  $@;!$z{$_}?$z{$_
00000020: 7d3d 313a 6465 6c65 7465 247a 7b24 5f7d  }=1:delete$z{$_}
00000030: 666f 7220 7370 6c69 742f 2f2c 3c44 4154  for split//,<DAT
00000040: 413e 3b70 7269 6e74 206b 6579 7325 7a3e  A>;print keys%z>
00000050: 353f 225c 6e22 3a6b 6579 7325 7a3b 5f5f  5?"\n":keys%z;__
00000060: 4441 5441 5f5f 2000 0102 0304 0506 0708  DATA__ .........
00000070: 090b 0c0d 0e0f 1011 1213 1415 1617 1819  ................
00000080: 1a1b 1c1d 1e1f 2326 2728 292a 2b2d 2e30  ......#&'()*+-.0
00000090: 3334 3536 3738 3942 4345 4647 4849 4a4b  3456789BCEFGHIJK
000000a0: 4c4d 4e4f 5051 5253 5556 5758 595a 5b5d  LMNOPQRSUVWXYZ[]
000000b0: 5e60 6162 6367 686a 6d71 7576 7778 7c7e  ^`abcghjmquvwx|~
000000c0: 7f80 8182 8384 8586 8788 898a 8b8c 8d8e  ................
000000d0: 8f90 9192 9394 9596 9798 999a 9b9c 9d9e  ................
000000e0: 9fa0 a1a2 a3a4 a5a6 a7a8 a9aa abac adae  ................
000000f0: afb0 b1b2 b3b4 b5b6 b7b8 b9ba bbbc bdbe  ................
00000100: bfc0 c1c2 c3c4 c5c6 c7c8 c9ca cbcc cdce  ................
00000110: cfd0 d1d2 d3d4 d5d6 d7d8 d9da dbdc ddde  ................
00000120: dfe0 e1e2 e3e4 e5e6 e7e8 e9ea ebec edee  ................
00000130: eff0 f1f2 f3f4 f5f6 f7f8 f9fa fbfc fdfe  ................
00000140: ff4b 3d20 ab0a 247a 7b24 2f7d 2b2b 3b24  .K= ..$z{$/}++;$
00000150: 2f3d 245c 3d24 403b 2124 7a7b 245f 7d3f  /=$\=$@;!$z{$_}?
00000160: 247a 7b24 5f7d 3d31 3a64 656c 6574 6524  $z{$_}=1:delete$
00000170: 7a7b 245f 7d66 6f72 2073 706c 6974 2f2f  z{$_}for split//
00000180: 2c3c 4441 5441 3e3b 7072 696e 7420 6b65  ,<DATA>;print ke
00000190: 7973 257a 3e35 3f22 5c6e 223a 6b65 7973  ys%z>5?"\n":keys
000001a0: 257a 3b5f 5f44 4154 415f 5f20 0001 0203  %z;__DATA__ ....
000001b0: 0405 0607 0809 0b0c 0d0e 0f10 1112 1314  ................
000001c0: 1516 1718 191a 1b1c 1d1e 1f23 2627 2829  ...........#&'()
000001d0: 2a2b 2d2e 3033 3435 3637 3839 4243 4546  *+-.03456789BCEF
000001e0: 4748 494a 4b4c 4d4e 4f50 5152 5355 5657  GHIJKLMNOPQRSUVW
000001f0: 5859 5a5b 5d5e 6061 6263 6768 6a6d 7175  XYZ[]^`abcghjmqu
00000200: 7677 787c 7e7f 8081 8283 8485 8687 8889  vwx|~...........
00000210: 8a8b 8c8d 8e8f 9091 9293 9495 9697 9899  ................
00000220: 9a9b 9c9d 9e9f a0a1 a2a3 a4a5 a6a7 a8a9  ................
00000230: aaab acad aeaf b0b1 b2b3 b4b5 b6b7 b8b9  ................
00000240: babb bcbd bebf c0c1 c2c3 c4c5 c6c7 c8c9  ................
00000250: cacb cccd cecf d0d1 d2d3 d4d5 d6d7 d8d9  ................
00000260: dadb dcdd dedf e0e1 e2e3 e4e5 e6e7 e8e9  ................
00000270: eaeb eced eeef f0f1 f2f3 f4f5 f6f7 f8f9  ................
00000280: fafb fcfd feff 4b3d 20ab 0a24 7a7b 242f  ......K= ..$z{$/
00000290: 7d2b 2b3b 242f 3d24 5c3d 2440 3b21 247a  }++;$/=$\=$@;!$z
000002a0: 7b24 5f7d 3f24 7a7b 245f 7d3d 313a 6465  {$_}?$z{$_}=1:de
000002b0: 6c65 7465 247a 7b24 5f7d 666f 7220 7370  lete$z{$_}for sp
000002c0: 6c69 742f 2f2c 3c44 4154 413e 3b70 7269  lit//,<DATA>;pri
000002d0: 6e74 206b 6579 7325 7a3e 353f 225c 6e22  nt keys%z>5?"\n"
000002e0: 3a6b 6579 7325 7a3b 5f5f 4441 5441 5f5f  :keys%z;__DATA__
000002f0: 2000 0102 0304 0506 0708 090b 0c0d 0e0f   ...............
00000300: 1011 1213 1415 1617 1819 1a1b 1c1d 1e1f  ................
00000310: 2326 2728 292a 2b2d 2e30 3334 3536 3738  #&'()*+-.0345678
00000320: 3942 4345 4647 4849 4a4b 4c4d 4e4f 5051  9BCEFGHIJKLMNOPQ
00000330: 5253 5556 5758 595a 5b5d 5e60 6162 6367  RSUVWXYZ[]^`abcg
00000340: 686a 6d71 7576 7778 7c7e 7f80 8182 8384  hjmquvwx|~......
00000350: 8586 8788 898a 8b8c 8d8e 8f90 9192 9394  ................
00000360: 9596 9798 999a 9b9c 9d9e 9fa0 a1a2 a3a4  ................
00000370: a5a6 a7a8 a9aa abac adae afb0 b1b2 b3b4  ................
00000380: b5b6 b7b8 b9ba bbbc bdbe bfc0 c1c2 c3c4  ................
00000390: c5c6 c7c8 c9ca cbcc cdce cfd0 d1d2 d3d4  ................
000003a0: d5d6 d7d8 d9da dbdc ddde dfe0 e1e2 e3e4  ................
000003b0: e5e6 e7e8 e9ea ebec edee eff0 f1f2 f3f4  ................
000003c0: f5f6 f7f8 f9fa fbfc fdfe ff4b 3d20 ab    ...........K= .

Explanation
This program consists of three identical parts. (Concatenating multiple identical portions of a program is something of a theme for me in radiation-hardening programs.) Every A Pear Tree requires a checksum somewhere to let the interpreter know which parts of the program to run; it rotates any portion of the program for which the checksum succeeds to the start before running it (or prints a partridge if no checksum matches). In this case, we have a checksum on each of the three parts, and thus a non-irradiated part will move to the start. So we can assume that the program consists of an unmodified part, followed by two other parts (one of which may have been modified).
Each part starts with a newline, then continues with the following code (I've added whitespace and comments below):
$z{$/}++;      # In the hash table %z, set the key "\n" to 1
$/=$\=$@;      # Turn off newline handling when reading ($/ = undef);
               # Also don't add newlines when printing ($\ = undef)
               # $@ is set to undef by default
!$z{$_}?       #   If the current character is not in the hash table %z
  $z{$_}=1:    #   place it in the hash table %z
  delete$z{$_} #   else remove it from the hash table %z
for split//,   # for each character in
    <DATA>;    # the text appearing from the line beneath __DATA__ to EOF
print          # Print the following (no newline because $\ was undefined):
  keys%z>5?    # if the hash table %z contains more than 5 elements:
  "\n":        #   a newline; otherwise
  keys%z;      #   every key of %z, separated by spaces
__DATA__       # Start a string literal running from after this line to EOF

After that comes a copy of every octet that hasn't been used in the program so far (purely to run the score up), and finally the checksum. (There's no trailing newline; parts start with a newline but don't end with one.)
There are three distinct cases here:

A character other than a newline was deleted. In this case, it'll appear an odd number of times in the second and third parts. That means it'll be added and/or removed from %z an odd number of times, finally ending up in the hash table. In fact, it'll be the only key in the hash table (as the string runs from after the newline of the second part to the end of the third part, and the hash table started with just a single newline), so it'll just be printed out on its own.
The first or third newline was deleted. In this case, the program will be rotated such that it's the third of the newlines that's missing, effectively merging the second and third parts into a single line. The string literal accessed via <DATA> contains every character an even number of times, so the hash table will have its original content, a single newline, and that'll get printed.
The second newline was deleted. In this case, the program won't be rotated (as the first part has a valid checksum), so the second part will be moved onto the same line as the first part. <DATA> only starts reading from the line below __DATA__, so it'll only see the third part. This has more than five characters that appear an odd number of times, so it'll trigger the special case to print a newline.

Verification
One final thing that has to be checked for pretty much any radiation-hardened A Pear Tree program is whether a deletion happens to randomly cause an unwanted section of the code to checksum correctly and rotate the code into the wrong place; given that we're using 32-bit checksums, this is unlikely but not impossible. I used the following brute-force script to ensure that this doesn't happen for any deletion:
use 5.010;
use IPC::Run qw/run/;
use warnings;
use strict;
use Data::Dumper;
$Data::Dumper::Useqq=1;
$Data::Dumper::Terse=1;
$Data::Dumper::Indent=0;
undef $/;
$| = 1;
my $program = <>;

for my $x (0 .. (length($program) - 1)) {
    my $p = $program;
    my $removed = substr $p, $x, 1, "";
    alarm 4;
    say Dumper($p);
    run [$^X, '-M5.010', 'apeartree.pl'], '<', \$p, '>', \my $out, '2>', \my $err;
    if ($out ne $removed) {
        print "Unexpected output deleting character $x ($removed)\n";
        print "Output: {{{\n$out}}}\n";
        print "Errors: {{{\n$err}}}\n";
        exit;
    }
}

say $program;
run [$^X, '-M5.010', 'apeartree.pl'], '<', \$program, '>', \my $out, '2>', \my $err;
if ($out ne '') {
    print "Unexpected output not mutating\n";
    print "Output: {{{\n$out}}}\n";
    print "Errors: {{{\n$err}}}\n";
    exit;
}

say "All OK!";

The verification script confirms that this program works correctly.

Stax, 11 bytes (Score of 4)
'''cc'~~'dd

Run and debug online!
It is my honor to have the first (chronologically) answer to this challenge with a score higher than or equal to 4. Maybe the score can be even higher though.
In Stax, a string literal that is composed of a single character is written with ', so '', 'c, 'd, '~ are all string literals. The corresponding commands for c d and ~ means duplicate the top of the main stack, pop the top of the main stack, and pop the top of the main stack and push to the input stack, respectively. For this challenge, input stack does not affect output and is not important, hence we can say d and ~ are identical.
Explanation
It is best to divide the code into several parts and consider them separately.
When it is not tampered with, '''cc pushes a literal ' and a literal c to the main stack, and duplicates the top, so the stack would be (from to bottom) c,c,'.
When not tampered with, '~~ pushes the literal ~ and then pops it (and push to the input stack), which is basically a no-op for the main stack.
When not tampered with, 'dd pushes the literal d and then pops it, another no-op for the main stack.
At the end of the program, since no explicit output is done, the top of the main stack will be implicitly printed out.
If the program is running as-is, the final stack is still c,c,' and will output c.
If the first part becomes ''cc, then we have a literal ', and two copy instructions, the final stack will be ',','. Given that the two other parts are no-op, the result will be '.
If the first part becomes '''c, the result is basically the same with the untampered one, but the c is not duplicated. So the stack will be c,'. After two no-op's the top of the stack is c.
So we can detect radiation in the first part.
The second part and the third part work in exactly the same way. I will take the third part as an example.
If the third part is tampered with, then the first two parts are kept as-is and the stack before running the third part is c,c,'
If the third part becomes 'd, a literal d is pushed to the top of the main stack and nothing further is done. The top of the main stack is now d which will be output.
If the third part becomes dd, two elements are popped from the main stack and now the top of the stack is ' and is output.
Hence we can detect radiation in the third part. For the same reason we can detect radiation in the second part.

Jelly, 5 bytes, score 2
”””ḷḷ

Try it online!
With any ” removed:
””ḷḷ

Try it online!
The character ” begins a one byte character literal. This programs begins with ”” which yields the string ”. The ḷ dyad takes it's left argument. The string ” just gets passed through the two instances of ḷ.
With any ḷ removed:
”””ḷ

Try it online!
In this program ”” yields the character ” then ”ḷ yields the character ḷ and only this is output.

Other solutions

Lots of other characters such as a or o would have worked in place of ḷ for this submission.
⁾⁾⁾⁾FFF. This works in a similar way. ⁾ is like ” but it starts a two byte string literal. The "irradiated" programs output the deleted byte twice which was ruled valid in the comments.

Here is a (much less fancy) Jelly version of Magic Octopus Urn's validity checker. The left column of the output is the deleted character and the right column is the output of the resulting program.

My validity checker isn't thaaat fancy. It fails for the other solution posted ;).

05AB1E, score 2, 6 bytes
„"""„„

Prints double the removed character sometimes. Doesn't contain '.
How it works:
Removing the first „
"""„„

Try it online!
First, we push an empty string literal to the stack. Then we push „„, which is printed implicitly.
Removing a "
„""„„

Try it online!
First, we push "" to the stack with the 2-char string instruction. Then we try to get another 2-character string, but this is aborted (I'm not exactly sure why) and the "" is printed.
Removing the second or third „
„"""„

Try it online!
First, we push "" to the stack with the 2-char string instruction. Then we push „, which is printed implicitly.

Vyxal, 65 bytes, score 22
\\\::\__\⅛⅛\££\→→\((\[[\‟‟\**\••\--\oo\PP\ḞḞ\↳↳\↲↲\⋏⋏\ǑǑ\FF\jj\∇∇

Try it Online!
Based on Weijun Zhou's Stax answer.
In Vyxal, \ takes the next character as a single character. So, the bit at the start \\\:: pushes "\", pushes ":", then duplicates it with the operation :.
The stack is now ["\", ":", ":"].
If either : is removed, the : operation is not run and the stack is just ["\", ":"]. If any \ is removed, the stack becomes ["\","\","\"].
The rest of the program is chunks of \xx, where x is some operation that effectively does nothing but remove a string from the stack. These chunks normally do nothing, as they effectively push and pop a value.
If a backslash is removed, an operation that effectively pops the stack is run twice, removing the two ":" from the stack and leaving the backslash we pushed at the start.
If either x is removed, the string "x" is pushed to the stack and not removed.
Finally, the top of the stack is implicitly output.
Operations, and why they work
For these, x is the value already on the stack and y is the value

_ - Simply pops y
⅛ - Pushes y to the global array.
£ - Stores y to the register
→ - Stores y to the empty variable
( - starts a for loop over y. As it's a 1-character string the code inside is run once
[ - If y is truthy, execute the remaining code. It will always be truthy.
‟ - Rotate y to the bottom of the stack.
* - Ring translate x by y. Since the strings share no characters, nothing happens.
• - Give x the casing of y. Since this occurs before anything alphabetical, nothing happens.
- - Remove y from x
o - Remove y from x
P - Strip y from the outside of x
Ḟ - Replace spaces in x with y. There are no spaces in x.
↳ - Pad x according to y
↲ - Pad x according to y
⋏ - Center x according to y
Ǒ - Remove y from x until x doesn't change
F - Remove characters in y from x
j - Join y by x. This does nothing to a 1-character x.
∇ - Rotate the top three items of the stack. Has to be at the end.


text:
Diluted Integer Sums
A positive integer can be diluted by inserting a 0 between two bits in its binary expansion. This means that an n-bit number has n-1 dilutions, which are not necessarily all distinct.
For example, for 12 (or 1100 in binary), the dilutions are
11000 = 24
   ^

11000 = 24
  ^

10100 = 20
 ^

In this challenge, we're going to be taking the sum of all the dilutions, exclusive of the original number. For 12, taking the sum of 24, 24, 20 results in 68, so 68 should be the output for 12.
Challenge
Given a positive integer n > 1 as input, output/return the diluted sum as explained above.
Examples
in    out
---   ---
2       4
3       5
7      24
12     68
333  5128
512  9216

Rules

The input and output can be assumed to fit in your language's native integer type.
The input and output can be given in any convenient format.
Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.
Standard loopholes are forbidden.
This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.

Does "any convenient format" include a binary string?

@Shaggy "Any convenient format" is intended to be inclusive of methods of input/output, not format. As such, I'm going to say no, you must take input as an integer or a string representing that integer.

Nice challenge!

This sequence is currently (30 Jan 2018) not in the OEIS

Python 2, 43 39 bytes
f=lambda n,i=2:n/i and n*2-n%i+f(n,i*2)

Try it online!

How?
Each call of the recursive function calculates a single dilution. The position of the inserted 0 is log2(i). The function recurses until i gets bigger than n and the insertion would be on the left of the number. If i>n, n/i evaluates to 0, which is a falsy value in Python.
n*2 shifts the entire number one binary digit left, n%i or n % 2**(position of insertion) calculates the value of the part that should not be shifted left. This value gets subtracted from the shifted number.
Example (n=7)
call       n/i          bin(n)  n*2     n%i   dilution       return value

f(7, i=2)  3 => truthy  0b111   0b1110  0b1   0b1101 = 13    13 + f(7, 2*2) = 13 + 11 = 24
f(7, i=4)  1 => truthy  0b111   0b1110  0b11  0b1011 = 11    11 + f(7, 4*2) = 11 + 0 = 11
f(7, i=8)  0 => falsy                                        0

Jelly, 11 bytes
BJṖ2*ɓdḅḤ}S

Try it online!
How it works
BJṖ2*ɓdḅḤ}S  Main link. Argument: n (integer)

B            Binary; convert n to base 2. This yields a digit array A.
 J           Indices; yield [1, ..., len(A)].
  Ṗ          Pop; remove the last element, yielding [1, 2, ..., len(A)-1].
   2*        Elevate 2 to these powers, yielding [2, 4, ..., 2**(len(A)-1)].
             Let's call the result B.
     ɓ       Begin a new, dyadic chain, with left argument n and right argument B.
      d      Divmod; yield [n/b, n%b], for each b in B.
        Ḥ}   Unhalve right; yield 2b for each b in B, i.e., [4, 8, ..., 2**len(A)].
       ḅ     Unbase; convert each [n/b, n%b] from base 2b to integer, yielding
             (2b)(n/b) + (n%b).
          S  Take the sum.

MATL, 13 bytes
tZl:W&\5ME*+s

Try it at MATL Online! Or verify all test cases.
Explanation
Consider input 12 as an example.
t     % Implicit input. Duplicate
      % STACK: 12, 12
Zl    % Binary logarithm
      % STACK: 12, 3.584962500721156
:     % Range (rounds down)
      % STACK: 12, [1 2 3]
W     % Power with base 2, element-wise
      % STACK: 12, [2 4 8]
&\    % 2-output modulus, element-wise: pushes remainders and quotients
      % STACK: [0 0 4], [6 3 1]
5M    % Push array of powers of 2, again
      % STACK: [0 0 4], [6 3 1], [2 4 8]
E     % Multiply by 2
      % STACK: [0 0 4], [6 3 1], [4 8 16]
*     % Multiply, element-wise
      % STACK: [0 0 4], [24 24 16]
+     % Add, element-wise
      % STACK: [24 24 20]
s     % Sum of array. Implicit display
      % STACK: 68

Japt, 12 11 bytes
¢¬£¢iYTÃÅxÍ

Try it

Explanation
                 :Implicit input of integer U
¢                :Convert to base-2 string
 ¬               :Split to an array of individual characters/digits
  £    Ã         :Map over the elements, with Y being the current 0-based index
   ¢             :  Convert U to a base-2 string
    iYT          :  Insert a 0 in that string at index Y
        Å        :Slice off the first element of the array
          Í      :Convert each element to a base-10 integer
         x       :Reduce by addition

C,  58  56 bytes
Thanks to @Dennis for saving two bytes!
s,k;f(n){for(s=0,k=2;k<=n;k*=2)s+=n/k*k*2+n%k;return s;}

Try it online!
C (gcc), 50 bytes
s,k;f(n){for(s=0,k=2;k<=n;)s+=n%k+n/k*(k+=k);k=s;}

Returning by k=s; is undefined behaviour, but works with gcc when optimizations are disabled. Also, n%k+n/k*(k+=k) has unspecified behaviour, but seems to work fine with gcc.
Try it online!

s,k;f(n){for(s=0,k=2;k<=n;)s+=n%k+n/k*(k*=2);return s;} (55 bytes)

There's no telling which one gets evaluated first n%k or n/k*(k*=2).

@KevinCruijssen Which side is evaluated first is left unspecified. C is like that...

Ah, I see you've added that in your answer indeed. Didn't knew this kind of undefined behavior happened in C. I have like three hours experience in C, so I barely know anything about it. TIL :) In Java for(s=0,k=2;k<=n;)s+=n%k+n/k*(k*=2);return s; is completely fine, and n%k will always be evaluated before n/k*(k*=2) and n/k will also evaluate before k*=2. Thanks for the explanation. (I will delete some of my comments now to reduce the clutter.)

I love using UB as a feature. And code golfing in a real life language should be in another category anyway :)

J, 20 15 14 bytes
+/@}:@:+[\&.#:

Try it online.
15 bytes
1#.-,+:-#.\.@#:

Try it online!
     +:             Input×2
       -            Subtract
        #.\.@#:     The list of binary suffixes of input (in decimal)
   -,               Append negative input
1#.                 Add them up

why does the double minus formula work?  why is it equivalent to dilutions?

@Jonah dilution is adding a certain binary prefix (number "rounded down") to the number, which is equivalent to adding the whole number to itself (both prefix and the remainder) and then subtracting the remainder.

Jelly, 9 8 bytes
BḊḄÐƤạḤS

Try it online!
B                        to binary          42 -> 1 0 1 0 1 0
 Ḋ                       drop first                 0 1 0 1 0
  ḄÐƤ                    each suffix to decimal   10 10 2 2 0
      Ḥ                  double the input                  84
     ạ                   absolute difference   74 74 82 82 84
       S                 add them up                      396

Vice versa, B¹ƤṖ+BḄS: get prefixes, drop last, add them to input, and sum.

JavaScript (ES6), 41 40 bytes
Saved 1 byte thanks to Mr.Xcoder
f=(n,k=1)=>k<n&&(n&k)+2*(n&~k)+f(n,k-~k)

Test cases

f=(n,k=1)=>k<n&&(n&k)+2*(n&~k)+f(n,k-~k)

console.log(f(2  )) //    4
console.log(f(3  )) //    5
console.log(f(7  )) //   24
console.log(f(12 )) //   68
console.log(f(333)) // 5128
console.log(f(512)) // 9216

Retina, 53 50 47 bytes
.+
*
+`(_+)\1
$1O
O_
_
L$`\B
$`O$'
+%`\B
¶$`¶
_

Try it online! Link includes test cases. Edit: Saved 3 bytes thanks to @MartinEnder. Explanation:
.+
*
+`(_+)\1
$1O
O_
_

Convert from decimal to binary, but using O to represent 0, as it's not a digit, and _ to represent 1, as it's the default repetition character in Retina 1.
L$`\B
$`O$'

Insert an O between each pair of digits, and collect the results as a list.
+%`\B
¶$`¶

Convert from binary to unary. (This conversion produces extra Os, but we don't care.)
_

Sum and convert to decimal.

Binary to decimal conversion can be done in 12 bytes (saving 3): https://tio.run/##K0otycxLNPz/X0@bS4tLO0EjXlszxpBLxdCfyz@eK54rxonLX0WJy1HXMIFLWzUByD20TSXBiiv@/39DIwA See this answer for how it works.

@MartinEnder Thanks, I keep forgetting about that. (I was also slightly disappointed that the alternative version only works on a single number.)

Well, in the case where you've got each number on its own line you can make it work with an additional %. If it's more complicated you'd need something like /[O_]+/_.

Pyth, 13 bytes
smiXd.BQZ2Ssl

Try it here!
Explanation

smiXd.BQZ2Ssl | Full program.

           sl | The base-2 logarithm of the input, floored to an integer.
          S   | Create the integer range [1 ... the floored logarithm].
 m            | And map a function over it.
------------+-+-----------------------------------------------------
  iXd.BQZ2  | The function to be mapped (uses a variable d).
     .BQ    | In the binary representation of the input...
   X    Z   | ... Insert a zero...
    d       | ... At index d.
  i      2  | And convert the result from base 2 to an integer.
------------+-+-----------------------------------------------------
s             | Sum the resulting list.

Jelly, 10 bytes
BµLḤ_J’×µḄ

Try it online!
Not the shortest currently, but it could be if there's a way around Bµ µḄ...
Explanation
BµLḤ_J’×µḄ    Main link. Argument: n (integer)
B             Binary; convert n to an binary of binary digits. Call this A.
 µ            Start a new monadic link with argument A.
  L           Length; yield len(A). We'll call this l.
   Ḥ          Unhalve; yield l * 2.
     J        Length range; yield [1, 2, ..., l].
    _         Subtract; yield [l*2 - 1, l*2 - 2, ..., l].
      ’       Decrement; subtract one from each item.
       ×      Multiply each item by the corresponding item in A. Call this B.
        µ     Start a new monadic link with argument B.
         Ḅ    Unbinary; convert from a binary array to a decimal.

Basically, this works by multiplying each binary digit by a magic number. I can't explain it without visualizing it, so here's the binary number we'll be working with:
1111

As explained by the challenge, he output we want is the sum of these binary numbers:
10111  = 2^4 + 2^2 + 2^1 + 2^0
11011  = 2^4 + 2^3 + 2^1 + 2^0
11101  = 2^4 + 2^3 + 2^2 + 2^0

However, we don't actually have to insert zeroes: Jelly's "unbinary" atom will accept numbers other than just 0 and 1. When we allow ourselves to use 2, this pattern gets simpler:
2111   = 2*2^3 + 1*2^2 + 1*2^1 + 1*2^0
2211   = 2*2^3 + 2*2^2 + 1*2^1 + 1*2^0
2221   = 2*2^3 + 2*2^2 + 2*2^1 + 1*2^0

When we sum up the digits in each column, we get
6543   = 6*2^3 + 5*2^2 + 4*2^1 + 3*2^0 = 48 + 20 + 8 + 3 = 79.

The trick this answer uses is to generate this pattern, and multiply each digit by the corresponding digit in the original to cancel out the necessary columns. 12, for example, would be represented as
 1100
×6543
=6500  = 6*2^3 + 5*2^2 + 0*2^1 + 0*2^0 = 48 + 20 + 0 + 0 = 68.

Husk, 13 12 bytes
-1 byte thanks to @Mr. Xcoder!
ṁḋ§z·+Θḣotṫḋ

Try it online!
Explanation
ṁḋ§z·+Θḣ(tṫ)ḋ  -- example input: 6
            ḋ  -- convert to binary: [1,1,0]
  §            -- fork argument
        (tṫ)   -- | tail of tails: [[1,0],[0]]
       ḣ       -- | heads: [[1],[1,1],[1,1,0]]
   z           -- and zipWith the following (example with [1,0] [1])
    · Θ        -- | prepend 0 to second argument: [0,1]
     +         -- | concatenate: [1,0,0,1]
               -- : [[1,0,1,0],[1,1,0,0]]
ṁ              -- map the following (example with [1,0,1,0]) and sum
 ḋ             -- | convert from binary: 10
               -- : 22

Java 8, 55 bytes
n->{int r=0,i=2;for(;i<=n;r+=n%i+n/i*(i*=2));return r;}

Port of Steadybox' C answer, and golfed 3 bytes in the process.
Try it online.

R, 141 48 bytes
function(n,l=2^(1:log2(n)))sum(n%%l+(n%/%l*2*l))

Try it online!
Either I'm doing something really wrong or R is just terrible at bit manipulation. Porting Luis Mendo's approach is easy, correct, and golfy.
But if you really just want to muck around with bit operations, MickyT suggested the following 105 byter:
function(i)sum(sapply(1:max(which(b<-intToBits(i)>0)),function(x)packBits(head(append(b,F,x),-1),"i")))-i

Try it online!

Here's a 111 byte one that I'm sure you could take a few more out of.

@MickyT Cheers! very nice, although porting an entirely different approach is better!

Python 3, 92 80 78 bytes
def b(x):x=f'{x:b}';return sum(int(x[:i]+'0'+x[i:],2)for i in range(1,len(x)))

Try It Online
Thanks to Mr.XCoder and ovs for -12 bytes and -2 bytes respectively.

80 bytes

05AB1E, 14 bytes
.²LoDŠ‰ø`r·*+O

Try it online!

Batch, 92 77 bytes
@set/an=2,t=0
:l
@if %1 geq %n% set/at+=%1*2-(%1%%n),n*=2&goto l
@echo %t%

Edit: Switched to the same formula everyone else is using.

Pip, 21 18 bytes
2*a-a%2**_MS1,#TBa

Try it online!
Explanation
Call our input number a. For each binary index i at which we want to insert a zero, we can calculate the bits left of the insertion point as a // 2**i (where // is integer division and ** is exponentiation), the bits right of the insertion point as a % 2**i, and therefore the diluted integer as 2 * (a // 2**i) * 2**i + (a % 2**i). But (a // 2**i) * 2**i is equal to a - (a % 2**i), and so we can rearrange to a shorter formula: 2 * (a - a % 2**i) + a % 2**i = 2 * a - a % 2**i.
2*a-a%2**_MS1,#TBa
                       a is 1st command-line argument (implicit)
               TBa     Convert a to binary
              #        Length of the binary expansion
            1,         Range from 1 up to (but not including) that number
          MS           Map this function to the range and sum the results:
2*a-a%2**_              The above formula, where _ is the argument of the function
                       The final result is autoprinted

Jelly, 14 bytes
BLḊṬœṗ¥€Bj€0ḄS

Try it online!

Perl 5, 36 + 1 (-p) = 37 bytes
$\+=$_*2-($_&$.-1)while($.*=2)<=$_}{

Try it online!

Attache, 57 bytes
Sum##UnBin=>{Join[Join=>_,"0"]}=>SplitAt#1&`:@{#_-1}##Bin

Try it online!
I thought I'd approach the problem from a non-bit manipulation approach, as such an approach is impractical in Attache. I have to investigate some of the parts of this approach for alternatives.
Explanation
Here is an expanded version:
Define[$joinByZero, {Join[Join=>_,"0"]}]

Define[$insertionPoints,
    SplitAt#1&`:@{#_-1}
]

Define[$f,
Sum##UnBin=>joinByZero=>insertionPoints##Bin
]

This simply takes the binary representation of the number, splits it at certain points, inserts zeroes there, converts back to decimal, and sums them together.

J, 33 bytes
1#.[:}:#.@(<\;@(,0;])"0<@}.\.)@#:

Most probably there is much room for further golfing.
How?
@#: convert to binary and
<@}.\. - find all suffices, drop the first digit from each and box
<\  - find all prefixes and box them
(,0;])"0 - to each prefix append 0 then append the corresponding beheaded suffix
;@ raze (unbox)
1#.[:}:#.@ - convert to decimal, curtail and sum
Try it online!

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
Solve Hitori Puzzles
Introduction
Write a solver for the Hitori puzzles using least bytes.
Challenge
Your task is write a solver for the Hitori (ひとり, the word for "alone" in Japanese; the meaning of the game name is "Leave me alone") logical puzzles. The rules are as follows:

You are presented with a n-by-n grid of cells, each cell contains an integer between 1 and n (inclusive).
Your goal is to make sure that no number appear more than once in each row and each column of the grid, by removing numbers from the given grid, subject to the restriction indicated in the next two rules,
You cannot remove two numbers from two adjacent (horizontally or vertically) cells.
The remaining numbered cells must be all connected to each other. It means that any two remaining numbered cells can be connected with a curve that is composed solely of segments connecting adjacent remaining numbers (horizonally or vertically). (Thanks to @user202729 for pointing out that this is missing)

I hope the rules are clear by now. If there is anything unclear about the rules, check the Wikipedia page.
Test Cases
The cells from which the numbers are removed are represented with 0s.
Input  ->  Output

4
2 2 2 4      0 2 0 4
1 4 2 3  ->  1 4 2 3
2 3 2 1      2 3 0 1
3 4 1 2      3 0 1 2

4
4 2 4 3      0 2 4 3
4 1 1 2  ->  4 1 0 2
3 1 2 1      3 0 2 1
4 3 1 3      0 3 1 0

5
1 5 3 1 2      1 5 3 0 2
5 4 1 3 4      5 0 1 3 4
3 4 3 1 5  ->  3 4 0 1 5
4 4 2 3 3      4 0 2 0 3
2 1 5 4 4      2 1 5 4 0

8
4 8 1 6 3 2 5 7      0 8 0 6 3 2 0 7
3 6 7 2 1 6 5 4      3 6 7 2 1 0 5 4
2 3 4 8 2 8 6 1      0 3 4 0 2 8 6 1
4 1 6 5 7 7 3 5  ->  4 1 0 5 7 0 3 0
7 2 3 1 8 5 1 2      7 0 3 0 8 5 1 2
3 5 6 7 3 1 8 4      0 5 6 7 0 1 8 0
6 4 2 3 5 4 7 8      6 0 2 3 5 4 7 8
8 7 1 4 2 3 5 6      8 7 1 4 0 3 0 6

9
8 6 5 6 8 1 2 2 9      8 0 5 6 0 1 2 0 9
5 6 2 4 1 7 9 8 3      5 6 2 4 1 7 9 8 3
5 8 2 5 9 9 8 2 6      0 8 0 5 0 9 0 2 0
9 5 6 6 4 3 8 4 1      9 5 6 0 4 3 8 0 1
1 1 6 3 9 9 5 6 2  ->  0 1 0 3 9 0 5 6 2
1 1 4 7 3 8 3 8 6      1 0 4 7 0 8 3 0 6
3 7 4 1 2 6 4 5 5      3 7 0 1 2 6 4 5 0
3 3 1 9 8 7 7 4 5      0 3 1 9 8 0 7 4 5
2 9 7 5 3 5 9 1 3      2 9 7 0 3 5 0 1 0

These test cases are taken from Concept Is Puzzles, PuzzleBooks, Concept Is Puzzles, Wikipedia, and Youtube, respectively.
Specs

No need to worry about exception handling.
You can assume that the input is always a valid puzzle with a unique solution and you can take advantage of this in writing your code.
This is code-golf, the lowest number of bytes wins.
4 <= n <= 9 (16 originally, changed to 9 following Stewie Griffin's suggestion, also save some trouble in IO)
You can take input and provide output through any standard form, and you are free to choose the format.
Some suggestions for the output format are (but you are not restricted to these)

Outputting the final grid
Outputting the grid containing all removed numbers
Output a list of coordinates of one of the above

As usual, default loopholes apply here.

Related(inspired by this challenge): Check if All Elements In a Matrix Are Connected

My last challenge: Extension of the Game of Sevens

I suggest that you require deterministic runtime, or require that the largest test case can be solved in no more than 1 minute (or maybe more/less). Also, you say 4 <= n <= 16, but the largest test case is for n=9. I suggest you either post a n=16 test case, or say 4 <= n <= 9. Nice challenge by the way :)

@StewieGriffin how about just having a separate fastest algorithm challenge?

@StewieGriffin Tried to add a 16x16 but not yet quite ready. Changed to 9 now.

@JonathanAllan As you wish.

Re "I decide to make a change to see whether it would be better": It would definitely be worse. Also you should not change an already posted challenge.

(I rolled back the challenge. If you want, you can post a separate fastest algorithm challenge. Don't worry, we allow the same challenge with different winning criteria)

@JonathanAllan (Just FYI, I posted a Jelly solution to the connectivity challenge)

@user202729 I didn't see your message until now. Thank you. I still don't have a good grasp of the types of puzzles ...

Hitori = 一人 = Singleplayer :)

Haskell, 374 bytes
import Data.Array;import Data.List;r=range;p=partition
c(e,f)=p(\(b,p)->any(==1)[(b-d)^2+(p-q)^2|(d,q)<-e])f
n#g=[s|(o,(e:f))<-[p((==0).(g!))$indices g],
 null.fst$c(o,o),null.snd$until(null.fst)c([e],f),
 s<-case[((l,c),d)|((l,c),h)<-assocs g,h>0,
 d<-[filter((==h).(g!))$r((l,c+1),(l,n))++r((l+1,c),(n,c))],d/=[]]
 of[]->[g];((c,d):_)->n#(g//[(c,0)])++n#(g//[(c,0)|c<-d])]

Try it online!

Thank you. Very impressive. Personally I am a beginner but also a big fan of Haskell.

https://tio.run/##bVHbbtswDH33V2RIHkiYTmLn4jiJAwzYy4D9gaYVrm8R6squrDwUyL9nlJIWBTYQpMTDw0NaPhfjS911t5t6HXpjJz8KW8y/G1O8H74iv9RoDyY3hW7rw5APhbHKql4HJdTUYD7Ab3imAaNTod8hz2MU8BxV@CcJYYje@LxCRW94jGqJTaCnbS7GK/QE9b5BhsUA3LbEObTfEGdKV6qsx0krSV@6bt6MdlYyvcd7PupqdtFWdfBRxhJELXkXGo9RWYy1AOioRKrw@rideU4xjn3JunQ@LaniuY3qbG3c8PPHcOP5YYzEp0YMQ4eEsdMAzRElVYtcSNk3QkYn0coDQMmT9k/8AnoK7WIhGFii5Oav@bU8RpVEeYuiCUxxv/@pbXTy7w3Ad2JH9KD4DyqD10LpfDBK25lWug6a/mLy9bTj//Pgx@QWX9MaUSTkbE0xe0Krh8ccHZbIwGnk2b/tGWXcvqMtbdh3jsyW@ewumHK2Y6ENx4Rj5vOE63fWllkrRhzX2Zaz7FMh9iulnuHcVdP7Ur5zw7Zii71q6msbv0HqK24ef4a8/QU

The above was too many characters too leave a comment alongside. It is just removing some whitespace

https://tio.run/##bVHbbtswDH33V2RIHkiESmvn6jQKNmAvA/YHmja4tuwoc2THdoGuS789o5RuGLCBIGUeHh5S8iHrv5u6vl7tqW26YfQxG7LZh67LfkR/I59tP0Sd7DJXmaiVbdYNdrCNi87SPdX1rOTyEQyVKFv4Ao/Uotg3nYJHUeDXZAqtOPMpZXyBgs64E0ZjGblxJVV/qc0ADZlt6IZdjDOo3iFOrCtsbvpRRefJkRkNUpjWu2Ly5AZbj86jIyijeS71O5FnvVHwQgVe4OU91JQjHXhW1vdN7mUO@3sqdkKVth5MByDl4fcszpg/jZH4dIjTqUemsdcAxxE1FXuldVNCzhO238S@aH6eWE3lXNIPbgzV3Z2CZ7rHy/NOnDS@PjBLVVpfhRjBGLfbT24Q@/C@APxN7IgBVP9BdXTKrJNtZ90wcdaZqGyeOrkY1/w/3vgx@Z0XtEBUCXlbUMye0PzNY44eS3TkNWT6b3tKKbdvaEVL9o0ns6UhuwmuOduw0JJjwjENecL1G2vFrDkjnuttxVn6RyEOK60Dw7uvrm9Lhc4l25wtDqrrUFuGDdah4ufxNfT1Fw

APL (Dyalog Unicode), 133 bytesSBCS
{q←{⊢/4 2⍴⍵}⌺3 3⋄g←⍵=⊂∪,⍵⋄⍵×~1⊃{((⌈/q b)⌈b<{2<≢∪0,,(⍵×⊢⌈⌈/∘q)⍣≡⍵×(⍴⍵)⍴1+⍳≢,⍵}¨~b∘⌈¨⊂⍤2∘.≡⍨⍳⍴b)(+/↑w<g×⌈.⌈⍨w×g)⌈w b←⍵}⍣≡×\(⌈/=∘⌽⍨q⍵)0}

Try it online!
My implementation of rule #4 (cells must form a single connected component) is rather wasteful, but still this passes all tests in about 10 seconds on TIO.

The overall algorithm: Store two boolean matrices b and w for cells that are certain to be black and white respectively. Initialise b as all-zero. Initialise w as 1 only for those cells that have opposite matching neighbours.
Repeat until b and w settle down:

add to b cells that are on the same line (horizontal or vertical) and of the same value as a cell in w
add to w the immediate neighbours of all cells in b
add to w all cutpoints - cells whose removal would split the graph of non-black cells into multiple connected components

Finally, output not(b) multiplied by the original matrix.

Thank you very much for your interest and explanation. I think what you described is also a typical algorithm used if one is to solve the puzzle by hand.

To be honest, I never even tried to solve Hitori by hand. I got these tricks from Wikipedia and I don't have a proof that the algorithm would always converge all the way to the (unique) solution.

Jelly, 62 bytes
Uses user202729's isConnected monadic link from another question.

FJṁa@µ«Ḋoµ€ZUµ4¡ÐLFQL<3
ḟ0ĠḊ€
¬T€œ&2\;Ç€FȦ
ZÇȯÇ_1Ŀ
2ḶṗLṗLa⁸ÇÞḢ

A full program printing a representation of a list of lists.
Works by brute force and is stupidly inefficient.
Try it online! - a 3 by 3, since it is too inefficient to run even a size 4 within the 60 second TIO limit!
How?
FJṁa@µ«Ḋoµ€ZUµ4¡ÐLFQL<3 - Link 1 isConnected? List of lists
...                     - 1 if connected 0 if not -- see linked answer in the header

ḟ0ĠḊ€ - Link 2, helperFor-AnyRepeatedValues: list
ḟ0    - filter out zeros
  Ġ   - group indices by value (i.e. [[indices of min],...,[indices of max]]
   Ḋ€ - dequeue €ach -- leaving a list of empty lists iff no repeated values
      -                 any remaining values are non-zero (1-based indexing in Jelly)

¬T€œ&2\;Ç€FȦ - Link 3, columnwiseAnyAdjacentZerosOrRowwiseAnyRepeatedValues: list of lists
¬            - logical not (convert all zeros to ones and all others to zeros)
 T€          - for €ach row get a list of truthy indexes (i.e. indexes of original zeros)
     2\      - pairwise reduction (i.e. for neighbouring rows) with:
   œ&        -   intersection (empty if no columnwise adjacent original zeros
             -                 any remaining values are non-zero due to 1-based indexing)
        Ç€   - call last link (1) as a monad for €ach row
       ;     - concatenate
          F  - flatten into a single list (empty iff no columnwise adjacent original zeros
             -                                   AND no rowwise repeated values)
           Ȧ - any and all (0 if empty [or contains any zero -- never] else 1)

ZÇȯÇ_1Ŀ - Link 4, validity check? list of lists
Z       - transpose
 Ç      - call last link (2) as a monad rowwiseAnyAdjacentZerosOrColumnwiseAnyRepeatedValues?
   Ç    - call last link (2) as a monad columnwiseAnyAdjacentZerosOrRowwiseAnyRepeatedValues?
  ȯ     - logical OR
     1Ŀ - call link 1 as a monad (isConnected?)
    _   - subtract
        - this yields -1 for valid, while it yields 0 or 1 if not.

2ḶṗLṗLa⁸ÇÞḢ - Main link: list of lists
2Ḷ          - lowered range of 2 -> [0,1]
   L        - length (number of rows in the input)
  ṗ         - Cartesian power (all lists of zeros and ones of length L)
     L      - length (number of rows in the input again)
    ṗ       - Cartesian power (all grids of zeros and ones of same shape as the input)
       ⁸    - the input
      a     - logical AND -- effectively uses each of the formed grids as a mask
         Þ  - sort by:
        Ç   -   last link (3) as a monad
          Ḣ - head
            - implicit print

NIce as a start. Thank you. I will take a look.

You forgot the 4th rule. (connected)

(good luck with implementing BFS/DFS/DSU in Jelly)

Oh... will delete when at a computer. Thanks.

yeah, I don't think this is possible in, say, <60 bytes of Jelly, not to say <100...

Python3, 567 bytes:
E=enumerate
M=[(0,1),(0,-1),(1,0),(-1,0)]
V=lambda b:[(x,r,y,v)for x,r in E(b)for y,v in E(r)]
J=list.count
def C(b,x,y,s):
 b=eval(str(b));b[x][y]=0
 if b in s:return
 t=[(x,y)for x,_,y,v in V(b)if v]
 q=[t.pop()]
 while q:
  x,y=q.pop(0)
  for X,Y in M:
   if(N:=(x+X,y+Y))in t:q+=[N];t.remove(N)
 if[]==t:return b
def f(b):
 q,s=[b],[]
 while q:
  b=q.pop(0)
  F=1
  for x,r,y,v in V(b):
   if v and(J(r,v)>1 or J([*[*zip(*b)][y]],v)>1):
    F=0
    if all(b[x+X][y+Y]for X,Y in M if 0<=x+X<len(b)and 0<=y+Y<len(r))and(B:=C(b,x,y,s)):q+=[B];s+=[B]
  if F:return b

Try it online!

Handful of relatively trivial golfs for 557 (footer elided for link space)

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Screenshot Tiler
Introduction
Given a set of text-based "screenshots" consisting of printable ASCII chars merge them so that all of them form one long screenshot so that nobody has to do it themselves when reading it.
Challenge
Take input as a list of strings (referred to as "screenshots"). Each screenshot consists of several lines of text.
To merge two screenshots:

Starting from the first line, check if that line occurs in the second screenshot

If it does, cut the first screenshot so it ends at this duplicated line and cut the second screenshot so it begins one line after the duplicated line
Concatenate these two together with the cuts

If they do not have a line of text in common, just append the second screenshot to the first (starting on a new line).

Your output should be a single string merging all of the screenshots together. Screenshot merging is not associative, so you should merge in the following order: merge the first and the second screenshot, then the resulting screenshot with the third, then the result with the fourth screenshot, and so on, until only one screenshot is left.
Example with explanation
Input:
Screenshot 1:
> hi
      hi <
> how are you doing
    good <

Screenshot 2:
      hi <
> how are you doing
    good <
> good
     yes <

Output:
> hi
      hi <
> how are you doing
    good <
> good
     yes <

Explanation:
Going from top to bottom, find the first line on both the first and second screenshot
> how are you doing

Take the first half of this screenshot above and including the line
> hi
      hi <
> how are you doing
--remove everything below--

Find the first line where it is duplicated in the next screenshot and cut one below there
--remove everything including and above--
    good <
> good
     yes <

Concatenate the two sections
> hi
      hi <
> how are you doing
--join them together--
    good <
> good
     yes <

Test Cases
Input:
line 1
line 2
line 3

line 2
line 3
line 4

Output:
line 1
line 2
line 3
line 4

Input:
line 1
line 2
line 10

line 10
line 2
line 3

Output:
line 1
line 2
line 3

Note that even though line 10 is duplicated, line 2 is duplicated first and split there.

Input:
words
really long repeated words
456

hi
really long repeated words
hmm
really long repeated words
kthxbye

Output:
words
really long repeated words
hmm
really long repeated words
kthxbye

Note that really long repeated words appears twice in the result because the one in the first screenshot and the other in the second screenshot is included

Input:
======= 10:42 ========
~~~ p1: hi
            hi :p2 ~~~
~~~ p1: yes
            no :p2 ~~~
v     -----------    v

======= 10:43 ========
            no :p2 ~~~
~~~ p1: why?
       because :p2 ~~~
~~~ p1: ok fine
v     -----------    v

======= 10:44 ========
       because :p2 ~~~
~~~ p1: ok fine
~~~                ~~~
~~~                ~~~
v     -----------    v

Output:
======= 10:42 ========
~~~ p1: hi
            hi :p2 ~~~
~~~ p1: yes
            no :p2 ~~~
~~~ p1: why?
       because :p2 ~~~
~~~ p1: ok fine
~~~                ~~~
~~~                ~~~
v     -----------    v

Note that the clock increases in time meaning that the clock is not the first duplicated input. Because it is before the first duplicated input, it gets ignored the second and third time.

Edge Case Input:
> hello
   oh hi <

> how are you doing
    good <

Output:
> hello
   oh hi <
> how are you doing
    good <

Note that nothing is duplicated here so just append them together

As this is code-golf, smallest submission in bytes wins.

Why is merging no associative?

I suggest you add a test case where the other way around won't work. Just a suggestion. If you think it will make people even more confused, you can ignore my suggestion.

Given the screenshots 1/2, 2/1, and 3/2, merging them left-to-right yields 1/3/2 and merging them right-to-left yields 1/2.

Can we take input as a list of lists of lines and output a list of lines?

@kamoroso94 yes

JavaScript (ES6), 112 bytes
Takes input as a list of lists of lines, outputs a list of lines.
s=>s.reduce((a,b)=>(i=a.findIndex(x=>(j=b.indexOf(x))>=0))<0?a.concat(b):a.slice(0,i+1).concat(b.slice(j+1)),[])

const f =
s=>s.reduce((a,b)=>(i=a.findIndex(x=>(j=b.indexOf(x))>=0))<0?a.concat(b):a.slice(0,i+1).concat(b.slice(j+1)),[])
;
const tests = [
[`line 1
line 2
line 3`,
`line 2
line 3
line 4`],
[`line 1
line 2
line 10`,
`line 2
line 10
line 3`],
[`words
really long repeated words
456`,
`hi
really long repeated words
hmm
really long repeated words
kthxbye`],
[`======= 10:42 ========
~~~ p1: hi
            hi :p2 ~~~
~~~ p1: yes
            no :p2 ~~~
v     -----------    v`,
`======= 10:43 ========
            no :p2 ~~~
~~~ p1: why?
       because :p2 ~~~
~~~ p1: ok fine
v     -----------    v`,
`======= 10:44 ========
       because :p2 ~~~
~~~ p1: ok fine
~~~                ~~~
~~~                ~~~
v     -----------    v`],
[`> hello
   oh hi <`,
`> how are you doing
    good <`]
];

for(let test of tests) {
  console.log('Input:', test=test.map(x=>x.split('\n')));
  console.log('Output:', f(test));
}

Jelly, 29 bytes
Ỵ€ð¹Ƥp¹ÐƤ}Ṛ⁼"¥Ḣ¥/ÐfḢṖ;¥/ȯ;µ/Y

Try it online!

Python 2, 124 bytes
def f(S):
 x=[]
 for y in S:
	y=y.split('\n');x+=y;i=0
	while(x[i]in y)<1:i+=1
	x=x[:i]+y[y.index(x[i]):]
 print'\n'.join(x)

Try it online!


text:
Longest Non-Repeating Substring
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 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:

<textarea id="input"></textarea>

<textarea id="output"></textarea>

Proposed test case: 11122324455 Jonathan Allan realized that my first revision didn't handle it correctly.

@Dennis Test case added.  I'm curious as to how that happened.

I generated all substrings (already sorted by length), then deduplicated the substrings and kept those that remained substrings. Unfortunately, that alterates the order; 11122 ocurrs after 324, but gets deduplicated to 12.

I'm wondering where the whitespace answer is.

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! (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:

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!

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!

Haskell, 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!
Golfed literally hundreds of bytes thanks to W W and Ørjan 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

224, mainly by fusing away the intermediate list.

I combined this answer with the one I posted in chat earlier to get 216.

209 by reordering things.

With the bounty announcement I took another look and realized  the @ trick actually costs 2 bytes over just making ? two chars: 207

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.

Jelly, score 2, 14 bytes
Ẇµµff  Q  €  Ṫ

Thanks to @JonathanAllan for score -1, +7 bytes and for noticing a bug.
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.

Retina 0.8.2, 37 bytes, score 9
.
$&$'¶
(.)(?<=\1.+).*

O#$^`
$.&
1G`

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.

Clean, 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! Thanks to @Οurous 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!

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!
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.

You can indeed implement equality using inline ABC, which should reduce the score. I'll come back with a suggested modification later today if you're interested.

Eg: char equality: https://tio.run/##S85JTcz7/z83P6U0J1UhNzEzjys5I7HItbA0MadYwcpKQdEZyIWSunYKTvn5Ocgq4hXiuRSAwFYhOT8lVaEazAGB1EJnMLuWK7gksagEpAChS91RHYT//wcA

@Ourous A code block with raw ABC instructions, which can be used for primitive functions like integer addition, for linking with C, bypassing the type system... welcome down the rabbit hole! (from cloogle) certainly sounds inviting. I'll look into it tomorrow, thanks for the suggestion!

@Οurous Thanks again, with your char equality test the score is now at 5.

Incidentally, you don't need either -IL flag, since nothing is being imported.

Python 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!

The string can be in chunks of 3, right?

@xnor Changing the name of the function, indeed. Thanks!

Brachylog, score 2, 19 bytes
s  ᶠ  l  ᵒ  ≠  ˢ  t

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

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!

Husk, score 2, 10 bytes
►IIËII≠IIQ

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 Is as its argument, but luckily that leads to a type error in our program, so it doesn't happen.

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

I shaved off some space: Try it online!

Alice, 40 bytes
/ii..nn$$@@BBww..DD~~FF..!!nn$$KK??oo@@

(Trailing newline)
Try it online!
The instruction pointer moves diagonally in ordinal mode, so only every other character is executed.
i.n$@Bw.D~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

Jelly, score 5, 10 bytes
ẆµQQ⁼µÐfµṪ

Try it online!

You can lower the score to 3 by adding spaces in your code. For example: ẆµQQ ⁼ µ  Ðf  µ Ṫ (probably added too many spaces now, but it's just an example. I'll leave optimizing byte-count versus spaces up to you).

Python 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!
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 execed (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.

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.

Perl 6, score: 15 10 8, length: 46 55 62 bytes
{~m:ov/(.+)<!{$0.comb.repeated}>/.max(&chars)}

Test it
{~m:ov/(..*)<!{(($0)).comb.repeated}>{{}}/.max(&chars)}

Test it
{m:ov:i/(..*)<!{(($0)).comb.repeated}>{{}}/.max((&chars)).Str}

Test it
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)
}

Score of 5 for 88 bytes. There might be a few places to golf bytes though

Haskell, 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!

f s=snd$maximum[(0<$i,i)|i<-tails=<<inits s,nub i==i] saves a byte and two on the score.

Adding some spaces brings the score down to 7: Try it online!

Kotlin, 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())
}

Aren't you able to reduce it to 10 by adding an additional space between roupingBy and {?

Nice find, I changed the other 11s and and got down to 10

It is 10 chars, but the longest substring isn't roupingBy (which is 9 chars) but eachCount (with trailing space).

roupingBy  has a trailing space (visible in the markdown, but the renderer seems to strip it)

Managed to reduce it to 9, fixing the trimming issue

I think you can remove a lot of whitespace without impacting your score.

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}}))@#&]&

Pyth, score 3 ( 18  14 bytes)
e  fq  T{T  .:

Try it online!
The longest non-repeating substrings is  .:.

A cute-ish alternative: e f  {I  T  .:.

05AB1E, 22 bytes | Score: 2
Œ  ʒ  D  Ù  Q  }  é  ¤

-1 score + 7 bytes thanks to HeebyJeeby
Try it online!

05AB1E, 15 bytes | Score: 3
Œ ʒ D Ù Q } é ¤

Try it online!

05AB1E, 8 bytes | Score: 8
ŒʒDÙQ}é¤

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.

@HeebyJeebyMan because I'm a moron, got a problem with that?

@HeebyJeebyMan kidding haha, thanks for the idea.


text:
How many draws are there in Quarto?
Introduction
This challenge is similar to Project Euler problems. I came up with it because I was playing a deceivingly simple board game and couldn't come up with an efficient solution to answer a simple question about its mechanics.
Quarto is a fun variant of 4 in a row. It is played on a 4 by 4 board with 16 unique pieces (no pieces are duplicated). Every turn each player places 1 piece on the board. Each piece has 4 binary characteristics (short/tall, black/white, square/circular, hollow/solid). The goal is to make four in a row, either horizontally, vertically or along the 2 diagonals, for any of the four characteristics! So 4 black pieces, 4 white pieces, 4 tall pieces, 4 short pieces, 4 square pieces, 4 circular pieces, 4 hollow pieces or 4 solid pieces.

The picture above shows a finished game, there is a four in a row because of 4 square pieces.
Challenge
In Quarto, some games may end in a draw.
The total number of possible end positions is 16!, about 20 trillion.
How many of those end positions are draws?
Rules

The solution must be a program that calculates and outputs the total number of end positions that are draws. The correct answer is 414298141056

You may only use information of the rules of the game that have been deduced manually (no computer assisted proof).

Mathematical simplifications of the problem are allowed, but must be explained and proven (manually) in your solution.

The winner is the one with the most optimal solution in terms of CPU running time.

To determine the winner, I will run every single solution with a reported running time of less than 30m on a MacBook Pro 2,5 GHz Intel Core i7 with 16 GB RAM.

No bonus points for coming up with a solution that also works with other board sizes. Even though that would be nice.

If applicable, your program must compile within 1 minute on the hardware mentioned above (to avoid compiler optimization abuse)

Default loopholes are not allowed

Submissions
Please post:

The code or a github/bitbucket link to the code.
The output of the code.
Your locally measured running time
An explanation of your approach.

Deadline
The deadline for submissions is March 1st, so still plenty of time.

Comments are not for extended discussion; this conversation has been moved to chat.

C: 414298141056 draws found in about 5 2.5 minutes.
Just simple depth-first search with a symmetry-aware transposition table. We use the symmetry of attributes under permutation and the 8-fold dihedral symmetry of the board.
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>

typedef uint16_t u8;
typedef uint16_t u16;
typedef uint64_t u64;

#define P(i, j) (1 << (4 * (i) + (j)))

#define DIAG0 (P(0, 0) | P(1, 1) | P(2, 2) | P(3, 3))
#define DIAG1 (P(3, 0) | P(2, 1) | P(1, 2) | P(0, 3))

u64 rand_state;

u64 mix(u64 x) {
    u64 a = x >> 32;
    u64 b = x >> 60;
    x ^= (a >> b);
    return x * 7993060983890856527ULL;
}

u64 rand_u64() {
    u64 x = rand_state;
    rand_state = x * 6364136223846793005ULL + 1442695040888963407ULL;
    return mix(x);
}

u64 ZOBRIST_TABLE[(1 << 16)][8];

u16 transpose(u16 x) {
    u16 t = 0;
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 4; j++) {
            if (x & P(j, i)) {
                t |= P(i, j);
            }
        }
    }
    return t;
}

u16 rotate(u16 x) {
   u16 r = 0;
   for (int i = 0; i < 4; i++) {
       for (int j = 0; j < 4; j++) {
           if (x & P(3 - j, i)) {
                r |= P(i, j);
            }
       }
   }
   return r;
}

void initialize_zobrist_table(void) {
    for (int i = 0; i < 1 << 16; i++) {
        ZOBRIST_TABLE[i][0] = rand_u64();
    }
    for (int i = 0; i < 1 << 16; i++) {
        int j = i;
        for (int r = 1; r < 8; r++) {
            j = rotate(j);
            if (r == 4) {
                j = transpose(i);
            }
            ZOBRIST_TABLE[i][r] = ZOBRIST_TABLE[j][0];
        }
    }
}

u64 hash_board(u16* x) {
    u64 hash = 0;
    for (int r = 0; r < 8; r++) {
        u64 h = 0;
        for (int i = 0; i < 8; i++) {
            h += ZOBRIST_TABLE[x[i]][r];
        }
        hash ^= mix(h);
    }
    return mix(hash);
}

u8 IS_WON[(1 << 16) / 8];

void initialize_is_won(void) {
    for (int x = 0; x < 1 << 16; x++) {
        bool is_won = false;
        for (int i = 0; i < 4; i++) {
            u16 stride = 0xF << (4 * i);
            if ((x & stride) == stride) {
                is_won = true;
                break;
            }
            stride = 0x1111 << i;
            if ((x & stride) == stride) {
                is_won = true;
                break;
            }
        }
        if (is_won == false) {
            if (((x & DIAG0) == DIAG0) || ((x & DIAG1) == DIAG1)) {
                is_won = true;
            }
        }
        if (is_won) {
            IS_WON[x / 8] |= (1 << (x % 8));
        }
    }
}

bool is_won(u16 x) {
    return (IS_WON[x / 8] >> (x % 8)) & 1;
}

bool make_move(u16* board, u8 piece, u8 position) {
    u16 p = 1 << position;
    for (int i = 0; i < 4; i++) {
        bool a = (piece >> i) & 1;
        int j = 2 * i + a;
        u16 x = board[j] | p;
        if (is_won(x)) {
            return false;
        }
        board[j] = x;
    }
    return true;
}

typedef struct {
    u64 hash;
    u64 count;
} Entry;

typedef struct {
    u64 mask;
    Entry* entries;
} TTable;

Entry* lookup(TTable* table, u64 hash, u64 count) {
    Entry* to_replace;
    u64 min_count = count + 1;
    for (int d = 0; d < 8; d++) {
        u64 i = (hash + d) & table->mask;
        Entry* entry = &table->entries[i];
        if (entry->hash == 0 || entry->hash == hash) {
            return entry;
        }
        if (entry->count < min_count) {
            min_count = entry->count;
            to_replace = entry;
        }
    }
    if (to_replace) {
        to_replace->hash = 0;
        to_replace->count = 0;
        return to_replace;
    }
    return NULL;
}

u64 count_solutions(TTable* ttable, u16* board, u8* pieces, u8 position) {
    u64 hash = 0;
    if (position <= 10) {
        hash = hash_board(board);
        Entry* entry = lookup(ttable, hash, 0);
        if (entry && entry->hash) {
            return entry->count;
        }
    }
    u64 n = 0;
    for (int i = position; i < 16; i++) {
        u8 piece = pieces[i];
        u16 board1[8];
        memcpy(board1, board, sizeof(board1));
        u8 variable_ordering[16] = {0, 1, 2, 3, 4, 8, 12, 6, 9, 5, 7, 13, 10, 11, 15, 14};
        if (!make_move(board1, piece, variable_ordering[position])) {
            continue;
        }
        if (position == 15) {
            n += 1;
        } else {
            pieces[i] = pieces[position];
            n += count_solutions(ttable, board1, pieces, position + 1);
            pieces[i] = piece;
        }
    }
    if (hash) {
        Entry* entry = lookup(ttable, hash, n);
        if (entry) {
            entry->hash = hash;
            entry->count = n;
        }
    }
    return n;
}

int main(void) {
    TTable ttable;
    int ttable_size = 1 << 28;
    ttable.mask = ttable_size - 1;
    ttable.entries = calloc(ttable_size, sizeof(Entry));
    initialize_zobrist_table();
    initialize_is_won();
    u8 pieces[16];
    for (int i = 0; i < 16; i++) {pieces[i] = i;}
    u16 board[8] = {0};
    printf("count: %lu\n", count_solutions(&ttable, board, pieces, 0));
}

Measured score (@wvdz):
$ clang -O3 -march=native quarto_user1502040.c
$ time ./a.out
count: 414298141056

real    1m37.299s
user    1m32.797s
sys     0m2.930s

Score (user+sys): 1m35.727s

Looks like an awesome solution. However, could you expand a bit on your explanation? How do you know the solution is correct?

What compiler flags should be used to time this? I tried with -O3 -march=native and got 1m48s on my machine. (CC @wvdz)

@Dennis, that's what I went with too.

@Dennis I'm no expert on compiling C. I didn't use any compiler flags. I will update my edit.

Java, 414298141056 draws, 23m42.272s
I hope it's not frowned upon to post a solution to one's own challenge, but the reason that I posted this challenge in the first place was that it drove me crazy that I couldn't come up with an efficient solution myself. My best try would take days to complete.
After studying user1502040's answer I actually managed to modify my code to run within a somewhat reasonable time. My solution is still significantly different, but I did steal some ideas:

Instead of focusing on end positions, I focus on actually playing the game, putting one piece after another on the board. This allows me to build a table of semantically identical positions with the correct count.
Realizing the order in which pieces are placed matters: they should be placed such that you maximize the chance of an early win.

The main difference between this solution and user1502040's is that I don't use a Zobrist table, but a canonical representation of a board, where I consider each board to have 48 possible transpositions over the characteristics (2 * 4!). I don't rotate or transpose the whole board, but just the characteristics of the pieces.
This is the best I could come up with. Ideas for obvious or less obvious optimizations are most welcome!
public class Q {

    public static void main(String[] args) {
        System.out.println(countDraws(getStartBoard(), 0));
    }

    /** Order of squares being filled, chosen to maximize the chance of an early win */
    private static int[] indexShuffle = {0, 5, 10, 15, 14, 13, 12, 9, 1, 6, 3, 2, 7, 11, 4, 8};

    /** Highest depth for using the lookup */
    private static final int MAX_LOOKUP_INDEX = 10;

    public static long countDraws(long board, int turn) {
        long signature = 0;
        if (turn < MAX_LOOKUP_INDEX) {
            signature = getSignature(board, turn);
            if (cache.get(turn).containsKey(signature))
                return cache.get(turn).get(signature);
        }
        int indexShuffled = indexShuffle[turn];
        long count = 0;
        for (int n = turn; n < 16; n++) {
            long newBoard = swap(board, indexShuffled, indexShuffle[n]);
            if (partialEvaluate(newBoard, indexShuffled))
                continue;
            if (turn == 15)
                count++;
            else
                count += countDraws(newBoard, turn + 1);
        }
        if (turn < MAX_LOOKUP_INDEX)
            cache.get(turn).put(signature, count);
        return count;
    }

    /** Get the canonical representation for this board and turn */
    private static long getSignature(long board, int turn) {
        int firstPiece = getPiece(board, indexShuffle[0]);
        long signature = minTranspositionValues[firstPiece];
        List<Integer> ts = minTranspositions.get(firstPiece);
        for (int n = 1; n < turn; n++) {
            int min = 16;
            List<Integer> ts2 = new ArrayList<>();
            for (int t : ts) {
                int piece = getPiece(board, indexShuffle[n]);
                int posId = transpositions[piece][t];
                if (posId == min) {
                    ts2.add(t);
                } else if (posId < min) {
                    min = posId;
                    ts2.clear();
                    ts2.add(t);
                }
            }
            ts = ts2;
            signature = signature << 4 | min;
        }
        return signature;
    }

    private static int getPiece(long board, int position) {
        return (int) (board >>> (position << 2)) & 0xf;
    }

    /** Only evaluate the relevant winning possibilities for a certain turn */
    private static boolean partialEvaluate(long board, int turn) {
        switch (turn) {
            case 15:
                return evaluate(board, masks[8]);
            case 12:
                return evaluate(board, masks[3]);
            case 1:
                return evaluate(board, masks[5]);
            case 3:
                return evaluate(board, masks[9]);
            case 2:
                return evaluate(board, masks[0]) || evaluate(board, masks[6]);
            case 11:
                return evaluate(board, masks[7]);
            case 4:
                return evaluate(board, masks[1]);
            case 8:
                return evaluate(board, masks[4]) || evaluate(board, masks[2]);
        }
        return false;
    }

    private static List<Map<Long, Long>> cache = new ArrayList<>();
    static {
        for (int i = 0; i < 16; i++)
            cache.add(new HashMap<>());
    }

    private static boolean evaluate(long board, long[] masks) {
        return _evaluate(board, masks) || _evaluate(~board, masks);
    }

    private static boolean _evaluate(long board, long[] masks) {
        for (long mask : masks)
            if ((board & mask) == mask)
                return true;
        return false;
    }

    private static long swap(long board, int x, int y) {
        if (x == y)
            return board;
        if (x > y)
            return swap(board, y, x);
        long xValue = (board & swapMasks[1][x]) << ((y - x) * 4);
        long yValue = (board & swapMasks[1][y]) >>> ((y - x) * 4);
        return board & swapMasks[0][x] & swapMasks[0][y] | xValue | yValue;
    }

    private static long getStartBoard() {
        long board = 0;
        for (long n = 0; n < 16; n++)
            board |= n << (n * 4);
        return board;
    }

    private static List<Integer> allPermutations(int input, int size, int idx, List<Integer> permutations) {
        for (int n = idx; n < size; n++) {
            if (idx == 3)
                permutations.add(input);
            allPermutations(swapBit(input, idx, n), size, idx + 1, permutations);
        }
        return permutations;
    }

    private static int swapBit(int in, int x, int y) {
        if (x == y)
            return in;
        int xMask = 1 << x;
        int yMask = 1 << y;
        int xValue = (in & xMask) << (y - x);
        int yValue = (in & yMask) >>> (y - x);
        return in & ~xMask & ~yMask | xValue | yValue;
    }

    private static int[][] transpositions = new int[16][48];
    static {
        for (int piece = 0; piece < 16; piece++) {
            transpositions[piece][0] = piece;
            List<Integer> permutations = allPermutations(piece, 4, 0, new ArrayList<>());
            for (int n = 1; n < 24; n++)
                transpositions[piece][n] = permutations.get(n);
            permutations = allPermutations(~piece & 0xf, 4, 0, new ArrayList<>());
            for (int n = 24; n < 48; n++)
                transpositions[piece][n] = permutations.get(n - 24);
        }
    }

    private static int[] minTranspositionValues = new int[16];
    private static List<List<Integer>> minTranspositions = new ArrayList<>();
    static {
        for (int n = 0; n < 16; n++) {
            int min = 16;
            List<Integer> elems = new ArrayList<>();
            for (int t = 0; t < 48; t++) {
                int elem = transpositions[n][t];
                if (elem < min) {
                    min = elem;
                    elems.clear();
                    elems.add(t);
                } else if (elem == min)
                    elems.add(t);
            }
            minTranspositionValues[n] = min;
            minTranspositions.add(elems);
        }
    }

    private static final long ROW_MASK = 1L | 1L << 4 | 1L << 8 | 1L << 12;
    private static final long COL_MASK = 1L | 1L << 16 | 1L << 32 | 1L << 48;
    private static final long FIRST_DIAG_MASK = 1L | 1L << 20 | 1L << 40 | 1L << 60;
    private static final long SECOND_DIAG_MASK = 1L << 12 | 1L << 24 | 1L << 36 | 1L << 48;

    private static long[][] masks = new long[10][4];
    static {
        for (int m = 0; m < 4; m++) {
            long row = ROW_MASK << (16 * m);
            for (int n = 0; n < 4; n++)
                masks[m][n] = row << n;
        }
        for (int m = 0; m < 4; m++) {
            long row = COL_MASK << (4 * m);
            for (int n = 0; n < 4; n++)
                masks[m + 4][n] = row << n;
        }
        for (int n = 0; n < 4; n++)
            masks[8][n] = FIRST_DIAG_MASK << n;
        for (int n = 0; n < 4; n++)
            masks[9][n] = SECOND_DIAG_MASK << n;
    }

    private static long[][] swapMasks;
    static {
        swapMasks = new long[2][16];
        for (int n = 0; n < 16; n++)
            swapMasks[1][n] = 0xfL << (n * 4);
        for (int n = 0; n < 16; n++)
            swapMasks[0][n] = ~swapMasks[1][n];
    }
}

Measured score:
$ time java -jar quarto.jar
414298141056

real    20m51.492s
user    23m32.289s
sys     0m9.983s

Score (user+sys): 23m42.272s