description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
Read problems statements in Mandarin chinese, Russian and Vietnamese as well. Chef has two integers $A$ and $B$. He can perform the following operation on $A$ an arbitrary number of times (including zero): write $A$ as a binary number with an arbitrary number of leading zeroes (possibly without any) shuffle the binar...
x = int(input()) for i in range(x): z = input() z = z.split(" ") a = int(z[0]) b = int(z[1]) if a == b: print(0) elif b == 0: print(-1) elif b == 1: if a == 0: print(1) else: print(-1) else: s = bin(b - 1)[2:].count("1") - b...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NU...
Read problems statements in Mandarin chinese, Russian and Vietnamese as well. Chef has two integers $A$ and $B$. He can perform the following operation on $A$ an arbitrary number of times (including zero): write $A$ as a binary number with an arbitrary number of leading zeroes (possibly without any) shuffle the binar...
t = int(input()) k = -1 for i in range(0, t): a, b = input().split() a = int(a) b = int(b) bq = b - 1 c = bin(a) c = str(c) cc = bin(bq) cc = str(cc) a1 = c.count("1") a0 = c.count("0") b1 = cc.count("1") b0 = cc.count("0") if b == 0 and a != 0: k = -1 eli...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_C...
Read problems statements in Mandarin chinese, Russian and Vietnamese as well. Chef has two integers $A$ and $B$. He can perform the following operation on $A$ an arbitrary number of times (including zero): write $A$ as a binary number with an arbitrary number of leading zeroes (possibly without any) shuffle the binar...
t = int(input()) while t > 0: t -= 1 a, b = input().split(" ") a, b = int(a), int(b) p = (b & -b).bit_length() if b == 0 and a != 0: print("-1") elif a == b: print("0") elif b == 1 and a != 0: print("-1") else: c1 = bin(a).count("1") c2 = bin(b - 1...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL BIN_OP VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR VAR EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FU...
Read problems statements in Mandarin chinese, Russian and Vietnamese as well. Chef has two integers $A$ and $B$. He can perform the following operation on $A$ an arbitrary number of times (including zero): write $A$ as a binary number with an arbitrary number of leading zeroes (possibly without any) shuffle the binar...
def Binary(dec): return bin(dec)[2:] def counter(list01, list02): count11 = 0 count12 = 0 for i in range(0, len(list01)): if list01[i] == 1: count11 += 1 for j in range(0, len(list02)): if list02[j] == 1: count12 += 1 return [count11, count12] t = int(...
FUNC_DEF RETURN FUNC_CALL VAR VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR NUMBER RETURN LIST VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN...
Read problems statements in Mandarin chinese, Russian and Vietnamese as well. Chef has two integers $A$ and $B$. He can perform the following operation on $A$ an arbitrary number of times (including zero): write $A$ as a binary number with an arbitrary number of leading zeroes (possibly without any) shuffle the binar...
def fn(n): b = "{0:b}".format(n) return b.count("1") def bins(a, b): if a == b: return 0 if b == 0: return -1 if b == 1: if a == 0: return 1 else: return -1 c = fn(b - 1) - fn(a) + 1 if c > 0: return c else: return...
FUNC_DEF ASSIGN VAR FUNC_CALL STRING VAR RETURN FUNC_CALL VAR STRING FUNC_DEF IF VAR VAR RETURN NUMBER IF VAR NUMBER RETURN NUMBER IF VAR NUMBER IF VAR NUMBER RETURN NUMBER RETURN NUMBER ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR NUMBER IF VAR NUMBER RETURN VAR RETURN NUMBER ASSIGN VAR F...
Read problems statements in Mandarin chinese, Russian and Vietnamese as well. Chef has two integers $A$ and $B$. He can perform the following operation on $A$ an arbitrary number of times (including zero): write $A$ as a binary number with an arbitrary number of leading zeroes (possibly without any) shuffle the binar...
T = int(input()) for i in range(T): A, B = map(int, input().split()) Abin = str("{0:b}".format(A)) Bbin = str("{0:b}".format(B - 1)) count1B = Bbin.count("1") count1A = Abin.count("1") if B == 0: if A == 0: print(0) else: print(-1) elif A == B: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL STRING VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL STRING BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER IF VAR NUMBER ...
Read problems statements in Mandarin chinese, Russian and Vietnamese as well. Chef has two integers $A$ and $B$. He can perform the following operation on $A$ an arbitrary number of times (including zero): write $A$ as a binary number with an arbitrary number of leading zeroes (possibly without any) shuffle the binar...
def f(a, b): n1 = "{0:b}".format(a) n2 = "{0:b}".format(b - 1) c1, c2 = n1.count("1"), n2.count("1") if c2 >= c1: return 1 + c2 - c1 return 2 t = int(input()) for x1 in range(t): a, b = map(int, input().split()) if a == b: ans = 0 elif a == 0 and b == 1: ans = 1...
FUNC_DEF ASSIGN VAR FUNC_CALL STRING VAR ASSIGN VAR FUNC_CALL STRING BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING IF VAR VAR RETURN BIN_OP BIN_OP NUMBER VAR VAR RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CA...
Read problems statements in Mandarin chinese, Russian and Vietnamese as well. Chef has two integers $A$ and $B$. He can perform the following operation on $A$ an arbitrary number of times (including zero): write $A$ as a binary number with an arbitrary number of leading zeroes (possibly without any) shuffle the binar...
t = int(input()) for i in range(t): z = input().split() z = [int(j) for j in z] a = bin(z[0])[2:] b = bin(z[1])[2:] rev = b[::-1] c = 0 for l in rev: if l == "1": break else: c += 1 c1 = 0 c1 = a.count("1") c2 = b.count("1") if z[0] == ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER ASSIGN VAR NUMBER AS...
Read problems statements in Mandarin chinese, Russian and Vietnamese as well. Chef has two integers $A$ and $B$. He can perform the following operation on $A$ an arbitrary number of times (including zero): write $A$ as a binary number with an arbitrary number of leading zeroes (possibly without any) shuffle the binar...
t = int(input()) for i in range(t): a, b = [int(i) for i in input().split()] bin_a = bin(a) bin_b = bin(b) na = bin_a.count("1") nb = bin_b.count("1") if a == b: print(0) elif a == 0 and b == 1: print(1) elif b == 1 or b == 0: print(-1) elif na == nb: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_...
Read problems statements in Mandarin chinese, Russian and Vietnamese as well. Chef has two integers $A$ and $B$. He can perform the following operation on $A$ an arbitrary number of times (including zero): write $A$ as a binary number with an arbitrary number of leading zeroes (possibly without any) shuffle the binar...
for _ in range(int(input().strip())): a, b = map(int, input().split()) if a == b: print("0") elif b == 0: print("-1") elif b == 1: if a == 0: print("1") else: print("-1") else: c = 0 c1 = 0 d = 0 d1 = 0 d...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
def potu(n): return 2 ** (len(bin(n)) - 3) def f(N, numTurns=0): if N == 1: return numTurns elif potu(N) == N: return f(int(N / 2), numTurns + 1) else: return f(int(N - potu(N)), numTurns + 1) T = int(input()) for i in range(T): N = int(input()) if f(N) % 2 == 1: ...
FUNC_DEF RETURN BIN_OP NUMBER BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER FUNC_DEF NUMBER IF VAR NUMBER RETURN VAR IF FUNC_CALL VAR VAR VAR RETURN FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER RETURN FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR ...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
def moves(n): res = 0 while n % 2 == 0: res += 1 n //= 2 while n != 1: if n % 2 == 1: res += 1 n //= 2 return res for _ in range(int(input())): n = int(input()) print("Richard" if moves(n) % 2 == 0 else "Louise")
FUNC_DEF ASSIGN VAR NUMBER WHILE BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER STRING STRING
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
def counter_game(c): i = 0 while int(c) > 1: tmp = "1" + "0" * (len(c) - 1) if c == tmp: c = tmp[:-1] else: c = bin(int(c, 2) - int(tmp, 2)).lstrip("0b") i += 1 if i % 2 == 0: print("Richard") else: print("Louise") for _ in range(...
FUNC_DEF ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP STRING BIN_OP STRING BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER STRING VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR S...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
def turn(a): t = 0 for i in range(len(a)): if a[i] == "1": t += 1 if t == 2: return "0b" + a[i:] return a[:-1] for i in range(int(input())): n = int(input()) turns = 0 a = bin(n) while a != "0b1": turns += 1 a = turn(a) if...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR NUMBER RETURN BIN_OP STRING VAR VAR RETURN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR STRING VAR NUMBER...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
for t in range(int(input())): k = 0 n = int(input()) d = 2**63 while n > 1: while d >= n: d //= 2 n -= d k += 1 print(["Richard", "Louise"][k % 2])
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER WHILE VAR NUMBER WHILE VAR VAR VAR NUMBER VAR VAR VAR NUMBER EXPR FUNC_CALL VAR LIST STRING STRING BIN_OP VAR NUMBER
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
t = int(input()) while t > 0: n = int(input()) x = bin(n)[2:] winner = 0 while len(x) > 1: if x[1:].count("1") == 0: x = x[: len(x) - 1] else: x = x[1:] while x[0] == "0": x = x[1:] winner = (winner + 1) % 2 if winner == 1: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR NUMBER STRING NUMBER ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER WHILE VAR NUMBER STRING ASSIGN VA...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
T = int(input()) for t in range(T): N = int(input()) N_bin = "{0:064b}".format(N) zero_num = 0 while N_bin[63 - zero_num] == "0": zero_num += 1 one_num = 0 for i in range(64): if N_bin[i] == "1": one_num += 1 a = (one_num - 1 + zero_num) % 2 if a: prin...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL STRING VAR ASSIGN VAR NUMBER WHILE VAR BIN_OP NUMBER VAR STRING VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR STRING VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER V...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
T = int(input()) winner = 0 def is_power2(num): return num != 0 and num & num - 1 == 0 def powerof2(num): i = 0 while i <= 64: if int(num / pow(2, i)) == 0: return i else: i = i + 1 for i in range(0, T): Number = int(input()) winner = 0 if Number == ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FUNC_DEF RETURN VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER NUMBER FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER IF FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VA...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
inputno = int(input()) cases = [] while inputno > 0: inputno -= 1 val = int(input()) cases.append(val) def fiddle(num): binnum = bin(int(num)) strlen = len(binnum) - 2 string = "0b1" + "0" * (strlen - 1) if binnum == string: return num / 2 intofstring = int(string, 2) lasts...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST WHILE VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP STRING BIN_OP STRING BIN_OP VAR NUMBER IF VAR VAR RETURN BIN_O...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
def calculate_new_n(n): for i in range(64, -1, -1): pow_n = 1 << i if pow_n == n: n //= 2 return n if pow_n < n: n -= pow_n return n for _ in range(int(input())): counter = int(input()) current_player = 0 while 1: counter ...
FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER VAR IF VAR VAR VAR NUMBER RETURN VAR IF VAR VAR VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR VA...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
cases = int(input()) def next(val): indx = 0 while 1 < val: val = val >> 1 indx += 1 return 2**indx for i in range(cases): n = int(input()) louise = True while True: if n & n - 1 == 0: n = n >> 1 else: n = n - next(n) if n == 1:...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER WHILE NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER RETURN BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE NUMBER IF BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN V...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
T = int(input()) def lsb(x): n = int(x) count = 0 while n & 1 == 0: n >>= 1 count += 1 return count def nbits(x): n = int(x) count = 0 while n > 0: count += n & 1 n >>= 1 return count def num_ops(N): if N == 1: return 1 else: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR FUNC_DEF IF VAR NUMBER RETURN NUMBER FOR VAR...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
for i in range(int(input())): n = int(input()) binary = str(bin(n))[-1:1:-1] count1 = binary.count("1") count2 = binary.index("1") print("Richard" if (count1 + count2) % 2 == 1 else "Louise")
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER STRING STRING
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
t = int(input()) def run(n): c = 0 while n != 1: j, base = 0, 1 while base * 2 <= n: base *= 2 j += 1 if base == n: c += j break else: c += 1 n -= base if c % 2 == 0: print("Richard") else: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER WHILE BIN_OP VAR NUMBER VAR VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR VAR NUMBER VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
two_powers = [(1 << i) for i in range(64)] def moves(n): if n == 1: return 0 elif n in two_powers: return 1 + moves(n // 2) else: largest_power = 0 for i in reversed(range(len(two_powers))): if n > two_powers[i]: largest_power = two_powers[i] ...
ASSIGN VAR BIN_OP NUMBER VAR VAR FUNC_CALL VAR NUMBER FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR VAR RETURN BIN_OP NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR RETURN BIN_OP NUMBER FUNC_CALL VAR BIN_OP VAR VAR FOR VAR F...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
def f(n): ret = 1 while ret <= n: ret *= 2 return ret // 2 for t in range(int(input())): n, k = int(input()), 0 while True: if n == 1: break if f(n) == n: n //= 2 else: n -= f(n) k ^= 1 print("Richard" if not k else "L...
FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER RETURN BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER WHILE NUMBER IF VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR NUMBER VAR FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR STRING STRING
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
lst = [(2**i) for i in range(65)] for i in range(int(input())): n = int(input()) counter = 0 while n != 1: j = 0 while lst[j + 1] < n: j += 1 n -= lst[j] counter += 1 if counter % 2 == 0: print("Richard") continue print("Louise")
ASSIGN VAR BIN_OP NUMBER VAR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER VAR VAR NUMBER VAR VAR VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
def nextPowerOf2(n): n = n - 1 n = n | n >> 1 n = n | n >> 2 n = n | n >> 4 n = n | n >> 8 n = n | n >> 16 n = n + 1 return n def main(): tt = int(input()) num = [] name = [] for i in range(tt): a = int(input()) num.append(a) for i in range(tt): ...
FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CAL...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
cases = int(input()) s = {(0): "Richard", (1): "Louise"} def solve(n): c = 0 while n != 1: c += 1 if n % 2 == 0: n >>= 1 else: sub = 1 << len(str(bin(n))) - 3 n -= sub print(s[c % 2]) for case in range(cases): n = int(input()) solve(n)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT NUMBER NUMBER STRING STRING FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR BIN_OP NUMBER BIN_OP FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER FOR VAR F...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
for _ in range(int(input())): N = int(input()) - 1 N = (N & 6148914691236517205) + (N >> 1 & 6148914691236517205) N = (N & 3689348814741910323) + (N >> 2 & 3689348814741910323) N = (N & 1085102592571150095) + (N >> 4 & 1085102592571150095) N = (N & 71777214294589695) + (N >> 8 & 71777214294589695) ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BI...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
T = int(input()) for i in range(T): N = int(input()) richard = True while N > 1: richard = not richard k = 1 while 2 * k < N: k = k * 2 N = N - k if richard: print("Richard") else: print("Louise")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE BIN_OP NUMBER VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
for _ in range(int(input())): N = bin(int(input())) p = "Louise" while True: if N.count("1") == 1: N = N[:-1] else: i = N.index("1") N = N[:i] + N[i + 1 :] if N.count("1") == 1 and N[-1] == "1": print(p) break p = "R...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR STRING WHILE NUMBER IF FUNC_CALL VAR STRING NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR STRING NUMBER VAR NUMBER STRING EXPR...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
def is_power_of_two(num): bin_string = bin(num)[2:] if bin_string.count("1") != 1: return False return True def largest_power_of_two_less_than(num): if is_power_of_two(num): return 2 ** (num.bit_length() - 2) else: return 2 ** (num.bit_length() - 1) t = int(input()) for _...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR STRING NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF IF FUNC_CALL VAR VAR RETURN BIN_OP NUMBER BIN_OP FUNC_CALL VAR NUMBER RETURN BIN_OP NUMBER BIN_OP FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VA...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
def isPowerOf2(N): M = N n1 = 0 for i in range(64): if M & 1 == 1: n1 += 1 M = M >> 1 return n1 == 1 def reduceByLargestPowerOf2LessThanN(N): M = N i = 0 while M != 1: i += 1 M = M >> 1 mask = 2**i return N ^ mask def halveN(N): ret...
FUNC_DEF ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR NUMBER FUNC_DEF ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR RETURN BIN_OP VAR VAR FUNC_DEF RETU...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
T = int(input()) for _ in range(T): N = int(input()) one = 1 << 63 count = 0 while N > 1: while one > N: one >>= 1 if N == one: N >>= 1 else: N -= one count += 1 if count % 2 == 0: print("Richard") else: print("L...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER WHILE VAR VAR VAR NUMBER IF VAR VAR VAR NUMBER VAR VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
a = "Louise" b = "Richard" d = int(input()) def ispower(n): for i in range(1, 65): if n == pow(2, i): return True return False def powto(n): if not ispower(n): for i in range(1, 65): if n - pow(2, i) < 0: return pow(2, i - 1) for e in range(d): ...
ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER NUMBER IF VAR FUNC_CALL VAR NUMBER VAR RETURN NUMBER RETURN NUMBER FUNC_DEF IF FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER IF BIN_OP VAR FUNC_CALL VAR NUMBER VAR NUMBER RETURN FUNC_CALL VAR NUMBER ...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
twosList = list(reversed([(2**i) for i in range(64)])) twosSet = {(2**i) for i in range(64)} def powerOfTwo(n): for e in twosList: if e < n: return e N = int(input()) for numTest in range(N): curr = int(input()) ops = 0 while curr != 1: if curr in twosSet: cur...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP NUMBER VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR VAR FUNC_CALL VAR NUMBER FUNC_DEF FOR VAR VAR IF VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR NUMBER IF...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
arr_2_power = [None] * 65 for i in range(1, 65): arr_2_power[i] = 2**i T = int(input()) for t in range(T): counter = int(input()) turn = 0 while counter != 1: turn += 1 if counter in arr_2_power: counter = counter // 2 else: for i in range(1, 65): ...
ASSIGN VAR BIN_OP LIST NONE NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMB...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
def ans(n): p = 1 while n > p: p <<= 1 p >>= 1 return n - p z = int a = input p = print t = z(a()) while t: t -= 1 c = 0 n = z(a()) while n > 1: p = n & n - 1 if p == 0: n >>= 1 else: n = ans(n) c += 1 if c % 2 == 0: ...
FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER VAR NUMBER RETURN BIN_OP VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER IF VAR NUMBER VA...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
def solve(N): c0 = 0 while N > 0 and not N & 1: c0 += 1 N >>= 1 c1 = 0 while N > 0: if N & 1: c1 += 1 N >>= 1 if (c0 + c1) % 2 == 0: return "Louise" else: return "Richard" T = int(input()) for _ in range(T): N = int(input()) p...
FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER RETURN STRING RETURN STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR F...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
T = int(input()) for i in range(T): N = int(input()) bits = list(bin(N))[2:] p = ["Louise", "Richard"] bit_count = bits.count("1") right_zeros = bits[::-1].index("1") print(p[(bit_count + right_zeros) % 2])
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST STRING STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR NUMBER STRING EXPR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
def isp2(val): if not val % 2 == 0: return 0 if val == 2: return 1 while val > 0: val = val / 2 if val == 2: return 1 return 0 def findPower(previous, goal): if previous * 2 > goal: return previous else: return findPower(previous * 2,...
FUNC_DEF IF BIN_OP VAR NUMBER NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF IF BIN_OP VAR NUMBER VAR RETURN VAR RETURN FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
for t in range(int(input())): v = bin(int(input())) names = ["Richard", "Louise"] v = list(map(int, v[2:])) count = 0 while True: i1 = v.index(1) if sum(v) == 1 and i1 == len(v) - 1: break if sum(v) == 1: for i in range(i1, len(v)): v[i...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST STRING STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR VAR NUMBER VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF FUN...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
import sys def run_tests(): T = sys.stdin.readline() for i in range(int(T)): determine_winner(int(sys.stdin.readline())) def determine_winner(N): lastMoveLouise = False while N != 1: if N & N - 1 == 0: N >>= 1 else: N -= 1 << get_highest_bit_position(N...
IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR BIN_OP NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR STRING STRING EXPR...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
def butt(n): i = 0 c = 0 h = 0 while n: if n & 1: c += 1 h = i n >>= 1 i += 1 return c, h T = int(input()) for _ in range(T): N = int(input()) c = 0 dudes = ["Richard", "Louise"] while N > 1: num_bits, highest_bit = butt(N) ...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR IF BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR NUMBER VAR NUMBER RETURN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST STRING STRING WHILE VAR N...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
tests = int(input()) for _ in range(tests): n = int(input()) iterations = 0 while n > 1: iterations += 1 n = n >> 1 if not n & n - 1 else n - 2 ** (n.bit_length() - 1) print("Richard" if not iterations & 1 else "Louise")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR BIN_OP NUMBER BIN_OP FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER STRING STRING
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
def solve(n): powersOfTwo = set() for x in range(64): powersOfTwo.add(1 << x) steps = 0 while n > 1: steps += 1 if not n in powersOfTwo: largestPower = 1 currentPower = 1 t = n while t > 0: if t & 1: ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR NUMBER IF BIN_OP VAR NUMBER ASSIGN VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR NUMBER ...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
def findFirstOneFromLeft(N): for i in range(63, -1, -1): if N >> i & 1 == 1: return i def play(N): i = findFirstOneFromLeft(N) if N == 1 << i: return N >> 1 else: return N & ~(1 << i) def win(N): flag = 1 while N != 1: N = play(N) flag = 1 ...
FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR IF VAR BIN_OP NUMBER VAR RETURN BIN_OP VAR NUMBER RETURN BIN_OP VAR BIN_OP NUMBER VAR FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUM...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
for _ in range(int(input())): a = int(input()) c = 1 while a & 1 == 0: c ^= 1 a >>= 1 while a: if a & 1: c ^= 1 a >>= 1 print("Louise" if c else "Richard")
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER WHILE VAR IF BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR STRING STRING
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
t = int(input()) for case in range(t): n = int(input()) count = 1 while n > 1: count += 1 if n & n - 1 == 0: n >>= 1 else: n -= int("1" + "0" * len(bin(n)[3:]), 2) if count % 2 == 0: print("Louise") else: print("Richard")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER IF BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR FUNC_CALL VAR BIN_OP STRING BIN_OP STRING FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER ...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
def CountMoves(N): C = 0 while N > 1 and N % 2 == 0: N = N // 2 C = C + 1 while N > 1: r = N % 2 if r == 1: C = C + 1 N = (N - r) // 2 return C T = int(input()) while T: T = T - 1 N = int(input()) Moves = CountMoves(N) if Moves % 2 ==...
FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSI...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
def is_power_of_two(n): return n & n - 1 == 0 and n > 0 def largest_power(n): res = 1 while res < n: res <<= 1 return res >> 1 def whois_winner(n): winner = 0 while n != 1: if is_power_of_two(n): n >>= 1 winner ^= 1 else: n -= large...
FUNC_DEF RETURN BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER RETURN BIN_OP VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER IF FUNC_CALL VAR VAR VAR NUMBER VAR NUMBER VAR FUNC_CALL VAR VAR VAR NUMBER RETURN VAR STRING STRING FUNC_DEF ASSIGN VAR FUNC_CALL VAR F...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
class Game(object): def __init__(self, initialvalue): self.counter = initialvalue self.turn = "Richard" def play(self): while not self.winner: if self._pow2(self.counter): self.reduce_by_half() else: self.reduce_by_pow2() ...
CLASS_DEF VAR FUNC_DEF ASSIGN VAR VAR ASSIGN VAR STRING FUNC_DEF WHILE VAR IF FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR RETURN VAR FUNC_DEF EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER FUNC_DEF EXPR FUNC_CALL VAR VAR BIN_OP NUMBER FUNC_CALL VAR VAR FUNC_DEF IF VAR NUMBER RETURN VAR RETURN NUMBER VAR FU...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
for t in range(int(input())): n, z = int(input()), False while n > 1: if n & n - 1 == 0: n = n >> 1 else: t, c = n, 0 while t > 0: t, c = t >> 1, c + 1 n = n - (1 << c - 1) z = not z if z: print("Louise ") el...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR NUMBER WHILE VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER BIN_O...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
def get(n): x = 1 while x * 2 < n: x *= 2 return x T = int(input()) for t in range(T): n = int(input()) for i in range(1000): n -= get(n) if n == 1: if i % 2 == 0: print("Louise") else: print("Richard") bre...
FUNC_DEF ASSIGN VAR NUMBER WHILE BIN_OP VAR NUMBER VAR VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR VAR IF VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR S...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
for i in range(0, int(input())): rWins = True num = int(input()) while num != 1: if num & num - 1 == 0: if (len(bin(num)) - 3) % 2 == 0: break else: rWins = not rWins break else: rWins = not rWins ...
FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER IF BIN_OP VAR BIN_OP VAR NUMBER NUMBER IF BIN_OP BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR BIN_OP NUMBER BIN_OP FUNC_CALL V...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
n = int(input()) for i in range(n): turns = 0 x = bin(int(input())) if False: print("Richard") else: turns += x.count("1") - 1 turns += len(x.split("1")[-1]) print("Louise" if turns % 2 == 1 else "Richard")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR IF NUMBER EXPR FUNC_CALL VAR STRING VAR BIN_OP FUNC_CALL VAR STRING NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER STRING STRING
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
def solve(x): ret = False ii = True for j in bin(x)[:1:-1]: if j == "0": if ii: ret ^= True else: ii = False ret ^= True return ret T = int(input()) for i in range(T): print("Richard" if solve(int(input())) else "Louise")
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER IF VAR STRING IF VAR VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR STRING STRING
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
for t in range(int(input())): n = int(input()) b = bin(n) i = b.count("1") j = len(b.split("1")[-1]) if (i + j) % 2 == 0: print("Louise") else: print("Richard")
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR STRING NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
def is_power_of_two(n): return n != 0 and n & n - 1 == 0 def highest_power_of_two(n): n = n | n >> 1 n = n | n >> 2 n = n | n >> 4 n = n | n >> 8 n = n | n >> 16 return n - (n >> 1) t = int(input()) for i in range(t): n = int(input()) louise = True while n != 1: if is...
FUNC_DEF RETURN VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER NUMBER FUNC_DEF ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER RETURN BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR F...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
for _ in range(int(input())): num = int(input()) turns = 0 while num != 1: low = 1 while low * 2 <= num: low *= 2 if low == num: num = num // 2 else: num -= low turns += 1 print("Richard" if turns % 2 == 0 else "Louise")
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR NUMBER VAR VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER STRING STRING
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
T = int(input()) for i in range(T): N = int(input()) n = 0 while N > 1: count = bin(N).count("1") if count == 1: N = int(N / 2) else: N = N - pow(2, len(bin(N)) - 3) n = (n + 1) % 2 if n == 0: print("Richard") else: print("Louis...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR STRING IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR FUNC_CALL VAR ...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
def makeMove(n): if n <= 1: return None nb = n i, ones = 0, 0 while nb > 0: if nb & 1: ones += 1 i += 1 nb >>= 1 if ones > 1: return n - (1 << i - 1) else: return n >> 1 def playBall(n): rounds = 0 while n: n = makeMov...
FUNC_DEF IF VAR NUMBER RETURN NONE ASSIGN VAR VAR ASSIGN VAR VAR NUMBER NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER RETURN BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBER RETURN BIN_OP VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR NUMB...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
def counter(): T = int(input()) for t in range(0, T): N = int(input()) binN = "{0:b}".format(N) lenBinN = len(binN) if binN.count("1") == 1: if lenBinN % 2 == 0: print("Louise") else: print("Richard") else: ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL STRING VAR ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR STRING NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER WHILE NUMB...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
for test in range(int(input())): N = int(input()) c = 0 while N > 1: b = bin(N)[2:] if b[1:].count("1"): N = int(b[1:], 2) else: N >>= 1 c += 1 print("Louise" if c % 2 else "Richard")
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER STRING STRING
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
def toBin(n): temp = n t = "" top = 0 count = 0 index = 0 while n > 0: if n & 1 == 1: top = index count = count + 1 n >>= 1 index = index + 1 if count == 1: return temp - int(temp / 2) return temp - (1 << top) amount = int(input()...
FUNC_DEF ASSIGN VAR VAR ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER RETURN BIN_OP VAR FUNC_CALL VAR BIN_OP VAR NUMBER RETURN BIN_OP VAR BIN_OP NUMBER...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
for t in range(int(input())): turn = True n = int(input()) powers_of_2 = [ 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER N...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
def is_power_of_2(n): return n & n - 1 == 0 def largest_p2_less(n): b = 1 while b < n: b <<= 1 return b >> 1 t = int(input()) for i in range(t): turn = 0 n = int(input()) c = n if c == 1: print("Richard") else: while c != 1: if is_power_of_2(in...
FUNC_DEF RETURN BIN_OP VAR BIN_OP VAR NUMBER NUMBER FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER RETURN BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING WHILE VAR NUMB...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
def counterGame(n): fs = bin(n)[2:] total = 0 i = len(fs) - 1 while i != -1: if fs[i] != "0": break i -= 1 total += len(fs) - i - 1 + fs[:i].count("1") if total & 1: print("Louise") else: print("Richard") def main(): t = int(input()) whil...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR BIN_OP BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER FUNC_CALL VAR VAR STRING IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING FUNC_DEF ASSIGN ...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
def pow3(a): z = 1 while 2 * z < a: z *= 2 return z r = int(input("")) for g in range(r): turn = "Louise" x = int(input("")) z = x while True: if z == 1: if turn == "Louise": print("Richard") break else: ...
FUNC_DEF ASSIGN VAR NUMBER WHILE BIN_OP NUMBER VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR STRING ASSIGN VAR VAR WHILE NUMBER IF VAR NUMBER IF VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
t = int(input()) for i in range(t): val = int(input()) bin_string = bin(val)[2:] if val == 1: print("Richard") continue moves = 0 while True: bin_len = len(bin_string) num_zeros = sum(1 for val in bin_string if val == "0") if num_zeros == bin_len - 1: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER VAR VAR VAR STRING IF VAR BIN_OP VAR NUMBER IF B...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
t = int(input()) while t > 0: t = t - 1 n = int(input()) m = 0 while n > 1: i = 0 k = 0 while n >> i > 0: k = k + (n >> i & 1) i = i + 1 if k == 1: n = n >> 1 else: n = n - (1 << i - 1) m = m + 1 if m == ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER ASS...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
def f(x): if x == 1: return False if x & x - 1 == 0: return not f(x >> 1) else: return not f(int(bin(x)[3:], 2)) t = int(input()) for _ in range(t): print("Louise" if f(int(input())) else "Richard")
FUNC_DEF IF VAR NUMBER RETURN NUMBER IF BIN_OP VAR BIN_OP VAR NUMBER NUMBER RETURN FUNC_CALL VAR BIN_OP VAR NUMBER RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR STRING STRIN...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
def cntAlt(n): c = 0 while n != 1: t = 1 while t < n: t <<= 1 n -= t >> 1 c += 1 return c for i in range(int(input())): print("Richard" if cntAlt(int(input())) % 2 == 0 else "Louise")
FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER NUMBER STRING STRING
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
def update_n(n): pow_2 = 1 << n.bit_length() - 1 if n == pow_2: return n // 2 else: return n - pow_2 def solve(n): louise_turn = True while n > 1: n = update_n(n) louise_turn = not louise_turn return "Richard" if louise_turn else "Louise" for _ in range(int(in...
FUNC_DEF ASSIGN VAR BIN_OP NUMBER BIN_OP FUNC_CALL VAR NUMBER IF VAR VAR RETURN BIN_OP VAR NUMBER RETURN BIN_OP VAR VAR FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR RETURN VAR STRING STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VA...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
def get_winner(num): binary = bin(num)[2:] num_ones = binary.count("1") num_trailing_zeros = len(binary.split("1")[-1]) num_turns = num_ones - 1 + num_trailing_zeros if num_turns % 2 == 1: return "Louise" else: return "Richard" num = int(input()) for counter_i in range(num): ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR STRING NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR IF BIN_OP VAR NUMBER NUMBER RETURN STRING RETURN STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
def one_places(N): b_str = bin(N)[2:] return [idx for idx, c in enumerate(reversed(b_str)) if c == "1"] def game_result(N): op = one_places(N) return (len(op) - 1 + op[0]) % 2 _players = "Richard", "Louise" T = int(input()) for _ in range(T): N = int(input()) print(_players[game_result(N)])
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR NUMBER RETURN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR STRING FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR RETURN BIN_OP BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER VAR NUMBER NUMBER ASSIGN VAR STRING STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUN...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
t = int(input()) for i in range(t): n = int(input()) end = n & -n turns = bin(n - end).count("1") + bin(end).count("0") - 1 print("Richard Louise".split()[turns % 2])
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL FUNC_CALL VAR BIN_OP VAR VAR STRING FUNC_CALL FUNC_CALL VAR VAR STRING NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING BIN_OP VAR NUMBER
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
import sys t = int(sys.stdin.readline().strip()) for tests in range(t): n = int(sys.stdin.readline().strip()) turns = 0 while n > 1: msb = 1 << len(bin(n)) - 3 if msb & n - 1 == 0: n = n >> 1 else: n = n - msb turns += 1 if turns % 2 == 0: ...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP NUMBER BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER IF BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
t = int(input()) for _ in range(t): n = int(input()) res = 0 while n > 1: if "1" not in str(bin(n))[3:]: n >>= 1 else: n -= int("1" + "0" * len(str(bin(n))[3:]), 2) res += 1 if res % 2: print("Louise") else: print("Richard")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR NUMBER IF STRING FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR FUNC_CALL VAR BIN_OP STRING BIN_OP STRING FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER NUMBER VAR NUMBER IF B...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
def testpower(n): power = False t = 1 while t < n: t <<= 1 if t == n: power = True return power, t >> 1 T = int(input()) for _ in range(T): n = int(input()) p = 0 while n ^ 1: power, below = testpower(n) if power: n >>= 1 else: ...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER RETURN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR IF VAR VAR NU...
Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of $2$. If it is, they divide it by $2$. If not, they reduce it by the next lower number which is a power of $2$. Whoever reduces the number to $1$ wins the game. Louise always starts. Given an initial value, de...
T = int(input()) for Ti in range(T): N = int(input()) result = 0 zero = True while zero: N, R = divmod(N, 2) zero = R == 0 if zero: result += 1 while N > 0: N, R = divmod(N, 2) if R == 1: result += 1 print("Richard" if result % 2 ==...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR VAR NUMBER WHILE VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUN...
Let's call an array $a_1, a_2, \dots, a_m$ of nonnegative integer numbers good if $a_1 + a_2 + \dots + a_m = 2\cdot(a_1 \oplus a_2 \oplus \dots \oplus a_m)$, where $\oplus$ denotes the bitwise XOR operation. For example, array $[1, 2, 3, 6]$ is good, as $1 + 2 + 3 + 6 = 12 = 2\cdot 6 = 2\cdot (1\oplus 2 \oplus 3 \oplu...
for _ in range(int(input())): n = int(input()) l = list(map(int, input().split())) sum1 = 0 x = 0 for i in range(n): sum1 += l[i] x ^= l[i] print(2) print(x, sum1 + x)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR VAR
Let's call an array $a_1, a_2, \dots, a_m$ of nonnegative integer numbers good if $a_1 + a_2 + \dots + a_m = 2\cdot(a_1 \oplus a_2 \oplus \dots \oplus a_m)$, where $\oplus$ denotes the bitwise XOR operation. For example, array $[1, 2, 3, 6]$ is good, as $1 + 2 + 3 + 6 = 12 = 2\cdot 6 = 2\cdot (1\oplus 2 \oplus 3 \oplu...
def inp(dtype=str, strip=True): s = input() res = [dtype(p) for p in s.split()] res = res[0] if len(res) == 1 and strip else res return res def problem3(): t = inp(int) for _ in range(t): n = inp(int) a = inp(int, strip=False) a_sum = sum(a) a_xor = a[0] ...
FUNC_DEF VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR VAR NUMBER VAR RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSI...
Let's call an array $a_1, a_2, \dots, a_m$ of nonnegative integer numbers good if $a_1 + a_2 + \dots + a_m = 2\cdot(a_1 \oplus a_2 \oplus \dots \oplus a_m)$, where $\oplus$ denotes the bitwise XOR operation. For example, array $[1, 2, 3, 6]$ is good, as $1 + 2 + 3 + 6 = 12 = 2\cdot 6 = 2\cdot (1\oplus 2 \oplus 3 \oplu...
import sys input = sys.stdin.readline t = int(input()) for you in range(t): n = int(input()) l = input().split() li = [int(i) for i in l] xori = 0 for i in li: xori ^= i sumi = sum(li) print(3) print(xori, xori + sumi, 0)
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP...
Let's call an array $a_1, a_2, \dots, a_m$ of nonnegative integer numbers good if $a_1 + a_2 + \dots + a_m = 2\cdot(a_1 \oplus a_2 \oplus \dots \oplus a_m)$, where $\oplus$ denotes the bitwise XOR operation. For example, array $[1, 2, 3, 6]$ is good, as $1 + 2 + 3 + 6 = 12 = 2\cdot 6 = 2\cdot (1\oplus 2 \oplus 3 \oplu...
results = [] for i in range(1, int(input()) + 1): xorsum = 0 numlens = int(input()) array = input().split() numbers = [int(x) for x in array] if numlens == 1: xorsum = numbers[0] else: for i in range(0, numlens): xorsum = xorsum ^ numbers[i] if sum(numbers) == xor...
ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR VAR IF FU...
Let's call an array $a_1, a_2, \dots, a_m$ of nonnegative integer numbers good if $a_1 + a_2 + \dots + a_m = 2\cdot(a_1 \oplus a_2 \oplus \dots \oplus a_m)$, where $\oplus$ denotes the bitwise XOR operation. For example, array $[1, 2, 3, 6]$ is good, as $1 + 2 + 3 + 6 = 12 = 2\cdot 6 = 2\cdot (1\oplus 2 \oplus 3 \oplu...
import sys input = sys.stdin.readline Q = int(input()) Query = [] for _ in range(Q): N = int(input()) A = list(map(int, input().split())) Query.append((N, A)) for N, A in Query: x = 0 s = 0 for a in A: x ^= a s += a t = s % 2 + (1 << 50) s += t x ^= t d = (2 * x ...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR FOR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR VAR VAR VAR ASSI...
Let's call an array $a_1, a_2, \dots, a_m$ of nonnegative integer numbers good if $a_1 + a_2 + \dots + a_m = 2\cdot(a_1 \oplus a_2 \oplus \dots \oplus a_m)$, where $\oplus$ denotes the bitwise XOR operation. For example, array $[1, 2, 3, 6]$ is good, as $1 + 2 + 3 + 6 = 12 = 2\cdot 6 = 2\cdot (1\oplus 2 \oplus 3 \oplu...
t = int(input()) for q in range(t): n = int(input()) lst = [int(i) for i in input().split()] s, xor = sum(lst), lst[0] for i in range(1, len(lst)): xor ^= lst[i] if 2 * xor == s: print(0) else: print(2) print(xor, s + xor)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR VAR VAR VAR IF BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR ...
Let's call an array $a_1, a_2, \dots, a_m$ of nonnegative integer numbers good if $a_1 + a_2 + \dots + a_m = 2\cdot(a_1 \oplus a_2 \oplus \dots \oplus a_m)$, where $\oplus$ denotes the bitwise XOR operation. For example, array $[1, 2, 3, 6]$ is good, as $1 + 2 + 3 + 6 = 12 = 2\cdot 6 = 2\cdot (1\oplus 2 \oplus 3 \oplu...
t = int(input()) for I in range(t): n = int(input()) li = list(map(int, input().split())) sum1 = 0 x = 0 for pp in li: num = int(pp) sum1 += int(num) x ^= int(num) print(2) print(str(x) + " " + str(sum1 + x))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EX...
Let's call an array $a_1, a_2, \dots, a_m$ of nonnegative integer numbers good if $a_1 + a_2 + \dots + a_m = 2\cdot(a_1 \oplus a_2 \oplus \dots \oplus a_m)$, where $\oplus$ denotes the bitwise XOR operation. For example, array $[1, 2, 3, 6]$ is good, as $1 + 2 + 3 + 6 = 12 = 2\cdot 6 = 2\cdot (1\oplus 2 \oplus 3 \oplu...
t = int(input()) def xor(A): x = 0 for i in range(len(A)): x = A[i] ^ x return x for i in range(t): n = int(input()) A = list(map(int, input().split())) x = sum(A) y = xor(A) print(2) print(y, x + y)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR F...
Let's call an array $a_1, a_2, \dots, a_m$ of nonnegative integer numbers good if $a_1 + a_2 + \dots + a_m = 2\cdot(a_1 \oplus a_2 \oplus \dots \oplus a_m)$, where $\oplus$ denotes the bitwise XOR operation. For example, array $[1, 2, 3, 6]$ is good, as $1 + 2 + 3 + 6 = 12 = 2\cdot 6 = 2\cdot (1\oplus 2 \oplus 3 \oplu...
t = int(input()) for _ in range(t): n = int(input()) a = list(map(int, input().strip().split())) vs = sum(a) xor = 0 for e in a: xor = xor ^ e print(2) print(xor, vs + xor)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_O...
Let's call an array $a_1, a_2, \dots, a_m$ of nonnegative integer numbers good if $a_1 + a_2 + \dots + a_m = 2\cdot(a_1 \oplus a_2 \oplus \dots \oplus a_m)$, where $\oplus$ denotes the bitwise XOR operation. For example, array $[1, 2, 3, 6]$ is good, as $1 + 2 + 3 + 6 = 12 = 2\cdot 6 = 2\cdot (1\oplus 2 \oplus 3 \oplu...
t = int(input()) while t: n = int(input()) l = list(map(int, input().split())) S = sum(l) X = 0 for i in range(n): X = X ^ l[i] temp = [] count = 0 if S == 2 * X: print(count) else: print(2) temp.append(X) temp.append(S + X) print(*temp...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER IF VAR BIN_OP NUMBER VAR EXP...
Let's call an array $a_1, a_2, \dots, a_m$ of nonnegative integer numbers good if $a_1 + a_2 + \dots + a_m = 2\cdot(a_1 \oplus a_2 \oplus \dots \oplus a_m)$, where $\oplus$ denotes the bitwise XOR operation. For example, array $[1, 2, 3, 6]$ is good, as $1 + 2 + 3 + 6 = 12 = 2\cdot 6 = 2\cdot (1\oplus 2 \oplus 3 \oplu...
def solve(xr, sm): k = [] if 2 * xr == sm: return [] else: k.append(xr) k.append(sm + xr) return k for _ in range(int(input())): n = int(input()) l = list(map(int, input().split())) xr = 0 sm = 0 for i in l: xr = xr ^ i sm += i z = so...
FUNC_DEF ASSIGN VAR LIST IF BIN_OP NUMBER VAR VAR RETURN LIST EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBE...
Let's call an array $a_1, a_2, \dots, a_m$ of nonnegative integer numbers good if $a_1 + a_2 + \dots + a_m = 2\cdot(a_1 \oplus a_2 \oplus \dots \oplus a_m)$, where $\oplus$ denotes the bitwise XOR operation. For example, array $[1, 2, 3, 6]$ is good, as $1 + 2 + 3 + 6 = 12 = 2\cdot 6 = 2\cdot (1\oplus 2 \oplus 3 \oplu...
def main(): for t in range(0, int(input())): n = input() arr = list(map(int, input().split())) bin_arr = [] for x in arr: bin_arr.append(num_bin(x)) xor_sum = bin_arr[0] add_count = 0 nums_added = [] for x in range(1, len(bin_arr)): ...
FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VA...
Let's call an array $a_1, a_2, \dots, a_m$ of nonnegative integer numbers good if $a_1 + a_2 + \dots + a_m = 2\cdot(a_1 \oplus a_2 \oplus \dots \oplus a_m)$, where $\oplus$ denotes the bitwise XOR operation. For example, array $[1, 2, 3, 6]$ is good, as $1 + 2 + 3 + 6 = 12 = 2\cdot 6 = 2\cdot (1\oplus 2 \oplus 3 \oplu...
def xor(s): ans = 0 for i in s: ans ^= i return ans T = int(input()) for case in range(T): n = int(input()) s = list(map(int, input().split())) a = sum(s) b = xor(s) if a == 2 * b: ans = [] else: ans = [b, a + b] print(len(ans)) print(*ans)
FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR BIN_OP NUMBER VAR ASSIGN V...
Let's call an array $a_1, a_2, \dots, a_m$ of nonnegative integer numbers good if $a_1 + a_2 + \dots + a_m = 2\cdot(a_1 \oplus a_2 \oplus \dots \oplus a_m)$, where $\oplus$ denotes the bitwise XOR operation. For example, array $[1, 2, 3, 6]$ is good, as $1 + 2 + 3 + 6 = 12 = 2\cdot 6 = 2\cdot (1\oplus 2 \oplus 3 \oplu...
import sys t = int(input()) for i in range(t): n = int(input()) arr = list(map(int, input().rstrip().split())) x = [] xor = 0 s = 0 for j in range(n): xor = xor ^ arr[j] s = s + arr[j] if 2 * xor == s: print("0") print("") else: print("2") ...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VA...
Let's call an array $a_1, a_2, \dots, a_m$ of nonnegative integer numbers good if $a_1 + a_2 + \dots + a_m = 2\cdot(a_1 \oplus a_2 \oplus \dots \oplus a_m)$, where $\oplus$ denotes the bitwise XOR operation. For example, array $[1, 2, 3, 6]$ is good, as $1 + 2 + 3 + 6 = 12 = 2\cdot 6 = 2\cdot (1\oplus 2 \oplus 3 \oplu...
def solve(): n = int(input()) arr = [int(x) for x in input().split()] xor = 0 for x in arr: xor ^= x arr.append(xor) sm = sum(arr) arr.append(sm) print(2) print(xor, sm) t = int(input()) for _ in range(t): solve()
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FU...
Let's call an array $a_1, a_2, \dots, a_m$ of nonnegative integer numbers good if $a_1 + a_2 + \dots + a_m = 2\cdot(a_1 \oplus a_2 \oplus \dots \oplus a_m)$, where $\oplus$ denotes the bitwise XOR operation. For example, array $[1, 2, 3, 6]$ is good, as $1 + 2 + 3 + 6 = 12 = 2\cdot 6 = 2\cdot (1\oplus 2 \oplus 3 \oplu...
for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) res = sum(a) xor = a[0] ans = [] for i in range(1, n): xor ^= a[i] if res == 2 * xor: print(0) print("") else: ans.append(xor) ans.append(res + xor) print(le...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR IF VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR NUMBER E...
Let's call an array $a_1, a_2, \dots, a_m$ of nonnegative integer numbers good if $a_1 + a_2 + \dots + a_m = 2\cdot(a_1 \oplus a_2 \oplus \dots \oplus a_m)$, where $\oplus$ denotes the bitwise XOR operation. For example, array $[1, 2, 3, 6]$ is good, as $1 + 2 + 3 + 6 = 12 = 2\cdot 6 = 2\cdot (1\oplus 2 \oplus 3 \oplu...
from sys import stdin def rl(): return [int(w) for w in stdin.readline().split()] (t,) = rl() for _ in range(t): (n,) = rl() a = rl() x = y = 0 for ai in a: x += ai y ^= ai print(2) print(y, x + y)
FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER FOR VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR VAR
Let's call an array $a_1, a_2, \dots, a_m$ of nonnegative integer numbers good if $a_1 + a_2 + \dots + a_m = 2\cdot(a_1 \oplus a_2 \oplus \dots \oplus a_m)$, where $\oplus$ denotes the bitwise XOR operation. For example, array $[1, 2, 3, 6]$ is good, as $1 + 2 + 3 + 6 = 12 = 2\cdot 6 = 2\cdot (1\oplus 2 \oplus 3 \oplu...
def main(): answer = "" for test in range(int(input())): n = int(input()) array = list(map(int, input().split(" "))) xor = 0 for num in array: xor = xor ^ num summ = sum(array) if summ % 2 == 0: firstelement = 288230376151711744 els...
FUNC_DEF ASSIGN VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER...