Python 2 3, 141-15=126
def win(x,y):w([y]*x)
w=lambda b,f=print:not[f(r+1,c+1)for r,p in enumerate(b)for c in range(p)if(r+c)*w(b[:r]+[min(i,c)for i in b[r:]],max)]

Brute-force minimax search. For every possible move, we recursively see if the opponent can win after we make that move. Pretty weakly golfed; someone else should be able to do much better. This feels like a job for APL.

win is the public interface. It takes the dimensions of the board, converts it to a board representation, and passes that to w.
w is the minimax algorithm. It takes a board state, tries all moves, builds a list whose elements correspond to winning moves, and returns True if the list is empty. With the default f=print, building the list has a side effect of printing the winning moves. The function name used to make more sense when it returned a list of winning moves, but then I moved the not in front of the list to save a space.
for r,p in enumerate(b)for c in xrange(p) if(r+c): Iterate over all possible moves. 1 1 is treated as not a legal move, simplifying the base case a bit.
b[:r]+[min(i,c)for i in b[r:]]: Construct the state of the board after the move represented by coordinates r and c.
w(b[:r]+[min(i,c)for i in b[r:]],max): Recurse to see whether the new state is a losing state. max is the shortest function I could find that would take two integer arguments and not complain.
f(r+1,c+1): If f is print, prints the move. Whatever f is, it produces a value to pad the list length.
not [...]: not returns True for empty lists and False for nonempty.

Original Python 2 code, completely ungolfed, including memoization to handle much larger inputs:
def win(x, y):
    for row, column in _win(Board([y]*x)):
        print row+1, column+1

class MemoDict(dict):
    def __init__(self, func):
        self.memofunc = func
    def __missing__(self, key):
        self[key] = retval = self.memofunc(key)
        return retval

def memoize(func):
    return MemoDict(func).__getitem__

def _normalize(state):
    state = tuple(state)
    if 0 in state:
        state = state[:state.index(0)]
    return state

class Board(object):
    def __init__(self, state):
        self.state = _normalize(state)
    def __eq__(self, other):
        if not isinstance(other, Board):
            return NotImplemented
        return self.state == other.state
    def __hash__(self):
        return hash(self.state)
    def after(self, move):
        row, column = move
        newstate = list(self.state)
        for i in xrange(row, len(newstate)):
            newstate[i] = min(newstate[i], column)
        return Board(newstate)
    def moves(self):
        for row, pieces in enumerate(self.state):
            for column in xrange(pieces):
                if (row, column) != (0, 0):
                    yield row, column
    def lost(self):
        return self.state == (1,)

@memoize
def _win(board):
    return [move for move in board.moves() if not _win(board.after(move))]

Demo:
>>> for i in xrange(7, 11):
...     for j in xrange(7, 11):
...         print 'Dimensions: {} by {}'.format(i, j)
...         win(i, j)
...
Dimensions: 7 by 7
2 2
Dimensions: 7 by 8
3 3
Dimensions: 7 by 9
3 4
Dimensions: 7 by 10
2 3
Dimensions: 8 by 7
3 3
Dimensions: 8 by 8
2 2
Dimensions: 8 by 9
6 7
Dimensions: 8 by 10
4 9
5 6
Dimensions: 9 by 7
4 3
Dimensions: 9 by 8
7 6
Dimensions: 9 by 9
2 2
Dimensions: 9 by 10
7 8
9 5
Dimensions: 10 by 7
3 2
Dimensions: 10 by 8
6 5
9 4
Dimensions: 10 by 9
5 9
8 7
Dimensions: 10 by 10
2 2


Brainfuck -> Ruby
e,
v[
a.
l>
"+
a[
=-<,----------
[>
i+
=<
0[-]
]>
*]
3,
e]
4[
;g
"4
+d
$)
<^
.%
b$
y@
ta
el
sD
.{
m[
a}
p]
{.
|d
bA
|:)
{y
?T
.K
,s
"+
pG
up
th
c}
 P
a$
[v
iF
]o
"d
,8
?t
,=
,h
"3
ay
[&
i*
]H
=s
gj
e9
t,
c<
"D
,d
?`
[q
,z
")
wT
hx
ie
lz
eW
 >
a$
[^
i!
];
>Y
0q
"#
,T
?X
]A
,b
"J
e$
n#
ds
"K
,$
?}
<?
,.
"e
iJ
-W
=k
1B
"&
,J
?g
>.
,>
"/
i@
+/
=s
1v
"E
,)
?.
+8
,v
"7
aS
[b
i$
]#
+5
=m
1w
"3
,*
?u
-f
,Z
"I
aW
[U
i%
]3
-v
=T
1E
":
}G
[;
b2
]@
};
*/
"+
;M
"B]

Horizontal is this little gem:
,[.>+[-<,----------[>+<[-]]>],]

And Vertical is this:
eval"a=[i=0]*3e4;"+$<.bytes.map{|b|{?.,"putc a[i]",?,,"a[i]=getc",?[,"while a[i]>0",?],"end",?<,"i-=1",?>,"i+=1",?+,"a[i]+=1",?-,"a[i]-=1"}[b]}*";"

Which is a brainfuck interpreter stolen from this question. It qualifies for all of the hard mode criteria except the no comments bit, which I don't think is really fair to apply to brainfuck, or pretty much nothing but BF->BF would be possible.
Horizontal program runs till EOF(0) is read. Assumes newline at end of file.


JavaScript ES6, 187 180 168 bytes

f=l=>{r=m=>Math.random()*m|0
d=l%2&&r(--l/2)*2+1
for(s='';l--;s+=s?a:a.toUpperCase())a=l%2?'bcdfghjklmnpqrstvwxyz'[r(21)]:'aeiou'[r(5)]+(l==d-1?'hy'[r(2)]:'')
return s}

Edit: I switched from using regex replace to a simple for loop, which improved the length considerably. Ungolfed code and test UI below. Input a negative number at your own risk because it makes an infinite loop. (Thanks to unclemeat for pointing that out.)

f=function(l){
  // Function to return a random integer between 0 and m-1 inclusive
  r=function(m){
    return Math.random()*m|0
  }
  // d is the position the h or y will be added
  // l is decremented only if l is odd so an extra consonant won't be added to the end
  d=l%2&&r(--l/2)*2+1

  for(s='';l--;){
    a=l%2?'bcdfghjklmnpqrstvwxyz'[r(21)]:'aeiou'[r(5)]+(l==d-1?'hy'[r(2)]:'')
    // If `s` is empty (i.e. this is the first leter), make it uppercase
    s+=s?a:a.toUpperCase()
  }
  return s
}

run=function(){ip=parseInt(document.getElementById('input').value);if(ip<2)return alert('Input must be greater than one.');document.getElementById('output').innerHTML=f(ip)};document.getElementById('run').onclick=run;run()
<input type="number" id="input" value="7" min="2" /><button id="run">Run</button>


Shortest code that return SIGSEGV among the given languages

bending the rules a bit ; the C linker doesn't care if 'main' is a function or not :

int main=0;

indeed, the default type is 'int' and the default global initialiser is 0 :

main;


Charcoal, 9 bytes

Ｐ¬↙×⁶#‖Ｏ¬

Try it online!


GolfScript 28 26 characters
Since the problem is here we might as well golf it. Anyone who plan on participating on spoj.pl better close their eyes while they read this.
~](;{11.@5+{.@+}*;.10%+n}%

It basically says: For all input, start with the numbers 11 and 11, do input+5 Fibonacci iterations, discard the highest of the two results, add itself mod 10 to the lowest result, done. As a formula this can be describes as 11*Fib(input+6) + (11*Fib(input+6)) mod 10.
Why does this work? It is simply a condensed way of calculating two second identities in the same run, one could start at [0 1] and [55 89], do a run on both of the same length and subtract the first result from the second to get the sum of a series of 10 Fibonacci numbers, but one may as well do the subtraction on the initial sets, thus getting the set [55 88], that can be stepped back a few steps to [11 11] which is short to write.
The Fibonacci series mod 10 has a period of 60, so Fib(i+246) mod 10 = Fib(i+6) mod 10.


Python 2, 385 345 332 bytes

A,I,R=max,min,range
a=b=0
p=[[a,b]]
for i in input():a+=i%2*(2-i);b+=(1-i%2)*(1-i);p+=[a,b],
k,l=zip(*p)
x=A(k)-I(k)+3
y=A(l)-I(l)+3
o=[[1]*y for _ in' '*x]
def g(m,n):
 if 0<o[m][n]and[m+I(k)-1,n+I(l)-1]not in p:o[m][n]=0;[g(i,j)for i in R(A(0,m-1),I(x,m+2))for j in R(A(0,n-1),I(y,n+2))if(i,j)!=(m,n)]
g(0,0)
print sum(map(sum,o))

Try it online! or Try all test cases

Input is numerical, 0~3, the 0-index of the symbols here: >v<^

#starting position
a,b=0
#new list to hold the wall coordinates
p=[[a,b]]

#iterate over the input calculating
#the next coordinate and storing on p
for i in input():
 a=a+i%2*(2-i)
 b=b+(1-i%2)*(1-i)
 p+=[[a,b]]
#i%2*(2-i) and (1-i%2)*(1-i) generate the increment
#of each symbol from last position
# >/0 : (0,1)
# v/1 : (1,0)
# </2 : (0,-1)
# ^/3 : (-1,0)

#transpose the coordinate list
k,l=zip(*p)
#calculate the difference between the max and min values
#to generate the total land size
#adding a border to avoid dead-ends
x=max(k)-min(k)+3
y=max(l)-min(l)+3

#create a matrix of 1's with the total land size
o=[([1]*y) for _ in ' '*x]

#recursive function that sets a cell to 0
#and call itself again on all surrounding cells
def g(m,n):
 #correct the indexes (like negative ones)
 a,b=m+min(k)-1,n+min(l)-1
 #if this cell contains 1 and don't belong to the wall
 if o[m][n]>0 and (a,b) not in p:
  #sets to 0
  o[m][n]=0
  #call again on surrounding cells
  for i in range(max(0,m-1),min(x,m+2)):
   for j in range(max(0,n-1), min(y,n+2)):
    if (i,j)!=(m,n):g(i,j)

#call the recursive function o origin
g(0,0)
#print the sum of the cells
print sum(map(sum,o))

This is the resulting matrix:

[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]
[0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0]
[0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0]
[0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0]
[0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0]
[0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0]
[0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0]
[0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0]
[0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0]
[0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0]
[0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]


05AB1E, 99.999999999999999957%

1111111111111111111 ... (9352835025086960662 1's total) ... 11111g₅B.V

g gets the length of the large integer literal. Obviously this is too long for TIO, so try a version using 9352835025086960662 instead of the equivalent 1111...1111g.


Convert number to comma separated number

Java, 50 chars

String C(double d){return String.format("%,f",d);}

Works as specified in most locales.  Does the correct thing in all locales :)

Edit:

If you really want commas no matter the default locale, do:

String C(double d){return String.format(java.util.Locale.US,"%,f",d);}

which is 70 characters (60 if you've already imported java.util.*).


Write a Program that Writes a function BUT in a different language!

GS2 → K, 2 bytes

•+

This prints a tacit, monadic function. The source code uses the CP437 encoding. Try it online!

Test run

$ xxd -c 2 -g 1 sum-func.gs2
00000000: 07 2b  .+
$ printf 42 | gs2 sum-func.gs2
42+
$ kona
K Console - Enter \ for help

  (42+) 69
111
  f : 42+
42+
  f 69
111

How it works

GS2

GS2 automatically reads from STDIN and pushes the input on the stack.
• indicates that the next byte is a singleton string literal.
Before exiting, GS2 prints all stack items.

K

Left argument currying is automatic in K.

Here, n+ turns the dyadic function + into a monadic function by setting its left argument to n.


Python 3, 475 410 bytes

Thanks to Mr.Xcoder for saving some bytes!

Use the symmetry of the formula to save 65 bytes. Yes, that's a lot.

from itertools import*
n=int(input())
P=permutations
R=[*range(n)]
u=[]
A=all
S=sorted
for T in P(P(R),n):u+=[T]*(A(A(R==S(x)for x in
t)and any([*x]==S(x)for x in t)and
A(t[z][t[x][t[z][y]]]==t[t[t[z][x]][z]][y]and
t[t[z][x]][t[y][z]]==t[t[z][t[x][y]]][z]for x in R
for y in R for z in R)for t
in(T,[*zip(*T)]))and A(A(1-A(p[T[i][j]]==U[p[i]][p[j]]for i in R
for j in R)for p in P(R))for U in u))
print(len(u))

Try it online!

Some and can be replaced by *, results in lower bytecount but at the cost of significantly slower execution time:

Python 3, ??? bytes

[TODO put code here]

(of course not all * makes the program significantly slower, only some of them are critical)

Ungolfed:

from itertools import *
n = 4 # int(input())
rangeN = list(range(n))

def is_moufang_loop(T):
    A = tuple(zip(*T))
    return all(
        all(sorted(x) == rangeN for x in t)
        and any(list(x) == sorted(x) for x in t)
        and all(
                T[z][T[x][T[z][y]]] == T[T[T[z][x]][z]][y]
            and T[T[z][x]][T[y][z]] == T[T[z][T[x][y]]][z]
            for x in rangeN for y in rangeN for z in rangeN)
        for t in (T, A)
    )

def isomorphic(loop1, loop2):
    for p in permutations(rangeN):
        if all(
            p[loop1[i][j]] == loop2[p[i]][p[j]]
            for i in rangeN
            for j in rangeN
        ): return True
    return False

unique_moufang_loops = []
for x in [
        cayley_table
        for cayley_table in permutations(permutations(rangeN), n)
        if is_moufang_loop(cayley_table)
]:
    if all(not isomorphic(x, y) for y in unique_moufang_loops):
        unique_moufang_loops.append(x)

print(len(unique_moufang_loops))

Try it online!

No scroll bars...

Explanation:

The program is pretty simple.

Each possible "binary operator" is represented by a Cayley table (0-indexing).
The "identity" property implies that there exists e such that both the e'th row and the e'th column are equal to [0, 1, 2, ..., n-1], which is the same condition as

  both the array T and its transpose has a row equal to [0, 1, 2, ..., n-1].

The "cancellation" property is equivalent to

  Every row and every column are a permutation of [0, 1, 2, ..., n-1].

So, the part

all(
        all(sorted(x) == rangeN for x in t)
        and any(list(x) == sorted(x) for x in t)
        for t in (T, A))

of the code checks that. (for all row in the array T and its transpose A, it being sorted is equal to rangeN, and there exists a row in both T and A that equals to itself being sorted)

The four conditions of a Moufang loops are checked manually.

z + (x + (z + y)) = ((z + x) + z) + y
((y + z) + x) + z = y + (z + (x + z))
(z + x) + (y + z) = (z + (x + y)) + z
(z + x) + (y + z) = z + ((x + y) + z)

In the code, (a + b) is represented as T[a][b]. (because of the representation as Cayley table). Use Python chaining equality comparison to avoid duplication of (z + x) + (y + z).

However, because the formula is symmetric:

If we switch the operands of + in the first formula, we get the second formula; and if we switch the operands of + in the third formula, we get the fourth formula with x and y swapped place.

Note that the transposition of the Cayley table is equivalent to the binary operators having operands swapped. (x + y -> y + x)

Finally, all the candidates Cayley table are picked from

permutations(permutations(rangeN), n)

so that each row is a permutation of rangeN (which is [0, 1, 2, ..., n-1]) and there are n distinct rows.


CJam, 35 bytes
qN/_s,S*f+{iD%[S3*" \/"_$]=}f%W%zN*

Try it online here


Fizz Buzz.. Crackle Pop! (Generalized Fizz Buzz)


CJam, 14 13 12 bytes

r$r$.-:)3,-!

Try it online! or verify all test cases at once.

Algorithm

Let s and t be two sorted words of the same length. For s and t to be lexicographically adjacent (LA), it is necessary and sufficient that all pairs of its corresponding characters are also LA.

The condition is clearly sufficient for all words, and necessary for words of length 1.

Now, assume s and t have length n > 1, and let a and b be the first characters, resp., of s and t.

Since s and t are LA, there is some bijective mapping φ between the characters of s and the characters of t such that x and φ(x) are LA for all x in s, meaning that |x - φ(x)| ≤ 1 for all x in s.

Let c = φ(a) and d = φ-1(b). Because of a's and b's minimality, a ≤ d (1) and b ≤ c (2).

Furthermore, since b and d, and a and c, and LA, d ≤ b + 1 (3) and c ≤ a + 1 (4).

By combining (1) and (3), and (2) and (4), we get that a ≤ d ≤ b + 1 and b ≤ c ≤ a + 1, from which we deduce that a - 1 ≤ b ≤ a + 1 and, therefore, that a and b are LA.

Now, by combining (1) and (4), and (2) and (3), we get that c - 1 ≤ a ≤ d and d - 1 ≤ b ≤ c, from which we deduce that c - 1 ≤ d ≤ c + 1 and, therefore that c and d are LA.

Thus, if we redefine φ by φ(a) = b and φ(d) = c, |x - φ(x)| ≤ 1 will still hold for all x in s and, in particular, for all x in s[1:].

This way, s[0] = a and t[0] = b, and s[1:] and t[1:], are LA.

Since s[1:] has length n - 1, this proves the necessity by induction.

Code

r               e# Read the first word from STDIN.
 $              e# Sort its characters.
  r             e# Read the second word from STDIN.
   $            e# Sort its characters.
    .-          e# Perform vectorized subtraction.
                e# This pushes either the difference of char codes of two
                e# corresponding characters or a character that has no does not
                e# correspond to a character in the other, shorter word.
      :)        e# Increment all results.
                e# In particular, this maps [-1 0 1] to [0 1 2].
        3,      e# Push the range [0 1 2].
          -     e# Perform set difference, i.e., remove all occurrences of 0, 1 and
                e# 2 from the array of incremented differences.
           !    e# Apply logical NOT. This gives 1 iff the array was empty iff
                e# all differences gave -1, 0 or 1.


Python 2, 58 bytes

a=0;b=1
exec"print a;a,b=b,int(str(a+b)[::-1]);"*-~input()

Uses str to convert rather than backticks because large enough numbers in Python 2 are written with an L at the end. I tried a recursive function, but it turned out longer (61):

f=lambda n,a=0,b=1:-~n*[0]and[a]+f(n-1,b,int(str(a+b)[::-1]))


Pyth, 7 bytes

e=+ZhO9

Try it online: Demonstration

Explanation

          implicit: Z = 0
     O9   Generate a random int from [0, 1, ..., 8]
    h     add 1
 =+Z      add this to Z and update Z
e         print Z modulo 10


xkcd challenge: "Percentage of the screen that is [x] color"

JavaScript with HTML

I tried to reproduce the original comic more precisely. A screenshot is taken using the html2canvas library. The numbers are calculated repeatedly, so you can resize the window or even add something to page in real time.

Try it online: http://copy.sh/xkcd-688.html

Here's a screenshot:

Fraction of
this website
which is white _/
<canvas width=150 id=g></canvas>
&nbsp; Fraction of
- this website
&nbsp; which is black

0
<canvas style="border-width: 0 0 1px 1px; border-style: solid" id=z></canvas>

Location of coloured pixels in this website


Stripping off extra spaces from a string

CJam, 7 bytes
q~S%S*p

Code Explanation
CJam has reserved all capital letters as inbuilt variables. So S has a value of a space here.
q~          e# Read the input (using q) and evaluate (~) to get the string
  S%        e# Split on running lengths (%) of space
    S*      e# Join (*) the splitted parts by single space
      p     e# Print the stringified form (p) of the string.

This removes the trailing and leading spaces as well
Try it online here


oOo CODE, score 0

Thanks to Dennis for golfing the Brainfuck code.

TwASbRIlLIgAnDthEsliTHyTOvEsdiDgyreaNdgImbleinthEwaBeaLlmimSywEreThEBoroGoveSAndTheMOmERaTHSoutGRabEbeWArEthEjaBbeRWockMYsONtHEJawsTHaTBiTEThecLawSthATcaTChBeWAReTHeJuBJuBBiRDAndsHUNtHeFRuMIoUSbANdERSnatchheTooKHisvORpaLswORdinhAndLonGtiMetHEmanXomEFoEHeSOUg

Try it online!

I've got bad news for this challenge... :(

oOo CODE is just a binary encoding of brainfuck which uses the case of a letter for each bit. So yeah, since the poem is long enough (or the output short enough) to cover a Brainfuck program that prints The Jabberwocky (without actually trying hard to golf it), this becomes a trivial optimal answer.


Haskell, 137 128 127 125 121 109 106 bytes

(-2)+(-4)=(-6) bytes thanks to nimi! Changing it to collect all the steps in a list (again due to nimi) saves 12 more bytes.

Another 3 bytes due to Laikoni, with pattern guard binding and a clever use of list comprehension to encode the guard.

import Data.List
g x|y<-x>>=h=x:[z|x/=y,z<-g y++[sort<$>x]]
h[a]=[[a]]
h x=foldr(\x[b,a]->[x:a,b])[[],[]]x

Try it online!

Splitting the lists into the odd and the even positioned elements is a shorter code than into the two sequential halves, because we're spared having to measure the length, then.

Works by "printing" the lists, then recursing with the split lists (x >>= h) if there actually was any splitting done, and "printing" the sorted lists; starting with the one input list; assuming the non-empty input. And instead of actual printing, just collecting them in a list.

The list produced by g[[6,5..1]], printed line-by-line, is:

[[6,5,4,3,2,1]]
[[6,4,2],[5,3,1]]
[[6,2],[4],[5,1],[3]]
[[6],[2],[4],[5],[1],[3]]
[[2,6],[4],[1,5],[3]]
[[2,4,6],[1,3,5]]
[[1,2,3,4,5,6]]


Is there any web esoteric language(like javascript)?


Python 3, 23 bytes

s=input()
s[0]!=s[-1]<e

Output is via exit code, so 0 (success) is truthy and 1 (failure) is falsy. If this is acceptable, a byte can be saved.

Try it online!

How it works

First of all, if s is an empty string, s[0] will raise an IndexError, causing the program to fail.

For non-empty s, if the first and last characters are equal, s[0]!=s[-1] will evaluate to False, so the program exits cleanly and immediately.

Finally, if the characters are different, s[0]!=s[-1] will evaluate to True, causing the compairson s[-1]<e to be performed. Since e is undefined, that raises a NameError.

If backwards compatibility with Python 2 is not desired,

s[0]!=s[-1]<3

works as well, since comparing a string with an integer raises a TypeError.


Perl 6, 46 bytes

{!/[(.).*]**4<?{[+^] $0 Xeq[...] ~<<$0[^2]}>/}

Try it online!
A regex solution that finds if there are four characters in the string such that the two later characters are in different sections of the circle, as defined by the first two characters.
Explanation
{                                           }   # Anonymous code block returning
 !/                                        /    # If the input does not match
   [(.).*]**4                                     # Any 4 characters
             <?{                          }       # Where
                           [...]                    # The range from
                                 ~<<$0[^2]          # The first character to the second
                        Xeq                         # Contains which of
                     $0                             # The four characters
                [+^]                                # Reduce the list of booleans by xor
                 # Effectively, if only one of the 3rd or 4th character is in that range


Wolfram Language (Mathematica), 42 bytes
Of course there is a built-in for this...
And as @Charlie mentioned we can golf "Portuguese" to "Spanish" and save 3 bytes
#~IntegerName~"Spanish"~StringTake~1=="d"&

Try all test cases
-13 bytes from @att


JavaScript (ES6), 88 87 bytes

s=>(a=[...s]).sort()[5]-a[3]&[7,56,73,84,146,273,292,448].every(j=>j&i,i=`0b`+s^~-a[4])

Takes input as a string of 9 0 and 1 characters and returns 1 for valid, 0 for invalid. We sort the characters into order. If the middle three characters are now the same then the board is invalid as there are too many of one piece. Otherwise, we convert the original board into binary, flipping the bits if there are more 0s than 1s. At this point the board is valid if 0 does not have a line of three, so we simply test all eight lines via an array of bitmasks. Edit: Saved 1 byte thanks to @ETHproductions.


Python 3, 97 bytes
The string has a leading and trailing unprintable with value 5.

for c in"wç¿ğŗŗĵý6çw":c=ord(c);s=c%8*'*'+c//8%7*' '+c//56*'*';print(f'{s+s[::-1]:^26}')

Try it online!


CJam/GolfScript, 2 languages, 50 bytes

{`"0$~e#"+0$-1%"":n}0$~e##e~$0}n:""%1-$0+"#e~$0"`{

Try it CJam!
Try it in GolfScript!

Huh, this went unanswered surprisingly long.

Explanation

It's probably easiest to explain this by showing how I turned the basic quine in each language into a palindromic polyglot quine.

So the basic quines in both languages are:

{".~"}.~

{"_~"}_~

In GolfScript and CJam, respectively. These are quite similar thanks to the fact that CJam was originally inspired by GolfScript (but has since deviated quite a lot). The first difference we notice is that one uses . for duplicating the top of the stack and the other uses _. A common trick to avoid this problem is to use 0$, since both languages have the "copy-nth-item-on-stack" operator $. So we get {"0$~"}0$~, although that still needs a trailing linefeed in GolfScript. But let's worry about that at the end.

First, we need to make it a palindrome. The obvious solution to this is to append a comment and put the source code there in reverse. This is quite simple, because CJam uses e# for comments, and in GolfScript e does nothing at all, and # is a comment. So if we append e#... that works for both languages. Here is what we've got:

{"0$~"}0$~e##e~$0}"~$0"{

Of course, that doesn't actually print the part from e# onward. We can reconstruct this quite easily from the source code itself. Both languages can turn the initial block into a string with ` and append the "0$~" part with +, so that we get the entire unmirrored source code in a single string. To append a mirrored copy, all we need to do is duplicate the string with 0$ again and then reverse it with -1%, which also works in both languages. So now we've got this:

{`"0$~e#"+0$-1%}0$~e##e~$0}%1-$0+"#e~$0"`{

This is a valid palindromic quine in CJam, and it also works in GolfScript but still prints that pesky trailing linefeed.

The usual way to prevent this is to assign an empty string to n, because what GolfScript really does is print the contents of n at the end. So what we need is "":n. So what about CJam? Thankfully, this does nothing at all. "" is also an empty string (or empty list, they're the same thing in CJam), and : maps the operator n (print with linefeed) over the list. But since the list is empty, mapping an operator over it does nothing at all. Hence, we can get rid of the linefeed, without messing with CJam, and end up with the final solution:

{`"0$~e#"+0$-1%"":n}0$~e##e~$0}n:""%1-$0+"#e~$0"`{


Brachylog, 44 bytes

-:[1]r:[1]cit.
t<gX=:?rc.'(l:2eLg:.rz:%adlL)

Try it online!

100 takes about a minute here, so be patient if you want to try 100.

Predicate 0 (main predicate)

-:[1]r:[1]cit.
-:[1]r:[1]c     create array [[1], input-1, 1]
           i    iterate: [1] as input, iterate (input-1) times, predicate 1
            t.  last element is the output

Predicate 1 (auxiliary predicate)

t<gX=:?rc.'(l:2eLg:.rz:%adlL)
t<                              last element of input < Temp
  gX                            [Temp] = X
   X=                           Assign a value to X, which assigns
                                a value to Temp
   X :?rc.                      [Input,X] concatenated is output
         .'(                )   The following about the output cannot
                                be proven:
            l:2eL                   L is a number between 2 and length
                                    of output, inclusive
                Lg:.rz:%a           every element of output, taken modulo L,
                         dlL        after removing duplicates, has length L


Don't use the Pipe operator or parenthesis for calling methods

# With Pipe
arg |> M.a |> M.b |> M.c   # 24 Bytes
arg|>M.a|>M.b|>M.c         # 18 Bytes

# With Parenthesis
M.c(M.b(M.a(arg)))         # 18 Bytes

# Only Spaces
M.c M.b M.a arg            # 15 Bytes


Fizz Buzz with unique characters in columns

Python 2, 127 bytes

i=0;exec"print ord('<<<<>@<<BD=F?@HABJCNP=@RT?VABXCBZ<^`=>bdDf>?hBCjEn'[i])%60*' '+(i%3/2*'Fizz'+i%5/4*'Buzz'or`-~i`);i+=1;"*50

Try it online!

A fifty-byte lookup table seems to hurt the code size less than the logic necessary to track which characters have occurred in each column.


Jelly, 7 bytes

%⁼⁴
0ç#

This is a full program. Arguments are divisors, target moduli, and number of solutions, in that order.

Try it online!

How it works

0ç#  Main link.
     Left argument: D (array of divisors)
     Right argument: M (array of target moduli)
     Third argument: n (number of solutions)

0ç#  Execute the helper link with k = 0, 1, 2, ... as left argument and D as the
     right one until n of them return 1. Yield the array of matches.

%⁼⁴  Helper link. Left argument: k. Right argument: D

%    Compute k % d for each d in D.
 ⁼⁴  Compare the result with M.


Lua, 174 176 156 bytes

The code would print height-amount of lines, not height-amount of hexagons. Added *4, that fixed it, but added 2 extra bytes.
Saved some bytes by changing the counter from if to modulo, and by putting two io.read()s into one.

Uses io.read() as input.

a,w,h,n,d={[[ /\__/\ \__/]],[[/_/  \_\/__\\]],[[\ \__/ /\__/]],[[_\/__\/_/  \\]]},io.read(,),"",0 for i=h*4,0,-1 do d=d+1 d=5%d end n=a[d]print(n:rep(w))end

Replicates the strings width-amount of times via string:rep(width), then iterates height-amount of times with a for-loop. Needed [[]] (literal strings) because the backslashes really screwed stuff up.

Old Version:

a,w,h,n,d={[[ /\__/\ \__/]],[[/_/  \_\/__\\]],[[\ \__/ /\__/]],[[_\/__\/_/  \\]]},io.read(),io.read(),"",0 for i=h*4,0,-1 do d=d+1 d=5%d end n=a[d]print(n:rep(w))end


Java, 201 196 189 186 182 bytes

Obviously not the best, but it is in Java.

class I{public static void main(String[]a){System.out.print(("__\na a"+new String(new byte[new Byte(a[0])-1]).replace("\0","__a\\  __\\\n a")+"  a   \\/").replace("a","\\ \\\n"));}}


Perl 5, 50,091 151 snippets

First snippet:

use utf8; print length A

2nd through 26th snippets: B through Z

27th through 46nd snippets: a through z, excluding the characters in "length"

47th through 56th snippets: 0 through 9

57th snippet: _

The remaining snippets are the 50,105 individual Unicode characters which Perl regards as "word" characters, excluding the 14 distinct word characters in the initial snippet, in any order.

Well, it was a nice thought, but it turns out that after a certain length Perl gives you an "identifier too long" error.  This is the longest combined program I was able to get Perl to digest:

use utf8; print length A012345679BCDEFGHIJKLMNOPQRSTUVWXYZ_abcdjkmoqsvwxyzĀāĂăĄąĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıĲĳĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňŉŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţ

The perldiag manual page says "Future versions of Perl are likely to eliminate these arbitrary limitations" but my Perl 5.18 has not done so.

Explanation:

In non-strict mode, Perl 5 interprets unquoted strings of word characters as "barewords," essentially quoting them for you automatically.  They're usually best avoided, but they sure help here!


convey, 47 bytes
Returns 0 for neither, 1 for one-based, 2 for zero-based and 3 for unknown.
{2+~`0
?;\2:!2[
v^<]`
?;\?+2
v^< v*+}
!>>>=?^
2

Try it online!
Run for 1 2 2 3 with index 2 and value 2:

On the left we split the input lines with ;\ ^< into the three paths.
The first one pushes two zeroes after length of path + index time steps into the +. The second one path tries to push the array into + – if there are values waiting (the two zeroes), they get passed through unaltered. Otherwise, they get deleted ?]. The two values then get pushed into =, where they are compared to the third input. The result are two boolean bits. The second one gets multiplied by 2, then they get added together.


Microsoft Excel, 43 Bytes.
=COLUMN(INDIRECT(A1))&" "&ROW(INDIRECT(A1))

I couldn't help myself, I just had to use the right tool for the job.
Takes input on A1.
Test Cases


JS, ES6 243 235 168 166 165 164 bytes

i=>fetch(`//api.stackexchange.com/users/${i}?site=codegolf`).then(x=>x.json()).then(x=>alert(~~((y=x.items[0]).reputation/((new Date/1e3-y.creation_date)/2592e3))))

Based on the Python answer.

Run this in the console:

(i=>fetch(`//api.stackexchange.com/users/${i}?site=codegolf`).then(x=>x.json()).then(x=>alert(~~((y=x.items[0]).reputation/((new Date/1e3-y.creation_date)/2592e3)))))(+prompt("Enter a userId"))

-4 thanks to @insert_name_here

Old answer:

z=>fetch("//codegolf.stackexchange.com/u/"+z).then(x=>x.text()).then(x=>alert((/([\d,]+) repu/.exec(x)[1].replace(/,/g,"")/(((y=/Member for <.+>((\d+) years?, )?(\d+) month/.exec(x))[2]||0)*12+ +y[3]||0))))

Improvements welcome! Just fetches the profile page and parses it with regular expressions!

Won't work as a stack snippet, but you can paste this in your console:

(z=>fetch("//codegolf.stackexchange.com/u/"+z).then(x=>x.text()).then(x=>alert(Math.floor(/([\d,]+) repu/.exec(x)[1].replace(/,/g,"")/(((y=/Member for <.+>((\d+) years?, )?(\d+) month/.exec(x))[2]||0)*12+ +y[3]||0)))))(+prompt("Enter a userId"))


Look-and-say sequence: roman numerals edition

Perl, 49 bytes

Includes +1 for -p

Run with the 0-based index on STDIN, e.g.

ecce.pl <<< 14

ecce.pl:

#!/usr/bin/perl -p
s,(.)\1*,$&/$1%182 .$1,eg for($_=/$/)x$`;y;19;IV

Magic formulas are so magic.

Normally I would use ($_=//)x$' to make the loop control one byte shorter, but scoring on this site gives that a handicap of 2 so it ends up 1 byte longer. On older perls you can drop the space before for. Some versions of perl force you to add a final ; to close the transliteration. But what is given above is the code that works on my system.

Explanation

Working backwards from solution to code:

The string transformations we need:

I     -> II
II    -> III
III   -> IIII
IIII  -> IVI
IIIII -> VI

V     -> IV
VV    -> IIV

Each replacement ends with the repeated character. I will get a sequence of the same characters using regex /(.)\1*/, so this can be done by appending $1. The part before the -> is in $&. With that I still need:

I     -> I
II    -> II
III   -> III
IIII  -> IV
IIIII -> V

V     -> I
VV    -> II

Write I as 1 and V as 9:

1     -> 1
11    -> 11
111   -> 111
1111  -> 19
11111 -> 9

9     -> 1
99    -> 11

By dividing the part before -> by the repeated digit this becomes:

1     -> 1
11    -> 11
111   -> 111
1111  -> 19
11111 -> 9

1     -> 1
11    -> 11

So now the original repeated V is not an exception anymore. So I want an expression that makes this happen:

1     -> 1
11    -> 11
111   -> 111
1111  -> 19
11111 -> 9

And this can be done by a simple modulo 182:

1     % 182 = 1
11    % 182 = 11
111   % 182 = 111
1111  % 182 = 19
11111 % 182 = 9

(this even gets IIIIII to VI right though it isn't needed here)

All that is left is initializing the working variable to 1 for index 0, repeat this transformation in a loop and at the end replace 1 by I and 9 by V

1, 9 and 182 is the only parameter combination for which this simple formula works.


Pyth, 55 53 52 50 bytes

FN*Fmsm?k}kG^Gvkcd\/ceKc-rz0`Hd\,#=sN)I!.-NhK1B)E0

Try it online: Demonstration or Test harness

Notice that the time and memory complexity is really bad. So the second example doesn't work. I allocates about 1.6 GB of Ram before it crashes on my machine.

Explanation

The explanation is for the 53 solution. The only difference is, that the initial parsing happens in the middle instead of the beginning.

Kc-rz0"{}"dFN*Fmsm?k}kG^Gvkcd\/ceKc-rz0`H\,#=sN)I!.-NhK1B)E0

So here's the initial parsing.

Kc-rz0`Hd
   rz0     convert input() to lowercase
  -   `H   remove all curly brackets (`H = "{}")
 c      d  split at the space
K          assign to K

So the input "{W},{R},{R} {2/W},{W/B}" gets converted into ['w,r,r', '2/w,w/b'].

m               ceK\,    map each cost d of the costs split by "," to:
 s                         the sum of
  m         cd\/           map each value k of cost split by "/" to:
    k                        k
   ? }kG                     if k in "abcdef...xyz" else
        ^Gvk                 Cartesian product with "abc...yz" of int(k) repeats

So what does this do? The cost input '2/w,w/b' gets converted into:

[['aa', 'ab', 'ac', ..., 'zx', 'zy', 'zz', 'w'], 'wb']

Every string in ['aa', 'ab', 'ac', ..., 'zx', 'zy', 'zz', 'w'] satisfies {2/W} and every char in 'wb' satisfies {w/b}.

Now we generate the Cartesian product of these lists (or strings) and see, if any combination can be produced with the mana-pool.

FN*F...              )      for N in Cartesian product of ...:
       #   )                   while 1:
        =sN                      N = sum(N)
                               this flattens N
            I!.-NhK            if not (subtract mana pool from N):
                   1             print 1 (True)
                    B            break
                      E      else:
                       0       print 0 (False)


Find the Interwoven Source Codes (Robbers)

Vitsy, 12 points

'o'2\I/NO

Try it online!

a5F\aZ

Try it online!

The NaN in NaNo was a dead giveaway.

The obvious way to push NaN would be to divide 0 by itself, 2\I pushes the input length (0) twice, / performs division, and N prints a float.

We're left with printing o, and 'o' is a string literal that O prints.

Whatever characters were left had to belong to the other program. In fact, a pushes a linefeed, 5F the factorial of 5 (120), \a turns that into 120 linefeeds, and Z prints the entire stack.


JavaScript (ES6), 103 102 bytes
Needs to be run from the root level of api.stackexchange.com. Returns a Promise object containing the result.
n=>fetch(`questions/${n}?site=codegolf`).then(r=>r.json()).then(({items:[j]})=>j.score/j.answer_count)

1 byte saved thanks to kamoroso94.

If requiring that it be run from a specific path is allowed then that becomes 92 90 bytes.
n=>fetch(n+`?site=codegolf`).then(r=>r.json()).then(({items:[j]})=>j.score/j.answer_count)

Try it
Full URL added to enable it to work here.

f=
n=>fetch(`//api.stackexchange.com/questions/${n}?site=codegolf`).then(r=>r.json()).then(({items:[j]})=>j.score/j.answer_count)
onchange=_=>f(+i.value).then(t=>o.innerText=t)
<input id=i type=number><pre id=o>


Sum of first row and column, then second row and column ... and so on

MATL, 16 bytes

&n:w:!XlX:GX:1XQ

Try it online! Or verify all test cases.

Explanation

Consider, as an example, the input

2   10   10    2    4
9    7    7    2    9
1    7    6    2    4
7    1    4    8    9

The code &n:w:!Xl builds the column vector [1; 2; 3; 4] and the row vector [1 2 3 4 5]. Then Xl computes the minimum element-wise with broadcast, which gives the matrix

1 1 1 1 1
1 2 2 2 2
1 2 3 3 3
1 2 3 4 4

X: linearizes this matrix (in column-major order) into the column vector [1; 1; 1; 1; 1; 2; 2; ... ; 4]. This vector and the linearized input matrix, obtained as GX:, are passed as inputs to the accumarray(... @sum) function, or 1XQ. This computes the sum of the second input grouped by values of the first input.


¡ǝƃuǝןןɐɥɔ uʍop ǝpısdn

Ruby, 78 bytes
I need to use an actual byte counter more often
->s{s.reverse.tr'a-z!?.,',"ɐqɔpǝɟƃɥıɾʞןɯuodbɹsʇnʌʍxʎz¡¿˙'"}

Try it online


Copy Memory Only Using Store And Subtraction

Assuming registers are signed and/or wrapping

8 instructions:

STO A 0x01
SUB A 0x01
SUB A 0x00
STO A 0x00
SUB A 0x00
SUB A 0x00
STO A 0x00
STO A 0x01

A 7-instruction version provided by lrn:

STO A 0x01
SUB A 0x01
SUB A 0x00
STO A 0x01
SUB A 0x01
SUB A 0x01
STO A 0x01


Python 2, 252 236 bytes

def g(n,s):
 if str(s)==s:return s.replace("'","+1")
 o,l,r=map(g,[n]*3,s);return['all((%s)for %s in range(%d))'%(r,l,n),'not((%s)*(%s))'%(l,r),'(%s)%%%d==(%s)%%%d'%(l,n,r,n),'(%s)%s(%s)'%(l,o,r)]['fn=+'.find(o)]
print eval(g(*input()))

Try it online!

Takes input as the nested prefix-syntax, with f instead of forall and n instead of nand:

[3, ["f", "v0", ["=", ["*", "v0", ["*", "v0", "v0"]], "v0"]]]


Make FizzBuzz using only preprocessor directives

C, Score 1,283 1,213 1,205

EDIT: Instead of basing on Loki Astari's solution, now I'm based on breadbox's

The basic code is not exactly the same as breadbox's - I replaced the loop with recursion, which is longer, but has more repetition.

With GCC, it can be improved further, by using ?: instead of ?0:.

#define A "Fi"
#define D "Bu"
#define E "z"
#define L E E
#define F L,z
#define R F)
#define G A R
#define H D R
#define I ""
#define K "%d"
#define X printf
#define Y puts
#define Z main
#define M 99
#define N z%5
#define O z%3
#define P Z(z
#define Q P)
#define a Q{X
#define b a(O
#define c b?N
#define d c?K
#define e d:I
#define f e:G
#define i f;Y
#define j i(N
#define k j?I
#define l k:H
#define n l;z
#define o n++
#define p o>M
#define q p?0
#define r q:Q
#define s r;
#define fizzbuzz s}

Macro-free code:

main(z){printf(z%3?z%5?"%d":"":"Fizz",z);puts(z%5?"":"Buzz",z);z++>99?0:main(z);}

The 2nd parameter to puts does nothing. It allows me to utilize the zz",z) sequence.


Evaluate an expression of ternary operators

Retina, 23 bytes

r-1=+`0\?.:|1\?(.):.
$1

Try it online! (The first line enables a linefeed-separated test suite.)

Explanation

It's fairly simple actually. The input is reduced to the result by repeatedly (+) evaluating ternaries that contain only literals. To make sure this is done right-associatively, we look for matches from right to left (r) and replace only the last match we find (-1=).

The regex itself either matches 0\?.: and removes it (leaving only the stuff after :) or 1\?.:. and replaces it with the value after the ?.


05AB1E, 46 42 36 bytes
Reading from the question-URL: 36 bytes
’ƒËŠˆ.Â‚‹º.ŒŒ/q/’žYì•3X&•«.w'Ž‡¡1èþ¨

-6 bytes thanks to @CommandMaster, by reading from this question's URL instead of the API
No direct TIO, since the .w builtin (to access a website) is disabled on TIO. But:
’ƒËŠˆ.Â‚‹º.ŒŒ/q/’žYì•3X&•«

Try this part online to see the generation of the URL.
'Ž‡¡1èþ¨

Try this part online to see the extraction of the amount of views from the HTML content. (Input doesn't contain the entire HTML content, because the TIO URL would extend 65k+ characters and be too big to post, haha.. xD)
Reading from the API: 46 42 bytes
•3X&•’¸¸.Â‚‹º.ŒŒ/…é/ÿ?€¼=ƒËŠˆ’žYì.w'š‹¡Åsþ

No direct TIO, since the .w builtin (to access a website) is disabled on TIO. But:
•3X&•’¸¸.Â‚‹º.ŒŒ/…é/ÿ?€¼=ƒËŠˆ’žYì

Try this part online to see the generation of the API-URL.
'š‹¡Åsþ

Try this part online to see the extraction of the amount of views from the JSON.
Explanation:

’ƒËŠˆ.Â‚‹º.ŒŒ/q/’
              # Push dictionary string "codegolf.stackexchange.com/q/"
 žY           # Push builtin "https://"
   ì          # And prepend it in front of the url
    •3X&•     # Push compressed integer 203590 (the id of this question)
         «    # Append it to the url
          .w  # Access this URL and read its contents
'Ž‡          '# Push dictionary string "wed"
   ¡          # Split the HTML on this word
    1è        # Get the second item (at index 1)
              #  (i.e. ` 119 times">\n                    <span class="fc-light mr2">Vie`)
      þ       # Only leave the digits (i.e. 1992)
       ¨      # And remove the last digit (2), that was part of the class
              # (after which it is output implicitly as result)

•3X&•         # Push compressed integer 203590 (the id of this question)
 ’¸¸.Â‚‹º.ŒŒ/…é/ÿ?€¼=ƒËŠˆ’
              # Push dictionary string "api.stackexchange.com/questions/ÿ?site=codegolf",
              # where the `ÿ` is automatically filled with this integer
  žY          # Push builtin "https://"
    ì         # And prepend it in front of the url
     .w       # Access this URL and read its contents
'š‹          '# Push dictionary string "count"
   ¡          # Split the JSON on this word:
              #  (i.e. `...,"view_count":14,"answer_count":2,...` will be split to
              #   [`...,"view_`, `":14,"answer_`, `":2,...`])
    Ås        # Pop and only leave the middle item (i.e. `":14,"answer_`)
      þ       # Pop and only leave its digits (i.e. 14)
              # (after which it is output implicitly as result)

See this 05AB1E tip of mine (sections How to use the dictionary? and How to compress large integers?) to understand why ’ƒËŠˆ.Â‚‹º.ŒŒ/q/’ is "codegolf.stackexchange.com/q/"; •3X&• is 203590; 'Ž‡ is "wed"; ’¸¸.Â‚‹º.ŒŒ/…é/ÿ?€¼=ƒËŠˆ’ is "api.stackexchange.com/questions/ÿ?site=codegolf"; and 'š‹ is "count".


Jelly,  16 15  14 bytes
U,Z;ŒD$€ẎḄỊÐḟḢ

A monadic link accepting a list of lists (the rows - or columns) with the values:
X = 0.155; O = -0.155; _ = 0

Returning results:
X wins = 1.085; O wins = -1.085; Tie = 0

Note: using a value of zero for _, and equal but opposite values for X and O, this value (here 0.155) may be in the range (1/6, 1/7) (exclusive at both ends) - I only chose a value in that range that gave a precisely representable floating point result for the win cases.
Try it online!
How?
U,Z;ŒD$€ẎḄỊÐḟḢ - Link: list of lists (as described above)
U              - upend (reverse each row)
  Z            - transpose (get the columns)
 ,             - pair the two
      $€       - last two links as a monad for each of them:
    ŒD         -   diagonals (leading diagonals - notes: 1. only one is of length 3;
               -              2. the upend means we get the anti-diagonals too)
   ;           -   concatenate (with the rows/columns)
        Ẏ      - tighten (make a single list of all the rows, columns and diagonals)
         Ḅ     - from binary (vectorises) (note that [0.155, 0.155, 0.155]
               -                           converts to 4*0.155+2*0.155+1*0.155 = 1.085
               -                           and [-0.155, -0.155, -0.155]
               -                           converts to 4*-0.155+2*-0.155+1*-0.155 = -1.085
               -                           while shorter lists or those of length three
               -                           with any other mixtures of 0.155, -0.155 and 0
               -                           yield results between -1 and 1
               -                           e.g. [.155,.155,0] -> 0.93)
           Ðḟ  - filter discard if:
          Ị    -   insignificant (if abs(z) <= 1) (discards all non-winning results)
             Ḣ - head (yields the first value from the list or zero if it's empty)


GolfScript, 96 characters
" "/~5<{+}*7%"v]nwm[{"=2*2base(;\(" #"@?]{.1>))["b""""#"..+]=+\[~@(@+@(7%65+\1$7%4%0>-]}7*;]" "*

Golfscript solution which can be tested online.
Note: As in the examples the key has to be upper case while mode has to be given in lower case.
Examples:
>C lydian
C D E F# G A B

>C mixolydian
C D E F G A Bb


C#

I put a random pixel in the middle, and then start putting random pixels in a neighborhood that most resembles them. Two modes are supported: with minimum selection, only one neighboring pixel is considered at a time; with average selection, all (1..8) are averaged. Minimum selection is somewhat noisy, average selection is of course more blurred, but both look like paintings actually. After some editing, here is the current, somewhat optimized version (it even uses parallel processing!):

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
using System.Drawing.Imaging;
using System.Diagnostics;
using System.IO;

class Program
{
    // algorithm settings, feel free to mess with it
    const bool AVERAGE = false;
    const int NUMCOLORS = 32;
    const int WIDTH = 256;
    const int HEIGHT = 128;
    const int STARTX = 128;
    const int STARTY = 64;

    // represent a coordinate
    struct XY
    {
        public int x, y;
        public XY(int x, int y)
        {
            this.x = x;
            this.y = y;
        }
        public override int GetHashCode()
        {
            return x ^ y;
        }
        public override bool Equals(object obj)
        {
            var that = (XY)obj;
            return this.x == that.x && this.y == that.y;
        }
    }

    // gets the difference between two colors
    static int coldiff(Color c1, Color c2)
    {
        var r = c1.R - c2.R;
        var g = c1.G - c2.G;
        var b = c1.B - c2.B;
        return r * r + g * g + b * b;
    }

    // gets the neighbors (3..8) of the given coordinate
    static List<XY> getneighbors(XY xy)
    {
        var ret = new List<XY>(8);
        for (var dy = -1; dy <= 1; dy++)
        {
            if (xy.y + dy == -1 || xy.y + dy == HEIGHT)
                continue;
            for (var dx = -1; dx <= 1; dx++)
            {
                if (xy.x + dx == -1 || xy.x + dx == WIDTH)
                    continue;
                ret.Add(new XY(xy.x + dx, xy.y + dy));
            }
        }
        return ret;
    }

    // calculates how well a color fits at the given coordinates
    static int calcdiff(Color[,] pixels, XY xy, Color c)
    {
        // get the diffs for each neighbor separately
        var diffs = new List<int>(8);
        foreach (var nxy in getneighbors(xy))
        {
            var nc = pixels[nxy.y, nxy.x];
            if (!nc.IsEmpty)
                diffs.Add(coldiff(nc, c));
        }

        // average or minimum selection
        if (AVERAGE)
            return (int)diffs.Average();
        else
            return diffs.Min();
    }

    static void Main(string[] args)
    {
        // create every color once and randomize the order
        var colors = new List<Color>();
        for (var r = 0; r < NUMCOLORS; r++)
            for (var g = 0; g < NUMCOLORS; g++)
                for (var b = 0; b < NUMCOLORS; b++)
                    colors.Add(Color.FromArgb(r * 255 / (NUMCOLORS - 1), g * 255 / (NUMCOLORS - 1), b * 255 / (NUMCOLORS - 1)));
        var rnd = new Random();
        colors.Sort(new Comparison<Color>((c1, c2) => rnd.Next(3) - 1));

        // temporary place where we work (faster than all that many GetPixel calls)
        var pixels = new Color[HEIGHT, WIDTH];
        Trace.Assert(pixels.Length == colors.Count);

        // constantly changing list of available coordinates (empty pixels which have non-empty neighbors)
        var available = new HashSet<XY>();

        // calculate the checkpoints in advance
        var checkpoints = Enumerable.Range(1, 10).ToDictionary(i => i * colors.Count / 10 - 1, i => i - 1);

        // loop through all colors that we want to place
        for (var i = 0; i < colors.Count; i++)
        {
            if (i % 256 == 0)
                Console.WriteLine("{0:P}, queue size {1}", (double)i / WIDTH / HEIGHT, available.Count);

            XY bestxy;
            if (available.Count == 0)
            {
                // use the starting point
                bestxy = new XY(STARTX, STARTY);
            }
            else
            {
                // find the best place from the list of available coordinates
                // uses parallel processing, this is the most expensive step
                bestxy = available.AsParallel().OrderBy(xy => calcdiff(pixels, xy, colors[i])).First();
            }

            // put the pixel where it belongs
            Trace.Assert(pixels[bestxy.y, bestxy.x].IsEmpty);
            pixels[bestxy.y, bestxy.x] = colors[i];

            // adjust the available list
            available.Remove(bestxy);
            foreach (var nxy in getneighbors(bestxy))
                if (pixels[nxy.y, nxy.x].IsEmpty)
                    available.Add(nxy);

            // save a checkpoint
            int chkidx;
            if (checkpoints.TryGetValue(i, out chkidx))
            {
                var img = new Bitmap(WIDTH, HEIGHT, PixelFormat.Format24bppRgb);
                for (var y = 0; y < HEIGHT; y++)
                {
                    for (var x = 0; x < WIDTH; x++)
                    {
                        img.SetPixel(x, y, pixels[y, x]);
                    }
                }
                img.Save("result" + chkidx + ".png");
            }
        }

        Trace.Assert(available.Count == 0);
    }
}

256x128 pixels, starting in the middle, minimum selection:

256x128 pixels, starting in the top left corner, minimum selection:

256x128 pixels, starting in the middle, average selection:

Here are two 10-frame animgifs that show how minimum and average selection works (kudos to the gif format for being able to display it with 256 colors only):

The mimimum selection mode grows with a small wavefront, like a blob, filling all pixels as it goes. In the average mode, however, when two different colored branches start growing next to each other, there will be a small black gap because nothing will be close enough to two different colors. Because of those gaps, the wavefront will be an order of magnitude larger, therefore the algorithm will be so much slower. But it's nice because it looks like a growing coral. If I would drop the average mode, it could be made a bit faster because each new color is compared to each existing pixel about 2-3 times. I see no other ways to optimize it, I think it's good enough as it is.

And the big attraction, here's an 512x512 pixels rendering, middle start, minimum selection:

I just can't stop playing with this! In the above code, the colors are sorted randomly. If we don't sort at all, or sort by hue ((c1, c2) => c1.GetHue().CompareTo(c2.GetHue())), we get these, respectively (both middle start and minimum selection):

Another combination, where the coral form is kept until the end: hue ordered with average selection, with a 30-frame animgif:

UPDATE: IT IS READY!!!

You wanted hi-res, I wanted hi-res, you were impatient, I barely slept. Now I'm excited to announce that it's finally ready, production quality. And I am releasing it with a big bang, an awesome 1080p YouTube video! Click here for the video, let's make it viral to promote the geek style. I'm also posting stuff on my blog at http://joco.name/, there will be a technical post about all the interesting details, the optimizations, how I made the video, etc. And finally, I am sharing the source code under GPL. It's become huge so a proper hosting is the best place for this, I will not edit the above part of my answer anymore. Be sure to compile in release mode! The program scales well to many CPU cores. A 4Kx4K render requires about 2-3 GB RAM.

I can now render huge images in 5-10 hours. I already have some 4Kx4K renders, I will post them later. The program has advanced a lot, there have been countless optimizations. I also made it user friendly so that anyone can easily use it, it has a nice command line. The program is also deterministically random, which means, you can use a random seed and it will generate the same image every time.

Here are some big renders.

My favorite 512:

(source: joco.name)

The 2048's which appear in my video:

(source: joco.name)

(source: joco.name)

(source: joco.name)

(source: joco.name)

The first 4096 renders (TODO: they are being uploaded, and my website cannot handle the big traffic, so they are temporarily relocated):

(source: joco.name)

(source: joco.name)

(source: joco.name)

(source: joco.name)


Python 342 355 398

R=(-1,0,1)
A=[];b={}
def s(w,x,y):
 if w: # not at the end of the word yet?
  for I in R: # search adjacent squares
   for j in R:
    if I|j: # skip the square we are on
     i=I+x;j+=y;c=b.get((i,j)) # get square in board
     if c==w[0]:s(w[1:],i,j) # square is what we are looking for?
     elif not c:b[i,j]=w[0];s(w[1:],i,j);del b[i,j] # we can set square?
 else:A.append(dict(b)) # all solutions
s(raw_input(),9,9) # run the search
A=min(A,key=len) # A is now the shortest solution
C=sum(map(list,A),[]) # put all board coords together
C=range(min(C),max(C)+1) # find the board biggest square bound
for r in C:print"".join(A.get((c,r)," ") for c in C)

Indent at four spaces is actually a tab character.

AMANAPLANACANALPANAMA:

MC
NA
PL

MISSISSIPPI:

S
SI
PPM

Oklahoma!:

oh
 ma
 ! l
    k
     O

Llanfairpwllgwyngyll is lethal ;)


CJam, 31 27 25 24 bytes
l:A;lel:N{_A_$er_N#}g;],

Takes input in the form of:
aebcdjfghiqklmnopzrstuvwxy
Mr. John Doe

i.e. first line - alphabets, second line - name.
How it works:
l:A;lel:N{_A_$er_N#}g;],
l:A;                         "Read the alphabets from the 1st line in A and pop from stack";
    lel:N                    "Read the name in small caps from 2nd line and store in N";
         {         }g        "Run a while loop until we have the original name back again";
          _                  "Put a dummy string on stack just to keep count of times";
           A                 "Put the alphabets on stack";
            _$               "Copy them and sort the copy to get the correct order";
              er             "Transliterate the right keys with the wrong ones";
                _N#          "Copy the result and see if its equal to the original name";
                     ;]      "Pop the last name and wrap everything in an array";
                       ,     "Get the length now. Since we were putting a dummy string";
                             "on stack in each iteration of the while loop, this length";
                             "represents the number of times we tried typing the name";

Try it online here


R, 3 31 25 bytes

# changes the builtin to only return the acf
body(acf)=body(acf)[1:18]

Usage (returns an array with the autocorrelations)

(acf(c(2.4, 2.4, 2.4, 2.2, 2.1, 1.5, 2.3, 2.3, 2.5, 2),5))
# , , 1
#
#             [,1]
# [1,]  1.00000000
# [2,]  0.07659298
# [3,] -0.06007802
# [4,] -0.51144343
# [5,] -0.02912874
# [6,] -0.10468140

Background:

The 31 byte solution based on the original acf built in

function(n,h)c(acf(n,h,,F)$acf)

Note that the 3 byte option  acf is the originalbuilt in that will plot (and print to 3 digits) while returning the required autocorrelation as an element in a list.

usage

 acf(c(2.4, 2.4, 2.4, 2.2, 2.1, 1.5, 2.3, 2.3, 2.5, 2),5)

output:

#    Autocorrelations of series ‘c(2.4, 2.4, 2.4, 2.2, 2.1, 1.5, 2.3, 2.3, 2.5, 2)’, by lag
#
#     0      1      2      3      4      5
# 1.000  0.077 -0.060 -0.511 -0.029 -0.105

If we want the correlations to display to more than 3 decimal places then 28 bytes will do it (or 31, if we want to suppress the plot)

# will still plot (28 bytes)
function(n,h)c(acf(n,h)$acf)
# won't plot (31 bytes)
function(n,h)c(acf(n,h,,F)$acf)


Malbolge, 128 bytes, cracked by KBRON111

(=&r:#o=~l4jz7g5vttbrpp^nllZjhhVfddRb`O;:('JYX#VV~jS{Ql>jMKK9IGcFaD_X]\[ZYXWVsN6L4J\[kYEhVBeScba%_M]]~IYG3Eyx5432+rpp-n+l)j'h%B0

Have fun!

(Yes, I learned Malbolge just for this. Yes, it took an absurdly long time to finally get working. And yes, it was totally worth it.)

Wrapped, so you can see it in its full, er, "glory":

(=&r:#o=~l4jz7g5vttbrpp^nllZjhhV
fddRb`O;:('JYX#VV~jS{Ql>jMKK9IGc
FaD_X]\[ZYXWVsN6L4J\[kYEhVBeScba
%_M]]~IYG3Eyx5432+rpp-n+l)j'h%B0

I used this interpreter to test it; I'm not sure if it matters, but I figured I'd specify just in case.


JavaScript (ES6), 81 67 bytes
Saved 1 byte thanks to @l4m2

f=(n,x=1)=>x<n?f(x,n):x>n?f(+[...n+''].reduce((p,i)=>p*i||p)+n,x):n

Try it online!
Commented
f = (n,                   // n = current value for the 1st sequence, initialized to input
        x = 1) =>         // x = current value for the 2nd sequence, initialized to 1
  x < n ?                 // if x is less than n:
    f(x, n)               //   swap the sequences by doing a recursive call to f(x, n)
  :                       // else:
    x > n ?               //   if x is greater than n:
      f(                  //     do a recursive call with the next term of the 1st sequence:
        +[...n + '']      //       coerce n to a string and split it
        .reduce((p, i) => //       for each digit i in n:
          p * i || p      //         multiply p by i, or let p unchanged if i is zero
        ) + n,            //       end of reduce(); add n to the result
        x                 //       let x unchanged
      )                   //     end of recursive call
    :                     //   else:
      n                   //     return n


Haskell, 124 120 119 117 113 110 109 106 105 104 101 98 bytes

4 bytes saved thanks to bartavelle!

3 bytes saved thanks to Zgarb

1 byte saved thanks to Peter Taylor

Here's a solution I worked out in Haskell.  Its ok right now pretty good thanks to some help I received, but I'm looking to make this shorter, so feedback/suggestions are appreciated.

until(!0)g.map d
_!1=1<0
('(':a)!x=a!(x-1)
(_:a)!x=a!(x+1)
_!_=1>0
g(a:b)=b++[a]
d '('=')'
d _='('

Try it online!

Explanation

This program defines 4 functions,  the first (!) determines if a string is balanced.  Its defined as follows:

_!1=1<0
('(':a)!x=a!(x-1)
(_:a)!x=a!(x+1)
_!_=1>0

This check assumes that the input has an equal number of open and close parens thanks to a suggestion from Peter Taylor.

The next g will rotate the string once.

g(a:b)=b++[a]

Then we have d which simply takes a paren and mirrors it

d '('=')'
d _='('

Finally we have the function we are concerned with. Here we use a pointfree representation of until(!0)g composed with map d, which maps d to the input and applies g until the result is balanced.  This is the exact process described in the question.

until(!0)g.map d


Jelly, 10 bytes
ŒJạ€ŒṪ§Ṃ€Ṁ

Try it online!
-2 bytes thanks to Sisyphus
Calculate the Manhattan differences from all 0s to all 1s, and the answer is the maximum of the minimums (each row's minimum is the number of stages until it gets infected, so the number of stages needed is the maximum of the stages needed for each person).
Conveniently, if all elements are 1, this returns 0 since that's the default value for minmax.
If no person is infected in the initial state, this also returns 0.
Explanation
ŒJạ€ŒṪ§Ṃ€Ṁ  Main Link
ŒJ          Get all indices in the grid (2D indices in a matrix)
    ŒṪ      Get all truthy indices in the grid (finds all infected people)
  ạ€  §     Manhattan distance between each point to each truthy point
       Ṃ€   Minimum of each (minimum number of days for each person to get infected)
         Ṁ  Maximum (of each point's required days to get infected)


Pyth, 20 bytes

Msme.H%dGu+G-HsGjHGY

This defines a function g which takes two integers as parameters. Take a look at this online demonstration: Pyth Compiler/Executor.

Explanation:

Msme.H%dGu+G-HsGjHGY
M                     def g(G, H): return _
                jHG      convert H to base G
         u      jHGY     reduce(lambda G, H: _, jHG, [])
          +G-HsG            G + [H - sum(G)]
  m                      map each number d to:
   e.H%dG                   hex-representation(d % G)[-1]
 s                       sum (join all digits)

This code is a little bit confusing. There are 4 function parameters in this code: two of them are called G and two of them are called H. The G in +G-HsG is different from the G in jHG or %dG.


Pyth, 13 bytes
++hAlDQ\_.-HG

Try it online.


CJam (77 bytes)

{Ma+a{():B;:A:|{A((:C;0\+a\+_e_,2*{[0C]f/[0_]f*z}*{0Der}%BD+a+a+}fDAe_(-}g;B}

Online demo. This is an anonymous block (function) which takes the input as a 2D array and provides the output as a 1D array.


Ruby, 129 122 115 111 108 107 105

Done with golfing...

Oops, completely forgot to remove unnecessary spaces - fixed...

Saved 2 chars thanks to Peter Taylor.

Online version

def t9(t)
(t.tr(" ",?`).bytes.map{|c|"09998887777666555444333222"[96-c..-1][/(.)\1*/]}*' ').gsub /(\d) (?!\1)/,'\1'
end

Explanation:

space is translated to the char with the ordinal 96

(t.tr(" ",?`).bytes

characters are first mapped to series of numbers:
- a to 2
- b to 22
- d to 3222
- h to 444333222

a regex expression then matches the first group of equal digits

map{|c|"09998887777666555444333222"[96-c..-1][/(.)\1*/]}

the array is joined

*' ')

all spaces in the occurences of "digit space different_digit" are removed

gsub /(\d) (?!\1)/,'\1'


These are not in any particular order, and some of them might even apply to other languages too, but not to a lot of them I think.

You can sometimes use awk's simple string concatenation to assemble numbers

z=x*10+y and a=b*10

become

z=x y and a=b 0
You can use the ~ operator (match pattern on the right side) to compare numbers or strings if you know that the two parts meet certain conditions

for instance if you know that a will always be smaller than or equal to b, you can replace

a==b

with

a~b

or if you want to check for an empty string s (which means that s isn't allowed to be "0" either), and you haven's changed the variable X before, so that it is still undefined, you could use

X~s

instead of

s==""

if you want to check if i is an integer you can use

i!~/\./ (i doesn't contain a dot)

instead of

i==int(i)
You can swap two numbers in a single command

t=a;a=b;b=t

becomes

a+=b-(b=a)

saving one character
If you don't need them as input anymore, you can use the input variables $1, $2, $3, ... as an array. So instead of writing a[n] you can just write $n. Sometimes even while reading the input from these you can use the already handled ones as a stack for something.
You can make good use of the built-in separators FS (space, if not changed by you) and RS (newline) when concatenating strings

a=$1" "$2

becomes

a=$1FS$2

or even better

a=$1"\n"$2

becomes

a=$1RS$2
If there is no input and you use the BEGIN block, you can try to use the END block instead. Depending on the judge it works. If you test it, you have to press Ctrl-D (end of input) to access the END block.
If you want to skip the first line, you can use

C++

instead of

NR>1

if you won't be using C anywhere in your program.


Greatest Number in a Range When The Sum of Squares of its Prime Factors are Subtracted

Pyth, 17 15 bytes
_eSttm,-ds^R2{P

Test suite.


A sequence of sums of integers that aren't in the sequence

Jelly, 13 12 9 bytes

rSạo4¥ð@¡

Uses 0-based indexing.

Try it online!

How it works

rSạo4¥ð@¡  Main link. No arguments. Implicit argument: 0

      ð    Collect everything to the left into a chain and start a new, dyadic one.
           The arity of the first chain is unknown at this point, as it isn't
           prefixed by ø, µ, or ð.
       @   Swap the arguments of the first chain. Swapping  arguments is only
           implemented for dyadic links, so this makes the chain dyadic.
        ¡  Read an integer n from STDIN and execute the chain n times. Taking the
           argument swap into account, the chain is executed first with 0 as left
           and right argument, then with the previous right argument as left
           argument and the previous return value as right argument.
           The return value of the last call is the return value of the quicklink
           and becomes the implicit output.

           Let's call the left argument x and the right argument y.
r            Range; yield [x, ..., y].
 S           Compute the sum of all integers in the range.
     ¥       Convert the two atoms to the left into a dyadic chain, and call that
             chain with arguments x and y.
   o4          Take the logical OR of x and 4, replacing a 0 with 4 and leaving
               positive integers untouched.
  ạ          Take the absolute difference of the sum to the left and the result of
             the logical OR to the right.


Haskell, 55 53 51
(t:w)%p|t=w++p|0<1=w
x%_=x
e w=(!!).scanl(%)w.cycle

this uses True as 1 and False as 0.
example run:
*Main> let t=True ; f=False
*Main> e [t,f,t] [[f,f,f],[t,t,t]] 4
[False,False,False,False,False]


Python 2 (228 209 208 207)

(not counting the last newline)

import time
s=time.strptime
f=raw_input().split('*')
t=s(f[2],"%d/%m/%Y")
if t[1:3]in[(2,29),(7,21)]:t=s("%s%s"%(t[0],t[7]-1),"%Y%j")
print"NNSSWEWE"[(t[7]+s(str(t[0]),"%Y")[6]-int(f[0])-int(f[1])*2+3)%4::4]

Edits:

substituted variables that were used only once, further golfed the print statement.
Removed the space after print as isaacg suggested.
Changed from time import*;s=strptime to import time;s=time.strptime to shave off one extra byte


R, 158 154 141  bytes
Edit: Because the only 1 in the upper 2x2 submatrix is the top left M[1,1] we can start the search for 1s when {x,y}>1 so no need for the if statement.
M=matrix(0,n<-scan(),n);M[1]=1;for(i in 2:n)for(j in 2:n){y=x=M[1:i,1:j];x[i,j]=0;y[i,j]=1;d=1/(i+j);M[i,j]=abs(d-mean(x))>=abs(d-mean(y))};M

The solution is highly inefficient as the matrix is duplicated twice for each iteration. n=1000 took just under two and a half hours to run and produces a matrix of 7.6 Mb.
Ungolfed and explained
M=matrix(0,n<-scan(),n);                        # Read input from stdin and initialize matrix with 0s
M[1]=1;                                         # Set top left element to 1
for(i in 2:n){                                  # For each row
    for(j in 2:n){                              # For each column
        y=x=M[1:i,1:j];                         # Generate two copies of M with i rows and j columns
        x[i,j]=0;                               # Set bottom right element to 0
        y[i,j]=1;                               # Set bottom right element to 1
        d=1/(i+j);                              # Calculate inverse of sum of indices
        M[i,j]=abs(d-mean(x))>=abs(d-mean(y))   # Returns FALSE if mean(x) is closer to d and TRUE if mean(y) is
    }
};
M                                               # Print to stdout

Output for n=20
      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14] [,15] [,16] [,17] [,18] [,19] [,20]
[1,]     1    0    0    0    0    0    0    0    0     0     0     0     0     0     0     0     0     0     0     0
[2,]     0    0    0    0    0    1    0    0    0     0     0     0     0     0     0     0     0     0     0     0
[3,]     0    0    1    0    0    0    0    0    0     0     0     0     0     0     0     0     0     0     0     0
[4,]     0    0    0    0    0    0    0    0    0     0     0     0     0     0     0     0     0     0     0     0
[5,]     0    0    0    0    1    0    0    0    0     0     0     0     0     0     0     0     0     0     0     0
[6,]     0    1    0    0    0    0    0    0    0     0     0     0     0     0     0     0     0     0     0     0
[7,]     0    0    0    0    0    0    0    0    0     0     0     0     0     0     0     0     0     0     0     0
[8,]     0    0    0    0    0    0    0    0    0     0     0     0     0     0     0     0     0     1     0     0
[9,]     0    0    0    0    0    0    0    0    0     0     0     0     0     0     1     0     0     0     0     0
[10,]    0    0    0    0    0    0    0    0    0     0     0     0     1     0     0     0     0     0     0     0
[11,]    0    0    0    0    0    0    0    0    0     0     1     0     0     0     0     0     0     0     0     0
[12,]    0    0    0    0    0    0    0    0    0     0     0     0     0     0     0     0     0     0     0     0
[13,]    0    0    0    0    0    0    0    0    0     1     0     0     0     0     0     0     0     0     0     0
[14,]    0    0    0    0    0    0    0    0    0     0     0     0     0     0     0     0     0     0     0     0
[15,]    0    0    0    0    0    0    0    0    1     0     0     0     0     0     0     0     0     0     0     0
[16,]    0    0    0    0    0    0    0    0    0     0     0     0     0     0     0     0     0     0     0     0
[17,]    0    0    0    0    0    0    0    0    0     0     0     0     0     0     0     0     0     0     0     0
[18,]    0    0    0    0    0    0    0    1    0     0     0     0     0     0     0     0     0     0     0     0
[19,]    0    0    0    0    0    0    0    0    0     0     0     0     0     0     0     0     0     0     0     0
[20,]    0    0    0    0    0    0    0    0    0     0     0     0     0     0     0     0     0     0     0     0


Neim, 3 bytes

ᚺ>:

Explanation:

ᚺ   halve
 >  increment
  : previous prime

Try it online!


05AB1E, 16 bytes

Thanks to Emigna for saving a byte and fixing a bug!

vyÐl'ŒÎ¾èQi¼ëš}?

Explanation:

vy                # For each character in the string...
  Ð               #   Triplicate that character
   l              #   Convert to lowercase
    'ŒÎ           #   Compressed version of "christmas"
       ¾          #   Push the counting variable (let's call this N)
        è         #   Get the nth character of "christmas", with modular indexing
         Qi   }   #   If equal...
           ¼      #      N += 1
            ë     #   Else...
             š    #      Swapcase
               ?  #   Print that character

Uses the CP-1252 encoding. Try it online!


Python 2, 101 bytes

Ports from my answer to square the numbers my way.

x,z=1,input()
while sum(float(i*len(z))for z in[[i for i in`x`if"/"<i]]for i in[x]+z)!=z:x+=1
print x

Try it online!


APL (124 120 116)

This is way too long. It does grade school multiplication.

N←{↓⌽↑⌽¨⍵}⋄S↓'-',A/⍨∨\×A←{∨/M←9<T←0,⍵:∇(1⌽M)+T-M×10⋄⍵}⊃+/N↑⍨⌿2L⍴E,(L-1)+⍳L←⊃⍴E←⌽Y∘×¨⊃X Y←N⍎¨¨A~¨'-'⊣S←1≠+/'-'∊¨A←⍞⍞

Explanation:

N←{↓⌽↑⌽¨⍵}: N is a function that, given a vector of vectors, makes all the vectors the same length, padding with zeroes at the front. It does this by reversing all inner vectors (⌽¨), turning the vector of vectors into a matrix (↑), reversing this matrix (⌽), and turning it back into a vector of vectors (↓).
S←1≠+/'-'∊¨A←⍞⍞: Read two lines of input, as characters (⍞⍞), store them in A, and count how many minuses there are in the input. S is zero or one depending on whether the result will be positive.
X Y←N⍎¨¨A~¨'-': In A (our input) without (~) the minuses, evaluate each separate character (⍎¨¨), run it through the N function and save the two vectors in X and Y. If the input was 123 32, we now have X=1 2 3 Y=0 3 2.
L←⊃⍴E←⌽Y∘×¨⊃X Y: For each digit in the first vector, produce a vector with the digits from the second vector multiplied by that digit. Reverse this vector of vectors so that the least significant one is at the front. Store this vector in E and its length in L.
+/N↑⍨⌿2L⍴E,(L-1)+⍳L: Shift all of these vectors left, padding with zeroes on the right, by their index. Run them through N again so that they're all the same length. Then add all these vectors together. I.e.:

       1 2 3
         3 2
      ------
       2 4 6 (shift 0)
     3 6 9   (shift 1)
    --------
    3 8 13 6 (before carry)
     3 9 3 6 (after carry)

A←{∨/M←9<T←0,⍵:∇(1⌽M)+T-M×10⋄⍵}: Carry the ones. As long as there are still 'digits' higher than 10 (∨/M←9<T←0,⍵), add one to the next significant digit (∇(1⌽M)+T) and remove 10 from the offending digit (-M×10).
'-',A/⍨∨\×A: Remove any leading zeroes from the result vector, and add a minus in front.
S↓: Remove S characters from the front, i.e. if the result is supposed to be positive then remove the minus again.


How does math work in Anastasiya's world?

Dyalog APL, 33 32 30 29 bytes

This extends APL to include the prefix notation +/A n₁ n₂ and ×/A n₁ n₂. (In fact, you can use any operation to the left of the /A.) Returns a list of {result, repetition count}.

A←{(⊃,≢)⍺⍺{∪⍵,⍨⍺⍺⍎¨⍕⊃⍵}⍣≡⍺⍺⍵}

  A←{ define a higher-order function in terms of left-hand function ⍺⍺, and right-hand argument ⍵

    (⊃,≢) the first element of, followed by the count of

    ⍺⍺{ the supplied function (+/ for sum or ×/ for product) fed to the higher-order function

      ∪ the unique elements of

      ⍵,⍨ the argument appended to

      ⍺⍺ the fed function applied to

      ⍎¨ the evaluation of each character of

      ⍕ the character representation of

      ⊃⍵ the first element of the argument

    }⍣≡ applied repeatedly until the result is identical to the argument, beginning with

    ⍺⍺⍵ the originally fed function (+/ or ×/) applied to the original argument

  } [end of higher-order function definition]

TryAPL online! (⍎ has been emulated with e for security reasons.)

Thanks to @ngn for saving a byte.

0 bytes (in jest)

Dyalog APL actually already has full support for Anastasiyan math; instead of (+) and (×), it uses +{n←0⋄n,⍺⍺{n+←1⋄⍺⍺/⍎¨⍕⍵}⍣=⍵⍺⍺⍨⍺} and ×{n←0⋄n,⍺⍺{n+←1⋄⍺⍺/⍎¨⍕⍵}⍣=⍵⍺⍺⍨⍺}.

Try 81 +{(⊃,≢)⍺⍺{∪⍵,⍨⍺⍺e¨⍕⊃⍵}⍣≡⍺⍺/⍺⍵} 31 and 21 ×{n←0⋄n,⍺⍺{n+←1⋄⍺⍺/e¨⍕⍵}⍣=⍵⍺⍺⍨⍺} 111.


Charcoal, 138 110 98 bytes

≔§⪪”)¶⊟eΦＯ∨ü&-T[¿Ｑ№i⧴⊕%⁰q”⁴ＬΦ⪪”)¶ »Ｒ≦ＰH↘{⎚″4χχβ´ΣP”⁴›ι✂θ⁴χ¹η¿⁼Ｉη¹²⁺⊖…θ⁴1212«…θ⁴¿⁻Ση³η«022§9888Ｉ…θ⁴

Try it online! Link is to verbose version of code. Edit: Saved 28 bytes by switching I/O to compact ISO format (yyyymmdd). Saved 12 bytes when the supported year range was restricted to 1901 to 2099. Explanation:

≔§⪪”)¶⊟eΦＯ∨ü&-T[¿Ｑ№i⧴⊕%⁰q”⁴ＬΦ⪪”)¶ »Ｒ≦ＰH↘{⎚″4χχβ´ΣP”⁴›ι✂θ⁴χ¹η

Take the dates (in mmdd format) 0120, 0317, 0421, 0523, 0623, 0725, 0822, 0922, 1024, 1124. These represent the cutoff points above which the next Doomsday is nearer. (In some cases the Doomsday is equidistant but in particular for 0120 that is not true on leap years.) Work out which cutoff point applies by counting the number of dates that fall before the input date. Then look up the relevant Doomsday date from the list (in mmdd format) 1212, 1107, 1010, 0905, 0808, 0711, 0606, 0509, 0404, 0300, 0012.

If I had access to a date library I could then ask it to fix up my date, but unfortunately I have to do that manually:

¿⁼Ｉη¹²

Is this the 0012 date, meaning the 12th of month 0, i.e. last December?

⁺⊖…θ⁴1212«

If so then output the previous year and a month and day of 12.

…θ⁴

Otherwise the year is at least correct...

¿⁻Ση³

Is this the 0300 date, meaning the 0th of March, i.e. the last day of February?

η«

If not then this is the date we seek.

022

Output February the 2?th.

§9888Ｉ…θ⁴

Output 9 if the year is a multiple of 4, otherwise 8.


Lenguage, score 0
Well, this is quite boring and obvious, but it seems to achieve the perfect score (assuming I understand the challenge correctly). To fix this loophole, you should probably add the program's length to the sum of the code points; I'm pretty sure that won't break the relative order of the current answers.
The program is
2282524454641945458940768311481012240407465625061984267694778013056442426959468031225640633070772676474431950201473533908

null bytes. Fortunately, 0 multiplied by the number above is still 0.
I believe this decompresses (alternatively, it compresses) to the automatically generated (with the help of a random web page that claims "Original Java program not from me") brainfuck program:
-[------->+<]>-.-[->+++++<]>++.+++++++..[-->+<]>------.[--->++<]>.---[->+++<]>.+[-->+<]>++++.[----->+<]>++.------.--------.-[--->+<]>.

It almost certainly could be golfed (but I haven't tried), but that is unnecessary.


CJam, 22 20 bytes

qa{4/3*' +f+W%z}8/N*

Test it here.

Explanation

How do you wrap a 2D grid of characters in one layer of spaces (or any other character)? Correct: four times, you append a space to each line and then rotate the grid by 90 degrees. That's exactly what I'm doing here with eight rotations: four for spaces, four for #:

qa      e# Read the input and wrap it in an array, to make it a 2D grid.
{       e# Execute this block for each value from 0 to 7.
  4/3*  e#   Divide by 4, multiply by 3. Gives 0 for the first four iterations and
        e#   and 3 for the other four.
  ' +   e#   Add the result to a space character (space + 3 == #).
  f+    e#   Append this to each line of the grid.
  W%z   e#   Reverse the lines, then transpose the grid - together these rotate it.
}8/
N*      e# Join the lines of the grid by newlines.


JavaScript (ES6), 54 bytes

a=>~(g=a=>g[a]||~-g(g[a]=a.map(i=>a[i]).reverse()))(a)

Try it online!


Print all the ways to aquire specific number using only specific numbers

Jelly, 10 bytes

ŒṗfƑƇL=¥Ƈ⁵

Try it online!

A full program that takes the total, token values and number of arguments as its arguments. Returns a list of lists of token values.

Explanation

Œṗ          | Integer partition (of first argument)
    Ƈ       | Keep only those which:
   Ƒ        | - are invariant when:
  f         |   - filtered to only include the (implicit) second argument.
       ¥Ƈ   | Keep only those for which:
     L      | - the length
      =  ⁵  |   - is equal to the third argument


Mathematica, 244.719 (245 bytes)
f[l_,n_]:=x/.Solve[d=Rest@Import@"QueryResults.csv";LinearModelFit[#.#2/Tr@#&@@{#~Max~-1&/@#4+1,#3}&@@Thread@#&/@{#,#~Cases~{_,l,__}}&/@d~GroupBy~Last/@#[[;;,1,5]],x,x,Weights->Tr/@#[[;;,;;,4]]]&[d~Cases~{_,l,_,v_/;v>=0,_}~GatherBy~Last]@x==n,x]

Test case
f["mathematica", n]   (* { .820033 (n + 53.4263) } *)
f["mathematica", 245] (* { 244.719 } *)

What about other languages?
f["c++", n]           (* { .821181 (n - 79.5437) } *)
f["java", n]          (* { .717579 (n - 56.0858) } *)
f["cjam", n]          (* { 2.21357 (n + 2.73772) } *)
f["pyth", n]          (* { 4.52194 (n - 8.82806) } *)

Alternative model: \$\log(c)=\log\left(\frac{n-B}V\right)\$
One notable feature of code golf (and probably other coding problems) is that the distribution of the lengths of programs tends to be exponential distribution (in contrast to uniform distribution). Hence model \$\log(n)=\log(Vc+B)\$ is much more likely to balance the influences between points with large \$c\$ and small \$c\$.
As we can see in the graphs below, the distribution of points are suitable for fitting in logarithmic scale.

Results of the new model
Language       V       B

Python       1.365   -19.4
Javascript   1.002     1.6
Ruby         0.724     1.7
Perl         1.177   -32.7
C            1.105     1.5
Haskell      1.454   -24.5
Mathematica  1.319   -39.7
PHP          1.799   -62.0
Java         1.642     4.4
C#           1.407     4.5

CJam         0.608   -12.5
Pyth         0.519   -11.4
Golfscript   0.766   -18.0
J            0.863   -21.4
APL          0.744   -17.7
K            0.933   -23.3
Retina       1.322   -37.9
MATL         0.762   -13.3
Jelly        0.965   -23.8

We have found two exceptional language - Ruby with \$V=0.72\$` and Retina with \$V=1.322\$, and a criterion of being a popular golfing language - having a large negative boilerplate.


Remove more than n consecutive vowels from input string


Cops and Robbers: Redacted Primality (Robbers' Thread)


nth number with n distinct prime factors

Java, 170 characters in one line

int a(int n) {
    int a = 2, t = a, m = 1, i = 1;
    Set s = new HashSet();
    while (i++ > 0) {
        if (t % i == 0) {
            s.add(i);
            t /= i;
            if (t == 1) {
                if (s.size() == n) {
                    if (n == m) {
                        break;
                    }
                    m++;
                }
                t = ++a;
                s.clear();
            }
            i = 1;
        }
    }
    return a;
}

Update, +77 characters IOL

int[] f(int n) {
    int[] f = new int[n];
    for (int i = 0; i < n; i++) {
        f[i] = a(i+1);
    }
    return f;
}


Since this is basically talking about a cellular automaton I give you..
Golly Quicklife rule, 10 bytes
01234/234V

Input the rule, paste the grid into Golly, run pattern. The resulting pattern is the output.
Explanation:
01234 Survive on any number of neighbors
     /234 Born on >2 neighbors
         V Only directly adjacent neighbors count

Or if you insist on a full RuleLoader rule, 89 bytes:
@RULE X
@TABLE
n_states:2
neighborhood:vonNeumann
symmetries:permute
011001
011101
011111

Rulename is X, same steps as before.


Easier communication means… ○ circular edition!

Octave, 168 bytes
for i=1:(n=nnz(s='CATION MEANS FASTER CODING MEANS FEWER CODERS MEANS EASIER COMMUNI')),text(sin(i/n*2*pi),cos(i/n*2*pi),s(i),'rotation',-i/n*360);axis([-2,2,-2,2]);end

Try it here


CJam (32 26 24 21 bytes)

0q~0]e`1f=2ew::>2,/,(

Expected input is space-separated numbers.

Online demo ; full test suite (expected output is a 1 per test case).

Thanks to Martin for informing me that the current version of CJam improves one of the operators used, saving 2 chars; and for a further 3-char saving.

Dissection

Two phases: deduplicate, then identify local maxima in each set of three.

0q~0]      e# Put the input in an array wrapped in [0 ... 0]
e`1f=      e# Use run-length encoding to deduplicate
2ew::>     e# Map [a b c ...] to [(a>b) (b>c) ...]
2,/        e# Split on [0 1], which since we've deduplicated occurs when (a<b) (b>c)
,(         e# Count the parts and decrement to give the number of [0 1]s


JavaScript (Node.js), score \$335\$
Pretty straight-forward algorithm. I made it multithreaded to be a bit faster.
// Run with: node ./square-root-multiples.js

const findMaxK = (fromN, toN) => {
  let maxK = 0;
  let maxN = 0;
  for (let n = fromN; n < toN; n++) {
    for (let k = 2, s = n * n; k < s; k++) {
      const r = Math.sqrt(k);
      const x = r * Math.ceil(n / r);
      if (x > n && x < n + 1) {
        if (k > maxK) {
          maxK = k;
          maxN = n;
        }
        break;
      }
    }
  }
  return { n: maxN, k: maxK };
};

const BATCH_SIZE = 10000000;

const cluster = require("cluster");
if (cluster.isMaster) {
  const start = Date.now();
  let nextBatch = 0;
  let maxK = 0;

  const numCpus = require("os").cpus().length;
  for (let i = 0; i < numCpus; i++) {
    const worker = cluster.fork();
    worker.on("message", (msg) => {
      if (msg.k > maxK) {
        maxK = msg.k;
        console.log(
          `found A261865(${msg.n}) = ${msg.k} in ${
            (Date.now() - start) / 1000
          }s`
        );
      }
      worker.send({ n: nextBatch, maxK });
      nextBatch += BATCH_SIZE;
    });
    worker.send({ n: nextBatch });
    nextBatch += BATCH_SIZE;
  }
} else {
  process.on("message", (msg) => {
    process.send(findMaxK(msg.n, msg.n + BATCH_SIZE));
  });
}

Output on my 2019 MacBook Pro:
found A261865(12779527) = 134 in 0.299s
found A261865(2345213) = 187 in 0.308s
found A261865(63856063) = 193 in 0.33s
found A261865(222125822) = 210 in 0.681s
found A261865(237941698) = 217 in 0.687s
found A261865(257240414) = 227 in 0.804s
found A261865(1217775885) = 230 in 2.704s
found A261865(1205703469) = 267 in 2.704s
found A261865(1558293414) = 299 in 3.306s
found A261865(4641799364) = 303 in 13.002s
found A261865(6600656102) = 323 in 20.045s
found A261865(11145613453) = 335 in 36.774s
found A261865(20641456345) = 354 in 73.047s

The highest K my machine found within 60s was A261865(11145613453) = 335.


Python 3, 693 690 686 687 bytes

Yeah, naive approach. I tried some compression methods, and this one seems to be the shortest.

-2 bytes thanks to HyperNeutrino.

EDIT: Bug fixed.

import random
v="Absinthe$Death in the Afternoon$Earthquake$Green Russians$Green Vesper$Moloko Plus$Beer$Black and Tan$Black Velvet$Boilermaker$Michelada$Irish Car Bomb$Brandy$B&B$Brandy Alexander$French Connection$Horse's Neck$Sidecar$Cachaca$Caipirinha$Leite de Onca$Quentao$Rabo-de-Galo$Royce$Gin$Bramble$Casino$Clover Club Cocktail$Gin Fizz$Martini$Rum$Bacardi$Cuba Libre$Daiquiri$El Presidente$Pina Colada$Tequila$El Toro Loco$Margarita$Matador$Paloma$Tequila Sunrise$Vodka$Black Russian$Bloody Mary$Cosmopolitan$Kamikaze$Screwdriver$Whiskey$Bourbon Lancer$Irish Coffee$Manhattan$Rusty Nail$Whiskey Sour".split('$');a=v.index(input());print(v[a-a%6if a%6else random.randint(1,5)+a])

Try it online!


05AB1E, 21 bytes

Defines a program \$f : \color{purple}{\texttt{AlphabeticChar}} \rightarrow \color{purple}{\texttt{String}}\$

Code:

2AA¹k._•1ëª»*Ć,ãiDΣ•Λ

Try it online!

Breakdown:

2AA¹k._•1ëª»*Ć,ãiDΣ•Λ

2                       # <length>
 AA¹k._                 # <filler>
       •1ëª»*Ć,ãiDΣ•    # <pattern>
                    Λ   # Invoke the canvas function.

Explanation:

The canvas (Λ) in this particular context works as a function with the following signature:

$$
\mathsf{\Lambda} : \left(\texttt{length}: \color{purple}{\texttt{Nat}},\ \texttt{filler}: \color{purple}{\texttt{String}},\ \texttt{pattern}: \color{purple}{\texttt{Nat}}\right) \rightarrow \color{purple}{\texttt{String}}
$$

The \$\texttt{pattern}\$ parameter is in this situation a number defining the directions. In the code, this number is represented as •1ëª»*Ć,ãiDΣ•, which is a compressed version of the big number \$2232344565666667670012122\$. Directions are denoted in the following manner:

$$
\begin{array}{l}
7 & & 0 & & 1 \\
  & \nwarrow & \uparrow & \nearrow & \\
6 & \leftarrow & \bullet & \rightarrow & 2 \\
  & \swarrow & \downarrow & \searrow & \\
5 & & 4 & & 3
\end{array}
$$

This means that the big number represents the following pattern of directions:

$$
[\rightarrow, \rightarrow, \searrow, \rightarrow, \searrow, \downarrow, \downarrow, \swarrow, \leftarrow, \swarrow, \leftarrow, \leftarrow, \leftarrow, \leftarrow, \leftarrow, \nwarrow, \leftarrow, \nwarrow, \uparrow, \uparrow, \nearrow, \rightarrow, \nearrow, \rightarrow, \rightarrow]
$$

With this signature context, the canvas iterates through the \$\texttt{pattern}\$ list and writes \$\texttt{length}\$ characters from the \$\texttt{filler}\$ in the current direction.

The \$\texttt{length}\$ is specified in the code as \$2\$ (at the beginning of the code). For the \$\texttt{filler}\$, we need a rotated version of the alphabet such that it starts with the given input. That is done with the following code (try it here):

AA¹k._

 A¹k       # Find the <index> of the given input character in the alphabet
A   ._     # Rotate the alphabet to the left <index> times.

In pseudocode, this would be executed by the canvas function:

\$
\begin{array}{l}
1. & \text{Write } \color{blue}{\texttt{ab}} \text{ in the direction} \rightarrow \\
2. & \text{Write } \color{blue}{\texttt{bc}} \text{ in the direction} \rightarrow \\
3. & \text{Write } \color{blue}{\texttt{cd}} \text{ in the direction} \searrow \\
4. & \text{Write } \color{blue}{\texttt{de}} \text{ in the direction} \rightarrow \\
5. & \text{Write } \color{blue}{\texttt{ef}} \text{ in the direction} \searrow \\
6. & \text{Write } \color{blue}{\texttt{fg}} \text{ in the direction} \downarrow \\
\dots
\end{array}
\$

Lastly, you can see that the filler argument is 'rotated' \$\texttt{length} - 1\$ times to the right, meaning that the canvas would iterate through the following (cycled and therefore infinite) list:

$$
[\color{blue}{\texttt{ab}}, \color{blue}{\texttt{bc}}, \color{blue}{\texttt{cd}}, \color{blue}{\texttt{de}}, \color{blue}{\texttt{ef}}, \color{blue}{\texttt{fg}}, \color{blue}{\texttt{gh}}, \color{blue}{\texttt{hi}}, \color{blue}{\texttt{ij}}, \color{blue}{\texttt{jk}}, ...
$$

Which results in the desired alphabet soup ascii-art shape.


Wolfram Language (Mathematica), 65 bytes

Tr[1^#]&@@Cases[Subsets[n=0~Range~#],k_/;Union@@Abs[k-#&/@k]==n]&

Try it online!


C, 0.480298s
Codes

#ifndef LOCAL_DEBUG
#include <reg51.h>
sbit P3_5 = P3 ^ 5;
unsigned int code input[4096] _at_ 0xE000;
unsigned int pdata output[4] _at_ 0x00;
#else

#include <stdio.h>
#define int short

#define UNIQ1 17
#define UNIQ2 273
#define UNIQ3 1298
#define UNIQ4 1554

unsigned int input[4096] = {
UNIQ1,
UNIQ2,
UNIQ3,
UNIQ4
};
unsigned int output[4];

#endif

#define INPUT_SIZE 4096
#define BUCKET_BITS 4
#define BUCKET_SIZE (1 << (BUCKET_BITS))
#define BUCKET_MASK ((BUCKET_SIZE) - 1)

unsigned int buckets[BUCKET_SIZE];

#define buckets_value(n) (buckets[n] & ~(bucket_mask)) | ((n) << bit_offset)

void main() {
  unsigned int output_offset = 0;
  unsigned int i, j, k, l;
  unsigned int search_bucket = 0, search_bucket_2 = 0, bit_offset = 0, bit_offset_2, bucket_mask;
  unsigned int target_mask, target_value;
  do {
    bucket_mask = BUCKET_MASK << bit_offset;
    for (i = 0; i < BUCKET_SIZE; ++i) {
      buckets[i] = 0;
    }
    for (i = 0; i < INPUT_SIZE; ++i) {
      buckets[(input[i] >> bit_offset) & BUCKET_MASK] ^= input[i] | bucket_mask;
    }
    for (i = j = 0; i < BUCKET_SIZE; ++i) {
      if (buckets[i] != 0) ++j;
    }
    if (j <= 1) {
      bit_offset += BUCKET_BITS;
    }
  } while (j <= 1);
  if (j == 4) {
    for (i = 0; i < BUCKET_SIZE; ++i) {
      if (buckets[i] == 0) continue;
      output[output_offset++] = buckets_value(i);
    }
  } else if (j == 3) {
    for (i = 0; i < BUCKET_SIZE; ++i) {
      if (buckets[i] == 0) continue;
      if (buckets[i] & (BUCKET_MASK << bit_offset)) {
        output[output_offset++] = buckets_value(i);
      } else {
        search_bucket = i << bit_offset;
      }
    }
  } else if (j == 2) {
    for (i = k = 0; i < BUCKET_SIZE; ++i) {
      if (buckets[i] == 0) continue;
      if (buckets[i] & (BUCKET_MASK << bit_offset)) {
        l = buckets_value(i);
        if (k == 0) {
          for (j = 0; j < INPUT_SIZE; ++j) {
            if (input[j] == l) ++k;
          }
          if (k == 1) {
            output[output_offset++] = l;
          } else {
            search_bucket = i << bit_offset;
            k = 2;
          }
        } else if (k == 1) {
          search_bucket = i;
        } else {
          output[output_offset++] = l;
        }
      } else {
        if (search_bucket) {
          search_bucket_2 = i << bit_offset;
        } else {
          search_bucket = i << bit_offset;
        }
      }
    }
  }
  bit_offset_2 = bit_offset;
  target_mask = BUCKET_MASK << bit_offset;
  target_value = search_bucket;
  while (output_offset < 4) {
    bit_offset += BUCKET_BITS;
    bucket_mask = BUCKET_MASK << bit_offset;
    for (i = 0; i < BUCKET_SIZE; ++i) {
      buckets[i] = 0;
    }
    for (i = 0; i < INPUT_SIZE; ++i) {
      if ((input[i] & target_mask) != target_value) continue;
      buckets[(input[i] >> bit_offset) & BUCKET_MASK] ^= input[i] | bucket_mask;
    }
    for (i = j = 0; i < BUCKET_SIZE; ++i) {
      if (buckets[i] != 0) ++j;
    }
    if (j == 1) {
      continue;
    }
    for (i = 0; i < BUCKET_SIZE; ++i) {
      if (buckets[i] == 0) continue;
      if ((buckets[i] >> bit_offset) & BUCKET_MASK) {
        output[output_offset++] = buckets_value(i);
        --j;
      } else {
        target_mask |= bucket_mask;
        target_value |= i << bit_offset;
      }
    }
    if (j == 0) {
      bit_offset = bit_offset_2;
      target_mask = BUCKET_MASK << bit_offset;
      target_value = search_bucket_2;
    }
  }
#ifndef LOCAL_DEBUG
  P3_5 = 0;
  while (1);
#else
  for (i = 0; i < 4; i++) {
    printf("%d\n", output[i]);
  }
#endif
}

Try it online!
I'm not sure about its correctness. Please comment if you find out some failed testcases. I will try my best to fix it.

Algorithm
Algorithm here only works when input array contains 4 unique values. It will fail if input array contains more than 4 values.
Consider xor of some numbers where most numbers occurred 2 times, and some occurred once. It is easy to prove: The xor result is zero if and only if we have at least 3 unique numbers here. Also, we try to count how many numbers at all. It is trivial to know: If the count is even / odd, then we have even / odd number of unique numbers here.
As there are only 4 unique numbers according to the description of this question. If both xor result is zero and count result is even, there should be 0 or 4 unique numbers.
By using this idea, we need to split numbers into some buckets while keep equals number in same buckets. You can do it by (input[i] >> n) & m. So we first split all values input[i] into 16 buckets based on (input[i] >> 0) & 15. We use input[i] | bucket_mask to mask out the bits for bucket name. We set them to 1s, so they are used to know count number in that buckets is odd or even.
for (i = 0; i < INPUT_SIZE; ++i) {
  buckets[(input[i] >> bit_offset) & BUCKET_MASK] ^= input[i] | bucket_mask;
}

We use above code. And after calculate these buckets:

If buckets[i] & bucket_mask is non-zero: we know the bucket i contains 1 or 3 unique numbers (number count is odd).
If buckets[i] & bucket_mask is zero, but buckets[i] is non-zero: we know the bucket i contains 2 unique numbers.
If buckets[i] is zero, and some other bucket bucket[j] is non-zero: we know the bucket i contains no unique numbers.
If all buckets are zero: 4 unique numbers are located in the same bucket. We need to try another 4 bits as mask and run the loop again.

After we know where the number is in some bucket:

If the bucket contains only 1 unique numbers: the unique number is (buckets[i] & ~(bucket_mask)) | ((i) << bit_offset);
If the bucket contains more than 1 unique numbers: We loop again on numbers in this bucket, and split them into different buckets based on other bits;

Analysis
Time complexity is \$O\left(size \cdot bit  / buckets + 2^{buckets} \right)\$. \$size\$ is how many numbers the input contains. \$bit\$ is how many bits each input contains. \$bucket\$ is how many bits for bucket id (4 in above codes).
Extra storage complexity is \$O\left(2^{buckets}\right)\$.


Pyth - 70 68 bytes
K^T5J^T3W>KZ%." r3úBTêî¢¤;¥
í".D/KJ60=J?<OT3O^T4J=-KJ.d1.

Try it online without sleeps.


Python + NumPy, 3.95 Seconds

from __future__ import division
import numpy as np

def rolls(n):
    if n == 1:
        return 1
    r = n * (np.log(n) - np.log(np.log(2)))
    x = np.log1p(np.arange(n) / -n)
    cx = x.cumsum()
    y = cx[:-1] + cx[-2::-1] - cx[-1]
    while True:
        r0 = np.round(r)
        z = np.exp(y + r0 * x[1:])
        z[::2] *= -1
        r = r0 - (z.sum() + 0.5) / z.dot(x[1:])
        if abs(r - r0) < 0.75:
            return np.ceil(r).astype(int)

for n in [1, 2, 3, 4, 5, 6, 20, 52, 100, 366, 1000, 2000, 5000, 10000, 100000, 1000000]:
    print('R({}) = {}'.format(n, rolls(n)))

import timeit
print('Benchmark: {:.2f}s'.format(timeit.timeit(lambda: sum(map(rolls, range(1, 10001))), number=1)))

Try it online!

How it works

This uses the closed-form series for P(r, n), and its derivative with respect to r, rearranged for numerical stability and vectorization, to do a Newton’s method search for r such that P(r, n) = 0.5, rounding r to an integer before each step, until the step moves r by less than 3/4.  With a good initial guess, this usually takes just one or two iterations.

xi = log(1 − i/n) = log((n − i)/n)
cxi = log(n!/((n − i − 1)! ⋅ ni + 1)
yi = cxi + cxn − i − 2 − cxn − 1 = log binom(n, i + 1)
zi = (-1)i + 1 ⋅ binom(n, i + 1) ⋅ ((n − i − 1)/n)r
1 + ∑zi = n! ⋅ S(r, n)/nr = P(r, n)
zi ⋅ xi + 1 = (-1)i + 1 ⋅ binom(n, i + 1) ⋅ ((n − i − 1)/n)r log((n − i − 1)/n)
∑zi ⋅ xi + 1 = d/dr P(r, n)


Pyth, 3 bytes
!DQ

Explanation:
  Q    Input
!D     Sort by logical NOT

Try it here.


Python, 27 bytes

lambda n:0x82492cb6dbf>>n&1

Try it online!


Smallest palindrome divisible by the input

Haskell, 45 37 34 bytes
(+)>>=until((reverse>>=(==)).show)


Python, 91 84 64 chars

s=m=0
try:
 while 1:s=max(s+input(),0);m=max(m,s)
except:print m

Takes about 14 12 72 seconds on the last test case.  Edit: using algorithm Paul R found. Edit: nixed the import, using input().


Python, 29 bytes

lambda x,n:pow(x,2**n-1,2**n)

This returns 0 for even x. It uses Euler’s theorem, with the observation that 2^n − 1 is divisible by 2^(n − 1) − 1, via Python’s builtin fast modular exponentiation. This is plenty fast enough for n up to 7000 or so, where it starts taking more than about a second.


Python 3, 69 bytes

lambda a,b,*c:b[0].upper()+"@"+a[2:]+c[b[0]in"bcdfghjklmnpqrstvwxyz"]

Try it online!


Thorough though Thoreau threw, Troll throws through tough troughs

CJam, 11 9 7 bytes

q1b2+B%

How it works:

We are making use of the fact that the sum of the ASCII codes + 2 moded with 11 gives very nice order of 1 through 9 and then 10 for the nine concerned words. Here is the ordering:

through -> 1
thorough -> 2
tough -> 3
Thoreau -> 4
throw -> 5
threw -> 6
trough -> 7
though -> 8
troll -> 9

Code explanation:

q               e# Read the input
 1b             e# Sum the ASCII code values of all characters in this word
   2+           e# Increment the sum by 2
     B%         e# Mod by 11 and automatically print the mod result at the end

4 bytes saved thanks to user23013

Try it online here