text:
Quartic Summation
Guidelines
Task
Given two non-negative integers, find the sum of both numbers... to the power of 4.

Examples
2, 3 -> 97 (2^4 + 3^4 = 97)
14, 6 -> 39712 (14^4 + 6^4 = 39712)
0, 25 -> 390625 (0^4 + 25^4 = 390625)

Rules

You will only ever receive two non-negative integers as input (bonus points if you get it to work with negative integer input).
You can take the input however you would like (arrays, list, two separate arguments, comma-separated string)
You can either output your answer as a number or a string.
As this is code golf, the shortest answer in bytes will win.

You say two positive integers, but one of the test cases contains a 0. Also, there's not many languages that would have trouble with negative integers, given the result is the same as if they were positive.

"positive integers" might be confusing for non english people. In French, 0 is both positive and negative.

I've downvoted this challenge for the following reason: it is a fairly trivial, yet non-essential (such as Hello, World!) and I doubt that any interesting answers will be produced.

Downvoted for the same reason as @cairdcoinheringaahing.

@Damien Interesting! In the US (at least), 0 is neither positive nor negative.

Upvoted because sometimes trivial challenges are fun

@cairdcoinheringaahing Just because it is trivial, does not mean it is a bad challenge? Take a look at the CP-1610 answer, I would definitely call that interesting. It has produced interesting solutions.

@Amorris That's a reason to upvote that answer, not a reason to not downvote the question.

The mark of a good question here is that nearly all of the answers are interesting.

@Amorris 2 things: 1) I don't think it is a bad challenge, simply that it adds nothing new to the site, and so, in my eyes, is downvote-worthy 2) I'd recommend not accepting an answer, especially not this early, as people view code golf as more of a competition within languages, rather than between them.

I'd prefer if this challenge didn't require zero to be handled, because not doing so lets me save bytes :P

Your challenges really split the community.

@user202729 Sure do. First it's too difficult, next it's too hard, next you only want input validation. Most challenges are not even challenges anymore.

@Zionmyceliaadamancy This challenge should be given another chance. Although trivial in mainstream languages, it's interesting in certain esoteric languages, or languages that are mainstream but not designed to do arithmetic.

Regex  m (PCRE2 v10.35 or later), 10 bytes
^(?*x+){4}

Attempt This Online! - PCRE2 v10.40+
Takes its input in comma-delimited unary, as a concatenation of strings of x characters whose lengths represent the numbers, separated by , characters. (Bonus: The number of arguments is variable, not just 2.) Returns its output as the number of ways the regex can match. (The rabbit emoji indicates this output method. It can yield outputs bigger than the input, and is really good at multiplying.)
^ anchors the expression to the beginning of each line, making it process each number in the list exactly once, thanks to the multiline flag. The result of each adds to the total (instead of multiplying the total), since they are independent matches not done in concert.
Non-atomic lookahead, added to PCRE2 in v10.34 as (*napla:...) and given the (?*...) synonym in v10.35, makes calculating \$n^k\$, where \$k\$ is a constant, very easy in -regex. (?*x+){4} is equivalent to (?*x+)(?*x+)(?*x+)(?*x+). Each (?*x+) essentially picks a number in \$[1,n]\$, cycling through all the values effectively independently of the others, so the number of possible choices that lead to a full match is \$n^4\$.
It would not be possible to emulate this kind of solution using lookbehind with recursion to emulate variable-length-lookbehind, because that requires using lookahead nested inside lookbehind, both of which are atomic – so only one possible match would be tried. And even if it were not for that problem, the engine will complain of "nested recursion at the same subject position", which is unavoidable.
Regex  (PCRE / Raku:P5), 27 bytes
(|xxx|((||){2}||)xx?)x*x*x+

Try it online! - PCRE1
Try it online! - PCRE2 v10.33 / Attempt This Online! - PCRE2 v10.40+
Try it online! - Raku (Perl 6)
(
                 # apply once with tail = N
|
    xxx          # apply once with tail = N-3
|
    ((||){2}||)  # apply 3**2+2==11 times...
    xx?          # ...with tail = N-1 or N-2
)
x*x*x+           # tail'th pentatope number

Although PCRE and Raku are the only regex engines currently capable of counting this regex's number of possible matches without their source code being patched, this regex itself only uses a POSIX ERE level of functionality, so is in theory universally compatible with all regex engines.
Lacking non-atomic lookahead, the only golf-efficient way I can think of to cause the number of possible matches to be \$n^k\$, where \$k\$ is a constant, is to decompose \$n^k\$ into a sum of \$n\$-simplex numbers. \$4\$-simplex numbers have the formula \$S_4(n)=n(n+1)(n+2)(n+3)/24\$. So what we want is to solve is:
$$n^4=a⋅S_4(n)+b⋅S_4(n-1)+c⋅S_4(n-2)+d⋅S_4(n-3)$$
for \$a,b,c,d\$. The general form of this turns out to have the \$k\$th Euler's triangle row as its solution. In the case of \$n^4\$, this is \$1,11,11,1\$.
The -regex for \$S_4(n)\$ is x*x*x+: Try it online!
What we need to do is have it match \$1\$ time on \$n\$, \$11\$ times on \$n-1\$, \$11\$ times on \$n-2\$, and \$1\$ time on \$n-3\$.
Multiplying the number of possible matches of a subexpression can be done simply by concatenating, for example, (|||) to multiply by \$4\$. As a standalone regex returning \$4(n+1)\$, this can simply be |||: Try it online! - note that this is \$4(n+1)\$ because an empty regex returns \$n+1\$ possible matches.
The simplest choice for multiplying by \$11\$ would be (||||||||||), but it turns out this can be optimized down to ((||){2}||), as \$11=3^2+2\$, where (||){2} is \$3^2\$ and each additional | adds \$1\$. Larger numbers can be additionally optimized by factorization. Additionally, there's expressions like (|){3,5} for \$56=2^3+2^4+2^5\$.
So, ((||){2}||)xx? is the part where it's creating \$11\$ possibilities each, ((||){2}||),  in which the subsequent expression is evaluated on \$n-1\$ or \$n-2\$, using xx?.
The first several n-simplex functions are as follows, in -regex:
\$S_0(n)\$: ^ (returns \$1\$)
\$S_1(n)\$: x (returns \$n\$)
\$S_2(n)\$: x+ (triangular numbers)
\$S_3(n)\$: x*x+ (tetrahedral numbers)
\$S_4(n)\$: x*x*x+ (pentatope numbers)
\$S_5(n)\$: x(x*){4}
\$S_6(n)\$: x(x*){5}
The first several \$n^k\$ are as follows:
\$n^0\$: Try it online! ^
\$n^1\$: Try it online! x
\$n^2\$: Try it online! x?x+ (squares)
\$n^3\$: Try it online! (|xx|(|||)x)x*x+ (cubes)
\$n^4\$: Try it online! (|xxx|((||){2}||)xx?)x*x*x+
\$n^5\$: Try it online! x(|x{4}|x((||||){2}|)(|xx)|((|){6}||)xx)(x*){4}
\$n^6\$: Try it online! x(|x{5}|x((|){3,5}|)(|xxx)|(|)((||||){2,3}|)xxx?)(x*){5}
\$n^7\$: Try it online! x(|x{6}|x(|){3,6}(|x{4})|xx(||)((||||||){2,3}|||||)(xx)?|xxx(|){4}((||||){2,3}|))(x*){6}
\$n^8\$: Try it online! x(|x{7}|x((||){5}||||)(|x{5})|xx(||){4}((|){4,5}|||||)(|xxx)|xxx((|){8}((|){2,5}|)|||)x?)(x*){7}
Perl 5 severely undercounts the number of possible matches (Attempt This Online); see below for a workaround. But Raku's Perl 5 compatibility mode (:P5 adverb) fully evaluates every choice path (and not just due to its :exhaustive adverb – it does the same without it).
Regex  (Perl / PCRE / Raku:P5), 30 bytes
(|xxx|(()||||||||||)xx?)x*x*x+

Try it online! - Perl v5.28.2 / Attempt This Online! - Perl v5.36+
Try it online! - PCRE1
Try it online! - PCRE2 v10.33 / Attempt This Online! - PCRE2 v10.40+
Try it online! - Raku (Perl 6)
The part in the 27 byte version that is undercounted by Perl is ((||){2}||), the expression that multiplies possibilities by 11.
Perl forces any loop to exit after making a zero-width match (whereas PCRE only does so on loops whose quantifier has no maximum, which I think is more logical), so (||){2} needs to be changed to (||)(||), adding 1 byte.
Perl prunes a group's alternatives down to one if they are all identical, but doesn't do this if even one alternative differs from the others. So (||) needs to be changed to (()||) in both places, adding 4 bytes.
After all that, it becomes ((()||)(()||)||). But that's longer than (()||||||||||), so we use the latter instead, at just 3 bytes longer than ((||){2}||).
Regex  m (PCRE), 73 69 bytes
Without decomposing a fourth power into pentatope numbers, I'm pretty sure this is the best solution possible (it might golf down a tiny bit more than this, but not much):
^(?=(x*)\1{3}(xx())?(x())?)((?=\1(x*))(x+(|||)|\3(|)|\5).*(?=\7$)){4}

Try it online! - PCRE2 v10.33 / Attempt This Online! - PCRE2 v10.40+
^                    # tail = N = input number
(?=
    (x*)\1{3}        # \1 = floor(tail / 4)
    (()xx)?(()x)?    # \3,\5 = {tail % 4} in binary:
                     # \3 set|unset = 2's place digit 1|0
                     # \5 set|unset = 1's place digit 1|0
)
(
    # Manipulate the number of possible matches to be exactly \1 * 4 + \2 == N
    (?=\1(x*))       # \7 = tail - \1
    (
        x+(|||)      # Add \1 * 4 to the number of possibilities of this iteration
    |
        \3(|)|\5     # Add \3*2 + \5 (where set=1 and unset=0) to the number of
                     # possibilities of this iteration
    )
    .*(?=\7$)        # tail = \7, i.e. the next multiple of \1 down from what it
                     # was when \7 was captured above.
){4}                 # Iterate the above 4 times, such that after finishing, each
                     # iteration could have been at any one of the N states.

This method does eventually win out against simplex decomposition:
1: x
   x
2: x?x+
   ^(?=(x*)\1(x()|))\2(x+(|)|\3).*(?=\1$)(?4)
3: (|xx|(|||)x)x*x+
   ^(?=(x*)\1\1(x())?(x())?)((?=\1(x*))(x+(||)|\3|\5).*(?=\7$)){3}
4: (|xxx|((||){2}||)xx?)x*x*x+
   ^(?=(x*)\1{3}(xx())?(x())?)((?=\1(x*))(x+(|||)|\3(|)|\5).*(?=\7$)){4}
5: x(|x{4}|x((||||){2}|)(|xx)|((|){6}||)xx)(x*){4}
   ^(?=(x*)\1{4}(xx())?(x())?(x())?)((?=\1(x*))(x+(||||)|\3(|)|\5|\7).*(?=\9$)){5}
6: x(|x{5}|x((|){3,5}|)(|xxx)|(|)((||||){2,3}|)xxx?)(x*){5}
   ^(?=(x*)\1{5}(xx())?(xx())?(x())?)((?=\1(x*))(x+(|||||)|\3(|)|\5(|)|\7).*(?=\9$)){6}
7: x(|x{6}|x(|){3,6}(|x{4})|xx(||)((||||||){2,3}|||||)(|xx)|xxx(|){4}((||||){2,3}|))(x*){6}
   ^(?=(x*)\1{6}(xxx())?(xx())?(x())?)((?=\1(x*))(x+(||||||)|\3(||)|\5(|)|\7).*(?=\9$)){7}
8: x(|x{7}|x((||){5}||||)(|x{5})|xx(||){4}((|){4,5}|||||)(|xxx)|xxx((|){8}((|){2,5}|)|||)x?)(x*){7}
   ^(?=(x*)\1{7}(x{4}())?(xx())?(x())?)((?=\1(x*))(x+(|){3}|\3(|||)|\5(|)|\7).*(?=\9$)){8}

CP-1610 assembly, 30 DECLEs = 38 bytes
Let's try this on a processor lacking a multiply instruction. This code is intended to be run on an Intellivision.
CP-1610 instructions are encoded with 10-bit values, known as 'DECLE' s. This subroutine is 30 DECLEs long, starting at $4808 and ending at $4825.
Takes input in registers R0 and R3. Saves the result in R2.
                              ROMW  10            ; use 10-bit ROM
                              ORG   $4800         ; map program at address $4800

4800  02B8 000E               MVII  #14,    R0    ; example call
4802  02BB 0006               MVII  #6,     R3
4804  0004 0148 0008          CALL  addX4Y4
4807  0017                    DECR  PC            ; loop forever

4808  0275            addX4Y4 PSHR  R5            ; push the return address
4809  0004 0148 001A          CALL  square        ; compute R2 = R0^2
480C  0004 0148 0019          CALL  square2       ; compute R2 = R2^2
480F  0272                    PSHR  R2            ; push this result on the stack
4810  0098                    MOVR  R3,     R0    ; compute R2 = R3^2
4811  0004 0148 001A          CALL  square
4814  0004 0148 0019          CALL  square2       ; compute R2 = R2^2
4817  02F2                    ADD@  R6,     R2    ; add this result to the intermediate one
4818  02B7                    PULR  PC            ; return

4819  0090            square2 MOVR  R2,     R0    ; copy R2 to R0
481A  0081            square  MOVR  R0,     R1    ; copy R0 to R1
481B  01D2                    CLRR  R2            ; initialize R2 = result
481C  0200 0002               B     halve         ; start by halving R1
481E  00C2            add     ADDR  R0,     R2    ; add R0 to R2
481F  0048            loop    SLL   R0            ; double R0
4820  0079            halve   SARC  R1            ; halve R1
4821  0221 0004               BC    add           ; was the LSB set?
4823  022C 0005               BNEQ  loop          ; is R1 now equal to zero?
4825  00AF                    JR    R5            ; return

Example run
Running the above code (with R0 = 14 and R3 = 6) gives:
> b 4807
Set breakpoint at $4807
> r
Hit breakpoint at $4807
 0900 0000 9B20 0006 01FE 4817 02F1 4807 S-----iq  DECR R7
           ^^^^

R2 is set to $9B20, which is 39712 in decimal.

Perl, 12 bytes
Includes +1 for p
Works for 1 or more numbers each given on a separate line on STDIN
(echo 2; echo 3) | perl -pe '$\+=$_**4}{'

Haskell, 11 bytes
sum.map(^4)

This is a function that takes the parameters as a list.
Try it online!

Same bytecount: a#b=a^4+b^4

Pyt, 2 bytes
⁴Ʃ

Try it online!
Takes input as a list.

Knew there would be a language with a built-in for **4, congrats.

Japt, 3 bytes
Takes input as an array of integers; can handle negatives and more than 2 integers at a time. Add N at the beginning to take input as individual integers.
xp4

Try it

Explanation
p4 raises each element to the power of 4 and x reduces by addition.

><>, 11 bytes
:*:*$:*:*+n

Try it online!
Takes values through the -v flag. Dupe and multipy, dupe and multiply, and repeat with the other value before adding the two together and printing.

Retina, 9 bytes
.+
****
_

Try it online!
Input should be linefeed-separated.
Explanation
.+
****

* is Retina's repetition operator. It has implicit operands $& and _, respectively, so the substitution pattern is short for $&*$&*$&*$&*_. It's also right-associative, if the regex matches a decimal number n, this generates a string of n4 underscores (i.e. a unary representation of the fourth power of n).
_

To sum the two results and convert the sum back to decimal, we simply count the number of underscores in the string.

Python 3, 20 bytes
lambda x,y:x**4+y**4

You can remove the assignment to f as this isn't a recursive function.

@Shaggy Maybe I'm confused but how else would my answer take any input? Wouldn't I then be defining something that is essentially 'lost' right after being interpreted? It's not like I can feed input in via args, for example. Or it is normal in codegolf that those bytes 'f=' are not counted?

What I meant was: you don't need to include it in your byte count. Anonymous functions/lambdas are valid.

MATL, 3 bytes
K^s

Try it online!
This can handle more than two input values, as well as negative inputs.
Explanation:
Fasten your seat belts, this might blow your mind!
       % Implicit input
K      % Push literal 4
 ^     % Raise each element of the input vector to the 4th power
  s    % Sum

Also works:
4^s    % Push 4 and raise input to it, then sum
UUs    % Square input twice, then sum

APL (Dyalog Unicode), 5 bytesSBCS
Anonymous tacit prefix function. Takes a list as argument. The list may have any length and contain any numbers, even complex ones.
+.*∘4

Try it online!
+.* is a variant on matrix product, +.× as follows: a b+.×c d is (a×c)+(b×d) and a b+.×c is (a×c)+(b×c). So a b+.*c is (a*c)+(b*c). * is power.
∘4 curry four as right argument. This results in a monadic function (a*4)+(b*4).

J, 7 6 bytes
-1 byte thanks to Adám
1#.^&4

Try it online!
Works for lists with arbitrary length
^&4 - each item of the list to the 4-th power
1#. - sum of all 4-th powers by base-1 conversion
Try it online!
Alternative
J, 7 bytes
+/ .^4:

This is a variant of the matrix product, analogue of Adám's APL solution
Try it online!

6 bytes: 1#.^&4

@Adám Thanks, I forgot to try to add up the numbers by base-1 conversion.

C (gcc), 0 + 24 bytes

Compile this code
main(){
    printf("%d\n",x(2,3));
    printf("%d\n",x(14,6));
    printf("%d\n",x(0,25));
}

With this flag:
-D=x(a,b)a*a*a*a+b*b*b*b

Try it online! (GCC Tio)
Try it online! (Bash Compile example)

Triangularity, 31 bytes
...)...
..IEM..
.)4s^}.
u......

Try it online!

R, 16 bytes
pryr::f(x^4+y^4)

Try it online!

Ruby, 16 bytes
->a,b{a**4+b**4}

Try It Online!

Java 8, 21 bytes
a->b->a*a*a*a+b*b*b*b

Try it online.

Perl 6, 9 bytes
*⁴+*⁴

Try it online!

@EsolangingFruit The problem is that along with * WhateverCode lambdas there are also ** HyperWhatever lambdas; so it would have to be written as * **4+* **4, or else it would would be seen as ** *4+** *4 which doesn't work. ((**⁴)(2,3) results in (16,18))

@BradGilbertb2gills I guess that makes sense. Why am I surprised Perl supports Unicode superscript exponents?

Pyth, 5
sm^d4

Online test.
  ^d4     # lambda to take 4th power
     Q    # implicit input
 m        # map lambda over input
s         # sum

Attache, 8 bytes
Sum@`^&4

Try it online!
Takes input as a pair of integers.
Explanation
This is a composition of two functions:

Sum
`^&4

The first executed is `^&4, which is equivalent to:
`^&4
RBond[`^, 4]
RBond[{_1 ^ _2}, 4]
{_1 ^ 4}

That is, a function that raises its argument to the fourth power. This vectorizes over the input array. Then, Sum takes the sum of these elements.
Alternative approaches
Sum@`^&4@V    ?? 11 bytes, input is two arguments
{Sum[_^4]}    ?? 11 bytes, input is array
{_^4+_2^4}    ?? 11 bytes, input is two arguments

Pyramid Scheme, 220 bytes
           ^
          / \
         /   \
        /  +  \
       /       \
      ^---------^
     /^\       /^\
    ^---^     ^---^
   /#\ /4\   /#\ /4\
  ^--- ---  ^--- ---
 /l\       /l\
/ine\     /ine\
-----     -----

Try it online!
line pyramids obtain a line from STDIN, # pyramids cast their arguments into numbers, ^ pyramids perform exponentiation, and the + pyramid adds two things together.

Minkolang 0.15, 10 bytes
$n4;r4;+N.

Try it here.
Explanation
$n4;r4;+N.
$n           take all input as numbers     [a, b]
  4;         raise to the fourth           [a, b^4]
    r        reverse stack                 [b^4, a]
     4;      raise to the fourth           [b^4, a^4]
       +     add                           [b^4 + a^4]
        N    output                        []
         .   terminate

D, 25 bytes
(int x,int y)=>x^^4+y^^4;

Try it online!
A simple lambda that performs exponentiation on each of its arguments, with ^^ being the exponentiation operator.

JavaScript (ES7), 15 bytes
Does exactly what it says on the tin.
a=>b=>a**4+b**4

Test cases

let f =

a=>b=>a**4+b**4

console.log(f(2)(3))
console.log(f(14)(6))
console.log(f(0)(25))

Ah, nuts!

05AB1E, 3 bytes
4mO

Try it online!
Explanation
4m    # raise each to the power of 4
  O   # sum

C, C++ => 29 bytes
-1 byte thanks to Jonathan Frech
#define Q(a,b)a*a*a*a+b*b*b*b

Test cases :
#include <stdio.h>
int main() {
    printf("Q(%d,%d) = %d\n", 2, 3, Q(2, 3));
    printf("Q(%d,%d) = %d\n", 14, 6, Q(14, 6));
    printf("Q(%d,%d) = %d\n", 0, 25, Q(0, 25));
}

Could you not drop the space in ) a?

Julia, 11 bytes
a$b=a^4+b^4

Try it online!

Julia, 12 bytes
!a=sum(a.^4)

Try it online!

Excel, 10 bytes
=A1^4+B1^4

Nothing to see here.

C (gcc), 26 bytes
f(a,b){a=a*a*a*a+b*b*b*b;}

Try it online!

Jelly, 3 bytes
*4S

Try it online!

Python 3, 20 bytes
lambda a,b:a**4+b**4

Try it online!

Add++, 8 bytes
L,4^$4^+

Try it online!

Python 2, 30 28 bytes
lambda i:sum(x**4for x in i)

Try it online!
Alternative approach for Python (albeit slightly longer than the more obvious one). Takes input as a list of integers.
-2 with thanks to @JonathanAllan

You can drop the [ and ]

@JonathanAllan - I was sure I'd tried that and got a syntax error but it seems to work now. Thanks!

Perl 6, 15 bytes
{$^a**4+$^b**4}

An anonymous lambda.
Try It Online!

APL+WIN, 5 bytes
Prompts for screen input of a two element vector. Seems to work for negative inputs
+/⎕*4

Husk, 3 bytes
ṁ^4

Input as a list, try it online!
Alternative, 4 bytes
One byte more but I like this more:
¤+^4

Expects two arguments, try it online!

,,,, 8 bytes
4*↔4*+

Try it online!
It's trivial enough for ,,,. :P

CJam, 7 bytes
{4f#:+}

Try it online!

Momema, 68 bytes
2*-8k03*2 2 01*3j02+*2*3 1+-1*1j=*1k*001k3 4*2 2*-8 02k2 03k1-8+*2*4

Try it online!
Doesn't work for zeroes. Awaiting clarification from OP.
Explanation
2   *-8    #  o = read num
k   0      #  procedure square(o, LABEL):
3   *2     #    original = o
2   0      #    o = 0
1   *3     #    i = original
j   0      #    do {
2   +*2*3  #      o = o + original
1   +-1*1  #      i = i - 1
j   =*1    #    while (i != 0)
k   *0     #    goto LABEL
           #  LABEL = sq0
           #  square(o, LABEL); sq0:
0   1      #  LABEL = sq1
k   3      #  square(o, LABEL); sq1:
4   *2     #  t = o
2   *-8    #  o = read num
0   2      #  LABEL = sq2
k   2      #  square(o, LABEL); sq2:
0   3      #  LABEL = sq3
k   1      #  square(o, LABEL); sq3:
-8  +*2*4  #  print num t + o

This program defines a "procedure" which squares memory cell 2 (using 1 and 3 as temporary cells) and then jumps based on the value of cell 0.

Zero is in the test cases (and was so even in the base revision), so it does have to work, no clarification from OP needed. Why not just modify this solution to handle zero properly?

Physica, 13 bytes
=>a;b:a^4+b^4

Demo
Note that physica is not on TIO yet. This is a lambda function, which can be called using F[a; b], as follows:

K4, 10 bytes
Solution:
+/xexp[;4]

Example:
q)k)+/xexp[;4]2 3
97f
q)k)+/xexp[;4]0 25
390625f

Explanation:
Pretty trivial...
+/xexp[;4] / the solution
  xexp[;4] / xexp does x^y, with y = 4
+/         / sum over

Canvas, 6 bytes
４＾╶４＾＋

Try it here!

Phoenix, 28 bytes
echo$argv[1]**4+$argv[2]**4;

Try it online!
Phoenix is a variant of PHP designed to be lightweight in terms of syntax. TO this end, it does a pretty okay job. A function would be longer, so this seems to be the shortest way. (The documentation is sparse, and I don't know much PHP myself.)

Jelly, 4 bytes
,*4S

Try it online!
Explanation
,       pair
 *4     to the power of four
   S    sum

IBM/Lotus Notes Formula, 17 bytes
@Sum(@Power(a;4))

Field formula that takes its input from a multi-value numeric field on the same form. Works because for most Formula functions, if a list is given as input then the formula will apply the given function recursively to every item in the list.
There is no TIO for Notes but here's a screenshot of one of the test cases:

Emojicode, 49 bytes
ij➡➕i 4j 4

Try it online!


text:
Minimally sort a list into a matrix
Given an unsorted list of unique strictly positive integers, minimally sort it into a 2D matrix. The input list is guaranteed to be of composite length, which means the output matrix is not necessarily square, but is of size n x m with n,m > 1.
"Minimally sort" here means the following:

Sort the list in ascending order.
Compact the output matrix as much as possible -- minimize the sum of the dimensions of the matrix (for example, for 20 input elements as input, a 5x4 or 4x5 output matrix is required, and not a 2x10).
Compact the sorted numbers as far to the upper-left of the matrix as possible, starting with the first element in the sorted list.
This can be thought of as sorting the list, then slicing it along the matrix's anti-diagonals, starting with the upper-left.

Examples:
For input 1..20 output is either a 5x4 or a 4x5 matrix as follows:
 1  2  4  7 11
 3  5  8 12 15
 6  9 13 16 18
10 14 17 19 20

 1  2  4  7
 3  5  8 11
 6  9 12 15
10 13 16 18
14 17 19 20

For input [3, 5, 12, 9, 6, 11] output is a 2x3 or 3x2 as follows
3  5  9
6 11 12

 3  5
 6  9
11 12

For input [14, 20, 200, 33, 12, 1, 7, 99, 58], output is a 3x3 as follows
 1   7  14
12  20  58
33  99 200

For input 1..10 the output should be a 2x5 or 5x2 as follows
1 2 4 6  8
3 5 7 9 10

1  2
3  4
5  6
7  8
9 10

For input [5, 9, 33, 65, 12, 7, 80, 42, 48, 30, 11, 57, 69, 92, 91] output is a 5x3 or 3x5 as follows
 5  7 11 33 57
 9 12 42 65 80
30 48 69 91 92

 5  7 11
 9 12 33
30 42 57
48 65 80
69 91 92

Rules

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

Oh, wow, a word I haven't seen since Linear Algebra; easily overlooked. My apologies.

@LuisMendo Added a 15 element test case.

Jelly, 24 22 20 bytes
pS€ỤỤs
LÆDżṚ$SÞḢç/ịṢ

Try it online!
Saved 2 bytes thanks to @Jonathan Allan.
Explanation
pS€ỤỤs  Helper link. Input: integer a (LHS), integer b (RHS)
p       Cartesian product between [1, 2, ..., a] and [1, 2, ..., b]
 S€     Sum each pair
   Ụ    Grade up
    Ụ   Grade up again (Obtains the rank)
     s  Split into slices of length b

LÆDżṚ$SÞḢç/ịṢ  Main link. Input: list A
L              Length
 ÆD            Divisors
     $         Monadic pair
    Ṛ            Reverse
   ż             Interleave
                 Now contains all pairs [a, b] where a*b = len(A)
      SÞ       Sort by sum
        Ḣ      Head (Select the pair with smallest sum)
         ç/    Call helper link
            Ṣ  Sort A
           ị   Index into sorted(A)

L%J¬TżṚ$ -> LÆDżṚ$ should save two I think

The first link can become pSÞỤs.

Python 2, 160 158 153 151 bytes
-2 bytes thanks to Erik the Outgolfer
-2 bytes thanks to Mr. Xcoder

s=sorted(input())
l=len(s)
x=int(l**.5)
while l%x:x+=1
n=1
o=eval(`l/x*[[]]`)
while s:
 for i in range(l/x)[max(0,n-x):n]:o[i]+=s.pop(0),
 n+=1
print o

Try it online! or Try all test cases

I belive you can use max(0,n-x) for -2 bytes.

R 110 95 bytes
function(x){n=sum(x|1)
X=matrix(x,max(which(!n%%1:n^.5)))
X[order(col(X)+row(X))]=sort(x)
t(X)}

Try it online!
How it works
f <- function(x) {
  n <- sum(x|1)                           # length
  p <- max(which(!n%%1:n^.5))             # height of matrix
  X <- matrix(x, p)                       # initialize matrix
  X[order(col(X) + row(X))] <- sort(x)    # filling the matrix using position distance to the top left corner
  t(X)                                    # probably required by OP
}

Giuseppe saved a whopping 15(!) bytes by the following tricks

replacing length(x) by sum(x|1) (-1 byte)
floor() is not required as : rounds down anyway (-7)
^.5 is shorter than sqrt() (-3)
using col(X) + row(X) instead of outer (nice!)
could not get rid of the t(X) though - disappointing ;)

Original solution
function(x){
n=length(x)
p=max(which(!n%%1:floor(sqrt(n))))
X=outer(1:p,1:(n/p),`+`)
X[order(X)]=sort(x)
t(X)}

It would look more fancy with outer being replaced by row(X)+col(X), but that would require to initialize the output matrix X first.
Try it online!

Very nice! You can get down to 95 bytes

Might be able to use something from my solution to a related challenge to help here as well.

It is indeed closely related. Very nice approach!

JavaScript (ES6), 172 bytes
l=>(n=l.sort((a,b)=>b-a).length,w=l.findIndex((_,i)=>!(i*i<n|n%i)),a=l=>[...Array(l)],r=a(n/w).map(_=>a(w)),a(w+n/w).map((_,x)=>r.map((s,y)=>x-y in s&&(s[x-y]=l.pop()))),r)

Explanation
l=>(                                // Take a list l as input
 l.sort((a,b)=>b-a),                // Sort it
 n=l.length,                        // Get the length n
 w=l.findIndex((_,i)=>!(i*i<n|n%i)),// Find the first integer w where w >= √n and n % w = 0
 a=l=>[...Array(l)],                // Helper function a
 r=a(n/w).map(_=>a(w)),             // Create the grid r of size w, n/w
 a(w+n/w).map((_,x)=>               // For every x from 0 to w + n/w:
  r.map((s,y)=>                     //  For every row s in r:
   x-y in s&&(                      //   If the index x-y is in s:
    s[x-y]=l.pop()))),              //    Set s[x-y] to the next element of l
 r)                                 // Return r

Test Cases

f=l=>(n=l.sort((a,b)=>b-a).length,w=l.findIndex((_,i)=>!(i*i<n|n%i)),a=l=>[...Array(l)],r=a(n/w).map(_=>a(w)),a(w+n/w).map((_,x)=>r.map((s,y)=>x-y in s&&(s[x-y]=l.pop()))),r)

l=m=>console.log(JSON.stringify(m))

l(f([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]))
l(f([3,5,12,9,6,11]))
l(f([14,20,200,33,12,1,7,99,58]))
l(f([1,2,3,4,5,6,7,8,9,10]))

Octave, 151 bytes
function f(v)n=floor(sqrt(l=nnz(v)));while i=mod(l,n);++n;end;A=nan(m=l/n,n);for k=[1:m 2*m:m:l];do A(k)=sort(v)(++i);until~mod(k+=m-1,m)|k>l;end;A'end

Using three different kinds of loop constructs.
Try it online!
Unrolled:
function f(v)
    n = floor(sqrt(l=nnz(v)));

    while i = mod(l,n);
        ++n;
    end;

    A = nan(m=l/n, n);

    for k = [1:m 2*m:m:l];
        do
            A(k) = sort(v)(++i);
        until ~mod(k+=m-1, m) | k>l;
    end;

    A'
end

Nice answer! Why is the ' in nnz(v')  required?

@LuisMendo Thanks! Turns out the ' is not required if I wrap the range expression, e.g. 1:20, around brackets ([1:20]) at the call site (to make it an actual vector). Apparently in Octave, the colon operator doesn't create a vector, but a range constant that takes much less space in memory. For some reason, nnz() doesn't work with that type, but transposing the range constant yields a vector, so it works with the apostrophe. Calling the function with an actual vector removes the need for the '.

Thanks for the explanation. I didn't know that a range expression had that special treatment in Octave. Anyway, the fact that it doesn't create a vector for memory efficiency should be transparent to the programmer. That is, the fact that nnz(1:20) doesn't work is probably a bug (max(1:20), sum(1:20) etc are valid).

@LuisMendo Yes, it definitely seems like a bug.

We should report it. It might affect other functions than nnz . Do you want to do it yourself, or shall I?

@LuisMendo Sure, go ahead.

Reported. It also affected MATL; now solved. Thanks for noticing this!

Perl 5, 132 bytes
sub d{$,=0|sqrt(@_=sort{$a-$b}@_);--$,while@_%$,;map{$r++,$c--for@_/$,..$c;$a[$r++][$c--]=$_;$c=++$i,$r=0if$r<0||$c<0||$r>=$,}@_;@a}

Try it online!
Subroutine returns a 2-D array.  TIO link includes footer code for displaying test result.

JavaScript (ES6), 233 bytes
f=s=>{l=s.length;i=Math.sqrt(l)|0;for(;l%++i;);p=(x)=>(x/i|0+x%i)*l+x%i;m=[...Array(l).keys()].sort((x,y)=>p(x)-p(y));return s.sort((a,b)=>a-b).map((x,i)=>m.indexOf(i)).reduce((a,b,d,g)=>!(d%i)?a.concat([g.slice(d,d+i)]):a,[])}

Explanation
f=s=>{                         // Take array `s` of numbers as input
  l=s.length                   // short-hand for length
  i=Math.sqrt(l)|0             // = Math.floor(Math.sqrt(l))
  for(;l%++i;);                // i = width
  j=l/i                        // j = height

  p=(x)=>(x/i|0+x%i)*l+x%i     // helper to calculate (sort-of) ~manhattan
                                 // distance (horizontal distance weighted
                                 // slightly stronger), from top-left corner
                                 // to the number x, if numbers 0,...,l are
                                 // arranged left-to-right, top-to-bottom
                                 // in an l=i*j grid

  m=[...Array(l).keys()]         // range array
  .sort((x,y)=>p(x)-p(y)),       // manhatten-sorted, sort-of...

  return s.sort((a,b)=>a-b)      // sort input array by numbers,
    .map((x,i,w)=>w[m.indexOf(i)])    // then apply inverse permutation of the
                                 // range-grid manhatten-sort mapping.
    .reduce(                     // slice result into rows
      (a,b,d,g)=>!(d%i)?a.concat([g.slice(d,d+i)]):a
      ,[]
     )
}

Husk, 15 bytes
ḟȯΛ≤Σ∂MCP¹→←½ḊL

This works by brute force, so longer test cases may time out.
Try it online!
Explanation
ḟȯΛ≤Σ∂MCP¹→←½ḊL  Implicit input, a list of integers x.
              L  Length of x (call it n).
             Ḋ   List of divisors.
            ½    Split at the middle.
          →←     Take last element of first part.
                 This is a divisor d that minimizes d + n/d.
        P¹       List of permutations of x.
      MC         Cut each into slices of length d.
ḟ                Find the first of these matrices that satisfies this:
     ∂            Take anti-diagonals,
    Σ             flatten them,
 ȯΛ≤              check that the result is sorted (each adjacent pair is non-decreasing).

C (gcc), 269 253 226 bytes

Saved 16 43 bytes thanks to ceilingcat.

j,w,h,x,y;c(int*a,int*b){a=*a-*b;}f(A,l)int*A;{int B[l];qsort(A,l,4,c);for(w=h=j=2;x=w*h-l;j++)l%j||(w=h,h=j),w=h*h-l?w:j;for(;j=x<w*h;x++)for(y=0;y<=x;y++)x-y<w&y<h?B[x-y+y*w]=*A++:0;for(;j<l;printf("\n%d "+(j++%w>0),B[j]));}

Try it online!

C (gcc), 214 bytes, using -zexecstack-lambdas

Thanks to ceilingcat for this hackier, yet slimmer version.

j,w,h,x,y;f(A,l)int*A;{int B[l];qsort(A,l,4,L"\x62b078bǃ");for(w=h=j=2;x=w*h-l;j++)l%j||(w=h,h=j),w=h*h-l?w:j;for(;j=x<w*h;x++)for(y=0;y<=x;y++)x-y<w&y<h?B[x-y+y*w]=*A++:0;for(;j<l;printf("\n%d "+(j++%w>0),B[j]));}

Try it online!

@ceilingcat Thank you.

@ceilingcat Thank you. I assume you implemented a 'lambda' -- giving qsort a function pointer disguised as a wide-character string? Whilst I appreciate the solution, I added it as an addendum as I feel it is a tad too briddle to qualify as generic 'C'.

no "lambda" 225 bytes

@ceilingcat Thank you.

Java 10, 199 188 186 bytes
a->{int j=a.length,m=0,n,i=0,k=0;for(n=m+=Math.sqrt(j);m*n<j;n=j/++m);var R=new int[m][n];for(java.util.Arrays.sort(a);i<m+n;i++)for(j=0;j<=i;j++)if(i-j<n&j<m)R[j][i-j]=a[k++];return R;}

Try it online.
Based on my answer here.
Explanation:
a->{                        // Method with int-array parameter and int-matrix return-type
  int j=a.length,           //  Length of the input-array
      m=0,n,                //  Amount of rows and columns
      i=0,k=0;              //  Index integers
   for(n=m+=Math.sqrt(j);   //  Set both `m` and `n` to floor(√ `j`)
       m*n<j;               //  Loop as long as `m` multiplied by `n` is not `j`
       n=j/++m);            //   Increase `m` by 1 first with `++m`
                            //   and then set `n` to `j` integer-divided by this new `m`
   var R=new int[m][n];     //  Result-matrix of size `m` by `n`
   for(java.util.Arrays.sort(a);
                            //  Sort the input-array
       i<m+n;)              //  Loop as long as `i` is smaller than `m+n`
     for(j=0;j<=i;j++)      //   Inner loop `j` in range [0,`i`]
       if(i-j<n&j<m)        //    If `i-j` is smaller than `n`, and `j` smaller than `m`
                            //    (So basically check if they are still within bounds)
         R[j][i-j]=a[k++];  //     Add the number of the input array at index `k`,
                            //     to the matrix in the current cell at `[j,i-j]`
  return R;}                //  Return the result-matrix

source: Stack Exchange

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

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

sort: votes


text:
Sum of combinations with repetition
Write the shortest code you can solving the following problem:
Input:
An integer X with  2 <= X and X <= 100
Output:
Total combinations of 2, 3, and 5 (repetition is allowed, order matters) whose sum is equal to X.
Examples:
Input: 8
Output: 6, because the valid combinations are:
3+5
5+3
2+2+2+2
2+3+3
3+2+3
3+3+2

Input: 11
Output: 16, because the valid combinations are
5+3+3
5+2+2+2
3+5+3
3+3+5
3+3+3+2
3+3+2+3
3+2+3+3
3+2+2+2+2
2+5+2+2
2+3+3+3
2+3+2+2+2
2+2+5+2
2+2+3+2+2
2+2+2+5
2+2+2+3+2
2+2+2+2+3

Input: 100
Output: 1127972743581281, because the valid combinations are ... many
Input and output can be of any reasonable form.
The lowest byte count in each language wins.
Standard code-golf rules apply.

Welcome to PPCG! Unfortunately, here we don't answer general programming questions. However, you may be able to get help on [so]. Just be sure to check their help center out before asking. :)

Can someone reword this into a challenge? Because this would be a fun one.

I was thinking the same, @MagicOctopusUrn, but then I got to wondering if it's not a dupe.

@Shaggy Ugghhh... filtering through the challenges with the word sum in them was not a good idea to try to solve that inquiry...

I rewrote your question a bit to make it better fit on codegolf. I also changed the result for input 11 from 12 to 16. Of course feel free to fix this if I misunderstood your intention

@TonHospel voted for your edit.

I feel like we've had a challenge like this before, to express a number as a sum from a fixed set, maybe of coins. Don't know how I'd search for a potential dupe here. Anyone remember what I might be thinking of?

This is https://oeis.org/A079973

Borderline dupe of https://codegolf.stackexchange.com/q/85/194

Python 2, 46 45 bytes
thanks to xnor for -1 byte
f=lambda n:n>0and f(n-2)+f(n-3)+f(n-5)or n==0

Try it online!

Looks like and/or works and saves a byte: f=lambda n:n>0and f(n-2)+f(n-3)+f(n-5)or n==0.

@xnor thanks a lot. I just tried it the other way round

Oasis, 9 bytes
cd5e++VT1

Try it online!
Explanation
        1    # a(0) = 1
       T     # a(1) = 0, a(2) = 1
      V      # a(3) = 1, a(4) = 1

             # a(n) =
c    +       # a(n-2) +
 d  +        # a(n-3) +
  5e         # a(n-5)

Pyth, 9 bytes
/sM{y*P30

Try it here!
Pyth, 16 bytes
l{s.pMfqT@P30T./

Try it here
How?

Generates the prime factors of 30, namely [2, 3, 5], gets the powerset of it repeated N times, removes duplicate elements, sums each list and counts the occurrences of N in that.

For each integer parition p, it checks whether p equals p ∩ primefac(30). It only keeps those that satisfy this condition, and for each remaining partition k, it gets the list of k's permutations, flattens the resulting list by 1 level, deduplicates it and retrieves the length.

Jelly, 11 bytes
5ÆRẋHŒPQḅ1ċ

Try it online!
How it works

5ÆRẋHŒPQḅ1ċ -> Full program. Argument: N, an integer.
5ÆR         -> Pushes all the primes between 2 and 5, inclusively.
   ẋH       -> Repeat this list N / 2 times.
     ŒP     -> Generate the powerset.
       Q    -> Remove duplicate entries.
        ḅ1  -> Convert each from unary (i.e. sum each list)
          ċ -> Count the occurrences of N into this list.

Speed it up by replacing ³ with H (then it will time out at 12 rather than 6)

@JonathanAllan Done, thanks.

Perl, 38 bytes
Includes +1 for p
perl -pE '$_=1x$_;/^(...?|.{5})+$(?{$\++})\1/}{' <<< 11; echo

Interesting enough I have to use \1 to force backtracking. Usually I use ^ but the regex optimizer seems too smart for that and gives too low results. I'll probably have to start giving perl version numbers when using this trick since the optimizer can change at every version. This was tested on perl 5.26.1
This 49 is efficient and can actually handle X=100 (but overflows on X=1991)
perl -pe '$\=$F[@F]=$F[-2]+$F[-3]+$F[-5]for($F[5]=1)..$_}{' <<< 100;echo

I only just now learned that you did this 3 years before my Fibonacci answer. I wonder why you didn't apply this to Fibonacci? Anyway, I've been now extending the idea much further, answering various challenges with regex ``-output (output by number of possible matches), and added it as a built-in to RegexMathEngine.

Also, you can do this in 3 fewer bytes, as done in my Fibonacci answer but without -p. And obligatory note: With the $\ and }{ trick you're doing, the program will still try to loop, but it won't reset the value of $\, so it only works properly when given one number followed by EOF.

JavaScript (ES6), 32 bytes
Same algorithm as in ovs' Python answer.
f=n=>n>0?f(n-2)+f(n-3)+f(n-5):!n

Test cases

f=n=>n>0?f(n-2)+f(n-3)+f(n-5):!n

console.log(f(8))
console.log(f(11))
console.log(f(13))

05AB1E, 10 bytes
30fIиæÙOI¢

Try it online!

C, 41 bytes
G(x){return x>0?G(x-2)+G(x-3)+G(x-5):!x;}

Try it online!

R, 56 49 47 bytes
Recursive approach from ovs's answer. Giuseppe shaved off those final two bytes to make it 47.
f=pryr::f(+`if`(x<5,x!=1,f(x-2)+f(x-3)+f(x-5)))

Try it online!

48 bytes

@Giuseppe Very nice improvement!

ah, you don't need the 0 (I didn't consider that before), as unary + will coerce to numeric as well.

Wolfram Language (Mathematica), 43 bytes
Tr[Multinomial@@@{2,3,5}~FrobeniusSolve~#]&

Try it online!
Explanation: FrobeniusSolve computes all solutions of the unordered sum 2a + 3b + 5c = n, then Multinomial figures out how many ways we can order those sums.
Or we could just copy everyone else's solution for the same byte count:
f@1=0;f[0|2|3|4]=1;f@n_:=Tr[f/@(n-{2,3,5})]

MATL, 15 bytes
:"5Zq@Z^!XsG=vs

Very inefficient: required memory is exponential.
Try it online!
How it works
:"       % For each k in [1 2 ... n], where n is implicit input
  5Zq    %   Push primes up to 5, that is, [2 3 5]
  @      %   Push k
  Z^     %   Cartesian power. Gives a matrix where each row is a Cartesian k-tuple
  !Xs    %   Sum of each row
  G=     %   Compare with input, element-wise
  vs     %   Concatenate all stack contents vertically and sum
         % Implicit end. Implicit display

Pari/GP, 32 bytes
n->1/(1-x^2-x^3-x^5)%x^(n+1)\x^n

Try it online!

Ruby, 41 bytes
f=->n{n<5?n==1?0:1:[n-5,n-2,n-3].sum(&f)}

Try it online!
This is a recursive solution, the recurcive call being: [n-5,n-2,n-3].sum(&f).

Regex  (ECMAScriptRME / Perl / PCRE / Raku:P5), 14 bytes
^(xxx?|x{5})*$

Takes its input in unary, as a string of x characters whose length represents the number. Returns its output as the number of ways the regex can match. (The rabbit emoji indicates this output method.)
Try it on replit.com (RegexMathEngine)
Try it online! - Perl
Try it online! - PCRE1
Try it online! - PCRE2
Try it online! - Raku
Same method as used for Fibonacci function or sequence, directly enumerating the ordered partitions.
^          # tail = input number
(
    xxx?   # tail-=2 or tail-=3
|          # or
    x{5}   # tail-=5
)*         # Loop the above as many times as possible, minimum zero
$          # Assert tail == 0

Regex  (Raku), 14 bytes
^(xxx?|x**5)*$

Try it online!
Raku's plain regex alternation operator is ||, and | does something special – it chooses the alternative making the longest match. But it'll still try every alternative when backtracking, so this makes no difference in the number of matches.
Perl, 38 bytes (full program)
1x<>~~/^(...?|.{5})*$(??{++$i})/;say$i

Try it online!
Interestingly, I noticed after making this post that Ton Hospel already used the same basic method (and it predates my Perl Fibonacci answer by 3 years), but did it with Perl -p in 37 bytes (which can be reduced to 34 bytes), by exploiting Perl actually using literal { } to create the -p loop. I previously assumed Perl emulated a loop when launched with -p, not that it literally string-concatenated the program into a loop.
Using the $\ trick (setting the print record separator), there's an alternative 38 byte flagless full program:
1x<>~~/^(...?|.{5})*$(??{++$\})/;print

Try it online!
Sadly it's only literally a print record separator and doesn't apply to say.
Raku, 27 bytesSBCS (anonymous function)
{+m:ex/^(...?|.**5)*$/}o¹x*

Try it online!

Vyxal, 9 bytes
⁺¤fẋfṗUṠO

Try it Online!
The header in the link halves the input to make things faster. It will return the same result if you remove it, but it may time out.
⁺¤f could alternatively be 30ǐ (prime factors of 30) or 5~æ (prime numbers up to 5).
⁺¤fẋfṗUṠO
⁺¤f       # Push the digits of 235: [2, 3, 5]
   ẋf     # Repeat the list the input times
     ṗ    # Powerset
      U   # Uniquify
       Ṡ  # Sum each
        O # Count the number of times the input appears in this array

Desmos, 101 bytes
l=mod(floor(nk/n^{[1,2,3]}),n)
f(n)=∑_{k=1}^{n^3}0^{(n-total([2,3,5]l))^2}l.total!/∏_{a=1}^3l![a]

Ugh, no recursion sucks. I literally see all these answers going f(n-2)+f(n-3)+f(n-5), like super golfy, but nope, can't do that in Desmos.
Try It On Desmos!
Try It On Desmos! - Prettified

Prolog (SWI), 50 bytes
N+O:-N>0,N-2+A,N-3+B,N-5+C,O is A+B+C;N<0,O=0;O=1.

Try it online!

Jelly, 21 bytes
Œṗe€2,3,5$Ạ$ÐfŒ!Q$€ẎL

Try it online!
Surely can be golfed

Pyth, 12 bytes
l{fqQsTy*P30

This is horrendously inefficient and hits the memory limit for inputs above 5.
Try it online
Explanation
l{fqQsTy*P30
         P30   Get the prime factors of 30 [2, 3, 5].
        *   Q  Repeat them (implicit) input times.
       y       Take the power set...
  fqQsT        ... and filter the ones whose sum is the input.
l{             Count unique lists.

Proton, 32 bytes
f=n=>n>0?f(n-2)+f(n-3)+f(n-5):!n

Try it online!
Same approach as ovs' answer.

JS polyglot :-)

Haskell, 40 bytes
f 0=1
f n|n<0=0|1>0=f(n-2)+f(n-3)+f(n-5)

Try it online!

05AB1E, 8 bytes
1λèƵ†S₆O

Port of @ovs' Python 2 answer.
Try it online or verify all test cases.
Outputting the infinite sequence would be 6 bytes instead:
λƵ†S₆O

Try it online.
Explanation:
 λ        # Start a recursive environment
  è       # to output the (implicit) input'th value
          # (which is output implicitly in the end)
1         # Starting with a(0)=1, and a(-1)=a(-2)=a(-3)=a(-4)=0
          # And where every next a(n) is calculated as:
   Ƶ†     #  Push compressed integer 235
     S    #  Convert it to a list of digits: [2,3,5]
      ₆   #  Calculate a(n-v) for each value v in this list: [a(n-2),a(n-3),a(n-5)]
       O  #  Sum this list together: a(n-2)+a(n-3)+a(n-5)

λ         # Start a recursive environment
          # to output the infinite sequence
          # (which is output implicitly in the end)
          # (implicitly starting with a(0)=1, and a(-1)=a(-2)=a(-3)=a(-4)=0)
          # And where every next a(n) is calculated as:
 Ƶ†S₆O    #  Same as above

See this 05AB1E tip of mine (section How to compress large integers?) to understand why Ƶ† is 235.

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


text:
Reduced Factorization Leader Changes
tl;dr: Output the values where the reduced prime factorization leader changes.
Every positive integer has a unique prime factorization. Let's call the reduced prime factorization just the list of multiplicity of the prime factors, ordered by the size of the factors. For instance, the reduced prime factorization of 1980 is [2, 2, 1, 1], because 1980 = 2 * 2 * 3 * 3 * 5 * 11.
Next, let's record how often each reduced prime factorization happens, over integers in [1, 2, ..., n]. For instance, in [1, 2, ..., 10], the following reduced prime factorizations occur:
[1]: 4 (2, 3, 5, 7)
[2]: 2 (4, 9)
[1, 1]: 2 (6, 10)
[]: 1 (1)
[3]: 1 (8)

We'll call the leader up to n the reduced prime factorization that occurs the most often over [1, 2, ..., n]. Therefore, the reduced prime factorization leader for n = 10 is [1]. Ties will be broken by the size of the largest integer less than or equal to n with that reduced prime factorization, with smaller largest integer being better. For instance, up to n = 60, the reduced prime factorizations [1] and [1, 1] occur 17 times each. The maximum integer in that range giving [1, 1] is 58, while the maximum integer giving [1] is 59. Therefore, with n = 60, the reduced prime factorization leader is [1, 1].
I'm interested in the values of n where the reduced prime factorization leader changes. Those are the values of n where the reduced prime factorization leader is different from the reduced prime factorization leader up to n-1. As an edge case, we will say that the leadership changes at n = 1, because a leader does not exist for n = 0.
Your challenge is to output.
An initial sequence of the desired output is:
1, 3, 58, 61, 65, 73, 77, 1279789, 1280057, 1280066, 1280073, 1280437, 1280441, 1281155, 1281161, 1281165, 1281179, 1281190, 1281243, 1281247, 1281262, 1281271, 1281313, 1281365

Allowed output styles are:

Infinite output.
The first k leader changes, where k is the input.
The kth leader change, where k is the input.

k may be zero or one indexed.
This is code-golf. If you're not sure about anything, ask in the comments. Good luck!

What about  the leader changes with value at most / less than k?

@user202729 I'm going to say no - that makes the challenge a bit too different.

Since you have defined the idea for positive integers you might want to allow people to start the sequence at either 1 or 3. (or change "Those are the values of n where the reduced prime factorization leader is different from the reduced prime factorization leader up to n-1")

@JonathanAllan I'm not changing things, but I clarified the relevant part of the challenge.

Husk, 18 bytes
m←ġ(←►Lk=mȯmLgpṫ)N

Try it online!
This prints the infinite list.
The link truncates the result to the first 7 values, since the program is quite inefficient and times out after that on TIO.
The parentheses are ugly, but I don't know how to get rid of them.
Explanation
m←ġ(←►Lk=mȯmLgpṫ)N  No input.
                 N  The list of natural numbers [1,2,3,4,..
  ġ(            )   Group into slices according to this function.
                    Each slice corresponds to a run of numbers with equal return values.
    ←►Lk=mȯmLgpṫ    Function: from n, compute the reduced factorization leader in [1..n].
                     As an example, take n = 12.
               ṫ     Reversed range: [12,11,10,9,8,7,6,5,4,3,2,1]
         m           Map over this range:
              p       Prime factorization: [[2,2,3],[11],[2,5],[3,3],[2,2,2],[7],[2,3],[5],[2,2],[3],[2],[]]
             g        Group equal elements: [[[2,2],[3]],[[11]],[[2],[5]],[[3,3]],[[2,2,2]],[[7]],[[2],[3]],[[5]],[[2,2]],[[3]],[[2]],[]]
          ȯmL         Take length of each run: [[2,1],[1],[1,1],[2],[3],[1],[1,1],[1],[2],[1],[1],[]]
       k=            Classify by equality: [[[2,1]],[[1],[1],[1],[1],[1]],[[1,1],[1,1]],[[2],[2]],[[3]],[[]]]
                     The classes are ordered by first occurrence.
     ►L              Take the class of maximal length: [[1],[1],[1],[1],[1]]
                     In case of a tie, ► prefers elements that occur later.
    ←                Take first element, which is the reduced factorization leader: [1]
                    The result of this grouping is [[1,2],[3,4,..,57],[58,59,60],[61,62,63,64],..
m←                  Get the first element of each group: [1,3,58,61,65,73,77,..

Why does ►= not work. Does maxBy not prefer later elements?

@H.PWiz The problem is that in case of a tie, I need to prefer the maximizing element whose first occurrence in the reversed range is the latest possible, or equivalently, whose last occurrence in the increasing range is the earliest possible. ►= does neither.

JavaScript (ES6), 120 bytes
Returns the N-th leader change, 1-indexed.
N=>(F=m=>N?F((F[k=(D=(n,d=2,j)=>d>n?j:n%d?D(n,d+1)+(j?[,j]:[]):D(n/d,d,-~j))(++n)]=-~F[k])>m?F[N-=p!=k,p=k]:m):n)(n=p=0)

Demo

let f =

N=>(F=m=>N?F((F[k=(D=(n,d=2,j)=>d>n?j:n%d?D(n,d+1)+(j?[,j]:[]):D(n/d,d,-~j))(++n)]=-~F[k])>m?F[N-=p!=k,p=k]:m):n)(n=p=0)

for(let n = 1; n <= 7; n++) {
  console.log('a(' + n + ') = ' + f(n))
}

Commented
Helper function D(), returning the reduced prime factorization of n in reverse order:
D = (n, d = 2, j) =>             // n = input, d = divisor, j = counter
  d > n ?                        // if d is greater than n:
    j                            //   append j and stop recursion
  :                              // else:
    n % d ?                      //   if d is not a divisor of n:
      D(n, d + 1) + (            //     recursive call with n unchanged and d = d + 1
        j ?                      //     if j is not undefined:
          [,j]                   //       append a comma followed by j
        :                        //     else:
          []                     //       append nothing
      )                          //
    :                            //   else:
      D(n / d, d, -~j)           //     recursive call with n divided by d and j = j + 1

Main function:
N =>                             // N = target index in the sequence
  (F = m =>                      // m = # of times the leader has been encountered
    N ?                          // if N is not equal to 0:
      F(                         //   do a recursive call to F():
        (F[k = D(++n)] =         //     increment n; k = reduced prime factorization of n
                         -~F[k]) //     increment F[k] = # of times k has been encountered
        > m ?                    //     if the result is greater than m:
          F[N -= p != k,         //       decrement N if p is not equal to k
                         p = k]  //       update p and set m to F[p]
        :                        //     else:
          m                      //       let m unchanged
      )                          //   end of recursive call
    :                            // else:
      n                          //   stop recursion and return n
  )(n = p = 0)                   // initial call to F() with m = n = p = 0

Stax, 24 bytes
Ç▓Δk/‼&²Θºk∙♥╜fv╛Pg8╝j♀§

This program takes no input and theoretically produces infinite output.  I say "theoretically" because the 8th element will take more than a year.
Run and debug it
The corresponding ascii representation of the same program is this.
0WYi^{|n0-m|=c:uny=!*{i^Q}Md

It keeps the last leader on the stack.  Iterating over integers, if there's a distinct mode in the factor representation, and it's different than the last one, output it.
0                               push zero for a placeholder factorization
 W                              repeat the rest of the program forever
  Y                             store the last factorization in the y register
   i^                           i+1 where i is the iteration index
     {    m                     using this block, map values [1 .. i+1]
      |n0-                          get the prime exponents, and remove zeroes
           |=                   get all modes
             c:u                copy mode array and test if there's only one
                ny=!            test if mode array is not equal to last leader
                    *           multiply; this is a logical and
                     {   }M     if true, execute this block
                      i^Q       push i+1 and print without popping
                           d    discard the top of stack
                                    if it was a leader change, this pops i+1
                                    otherwise it pops the mode array
                                at this point, the last leader is on top of
                                the stack

Python 2, 145 bytes
m=i=0;f=[]
while 1:
 i+=1;a=i;d=[0]*-~i;k=2
 while~-a:x=a%k>0;k+=x;a/=x or k;d[k]+=1-x
 k=filter(abs,d);f+=k,;c=f.count
 if c(k)>c(m):print i;m=k

Try it online!
Ungolfed
m=0                    # reduced prime factorizations leader
i=0                    # current number
f=[]                   # list of reduced prime factorizations
while 1:               # Infinite loop:
  i+=1                 #   next number
  a=i                  #   a is used for the prime factorization
  d=[0]*-~i            #   this lists stores the multiplicity
  k=2                  #   current factor
  while~-a:            #   As long as a-1 != 0:
    x=a%k>0            #      x := not (k divides a)
    k+=x               #      If k does not divide a, go to the next factor
    a/=x or k          #      If k does not divide a,
                       #         divide a by 1,
                       #         else divide it by k
    d[k]+=1-x          #      add 1 to the multiplicity of k if k divides a
  k=filter(abs,d)      #   Only keep non-zero multiplicities
                       #     k is now the reduced prime factorization of i
  f+=k,                #   append k to the list of reduced prime factorizations
  c=f.count            #   c(x) := number of occurences of x in f
  if c(k)>c(m):        #   has the current reduced prime factorization
                       #    appeared more often than the leader?
    print i;m=k        #     print the current number, set new leader

Try it online!

Jelly,  35  34 bytes
I feel like it's still golfable
ÆEḟ0µ€ĠL€M⁸’ß¤¹Ṗ?
®‘©Ç€F0;ITµL<³µ¿

A full program taking k and outputting a Jelly list representation of the first k leader change points.
Try it online!


text:
Counting polystrips
Polystrips are a subset of polyominoes conforming to the following rules:

each piece consist of 1 or more cells
no cell can have more than two neighbours
the cells should not enclose a hole

Free polyominoes are distinct when none is a rigid transformation (translation, rotation, reflection or glide reflection) of another (pieces that can be picked up and flipped over). Translating, rotating, reflecting, or glide reflecting a free polyomino does not change its shape (Wikipedia)
For example, there are 30 free heptastrips (polystrips with length 7). Here are all of them, packed into a 14x15 grid.

Image credit: Miroslav Vicher
Goal
Write a program / function that takes a positive integer n as input and enumerates the distinct free n-polystrips.

n=1 --> 1 (A single square)
n=2 --> 1 (There is only one possible 2-polystrip made of 2 squares)
n=3 --> 2 (One is composed of 3 squares joined in a line and the
other one is L-shaped)
n=4 --> 3 (One straight, one L-shaped and one Z-shaped)
. . .

Test cases:
n   polystrips

1   1
2   1
3   2
4   3
5   7
6   13
7   30
8   64
9   150
10  338
11  794
12  1836
13  4313
14  10067
15  23621

Scoring
This is code-golf, so the shorter code is better. I would highly appreciate detailed explanations of the algorithm and the code.
Partial reference implementation in J
I decided to describe each piece in "vector" format and I only need n-2 blocks to describe an n-polystrip piece (there is only 1 2-polystrip and it's returned explicitly). The blocks describe the relative direction: 0 - no change; 1 - turn left; 2 - turn right. It doesn't matter which direction one will start but only to indicate where the next cell is to be put. There can be any number of consecutive 0s, but 1s and 2s are always single.
This implementation is partial, because it doesn't account for the holes - solutions for n>6 count the pieces with holes too.
Try it online!

Relevant OEIS. (But doesn't exclude holes.)

@ Martin Ender Thank you, I didn't know it.

Just to be sure, I assume that if you fill a 3x3 grid except for the center and one corner that also counts as a hole (101010 in your sample notation) ?

@Ton Hospel Yes, exactly - this is the only heptastrip piece with a hole.

Out of curiosity, do you know if a rectangular packing is possible for all numbers?

@Jonah No, I don't know. Three years ago I experimented with hexa- and heptastrips (they do) - I think they would be a good alternative for a puzzle game similar to Nikoli's Numberlink where all lines have equal length.

Perhaps a good question for math.SE

Did you know that now this is https://oeis.org/A333313? You can ask the author (who is a fellow golfer) to add your name in the OEIS entry.

Python 3, 480 433 406 364 309 299 295 bytes
Looked like a good point to start my PPCG career (or not?).
def C(s):
 S,*a={''},0,1;n=d=r=1
 for c in s:d=c*d*1jor d;n+=d;a+=n,;r*=not{n}&S;x,*a=a;S|={x+t+u*1jfor t in A for u in A}
 return r
from itertools import*;A=-1,0,1;n,y=int(input())-2,0;x={*filter(C,product(*[A]*n))}
while x:s=x.pop();S=*(-u for u in s),;x-={s[::-1],S,S[::-1]}-{s};y+=1
print(y)

Try it online!
Edits:

Inlined D and X, and tweaked a little bit on some golfable spots.
Applied more tricks, mainly set-related ones.
Changed into program form, and changed to using complex numbers instead of arbitrary number m. (Complex numbers are really a strong but often ignored golfy feature; adapted from xnor's solution for another challenge)
Changed the LFR string representation to -1,0,1 tuples and sacrificed execution time for crazy amount of byte reduction(!). Now the solution is theoretically correct but timeouts before outputting the result for 15.
One-lined the loop thanks to Jonathan Frech, then I found the much better alternative for calculating r. FINALLY UNDER 300 BYTES!!!
Surprisingly 1j can stick to anything else without confusing the parser (-2B), and not has insanely low precedence (-2B).

Obsolete version (480 bytes):
def C(s):
 m=999;a=[0,1];n=d=1
 D={'F':{},'L':{1:m,m:-1,-1:-m,-m:1},'R':{1:-m,-m:-1,-1:m,m:1}}
 X=lambda x:{x+~m,x-m,x-m+1,x-1,x,x+1,x+m-1,x+m,x-~m}
 for c in s:
  d=D[c].get(d,d);n+=d;a+=n,
  if n in set().union(*map(X,a[:-3])):return 0
 return 1
def f(n):
 if n<3:return 1
 x={*'LF'}
 for _ in range(3,n):x={s+c for s in x for c in({*'LRF'}-{s[-1]})|{'F'}}
 y={*x}
 for s in x:
  if s in y:S=s.translate(str.maketrans('LR','RL'));y-={s[::-1],S,S[::-1]}-{s}
 return sum(map(C,y))

Try it online!
Ungolfed solution with comments:
t = str.maketrans('LR','RL')

# hole checking function
def check(s):
    m = 999   # (imaginary) board size enough to fit all generated polyominoes
    a = [0,1] # previous path
    n = 1     # current cell
    d = 1     # current direction
    # dict for direction change
    D = {'F':{}, 'L':{1:m, m:-1, -1:-m, -m:1}, 'R':{1:-m, -m:-1, -1:m, m:1}}
    # used to 'blur' all cells in path into 3x3
    X = lambda x: {x-m-1,x-m,x-m+1,x-1,x,x+1,x+m-1,x+m,x+m+1}
    for c in s:
        d = D[c].get(d,d) # change direction
        n += d            # move current cell
        # the polyomino has a hole if the current cell touches previous cells (including diagonally; thus the blurring function)
        if n in set().union(*map(X,a[:-2])): return False
        a.append(n)       # add current cell to the path
    return True

# main function
def f(n):
    if n < 3: return 1
    x = {*'LF'}
    # generate all polystrips using the notation similar to the reference
    for _ in range(3, n): x = {s+c for s in x for c in ({*'LRF'}-{s[-1]})|{'F'}}
    y = {*x}
    # remove duplicates (mirror, head-to-tail, mirror of head-to-tail) but retain self
    for s in x:
        if s in y:
            S = s.translate(t)
            y -= {s[::-1], S, S[::-1]} - {s}
    # finally filter out holey ones
    return sum(map(check,y))

Try it online!
m = 999 is chosen because it takes exponential time to count everything, and it's already taking ~8s to calculate n = 1..15. Maybe it's fine to save 1 byte by using 99 instead. We don't need this anymore, and now it's guaranteed to be correct for arbitrary input size, thanks to complex number built-in.

Welcome to PPCG! Definitely an impressive way to start your PPCG career. :)

Welcome to PPCG and thanks for this solution! I had already given up expecting to see a solution :)

Looked like a good point to start my PPCG career (or not?). Well, this is a surprisingly short solution to this most of us wouldn't even think could ever be, even the ungolfed version looks surprisingly simple, but, eh, maybe this is an average way to start your PPCG career, right? :)

@Erik That line was half a joke :) But yeah, the solution is even surprising to me - I never expected myself to pull out ~36% reduction from original submission.

Possible 306 bytes.

Possible 305 bytes.

Possible 303 bytes.

@JonathanFrech Thanks, and I could rearrange the set operation to get it under 300. This is getting really crazy...

x+t*1j+u for can be x+u+t*1jfor.

c*1j*d or can be c*d*1jor.

APL (Dyalog Unicode), 70 65 bytes
+/{∧/∊2≤|(⊢-¯3↓¨,\)+\0 1,×\0j1*⍵}¨∪{(⊃∘⍋⊃⊢)(⊢,⌽¨)⍵(-⍵)}¨2-,⍳2↓⎕⍴3

Try it online!
Full program version of the code below, thanks to Adám.

APL (Dyalog Unicode), 70 bytes
{+/{∧/∊2≤|(⊢-¯3↓¨,\)+\0 1,×\0j1*⍵}¨∪{(⊃∘⍋⊃⊢)(⊢,⌽¨)⍵(-⍵)}¨2-,⍳3⍴⍨0⌈⍵-2}

Try it online!
How it works
The code above is equivalent to the following definition:
gen←{2-,⍳3⍴⍨0⌈⍵-2}
canonicalize←{(⊃∘⍋⊃⊢)(⊢,⌽¨)⍵(-⍵)}
test←{(∧/⊢{∧/2≤|⍺-¯3↓⍵}¨,\)+\0 1,×\0j1*⍵}
{+/test¨∪canonicalize¨gen⍵}

This works like the Python solution, but in a different order. It generates LFR-strips of length n-2, canonicalizes each strip, takes ∪nique strips, tests each strip if it touches itself (1 if not touching, 0 otherwise), and sums +/ the boolean result.
gen
{2-,⍳3⍴⍨0⌈⍵-2}
{            }  ⍝ ⍵←input number n
        0⌈⍵-2   ⍝ x←max(0, n-2)
     3⍴⍨        ⍝ x copies of 3
   ,⍳           ⍝ multi-dimensional indexes; x-th cartesian power of [1,2,3]
                ⍝ (`⍳` gives x-dimensional hypercube; `,` flattens it)
 2-             ⍝ compute 2-k for each k in the array

⍝ in each strip, ¯1, 0, 1 corresponds to R, F, L respectively

canonicalize
{(⊃∘⍋⊃⊢)(⊢,⌽¨)⍵(-⍵)}
{                  }  ⍝ ⍵←single strip
              ⍵(-⍵)   ⍝ nested array of ⍵ and its LR-flip
        (⊢,⌽¨)        ⍝ concatenate their head-to-tail flips to the above
 (⊃∘⍋  )              ⍝ find the index of the lexicographically smallest item
     ⊃⊢               ⍝ take that item

test
{(∧/⊢{∧/2≤|⍺-¯3↓⍵}¨,\)+\0 1,×\0j1*⍵}
{                                  }  ⍝ ⍵←single strip
                              0j1*⍵   ⍝ power of i; direction changes
                            ×\        ⍝ cumulative product; directions
                        0 1,    ⍝ initial position(0) and direction(1)
                      +\        ⍝ cumulative sum; tile locations
 (  ⊢{           }¨,\)   ⍝ test with current tile(⍺) and all tiles up to ⍺(⍵):
             ¯3↓⍵        ⍝ x←⍵ with last 3 tiles removed
           ⍺-            ⍝ relative position of each tile of x from ⍺
        2≤|              ⍝ test if each tile of x is at least 2 units away
      ∧/                 ⍝ all(...for each tile in x)
  ∧/        ⍝ all(...for each position in the strip)

-5

Scala, 2277 1710 bytes*:
Modified from @Bubbler's answer.
Golfed version
Try it online!
import scala.collection.mutable.Set

object Main {
  def checkSeq(s: String): Boolean = {
    val max = BigInt(9).pow(9)
    var a = Seq(BigInt(0), BigInt(1))
    var n = BigInt(1)
    var d = BigInt(1)
    val dirs = Map(
      'F' -> Map[BigInt, BigInt](),
      'L' -> Map(BigInt(1) -> max, max -> BigInt(-1), BigInt(-1) -> -max, -max -> BigInt(1)),
      'R' -> Map(BigInt(1) -> -max, -max -> BigInt(-1), BigInt(-1) -> max, max -> BigInt(1))
    )
    val adj = (x: BigInt) => Set(x - max - 1, x - max, x - max + 1, x - 1, x, x + 1, x + max - 1, x + max, x + max + 1)

    s.foreach { c =>
      d = dirs(c).getOrElse(d, d)
      n += d
      val v1 = if (a.length > 2) a.slice(0, a.length - 2).map(adj) else Seq()
      val s1 = if (v1.isEmpty) Set[BigInt]() else v1.reduce(_ ++ _)
      if (s1.contains(n)) return false
      a = a :+ n
    }
    true
  }

  def f(n: Int): Int = {
    if (n < 3) return 1

    var x = Set("L", "F")
    (3 until n).foreach { _ =>
      x = x.flatMap { seq =>
        val chars = Set('L', 'R', 'F') - seq.last + 'F'
        chars.map(c => seq + c)
      }
    }

    var y = x.clone()
    x.foreach { seq =>
      if (y.contains(seq)) {
        val trSeq = seq.replace("L", "#").replace("R", "L").replace("#", "R")
        val s1 = Set(seq.reverse, trSeq, trSeq.reverse)
        y --= s1.diff(Set(seq))
      }
    }

    y.count(checkSeq)
  }

  def main(args: Array[String]): Unit = {
    val t1 = System.nanoTime()
    (1 to 15).foreach { i =>
      val t2 = System.nanoTime()
      val res = f(i)
      val t3 = System.nanoTime()
      println(s"$i $res ${t3 - t2}ns")
    }
    val t4 = System.nanoTime()
    println(s"Total time: ${(t4 - t1) / 1000000.0}ms")
  }
}

Ungolfed version
Try it online!
import scala.collection.mutable.Set

object Main {
  def checkSequence(s: String): Boolean = {
    val maxValue = BigInt(9).pow(9)
    var a = Seq(BigInt(0), BigInt(1))
    var n = BigInt(1)
    var d = BigInt(1)
    val directions = Map(
      'F' -> Map[BigInt, BigInt](),
      'L' -> Map[BigInt, BigInt](BigInt(1) -> maxValue, maxValue -> BigInt(-1), BigInt(-1) -> -maxValue, -maxValue -> BigInt(1)),
      'R' -> Map[BigInt, BigInt](BigInt(1) -> -maxValue, -maxValue -> BigInt(-1), BigInt(-1) -> maxValue, maxValue -> BigInt(1))
    )
    val calculateAdjacent = (x: BigInt) => Set(x - maxValue - 1, x - maxValue, x - maxValue + 1, x - 1, x, x + 1, x + maxValue - 1, x + maxValue, x + maxValue + 1)   // return a set

    for (c <- s) {
      d = directions(c).getOrElse(d, d)
      n += d
      val var1 = if (a.length > 2) a.slice(0, a.length - 2).map(calculateAdjacent) else Seq()
      val set1 = if (var1.isEmpty) Set[BigInt]() else var1.reduce(_ ++ _)
      if (set1.contains(n)) {
        return false
      }
      a = a :+ n
    }
    true
  }

  def f(n: Int): Int = {
    if (n < 3) {
      return 1
    }

    var x = Set("L", "F")
    for (i <- 3 until n) {
      val newSet = Set[String]()
      for (sequence <- x) {
        var characters = Set('L', 'R', 'F') - sequence.last
        characters += 'F'
        for (character <- characters) {
          newSet += sequence + character
        }
      }
      x = newSet
    }

    var y = x.clone()
    for (sequence <- x) {
      if (y.contains(sequence)) {
        val translatedSequence = sequence.replace("L", "#").replace("R", "L").replace("#", "R") //exchange 'L' and 'R' in sequence
        val set1 = Set(sequence.reverse, translatedSequence, translatedSequence.reverse)
        val set2 = Set(sequence)
        val setDifference = set1.diff(set2)
        y --= setDifference
      }
    }

    y.count(checkSequence)
  }

  def main(args: Array[String]): Unit = {
    val t1 = System.nanoTime()
    for (i <- 1 to 15) {
      val t2 = System.nanoTime()
      val result = f(i)
      val t3 = System.nanoTime()
      println(i + " " + result + " " + (t3 - t2) + "ns")
    }
    val t4 = System.nanoTime()
    val elapsedMs = (t4 - t1) / 1000000.0
    println("Total time: " + elapsedMs + "ms")
  }
}

* Rather long in bytes, but computes solutions up to and including \$n=15\$
around 15 seconds on TIO.

Great answer, but all answers to [tag:code-golf] challenges must show at least some golfing effort. An easy way to achieve it is to remove all unnecessary spaces and newlines, and use shorter variable names. (You can still keep the ungolfed version in the answer; just be sure to put the golfed one at the top.)


text:
Convert a number to Korean
Goal
You will be given a positive integer number less than 10^20. You must convert it to Korean.
For example, if the input is 12345, the output should be 일만이천삼백사십오.
Technical details (Small)
Let's starts with simple numbers.
// 1 - 9
1 -> 일
2 -> 이
3 -> 삼
4 -> 사
5 -> 오
6 -> 육
7 -> 칠
8 -> 팔
9 -> 구

// 10, 100, 1000
10 -> 십
100 -> 백
1000 -> 천

You can concatenate 2 ~ 9 front of 10, 100, 1000.
However, you should not concatenate 1 front of 10, 100, 1000.
// 20 = 2 * 10
20 -> 이십

// 300 = 3 * 100
300 -> 삼백

// 9000 = 9 * 1000
9000 -> 구천

// 1000 is just 1000
1000 -> 천

For integer less than 10000, below rule is used for pronunciation.
// 1234 = 1000 + 200 + 30 + 4
1234 -> 천이백삼십사

// 1002 = 1000 + 2
1002 -> 천이

// 2048 = 2000 + 40 + 8
2048 -> 이천사십팔

// 510 = 500 + 10
510 -> 오백십

// 13 = 10 + 3
13 -> 십삼

Technical details (Large)
Now let's go to the hard part.
First, you need to know some parts used in larger numbers:
1 0000 -> 만
1 0000 0000 -> 억
1 0000 0000 0000 -> 조
1 0000 0000 0000 0000 -> 경

When Koreans pronounce big numbers

Cut it with width 4
Convert each of them using methods for less than 10000
Combine them with default form of big numbers

Here is some detailed examples. (I added some space to korean for readability)
// 12345678 = 1234 5678
// 1234 -> 천이백삼십사
// 5678 -> 오천육백칠십팔
12345678 -> 천이백삼십사 만 오천육백칠십팔

// 11122223333 = 111 2222 3333
// 111 -> 백십일
// 2222 -> 이천이백이십이
// 3333 -> 삼천삼백삼십삼
11122223333 -> 백십일 억 이천이백이십이 만 삼천삼백삼십삼

// 10900000014 = 109 0000 0014
// 109 -> 백구
// 0000 -> (None)
// 0014 -> 십사
10900000014 -> 백구 억 십사

// 100000000 -> 1 0000 0000
// 1 -> 일
// 0000 -> (None)
// 0000 -> (None)
100000000 -> 일 억

Here are some more examples.
Rule
You can make your program gets input from stdin and output to stdout, or make a function that gets string/integer and returns string.
This is code-golf, so answers will be scored in bytes with fewer bytes being better.

@JonathanAllan 일억 is correct form of 100000000. 억 is a unit that cannot used alone.

Thanks for clarification I've edited the post very slightly for clarity.

Oh well now people are getting inspired on my question.

Aheui, 1555 bytes
살밦발따밝따빠따밦발다빠따다빠밞빠따받다빠따밝발따두
수터더떠벋벓떠뻐더벖떠뻐벍뻐터터떠벌벖떠뻐떠벋벎뻐더
방뺘우차빠발발다빠따빠뚜
우노여뗘뻐떠뻐더벌벌썪러
샦우싹어
아삳부
ㅇ아삭뺘우차빠불
ㅇ유어우여려더벌
ㅇ요ㅇ빠받반타탸우처삳뺘우처밝밤뚜
ㅇㅇ우쑨여텨여볋여뗘여뼈여뎌벅떠벓
ㅇ요아삭뺘우차삳빠박탸유처발불
ㅇㅇ우어ㅇ여따뱖볆뚜텨벎떠뻐떠
ㅇ요ㅇ우어쎤여뎌여별여어
ㅇㅇㅇ빠밤탸우처밣빠따밞다뿌
ㅇ요ㅇ우어쎤여뗘벎더떠벋벓떠
ㅇㅇㅇ빠밦탸우처밞밦따빠뚜
ㅇ뇨ㅇ숙어쎤여뗘벎떠벅터벖
ㅇㅇㅇ빠박탸우처밝밤따밣따북
ㅇ됴ㅇ우어썬여텨더벓벓떠뻐더
ㅇㅇㅇ빠받탸우처밣밝다빠따붇
ㅇ뵬ㅇ우어썬여뎌떠벍벓떠뻐터
ㅇㅇㅇ빠밤탸우처밣밝다빠따붇
ㅇ뵬ㅇ우어썬여뎌떠벌벓떠뻐터
ㅇㅇㅇ빠발탸우처밣밝다빠따뿌
ㅇ묘ㅇ우어썬여뎌떠벎더벌벖떠
ㅇㅇㅇ빠밦탸우처밣밝다빠따빠뚜
ㅇ쇽ㅇ우어썬여뎌떠벓더벓떠뻐벖
ㅇㅇㅇ빠밝탸우처밞밞따빠따붒
ㅇ됴ㅇ우어썬여뗘벓더더벍떠뻐
ㅇㅇㅇ빠밣탸우처발발따발따붒
ㅇ뵥ㅇ우어썬여뗘벎더범떠벓떠
ㅇㅇㅇ빠밟탸우처밝발따빠따붏
ㅇ숃어어어쎤여뎌벓떠벎떠범더
ㅇ마샬우싹샥우파뺘무차파쑨
ㅇㅇ오유여어유여ㅇ며ㅇㅇ우
오ㅇㅇㅇㅇㅇㅇㅇㅇㅇㅇㅇ어
우ㅇㅇ어ㅇㅇ어어
샨희맣어

Try it online! (trailing new line for input is necessary)
Why not?
Hours of coding, and another hours of packing and layouting. I think it can be golfed furthermore, but it already took so much effort. I really wanted  to pack it into a rectangle.
Because 10^20 is larger than 2^64, not every implementation of Aheui will not support 경-scale numbers.
Luckily, Python and pyaheui implementation (which is used on  TIO) uses much-larger precision numbers, so it can support not only 경, but more than 해, 자, 양, 구, 간, 정, 재, 극.
And my code can be easily extended to use more larger unit suffixes.
This code will not terminate on input 0, but this spec was not defined in the question (which should output 영).
Explanation-ish Unpacked Code
ㅣPush unit suffixes (만, 억, 조, 경) to stack ㄹ
ㅣ
술
밦발따밝따빠따밦발다우
우ㅡㅡㅡㅡㅡㅡㅡㅡㅡ어
빠따다빠밞빠따받다빠따밝발따다다우
우ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ어
빠밞받따빠따밦발따타타우
우ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ어
빠밝빠따밦다빠따밣받따다타우
우ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ어
ㅣ
ㅣGet input as number
ㅣ
사방우
우ㅡ어
ㅣ
ㅣSplit input by four digits
ㅣ
ㅣㅣIf input is zero, end the loop
아아뺘우차우
우ㅇㅡ어　ㅣ
ㅣㅣ우ㅡㅡ어
ㅣㅣㅣTake mod 10000 to stack ㄲ
ㅣㅣ빠발발다빠따빠따라싺우
ㅣㅣ우ㅡㅡㅡㅡㅡㅡㅡㅡㅡ어
ㅣㅣㅣDivide by 10000
ㅣㅣ발발다빠따빠따나우
ㅣ오ㅡㅡㅡㅡㅡㅡㅡㅡ어
ㅣ
ㅣReverse stack ㄲ to stack ㄱ
ㅣ
샦우싹어
우어
ㅣ
ㅣProcess four digits
ㅣ
아우ㅣUse ㄷ stack for index (0, 2, 4, 6)
ㅣ아삳바우
ㅣ우ㅡㅡ어
ㅣㅣ
ㅣㅣㅣConvert four digits into korean
ㅣ아아숙
ㅣㅣㅣㅣIf current multiplier is zero, escape
ㅣㅣㅣ뺘우차우
ㅣ우ㅇㅡ어　ㅣ
ㅣㅣㅣ우ㅡㅡ어
ㅣㅣㅣㅣTake mod 10
ㅣㅣㅣ빠발발다라우
ㅣㅣㅣ우ㅡㅡㅡㅡ어
ㅣㅣㅣㅣIf remainder - 1 is 0 (remainder is 1) and index is 0 (ones digit), push 일 on stack ㄴ
ㅣㅣㅣ빠받반타탸우처삳뺘우처밝밤따밣따박다빠따밣타싼우
ㅣㅣㅣ우ㅡㅡㅡㅡ어ㅡㅡㅡ어ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ어
ㅣㅣㅣㅣIf remainder is not 0
ㅣㅣㅣ삭뺘우차우
ㅣㅣㅣ우ㅡ어　ㅣ
ㅣㅣㅣㅣ우ㅡㅡ어
ㅣㅣㅣㅣ숟
ㅣㅣㅣㅣㅣIf index is [2, 4, 6], push [십, 백, 천] on stack ㄴ
ㅣㅣㅣㅣ빠박탸우처발발따빠따밞타밞따밞따발다싼우
ㅣㅣㅣㅣ우ㅡㅡ어ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ어
ㅣㅣㅣㅣ빠밤탸우처밣빠따밞다빠따밣받따다밞따싼우
ㅣㅣㅣㅣ우ㅡㅡ어ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ어
ㅣㅣㅣㅣ빠밦탸우처밞밦따빠따밦타박따밞따싼우
ㅣㅣㅣㅣ우ㅡㅡ어ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ어
ㅣㅣㅣㅣㅣ
ㅣㅣㅣㅣㅣIf remainder is [2 ... 9], push [이 ... 구] on stack ㄴ
ㅣㅣㅣㅣ숙
ㅣㅣㅣㅣ빠박탸우처밝밤따밣따박다빠따밣밣다타싼우
ㅣㅣㅣㅣ우ㅡㅡ어ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ어
ㅣㅣㅣㅣ빠받탸우처밣밝다빠따받타빠따밣밝따다싼우
ㅣㅣㅣㅣ우ㅡㅡ어ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ어
ㅣㅣㅣㅣ빠밤탸우처밣밝다빠따받타빠따밣발따다싼우
ㅣㅣㅣㅣ우ㅡㅡ어ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ어
ㅣㅣㅣㅣ빠발탸우처밣밝다빠따빠따밦발다밞따다싼우
ㅣㅣㅣㅣ우ㅡㅡ어ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ어
ㅣㅣㅣㅣ빠밦탸우처밣밝다빠따빠따밦빠따밣다밣따다싼우
ㅣㅣㅣㅣ우ㅡㅡ어ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ어
ㅣㅣㅣㅣ빠밝탸우처밞밞따빠따밦빠따밝다다밣따싼우
ㅣㅣㅣㅣ우ㅡㅡ어ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ어
ㅣㅣㅣㅣ빠밣탸우처발발따발따밦따밣따밤다밞따싼우
ㅣㅣㅣㅣ우ㅡㅡ어ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ어
ㅣㅣㅣㅣ빠밟탸우처밝발따빠따밣다밤따밞따밣다싼우
ㅣㅣㅣ우ㅡㅡㅡ어ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ어
ㅣㅣㅣㅣ
ㅣㅣㅣㅣIncrease index, move onto next digit
ㅣㅣㅣ삳박다삭마발발다나우
ㅣㅣ오ㅡㅡㅡㅡㅡㅡㅡㅡㅡ어
ㅣㅣ
ㅣㅣㅣPop zero
ㅣ아무
ㅣㅣㅣ
ㅣㅣㅣㅣMove one suffix to stack ㄱ
ㅣㅣㅣㅣIf all suffix has been used, escape
ㅣㅣ아샬우싹삭우
ㅣ우ㅇㅡ어　　ㅣ
ㅣㅣㅣ우ㅡㅡㅡ어
ㅣㅣㅣㅣIf next multiplier is zero, discard next multiplier and suffix, then check next
ㅣㅣㅣㅣIf next multipler is not zero, move suffix to stack ㄴ and continue
ㅣㅣㅣㅣIf all multiplier has been processed, escape
ㅣㅣㅣ야우파뺘우차파싼우
오ㅇㅇㅡㅇㅡㅡㅇㅡㅡㅡ어
우어ㅇㅡ어ㅡㅡㅣ
ㅣㅡ오ㅡㅡ머머어
샨희맣어

Are you sure this works for all of the test cases? 10900000014 seems to output 십억구천만일 instead of 백구억십사.

@KevinCruijssen Looks like trailing new line for the input is necessary.

Ah, that's a weird input-format. But you're right, it indeed works with the new-line in the input. :) +1 from me, nice answer!

Wow. Also, you can use any printable ascii character instead of ㅇ, so this code can be golfed to 1391 bytes instead of 1555.

@0xrgb Oh, right, right, absolutely.

Retina 0.8.2, 147 bytes
^
0경0조0억0만
\G0?\D?
0천0백0십$&
+`0(\D)(\d+)(\d)
$2$1$3
0(천0백0십0.?|천|백|십)

1(천|백|십)
$1
T`d`_일이삼사오육칠팔구

Try it online! Link includes test cases. Explanation:
^
0경0조0억0만

Insert the symbols for powers of 10,000.
\G0?\D?
0천0백0십$&

Insert the thousands, hundreds and tens symbols.
+`0(\D)(\d+)(\d)
$2$1$3

Replace the zeros between the symbols with the input digits.
0(천0백0십0.?|천|백|십)

Delete zero thousands, hundreds or tens, or a whole power of 10,000.
1(천|백|십)
$1

Delete the 1 of one thousand, one hundred or one ten.
T`d`_일이삼사오육칠팔구

Transliterate the remaining digits, deleting any remaining zeros.

(The bytecount is measured in UTF8. TIO doesn't bother to check all characters are in SBCS)

Jelly,  96 95 94  92 bytes
“Ŀ|ĿtĊỴĊḄİ$Ŀ!Ṫ`ạÞḌlĖḣỴ1ṘƈỤṘḢỌṀpḄẒ‘s2ḅ⁹Ọ
bȷ4DUµż“¢½¿€‘ṁ$Ṛœl€1P€0¦ẠÐfFµ€Ṛµ;"“¡ÆÇÐÑ‘ṚL’$ÐfFḟ0ị¢

A monadic link taking a positive integer and returning a list of characters.
Try it online! or see a test-suite (numbers referenced in the OP)
...or see assertion of the pastebin values here
How?
Constructs the parts-characters required as indexes of the list:
[1,2,3,4,5,6,7,8,9,10,100,1000,10000,100000000,1000000000000,10000000000000000]
i.e.: 일이삼사오육칠팔구십백천만억조경

and indexes into the list. Thus 30210 would become [3,13,2,11,10] and then 삼만이백십
“Ŀ|ĿtĊỴĊḄİ$Ŀ!Ṫ`ạÞḌlĖḣỴ1ṘƈỤṘḢỌṀpḄẒ‘s2ḅ⁹Ọ - Link 1, get part-characters: no arguments
“Ŀ|ĿtĊỴĊḄİ$Ŀ!Ṫ`ạÞḌlĖḣỴ1ṘƈỤṘḢỌṀpḄẒ‘      - code-page indices = [199,124,199,116,192,188,192,172,198,36,199,33,206,96,211,20,173,108,194,237,188,49,204,156,185,204,197,181,200,112,172,189]
                                  s2    - split into twos = [[199,124],[199,116],[192,188],[192,172],[198,36],[199,33],[206,96],[211,20],[173,108],[194,237],[188,49],[204,156],[185,204],[197,181],[200,112],[172,189]]
                                    ḅ⁹  - convert from base 256 = [51068,51060,49340,49324,50724,50977,52832,54036,44396,49901,48177,52380,47564,50613,51312,44221]
                                      Ọ - cast to characters = "일이삼사오육칠팔구십백천만억조경"

bȷ4DUµż“¢½¿€‘ṁ$Ṛœl€1P€0¦ẠÐfFµ€Ṛµ;"“¡ÆÇÐÑ‘ṚL’$ÐfFḟ0ị¢ - Main link: integer, n     e.g. 102031
 ȷ4                                                  - 10^4 = 10000
b                                                    - convert (n) to base (10000)    [10,2031]
   D                                                 - convert (each) to base 10      [[1,0],[2,0,3,1]]
    U                                                - reverse each                   [[0,1],[1,3,0,2]]
     µ                      µ€                       - monadic chain for €ach:
              $                                      -   last two links as a monad:
       “¢½¿€‘                                        -     code-page indices = [1,10,11,12]
             ṁ                                       -     mould like             e.g. [1,10] or [1,10,11,12]
      ż                                              -   zip                   [[0,1],[1,10]] or [[1,1],[3,10],[0,11],[2,12]]
               Ṛ                                     -   reverse               [[1,10],[0,1]] or [[2,12],[0,11],[3,10],[1,1]]
                œl€1                                 -   left-strip ones         [[10],[0,1]] or [[2,12],[0,11],[3,10],[]]
                    P€0¦                             -   product @ index 0           [[10],0] or [[2,12],[0,11],[3,10],1]  (Note: the empty product is 1)
                        ẠÐf                          -   filter keep if any            [[10]] or [[2,12],[3,10],1]
                           F                         -   flatten                         [10] or [2,12,3,10,1]
                              Ṛ                      - reverse                        [[2,12,3,10,1],[10]]
                               µ                     - new monadic chain
                                  “¡ÆÇÐÑ‘            - code-page indices = [0,13,14,15,16]
                                ;"                   - zip with concatenation         [[2,12,3,10,1,0],[10,13],14,15,16]
                                         Ṛ           - reverse                        [16,15,14,[10,13],[2,12,3,10,1,0]]
                                             Ðf      - filter keep if:
                                            $        -   last two links as a monad:
                                          L          -     length                      1  1  1   2      6
                                           ’         -     decrement                   0  0  0   1      5
                                                     -                           i.e. [[10,13],[2,12,3,10,1,0]]
                                                     -     (This also removes any 0-sized 10K parts e.g. the [13] from 200001234 -> [16,15,[2,14],[13],[12,2,11,3,10,4,0]])
                                               F     - flatten                        [10,13,2,12,3,10,1,0]
                                                ḟ0   - filter discard zeros           [10,13,2,12,3,10,1]  (Note: not there for multiples of 10000 so cann't simply pop with Ṗ)
                                                   ¢ - call the last link as a nilad  "일이삼사오육칠팔구십백천만억조경"
                                                  ị  - index into                     "십만이천삼십일"

Ruby, 158 bytes
This task has been haunting me for a few days, but after several iterations of tinkering with the code and gaining max 1-2 bytes at a time, I think it isn't going to become much shorter than this, unless somebody points out a conceptually different approach.
->n{i=0;n.digits.map{|d|'-만억조경'[i%4>0?'':i/4]+'천-십백'[(i+=1)%4]+'0일이삼사오육칠팔구'[d]}.join.reverse.gsub /(0.){4}.|0.|일(?!-)|-/,''}

Try it online!
Explanation
Takes input as integer and extracts the digits (listed from the least to most significant) using the convenient built-in available since Ruby 2.4.
Then, we combine the corresponding Korean digits with position markers and where necessary, 104 block markers. - is a placeholder for the missing markers of lower digits.
천-십백 has such strange ordering because it is rotated by one place to compensate for the fact that we are also incrementing the counter i in the same step.
Finally, we reverse the resulting string back to normal direction and remove some redundant stuff with RegEx replacements:

(0.){4}. : 4 * (0+marker) + another marker = a completely empty 104 block.
0. : zeroes at any single position
일(?!-) : ones followed by any meaningful (non-placeholder) markers
- : finally, get rid of the placeholders themselves

Alternative
Interestingly, a similar approach, but working with string input is just 1 byte longer:

->s{i=s.size;s.chars.map{|c|'0일이삼사오육칠팔구'[c.to_i]+'-십백천'[(i-=1)%4]+'-만억조경'[i%4>0?'':i/4]}.join.gsub /(0.){4}.|0.|일(?!-)|-/,''}

Try it online!

Wolfram Language 23 bytes
Mathematica has a built-in for this. (What a surprise!)
IntegerName[#,"Korean"]&

To save one byte...
#~IntegerName~"Korean"&

Haskell, 270 bytes
(0#_)_=""
(n#1)_=[" 일이삼사오육칠팔구"!!fromInteger n]
(n#b)(c:r)|d<-div n b=[k |d>1,k<-d#1$r]++[c |d>0]++(mod n b#div b 10)r
t=10^4
(n%1)_=f n
(n%b)(c:r)|d<-div n b=[k |d>0,k<-f d++[c]]++(mod n b%div b t)r
f n|n<t=n#1000$"천백십"|1>0=n%(t^4)$"경조억만"

Try it online!
This could probably be improved as there is a bit of duplication but I can't think of a good way of unifying the # and % operators.
Both of those operators work in a similar way but # is for n<10^4 and % is for big numbers. They take the number n, the current "base" b and a list of characters representing the relevant powers of ten in decreasing order. First I divide n by b to get d and stick it's korean representation in front if it's greater than 1 (in the case of numbers less than ten thousand) or 0 (otherwise). Then I insert the representation of the power itself (which should correspond to c) if d>0. Then we just recur by modding n by b and dividing b down to get the base corresponding to the next character.
When we reach n==1 in # We know it's down to a one digit number so we just index into a list (I need fromInteger because Int isn't large enough to store numbers as large as 10^20). When n==1 in % then n is now <10^4 so we recur to # (via f) to do the rest of the number.


text:
Tetris strategy
Your task is to implement a Tetris strategy balanced in terms of score vs code size.
In this version of the game tetrominoes are rotated and dropped from above into a grid of 20 rows and 10 columns. While falling, they cannot be rotated or moved horizontally. As usual, a dropped piece stops when it reaches the bottom of the grid or when further downwards motion would cause collision with an already occupied square.
When n horizontal lines get filled completely, they collapse simultaneously, the grid is replenished with n empty lines at the top, and the score is incremented by 2n-1 points. For n=1,2,3,4 that's 1,3,7,15 points respectively. After the lines disappear, some blocks may remain floating in the air (there's no "gravity chain reaction").
When no room is available for the current piece to appear where desired, the grid is cleared, the current piece ignored, and the game continues with the next piece as current. There's no penalty for that.
You should read a stream of piece types and decide how to rotate them and where to drop them. Look-ahead for the next piece (just one) is allowed: you can look at piece i+1 before responding to i, but you must have decided the fate of i before looking at i+2. No look-ahead is available beyond the last piece of the input.
Tetromino types and their rotations are encoded per the following table:
        type 0    1    2    3    4    5    6
             O    I    Z    J    L    S    T
            ┌────┬────┬────┬────┬────┬────┬────┐
 rotation 0 │##  │#   │##  │ #  │#   │ ## │### │
            │##  │#   │ ## │ #  │#   │##  │ #  │
            │    │#   │    │##  │##  │    │    │
            │    │#   │    │    │    │    │    │
            ├────┼────┼────┼────┼────┼────┼────┤
          1 │##  │####│ #  │### │  # │#   │#   │
            │##  │    │##  │  # │### │##  │##  │
            │    │    │#   │    │    │ #  │#   │
            │    │    │    │    │    │    │    │
            ├────┼────┼────┼────┼────┼────┼────┤
          2 │##  │#   │##  │##  │##  │ ## │ #  │
            │##  │#   │ ## │#   │ #  │##  │### │
            │    │#   │    │#   │ #  │    │    │
            │    │#   │    │    │    │    │    │
            ├────┼────┼────┼────┼────┼────┼────┤
          3 │##  │####│ #  │#   │### │#   │ #  │
            │##  │    │##  │### │#   │##  │##  │
            │    │    │#   │    │    │ #  │ #  │
            │    │    │    │    │    │    │    │
            └────┴────┴────┴────┴────┴────┴────┘

Input is binary - a sequence of bytes whose remainders when divided by 7 should be interpreted as the OIZJLST tetrominoes. They will occur with roughly the same probability (except that the first few types may appear slightly more often due to 256 not being a multiple of 7, but that should be negligible). Input can be from stdin or from a file named "i" or passed as an argument. You can read all of the input at once, provided you make sure to abide by the look-ahead restriction.
Output is binary too - a sequence of bytes of the same length as the input. It can be stdout or a file named "o" or the result from a function. Each byte encodes r*16 + x, where r is the desired rotation and x is the 0-based index of the column where the leftmost square of the rotated tetromino should go. Those r and x must be valid, i.e. 0 ≤ r ≤ 3 and 0 ≤ x ≤ 10-w, where w is the width of the corresponding piece.
You program must be deterministic - given the same input, it has to produce exactly the same output. Using a PRNG is ok as long as it's const-seeded.
The total score is the score from the game minus the size of your code in bytes. Please use the following file (64kiB of pseudo-random noise) as input:
https://gist.github.com/ngn/857bf2c99bfafc649b8eaa1e489e75e4/raw/880f29bd790638aa17f51229c105e726bce60235/i
The following python2/python3 script reads files "i" and "o" from the current directory, replays the game and prints the score (please remember to subtract your code size from the score):
a = [0] * 23 # grid (1square=1bit, 1row=1int, LSB is left, 3 empty rows on top)
#      O     I         Z       J       L       S       T        tetrominoes
t = [[[3,3],[1,1,1,1],[3,6],  [2,2,3],[1,1,3],[6,3],  [7,2]  ],
     [[3,3],[15],     [2,3,1],[7,4],  [4,7],  [1,3,2],[1,3,1]],
     [[3,3],[1,1,1,1],[3,6],  [3,1,1],[3,2,2],[6,3],  [2,7]  ],
     [[3,3],[15],     [2,3,1],[1,7],  [7,1],  [1,3,2],[2,3,2]]]
tw = [[2,1,3,2,2,3,3],[2,4,2,3,3,2,2],[2,1,3,2,2,3,3],[2,4,2,3,3,2,2]] # widths
th = [[2,4,2,3,3,2,2],[2,1,3,2,2,3,3],[2,4,2,3,3,2,2],[2,1,3,2,2,3,3]] # heights
score = 0
for p, rx in zip(bytearray(open('i', 'rb').read()),
                 bytearray(open('o', 'rb').read())):
    p %= 7; r = rx >> 4; x = rx & 15  # p:piece type, r:rotation, x:offset
    b = [u << x for u in t[r][p]]     # as a bit-matrix (list of ints)
    bw = tw[r][p]; bh = th[r][p]      # width and height
    y = 0                             # drop it
    while y <= 23 - bh and all((a[y + i] & b[i]) == 0 for i in range(bh)):
        y += 1
    y -= 1
    if y < 3:                         # no room?
        a = [0] * len(a)              # clear the grid and carry on
    else:
        for i in range(bh):           # add the piece to the grid
            a[y + i] |= b[i]
        n = 0
        for i in reversed(range(bh)): # collapse full lines
            if a[y + i] == (1 << 10) - 1:
                n += 1; del a[y + i]; a = [0] + a
        score += (1 << n) - 1
print(score)

So does the following much faster C program but it's guaranteed to work only on Linux:
#include<stdio.h>
#include<fcntl.h>
#include<sys/mman.h>
#include<sys/stat.h>
#define F(i,n,b...)for(i=0;i<n;i++){b;}
typedef int I;typedef char C;
I a[23],t[]={
51,4369,99,802,785,54,39,51,15,306,71,116,561,305,
51,4369,99,275,547,54,114,51,15,306,113,23,561,562};
C*th="2423322213223324233222132233";
I main(){
 struct stat h;stat("i",&h);I i,j,k,l=h.st_size,z=0;
 C*mi=mmap(0,l,1,1,open("i",0,0),0),*mo=mmap(0,l,1,1,open("o",0,0),0);
 F(k,l,
  I p=(mi[k]&255)%7,r=3&mo[k]>>4,q=r*7+p,x=mo[k]&15,y=0,h=th[q]-'0',b[4];
  F(i,h,b[i]=(t[q]>>(4*i)&15)<<x)
  while(y<=23-h){I u=0;F(i,h,u|=a[y+i]&b[i])if(u)break;y++;}
  if(--y<3){F(i,23,a[i]=0)continue;}
  F(i,h,a[y+i]|=b[i])
  I n=0;F(i,23,n+=a[i]==1023)
  if(n){j=23;F(i,20,a[j]=a[22-i];j-=a[j]!=1023)F(i,j,a[i]=0);z+=(1<<n)-1;})
 printf("%d\n",z);return 0;}

The highest total score wins. Standard loopholes are forbidden.

When no room is available for the current piece to appear where desired Let's see if I understand that correctly. For instance, if the leftmost column is entirely filled and the program want to place the next piece there, this will force the grid to be cleared, even if there was plenty of room elsewhere. Is that correct?

@Arnauld yes, correct

Is it OK to optimize for the i file? Nice challenge, BTW!

Yes, it comes from my /dev/urandom, so I don't expect there to be exploitable patterns in it. Thanks :)

More precisely: is it legal to store helper data in our code which is specific to i, such as "clear 2 lines at move #147 instead of waiting for a Tetris, otherwise the stack will go too high"? (This doesn't seem to conflict with 'don't look at piece i+2 from the input file'.)

Yes, as long as your program is capable of handling correctly any input, I think it's fine to optimise for the given one. By "capable of handling correctly" I mean it should produce an output file with the same byte-length as the input file, with rotations in 0...3, and offsets in 0...(10-pieceWidth), regardless of the score.

I added to the challenge an explicit mention of the requirement for validity of rotations and offsets.

I had a Tetris minimax implementation in java once... Was basically like "receive shape, find all valid final positions, find one that causes lowest height and highest density."

@MagicOctopusUrn Sounds like a very good strategy. An even better one could try to fill 4 lines at a time (or at least 3) to take advantage of the disproportionate rewards, though dealing with holes may be tricky.

@ngn (regarding /dev/urandom not being a PRNG), I know this and my original comment on it was a mistake - please see my previous comment.

@ngn it performed average, the best part about it was how stupidly fast it ran compared to what everyone else tried. My biggest regret is that it didn't try to prevent "holes". Eventually, in an endless game, it would usually lose with 1 hole on each tier. The density maximizer was pretty decent, but when you have a 1x1 hole 3 deep instead of a 1x1 gap at the top you've got problems.

The input / output format is super confusing. Can't I just use something like "## | ##" to indicate the S piece and write "r x w" as is on each line space-seperated?

@Unihedron Actually, I went out of my way (used the sandbox) to make sure it's not confusing. Oh well... If you need the incoming piece as a matrix, you can just look up tetrominoes[inputByte%7] from an array in your code. As for the output, is it really that hard to write 16*r+x as a single byte instead of formatting and writing r and x as strings? w is not part of the output.

C, score: 4136 (4290 - 154 bytes)
#include <stdio.h>
main(){int c,p=0,t[]={7,9,21,0,0,51,1,32,16,48,0,33,0,32,16,49};for(;(c=getchar())>=0;putchar(c)){c%=7;c=t[!c||!(10%c)?c:2*c+p++%4];}}

The idea is that blocks S,Z,O,I use fixed locations and rotations:
                  |
      s     z     |
      s s z z # # |
        s z   # # |
0 1 2 3 4 5 6 7 8 9

The rest - J,L,T - are packed into first three columns with some cyclic rotation.
Ungolfed version:
#include <stdio.h>
int main() {
    int c,p=0,t[] = {7,9,21,51, 1,32,16,48, 16,48,0,33, 0,32,16,49 };
    while ((c=getchar())!=EOF) {
            switch(c%7) {
            case 0: c = t[0]; break;
            case 1: c = t[1]; break;
            case 2: c = t[2]; break;
            case 3: c = t[4+p++%4]; break;
            case 4: c = t[8+p++%4]; break;
            case 5: c = t[3]; break;
            case 6: c = t[12+p++%4]; break;
            }
            putchar(c);
    }
    return 0;
}

simple and efficient - well done!