text:
Code Golf Measurer © 2019
Code Golf Measurer © 2019
Hexdumps used with xxd look something like this:
00000000: 666f 6f20 6261 7220 7370 616d 2065 6767  foo bar spam egg
00000010: 730a                                     s.

Your task is to convert a hexdump in this form in to the number of bytes used.
Rules:

Usual loopholes forbidden.
This is code-golf, so shortest valid answer in bytes wins.
You may or may not include the newline at the end of text (0a). This means that if the hexdump ends in a newline (0a), that input may have it's output reduced by one.
An empty input (literally nothing: empty list/string/etc.) must output 0.
Input can be taken in any form
Input will be valid ASCII with no control characters
The input must contain the whole hexdump

Test cases:
00000000: 4865 6c6c 6f2c 2077 6f72 6c64 2120 4865  Hello, world! He
00000010: 6c6c 6f2c 2077 6f72 6c64 210a            llo, world!.

returns 28 or 27
00000000: 0a                                       .

returns 1 or 0
00000000: 6368 616c 6c65 6e67 650a                 challenge.

returns 10 or 9
00000000: 4865 6c6c 6f2c 2077 6f72 6c64 21         Hello, world!

returns 13

returns 0 (This is literally nothing: empty list/string/etc.)
Explanations would be nice for non-standard languages.

May we assume the input is ascii? Can it contain control characters? What are the input rules? Some languages can't handle input over multiple lines. Can we pad the last line so that all lines are equally long? Why include the blank input?

@StewieGriffin Yes; no; yes; because if xxd is fed an empty string, it outputs nothing.

@StewieGriffin You edited your comment while I was answering, so here's an expansion: Yes; No; it can be input however you want, provided the whole dump is included; See last answer; Yes; Because if xxd is fed an empty string, it outputs nothing

@JonathanAllan Oh yes, well spotted.

Counting a hexdump format that didn't include the ASCIIfied data at the right might be interesting.  Everyone's going with just stripping the hex part and byte-counting the rest.  If the challenge was to do this given only the last line of hexdump, that would force parsing the hex number (the position) as well as counting the number of hex digits on that line.  (Like I do by hand when looking at objdump disassembly or nasm listings for machine-code answers.)  I guess I should post that in the sandbox...

@PeterCordes Interesting idea! When you do, link it here; I'd definitely upvote it :).

May I assume the xxd dump use UNIX style line ending (LF)? An Windows version xxd (xxd V1.10 27oct98 by Juergen Weigert (Win32), comes with Vim) does output with CRLF line endings.

@tsh Any consistent specification. (So yes, but it could be either)

tcsh, 12 bytes
xxd -r|wc -c

Try it online!

Very robust and do exactly what OP want.

Retina 0.8.2, 8 bytes
.{51}

.

Try it online! Explanation:
.{51}

Delete the first 51 characters of each line. (Lines can only have between 52 and 67 characters, so this always matches once per line.)
.

Count the remaining non-newline characters.
7 bytes if empty input did not have to be supported:
.{52}

Try it online! Explanation:
.{52}

Delete the first 52 characters of each line. (Lines can only have between 52 and 67 characters, so this always matches once per line.)

Count 1 more than the number of remaining characters (including newlines).

7 with &`.{52}.

@Grimy That's just... awesome... you must post that as your own answer.

I didn't notice it at first but actually there's already an almost identical answer.

V (vim), 7 bytes
Î51x
Ø.

Try it online!
Explanation:
Î       " On every line...
 51x    "   Delete the first 51 characters
Ø.      " Count the number of remaining characters on any line

Hexdump:
00000000: ce35 3178 0dd8 2e                        .51x...

Retina, 7 bytes
This counts the total number of single-line strings of length 52. It might be possible to do something similar to %52,`., but I failed to find a way to fix that.
w`.{52}

Try it online!

Also: &`.{52} for Retina 0.8.2.

APL (Dyalog Extended), 18 bytes
Full program. Prompts for list of strings (i.e. of lists of characters).
2÷⍨≢∊(1↓≠⊆⊢)¨49↑¨⎕

Try it online!
⎕ prompt
49↑¨ take the first 49 characters from each
(…)¨ apply the following tacit function to each:
 ⊢ the argument
 ⊆ chop into runs of characters that are
 ≠ different from the padding character (space)
 1↓ drop the first "word"
∊ ϵnlist (flatten)
≢ tally
2÷⍨ divide by two

C (gcc), 64 55 45 39 bytes
s[];f(l){l=gets(s)?strlen(s)-51+f():0;}

Try it online!
9 bytes shaved off thanks to YSC, 10 thanks to jdt, and 6 thanks to c--!

You could use for.

Also, s[] seems to me to be unstable undefined behaviour.

59 bytes by changing return r to l=r

@jonathan-french using a for loop doesn't seem to save any bytes.

-3 bytes by making r a global: s[];r;f(l){while(*s=0,gets(s),l=strlen(s))r+=l-51;return r;}

@JonathanFrech undefined behaviour is perfectly fine for code golf!

@YSC Hm, but I think making r global violates the rule that if you define a function to do something (and it's not main), it should be possible to call it multiple times.

It doesn't matter here since f consumes all the input. Calling it a second time has no meaning (and as-is, returns 0 the second time).

Anyway, r;s[];f(l){while(*s=0,gets(s),l=strlen(s))r+=l-51;l=r;}: 55 bytes :)

@G.Sliepen I would disagree in the case of unstable undefined behavior, as it violates the general relaunchability requirement of your program.

@girobuz while() has the same number of bytes as for(;;). Thus ;while() is one byte longer than for(;;).

45 bytes

Jelly, 5 bytes
Ẉ_51S

A monadic Link accepting a list of lines which yield the integer byte count.
Try it online!
How?
Ẉ_51S - Link: list of lists of characters, H
Ẉ     - length of each (line in H)
  51  - literal fifty-one
 _    - subtract (vectorises)
    S - sum

You can accept a list of lines. Also, would you care to add an explanation?

Ah cool, so is the empty input an empty list OR a list with a single empty line? (This should be made clear in the post since it's an edge-case.)

It's and empty list/string/etc. I've just clarified this.

Thanks, explanation added now too.

Python 3, 48 46 bytes
lambda s:(len(s)or 51)+1-52*len(s.split('\n'))

Input is passed as a string to the function. The function increments the length of the input (including newlines), then subtracts 52 for each line.
Try it online

From what I've seen, the f= can be moved in to the header as f=\, leaving just the lambda as code and saving two bytes: Try it online!

@gadzooks02 Thanks, will edit. The f= is a habit I picked up from the Python discord server.

05AB1E, 8 6 bytes
€g51-O

Try it online!
Input as a list of strings.
€g     get lengths of each line
51-    subtract 51 from each
O      push the sum of the resulting list
       implicitly print

Sorry, the input must contain the whole hexdump. (Yours skips the letters at the end of each line)

Oh, my bad. I made this on my smartphone. Didn't see there's something behind the hex codes. I made a correction.

Japt -x, 5 bytes
Input as an array of lines.
®Ê-51

Try it
®Ê-51     :Implicit input of array
®         :Map
 Ê        :  Length
  -51     :  Subtract 51
          :Implicit output of sum of resulting array

Perl 6, 18 bytes
{.join.comb-51*$_}

Try it online!
Anonymous Whatever lambda that takes a list of lines and returns the sum of the number of characters, subtracting 51 for each line

IBM/Lotus Notes Formula Language, 53 bytes
@Sum(@Length(@Explode(@Right(@Left(i;"  ");": ")))/2)

There is no TIO for Formula so here are screenshots of the test cases:

The formula is in the computed field that provides the value after "Returns".
Explanation
This is a good demonstration of the way that Formula will recursively apply a function to a list without needing a loop. The formula is in a computed field on the same form as editable input field `i'.

Start in the middle. @Left and @Right allow a string delimiter or a number of characters to be used. We therefore search to the right of :  and then to the left of the first occurrence of two spaces. Since Formula sees the newline as a list separator it will apply this to each line in the input.
@Explode is Formula's equivalent of a split function and defaults to space, , or ;. Again it is applied to each line in the field but this time the results are combined into a single list.
@Length will then be applied to each member of the list. In each case we divide it's return value by 2.
@Sum the whole list and output the result.

Do you have a link to an interpreter (either online or downloaded)?

Unfortunately not. Formula is a proprietary language that is tied in to the IBM product (I did ask on Meta some time ago if this is allowed on this site and the answer was "yes" but not for Cops & Robbers challenges). Last time I looked, Domino Designer (which supports Formula) was still available as a free download from IBM. Unfortunately Windows only and as I run Linux at home I can't confirm. This answer was written during my lunch break as I am unfortunate enough to still support some legacy Notes apps and still have Notes on my machine at work :-)

BTW, if you search Lotus Notes on this site you will find that I am the only guy who is stupid enough to try to golf in this language :-)

Red, 81 55 bytes
func[s][n: 0 foreach l s[n: n - 51 + length? l]max 0 n]

Try it online!
Takes the input as a list of strings.

JavaScript (ES6), 34 bytes
s=>(n=s.length)&&(n/68<<4)+n%68-51

Try it online!
Commented
s =>                // s = input string
  (n = s.length) && // n = length of s; return 0 right away if n = 0 (special case)
  (n / 68 << 4) +   // otherwise compute the number of full lines and multiply it by 16
  n % 68 - 51       // add the length of the last line minus 51

JavaScript, 33 32 bytes
a=>a.map(x=>a=~~a+x.length-51)|a

Try it Online!
Saved 1 byte thanks to Arnauld.

Ruby, 39 29 28 bytes
-10 bytes thanks to south
-1 byte thanks to Sʨɠɠan
p$<.sum{_1=~/.{52}/;$'.size}

Attempt This Online!

29 bytes

@south Very nice. I forgot you can just enumerate on stdin.

You can change && to ;.

Befunge-98 (FBBI), 16 bytes
"c- cw|r- dxx"=@

Try it online!

Stax, 5 bytes
ôφß→ê

Run and debug it

Zsh, 36 bytes
With zsh's default flags:

for l (${(f)1})((c+=$#l-52))
<<<$[c]

Try it online!
${(f)1} splits $1 on newlines, and discards empty lines.
The $[ arithmetic expansion ] guards against the empty case, when the loop never sets $c.
Zsh, 28 bytes
With -o extendedglob:
<<<${#${(F)${(f)1}#?(#c52)}}

Try it online!
(f) Split on newlines, ${   #?(#c52)} remove leading 52 characters, (F) join on newlines so that counting is characterwise instead of listwise, ${#  } count characters.

asm2bf, 135 bytes
Golfed version:
lbl 3
mov r2,51
lbl 1
in_ r1
dec r2
jz_ r1,4
jnz r2,1
lbl 2
in_ r1
jz_ r1,4
sub r1,10
jz_ r1,3
inc r3
jmp 2
lbl 4
out r3

Commented version:
lbl 3               ; Main loop - the kinda entry point

    mov r2, 51      ; Loop 51 times.
    lbl 1           ; Loop start.
        in_ r1      ; Read character
        dec r2      ; Decrement the loop accumulator.
        jz_ r1, 4   ; If zero was read, end.
        jnz r2, 1   ; If we still loop, loop again.

    lbl 2           ; Second loop, accumulating the result.
        in_ r1      ; Read a character.
        jz_ r1, 4   ; If character is zero, end the loop and print result.
        sub r1, 10  ; Decrement r1 by 10 for next check.
        jz_ r1, 3   ; If the character - 10 (the newline) is zero, jump to 3
        inc r3      ; Increment character read amount.
        jmp 2
lbl 4
    out r3          ; Print out the result as an ASCII character.

PHP, 22 bytes
fn()=>strlen(`xxd -r`)

Doesn't work on ATO unfortunatly

Two bytes shorter as a full program: <?=strlen(\xxd -r`);- [Try it online!](https://tio.run/##K8go@P/fxt62uKQoJzVPI6GiIkVBtyhB0/r/fwMosFIwsTAzVTBLNktWMEszSlYwMjA3B7LMjUBiJgpGhkYGECUKHqk5Ofk6CuX5RTkpikAeF8QEQ6AZeLQbJCogASQT9AA "PHP – Try It Online") You can actually save two more withwc-<?=`xxd -r|wc -c`;` At that point tho, you might as well be answering in bash.


text:
Fermat's polygonal number theorem
Fermat's polygonal number theorem states that every positive integer can be expressed as the sum of at most \$n\$ \$n\$-gonal numbers. This means that every positive integer can be expressed as the sum of up to three triangle numbers, four square numbers, five pentagonal numbers etc. Your task is to take a positive integer \$x\$, and an integer \$s \ge 3\$, and to output the \$s\$-gonal integers which sum to \$x\$.
The \$n\$-th \$s\$-gonal integer, where \$n \ge 1\$ and \$s \ge 3\$, can be defined in a couple of ways. The non-math-y way is that the \$n\$th \$s\$-gonal number can be constructed as a regular polygon with \$s\$ sides, each of length \$n\$. For example, for \$s = 3\$ (triangular numbers):

See here for examples with a larger \$s\$.
The math-y definition is by using the formula for \$P(n, s)\$, which yields the \$n\$-th \$s\$-gonal number:
$$P(n, s) = \frac{n^2(s-2) - n(s-4)}{2}$$
which is given in the Wikipedia page here.
Input
Two positive integers, \$s\$ and \$x\$, with the condition \$s \ge 3\$. You may input these integers in the most natural representation in your language (decimal, unary, Church numerals, integer-valued floating point numbers etc.).
Output
A list of integers, \$L\$, with a maximum length of \$s\$, where the sum of \$L\$ is equal to \$x\$ and all integers in \$L\$ are \$s\$-gonal integers. Again, the integers may be outputted in the natural representation in your language, with any distinct, consistent separator (so non-decimal character(s) for decimal output, a character different from that used for unary output etc.)
Rules

The inputs or outputs will never exceed the integer limit for your language
\$L\$ does not have to be ordered
In case of multiple possible outputs, any or all are acceptable
This is code-golf so the shortest code in bytes wins

Test cases
   x,  s => L
   1,  s => 1
   2,  s => 1, 1
   5,  6 => 1, 1, 1, 1, 1
  17,  3 => 1, 6, 10
  17,  4 => 1, 16
  17,  5 => 5, 12
  36,  3 => 36
  43,  6 => 15, 28
 879, 17 => 17, 48, 155, 231, 428
4856, 23 => 130, 448, 955, 1398, 1925

Sandbox post

Can the output have some zero padding? For instance if we consider x=17, s=5 could we output 5,12,0,0,0 instead of just 5,12?

@flawr So long as the length of the array doesn't exceed $s$, even with padding, that's fine

Are repeats allowed or should I add a Q to my submission?

@JonathanAllan Repeated outputs are perfectly fine (if outputting multiple solutions)

@AZTECCO Added, but all the answers I checked worked

@caird coinheringaahing  The test I suggested was s=3 n=53, anyway I written directly to the people after consulting meta stack exchange for the right approach.

In the sum for n s=53 10 can not to be 15 because 15 not seem to me a s=10 number...possible I wrong on it, if so what number u is such that P(u,10)=15?

Haskell, 55 bytes
n%s=[l|l<-mapM(\_->scanl(+)0[1,s-1..n])[1..s],sum l==n]

Try it online!
Outputs all possible solutions. Defines the s-gonal numbers as the cumulative sum of the arithmetic progression
1, s-2, 2*s-3, 3*s-4, ...

Haskell, 78 80 77 bytes
We compute the cartesian product of the first \$n\$ s-gonal numbers, and then find the first entry that sums to \$n\$.
s#n=[x|x<-mapM(map(\n->s*(n^2-n)`div`2+n*(2-n)))([0..n]<$[1..s]),sum x==n]!!0

Try it online!

JavaScript (ES6),  83  80 bytes
A fast recursive search which maximizes the smallest term of the output.
Takes input as (s)(x).
s=>g=(x,n=0,a=[],y=~n*(~-n-n*s/2))=>x<y?x|a[s]?0:a:g(x,n+1,a)||g(x-y,n,[...a,y])

Try it online!
Formula
It turns out to be shorter to use a 0-based formula to compute the \$s\$-gonal numbers in JS, i.e. to start with \$n=0\$ and to compute \$P(n+1,s)\$:
$$\begin{align}P(n+1,s)&=((n+1)^2(s-2)-(n+1)(s-4))/2\\
&=(n^2(s-2)+ns+2)/2\\
&=-(n+1)((n-1)-ns/2)
\end{align}$$
which can be written in 14 bytes:
~n*(~-n-n*s/2)

Commented
s =>                         // main function taking s
  g = (                      // recursive function g
    x,                       // taking x
    n = 0,                   // start with n = 0
    a = [],                  // a[] = list of s-gonal numbers
    y =                      // y = P(n + 1, s)
      ~n * (~-n - n * s / 2) //   = -(n + 1) * ((n - 1) - n * s / 2)
  ) =>                       //
    x < y ?                  // if x is less than P(n + 1, s):
      x | a[s] ?             //   if x is not equal to 0 or a[] is too long:
        0                    //     failed: return 0
      :                      //   else:
        a                    //     success: return a[]
    :                        // else:
                             //   process recursive calls:
      g(x, n + 1, a) ||      //   preferred: try to increment n
      g(x - y, n, [...a, y]) //   fallback : try to use the current s-gonal number

@AZTECCO I may try to fix it later. Removed for now.

Thanks. Waiting for it!

05AB1E, 14 13 bytes
Port of Jonathan Allan's Jelly answer.
ÍIÝ*>.¥¹ã.ΔOQ

Try it online!

Jelly,  17  15 bytes
-2 thanks to caird coinheringaahing
x’2;’ÄÄx⁸ŒPS⁼¥Ƈ

A (very very inefficient) dyadic Link accepting s on the left and x on the right which yields a list of many possible L lists, with repeats.
Try it online! - not much point trying it for much higher values!
How?
x’2;’ÄÄx⁸ŒPS⁼¥Ƈ - Link: s, x                    e.g.  5, 17
x               - repeat (s) (x) times                [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]
 ’              - decrement (vectorises)              [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]
  2;            - prepend a two                       [2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]
    ’           - decrement (vectorises)              [1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]
     Ä          - cumulative sums                     [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49, 52]
      Ä         - cumulative sums                     [1, 5, 12, 22, 35, 51, 70, 92, 117, 145, 176, 210, 247, 287, 330, 376, 425, 477]
       x⁸       - repeat (each of those) (s) times    [1, 1, 1, 5, ..., 425, 477, 477, 477]
         ŒP     - power-set                           [[], [1], [1], ..., [1, 1], ..., [5, 22, 70], ... etc]
                    (this has 2^(x(s+1)) entries ...this example would have 2^(17(5+1)) = 2^102 = 5070602400912917605986812821504 entries!)
                    (Note: the lengths increase left to right)
              Ƈ - filter keep if:
             ¥  -   last two links as a dyad:
           S    -     sum
            ⁼   -     equals (x)?                     [[5,12], ... , [5,12], [1, 1, 5, 5, 5], ... , [1, 1, 5, 5, 5], [1, 1, 1, 1, 1, 12], ...]

@AZTECCO That's perfectly fine, it times out on TIO there at 60 seconds (I'm pretty sure even far smaller input number than that will time out). As I point out in my answer, this is "very very inefficient" and that there's "not much point trying it for much higher values!". Remember, the code given for a code-golf solution only need work given infinite resources.

ok I tested with s=3 and n=5 and it taken 12 seconds!! I like this inefficient solution and I'll trust you, even if it's almost impossible to test it :) thank you!

@AZTECCO Indeed, it's hard to test - I originally did not have the ⁸ so was repeating the elements of the cumulative sum result $x$ times each rather than $s$ times each (which is incorrect) and it was hard to spot that it was actually doing anything wrong without running just parts of the code!

Because you can output multiple $L$ that work, and you can output repeated lists, -2 bytes

@cairdcoinheringaahing ah I missed that, ta. I asked about repeats but didn't seem to think about the fact we can output any or all values.

Ruby, 79 bytes
Computes the first \$n\$ \$s\$-gonal numbers and zero, gets the cartesian product of itself \$s\$ times, and finds the first entry that matches. Later test cases run out of memory on TIO but theoretically work.
\$\frac{n^2(s-2)-n(s-4)}{2}\$ is reorganized into \$\frac{n(ns-2n-s+4)}{2}\$ because it saves bytes in Ruby.
->n,s{a=(0..n).map{|i|i*(i*s-2*i-s+4)/2};a.product(*[a]*~-s).find{|a|a.sum==n}}

Try it online!

Retina, 111 bytes
\d+
*
~(`$
$"
0%["^_+ "|""]'$L$`\G_(?<=(?=___(_*))_+)
((_(?($.(2*$>`))$1\$.(2*$>`)))$*)
1%|' L$`\G_
$$.$.($`$>`

Try it online! Link includes test cases. Takes input in the order s n. Explanation:
\d+
*

Convert to unary.
~(`

After processing the remaining stages, treat them as a Retina program and execute them on the same input.
$
$"

Duplicate the line.
0%["^_+ "|""]'$L$`\G_(?<=(?=___(_*))_+)
((_(?($.(2*$>`))$1\$.(2*$>`)))$*)

Replace the first copy with a regular expression that skips over the first number and then matches s s-gonal numbers. The numbers themselves are captured in odd capture groups and the even capture groups are used to ensure that all of the numbers are s-gonal.
1%|' L$`\G_
$$.$.($`$>`

Replace the second copy with a space-separated list of the odd capture groups.
As an example, the generated code for an input of 5 17 is as follows:
^_+ ((_(?(2)__\2))*)((_(?(4)__\4))*)((_(?(6)__\6))*)((_(?(8)__\8))*)((_(?(10)__\10))*)$
$.1 $.3 $.5 $.7 $.9

Python 3, 105 bytes
def f(s,x,n=0,a=[]):y=~n*(~-n-n*s/2);return(x<1)*a*(len(a)<=s)if x<y else f(s,x,n+1,a)or f(s,x-y,n,a+[y])

Try it online!
Port of Arnauld's JavaScript answer, so make sure to upvote him!

C++ (clang), 198 bytes
#import<vector>
using V=std::vector<int>;V f(int n,int s){V _{0};int z=1,a=0,b=1,i,t;for(;a<n;b+=s-2)_.push_back(a+=b),++z;V o;for(t=a=0;t-n;b=++a)for(o=V(s),t=i=0;b;b/=z)t+=o[i++]=_[b%z];return o;}

Try it online!
V=vector<int>
V _{0}; // initialized with one element =0
int z=1, // vector size
a=0,b=1,i,t;for(;a<n;b+=s-2)_.push_back(a+=b),++z;
// pushes polygons in V
V o; // vector to be returned
for(t=a=0;t-n;b=++a) // ends when t=n
// loop to generate multi-dimension indexes
// for example a=1234 z=10
// a%z->4 , a/=z , a%z-> 3 , ... 2 , 1
for(o=V(s),t=i=0;b;b/=z)// loop to extract indexes
t+=o[i++]=_[b%z]; // put the sum in t and values in o
return o

APL(NARS), 149 chars, 298 bytes
r←f w;n;s;i;k
(n s)←w⋄r←⍬⋄→0×⍳s<3⋄i←1
→0×⍳n<k←2÷⍨(i×i×s-2)-i×s-4⋄r←r,k⋄i+←1⋄→2

h←{0=≢b←((v←↑⍵)=+/¨a)/a←{0=≢⍵:⊂⍬⋄m,(⊂1⌷⍵),¨m←∇1↓⍵}f⍵:v⍴1⋄k←↑⍋≢¨b⋄k⊃b}

if not find solutions "0=≢b" than return for (n s) input, n times 1;
else it would return the sum of s numbers that has less addend...
test:
  h 1 3
1
  h 2 8
1 1
  h 5 6
1 1 1 1 1
  h 17 3
1 6 10
  h 17 4
1 16
  h 17 5
5 12
  h 36 3
36
  h 43 6
15 28
  h 879 17
17 48 155 231 428
  h 4856 23
321 448 596 955 2536
  +/h 4856 23
4856

The problem of this: It not find some solution has some number repeat in the sum...

source: Stack Exchange

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

sort: votes


text:
Compute OEIS A161169, approximately and quickly
\$T(n, k)\$ gives the number of permutations of length \$n\$ with up to \$k\$ inversions. This values grows very quickly, for example for \$T(20, 100) = 1551417550117463564\$.
The maximum number of inversions possible is \$n\frac{n-1}{2}\$ so for \$k =  n\frac{n-1}{2}\$ we know that \$T(n, k) = n!\$.
To make this task more interesting, and to allow for a wider variety of possible answers you will only have to compute \$T(n, k)\$ approximately.
Examples:
For \$n = 3\$ and \$k\$ from \$0…3\$:
0.167, 0.5, 0.833, 1.0

For \$n = 4\$ and \$k\$ from \$0…6\$:
0.042, 0.167, 0.375, 0.625, 0.833, 0.958, 1.0

For \$n = 5\$ and \$k\$ from \$0…10\$:
0.008, 0.042, 0.117, 0.242, 0.408, 0.592, 0.758, 0.883, 0.958, 0.992, 1.0

For \$n = 50\$ and \$k\$ from \$0…1225\$:
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.002, 0.002, 0.002, 0.002, 0.002, 0.002, 0.002, 0.002, 0.002, 0.003, 0.003, 0.003, 0.003, 0.003, 0.003, 0.003, 0.004, 0.004, 0.004, 0.004, 0.005, 0.005, 0.005, 0.005, 0.006, 0.006, 0.006, 0.006, 0.007, 0.007, 0.007, 0.008, 0.008, 0.008, 0.009, 0.009, 0.01, 0.01, 0.011, 0.011, 0.012, 0.012, 0.013, 0.013, 0.014, 0.015, 0.015, 0.016, 0.017, 0.017, 0.018, 0.019, 0.02, 0.02, 0.021, 0.022, 0.023, 0.024, 0.025, 0.026, 0.027, 0.028, 0.029, 0.03, 0.032, 0.033, 0.034, 0.035, 0.037, 0.038, 0.039, 0.041, 0.042, 0.044, 0.046, 0.047, 0.049, 0.051, 0.052, 0.054, 0.056, 0.058, 0.06, 0.062, 0.064, 0.066, 0.069, 0.071, 0.073, 0.075, 0.078, 0.08, 0.083, 0.085, 0.088, 0.091, 0.094, 0.096, 0.099, 0.102, 0.105, 0.108, 0.112, 0.115, 0.118, 0.121, 0.125, 0.128, 0.132, 0.136, 0.139, 0.143, 0.147, 0.151, 0.155, 0.159, 0.163, 0.167, 0.171, 0.175, 0.18, 0.184, 0.189, 0.193, 0.198, 0.202, 0.207, 0.212, 0.217, 0.222, 0.227, 0.232, 0.237, 0.242, 0.247, 0.253, 0.258, 0.263, 0.269, 0.274, 0.28, 0.286, 0.291, 0.297, 0.303, 0.309, 0.315, 0.321, 0.327, 0.333, 0.339, 0.345, 0.351, 0.357, 0.363, 0.37, 0.376, 0.382, 0.389, 0.395, 0.401, 0.408, 0.414, 0.421, 0.427, 0.434, 0.44, 0.447, 0.454, 0.46, 0.467, 0.473, 0.48, 0.487, 0.493, 0.5, 0.507, 0.513, 0.52, 0.527, 0.533, 0.54, 0.546, 0.553, 0.56, 0.566, 0.573, 0.579, 0.586, 0.592, 0.599, 0.605, 0.611, 0.618, 0.624, 0.63, 0.637, 0.643, 0.649, 0.655, 0.661, 0.667, 0.673, 0.679, 0.685, 0.691, 0.697, 0.703, 0.709, 0.714, 0.72, 0.726, 0.731, 0.737, 0.742, 0.747, 0.753, 0.758, 0.763, 0.768, 0.773, 0.778, 0.783, 0.788, 0.793, 0.798, 0.802, 0.807, 0.811, 0.816, 0.82, 0.825, 0.829, 0.833, 0.837, 0.841, 0.845, 0.849, 0.853, 0.857, 0.861, 0.864, 0.868, 0.872, 0.875, 0.879, 0.882, 0.885, 0.888, 0.892, 0.895, 0.898, 0.901, 0.904, 0.906, 0.909, 0.912, 0.915, 0.917, 0.92, 0.922, 0.925, 0.927, 0.929, 0.931, 0.934, 0.936, 0.938, 0.94, 0.942, 0.944, 0.946, 0.948, 0.949, 0.951, 0.953, 0.954, 0.956, 0.958, 0.959, 0.961, 0.962, 0.963, 0.965, 0.966, 0.967, 0.968, 0.97, 0.971, 0.972, 0.973, 0.974, 0.975, 0.976, 0.977, 0.978, 0.979, 0.98, 0.98, 0.981, 0.982, 0.983, 0.983, 0.984, 0.985, 0.985, 0.986, 0.987, 0.987, 0.988, 0.988, 0.989, 0.989, 0.99, 0.99, 0.991, 0.991, 0.992, 0.992, 0.992, 0.993, 0.993, 0.993, 0.994, 0.994, 0.994, 0.994, 0.995, 0.995, 0.995, 0.995, 0.996, 0.996, 0.996, 0.996, 0.997, 0.997, 0.997, 0.997, 0.997, 0.997, 0.997, 0.998, 0.998, 0.998, 0.998, 0.998, 0.998, 0.998, 0.998, 0.998, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0

Input:
One value: \$n\$.
Output:
\$\frac{T(n,\lfloor n^2/4 \rfloor)}{n!}\$ rounded to three decimal places. \$T(n, k)\$ is defined by OEIS sequence A161169.
Sample input and output
n = 3. Output: 0.833
n = 6. Output: 0.765
n = 9. Output: 0.694
n = 12. Output: 0.681
n = 15. Output: 0.651
n = 18. Output: 0.646
n = 50. Output: 0.586
n = 100. Output: 0.56
n = 150. Output: 0.549
n = 200. Output: 0.542
n = 250. Output: 0.538
n = 300. Output: 0.535

Your code should be correct no matter what values of \$n\$ and \$k\$ are given but will only be tested on \$k = \lfloor n^2/4 \rfloor \$. Your output must be within \$0.001\$ of the correct value.
Score
I will run your code on my machine: 8GB RAM, AMD FX(tm)-8350 Eight-Core Processor running Ubuntu 16.04.6 LTS.
I will test for \$n = 50, 100, 150, 200, 250, 300, 350, 400, ...\$ until it no longer completes in 10 seconds. I will also limit the RAM used to 6GB using https://github.com/pshved/timeout.
Your score is the highest \$n\$ your code can reach on my computer within the time limit. If there is a tie, the first answer wins.
Notes
Your code does not need to be deterministic.  That is random sampling methods are allowed as long as they give the right answer at least 9 times out of the first 10 times I test them.

I think the restriction that the code should work for all $(n,k)$ should be changed to for all $n$ if you only look at the cases where $k=\lfloor\frac{n^2}{4}\rfloor$ and the only required output is $\frac{T(n,\lfloor\frac{n^2}{4}\rfloor)}{n!}$.

FWIW, a naive random-sampling implementation in MATLAB can get to 200 on my laptop before timing out.

I would suggest asking for a program that takes both $n$ and $k$ as input, so that “correct no matter what values of $n$ and $k$ are given” is not a non-observable requirement.

Python 3 + SciPy, score ≈ 1.86 · 10103
\$T(n, k)\$ approaches the normal distribution quickly enough that we can just compute it exactly for \$n < 97\$ and use the CDF of the normal distribution for \$n \ge 97\$.  This solution runs in effectively constant time.  (Technically, for \$n > 1.86 \cdot 10^{103}\$ the numbers start being too large to convert to float and we start getting OverflowError.  This hardly matters because the answer is 0.500 for \$n > 1500000\$ or so.)
import sys
import numpy as np
from scipy.special import erfc

n = int(sys.argv[1])
k = n * n // 4

if n < 97:
    a = np.array([1])
    for i in range(1, n + 1):
        a = np.cumsum((np.r_[a, np.ones(i)] - np.r_[np.zeros(i), a])[:-1] / i)
    out = a[k]
else:
    mean = n * (n - 1) / 4
    variance = n * (n - 1) * (2 * n + 5) / 72
    out = erfc((mean - k - 0.5) / np.sqrt(2 * variance)) / 2

print("%.3f" % (out,))

Try it online!

Is it proven to approach the normal distribution? How did you figure that out?

@HiddenBabel Inserting $n$ into any permutation of $1, \dotsc, n - 1$ adds a number of inversions equal to $n$ minus its position. When building random permutations, this number of added inversions is an independent uniformly random number from $0, \dotsc, n - 1$. The central limit theorem tells you that when you add a large number of small enough independent random variables, the result approaches a normal distribution.

Is it correct (up to the required precision)  for all n and k? I will test it in about 12 hours time.

Unfortunately my internet connection has gone down so it will take me a few days until I can test this.

@Anush Yeah, all $n$ and $k$ (if you edit the program to take $k$ as input). Although I just realized that I had forgotten to take into account the combined effect of the normal distribution approximation with the three-digit rounding, so I’ve bumped the cutoff to $n \ge 97$. The worst case is $T(97, 2217)/97! \approx 0.24598945$, where the normal distribution approximation is $0.24548087$ which rounds to $0.245$ for an error of $0.00098945$.

I really like the way you have done this. Have a bounty!

Rust
Port of @Anders Kaseorg's Python answer in Rust.
/src/main.rs
use std::{cmp, env, f64, sync::mpsc, thread, time::Duration};
use statrs::{
    function::erf::erfc,
    distribution::{Normal, Univariate},
};
use ndarray::{Array, Array1, Axis, stack, concatenate, s, prelude::*};
use ndarray_stats::QuantileExt;

fn main() {
    let args: Vec<String> = env::args().collect();
    if args.len() < 2 {
        println!("Please provide a command line argument 'n'.");
        return;
    }
    let n: usize = match args[1].parse() {
        Ok(val) => val,
        Err(_) => {
            println!("Invalid argument. Please provide an integer.");
            return;
        }
    };
    let k = n * n / 4;
    let mut out = 0.0;

    if n < 97 {
        let mut a = Array1::<f64>::from_elem(1, 1.0);
        for i in 1..n + 1 {
            let ones = Array1::<f64>::from_elem(i, 1.0);
            let zeros = Array1::<f64>::from_elem(i, 0.0);
            let a_extended = concatenate(Axis(0), &[a.view(), ones.view()]).unwrap();
            let zeros_extended = concatenate(Axis(0), &[zeros.view(), a.view()]).unwrap();
            let mut a_diff = &a_extended - &zeros_extended;
            a_diff = a_diff.slice(s![..-1]).to_owned();
            a_diff = a_diff / (i as f64);
            let cumsum = |x: &Array1<f64>| {
                let mut sum = 0.0;
                x.mapv(|val| {
                    sum += val;
                    sum
                })
            };
            a = cumsum(&a_diff);
        }
        out = a[cmp::min(k, a.len() - 1)];
    } else {
        let mean = n as f64 * (n as f64 - 1.0) / 4.0;
        let variance = n as f64 * (n as f64 - 1.0) * (2.0 * n as f64 + 5.0) / 72.0;
        // println!("{:.3} {:.3}",mean,variance);
        out = erfc((mean - k as f64 - 0.5) / f64::sqrt(2.0 * variance)) / 2.0;
    }
    println!("{:.3}", out);
}

Cargo.toml
[package]
name = "rust_hello"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
# rand = "0.8.0"
# hyper = "0.13"
# tokio = { version = "0.2", features = ["full"] }
# rayon = "1.5.1"

ndarray = "0.15.4"
statrs = "0.13.0"
ndarray-stats = "0.4.0"

Building and running
# win10 environment

$ cargo build
$ target\debug\rust_hello.exe 500
$ target\debug\rust_hello.exe 100
$ target\debug\rust_hello.exe 18

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


text:
Number of distinct tilings of an n X n square with free n-polyominoes
The newest "nice" OEIS sequence, A328020, was just published a few minutes ago.

Number of distinct tilings of an n X n square with free n-polyominoes.

This sequence counts tilings up to symmetries of the square. The sequence has six terms, but I'd like to see if folks here can extend it further.
Example
For n=4 there are 22 such grids, as shown in this image from the OEIS.

Credit: Jeff Bowermaster, Illustration of A328020(4).
Challenge
Like this previous challenge, the goal of this challenge is to compute as many terms as possible in this sequence, which begins 1, 1, 2, 22, 515, 56734 and where the n-th term is the number of tilings of the n X n grid with n-polyominoes.
Run your code for as long as you'd like. The winner of this challenge will be the user who posts the most terms of the sequence, along with their code to generate it. If two users post the same number of terms, then whoever posts their last term earliest wins.

So this is modulo symmetries of the square?

@PeterTaylor, that's right. I've disambiguated this in the question.

Naively I would say that the n'th entry would take number_of_fixed_n_polyominoes^(n-1) operations to calculate. So for n = 7, that would take 760^6 ≈ 2^57.4 operations. You can probably cut that down a lot, but it's a big number to start with...

@Sliepen, I expect that you can cut down that by quite a lot just by backtracking. In particular, there are a lot of fixed polynomials that can't be placed in the corner, and once a valid polyomino is placed somewhere, it hugely constrains what can be placed next to it.

@PeterKagey, you're right. I guess it helps if, given that you already have placed m n-polyominoes, you choose the next position to try to place a polyomino in the worst possible position, that you can cut it down a lot.

An extension to @Grimy's code gets N=8
This just underlines that @Grimy deserves the bounty:
I could prune the search tree by extending the code to check, after each finished polyomino, that the remaining free space is not partitioned into components of size not divisible by N.
On a machine where the original code took 2m11s for N=7, this takes 1m4s, and N=8 was computed in 33h46m. The result is 23437350133.
Here is my addition as a diff:
--- tilepoly.c  2019-10-11 12:37:49.676351878 +0200
+++ tilepolyprune.c     2019-10-13 04:28:30.518736188 +0200
@@ -51,6 +51,30 @@
     return 1;
 }

+static int check_component_sizes(u64 occupied, u64 total){
+    u64 queue[N*N];
+    while (total<N*N){
+        u64 count = 1;
+        u64 start = ctz(~occupied);
+        queue[0] = start;
+        occupied |= 1ul << start;
+        for(u64 current=0; current<count; ++current){
+            u64 free_adjacent = adjacency_matrix[queue[current]] & ~occupied;
+            occupied |= free_adjacent;
+            while (free_adjacent){
+                u64 next = ctz(free_adjacent);
+                free_adjacent &= ~(1ul << next);
+                queue[count++] = next;
+            }
+        }
+        if (count % N){
+            return 0;
+        }
+        total += count;
+    }
+    return 1;
+}
+
 static void recurse(u64 mino, u64 cell, u64 occupied, u64 adjacent, u64 forbidden)
 {
     if (cell >= N) {
@@ -61,6 +85,9 @@
             return;
         }

+        if(!check_component_sizes(occupied,N*mino))
+            return;
+
         u64 next = ctz(~occupied);
         board[next] = mino;
         recurse(mino, 1, occupied | 1ul << next, adjacency_matrix[next], 0);

Try it online!

This is very nice.

All we need now is a multithreaded simd version :)

Oh that’s really cool! I actually considered this optimization, but didn’t think it’d be enough to reach N=8 in a reasonable time, so I didn’t bother implementing it.

C, 7 terms
The seventh term is 19846102. (The first six are 1, 1, 2, 22, 515, 56734, as stated in the question).
#include <stdio.h>
#include <string.h>
#include <stdint.h>

#define N 7
#define ctz __builtin_ctzl

typedef uint64_t u64;

static u64 board[N*N] = { 0 };
static u64 adjacency_matrix[N*N] = { 0 };
static u64 count = 0;

static u64 check_symmetry()
{
    static const u64 symmetries[7][3] = {
        { 0,     +N, +1 },
        { N-1,   -1, +N },
        { N-1,   +N, -1 },
        { N*N-1, -1, -N },
        { N*N-1, -N, -1 },
        { N*N-N, +1, -N },
        { N*N-N, -N, +1 },
    };

    int order[N];

    for (u64 i = 0; i < 7; ++i) {
        u64 start = symmetries[i][0];
        u64 dcol = symmetries[i][1];
        u64 drow = symmetries[i][2];
        memset(order, 0xFF, N*sizeof(int));

        for (u64 row = 0, col = 0; col < N || (col = 0, ++row < N); ++col) {
            u64 base = board[col + N*row];
            u64 symmetry = board[start + dcol*col + drow*row];
            u64 lex = 0;

            while (order[lex] != symmetry && order[lex] != -1)
                ++lex;
            order[lex] = symmetry;

            if (lex < base)
                return 0;

            if (base < lex)
                break;
        }
    }

    return 1;
}

static void recurse(u64 mino, u64 cell, u64 occupied, u64 adjacent, u64 forbidden)
{
    if (cell >= N) {
        ++mino;

        if (mino == N) {
            count += check_symmetry();
            return;
        }

        u64 next = ctz(~occupied);
        board[next] = mino;
        recurse(mino, 1, occupied | 1ul << next, adjacency_matrix[next], 0);
        return;
    }

    adjacent &= ~occupied & ~forbidden;
    while (adjacent) {
        u64 next = ctz(adjacent);
        adjacent &= ~(1ul << next);
        forbidden |= 1ul << next;
        board[next] = mino;
        recurse(mino, cell + 1, occupied | 1ul << next, adjacent | adjacency_matrix[next], forbidden);
    }
}

int main(void)
{
    for (u64 i = 0; i < N*N; ++i) {
        if (i % N)
            adjacency_matrix[i] |= 1ul << (i - 1);
        if (i / N)
            adjacency_matrix[i] |= 1ul << (i - N);
        if (i % N != N - 1)
            adjacency_matrix[i] |= 1ul << (i + 1);
        if (i / N != N - 1)
            adjacency_matrix[i] |= 1ul << (i + N);
    }

    recurse(0, 2, 3, 4 | 3 << N, 0);
    printf("%ld\n", count);
}

Try it online! (for N=6, since N=7 would time out.)
On my machine, N=6 took 0.171s, and N=7 took 2m23s. N=8 would take a few weeks.

This is wonderful! Let me know if you'd like to add it to the OEIS—which might result in you doxxing yourself—or if you'd like me to add it.

@PeterKagey Please feel free to add it (:

Fascinating check_symmetry function. Could you please give a brief explanation as I’m not familiar with the approach?

@JohnRees It simply tests that the current board is lexicographically ≤ to all of its symmetries. Thus in any set of symmetrical boards, exactly one is counted: the lexicographical minimum.

To do better than enumerating the solutions one by one, some kind of meet-in-the-middle is required. The problem is that there doesn't seem to be any way of splitting things up which gets significant clustering. E.g. using the same canonical ordering as this answer, placing 3 hexominoes I get an average of about 3.7 sets of hexominos per mask. I conclude that this approach is not likely to be beaten.


text:
Make Korean Character Multi-style Ascii/Box Art
About Hangul
As I'm Korean, I'm really proud of Korean character, Hangul(한글).
Hangul is a syllabary invented by King Sejong the great, 4th king of Joseon dynasty, in 1443.
Because today (October 9th) is Hangul day in Korea, I'll give you a challenge: Make some Hangul ascii-art
List of characters
So, To make ASCII art, you have to know every characters represent each syllables, right?
No. There are 11172 syllables in Korean character, so it's almost impossible to hardcode it. But, there are only 24 basic characters:
ㄱㄴㄷㄹㅁㅂㅅㅇㅈㅊㅋㅌㅍㅎㅏㅑㅓㅕㅗㅛㅜㅠㅡㅣ

And in Korean you compose these to make all those syllables.
How to compose
24 basic characters can be separated into two part: a consonant and a vowel.
The first 14 characters ㄱㄴㄷㄹㅁㅂㅅㅇㅈㅊㅋㅌㅍㅎ are consonants, and followingthe  10 characters ㅏㅑㅓㅕㅗㅛㅜㅠㅡㅣ are vowels.
There are roughly 3 parts to a Korean character: initial consonant, vowel, and a final consonant.
Initial consonant
The initial consonant (초성 in Korean) is simplest part. It is just consonant, only with ㄲㄸㅃㅆㅉ(double consonant). It placed in the top-left.
Vowel
The vowel (중성 or 모음 in Korean) is the hardest part. Here is list of the vowels:
ㅏㅐㅑㅒㅓㅔㅕㅖㅗㅘㅙㅚㅛㅜㅝㅞㅟㅠㅡㅢㅣ
ㅏㅐㅏㅒㅓㅔㅕㅖㅣ go on the right side of initial consonant; ㅗㅛㅜㅠㅡ go at the bottom; ㅘㅙㅚㅝㅞㅟㅢ are both. For example: 가, 고, 과.
Final consonant
The final consonant (종성 in Korean) is at the bottom. Here is list of final consonants: ㄱㄲㄳㄴㄵㄶㄷㄹㄺㄻㄼㄽㄾㄿㅀㅁㅂㅄㅅㅆㅇㅈㅊㅋㅌㅍㅎ, or blank.
Example characters using final consonant : 각, 갌, 갏
How to decompose Unicode
See this webpage for help.
Challenge
Input is in this format: (number) Korean char (number) Korean char ...
Where (number) is optional. If a number is given, switch to a different style as specified below. 1 and 2 are ASCII only, and 3 is Unicode box-art.
Separate characters with 2 spaces. Note that not every character has the same width.
If the vowel is not ㅗㅛㅜㅠㅡ, the following final consonant must be indented with a space.
The default style is 1, so if first character doesn't have a number, style 1 is used.
An example input could be: 1한2글3날 or 한3글날.
Here is list of Korean ascii art(style 1 and 2).
Here is list of Korean unicode box-art(style 3).
List of ASCII art
Style 1
ㄱ
___
   |
   |

ㄴ
|
|
|__

ㄷ
 ___
|
|___

ㄹ
___
 __|
|___

ㅁ
 __
|  |
|__|

ㅂ
|  |
|__|
|__|

ㅅ
 /\
|  |
|  |

ㅇ
 __
/  \
\__/

ㅈ
____
 /\
/  \

ㅊ
 __
____
/  \

ㅋ
___
___|
   |

ㅌ
 ___
|___
|___

ㅍ
____
 ||
_;;_

ㅎ
 __
____
 ()

ㄲ
_ _
 | |
 | |

ㄸ
 _ _
| |
|_|_

ㅃ
||||
[][]
""""

ㅆ
/|/|
||||
||||

ㅉ
____
/|/|
||||

ㅏ
    |
    |_
    |
    |

ㅐ
    | |
    |_|
    | |
    | |

ㅑ
    |
    |_
    |_
    |

ㅒ
    | |
    |_|
    |_|
    | |

ㅓ
     |
    _|
     |
     |

ㅔ
     ||
    _||
     ||
     ||

ㅕ
     |
    _|
    _|
     |

ㅖ
     ||
    _||
    _||
     ||

ㅗ

 |
_|__

ㅘ
    |
    |
    |_
 |  |
_|__|

ㅙ
    | |
    | |
    |_|
 |  | |
_|__| |

ㅚ
    |
    |
    |
 |  |
_|__|

ㅛ

 ||
_][_

ㅜ

____
 |

ㅝ
    |
    |
    |
____|
 |--|

ㅞ
    ||
    ||
    ||
____||
 |--||

ㅟ
    |
    |
    |
____|
 |  |

ㅠ

____
 ||

ㅡ

____

ㅢ
    |
    |
    |
    |
____|

ㅣ
    |
    |
    |
    |

ㄳ
_ /|
 |||
 |||

ㄵ
| __
| /|
|_||

ㄶ
| __
| __
|_()

ㄺ
_ _
 ] |
[_ |

ㄻ
_ ++
 ]||
[_""

ㄼ
_ ||
 ][]
[_""

ㄽ
_ /|
 ]||
[_||

ㄾ
_  _
 ]|_
[_|_

ㄿ
_ __
 ]][
[_""

ㅀ
_ __
 ]__
[_()

Style 2
ㄱ
---.
   :
   :

ㄴ
:
:
'---

ㄷ
.---
:
'---

ㄹ
---.
.--'
'---

ㅁ
.--.
:  :
'--'

ㅂ
:  :
:--:
'--'

ㅅ
 ,.
:  :
:  :

ㅇ
 ..
(  )
 ''

ㅈ
-.,-
 ;:
'  `

ㅊ
 --
-,.-
;  :

ㅋ
---.
---:
   :

ㅌ
.---
:---
'---

ㅍ
-..-
 ::
-''-

ㅎ
 --
----
 ()

ㄲ
-.-.
 : :
 : :

ㄸ
.-.-
: :
'-'-

ㅃ
::::
[][]
''''

ㅆ
,:,:
::::
::::

ㅉ
----
,:,:
::::

ㅏ
    :
    :-
    :
    :

ㅐ
    : :
    :-:
    : :
    : :

ㅑ
    :
    :-
    :-
    :

ㅒ
    : :
    :-:
    :-:
    : :

ㅓ
     :
    -:
     :
     :

ㅔ
     ::
    -::
     ::
     ::

ㅕ
     :
    -:
    -:
     :

ㅖ
     ::
    -::
    -::
     ::

ㅗ

 :
-^--

ㅘ
    :
    :
    :-
 :  :
-^--:

ㅙ
    : :
    : :
    :-:
 :  : :
-^--: :

ㅚ
    :
    :
    :
 :  :
-^--:

ㅛ

 ::
-^^-

ㅜ

-v--
 :

ㅝ
    :
    :
    :
-v--:
 :--:

ㅞ
    ::
    ::
    ::
-v--::
 :--::

ㅟ
    :
    :
    :
-v--:
 :  :

ㅠ

-vv-
 ::

ㅡ

----

ㅢ
    :
    :
    :
    :
----:

ㅣ
    :
    :
    :
    :

ㄳ
-.,:
 :::
 :::

ㄵ
: --
: ,:
'-::

ㄶ
: --
: --
'-()

ㄺ
-.-.
.' :
'- :

ㄻ
-...
.'::
'-''

ㄼ
-.::
.'][
'-''

ㄽ
-.,:
.'::
'-::

ㄾ
-..-
.':-
'-'-

ㄿ
-...
.'][
'-''

ㅀ
-.--
.'--
'-()

Style 3
ㄱ
───┐
   │
   │

ㄴ
│
│
└──

ㄷ
┌───
│
└───

ㄹ
───┐
┌──┘
└───

ㅁ
┌──┐
│  │
└──┘

ㅂ
│  │
├──┤
└──┘

ㅅ
 ╱╲
│  │
│  │

ㅇ
╭──╮
│  │
╰──╯

ㅈ
────
 ╱╲
╱  ╲

ㅊ
 ──
────
╱  ╲

ㅋ
───┐
───┤
   │

ㅌ
┌───
├───
└───

ㅍ
─┬┬─
 ││
─┴┴─

ㅎ
 ──
────
 ()

ㄲ
─┐─┐
 │ │
 │ │

ㄸ
┌─┌─
│ │
└─└─

ㅃ
││││
├┤├┤
└┘└┘

ㅆ
╱│╱│
││││
││││

ㅉ
────
╱│╱│
││││

ㅏ
    │
    ├─
    │
    │

ㅐ
    │ │
    ├─┤
    │ │
    │ │

ㅑ
    │
    ├─
    ├─
    │

ㅒ
    │ │
    ├─┤
    ├─┤
    │ │

ㅓ
     │
    ─┤
     │
     │

ㅔ
     ││
    ─┤│
     ││
     ││

ㅕ
     │
    ─┤
    ─┤
     │

ㅖ
     ││
    ─┤│
    ─┤│
     ││

ㅗ

 ╷
─┴──

ㅘ
    │
    │
    ├─
 ╷  │
─┴──│

ㅙ
    │ │
    │ │
    ├─┤
 ╷  │ │
─┴──│ │

ㅚ
    │
    │
    │
 ╷  │
─┴──│

ㅛ

 ╷╷
─┴┴─

ㅜ

─┬──
 ╵

ㅝ
    │
    │
    │
─┬──│
 ╵──┤

ㅞ
    ││
    ││
    ││
─┬──││
 ╵──┤│

ㅟ
    │
    │
    │
─┬──│
 ╵  │

ㅠ

─┬┬─
 ╵╵

ㅡ

────

ㅢ
    │
    │
    │
    │
────│

ㅣ
    │
    │
    │
    │

ㄳ
─┐╭╮
 │││
 │││

ㄵ
╷ ──
│ ╱│
└─╵╵

ㄶ
│ ──
│ ──
└─()

ㄺ
─┐─┐
┌┘ │
└─ ╵

ㄻ
─┐┌┐
┌┘││
└─└┘

ㄼ
─┐╷╷
┌┘├┤
└─└┘

ㄽ
─┐╭╮
┌┘││
└─╵╵

ㄾ
─┐┌─
┌┘├─
└─└─

ㄿ
─┐┬┬
┌┘││
└─┴┴

ㅀ
─┐──
┌┘──
└─()

Example input and output
1한2글3날
 __ |   ---.  │   │
____|_     :  │   ├─
 () |      :  └── │
    |   ----      │
 |      ---.   ───┐
 |      .--'   ┌──┘
 |__    '---   └───

뛟쀒3쫽
 _ _||  ||||||  ────│ │
| | ||  [][]||  ╱│╱││ │
|_|_||  """"||  ││││├─┤
____||  ____||   ╷  │ │
 |--||   |--||  ─┴──│ │
 _ __    _ __    ─┐─┐
  ]__     ]][    ┌┘ │
 [_()    [_""    └─ ╵

Scoring
This is code-golf, so the shortest code in bytes wins.

I was about to say something criticizing the three different styles, but come to think of if they could actually result in some very interesting compression techniques.

Wow I am impressed with the language and thanks for explaining about the consonant/vowel system, interesting stuff. But this challenge still seems too complicated. :O

Very cool challenge. I am going to try this on the weekend. Any entry, no matter how long, beats no entries!

C, 1832 bytes
Well, this is the first time I've ever golfed anything, and this is easily the ugliest code I have ever written:
(compiled with gcc 7.5.0)
#define C(x,y)case 0x##x:y;break;
#define c(x)case x:r=r<<6|getchar()&63;
#define F(x,n)for(x=0;x<n;x++)
#define M(n)"\e["#n"D\e[B"
#define m M(1)
#define U(n)"\e["#n"A"
#define l U(4)
char p[]={0,1,3,6,27,7,15,16,28,18,19,20,21,29,22,23,24,25,26},*H="---.-.-.-.,::   : --: --.------.-.-.-...-.::-.,:-..--...-.--.--.:  :::,: ,. ,:,: .. -.,- -- ---..----..- -- .-.-::::----   : : : ::::   : ,:: --:   .--'.' :.'::.'][.'::.':-.'][.'--:  ::--:[]:::  :::::(  ) ;: -,.----::--- :: ----: : [][],:,:   : : : :::'---'-::'-()'---'---'- :'-'''-'''-::'-'-'-'''-()'--''--''':::  ::::: '' '  `;  :   :'----''- () '-'-''''::::",*B=M(4),
#define P "    "U(3)
#define Q " :"M(2)"-^--"l
*U[]={P,P,P,P,P,P,P,P,Q,Q,Q,Q," ::"M(3)"-^^-"l,"-v--"M(4)" :  "l,"-v--"M(4)" :--"l,"-v--"M(4)" :--"l,"-v--"M(4)" :  "l,"-vv-"M(4)" :: "l,"----","    "M(4)"----"U(4),P},
#define X(x,y)x y x
#define Y(x,y)x y y
#define Z(x,y)x x y x
#define R "\e[4B"M(4)
#define S Z(":"m,":"m)":"M(4)
*V[]={X(":"m,":-"M(2))":"M(4),X(": :"M(3),":-:"M(3))": :"M(6),Y(":"m,":-"M(2))":"M(4),Y(": :"M(3),":-:"M(3))": :"M(6),X(" :"M(2),"-:"M(2))" :"M(5),X(" ::"M(3),"-::"M(3))" ::"M(6),Y(" :"M(2),"-:"M(2))" :"M(5),Y(" ::"M(3),"-::"M(3))" ::"M(6),R,Z(":"m,":-"M(2))":"M(4),Z(": :"M(3),":-:"M(3))": :"M(6),S,R,R,S,Z("::"M(2),"::"M(2))"::"M(5),S,R,M(4),S,Z(":"m,":"m)"\e[3D"},
#define w(m,n)"\e["#m"C"U(n)
#define T w(7,7)
#define W w(8,7)
#define x w(6,8)
*A[]={T,W,T,W,T,W,T,W,x,w(7,8),w(7,8),x,x,x,x,w(7,8),x,x,x,x,x};
#define D(x) printf(x);
g(){int r=getchar(),n=~0;switch(r>>4){C(f,n=7)C(e,n=15)C(d,C(c,n=31))}r&=n;switch(n){c(7)c(15)c(31)}return r;}main(){D("\e[2J\e[H")int n,j,k,t,v,h;while(~(n=g())){if(n>>8){n-=44032;t=n%28;v=n/28%21;h=p[n/588];F(j,3){F(k,4)putchar(H[(j*30+h)*4+k]);D(B)}D(U[v])D(V[v])if(t--)F(j,3){F(k,4)putchar(H[(j*30+t)*4+k]);D(B)}else D("\e[3B")D(A[v])}}}

It only does style 2; the challenge was already difficult enough for me without needing to support all three styles! It's a shame though, because I'm really in love with the charming ASCII art the OP made (by the way, they forgot to provide art for the ㅃ jamo, so I made one myself).
You can see the project here: https://repl.it/@Mahkoe/hangul-ASCII-art
Brief hints for understanding the code

This makes heavy use of ANSI escape sequences for moving the cursor. The U(n) macro moves the cursor up by n characters, and the M(n) macro moves the cursor left by n characters then down by one. (U stands for "up", and M stands for "mot", which is French for "word").
Because U(4) appeared enough times, I defined l to U(4) (l doesn't stand for anything, it was just one of the few single-character identifiers left).
The g function reads stdin and parses out a UTF-8 sequence. It correctly returns EOF when it sees one.
The C and c macros are used to shorten the cases in the switch statements in the g function.
The H string contains all the tail consonants (copy-paste the string to a text file and break it into three 30-character wide lines to see it better). They are ordered according to increasing UTF-8 codepage addresses. (I originally called this string H because early on it only had head consonants, but the name stuck around even after I changed my mind and put in the tail consonants).
Some consonants are head-only consonants (ㄸ, ㅃ, and ㅉ), so I tacked these onto the "right-hand side" of H. The p array is a mapping from the head consonant number to the position in the H string. (I originally called this array p because I thought of it as a permutation, but the name stuck around after I realized it wasn't actually a permutation).
The vowels had so many special cases that I ended up splitting a vowel into three actions: the "underneath" (anything that would end up between the head and tail consonants), the rest of the vowel, and any adjustments needed to the cursor after drawing the tail consonant. These three quantities are stored in the U, V, and A strings, respectively.
If anything appeared often enough in the U, V, or A strings, I made a macro for it. This consists of the P, Q, R, S, T, W, w, and x macros (I started having name collisions, which is why the macro name pattern breaks after T).
All together, the main function eats characters from stdin until it gets an EOF. If it sees a Hangul character, it prints the head consonant, then the underneath, then the rest of the vowel, then the tail consonant, then the adjustment.

This challenge was delightful, and I'm really excited about having learned Hangul. Thanks!

Welcome to Code Golf! This is a seriously impressive first answer!

Nice first answer! I think you're eligible to claim this bounty.

Do also note what language it is (in this case it'd be # C, 1832 bytes)

1538 bytes


text:
Typing, but to the left
Background
You've been given a task to take notes for a meeting. You start typing on your Google Doc, but you don't have enough time during the meeting to look at your keyboard while you type.
Fortunately for you, you can type without looking at your keyboard. After the meeting, you realize that everything you typed was one key to the left.
The Challenge
For this challenge, you will be using the letters, numbers, and space bar of the QWERTY keyboard layout.

Given an input of text (from any standard input method), output the resulting text, where every character is moved one to the left on the keyboard.

For the majority of letters, just look at the letter and translate it to the letter to the left (c becomes x, t becomes r, etc).
For letter q, translate to a literal tab character (\t).
For letter a, enable caps lock, so the capitalization of the rest of the string is reversed.
For letter z, capitalize the next letter in the string.
No translation is required for the space bar.

Preserve capitalization while translating, and be mindful of caps lock (if caps lock is enabled, make sure the case is the opposite).
All characters in the input string will be letters, numbers, or a space. No punctuation or other characters can be included.

Test Cases
\t is a literal tab character
Hello world    -> Gwkki qieks
Code Golf      -> Xisw Fikd
Queried apples -> \tyweuws OOKWA

Scoring
Lowest score in bytes wins. Have fun!

A quick reference of the relevant rows of the QWERTY keyboard would be useful, and keep the challenge self-contained

Do numbers get shifted up to punctuation if there was a "Z" prior to them?

@ErikF No, because caps lock does not do that on most common keyboard that I'm aware of.

But Z corresponds to shift...?

Suggested test case: Azerty -> wERT

Suggested test cases: a123 -> \12; z123 -> ~12`

Suggested test case with multiple A and a Z: All zodiacs -> KK iSUxa

For letter z, capitalize the next letter in the string -> does that mean that we only have to care about letter capitalization and don't have to toggle between digits and symbols? What's the expected output for 0123456789, a0123456789 and z0z1z2z3z4z5z6z7z8z9? (Besides, on many non-QWERTY keyboards, 'Caps Lock' really acts as a 'Shift Lock'. I believe that QWERTY doesn't follow this pattern, but it should be specified for those of us who are not familiar with it.)

The question could do with explicit clarification of the expected behaviour for 1.  My keyboard would result in z123 -> ¬12, and not tilde.  (Assuming the answer to @ErikF's question is Yes)

Possible duplicate of Given an input, move it along the keyboard by N characters

In fact, the Shift behaviour of all Numbers needs defining.  My keyboard has: ¬!"£$%^&*()
@Matthew Jensen has ~!@#$%^&*()

What will happen if input contains two z in a row like: zze? Should it output W or w?

JavaScript (V8), 271 bytes
f=(s,k='~!@#$%^&*()_+`1234567890-=\tQWERTYUIOP{}|\tqwertyuiop[]\\ASDFGHJKL:"\n\\asdfghjkl;\'ZXCVBNM<>?zxcvbnm,./')=>s.replace(/[^ ]/g,c=>k[k.indexOf(c)-1]).replace(/\\([^\\]*)\\?/g,(m,c)=>c.replace(/[a-zA-z]/g,l=>l>'Z'?l.toUpperCase():l.toLowerCase())).replace(/[?']/,"")

Try it online!
My first JavaScript code golf.
It could definitely be shorter, but I think this is a good start.
It basically finds each character in the k string and replaces it with the previous one, then swaps the case of everything between the A or a, and removes all occurences of Z or z (as shift key does nothing on its own).
This should be a normal QWERTY keyboard layout, but let me know if not.

In your own TIO link, zebras=>wveA test case seems to be wrong. The first z should cause the e to print an uppercase w. From OP: "For letter z, capitalize the next letter in the string."

@Night2 Cheers, I posted before OP made the clarification. I assumed pressing the shift key once will do nothing.

Python 3, 211 bytes
d=' ~!@#$%^&*()`~1!2@3#4$5%6^7&8*9(0)		qQwWeErRtTyYuUiIoOpPaAsSdDfFgGhHjJkKlLzZxXcCvVbBnNmM  '
c=s=0
for i in input():k=d.find(i);print(end=d[k-2+(c*i.isalpha()^s)*(1-k%2*2)][i in'aAzZ':]);c^=i in'aA';s=i in'zZ'

Try it online!
Uses a lookup string in which the normal character and its shift-modified version are grouped together. For each character in the input, it will retreive the character two places to the left. Changes capitalization by adding 1 (or -1 if the current character is uppercase) to the lookup value when shift XOR caps lock is active. Numbers are not influenced by the caps lock modifier.

C (gcc), 276 bytes
i;j;k;h;l;m;n;o;f(char*b){char*c=calloc(m=strlen(b),1),*a=" \tqwertyuiop\aasdfghjkl\nzxcvbnm\tQWERTYUIOP\aASDFGHJKL\nZXCVBNM`1234567890";for(i=k=j=n=0;j<=m;l=a[i=index(a,b[j++])-a-1])k=l^7?k:!k,o=l>64&l<91?a[i-30*k]:l<97?h=i?l^7?l?l^10?l:0:32:0:0:a[i+29*k],o?c[n++]=o:n;b=c;}

Thanks to ceilingcat for -33 bytes.
Try it online!

Suggest k^=!(l^7) instead of k=l^7?k:!k

Red, 218 bytes
func[t][c: z: 0 rejoin collect[foreach s t[case[find"Aa"s[c: c xor 32]find"Zz"s[z: 32]on
[keep(select/case"  poiuytrewq^-lkjhgfdsamnbvcxzPOIUYTREWQ^-LKJHGFDSAMNBVCXZ0987654321~"s)xor either s <#"Z"[0][c xor z]z: 0]]]]]

Try it online!
Currently AaZz don't affect digits.

This does not seem to work for 'A pear' -> ' OWe'

@Jitse Hmm

@Jitse But really doesn't work well with digits, it is not entirely clear from the OP

I agree, the challenge is very ambiguous as is.

PHP, 227 bytes
for(;''<$s=$argn[$i++];)$s!=a&&$s!=A?$s!=z&&$s!=Z?($t=$m[stripos($m='~1!2@3#4$5%6^7&8*9(0	qwertyuiopasdfghjklzxcvbnm',$s)-1])+(print$s>' '?$s<A?!$h?$s-1?$s?$s-1:9:'`':$t:($t>=A&&(($s<a)+$h+$c)%2?$t^' ':$t):$s)+$h=0:$h=1:$c=!$c;

Try it online!
I have created a mapping string (~1!2@3#4$5%6^7&8*9(0  qwertyuiopasdfghjklzxcvbnm) which for each digit has their SHIFT mode on the left and for each letter has the letter/key to their left.
I loop over input characters and for each character:

If character is a or A, caps lock flag gets reversed (logical not).
If character is z or Z, shift flag is set to 1.
When character is not in aAzZ:

Character to the left of current character in the mapping string is stored in $t.
If current character is an space, it is printed.
If current character is a digit, and if shift flag is 1, $t is printed, else, if digit is 1, ` is printed, if digit is 0, 9 is printed and otherwise, digit-1 is printed.
If current character is a letter, based on status of shift flag, caps lock flag and casing of current character (lower/upper), $t in lower or upper case is printed. The only special case here is tab character, which is printed as is.
Shift flag is always set back to 0 at the end.


text:
Tips for golfing in MathGolf
What general tips do you have for golfing in MathGolf? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to MathGolf (for tips which can be applied to loads of programming languages, look at the general tips).

Writing 513 in a MathGolf program will push three separated digits (5;1;3), instead of the number 513 itself.
In MathGolf there are therefore quite a lot of 1-byte builtins for numbers: -3 through and including 38; 60; 64; 100; 128; 256; 512; 1000; 1024; 2048; 3600; 4096; 10000; 86400; 100000; 1000000; 10000000; 100000000.
However, for other numbers it can sometimes be tricky to find the shortest way to generate it, so here an overview of the integers in the range [1, 1000]:
NOTE: This is W.I.P. I will add more when I have some time. I was unable to make an evaluation program to check all possibilities (thus far), so these were done by hand.. I've also made it a community wiki, so if anyone else finds shorter alternatives or wants to continue with the numbers, feel free to edit it.
Of course many variations can be found for certain numbers, as can be seen here and here. So the list below contains just one of the shortest variations.
-3-0:   d, c, b, 0
1-10:   1, 2, 3, 4, 5, 6, 7, 8, 9, ♂
11-20:  A, B, C, D, E, ☻, F, G, H, I
22-30:  J, K, L, M, N, O, P, Q, R, S
31-40:  T, ♥, U, V, W, X, Y, Z, Z), Z⌠
41-50:  Dx, J∞, Vx, K∞, K∞), L∞, L∞), M∞, 7², N∞       TODO: 2-byters for 45,47
51-60:  Ex, O∞, Wx, P∞, ♂f, Q∞, ╟╫, R∞, ╟(, ╟
61-70:  ☻x, T∞, Xx, ♦, ♦), U∞, U∞), V∞, V∞), W∞        TODO: 2-byters for 67,69
71-80:  Fx, X∞, Yx, Y∞, Y∞), Z∞, Z∞), Z∞⌠, ♦E+, ♦F+    TODO: 2-byters for 75,77,78,79,80
81-90:  Gx, Qx, Zx, Zx), Zx⌠, ♦K+, ♦L+, R■, ♂f, ♦O+    TODO: 2-byters for 84,85,86,87,90
91-100: Hx, Rx, ♦R+, T■, ♦T+, ♦♥+, ♦U+, ♀⌡, ♀(, ♀      TODO: 2-byters for 93,95,96,97
TODO: Continue through 1000

Here is a universal constant-generating method in MathGolf. Example (generating 513):
û☺☻$

This defines a two-character string and takes its ord code. The ord code of ☻ is 2, and the ord code of ☺ is 1. The ord code of this string is therefore 2*256+1=513.
Taking the ord code also works for single characters. (Constants generated by this method are likely to be unoptimal.) This one returns 2.
'☻$

Also works for string length 3 and so on...
ùUTS$
83*256*256+84*256+85=5461077

Can this be brute forced (with a time-out)?

@someone "I was unable to make an evaluation program to check all possibilities (thus far), so these were done by hand.." ;) I'm pretty sure it should be possible with a pure bash script instead of inside the MathGolf TIO, because MathGolf will stop with an error quite easily. Getting all possible pairs and just using eval in MathGolf itself already errors on the very first combination. The language is still pretty unstable imho.

49 = 7² or , 55 = ♂f, 89 = Af

@Grimy You could edit it in yourself, I've made it a comm wiki anyway. And I'm an idiot for missing 7². As for the other two, I didn't even knew MathGolf had a Fibonacci builtin. :)

@someone For a list it will do the cartesian product with itself: Try it online. For an integer, it will output the n'th Collatz number (which is basically 3n+1 for odd numbers; and n/2 for even numbers - although this second part is less useful because there is already a builtin for that): Try it online.

This post tries to explain how the compressed strings work in MathGolf (a canonical feature for golfing languages).
This mechanism is actually quite simple: say you are trying to decompress the character Σ via the ╢ instruction.
First of all, this character is 0xE4 in CP437. We then pass this through a lookup table. (We are decompressing using ╢, which has the lookup table etaoinsrdluczbfp. There is one other such table gwymvkxjqh ?*#.,.)
We realize that the E'th character (in hex) in the lookup table is f. The 4th character in the lookup table is i. So we get the decompressed string fi.

The way I do it is that I check the reference page and Code page 437, and I match the column and the row of the character within the code page with the indices of the string I want. So, ╕ means indexing in the string etaoinsrdluczbfp. In that string, b has index 13, z has index 12, and t has index 1. Thus, I look at row 13 and column 12 for bz, which is character ▄. Then I look at row 12 and column 1 for zt, which is character ┴. --maxb

For the sake of completeness I will also explain the dictionary: ╩ pushes top 256 dictionary words. The word is indexed by the next character in the program, and the index is 0-indexed. ╦ uses a number on the stack.

I see you've already figured it out. I was about to post this comment: "Well, the string compression part is on the TODO list to be changed, since right now it isn't possible to mix characters of etaoinsrdluczbfp and gwymvkxjqh ?*#.,". But when I asked maxb about the compression, he briefly explained it in the comments here.

Maybe also useful to mention that it isn't strictly CP437. EDIT: Although I'm not sure the null-byte is still part of the encoding. I know Max changes a command from a null-byte to something else because it was hard to type, but not sure what the null-byte represents right now.


text:
Digit Date Range
NOTE: Since I'm Dutch myself, all dates are in the Dutch dd-MM-yyyy format in the challenge description and test cases.
Challenge:
Inputs:
Start date \$s\$; End date \$e\$; Digit \$n\$
Outputs:
All dates within the range \$[s,e]\$ (including on both sides), which contain \$n\$ amount of unique digits in their date.
Example:
Inputs: Start date: 12-11-1991; End date: 02-02-1992; Digit: 4
Outputs:
With leading 0s for days/months:
[20-11-1991, 23-11-1991, 24-11-1991, 25-11-1991, 26-11-1991, 27-11-1991, 28-11-1991, 30-11-1991, 01-12-1991, 02-12-1991, 09-12-1991, 10-12-1991, 13-12-1991, 14-12-1991, 15-12-1991, 16-12-1991, 17-12-1991, 18-12-1991, 20-12-1991, 23-12-1991, 24-12-1991, 25-12-1991, 26-12-1991, 27-12-1991, 28-12-1991, 31-12-1991, 01-01-1992, 02-01-1992, 09-01-1992, 10-01-1992, 11-01-1992, 12-01-1992, 19-01-1992, 20-01-1992, 21-01-1992, 22-01-1992, 29-01-1992, 01-02-1992, 02-02-1992]

Without leading 0s for days/months:
[20-11-1991, 23-11-1991, 24-11-1991, 25-11-1991, 26-11-1991, 27-11-1991, 28-11-1991, 30-11-1991, 3-12-1991, 4-12-1991, 5-12-1991, 6-12-1991, 7-12-1991, 8-12-1991, 10-12-1991, 13-12-1991, 14-12-1991, 15-12-1991, 16-12-1991, 17-12-1991, 18-12-1991, 20-12-1991, 23-12-1991, 24-12-1991, 25-12-1991, 26-12-1991, 27-12-1991, 28-12-1991, 31-12-1991, 3-1-1992, 4-1-1992, 5-1-1992, 6-1-1992, 7-1-1992, 8-1-1992, 10-1-1992, 13-1-1992, 14-1-1992, 15-1-1992, 16-1-1992, 17-1-1992, 18-1-1992, 20-1-1992, 23-1-1992, 24-1-1992, 25-1-1992, 26-1-1992, 27-1-1992, 28-1-1992, 31-1-1992]

Challenge rules:

The input and output dates may be in any reasonable (date-)format. Can be as a string in any dMy format (including optional separators), list of three integers, your language's native Date-object, etc. Output may be a list/array/stream, printed to STDOUT, a single delimited String, etc.
You are allowed to include or exclude leading 0s for days/months in your outputs. Please specify which of the two you use in your answer, since it will cause different results. I.e. 1-1-1991 has 2 unique digits, but 01-01-1991 as 3 unique digits.
You don't have to deal with leap years and differences of Gregorian vs Julian calendars. You can assume the date-ranges given in the test cases will never go over February 28th/March 1st for years divisible by 4.
The input-digit \$n\$ is guaranteed to be in the range \$[1,8]\$, so dealing with \$n=0\$ is unspecified (returning an empty list would be most reasonable, but giving an error or incorrect result is fine as well; you won't have to deal with that input).

General rules:

This is code-golf, so shortest answer in bytes wins.
Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.
Standard rules apply for your answer with default I/O rules, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.
Default Loopholes are forbidden.
If possible, please add a link with a test for your code (i.e. TIO).
Also, adding an explanation for your answer is highly recommended.

Test cases:
Inputs: [12-11-1991, 02-02-1992], 4
Outputs with leading 0s:    [20-11-1991, 23-11-1991, 24-11-1991, 25-11-1991, 26-11-1991, 27-11-1991, 28-11-1991, 30-11-1991, 01-12-1991, 02-12-1991, 09-12-1991, 10-12-1991, 13-12-1991, 14-12-1991, 15-12-1991, 16-12-1991, 17-12-1991, 18-12-1991, 20-12-1991, 23-12-1991, 24-12-1991, 25-12-1991, 26-12-1991, 27-12-1991, 28-12-1991, 31-12-1991, 01-01-1992, 02-01-1992, 09-01-1992, 10-01-1992, 11-01-1992, 12-01-1992, 19-01-1992, 20-01-1992, 21-01-1992, 22-01-1992, 29-01-1992, 01-02-1992, 02-02-1992]
Outputs without leading 0s: [20-11-1991, 23-11-1991, 24-11-1991, 25-11-1991, 26-11-1991, 27-11-1991, 28-11-1991, 30-11-1991, 3-12-1991, 4-12-1991, 5-12-1991, 6-12-1991, 7-12-1991, 8-12-1991, 10-12-1991, 13-12-1991, 14-12-1991, 15-12-1991, 16-12-1991, 17-12-1991, 18-12-1991, 20-12-1991, 23-12-1991, 24-12-1991, 25-12-1991, 26-12-1991, 27-12-1991, 28-12-1991, 31-12-1991, 3-1-1992, 4-1-1992, 5-1-1992, 6-1-1992, 7-1-1992, 8-1-1992, 10-1-1992, 13-1-1992, 14-1-1992, 15-1-1992, 16-1-1992, 17-1-1992, 18-1-1992, 20-1-1992, 23-1-1992, 24-1-1992, 25-1-1992, 26-1-1992, 27-1-1992, 28-1-1992, 31-1-1992]

Inputs: [19-09-2019, 30-09-2019], 5
Outputs (same with and without leading 0s): [23-09-2019, 24-09-2019, 25-09-2019, 26-09-2019, 27-09-2019, 28-09-2019, 30-09-2019]

Inputs: [19-09-2019, 30-09-2019], 8
Output (same with and without leading 0s): []

Inputs: [20-06-1749, 30-06-1749], 8
Outputs with leading 0s:    [23-06-1749, 25-06-1749, 28-06-1749]
Outputs without leading 0s: []

Inputs: [10-12-1969, 12-01-1970], 6
Outputs (same with and without leading 0s): [30-12-1969]

Inputs: [10-12-1969, 12-01-1970], 5
Outputs with leading 0s:    [10-12-1969, 13-12-1969, 14-12-1969, 15-12-1969, 17-12-1969, 18-12-1969, 20-12-1969, 23-12-1969, 24-12-1969, 25-12-1969, 27-12-1969, 28-12-1969, 31-12-1969, 02-01-1970, 03-01-1970, 04-01-1970, 05-01-1970, 06-01-1970, 08-01-1970, 12-01-1970]
Outputs without leading 0s: [10-12-1969, 13-12-1969, 14-12-1969, 15-12-1969, 17-12-1969, 18-12-1969, 20-12-1969, 23-12-1969, 24-12-1969, 25-12-1969, 27-12-1969, 28-12-1969, 31-12-1969, 2-1-1970, 3-1-1970, 4-1-1970, 5-1-1970, 6-1-1970, 8-1-1970, 12-1-1970]

Inputs: [11-11-1111, 11-11-1111], 1
Output (same with and without leading 0s): [11-11-1111]

I know it is specifically not the format demanded here, but I just comment here to "spread the word": there is an internationnal standard that programmers should try to use for dates (in logs, filenames, etc) : https://en.wikipedia.org/wiki/ISO_8601. (uses a 'T' to desambiguate (without the T the date+time could be something else entirely) and specifies the separators to use, and when one can not use separators [ie proposes different variant (from short to long] of the same standard]: the main one being: YYYY-MM-DDThh:mm:ss.mmm +hh:mm, the +hh:mm being your locale's time offset from UTC .)

Japt, 23 bytes
Takes the date inputs as Unix timestamps, outputs an array of strings with formatting and leading 0s dependent on your locale. Would be 1 byte shorter in Japt v2 but there seems to be a bug when converting Date objects to strings.
òV864e5@ÐX s7Ãf_¬â Ê¶WÄ

Try it
òV864e5@ÐX s7Ãf_¬â Ê¶WÄ     :Implicit input of integers U=s,V=e & W=n
òV                          :Range [U,V]
  864e5                     :  With step 86,400,000 (24*60*60*1000)
       @                    :Map each X
        ÐX                  :  Convert to Date object
           s7               :  Convert to locale date string
             Ã              :End map
              f             :Filter
               _            :By passing each through the following function
                ¬           :  Split
                 â          :  Deduplicate
                   Ê        :  Length
                    ¶       :  Is equal to
                     WÄ     :  W+1, to account for the inclusion of the delimiting "/" or "-"

R, 81 bytes
function(s,e,n,x=seq(s,e,1))x[lengths(sapply(strsplit(paste(x),""),unique))==n+1]

Try it online!
Uses R’s native date format and has leading zeros on day and month.

Red, 93 bytes
func[a b n][until[if n = length? exclude d: rejoin[a/4"-"a/3"-"a/2]"-"[print d]b < a: a + 1]]

Try it online!
Without leading 0s for days/months.
Too bad that Red converts internally 09-10-2019 to 9-Oct-2019 - that's why I need to extract the day/month/year individually.

I'm not familiar with Red but it seems like there's a lot of whitespace that could be cut out of this. Pardon me if I'm wrong, though.

@connectyourcharger No problem! Seemingly there are several unnecessary whitespaces, but they are needed to separate the tokens. Words (identifiers) in Red can include -=+*<>?!~&, that's why a whitespace (or (...)[...]"...") are needed.

Python 3.8 (pre-release), 84 bytes
-6 bytes thanks to Gloweye
lambda s,e,n:[d for i in range((e-s).days+1)if-len(set(d:=str(s+type(e-s)(i))))==~n]

An unnamed function which returns a list of strings (counting/including leading zeros) that accepts three arguments:

s, the start - a datetime.date object;
e, the end - a datetime.date object; and
n, the number of days - an int object.

Try it online!
Note: As the function accepts datetime.date objects I have not counted the import code for that (and have worked around importing the datetime.timedelta object as it is indirectly accessible via subtraction of these input objects).

type(obj) is 3 bytes shorter than obj.__class__.

@Gloweye awesome thanks!

@Gloweye saves 6 in the end (the dot goes and the brackets are already present)

I hadn't analyzed to that depth yet, just saw the __class__ and made a quick comment. Always glad to help.

Ruby -rdate, 54 bytes
Takes 2 Date objects and a number as input, and returns a list of Date objects as output. Handles leap years and uses leading zeroes.
->a,b,n{(a..b).select{|d|d.to_s.chars.uniq.size==n+1}}

Try it online!

JavaScript (ES6), 91 bytes
Takes input as (n)(end)(start), where the dates are expected as Unix timestamps in milliseconds. Returns a space-separated list of dates in format yyyy-mm-dd.
Leading 0s are included.
n=>b=>g=a=>a>b?'':(new Set(d=new Date(a).toJSON().split`T`[0]).size+~n?'':d+' ')+g(a+864e5)

Try it online!

This snippet will probably fail if DST shifted happened (a+864e5 may not be tomorrow in that case). But thankfully, tio use UTC timezone which doesn't have DST. -- from someone who use the same logic in product website and realize something wrong until DST shifted...

PHP, 90 bytes
for([,$s,$e,$n]=$argv;$s<=$e;)$n-count(count_chars($d=date(Ymd,86400*$s++),1))||print$d._;

Try it online!
This is with leading 0s. Inputs are command arguments ($argv) and dates are Unix timestamps in days (basically standard seconds / 86400), I used this format as we don't need the time in this challenge and it allowed me to golf 1 more byte. Keeps adding a day to start until it reaches the end and prints any dates with $n unique digits in it, separated by _ in Ymd format.
Also have a 89 bytes alternative which prints dates to output in same format as input (Unix timestamps in days).

Java (JDK), 86 bytes
(s,e,n)->s.datesUntil(e.plusDays(1)).filter(d->(""+d).chars().distinct().count()==n+1)

Try it online!
I chose to use leading 0s.
Credits

-24 thanks to Kevin Cruijssen who didn't know he could golf away that much :p

Maybe I shouldn't have made it inclusive on both ends, then you could have used Java 9's datesUntil for 103 bytes. ;) Nice answer. I don't see anything that could be golfed personally.

@KevinCruijssen Well, actually, you gave an extremely nice way of golfing! Just add .plusDays(1) and remove the .forEach(System.out::println) and it's a very much golfed answer because as you wrote, dates can be returned as value objects and streams are allowed. ;-) I had no clue that datesUntil even existed! Thank you for that :-)

Woops, forgot about my own rules allowing stream returns, haha XD I'm an idiot. But glad I could help you with my idiocy. ;p

C# (Visual C# Interactive Compiler)
Without leading 0s, 104, 103 bytes
(s,e,n)=>new int[(e-s).Days+1].Select((x,i)=>s.AddDays(i)).Where(x=>$"{x:yyyMd}".Distinct().Count()>=n)

Try it online!
With leading 0s, 106 105 bytes
(s,e,n)=>new int[(e-s).Days+1].Select((x,i)=>s.AddDays(i)).Where(x=>$"{x:yyyMMdd}".Distinct().Count()>=n)

Try it online!

You can remove the space at x =>$" in both your versions for -1. :)

@KevinCruijssen ah fuck thanks x) I'm sure someone can come up with a shorter solution too, I'm not satisfied with this one

Kotlin, 119 bytes
fun f(a:LocalDate,b:LocalDate,c:Long)=a.datesUntil(b.plusDays(1)).filter{it.toString().chars().distinct().count()==c+1}

Without leading 0s, takes in two java.time.LocalDate and a Long, returns a Stream of LocalDates

Hi, welcome to CCGC! Could you perhaps add a Try it online link with test code to verify it works? Also, I don't know Kotlin, but is it possible to replace it.toString() with (it+"") to save a few bytes? I know this is possible in some other languages like Java or .NET C#.


text:
Implement the named labels for assembly
Let's assume we've got an imaginary assembler. The assembler supports numerical labels. An infinite loop example:
:1
    jmp 1

Your task is, to write a preprocessor for this assembler supporting named labels (instead of numerical ones; with up to 8 characters in length), so the label name is replaced to it's numerical value.
The assembler uses a dot (.) to express a character constant, for example:
mov dl, .A

Will store ASCII(65) - 'A', in the register dl. The assembler supports string constants in double quotes too:
:20
db "Hello, world!"

So, to sum things up, you need to be aware of character constants, and the fact that you can't perform any substitution inside quote-enclosed strings.
The label declaration character and reference character is up to your choice, but for the sake of completness I will use a $ to refer to a label, and @ to denote a label.
The label' number might be any natural number not equal to zero.
You may assume that assembly on the input is perfectly valid.
Let's look at a few examples:
@loop
    jmp $loop

:1
    jmp 1

jmp $skip
mov dl, .@
@skip
cmp dl, .$

jmp 1
mov dl, .@
:1
cmp dl, .$

@x
db "$a @b"
@a
    jmp $a
    @b
        jmp $b

:1
db "$a @b"
:2
    jmp 2
    :3
        jmp 3

This is a code golf, so the smallest answer wins. Standard rules and loopholes apply.
You can safetly assume that the user won't use numerical labels anymore, and the labels contain just A-Za-z letters.
Label declaration and reference character has to be different.

May the strings contain escaped double-quotes? (e.g. db "this is \"bad\"")

@Arnauld nope, they can't. The example you've given is incorrect input so you don't need to deal with that.

Can the named labels contain numbers? Besides a newline can they contain any ASCII character? Or even any character?

@Arnauld sorry, my mistake.

@FryAmTheEggman you can assume just A-Za-z letters.

@Arnauld no, they have to be different.

May a single line contain both a string and a genuine reference to a label?

(Or maybe more generally: may a genuine reference to a label be followed by anything other than an end of line?)

@Arnauld yes, it can.

You should specify what the behaviour of each of the examples is

Can anything be on the same line as a label?

Can newlines be inside quoted strings?

Can quote characters appear anywhere for any other purpose?

Answering questions in order, yes - a comment starting with a semicolon and ending with a newline, no - they can not, yes - you have to parse the syntax, not guess the semantics.

Do we need to preserve comments unchanged? Also there is nothing about comments in the question itself.

JavaScript (ES6), 96 bytes
Uses @label for a declaration and %label for a reference.
s=>s.replace(o=/^\s*@(.+)/gm,(_,s)=>':'+(o[s]=++n),n=0).replace(/".*?"|%(\w+)/g,(s,x)=>x?o[x]:s)

Try it online!
Commented
(alternate slash characters are used below to prevent the SE syntax highligter from going mad)
s =>                  // s = input string
  s.replace(          // 1st pass:
    o =               //   assign the regex object to o; we'll use it to store the labels
    ∕^\s*@(.+)∕gm,    //   look for [start] + [optional whitespace] + '@' + [label]
    (_, s) =>         //   replace with:
      ':' +           //     ':' + label ID
      (o[s] = ++n),   //     increment n and store the label in o
    n = 0             //   start with n = 0
  )                   // end of replace()
  .replace(           // 2nd pass:
    ∕".*?"|%(\w+)∕g,  //   look for either ".*?" (non-greedily) or %label
    (s, x) =>         //   replace with:
      x ? o[x]        //     o[label] if x is defined,
        : s           //     or the original string otherwise
  )                   // end of replace()

Nice! Would you like to add explaination?

I might have stolen your RegEx idea (embarrassed face).

@Night2 My RegEx! Where's my RegEx?! :p

/".*?"|%(\w+)/g, ported it to /".*?"|([@_]\w+)/ for my usage!

Btw, invalidated: Doesn't work if there is whitespace at the start of the line.

@KrzysztofSzewczyk Do you mean that there can be whitespace before a label declaration?

@Arnauld yes, quick fix - [ \t]* before the @.

@KrzysztofSzewczyk This should be specified.

@Arnauld I thought it's implicit. Well, I'll state it in the question anyway.

@KrzysztofSzewczyk FWIW, most assemblers I know of would throw a syntax error if there's some whitespace before a label declaration.

@Arnauld NASM doesn't for sure, GAS doesn't too.

PHP (7.4), 148 143 bytes
-5 bytes by stealing RegEx idea from @Arnauld.
<?=preg_replace_callback('/".*?"|([@_]\w+)/',fn($m)=>$m[1]?[':'][$m[0][0]>A].($_GET[$w=substr($m[0],1)]?:$_GET[$w]=++$_GET[0]):$m[0],$argv[1]);

Try it online!
Define labels with @ and refer to them with _.
Captures any @<label> or _<label> which aren't inside double quotes ("...") and replaces them with a unique number for every unique label, starting from 1. Also adds the : when replacing labels that have @ before them.
PHP's global variable $_GET is used to store and access last used id and unique ids for each label inside the arrow function. $_GET[0] holds last used id and $_GET[<label>] holds unique id for <label>.

Nice job! Quite small one.

Retina 0.8.2, 97 bytes
ms(1`^@
:@
+`(.*^:(1*).*?^)@
$1:1$2@
^:1*
:$.&
\$(.+?)$(?<=(?=.*^:(\d+)@\1$).+)
$2
^(:\d+).*?$
$1

Try it online! Uses the provided symbols (could save 1 byte by using a different symbol). Explanation:
ms(

Run everything in single multiline mode, where . matches newlines and ^ and $ match at the beginning and end of each line.
1`^@
:@

Prefix a : to the first label.
+`(.*^:(1*).*?^)@
$1:1$2@

Number the labels in unary.
^:1*
:$.&

Convert to decimal.
\$(.+?)$(?<=(?=.*^:(\d+)@\1$).+)
$2

Find all matching references and replace them with the number.
^(:\d+).*?$
$1

Delete the label names.

Python 3, 136 117 bytes
New and improved:
import re;d={}
f=lambda s:re.sub(r'(".+?")|([@$])(\w+)',lambda m:m[1]or d.setdefault(m[3],f":{m.end()}")[m[2]<='@':],s)

Try it online!
Uses the position of the match.end() as the integer for a label.
Old code
import re;d={};n=[*range(9999)]
f=lambda s:re.sub(r'(".+?")|([@$])(\w+)',lambda m:m[1]or d.setdefault(m[3],f":{n.pop()}")[m[2]<='@':],s)

Try it online!
Labels start at 9998 and count downward.  Some numbers may be skipped.  It will handle about 5000 labels, which should be enough for any sane asm program, but the number can be increased at 1 byte for each order of magnitude increase in range.

Perl 5 (-p), 57 bytes
s/^\s*\K@(\w+)/":".($$1=++$,)/mge;s/".*?"\K|\$(\w+)/$$1/g

Try it online!

$, : global variable used as counter
s/^\s*\K@(\w+)/":".($$1=++$,)/mge : replaces labels "@[label]" by ":[counter]", increment counter and store counter in variable label name's variable
".*?"\K| : regex part used to ignore strings between ""
s/...\$(\w+)/$$1/g : replaces references by variables value

Hell yeah, that's what I've been looking for. Classy, write-only Perl snippet.

See nothing about ignoring comments starting from semicolon. Or we don't need to preserve them?

indeed, it's similar lbl, instead of :. Just strings handling seems easier to maintain when matching first unwanted in alternation

Javascript ES6, 71 char
s=>s.replace(/(;.*|".*?")|:(:?)(\w+)/gm,(m,s,c,l)=>s||c+parseInt(l,36))

Conditions:

:: to introduce the label
: to use the label
Labels are case insensitive
; starts comment till the end of the line
Quoted strings may not have " or linebreak inside
Charecter constants may not be followed by colon or letter like .:a or .::
Classic numeric labels starting from : are disallowed

Test:

console.log((

s=>s.replace(/(;.*|".*?")|:(:?)(\w+)/gm,(m,s,c,l)=>s||c+parseInt(l,36))

)(`
::loop
    jmp :loop

jmp :skip
mov dl, .:
::skip
cmp dl, .:

::x
db ":a ::b"
::a
    jmp :a
    ::b
        jmp :b
`))
.as-console-wrapper.as-console-wrapper{max-height:100vh}

Your assumptions on character constants make the submission invalid, but the example output is proving your submission is right. Please clarify your points.

@KrzysztofSzewczyk, character constant is . followed by any single char. .: is character constant (and it works fine). I require it not to be followed by letter or colon, so .:a and .:: should not be in the program. I don't see points why that makes submission invalid.

You should use conjunction instead of alternative.

@KrzysztofSzewczyk, don't understand you.

You should have used AND instead of OR for the sentence to be true.


text:
Russian Caesar cipher
The objective
Given a Russian text, encrypt it with Caesar cipher with key 16.
The basic Cyrillic alphabets
The basic Cyrillic alphabets are: (U+0410 – U+042F)
АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ

By the Caesar cipher, they are mapped to:
РСТУФХЦЧШЩЪЫЬЭЮЯАБВГДЕЖЗИЙКЛМНОП

The small letters (U+0430 – U+044F) are also mapped likewise.
Note the absence of Ё.
Rules

Ё (U+0401) and ё (U+0451) are not considered basic, and are mapped to Х̈ (U+0425 U+0308) and х̈ (U+0445 U+0308), respectively.
Any other characters are preserved.

Example
The following sentence:
В чащах юга жил бы цитрус? Да, но фальшивый экземпляр!

Is encrypted to:
Т зрйре оур цшы сл жшвагб? Фр, эю дрымиштлщ нъчхьяыпа!

We only have to map Ё and ё to Х̈ and х̈, right? And not also the reverse from X/x to E/e?

@Kevin Cruijseen Since Х̈ doesn't exist in Russian, it falls in don't care situation.

Are all non-Cyrillic characters in the input guaranteed to be standard ASCII? (32-126)

@Arnauld You can assume so.

Your answer to @KevinCruijssen should probably be included as a short comment in the challenge to make this perfectly clear. (My initial version was converting x/X + diaeresis to E/e + diaeresis.)

That's far too soon to be accepting a solution.

test case for Ё/ё: 'Ёжик живёт под ёлочкой' -> 'Х̈цшъ цштх̈в яюф х̈ыюзъющ'

05AB1E, 16 40 39 33 bytes
63ÝD16^‚Ž4K+ç`‡•2.w2γ•3äçDl‚vy`«:

Would be just the first 15 bytes without the edge case of mapping Ёё to Х̈х̈.
-7 bytes thanks to @Grimy.
Try it online.
Explanation:
63Ý              # Push a list in the range [0,63]
   D             # Duplicate it
    16^          # Bitwise-XOR each value with 16: [16..31, 0..15, 48..63, 33..47]
        ‚        # Pair it with the initial [0,63] list we duplicated
         Ž4K     # Push compressed integer 1040
            +    # Add it to each integer in the inner lists
             `   # Push both lists separated to the stack again
              ‡  # Transliterate the characters in the first list to the second list
                 # in the (implicit) input-string
•2.w2γ•          # Push compressed integer 10251061776
       3ä        # Spit it into three parts: [1025,1061,776]
         ç       # Convert each to a character: ["Ё","Х","̈"]
Dl               # Create a lowercase copy: ["ё","х","̈"]
  ‚              # Pair them together: [["Ё","Х","̈"],["ё","х","̈"]]
   v             # Loop over both these lists `y`:
    y`           #  Push the characters of the current list separated to the stack
      «          #  Append the top two together: Х̈/х̈
       :         #  And replace the Ё/ё with Х̈/х̈ in the (modified) input-string
                 # (after which the result is output implicitly)

See this 05AB1E tip of mine (section How to compress large integers?) to understand why Ž4K is 1040 and •2.w2γ• is 10251061776.

Undealt with Ё.

@DannyuNDos Fixed (at the cost of 24 bytes.. >.>)

The first part can be 63ÝD16^‚Ž4K+ç`‡ for -1. It's a shame .š doesn't work on cyrillic letters (even though u and l do), that would save a lot.

@Grimy Hmm, sounds like something to report as a bug. And thanks for the -1. Nice approach with the XOR 16

And the second part can be •2.w2γ•3äçDl‚vy`«: for -6.

@Grimy Thanks again. :) After I added the 0776 to my compressed integer I thought about using something with 766 at the end with 4ô or 3ä as well, but couldn't really get it to work..

JavaScript (ES6),  148 ... 110  108 bytes
Saved 12 bytes thanks to @Grimy!
This function applies some maths to the code points.
s=>s.replace(/./g,s=>String.fromCharCode(...(n=s.charCodeAt()-304)%80-1?[(n^16*(n>0))+304]:[1060+n%48,776]))

Try it online!
How?
For each character in the input string, we define \$n\$ as its code point minus \$304\$.
 characters    | code points  | n
---------------+--------------+---------------
 А to Я        | 1040 to 1071 | 736 to 767
 а to я        | 1072 to 1103 | 768 to 799
 Ё             | 1025         | 721
 ё             | 1105         | 801
 ASCII         | 0 to 126     | -304 to -178

Then we apply the following logic:
// neither 'Ё' nor 'ё'?
n % 80 - 1 ?
  // output a single code point
  [
    // invert the case if this is a Cyrillic character
    (n ^ 16 * (n > 0))
    // and restore the original offset
    + 304
  ]
:
  // output two code points
  [
    // the first one is either 1061 (Х) or 1093 (х)
    1060 + n % 48,
    // the 2nd one is the combining diaeresis
    776
  ]

110 with some bitwise magic

Easy fix, still 110

@Grimy Would you like to post it as a separate answer?

No, I'm fine, thanks.

Retina 0.8.2, 41 bytes
T`А-Па-пя-рЯ-Р`Ro
Ё
Х̈
ё
х̈

Try it online! Just a transliteration and a fixup of the two special cases. The characters to be transliterated are listed in mirror order so that Ro can be used to specify the reverse order for the transliteration.

seems works without ё case 22 bytes

@NahuelFouilleul That's not a U+0451 that you've got there...

ok it was composed character, my bad, this is why it was working

seems number of bytes not up to date isn't 27

@NahuelFouilleul Unfortunately TIO always assumes I'm using ISO-8859-1 (most Retina programs do) but here I'm using UTF-8 so I have to count it in UTF-8 bytes.

Perl 5 (-pC -Mutf8 -MUnicode::Normalize=NFD), 37 bytes (27 chars)
$_=NFD$_;y;А-я;Р-ЯА-Пр-яа-п

Try it online!

Does it work in Perl 6?

I don't know perl 6, 40 bytes ->52 bytes because there was an issue with ё instead of ё in input

Red, 236 166 bytes
func[s][rejoin collect[foreach c s[keep
case[c =#"Ё"["Х̈ "]c =#"ё"["х̈"]c < #"А"[c]any[c > #"Џ"c < #"ѐ"][(pick[#"А"#"а"]c < #"а")+ to 1 c - 1024 % 32]]]]]

Try it online!

PHP (7.4), 199 chars, 333 bytes
<?=strtr($argn,array_combine(($s=str_split)(АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюяёЁ,2),[...$s(РСТУФХЦЧШЩЪЫЬЭЮЯАБВГДЕЖЗИЙКЛМНОПрстуфхцчшщъыьэюяабвгдежзийклмноп,2),х̈,Х̈ ]));

Try it online!
Just a string replacement.

PowerShell, 103 102 101 bytes
-join$(switch -c($args){Ё{'Х̈'}ё{'х̈'}default{[char](2*(($_-band16)-8)*($_-in1040..1103)+$_)}})

Try it online!
This script takes a splatted string. Unrolled:
-join$(
    switch -CaseSensitive ($args){
        Ё{'Х̈'}
        ё{'х̈'}
        default {
            $offset  = 2*(($_ -band 16)-8) # -band is 'Bitwise AND'
            $offset *= ($_ -in 1040..1103) # is basic Cyrillic alphabet?
            [char]($offset+$_)

        }
    }
)

Charcoal, 53 bytes
ＦＳ¿⁼Ё↥ι⁺§хХ⁼Ёϊ¿№…А¦ѐι℅⁺℅ι⎇‹↥ιР¹⁶±¹⁶ι

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

Loop over the characters in the input.
¿⁼Ё↥ι

If the uppercase is equal to Ё...
⁺§хХ⁼Ёϊ

... then print the appropriate х or Х with its combining character...
¿№…А¦ѐι

... otherwise if it's a Cyrillic letter...
℅⁺℅ι⎇‹↥ιР¹⁶±¹⁶

... do some maths on its ordinal to create the character to output...
ι

... otherwise output the input character.