text:
Do two numbers contain unique powers of 2
Break two numbers up into their powers of 2, if they share any, return a falsey value. Otherwise, return a truthy value.
If one input is 0, the answer will always be truthy.
if one input is 255, the answer will be falsey if the other is not 0.
Example
Given 5 and 3
5 = 2⁰ + 2²
3 = 2⁰ + 2¹

Both share 2⁰, return falsey.
Given 8 and 17
8  = 2³
17 = 2⁰ + 2⁴

Neither share any powers, return truthy.
I/O
Input and output can be through any standard means
Input will always be two integers in the range 0 <= n <= 255
Output should be one truthy or falsey value
Test Cases
Truthy:
1, 2
3, 4
2, 4
8, 17
248, 7

Falsey:
1, 3
6, 4
8, 8

Standard Loopholes apply.
This is code-golf, so fewest bytes wins!

Can I output 0 for truthy and 1 for falsey instead?

@KritixiLithos Although it often depends on the language as to what counts as Truthy or Falsey, this is usually acceptable. EDIT: Read the comment wrong, backwards output is not acceptable.

Do all truthy inputs have to result in the same truthy value?

@Dennis They can be different values, as long as they are Truthy/Falsey

May we take inputs in binary?

If your language's default number system is binary sure, otherwise, you should use the language's default.

This challenge is way too trivial.

Is there a language with a 1-byte NAND built-in? If so, it will win.

Actually, 2 bytes
&Y

Try it online!
Explanation:
&Y
&   bitwise AND
 Y  boolean negation

x86 Machine Code, 5 bytes
20 C8 0F 95 C0

takes inputs in al and cl, and returns output in al, and is equivalent to:
and al, cl
setnz al

You could make this follow a standard calling convention (specifically, the Windows 64-bit calling convention, or Windows 32-bit __fastcall) by receiving the parameters in cl and dl. The setnz al instruction would remain the same, since a result is always returned in eax (or sub-portions thereof). That doesn't change the code size any at all, but makes the code a bit more real-world and callable from other languages.

Jelly, 2 bytes
&¬

Try it online!
Explanation:
&¬
&   bitwise AND
 ¬  logical negation

I was expecting this to be easy, but I didn't think of &, I was not expecting this to be two bytes easy.

Ruby, 12 bytes
->a,b{a&b<1}

Try it online!

Mathematica, 12 bytes
BitAnd@##<1&

Pure function taking two positive integers as argument and returning True or False.

Python, 18 bytes
lambda a,b:not a&b

Try it online!

2 bytes saved using <1 rather than not .

Bash, 10 bytes
!(($1&$2))

Input is via command-line arguments. Output is via exit code, so 0 is truthy and 1 if falsy.
Try it online!

05AB1E, 2 bytes
&_

Try it online!

R, 28 bytes
f=function(a,b)!bitwAnd(a,b)

JavaScript (ES6), 12 bytes
a=>b=>!(a&b)

Takes input in the currying format.

let f=

a=>b=>!(a&b)

console.log(f(1)(2));
console.log(f(3)(4));
console.log(f(2)(4));
console.log(f(8)(17));
console.log(f(248)(7));
console.log(f(1)(3));
console.log(f(6)(4));
console.log(f(8)(8));

1B saved: a=>b=>a&b<1

@Luke That outputs 0 for all the testcases. In order to make that work I would have to surround a&b with parentheses.

Oh, nvm then...

CJam, 23 4 bytes
q~&!

It turns out my previous solution contained an implementation of what was essentially just bitwise AND (which is silly because it used & anyway).

CJam, 4 bytes
{&!}

Try it online!

https://codegolf.stackexchange.com/a/124643/61384

@Challenger5 Damn you grace period!

R, 23 bytes
if allowed - this version can get multiple inputs as a1,a2,a3..... b1,b2,b3.....
!bitwAnd(scan(),scan())

GolfScript, 3 bytes
~&!

Try it online!

Pyke, 3 bytes
.&!

Try it here!
.&  -  bitwise_and(input_1, input_2)
  ! - not ^

MATL, 3 bytes
Z&~

Try it at MATL Online.
Explanation
    % Implicitly grab both inputs
Z&  % Bit-wise AND
~   % Negate the result and implicitly display

Chip, 80 bytes
 AZ BZ CZ DZ EZ FZ GZ HZ
,[',[',[',[',[',[',[',['*Z~S
`--)--)--)--)--)--)--)~aef

Try it online!
Takes input as two consecutive bytes. (In the TIO, the characters 'A' and '$' are used, corresponding to values 65 and 36.)
This solution has eight chunks, one per bit, plus an extra chunk at the end. Looking at these chunks:
A is bit 0x01 of the input. (The letters A though H correspond to a bit each.) Z holds on to a value for the next cycle while producing the previous value. Hence, A and Z are the current and previous values of bit 0x01.
[ is an AND-gate; it simply ANDs its two inputs together. So the full row of such gates is performing a bitwise AND of the two bytes.
Finally, ) is an OR-gate. All eight AND results are OR'd together, giving us a True is there is a match, and a False otherwise. We want the inverse of that, so use a NOT-gate (~) before passing it to the output.
We output via a, e, and f. The a, which corresponds to bit 0x01 of the output,  receives the result of the above computation. The other two bits e and f are unconditionally on, together forming 0x30. Therefore, the output is either 0x30 or 0x31, which are the codes for ASCII characters '0' and '1'.
The extra stuff is housekeeping, it prevents output for the first cycle (there is no previous value at this point, so there is no reason to do a comparison).

Alternate solution, also 80 bytes
A~.B~.C~.D~.E~.F~.G~.H~.
Z~<Z~<Z~<Z~<Z~<Z~<Z~<Z~<*Z~S
 a[--[--[--[--[--[--[--'ef

This is very similar in style, but uses a different algorithm. Where above we AND each pair of bits, and use OR to reduce the result to a single value, here we OR the negation of each pair of bits, then use AND to reduce.
One thing to note: we use an implicit OR here, instead of a proper gate as above. We could have used implicit OR'ing above as well, but there is no byte-savings there.

Java 13 bytes
a->b->(a&b)<1

Desmos, 87 85 87 80 bytes
+2 bytes to correct an error pointed out by @Steffan
-7 bytes thanks to @aiden-chow
D(n)=mod(floor(n/2^{[0...floor(log_2(n+0^n))]}),2)
f(a,b)=\{\total(D(a)D(b))=0\}

Try It On Desmos!
f returns 1 when they are "truthy" and otherwise undefined.

nice! for it to paste correctly, {...} needs to be \{...\}, and \log_{2}n can just be log2n.

@Steffan Yeah I forgot, it should have been \{...\}.
For me, log2n doesn't work btw.

Well it can still be log_2n.

\{...\} won't paste correctly if the built-in functions don't have backslashes in front of them. In this case, you need to replace total with \total.

But there are a few golfs you can do: 74 bytes. Namely, I utilized a golfier way to convert to binary which only uses 2^{[0...floor(log_2n)]} once, so both X and W are not needed.

Actually, your code doesn't handle 0 input correctly, so you will need to replace floor(log_2n) with floor(log_2(n+0^n)), which brings up the byte count to 80 bytes.

@AidenChow great

Rust, 10 bytes
|a,b|a&b<1
Attempt This Online!

Pari/GP, 18 bytes
x->y->!bitand(x,y)

Try it online!

Javascript, 28
(a,b)=>!(256&(-~a|-~b)||a&b)

QBIC, 12 bytes
?(: and :)=0

This returns -1 for truthy inputs, and 0otherwise. "Bitwise" is something QBasic isn't very good at, and I haven't built any of this stuff into QBIC either.

D, 13 bytes
(x,y)=>!(x&y)

Here, (arg1,...)=>result is the D lambda syntax, and the ! and & are common notations for boolean negation and bitwise AND.
You can find the whole program coupled with the tests at tio.run.

PHP, 25 Bytes
print 1 for true and nothing for false

<?=!($argv[1]&+$argv[2]);

Try it online!

<?=+!($argv[1]&$argv[2]); -2 bytes

@FelipeNardiBatista  Yes then the arguments must cast from string to integer.Otherwise 40&4 is false and "40"&"4" is true for example

what about removing just one of the two? it worked with 40&4

@FelipeNardiBatista right that cast both values to integer Thank You

Lua, 19 bytes
a,b=...print(a&b<1)

Try it online!

C (gcc), 18 bytes
Uses exit-code 0 as truthy.
f(a,b){exit(a&b);}

Try it online!

Pyth, 6 bytes
!.&hQe

Test it online!
Explanations
!.&hQe

   hQ     Get first input number
     e    Get second (implicit) input number
 .&       Bitwise and
!         Negate

Wise, 11 bytes
&::^~![&&]|

Due to a bug this does not currently work on tio, however it does work on the desktop version.
Here is a slightly longer version that works for both:
&::^~![?~&:]|

Try it online!
Explanation
Most of our code goes into a logical not, in fact only the first byte is required if you want to get the opposite answer.
&             #Bitwise and
 ::^~![?~&:]| #Logical not

Oracle SQL, 34 bytes
-- Begin test cases
WITH T (x, y, desired) AS (
  SELECT   1,  2, 1 FROM DUAL UNION ALL
  SELECT   3,  4, 1 FROM DUAL UNION ALL
  SELECT   2,  4, 1 FROM DUAL UNION ALL
  SELECT   8, 17, 1 FROM DUAL UNION ALL
  SELECT 248,  7, 1 FROM DUAL UNION ALL
  SELECT   1,  3, 0 FROM DUAL UNION ALL
  SELECT   6,  4, 0 FROM DUAL UNION ALL
  SELECT   8,  8, 0 FROM DUAL)
-- End test cases
SELECT T.*, -SIGN(BITAND(x, y)) + 1 result FROM T
/

APL, 10 bytes
 ∧/⍲/⎕⊤⍨8⍴2

Take two (or more) numbers, convert them to binary, then apply the NAND to pairs of bits, then reduce by conjunction.

Go, 30 bytes
func(a,b int)any{return a&b<1}
Attempt This Online!


text:
Do two numbers contain unique factorials?
Break two numbers up into their factorials; if they share any, return a falsey value. Otherwise, return a truthy value. (inspired by this recent question)
In other words, write each input number as the sum of factorials (of positive integers) in the greediest possible way; return a truthy value if no factorial appears in both representations, a falsey value otherwise.
Example
Given 20 and 49:
20 = 3! + 3! + 3! + 2!
49 = 4! + 4! + 1!

No factorial appears in both representations, so return a truthy value.
Given 32 and 132:
132 = 5! + 3! + 3!
 32 = 4! + 3! + 2!

3! appears in both representations, so return a falsey value.
I/O
Input and output can be through any standard means.
Input will always be two nonnegative integers; no upper bound on these integers other than what your language requires.
Output should be a truthy or falsey value. These values don't necessarily have to be consistent for different inputs, as long as every output is correctly truthy/falsey.
Test Cases
If one input is 0, the answer will always be truthy. Other truthy test cases:
{6, 3}, {4, 61}, {73, 2}, {12, 1}, {240, 2}, {5, 264}, {2, 91}, {673, 18},
 {3, 12}, {72, 10}, {121, 26}, {127, 746}

If both inputs are odd integers, or if both inputs are the same positive integer, then the output will always be falsey. Other falsey test cases:
{8, 5}, {7, 5}, {27, 47}, {53, 11}, {13, 123}, {75, 77}, {163, 160}, {148, 53},
 {225, 178}, {285, 169}, {39, 51}, {207, 334}, {153, 21}, {390, 128}, {506, 584},
 {626, 370}, {819, 354}

This is code-golf, so fewest bytes wins!

"write each input number as the sum of factorials (of positive integers) in the greediest possible way" don't you mean the laziest possible way instead?

@KritixiLithos no. He's referring to the class of algorithms known as greedy algorithms, which work by maximizing some metric after each step. As in, always taking as much as they can.

Jelly, 7 bytes
Æ!ṠḄ&/¬

Try it online!
How it works
Æ!ṠḄ&/¬  Main link. Argument: (x, y) (pair of integers)

Æ!       Convert x and y to factorial base.
  Ṡ      Apply the sign function to each digit.
   Ḅ     Unbinary; convert each resulting Boolean array from base 2 to integer.
    &/   Reduce the resulting pair of integers by bitwise AND.
      ¬  Take the logical NOT of the result.

Æ! seems insanely useful in certain scenarios.

Is there anything to be gained by trying to elementwise-multiply the factorial-base lists directly, without taking signs?

@GregMartin I don't think so. The digits arrays would have to be padded or truncated to the same length, which will probably cost more bytes than it saves.

Python 3, 93 91 bytes
lambda a,b:k(a)&k(b)=={0}
k=lambda t,n=1,a=1:{t}&{0}or a*n>t and{a-1}|k(t-n)or k(t,n*a,a+1)

Try it online!

Python 2, 47 bytes
h=lambda a,b,d=2:a<1or a%d*(b%d)<h(a/d,b/d,d+1)

Try it online!

I love this solution. Could you annotate it with a bit of your thinking?

JavaScript (ES6), 71 bytes
(a,b,g=(n,e=1,f=1)=>n>=f&&g(n,++e,f*e)+((n/f|0)%e&&1<<e))=>!(g(a)&g(b))

JavaScript's integers are limited to 53 bits of precision, which is just about enough for 18!; this means that I can use a mask of 18 bits to track which factorials are needed.

PHP, 109 Bytes
for(;$a?:$a=$argv[++$i];$a-=$r[$i][]=$f,$i<2?:$t+=in_array($f,$r[1]))for($c=$f=1;($a/$f*=$c)>=++$c;);echo!$t;

Try it online!

Mathematica, 73 bytes
F[x_]:=First@IntegerPartitions[x,99,Range[99]!];!IntersectingQ[F@#,F@#2]&

input form

[x1,x2]

I'm getting several errors testing this...

Just type at the end [x1,x2]

Ah. I was inputting a list, instead of two separate integers. You can golf it further with ±x_:=First@IntegerPartitions[x,99,Range[99]!];!IntersectingQ[±#,±#2]&[4,61] (69 bytes). In ISO 8859-1 encoding, the ± is one byte.

C, 122 119 bytes
G(q,i){return gamma(q+1)>i?gamma(q):G(q+1,i);}
Q(a,b,u,v){while(a&&b){a-=u=G(1,a);b-=v=G(1,b);if(a==b)exit();}exit(0);}

Q is the main function. It should be invoked with exactly two positive integer values. This exits with an exit code of 0 for truthy and 1 for falsy.
Although this does not seem to work on TIO, it works on my system with the Homebrew provided gcc 7.1.0.
I have not golfed in C in quite a while, so golfing tips are very much appreciated!

source: Stack Exchange

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

sort: votes


text:
How high can you count in different languages?
Based on How high can you count? let us give an advantage to the polyglot people.
Challenge:
Your task is to write as many programs / functions / snippets as you can, where each one outputs / prints / returns an integer. The first program must output the integer 1, the second one 2 and so on.
You can not reuse any characters between the programs. So, if the first program is simply: 1, then you may not use the character 1 again in any of the other programs. Note: It's allowed to use the same character many times in one program.
You can only use a programming language once. So every number must be in a different programming language.
Scoring:
The winner will be the submission that counts the highest. In case there's a tie, the winner will be the submission that used the fewest number of bytes in total.
Rules:

You can only use a language for one integer - after that you cannot reuse the language
Snippets are allowed!
To keep it fair, all characters must be encoded using a single byte in same encoding in the languages you choose.
The output must be in decimal. You may not output it with scientific notation or some other alternative format. Outputting floats is OK, as long as all digits that are shown behind the decimal point are 0. So, 4.000 is accepted. Inaccuracies due to FPA is accepted, as long as it's not shown in the output.
ans =, leading and trailing spaces and newlines etc. are allowed.
You may disregard STDERR, as long as the correct output is returned to STDOUT
You may choose to output the integer to STDERR, but only if STDOUT is empty.

Note: Explanations are encouraged!

I suggest you remove the tag [tag:polyglot] because the code is not being run in multiple languages, but rather each program/snippet is run individually in each language.

Also, do all the languages have to have the same encoding?

What if the same character is encoded differently in different languages? E.g. 1 is encoded as 0x65 in language A, and as 0x67 in language B. Can I then use the character 1 in both languages because they map to different bytes?

@KritixiLithos As far as I know, only the hex bytes matter.

For future reference, these types of challenges which ask for individual programs in multiple languages are called [tag:rosetta-stone]

Can we use languages where 0 bytes produces a number?

GS2, 3var, Alphuck, brainf***, Numberwang, evil, ;#+, Charcoal, Retina, wsf, Jelly, Beeswax, CJam, Fourier, Fireball, M, Pushy, MATL, Brain-Flak, Convex, COW, Mouse-79, Mouse-98, Mouse-2002, Pyke, Neim, JavaScript, Braingolf, Japt, SOGL, score 31
All are encoded as hex bytes in either ASCII or the language's native encoding
GS2 - 1: 01 01
3var - 2: 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64
Alphuck - 3: 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65
brainf*** - 4: 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b
Numberwang - 5: 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39
Evil - 6: 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61
;#+ - 7: 3b 3b 3b 3b 3b 3b 3b 3b 3b 3b 3b 3b 3b 3b 3b 3b 3b 3b 3b 3b 3b 3b 3b 3b 3b 3b 3b 3b 3b 3b 3b 3b 3b 3b 3b 3b 3b 3b 3b 3b 3b 3b 3b 3b 3b 3b 3b 3b 3b 3b 3b 3b 3b 3b 3b
Charcoal - 8: b8
wsf - 9: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
Jelly - 10: 85
Beeswax - 11: 50 50 50 50 50 50 50 50 50 50 50
CJam - 12: 43
Retina - 13: 0a 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 0d 0a 2e
Fourier - 14: 5e 5e 5e 5e 5e 5e 5e 5e 5e 5e 5e 5e 5e 5e
Fireball - 15: 46
M - 16: 96
Pushy - 17: 54 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 7e
MATL - 18: 32 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51
Brain-Flak - 19: 28 28 29 28 29 28 29 28 29 28 29 28 29 28 29 28 29 28 29 28 29 28 29 28 29 28 29 28 29 28 29 28 29 28 29 28 29 28 29 29
Convex - 20: 4b
COW - 21: 4d 6f 4f 4d 6f 4f 4d 6f 4f 4d 6f 4f 4d 6f 4f 4d 6f 4f 4d 6f 4f 4d 6f 4f 4d 6f 4f 4d 6f 4f 4d 6f 4f 4d 6f 4f 4d 6f 4f 4d 6f 4f 4d 6f 4f 4d 6f 4f 4d 6f 4f 4d 6f 4f 4d 6f 4f 4d 6f 4f 4d 6f 4f
Mouse-79 - 22: 57
Mouse-98 - 23: 58
Pylons - 24: 34 21
Mouse-2002 - 25: 5a
Pyke - 26: 4e 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68
Neim - 27: f9
JavaScript - 28: 30 78 31 63
Braingolf - 29: 6c 6c 6c 6c 6c 6c 6c 6c 6c 6c 6c 6c 6c 6c 6c 6c 6c 6c 6c 6c 6c 6c 6c 6c 6c 6c 6c 6c 6c 6c
Japt - 30: c4 c4 c4 c4 c4 c4 c4 c4 c4 c4 c4 c4 c4 c4 c4 c4 c4 c4 c4 c4 c4 c4 c4 c4 c4 c4 c4 c4 c4 c4
SOGL - 31: 41 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49

More to come :)
also if i was allowed to use any language as many times as i want i would be able to get ~200

Might be worth showing both the actual characters and the hex bytes, makes it easier to see what characters have already been used.
Also if you haven't already used ASCII l, 13 ls in Braingolf will output 12

@Mayube Thanks for that braingolf tip :)

if you find an easier way to make 12 in another language, but struggle with a different number later on, n+1 ls in Braingolf will always output n, so for example 43 ls will output 42

@Mayube I noticed.

SOGL programs for 31: 41 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 (AIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII) or 27 0e ('«) or 8c b7 52 05 fe 6a (∫ΠR⁵‘j).

Your Fourier program won't work since printing isn't implicit. You should have ^^^^^^^^^^^^^^o or 5e 5e 5e 5e 5e 5e 5e 5e 5e 5e 5e 5e 5e 5e 6f

@BetaDecay I believe snippets are allowed.

Oh I see. I never thought you could have snippets in Fourier :D

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


text:
Roll to see all sides!
Let's say you have a 20-sided die. You start rolling that die and have to roll it a few dozen times before  you finally roll all 20 values. You wonder, how many rolls do I need before I get a 50% chance of seeing all 20 values? And how many rolls of an n-sided die do I need to roll before I roll all n sides?
After some research, you find out that a formula exists for calculating the chance of rolling all n values after r rolls.
P(r, n) = n! * S(r, n) / n**r

where S(a, b) denotes Stirling numbers of the second kind, the number of ways to partition a set of n objects (each roll) into k non-empty subsets (each side).
You also find the OEIS sequence, which we'll call R(n), that corresponds to the smallest r where P(r, n) is at least 50%. The challenge is to calculate the nth term of this sequence as fast as possible.
The challenge

Given an n, find the smallest r where P(r, n) is greater than or equal to 0.5 or 50%.
Your code should theoretically handle any non-negative integer n as input, but we will only be testing your code in the range of 1 <= n <= 1000000.
For scoring, we will be take the total time required to run R(n) on inputs 1 through 10000.
We will check if your solutions are correct by running our version of R(n) on your output to see if P(your_output, n) >= 0.5 and P(your_output - 1, n) < 0.5, i.e. that your output is actually the smallest r for a given n.
You may use any definition for S(a, b) in your solution. Wikipedia has several definitions that may be helpful here.
You may use built-ins in your solutions, including those that calculate S(a, b), or even those that calculate P(r, n) directly.
You can hardcode up to 1000 values of R(n) and a million Stirling numbers, though neither of these are hard limits, and can be changed if you can make a convincing argument for raising or lowering them.
You don't need to check every possible r between n and the r we're looking for, but you do need to find the smallest r and not just any r where P(r, n) >= 0.5.
Your program must use a language that is freely runnable on Windows 10.

The specifications of the computer that will test your solutions are i7 4790k, 8 GB RAM. Thanks to @DJMcMayhem for providing his computer for the testing. Feel free to add your own unofficial timing for reference, but the official timing will be provided later once DJ can test it.
Test cases
n       R(n)
1       1
2       2
3       5
4       7
5       10
6       13
20      67       # our 20-sided die
52      225      # how many cards from a huge uniformly random pile until we get a full deck
100     497
366     2294     # number of people for to get 366 distinct birthdays
1000    7274
2000    15934
5000    44418
10000   95768
100000  1187943
1000000 14182022

Let me know if you have any questions or suggestions. Good luck and good optimizing!

@JonathanAllan Knew I should have chosen a different wording. Thanks for the heads up.

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)

Excellent work on the whole answer! First, I should have realized that 0.366512 was the log of something ages ago. Will use -log(log(2) in my next iteration. Second, the idea to use Newton's method is also very clever and I'm glad to see that this works so well. Third, I'm almost definitely going to steal exp(log(binom(n, i+1)) + r * log((n-i-1)/n)) :P Kudos on a great answer! :D

I've added the official timing! Nice answer BTW :)

I'm really confused. I changed the numpy import to from numpy import * and for some reason the time dropped to basically 0... Try it online?

@notjagan cache hit maybe?

@notjagan That’s because numpy.sum doesn’t know how to iterate over a map object and instead returns the map object back without evaluating anything.

I'd like to apologize for several things: 1) my plagiarism of your answer when I tried to find improvements; 2) not owning up to it properly and just trying to fix my answer; 3) that this apology has taken so long. I was so mortified that at first I just abandoned this challenge. In a small attempt at reparation, I suppose it fair to tell you that my main improvement on this answer was changing from Newton's method to incrementing r, as your initial approximation is already quite good. Hope to see you in PPCG once more, and sorry for everything.


text:
Create a Parrot Program
Given an input, output that input followed by a newline endlessly.
Input will be a string consisting only of printable ASCII characters (0x20-0x7E) and newlines (0x0A).
If input is length 0, endlessly output newlines.
This is code-golf so fewest bytes in each language wins!

Half of yes is 91 lines long.

So related it hurts.

@VoteToClose I knew I've answered this before..

Microsoft, 1 Steve Ballmer — developers, developers, developers, developers, ...

Bash, 8 bytes
yes "$1"

Try it online!

damn, 10 minutes late! but this does not print out newlines as newlines.

sorry, I didn't mean the yes-newlines but any newlines that could be contained IN the input are instead printed out as \n.  kind of depends on how you read the question :D

@Blauhirn Oh I misunderstood this part :/. You need to call this as ./script $'Hello\n World' to include real newlines. On TIO you can just add a newline to the command line argument

Are the quotations necessary? yes $1 works fine for me

@DrnglVrgs this does not work for me for an empty input

@DrnglVrgs Unless the input contains spaces.

05AB1E, 2 bytes
[,

Try it online!

Why aren't you doing [I,?

@FrodCube: Because unfortunately that doesn't work with empty input :(

@FrodCube: Actually, the question states input of length 0 and not empty input so I can decrease this :)

05AB1E is smart enough to implicitly push inputs. The language I'm using now (Ohm) only does it the first time... After it gets the first input it tries to push the input in the next line and crashes since there is not one

@FrodCube: Yeah, it's a pretty new feature in 05AB1E actually. I'm sure Ohm will get it eventually as well.

[= also works and is a smiley face; the smile is the only benefit lol.

AutoHotkey, 20 Bytes
OP did not specify how the output should happen, said only it has to happen endlessly with a newline after it. AHK was not tailored for cmd interaction. So the output happens repeatedly in a ToolTip at mouse position:

loop
tooltip,%1%`n`n

I like AHK's loop feature. loop repeats the next block forever, loop, 10 would repeat it 10 times. Sometimes I miss this feature in other languages like Python.
The escape character in AutoHotkey is ` (so there are no problems with backslashes in Windows paths). For some reason, a trailing newline is ignored so it is needed twice. (trayTip might not have this "bug" but I cannot test it because running with wine)
old answer:
loop
msgbox,%1%

I just realized that OP probably wont like this solution, the output happens with user-interaction and includes no newlines. I'll look for another way.

Well, you've got my upvote for a creative solution

JavaScript (ES6), 24 bytes
f=a=>f(a,console.log(a))

Try it online!

Ohm, 3 bytes
∞┼,

Try it online!
It doesn't work with an empty input because Ohm is bad at input handling compared to other languages, but you can input "".
Explanation
∞     Infinite loop next code (until ";" or end of line)
 ┼    Get first input
  ,   Println

This looks cool... Could you explain it :D

@BetaDecay done!

FYI, Ohm v2 (hopefully coming soon-ish) will have much better input handling than before!

@NickClifford cool! I'm looking forward to that! I like your language

Oooo... Is Ohm like 05AB1E with different commands?! Fervently starts reading GitHub pages

@carusocomputing Ohm is like 05AB1E with different commands and Jelly-like links

sed, 5
:      # label (unnamed)
p      # print the pattern space
b      # branch back to the label

Unnamed labels is an undocumented "feature" in sed that works with version 4.2.2, but may not work in future versions.

Jelly, 2 bytes
Ṅß

Try it online!
Print with a newline, repeat the whole link (program).

brainfuck, 27 bytes
+[>,]++++++++++[[<]>>[.>]<]

Try it online!

Could you save a byte with ,[>,]++++++++++[[<]>[.>]<]?

Python 2, 21 bytes
def f(s):print s;f(s)

Assumes no recursion limit
Try it online!

V, 2 bytes
òÙ

You can't try this online for obvious reasons.
ò    'Recursively
 Ù   'Duplicate the current line downwards

TIO actually runs for 60 seconds then terminates and prints the STDOUT up until the termination point truncated to the first 128KiB.

In V because the output it inside of an nvim session, and isn't printed to STDOUT until it finishes, TIO kills the session and sees nothing on STDOUT.  I didn't know about what you said, but unfortunately it doesn't fix V

Ahhhh... That's unfortunate, I forgot the properties of V, I've only used it once unsuccessfully.

LibreLogo, 33 bytes
Code:
x=input " repeat [ label x bk 9 ]

Explanation:
x = input "               ; Input Stored in x as String
repeat [                  ; Endless Loop
    label x               ; Print x in Current Position
    bk 9                  ; Move Back 9 pt
]

Result:

Ruby, 18 17 12 + 2 = 14 bytes
Run with the -n flag.
loop{$><<$_}

Edit: Thanks for @sethrin for the -n flag!

Use the -n flag and skip the gets.

@sethrin Nice one! I did not know about this flag!

Cubix, 6 bytes
AN/qvo

Test it here
  A
N / q v
  o

N/A Push Newline(10) and input onto the stack
v redirect into the loop
o/q loop that outputs a character and pushes it to the bottom of the stack continuously

I was going to remove the EOI (-1) indicator from the stack, but it doesn't appear to affect the output any, so have left it saving bytes.

Braingolf, 14 12 bytes
#
V[R!&@v1+]

Try it online!
-2 bytes thanks to totallyhuman
Explanation
#\nV[R!&@v1+]  Implicit input of string as charcodes
#\n            Push charcode of newline
   V           Create stack2
    [R...v1+]  While loop, runs endlessly
      !&@      Print entire stack1 as chars without popping

Python 2, 25 bytes
s=input()
while 1:print s

Try it online!
Input is expected to be a Python literal (quotes for a string, square bracket or parentheses with comma-separated items for a list/tuple, etc.)
Python 3 would be +1 byte because print is a function, but also could do raw input without the 4-byte penalty for raw_input() in Python 2.

Haskell, 14 bytes
cycle.(++"\n")

Try it online!
Append a newline to the input and make list of infinite copies of it.
Alternative version, also 14 bytes:
unlines.repeat

The alternative version is quite elegant :)

Brachylog, 3 bytes
ẉ?↰

Try it online!
Port of my Jelly answer.

PHP, 20 bytes
for(;;)echo"$argn
";

C, 24 bytes
f(char*s){puts(s),f(s);}

Basically a recursive function that outputs the string before calling herself again.
Its my second post on codegolf so please be nice :p

Haskell, 21 bytes
putStr.cycle.(++"\n")

Java 8, 34 bytes
s->{for(;;System.out.println(s));}

Surprised there wasn't a Java answer yet.
Try it here. (Wait 60 second for it to time-out.)

you don't need to wait for it to timeout, it'll reach the max output buffer of 128kb much faster than that :P

@Mayube Perhaps, but it's still running Real time: 60.008 s according to the Debug-section before it outputs the result (and gives two warnings 60-sec limit exceeded and 128kb exceeded).

TIO also caches the results, so once it's been run and hit the timelimit, the output is cached and will simply be served to others who run it without actually re-compiling and running the code

@Mayube True. I didn't knew this also applied to others. Thought it was a local cache. In that case you can ignore the "(Wait 60 second for it to time-out.)" in my answer. :) But if you check on the "disable output cache" setting you'll see it takes ~ 60 seconds.

Perl 5, 27 bytes
while(1){print"$ARGV[0]\n"}

Try it online!

input will always be given, it just might be an empty string, so you should be able to do while(1){print"$ARGV[0]\n"}

@Mayube - thx, updated answer.

Also welcome to ppcg! I fixed the formatting on your answer for you, in the future I totally recommend using Try it online (linked in the edited answer) as it not only makes testing way easier, but can give you a fully formatted ppcg answer to post

@Mayube - thx, glad to be here...

><>, 16 bytes
i:0(?v
:o71.>~a{

Try it online!
As mentioned in the comments below my first attempt may have misunderstood the question so the newer 16 byte solution has been made, I have left the original below so people may see.
><>, 13 bytes
<ov!?+1:i
oa<

Try it online!

I think there's been a bracketing problem: this code returns "that input followed by (a newline endlessly)", while most of the other answers give "(that input followed by a newline) endlessly"…

@Notatree, Thanks for mentioning this, I have updated my answer to respect your comment :)

Nice, my best try was 17 bytes!

@Notatree, I changed the check in the first line from 1+?!v to 0)?v which saved a byte, what was your solution, would be nice to see more ><> answers :) - I also believe with some nifty mirrors you may be able to remove the jump instructions too but haven't figured it out yet.

My solution was:
<v?(0:i
v>~a
>{:o (which isn't formatting properly). The jump is nice — I should start using those more often!

@Notatree, you were really close to the 16 bytes as well, change your second line to a~ then move your last line around 1 to o>{: and you would have made it. the jump is just to cut  out on extra mirrors across lines but yours works just as well :)

Japt, 5 bytes
OpU;ß

Try it online!
Explanation
OpU;     output the input with a newline
    ß    run the code again with the same input

C#, 40 bytes
s=>{for(;;)System.Console.WriteLine(s);}

MATL, 4 bytes
`GDT

Try it Online
Explanation
`     % Do...while loop
  G   % Grab input
  D   % Display it on a new line
  T   % Literal TRUE to create an infinite loop

SAS, 32 bytes
%macro t(s);%put&s;%t(&s);%mend;

PowerShell, 17 bytes
This one taking a reasonable position towards the shorter end of the non-golf-langs:
$f={for(){$args}}

The infinite recursion approach works, at least for a while, but isn't as terse:
$f={($s="$args");& $f $s}

C, 26 bytes
f(char*s){for(;;)puts(s);}

A function, f, that takes a C-style string as a parameter, s. The body of the function loops repeatedly, passing the string to the library function puts, which outputs the string to the standard output (stdout) along with a trailing new-line.
Pretty simple stuff. The only hack here is taking advantage of default-int for the return value and then not actually returning a value. That doesn't matter in this case, though, since the function never returns (it just keeps printing forever)!
Try it online!

f(char*s){puts(s);f(s);} saves a few

CJam, 6 bytes
q{_n}h

Try it online!

@LuisMendo Ooh didn't read that part...

Pyth, 2 bytes
#

Unfortunately I can't remove Q :(
You need to run from command-line like this, so that this is competing:
python3 pyth.py -c "#
"

The interpreter has been fixed too.

Groovy, 20 bytes
x={println it;x(it)}

Does this run forever since it is recursive?

T-SQL, 45 bytes
CREATE PROC r @ TEXT=NULL AS G:PRINT @ GOTO G

Usage
EXECUTE r 'Hello word!'

Husk, 1 byte
∞

Try it online!
In Husk, ∞ builds an infinite list repeating its argument forever. If a full program produces a list of strings as result, they get printed by joining them with newlines.
The wonderful thing about Husk's laziness is that computations involving infinite lists can be managed and used to produce useful output, like in this case :)

Keg, -pn, 2 bytes
{⑩

Try it online!
Forever, print the top of the stack with a newline without popping it.

Aceto, 8 bytes
>v
np
rk

Uses sticky mode to avoid having to duplicate the string.

OIL, 12 bytes
5

4

11
6
2

Read a value into the 0th line, print the value in the 0th line, print a newline, then jump to line 2.

Reticular, 9 bytes
i1=v
1`p>

Try it online!
Explanation:
i1=        Sets variable 1's value to a single line of input read from STDIN
   v       Change direction to down
   >       Change direction to right, wrap from end of line
1`p        1` fetches the value of variable 1, p prints it

Python 3, 22 bytes
while 1:print(input())

Surprised not to have seen a python 3 answer yet.

Welcome to PPCG! This code won't work currently, as it will call input() each time, meaning it will only output the input once. I highly suggest using TIO for testing and formatting your answer, it makes life much easier

I think this is as short as one can get in python3, although I'm not great at python3 golfing, I usually golf in weird esoteric languages

@Mayube Ah, I misunderstood what was required.

Actually, 6 bytes
1W@;.@

Try it online!
Explanation:
1W@;.@  (implicit input)
1       push 1
 W      loop while top of stack is truthy:
  @       move input to top of stack
   ;.     duplicate and print
     @    move 1 to top of stack to continue loop

QBIC, 3 bytes
{?;

Explanation
{      DO
 ?     PRINT
  ;    a string read from the cmd line
       DO is implicitly closed by EOF

What on earth is QBIC in Google Drive for???

@MDXF 'cause I can't handle any other source control solution...

Vim, 6 bytes
Similar solution as the V answer.
Yqqp@q

Go, 46 bytes
import."fmt"
func f(s string){for{Println(s)}}

Try it online!
Recursive approach, 46 bytes
Surprisingly, a recursive approach led to the same byte count.
import."fmt"
func f(s string){Println(s);f(s)}

Try it online!

Avoid the import."fmt" by using the built-in print command: func f(s string){for{print(s+"\n")}}

@chowey That prints to STDERR, not STDOUT.

tcl, 20
while 1 {puts $argv}

demo —  on the green area type
tclsh main.tcl string you want to repeat

where string you want to repeat is the input for program.
DO NOT USE BACKSPACE KEY ON GREEN AREA! It will make browser go back in history.

shortC, 7 bytes
AWJ@[1]

Explanation:
A        main function
 W       while loop
  J      print string with newline
   @[1]  first command line argument

Try it online!

Chip, 19+3 = 22 bytes
+3 for flag -z, which adds an infinite stream of 0x00 bytes to the end of the input.
cCGgbbBAa
fF^~^dDEe

Try it online!
The behavior, in pseudocode:
out_byte := in_byte
if !(in_byte & 0x60) {
    out_byte |= 0x0A
}

Basically, if both bits 0x20 and 0x40 are unset, then either we have a newline character, or we've hit the end of the input. In either case, we just output a newline character and carry on.

Python 3, 26 bytes
a=input()
while 1:print(a)

Try it online!
As simple as it gets.

W, 1 byte
It's not an infinitely-repeating built-in. That will be explained in the explanation.
I

Explanation
With implicit inputs this becomes:
aPI

  I % An infinite loop with the following body:
a   % Take a single input from the arguments
 P  % Implicitly print the inputted argument on every iteration
    % (The above printing only occurs if the operand expression)
    % hasn't been printed before
```

Hy, 34 bytes
(setv a(input))(while 1(print a))

Try it Online!

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


text:
Dodge your death!
Introduction
"Muhuhuhahahah!" The mad scientist laughs. "You're trapped in my own little game!"
In front of you is a deadly pit of snakes, while behind you is a bottomless chasm. There's no way out, you're stuck!
"Two steps in front of you is the snake pit, and two steps behind you is the chasm. But! Before you move, you MUST write down a sequence of steps, forwards and backwards, and give them to me. But! because I'm feeling a bit evil today, I can make you take, instead of every step, every nth step, where n is less than your sequence length!
Choose wisely, now."
What's the maximum number of steps you can take before your imminent death?
Task
The intro above is a twist on the Erdős discrepancy conjecture, which was recently proven true (if you want to understand more about this, go to this video, by James Grime - I "stole" the twist question off of him).
The answer to the intro is 11 steps, but I won't go too in-depth with a proof. The answer, if the distance between you and the two "dangers" were 3 steps, is 1160 steps, although that isn't validated properly yet.
Your task is to make a program that generates the longest sequence of steps you can achieve for a larger x, where x is the number of steps between you and the two "dangers".  Your program must take an input for x, and output a valid sequence for that x.
For the purposes of this challenge, + represents a step forward, and - represents a step back.
So, an output for an input 2 is:
+--+-++--++

Which works, no matter what n the mad scientist chooses. For our challenge, x = 5.
NOTE: This challenge is not a dupe of this challenge or this challenge, as my challenge focuses on the output, as opposed to the code itself - in other words, it's not a code golf challenge. As well as that, these challenges are based off of x = 3, which already has an established upper bound.
Rules:

Your entire program should fit into your answer. However, if it doesn't fit, please provide an additional Github repository, or something similar.
You may update both your answer and your program, if you can get a better score via optimising your code - but by doing so, you must update everything in the list below.
In your answer, you must have:

Your program, in its entirety, or a link to a GH repository hosting your code
The amount of steps generated - this will be your final score.

You must also provide an online version of the sequence in a Pastebin, or something similar. This is so we can check your answer.

The time your final score was last updated, so I don't have to check your history

You may NOT hardcode sequences beforehand.
Your program must work for all x (where x is the number of steps between you and the pit & chasm), but you only need to provide the score for x = 5.

The answer with the largest score wins!

Just to check my understanding, you need a sequence where even if you took every other, or every third element, you survive?

@Notts90 Yup - it musn't just work for that, though. It must work if you took every nth step, where n is any number below your sequence size.

Very closely related. (I called this up as a potential duplicate in the sandbox; I'd have therefore expected the text of the challenge to at least discuss it.)

I think this challenge is impossible, practically speaking. Finding the maximum discrepancy length for x=5 would require a major breakthrough that would be worthy of publication. Consider that the maximum of 1160 for x=3 was proven and published in 2014 and no further values are known..

Is 0 a proper N?

@xnor I'm only asking for people to generate the largest sequence they can, not necessarily the largest sequence possible, so how is the task impossible? Also, how is this a dupe of Dennis's challenge? The goal of my challenge is to generate the longest sequence compared to other answers, while his challenge is a code golf.

@Qwerp-Derp Ah, I'd misunderstood then. When you write "make a program that generates the longest sequence of steps you can", I took "you can" to mean "is mathematically possible", not "the best you can accomplish for your submission".

@xnor Sorry if I sound a bit defensive, I was just trying to prove my stance, and now when I look back at it, it looks defensive...

@ais523 Issue addressed.

@tuskiomi Nope, but even if it were valid it wouldn't make a difference.

I don't understand, that "Your program must work for all x" and "generate the largest sequence you can" seems contradicting. And why do you require the code to be uploaded?

Is +--+-++--+- valid for x=2? The video suggests the only solution is +--+-++--++ but I wrote a brute force method and got both patterns.

@user202729 When I say "your code must work for all x", I mean that your program must output a  valid sequence that follows all of the rules for if the length between you and the dangers are x, given x as an input.

But any sequence that valid for x is valid for x+k for all non negative integer k.

@Notts90 Yes, that is valid.

@user202729 Yeah, I know that... what's your point? Also, the requirement for the code to be uploaded was so 1) The code could be checked against, and 2) I want to look at the code.

Rust, score=4997216, time=2017-07-12 00:18 UTC
This improves on the best result I was able to find in the literature, which was 1148805 (Ronan Le Bras, Carla P. Gomes, Bart Selman, On the Erdős Discrepancy Problem, 2014), by a factor of 4.3.
Output sequence of length 4997216
Source code on GitHub
Running
The program accepts the maximum discrepancy as an argument (this is x − 1 in the language of the challenge, to align with the more common mathematical convention).  It produces incremental outputs in a slightly compressed format that looks like this for x = 3:
$ cargo run --release 2
add +--+-++-++--+-++--+--+-++--+--+-++-++--+-++--+--+-++-++--+-++-++--+-++--+--+-++-++--+-++-+
length 90
delete 12
add --++--+-++-++--+-++--+--+-++--+-
length 110
delete 4
add +-+--+-++-++--+-++--+--+-++-++--+-++-+
length 144
delete 6
add --++-++--+-++--+--++++--+--+-++-++--+-++--+--+-++--+--+-++-++--+-++--+--+-+-
length 214
delete 208
add --+++--+++--+-+--+++--+-+--+++--++---+-+--+-+-++-+--+++--+++--+---++-+--+-++-+++---++--+-++-++--++--+--++--+++--+-+-++-+--+-+--+++---+++-+----+++--+-++--++-+-++--+-+--+-+-++-+--+++--++--+--+--+-++-++---++-++-++-+--+-++
length 224
delete 2
add -+++--+-+--+++---++--+--
length 246
done

where add means append a sequence of signs to the end of the current sequence, delete means remove some number of signs from the end of the current sequence, and length asserts the length of the current sequence.  This scheme avoids the production of many gigabytes of intermediate results as longer and longer sequences are discovered.  You can extract the best result so far with the following Python program:
import sys
s = ''
for line in sys.stdin:
    cmd = line.split()
    if cmd[0] == 'delete': s = s[:-int(cmd[1])]
    elif cmd[0] == 'add': s += cmd[1]
    elif cmd[0] == 'length': assert len(s) == int(cmd[1])
print(s)

How it works
There are about a thousand lines of code here, so this is only going to be a very rough overview.
We limit the search to completely multiplicative sequences (those with f(a·b) = f(a)·f(b)), because that means we need only concern ourselves with bounding the partial sums for n = 1, and the partial sums for n ≥ 2 will satisfy the same bound automatically.
For any substring f(i + 1), …, f(j) of a partially assigned sign sequence (so each element is ‘+’, ‘−’, or unknown), define danger+(i, j) to be twice the number of ‘+’s minus the length j − i (for convenience, we allow i to be as small as −x + 2 and assume f(−x + 3) = ⋯ = f(0) = ‘+’ for this purpose).  Define danger−(i, j) similarly.  Then the bound on partial sums for n = 1 is equivalent to the condition that whenever i ≡ j ≡ x (mod 2), danger+(i, j) ≤ x − 2 and danger−(i, j) ≤ x − 2.
We build an incremental data structure that supports constant time queries for the substring with largest danger, with logarithmic time updates.  It works by associating four values:

danger(i, j),
maxi ≤ k ≤ j danger(i, k),
maxi ≤ k ≤ j danger(k, j), and
maxi ≤ k ≤ l ≤ j danger(k, l),

with every string of length 2, every other string of length 4, every fourth string of length 8, and so on.  The values associated with a longer string can be computed in constant time from the values associated with its two halves.
This structure, augmented with some auxiliary information, lets us perform constraint propagation and conflict detection on partial sequences very quickly.  We use it to do a CDCL-like search, with unit propagation, decision levels, and non-chronological backtracking (but without clause learning, for now), for full sequences of longer and longer lengths.
At each search step, we make a guess for the earliest unassigned sign.  The heuristic used to make this guess is very important for avoiding a lot of backtracking; we use f(3·k) = −f(k), f(3·k + 1) = ‘+’, f(3·k + 2) = ‘−’.
Results
The discrepancy 0, 1, and 2 searches immediately find the optimal completely multiplicative sequences of length 0, 9, and 246.
The discrepancy 3 search gets stuck within seconds at 41319, which is pretty far from the known optimal completely multiplicative sequence of length 127645 found by Le Bras et al., 2014 (and a very slightly longer non-multiplicative extension of length 130000 found shortly thereafter), but much better than the best known sequence before that of length 17000.
The discrepancy 4 search improves the longest sequence more or less continually for about five minutes until it gets stuck at 4997216.  The best previously known sequence of length 1148805 = 9·127645 was expanded from the discrepancy 3 sequence by replacing every sign s with +−−+−++−s.  As far as I can tell, sequences this long are too hard for a general SAT solver to reasonably improve directly (but maybe you, dear reader, can prove me wrong!).
I expect I’ll need to add some kind of clause learning to my program to get past these barriers.
The sequence as a 2187×2285 bitmap
(Click to view at full resolution.)

127465 is for completely multiplicative sequences, right?

"Clause learning"?

See conflict-driven clause learning—it’s how modern SAT solvers work.

What's all the fuzz in the bitmap?

@S.S.Anne Places where the program discovered that a deviation from the heuristic leads to a longer sequence.

Haskell, score=9020, time=2017-06-09 00:52 UTC
f 1=""
f n="+-"++do c<-f(n-1)++"-";"-+-++-"++c:"+-"

Try it online!
This scores (9n − 1 − 1)⋅11/8 for all n.  Here are the first few outputs:
n=1, length=0:
n=2, length=11: +--+-++--+-
n=3, length=110: +--+-++-++--+-++--+--+-++--+--+-++-++--+-++--+--+-++-++--+-++-++--+-++--+--+-++--+--+-++-++--+-++--+--+-++--+-
n=4, length=1001: +--+-++-++--+-++--+--+-++--+--+-++-++--+-++--+--+-++-++--+-++-++--+-++--+--+-++-++--+-++-++--+-++--+--+-++--+--+-++-++--+-++--+--+-++-++--+-++-++--+-++--+--+-++--+--+-++-++--+-++--+--+-++--+--+-++-++--+-++--+--+-++-++--+-++-++--+-++--+--+-++--+--+-++-++--+-++--+--+-++--+--+-++-++--+-++--+--+-++-++--+-++-++--+-++--+--+-++-++--+-++-++--+-++--+--+-++--+--+-++-++--+-++--+--+-++-++--+-++-++--+-++--+--+-++--+--+-++-++--+-++--+--+-++--+--+-++-++--+-++--+--+-++-++--+-++-++--+-++--+--+-++-++--+-++-++--+-++--+--+-++--+--+-++-++--+-++--+--+-++-++--+-++-++--+-++--+--+-++-++--+-++-++--+-++--+--+-++--+--+-++-++--+-++--+--+-++-++--+-++-++--+-++--+--+-++--+--+-++-++--+-++--+--+-++--+--+-++-++--+-++--+--+-++-++--+-++-++--+-++--+--+-++--+--+-++-++--+-++--+--+-++--+--+-++-++--+-++--+--+-++-++--+-++-++--+-++--+--+-++-++--+-++-++--+-++--+--+-++--+--+-++-++--+-++--+--+-++-++--+-++-++--+-++--+--+-++--+--+-++-++--+-++--+--+-++--+--+-++-++--+-++--+--+-++-++--+-++-++--+-++--+--+-++--+--+-++-++--+-++--+--+-++--+-
n=5, length=9020: [encoded data, 9020 characters]


text:
Exploring the xorspace
The xorspace of a set of integers is the set of all integers that can be obtained by combining the starting integers with the usual bitwise xor operator (^). For example, the xorspace of (8, 4) is (0, 4, 8, 12): 0 is 4^4, 12 is 4^8, and no other numbers can be reached. Note that the starting numbers are always included, by this definition (for example, 4 is 4^4^4).
Your goal is to write the shortest program that takes a list of non-negative integers as input, and outputs the number of elements in their xorspace.

Standard loopholes are forbidden.
Input and output can be in any of the usual formats. Input is guaranteed to be valid, non-empty, and without duplicates.
Your code should be able to process all test cases in less than a day.

Test cases
Input: 0
Output: 1

Input: 6
Output: 2

Input: 8 4
Ouput: 4

Input: 0 256
Output: 2

Input: 256 259 3
Output: 4

Input: 60 62 94 101 115
Output: 32

Input: 60 62 94 101 115 40 91
Output: 32

Input: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
Output: 64

Input: 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384
Output: 32768

Pyth, 8 bytes
lu{+xM*Q

Test suite
Explanation:
To generate the xorspace, we find the fixpoint of taking the xor of every pair of numbers, adding in every number, and deduplicating. Then, we take the length of the result. This runs in 20 seconds (offline only) on the final test case.
lu{+xM*Q
lu{+xM*QGGQ    Implicit variable introduction
 u        Q    Find the fixed point of the following, starting with the input,
               where the current value is G.
      *QG      Form the Cartesian product of Q (input) and G (current)
    xM         Take the xor of every pair
   +           Add the current values
  {            Deduplicate
l              Output the length of the result.

Packed Pyth, 7 bytes
Hexdump:
0000000: d9d7 dabf 1355 51                        .....UQ

The same as the above, with a 7-bit ASCII encoding.
Put the above in a file with xxd -r, and run it as follows:
py packed-pyth.py xorspace.ppyth '[256, 259, 3]'

I think you can do l{mxFdy.

@xnor y applied to the 1 through 63 test case is much too slow. I don't have 2^63 memory.

MATL, 11 bytes
t"G!Z~Ghu]n

Try it online!
The last test case doesn't run in the online interpreter because of memory limitations, but runs offline in less than 2 seconds on a modern computer.
Explanation
For input of size n, this does the following:

Initiallize result to input.
Repeat n times:

Apply bitwise XOR to all pair of entries from current result and input.
Attach input values to the result.
Deduplicate.

The output is the number of elements of the final result.

Commented code.
t      % Implicit input: row vector. Duplicate
"      % For each (i.e. do as many times as the input size)
  G!   %   Push input as a column vector
  Z~   %   Bitwise XOR with broadcast, i.e. for all pairs of entries of the
       %   two arguments. The first argument is the accumulated result
       %   from the previous iteration, the second is the input vector
  G    %   Push input again
  h    %   Postpend
  u    %   Unique values. Gives a row vector
]      % End
n      % Number of entries. Implicitly display

Example
The intermediate results (steps 2.1 and 2.3) for input [256 259 3] are:
First iteration: [256 259 3] with [256 259 3]: computing all pairs of bitwise-XOR gives the matrix
  0   3 259
  3   0 256
259 256   0

Attaching [256 259 3] and deduplicating
0 3 259 256

Second iteration: current result [0 3 259 256] with [256 259 3]. After deduplicating this again gives
0 3 259 256

Third iteration: again
0 3 259 256

So the output is 4 (number of entries of result).

Explanation please? You can't use O(2^n).

I have no idea how it works, but it’s definitely not O(2^n). It actually solves the (1 2 3 … 63) test-case pretty quickly, even though it’s the worst-case for the brute-force method.

@EriktheOutgolfer I still don't know what n is, but if it completes the last test case in two sexonds, it's definitely not exponential.

@Dennis I just asked for a proof, I don't dispute anything, it's just that running time is hardware-dependent, so it's not formal proof. ;)

Explanation added

How is this so quick? I've been trying to do pretty much the same in Jelly, but the first attempt got killed after 19 minutes... (Now trying with more RAM.)

I am still a bit confused on how this works. Can you please explain what the program does for, let's say, input of 256 259 3?

@Dennis Perhaps I got something wrong then. Are you deduplicating after each step? How many steps are you applying? I think n suffice, where n, is input size, but I0'm not sure

@KritixiLithos Done

Hm, I was applying the steps until the result no longer changes, but with 32,768 elements, that 16 gibielements in the last check. Only doing n passes would reduce that to 4 gibielements, but since Jelly is rather slow and memory-inefficient, that probably still a no-go.

I believe this is O(2ⁿ) worst case; it's just that in the test that exercises it, n is only 15, so the program still runs fairly quickly.

@ais523 The intermediate numbers obtained from bitwise-XOR can never get greater than the maximum number in the input, call that M. So the size of the vector of intermediate results never exceeds M, and complexity is O(M*M). The OP has said that the exact definition of n doesn't matter, so if I define n as M I can claim this to be O(n*n).

... or is it O(M*M*M)? Well, polynomial in any case

Haskell, 64 bytes
f takes a list of integers and returns an integer.
import Data.Bits
f l|m<-maximum l,m>0=2*f(min<*>xor m<$>l)|0<1=1

Try it online!
This doesn't handle an empty list, for that you can but $0: instead of the space after maximum.
How it works

If the maximum m of the list is zero, returns 1.
Otherwise, xors every element with the maximum.

If the result is smaller than the element, the element is replaced by it.
This necessarily zeroes the most significant bit set anywhere in the list.
Then recurses on the resulting list, doubling the result of the recursion.

This process essentially performs Gaussian elimination (although throwing away the final rows by setting them to 0) modulo 2, on the matrix whose rows are the bit representations of the list of numbers. The set of bit representations of the "xorspace" is the vector space modulo 2 spanned by the rows of this matrix, and whose number of elements is 2 to the power of the matrix's row rank.
This algorithm is polynomial time, so should definitely be better than O(2^n).

This is basically the algorithm I was thinking of (for beating the complexity bounds), although this is a particularly elegant way to represent it. It's nice to see it in a properly golfed answer.

Mathematica, 52 bytes
2^MatrixRank[PadLeft@IntegerDigits[#,2],Modulus->2]&

Why did you delete your Pari/GP answer? It seemed to be working fine. EDIT: nevermind, it failed some test-cases actually.

@Grimy Why did you accept my answer? This is a code-golf, the shortest code wins.

Sorry, I changed the accepted answer to the 7 bytes packed Pyth one.

05AB1E, 8 bytes
vDy^ìÙ}g

Try it online!
All test-cases finish in under 1 minute on TIO.

This fails the last criterion: « Your code should be able to process all test cases in less than a day (no O(2**n) stuff). »

@Grimy: Didn't read the 2^n part :/

@Grimy: Now updated to finish allt test-cases in under 1 minute (and with fewer bytes used)

Was thinking âü^Ùg until I saw you can xor more than once, nice solution.

@carusocomputing: That saves a byte, but I'm not sure about the complexity.

It's not valid as-is (my solution), but I still think Cartesian may be usable without exploding your complexity.

Python 2, 55 bytes
r={0}
for n in input():r|={x^n for x in r}
print len(r)

Try it online!
Beats out functions:
f=lambda l,r={0}:l and f(l[1:],r|{x^l[0]for x in r})or len(r)
f=lambda l:len(reduce(lambda r,n:r|{x^n for x in r},l,{0}))

Ørjan Johansen's beautiful row elimination method is one byte shorter.
Python 2, 54 bytes
f=lambda l:1-any(l)or 2*f([min(x,x^max(l))for x in l])

Try it online!

Jelly, 9 8 bytes
0œ|⁺^¥/L

Finishes all test cases in under 8 seconds on TIO, with negligible memory requirements.
Try it online!
How it works
0œ|⁺^¥/L  Main link. Argument: A (array)

0œ|       Perform multiset union with 0, prepending 0 if A doesn't contain it.
      /   Reduce A by the link to the left.
     ¥      Combine the previous two links into a dyadic chain.
            Left argument: V (array). Right argument: n (integer)
    ^           Bitwise XOR each element in V with n.
   ⁺            This quick refers to the previous link, making it a shorthand for
                the link 'œ|'. Thus, it performs multiset union on V and the array
                of bitwise XORs.
       L  Compute the length of the result.

Python, 113 bytes
def f(x):
 u,s=[0],{0}
 while u:
	a=u.pop()
	for b in x:
	 c=a^b
	 if c not in s:u+=[c]
	 s.add(c)
 return len(s)

It works, but I’m counting 113 bytes; did I miss something?

@totallyhuman that’s probably because you’re counting tabulations as 8 bytes, rather than a single byte.

If the first indentation is a space, next one is a tab, and the last one a tab + a space (or 2 tabs), then it's 113 bytes

@Grimy Actually each tab is 4 spaces not 8.

A full program would be shorter, as it saves a handful of indentation. Also, the for loop can be condensed into a single line, as u+=[c][c in s:] is equivalent to your if statement.

https://tio.run/##FcnLCoQgAEbhdT7Fv1SKiFkKPkkUmBcSQsULNQzz7I6zOvCd@C5n8K/WtLGw9GGcoE5ZrMs2fZYvwX26y6ByMkhR5xgiZWSwIeGA83i6Qwm5H73OQsGH8h@Z11GsauucZ6k1VYwgmVKTx2U8zay1Hw


text:
Appending Numbers
A fairly simple challenge: You will receive two inputs, a string and a number (the number may be taken as a string, ie "123" instead of 123)
If the string does not end in a number (ie, it does not match the regex \d$), just append the number to the end of the string.
If the string does end in a number (ie, it matches the regex \d+$), you should first delete that and then append the number.
Neither of the inputs will ever be invalid or empty (invalid is defined by the numerical input not containing only digits)
The number will never contain a - or a ..
The string will never contain a newline, or unprintable non-whitespace characters.
Test Cases:
abc123 + 345 -> abc345
123 + 1 -> 1
hello + 33 -> hello33
123abc123 + 0 -> 123abc0
ab3d5 + 55 -> ab3d55
onetwo3 + 3 -> onetwo3
99ninenine + 9999 -> 99ninenine9999

Retina, 5 bytes
\d*¶

Takes two strings as input, separated by a newline.
Try it online!

ninja'd. Though I'm not sure if the space is a good separator choice.

Fair enough, changed to a tabulator.

How about a semicolon? That one doesn't need to be escaped either.

Oh, I just read the OP's clarification. Newline it is.

Python 2, 30 bytes
lambda a,b:a.rstrip(`56**7`)+b

Try it online!

Nice trick to create a number with all the digits!

Not sure what is going on, but for me (v2.7.11 on Windows), this fails when a ends with "L" because 56**7 evaluates to 1727094849536L. Input of a="abcdL"; b="59" outputs "abcd59".  Your TIO link does not evaluate 56**7 to a long so I don't know what is happening

PHP, 37 36 35 33 bytes
<?=chop($argv[1],3**39),$argv[2];

Saved 1 byte thanks to Jörg Hülsermann.

chop as alias saves 1 Bytes

Perl 5, 12 bytes
11 bytes code + 1 for -p.
s/\d*$/<>/e

Try it online!

Hehe, came up with exactly the same code! Glab to see you back around :)

Java 8, 32 bytes
a->b->a.replaceAll("\\d*$","")+b

Takes input a as a String, and for b it doesn't matter whether it's a String or integer (although I use Integer in the TIO-link below).
Try it here.

Japt, 10 bytes
r"%d*$" +V

Try it online!
 r"%d*$" +V
Ur"%d*$" +V # Implicit input (U and V)
 r          # Remove
  "%d*$"    #   any trailing digits
U           #   from the first input
         +V # And append the second input
            # Implicit output

Doesn't work if U doesn't end in a number. Try using * in the RegEx, instead of +. TIO

Now it doesn't work if U does end in a number. I think you'll have to do r"%d+$" +V

Yeah, I just realised that. Should be fixed now

Python 2, 44 41 39 bytes
EDIT: -4 bytes thanks to @Dom Hastings. I don't use regular expressions much.
EDIT 2: -2 bytes thanks to @totallyhuman pointing out that the number could be taken as a string
Had to be expected...
lambda x,y:re.sub("\d*$",y,x)
import re

Just removes the digits at the end of the string and appends the number
Try it online!

If you replace your regex with \d*$, can you replace the "" with `y`  to save some bytes?

@DomHastings: Nice! I don't use regular expressions much so thanks!

You can take the y parameter as a string too.

@totallyhuman: Glazed over that detail. Thanks!

Pip, 9 7 bytes
a<|XD.b

@DLosc saved me 2 bytes!
Try it online!
Explanation
a<|         Strip all matches off the end of 'a' (the first cmd line arg)
   XD         of the pattern \d (ordinarily, a regex would be entered as '\d', but digits
              have a pre-existing constant XD)
     .b     Then concatenate 'b' (the second cmd line arg)
            PIP implicitly prints the results of the last operation.

Python 2, 32 bytes
import re
re.compile("\d*$").sub

Try it online!
Takes the inputs in reverse order, both as string.

05AB1E, 9 bytes
DvTFNÜ}}«

Try it online!
Probably a bad solution but it's the best I could come up with
Explanation
DvTFNÜ}}«
Dv     }  # For each character in input1
  TF  }   # 10 times
    NÜ    # Get 0-9 and trim it from input1
        « # Concatenate with input2

Nevermind, I was wrong.

Ruby, 21 bytes
->a,b{a=~/\d*$/;$`+b}

Takes two strings in input.
Try it online!

Jelly, 5 bytes
œrØD;

Try it online!
How it works
œrØD;  Main link. Left argument: s. Right argument: t

  ØD   Digits; yield "0123456789".
œr     Trim these characters from the right of s.
    ;  Append t.

JavaScript (ES6), 28 26 25 bytes
x=>y=>x.replace(/\d*$/,y)

1 byte saved thanks to Neil reminding me why I shouldn't golf early in the morning!

Is the ? required?

C#, 45 bytes
s=>n=>s.TrimEnd("0123456789".ToCharArray())+n

Explanation:
s=>n=>                                        // Take input
      s.TrimEnd(                              // Trim the end of the string with the specified chars
                "0123456789"                  // Create a string of the digits
                            .ToCharArray())   // Turn the string into a char array
                                           +n // Append the integer onto the end

V, 7 4 bytes
óä*î

Try it online!
This uses the same regex as the Retina answer above:
s:/\d*\n//

Perl 6, 20 bytes
->$_,\n{S/\d*$/{n}/}

Tcl 32 bytes
proc s a\ b {regsub \\d*$ $a $b}

I'm not sure about the expected interface. This is done as a procedure that accepts the two inputs as call arguments. To turn it to a standalone script that reads input from stdin and outputs the result to stdout, one would need the extra line:
puts [s [gets stdin] [gets stdin]]

or would do it all "inline":
puts [regsub \\d*$ [gets stdin] [gets stdin]]

regsub takes an RE, the original string and a string to replace the matching part with.

Carrot, 16 21 bytes
$^//^.*?(?=\d*$)/S0^#

Try it online! (input is linefeed separated)
Explanation
$^                Set the stack-string to be equal to the first line in the input
/                 Set the stack-array to be equal to the matches of this regex:
 /^.*?(?=\d*$)/   The beginning of the string followed by non-digit characters at the end that are not included in the match.
S0                Convert to a string with 0 as the delimiter
^#                Append the rest of the input to the stack-string

I had to increase the bytecount by 5 because the code did not work for testcases like a5b3 with multiple digits.

Mathematica, 48 bytes
There is already a Mathematica solution (84 bytes).
StringDrop[StringTrim["."<>#,_?DigitQ..]<>#2,1]&

Haskell, 75 bytes 95 bytes 91 79 61 bytes
b=(`notElem`['0'..'9'])
r=reverse
d#e=r(snd$break b$r d)++e

I tried doing this without regex so maybe that would be a dramatically improved answer.  Also there are a couple ways I could go about this so I am unsure if I can shave a few bytes with a different approach.
UPDATE: I went up in bytes because I realized I was failing the test case where numbers exist in the string that are not the suffix.  Now I am sure that regex would provide a much better answer.
UPDATE2: After some great feedback, more bytes were golfed!

b=(`elem`['0'..'9']) is shorter than isDigit+ import.  dropWhile can be replaced with snd.span, i.e. =r(snd$span b$r d)++e. If you reverse the test b=(`notElem`...) you can go with d#e|b$last$d=d++e|2>1=r(snd$break b$r d)++e.

@nimi Thanks for the suggestions!  I keep forgetting about span and break and how useful those can be.

Can't the |b$last$d=d++e|2>1 part be simply dropped? All the test cases seem to work fine. Try it online!

@Laikoni Great idea!  you just golfed me 18 bytes!

As you can see in the TIO link, b can now be in-lined to save some further bytes.

Finally (\c->c>'/'&&c>':') is shorter than (\notElem`['0'..'9'])`, for a total of 51 bytes: Try it online!

Pointfree (++).r.snd.break(\c->c>'/'&&c>':').r is 46 bytes: Try it online!

@Laikoni I feel thoroughly discouraged at this point.  I have so much to learn.

Don't be! Learning new tricks and things about Haskell I didn't know before are some of my favourite parts of golfing.

AWK, 18 bytes
sub("[0-9 ]*$",$2)

Try it online!
This just replaces a string composed of any number of digits and spaces that ends the arguments to the command with the second argument to the command.  It's effectively stripping the commandline and adding back the second argument.  And since there's guaranteed to be a non-empty second argument, the result is truthy and $0 is printed, which is the modified commandline arguments.

Mathematica, 84 bytes
(k=#;T=ToCharacterCode;L=T@k;While[47<Last@L<58,w=k~StringDrop~-1;k=w;L=T@w];w<>#2)&

input 2 strings

["ab3d5", "55"]

output

ab3d55

Noether, 11 bytes
I"\d+$"-I+P

Try it here!
When inputting a string, enclose it in quotation marks
Explanation:
I       - Push input to stack
"\d+$"  - Push string to stack
-       - Remove characters from first string which match the regex
I       - Push input to stack
+       - Append to the first string
P       - Print top item of stack

C (gcc), 99 98 96 95 bytes
Should be able to golf this down a bit...
main(c,v)char**v;{for(c=strlen(v[1]);~c*isdigit(v[1][--c]);v[1][c]=0);printf(v[1]),puts(v[2]);}

Try it online!

89 bytes

Arturo, 25 bytes
$=>[++replace&{/\d+$}""&]

Try it

Go, 77 bytes
import."strings"
func a(s,n string)string{return TrimRight(s,"0123456789")+n}

Attempt This Online!

05AB1E, 8 bytes
DþRvyÜ}«

Try it online!
Explanation:
DþRvyÜ}«
D        Duplicate input.
 þ       Get the digits of the input.
  R      Reverse the digits of the input.
   v  }  For each of the digits in the input:
    y        Push the current digit
     Ü       Trim that from the right of the input.
       « Concatenate to 2nd input.

Google Sheets, 28 bytes
=REGEXREPLACE(A1,"\d+$",)&B1


text:
9/10 Geometers agree, Nepal has the coolest flag
Given no input, output the following:
 _
| ~-_
| o  ~-_
| ~     ~-_
|    ＼~~~~~~
|  *   ＼
|        ＼
|~~~~~~~~~~＼

Note the backslashes are actually ＼, which is U+FF3C
Trailing whitespace is allowed, however leading whitespace is not.
This is code-golf so fewest bytes in each language wins!

Not as cool as in Let's draw the flag of Nepal. While you ask Unicode character instead of backslash, you could ask for ⏝ U+23dd (bottom parenthesis) instead of tilde under the Sun.

@manatwork would've had I known about said character before-hand, making ascii-art by hand isn't the easiest thing :P

Why don't you use a backslash? Some languages struggle with unicode characters.

@Okx I don't see a problem with that. For example, Print a shuffled deck of cards, my C# answer here was fun to solve because C# struggles with surrogate pairs when creating those strings.

@Okx it makes the challenge a little more interesting

"9/10 Geometers agree" citation please?

Despite my happiness to see my country's flag in codegolf, I must say that this is a very bad ascii rendition of Nepali flag.. :D

Tagged ASCII art, demands non-ASCII characters...

"a little more interesting" Not really IMO. Please explain why.

@TheLethalCoder : Yours or Peter Taylor's answer?

Python 2, 94 92 96 bytes
print(""" _
| ~-_
| o  ~-_
| ~     ~-_
|    ＼~~~~~~
|  *   ＼
|        ＼
|~~~~~~~~~~＼""")

Try it online!

Why the \n at the very end? You don't have to output a trailing new-line.

Also, not sure who downvoted you, but I upvoted to neutralize it. Welcome too PPCG! :)

@KevinCruijssen Sympathy voting isn't recommended. To the OP, I suggest adding a try it online link to an implementation of your answer (see other answers for link/examples), it helps people validate your code.

I'm counting 97 bytes, 89 chars.

@Notts90 does help to downvote & say nothing! Can confirm.

05AB1E, 50 bytes
•ζ1VS¹Tšã¦1d’sΩç!ÙT>_äтÿÀ†{ECZ{Ý•7ÝJ"_ -~|＼*o"‡8¡»

Try it online!

First I created a translation table as follows:
0   | "_"
1   | " "
2   | "-"
3   | "~"
4   | "|"
5   | "＼"
6   | "*"
7   | "o"
8   | "\n"

I then proceeded to replace each unique character in the flag with the number corresponding to the character at that specific position to get the number:
108413208417113208413111113208411115333333841161115841111111158433333333335

Here's the same pattern with the newlines (makes it more obvious):
10
41320
41711320
41311111320
411115333333
41161115
4111111115
433333333335

I then compressed the number into base-255 using 05AB1E (To compress a base-10 number to base 255 simply run 255B in 05AB1E).
Then, see the code explanation for how I rebuild it from the number.

•ζ1VS¹Tšã¦1d’sΩç!ÙT>_äтÿÀ†{ECZ{Ý• # Push the number we discussed.
7ÝJ                               # Push 01234567.
   "_ -~|＼*o"                    # Push "_ -~|＼*o".
              ‡                   # Replace 0-7 with the appropriate block.
               8¡»                # Split on 8's and print with newlines.

I had glanced at base 255 compression but never really understood it. This is great!

This is actually 78 bytes, because this program cannot be encoded in 05AB1E's native encoding and so must be encoded in UTF-8.

Japt, 83 79 78 bytes (UTF-8)
" _
| ~-_
| o  ~-_
| ~     ~-_
|    ＼~~~~~~
|  *   ＼
|{8ç}＼
|{Aç'~}＼

Hardcodes most of the string
Try it online!

SOGL, 49 bytes
⁰∑J“ζ"Ω‰Θx(;╝φ╚○Δ§∆qσG⅛>K█׀IR'ΚΧqΞ⅞≥№█▼¡└+Β8‘# ~ŗ

If the flag used any other character than ~, this would be 4 bytes shorter.

05AB1E, 76 74 72 66 bytes
-6 bytes thanks to @carusocomputing
'~T×ð8×'~6×ð5×" _
| ~-_
| o  ~-_
| ~ÿ~-_
|    ＼ÿ
|  *   ＼
|ÿ＼
|ÿ＼"

String interpolation replaces the ÿs. In order from first to last, it is: 5 spaces, 6 ~s, 8 spaces, and then 10 ~s
Try it online!

This is perfect for String Interpolation! https://tio.run/##MzBNTDJM/f9fvS7k8PTDGywOT1dSiOeqUajTBZH5ClBGnQIIQNhA8H7PnjowAHG1IAJcNYf3Iyil//8B

Basically, what it's doing is the ÿ will pop whatever was previous on the stack and throw it directly into the string, so first we push the 10 tildes followed by the 8 spaces then use two ÿ inside of the string to slam them into it! Saves you 4 bytes and is uncommonly seen ;). A nifty trick few people utilize.

@carusocomputing: Did not notice that. Thanks!

Also, for these types of challenges see my answer here: https://codegolf.stackexchange.com/a/124965/59376 (I only answered to explain base conversion to you =])

C#, 89 bytes
_=>@" _
| ~-_
| o  ~-_
| ~     ~-_
|    ＼~~~~~~
|  *   ＼
|        ＼
|~~~~~~~~~~＼"

Any formatting options in C# for this require too many extra bytes that it is just cheaper to hard code the output as far as I can tell.

is the @ needed? Are there any characters in there that would need to be escaped otherwise?

The @ is needed to tell the compiler the string will wrap onto newlines. That is shorter than hard coding all the line feeds. No chars need escaping.

aaah right, didn't realise @ also allowed a string to be multiline

Jelly, 51 50 bytes
“ ½|~-o*_‘;65340Ọ“ßṆiṣ€|ʂwĊeḌ\<S@DƝbƘ×©ṗþ8¥Ḅ3Zȥ ’ṃ

Try it online!

Java 8, 96 bytes
()->" _\n| ~-_\n| o  ~-_\n| ~     ~-_\n|    ＼~~~~~~\n|  *   ＼\n|        ＼\n|~~~~~~~~~~＼"

Boring, but it probably can't be shortened by using some fancy .replace or loops anyway in Java..
Try it here.

According to the meta post, can't you take an unused argument to save a byte?

@TheLethalCoder Well, I consider the question to be still in process. And since the only answer stating Yes only has 1 upvote so far, I don't think it's valid (yet).

Sounds about right then :)

Mathematica, 84 bytes
"_
| ~-_
| o  ~-_
| ~     ~-_
|    ＼~~~~~~
|  *   ＼
|        ＼
|~~~~~~~~~~＼"

Missing a space between "_?

Bubblegum, 40
Not sure why no-one posted the bubblegum answer yet - Is bubblegum frowned upon these days?
xxd dump:
00000000: 5388 e7aa 51a8 d305 91f9 0a50 469d 0210  S...Q......PF...
00000010: 40d9 40f0 7ecf 9e3a 3000 71b5 2002 1019  @.@.~..:0.q. ...
00000020: 0518 a70e 0e80 5c00                      ......\.

Try it online.

Retina, 60 59 bytes

1_!1~-_!1o2~-_!1~5~-_!4＼""!2*3＼!8＼!"""~＼
"
~~~
!
¶|
\d
$*

Try it online!

Charcoal, 37 bytes
←×~χ↑⁷ _Ｐ¶¶o¶~¶¶ *Ｆ³¶~-_↓←×~⁶Ｆ⁴«＼↘

Try it online! Link is to verbose version of code. Explanation:
←×~χ

Print the bottom ~s.
↑⁷

Print the left |s.
 _Ｐ¶¶o¶~¶¶ *Ｆ³¶~-_

Print the upper right line and the interior decoration.
↓←×~⁶

Print the middle ~s.
Ｆ⁴«＼↘

Print the lower right line.

Deadfish~, 459 bytes
{iii}iic{iiiiii}iiic{{d}ii}dddddc{{i}}{i}iiiic{{d}i}ddc{{i}d}iiiic{{d}ii}dc{iiiii}c{{d}ii}dddddc{{i}}{i}iiiic{{d}i}ddc{{i}dd}dc{{d}ii}icc{{i}d}iiiic{{d}ii}dc{iiiii}c{{d}ii}dddddc{{i}}{i}iiiic{{d}i}ddc{{i}d}iiiic{{d}i}ddddccccc{{i}d}iiiic{{d}ii}dc{iiiii}c{{d}ii}dddddc{{i}}{i}iiiic{{d}i}ddcccc{iiiiii}c{iii}iiiicccccc{{d}}{d}ddddddc{{i}}{i}iiiic{{d}i}ddcc{i}c{d}ccc{iiiiii}c{{d}ii}ddc{{i}}{i}iiiic{{d}i}ddcccccccc{iiiiii}c{{d}ii}ddc{{i}}{i}iiiicii{c}{ddd}ddddc

Try it online!
Uses backslashes instead.