Perl, 90 chars

$_++for@q{<>=~/./g};open E,"E";while(<E>){%p=%q;$.*=$p{$_}--for/./g;y///c>3&&$.&&print}

The program takes the list of letters as a line on standard input. The word list is referenced as a file in the current directory named "E". (Presumably this falls under the umbrella of "any way you wish".)

Some other assumptions I made that were not spelled out in the problem description:

that the goal was to produce a program (as opposed to a function);
that the input was case-sensitive;
that apostrophes and hyphens were not to be ignored;
that the program was required to not match on words in the word list that were too short.

Also, I wonder if the time limit given in the original description is necessary. Even when given a huge list of letters such that every word in "english.0" matches, my program still runs to completion in under 1s.


Trumpscript, 303 285 244 231 226 bytes

make i 1000005-1000000
as long as,i;:
make i,i - fact;
say "_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|"
say "___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__"!
America is great

I would like to say this is one of the most verbose languages where almost everything fails to compile into a working program.

Apparently whether - works instead of minus is completely up to the interpreter and sometimes works. This time it did so I'm putting it in as golfed.

Abuses the fact Trumpscript is written in Python and therefore fact when used as an integer is one.

Golfing tips welcome.


Jelly, 53 50 bytes

Ḋœṡ¥€⁶ZµḢVØ0jI>0ẋ"AƲị“
“
”żṪ“
“
”jⱮƊ

Try it online!

A monadic link taking a list of strings as input and outputting an HTML fragment with nested ordered lists. Should handle arbitrarily deep nesting of lists and return a syntactically valid HTML fragment.

Example:

H1 All About Birds
H2 Kinds of Birds
H3 The Finch
H3 The Swan
H2 Habitats
H3 Wetlands
H4 Types of wetlands
H5 Very wet wetland
H3 Coast
H1 All about fish
H2 Sharks

yields:

All About Birds

Kinds of Birds

The Finch

The Swan

Habitats

Wetlands

Types of wetlands

Very wet wetland

Coast

All about fish

Sharks

All About BirdsKinds of BirdsThe FinchThe SwanHabitatsWetlandsTypes of wetlandsVery wet wetlandCoastAll about fishSharks


Python 2, 250 bytes, n^log_2(3)

s=lambda a,b,S=1:[x+y*S for x,y in zip(a,b)]
def f(a,A):
 n=len(a);m=n/2
 if m<1:return[a[0]*A[0]]
 if n%2:return f([0]+a,[0]+A)[2:]
 b,c=a[:m],a[m:];B,C=A[:m],A[m:];p=f(b,B);r=f(c,C);z=m*[0];return s(z+z+r,s(z+s(f(s(b,c),s(B,C)),s(p,r),-1)+z,p+z+z))

This isn't well golfed, but more a proof of concept of the algorithm. Let's look at a more readable version.
s=lambda a,b,S=1:[x+y*S for x,y in zip(a,b)]

def f(a,A):
 n=len(a)
 if n==1:return[a[0]*A[0]]
 if n%2:return f([0]+a,[0]+A)[2:]
 m=n/2
 b,c=a[:m],a[m:]
 B,C=A[:m],A[m:]
 p=f(b,B)
 r=f(c,C)
 q=s(f(s(b,c),s(B,C)),s(p,r),-1)
 z=m*[0]
 return s(z+z+r,s(z+q+z,p+z+z))

The idea is to divide and conquer adapting the Karatsuba multiplication algorithm to do convolution. As before, it runs in time n^log_2(3), as it makes 3 recursive calls which shrink the input length in half. This isn't as good as the quasilinear of DFT, but still better than quadratic.
We can think of convolution as multiplication of formal polynomials. Alternatively, if multiplication were done without regrouping, you'd get convolution. So, adapting the algorithm only requires doing vector addition and subtraction instead of the numerical operations. These additions are still linear-time.
Unfortunately for Python, it doesn't have built-in vector addition and subtraction, so we hack together a function s to do both: addition by default, and subtraction when passed an optional argument of -1. Whenever we add, we make sure to pad with zeroes to avoid truncation.
We handle odd list lengths by padding with a zero to an even length, removing the extraneous zeroes that result.


Contest: fastest way to sort a big array of Gaussian-distributed data

Here is a solution in C++ which first partitions the numbers into buckets with same expected number of elements and then sorts each bucket separately. It precomputes a table of the cumulative distribution function based on some formulas from Wikipedia and then interpolates values from this table to get a fast approximation.

Several steps run in multiple threads to make use of the four cores.

#include <cstdlib>
#include <math.h>
#include <stdio.h>
#include <algorithm>

#include <tbb/parallel_for.h>

using namespace std;

typedef unsigned long long ull;

double signum(double x) {
    return (x<0) ? -1 : (x>0) ? 1 : 0;
}

const double fourOverPI = 4 / M_PI;

double erf(double x) {
    double a = 0.147;
    double x2 = x*x;
    double ax2 = a*x2;
    double f1 = -x2 * (fourOverPI + ax2) / (1 + ax2);
    double s1 = sqrt(1 - exp(f1));
    return signum(x) * s1;
}

const double sqrt2 = sqrt(2);

double cdf(double x) {
    return 0.5 + erf(x / sqrt2) / 2;
}

const int cdfTableSize = 200;
const double cdfTableLimit = 5;
double* computeCdfTable(int size) {
    double* res = new double[size];
    for (int i = 0; i < size; ++i) {
        res[i] = cdf(cdfTableLimit * i / (size - 1));
    }
    return res;
}
const double* const cdfTable = computeCdfTable(cdfTableSize);

double cdfApprox(double x) {
    bool negative = (x < 0);
    if (negative) x = -x;
    if (x > cdfTableLimit) return negative ? cdf(-x) : cdf(x);
    double p = (cdfTableSize - 1) * x / cdfTableLimit;
    int below = (int) p;
    if (p == below) return negative ? -cdfTable[below] : cdfTable[below];
    int above = below + 1;
    double ret = cdfTable[below] +
            (cdfTable[above] - cdfTable[below])*(p - below);
    return negative ? 1 - ret : ret;
}

void print(const double* arr, int len) {
    for (int i = 0; i < len; ++i) {
        printf("%e; ", arr[i]);
    }
    puts("");
}

void print(const int* arr, int len) {
    for (int i = 0; i < len; ++i) {
        printf("%d; ", arr[i]);
    }
    puts("");
}

void fillBuckets(int N, int bucketCount,
        double* data, int* partitions,
        double* buckets, int* offsets) {
    for (int i = 0; i < N; ++i) {
        ++offsets[partitions[i]];
    }

    int offset = 0;
    for (int i = 0; i < bucketCount; ++i) {
        int t = offsets[i];
        offsets[i] = offset;
        offset += t;
    }
    offsets[bucketCount] = N;

    int next[bucketCount];
    memset(next, 0, sizeof(next));
    for (int i = 0; i < N; ++i) {
        int p = partitions[i];
        int j = offsets[p] + next[p];
        ++next[p];
        buckets[j] = data[i];
    }
}

class Sorter {
public:
    Sorter(double* data, int* offsets) {
        this->data = data;
        this->offsets = offsets;
    }

    static void radixSort(double* arr, int len) {
        ull* encoded = (ull*)arr;
        for (int i = 0; i < len; ++i) {
            ull n = encoded[i];
            if (n & signBit) {
                n ^= allBits;
            } else {
                n ^= signBit;
            }
            encoded[i] = n;
        }

        const int step = 11;
        const ull mask = (1ull << step) - 1;
        int offsets[8][1ull << step];
        memset(offsets, 0, sizeof(offsets));

        for (int i = 0; i < len; ++i) {
            for (int b = 0, j = 0; b < 64; b += step, ++j) {
                int p = (encoded[i] >> b) & mask;
                ++offsets[j][p];
            }
        }

        int sum[8] = {0};
        for (int i = 0; i <= mask; i++) {
            for (int b = 0, j = 0; b < 64; b += step, ++j) {
                int t = sum[j] + offsets[j][i];
                offsets[j][i] = sum[j];
                sum[j] = t;
            }
        }

        ull* copy = new ull[len];
        ull* current = encoded;
        for (int b = 0, j = 0; b < 64; b += step, ++j) {
            for (int i = 0; i < len; ++i) {
                int p = (current[i] >> b) & mask;
                copy[offsets[j][p]] = current[i];
                ++offsets[j][p];
            }

            ull* t = copy;
            copy = current;
            current = t;
        }

        if (current != encoded) {
            for (int i = 0; i < len; ++i) {
                encoded[i] = current[i];
            }
        }

        for (int i = 0; i < len; ++i) {
            ull n = encoded[i];
            if (n & signBit) {
                n ^= signBit;
            } else {
                n ^= allBits;
            }
            encoded[i] = n;
        }
    }

    void operator() (tbb::blocked_range<int>& range) const {
        for (int i = range.begin(); i < range.end(); ++i) {
            double* begin = &data[offsets[i]];
            double* end = &data[offsets[i+1]];
            //std::sort(begin, end);
            radixSort(begin, end-begin);
        }
    }

private:
    double* data;
    int* offsets;
    static const ull signBit = 1ull << 63;
    static const ull allBits = ~0ull;
};

void sortBuckets(int bucketCount, double* data, int* offsets) {
    Sorter sorter(data, offsets);
    tbb::blocked_range<int> range(0, bucketCount);
    tbb::parallel_for(range, sorter);
    //sorter(range);
}

class Partitioner {
public:
    Partitioner(int bucketCount, double* data, int* partitions) {
        this->data = data;
        this->partitions = partitions;
        this->bucketCount = bucketCount;
    }

    void operator() (tbb::blocked_range<int>& range) const {
        for (int i = range.begin(); i < range.end(); ++i) {
            double d = data[i];
            int p = (int) (cdfApprox(d) * bucketCount);
            partitions[i] = p;
        }
    }

private:
    double* data;
    int* partitions;
    int bucketCount;
};

const int bucketCount = 512;
int offsets[bucketCount + 1];

int main(int argc, char** argv) {
    if (argc != 2) {
        printf("Usage: %s N\n N = the size of the input\n", argv[0]);
        return 1;
    }

    puts("initializing...");
    int N = atoi(argv[1]);
    double* data = new double[N];
    double* buckets = new double[N];
    memset(offsets, 0, sizeof(offsets));
    int* partitions = new int[N];

    puts("loading data...");
    FILE* fp = fopen("gaussian.dat", "rb");
    if (fp == 0 || fread(data, sizeof(*data), N, fp) != N) {
        puts("Error reading data");
        return 1;
    }
    //print(data, N);

    puts("assigning partitions...");
    tbb::parallel_for(tbb::blocked_range<int>(0, N),
            Partitioner(bucketCount, data, partitions));

    puts("filling buckets...");
    fillBuckets(N, bucketCount, data, partitions, buckets, offsets);
    data = buckets;

    puts("sorting buckets...");
    sortBuckets(bucketCount, data, offsets);

    puts("done.");

    /*
    for (int i = 0; i < N-1; ++i) {
        if (data[i] > data[i+1]) {
            printf("error at %d: %e > %e\n", i, data[i], data[i+1]);
        }
    }
    */

    //print(data, N);

    return 0;
}

To compile and run it, use this command:

g++ -O3 -ltbb -o gsort gsort.cpp && time ./gsort 50000000

EDIT: All buckets are now placed into the same array to remove the need to copy the buckets back into the array. Also the size of the table with precomputed values was reduced, because the values are accurate enough. Still, if I change the number of buckets above 256, the program takes longer to run than with that number of buckets.

EDIT: The same algorithm, different programming language. I used C++ instead of Java and the running time reduced from ~3.2s to ~2.35s on my machine. The optimal number of buckets is still around 256 (again, on my computer).

By the way, tbb really is awesome.

EDIT: I was inspired by Alexandru's great solution and replaced the std::sort in the last phase by a modified version of his radix sort. I did use a different method to deal with the positive/negative numbers, even though it needs more passes through the array. I also decided to sort the array exactly and remove the insertion sort. I will later spend some time testing how do these changes influence performance and possibly revert them. However, by using radix sort, the time decreased from ~2.35s to ~1.63s.


Test if a string is parenthesly balanced

Japt v2, 20 bytes

V="()"V¥iU1 eViV²1 V

Test it online!

Everyone misunderstood the challenge at first and though that each pair of parentheses had to contain an even number of sub-pairs, when in fact the challenge actually asks for 0 or 2 sub-pairs. So here's my revised answer, using the same technique as before.

We can still solve the challenge with recursive replacement. The thing is, instead of just removing all occurrences of ()(), we need to make sure that there's nothing else in the same wrapper besides the ()() (in other words, no ()()()() or anything like that). We can do this by recursively replacing (()()) with ().

The new problem is that the input itself does not have one pair of outer parentheses (as that would make it not a parenthesly balanced string), forcing us to wrap it in an extra pair to fully reduce it. Finally, the end result for balanced strings is now () instead of the empty string, so we check for equality rather than just taking logical NOT of the output.


R, 119 110 108 105 100 bytes
Edit: -2 bytes thanks to Giuseppe

n=scan();repeat for(b in -(F=-F+!(F>0)):F)for(i in (d=-(c=F^n+b^n):c)[abs(d^n-c)==1])cat(F,b,i,'\n')

Try it online!
Prints the infinite list of near-misses, without duplicates (this includes duplicates by re-ordering a and b, so the triples (a,b,c) and (b,a,c) are considered duplicates: add an extra ,b,F,i,'\n' (11 bytes) to print the list with duplicates).
Wastes a few bytes avoiding taking nth-roots, to prevent floating-point errors.
How?
function(n){
                            # note: F (false), which represents variable a, is initialized to zero;
repeat{                     # repeat for ever:
 for(b in -F:F){            # try all possible values of b from -a to a,
  c=F^n+b^n                 # calculate c as a^n+b^n,
  c=(-c:c)                  # now find value in the range -c to c
  [(-c:c)^n%in%(c+c(1,-1))] # that gives either c+1 or c-1 when raised to the n-th power
                            # replace c with this value (if there is one),
  for(i in c)               # now, if there were any:
   print(c(F,b,i))}         # print out the a,b,c combination
 F=-F+!(F>0)}}              # update F to the next value of variable a, in the sequence:
                            # 0, 1, -1, 2, -2, 3, -3 ... and so on


Python 3, 195 189 bytes

-6 bytes thanks to @Jo King

lambda m:sum({16:1,257:2,68:2,273:3,84:3,325:4,341:5,455:6,365:6}.get(int(''.join(str(e)for c in m[3*i:][:3]for e in c[3*j:][:3]),2),0)for i in range(len(m)//3)for j in range(len(m[0])//3))

Try it online! (189)
Try it online! (195)

Human readable version:

# 3x3 part matrix to dice, beginning at coordinates 3*i, 3*j
def single_matrix_to_dice(matrix, i, j):
    # Example: matrix = [[0, 0, 0], [0, 1, 0], [0, 0, 0]], i=0, j=0 (result is 1)

    matrix_string = ''.join(
        str(e) for column in matrix[3*i:3*i+3]
        for entry in column[3*j:3*j+3]
    ) # Slicing the matrix so that only the valid entries remain, here '000010000'

    # Interpreting the matrix string as binary number, here 16
    binary_number = int(matrix_string,2)

    # binary representations of all valid dice rolls
    dct = {16:1,257:2,68:2,273:3,84:3,325:4,341:5,455:6,365:6}

    return dct.get(binary_number, 0)

def f(matrix):
    return sum(
        single_matrix_to_dice(matrix, i, j) for i in range(len(m)//3)
        for j in range(len(m[0])//3))
    ) # len(m)/3 would generate a float, so len(m)//3 is used


ed, 3 bytes

Note: Most of the answers here are ignoring the trailing newline printed as part of the error message in their count.  But I don’t see anything in the question to justify ignoring it, and the author commented that the newline should be included.  So unless the question is changed, I’m going to include it.

Code (with trailing newline):

??

Error (with trailing newline):

?


Python 3, 86 * 0.9 = 77.4 bytes

s=input()
N=int(s.split('H')[1])
print("2%s + %dO2 > %dH20 + %dCO2"%(s,N*1.5-2,N,N-2))

Extracts the number of H's rather than the number of C's from the input. This avoid special-casing CH4 and simplifies the output expressions in terms of N=2n+2.

The output has parameters plugged in via string formatting. The first summand is just the input string, and the rest have calculated numbers plugged in. Note that N*1.5-2 (same as N*3/2-2) gives a float, but the string formatting converts it to an int.


Vitsy, 50 bytes

I don't think I'm done golfing yet!

VVHr1mV{V2*1+\[2m]
:Xru
v&VvD([D\[' 'O]]-H1ml\NaOY

Explanation:

VVHr1mV{V2*1+\[2m]
V                  Pop n, set n as the global final variable (GFV).
 V                 Push the GFV to the current stack.
  H                Pop n, pop o, push each item of the range from o to n.
   r               Reverse the current program stack.
    1m             Call the method on line index 1.
      V{           Push the GFV to the bottom of the current stack.
        V2*1+      Push the GFV*2+1 to the stack.
             \[  ] Pop n, do the stuff in brackets n times.
               2m  Call the method on line index 2. Note that this is necessary due
                   to an unknown bug.

:Xru
:                  Clone the current stack, pushing a second stack to the stack
                   stack and jumping to it.
 X                 Pop n and discard.
  r                Reverse the current stack.
   u               Pop the current stack and concatenate it to the previous.

v&VvD([D\[' 'O]]-H1ml\NaOY
v                  Pop n, save as a temporary variable.
 &                 Push a new stack to the stack stack and jump to it.
  V                Push the GFV.
   v               Push the temp var, clear the temp var memory.
    D([        ]   If the top item is not zero, do the stuff in brackets.
                   This is necessary as all loops always apply once.
       D\[' 'O]    Peek n, output n spaces.
   -               Pop n, pop o, push o-n.
    H              Pop n, pop o, push each item of the range from o to n.
     1m            Call the method at line index 1.
       l\N         Output all numbers in this stack.
          aO       Output a newline.
            Y      Pop and discard the current stack from the stack stack.

Try it online!


Jelly, 7 bytes

fċ@ÐṂ;Ṁ

Try it online!

How it works

fċ@ÐṂ;Ṁ  Main link. Left argument: A. Right argument: B

f        Filter; keep those elements of A that appear in B.
   ÐṂ    Yield all elements of the result for which the link to left yields a
         minimal value (2).
 ċ@        Count the occurrences of the element...
     ;     in the concatenation of A and B.
      Ṁ  Take the maximum.


Using two linked programs, output ordinal numbers up to n

Sledgehammer 0.5.1 / Sledgehammer 0.5.1, 10 bytes

Program 1 (10 bytes):

⣘⢷⠾⣃⢖⣎⢅⡨⠱⢳

Decompresses into this Wolfram Language function:

{Range[#1], "Ordinal"} &

Program 2 (7 bytes):

⡾⡁⢚⣷⣬⠤⣾

Decompresses into this Wolfram Language function:

StringRiffle[IntegerName @@ #1, " "] &

Try it online!


Python 3, 130 bytes

lambda w,d={'QAZWSXEDCRFVTGBYHNUJMIKOOLPP'[i]:i%3*1j+i/3for i in range(28)}:min(d,key=lambda c:abs(d[c]-sum(map(d.get,w))/len(w)))

Try it online!

d={'QAZWSXEDCRFVTGBYHNUJMIKOOLPP'[i]:i%3*1j+i/3for i in range(28)} constructs the mapping from letters to points (represented as complex numbers, (x+y*1j)).

As for the lambda body, sum(map(d.get,w))/len(w) computes the average position of word w, and putting that in min(d,key=lambda c:abs(d[c]-…)) finds the closest letter to that position. (For complex numbers, abs(A-B) corresponds to the Euclidean distance between (A.real, A.imag) and (B.real, B.imag).)


Haskell, 35
0%n=1+n
m%n=iterate((m-1)%)1!!(n+1)

this defines the operator function %.
this works by noticing that m%n (where a is the ackerman function) for nonzero m is (m-1)% applied n+1 times to 1. for example, 3%2 is defined as 2%(3%1) which is 2%(2%(3%0)), and this is 2%(2%(2%1))


Convert radicals to mixed & entire radicals and to real numbers

C (314)

n,d;main(i){scanf("%d %d",&n,&d);int val[d];for(;pow(i,n)<=d;i++)val[i]=pow(i,n);printf("Entire radical: %drt(%d)\n",n,d);for(i--;i>0;i--)if(d%val[i]==0){printf("Mixed radical: %d*%drt(%d)\n",i,n,d/val[i]);break;}double v,x=1.5,a=d;do{v=(a/pow(x,n-1)-x)/n;x+=v;}while(abs(v)>=1E-9);printf("Real number: %lf\n",x);}

Here it is with whitespace.

n,d;
main(i){
    scanf("%d %d",&n,&d);
    int val[d];

    for(;pow(i,n)<=d;i++)
        val[i]=pow(i,n);

    printf("Entire Radical: %d*rt(%d)\n",n,d);

    for (i--;i>0;i--)
        if (d%val[i]==0){
            printf("Mixed Radical: %d*%drt(%d)\n", i, n, d/val[i]);
            break;}

    double v,x=1.5,a=d;
    do{
        v=(a/pow(x,n-1)-x)/n;
        x+=v;
    }while(abs(v)>=1E-9);

    printf("Real number: %lf\n", x);
}

Input:

2 125

Output:

Entire radical: 2rt(125)
Mixed radical: 5*2rt(5)
Real number: 11.180340

Input:

3 125

Output:

Entire radical: 3rt(125)
Mixed radical: 5*3rt(1)
Real number: 5.000000

This isn't perfect, the root calculation will not work for all input values, and the chosen guess value is not random. It takes the whole value of the radical as input (see above).


Python 2, 106 bytes (94 chars)
n=input();j=1
exec"s=j/2*'║';print s+'╔'+'═'*(2*n-j)+'╗'+s;j+=2;"*n
if n:t='╨'*n;print t+'─'+t

Pretty straightforward. Prints line by line with a changing number of horizontal and vertical bars. The last line is printed separately.
I feel like I'm missing some optimizations. The fact that the chars are multiple bytes means you can't do something like '║╨'[n>0], so I didn't find a good way to print the last line in the loop. It's ugly that there's so much manipulation going on with the counter. I'd like update strings directly, like s+='║', but the index is also used for horizontal bars.


Mathematica, 126 121 chars
Thanks to belisarius.
Using the formula on wikipedia.
f=(i=j=1;While[j<#,If[And@@Thread[#[[;;,1]]<2+Most@DivisorSum[FoldList[#Power@@#2&,1,#],#&]&@FactorInteger@++i],j++]];i)&

Examples:
f[1]

1

f[8]

18

f[250000]

2764000

It took 70s to compute f[250000] on my computer.


Solving Three Open Problems with a Halting Oracle

Haskell, 242
p n=and[rem n r>0|r<-[2..n-1]]
c 1=1
c n|odd n=c$3*n+1|0<1=c$div n 2
s!f=putStr(s++" Conjecture is ")>>print(not$h2$all(h1.f)[4..])
main=do"The Collatz"!c;"Goldbach's"! \n->or[p$n-r|r<-[2..n-2],p r];"The Twin Primes"! \n->or[p$r+2|r<-[n..],p r]

because in Haskell variables can contain not only values, but computations (this is called laziness) I let myself make h1, h2 take a single argument and return weather or not it's evaluation will halt.
somewhat ungolfed code:
h1 = undefined
h2 = undefined

prime n=and[rem n r>0|r<-[2..n-1]]
collatz 1=1
collatz n
    |odd n=collatz (3*n+1)
    |0<1  =collatz (div n 2)

s!f=do
    putStr (s++" Conjecture is ")
    print$not$h2$all(h1.f)[4..]

main=do
    "The Collatz"!c                                         --collatz
    "Goldbach's"! \n->or[prime (n-r)|r<-[2..n-2],prime r]   --goldbach
    "The Twin Primes"! \n->or[prime (r+2)|r<-[n..],prime r] --twin primes

a bit of explanation:
when all is applied to an infinite list, it will halt iff one of the elements of the list is False, due to laziness (short-circuiting, for all non-Haskell folks out there). we use this to compute the collatz conjecture and the twin primes conjecture.
! packages this trickery along with printing.
the result is True when f terminates on all the numbers 4... (this doesn't matter for the collatz conjecture or the twin primes conjecture, because we already know they are true for such small numbers).
the code for the collatz conjecture is "The Collatz"!c. it prints "The Collatz Conjecture is " and the result, which is weather c terminates on all numbers 4...
the code for the goldbach conjecture is "Goldbach's"! \n->or[p$n-r|r<-[2..n-2],p r].
\n->or[p$n-r|r<-[2..],p r,r<n+1] is a function which given n, if it is a sum of two primes, returns True, but otherwise loops indefinitely. thus, if it halts for every 4.. goldbach's conjecture is true.
the code for the twin primes conjecture is "The Twin Primes"! \n->or[p$r+2|r<-[n..],p r].
\n->or[p$r+2|r<-[n..],p r] is a function which given n, if there are twin primes greater than n, returns True, but otherwise loops indefinitely. thus, if it halts for every 4.. the twin prime conjecture is true.


Identify the smallest possible tile in the matrix

JavaScript (ES6),  354 352 345  342 bytes
I/O: matrix of integers.
This is quite long but pretty fast -- at least with those test cases.

m=>m[b=P='map']((r,h)=>r[P]((_,w)=>(M=m.slice(~h)[P](r=>r.slice(~w)),a=~w*~h,g=(x,y,F)=>a>b|q.some((r,Y)=>r.some((v,X)=>~v?v^m[Y][X]:![x=X,y=Y]))?0:1/y?[...P+0][P](z=>(F=k=>!M[P]((r,Y)=>r[P]((v,X)=>k^1?q[y-Y][x-X]=v|k:(z|=~(q[y-X]||0)[x-Y],T[X]=T[X]||[])[Y]=v),T=[]))(1)&T.reverse(M=T)|z||g(F())|F(-1)):(o=M,b=a))(q=m[P](r=>r[P](_=>-1)))))&&o

Try it online!
How?
Whatever the tiling is, it is guaranteed that each corner of the matrix is also a corner of the tile that we're looking for. The two outer map() loops extract each possible tile \$M\$ from the bottom-right side of the input matrix \$m\$ and compute its area \$a\$.
m.map((r, h) =>           // for each row r[] at position h in m[]:
  r.map((_, w) =>         //   for each value at position w in r[]:
    (                     //
      M =                 //     build M[]:
        m.slice(~h)       //       keep the last h + 1 rows of m[]
        .map(r =>         //       for each of them:
          r.slice(~w)     //         keep the last w + 1 columns
        ),                //
      a = ~w * ~h,        //     area = (w + 1) * (h + 1)
      ...                 //     attempt to do a tiling with M
    )                     //
  )                       //   end of map()
)                         // end of map()

We build a matrix \$q\$ with the same dimensions as \$m\$, initially filled with \$-1\$.
q = m.map(r => r.map(_ => -1))

At each iteration of the recursive function \$g\$, we look for the position \$(x,y)\$ of the last cell in \$q\$ still set to \$-1\$, going from left to right and from top to bottom.
By definition, this cell has either a cell already set or a border on its right, and ditto below it. So it must be the bottom-right corner of a new tile, such as the cell marked with an 'x' below:

Simultaneously, we test whether there's a cell in \$q\$ whose value is not \$-1\$ and is different from the value in \$m\$ at the same position. If such a tile is found, we abort the recursion.
q.some((r, Y) =>          // for each row r[] at position Y in q[]:
  r.some((v, X) =>        //   for each value v at position X in r[]:
    ~v ?                  //     if v is not equal to -1:
      v ^ m[Y][X]         //       abort if v is not equal to M[Y][X]
    :                     //     else:
      ![x = X, y = Y]     //       set (x, y) = (X, Y)
  )                       //   end of some()
)                         // end of some()

If all cells of \$q\$ are matching the cells of \$m\$ and the area of \$M\$ is less than (or equal to) the best area found so far, we update the output \$o\$ to \$M\$.
Otherwise, we invoke the following code 4 times:
F(1) & T.reverse(M = T) | z || g(F()) | F(-1)

The behavior of the helper function \$F\$ depends on the parameter \$k\$:

If \$k=1\$, it computes the transpose \$T\$ of \$M\$ and checks whether all cells in \$q\$ between \$(x-w,y-h)\$ and \$(x,y)\$ are set to \$-1\$. The result of this test is saved in \$z\$.
If \$k\$ is undefined, it copies the content of \$M\$ to \$q\$ at \$(x-w,y-h)\$.
If \$k=-1\$, it cancels the previous operation by restoring all updated values to \$-1\$.

It is defined as follows:
F = k =>                  // k = parameter
  !M.map((r, Y) =>        // for each row r[] at position Y in M[]:
    r.map((v, X) =>       //   for each value v at position X in r[]:
      k ^ 1 ?             //     if k is not equal to 1:
        q[y - Y][x - X] = //       set q[y - Y][x - X]
          v | k           //       to v if k is undefined, or -1 if k = -1
      :                   //     else:
        ( z |=            //       update z:
            ~( q[y - X]   //         read q at (x - Y, y - X)
              || 0        //
            )[x - Y],     //         set z if it's not equal to -1
          T[X] =          //       compute T by writing v at the
            T[X] || []    //       relevant position
        )[Y] = v          //
    ),                    //   end of inner map()
    T = []                //   initialize T to an empty array
  )                       // end of outer map()

Therefore, the code block mentioned above can be interpreted as follows:
F(1)                      // compute the transpose T[] of M[] and test whether
&                         // M[] can be copied at (x-w, y-h) in q[]
T.reverse(M = T)          // reverse T[] and assign it to M[], which means
|                         // that M[] has been rotated 90° counterclockwise
z ||                      // if z = 0:
  g(F()) |                //   copy M[] to q[] and do a recursive call
  F(-1)                   //   restore q[] to its previous state


Python 2, 26 bytes
lambda n:2*n-3*(4**n/3&n/2)

Bit tricks!
Say n has form ...ghfedcba in binary. Then, we can split it into every other bit as
n   = o + 2*e
n   = ...hgfedcba
o   = ...0g0e0c0a
2*e = ...h0f0d0b0

Then, the bit-switched result s can be expressed as s=2*o+e.
s   = 2*o + e
s   = ...ghefcdab
2*o = ...g0e0c0a0
e   = ...0h0f0d0b

We'd rather compute only one of e and o, so we express o=n-2*e and substitute
s=2*(n-2*e)+e = 2*n-3*e

So, now it remains to express e in terms of n. The number M=4**n/3 has form ...10101010101 in binary, which serves as a mask for the odd digits. The exponent n ensures that M is long enough. Taking the bitwise and of n/2 and this value gives e as desired.
n/2     = ...hgfedcb
M       = ...1010101
n/2 & M = ...h0f0d0b = e

We can instead express e in terms of o e=(n-o)/2, which gives s=(n+o*3)/2, which saves a byte thanks to an optimization from xsot.
lambda n:n+(n&4**n/3)*3>>1


R, 33 bytes

function(n,k)prod(seq(n+!n,1,-k))

Try it online!

Handles \$n=0\$ by adding the logical negation of \$n\$.


05AB1E, 19 bytes

Uses CP-1252 encoding.

nžs¦¦¹ôI£íRvyN>£J}R

Try it online!

Explanation

n=5, y=3 used for example

nžs                  # push pi to n^2 digits
                     # STACK: 3.1415926535897932384626433
   ¦¦                # remove the first 2 chars
                     # STACK: 1415926535897932384626433
     ¹ô              # split into n*n matrix
                     # STACK: ['14159', '26535', '89793', '23846', '26433']
       I£            # keep the first y rows
                     # STACK: ['14159', '26535', '89793']
         íR          # reverse the list of rows and each individual row
                     # STACK: ['39798', '53562', '95141']
           v     }   # for each y,N (row, index) in the list
            yN>£J    # keep the first index+1 digits of the row and join to string
                     # STACK: 353951
                  R  # reverse the string
                     # STACK: 159353
                     # implicit print


Generate the fewest lottery tickets to play in order to have at least N good numbers

I know it's not optimal, but here is the code in node.js:

function min_lottery_tickets(total_numbers_to_choose_from, how_many_numbers_to_choose, how_many_good_numbers_i_want) {
    c(function(result) {
        var other = result[result.length - 1];
        while (result.length < how_many_numbers_to_choose) {
            other++;
            var already = false;
            for (var i = 0; i < result.length; i++) {
                if (other === result[i]) {
                    already = true;
                    break;
                }
            }
            if (!already) {
                result.push(other);
            }
        }
        if (other <= total_numbers_to_choose_from) {
            // Print results
            console.log(result);
        }
    }, total_numbers_to_choose_from, how_many_good_numbers_i_want);
}

function c(next, total_numbers, length, start, results) {
    if (!start) start = 1;
    if (!results) results = [];

    for (var i = start; i <= total_numbers + 1 - length; i++) {
        var resultsNew = results.slice(0);
        resultsNew.push(i);
        if (length > 1) {
            c(next, total_numbers, length - 1, i + 1, resultsNew);
        } else {
            next(resultsNew);
        }
    }
}

Some example results:

> min_lottery_tickets(5, 3, 2)
[ 1, 2, 3 ]
[ 1, 3, 4 ]
[ 1, 4, 5 ]
[ 2, 3, 4 ]
[ 2, 4, 5 ]
[ 3, 4, 5 ]

other:

> min_lottery_tickets(10, 5, 2)
[ 1, 2, 3, 4, 5 ]
[ 1, 3, 4, 5, 6 ]
[ 1, 4, 5, 6, 7 ]
[ 1, 5, 6, 7, 8 ]
[ 1, 6, 7, 8, 9 ]
[ 1, 7, 8, 9, 10 ]
[ 2, 3, 4, 5, 6 ]
[ 2, 4, 5, 6, 7 ]
[ 2, 5, 6, 7, 8 ]
[ 2, 6, 7, 8, 9 ]
[ 2, 7, 8, 9, 10 ]
[ 3, 4, 5, 6, 7 ]
[ 3, 5, 6, 7, 8 ]
[ 3, 6, 7, 8, 9 ]
[ 3, 7, 8, 9, 10 ]
[ 4, 5, 6, 7, 8 ]
[ 4, 6, 7, 8, 9 ]
[ 4, 7, 8, 9, 10 ]
[ 5, 6, 7, 8, 9 ]
[ 5, 7, 8, 9, 10 ]
[ 6, 7, 8, 9, 10 ]

other:

> min_lottery_tickets(10, 5, 3)
[ 1, 2, 3, 4, 5 ]
[ 1, 2, 4, 5, 6 ]
[ 1, 2, 5, 6, 7 ]
[ 1, 2, 6, 7, 8 ]
[ 1, 2, 7, 8, 9 ]
[ 1, 2, 8, 9, 10 ]
[ 1, 3, 4, 5, 6 ]
[ 1, 3, 5, 6, 7 ]
[ 1, 3, 6, 7, 8 ]
[ 1, 3, 7, 8, 9 ]
[ 1, 3, 8, 9, 10 ]
[ 1, 4, 5, 6, 7 ]
[ 1, 4, 6, 7, 8 ]
[ 1, 4, 7, 8, 9 ]
[ 1, 4, 8, 9, 10 ]
[ 1, 5, 6, 7, 8 ]
[ 1, 5, 7, 8, 9 ]
[ 1, 5, 8, 9, 10 ]
[ 1, 6, 7, 8, 9 ]
[ 1, 6, 8, 9, 10 ]
[ 1, 7, 8, 9, 10 ]
[ 2, 3, 4, 5, 6 ]
[ 2, 3, 5, 6, 7 ]
[ 2, 3, 6, 7, 8 ]
[ 2, 3, 7, 8, 9 ]
[ 2, 3, 8, 9, 10 ]
[ 2, 4, 5, 6, 7 ]
[ 2, 4, 6, 7, 8 ]
[ 2, 4, 7, 8, 9 ]
[ 2, 4, 8, 9, 10 ]
[ 2, 5, 6, 7, 8 ]
[ 2, 5, 7, 8, 9 ]
[ 2, 5, 8, 9, 10 ]
[ 2, 6, 7, 8, 9 ]
[ 2, 6, 8, 9, 10 ]
[ 2, 7, 8, 9, 10 ]
[ 3, 4, 5, 6, 7 ]
[ 3, 4, 6, 7, 8 ]
[ 3, 4, 7, 8, 9 ]
[ 3, 4, 8, 9, 10 ]
[ 3, 5, 6, 7, 8 ]
[ 3, 5, 7, 8, 9 ]
[ 3, 5, 8, 9, 10 ]
[ 3, 6, 7, 8, 9 ]
[ 3, 6, 8, 9, 10 ]
[ 3, 7, 8, 9, 10 ]
[ 4, 5, 6, 7, 8 ]
[ 4, 5, 7, 8, 9 ]
[ 4, 5, 8, 9, 10 ]
[ 4, 6, 7, 8, 9 ]
[ 4, 6, 8, 9, 10 ]
[ 4, 7, 8, 9, 10 ]
[ 5, 6, 7, 8, 9 ]
[ 5, 6, 8, 9, 10 ]
[ 5, 7, 8, 9, 10 ]
[ 6, 7, 8, 9, 10 ]


JavaScript (ES6), 195 245 231 242 246 250
Edit4 Now, a single recursive function. Probably can't be golfed more
Edit3 Test for straight line and test for arrowhead merged in T function, S  and H functions removed.
Edit2 Revised and longer :( after this this clarification
Edit Small improvements, cutting some char here and there, waiting for CJammers to step in
Test running the snippet below in an EcmaScript 6 compliant browser. (works on Firefox. Chrome still missing the spread operator ...)

f=(s,p=s[I='indexOf']`S`,w=m=[o=~s[I]`
`,1,-o,-1],q,v,r)=>m.some((d,i)=>{for(v=w,q=p;r=s[q+=d],r=='|-'[i&1];)v='+';return r=r==v?f(s,q,v):/\w/.test(r=s[q+m['^>V<'[I](r)]])&&r},s=[...s],s[p]=0)&&r

// Less golfed
// U: recursive scan function
U = (s, // input string or array
     p = s.indexOf`S`, // current position, defult to position of S into string (at first call)
     w = // char to compare looking for a '+', at first call default to garbage as you can't follow '+' near 'S'
       m = [// m, global, offset array form movements.
         o = ~s.indexOf`\n`, // o, global, row line +1 (negated)
         1, -o, -1], // complete the values of m array
     // m and o are assigned again and again at each recursive call, but that is harmless
     // params working as local variables as the function is recursive
     q,v,r) =>
{
   s = [...s]; //convert to array, as I have to modify it while scanning
     //the conversion is done again and again at each recursive call, but that is harmless
   s[p] = 0; // make s[p] invalid to avoid bouncing back and forth

   m.some( // for each direction, stop if endpoint found
      (d,i ) => {
        q = p; // start at current position, then will add the offset relative to current direction
        v = w; // for each direction, assign the starting value that can be '+' or garbage at first call
        // compare char at next position with the expected char based on direction (- for horiz, | for vertical)
        // in m array, values at even positon are vertical movements, odds are horizontal
        while (s[q+=d] == '|-'[i&1]) // while straight direction, follow it until it ends
          v = '+'; // from now on '+' is allowed
        r = s[q];
        if (r == v) // check if found a '+'
          r = U(s, q, v) // recursive call to check all directions from current position
        else
        {
          r = s[q + m['^>V<'.indexOf(r)]], // pointed char in p (if arrowhead, else will return undefined)
          r = /\w/.test(r) && r // if alphanumeric, then we found our result - else r = false
        }
        return r; // returning r to .some; if r is truthy, the .some function will stop
      }
   )
   return r; // result if found, else undefined or null
}

// TEST
out=x=>O.innerHTML+=x.replace(/</g,'&#60;')+'\n'

// Using explicit newlines '\n' to ensure the padding to a rectangle
;[
 ['z<+S-+->a','a']
,['a<-+S>b','b']
,['S-+\n  |\n  V\n  a','a']
,['a S      s\n  |      |\n  V      V\n  b      c  ','b']
,['S-----+  \n|     +-^  \n+---+->B \n    +---^','B']
,['d s<+S+--V\n    |||  Q\n    -++    ','Q']
,['d s-+   +-S  +--+\n    +-->b |  |  |\n     |  | +--+  |\n     +--+ A<----+  ','A']
,['S-----+   \n|     +-^ \n+---+->B  \n    +---^ ','B']
].forEach(t=>{
  r=f(t[0])
  k=t[1]
  out('Test '+(r==k?'OK':'Fail')+'\n'+t[0]+'\nResult: '+ r +'\nCheck: '+k+'\n')
})


Commodore 64 BASIC

Writing directly in the screen and color memory.

Output:

Here's how you do this with sprites.


The Top Ten Elements You Won't BELIEVE Are In This Array

Jelly, 142 bytes

I>-ṣ0ṖS€ỊÐḟ‘ɓĠL€ḟ1,ɓ¹ƝÆPẠ$ÐfW;ɓLẋ<¥21W;ż@€"“æƥu®ụ³Km&|°ẓz“ṿ$¥{d3ɓFȤSJẎVḍnṃ*¹0Ḟ¬ȤɲƝċƲạB'ɼɓ.€⁺Ƒ“¢ßUṡʠx\~⁻ḅėʠAƓḳ¶e<“½ė!Ƙ¥Ḍ3]⁷ṀƭȮþċ⁽?ṫĠƁÆȦØ⁾Ż»ṣ€⁷¤

A monadic link accepting a list of integers, returning a list of lists of clickbaits (each of which is a list of characters and integers). For a full program printing line-feed separated clickbaits just add ẎY to the end.

Try it online! (Footer makes a single list of clickbaits and then separates them with new-lines.)
...or see the example given in the question.

How?

The 99 right-most bytes of this Link form a nilad (a function with zero arguments, i.e. a constant):

“...“...“...“...»ṣ€⁷¤
                    ¤ - nilad followed by link(s) as a nilad:
“...“...“...“...»     - list of compressed strings (the four clickbait-texts with the
                      -   integers replaced with line-feed characters)
                   ⁷  - literal line-feed character
                 ṣ€   - split-at for €ach (read to interweave with the integers)

Let's label these text-parts as X, now the Link is:

I>-ṣ0ṖS€ỊÐḟ‘ɓĠL€ḟ1,ɓ¹ƝÆPẠ$ÐfW;ɓLẋ<¥21W;ż@€"X - Link: list of integers Z
                                             - # get the monotonically increasing runs:
I                                            - incremental differences of Z
 >-                                          - greater than -1 (vectorises)
   ṣ0                                        - split at zeros
     Ṗ                                       - pop (discard final run)
      S€                                     - sum each (length - 1 for all runs)
         Ðḟ                                  - filter discard if:
        Ị                                    -   insignificant (discard any 0s or 1s)
           ‘                                 - increment (yielding all run-lengths >= 3)
            ɓ                                - new dyadic chain with that on the right
                                             - # get the multiplicities:
             Ġ                               - group indices of Z by value
              L€                             - length of €ach
                ḟ1                           - filter discard 1s
                  ,                          - pair with right (the run-lengths)
                   ɓ                         - new dyadic chain with that on the right
                                             - # get the prime-pairs
                     Ɲ                       - for each pair in Z
                    ¹                        -   identity (do nothing)
                          Ðf                 - filter keep if:
                         $                   -   last two links as a monad:
                      ÆP                     -     is prime? (vectorises)
                        Ạ                    -     all?
                            W                - wrap in a list
                             ;               - concatenate with right ([multiplicities,runs])
                              ɓ              - new dyadic chain with that on the right
                                             - # get top count as a list
                               L             - length
                                   21        - literal 21
                                  ¥          - last two links as a dyad
                                 <           -   less than? (1 if 20 or less, else 0)
                                ẋ            -   repeat ([length] if 20 or less, else [])
                                     W       - wrap in a list (i.e. [[length]] or [[]])
                                      ;      - concatenate with right ([[prime pairs],[multiplicities],[run-lengths]])
                                             - ...now we have [[length],[prime pairs],[multiplicities],[run-lengths]]
                                          "X - zip with X (the text-parts)
                                         €   -   for each (item in the current list):
                                       ż@    -     interleave with swapped arguments


JavaScript (ES6), 49 48 47 46 bytes

Expects:

1 for down
7 for up

f=([c,...s],g=2)=>c?f(s,g-c&7||g):'1N'[--g]||g

Formatted and commented

f = (                   // f is a recursive function which takes:
  [c,                   // - c = next character in input string
      ...s],            // - s = remaining characters
  g = 2                 // - g = current gear, with default = neutral = 2
) =>                    //
  c ?                   // if there's still a character to process:
    f(                  //   do a recursive call with:
      s,                //     - the remaining characters
      g - c & 7 ||      //     - the updated gear if it is valid
      g                 //       or the previous gear if not
    )                   //
  :                     // else:
    '1N'[--g] ||        //   decrement g and output '1' for g = 0, 'N' for g = 1,
    g                   //   or simply the corresponding digit for other values

Gears are mapped as follows:

g MOD 8 = 0 1 2 3 4 5 6 7
          ---------------
gear    = X 1 N 2 3 4 5 6       (where 'X' is an invalid state)

Which allows us to easily check the validity of the current gear with:

(g & 7) != 0

Demo

f=([c,...s],g=2)=>c?f(s,g-c&7||g):'1N'[--g]||g

console.log(f(''))
console.log(f('1'))
console.log(f('11'))
console.log(f('17777'))
console.log(f('1777777771'))


Count the number of a number in the picture area

Mathematica, 92 bytes

Count[Take[Characters@StringSplit@TextRecognize@Binarize[Import@#4,.9],#2,#],ToString@#3,2]&

Unnamed function taking the arguments in this format: [{X1,X2}, {Y1,Y2}, N, "image.jpg"]. (Indeed, the fourth argument can be either the local file name or the URL http://i67.tinypic.com/6qh5lj.jpg.)

Import@#4 imports the image file, Binarize[...,.9] darkens all of the numbers to black, and TextRecognize (the function clearly doing the heavy lifting here!) extracts a multi-line string from the resulting image, which is split into a nested list of characters with Characters@.

Take[...,#2,#] keeps only the characters corresponding to the outlined rectangle, and Count[...,ToString@#3,2] counts the number of occurrences of N in the result.


Strategies for representing a given large integer using arithmetic expression


APL (Dyalog Unicode), 9 bytesSBCS

Full program. Prompts stdin for n (actually works for the range 0–29). APL keywords are single character symbols, so this prints n symbols to stdout.

⎕↑156↓⎕AV

Try it online!

⎕AV the Atomic Vector (i.e. the character set)

156↓ drop the first 156 elements

⎕↑ prompt for n and take that many elements from the above


Output subdivisions of international standard paper sizes


Python 2, 99 96 93 91 bytes
k=1
while 1:print('%2d '*7+'%2d\n')*4%tuple(n for n in range(64)if k&n),11/(k<32)*' -';k*=2

Exits with an error, which is allowed by default.
Try it online! or verify the MD5 hash.
How it works
After initializing k as 1, we enter an infinite loop that executes the following code.
print('%2d '*7+'%2d\n')*4%tuple(n for n in range(64)if k&n),11/(k<32)*' -';k*=2

tuple(n for n in range(64)if k&n) creates a tuple of all non-negative integers below 64 that have there jth bit set, where j is the iteration count of the loop, i.e., 2j = k.
('%2d '*7+'%2d\n')*4 first creates the format string '%2d %2d %2d %2d %2d %2d %2d \n', then repeats it four times. This is a template for each card, which pads each integer in the tuple to two characters (prepending spaces), separates each group of 8 integers by spaces, and the groups themselves by linefeeds.
Now, Python 2's print statement is a curious beast. It takes several expressions, separated by commata, and prints them one by one. It evaluates the first expression, prints it, evaluates the next expressions, prints it, etc. until no more expressions are left. Unless the last expression is followed by a comma, it appends a linefeed to it. Also, it prepends a space to all expressions, unless they are printed at the beginning of a line.
In each iteration, we first print the result of applying the format string to the tuple. We're at the beginning of a line, so no space is prepended.
Then, we (attempt to) print the result of 11/(k<32)*' -'. If k < 32, this expressions evaluates to ' - - - - - - - - - - -'. Again, we're at the beginning of a line, so no space is prepended. There is no comma after this expression, so print appends a linefeed. However, in the sixth iteration, k = 25 = 32, so trying to evaluate 11/(k<32)*' -' raises an uncaught ZeroDivisionError. This breaks out of the loop and ends the program immediately.


R, 43 34 bytes

function(n)(8*n^3-3*n^2+4*n+3)%/%6

Try it online!

The OEIS page lists the following formula for a(n):

(16*n^3 - 6*n^2 + 8*n + 3 - 3*(-1)^n)/12

However, I skipped right over that to get to the PROG section where the following PARI code is found:

floor((16*n^3 - 6*n^2 + 8*n + 3 - 3*(-1^n))/12))

Naturally, +3-3*(-1^n) is the same as +6 so we can simplify the linked formula, first by reducing it to

(16*n^3-6*n^2+8*n+6)/12 -> (8*n^3-3*n^2+4*n+3)/6

and using %/%, integer division, rather than / to eliminate the need for floor.


La La Land... no wait, Moo Moo Moonlight

Sed 30 bytes

s/[^aeiouy]*[aeiouy]\+/& & &/i


Least integer as a product of given factors

Husk, 8 bytes

ḟṠ€ȯmΠṖṘ

Extremely slow.
Try it online!

Explanation

ḟṠ€ȯmΠṖṘ  Implicit inputs, say L=[3,4] and n=5.
ḟ         Find the lowest integer k≥n that satisfies:
       Ṙ   Replicate L by k: [3,3,3,3,3,4,4,4,4,4]
      Ṗ    Powerset: [[],[3],[4],..,[3,3,3,3,3,4,4,4,4,4]]
    mΠ     Product of each: [1,3,4,..,248832]
 Ṡ€ȯ       k is in this list.


Ruby, 698 648
O=[A='&',B='+',C='*']
M='Syntax error'
def u(x)c=x.shift;(c.nil?)?S[0]=~/[a-z]/?(S.shift):S[0]=='('?(S.shift;o=u(O*1);S[0]==')'?(S.shift;o):abort(M)):abort(M):(o=[c];loop{o<<u(x*1);break if S[0]!=c;S.shift};o)end
def d(e,a,b)a!=e[0]?e:(i=e.index{|x|x[0]==b};(i.nil?)?e:y([b]+e[i][1..-1].map{|k|z=e*1;z[i]=k;z}))end
def y(e)e.map!{|x|(x.is_a?Array)?(y(x)):(x)};o=[e[0]];e[1..-1].map{|x|x[0]==o[0]?(o+=x[1..-1]):(o<<x)};d(d(d(o.size==2?o[1]:o,C,B),C,A),B,A)end
def j(e)(e.is_a?Array)?(e.map!{|x|j(x)};o=e.shift;e*(o=='*'?'':" #{o} ")):e;end
S=gets.gsub(/ /,'').gsub(/([a-z)])(?=[a-z(])/,'\1*\2').split(//)
k=u(O*1)
puts S!=["\n"]?(M):(j y k)

This solution consists of a basic recursive descent parser (method u) which builds an syntax tree which is then flattened (y) and transformed (d) according to the distribution axioms. The output (j) simply joins the operands again.
Unfortunately I broke the functionality when I later tried to reduce the code by restructuring. Nevertheless I think there is still some chance for golfing.


Python - 86

from string import*
def t(n,r,s=''):
 while n:s=printable[n%r]+s;n/=r
 return s or'0'

Credit due to Hoa Long Tam for the string import trick


J, 14 13 bytes
<[:>./2^/@p:]

Try it online!
-1 byte thanks to @Jonah
A dyadic function. The right argument is \$n\$, the left argument is \$B\$. Returns 0 if \$n\$ is \$B\$-powersmooth, 1 otherwise.
How it works
<[:>./2^/@p:]  NB. left arg = B, right arg = n
      2   p:]  NB. Prime factorization of n,
               NB. given as a 2-row matrix of [primes, exponents]
       ^/@     NB. Evaluate all pi^ei for each prime factor
 [:>./         NB. Maximum of all prime powers found above
<              NB. 1 if the above is greater than B, 0 otherwise


Powershell, 25 22/23 bytes
Two Options, one just calls split on the first arg, using the second arg as a delim value.
$args[0]-split$args[1]

One byte longer, builtin to parse csvs, takes filename as first arg and delim as second.
ipcsv $args[0] $args[1]

-2 because it doesn't require the -Delimiter (-D) param, and will assume it by default.
sadly powershell cannot pass an array of two params, as it will assume they are both files, and will run the command against it twice, no other two-var input method is shorter than this as far as I can see, so this is likely the shortest possible answer.
ipcsv is an alias for Import-Csv, takes a file name as the first unnamed input, and the delim character as the second by default behavior.
Run against the example from the wiki page returns
PS C:\Users\Connor\Desktop> .\csvparse.ps1 'example.csv' ','

Date     Pupil               Grade
----     -----               -----
25 May   Bloggs, Fred        C
25 May   Doe, Jane           B
15 July  Bloggs, Fred        A
15 April Muniz, Alvin "Hank" A


Canvas, 26 25 24 21 18 bytes

４／╬/╬⁰ｒ：⤢ｎ↷⁸｛Ａ×├ｍ↷

Try it here!

-3 bytes by fixing ｍ not repeating canvas

Explanation:

4/╬                 quad-palindromize a 4-long diagonal - big inner diamond
   /╬               quad-palindromize "/" - small diamond
     ⁰r             join the two vertically, centered
       :⤢n          overlap with transpose
           ↷        and rotate the thing clockwise
            ⁸{      for each input
              A×      times 10
                ├     plus 2
                 m    mold the canvas to that width
                  ↷   and rotate clockwise, setting up for the next iteration


><>, 112 bytes

You may be thinking "Is ><> really the best language to write an interpreter in?", to which my answer is "no, but let's try anyway!"

i:}b(?v
0(?;v0<o}\.24;!?:}\    /}~51. /}1-32./}1+32./}~i:
6*bb< o:}\?="#":  \?(b:\?="!":\?="-":\?="+":\?="%":$%+

Try it online, or at the fish pond!

Takes input from STDIN: first the +-#$%! code, then optionally a newline and any extra input.

This could do with some explanation.

The first loop is i:}b(?v. This reads from STDIN to the stack until it hits a character less than b = 11, which means either a newline (charcode 10) or EOF (charcode -1).
Once that's done, the fish swims down…

  v
v0<
<

…into the main loop, adding a 0 to the stack to use as the accumulator.
First, the fish sees bb*6+% — this computes 127 = 11*11+6 and takes the modulus of the accumulator. Then $ brings forward the first character from the stack.
Now, we get to the bulk of the code — reading the character. There are seven branches in this bit of the code. (I think I've tetrissed the branches as much as I can, but there might be more blank space that can be removed here.)

0(?;                                       /}~i:
                                           \?="%":

Note that the fish starts from the bottom right, moving left, and wraps when it hits the side of the code. If the character is a literal "%", we shift it to the back of the stack for safekeeping, delete the accumulator, replace it with the first character in STDIN, check if that's EOF (that is, if its charcode is negative), and end the program if so. We then hit the start of the main loop again.

                             /}1-32./}1+32.
                             \?="-":\?="+":

If the character is "+", we put it on the back of the stack again, add 1 to the accumulator, and jump to the start of the main loop. The "-" case is similar.

                      /}~51.
                      \?="!":

If the character is "!", delete the accumulator and jump to just before the start of the main loop, where we first created the accumulator by adding a 0 to the stack.

         .24;!?:}\
                 \?(b:

If the character is EOF or newline, check if the accumulator is 0, and terminate the program if so; otherwise, jump back to the start of the main loop. We kept all the used characters on the stack, so now we're back at the start of the program anyway.

      o}\
        \?="#":

If the character is "#", output the accumulator as a character. We're then conveniently back just before the main loop, where we created the accumulator with a 0.

     o:}

If we've reached this branch, the character can only be "$", since the stack only contained the characters +-#$%! and EOF or linefeed. Therefore we print a copy of the accumulator, and we're back at the start of the main loop.


Jelly, 6 bytes
ṚŒHZUZ

Try it online!
Explanation
Consider the string ABCDEFGHI:
ṚŒHZUZ
Ṛ      reverse -> IHGFEDCBA
 ŒH    split into halves -> IHGFE
                            DCBA
   Z   transpose -> ID
                    HC
                    GB
                    FA
                    E
    U  reverse each row -> DI
                           CH
                           BG
                           AF
                           E
     Z transpose -> DCBAE
                    IHGF
       implicitly concatenate -> DCBAEIHGF

I never thought the time would come when I'd outgolf Jonathan Allan in Jelly…


Bash + common Linux utils, 50

xxd -s20 -p -c2 $0
#<30 bytes of binary data>

To recreate this from encoded base64:
base64 -d <<< eHhkIC1zMjAgLXAgLWMyICQwCiMiImaSaZlmkDAAMwSjRKNEqoGogYhRVVF7UXu7d3s= > pent.sh

Since there are 12 pentominoes, their colours are easily encoded in hex nybbles.
Output:
$ ./pent.sh
2222
6692
6999
6690
3000
3304
a344
a344
aa81
a881
8851
5551
7b51
7bbb
777b
$


Find the occurrences of a character in an input string

Pyth, 3 bytes

/ww

Example run:

$ pyth -c '/ww'
sdhkfhjkkj
k
3

Of course, the user could input more or less than 10 letters on the first input, but we don't need to worry about what happens when the user violates the spec.


Monday Mini-Golf #1: Reverse Fibonacci Solver

Pyth, 23 bytes

AQWgHGA,-HGG)VvwHA,H+GH

Try it online: Demonstration or Test Suite

Quite unusual style of Pyth programming. Sometimes functional programming has its downsides.

Explanation:

AQWgHGA,-HGG)VvwHA,H+GH  Q = input list of the two starting numbers
AQ                       G, H = Q (unpacking Q)
  WgHG                   while H >= G:
      A,-HGG                G, H = [H - G, G]
            )            end while
              vw         read a number from input
             V           for N in range(^):
                H           print H
                 A,H+GH     G, H = [H, G + H]


Python 2, 300 285 257 246 236 bytes

Something to kick things off. It should be possible to shrink this down further. Thanks @Maltysen for shaving 10 bytes.

from random import*
N=input()
x=y=0;G={}
exec'n=randrange(4);l=n<2;u=n&1;G[(x-l,y-u)]="\\/"[l^u];x-=2*l-1;y-=2*u-1;'*N
f=lambda i:range(min(x[i]for x in G),max(x[i]for x in G)+1)
for i in f(0):print"".join(G.get((i,j)," ")for j in f(1))

Generates the walk output into a dictionary G of visited (x,y) tuples, updating our location as we go. Each random step n is both either u/d (u) and l/r (l).


Retina, 32 bytes

+`(/.\\)|(/)\||\|(\\)
$1$2$2$3$3

Try it online!

Explanation

The + tells Retina to run the replacement in a loop until it fails to change the string. Each replacement computes one step the falling dominoes. The replacement itself is really three replacements in one, but this ensures that they happen simultaneously:

(/.\\)...
$1

This just matches /|\ (as well as /\\ and /\\, but those don't matter) and reinserts it unchanged. The purpose of this is to skip over | with fallen dominoes on both sides, because this is shorter than ruling out those cases with separate lookarounds in the other two cases.

...(/)\|...
$2$2

This matches /| and turns it into //.

...\|(\\)
$3$3

This matches |\ and turns it into \\.


This can be useful if you want to use a module just once in an anonymous lambda function, as it allows you to avoid writing a separate statement:

lambda x:__import__('SomeModule').foo(x,123)

is one byte shorter than

from SomeModule import*;f=lambda x:foo(x,123)

If the code is a named function or program, then __import__ is unlikely to help except in the most extreme or contrived circumstances.


J, 39 35 30 28 bytes
(]{~1+i.~)1*.[:+/\_2^~1+i.,]

Try it online!
-5 thanks to Bubbler's observation that the numerator is the LCM of the fraction and 1.
-2 thanks to Bubbler for a transformation.
Note: The approach below relies on the assumption that every Wolstenholme number is greater than or equal its index, which was kindly proved by Greg Martin.

[:+/\_2^~1+i.,] Generates the sequence up to n+1, where n is the input: Scan sum +/\ of 1 over 1% the square of *: one plus 1...+ the integers from 0 to the input i.@>:.
1*. Numerators only.
(]{~1+i.~) Finds index of the input in previous result, adds 1, and plucks from previous result.


C, 824 803 bytes

#define Z return
#define Y char*b
#define N --n
i,j,n,w,h,A,B,C,D,E,F,G,H;char c[9999],*r,*d;x(b)Y;{if(b<c||*b<35)Z;++n;*b^=1;x(b-1);x(b+1);x(b-w);x(b+w);}m(b,p,y)Y,*p;{d=b;if(!y)for(y=-1,--p;1[++p]&31;)d+=w;for(i=0;*p&31?!(*p&16>>i)||b[i]&1:0;++i>4?p+=y,b+=w,i=0:0);Z!(*p&31)?x(d),n:0;}a(b)Y;{for(j=n=0;j<w*h;++j)if(m(c+j,b,1)||m(c+j,b,0))Z n;Z 0;}f(Y){bzero(c,9999);for(h=0,b=strcpy(c,b);r=b,b=strchr(b+1,10);h++,w=b-r);for(A=2,r=1+"@_`^C@|T@^R@XO@XX`|FB@|PP@|DD@PXN@XHX@XPX`PPXL@XHHX@XLDD@XPPX`PPPXH@PXHHH@PPPPP@";*r;r+=A+=r[-1]/96)while(a(r));A=B=C=D=E=F=G=H=0;while(a("PX")||a("XH")) (n-=3)?N?N?N?0:++H:++G:++F:++C;while(a("^")||a("PPPP"))(n-=4)?N?N?0:++H:++G:++E;while(a("P"))N?N?N?N?N?N?0:++H:++G:++F:++D:++B:++A;Z H||(G&&A)||(F&&B+B+A>1)||(E&&A>1)||D>1||C>1||((D||C)*3+B*2+A>5)*(A>1||B>2||A*B);}

  Note: Includes a bug fix (the previous entry falsely identified a tromino and two dominoes as forming a cube).
  In the TIO driver code, there are more test cases and there's now a pass/fail tracker; hexomino test cases were updated with the expected pass/fail value in the label.

Try it online!

...and before explaining this in detail, it's worth a high level overview.

Basic Overview

This algorithm applies a pattern matcher to classify each polyomino it finds with a given pattern as its subset.  As polyominoes are matched they are "unmarked", excluding them from pattern matching again.  The initial classification given by the matcher is simply a count of the number of tiles in the polyomino.

The matcher is applied first to cull out all polyominoes that cannot be folded onto a cube; the classification of these polyominos is discarded.  The match succeeds if these polyominoes appear within higher level ones; therefore, we only care about the smallest subset of "unfoldable" for each class.  Shown here along with padded encodings are all such polyominoes (excluding their vertical reflections).  The encoding uses bits 4-0 of each character to represent squares on each row:

[^C```] [XHX``] [PPPXH] [XHHX`] [PXN``] [|PP``]
 ####.   ##...   #....   ##...   #....   ###..
 ...##   .#...   #....   .#...   ##...   #....
 .....   ##...   #....   .#...   .###.   #....
 .....   .....   ##...   ##...   .....   .....
 .....   .....   .#...   .....   .....   .....
[|FB``] [XPX``] [PPXL`] [XLDD`] [XPPX`] [|DD``]
 ###..   ##...   #....   ##...   ##...   ###..
 ..##.   #....   #....   .##..   #....   ..#..
 ...#.   ##...   ##...   ..#..   #....   ..#..
 .....   .....   .##..   ..#..   ##...   .....
 .....   .....   .....   .....   .....   .....
[|T```] [^R```] [PXHHH] [XO```] [_````] [PPPPP]
 ###..   ####.   #....   ##...   #####   #....
 #.#..   #..#.   ##...   .####   .....   #....
 .....   .....   .#...   .....   .....   #....
 .....   .....   .#...   .....   .....   #....
 .....   .....   .#...   .....   .....   #....

[XX```]
 ##...
 ##...
 .....
 .....
 .....

Once these polyominoes are culled, we categorize the remaining polyominoes into relevant categories.  It's worth noting that in almost all cases, one can just find polyominoes that remain (those foldable onto cubes) and simply search for sums of six.  There are two exceptions:

A corner tromino and a line tromino cannot form a cube
A line tetromino and a domino cannot form a cube

In order to be able to accommodate this restriction we form 8 categories, from A-H: A for monominoes (lone tiles), B for dominoes, C for corner trominoes, D for line trominoes, E for line tetrominoes, F for other tetrominoes, G for pentominoes, and H for hexominoes.  Anything not falling into one of these categories is just ignored.  Counting polyominoes that fall into each category suffices.

At the end, we just return truthiness or falsiness based on a giant equation and these tabulations.

Ungolfed with comments

i,j,n,w,h,A,B,C,D,E,F,G,H;char c[9999],*r,*d;
x(b)char*b;{      // recursively unmarks polyomino pointed to by b.
   if(b<c||*b<35)return;
   ++n; *b^=1;    // Tabulates tiles in n as it goes.
   x(b-1);x(b+1);x(b-w);x(b+w); // left/up/down/right
}
m(b,p,y)char*b,*p;{ // pattern match area b with pattern p, direction y.
                    //   y=1 scans down; y=0 scans up.
   d=b; // d tracks a tile in the currently matched pattern for unmarking.
        // Note that all patterns are oriented to where "top-left" is a tile.
   if(!y) // ...when scanning up, move p to the end, set y to -1 to count backward,
          //    and advance d to guarantee it points to a tile (now "bottom-left")
      for(y=-1,--p;1[++p]&31;)d+=w;
   // Match the pattern
   for(i=0;*p&31?!(*p&16>>i)||b[i]&1:0;++i>4?p+=y,b+=w,i=0:0);
   return !(*p&31)   // If it matches...
          ? x(d),n   // ...unmark/count total polyomino tiles and return the count
          : 0;
}
a(b)char*b;{ // Scan for an occurrence of the pattern b.
   for(j=n=0;j<w*h;++j)
      if(m(c+j,b,1)||m(c+j,b,0)) // (short circuit) try down then up
         return n;
   return 0;
}
// This is our function.  The parameter is a string containing the entire area,
// delimited by new lines.  The algorithm assumes that this is a rectangular area.
// '#' is used for tiles; ' ' spaces.
f(char*b) {
   bzero(c,9999); // Init categories, c buffer
   for(h=0,b=strcpy(c,b);r=b,b=strchr(b+1,10);h++,w=b-r); // Find width/height
   // Unmark all polyominoes that contain unfoldable subsets.  This was
   // compacted since the last version as follows.  A tracks
   // the current pattern's length; r[-1], usually terminator for the
   // previous pattern, encodes whether the length increases; and o/c
   // the patterns were sorted by length.
   for(A=2,r=1+"@_`^C@|T@^R@XO@XX`|FB@|PP@|DD@PXN@XHX@XPX`PPXL@XHHX@XLDD@XPPX`PPPXH@PXHHH@PPPPP@";*r;r+=A+=r[-1]/96)
      while(a(r));
   A=B=C=D=E=F=G=H=0;
   // Match corner trominoes now to ensure they go into C.
   while(a("PX")||a("XH"))
      (n-=3)
         ?   --n
             ?   --n
                 ?   --n
                    ?   0 // More than 6 tiles?  Ignore it.
                    : ++H // 6 tiles?  It's an H.
                 : ++G // 5 tiles?  It's a G.
             : ++F // 4 tiles?  It's an F.
        : ++C; // only 3 tiles?  It's a C.
   // Now match line tetrominoes to ensure they go into E.
   while(a("^")||a("PPPP"))
      (n-=4)
         ?   --n
             ?   --n
                 ?   0 // More than 6 tiles?  Ignore it.
                 : ++H // 6 tiles?  It's an H.
             : ++G // 5 tiles?  It's a G.
         : ++E; // only 4 tiles?  It's an E.
   // Find all remaining tetrominoes ("P" is a monomino pattern)
   while(a("P"))
      --n
         ?   --n
             ?   --n
                 ?   --n
                     ?   --n
                         ?   --n
                             ?   0 // More than 6 tiles?  Ignore it.
                             : ++H // 6 tiles?  It's an H.
                         : ++G // 5 tiles? It's a G.
                     : ++F // 4 tiles?  It's an F.
                : ++D // 3 tiles?  It's a D.
            : ++B // 2 tiles?  It's a B.
         : ++A; // only 1 tile? It's an A.
   // Figure out if we can form a cube:
   return H               // Yes if we have a foldable hexomino
      ||(G&&A)            // Yes if we have a foldable pentomino
                          // and a monomino
      ||(F&&B+B+A>1)      // Yes if we have a foldable non-line tetromino
                          // and 2 other tiles (dominoes count twice).
                          // Either one domino or two monominoes will do.
      ||(E&&A>1)          // Yes if we have a foldable line tetromino (E)
                          // and two monominoes (A).  Note we can't make a
                          // cube with a line tetromino and a domino (B).
      ||D>1               // Yes if we have two line trominoes
      ||C>1               // Yes if we have two corner trominoes
      ||((D||C)*3+B*2+A>5)
                          // Any combination of trominoes, dominoes, monominoes>6,
                          // where trominoes are used at most once
                          // (via logical or)...
         * (A>1||B>2||A*B)
                          // ...times this includer/excluder fudge factor
                          // that culls out the one non-working case;
                          // see table:
                          //
                          // Trominos Dominos Monomos Cube  A>1 B>2 A*B
                          //    1        0       3+    yes   Y   N   0
                          //    1        1       1+    yes   Y   N   1
                          //    1        2       0     no    N   N   0
                          //    0+       3       0+    yes   Y   Y   1
      ;
}


Do I have a twin with permutated remainders?

R, 63 59 bytes

s=scan()%%c(2,3,5,7);i=which(s<c(0,2,3,5));any(s[i]-s[i-1])

Try it online!

-4 bytes thanks to Giuseppe

(The explanation contains a spoiler as to how to solve the problem without computing \$k\$.)

Explanation:
 Let \$s\$ be the list of remainders. Note the constraint that s[1]<2, s[2]<3, s[3]<5 and s[4]<7. By the Chinese Remainder Theorem, there exists a \$k\$ iff there is a permutation of \$s\$, distinct from \$s\$, which verifies the constraint. In practice, this will be verified if one of the following conditions is verified:

s[2]<2 and s[2]!=s[1]
s[3]<3 and s[3]!=s[2]
s[4]<5 and s[4]!=s[3]


Python 2 - 164

from datetime import*
d,t=input().split('T')
y,m,d=map(int,d.split('-'))
t=int(t[:2])
print'OMOfinfd'[(1+((10<t<17)==(4<m<11)))*(date(y,m,d).weekday()<5<6<t<19)::3]

If needed, below is a explanation of the logic in the final line:

The final line prints a slice of 'OMOfinfd' depending on the evaluation of its conditionals.

First, evaluate the operation 1+((10<t<17)==(4<m<11)).

If the XNOR between the conditions 10<t<17 and 4<m<11 is False, this will evaluate to 1+False => 1+0 => 1. Otherwise, the operation will evaluate to 1+True => 1+1 => 2.
Finally, multiply that result of the above operation by whether the day is a weekday and whether the time is between 6am-7pm.

If this is False, either the day is a weekend or the time is between 7pm-6am, and the result will be (1|2)*0 => 0. Otherwise the result will be (1|2)*1 => 1|2.

A result of 0 will print Off, 1 will print Mid, and 2 will print On.


Retina, 13 11 bytes

!`[^.?!]*\?

Try it online!

!`       print all matches
[^.?!]*  any number of non-ending-punctuation symbols
\?       followed by a question mark

Thanks to @MartinEnder for 2 bytes!


List prime-factorized natural numbers up to N in ascending order

Below is my attempt, in R5RS scheme (disclaimer: I'm not actually a Schemer (yet!), so pardon the (probably) terrible code).

(define count 10)

; `factors` is our vector of linked-lists of factors.  We're adding to these
; as we go on.
(define factors (make-vector count 'not-found))
(vector-set! factors 0 '())

; `primes-so-far` contains all the prime numbers we've discovered thus far.
; We use this list to speed up the dividing of numbers.
;   `primes-so-far-last` is a ref to the last entry in the `primes-so-far`
; list, for O(1) appending to the list.
(define primes-so-far '(dummy))
(define primes-so-far-last primes-so-far)

;; Helpers
(define (factor-ref n)
  (vector-ref factors (- n 1)))

(define (factor-cached? n)
  (not (eq? (vector-ref factors (- n 1)) 'not-found)))

(define (factor-put n factor)
  (let* ((rest        (/ n factor))
         (factor-cell (cons factor (factor-ref rest))))
    (vector-set! factors (- n 1) factor-cell)
    factor-cell))

(define (prime-append n)
  (let ((new-prime-cell (cons n '())))
    (set-cdr! primes-so-far-last new-prime-cell)
    (set!     primes-so-far-last new-prime-cell)
    new-prime-cell))

;; The factor procedure (assumes that `[1..n-1]` have already been factorized).
(define (factor n)
  (define (divides? m n)
    (= (modulo n m) 0))

  ; n       the number to factor.
  ; primes  the list of primes to try to divide with.
  (define (iter n primes)
    (cond ((factor-cached? n)
           (factor-ref n))

          ((null? primes)
           ; no primes left to divide with; n is prime.
           (prime-append n)
           (factor-put n n)) ; the only prime factor in a prime is itself

          ((divides? (car primes) n)
           (factor-put n (car primes))
           (factor-ref n))

          (else
           (iter n (cdr primes)))))

  (iter n (cdr primes-so-far)))

(define (print-loop i)
  (if (<= i count)
      (begin
        (display i)
        (display ": ")
        (display (factor i))
        (newline)
        (print-loop (+ i 1)))))

(print-loop 1)

Prints as:

1: ()
2: (2)
3: (3)
4: (2 2)
5: (5)
6: (2 3)
7: (7)
8: (2 2 2)
9: (3 3)
10: (2 5)

(Not exactly like in the task description, but all you'd have to do to get that output is to fold the list and merge repetitions of the same number, during the output part of the code.  The internal representation/algorithm would still be the same.)

The idea is to cache the previously computed values, but make use of the fact that the factors of n is the first prime factor of n and the prime factors of (n / first-factor).  But the latter is already known, so we just re-use the already existing list of factors for that smaller number.  Thus, for each number in [1..n] which is not prime, a single cons cell is stored.

For each number, a single cons cell is created and stored.  Thus, this approach should run with O(n) storage usage.  I've no clue if it's possible to neatly express the time-complexity.


Python 3, 296 bytes

import P,re,itertools
r="[A-Z][a-z]?"
f=re.findall(r,re.sub("(%s)(\d)"%r,lambda g:g.group(1)*int(g.group(2)),input()))
print(all(any(any(q[:len(q)//i]*i==q for i in range(2,len(q)))for q in[j[i:]+j[:i]for i in range(len(j))])<1for j in itertools.permutations(f+['e']*-(len(f)-P.a[f.pop(0)]>>1))))

Try it online!

-29 bytes thanks to ovs

Prints False or True.

This requires a dict of all p-block element symbols to the number of valence electrons they have. H is not necessary since it will only be one of the surrounding atoms. The dict is stored in P.py as a variable named a (it's written in the input for TIO and then placed into a Python file by the header)


Haskell, 53 52 bytes

Thanks nimi for saving 1 byte!

f<$>[2..100]
f 1=0
f n=1+f(sum[1|1<-gcd n<$>[1..n]])

Try it online!

sum[1|1<-gcd n<$>[1..n]] gives φ(n) (Taken from flawr,  thanks!)

f is a recursive function that calculates 1+φ(n) if n is not 1, and outputs 0 if n is 1, as there are no more iterations to be taken to reach 1

Finally f<$>[2..100] creates a list of f applied to each element of [2..100]


Haskell, 120 111 bytes

import Data.List
a&b=(a#b,b#a)
[]#_=[]
(a:y)#b=[a]%y where p%(i:w)|reverse(i:p)`isInfixOf`b=(i:p)%w;p%x=p++x#b

Test runs:

λ: "abc bab"&"abdabc"
("cba bba","badcba")

λ: "abcde"&"abcd bcde"
("dcbae","dcba edcb")

λ: "hello test"&"test banana"
("hello tset","tset banana")

λ: "birds flying high"&"whistling high nerds"
("bisdr flyhgih gni","wihstlhgih gni nesdr")


The number of ways a number is a sum of consecutive primes

Jelly,  6  5 bytes
-1 thanks to dylnan
ÆRẆ§ċ

A monadic link
Try it online! Or see the test-suite (note the final test case would time out at 60s at TIO).
How?
ÆRẆ§ċ - Link: integer, n
ÆR    - primes from 2 to n inclusive
  Ẇ   - all contiguous substrings
   §  - sum each
    ċ - count occurrences of n


Vim, 67 bytes/keystrokes
:s/\c[^a-z!'()*0-9._-]/\='%'.printf("%02x",char2nr(submatch(0)))/g<cr>

Note that <cr> represents the enter key, e.g. 0x0D which is a single byte.
This is a pretty straightforward solution. Explanation:
:s/                                                                    "Search and replace
   \c                                                                  "Case-insensitive
     [^a-z!'()*0-9._-]/                                                "A negative range. Matches any character not alphabetc, numeric or in "!'()*0-9._-"
                       \=                                              "Evaluate
                         '%'                                           "a percent sign string
                            .                                          "Concatenated with
                             printf("%02x",char2nr(submatch(0)))       "The hex value of the character we just matched
                                                                /g     "Make this apply to ever match
                                                                  <cr> "Actually run the command

That printf("%02x",char2nr(submatch(0))) garbage is terribly ungolfy.


Node.js 11.6.0,  34  33 bytes
Expects an array of digits. Returns false for strobogrammatic, or true otherwise.

n=>n.some(c=>n.pop()-c**66%79%63)

Try it online!
How?
Taking the precision errors on large integers into account1, we look for a function:
$$f(x)=(x^p\bmod m_0)\bmod m_1$$
such that:
$$f(0)=0,\:f(1)=1,\:f(6)=9,\:f(8)=8,\:f(9)=6$$
and:
$$f(x)>9\text{ for }x\in\{2,3,4,5,7\}$$
1: These errors actually depend on the JS engine. This is guaranteed to work with Node 11.6.0.

JavaScript (ES6), 38 bytes
Expects an array of digits. Returns false for strobogrammatic, or true otherwise.

n=>n.some(c=>n.pop()!="01----9-86"[c])

Try it online!


Jelly, 14 bytes

DUz0«9_ṚƊṀƊ€UḌ

Try it online!

Grid of all single digit pairs

A monadic link taking a list of two integers as its argument and returning an integer.

Explanation

D               | Decimal digits
 U              | Reverse order of each set of digits
  z0            | Transpose with 0 as filler
          Ɗ€    | For each pair of digits, do the following as a monad:
    «   Ɗ       | - Minimum of the two digits and the following as a monad (vectorises):
     9_         |   - 9 minus the digits
       Ṛ        |   - Reverse the order
         Ṁ      | - Maximum
            U   | Reverse the order of the answer to restore the orignal order of digits
             Ḍ  | Convert back from decimal digits to integer

If a digit matrix is acceptable input/output:

Jelly, 12 bytes

Uz0«9_ṚƊṀƊ€U

Try it online!


Python 3, 132

from datetime import*
t=datetime.now().timetuple()
m=max(0,t[3]*2+t[4]/30-18)
print(20*min(5,(t[6]+min(15,m-min(8,max(7,m))+7)/15)))

The resolution is one minute, or 2/45 of a percent. That's more than enough IMO.


Charcoal, 31 bytes
Ｎθ≔ＥＸ⊕θ²Φ⊕ι∧λ¬∨›Ｘλ²ι﹪ιλη⁼¹№η§ηθ

Try it online! Link is to verbose version of code. Inefficiently outputs a Charcoal boolean, i.e. - for unique, nothing if not. Explanation:
Ｎθ

Input n.
≔ＥＸ⊕θ²Φ⊕ι∧λ¬∨›Ｘλ²ι﹪ιλη

For all integers up to (n+1)², list those factors that do not exceed its square root.
⁼¹№η§ηθ

See whether the nth list is unique.
Edit: Switching from (2n)² to (n+1)² made the code an order of magnitude faster without generating false positives. At a cost of 3 bytes, 2+⁴√n⁵ would be even faster; this works because the worst case scenario is of the form p₁²p₂ where p₁<p₂<p₁²; the next integer with the same half rainbow is p₁p₂², and since p₂<p₁² we have p₂³<p₁⁶ and therefore (p₁p₂²)⁴<(p₁²p₂)⁵.


Wolfram Language (Mathematica), 52 bytes

Max[Length/@Cases[Subsets@Divisors@#,{a__}/;1a==#]]&

Try it online!

4-bytes saved thanks to @attinat

Here is also a 153 bytes version that calculates 1099511627776 and 10^15

Max[Length/@Table[s=RandomSample@Flatten[Table@@@FactorInteger[#]];Last@Select[Times@@@TakeList[s,#]&/@IntegerPartitions@Length@s,DuplicateFreeQ],5!]]+1&

Try it online!

The result for 10^15 is 12

  {1, 2, 4, 5, 10, 16, 25, 40, 50, 100, 125, 250}


Julia, 66 62 60 bytes

!n=sum(isprime,[a<1<b%3?b:a^2-a*b+b^2for a=[0;0;0:n],b=0:n])

Try it online!

Explanation

We’re interested in the primes in this parallelogram on the complex plane (example for n = 4):

We can split them into primes on the green lines, and on the gray lines.

Wikipedia tells me an Eisenstein number z is a green line Eisenstein prime iff |z| is a natural prime equal to 2 mod 3.

It also says z is a gray line Eisenstein prime iff |z|² = a² − ab + b² is a natural prime.

So we loop over a = 0…n and b = 0…n, and check:

If (a = 0 or b = 0 or a = b) and max(a, b) % 3 = 2, then count whether max(a, b) is a prime.
Else, count whether a² − ab + b² is a prime.

However, we can abuse the distribution’s symmetry. Instead of counting each green line once, we can just count one green line thrice! That is, only check a = 0 and increment the counter by three when we find a green line prime. The a=[0;0;0:n] achieves exactly this.

Since we know we’re only considering the green line a = 0, we can replace max(a, b) by b.

The “green line condition” is nicely expressed in Julia using operator chaining: a<1<b%3.

(For the remaining green lines, we will never return a false positive: if a = b or b = 0 then a² − ab + b² = a², which can’t be prime.)

Ideas

Maybe, instead of writing a^2-a*b+b^2, I can conditionally replace the exponent at b by 1 when a<1<b%3 – then the expression reduces to b. This doesn’t seem to be shorter, but it’s neat!


05AB1E, 7 bytes
Code:
',ì#Áðý

Uses the 05AB1E encoding. Try it online!
Explanation:
',ì         # Prepend the input to ","
   #        # Split on spaces
    Á       # Rotate every element one position to the right (wrapping)
     ðý     # Join the array by spaces


Gray Snail, 1206 bytes for numeric I/O, 149 bytes for unary I/O

For fun. Composition of first program:

451 bytes, converting number into dots
121 bytes, core function (a separated version is written below)
634 bytes, converting dots into number

Take numeric input and output.
Input is A, B, C respectively. Compared to other (near) O(1) answer, the code has a complexity of O(n). But for large number, it may eat up your memory first.

Hang if no solution is found.

INPUT p
POP Z r .!
f
POP Z o .
q
POP Z p [p]
GOTO [Z]
0
POP Z n .
GOTO w
1
POP Z n ..
GOTO w
2
POP Z n ...
GOTO w
3
POP Z n ....
GOTO w
4
POP Z n .....
GOTO w
5
POP Z n ......
GOTO w
6
POP Z n .......
GOTO w
7
POP Z n ........
GOTO w
8
POP Z n .........
GOTO w
9
POP Z n ..........
GOTO w
w
POP Z o .[o][o][o][o][o][o][o][o][o][o][n]
GOTO [r] [p]
GOTO q
!
POP Z A .[o]
INPUT p
POP Z r .@
GOTO f
@
POP Z B .[o]
INPUT p
POP Z r .#
GOTO f
#
POP Z C .[o]
POP H N .[B]
U
POP Z A [A]
POP Z B [B]
GOTO D [A]
GOTO $ [B]
GOTO U
$
POP Z A .[A][C]
POP Z H ..[H]
POP Z B .[N]
GOTO U
D
POP Z r .
POP Z M .
POP Z N ...........
POP Z z .[N]
POP Z V .[H]
+
GOTO l[V] [H]
POP Z H [H]
POP Z z [z]
GOTO ( [z]
GOTO +
(
GOTO ) [H]
POP Z z .[N]
POP Z M ..[M]
POP Z V .[H]
GOTO +
)
POP Z r .0[r]
POP Z M ..[M]
POP Z H .[M]
POP Z M .
POP Z V .[H]
POP Z z .[N]
GOTO +
l
POP Z r .0[r]
GOTO -
l.
POP Z r .1[r]
GOTO -
l..
POP Z r .2[r]
GOTO -
l...
POP Z r .3[r]
GOTO -
l....
POP Z r .4[r]
GOTO -
l.....
POP Z r .5[r]
GOTO -
l......
POP Z r .6[r]
GOTO -
l.......
POP Z r .7[r]
GOTO -
l........
POP Z r .8[r]
GOTO -
l.........
POP Z r .9[r]
GOTO -
-
GOTO / [M]
POP Z H .[M]
POP Z M .
POP Z V .[H]
POP Z z .[N]
GOTO +
/
OUTPUT [r]

f is a (maybe) recursive function to convert integers into dots. Argument is saved in [p] and output in [o].

U is a function testing S1>=S2, storing parameter in B, A while saving A-B into A.

Code starting from D is a stub converting dots into numbers.

The underlying principle is the same with my C answer (ripping off falsy output for impossible solutions).

Standalone version, 149 156 157 167 170 230 bytes, only support unary I/O

Input needs to be dots, e.g. .......... for 10.

INPUT A
INPUT B
INPUT C
POP N H .
GOTO U
$
POP N A .[A][C]
POP Z H ..[H]
U
POP Z A [A]
POP Z N ..[N]
GOTO D [A]
GOTO $ .[B] [N]
GOTO U
D
OUTPUT .[H]

U calculates A=A-B, and jumps to D when A<=0. Otherwise $ assigns A+C to A and call U.

Hang if no solution is found.

Tricks: abuse the "compiler"'s ability to interpret empty string. You can rip off conditions in GOTO statement to make unconditioned jumps and the same trick works for POP.

Remark: I may golf it more by 3 bytes but by doing so, mine and WheatWizard's answer would have the exact same logic. The result is probably the shortest GraySnail solution and I'm trying to prove it.


Game Theory is stupid anyway
{
    name: "Game Theory is stupid anyway",
    run: _ => 100
}

Senioritis hits hard sometimes.


Python 2, 118 bytes
Saving 2 bytes thanks to Shebang

def f(n,L):
 for i in range(n):print''.join(' #'[i==j]for j in[n-1-int(~-n*(x-min(L))/(max(L)-min(L))+0.5)for x in L])


I'll start us out with something simple.

Javascript 232+2730=2962

w=prompt();r="ay,ays;ey,eys;oy,oys;y,ies;us,i;um,a;is,es;x,xes;man,men;s,ses;sh,shes;ch,ches;z,zes".split(";");for(i=0;i<r.length;i++){b=r[i].split(",");if(w.slice(-b[0].length)==b[0])return w.slice(0,-b[0].length)+b[1];}alert(w+"s")

Uses a small list of replacement rules. Fails 2730 test cases out of 95642.


Python 2, 53 bytes

f=lambda n,x:n<1or((2*n-1-x)*f(n-1,x)-~-n*f(n-2,x))/n

Try it online!


reach catch when everything in the try block is caught already

C#, 46 (88 including boilerplate)

using System;class P{static void Main(){
        try
        {
            while(true)
                try
                {
                    System.Threading.Thread.CurrentThread.Abort();
                }
                catch(Exception ex2) {  }
        }
        catch(Exception ex1)
        {
            // your goal is to reach this catch block by modifying the code ...
            // in the inner try block above
            // You win if you reach this part and execute on of the following code lines
            Console.WriteLine("You won!"); // for C#
        }
}}

The Abort() method raises a ThreadAbortException, which is a special exception that is automatically rethrown at the end of each catch block (unless Thread.ResetAbort() is called).


Python, 140

^ 140 chars was actually a coincidence.

def f(s):
 s=s.split();i=0;l=[]
 while s:
  i+=1;t='(%d/%%d)'%i
  while s and len(t+s[0])<140:t+=' '+s.pop(0)
  l+=[t]
 for t in l:print t%i

While there are words left, the solution will create new tweets from the supply of words and append them to a list. For each tweet, it will keep trying to add words until the tweet's length reaches over 140 characters. Two characters are reserved for the total tweets, which are filled in later as each tweet in the list is printed.

Example output:

(1/11) FOUR SCORE AND SEVEN YEARS AGO OUR FATHERS BROUGHT FORTH ON THIS CONTINENT A NEW NATION CONCEIVED IN LIBERTY AND DEDICATED TO THE
(2/11) PROPOSITION THAT ALL MEN ARE CREATED EQUAL. NOW WE ARE ENGAGED IN A GREAT CIVIL WAR TESTING WHETHER THAT NATION OR ANY NATION SO
(3/11) CONCEIVED AND SO DEDICATED CAN LONG ENDURE. WE ARE MET ON A GREAT BATTLEFIELD OF THAT WAR. WE HAVE COME TO DEDICATE A PORTION OF THAT
(4/11) FIELD AS A FINAL RESTING PLACE FOR THOSE WHO HERE GAVE THEIR LIVES THAT THAT NATION MIGHT LIVE. IT IS ALTOGETHER FITTING AND PROPER
(5/11) THAT WE SHOULD DO THIS. BUT IN A LARGER SENSE WE CAN NOT DEDICATE, WE CAN NOT CONSECRATE, WE CAN NOT HALLOW, THIS GROUND. THE BRAVE
(6/11) MEN LIVING AND DEAD WHO STRUGGLED HERE HAVE CONSECRATED IT FAR ABOVE OUR POOR POWER TO ADD OR DETRACT. THE WORLD WILL LITTLE NOTE NOR
(7/11) LONG REMEMBER WHAT WE SAY HERE BUT IT CAN NEVER FORGET WHAT THEY DID HERE. IT IS FOR US THE LIVING RATHER TO BE DEDICATED HERE TO THE
(8/11) UNFINISHED WORK WHICH THEY WHO FOUGHT HERE HAVE THUS FAR SO NOBLY ADVANCED. IT IS RATHER FOR US TO BE HERE DEDICATED TO THE GREAT
(9/11) TASK REMAINING BEFORE US, THAT FROM THESE HONORED DEAD WE TAKE INCREASED DEVOTION TO THAT CAUSE FOR WHICH THEY GAVE THE LAST FULL
(10/11) MEASURE OF DEVOTION, THAT WE HERE HIGHLY RESOLVE THAT THESE DEAD SHALL NOT HAVE DIED IN VAIN, THAT THIS NATION UNDER GOD SHALL HAVE
(11/11) A NEW BIRTH OF FREEDOM, AND THAT GOVERNMENT OF THE PEOPLE BY THE PEOPLE FOR THE PEOPLE SHALL NOT PERISH FROM THE EARTH.


Fission, 6 bytes

'!+OR"

Try it online! Try two copies! Try three!

Explanation

This is just the Fission standard quine. It happens to work for this challenge, because Fission has explicit entry points into the program. In particular, by duplicating the program, we add another R which adds another atom (instruction pointer). Since the source code is toroidal, the effective code being executed doesn't change otherwise — to each atom, the code still looks the same locally. However, the atoms are executed in lock step, so that the things they print are interleaved and we get an additional copy of each character in the output.

For completeness' sake I'll just shortly reiterate how the program itself works. Regardless of whether we repeat the program or not (e.g. '!+OR"'!+OR"'!+OR"), each atom sees the following code:

R"'!+OR"'!+O

The " toggles string printing mode, so that the program starts by printing '!+OR directly to STDOUT, which is all of the quine except the quote. Then '! sets the atom's mass to the character code of !, + increments it, which gives ", and O prints it while simultaneously destroying the atom. The program then terminates, because there are no atoms left.


Jelly, 10 bytes

9s3’Ẓæ*³FṀ

Try it online!

1-indexed. Computes the largest element of: $$\begin{bmatrix}0&0&1 \\ 1&0&1 \\ 0&1&0\end{bmatrix}^n$$
where the binary matrix is conveniently computed as: $$\begin{bmatrix}\mathsf{isprime}(0)&\mathsf{isprime}(1)&\mathsf{isprime}(2) \\ \mathsf{isprime}(3)&\mathsf{isprime}(4)&\mathsf{isprime}(5) \\ \mathsf{isprime}(6)&\mathsf{isprime}(7)&\mathsf{isprime}(8)\end{bmatrix}$$

(this is a total coincidence.)

9s3         [[1,2,3],[4,5,6],[7,8,9]]    9 split 3
   ’        [[0,1,2],[3,4,5],[6,7,8]]    decrease
    Ẓ       [[0,0,1],[1,0,1],[0,1,0]]    isprime
     æ*³    [[0,0,1],[1,0,1],[0,1,0]]^n  matrix power by input
        FṀ                               flatten, maximum


Output Rhombus Sequence without Nested Loops

Mathematica, 23 bytes
((10^#-1)/9)^2&~Array~9

Try it online!