description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | import sys
def main():
import sys
input = sys.stdin.buffer.readline
u, v = map(int, input().split())
if u > v:
print(-1)
exit()
if u & 1 != v & 1:
print(-1)
exit()
if u == v == 0:
print(0)
exit()
a = 0
b = 0
w = v - u >> 1
for i ... | IMPORT FUNC_DEF IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR IF BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSI... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | import sys
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:
... | IMPORT 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 NUMB... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | a, b = list(map(int, input().split()))
if a == b and a == 0:
print(0)
elif a == b:
print(1)
print(a)
elif a > b:
print(-1)
elif (b - a) % 2 == 0:
c = (b - a) // 2
if c ^ a == c + a:
print(2)
print(c + a, c)
else:
print(3)
print(c, c, a)
else:
print(-1) | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR VAR BIN_OP ... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | def solve(u, v):
if u > v or (v - u) % 2 == 1:
return None
if u == v == 0:
return []
if u == v:
return [u]
w = (v - u) // 2
if not w & u:
return [w, v - w]
return [u, w, w]
u, v = map(int, input().split())
a = solve(u, v)
if a is None:
print(-1)
else:
pr... | FUNC_DEF IF VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER RETURN NONE IF VAR VAR NUMBER RETURN LIST IF VAR VAR RETURN LIST VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR VAR RETURN LIST VAR BIN_OP VAR VAR RETURN LIST VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | u, v = map(int, input().split())
if u > v:
print(-1)
elif u == v and u == 0:
print(0)
elif u == v:
print(1)
print(u)
elif u % 2 == 0 and v % 2 != 0 or u % 2 != 0 and v % 2 == 0:
print(-1)
elif u == 1:
print(v)
for i in range(v):
print(1, end=" ")
print()
else:
a = (v - u) // ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL ... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | import sys
u, v = map(int, input().split())
if u > v:
print(-1)
sys.exit(0)
if u == v and u == 0:
print(0)
sys.exit(0)
if u == v:
print(1)
print(u)
sys.exit(0)
if (v - u) % 2 == 1:
print(-1)
sys.exit(0)
ans = [0] * 64
ans[0] = u
v -= u
for i in range(65, -1, -1):
if u & 1 << i:
... | IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER N... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | import sys
inp = sys.stdin.readline
def input():
return inp().strip()
def iin():
return int(input())
def lin():
return list(map(int, input().split()))
def main():
T = 1
while T:
T -= 1
u, v = lin()
if u > v:
print(-1)
else:
a = []
... | IMPORT ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST ASSIGN VAR N... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | a, b = list(map(int, input().split()))
if a > b or (b - a) % 2 != 0:
print(-1)
else:
k = b - a
if k == 0:
if a == 0:
print(0)
else:
print(1, "\n" + str(a))
elif a & k // 2 == 0:
print(2)
print(a + k // 2, k // 2)
else:
print(3)
... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER BIN_OP STRING FUNC_CALL VAR VAR IF BIN_OP VAR BIN_OP VAR NUMBER NUMBER... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | u, v = map(int, input().split())
if u > v or u & 1 != v & 1:
print(-1)
elif v == u and u == 0:
print(0)
elif v == u:
print(1)
print(u)
else:
r = (v - u) // 2
if r & u:
print(3)
print(u, r, r)
else:
print(2)
print(u ^ r, r) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR VAR EXPR FUNC_CALL VAR NUMBE... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | def sol():
u, v = map(int, input().split())
if u > v or (u - v) % 2 != 0:
return -1
if u == v:
if u == 0:
return 0
else:
return "1\n%d" % u
x = (v - u) // 2
a, b = 0, 0
i = 1
u_ = u
x_ = x
while u_ or x_:
m, n = u_ % 2, x_ % 2
... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER RETURN NUMBER IF VAR VAR IF VAR NUMBER RETURN NUMBER RETURN BIN_OP STRING VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR WHILE VAR VA... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | u, v = map(int, input().split())
A = (v - u) // 2
if A < 0 or (v - u) % 2 != 0:
print(-1)
elif u == 0 and v == 0:
print(0)
else:
a = 0
b = 0
c = 0
for i in range(61):
ui = u & 1 << i
Ai = A & 1 << i
if ui == 0 and Ai > 0:
a = 1 << i | a
b = 1 << i ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BI... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | u, v = list(map(int, input().split()))
if u > v or (v - u) % 2:
print("-1")
elif u == v == 0:
print("0\n")
elif u == v:
print("1\n%d" % u)
else:
diff = (v - u) // 2
if diff & u == 0:
print("2\n%d %d" % (u | diff, diff))
else:
print("3\n%d %d %d" % (diff, diff, u)) | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP ... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | u, v = list(map(int, input().split()))
if v > u:
if (v - u) % 2 == 0:
b = (v - u) // 2
if (u ^ b) + b == v:
print(2)
print(*[u ^ b, b])
else:
print(3)
print(*[u, b, b])
else:
print(-1)
elif v == u:
if u == 0:
print(0)
... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR LIST BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR LIST VAR VAR... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | m, n = [int(i) for i in input().split()]
if m > n or (n - m) % 2 != 0:
print(-1)
else:
rz2 = (n - m) // 2
rz3 = rz2
if n == 0:
print(0)
elif n == m:
print(1)
print(n)
elif m ^ rz2 ^ rz3 == m + rz2 ^ rz3:
print(2)
print(m + rz2, rz3)
else:
print... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR VAR VAR BI... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | def compute(x, s):
rem = (s - x) // 2
a, b = 0, 0
for i in range(64):
j = x & 1 << i
k = rem & 1 << i
if j == 0 and k == 0:
pass
elif j == 0 and k > 0:
a = 1 << i | a
b = 1 << i | b
elif j > 0 and k == 0:
a = 1 << i | a
... | FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR NUMBER 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 VAR IF ... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | def solve(x, s):
a = (s - x) // 2
aa, bb = 0, 0
for i in range(0, 64):
ai = 1 << i & a
xi = 1 << i & x
if ai == 0 and xi == 0:
pass
elif ai > 0 and xi == 0:
aa = 1 << i | aa
bb = 1 << i | bb
elif ai == 0 and xi > 0:
aa =... | FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR 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 ... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | def codechef(s, x):
if s == x == 0:
print(0)
elif s == x != 0:
print(1)
print(s)
else:
a = (s - x) // 2
if s - x & 1:
print(-1)
elif a < 0:
print(-1)
elif x & a == 0:
print(2)
print(int(x + a), int(a))
... | FUNC_DEF IF VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_C... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | n, m = map(int, input().split())
if n > m:
print(-1)
elif n == m:
if n == 0:
print(0)
else:
print(1)
print(n)
elif (m - n) % 2 == 1:
print(-1)
else:
a = n
b = (m - n) // 2
if a ^ b == a + b:
print(2)
print(a ^ b, b)
else:
print(3)
p... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | MX = 64
u, v = map(int, input().split())
cx = list(map(int, reversed(bin(u)[2:])))
cx += [0] * (MX - len(cx))
cs = list(map(int, reversed(bin(v)[2:])))
cs += [0] * (MX - len(cs))
imp = False
for i in reversed(range(MX)):
if cs[i] % 2 == cx[i]:
continue
if i == 0:
imp = True
break
if ... | ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR BIN_OP LIST NUMBER BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR BIN_OP LIST NUMBER BIN_OP... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | import sys
sys.setrecursionlimit(10**6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II():
return int(sys.stdin.readline())
def MI():
return map(int, sys.stdin.readline().split())
def LI():
return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number):
return [... | IMPORT EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR STRING FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | u, v = map(int, input().split())
if u > v or u % 2 != v % 2:
print(-1)
exit()
if u == 0 and v == 0:
print(0)
exit()
if u == v:
print(1)
print(u)
exit()
w = (v - u) // 2
W = format(w, "b")
U = format(u, "b")
L = max(len(W), len(U))
W = "0" * (L - len(W)) + W
U = "0" * (L - len(U)) + U
a, b = ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | xor, sm = map(int, input().split())
diff = sm - xor
if diff < 0 or diff % 2:
l = -1
elif xor == sm == 0:
l = 0
elif xor == sm:
l = 1
ans = [sm]
else:
l = 2
for i in range(60):
if xor >> i & diff >> i + 1:
l = 3
ans = [0] * l
for i in range(60):
j = 0
i... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP BIN_OP VAR VAR BIN_OP VAR BIN_OP VAR NUMBER A... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | u, v = map(int, input().split())
def d(v=-1):
print(v)
exit(0)
if u > v:
d()
if u == v:
if u == 0:
d(0)
else:
print(1)
d(u)
bit_u = [0] * 600
bit_v = [0] * 600
for i in range(64):
if 1 << i & u:
bit_u[i] = 1
if 1 << i & v:
bit_v[i] = 1
for i in ran... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR IF VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER N... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | def main_function():
u, v = list(map(int, input().split(" ")))
if u > v or (v - u) % 2 == 1:
print("-1")
elif (v - u) % 2 == 0:
sup_num = (v - u) // 2
A = [sup_num, u + sup_num]
if A[0] ^ A[1] == u:
if A[0] != 0:
print(2)
else:
... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR LIST VAR BIN_OP VAR VAR IF BIN_OP VAR NUMBER VAR NUMBER VAR IF VAR NUM... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | for _ in range(1):
u, v = map(int, input().split())
if u == v and u + v != 0:
print(1)
print(u)
elif v < u:
print(-1)
elif (v - u) % 2 == 1:
print(-1)
elif u + v == 0:
print(0)
else:
z = v - u
if z // 2 + u ^ z // 2 == u:
print(... | FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | def solve():
u, v = map(int, input().split())
if u > v:
print("-1")
return
if u % 2 != v % 2:
print("-1")
return
if u == 0 and v == 0:
print(0)
return
if u == v:
print(1)
print(u)
return
x = (v - u) // 2
if u & x:
... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR STRING RETURN IF BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING RETURN IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN ASSIGN VAR BI... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | import sys
input = sys.stdin.readline
x, s = [int(x) for x in input().split()]
if x > s or x % 2 != s % 2:
print(-1)
exit()
elif x == s:
if x == 0:
print(0)
else:
print(1)
print(x)
exit()
ans1, ans2 = 0, 0
a = (s - x) // 2
if a & x:
print(3)
print(x, a, a)
else:
... | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR IF VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMB... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | v, u = map(int, input().split())
count = [0] * 100
index = 0
works = True
while u >= 0 and v >= 0 and (v > 0 or u > 0):
u2 = u & 1
v2 = v & 1
if u2 != v2:
u -= 1
if index:
count[index - 1] += 2
else:
works = False
break
elif u2:
u -= 1
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER IF VAR... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | x, s = map(int, input().split())
if x == 0 and s == 0:
print(0)
exit()
if x > s:
print(-1)
exit()
if x & 1 != s & 1:
print(-1)
exit()
if x == s:
print(1)
print(x)
exit()
if x == 0:
print(2)
print(s // 2, s // 2)
exit()
b = (s - x) // 2
f = 1
bx = bin(x)[2:]
ba = ""
bb = b... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR IF BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL V... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | import sys
def go():
x, s = map(int, input().split())
if x > s:
return -1
if x == s == 0:
return 0
left = 0
bits = []
for b in range(s.bit_length() - 1, -1, -1):
f = 1 << b
curbit = 0
left = left * 2 + ((s & f) >> b)
cur = (x & f) >> b
if... | IMPORT FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR RETURN NUMBER IF VAR VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER BIN_OP BI... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | u, v = [int(x) for x in input().split()]
if u == v == 0:
print(0)
exit()
if u == v:
print("1\n" + str(u))
exit()
if u > v:
print(-1)
exit()
if (u - v) % 2 == 1:
print(-1)
exit()
a = (v - u) // 2
b = v - a
if a & b != a:
print("3\n" + str(u) + " " + str(a) + " " + str(a))
else:
pr... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR EXPR FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR N... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | import sys
u, v = [int(v) for v in sys.stdin.readline().split()]
def m():
if (v - u) % 2 == 1:
return None
ar = []
h = (v - u) // 2
if u & h == 0:
ar.append(u | h)
ar.append(h)
else:
ar.append(u)
ar.append(h)
ar.append(h)
return ar
if u > v:
... | IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER RETURN NONE ASSIGN VAR LIST ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUN... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | from sys import stdin
u, v = map(int, stdin.readline().split())
k = u
if (u - v) % 2 != 0:
print(-1)
exit()
if u == v:
if u == 0:
print(0)
exit()
else:
print(1)
print(u)
exit()
if v < u:
print(-1)
exit()
x = (v - u) // 2
u = [int(z) for z in list(bin(u)[2... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR IF VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL ... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | xor, sm = map(int, input().split())
if xor > sm:
print("-1")
elif xor % 2 != sm % 2:
print("-1")
elif xor == 0 and sm == 0:
print("0")
elif xor == 0:
print("2")
v = sm // 2
print(v, v)
elif xor == 1 and sm == 1:
print("1")
print("1")
elif xor == sm:
print("1")
print(xor)
else:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR STRING IF BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR IF VAR NUMBER ... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | u, v = [int(i) for i in input().split(" ")]
if v == 0:
print(0)
elif v == u:
print(1)
print(v)
elif v > u and (v - u) % 2 == 0:
if u ^ (v - u) // 2 == u + (v - u) // 2:
print(2)
print(u + (v - u) // 2, (v - u) // 2)
else:
print(3)
print(u, (v - u) // 2, (v - u) // 2)
... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER IF BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUM... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | u, v = list(map(int, input().split()))
if u > v:
print(-1)
elif u == v:
if u == v == 0:
print(0)
else:
print(1)
print(u)
elif (v - u) % 2 == 1:
print(-1)
else:
a = u
b = 0
for i in reversed(list(range(65))):
res = v - (a + b)
if u & 1 << i:
... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FU... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | def kset(n, k):
if n >> k - 1 and 1:
return 1
else:
return 0
def compute(S, X):
A = (S - X) // 2
a = 0
b = 0
for i in range(64):
Ai = A & 1 << i
Xi = X & 1 << i
if Xi == 0 and Ai == 0:
pass
elif Xi == 0 and Ai != 0:
a = 1 ... | FUNC_DEF IF BIN_OP VAR BIN_OP VAR NUMBER NUMBER RETURN NUMBER RETURN NUMBER 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 ... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | u, v = map(int, input().split())
if u > v or u % 2 != v % 2:
print("-1")
elif u == 0 and v == 0:
print("0")
elif u == v:
print("1\n")
print(u)
else:
x = int((v - u) // 2)
if u & x == 0:
print("2")
print(u + x, x, sep=" ")
else:
print("3")
print(u, x, x, sep=" ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER ... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | u, v = map(int, input().split())
if u == 0 and v == 0:
print(0)
exit()
if u == v:
print(1)
print(u)
exit()
if v < u or v - u & 1:
print(-1)
exit()
a, b, c = u, (v - u) // 2, (v - u) // 2
if a + b == a ^ b:
print(2)
print(a + b, c)
else:
print(3)
print(a, b, c) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR IF VAR VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR BIN_OP... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | def compute(S, X):
A = (S - X) // 2
a = 0
b = 0
if (S - X) % 2 != 0:
return -1
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
e... | FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER RETURN 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_O... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | def solve():
u, v = map(int, input().split())
if u % 2 != v % 2 or u > v:
print(-1)
return
if u == v:
if u:
print(1)
print(u)
else:
print(0)
return
x = (v - u) // 2
if u & x:
print(3)
print(u, x, x)
else:... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL VAR NUMBER RETURN IF VAR VAR IF VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR VAR EXPR FUNC_CALL V... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | def f():
xor, sum = [int(s) for s in input().split()]
rem = sum - xor
if rem < 0 or rem & 1:
print(-1)
return
if sum == 0:
print(0)
return
if rem == 0:
print(1)
print(xor)
return
rem >>= 1
if rem & xor == 0:
print(2)
pri... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN VAR NUMBER IF BIN_OP VAR VAR NUMBER EXPR F... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | def linput(a):
return [int(i) for i in a.split()]
for ughblnk in range(1):
u, v = linput(input())
if u > v:
print(-1)
elif u % 2 != v % 2:
print(-1)
elif u == 0 and v == 0:
print(0)
elif u == v:
print(1)
print(u)
else:
t = (v - u) // 2
... | FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR F... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | u, v = input().split()
u = int(u)
v = int(v)
delta = v - u
if delta < 0 or delta % 2 == 1:
print(-1)
elif delta == 0:
if u == 0:
print("0")
else:
print("1", "\n", u, sep="")
else:
d2 = delta // 2
if d2 & u:
print("3", "\n", d2, " ", d2, " ", u, sep="")
else:
print... | 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 VAR IF VAR NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING STRING VAR STRING ASSIGN VAR BIN_OP VAR NUMBER IF BI... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | sp = lambda: list(map(int, input().split()))
si = lambda: int(input())
u, v = sp()
k = (v - u) // 2
if u > v or u % 2 != v % 2:
print(-1)
elif u == 0:
if v == 0:
print(0)
else:
print(2)
print(k, k)
elif k == 0:
print(1)
print(u)
elif k & u == 0:
print(2)
print(u + k, ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | def pr1(a):
print(a)
exit()
flag = [0] * 100
u, v = map(int, input().split())
if u <= v:
if v == 0:
pr1(0)
if v == u:
print(1)
print(v)
exit()
if (v - u) % 2 == 1:
pr1(-1)
fl = True
for i in range(70):
if v - u & 1 << i:
flag[i - ... | FUNC_DEF EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR F... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | import sys
input = sys.stdin.readline
def inp():
return int(input())
def inlt():
return list(map(int, input().split()))
def insr():
s = input()
return list(s[: len(s) - 1])
def invr():
return map(int, input().split())
n, k = invr()
if k < n or abs(k - n) % 2 != 0:
print(-1)
elif n == ... | IMPORT ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR RETURN FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR IF V... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | u, v = map(int, input().split())
ans = []
tmp = v
for i in range(1000):
if u >> i & 1 == 1 and v >> i & 1 == 0:
if i - 1 < 0:
print(-1)
exit()
ans.append(1 << i - 1)
ans.append(1 << i - 1)
ans.append(1 << i)
v -= 1 << i + 1
elif u >> i & 1 == 0 and... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER BIN_OP BIN_OP VAR VAR NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP NUMBER BIN_OP VAR NUMBER EXPR... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | import sys
def main():
u, v = readIntArr()
ans = []
if u > v:
ans.append([-1])
elif u == v:
if u == 0:
ans.append([0])
else:
ans.append([1])
ans.append([u])
else:
w = v - u
if w % 2 == 1:
ans.append([-1])
... | IMPORT FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR LIST IF VAR VAR EXPR FUNC_CALL VAR LIST NUMBER IF VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR LIST NUMBER EXPR FUNC_CALL VAR LIST NUMBER EXPR FUNC_CALL VAR LIST VAR ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR LIST NUMBER ASSIGN VAR BIN_OP... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | def f(a):
b = 0
while a > 0:
b += 1
a //= 2
return 2 ** (b - 1)
u, v = map(int, input().split())
if u > v:
print(-1)
elif u == v == 0:
print(0)
elif u == v:
print(1)
print(v)
else:
k = 0
while True:
if u == 0:
break
c = f(u)
u -= ... | FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER VAR NUMBER RETURN BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | u, v = map(int, input().split())
if v < u or (v - u) % 2 != 0:
print(-1)
elif u == v:
if u == 0:
print(0)
else:
print("1\n" + str(u))
else:
w = (v - u) // 2
if w | u == w + u:
print("2\n" + str(w | u) + " " + str(w))
else:
print("3\n" + str(u) + " " + str(w) + " "... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL ... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | x, s = map(int, input().split())
def odw(l):
wyn = 0
pot = 1
for i in l:
wyn += pot * i
pot *= 2
return wyn
def konw(n):
l = []
while n > 0:
l.append(n % 2)
n //= 2
return l
xx = konw(x)
ss = konw(s)
if x == 0 and s == 0:
print(0)
else:
if x > s:... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR BIN_OP VAR VAR VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR LIST WHILE VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | u, v = map(int, input().split())
if u == v == 0:
print(0)
exit()
if u == v:
print(1)
print(u)
exit()
if u > v:
print(-1)
exit()
a = (v - u) // 2
b = v - a
if a ^ b == u:
print(2)
print(a, b)
exit()
if (v - u) % 2 == 0:
print(3)
print(u, (v - u) // 2, (v - u) // 2)
else:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | u, v = map(int, input().split())
if u > v or (v - u) % 2 == 1:
print(-1)
return
v = (v - u) // 2
a = u | v
b = v
c = u & v
if a == 0:
print(0)
elif b == 0:
print(1)
print(a)
elif c == 0:
print(2)
print(a, b)
else:
print(3)
print(a, b, c) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUM... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | u, v = map(int, input().split())
if u > v:
print(-1)
elif u == v:
if u == 0:
print(0)
else:
print(1)
print(u)
else:
dif = v - u
if dif % 2 == 0:
ha = dif // 2
tr = ha + u
if ha ^ tr == u:
print(2)
print(tr, ha)
else:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR VAR... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | u, v = map(int, input().split())
if u % 2 != v % 2 or u > v:
print(-1)
exit()
s = bin(u)[2:].rjust(60, "0")
cnt = [0] * 60
for i in range(60):
cnt[i] += int(s[i])
dif = v - u
for i in range(60):
if i == 55:
h = 0
cur = dif // (1 << 60 - i - 1)
cur -= cur % 2
if 1 << 60 - i - 1 <= dif... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER NUMBER STRING ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | u, v = list(map(int, input().split()))
if u > v:
print(-1)
elif u == 0 and v == 0:
print(0)
elif u == v:
print(1)
print(u)
else:
a, b, c = u, (v - u) // 2, (v - u) // 2
d, e = (v - u) // 2 + u, (v - u) // 2
if d + e == v and d ^ e == u:
print(2)
print(d, e)
elif a + b + c... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR BIN_O... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | import sys
u, v = list(map(int, sys.stdin.readline().strip().split()))
w = v - u
if w % 2 == 1 or w < 0:
print(-1)
elif w == 0:
if u == 0:
print(0)
else:
print(1)
print(str(u))
else:
w = w // 2
if u & w == 0:
print(2)
print(str(u + w) + " " + str(w))
else... | IMPORT ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NU... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | u, v = map(int, input().split())
bits = [0] * 61
i = 0
if u & 1 != v & 1:
print(-1)
else:
c = 0
while u or v:
a = u & 1
b = v & 1
if a == 1 and b == 1:
bits[i] += 1
if c == 1:
bits[i - 1] += 2
elif a == 1 and b == 0:
bits[i]... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR NUMBER VAR VAR NUMBER IF VAR NUMBER... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | u, v = map(int, input().split())
def sameforbin(a, b):
aa = bin(a)[2:]
bb = bin(b)[2:]
for i in range(1, min(len(aa), len(bb)) + 1):
if aa[-i] == bb[-i] == "1":
return True
return False
if u > v or (v - u) % 2:
print(-1)
elif u == v == 0:
print(0)
elif u == v:
print(1... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR VAR STRING RETURN NUMBER RETURN NUMBER IF VAR VAR BIN_OP BIN_OP VAR VAR NU... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | u, v = [int(x) for x in input().split()]
if u > v or (v - u) % 2 == 1:
print(-1)
elif u == v == 0:
print(0)
elif u == v:
print(1)
print(u)
else:
a, b = u | (v - u) // 2, (v - u) // 2
if a ^ b == u and a + b == v:
print(2)
print(a, b)
else:
print(3)
print((v - ... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBE... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | [u, v] = list(map(int, input().split(" ")))
if u == 0 and v == 0:
print(0)
elif u > v or u % 2 != v % 2:
print(-1)
elif u == v:
print(1)
print(v)
else:
t = (v - u) // 2
if t & u:
print(3)
print(str(t) + " " + str(t) + " " + str(u))
else:
print(2)
print(str(t) ... | ASSIGN LIST VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | from sys import stdin, stdout
u, v = map(int, stdin.readline().split())
if u > v:
print("-1")
elif u % 2 != v % 2:
print("-1")
elif u == 0 and v == 0:
print("0")
elif u == 0:
print(2)
print(v // 2, v // 2)
elif u == v:
print(1)
print(u)
else:
t = (v - u) // 2
if t & u != 0:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR STRING IF BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR EXPR... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | x, y = map(int, input().split())
if x == 0 and y == 0:
print(0)
elif x == y:
print(1)
print(x)
elif abs(x - y) % 2 == 1 or x > y:
print(-1)
else:
y = y - x
y = y // 2
yy = y
xx = x
p = 0
while yy > 0:
if yy % 2 == 1 and xx % 2 == 1:
p = 1
break
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR BIN_OP VAR VAR NUMBER NUMBER VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | def calc():
tot = 2
a = u
b = 0
c = 0
d = v - u
nb = 0
while d > 0:
if d & 1:
if 1 << nb - 1 & a:
tot = 3
b += 1 << nb - 1
c += 1 << nb - 1
else:
a += 1 << nb - 1
b += 1 << nb - 1
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER IF BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER VAR BIN_OP NUMBER BIN_OP VAR NUMBER VAR BIN_OP NUMBER BIN_OP VAR NUMBER VAR BIN_OP NUMBER BIN_OP... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | u, v = map(int, input().split())
if u > v or u % 2 != v % 2:
print("-1")
elif u == v == 0:
print(0)
elif u == v:
print(1)
print(u)
elif u & (v - u) // 2 is not 0:
print(3)
print(u, (v - u) // 2, (v - u) // 2)
else:
print(2)
print(u + (v - u) // 2, (v - u) // 2) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR IF BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | import sys
input = lambda: sys.stdin.readline().rstrip()
u, v = map(int, input().split())
if u == 0 and v == 0:
print(0)
elif v < u or (v - u) % 2 == 1:
print(-1)
elif u == v:
print(1)
print(u)
else:
Ans = [u, (v - u) // 2, (v - u) // 2]
if Ans[0] + Ans[1] == Ans[0] | Ans[1]:
Ans = [Ans... | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR BIN_OP BIN_OP VAR... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | u, v = map(int, input().split())
if u & 1 ^ v & 1 or u > v:
print(-1)
exit()
if not u and not v:
print(0)
exit()
if u == v:
print(1)
print(u)
exit()
_and = (v - u) // 2
c = int(u + _and)
d = int(_and)
if c ^ d == u:
print(2)
print(c, d)
exit()
print(3)
print((v - u) // 2, u, (v -... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR ... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | import sys
from sys import stdin
tt = 1
for loop in range(tt):
u, v = map(int, stdin.readline().split())
if v == u == 0:
print(0)
sys.exit()
if u % 2 != v % 2 or u > v:
print(-1)
sys.exit()
if u == v:
print(1)
print(u)
sys.exit()
ans = [0, 0]
... | IMPORT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR IF BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR V... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | from sys import exit
v, u = map(int, input().split())
arr = []
for i in range(64):
if v >> i & 1:
arr.append(1 << i)
x = u - v
if x < 0 or x % 2 != 0:
print(-1)
exit(0)
for i in range(64):
if x >> i & 1:
arr.append(1 << i - 1)
arr.append(1 << i - 1)
for i in range(len(arr)):
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF ... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | a, b = map(int, input().split())
x = (b - a) // 2
if a > b or (a - b) % 2:
print(-1)
elif b == 0:
print(0)
elif a == b:
print(1)
print(b)
elif x + a ^ x == a:
print(2)
print(x + a, x)
else:
print(3)
print((b - a) // 2, (b - a) // 2, a) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR NUMBE... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | u, v = list(map(int, input().split()))
rem = v - u
out = [u]
if rem < 0:
print(-1)
elif v == u == 0:
print(0)
elif rem == 0:
print(1)
print(u)
elif rem % 2 == 0:
add = rem // 2
if add + u == add ^ u:
print(2)
print(add + u, add)
else:
print(3)
print(u, add, ad... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR LIST VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | xor, sum = map(int, input().split())
answer = []
if xor > sum or sum - xor & 1:
print(-1)
exit()
elif xor == sum:
if xor == 0:
print(0)
exit()
answer.append(xor)
else:
carry = False
X, S = xor, sum
xor, sum = bin(xor)[2:][::-1], bin(sum)[2:][::-1]
xor = xor + "0" * (len(s... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST IF VAR VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR IF VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | s = input().split()
u = int(s[0])
v = int(s[1])
if u > v or (u + v) % 2 == 1:
print(-1)
elif u == v == 0:
print(0)
elif u == v:
print(1)
print(u)
elif (u + v) % 2 == 0:
if (v + u) // 2 ^ (v - u) // 2 == u:
print(2)
print((v + u) // 2, " ", (v - u) // 2)
else:
print(3)
... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER NUMB... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | import sys
input = sys.stdin.readline
def main():
U, V = [int(x) for x in input().split()]
if U > V:
print(-1)
return
if V == 0:
print(0)
return
if U == V:
print(1)
print(U)
return
if abs(U - V) % 2 != 0:
print(-1)
return
... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER RETURN IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN IF BIN_OP FUNC_CALL VAR BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VA... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | from sys import stdin, stdout
def main():
a, b = list(map(int, stdin.readline().split()))
if a == 0:
if b == 0:
print("0")
return
elif b % 2 == 0:
print("2")
print(str(int(b / 2)) + " " + str(int(b / 2)))
return
else:
... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING RETURN IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER STRING FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR ... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | u, v = map(int, input().split())
if (u - v) % 2 != 0 or u > v:
print(-1)
elif u == 0 == v:
print(0)
elif u == v:
print(1)
print(u)
else:
U = u
V = v
u = bin(u)[2:]
v = bin(v)[2:]
u = "0" * (70 - len(u)) + u
v = "0" * (70 - len(v)) + v
A = [0] * 70
b = True
for i in ra... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | ch = input()
L = [int(i) for i in ch.split()]
a = L[0]
b = L[1]
if a > b:
print(-1)
elif a == b:
if a == 0:
print(a)
else:
print(1)
print(a)
elif (b - a) % 2 == 1:
print(-1)
elif a & (b - a) // 2 == 0:
print(2)
print(a + (b - a) // 2, (b - a) // 2)
else:
print(3)
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER IF BI... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | 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 ... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | u, v = map(int, input().split())
def xorcise(u, v):
if u > v or v & 1 != u & 1:
print(-1)
return
m = v.bit_length()
r_bits = list(map(int, reversed(format(v - u, "b").zfill(m))))
x = u
y = 0
z = 0
for b in range(m - 1):
d = 1 << b
if r_bits[b + 1]:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR BIN_OP VAR VAR STRING VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VA... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | def two(s, x):
aa = (s - x) // 2
a = 0
b = 0
for i in range(0, 100):
nowi = x & 1 << i
nowa = aa & 1 << i
if nowi == 0 and nowa == 0:
continue
if nowi == 0 and nowa > 0:
a = 1 << i | a
b = 1 << i | b
elif nowi > 0 and nowa == 0:... | FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER 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 NUMB... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
u, v = list(map(int, input().split()))
if u > v:
print(-1)
elif u == v:
if u == 0:
print(0)
else:
print(1)
print(u)
elif u % 2 == 0:
if v % 2 == 0:
num = (v - u) // 2
num2 = int(num & u)
... | IMPORT ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER A... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | powers = [(2**i) for i in range(61)]
x, s = map(int, input().split())
if x > s:
print(-1)
elif x == s:
if x == 0:
print(0)
else:
print(1)
print(x)
else:
bckt = [0] * 3
bckt[0] = x
s -= x
i = 0
bad = set()
good = set()
while i < 61:
query = x >> i
... | ASSIGN VAR BIN_OP NUMBER VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER VAR VAR VAR ASSIG... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | def linput(a):
return [int(i) for i in a.split()]
for ughblnk in range(1):
u, v = linput(input())
if u > v:
print(-1)
elif u % 2 != v % 2:
print(-1)
elif u == 0 and v == 0:
print(0)
elif u == v:
print(1)
print(u)
else:
t = (v - u) // 2
... | FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR F... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | def solve(u, v):
if u == v:
return [u]
elif u > v:
return None
if (v - u) % 2 == 0:
x = (v - u) // 2
if u & x == 0:
return [u | x, x]
else:
return [u, x, x]
else:
return None
u, v = map(int, input().split())
r = solve(u, v)
if not... | FUNC_DEF IF VAR VAR RETURN LIST VAR IF VAR VAR RETURN NONE IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER RETURN LIST BIN_OP VAR VAR VAR RETURN LIST VAR VAR VAR RETURN NONE ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | from sys import stdin
for line in stdin:
u, v = map(int, line.split())
if u > v or (v - u) % 2 == 1:
print("-1")
elif u == v:
if v == 0:
print("0")
else:
print("1")
print(u)
else:
t = (v - u) // 2
if u & t == 0:
pri... | FOR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR IF VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING IF VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRI... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | def f(u, v):
x = [int(y) for y in bin(u)[2:]]
s = [int(z) for z in bin(v)[2:]]
x = [0] * (len(s) - len(x)) + x
a = [0] * len(x)
b = [0] * len(x)
for i in range(len(x) - 1, 0, -1):
if x[i] == 1:
a[i] = 0
b[i] = 1
elif s[i - 1] == x[i - 1]:
a[i] ... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP LIST NUMBER BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CA... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | def main():
u, v = map(int, input().split())
if u > v:
print(-1)
return
if u == v:
if u == 0:
print(0)
return
print(1)
print(u)
return
diff = v - u
if diff % 2 == 0:
arr = [u, diff // 2, diff // 2]
a = diff // 2
... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER RETURN IF VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR LIST VAR BIN_OP VAR NUMBER BIN_... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | u, v = map(int, input().split())
if u == v and u == 0:
print(0)
elif v < u or (v - u) % 2 == 1:
print(-1)
elif u == v:
print(1)
print(u)
else:
ub = []
a1 = u
while u > 0:
ub.append(u % 2)
u = u // 2
vb = []
v = (v - a1) // 2
a2 = v
while v > 0:
vb.appe... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR VAR WHILE VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMB... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | x, s = map(int, input().split())
if s == 0:
print(0)
elif x > s or (s - x) % 2 == 1:
print(-1)
elif x == 0:
print(2)
print(s // 2, s // 2)
elif x == s:
print(1)
print(s)
elif (
int("1" * (len(bin(x)) - 2), 2) ^ s - int("1" * (len(bin(x)) - 2), 2) == x
and s - int("1" * (len(bin(x)) - 2),... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | from sys import stdin
input = stdin.buffer.readline
u, v = map(int, input().split())
if u > v or u & 1 != v & 1:
print(-1)
elif u == v:
print("1\n{}".format(u) if u else "0")
else:
z = (v - u) // 2
print("3\n{} {} {}".format(u, z, z) if u & z != 0 else "2\n{} {}".format(u + z, z)) | ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR FUNC_CALL STRING VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR NUMBER FUNC_CALL STRING VAR VAR VAR FUN... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | u, v = map(int, input().split())
if u > v:
print(-1)
exit(0)
if u == 0 and v == 0:
print(0)
exit(0)
if u == v:
print(1)
print(u)
exit(0)
binary = [(2**i) for i in range(61)]
p = [0] * 60
d = v - u
v1 = v - u
u1 = u
for i in range(60 - 1, -1, -1):
p[i] += u1 // binary[i]
u1 %= binary[... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR VAR FUNC... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | u, v = map(int, input().split())
if u == v:
if u > 0:
ans = [u]
else:
ans = []
elif u > v:
ans = None
else:
diff = v - u
if diff % 2:
ans = None
elif u + diff // 2 == u ^ diff // 2:
ans = [u + diff // 2, diff // 2]
else:
ans = [u, diff // 2, diff // 2]... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR IF VAR NUMBER ASSIGN VAR LIST VAR ASSIGN VAR LIST IF VAR VAR ASSIGN VAR NONE ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR NUMBER ASSIGN VAR NONE IF BIN_OP VAR BIN_OP VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR LIST BIN_OP VAR BIN_OP VAR NUMBER BIN_OP... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | from sys import stdin
inf = stdin
v, u = map(int, inf.readline().split(" "))
if u > v:
if v % 2 != u % 2:
print(-1)
else:
posi = v
temp = (u - v) // 2
if posi + temp == posi ^ temp:
print(2)
print(posi + temp, temp)
else:
print(3)
... | ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF VAR VAR IF BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR EXPR FUNC_CAL... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | import sys
input = sys.stdin.readline
u, v = map(int, input().split())
if u > v:
print(-1)
elif (v - u) % 2 == 1:
print(-1)
elif u == v == 0:
print(0)
elif u == v:
print(1)
print(u)
else:
A = (v - u) // 2
B = (v - u) // 2
REST = u
for i in range(64):
if REST & 1 << i != 0 an... | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NU... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | import sys
def input():
return sys.stdin.readline()
def iinput():
return int(input())
def rinput():
return input().split()
def rlinput():
return [int(i) for i in input().split()]
def main():
q = [0] * 100
u, v = rlinput()
if u <= v:
if v == 0:
print(0)
... | IMPORT FUNC_DEF RETURN FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR IF VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN NUMB... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | import sys
input = sys.stdin.readline
def solve():
u, v = map(int, input().split())
if u == 0:
if v == 0:
print(0)
return
if v % 2 == 1:
print(-1)
return
print(2)
print(v // 2, v // 2)
return
if u > v:
print(-... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER RETURN EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER RETURN IF VAR VAR EXPR FUNC_C... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | data = input().rstrip().split()
x, s = int(data[0]), int(data[1])
def main(s, x):
if s == x:
if s == 0:
print(0)
else:
print(1)
print(x)
else:
d = s - x
if d < 0 or d % 2 == 1:
print(-1)
return
a = d // 2
... | ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER FUNC_DEF IF VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER RETURN ASS... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | from sys import stdin
def mp():
return map(int, stdin.readline().split())
def ml():
return list(map(int, stdin.readline().split()))
xor, sm = mp()
if xor > sm:
print(-1)
elif (sm - xor) % 2 == 1:
print(-1)
else:
n1 = xor
n2 = (sm - xor) // 2
if n1 == 0 and n2 == 0:
print(0)
... | FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF V... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | u, v = list(map(int, input().split()))
mas = []
if v < u - 1:
print(-1)
exit()
if u % 2 != v % 2:
print(-1)
exit()
if u == 0 and v == 0:
print(0)
exit()
if u == v:
print(1)
print(u)
exit()
x = (v - u) // 2
if u & x:
print(3)
print(u, x, x, sep=" ")
exit()
print(2)
print(u... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR IF BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR IF VAR VA... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.