text:
Turn a sentence into a dictionary
For this challenge, you will be given a long string as an input. With this string, you must create a dictionary.
Details:
This dictionary will contain all the words from the string - a word being any sequence of letters surrounded by non-letter characters (ASCII). Letter case of the entries of the dictionary should always be consistent (i.e. all lower case or all upper case, or only the first letter of each word is capitalised). The dictionary can be a list, array, or any other type so long as the words are distinct from each other. Finally, as this is a dictionary, the words must be in alphabetical order, and there may not be any duplicates.
You can assume no contractions will be used (the input will never contain it's, there's, etc.), and that there will always be at least one word
Some examples:
"this is an eXaMpLe of an Input" -> ["an","example","input","is","of","this"]
"Here is another example of an input, this time with Punctuation!" -> ["an","another","example","here","input","is","of","punctuation","this","time","with"]
"290(&79832aAa(*& *79 --=BBBb)bbBb ( x )*d -cxaAa_" -> ["aaa","bbbb","cxaaa","d","x"]

Scoring
Shortest code wins

Are we guaranteed the input will contain at least one word?

May we include the empty word at the start of our dictionary?

yes, it's guaranteed at least one word, I'll update it

Note that in standard computer-science terminology, a "dictionary" data structure is a map: each entry has associated storage of some type beyond the mere fact that it's present.  You're using the common English meaning, which is fine, but real dictionaries have definitions.  This is just a word-list.  Probably fine to leave the title and description as-is, but in programming terms the problem is to tokenize a string into an ordered set of words.

Could you answer @JonathanAllan's question as well, please? And, if we can include it, must we do so consistently?

Should I lemmatize it or not?

@JonathanAllan I'm going to disallow the empty word at the start because the answers that are already posted follow this guideline. As for lemmatizing the dictionary, you don't have to (walked and walk should be different entries)

Is it guaranteed that the input contains non-letters, or is a single word without anything else a valid input?

I suggest a test case where a word is repeated twice ;)

JavaScript (ES6),  57  51 bytes
Returns a Set of words in lower case.
NB: In JS, the elements of a Set are guaranteed to appear in insertion order. In this case, this  is the order defined in the sorted array the Set is built from.
s=>new Set(s.toLowerCase().match(/[a-z]+/g).sort())

Try it online!

Ruby -nl, 33 bytes
p$_.upcase.scan(/[A-Z]+/).sort|[]

Try it online!

Stax, 7 bytes
èñ≤!á~¬

Run and debug it
The output dictionary is produced as a space separated word list.

It would be amazing if Stax's source compression also does Huffman coding.

It doesn't now, but that's an interesting idea...

Pyth, 16 bytes
S{c:r0Q"[^a-z]"d

Try it online!
S{c:r0Q"[^a-z]"d   Implicit: Q=input(), d=" "
    r0Q            Convert input to lowercase
   :   "[^a-z]"d   Regex replace non-alphas with a space
  c                Split on spaces
 {                 Deduplicate
S                  Sort, implicit print

Retina, 24 23 19 bytes
thanks to @FryAmTheEggman and @Neil for -5 bytes!
T`Llp`ll¶
D`
G`.
O`

Try it online!
T`Llp`ll¶ convert the letters to lowercase and everything else to newlines.
D` deduplicates lines.
G`. removes empty lines.
O` sorts the lines.

gawk -F[^a-zA-Z]+, 93 bytes
{for(i=1;i<=NF;i++){if($i!=""){a[tolower($i)]=1}}n=asorti(a,b);for(j=1;j<=n;j++){print b[j]}}

Try it online!
Works for GNU AWK, not regular AWK, due to the use of the asorti function.
The input is split on anything which isn't a letter, leaving the words in $1, $2, etc. We iterate over the numbered variables, and, if they aren't equal to the empty string†, we put them, lowercased, into an associative array a as an index. Once done, we sort the indices of the array a and put the result into an array b. Finally, we print the elements of b, in order.
†We need the test for an empty string, because if the input string ends with a non-letter, the last numbered variable will be an empty string.

This trims off some bytes... {for(;i<NF;)$++i?a[tolower($i)]=1:0;for(;j<asorti(a,b);)print b[++j]}

Japt v2.0a0, 12 11 bytes
Two bytes can be saved if we can include the empty string in the "dictionary". Will update explanation upon confirmation.
v q\L f â n

Try it - Includes all test cases
v f"%a+" â n     :Implicit input of string
v                :Lowercase
  f              :Match
   "%a+"         :  RegEx /[a-z]/g
         â       :Deduplicate
           n     :Sort

Python 3, 89 \$\cdots\$ 61 60 bytes
Saved 2 bytes thanks to 640KB!!!
lambda s:sorted({*re.findall("[a-z]+",s.lower())})
import re

Try it online!

Why the downvote?

Vyxal, 13 bytes
⇩`[a-z]+`$ẎUs

Try it Online!
-3 thanks to Razetime.
+1 because I forgot to sort it.

14: Try it Online!

12: Try it Online!

@Razetime Nice, I forgot I could lowercase it first!

Unless I'm missing something, this doesn't seem to work for testcase #3. Edit: It also doesn't seem to sort the list at any point.

@Underslash Oops, forgot to sort the list. Fixed now.

perl -Mfeature=say -MList::Util=uniq -n, 31 bytes
say for sort@e=uniq lc=~/\pL+/g

Try it online!
Lowercases the input string (read from STDIN), extracts sequences of letters, removes duplicates, sorts and prints them.

Nice! I'm sure there's a way to overuse -F which I might play with later! For this, you can save two bytes removing @e= by swapping sort and uniq: Try it online!

Raku, 29 bytes
{sort unique m:g/<:L>+/».lc}

Try it online!
m:g/<:L>+/ returns an array of match objects, one for each sequence of letters in the input.  ».lc calls the lc (lowercase) method on each of those match objects, coercing them to strings in the process.  sort and unique are self-explanatory, hopefully.

Red, 93 bytes
func[s][a: charset[#"a"-#"z"]sort unique parse lowercase s[collect[any[keep some a | skip]]]]

Try it online!

Perl 5 MList::Util=uniq -F'[^a-zA-Z]+', 27 bytes
say for uniq sort map{lc}@F

Try it online!

05AB1E, 9 bytes
05AB1E has a built-in that I don't even know!
l.γa}ʒa}ê

Try it online!
Explanation
l         Lowercase
 .γ       Group by:
   a}     Is alphabetic?
     ʒa}  Filter: is alphabetic?
        ê sorted uniquify

PostgreSQL, 80 bytes
SELECT regexp_split_to_table(lower($1),'[^a-z]')UNION SELECT''ORDER BY 1OFFSET 1

Input is given as a query parameter and output is given as one word per row. Changing lower to upper outputs in uppercase instead. initcap also works but is 2 more bytes.
Explanation
regexp_split_to_table splits a string based on the regular expression provided.
UNION SELECT'' is used to add the empty string and also remove duplicates.
ORDER BY 1 is used to sort the results
OFFSET 1 is used to not output the empty string.
If the empty string is sometimes allowed, the following 67 byte solution works:
SELECT DISTINCT regexp_split_to_table(lower($1),'[^a-z]')ORDER BY 1

Husk, 13 12 bytes
↓¬uO†_mf√ġK√

Try it online!
-1 byte from Jo King.
Explanation
↓¬uO†_mf√ġK√
         ġK√ Group the input on non alphabet chars
      mf√    filter out non-alphabet chars.
    †_       convert all characters to lowercase
   O         sort in ascending order
  u          uniquify
↓¬           drop all empty strings at the beginning

@Jo King ah, it works since they're ordered. Nice find.

Burlesque, 16 bytes
zz"[a-z]+"~?NB><

Try it online!
Explanation:
zz               # Lowercase input
  "[a-z]+"~?     # Get list of all regex matches
            NB   # Remove duplicates
              >< # Sort

MATL, 13 8 bytes
5 bytes removed thanks to @Sanchises!
k3Y4XXuS

Output is in lowercase.
Try it online! Or verify all test cases.
How it works
k          % Implicit input: string. Convert to lowercase
3Y4        % Push string '[A-Za-z]+' (predefined literal)
XX         % Regexp match. Gives a cell array of substrings
u          % Unique
S          % Sort. Implicit display

Why not k3Y4XXuS?

@Sanchises Thank you! I had completely forgotten about the Y4 literals

Charcoal, 39 bytes
Ｆ⪫  ↧Ｓ¿№βι⊞§υ±¹ι⊞υ⟦⟧≔⟦⟧ζＷ⁻υζ⊞ζ⌊ι✂Ｅζ⪫ιω¹

Try it online! Link is to verbose version of code. Explanation:
Ｆ⪫  ↧Ｓ

Wrap the lowercased input in spaces and loop over the characters.
¿№βι

If this is a letter, ...
⊞§υ±¹ι

... then append it to the last entry, ...
⊞υ⟦⟧

... otherwise start a new entry.
≔⟦⟧ζ

Start a list of unique entries.
Ｗ⁻υζ

While there are more entries, ...
⊞ζ⌊ι

... add the lexicographically first entry to the list of unique entries. This also ends up sorting the deduplicated list.
✂Ｅζ⪫ιω¹

Join the entries back into strings and print all but the first (which is always empty).

Jelly, 14 bytes
13 bytes if we may include the empty word as a leading entry - exclude the trailing Ḋ (maybe?).
11 bytes if we may output an empty word, but not always - exclude ⁸Ż also (probably not).
e€ØẠa⁸Żṣ0ŒlQṢḊ

A monadic Link accepting a list of characters which yields a list of lists of characters.
Try it online!
How?
e€ØẠa⁸Żṣ0ŒlQṢḊ - Link: list of charachters, S       e.g. "I((or))a"
  ØẠ           - Latin alphabet characters               "AB...Zab...z"
e€             - for each (c in S): exists in (ØẠ)?      [1,0,0,1,1,0,0,1]
    a⁸         - logical AND (vectorises) (with chain's left argument = S)       ['i',0,0,'o','r',0,0,'a']
      Ż        - prepend a zero (for S like "abc")       [0,1,0,0,1,1,0,0,1]
       ṣ0      - split at zeros                          [[],['I'],[],['o','r'],[],['a']]
         Œl    - lower-case                              [[],['i'],[],['o','r'],[],['a']]
           Q   - deduplicate                             [[],['i'],['o','r'],['a']]
            Ṣ  - sort                                    [[],['a'],['i'],['o','r']]
             Ḋ - dequeue (remove the empty word)         [['a'],['i'],['o','r']]

J, 44 bytes
Drops the potential empty word, otherwise -4 bytes.
}.@~.@/:~@([;._2~2|1+'@Z'&I.)@toupper@,&'  '

Try it online!
How it works
}.@~.@/:~@([;._2~2|1+'@Z'&I.)@toupper@,&'  '
                                      ,&'  ' append two spaces
                              toupper        one of the few functions, non
                                              J user can guess by name :)
          (          '@Z'&I.)                index into intervals …@](A…Z](_…
                 2|1+                        add 0 and mod 2, so A-Z is 0, else 1
           [;._2~                            partition the string into groups,
                                              each group ends with 1 (exclusive).
                                              the end is based on the last item,
                                              which is space -> 1
      /:~                                    sort the strings
   ~.                                        remove duplicates
}.                                           remove head,
                                              which will be the space group

R, 60 bytes
sort(setdiff(strsplit(tolower(readline()),"[^a-z]")[[1]],"")

Used setdiff to remove possible empty strings, but it deduplicates as well.

Haskell, 88 bytes
import Data.Char
import Data.List
s=sort.nub.words.map f
f x|isAlpha x=toLower x
f _=' '

Replace non-alpha characters with spaces so we can use words to split it.
Try it online!

If you remove the Data.Char import, f x|x>'`',x<'{'=x|x>'@',x<'['=[x..]!!32;f _=' ' saves a single byte :).

Rust, 201 bytes
fn main(){let y=&mut"".into();std::io::stdin().read_line(y);y.retain(|c|c.is_alphabetic()||c==' ');*y=y.to_lowercase();let mut v=y.split(" ").collect::<Vec<_>>();v.sort();v.dedup();println!("{:?}", v)}

Try it online!
fn main(){
    let y = &mut"".into();std::io::stdin().read_line(y); //Get input into string
    y.retain(|c|c.is_alphabetic()||c==' '); //Retain spaces and letters in string
    *y=y.to_lowercase(); //Convert to lowercase
    let mut v=y.split(" ").collect::<Vec<_>>(); //Split string by space and collect into vector
    v.sort(); //sort Vec
    v.dedup(); //delete duplicates (only works on sorted Vec)
    println!("{:?}", v) //debug-print vector (because no std::fmt::Display for Vec<&str>)
}

Haskell, 93 bytes
import Data.List
s=sort.nub.words.map(((do c<-"q69";(" "<*['1'..c])++['a'..'z'])!!).fromEnum)

Try it online!
It's not shorter than the other Haskell answer, but I thought this approach was pretty fun.
It creates a big string like "...               abc...xyz      abc...xyz     ..." so that indexing into this string performs the same mapping as f in the other answer.
I'm including s= because the other answer also is.

Clojure, 59 46 bytes
#(sort(set(re-seq #"[a-z]+"(.toLowerCase %))))

Try it online!
13 bytes saved by NikoNyrh.

Java-interop to .toLowerCase is bit shorter :)

Indeed, I was so frustrated dealing with the fact that Clojure doesn't expose string functions in the core, that didn't even try thinking about interop :)

QuadS, 15 bytes (SBCS)
∪⍵[⍋⍵]
\pL+
\l&

Try it online!
∪ Unique elements of
⍵[…] the data reordered to:
 ⍋⍵ the order that would sort it ascending
where the data is:
\pL+ all runs of Letters
\l& mapped to lowercase

PHP, 82 bytes
$a=array_filter(array_unique(preg_split("/[^a-z]+/",strtolower($argn))));sort($a);

Try it online!
I'm still not satisfied by it, but so far the best I could find.. Yeah array functions names are looooong in PHP :S
The question doesn't ask to display the dictionary, so it's in the footer ;P

05AB1E (legacy), 6 bytes
áмS¡lê

Try it online or verify all test cases.
Explanation:
á       # Only leave letters of the (implicit) input-string
 м      # Remove all those letters from the (implicit) input-string
  S     # Convert the remaining characters to a list of characters
   ¡    # Split the (implicit) input-string on those characters
    l   # Convert everything to lowercase
     ê  # Sort and uniquify the words

NOTE: This doesn't work in the new version of 05AB1E for two reasons:

The ¡ would also keep empty string items.
A single word wouldn't be wrapped into a list, so something like input "test" would result in output "est" due to the ê working directly on this single string instead of a list.

See the result of all test cases in the new version of 05AB1E.

AWK (+"sort" callout), 87 bytes
gsub("[^a-zA-Z]"," ")&&$0=tolower($0){for(;$++a;)!b[$a]++?c=c $a"\n":0;printf c|"sort"}

Try it online!
This AWK version is longer than the entry Abigail submitted (once it's golfed a bit) but it shows a trick I thought was worth highlighting.
gsub("[^a-zA-Z]"," ")&&$0=tolower($0){ ... }

The gsub call translates all the non-alphabetic characters to spaces, then the $0=tolower($0) bit does two things.  It converts everything to lowercase, then the assignment effectively re-maps the string to positional parameters, dealing with all the added spaces.  As a result if $1 was =BBBb)))bbBdb originally, after running through those calls, the data would set $1="BBBd" and $2="bbDdb".
Once the input line has been cleaned up,
for(;$++a;)!b[$a]++?c=c $a"\n":0

loops through all the words via $++a, and for each one increments a frequency counter array for that word b[$a]++.  If the value of that frequency counter is 0, the ternary appends the word plus a LF to an accumulator string.
Then the code prints the accumulated string and pipes it to "sort" with this line.
printf c|"sort"


text:
Friendly Incenters
The incenter of a triangle is the intersection of the triangle's angle bisectors. This is somewhat complicated, but the coordinate formula for incenter is pretty simple (reference). The specifics of the formula do not matter much for this challenge.
The formula requires lengths of sides, so it can be very messy for most triangles with integer coordinates because lengths of sides tend to be square roots. For example, the incenter of the triangle with vertices (0,1), (2,3), and (1,5) is
((2√2+2√17)/(2√2+√5+√17),(10√2+√5+3√17)/(2√2+√5+√17)) (yuck).
A triangle with integer coordinates can have an incenter with rational coordinates in only two cases:

the side lengths of the triangle are all integers
the side lengths of the triangle are a√d, b√d, and c√d for integers a, b, c, and d (equivalent for d=1).

(Meeting at least one of these two conditions is necessary to having a rational incenter, and the former is sufficient. I am not sure if the second case is sufficient)
Challenge
Given a triangle OAB, it meets the "friendly incenter" condition if all of the following are true:

points A and B have nonnegative integer coordinates,
If O is the origin, the distances OA, OB, and AB are either:

all integers or
integers multiplied by the square root of the same integer (a√d, b√d, and c√d as described in the intro).

The triangle is not degenerate (it has positive area, i.e. the three vertices are not collinear)

Based on wording from the sequence tag, your program may

Given some index n, return the n-th entry of the sequence.
Given some index n, return all entries up to the n-th one in the sequence.
Without taking any index, return an (infinite) lazy list or generator that represents the whole sequence.

But what is the sequence? Since it would be too arbitrary to impose an ordering on a set of triangles, the sequence is the infinite set of all triangles that meet the "friendly incenter" condition. You may order these triangles however you wish, for example:

in increasing order of the sum of coordinates
in increasing order of distance from the origin

This sequence must include every "friendly incenter" triangle once and once only. To be specific:

Every triangle must have finite index in the sequence
Two triangles are the same if one can be reflected over the line y=x to reach the other, or the points A and B are the same but swapped.

For example, the triangle with vertices (0,0), (32, 24), and (27, 36) must be included at some point in the sequence. If this is included as A(32,24) B(27,36), then the following triangles cannot be included because they duplicate that included triangle:

A(24,32) B(36,27)
A(27,36) B(32,24)
A(36,27) B(24,32)

Example Output:
If a program opts to output the first n triangles and is given n=10, it may output:

(0,0),(0,4),(3,4)
(0,0),(3,0),(3,4)
(0,0),(3,0),(0,4)
(0,0),(4,3),(0,6)
(0,0),(4,4),(1,7)
(0,0),(7,1),(1,7)
(0,0),(1,7),(8,8)
(0,0),(0,8),(6,8)
(0,0),(6,0),(6,8)
(0,0),(3,4),(0,8)

Of course, the output format is flexible. For example, the (0,0) coordinates may be excluded, or you may output complex numbers (Gaussian Integers) instead of coordinate pairs.

Sandbox

I read it as "Friendly Incrementers" at first

@Arnauld Yes, degenerate triangles are excluded, and (0,0) (0,3) (4,0) is valid

JavaScript (V8),  232  229 bytes
Prints the results as \$X_A,Y_A,X_B,Y_B\$.
n=>{for(o=[0,1,2,k=3];n;)for(z=++k**4;o[A=[x,y,X,Y]=o.map(i=>~~(z/k**i)%k)]|o[[y,x,Y,X]]|o[[X,Y,x,y]]|o[[Y,X,y,x]]|Y*x==X*y|(g=d=>!d||[p,q=X*X+Y*Y,p+q-2*(x*X+y*Y)].some(v=>(v/d)**.5%1)*g(d-1))(p=x*x+y*y)?--z:o[print(A),A]=--n;);}

Try it online!
Commented
n => {                      // n = input
  for(                      // outer loop:
    o = [0, 1, 2, k = 3];   //   o = [0, 1, 2, 3], re-used as an object to store
                            //       the coordinates that were already tried
                            //   k = counter
    n;                      //   loop until n = 0
  ) for(                    //   inner loop:
    z = ++k ** 4;           //     increment k; start with z = k ** 4
    o[  A = [x, y, X, Y] =  //     build the next tuple A = [x, y, X, Y]
          o.map(i =>        //     we try all tuples such that:
            ~~(z / k ** i)  //       0 ≤ x < k, 0 ≤ y < k, 0 ≤ X < k, 0 ≤ Y < k
            % k             //
          )                 //
    ] |                     //     if [x, y, X, Y] was already tried
    o[[y, x, Y, X]] |       //     or [y, x, Y, X] was already tried
    o[[X, Y, x, y]] |       //     or [X, Y, x, y] was already tried
    o[[Y, X, y, x]] |       //     or [Y, X, y, x] was already tried
    Y * x == X * y |        //     or (0, 0), (x, y) and (X, Y) are co-linear
    ( g = d =>              //     or g returns a truthy value:
      !d ||                 //       stop if d = 0
      [                     //       compute the squared distances:
        p,                  //         OA² = p = x² + y² (computed below)
        q = X * X + Y * Y,  //         OB² = q = X² + Y²
        p + q - 2 *         //         AB² = (X - x)² + (Y - y)² = p + q - 2(xX + yY)
        (x * X + y * Y)     //
      ].some(v =>           //       test whether there's any v in the above list
        (v / d) ** .5 % 1   //         such that sqrt(v / d) is not an integer
      ) * g(d - 1)          //       and that this holds for d - 1
    )(p = x * x + y * y) ?  //     initial call to g with d = p; if truthy:
      --z                   //       decrement z
    :                       //     else:
      o[print(A), A] = --n; //       print A, set o[A] and decrement n
  );                        //
}                           //

05AB1E, 54 bytes
∞<€Ðæ4ùÙεœÙ}€`2δôʒnOy`αnOª¬Lδ/tøεεDïQ}P}ày`R*Ë≠*}4ô€н

Outputs the infinite sequence of \$[[x_A,y_A],[x_B,y_B]]\$, although in a different order than the challenge description.
Try it online. (Extremely slow, so will only output the first five triangles before timing out after 60 seconds on TIO.)
Explanation:
∞<             # Push an infinite list non-negative list: [0,1,2,3,4,...]
  €Ð           # Repeat each item three times: [0,0,0,1,1,1,2,2,2,3,3,3,4,4,4,...]
    æ          # Take the powerset of this infinite list
     4ù        # And only keep sublists of length 4:
               #  [[0,0,0,1],[0,0,0,1],[0,0,1,1],[0,0,1,1],[0,0,1,1],...]
       Ù       # Uniquify this list of sublists:
               #  [[0,0,0,1],[0,0,1,1],[0,1,1,1],[0,0,0,2],[0,0,1,2],...]
        ε      # Map each sublist to:
         œ     #  Get all permutations of the current list
          Ù    #  And uniquify it
        }€`    # After the map: flatten it one level down:
               #  [[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1],[1,1,0,0],...]
            δ  # Map over each sublist again
           2 ô #  And split it into parts of size 2
               #   [[[1,0],[0,0]],[[0,1],[0,0]],[[0,0],[1,0]],[[0,0],[0,1]],...]

We now have an infinite list of triangles in all four permutations of the \$A\$ and \$B\$ coordinates (try ∞<€Ðæ4ùÙεœÙ}€`2δô loose).
Minor pet peeve: If the cartesian product builtin would have sorted in the same order as the powerset for infinite lists instead of [[[0,0],[0,0]], [[0,0],[0,1]], [[0,0],[0,2]], [[0,0],[0,3]], ...], this entire first part could have been ∞<ãÙãÙ instead.. :/
Now we keep all valid triangles:
ʒ              # Filter this list of triangles [[a,b],[c,d]] by:
 n             #  Square all inner values: [[a²,b²],[c²,d²]]
  O            #  Sum each inner list: [a²+b²,c²+d²]
   y           #  Push the original triangle [[a,b],[c,d]] again
    `          #  Pop and push both values separated to the stack
     α         #  Take the absolute difference between the coordinates: [|a-c|,|b-d|]
      n        #  Square the inner values: [|a-c|²,|b-d|²]
       O       #  Sum it: |a-c|²+|b-d|²
        ª      #  And append it to the earlier list: [a²+b²,c²+d²,|a-c|²+|b-d|²]
               #  (let's call this list [OA²,OB²,AB²] for now)
 ¬             #  Push the first item OA² (without popping the list)
  L            #  Pop and push a list in the range [1,OA²]
   δ/          #  Divide the values in both lists double-vectorized:
               #   [[OA²/1,OB²/1,AB²/1],
               #    [OA²/2,OB²/2,AB²/2],
               #    ...,
               #    [OA²/OA²,OB²/OA²,AB²/OA²]]
     t         #  Take the square root of each inner value:
               #   [[sqrt(OA²/1),sqrt(OB²/1),sqrt(AB²/1)],
               #    [sqrt(OA²/2),sqrt(OB²/2),sqrt(AB²/2)],
               #    ...,
               #    [sqrt(OA²/OA²),sqrt(OB²/OA²),sqrt(AB²/OA²)]]
      ø        #  Zip/transpose; swapping rows/columns:
               #   [[sqrt(OA²/1),sqrt(OA²/2),...,sqrt(OA²/OA²)],
               #    [sqrt(OB²/1),sqrt(OB²/2),...,sqrt(OB²/OA²)],
               #    [sqrt(AB²/1),sqrt(AB²/2),...,sqrt(AB²/OA²)]]
       ε       #  Map each inner list to:
        ε      #   Map each number to:
         D     #    Duplicate the number
          ï    #    Cast the copy to an integer
           Q   #    And check if it's still the same as before the cast
               #    (which means this number is an integer)
        }P     #   After inner map: check if all are truthy (by taking the product)
       }à      #  After the outer map: check if any are truthy (by taking the maximum)
 y             #  Push the original triangle [[a,b],[c,d]] again
  `            #  Pop and push both values separated to the stack
   R           #  Reverse the second list ([c,d] to [d,c])
    *          #  Multiply the coordinates: [a*d,b*c]
     Ë≠        #  Check that both are NOT the same: a*d != b*c
 *             #  Check if both checks were truthy

And since we've included all four permutations of the triangle coordinates in the infinite list, we fix this after the filter:
}4ô            # After the filter: split the infinite lists into parts of size 4
               # (which are all four the same triangles, but in different permutations)
   €н          # And only leave a single triangle of each quartet (the first)
               # (after which the infinite list is output implicitly as result)

Husk, 42 bytes
foË(fεṁC2gpṁ□)S:Fz-foV≠Fz/fo§=←▲S+m↔m½π4ΘN

Try it online!
This is an infinite list of point pairs [[xA,yA],[xB,yB]].
For some reason TIO refuses to print an initial segment before running out of time, so the link cuts it after 8 elements (the 9th would take too long).
Explanation
First we generate all point pairs.
m½π4ΘN
     N Infinite list of positive integers: [1,2,3..]
    Θ  Prepend zero: [0,1,2,3..]
  π4   Cartesian 4th power: [[0,0,0,0],[0,0,0,1],[1,0,0,0]..]
m½     Split each in half: [[[0,0],[0,0]],[[0,0],[0,1]],[[1,0],[0,0]]..]

Next we discard duplicates.
This is done by creating the list of equivalent point pairs and checking that the current one is the lexicographic maximum.
fo§=←▲S+m↔
fo          Filter by condition:
        m↔    Reverse each: [[yA,xA],[yB,xB]]
      S+      Concatenate with the current point pair: [[xA,yA],[xB,yB],[yA,xA],[yB,xB]]
     ▲        The maximum of this list of 4 points
    ←         and its first element [xA,yA]
  §=          are equal.

Then we remove degenerate triangles by dividing B element-wise by A and checking that the results are distinct.
Husk handles division so that this works out:

Dividing by a nonzero integer gives a rational number by default.
Dividing a positive number by zero gives infinity.
Dividing a negative number by zero gives negative infinity.
Dividing zero by zero gives a special value "Any", which is equal to every finite number, but not equal to the infinities.

foV≠Fz/
fo       Filter by condition:
    F      Fold by
     z/    element-wise division: [xB/xA,yB/yA]
  V≠       This list contains an unequal pair.

Finally, we verify the friendly incenter condition.
This is done by computing the squares of the three sides, dividing out square factors and checking that the results are equal.
foË(...)S:Fz-
fo             Filter by condition:
          F      Fold by
           z-    element-wise subtraction
        S:       and prepend to the point pair: [[xB-xA,yB-yA],[xA,yA],[xB,yB]]
  Ë(...)         The results of ... are equal for these three points.

fεṁC2gpṁ□  Compute (a value corresponding to) d from a point (x,y) of magnitude n√d
       ṁ   Map and sum
        □  square: x²+y²
      p    Prime factors, say [2,2,2,2,2,3,5,5]
     g     Group equal adjacent elements: [[2,2,2,2,2],[3],[5,5]]
  ṁ        Map and concatenate
   C2      splitting into chunks of length 2: [[2,2],[2,2],[2],[3],[5,5]]
fε         Keep singletons: [[2],[3]]

source: Stack Exchange

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

sort: votes


text:
Split pythagorean triples into two sets
Task
Write a program/function that when given a positive integer \$n\$ splits the numbers from \$1\$ to \$n\$ into two sets, so that no integers \$a, b, c\$, satisfying \$a^2 + b^2 = c^2\$ are all in the same set. For example, if \$3\$ and \$4\$ are in the first set, then \$5\$ must be in the second set since \$3^2+4^2=5^2\$.
Acceptable Output Formats:

One of the sets
Both the sets
An array of length \$n\$ where the \$i\$-th element (counting from 1) is one of two different symbols (e.g. 0 and 1, a and b, etc.) which represent which set \$i\$ belongs to.The reverse of this is also fine

Constraints
You can expect \$n\$ to be less than \$7825\$. This is because \$7824\$ is proven to be the largest number to have solution (which also implies that all numbers less than 7825 have a solution).
Scoring
This is code-golf so shortest bytes wins.
Sample Testcases
3 -> {1}
3 -> {}
5 -> {1, 2, 3}
5 -> {1, 2, 3}, {4, 5}
5 -> [0, 0, 0, 1, 1]
5 -> [1, 1, 0, 0, 1]
10 -> {1, 3, 6}
10 -> {1, 2, 3, 4, 6, 9}
41 -> {5, 6, 9, 15, 16, 20, 24, 35}

A checker to verify your output can be found here

Inspired by The Problem with 7825 - Numberphile

Is it guaranteed that a solution exists for all n below 7825? It may be worth clarifying in the challenge

Suggested test case: 41. This is the first value for which this simple but invalid algorithm doesn't work anymore: start with an empty list A; for x = 1 to n: if there's some x in A such that sqrt(x²+n²) also exists in A: leave A unchanged else append x to A; return A.

@LuisMendo Theorem 1. The set {1, . . . , 7824} can be partitioned into two parts, such that no part contains a Pythagorean triple, while this is impossible for {1, . . . , 7825}.
https://arxiv.org/pdf/1605.00723.pdf

@Arnauld added 41 as a testcase

May we output an empty set when $n<5$? (I would assume so.)

@JonathanAllan, that is acceptable

When outputting an array of symbols, is it OK if the array is in reverse order?

@RobinRyder the set can be in any order it does not even have to be sorted

@RobinRyder sorry i misunderstood the question but reverse order is fine

J, 37 bytes
Brute forces through the possible sets, outputs the bit mask.
((-&.#.+./@,)[(e.~+/~)/.*:@#\)^:_@#&1

Try it online! (Also outputs list as numbers for easier comparison.)
How it works
((-&.#.+./@,)[(e.~+/~)/.*:@#\)^:_@#&1
                                  #&1 convert to list of N 1's
(                            )^:_     do until list does not change
                        *:@#\         right: convert to 1,4,9…,N^2
             [                        left: the bit mask
                      /.              partition left based on right, for each set:
                  +/~                 make M*M addition table
               e.~                    any element of that in the same set?
       +./@,                          OR all answers: 1 on conflict, 0 if finished
  -&.#.                               list: from base 2, subtract that^, to base 2

I guess 1,2,4…,N^2 is a typo of 1,4,9…,N^2?

@Bubbler Indeed!

Wolfram Language (Mathematica), 132 116 bytes
{1}.SatisfiabilityInstances[And@@(And[Or@@#,Nand@@#]&/@Map[x,Select[#~Tuples~3,{1,1,-1}.#^2==0&],{2}]),x/@#]&@*Range

Try it online!
This uses Mathematica's SAT solver to label the integers 1 through the input as True and False.

This is composed with Range, so what feeds into the main function is a list of the integers from 1 to the input.
Select[#~Tuples~3,{1,1,-1}.#^2==0&] generates all the Pythagorean triples (multiple times actually, but that's okay).
And[Or@@#,Nand@@#]& is true if at least one, but not all, of the elements of its input is true.
{1}.SatisfiabilityInstances[...,x/@#] uses the SAT solver. Since SatisfiabilityInstances returns a list containing one solution, we use {1}. to get its first element.

Very nice +1! you can use infix notation in ~Subsets~ to save a byte. Also your program must be a function and that costs 3 bytes... Try it online!

@J42161217 My program is a function, I just haven't finished it with &: it's the composition of two functions, {1}.Satisf....,x/@#]& and Range. Your version composes with Range@#& instead which is equivalent to Range, but longer.

My bad, here is a better presentation  131 bytes!

I ended up going with Tuples instead, because #~Tuples~3 is shorter than #~Subsets~{3}. It also generates way more triples, and even after the Select we end up getting {3,4,5} and {4,3,5} separately, but that's fine.

Jelly, 18 bytes
œc3²SHeƊ$Ƈ
ÇŒpÇÞḢQ

Try it online! (too inefficient for \$n>25\$ on TIO).
How?
Strategy: Find all Pythagorean triples using \$[1,n]\$ then find a way to pick 1 element from each of them such that the resulting set contains no Pythagorean triples. That way we have a set which both contains no Pythagorean triple and blocks the other set from having any.
œc3²SHeƊ$Ƈ - Link 1, find all Pythagorean triples: list of integers OR number
œc3        - all combination of length 3 (given n uses [1..n])
         Ƈ - keep those for which:
        $  -   last two links as a monad:
   ²       -     square each of them
       Ɗ   -     last three links as a monad:
    S      -       sum (of the three squares)
     H     -       halved
      e    -       exists in (the squares)?

ÇŒpÇÞḢQ - Main Link: n
Ç       - call Link 1 as a monad -> all Pythagorean triples using [1,n]
 Œp     - Cartesian product -> all ways to pick one from each
    Þ   - sort those by:
   Ç    -   call Link 1 as a monad (empty lists are less than non-empty ones)
     Ḣ  - head
      Q - deduplicate (if n < 7825 this is a valid answer)

Nice! Certainly runs faster than mine, besides being much shorter

What is the purpose of ÇÞ? Isn't the Cartesian product automatically in that order?

No, once $n=26$ the result's first item will contain $6$, $8$, and $10$. (So taking the smallest of each triple is not a valid strategy.)

Oh, I misunderstood how Þ works, and I was about to bring up the counterexample for n=86 ((5,12,13),(12,35,37),(13,84,85))

Is it always possible to pick exactly 1 element from each triple? That doesn't follow just from the two-set partition existing.

I think you're right @MishaLavrov, I'm going to delete for now.

@MishaLavrov I've made an answer which will work (every way to make two sets is considered and both sets of each are evaluated). Now much slower of course.

@MishaLavrov "we wouldn't pick anything else..." if we pick 481 from one of the first three triples what stops us picking another number from the other two? (Also what need do we have to pick 481?)

("Also what need do we have to pick 481?" - Ah I see that we need to pick one of the 3,4,5 multiples). The first question still stands though, we could pick 481, 480, 769 for example.

I see what's confused matters - when we do the Cartesian product we do pick one from each triple but in doing so we can end up picking more than one from some due to repeats. For example when n=13 we can pick both 3 and 5 (e.g. if we pick 3 from (3,4,5) and 5 from (5,12,13) we've still managed to pick two from (3,4,5) - indeed picking {3,5,6} works for 13)

In that case, I retract my objection - assuming that, as you pick more than one due to repeats, you check that you don't end up picking all of a triple eventually. If you have a valid partition into two sets X and Y, you can just, for each triple, pick an element of that triple that's in X. The set Z of all elements picked is a subset of X (so it doesn't contain all of any triple) but contains one element of each triple by construction.

JavaScript (ES6),  118  117 bytes
Much slower for -1 byte.
f=(n,a=[],b=a)=>n?f(n-1,[n,...a],b)||f(n-1,a,[n,...b]):[a,b][E='every'](o=>o[E](x=>o[E](y=>o[E](k=>k*k-x*x+y*y))))&&b

Try it online!

JavaScript (ES6),  122 119  118 bytes
Returns one of the sets as an array.
f=(n,a=[],b=a)=>[a,b][S='some'](o=>o[S](x=>o[S](y=>o[S](k=>k*k==x*x+y*y))))?0:n?f(n-1,[n,...a],b)||f(n-1,a,[n,...b]):b

Try it online!
Solution found locally for \$n=41\$:
[ 5, 6, 9, 15, 16, 20, 24, 35 ]

05AB1E, 14 bytes
Port of the 17 byte Jelly answer. (Læ3ùʒDnO;tå}€н is the same length)
Læ3ùʒnRćsOQ}€н

Try it online!
Explanation
L              Length range
 æ             Powerset
  3ù           Pick truples (length-3 tuples)
    ʒ          Filter:
     n             Square all items
      R            Reverse the list
       ć           Head-extract (head on top)
        s          Swap
         O         Sum the remaining list
          Q}       Equal?
            €н Take head of each

Not sure how to fix it, but it's currently incorrect for certain inputs $\geq26$, just like Jonathan's initial answer. PS: using 3.Æ is faster than æ3ù, although it doesn't matter for the byte-count. :)

Jelly, 30 26 bytes
œ|/L=³
Œc§œ&
ŒP²ÇẸƊÐḟŒcÑƇḢ

Try it online!
How?
This does a more brute-force approach, filtering subsets of [1..n] based on whether they contain any Pythagorean triples. Then, it finds two triple-less subsets that have all n elements between them
œ|/L=³         # Test if a pair of sets unions to [1..n]
œ|/              # Set intersection
   L             # Is the length
    =³           # equal to n?

Œc§œ&          # Does a pair exist that sums to another?
Œc               # Compute all pairs of squares
  §              # Sum each
   œ&            # Set intersection with the set of squares (nonempty & truthy if a pair of squares sum to another square)

ŒP²ÇẸƊÐḟŒcÑƇḢ  # Main link
ŒP               # All subsets of 1..n
     ƊÐḟ         # Remove those where:
  ²                # of the squares,
   ÇẸ              # a pair of the squares exists that sum to another square
        Œc       # All pairs of these triple-less subsets
          ÑƇ     # Filter the pairs by whether they union to [1..n]
            Ḣ    # Head; get the first one

Wolfram Language (Mathematica), 1664 bytes
works for all n (1 to 7824) instantly
IntegerDigits[Uncompress@"1:eJwllsmRHDkMRXWVGfIAKwGYoKtMGAfG/5veT0V0dHVlkiDwN/av//7/87t+/vjhPfem6tm+K6+yqFft5e/e9fXzeH6W62050307NdsTzYtIe/mMApOd/mJY5G/Yn9FdxidPe95uu/lGRNu2+U2n1c6zypfbWza7m80S99pKerF625V9oeNuzW1ywnt92jfZUcXbV94eHrael5Evyo1vHazcy3LPpOa7fXNlmW6d0xF0QXvLBHP+ikf2mKuDBp+1v94BBtvQlEDVdrdRfES8pIPsR1mmfAOUUXdeN2f8DvZzxNFc64c5VWJjPGie0rHls/TaOo4TmoGXtwx4Ry/rHzwDEtbwMwYbMDW2xhkvg18BoPva04zBJqAwisL+AbcLa34OLdSBUGpa1VlDJp3G2wqtA+zTgmz4sTh7YxCVN1RCFYy7x3z5ivIghVhm/s3vBxM6F1S0KJO5k8GpRiuMbRCaRT1eF1NoRSGflb7OUYgJJSYNOoRzyIDMLEaCQgAxNFWsRkq5zPxGDYZLewakSRvgCRNrcJ92EFzis1FSIhnoZ8pYZ3HeA4TJfUwq+RiyB478gA7UA7QgUxl05yvcKDHgOonYOcLfciywwgKLC+ICNSWqFNaLYFEzQ6ANmsEBJ96ZhnEwE5prPX06RBYD20FJPVk6EyrYfOoK3dnniG+kCBBbCY1Ra/FGBfDtMzB/vEItgKMRAYiHqDREkghhA5KiC6jFTp8nGAycUCi+dg6B4ZdSGxMVXb8bGWLYOgQDzFe0fG3wztNPk/edjBV6v5m1uOgvMKCxOwBWtr5OoAYuFmUyTAkdkiNoytgrx32iBDDEjzsfsdQJltIFFnaAQztkUigpUtSiG+Y98Jz56Ejgv0eXhBAiwhtKBVYjqpJdqB8KHPQN60QCRj+gnFWejUKLrUQAuHIcwmUh/sQAYIqxlBAGcHCF2S+pCdPsY/hHMAZKEVBCn9AUeyB0wEcZZClbIEmXLkyZ5YMM5dSobQkJQbjyQoYAE4J05LbAcwpAlJQu8VIKW4M4PsccBJFi4TxOPiyRKUJMcc7LIO1JVgWiwpHoIWA4oTj0Ri2yAqsiQZS6Cm9QIXpLtwCGIU0lb3TzkcyM0iEvsA5mHPLi5OPH/SBx4zj6IeMfwxnC/HQ68ouCiGBS42nw6ErC/eIaJYEQoHIWgIFRSo7QA2ZomqcKfSEKyDdKcsUXPXAlYNf40HqfbCBMzgKVc5pFvs6nxodtJ9xV9+kOITFIVFAfdYMAWrfQY03joC+08pt2kZgpz584m4EWhA4x/I0WHNjo7xBP4ifFGfgf3VIIueRHe0jyaL+rkQhEk6xGhpXi8LlBu4YBYYyAnaAHw1MeBRUXMLoAfK5S3IfisZWE+7jYKN4EGG2SlkBlKICHzEOaLxFKWuMImiBA0bLMAi3IBR/wUNnByvhCD1uTcsJLN04oGBu9SaKGlJFAKs24krEs9NKZ7h0oxTkMTAYUyjn91xAKWMCFv8CZyock+EGWMjCutNANrdZOqY0Z0T66Yr2oJswJ+FBaKHORK8sOAbUuruSWkR5gRbZoLuYPer7CORkDULwUjQgHD++RLKBOR0p3EkvGh0VG4pbCOyt+QBs99V9DtuSl",2][[;;#]]&

Try it online!

R, 99 95 bytes
n=scan():1
f=function(j)outer(a<-n[j]^2,a,`+`)%in%a
while(any(f(i<-sample(!0:1,n,T)),f(!i)))0
i

Try it online!
Outputs a vector of TRUE and FALSE representing in reverse order which set each integer belongs to. (The footer of the TIO transforms this into a list of integers in the first set.)
Works by random sampling: repeatedly draw a random subset of 1:n until neither the subset nor its complement contain any Pythagorean triples (checked by the function f).
It will finish in finite time for any input <7825, but will in expectation take a very long time for largeish n. TIO starts timing out around n=90.

Charcoal, 74 bytes
ＮθＦθＦιＦκＦ⁼Ｘ⊕ι²ΣＸ⊕⟦κλ⟧²⊞υ⊕⟦ικλ⟧≔⁰ηＷ¬ⅉ«≔Ｅυ§κ÷ηＸ³λζ≦⊕η≔Ｘζ²ε¿¬⊙ε⊙ε№ε⁺κμＩ⁻Ｅθ⊕κζ

Try it online! Well, for n<50, otherwise it gets too slow. Link is to verbose version of code. Based on @JonathanAllen's answer. Explanation:
Ｎθ

Input n.
ＦθＦιＦκ

Loop through all potential Pythagorean triples.
Ｆ⁼Ｘ⊕ι²ΣＸ⊕⟦κλ⟧²

If this is indeed a triple,
⊞υ⊕⟦ικλ⟧

then push it to the empty list.
≔⁰η

Start iterating through the ways of picking one element of each triple.
Ｗ¬ⅉ«

Repeat until output has been generated.
≔Ｅυ§κ÷ηＸ³λζ

Pick one element from each triple.
≦⊕η

Increment the loop counter.
≔Ｘζ²ε

Square the elements.
¿¬⊙ε⊙ε№ε⁺κμ

Check for Pythagorean triples.
Ｉ⁻Ｅθ⊕κζ

If none, then output one of the sets.

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


text:
Scoring Quantum Tic-Tac-Toe
In the description of this challenge, the following board will be used as a reference for positions:
ABC
DEF
GHI

For instance, in a game of ordinary tic-tac-toe, B E A C G D F H I describes the following:
-X-   -X-   XX-   XXO   XXO   XXO   XXO   XXO   XXO
---   -O-   -O-   -O-   -O-   OO-   OOX   OOX   OOX
---   ---   ---   ---   X--   X--   X--   XO-   XOX

Quantum Tic-Tac-Toe Gameplay
In quantum tic-tac-toe, players' moves are superpositions of moves in classical tic-tac-toe. Players mark two cells per move instead of just one, and those cells become entangled. Each quantum mark is given a subscript telling the number of the turn in which it was placed.

In the above board, A and B are entangled, and so it is said that X made the move AB: X1 is either in A or B but the true position cannot be known with certainty until later in the game.
Consider the following board, made with the sequence AB BE DE AE (X makes the move AB, O makes the move BE, X makes the move DE, O makes the move AE; note that the relative positions of quantum marks in a cell in the image do not actually matter):

Here, there has arisen a cyclic entanglement between cells A, B and E. Consider the following image, in which a line represents an entanglement:

After a cyclic entanglement (which does not necessarily have length 3) is formed, measurement takes place, in which every quantum mark involved in the cycle collapses into a known state and becomes a classical mark. This includes entanglements like the red one above that are merely accessories to the cyclic entanglement, and don't actually complete the cycle. After one player forms a cyclic entanglement, the other player chooses which state the board assumes. Since X formed the cyclic entanglement, it is up to O to choose between these two states:

There are only ever two possible states to choose from, because all individual entanglements only involve two cells. To record which state was chosen, the following methodology will be used:

Find the first cell (i.e. A takes precedence over B, etc) in the cyclic entanglement which cannot be removed without breaking the cycle (meaning entanglements like the red one above are excluded). In this case this is A.

Write the number of the mark that fills that cell.

Since either X1 or O4 will occupy A, either 1 or 4 will be written. This would mean the above boards would be described by the sequences AB BE DE AE 1 and AB BE DE AE 4, respectively. After measurement occurs, no more moves can be made in A, B, D or E because it is now known what lies in those cells.
A single-cell entanglement, e.g. AA 1, is not allowed under ordinary circumstances, as that would mimic the behavior of a classical mark. This sort of move is only allowed when just one cell not occupied by a classical mark remains.
A game continues until at least one tic-tac-toe is formed or until the board is filled with classical marks. Multiple tic-tac-toes can be made only if they appear simultaneously after a measurement; this is because the presence of one or multiple tic-tac-toes disallows the placement of any additional quantum marks.

Scoring
The first number corresponds to X's score and the second to O's.

If neither player has a tic-tac-toe, then both players get zero points.

If there is only one tic-tac-toe present, then the player with the tic-tac-toe gets one point and the other player gets zero points.

If one player gets two tic-tac-toes after a measurement, then they get two points and the other player gets zero. It is not possible for one player to get one tic-tac-toe while the other gets two, nor is it possible for both players to get two, nor one player to get three.

If both players get a tic-tac-toe after a measurement, then the player with the least maximum subscript in their tic-tac-toe will get one point and the other player will get one half-point.

For clarification on that last point, consider the board made by the sequence AI EG BE EH DG AI 1 BC CE 3:

The maximum subscript in X's tic-tac-toe is seven, while the maximum subscript in O's tic-tac-toe is six. Because of this, O has the least maximum subscript and gets one point while X gets one half-point.

The Challenge
Given a series of moves from a game of quantum tic-tac-toe, determine the score of each player.
Rules

Input and output may be given in whatever form is most convenient, but it must be explained if it differs from what is described above. Changes can be slight, like describing locations or scores differently, or more drastic. For instance, writing the number of the classical mark that fills the cell of the last quantum mark placed can be done instead of writing the number of the mark that fills the first cell alphabetically.

One must always be able to tell which score corresponds to which player. For instance, always putting the winner's score first is not acceptable unless the output also tells which player won or lost. If a specific player's score is always given first, that does not have to be included in the output (as seen in the test cases).

Assume only valid input is given.

Spaces are not necessary; they were added for the purpose of legibility.

This is code-golf so the smallest program in bytes wins.

Test Cases
In: AB
Out: 0 0

In: AI EG BE EH DG AI 1 BC CE 3
Out: 0.5 1

In: IA EG EB EH GD AI 1 CB CE 3
Out: 0.5 1

In: DE AB DE 1 AH CF CH CG BC 2
Out: 1 0.5

In: AE BF EI DH AI 1
Out: 1 0

In: CE BD EG FH CG 1
Out: 1 0

In: AB AD BC CF AC 5
Out: 1 0

In: AB BE BC CE 2 DG HI DF HI 6
Out: 0 1

In: BC BE CF EF 1 AD AG GH DG 6 II 9
Out: 0 0

In: DI AE AB BF EH AH 2 DI 7 CG CG 8
Out: 0 0

In: AD BH EF CI EF 3 HI DG BI 2 AG 1
Out: 2 0

There appear to be no testcases where there is a 3-in-a-row on either diagonal

Switching C with I in the testcase which outputs 0 1 gives an antidiagonal 3-in-a-row, and switching A with G in the same testcase gives a diagonal 3-in-a-row

@fireflame241 I found shorter ones: Main diagonal is AE BF EI DH AI 1 and antidiagonal is CE BD EG FH CG 1

My brain just exploded, or it didn't.. I'll have to make a measure to find out

Python 3.8 (pre-release), 419 371 351 bytes
-48 bytes following suggestions from @ovs
-16 bytes thanks to @JBernardo
def s(C,l=[]):
 l=l+[p:=C.pop(0)]
 if 0==p*0:
  del l[~1];r=[p]
  while r:c=r.pop();l=[r.append(t:=sum(e)-c)or t if e*0!=0and c in e else e for e in l]
 if C:s(C,l)
 else:w=[a:=[sum(z.count(j)>2for z in[*zip(*[[k//3,k%3,k%4,6559>>2*k&3]for k in l[i:f+1:2]if 0==k*0])]for j in set(z))for i in[0,1]]for f in range(9)];a[[1,0]in w]/=1+([1,1]==a);print(a)

Try it online!
Takes input with A-I translated to 0-8 in tuples. The collapse choice is represented by the cell the last entanglement collapses to.
Massive Explanation
# Take input C
# I(k) <==> move k is a collapse, not entanglement <==> 'imag'in dir(k) <==> isinstance(k,int) <==> hasattr(k,'imag')
# I have a feeling that collapses vs entanglements can be encoded in a much more byte-efficient manner
I=lambda k:'imag'in dir(k)
# C: list of moves, where a pair entry (e.g. [0,1]) is entanglement (e.g 0-1).
# and an int entry (e.g 1) states collapse of the last entry, (e.g. [0,1] collapsed to 1)
# l: be the list of entangled/collapsed states, built up with recursion
# pair (e.g. [0,1]) represents an existing entanglement, and int (e.g. 1) represents collapsed state
# the owners alternate XOXOXO in the list
def s(C,l=[]):
 l=l[:] # clone l for array operations
 if C:  # deal with end condition: only recurse if C has any mvoes
  l+=[  # append the first move in C to l
    p:=C[0] # assign p to be the first move
  ]
  if I(p):  # if that move is an int, collapse:
   del l[~1];   # delete the entangled move before
   r=[p]        # r will be the list of location to remove
                # start by adding p to r: no entanglement can have the location p anymore
   # I have a feeling this whole while loop can be replaced with a recursive method
   while r:     # while there is still a location to remove:
    c=r.pop()   # take c to be the first location, so we will collapse all states that contain c
    for i,e in enumerate(l):    # for each state e of l:
     if (1-I(e)  # If it is not a collapsed state
        and c in e): # and it contains c
         r+=[       # add to r:
            sum(l[i])-c     # the location besides e of c
         ];
         l[i]=r[~0] # replace e with that collapsed location
  s(C[1:],l) # recurse without the first move and with the modified l
 else:  # end condition: all moves have been processed
       # for case 5 (begins [[0, 1], [1, 4]...),
       # l=[0, 1, 2, 4, [3, 6], 7, [3, 5], 8] (most states are collapsed, except for [3,6] and [3,5])
  w=[  # w will be a list, supposing everything is collapsed as soon as it is intered,
       # of how many 3-in-a-rows each player has after each move
    a:=     # this is a for loop, so `a` gets set to the *last* 3-in-a-row count (the final win state)
        [
            sum(    # take the sum of:
                z.count(j)>2    # the number of directions that have exactly 3 (more than 2) identical entries
                    for z in    # for each of the 3 directions (rows, cols, diags) in
                        [*zip(*[    # the transpose:
                                [
                                    k//3, # floor divide maps items on each row to the same value
                                    k%3, # mod 3 maps items in the same column to the same value
                                    k%4 # mod 4 maps items on the main diagonal to 0
                                    6559>>2*k&3 # k on antidiagonal to 0; 0,1,7,8 to negative; 3,5 to 1
                                                    # (k in[2,4,6] doesn't work because it also maps all of 0,1,3,5,7,8 to False)
                                ]
                                for k in l[i:f+1:2] # i=0: every even state; i=1: every odd state
                                                    # states limited to from the first f moves
                                if I(k) # only consider the state if it is collapsed
                            ]
                        )]
                    for j in set(z) # take the count for each unique value in the direction
                )
            for i in[0,1] # do this for both player i=0=X and player i=1=O)
        ]
    for f in range(9)   # for each count f of moves from 0 moves to 8 moves, calculate the 3-in-a-row count
  ]
  # now a should be [0,0],[1,0],[2,0],[1,1] or the opposite order
  if[1,1]==a:   # [1,1] is the only case we have to special handle
    a[[1,0]in w]*=.5    # subtract .5 from the second element (O's score) if X got the point first, otherwise subtract from X's score
  print(a)  # finally

A few minor golfs:
I can (probably) be written shorter as I=lambda k:k*0==0.
Copying a list can be done by multiplying by 1: l=l*1.
l[i]=d=sum(l[i])-c;r+=d, saves a few bytes.
You can get your end condition into a single line by using a[[1,0]in w]/=1+([1,1]==a).

@ovs Nice tips! Since I immediately appended to the cloned l, array deconstruction ended up shorter than multiplying by 1.

There is a trailing semicolon on line 8. Also l=l+[p:=C.pop(0)] is one byte shorter

You can shave a lot more on the while loop too: while r:c=r.pop();l=[r.append(t:=sum(e)-c)or t if e*0!=0and c in e else e for e in l]

@JBernardo Good suggestion... much more impactful than the 2 bytes of your previous one :).


text:
Implement Entombed's lookup table
Background
Entombed is an Atari 2600 game released in 1982, with the goal of navigating through a continuous mirrored maze as it scrolls upwards. In recent times, the game has been subject to research — despite the strict hardware limitations of the Atari 2600, it somehow manages to create solvable mazes every time. By disassembling the game's ROM, researchers discovered that this is done with the help of a mysterious lookup table.
When a tile X is to be generated, the game first looks at the states of 5 tiles A, B, C, D, and E which are around it:
$$
\bbox[5px, border: 1px solid white]{\color{white}{\mathsf{x}}}
\bbox[6px, border: 1px solid black]{\mathtt{C}}\,
\bbox[6px, border: 1px solid black]{\mathtt{D}}\,
\bbox[6px, border: 1px solid black]{\mathtt{E}}\\
\;
\bbox[6px, border: 1px solid black]{\mathtt{A}}\,
\bbox[6px, border: 1px solid black]{\mathtt{B}}\,
\bbox[6px, border: 1px solid white]{{\mathtt{X}}}\,
\bbox[10px, border: 1px solid white]{\color{white}{\mathsf{x}}}\,
$$
These five values then index into the following 32-byte lookup table to determine what should appear at X — a wall, an empty space, or either a wall or an empty space, chosen at random:
A B C D E    X
0 0 0 0 0    1
0 0 0 0 1    1
0 0 0 1 0    1
0 0 0 1 1    R
0 0 1 0 0    0
0 0 1 0 1    0
0 0 1 1 0    R
0 0 1 1 1    R
0 1 0 0 0    1
0 1 0 0 1    1
0 1 0 1 0    1
0 1 0 1 1    1
0 1 1 0 0    R
0 1 1 0 1    0
0 1 1 1 0    0
0 1 1 1 1    0
1 0 0 0 0    1
1 0 0 0 1    1
1 0 0 1 0    1
1 0 0 1 1    R
1 0 1 0 0    0
1 0 1 0 1    0
1 0 1 1 0    0
1 0 1 1 1    0
1 1 0 0 0    R
1 1 0 0 1    0
1 1 0 1 0    1
1 1 0 1 1    R
1 1 1 0 0    R
1 1 1 0 1    0
1 1 1 1 0    0
1 1 1 1 1    0

Here R represents a value to be chosen randomly.
Task
Given values for A, B, C, D, and E as input, your program or function should output the correct value for X (either 0 or 1, depending on which row of the table the input corresponds to). However, if the input corresponds to a row in the table with an X value of R, your program should output either 0 or 1 uniformly randomly.
Rules

This is code-golf, so shortest answer in bytes wins.
Your input can be given in any reasonable format, e.g. a list of values, a string with the values in it, an integer in the range [0..31], etc.
When receiving input that corresponds to an X value of R in the table, your output has to be non-deterministic.

@Arnauld Yes. I've amended the input rule accordingly.

May we choose any 2 distinct values for the output?

@Shaggy No. 0 and 1 are the only distinct values that Entombed outputs, so I'd argue that they're the values that your code should output as well, despite the fact that, since 0 and 1 are "falsy" and "truthy", they can normally be eschewed in favor of alternatives.

What is meant by "solvable" in this context? I watched a replay and it seems that at eg. 0:35 there starts a path, which either needed to be dug through right there, or taking other path means digging through  some 5 secs later https://youtu.be/RkvkOfVHayE

@gnudifff It's mentioned in the original paper in the question in the context of an unsolvable maze. "This would spell certain doom for the player, were it not for the free-floating rectangle in the upper right part of the screen. This is a “make-break,” and acquiring these allows the player to make a new piece of maze wall or, more importantly, remove an existing piece of wall." I didn't read the full paper, so I guess the algorithm isn't technically always solvable without the make-break, but that can be ignored for the challenge.

It's a pity that you force the Rs to be output randomly. If we were allowed to choose the output on an R entry, we could simplify the table into a Karnaugh map, which resolves to the simple boolean function X = !C & (!A | !B | !E).

I'm curious, is there a nice argument that mazes made this way are always solvable?

It was my mistake when writing the background text, really, but the algorithm sometimes generates dead ends which require the make-break to get past. I can change that section slightly if it would help to make things more clear.

Jelly, 21 19 15 bytes
ị“£ṅ@kṃżF’b3¤BX

Try it online!
-4 bytes after inspiration from @Neil's Charcoal Answer (binary!).
Try all testcases listed out in a grid (each row is one input tested multiple times).
How?
ị“£ṅ@kṃżF’b3¤BX     # Main link
 “©½B.ọṅc’                # The integer 1719989029560350
          b3              # to base 3: [1,1,2,0,0,2,2,1,1,1,1,2,0,0,0,1,1,1,2,0,0,0,0,2,0,1,2,2,0,0,0,1]
                          # (2 => R; 1 => 1; 0 => 0)
ị           ¤             # Index the input into the base 3 list above
                            # (1-indexed, and 0 gives the last element)
             B            # convert to binary: 2 => [0,1], 1 => [1], 0 => [0]
              X           # Pick a random element from that list

19 byte version
(I personally like this one more because it uses special properties of ị and X)
Try it online!
Try all testcases.
ị“©½B.ọṅc’b3¤Hị1,0X     # Main link
 “©½B.ọṅc’                # The integer 1719989029560350
          b3              # to base 3: [2,2,1,0,0,1,1,2,2,2,2,1,0,0,0,2,2,2,1,0,0,0,0,1,0,2,1,1,0,0,0,2]
                          # (2 => 1; 1 => R; 0 => 0)
ị           ¤             # Index the input into the base 3 list above
                            # (1-indexed, and 0 gives the last element)
             H            # Halve: [2,1,0] => [1,0.5,0]
              ị1,0        # Index into 1,0 (again 1-indexed)
                            # 1 gives 1, and 0 gives 0
                            # 0.5 gives [0,1]; since it is a fractional index, it gives both the element corresponding to floor(0.5) and ceil(0.5)
                  X       # Random; 3 different functions
                            # 0 => 0
                            # 1 => random integer from 1 to 1 => 1
                            # [0,1] => random element of [0,1]

JavaScript (ES6), 47 bytes
Expects an integer in \$[0..31]\$ as input.
Similar to @histocrat's Ruby answer, except that the \$\text{R}\$-mask is left-shifted by 1 position so that we can directly get \$0\$ or \$2\$.
n=>Math.random()*(975060894>>n&2)|67571463>>n&1

Try it online!

JavaScript (ES6),  58 56  49 bytes
Expects an integer in \$[0..31]\$ as input.
n=>(Math.random(k=n*5%62%46%18)*2|k<11)&253553>>k

Try it online!
How?
The input \$n\$ is turned into an index \$k \in[0..17]\$ with the following formula:
$$\big(((n\times 5)\bmod 62)\bmod 46\big)\bmod 18$$
In addition to reducing the size of the lookup table, it isolates all \$\text{R}\$ values at the end of the table, with an index greater than \$10\$.
As a string, the lookup table looks as follows:
10001110011RR0RRRR

Therefore, we can use a bitmask to determine if the answer is either \$0\$ or something else, and the test \$k<11\$ to decide between \$1\$ and \$\text{R}\$.
  n | * 5 | mod 62 | mod 46 | mod 18 | output
----+-----+--------+--------+--------+--------
  0 |   0 |    0   |    0   |    0   |   1
  1 |   5 |    5   |    5   |    5   |   1
  2 |  10 |   10   |   10   |   10   |   1
  3 |  15 |   15   |   15   |   15   |   R
  4 |  20 |   20   |   20   |    2   |   0
  5 |  25 |   25   |   25   |    7   |   0
  6 |  30 |   30   |   30   |   12   |   R
  7 |  35 |   35   |   35   |   17   |   R
  8 |  40 |   40   |   40   |    4   |   1
  9 |  45 |   45   |   45   |    9   |   1
 10 |  50 |   50   |    4   |    4   |   1
 11 |  55 |   55   |    9   |    9   |   1
 12 |  60 |   60   |   14   |   14   |   R
 13 |  65 |    3   |    3   |    3   |   0
 14 |  70 |    8   |    8   |    8   |   0
 15 |  75 |   13   |   13   |   13   |   0
 16 |  80 |   18   |   18   |    0   |   1
 17 |  85 |   23   |   23   |    5   |   1
 18 |  90 |   28   |   28   |   10   |   1
 19 |  95 |   33   |   33   |   15   |   R
 20 | 100 |   38   |   38   |    2   |   0
 21 | 105 |   43   |   43   |    7   |   0
 22 | 110 |   48   |    2   |    2   |   0
 23 | 115 |   53   |    7   |    7   |   0
 24 | 120 |   58   |   12   |   12   |   R
 25 | 125 |    1   |    1   |    1   |   0
 26 | 130 |    6   |    6   |    6   |   1
 27 | 135 |   11   |   11   |   11   |   R
 28 | 140 |   16   |   16   |   16   |   R
 29 | 145 |   21   |   21   |    3   |   0
 30 | 150 |   26   |   26   |    8   |   0
 31 | 155 |   31   |   31   |   13   |   0

Ruby, 35 bytes
->i{[67571463,487530447].sample[i]}

Try it online!
There are 128 different pairs of numbers such that the nth bit is 0 for both when the table's value is 0, 1 for both when the table's value is 1, and different when the table's value is R. So we just choose one of the two at random and take the nth bit.
It seems very likely there's a way to compress this array since we have 128 pairs to choose from, but some quick searching didn't turn it up.

J, 30 28 bytes
Takes in an integer.
>.@?@{&(36bkmh2k8esv#:~32#3)

Try it online! Apparently TIO resets J's random seed every session. If you run it locally, the results of R will change.
How it works
>.@?@{&(36bkmh2k8esv#:~32#3)
        36bkmh2k8esv         base 36 representation of the table
                               with 0 and 1 swapped
                    #:~32#3  back to base 3 (there is usually the
                               shorter 3#.inv, but that would drop the
                               leading 0's.)
     {                       get the corresponding entry
   ?                         roll: 1 -> 0
                                   2 -> 0 or 1
                                   0 -> open interval (0,1)
>.                           round up the floats from 0.… to 1

Charcoal, 20 19 bytes
‽⍘Ｉ§”)∨‴)Ｃ]!P"”↨²Ｓ²

Try it online! Link is to verbose version of code. Takes input as a string of five bits. Explanation:
    ”...”       Compressed string
   §            Indexed by
           Ｓ    Input string
         ↨²     Converted from base 2
  Ｉ             Cast to integer
 ⍘          ²   Converted to base 2
‽               Random element
                Implicitly print

The compressed string contains 2 where either 0 or 1 is allowed. This converts to base two as 10 thus giving the randomisation operator a choice.

Python 3, 66 bytes
lambda n:randint(67571463>>n&1,487530447>>n&1)
from random import*

Try it online!

Retina, 55 bytes
~`.+
K`111R00RR1111R000111R0000R01RR000¶$&L`.
R
10
@L`.

Try it online! Link includes test cases. Explanation:
.+
K`111R00RR1111R000111R0000R01RR000¶$&L`.

Replace the input by Retina code that takes the nth character of the lookup table.
~`

Evaluate that code.
R
10

Change R to 10.
@L`.

Output a random character.

Excel, 63 56 55 bytes
Cell A1 (33 bytes):
=MID(BASE(940349744638137,3),A2,1

Cell B1 (Output Cell, 22 bytes):
=--IF(A1-2,A1,.5<RAND(

-8 thanks to @Calculuswhiz
Input goes into cell A2. Input is 1 indexed rather than 0 indexed, and needs to be in the range \$[1, 32]\$
But How?
Well, lets first look at cell A1. This is where the row lookup is performed.
     BASE(940349744638137,3)        | Produces the number 11120022111120001112000020122000
=MID(                       ,A2,1   | Indexes that number at the position in A2 (input)

Then, we go to cell B1 (the output cell). This is where we check if we need to pick a random number.
    IF(A1-2,                | Coerce A1 to Number and subtract 2 from it.
            A1,             | If A1 isn't 2, condition is nonzero->TRUE. Set to A1.
               .5<RAND(     | Otherwise, pick FALSE or TRUE at random
=--                         | Coerce Boolean to Number, or do nothing to Number

Where's the Closing Brackets?!?
Not needed. That's where. ;P

Also, how about (RAND()>.5)+0?

Or even better: =--IF(A1-2,A1,.5<RAND(

Japt, 20 bytes
Takes input as 0-31.
g`qn77sq5p`nH ì3)¤ö

Try it - includes all test cases

05AB1E, 15 bytes
•3-aáδÜ[•3вbIèΩ

Input as an integer in the range \$[0,31]\$.
Try it online or verify all test cases.
Explanation:
•3-aáδÜ[•  # Push compressed integer 940349744638137
 3в        # Convert it to base-3 as list:
           #  [1,1,1,2,0,0,2,2,1,1,1,1,2,0,0,0,1,1,1,2,0,0,0,0,2,0,1,2,2,0,0,0]
   b       # Take the binary string of each, converting the 2s to 10s:
           #  [1,1,1,10,0,0,10,10,1,1,1,1,10,0,0,0,1,1,1,10,0,0,0,0,10,0,1,10,10,0,0,0]
    Iè     # Index the input-integer into this list
      Ω    # And pop and push a random digit of this integer
           # (after which it is output implicitly as result)

See this 05AB1E tip of mine (sections How to compress large integers? and How to compress integer lists?) to understand why •3-aáδÜ[• is 940349744638137 and •3-aáδÜ[•3в is [1,1,1,2,0,0,2,2,1,1,1,1,2,0,0,0,1,1,1,2,0,0,0,0,2,0,1,2,2,0,0,0].

C (gcc), 81 \$\cdots\$ 66 52 bytes
Saved 2 bytes thanks to ceilingcat!!!
Saved a whopping 14 bytes thanks to Neil!!!
f(n){n=(n=0x29200950255a095l>>n*2&3)<2?n:time(0)&1;}

Try it online!
Inputs an integer in the range \$[0,31]\$ and returns either \$0\$, \$1\$, or one of them randomly.
Uses the bits of a long int to map each return value to 2-bits.

Would returning time(0)%2 be sufficiently random?

@Neil Don't see why not since we're seeding the random generator with time() it's consistent across seconds anyway. ¯\(ツ)/¯

Vyxal r, 14 bytes
3»∧l%≥D⋎v»τiB℅

Try it Online!
Takes input as a number.


text:
Metagolf the OEIS
We've had Meta Regex Golf and Display OEIS Sequences. Now, it is time for Meta OEIS Golf.
Challenge
Given a sequence of integers, your program/function should output a program/function in the same language that then outputs the same sequence.
A simple example in Python would be
def f(sequence):
  # generate a dictionary/table lookup
  dc = {index: element for (index, element) in enumerate(sequence)}
  s = "lambda n: " + repr(dc) + "[n]"
  # at this point, eval(s) gives a lambda function, so
  # eval(s)(n) = sequence[n] = n-th element of sequence
  # as required
  return s

The function f takes as input a sequence of integers and outputs the source code to a lambda function. When the lambda function is called on an index n, it outputs the n-th element of that sequence.
Try it Online
Output
The program that is output should be able to be submitted as an entry on this site for a code-golfsequence challenge. Hence, it could be a program or function and can use one of the following input/output methods (from the sequence tag):

Indexing: Allowed are both 0- and 1-based indexing, and the following rules can be applied with both these types of indexing.
Output:

Given some index n it can return the n-th entry of the list.
Given some index n it can return all entries up to the nth one in the sequence.
Without taking any index, it can return a (potentially infinite) lazy list or generator that represents the whole sequence.

Behavior past the final given term in the sequence is undefined. For example, your program may be given A000004 as
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0

This consists of 101 0s. The generated program must then output 0 for each n from 1 to 101 (assuming 1-indexing), but it can output anything (even a string or non-integer) for n=102 and onward. Consequently, the generated program can output an infinite generator, as long as the first 101 terms are right.
Scoring
Your score will be the sum of your program's length and the length of all 100 programs it generates from the A000001 to A000100 sequences (the program does not necessarily have to work for other sequences). This file has sequence A000001 on line 6, A000002 on line 7, in order up to A000100 on line 105, so each sequence is one line. The sequences have varying number of terms; for example, A000066 (line 71) only has 10 terms.
The ungolfed Python example above would score 46713 + 261 = 46974 points.
If the program outputs an auxiliary file (I'm not sure how this could help, but it might come into play), then follow the part of this ruling before the horizontal line.
Lowest score wins, as usual.

@FryAmTheEggman Not all sequences are the same length. It's whatever http://oeis.org/stripped.gz had available. I'll mention the file format in the question

Should I/O methods be the same for all generated programs?

@Arnauld Not necessarily. Think of each generated program as a separate, independent code golf submission, so one could be 0-indexed and return the n-th element, another could be 1-indexed and return the first n elements, etc.

I assume if the program writes a file to disk which is used by the others, that file gets counted 100 times?

Does the program have to behave correctly on inputs other than those 100 sequences?

@SteveBennett Yes, that file would be counted 100 times

@SteveBennett No, the program can fail for other inputs as longs as it behaves for the 100-sequence battery

You should clarify that in the statement of the challenge.

Yes, I'm adding it in now

Ok, so one of the terms is 24637809253125004524383007491432768. In Javascript, that's well beyond the range of an integer. So can I assume that the input to the program will be an array of strings?

@SteveBennett Ah, I did not catch that since Python has arbitrary precision integers. Yes, you can take input as an array of strings

I think the test set is too small here (it's not hard enough to write 100 programs)

100 is a pretty painful amount. If it was 10, you could happily hand-code 10 solutions and focus on golfing. If it was 10,000, you'd have to find a way to automatically respond to the input. But 100 is sort of painfully many to hand-code, but too few for an automatic approach to be competitive.

JavaScript (Node.js),  15604 15329 15204  944 + 14168 = 15112
Saved 2 bytes thanks to @Neil
The main program expects an array of BigInt's. Each generated program expects a 0-indexed integer and returns the nth term as a Number, a BigInt or a string.
a=>eval(require('zlib').inflateRawSync(Buffer.from('lZRNb9pAEIZ/CxHYO94PbFfJwWKxVNpKPbSXHh1LXn8IUicTBDRKheG3d3ZtCKW5VELGO/vO+JnZ185Qz0NBF7bUtZ7XnsdwUs8i4EtWywiAcY4wCFo9x3RJkVag1H1GO5GypmANST2LgbUASQsshiBQt50rzUc4FGAoWo1AWVLSk1aaGVHSskxXrBRmUkJibBGSWQD7RwseOYDIXXhfC7nvQxbmQ2wSuxvPbSLn8sjQAnB163Lj4MzwX01cc4/aDmdhGia2BAWlGxTKlkiTiFih6xynH/lq06wbszvzUx1Dz5aSUjND7JwdjyaLc88zWZSDtKsozoVSyuQ0CZIAszsnin5YfQUaF7fjAhaKYT48DoJTl9h3KSXSQcQoCRJ4hEmMwD4+LL8icYFLo/Odsm9mt1KfZQxd+P6YVq6i541WDD10xhiGFF3hHd/jk9GFSFQXXVRWx6tBeerlrBT1X9q6V/P6rD9lXPRO6MfW2YvWI+w6DIjaMSNM7W0ctDCljJZWzmltvzuf98XIO9HJvRjQCX4g+RWXaK7IGhEHDa9lReVLaS4JRQy52j4/NeyLnhvVvDSb34y9CGupF63ZQn+xbADpgnydFPSk8b7UoVjoIhvvjXoya0bB77+eymZjj9L3tcYUEz989Tmq3fOP3eYBCUVHd7SLPqifzw9YiOKQF6JMF0nW+6+v97ZnXfpoqoZNWTob3dedBKYE7O/EQbFU33+C6VJsqfOt3r5pBQXpBYQsDvO0IMOGr+P94KstvOEQzMG+qkViRTfj/fZwU9Ckje576hsiIy5ZH6j0XLI1/XRF0bUOgbo57ay55pUL+pcJg/wftdSD2M5+s2ODQY16bHC5W8lyuLHfkUOGefEH','base64'))+'')

Try it online!
How?
Most sequences are stored as arrays, using several compression strategies:

Large integers are stored as BigInt's in hexadecimal notation.
/* before */ 805381710463762432000n
/* after  */ 0x2ba8ea9e9255100000n

Spread syntax is used on lists of at least 7 consecutive single-digit, positive entries. If there are more than 20 digits, the string is turned into a BigInt in hexadecimal notation.
/* before */ 1,0,1,0,1,1,1,1,1,1,3,1,3,1,3,3,3,3,3,3,6,3,6,3,6,6,6,6,6,6
/* step 1 */ ..."101011111131313333336363666666"
/* step 2 */ ...0x146626ecaafee6bfa04ca8cean+''

Positive or negative delta-encoding is used if it turns out to be shorter.
[...].map(c=>p+=+c,p=0) /* or */ [...].map(c=>p-=c,p=0)

Dedicated functions are used for a couple of easy sequences:
/* A000004 */ n=>0
/* A000005 */ n=>(g=d=>d&&(n%d<1)+g(d-1))(++n)
/* A000006 */ n=>(g=k=>n?g(++k,n-=(g=d=>k%--d?g(d):d<2)(k)):k)(2)**.5|0
/* A000007 */ n=>+!n
/* A000010 */ n=>(g=(n,k=n)=>k--&&(h=(a,b)=>b?h(b,a%b):a<2)(n,k)+g(n,k))(n+1)
/* A000012 */ n=>1
/* A000027 */ n=>1+n
/* A000030 */ n=>(n+'')[0]
/* A000034 */ n=>1+n%2
/* A000035 */ n=>1&n
/* A000037 */ n=>n++-~(n**.5+.5)
/* A000038 */ n=>2*!n
/* A000040 */ n=>(g=k=>n?g(++k,n-=(g=d=>k%--d?g(d):d<2)(k)):k)(2)
/* A000041 */ n=>(g=(n,k=n)=>!k|n<0?0:n?g(n,k-1)+g(n-k,k):1)(n)||1
/* A000042 */ n=>'1'.repeat(n+1)
/* A000044 */ n=>(g=a=>n--?g([a[0]+(~~a[2]&&a[1])-~~a[12],...a]):a[0])([1])
/* A000045 */ n=>(g=(a,b)=>n--?g(b,a+b):a)(0,1)
/* A000051 */ n=>1+2**n
/* A000058 */ n=>(g=n=>n?g(--n)**2n-g(n)+1n:2n)(BigInt(n))
/* A000062 */ n=>++n/(Math.E-2)|0
/* A000069 */ n=>(g=k=>n?g(++k,n-=(h=n=>n&&!h(n&n-1))(k)):k)(1)
/* A000071 */ n=>(g=(a,b)=>~n--?g(b,a+b):a)(0,1)-1
/* A000073 */ n=>(g=(a,b,c)=>n--?g(b,c,a+b+c):a)(0,0,1)
/* A000078 */ n=>(g=(a,b,c,d)=>n--?g(b,c,d,a+b+c+d):a)(0,0,0,1)
/* A000079 */ n=>2**n
/* A000085 */ n=>(g=k=>~k&&(h=n=>!n||n*h(n-1))(n)/h(n-2*k)/2**k/h(k)+g(k-1))(n>>1)
/* A000093 */ n=>n**1.5|0
/* A000096 */ n=>n*(n+3)/2
/* A000100 */ n=>(g=(a,b,c,d,e)=>n--?g(b,c,d,e,2*e+d-c-2*b-a):a)(0,0,0,1,2)

I think A000007 is n=>+!n and A000038 is n=>2*!n, if it helps.

TIL: zlib is a standard part of node.

@SteveBennett And so is Brotli in more recent versions. Brotli compresses this code more effectiently, but it's not supported on TIO. (As you mentioned earlier, this could be optimized endlessly anyway.)

What if you brotli or zlib compress the resulting programs as well? :)

@mypronounismonicareinstate Given the length of the decompression code and the base-64 encoding overhead, that would basically make everything longer, unfortunately.

Buffer.from can just be Buffer, I think

05AB1E, score 20925 11038 10270 (110 + 10160 output bytes)
ÙgiнëW0‹iWÄDU+}¬_iÌ2U}Z>©β®X)I‚εNVεƵ0ƵÿŸyåiƵ0-₅B‘Ƶ‘ìë₅Byт‹Y≠*iyëDg<i‘Ž‘ìë‘•‘.ø}}}}YiJ')«ë`'вsXi\ë'-}J}}éн}„IèJ

-768 score thanks to a tip of @JonathanAllan.
Takes each input sequence as a list of integers.
Resulting programs take an integer \$n\$ as input and output the 0-based \$n^{th}\$ value in the sequence (although outputting the first \$n\$ values instead of \$n^{th}\$ value would be the same byte-count by replacing the trailing è with £ in all output programs).
Test suite to verify the results or try a single output program with \$n\$ input (which currently uses the first A1 program).
Explanation of the generator program:
Ùgi                            # If all values in the (implicit) input-list are the same:
   н                           #  Only leave that unique value
  ë                            # Else:
   W                           #  Get the minimum (without popping)
    0‹i     }                  #  If this minimum is negative:
       WÄ                      #   Take the absolute value of this minimum
         DU                    #   Store a copy in variable `X` (1 by default)
           +                   #   And add it to each value in the list
   ¬_i   }                     #  If the first value is 0 (without popping)
      Ì                        #   Increase each value in the list by 1
       2U                      #   And store 2 in variable `X` (1 by defaul)
   Z                           #  Get the maximum of this new list (without popping)
    >                          #  Increase this maximum by 1
     ©                         #  Store it in variable `®` (without popping)
      β                        #  Convert the list from base-`®` to an integer
       ®                       #  Push `®`
        X                      #  Push `X`
         )                     #  Wrap all three values into a list
   I‚                          #  Pair it with the input-list
     ε                         #  Map both inner lists to:
      NV                       #   Store the outer map-index in variable `Y`
      ε                        #   Map all three values to:
       Ƶ0ƵÿŸ                   #    Push a list in the range [101,355]
            yåi                #    If the current value is in this list:
               Ƶ0-             #     Subtract 101 from the value
                  ₅B           #     Convert that to a base-255 string
                    ‘Ƶ‘ì       #     And prepend a "Ƶ"
              ë                #    Else:
               ₅B              #     Convert it to a base-255 string
                 yт‹           #     If the current value is less than 100
                 Y≠*i          #     and `Y` is NOT 1:
                     y         #      Just leave the current value as is
                    ë          #     Else:
                     Dg<i      #      If the length of the base-255 string is 2:
                         ‘Ž‘ì  #       Prepend a "Ž"
                        ë      #      Else:
                         ‘•‘.ø #       Surround the base-255 string with "•"
     }}}}                      #   Close the inner map and three if-else statements
         Yi                    #   If `Y` is 1 (thus the second map-iteration):
           J                   #    Join all individual compressed strings together
            ')«               '#    And append a trailing ")"
          ë                    #   Else (thus the first map-iteration):
           `                   #    Dump all three values separated to the stack
            'в                '#    Push "в"
              s                #    Swap the top two values on the stack
               Xi              #    If `Y` is still the default 1:
                 \             #     Discard the mapped value of `Y`
                ë              #    Else:
                 '-           '#     Push a "-"
                }J             #    After this if-else statement: join the stack together
     }}                        #  Close the if-statement and outer map
       é                       #  Take the shortest compressed list by first sorting on length
        н                      #  and then pop and pushing its first (shortest) string
   }                           # Close the outer if-statement
    „IèJ                       # And append "Iè" at the end of the string
                               # (after which the generated program is output implicitly)

This will result in one of the following programs:

abвIè: This is the base program template, where a and b are both a (compressed) integer, in one of the following forms:

d/dd: A hard-coded integer, where d is a digit (when below 100)
•...•: A large compressed integer, where ... are three or more 05AB1E characters (when above 65024)
Ƶ.: A small compressed integer, where . is a single 05AB1E character (when within the range [101, 355])
Ž..: A medium compressed integer, where .. are both 05AB1E characters (when within the range [356, 65024])

abвc-Iè: Similar as above, but c is a (compressed) integer as well.
dIè: Where d is a digit.
abc...xyz)Iè: Where [a,z] are each compressed integers in the form of 1.2, 1.3, or 1.4. And we also use compression method 1.2 instead of hard-coded 1.1 integers, since we join everything together at the end.

The third program type is used for the two sequences of the same integer. I could have also just used 0 instead, but the generator program would increase by more than it would save in that case.
See sequences A4 and A12.
The second program type is used for sequences that either start with a leading 0, or contain negative values. Neither of which can be compressed by the 05AB1E base-conversion list compression I'm using.
See sequences A1; A25; A30; A35; A36; A39; A45; A65; A71; A72; A76; A93; A94; A96; and A100.
The fourth program type is used for if that method is shorter for the sequence than any of the other three program types.
See sequences A11; A14; A18; A21; A22; A23; A24; A33; A42; A49; A50; A55; A58; A60; A63; A75; A78; A80; A81; A83; A84; A85; A87; A88; and A90.
All other sequences use the default first program type.
See sequences A2; A3; A5; A6; A7; A8; A9; A10; A13; A15; A16; A17; A19; A20; A26; A27; A28; A29; A31; A32; A34; A37; A38; A40; A41; A43; A44; A46; A47; A48; A51; A52; A53; A54; A56; A57; A59; A61; A62; A64; A66; A67; A68; A69; A70; A73; A74; A77; A79; A82; A86; A89; A91; A92; A95; A97; A98; and A99.
See this 05AB1E tip of mine (sections How to compress large integers? and How to compress integer lists?) for a bit more in-depth information of how the compressed integers and compressed lists work.

You can probably save quite a few output bytes if you replace the output program with something like the following if it is shorter: get the nth item from a list of base 255 integers (or if the separator between elements takes more than one byte consider spliting a compressed strings on 0 bytes and then converting each from base 254) For example A33 has 179 bytes between the first compressed value indicators, but the sum of the lengths of all 22 items in base 254 is only 87, and only 21 0s would be required. There seem to be a fair few sequences that would benefit from this strategy.

Javascript (Node) 40 + 21058 = 21098
z=>`i=>[${z.map(x=>x===+x+''?x:x+'n')}]`

Takes inputs as arrays of strings, outputs a program which outputs an array containing numbers and BigInts.
Javascript (Node) 14 + 20852 = 20866
z=>`i=>[${z}]`

It seems to be acceptable for the generated programs to return an array?
Javascript (Node) 17 + 21152 = 21169
z=>`i=>[${z}][i]`

I'm not sure I entirely understood the challenge? Given an array ([1,2,3]), it outputs:
i=>[1,2,3][i]

This is a valid program, but it (probably) doesn't get a very good score.

I guess it's yet another challenge for the languages with built in compression/decompression routines.

Oh, turns out it's not a valid program. Some of the terms are too big for integers.

My intention is that some of the sequences are constant or have a simple representation, such as a(n)=n, so a program can detect that and respond accordingly

Yeah. It feels like a challenge with an extraordinarily long series of possible optimisations of diminishing returns. Every single one of the 100 sequences is a candidate for detecting and outputting a generator (and then golfing each of those).

@SteveBennett Name a good [code-golf] challenge that doesn't have an extraordinarily long series of possible optimisations of diminishing returns.

In my experience, after a couple of hours on most of them, it quickly becomes hard to find further optimisations. They might exist, but finding them is the challenge. Whereas here, it could take a very long time to get to that point.


text:
Is this a valid Shakashaka solution?
Background
Shakashaka is a puzzle on a grid, whose objective is to place some half-squares (right triangles) on the empty cells so that all the remaining contiguous regions form rectangles, either upright or 45 degrees rotated. Here is an example puzzle with a solution:

Ignore the number clues for this challenge.
Challenge
Given a grid with black squares and half-squares placed on some of the cells, determine if it is a valid solution to some Shakashaka puzzle, i.e. all the white regions form rectangles.
The input is a 2D grid (in any valid form) with each cell containing its encoded state. Each cell will be in one of the six states: white square (empty), black square, and four possible orientations of the half-square (NW, NE, SW, SE). You may encode them as six distinct numbers or (possibly multi-dimensional) arrays of numbers, and you can use characters instead of numbers (so strings or string arrays are also acceptable).
Standard code-golf rules apply. The shortest code in bytes wins.
Test cases
Because it is pretty hard to reproduce a Shakashaka board with Unicode chars, I include a Python script to convert the input to any form of your choice. The default configuration renders them using Unicode geometric shapes, so you can roughly see how the actual grid will look like.
def gentest(tc,mapping,charjoin='',linejoin='\n',preamble='',postamble=''):
  return preamble+linejoin.join(charjoin.join(mapping[x] for x in line.split())for line in tc.strip().splitlines())+postamble

Try it online!
How to use it
tc - the testcase string, which will be supplied in the footer
mapping - the dict of 6 keys 'B', 'W', 'NE', 'NW', 'SE', 'SW' mapped to
          6 distinct strings
          'B' is filled (black) square, 'W' is white square,
          the rest four represent half-cell filled in that direction
charjoin - string to insert between each cell on a horizontal line
linejoin - string to insert between each line of cells
preamble - string to add in front of the entire grid
postamble - string to add at the end of the entire grid

Alternatively, you can use this Stack Snippet kindly written by @Arnauld to better visualize the test cases (it shows the 10 test cases by default):

function draw2() { let grids = document.getElementById("in").value.split('\n\n').map(g => g.split('\n').map(r => r.split(/ +/))), out = ""; grids.forEach(g => { out += '
'; g.forEach(r => { r.forEach(s => { out += '

'; }); }); out += '
'; }); document.getElementById("out").innerHTML = out;}window.onload = () => { document.getElementById("in").value = [ "NW NE W W B W NW NE NW NE", "SW W NE NW NE B SW SE SW SE", "B SW SE SW SE W NW NE B W", "W NW NE NW NE W SW W NE W", "NW W SE SW SE B W SW SE B", "SW SE B B W W NW NE NW NE", "B NW NE W B NW W SE SW SE", "NW W W NE W SW SE B NW NE", "SW W W SE B NW NE NW W SE", "B SW SE W W SW SE SW SE B", "", "W W W", "W W W", "W W W", "", "NW NE W", "SW SE W", "W W B", "", "B B B", "B B B", "B B B", "", "SE", "", "W NW", "NW W", "", "NW W SE", "", "W NW NE W", "NW W W NE", "SW W B SE", "W SW SE W", "", "B W", "W W", "", "W NW NE B", "NW W W NE", "SW SE SW SE" ].join('\n'); draw2();};
textarea { width: 400px; } #wrapper, .wrapper { border-left: 1px solid #555; border-top: 1px solid #555; margin-top: 10px; } .cell { float: left; width: 16px; height: 16px; border-right: 1px solid #555; border-bottom: 1px solid #555; overflow: hidden; } .NW { width: 0; height: 0; border-right: 16px solid #fff; border-top: 16px solid #00b496; } .SW { width: 0; height: 0; border-right: 16px solid #fff; border-bottom: 16px solid #00b496; } .NE { width: 0; height: 0; border-left: 16px solid #fff; border-top: 16px solid #00b496; } .SE { width: 0; height: 0; border-left: 16px solid #fff; border-bottom: 16px solid #00b496; } .W { width: 16px; height: 16px; } .B { width: 16px; height: 16px; background-color: #000; }
<textarea id="in" oninput="draw2()"></textarea>

Truthy test cases
# The 10x10 puzzle solution above
NW NE W  W  B  W  NW NE NW NE
SW W  NE NW NE B  SW SE SW SE
B  SW SE SW SE W  NW NE B  W
W  NW NE NW NE W  SW W  NE W
NW W  SE SW SE B  W  SW SE B
SW SE B  B  W  W  NW NE NW NE
B  NW NE W  B  NW W  SE SW SE
NW W  W  NE W  SW SE B  NW NE
SW W  W  SE B  NW NE NW W  SE
B  SW SE W  W  SW SE SW SE B

# all white
W  W  W
W  W  W
W  W  W

# a diamond and some rectangles
NW NE W
SW SE W
W  W  B

# all black
B  B  B
B  B  B
B  B  B

Falsy test cases
# a triangle
SE

# a larger triangle, with a valid white square
W  NW
NW W

# a parallelogram
NW W SE

# a slanted square with a black hole in the middle
W  NW NE W
NW W  W  NE
SW W  B  SE
W  SW SE W

# a region that contains two rectangles but is not a rectangle by itself
B  W
W  W

# same as above, but 45 degrees rotated
W  NW NE B
NW W  W  NE
SW SE SW SE

Python 3.8 (pre-release), 179 bytes
lambda C:all({'','11','1'*4}>={*bin(65793*(a&3|c&12|d&48|b&192)).split("0")[2:-1]}for
i,j in p(C,[0]*len(C[0]))for(a,b),(c,d)in p([*zip(i,j)],(0,0)))
p=lambda l,d:zip([d]+l,l+[d])

Try it online!
mapping={'B': 0, 'W': 255, 'SE': 180, 'SW': 210, 'NW': 75, 'NE': 45}
Mapping visualization:

The numbers are the bit position (least significant bit position is 0). Black has value 0, white has value 1. With this bit order, some simple bitmasking will give the state of the 8 triangles around a corner.
Use the method that I posted in chat.
Other key ideas for golfing:

65793 = 0x10101.
{'','11','1'*4}>={*bin(65793*X).split("0")[2:-1]} checks the condition  with X a 8-bit number.

The function p returns the consecutive pairs in the list l, with the added first element (d, l[0]) and last element (l[-1], d).

How does it work? The spoiler in chat doesn't link to anything.

@fireflame241 (the spoiler is in the tool tip.)

Oh I see. That's smart. Still, it would be nice to paste that in so viewers do not have have to click on the link

Nice observation!

Python 3, 667 554 526 461 bytes
-49 bytes thanks to @ovs and @pppery
C=eval(input())
N=next
E=enumerate
def F(x,y,f):
 try:1/-~x/-~y;c=C[y][x];(x,y)in v<Q;n[c]+=1;c&f<1<Q;C[y][x]=0;v[:0]=[(x,y)];[c>>i&1and F(x+i%2*(2-i),y+(i-1&~i),1<<(i^2))for i in(0,1,2,3)]
 except:1
while l:=[(x,y)for y,r in E(C)for x,e in E(r)if e]:
 a=0;v=[];n={k:0for k in range(16)};F(*l[0],15);a=len(v)+n[15];(len(v)!=n[15]or(N(M:=map(max,zip(*v)))-N(m:=map(min,zip(*v)))+1)*(N(M)-N(m)+1)!=a/2)and(a!=4*n[6]*n[12]or n[6]!=n[9]or n[3]!=n[12]or n[0]>0)and z

Try it online! (all testcases)
Throws NameError for false and doesn't throw for true.
Golf notes:

or has a higher precedence than and

Commented, Ungolfed
# bit order of a cell:
# truthy bit if that side is white(opeN)
#   0
# 3   1
#   2

# black: 0
# white: 15
# SE: 9
# SW: 3
# NW: 6
# NE: 12

# helper function to flood fill starting at (x,y)
# passes x,y position
# passes down mutable values
  # visited: array of coordinates visited
  # num_visited: dict counting how many of each cell type have been visited
def flood_solve(case, x, y, coming_from):
    global touched0, white_area, visited, num_visited
    # if out-of-bounds in the positive direction, this will throw
    try: c = case[y][x]
    except: return
    if (x,y) in visited: return
    # maybe can include touched0 into num_visited dict, then del num_visited[0] later
    # Keep track if the white region touches a full-black cell (0)
    touched0 = touched0 or c == 0
    # Check if this new cell is white on the side of the previous cell
    if not c & coming_from: return
    # Turn all visited cells to 0 to avoid flood-filling the same region
    case[y][x] = 0
    # Keep track of which cells are visited
    visited += [(x,y)]
    # Keep track of the counts of NE,NW,SE,and SW cells (3,6,9,12)
    num_visited[c] += 1
    # Keep track of the area of cells visited (1 for full-white, 0.5 for all else)
    if c != 15:
        white_area += 0.5
    else:
        white_area += 1
    # Flood recurse in each direction
    # Call flood_solve on (x,y-1) if (x,y) is white on its top side
    # Whether (x,y-1) is white on its bottom side is determined using coming_from
    if c & 1 and y>0: flood_solve(case, x, y-1, 4)
    if c & 2: flood_solve(case, x+1, y, 8)
    if c & 4: flood_solve(case, x, y+1, 1)
    if c & 8 and x>0: flood_solve(case, x-1, y, 2)
    return(visited, num_visited)

def solve(case):
    global touched0, white_area, visited, num_visited
    touched0 = False
    white_area = 0
    visited = []
    num_visited = {3:0,6:0,9:0,12:0,15:0}
    # Pick a cell with white
    for y,row in enumerate(case):
        for x,e in enumerate(row):
            if e > 0:
                # Floodfill whites from it
                # Pass 15 (0b1111) as coming_from since (x,y) can always be reached
                # Pass case mutably
                visited, num_visited = flood_solve(case, x, y, 15); break
                # (Maybe rectangular checks can be moved here to avoid looping by re-calling solve)
        # flooding always visits at least one cell, so visited is equivalent to the proposition
        # "A cell containing some white has already been found"
        if visited: break
    # Base case: if no white remains, then return True
    if not visited:
        return True
    v = list(zip(*visited))
    # v = [list of x positions visited, list of y positions visited]
    top_left = list(map(min, v))
    bottom_right = list(map(max, v))
    # If only entered all-white cells and area of bounding box of cells entered == area of cells entered:
    if len(visited)==num_visited[15] and (bottom_right[1] - top_left[1] + 1) * (bottom_right[0] - top_left[0] + 1) == white_area:
        # looks like an infinite recursion, but visited cells are replaced with 0 in flood_solve
        return solve(case)
    # If touched an all-black cell, can't be an angled rectangle, since angled rectangles only have angled sides
    if touched0:
        return
    n = num_visited
    # Should have #(NW entered)=#(SE entered) and #(NE)=#(SW)
    # (is this check redundant with the next area check? Maybe the area check can be rearranged by using area<=2*(perimeter/2)^?)
    if not n[6] == n[9] or not n[3] == n[12]:
        return
    if 2*n[6]*n[12] == white_area:
        # Success! it's an angled rectangle
        return solve(case)

Pseudo-code algorithm

Start
Pick a cell with white; floodfill whites from it

(Base case: if no white remains, then return True)
While floodfilling:

Keep track of which cells are visited
Keep track of the counts of cells
Keep track if the white region touches a full-black cell (0)
Keep track of the area of cells visited (1 for full-white, 0.5 for all else)
Turn all visited cells to 0 to avoid flood-filling the same region

If only entered all-white cells and area of bounding box of cells entered == area of cells entered:

Success! it's an upright rectangle.
GOTO Start; use the updated case (all visited cells turned black)

If touched an all-black cell

Can't be an angled rectangle, since angled rectangles only have angled sides
return False

Should have #(NW enetered)=#(SE entered) and #(NE)=#(SW) (is this check redundant with the next area check?)
Each NW cell contributes sqrt(2) to the length of the NW side of the rectangle
Each NE cell contributes sqrt(2) to the length of the NE side of the rectangle
If area == 2*#(NW)*#(NE):

Success! it's an angled rectangle
GOTO Start; use the updated case (all visited cells turned black)
White region filled can't be angled or upright rectangle anymore
return False

You can wrap the entire F function in try/except and return by throwing an error: Try it online!.

And replace the last part of F with [(c>>a&1)*(a+y)*(3-a+x)and F(x+a%2*(2-a),y+(a-1&~a),1<<(a^2))for a in(0,1,2,3)] for another -4 bytes. Then you can move the check for x and y to the front.

All combined: Try it online!.

@pppery Yep, that's the power of using all the testcases. The problem with the 473-byte code was that it modified a within the function, though it did deal with v and n properly

You appear to have gotten my technique to work, anyway, though, with some of your own modifications, so I at least provided an idea. (I'm deleting my own comments as they get responded to so the comment section doesn't get too cluttered)