description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
Given an integer N, Chef wants to find the smallest positive integer M such that the bitwise XOR of M and M+1 is N. If no such M exists output -1. -----Input----- The first line of input contain an integer T denoting the number of test cases. Each of the following T lines contains an integer N for that test case. ---...
for _ in range(int(input())): n = int(input()) if n == 1: print(2) elif n + 1 & n == 0: print(n // 2) else: print(-1)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER
Given an integer N, Chef wants to find the smallest positive integer M such that the bitwise XOR of M and M+1 is N. If no such M exists output -1. -----Input----- The first line of input contain an integer T denoting the number of test cases. Each of the following T lines contains an integer N for that test case. ---...
try: primes = ["1"] for i in range(2, 31): primes.append(primes[0] * i) for _ in range(int(input())): given = int(input()) if given == 1: print("2") continue x = bin(given)[2:] if x in primes: print(int("1" * (len(x) - 1), 2)) ...
ASSIGN VAR LIST STRING FOR VAR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP STRI...
Given an integer N, Chef wants to find the smallest positive integer M such that the bitwise XOR of M and M+1 is N. If no such M exists output -1. -----Input----- The first line of input contain an integer T denoting the number of test cases. Each of the following T lines contains an integer N for that test case. ---...
def read(): return input().strip() def readint(): return int(read()) t = readint() for i in range(0, t): n = readint() if n == 1: print(2) continue if n % 2 == 0: print(-1) else: isFound = True for j in range(0, 32): if n == (1 << j) - 1: ...
FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER IF VA...
Given an integer N, Chef wants to find the smallest positive integer M such that the bitwise XOR of M and M+1 is N. If no such M exists output -1. -----Input----- The first line of input contain an integer T denoting the number of test cases. Each of the following T lines contains an integer N for that test case. ---...
for i in range(int(input())): n = int(input()) t = -1 for j in range(30): if n == 2**j - 1: t = j break if t == 1: print(2) elif t == -1: print(-1) else: print(2 ** (t - 1) - 1)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER BIN_OP VAR...
Given an integer N, Chef wants to find the smallest positive integer M such that the bitwise XOR of M and M+1 is N. If no such M exists output -1. -----Input----- The first line of input contain an integer T denoting the number of test cases. Each of the following T lines contains an integer N for that test case. ---...
a = [ 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575, 2097151, 4194303, 8388607, 16777215, 33554431, 67108863, 134217727, 268435455, 53687...
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 NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL V...
Given an integer N, Chef wants to find the smallest positive integer M such that the bitwise XOR of M and M+1 is N. If no such M exists output -1. -----Input----- The first line of input contain an integer T denoting the number of test cases. Each of the following T lines contains an integer N for that test case. ---...
for _ in range(int(input())): curr = int(input()) if bin(curr)[2:].count("0") > 0: print(-1) else: print([curr // 2, 2][curr == 1])
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF FUNC_CALL FUNC_CALL VAR VAR NUMBER STRING NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR LIST BIN_OP VAR NUMBER NUMBER VAR NUMBER
Given an integer N, Chef wants to find the smallest positive integer M such that the bitwise XOR of M and M+1 is N. If no such M exists output -1. -----Input----- The first line of input contain an integer T denoting the number of test cases. Each of the following T lines contains an integer N for that test case. ---...
for _ in range(int(input())): n = int(input()) flag = 0 if n == 1: print(2) continue for i in range(1, 31): ans = 1 << i if ans ^ ans - 1 == n: print(ans - 1) flag = 1 if flag == 0: print(-1)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER VAR IF BIN_OP VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER EXP...
Given an integer N, Chef wants to find the smallest positive integer M such that the bitwise XOR of M and M+1 is N. If no such M exists output -1. -----Input----- The first line of input contain an integer T denoting the number of test cases. Each of the following T lines contains an integer N for that test case. ---...
numb = [] for i in range(31): numb.append(str(2**i - 1)) for _ in range(int(input())): n = input() if n == "1": print(2) elif n in numb: print(int(n, 10) // 2) else: print(-1)
ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF VAR STRING EXPR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER
Given an integer N, Chef wants to find the smallest positive integer M such that the bitwise XOR of M and M+1 is N. If no such M exists output -1. -----Input----- The first line of input contain an integer T denoting the number of test cases. Each of the following T lines contains an integer N for that test case. ---...
for _ in range(int(input())): n = int(input()) if n == 1: print("2") elif n % 2 == 0: print(-1) else: x = bin(n)[2:].count("0") if x == 0: ans = n // 2 print(ans) else: print(-1)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER STRING IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR...
Given an integer N, Chef wants to find the smallest positive integer M such that the bitwise XOR of M and M+1 is N. If no such M exists output -1. -----Input----- The first line of input contain an integer T denoting the number of test cases. Each of the following T lines contains an integer N for that test case. ---...
for i in range(int(input())): n = int(input()) if n == 1: print(2) elif n % 2 == 0: print(-1) else: m = n while m > 1: m = m // 2 if m % 2 == 0: print(-1) break else: print(n // 2)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN...
Given an integer N, Chef wants to find the smallest positive integer M such that the bitwise XOR of M and M+1 is N. If no such M exists output -1. -----Input----- The first line of input contain an integer T denoting the number of test cases. Each of the following T lines contains an integer N for that test case. ---...
t = int(input()) for i in range(t): flag = True n = int(input()) if n == 1: print(2) else: m = int(n / 2) if m ^ m + 1 == n: print(m) else: print(-1)
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 IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER
Given an integer N, Chef wants to find the smallest positive integer M such that the bitwise XOR of M and M+1 is N. If no such M exists output -1. -----Input----- The first line of input contain an integer T denoting the number of test cases. Each of the following T lines contains an integer N for that test case. ---...
for _ in range(int(input())): l = int(input()) if l == 1: print(2) continue t_1 = list(bin(l)[2:]) flag = 0 for i in range(len(t_1) - 1, 0, -1): if flag == 1 and t_1[i] == "1": break if t_1[i] == t_1[i - 1] and t_1[i] == "1": continue e...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF VAR NUMBER VAR VAR STRING IF VAR VAR VAR BIN_OP VAR ...
Given an integer N, Chef wants to find the smallest positive integer M such that the bitwise XOR of M and M+1 is N. If no such M exists output -1. -----Input----- The first line of input contain an integer T denoting the number of test cases. Each of the following T lines contains an integer N for that test case. ---...
d = {(1): 0} st = 1 prev = 1 while True: new = st + st + 1 d[new] = prev prev = new st = new if st > 2 * 2**30: break for _ in range(int(input())): n = int(input()) if n == 1: print(2) else: try: print(d[n]) except: print(-1)
ASSIGN VAR DICT NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR IF VAR BIN_OP NUMBER BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FU...
You are given two integers N and K. Find number of ordered triplets (A, B, C) that satisfy the following conditions: 0 ≤ A, B, C < 2^{N} A, B and C are distinct A \oplus B \oplus C = K Here, \oplus denotes the [bitwise XOR operation]. ------ Input Format ------ - The first line contains a single integer T — the num...
t = int(input()) while t > 0: t = t - 1 n, k = map(int, input().split()) max = 1 << n print((max - 1) * (max - 2))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER
You are given two integers N and K. Find number of ordered triplets (A, B, C) that satisfy the following conditions: 0 ≤ A, B, C < 2^{N} A, B and C are distinct A \oplus B \oplus C = K Here, \oplus denotes the [bitwise XOR operation]. ------ Input Format ------ - The first line contains a single integer T — the num...
for _ in range(int(input())): a, b = [int(i) for i in input().split()] res = pow(2, a) - 1 print(int(res * (res - 1)))
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER
You are given two integers N and K. Find number of ordered triplets (A, B, C) that satisfy the following conditions: 0 ≤ A, B, C < 2^{N} A, B and C are distinct A \oplus B \oplus C = K Here, \oplus denotes the [bitwise XOR operation]. ------ Input Format ------ - The first line contains a single integer T — the num...
t = int(input()) for i in range(t): n, k = map(int, input().split()) a = 2**n - 1 b = 2**n - 2 print(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 BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR
You are given two integers N and K. Find number of ordered triplets (A, B, C) that satisfy the following conditions: 0 ≤ A, B, C < 2^{N} A, B and C are distinct A \oplus B \oplus C = K Here, \oplus denotes the [bitwise XOR operation]. ------ Input Format ------ - The first line contains a single integer T — the num...
def Binexp(a, n): ans = 1 while n > 0: if n & 1: ans *= a a *= a n >>= 1 return ans def solve(): n, k = map(int, input().split()) ans = (Binexp(2, n) - 1) * (Binexp(2, n) - 2) return ans for _ in range(int(input())): print(solve())
FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER VAR VAR VAR VAR VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR NUMBER VAR NUMBER BIN_OP FUNC_CALL VAR NUMBER VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CAL...
You are given two integers N and K. Find number of ordered triplets (A, B, C) that satisfy the following conditions: 0 ≤ A, B, C < 2^{N} A, B and C are distinct A \oplus B \oplus C = K Here, \oplus denotes the [bitwise XOR operation]. ------ Input Format ------ - The first line contains a single integer T — the num...
t1 = int(input()) for i in range(t1): n1, k1 = map(int, input().split()) ans = 1 a1 = n1 while a1 != 0: ans *= 4 a1 -= 1 ans -= ((1 << n1) - 1) * 3 print(ans - 1)
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 NUMBER ASSIGN VAR VAR WHILE VAR NUMBER VAR NUMBER VAR NUMBER VAR BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER
You are given two integers N and K. Find number of ordered triplets (A, B, C) that satisfy the following conditions: 0 ≤ A, B, C < 2^{N} A, B and C are distinct A \oplus B \oplus C = K Here, \oplus denotes the [bitwise XOR operation]. ------ Input Format ------ - The first line contains a single integer T — the num...
MOD = 1000000007 t = int(input()) while t > 0: N, K = map(int, input().split()) max = 1 << N print((max - 1) * (max - 2)) t -= 1
ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER
You are given two integers N and K. Find number of ordered triplets (A, B, C) that satisfy the following conditions: 0 ≤ A, B, C < 2^{N} A, B and C are distinct A \oplus B \oplus C = K Here, \oplus denotes the [bitwise XOR operation]. ------ Input Format ------ - The first line contains a single integer T — the num...
for t in range(int(input())): n, k = list(int(i) for i in input().split()) l = len(bin(k)) l -= 2 if l > n: print(0) else: print(4**n - 3 * 2**n + 2)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP NUMBER VAR BIN_OP NUMBER BIN_OP NUMBER VAR NUMBER
You are given two integers N and K. Find number of ordered triplets (A, B, C) that satisfy the following conditions: 0 ≤ A, B, C < 2^{N} A, B and C are distinct A \oplus B \oplus C = K Here, \oplus denotes the [bitwise XOR operation]. ------ Input Format ------ - The first line contains a single integer T — the num...
def main(): T = int(input()) for _ in range(T): N, K = map(int, input().split()) print(pow(4, N) - 3 * ((1 << N) - 1) - 1) main()
FUNC_DEF 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 EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR NUMBER VAR BIN_OP NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER NUMBER EXPR FUNC_CALL VAR
You are given two integers N and K. Find number of ordered triplets (A, B, C) that satisfy the following conditions: 0 ≤ A, B, C < 2^{N} A, B and C are distinct A \oplus B \oplus C = K Here, \oplus denotes the [bitwise XOR operation]. ------ Input Format ------ - The first line contains a single integer T — the num...
t = int(input()) while t: n, k = map(int, input().split()) k = n res = 1 while k: res *= 4 k -= 1 res -= ((1 << n) - 1) * 3 + 1 print(res) t -= 1
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR NUMBER VAR NUMBER VAR BIN_OP BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER
You are given two integers N and K. Find number of ordered triplets (A, B, C) that satisfy the following conditions: 0 ≤ A, B, C < 2^{N} A, B and C are distinct A \oplus B \oplus C = K Here, \oplus denotes the [bitwise XOR operation]. ------ Input Format ------ - The first line contains a single integer T — the num...
for _ in range(int(input())): n, k = map(int, input().split()) x = pow(2, n) - 1 y = pow(2, n) - 2 print(x * y)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR
You are given two integers N and K. Find number of ordered triplets (A, B, C) that satisfy the following conditions: 0 ≤ A, B, C < 2^{N} A, B and C are distinct A \oplus B \oplus C = K Here, \oplus denotes the [bitwise XOR operation]. ------ Input Format ------ - The first line contains a single integer T — the num...
t = int(input()) for i in range(t): a, b = map(int, input().split(" ")) if b > 2**a - 1: print(0) else: ans = 4 s = 4 for j in range(a - 1): ans = ans * 4 s = 2 * s + 2 print(ans - s)
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 STRING IF VAR BIN_OP BIN_OP NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN...
You are given two integers N and K. Find number of ordered triplets (A, B, C) that satisfy the following conditions: 0 ≤ A, B, C < 2^{N} A, B and C are distinct A \oplus B \oplus C = K Here, \oplus denotes the [bitwise XOR operation]. ------ Input Format ------ - The first line contains a single integer T — the num...
t = int(input()) for i in range(t): l = list(map(int, input().split())) n = l[0] m = 2**n print((m - 1) * (m - 2))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER
You are given two integers N and K. Find number of ordered triplets (A, B, C) that satisfy the following conditions: 0 ≤ A, B, C < 2^{N} A, B and C are distinct A \oplus B \oplus C = K Here, \oplus denotes the [bitwise XOR operation]. ------ Input Format ------ - The first line contains a single integer T — the num...
t = int(input()) for _ in range(t): n, m = map(int, input().split(" ")) count = 0 r = 2**n res = (r - 1) * (r - 2) print(res)
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 STRING ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR
You are given two integers N and K. Find number of ordered triplets (A, B, C) that satisfy the following conditions: 0 ≤ A, B, C < 2^{N} A, B and C are distinct A \oplus B \oplus C = K Here, \oplus denotes the [bitwise XOR operation]. ------ Input Format ------ - The first line contains a single integer T — the num...
t = int(input()) while t: n, k = map(int, input().split()) mod = 10**9 + 7 power = pow(2, n, mod) print((power - 1) * (power - 2)) t -= 1
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER
You are given two integers N and K. Find number of ordered triplets (A, B, C) that satisfy the following conditions: 0 ≤ A, B, C < 2^{N} A, B and C are distinct A \oplus B \oplus C = K Here, \oplus denotes the [bitwise XOR operation]. ------ Input Format ------ - The first line contains a single integer T — the num...
import sys f = sys.stdin next(f) for s in f: n = int(s.split()[0]) m = 1 << n print((m << n) - 3 * m + 2)
IMPORT ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP NUMBER VAR NUMBER
You are given two integers N and K. Find number of ordered triplets (A, B, C) that satisfy the following conditions: 0 ≤ A, B, C < 2^{N} A, B and C are distinct A \oplus B \oplus C = K Here, \oplus denotes the [bitwise XOR operation]. ------ Input Format ------ - The first line contains a single integer T — the num...
t = int(input()) for _ in range(t): n, x = input().split(" ") n = int(n) ans = (2**n - 1) * (2**n - 2) print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
You are given two integers N and K. Find number of ordered triplets (A, B, C) that satisfy the following conditions: 0 ≤ A, B, C < 2^{N} A, B and C are distinct A \oplus B \oplus C = K Here, \oplus denotes the [bitwise XOR operation]. ------ Input Format ------ - The first line contains a single integer T — the num...
t = int(input()) for i in range(0, t): n, x = map(int, input().split()) k = n res = 1 while k != 0: res = res * 4 k = k - 1 res = res - (2**n - 1) * 3 print(res - 1)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER NUMBER EXPR FUNC_CALL ...
You are given two integers N and K. Find number of ordered triplets (A, B, C) that satisfy the following conditions: 0 ≤ A, B, C < 2^{N} A, B and C are distinct A \oplus B \oplus C = K Here, \oplus denotes the [bitwise XOR operation]. ------ Input Format ------ - The first line contains a single integer T — the num...
import sys input = sys.stdin.readline def xor(n, k): cnt = 0 nn = n n = 2**n print((2**nn - 2) * (n - 1)) def dense(n, s): cnt = 0 left = 0 right = n - 1 while left <= right: if s[left] == ")": cnt += 1 left += 1 continue if s[righ...
IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER BIN_OP VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR IF VAR VAR STRING VAR NUMBER VAR NUMBER IF VAR VAR STRING VAR N...
You are given two integers N and K. Find number of ordered triplets (A, B, C) that satisfy the following conditions: 0 ≤ A, B, C < 2^{N} A, B and C are distinct A \oplus B \oplus C = K Here, \oplus denotes the [bitwise XOR operation]. ------ Input Format ------ - The first line contains a single integer T — the num...
t = int(input()) for _ in range(t): n, k = map(int, input().split()) a = 2**n ans = 4**n - 3 * (a - 1) - 1 print(ans)
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 BIN_OP NUMBER VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER VAR BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR
You are given two integers N and K. Find number of ordered triplets (A, B, C) that satisfy the following conditions: 0 ≤ A, B, C < 2^{N} A, B and C are distinct A \oplus B \oplus C = K Here, \oplus denotes the [bitwise XOR operation]. ------ Input Format ------ - The first line contains a single integer T — the num...
q = [0] * 21 for _ in range(int(input())): n, k = map(int, input().split()) x = (1 << n) - 1 print(x * (x - 1))
ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER
You are given two integers N and K. Find number of ordered triplets (A, B, C) that satisfy the following conditions: 0 ≤ A, B, C < 2^{N} A, B and C are distinct A \oplus B \oplus C = K Here, \oplus denotes the [bitwise XOR operation]. ------ Input Format ------ - The first line contains a single integer T — the num...
t = int(input()) while t: n, k = map(int, input().split()) print((pow(2, n) - 1) * (pow(2, n) - 2)) t -= 1
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR NUMBER VAR NUMBER BIN_OP FUNC_CALL VAR NUMBER VAR NUMBER VAR NUMBER
You are given two integers N and K. Find number of ordered triplets (A, B, C) that satisfy the following conditions: 0 ≤ A, B, C < 2^{N} A, B and C are distinct A \oplus B \oplus C = K Here, \oplus denotes the [bitwise XOR operation]. ------ Input Format ------ - The first line contains a single integer T — the num...
def data(): x, y = map(int, input().split()) max = 1 << x print((max - 1) * (max - 2)) a = int(input()) while a > 0: a = a - 1 data()
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR
You are given two integers N and K. Find number of ordered triplets (A, B, C) that satisfy the following conditions: 0 ≤ A, B, C < 2^{N} A, B and C are distinct A \oplus B \oplus C = K Here, \oplus denotes the [bitwise XOR operation]. ------ Input Format ------ - The first line contains a single integer T — the num...
import sys input = sys.stdin.readline M = int(1000000000.0) + 7 def solve(): n, k = map(int, input().split()) return (2**n - 1) * (2**n - 2) for _ in range(int(input())): print(solve())
IMPORT ASSIGN VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER NUMBER FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR RETURN BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR
You are given two integers N and K. Find number of ordered triplets (A, B, C) that satisfy the following conditions: 0 ≤ A, B, C < 2^{N} A, B and C are distinct A \oplus B \oplus C = K Here, \oplus denotes the [bitwise XOR operation]. ------ Input Format ------ - The first line contains a single integer T — the num...
t = int(input()) for k in range(t): n, k = input().split() n, k = int(n), int(k) print(4**n - (3 * 2**n - 2))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR BIN_OP BIN_OP NUMBER BIN_OP NUMBER VAR NUMBER
Let's denote as <image> the number of bits set ('1' bits) in the binary representation of the non-negative integer x. You are given multiple queries consisting of pairs of integers l and r. For each query, find the x, such that l ≤ x ≤ r, and <image> is maximum possible. If there are multiple such numbers find the sma...
n = int(input()) for i in range(n): l, r = map(int, input().split()) l = bin(l)[2:] r = bin(r)[2:] while len(l) < len(r): l = "0" + l x = [0] * len(l) for i in range(len(l)): x[i] = l[i] if l[i] < r[i]: ok = True for j in range(i + 1, len(l)): ...
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 VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER WHILE FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR FOR VAR...
Let's denote as <image> the number of bits set ('1' bits) in the binary representation of the non-negative integer x. You are given multiple queries consisting of pairs of integers l and r. For each query, find the x, such that l ≤ x ≤ r, and <image> is maximum possible. If there are multiple such numbers find the sma...
for i in range(int(input())): l, r = map(int, input().split()) L = list(bin(l)) R = list(bin(r)) L = L[2:] R = R[2:] w = 0 c = 0 L = ["0"] * (len(R) - len(L)) + L ans = 0 if l == r: print(l) continue for i in range(len(R)): if L[i] != R[i]: ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP LIST STRING BIN_OP FUN...
Let's denote as <image> the number of bits set ('1' bits) in the binary representation of the non-negative integer x. You are given multiple queries consisting of pairs of integers l and r. For each query, find the x, such that l ≤ x ≤ r, and <image> is maximum possible. If there are multiple such numbers find the sma...
from sys import stdin def parseline(line): return list(map(int, line.split())) def round_to_power_of_2(k): k |= k >> 1 k |= k >> 2 k |= k >> 4 k |= k >> 8 k |= k >> 16 k += 1 return k def is_power_of_2(k): return 0 == k & k - 1 lines = list(filter(None, stdin.read().split("\n...
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_DEF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR FUNC_DEF RETURN NUMBER BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NONE FUNC_CALL FUNC_CALL V...
Let's denote as <image> the number of bits set ('1' bits) in the binary representation of the non-negative integer x. You are given multiple queries consisting of pairs of integers l and r. For each query, find the x, such that l ≤ x ≤ r, and <image> is maximum possible. If there are multiple such numbers find the sma...
n = int(input()) for k in range(n): l, r = map(int, input().split()) a = [] for i in range(62): a.append("0") lbin = list(bin(l)) lbin = lbin[2:] ans = l num = l for i in range(len(lbin)): a[61 - i] = lbin[len(lbin) - 1 - i] blah = 0 for i in range(61, -1, -1): ...
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 LIST FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL ...
Let's denote as <image> the number of bits set ('1' bits) in the binary representation of the non-negative integer x. You are given multiple queries consisting of pairs of integers l and r. For each query, find the x, such that l ≤ x ≤ r, and <image> is maximum possible. If there are multiple such numbers find the sma...
import sys def binary(a): s = "" for i in range(64): if a % 2 == 0: s += "0" else: s += "1" a //= 2 return s def dec(s): resp = 0 for k in s: resp *= 2 if k == "1": resp += 1 return resp def solve(a, b): x = bi...
IMPORT FUNC_DEF ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR STRING VAR STRING VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR VAR NUMBER IF VAR STRING VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR STR...
Vlad found two positive numbers $a$ and $b$ ($a,b>0$). He discovered that $a \oplus b = \frac{a + b}{2}$, where $\oplus$ means the bitwise exclusive OR , and division is performed without rounding.. Since it is easier to remember one number than two, Vlad remembered only $a\oplus b$, let's denote this number as $x$. H...
def ans(x): if x % 2 == 0: a = x // 2 b = 2 * x - a if a ^ b == (a + b) / 2: return a, b return -1, -1 test_cases = int(input()) while test_cases != 0: d = int(input()) k1, k2 = ans(d) if k1 == -1: print(-1) else: print(k1, k2) test_cases...
FUNC_DEF IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR VAR IF BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER RETURN VAR VAR RETURN NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR IF ...
Vlad found two positive numbers $a$ and $b$ ($a,b>0$). He discovered that $a \oplus b = \frac{a + b}{2}$, where $\oplus$ means the bitwise exclusive OR , and division is performed without rounding.. Since it is easier to remember one number than two, Vlad remembered only $a\oplus b$, let's denote this number as $x$. H...
def generator(x, y): s = bin(x)[2:] carry = 0 for i in range(len(s) - 1, -1, -1): j = len(s) - 1 - i k1, k2 = x & 1 << j, y & 1 << j carry += k1 ^ k2 v1 = v2 = 0 for i in range(len(s) - 1, -1, -1): j = len(s) - 1 - i if s[i] == "0": if i >= 1: ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VAR BIN_OP NUMBER VAR BIN_OP VAR BIN_OP NUMBER VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR...
Vlad found two positive numbers $a$ and $b$ ($a,b>0$). He discovered that $a \oplus b = \frac{a + b}{2}$, where $\oplus$ means the bitwise exclusive OR , and division is performed without rounding.. Since it is easier to remember one number than two, Vlad remembered only $a\oplus b$, let's denote this number as $x$. H...
import sys input = sys.stdin.readline out = [] for _ in range(int(input())): x = int(input()) a = x // 2 b = x ^ a if a == 2 * x - b: out.append(f"{a} {b}") else: out.append(-1) for i in out: print(i)
IMPORT ASSIGN VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR BIN_OP BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR VAR STRING VAR EXPR FUNC_CALL VAR NUMBER FOR VAR VAR EXPR FUNC_CALL VAR VAR
Vlad found two positive numbers $a$ and $b$ ($a,b>0$). He discovered that $a \oplus b = \frac{a + b}{2}$, where $\oplus$ means the bitwise exclusive OR , and division is performed without rounding.. Since it is easier to remember one number than two, Vlad remembered only $a\oplus b$, let's denote this number as $x$. H...
for _ in int(input()) * " ": n = int(input()) x = n // 2 y = 3 * x if x ^ y == n: print(x, y) else: print(-1)
FOR VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR IF BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER
Vlad found two positive numbers $a$ and $b$ ($a,b>0$). He discovered that $a \oplus b = \frac{a + b}{2}$, where $\oplus$ means the bitwise exclusive OR , and division is performed without rounding.. Since it is easier to remember one number than two, Vlad remembered only $a\oplus b$, let's denote this number as $x$. H...
def find_pair(x): if x % 2 == 1: return -1 a = x + x // 2 b = x - x // 2 if a ^ b == x: return a, b else: return -1 t = int(input()) for _ in range(t): x = int(input()) ans = find_pair(x) if type(ans) == int: print(-1) else: print(ans[0], ans...
FUNC_DEF IF BIN_OP VAR NUMBER NUMBER RETURN NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR VAR RETURN VAR VAR RETURN 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 FUNC_CALL VAR VAR IF FU...
Vlad found two positive numbers $a$ and $b$ ($a,b>0$). He discovered that $a \oplus b = \frac{a + b}{2}$, where $\oplus$ means the bitwise exclusive OR , and division is performed without rounding.. Since it is easier to remember one number than two, Vlad remembered only $a\oplus b$, let's denote this number as $x$. H...
t = int(input()) while t: x = int(input()) a = x + x // 2 b = x // 2 if x % 2 == 1: print(-1) elif a ^ b == x: print(a, b) else: print(-1) t -= 1
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER VAR NUMBER
Vlad found two positive numbers $a$ and $b$ ($a,b>0$). He discovered that $a \oplus b = \frac{a + b}{2}$, where $\oplus$ means the bitwise exclusive OR , and division is performed without rounding.. Since it is easier to remember one number than two, Vlad remembered only $a\oplus b$, let's denote this number as $x$. H...
n = int(input()) for i in range(n): x = int(input()) if x % 2 == 1: k = (x + 1) // 2 else: k = x // 2 a = [0] * 33 b = [0] * 33 w = [0] * 33 wk = [0] * 33 for j in range(33): if x >> j & 1: w[j] = 1 if k >> j & 1: wk[j] = 1 flag...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIG...
Vlad found two positive numbers $a$ and $b$ ($a,b>0$). He discovered that $a \oplus b = \frac{a + b}{2}$, where $\oplus$ means the bitwise exclusive OR , and division is performed without rounding.. Since it is easier to remember one number than two, Vlad remembered only $a\oplus b$, let's denote this number as $x$. H...
for _ in range(int(input())): n = int(input()) if n % 2 != 0: print(-1) continue if n ^ n // 2 == n // 2 * 3: print(n // 2, 3 * n // 2) else: print(-1)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER
Vlad found two positive numbers $a$ and $b$ ($a,b>0$). He discovered that $a \oplus b = \frac{a + b}{2}$, where $\oplus$ means the bitwise exclusive OR , and division is performed without rounding.. Since it is easier to remember one number than two, Vlad remembered only $a\oplus b$, let's denote this number as $x$. H...
def solve(): x = int(input()) a = 2 * x // 4 b = 2 * x // 4 * 3 if 2 * (a ^ b) == a + b and x % 2 != 1: print(a, b) else: print(-1) t = int(input()) for _ in range(t): solve()
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER NUMBER IF BIN_OP NUMBER BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR ...
Vlad found two positive numbers $a$ and $b$ ($a,b>0$). He discovered that $a \oplus b = \frac{a + b}{2}$, where $\oplus$ means the bitwise exclusive OR , and division is performed without rounding.. Since it is easier to remember one number than two, Vlad remembered only $a\oplus b$, let's denote this number as $x$. H...
for i in range(int(input())): n = int(input()) if n % 2 == 1: print(-1) else: a = n // 2 if a & n == 0: b = a + n else: print(-1) continue print(a, b)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR VAR
Vlad found two positive numbers $a$ and $b$ ($a,b>0$). He discovered that $a \oplus b = \frac{a + b}{2}$, where $\oplus$ means the bitwise exclusive OR , and division is performed without rounding.. Since it is easier to remember one number than two, Vlad remembered only $a\oplus b$, let's denote this number as $x$. H...
for _ in range(int(input())): if (p := 3 * (x := int(input())) // 2) ^ (b := x // 2) == x == (p + b) // 2: print(p, b) else: print(-1)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR BIN_OP BIN_OP NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER
Vlad found two positive numbers $a$ and $b$ ($a,b>0$). He discovered that $a \oplus b = \frac{a + b}{2}$, where $\oplus$ means the bitwise exclusive OR , and division is performed without rounding.. Since it is easier to remember one number than two, Vlad remembered only $a\oplus b$, let's denote this number as $x$. H...
for _ in range(int(input())): n = int(input()) if n % 2: print(-1) continue arr = [] while n: arr.append(n % 2) n //= 2 arr = arr[::-1] n = len(arr) yes = 1 for i in range(n - 1): if arr[i] == 1 and arr[i + 1] == 1: yes = 0 ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST WHILE VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER I...
Vlad found two positive numbers $a$ and $b$ ($a,b>0$). He discovered that $a \oplus b = \frac{a + b}{2}$, where $\oplus$ means the bitwise exclusive OR , and division is performed without rounding.. Since it is easier to remember one number than two, Vlad remembered only $a\oplus b$, let's denote this number as $x$. H...
for a in range(int(input())): n = int(input()) << 1 s = "0" + bin(n)[2:] c, d = 0, 0 if n % 4 != 0: print(-1) else: n1 = len(s) for b in range(1, n1): if s[b] == "1" and s[b - 1] == "1": print(-1) break else: pri...
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 STRING FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING VAR ...
Vlad found two positive numbers $a$ and $b$ ($a,b>0$). He discovered that $a \oplus b = \frac{a + b}{2}$, where $\oplus$ means the bitwise exclusive OR , and division is performed without rounding.. Since it is easier to remember one number than two, Vlad remembered only $a\oplus b$, let's denote this number as $x$. H...
for i in range(int(input())): s = int(input()) a = 3 * s // 2 b = s // 2 if s == a ^ b and s - a / 2 - b / 2 == 0.0: print(a, b) else: print(-1)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER
Vlad found two positive numbers $a$ and $b$ ($a,b>0$). He discovered that $a \oplus b = \frac{a + b}{2}$, where $\oplus$ means the bitwise exclusive OR , and division is performed without rounding.. Since it is easier to remember one number than two, Vlad remembered only $a\oplus b$, let's denote this number as $x$. H...
for _ in range(int(input())): a = int(input()) if a % 2: print(-1) elif 3 * a // 2 ^ a // 2 == a: print(3 * a // 2, a // 2) else: print(-1)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER
Vlad found two positive numbers $a$ and $b$ ($a,b>0$). He discovered that $a \oplus b = \frac{a + b}{2}$, where $\oplus$ means the bitwise exclusive OR , and division is performed without rounding.. Since it is easier to remember one number than two, Vlad remembered only $a\oplus b$, let's denote this number as $x$. H...
t = int(input()) for _ in range(0, t): x = int(input()) if x % 2 == 1: print("-1") else: a = int(3 * x / 2) b = int(x / 2) if a ^ b == x: print(f"{a} {b}") else: print("-1")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR STRING VAR...
Vlad found two positive numbers $a$ and $b$ ($a,b>0$). He discovered that $a \oplus b = \frac{a + b}{2}$, where $\oplus$ means the bitwise exclusive OR , and division is performed without rounding.. Since it is easier to remember one number than two, Vlad remembered only $a\oplus b$, let's denote this number as $x$. H...
import sys input = lambda: sys.stdin.readline().strip() def compute(S, X): if (S - X) % 2 != 0: return [-1] A = (S - X) // 2 a = 0 b = 0 for i in range(64): Xi = X & 1 << i Ai = A & 1 << i if Xi == 0 and Ai == 0: pass elif Xi == 0 and Ai > 0: ...
IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER RETURN LIST NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR IF VAR NUMBER VAR NUMBER I...
Vlad found two positive numbers $a$ and $b$ ($a,b>0$). He discovered that $a \oplus b = \frac{a + b}{2}$, where $\oplus$ means the bitwise exclusive OR , and division is performed without rounding.. Since it is easier to remember one number than two, Vlad remembered only $a\oplus b$, let's denote this number as $x$. H...
t = int(input()) for test in range(t): x = int(input()) su = x * 2 x1 = "0" + bin(x)[2:] su1 = bin(su)[2:] otva = 0 otvb = 0 cur = 1 fl = 1 ls = 0 for i in range(len(x1) - 1, -1, -1): if int(x1[i]) == abs(int(su1[i]) - ls) == 0: if x1[i - 1] == su1[i - 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 BIN_OP VAR NUMBER ASSIGN VAR BIN_OP STRING FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUN...
Vlad found two positive numbers $a$ and $b$ ($a,b>0$). He discovered that $a \oplus b = \frac{a + b}{2}$, where $\oplus$ means the bitwise exclusive OR , and division is performed without rounding.. Since it is easier to remember one number than two, Vlad remembered only $a\oplus b$, let's denote this number as $x$. H...
def solve(): x = int(input()) if x % 2 == 1: print(-1) return rest = x // 2 if x & rest == 0: print(x + rest, rest) else: print(-1) t = int(input()) for _ in range(t): solve()
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR
Vlad found two positive numbers $a$ and $b$ ($a,b>0$). He discovered that $a \oplus b = \frac{a + b}{2}$, where $\oplus$ means the bitwise exclusive OR , and division is performed without rounding.. Since it is easier to remember one number than two, Vlad remembered only $a\oplus b$, let's denote this number as $x$. H...
t = int(input()) for i in range(0, t): m = int(input()) x = m l = [] ll = [] while m >= 1: l.append(m % 2) m = m // 2 for j in range(1, len(l)): ll.append(l[j]) ll.append(0) l ll a = 0 b = 0 bl = True for k in range(0, len(l)): if l[k] ...
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 VAR ASSIGN VAR LIST ASSIGN VAR LIST WHILE VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR ...
Vlad found two positive numbers $a$ and $b$ ($a,b>0$). He discovered that $a \oplus b = \frac{a + b}{2}$, where $\oplus$ means the bitwise exclusive OR , and division is performed without rounding.. Since it is easier to remember one number than two, Vlad remembered only $a\oplus b$, let's denote this number as $x$. H...
def main(): _i = int(input()) for _ in range(_i): n = int(input().strip("\r\n")) a1 = "" a2 = "" sn = f"{n:b}" i = 0 fail = False while i < len(sn): if sn[i] == "1": if i == len(sn) - 1 or sn[i + 1] != "0": f...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR BIN_OP ...
Vlad found two positive numbers $a$ and $b$ ($a,b>0$). He discovered that $a \oplus b = \frac{a + b}{2}$, where $\oplus$ means the bitwise exclusive OR , and division is performed without rounding.. Since it is easier to remember one number than two, Vlad remembered only $a\oplus b$, let's denote this number as $x$. H...
cases = int(input()) def main(): for case in range(cases): x = int(input()) n = 2 * x if x % 2: print(-1) continue a = 0 b = 0 wr = bin(x)[:1:-1] wr += "0" pow2 = 1 xs = [] for i, d in enumerate(wr): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER VAR IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER NUMBER VAR STRING ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR...
Vlad found two positive numbers $a$ and $b$ ($a,b>0$). He discovered that $a \oplus b = \frac{a + b}{2}$, where $\oplus$ means the bitwise exclusive OR , and division is performed without rounding.. Since it is easier to remember one number than two, Vlad remembered only $a\oplus b$, let's denote this number as $x$. H...
t = int(input()) for _ in range(t): n = int(input()) if n % 2 == 1: print(-1) else: x = n // 2 y = 1 flag = 0 if x == 1: flag *= 4 for i in range(5): if y == 0: y += 1 else: break for ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL ...
Vlad found two positive numbers $a$ and $b$ ($a,b>0$). He discovered that $a \oplus b = \frac{a + b}{2}$, where $\oplus$ means the bitwise exclusive OR , and division is performed without rounding.. Since it is easier to remember one number than two, Vlad remembered only $a\oplus b$, let's denote this number as $x$. H...
for _ in range(int(input())): x = int(input()) if x % 2 == 1: print(-1) else: a = x + x // 2 b = x // 2 if a ^ b == x: print(a, b) else: print(-1)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER
Vlad found two positive numbers $a$ and $b$ ($a,b>0$). He discovered that $a \oplus b = \frac{a + b}{2}$, where $\oplus$ means the bitwise exclusive OR , and division is performed without rounding.. Since it is easier to remember one number than two, Vlad remembered only $a\oplus b$, let's denote this number as $x$. H...
t = int(input()) for _ in range(t): x = int(input()) binary = bin(x)[2:] a = int(len(binary) * "1", 2) b = int(binary.replace("0", "_").replace("1", "0").replace("_", "1"), 2) k = (a + b) // 2 if (a + b) % 2 != 0 or a == 0 or b == 0 or k < x: print(-1) continue diff = k - 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 VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR STRING NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING STRING STRING STRING STRING STRING NUMBER ASSIGN V...
Vlad found two positive numbers $a$ and $b$ ($a,b>0$). He discovered that $a \oplus b = \frac{a + b}{2}$, where $\oplus$ means the bitwise exclusive OR , and division is performed without rounding.. Since it is easier to remember one number than two, Vlad remembered only $a\oplus b$, let's denote this number as $x$. H...
def find_ab(x): a = (x + 1) // 2 b = a ^ x if (a + b) % 2 == 0 and (a + b) // 2 == x: return a, b else: return -1 for _ in range(int(input())): ans = find_ab(int(input())) if ans == -1: print(-1) else: print(ans[0], ans[1])
FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER BIN_OP BIN_OP VAR VAR NUMBER VAR RETURN VAR VAR RETURN NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBE...
Vlad found two positive numbers $a$ and $b$ ($a,b>0$). He discovered that $a \oplus b = \frac{a + b}{2}$, where $\oplus$ means the bitwise exclusive OR , and division is performed without rounding.. Since it is easier to remember one number than two, Vlad remembered only $a\oplus b$, let's denote this number as $x$. H...
def func(): x = int(input()) if x % 2 == 1: print(-1) return a = 0 v = [] t = x p = 1 while t != 0: y = t % 2 t = t // 2 if y == 0: v.append(p) else: a += p p *= 2 t = x - a // 2 p = 1 b = 0 while...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR BI...
Vlad found two positive numbers $a$ and $b$ ($a,b>0$). He discovered that $a \oplus b = \frac{a + b}{2}$, where $\oplus$ means the bitwise exclusive OR , and division is performed without rounding.. Since it is easier to remember one number than two, Vlad remembered only $a\oplus b$, let's denote this number as $x$. H...
t = int(input()) for i in range(t): n = int(input()) S = 2 * n bn = [] tmp = n while tmp: bn.append(tmp % 2) tmp //= 2 bn.reverse() a = bn[:] b = [(0) for _ in range(len(bn))] res = 1 if bn[-1] == 1: res = 0 else: for i in range(len(bn) - 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 BIN_OP NUMBER VAR ASSIGN VAR LIST ASSIGN VAR VAR WHILE VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR...
Vlad found two positive numbers $a$ and $b$ ($a,b>0$). He discovered that $a \oplus b = \frac{a + b}{2}$, where $\oplus$ means the bitwise exclusive OR , and division is performed without rounding.. Since it is easier to remember one number than two, Vlad remembered only $a\oplus b$, let's denote this number as $x$. H...
import sys def rec(mask, s, x, bit, a, b): if s == 0 and bit == 0: return [a, b] if x & 1: if s & 1 == 1 + bit & 1: return rec(mask << 1, s >> 1, x >> 1, bit + 1 >> 1, a | mask, b) else: r = None if bit + 1 + 1 & 1 == s & 1: r = rec(mask << 1, s >> 1...
IMPORT FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN LIST VAR VAR IF BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER RETURN FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP VAR VAR VAR ASSIGN VAR NONE IF BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER N...
Vlad found two positive numbers $a$ and $b$ ($a,b>0$). He discovered that $a \oplus b = \frac{a + b}{2}$, where $\oplus$ means the bitwise exclusive OR , and division is performed without rounding.. Since it is easier to remember one number than two, Vlad remembered only $a\oplus b$, let's denote this number as $x$. H...
t = int(input()) for _ in range(t): x = int(input()) a = x b = 0 for i in range(32, -1, -1): if x & 1 << i > 0: continue if 2 * x - a - b >= 2 << i: a += 1 << i b += 1 << i if a + b == 2 * x and a ^ b == x: print(a, b) else: pri...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF BIN_OP VAR BIN_OP NUMBER VAR NUMBER IF BIN_OP BIN_OP BIN_OP NUMBER VAR VAR VAR BIN_OP NUMBER VAR VAR BIN_OP NUMBER VAR VAR BIN_OP NUMBER ...
Vlad found two positive numbers $a$ and $b$ ($a,b>0$). He discovered that $a \oplus b = \frac{a + b}{2}$, where $\oplus$ means the bitwise exclusive OR , and division is performed without rounding.. Since it is easier to remember one number than two, Vlad remembered only $a\oplus b$, let's denote this number as $x$. H...
def check(s, xor): a2 = (s - xor) // 2 a = 0 b = 0 for i in range(64): x1 = xor & 1 << i a1 = a2 & 1 << i if x1 == 0 and a1 == 0: pass elif x1 == 0 and a1 > 0: a = 1 << i | a b = 1 << i | b elif x1 > 0 and a1 == 0: a...
FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR IF VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR ...
Vlad found two positive numbers $a$ and $b$ ($a,b>0$). He discovered that $a \oplus b = \frac{a + b}{2}$, where $\oplus$ means the bitwise exclusive OR , and division is performed without rounding.. Since it is easier to remember one number than two, Vlad remembered only $a\oplus b$, let's denote this number as $x$. H...
for _ in range(int(input())): n = int(input()) a = 2 * n if a - n // 2 ^ n // 2 == n: print(a - n // 2, n // 2) else: print(-1)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER VAR IF BIN_OP BIN_OP VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER
Vlad found two positive numbers $a$ and $b$ ($a,b>0$). He discovered that $a \oplus b = \frac{a + b}{2}$, where $\oplus$ means the bitwise exclusive OR , and division is performed without rounding.. Since it is easier to remember one number than two, Vlad remembered only $a\oplus b$, let's denote this number as $x$. H...
def N(): return int(input()) def A(): return [int(x) for x in input().split()] def S(): return input() def decimalToBinary(n): return bin(n).replace("0b", "") for _ in range(N()): n = N() a = [] f = n % 2 == 0 p = 0 b = [] if "codeforces" == 28226329: print("Tanma...
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR VAR STRING STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR NU...
Vlad found two positive numbers $a$ and $b$ ($a,b>0$). He discovered that $a \oplus b = \frac{a + b}{2}$, where $\oplus$ means the bitwise exclusive OR , and division is performed without rounding.. Since it is easier to remember one number than two, Vlad remembered only $a\oplus b$, let's denote this number as $x$. H...
def main(): n = int(input()) if n % 2: print(-1) return b = bin(n) b = b[2:] alt = ["0"] * len(b) b = list(b) i = 0 while i < len(b) - 1: if b[i] == "1": if b[i + 1] == "1": print(-1) return b[i + 1] = "1" ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP LIST STRING FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING IF VAR BIN_O...
Vlad found two positive numbers $a$ and $b$ ($a,b>0$). He discovered that $a \oplus b = \frac{a + b}{2}$, where $\oplus$ means the bitwise exclusive OR , and division is performed without rounding.. Since it is easier to remember one number than two, Vlad remembered only $a\oplus b$, let's denote this number as $x$. H...
t = int(input()) for _ in range(t): n = int(input()) bl = True if n & 1: bl = False a = n // 2 if a & n or not bl: print(-1) else: print(a | n, a)
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 IF BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR
Vlad found two positive numbers $a$ and $b$ ($a,b>0$). He discovered that $a \oplus b = \frac{a + b}{2}$, where $\oplus$ means the bitwise exclusive OR , and division is performed without rounding.. Since it is easier to remember one number than two, Vlad remembered only $a\oplus b$, let's denote this number as $x$. H...
import sys N = int(200000.0 + 5) sys.setrecursionlimit(N) def charming(): x = int(input()) if x & 1 == 1: print(-1) return two = list() for i in range(32): if x // pow(2, i) & 1: two.append(i) a = x + pow(2, two[0] - 1) b = pow(2, two[0] - 1) for i in r...
IMPORT ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER EXPR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP BIN_OP VAR FUNC_CALL VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIG...
Vlad found two positive numbers $a$ and $b$ ($a,b>0$). He discovered that $a \oplus b = \frac{a + b}{2}$, where $\oplus$ means the bitwise exclusive OR , and division is performed without rounding.. Since it is easier to remember one number than two, Vlad remembered only $a\oplus b$, let's denote this number as $x$. H...
def hkjbklj(x): if x % 2 == 1: return -1 s = x // 2 asa = 1 for i in range(1, 30): asa *= 2 if asa >= x: asa = i + 1 break a = [None] * asa b = [None] * asa bsb = 1 for i in range(asa): csc = bsb bsb *= 2 a[0 - i - 1...
FUNC_DEF IF BIN_OP VAR NUMBER NUMBER RETURN NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NONE VAR ASSIGN VAR BIN_OP LIST NONE VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER A...
Vlad found two positive numbers $a$ and $b$ ($a,b>0$). He discovered that $a \oplus b = \frac{a + b}{2}$, where $\oplus$ means the bitwise exclusive OR , and division is performed without rounding.. Since it is easier to remember one number than two, Vlad remembered only $a\oplus b$, let's denote this number as $x$. H...
def findab(x): a = x >> 1 b = x | a y = (a + b) / 2 if x == y: print(a, b) return print(-1) return t = int(input()) for T in range(t): x = int(input()) findab(x)
FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR VAR RETURN EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR
Vlad found two positive numbers $a$ and $b$ ($a,b>0$). He discovered that $a \oplus b = \frac{a + b}{2}$, where $\oplus$ means the bitwise exclusive OR , and division is performed without rounding.. Since it is easier to remember one number than two, Vlad remembered only $a\oplus b$, let's denote this number as $x$. H...
t = int(input().strip()) result = [] for _ in range(t): x = int(input().strip()) a = x // 2 if 2 * a == x and a & x == 0: print(a, a + x) else: print(-1)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP NUMBER VAR VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR NUMBER
Vlad found two positive numbers $a$ and $b$ ($a,b>0$). He discovered that $a \oplus b = \frac{a + b}{2}$, where $\oplus$ means the bitwise exclusive OR , and division is performed without rounding.. Since it is easier to remember one number than two, Vlad remembered only $a\oplus b$, let's denote this number as $x$. H...
t = int(input()) for i in range(0, t): n = int(input()) def solve(num): a = 0 b = 0 last = 0 ok = 1 tmp = -1 while num > 0: w = num & 1 num >>= 1 tmp += 1 if tmp == 0 and w == 1: ok = 0 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER...
Vlad found two positive numbers $a$ and $b$ ($a,b>0$). He discovered that $a \oplus b = \frac{a + b}{2}$, where $\oplus$ means the bitwise exclusive OR , and division is performed without rounding.. Since it is easier to remember one number than two, Vlad remembered only $a\oplus b$, let's denote this number as $x$. H...
def compute(S, X): A = (S - X) // 2 a = 0 b = 0 for i in range(64): Xi = X & 1 << i Ai = A & 1 << i if Xi == 0 and Ai == 0: pass elif Xi == 0 and Ai > 0: a = 1 << i | a b = 1 << i | b elif Xi > 0 and Ai == 0: a = 1 <...
FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR IF VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR ...
Vlad found two positive numbers $a$ and $b$ ($a,b>0$). He discovered that $a \oplus b = \frac{a + b}{2}$, where $\oplus$ means the bitwise exclusive OR , and division is performed without rounding.. Since it is easier to remember one number than two, Vlad remembered only $a\oplus b$, let's denote this number as $x$. H...
t = int(input()) for i in range(t): x = int(input()) y = x // 2 a = 0 b = 0 ca = 1 ind = 0 if x % 2 == 1: print(-1) continue while x > 0: tx = x % 2 ty = y % 2 if tx == 0 and ty == 1: a += ca b += ca elif tx == 1 and...
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 NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_...
Vlad found two positive numbers $a$ and $b$ ($a,b>0$). He discovered that $a \oplus b = \frac{a + b}{2}$, where $\oplus$ means the bitwise exclusive OR , and division is performed without rounding.. Since it is easier to remember one number than two, Vlad remembered only $a\oplus b$, let's denote this number as $x$. H...
for __ in range(int(input())): x = int(input()) a, b = x // 2 * 3, x // 2 if a ^ b == x: print(a, b) else: print("-1")
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING
Vlad found two positive numbers $a$ and $b$ ($a,b>0$). He discovered that $a \oplus b = \frac{a + b}{2}$, where $\oplus$ means the bitwise exclusive OR , and division is performed without rounding.. Since it is easier to remember one number than two, Vlad remembered only $a\oplus b$, let's denote this number as $x$. H...
for n in [*map(int, open(0))][1:]: b = n >> 1 print(*[b * 3, -1, b][bool(n & 1 or n & b) :: 2])
FOR VAR LIST FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR LIST BIN_OP VAR NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR VAR NUMBER
Vlad found two positive numbers $a$ and $b$ ($a,b>0$). He discovered that $a \oplus b = \frac{a + b}{2}$, where $\oplus$ means the bitwise exclusive OR , and division is performed without rounding.. Since it is easier to remember one number than two, Vlad remembered only $a\oplus b$, let's denote this number as $x$. H...
for _ in range(int(input())): n = int(input()) if not n % 2: n2 = int(n / 2) if n + n2 ^ n - n2 == n: print(f"{n + n2} {n - n2}") continue else: print(-1) else: print(-1)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR STRING BIN_OP VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER
Vlad found two positive numbers $a$ and $b$ ($a,b>0$). He discovered that $a \oplus b = \frac{a + b}{2}$, where $\oplus$ means the bitwise exclusive OR , and division is performed without rounding.. Since it is easier to remember one number than two, Vlad remembered only $a\oplus b$, let's denote this number as $x$. H...
def one(): n = int(input()) s = 1 d = [] while s <= n: if not n & s: d.append(s) s += s a, b = 0, n for x in reversed(d): if a + b + x + x <= n + n: a += x b += x if a + b == n + n: print(a, b) else: print(-1) ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR VAR IF BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR VAR VAR IF BIN_OP VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR ...
Vlad found two positive numbers $a$ and $b$ ($a,b>0$). He discovered that $a \oplus b = \frac{a + b}{2}$, where $\oplus$ means the bitwise exclusive OR , and division is performed without rounding.. Since it is easier to remember one number than two, Vlad remembered only $a\oplus b$, let's denote this number as $x$. H...
t = int(input()) for test in range(t): x = int(input()) y = bin(x) a, b = 0, 0 i = 2 while i < len(y): if y[i : i + 2] == "10": a, b = a << 2 | 3, b << 2 | 1 i += 2 elif y[i : i + 1] == "0": a, b = a << 1, b << 1 i += 1 else: ...
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 ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP VAR NUMBER NUMB...
Vlad found two positive numbers $a$ and $b$ ($a,b>0$). He discovered that $a \oplus b = \frac{a + b}{2}$, where $\oplus$ means the bitwise exclusive OR , and division is performed without rounding.. Since it is easier to remember one number than two, Vlad remembered only $a\oplus b$, let's denote this number as $x$. H...
t = int(input()) while t: n = int(input()) if n % 2 != 0: print(-1) else: a = int(3 * n / 2) b = int(n / 2) if int((a + b) / 2) == a ^ b: print(a, b) else: print(-1) t -= 1
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR VAR EXPR FUNC_CALL VA...
Vlad found two positive numbers $a$ and $b$ ($a,b>0$). He discovered that $a \oplus b = \frac{a + b}{2}$, where $\oplus$ means the bitwise exclusive OR , and division is performed without rounding.. Since it is easier to remember one number than two, Vlad remembered only $a\oplus b$, let's denote this number as $x$. H...
t = int(input()) for _ in range(t): n = int(input()) if n % 2 != 0 or "11" in bin(n): print(-1) continue print(n // 2, n // 2 + n)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER STRING FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER VAR
Chef has an array A of length N such that A_{i} = i. In one operation, Chef can pick any two elements of the array, delete them from A, and append either their [bitwise XOR] or their [bitwise OR] to A. Note that after each operation, the length of the array decreases by 1. Let F be the final number obtained after N-...
import sys def solve(): n, x = map(int, sys.stdin.readline().split()) maxNum = 0 for i in range(20, 0, -1): if n & 1 << i: maxNum = 1 << i + 1 break if n == 2 and x != 3 or x >= maxNum or n & n - 1 == 0 and x & n == 0: print("-1") return if n == 2: ...
IMPORT FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF BIN_OP VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP NUMBER BIN_OP VAR NUMBER IF VAR NUMBER VAR NUMBER VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR S...
Chef has an array A of length N such that A_{i} = i. In one operation, Chef can pick any two elements of the array, delete them from A, and append either their [bitwise XOR] or their [bitwise OR] to A. Note that after each operation, the length of the array decreases by 1. Let F be the final number obtained after N-...
for _ in range(int(input())): n, x = map(int, input().split()) d = dict.fromkeys(list(range(1, n + 1))) if n == 2: if x == 3: print("1 1 2") else: print(-1) else: for i in range(20): ni = 1 << i d[ni] = True if ni & n: ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP NUMBER V...
Read problem statements in [Bengali], [Russian], [Mandarin] and [Vietnamese] as well. You are given an array A of N non-negative integers, where N is odd. Find the minimum non-negative integer x that satisfies the equation (A_{1} + x) \oplus (A_{2} + x) \oplus \dots \oplus (A_{N} + x) = 0 where \oplus denotes the [b...
def compute(A, X): S = 0 for a in A: S ^= a + X return S def naive(N, A): for x in range(10): S = compute(A, x) if not S: return x return -1 def main(N, A): X = 0 for k in range(64): s = compute(A, X) >> k & 1 if s == 1: X +...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR VAR BIN_OP VAR VAR RETURN VAR FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR RETURN VAR RETURN NUMBER FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR VAR NUMBER IF VAR NUMBER VAR BIN_OP NUMBER VA...
Read problem statements in [Bengali], [Russian], [Mandarin] and [Vietnamese] as well. You are given an array A of N non-negative integers, where N is odd. Find the minimum non-negative integer x that satisfies the equation (A_{1} + x) \oplus (A_{2} + x) \oplus \dots \oplus (A_{N} + x) = 0 where \oplus denotes the [b...
t = int(input()) def func(a): ans = 0 xor = 0 for _ in range(64): for c in a: xor = xor ^ c + ans if xor == 0: return ans s = "{0:b}".format(xor) for i, c in enumerate(s[::-1]): if int(c) == 1: ans += 2**i ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR IF VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL STRING VAR FOR VAR VAR FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER VAR BIN_OP NUMBER VAR ASSIGN VAR NUM...
Read problem statements in [Bengali], [Russian], [Mandarin] and [Vietnamese] as well. You are given an array A of N non-negative integers, where N is odd. Find the minimum non-negative integer x that satisfies the equation (A_{1} + x) \oplus (A_{2} + x) \oplus \dots \oplus (A_{N} + x) = 0 where \oplus denotes the [b...
for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) nn = max(a) if n <= 1000 and nn <= 1000: f = 1 for i in range(n): ans = i + a[0] for j in range(1, n): ans = ans ^ i + a[j] if ans == 0: ...
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 IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ...
Read problem statements in [Bengali], [Russian], [Mandarin] and [Vietnamese] as well. You are given an array A of N non-negative integers, where N is odd. Find the minimum non-negative integer x that satisfies the equation (A_{1} + x) \oplus (A_{2} + x) \oplus \dots \oplus (A_{N} + x) = 0 where \oplus denotes the [b...
t = int(input()) def isbit(n, i): b = bin(n)[2:] if len(b) < i: return False if int(b[-i]): return True else: return False def xorsum(l, x): xum = 0 for i in l: xum ^= i + x return xum def do(l): x = 0 c = xorsum(l, 0) cb = bin(c)[2:] k =...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR RETURN NUMBER IF FUNC_CALL VAR VAR VAR RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR VAR BIN_OP VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR F...
Read problem statements in [Bengali], [Russian], [Mandarin] and [Vietnamese] as well. You are given an array A of N non-negative integers, where N is odd. Find the minimum non-negative integer x that satisfies the equation (A_{1} + x) \oplus (A_{2} + x) \oplus \dots \oplus (A_{N} + x) = 0 where \oplus denotes the [b...
def binary(c): return "{0:b}".format(int(c)) def find_one(a): one_index = 0 dup = a while 1: if dup % 10 == 1: return one_index else: one_index += 1 dup = dup // 10 return None def xor(n, arr, i): xor_val = arr[0] + i for l in range(1, ...
FUNC_DEF RETURN FUNC_CALL STRING FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE NUMBER IF BIN_OP VAR NUMBER NUMBER RETURN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN NONE FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR VAR RETURN ...
Read problem statements in [Bengali], [Russian], [Mandarin] and [Vietnamese] as well. You are given an array A of N non-negative integers, where N is odd. Find the minimum non-negative integer x that satisfies the equation (A_{1} + x) \oplus (A_{2} + x) \oplus \dots \oplus (A_{N} + x) = 0 where \oplus denotes the [b...
def Solve(): def calc(pos, ans): tmp, x = 0, int("1" + ans, 2) for a in A: tmp ^= a + x return "1" + ans if bin(tmp)[2:][::-1].ljust(mx, "0")[pos] == "0" else "0" + ans mx = len(bin(max(A))[2:]) ans = "" for pos in range(mx + 1): ans = calc(pos, ans) if ...
FUNC_DEF FUNC_DEF ASSIGN VAR VAR NUMBER FUNC_CALL VAR BIN_OP STRING VAR NUMBER FOR VAR VAR VAR BIN_OP VAR VAR RETURN FUNC_CALL FUNC_CALL VAR VAR NUMBER NUMBER VAR STRING VAR STRING BIN_OP STRING VAR BIN_OP STRING VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR...
Read problem statements in [Bengali], [Russian], [Mandarin] and [Vietnamese] as well. You are given an array A of N non-negative integers, where N is odd. Find the minimum non-negative integer x that satisfies the equation (A_{1} + x) \oplus (A_{2} + x) \oplus \dots \oplus (A_{N} + x) = 0 where \oplus denotes the [b...
def getAns(entries): xorVal = 0 answer = 0 for num in entries: xorVal ^= num index = 0 maxVal = max(entries) while xorVal != 0: if maxVal < 1 << index: break if xorVal & 1 << index: answer += 1 << index index += 1 xorVal = 0 ...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR NUMBER IF VAR BIN_OP NUMBER VAR IF BIN_OP VAR BIN_OP NUMBER VAR VAR BIN_OP NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR BIN_OP VAR VAR IF VAR NUMBER RETURN NUMBER RETURN VAR FUNC_DEF ASSI...