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:...
xor, summ = map(int, input().split()) if xor > summ or xor & 1 != summ & 1: print(-1) else: temp = (summ - xor) // 2 if temp != 0: if xor & temp: print(3) print(xor, temp, temp) else: print(2) print(temp + xor, temp) elif xor == 0 and summ ...
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 ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR NUMBER IF BIN_OP VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR 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:...
def solve(): u, v = map(int, input().split()) if abs(u - v) % 2 != 0 or u > v: return -1 elif u == v: return f"{1}\n{u}" if u != 0 else "0" else: x = (v - u) // 2 if u & x: return f"3\n{u} {x} {x}" else: return f"2\n{u ^ x} {x}" print(sol...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP FUNC_CALL VAR BIN_OP VAR VAR NUMBER NUMBER VAR VAR RETURN NUMBER IF VAR VAR RETURN VAR NUMBER NUMBER STRING VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR VAR RETURN STRING VAR STRING VAR STRING VAR RETURN STRING BIN_OP 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 = list(map(int, input().split())) ind = 0 if u > v or (v - u) % 2 == 1: print(-1) elif v == 0: print(0) elif u == v: print("1") print(u) else: v = (v - u) // 2 bit_u = [0] * 100 bit_v = [0] * 100 ind = 0 while v > 0: if v % 2 == 1: bit_v[ind] = 1 v = ...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN 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 IF VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR 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:...
u, v = [int(x) for x in input().split()] if u == 0 and v == 0: print(0) exit(0) if u == v: print(1) print(u) exit(0) if u > v or (u - v) % 2 == 1: print(-1) exit(0) result = 0 tmp_u = u tmp_and = v - u >> 1 x = tmp_and i = 0 j = 0 while tmp_u > 0 or tmp_and > 0: a = tmp_and % 2 b = t...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR 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 IF VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL 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:...
u, v = [int(x) for x in input().split()] v1 = (v - u) // 2 v2 = (v + u) // 2 if u > v or (v - u) % 2 == 1: print(-1) elif u == v and v == 0: print(0) elif u == v: print(1) print(u) elif v1 ^ v2 == u: print(2) print(v1, v2) else: print(3) print(v1, v1, u)
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR BIN_OP BIN_OP VAR VAR NUMBER 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 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:...
import sys def toBinary(n): arr = [] k = n i = 0 while k > 0: next = k % (2 * 2**i) // 2**i arr.append(next) k -= next * 2**i i += 1 return arr fptr = sys.stdout uv = input().split() u = int(uv[0]) v = int(uv[1]) def f(u, v): if u > v: fptr.write(str...
IMPORT FUNC_DEF ASSIGN VAR LIST ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP NUMBER BIN_OP NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR VAR VAR BIN_OP VAR BIN_OP NUMBER VAR VAR NUMBER RETURN VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL 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:...
def ii(): return int(input()) def mi(): return map(int, input().split()) def ai(): return list(map(int, input().split())) u, v = mi() if u > v or u & 1 != v & 1: print(-1) elif u == 0 and v == 0: print(0) else: x = (v - u) // 2 if x: if u & x != 0: print(3) ...
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 ASSIGN VAR VAR FUNC_CALL VAR IF VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER 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:...
u, v = list(map(int, input().split())) if (v - u) % 2 == 1: print(-1) elif v == 0 and u == 0: print(0) elif v < u: print(-1) elif v == u: print(1) print(u) else: bu = bin(u) bv = bin(v) k = (v - u) // 2 bk = bin(k) if u ^ k == u + k: print(2) print(k, k + u) e...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN ...
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()) dif = v - u if dif < 0 or dif % 2: print(-1) return elif dif == 0 and u == 0: print(0) return elif dif == 0: ans = [u] else: half = dif >> 1 rest = v - 2 * half if rest & half: ...
FUNC_DEF 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 EXPR FUNC_CALL VAR NUMBER RETURN IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN IF VAR NUMBER ASSIGN VAR LIST VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER 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 run(): xo, s = list(map(int, input().split())) if s < xo: print(-1) return if s == xo: if s != 0: print(1) print(xo) return if (s - xo) % 2 != 0: print(-1) return an = (s - xo) // 2 an_binary = "{0:b}".format(an) xo_bina...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL 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 EXPR FUNC_CALL VAR VAR RETURN IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER 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 gettrace, stdin if not gettrace(): def input(): return next(stdin)[:-1] def main(): u, v = map(int, input().split()) if u > v: print(-1) return if u % 2 != v % 2: print(-1) return if v == 0: print(0) return if u == v: ...
IF FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR NUMBER FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER RETURN IF BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN IF VAR VAR 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:...
def GETBIT(x, bit): return x >> bit & 1 def solve(u, v): if u > v: print(-1) return if v == 0: print(0) return v -= u if v == 0: print(1) print(u) return rs = 1 lst = [0] * 3 lst[0] += u if v % 2 == 1: print(-1) ...
FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR NUMBER FUNC_DEF IF VAR VAR EXPR FUNC_CALL VAR NUMBER RETURN IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR NUMBER VAR IF 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:...
bit = 67 x, s = map(int, input().split()) if x == s: if s != 0: print(1) print(s) else: print(0) exit(0) s -= x if s < 0 or s & 1: print(-1) exit(0) a = 0 for i in range(1, bit): if s >> i & 1: a += 1 << i - 1 if a & x: print(3) print(a, a, x) else: x ...
ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR VAR IF VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR 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:...
a, b = map(int, input().split()) def f(a, b): if b - a < 0 or (b - a) % 2 == 1: print(-1) elif b == 0: print(0) elif a == b: print(1) print(b) else: x = (b - a) // 2 if a ^ x == a + x: sol = [a + x, x] else: sol = [a, x, x...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER 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 ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR VAR BIN_OP 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()) kouho = [u] k = v - u if k < 0 or k % 2 != 0: if u == v: print(1) print(u) else: print(-1) exit() k //= 2 kouho.append(k) kouho.append(k) if kouho[1] == 0: if u == 0: print(0) else: print(1) print(u) elif kouho[0] ^ kou...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER BIN_OP VAR NUMBER NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR IF VAR NUMBER 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 main(): u0, v = map(int, input().split()) if u0 > v or (v - u0) % 2 != 0: print(-1) return 0 u = [(0) for i in range(100)] curr = 0 while u0 > 0: u[curr] = u0 % 2 u0 //= 2 curr += 1 out = [(0) for i in range(100)] s = 0 for i in ra...
IMPORT 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 EXPR FUNC_CALL VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER 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 = list(map(int, input().split())) def function(u, y): dict1 = {} a = bin(u)[2:] b = len(a) for i in range(b): if a[i] == "1": dict1[b - i] = 1 c = bin(y)[2:] d = len(c) for i in range(d): if c[i] == "1": if d - i in dict1.keys(): ...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR DICT ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR 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:...
x, s = map(int, input().split()) if x > s: print(-1) exit(0) if x == s == 0: print(0) exit(0) if x == s: print(1) print(x) exit(0) if x == 0 and s % 2 == 1: print(-1) exit(0) elif x == 0: print(2) print(s // 2, s // 2) exit(0) if (s + x) % 2 == 1: print(-1) exit(0...
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 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 VAR NUMBER BIN_OP VAR NUMBER 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:...
x, s = map(int, input().split()) def func(x, s): if s < x or abs((s - x) % 2) == 1: return [-1] elif s == x: return [s] else: andd = (s - x) // 2 a = 0 b = 0 c = 0 for i in range(64): xi = x & 1 << i ai = andd & 1 << i ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER RETURN LIST NUMBER IF VAR VAR RETURN LIST VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP 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 readline = sys.stdin.readline ns = lambda: readline().rstrip() ni = lambda: int(readline().rstrip()) nm = lambda: map(int, readline().split()) nl = lambda: list(map(int, readline().split())) def solve(): u, v = nm() if u == v: if u == 0: print(0) else: print...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR IF VAR VAR IF VAR NUMBER EXPR FUNC_CALL 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 input = sys.stdin.readline u, v = map(int, input().split()) if u == v == 0: print(0) elif u == v: print(1) print(u) elif v > u and (v - u) % 2 == 0: a = (v - u) // 2 if u & a: print(3) print(a, a, u) else: print(2) x = a | u print(x, a) else: ...
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR 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 ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP 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:...
import sys def fun(u, v): x = [0] * 64 z = (v - u) // 2 a = list(bin(u)[2:]) aa = len(a) for i in range(aa): if a[aa - i - 1] == "1": x[i] += 1 a = list(bin(z)[2:]) aa = len(a) for i in range(aa): if a[aa - i - 1] == "1": x[i] += 2 xxx = max(...
IMPORT FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR BIN_OP BIN_OP VAR VAR NUMBER STRING VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN 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:...
x, s = map(int, input().split()) t = (s - x) // 2 a = 0 b = 0 f = 0 if x > int(s) or int(x) % 2 != int(s) % 2: print(-1) elif int(x) == 0 and int(s) == 0: print(0) elif x == s: print(1) print(x) else: for i in range(64): y = x & 1 << i z = t & 1 << i if y == 0 and z == 0: ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER E...
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 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 =...
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:...
def compute(y, x): A = (y - 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:...
def main(): x, y = list(map(int, input().split())) if x > y: print(-1) elif x == 0 and y == 0: print(0) elif x == y: print(1) print(x) elif ( y // 2 - x // 2 ^ y // 2 + (x + 1) // 2 == x and y // 2 - x // 2 + (y // 2 + (x + 1) // 2) == y ): ...
FUNC_DEF 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 IF BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER BIN_OP BIN_OP ...
Chef has 3 hidden numbers A, B, and C such that 0 ≤ A, B, C ≤ N. Let f be a function such that f(i) = (A \oplus i) + (B \oplus i) + (C \oplus i). Here \oplus denotes the [bitwise XOR] operation. Given the values of f(0), f(1), \dots, f(N), determine the values of A, B, and C. It is guaranteed that at least one tuple...
def powerof2(n): res = 0 for i in range(n, 0, -1): if i & i - 1 == 0: res = i return res t = int(input()) for j in range(t): n = int(input()) arr = [int(x) for x in input().split()] ans = [0] * 3 i = powerof2(n) while i > 0: diff = arr[i] - arr[0] ...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER IF BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMB...
Chef has 3 hidden numbers A, B, and C such that 0 ≤ A, B, C ≤ N. Let f be a function such that f(i) = (A \oplus i) + (B \oplus i) + (C \oplus i). Here \oplus denotes the [bitwise XOR] operation. Given the values of f(0), f(1), \dots, f(N), determine the values of A, B, and C. It is guaranteed that at least one tuple...
for _ in range(int(input())): n = int(input()) ll = list(map(int, input().split())) x = ll[0] mm = min(ll) c = ll.index(mm) ok = False if x == 0: print(0, 0, 0) ok = True for a in range(x + 1): if ok: break b = x - c - a for i in range(...
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 VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR N...
Chef has 3 hidden numbers A, B, and C such that 0 ≤ A, B, C ≤ N. Let f be a function such that f(i) = (A \oplus i) + (B \oplus i) + (C \oplus i). Here \oplus denotes the [bitwise XOR] operation. Given the values of f(0), f(1), \dots, f(N), determine the values of A, B, and C. It is guaranteed that at least one tuple...
t = int(input()) for tt in range(t): n = int(input()) arr = list(map(int, input().split())) a = int(0) b = int(0) c = int(0) pp = 0 for pp in range(2000): pp = pp + 1 for i in range(20): if 2**i > n: break delta = int(arr[2**i] - arr[0]) delta ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN...
Chef has 3 hidden numbers A, B, and C such that 0 ≤ A, B, C ≤ N. Let f be a function such that f(i) = (A \oplus i) + (B \oplus i) + (C \oplus i). Here \oplus denotes the [bitwise XOR] operation. Given the values of f(0), f(1), \dots, f(N), determine the values of A, B, and C. It is guaranteed that at least one tuple...
def power2(n): res = 0 for i in range(n, 0, -1): if i & i - 1 == 0: res = i break return res t = int(input()) for i in range(t): n = int(input()) l = list(map(int, input().split())) arr = [0, 0, 0] x = power2(n) while x > 0: dif = l[x] - l[0] ...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER IF BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST N...
Chef has 3 hidden numbers A, B, and C such that 0 ≤ A, B, C ≤ N. Let f be a function such that f(i) = (A \oplus i) + (B \oplus i) + (C \oplus i). Here \oplus denotes the [bitwise XOR] operation. Given the values of f(0), f(1), \dots, f(N), determine the values of A, B, and C. It is guaranteed that at least one tuple...
def find_p(p): for i in range(p, 0, -1): if i & i - 1 == 0: return i for _ in range(int(input())): n = int(input()) li = [int(i) for i in input().split()] i = find_p(n) res = [0] * 3 while i > 0: d = li[i] - li[0] if d < 0: d *= -1 c ...
FUNC_DEF FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER IF BIN_OP VAR BIN_OP VAR NUMBER NUMBER RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER WHILE VAR...
Chef has 3 hidden numbers A, B, and C such that 0 ≤ A, B, C ≤ N. Let f be a function such that f(i) = (A \oplus i) + (B \oplus i) + (C \oplus i). Here \oplus denotes the [bitwise XOR] operation. Given the values of f(0), f(1), \dots, f(N), determine the values of A, B, and C. It is guaranteed that at least one tuple...
def isPowerofTwo(number): while number != 1: if number % 2: return False number /= 2 return True def hpot(n): res = 0 for i in range(n, 0, -1): if isPowerofTwo(i): res = i break return res T = int(input()) for i in range(T): N = int...
FUNC_DEF WHILE VAR NUMBER IF BIN_OP VAR NUMBER RETURN NUMBER VAR NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER IF FUNC_CALL VAR VAR ASSIGN VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_...
Chef has 3 hidden numbers A, B, and C such that 0 ≤ A, B, C ≤ N. Let f be a function such that f(i) = (A \oplus i) + (B \oplus i) + (C \oplus i). Here \oplus denotes the [bitwise XOR] operation. Given the values of f(0), f(1), \dots, f(N), determine the values of A, B, and C. It is guaranteed that at least one tuple...
def check(x, y, z, b): for i in range(len(b)): if (x ^ i) + (y ^ i) + (z ^ i) != b[i]: return False return True for x in range(int(input())): a = int(input()) b = list(map(int, input().split())) if 0 in b: c = b.index(0) print(c, c, c) else: c = b.in...
FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR VAR VAR RETURN NUMBER RETURN NUMBER 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 IF NUMBER VAR ASS...
Chef has 3 hidden numbers A, B, and C such that 0 ≤ A, B, C ≤ N. Let f be a function such that f(i) = (A \oplus i) + (B \oplus i) + (C \oplus i). Here \oplus denotes the [bitwise XOR] operation. Given the values of f(0), f(1), \dots, f(N), determine the values of A, B, and C. It is guaranteed that at least one tuple...
def isPowerofTwo(number): while number != 1: if number % 2: return False number /= 2 return True def hpot(n): res = 0 for i in range(n, 0, -1): if isPowerofTwo(i): res = i break return res T = int(input()) for i in range(T): N = int...
FUNC_DEF WHILE VAR NUMBER IF BIN_OP VAR NUMBER RETURN NUMBER VAR NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER IF FUNC_CALL VAR VAR ASSIGN VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_...
Chef has 3 hidden numbers A, B, and C such that 0 ≤ A, B, C ≤ N. Let f be a function such that f(i) = (A \oplus i) + (B \oplus i) + (C \oplus i). Here \oplus denotes the [bitwise XOR] operation. Given the values of f(0), f(1), \dots, f(N), determine the values of A, B, and C. It is guaranteed that at least one tuple...
for t in range(int(input())): n = int(input()) f = list(map(int, input().split())) m = bin(n) po = len(m) - 2 a = "0b" b = "0b" c = "0b" s = f[0] q = 2 ** (po - 1) saved = [False, False] for i in range(po): r = f[q] - s if r == 3 * q: a += "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 ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_O...
Chef has 3 hidden numbers A, B, and C such that 0 ≤ A, B, C ≤ N. Let f be a function such that f(i) = (A \oplus i) + (B \oplus i) + (C \oplus i). Here \oplus denotes the [bitwise XOR] operation. Given the values of f(0), f(1), \dots, f(N), determine the values of A, B, and C. It is guaranteed that at least one tuple...
T = int(input()) def find(v, o, j): if v == o: return -1 elif v > o: if v - o == 2**j: return 1 else: return 0 elif o - v == 2**j: return 2 else: return 3 def bits(N): i = 0 while N >= 2**i: i += 1 return i def alg...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF IF VAR VAR RETURN NUMBER IF VAR VAR IF BIN_OP VAR VAR BIN_OP NUMBER VAR RETURN NUMBER RETURN NUMBER IF BIN_OP VAR VAR BIN_OP NUMBER VAR RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR NUMBER WHILE VAR BIN_OP NUMBER VAR VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL V...
Chef has 3 hidden numbers A, B, and C such that 0 ≤ A, B, C ≤ N. Let f be a function such that f(i) = (A \oplus i) + (B \oplus i) + (C \oplus i). Here \oplus denotes the [bitwise XOR] operation. Given the values of f(0), f(1), \dots, f(N), determine the values of A, B, and C. It is guaranteed that at least one tuple...
for t in range(int(input())): n = int(input()) arr = list(map(int, input().split())) i = 1 while i <= n: if i << 1 > n: break else: i = i << 1 ans = [0, 0, 0] while i > 0: k = arr[i] - arr[0] if k < 0: k *= -1 z = k ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR VA...
Chef has 3 hidden numbers A, B, and C such that 0 ≤ A, B, C ≤ N. Let f be a function such that f(i) = (A \oplus i) + (B \oplus i) + (C \oplus i). Here \oplus denotes the [bitwise XOR] operation. Given the values of f(0), f(1), \dots, f(N), determine the values of A, B, and C. It is guaranteed that at least one tuple...
def maxPowOf2(n): while n: if n & n - 1 == 0: return n n -= 1 return 1 t = int(input()) while t: t -= 1 n = int(input()) x = list(map(int, input().split())) s = x[0] idx = maxPowOf2(n) ans = [0, 0, 0] while idx > 0: ans.sort() if s > x[id...
FUNC_DEF WHILE VAR IF BIN_OP VAR BIN_OP VAR NUMBER NUMBER RETURN VAR VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VA...
Chef has 3 hidden numbers A, B, and C such that 0 ≤ A, B, C ≤ N. Let f be a function such that f(i) = (A \oplus i) + (B \oplus i) + (C \oplus i). Here \oplus denotes the [bitwise XOR] operation. Given the values of f(0), f(1), \dots, f(N), determine the values of A, B, and C. It is guaranteed that at least one tuple...
for t in range(int(input())): n = int(input()) arr = list(map(int, input().split())) a, b, c = [], [], [] isA, isB, isC = False, False, False nbin = bin(n)[2:] d = len(nbin) i = 0 curr = 2 ** (d - 1) while i < d: diff = (arr[curr] - arr[0]) // curr if diff == 3: ...
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 VAR VAR LIST LIST LIST ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN ...
Chef has 3 hidden numbers A, B, and C such that 0 ≤ A, B, C ≤ N. Let f be a function such that f(i) = (A \oplus i) + (B \oplus i) + (C \oplus i). Here \oplus denotes the [bitwise XOR] operation. Given the values of f(0), f(1), \dots, f(N), determine the values of A, B, and C. It is guaranteed that at least one tuple...
t = int(input()) while t: n = int(input()) array = list(map(int, input().split())) for j in range(n, 0, -1): if j & j - 1 == 0: i = j break res = [0, 0, 0] while i > 0: temp = 0 m = array[i] - array[0] if m < 0: m *= -1 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER IF BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER WHILE VAR NUMBER ASSIGN VAR NUMBER...
Chef has 3 hidden numbers A, B, and C such that 0 ≤ A, B, C ≤ N. Let f be a function such that f(i) = (A \oplus i) + (B \oplus i) + (C \oplus i). Here \oplus denotes the [bitwise XOR] operation. Given the values of f(0), f(1), \dots, f(N), determine the values of A, B, and C. It is guaranteed that at least one tuple...
for _ in range(int(input())): n = int(input()) l = list(map(int, input().split())) for i in range(n, 0, -1): if i & i - 1 == 0: res = i break val = [0] * 3 i = res while i > 0: dif = l[i] - l[0] if dif < 0: dif = dif * -1 c ...
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 FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER IF BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR VAR WHILE VAR NUMBER A...
Chef has 3 hidden numbers A, B, and C such that 0 ≤ A, B, C ≤ N. Let f be a function such that f(i) = (A \oplus i) + (B \oplus i) + (C \oplus i). Here \oplus denotes the [bitwise XOR] operation. Given the values of f(0), f(1), \dots, f(N), determine the values of A, B, and C. It is guaranteed that at least one tuple...
def deep_dive(a, b, c, bundles, base, level): if level == len(bundles): if a <= n and b <= n and c <= n: return [a, b, c] return False bundle = bundles[level] is_success = deep_dive( a + bundle[0] * base, b + bundle[1] * base, c + bundle[2] * base, ...
FUNC_DEF IF VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR VAR RETURN LIST VAR VAR VAR RETURN NUMBER ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER IF VAR RETURN VAR ASSIGN VAR FUNC_CALL...
Chef has 3 hidden numbers A, B, and C such that 0 ≤ A, B, C ≤ N. Let f be a function such that f(i) = (A \oplus i) + (B \oplus i) + (C \oplus i). Here \oplus denotes the [bitwise XOR] operation. Given the values of f(0), f(1), \dots, f(N), determine the values of A, B, and C. It is guaranteed that at least one tuple...
t = int(input()) for _ in range(t): n = int(input()) a = list(map(int, input().split())) li2 = [0, 0, 0] temp1 = 0 for i in range(n, 0, -1): if i & i - 1 == 0: temp1 = i break j = temp1 while j > 0: x = a[j] - a[0] if x < 0: x = x *...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER IF BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR ...
Chef has 3 hidden numbers A, B, and C such that 0 ≤ A, B, C ≤ N. Let f be a function such that f(i) = (A \oplus i) + (B \oplus i) + (C \oplus i). Here \oplus denotes the [bitwise XOR] operation. Given the values of f(0), f(1), \dots, f(N), determine the values of A, B, and C. It is guaranteed that at least one tuple...
for test in range(int(input())): n = int(input()) lst = list(map(int, input().split())) if lst[0] == 0: print("0 0 0") else: a = lst.index(min(lst)) lst = [(lst[i] - (a ^ i)) for i in range(n + 1)] rev = lst[::-1] b = n - rev.index(min(rev)) lst = [(lst[i]...
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 IF VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR BIN_OP VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMB...
Chef has 3 hidden numbers A, B, and C such that 0 ≤ A, B, C ≤ N. Let f be a function such that f(i) = (A \oplus i) + (B \oplus i) + (C \oplus i). Here \oplus denotes the [bitwise XOR] operation. Given the values of f(0), f(1), \dots, f(N), determine the values of A, B, and C. It is guaranteed that at least one tuple...
def indexes(ar, n): ind = n min = ar[n] for i in range(n, -1, -1): if min > ar[i]: ind = i min = ar[i] return ind def valid(ar, a, i, n): b_p = i ^ a c_p = ar[a] - i ^ a if max(b_p, c_p) > n: return False check = 0 if (a ^ b_p) + (c_p ^ b_p) ...
FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER IF VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR IF FUNC_CALL VAR VAR VAR VAR RETURN NUMBER ASSIGN VAR NUMBER IF BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ...
Chef has 3 hidden numbers A, B, and C such that 0 ≤ A, B, C ≤ N. Let f be a function such that f(i) = (A \oplus i) + (B \oplus i) + (C \oplus i). Here \oplus denotes the [bitwise XOR] operation. Given the values of f(0), f(1), \dots, f(N), determine the values of A, B, and C. It is guaranteed that at least one tuple...
from sys import stdin a = int(stdin.readline()) for t in range(0, a): b = int(stdin.readline()) c = stdin.readline().split() d = [int(x) for x in c] start = d[0] f = dict() counter = 0 solution = 0 while 2**counter < len(d): f[counter] = 0 if d[2**counter] - start == 2**...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR V...
Chef has 3 hidden numbers A, B, and C such that 0 ≤ A, B, C ≤ N. Let f be a function such that f(i) = (A \oplus i) + (B \oplus i) + (C \oplus i). Here \oplus denotes the [bitwise XOR] operation. Given the values of f(0), f(1), \dots, f(N), determine the values of A, B, and C. It is guaranteed that at least one tuple...
for _ in range(int(input())): n = int(input()) arr = list(map(int, input().split())) L = [0, 0, 0] for i in range(20, -1, -1): if 2**i > n: continue L = list(sorted(L)) delta = (3 - (arr[2**i] - arr[0]) // 2**i) // 2 for j in range(delta): L[j] += ...
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 LIST NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF BIN_OP NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_O...
Chef has 3 hidden numbers A, B, and C such that 0 ≤ A, B, C ≤ N. Let f be a function such that f(i) = (A \oplus i) + (B \oplus i) + (C \oplus i). Here \oplus denotes the [bitwise XOR] operation. Given the values of f(0), f(1), \dots, f(N), determine the values of A, B, and C. It is guaranteed that at least one tuple...
def pow(i): return i & i - 1 == 0 for _ in range(int(input())): n = int(input()) f = list(map(int, input().split())) a, b, c = 0, 0, 0 numXbits = [ ((f[0] - f[i] + 3 * i) // (2 * i) if i != 0 and pow(i) else 0) for i in range(n + 1) ] for i in range(n, -1, -1): if n...
FUNC_DEF RETURN BIN_OP VAR BIN_OP VAR NUMBER NUMBER 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 VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR NUMBER FUNC_CALL VAR VAR BIN_OP BIN_OP BIN_OP VAR NUMBER ...
Chef has 3 hidden numbers A, B, and C such that 0 ≤ A, B, C ≤ N. Let f be a function such that f(i) = (A \oplus i) + (B \oplus i) + (C \oplus i). Here \oplus denotes the [bitwise XOR] operation. Given the values of f(0), f(1), \dots, f(N), determine the values of A, B, and C. It is guaranteed that at least one tuple...
for _ in range(int(input())): N = int(input()) input_list = list(map(int, input().split())) next_idx = 1 bits_count = {} for idx, val in enumerate(input_list): if idx == next_idx: diff = int((input_list[idx] - input_list[0]) / idx) if diff == -3: bits_...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR DICT FOR VAR VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR NUMBER VAR IF VAR NUMBER ASSIGN VAR VA...
Chef has 3 hidden numbers A, B, and C such that 0 ≤ A, B, C ≤ N. Let f be a function such that f(i) = (A \oplus i) + (B \oplus i) + (C \oplus i). Here \oplus denotes the [bitwise XOR] operation. Given the values of f(0), f(1), \dots, f(N), determine the values of A, B, and C. It is guaranteed that at least one tuple...
t = int(input()) for _ in range(t): n = int(input()) a = list(map(int, input().split())) l = [0, 0, 0] v = 1 dc = {} while v <= n: d = (a[v] - a[0]) // v d = (3 - d) // 2 dc[v] = d v = v << 1 for k in sorted(dc.keys())[::-1]: d = dc[k] for i in...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR DICT WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR NUMBER VAR ASSIGN VAR BIN_O...
Chef has 3 hidden numbers A, B, and C such that 0 ≤ A, B, C ≤ N. Let f be a function such that f(i) = (A \oplus i) + (B \oplus i) + (C \oplus i). Here \oplus denotes the [bitwise XOR] operation. Given the values of f(0), f(1), \dots, f(N), determine the values of A, B, and C. It is guaranteed that at least one tuple...
import sys input = sys.stdin.readline for _ in range(int(input())): n = int(input()) f = list(map(int, input().split())) ans = [0, 0, 0] ones = [] i = 1 while i <= n: ones.append((3 - (f[i] - f[0]) // i) // 2) i *= 2 while len(ones) > 0: for i in range(3): ...
IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER BIN_OP BIN_OP VAR...
Chef has 3 hidden numbers A, B, and C such that 0 ≤ A, B, C ≤ N. Let f be a function such that f(i) = (A \oplus i) + (B \oplus i) + (C \oplus i). Here \oplus denotes the [bitwise XOR] operation. Given the values of f(0), f(1), \dots, f(N), determine the values of A, B, and C. It is guaranteed that at least one tuple...
t = int(input()) for _ in range(t): n = int(input()) f = list(map(int, input().split())) abc = [0, 0, 0] j = 0 for i in range(n, 0, -1): if i & i - 1 == 0: j = i break while j > 0: diff = f[j] - f[0] if diff < 0: diff *= -1 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER IF BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR ...
You are given three integers a, b, k. Find two binary integers x and y (x ≥ y) such that 1. both x and y consist of a zeroes and b ones; 2. x - y (also written in binary form) has exactly k ones. You are not allowed to use leading zeros for x and y. Input The only line contains three integers a, b, and k (...
def getints(): return map(int, input().split()) z, o, k = getints() if k == 0: print("Yes") s = "1" * o + "0" * z print(s) print(s) elif o == 1 or z == 0: print("No") elif k <= z + o - 2: print("Yes") if k >= o: mx = z + o - 2 print( "1" + "0" * (mx - k) + "...
FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR BIN_OP BIN_OP VAR VAR NUMBER EX...
You are given three integers a, b, k. Find two binary integers x and y (x ≥ y) such that 1. both x and y consist of a zeroes and b ones; 2. x - y (also written in binary form) has exactly k ones. You are not allowed to use leading zeros for x and y. Input The only line contains three integers a, b, and k (...
from sys import stdin, stdout t = 1 for _ in range(t): a, b, k = map(int, input().split()) if a == 0 and k == 0: print("YES") val = ["1" for i in range(b)] s = "".join(val) print(s) print(s) continue if a == 0: print("NO") continue if k > ...
ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR STRING VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL STRING VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR...
You are given three integers a, b, k. Find two binary integers x and y (x ≥ y) such that 1. both x and y consist of a zeroes and b ones; 2. x - y (also written in binary form) has exactly k ones. You are not allowed to use leading zeros for x and y. Input The only line contains three integers a, b, and k (...
def main(): inp = input().rstrip().split(" ") a, b, k = int(inp[0]), int(inp[1]), int(inp[2]) x = [] y = [] if b == 1 or a == 0: if k == 0: print("Yes") for _ in range(b): x.append("1") y.append("1") for _ in range(a): ...
FUNC_DEF ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST IF VAR NUMBER VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL V...
You are given three integers a, b, k. Find two binary integers x and y (x ≥ y) such that 1. both x and y consist of a zeroes and b ones; 2. x - y (also written in binary form) has exactly k ones. You are not allowed to use leading zeros for x and y. Input The only line contains three integers a, b, and k (...
def arrIn(): return list(map(int, input().split())) def mapIn(): return map(int, input().split()) a, b, k = mapIn() if b == 0: if k > 0: print("NO") else: print("YES") s = "0" * a + "1" * b print(s) print(s) elif b == 1: if k == 0: print("YES") ...
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR VAR ...
You are given three integers a, b, k. Find two binary integers x and y (x ≥ y) such that 1. both x and y consist of a zeroes and b ones; 2. x - y (also written in binary form) has exactly k ones. You are not allowed to use leading zeros for x and y. Input The only line contains three integers a, b, and k (...
def solve(): global x, y if b == 1 or a == 0 or k == 0: if k > 0: return print("No") print("Yes") x = "1" * b + "0" * a print(x + "\n" + x) return if k >= a + b - 1: return print("No") c = min(k - 1, a - 1) d = max(0, k - 1 - c) x = "1"...
FUNC_DEF IF VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER RETURN FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR STRING VAR RETURN IF VAR BIN_OP BIN_OP VAR VAR NUMBER RETURN FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR BIN_OP VA...
You are given three integers a, b, k. Find two binary integers x and y (x ≥ y) such that 1. both x and y consist of a zeroes and b ones; 2. x - y (also written in binary form) has exactly k ones. You are not allowed to use leading zeros for x and y. Input The only line contains three integers a, b, and k (...
from sys import stdin, stdout input = stdin.readline def main(inp): a, b, k = inp if b == 1: if k != 0: print("No") else: print("Yes") print("1" * b + "0" * a) print("1" * b + "0" * a) return if a == 0: if k != 0: ...
ASSIGN VAR VAR FUNC_DEF ASSIGN VAR VAR VAR VAR IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR RETURN IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUN...
You are given three integers a, b, k. Find two binary integers x and y (x ≥ y) such that 1. both x and y consist of a zeroes and b ones; 2. x - y (also written in binary form) has exactly k ones. You are not allowed to use leading zeros for x and y. Input The only line contains three integers a, b, and k (...
from sys import gettrace, stdin if gettrace(): def inputi(): return input() else: def input(): return next(stdin)[:-1] def inputi(): return stdin.buffer.readline() def main(): a, b, k = map(int, input().split()) if k == 0: print("Yes") print("1" * b + "...
IF FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR BIN_OP BIN_...
You are given three integers a, b, k. Find two binary integers x and y (x ≥ y) such that 1. both x and y consist of a zeroes and b ones; 2. x - y (also written in binary form) has exactly k ones. You are not allowed to use leading zeros for x and y. Input The only line contains three integers a, b, and k (...
x = input().split() a = int(x[0]) b = int(x[1]) k = int(x[2]) if k == 0: print("Yes") print("1" * b + "0" * a) print("1" * b + "0" * a) elif k < b and a > 0: print("Yes") print("1" * b + "0" * a) print("1" * (b - k) + "0" + "1" * k + "0" * (a - 1)) elif k < a + b and b > 1 and a > k - b + 1 and ...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR IF VAR VAR VA...
You are given three integers a, b, k. Find two binary integers x and y (x ≥ y) such that 1. both x and y consist of a zeroes and b ones; 2. x - y (also written in binary form) has exactly k ones. You are not allowed to use leading zeros for x and y. Input The only line contains three integers a, b, and k (...
def solution(): a, b, k = map(int, input().split()) if k > max(a + b - 2, 0) or b == 1 and k != 0 or a == 0 and k != 0: print("No") elif k <= a: print( "Yes", b * "1" + a * "0", (b - 1) * "1" + k * "0" + "1" + (a - k) * "0", sep="\n", )...
FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR VAR EXPR FUNC_CALL VAR STRING BIN_OP BIN_OP VAR STRING BIN_OP VAR STRING BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMB...
You are given three integers a, b, k. Find two binary integers x and y (x ≥ y) such that 1. both x and y consist of a zeroes and b ones; 2. x - y (also written in binary form) has exactly k ones. You are not allowed to use leading zeros for x and y. Input The only line contains three integers a, b, and k (...
import sys zz = 1 sys.setrecursionlimit(10**5) if zz: input = sys.stdin.readline else: sys.stdin = open("input.txt", "r") sys.stdout = open("all.txt", "w") di = [[-1, 0], [1, 0], [0, 1], [0, -1]] def fori(n): return [fi() for i in range(n)] def inc(d, c, x=1): d[c] = d[c] + x if c in d else x ...
IMPORT ASSIGN VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER IF VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR LIST LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF NU...
You are given three integers a, b, k. Find two binary integers x and y (x ≥ y) such that 1. both x and y consist of a zeroes and b ones; 2. x - y (also written in binary form) has exactly k ones. You are not allowed to use leading zeros for x and y. Input The only line contains three integers a, b, and k (...
a, b, k = map(int, input().split()) n = a + b if k == n: print("no") elif k == 0: print("yes") s = ["1"] * b + ["0"] * a print("".join(s)) print("".join(s)) elif a == 0: print("no") elif k == n - 1: print("no") elif k + 1 <= b: print("yes") res1 = ["1"] + ["1"] * k + ["0"] + ["1"] * ...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR EXPR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP LIST STRING VAR BIN_OP LIST STRING VAR EXPR FUNC_CALL VAR FUNC_CALL STRING VAR EXPR FUNC_CALL VAR FUNC_CALL STRING VAR IF VAR NUMBE...
You are given three integers a, b, k. Find two binary integers x and y (x ≥ y) such that 1. both x and y consist of a zeroes and b ones; 2. x - y (also written in binary form) has exactly k ones. You are not allowed to use leading zeros for x and y. Input The only line contains three integers a, b, and k (...
a, b, k = map(int, input().split()) x = "1" * (b - 1) + "0" * (a - 1) if k == 0: print("YES", "1" * b + "0" * a, "1" * b + "0" * a, sep="\n") elif a + b - 2 >= k and b != 1 and a != 0: print( "YES", x[: a + b - 1 - k] + "1" + x[a + b - 1 - k :] + "0", x[: a + b - 1 - k] + "0" + x[a + b -...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP VAR NUMBER BIN_OP STRING BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR STRING IF BIN_OP BIN_OP VAR VAR NUMBER VAR VAR NUMB...
You are given three integers a, b, k. Find two binary integers x and y (x ≥ y) such that 1. both x and y consist of a zeroes and b ones; 2. x - y (also written in binary form) has exactly k ones. You are not allowed to use leading zeros for x and y. Input The only line contains three integers a, b, and k (...
a, b, k = map(int, input().split()) s1 = "1" s2 = "1" if b == 1: if k == 0: print("Yes") print("1" + "0" * a) print("1" + "0" * a) exit(0) print("No") exit() pos1 = 1 pos2 = 1 + k s1 = list("0" * (a + b)) s2 = list("0" * (a + b)) s1[0] = s2[0] = "1" try: s1[pos1] = "1" ...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR STRING IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP STRING BIN_OP STRING VAR EXPR FUNC_CALL VAR BIN_OP STRING BIN_OP STRING VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL ...
You are given three integers a, b, k. Find two binary integers x and y (x ≥ y) such that 1. both x and y consist of a zeroes and b ones; 2. x - y (also written in binary form) has exactly k ones. You are not allowed to use leading zeros for x and y. Input The only line contains three integers a, b, and k (...
import sys def main(): a, b, k = readIntArr() if k == 0: x = b * "1" + a * "0" print("Yes") print(x) print(x) elif k >= a + b - 1: print("No") elif not (a >= 1 and b >= 2): print("No") else: n = a + b x = [None for _ in range(n)] ...
IMPORT FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR STRING BIN_OP VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR IF VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP ...
You are given three integers a, b, k. Find two binary integers x and y (x ≥ y) such that 1. both x and y consist of a zeroes and b ones; 2. x - y (also written in binary form) has exactly k ones. You are not allowed to use leading zeros for x and y. Input The only line contains three integers a, b, and k (...
a, b, k = list(map(int, input().split())) if a == 0 and k != 0: print("No") elif k == 0: print("Yes") print("1" * b + "0" * a) print("1" * b + "0" * a) elif b == 1 or k > a + b - 2: print("No") else: shift = a + b - 2 - k print("Yes") ans_1 = ["1" for _ in range(b)] + ["0" for _ in range...
ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR IF VAR NUMBER VAR BIN_OP BIN_O...
You are given three integers a, b, k. Find two binary integers x and y (x ≥ y) such that 1. both x and y consist of a zeroes and b ones; 2. x - y (also written in binary form) has exactly k ones. You are not allowed to use leading zeros for x and y. Input The only line contains three integers a, b, and k (...
a, b, k = map(int, input().split()) if k == 0: print("Yes") print("1" * b + "0" * a) print("1" * b + "0" * a) exit(0) if a == 0 or b == 0: print("No") exit(0) a -= 1 b -= 1 if b == 0: print("No") exit(0) s = "1" * b + "0" * a b -= 1 k -= 1 if k > a + b: print("No") exit(0) print(...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR...
You are given three integers a, b, k. Find two binary integers x and y (x ≥ y) such that 1. both x and y consist of a zeroes and b ones; 2. x - y (also written in binary form) has exactly k ones. You are not allowed to use leading zeros for x and y. Input The only line contains three integers a, b, and k (...
a, b, k = map(int, input().split()) if k != 0 and (b == 1 or a == 0) or a < min(k, k - b + 2): print("No") else: print("Yes") print("1" * b + "0" * a) if k <= a: print("1" * (b - 1) + "0" * k + "1" + "0" * (a - k)) else: print("1" * (a + b - k - 1) + "0" + "1" * (k - a) + "0" * (a - ...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER VAR NUMBER VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP BIN_OP ...
You are given three integers a, b, k. Find two binary integers x and y (x ≥ y) such that 1. both x and y consist of a zeroes and b ones; 2. x - y (also written in binary form) has exactly k ones. You are not allowed to use leading zeros for x and y. Input The only line contains three integers a, b, and k (...
a, b, k = map(int, input().split()) if a == 0: if k == 0: print("YES") print("1" * b) print("1" * b) else: print("NO") exit(0) if b == 1: if k == 0: print("YES") print("1" + "0" * a) print("1" + "0" * a) else: print("NO") exit(0) if...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP...
You are given three integers a, b, k. Find two binary integers x and y (x ≥ y) such that 1. both x and y consist of a zeroes and b ones; 2. x - y (also written in binary form) has exactly k ones. You are not allowed to use leading zeros for x and y. Input The only line contains three integers a, b, and k (...
a, b, k = map(int, input().split()) if k == 0: x = [1] for i in range(a + b - 1): if a: x.append(0) a -= 1 else: x.append(1) print("Yes") print("".join(map(str, x))) print("".join(map(str, x))) elif k >= a + b - 1: print("No") elif b == 1 or a ...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR EXPR FUNC_CALL VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VA...
You are given three integers a, b, k. Find two binary integers x and y (x ≥ y) such that 1. both x and y consist of a zeroes and b ones; 2. x - y (also written in binary form) has exactly k ones. You are not allowed to use leading zeros for x and y. Input The only line contains three integers a, b, and k (...
a, b, k = map(int, input().split()) b -= 1 if a == 0: if k == 0: x = "1" * b y = "1" * b else: x = None y = None elif b == 0: if k == 0: x = "0" * a y = "0" * a else: x = None y = None elif k >= a + b: x = None y = None elif k <= b:...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER IF VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR NONE ASSIGN VAR NONE IF VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR NONE ASSIGN VAR NONE IF VAR BIN_O...
You are given three integers a, b, k. Find two binary integers x and y (x ≥ y) such that 1. both x and y consist of a zeroes and b ones; 2. x - y (also written in binary form) has exactly k ones. You are not allowed to use leading zeros for x and y. Input The only line contains three integers a, b, and k (...
import sys input = sys.stdin.readline l = input().split() a = int(l[0]) b = int(l[1]) k = int(l[2]) if k == 0: print("Yes") print("1" * b, end="") print("0" * a) print("1" * b, end="") print("0" * a) quit() if a == 0: if k == 0: print("Yes") print("1" * b) print("1" ...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP STRING VAR STRING EXPR FUNC_CALL VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR BIN_OP STRING V...
You are given three integers a, b, k. Find two binary integers x and y (x ≥ y) such that 1. both x and y consist of a zeroes and b ones; 2. x - y (also written in binary form) has exactly k ones. You are not allowed to use leading zeros for x and y. Input The only line contains three integers a, b, and k (...
import sys __version__ = "2.1" __date__ = "2021-03-10" def solve(a, b, k): x = "1" * b + "0" * a if k <= b and k <= a: y = "1" * (b - 1) + "0" * k + "1" + "0" * (a - k) elif k > b: y = "10" + "1" * (b - 2) + "0" * (k - b + 1) + "1" + "0" * (a + b - k - 2) else: y = ( ...
IMPORT ASSIGN VAR STRING ASSIGN VAR STRING FUNC_DEF ASSIGN VAR BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR IF VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP STRING BIN_OP VAR NUMBER BIN_OP STRING VAR STRING BIN_OP STRING BIN_OP VAR VAR IF VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP STRING BIN_OP STRING BIN_OP...
You are given three integers a, b, k. Find two binary integers x and y (x ≥ y) such that 1. both x and y consist of a zeroes and b ones; 2. x - y (also written in binary form) has exactly k ones. You are not allowed to use leading zeros for x and y. Input The only line contains three integers a, b, and k (...
a, b, c = map(int, input().split()) if c == 0: print("YES") print("1" * b + "0" * a) print("1" * b + "0" * a) elif c > a + b - 2 or b < 2 or a < 1: print("NO") else: print("YES") s1 = "1" s2 = "1" ost = a + b - 2 - c while a > 1 and ost > 0: s1 += "0" s2 += "0" ...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR IF VAR BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_C...
You are given three integers a, b, k. Find two binary integers x and y (x ≥ y) such that 1. both x and y consist of a zeroes and b ones; 2. x - y (also written in binary form) has exactly k ones. You are not allowed to use leading zeros for x and y. Input The only line contains three integers a, b, and k (...
import sys input = sys.stdin.readline a, b, k = map(int, input().split()) if a == 0 or b == 1: if k == 0: print("YES") for i in range(b): print(1, end="") for i in range(a): print(0, end="") print() for i in range(b): print(1, end="") ...
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER STRING FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER STRING EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC...
You are given three integers a, b, k. Find two binary integers x and y (x ≥ y) such that 1. both x and y consist of a zeroes and b ones; 2. x - y (also written in binary form) has exactly k ones. You are not allowed to use leading zeros for x and y. Input The only line contains three integers a, b, and k (...
import sys input = sys.stdin.readline I = lambda: list(map(int, input().split())) for _ in range(1): zero, one, k = I() if k == 0: x = "1" * one + "0" * zero print("Yes") print(x) print(x) break one -= 1 if (one and zero) and k <= zero + one - 1: x = "1" ...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER IF VAR VAR VAR BIN...
You are given three integers a, b, k. Find two binary integers x and y (x ≥ y) such that 1. both x and y consist of a zeroes and b ones; 2. x - y (also written in binary form) has exactly k ones. You are not allowed to use leading zeros for x and y. Input The only line contains three integers a, b, and k (...
a, b, k = map(int, input().split()) def actual(): a1 = a - 1 b1 = b - 1 ab = a + b if a == 0: if k != 0: return else: x = y = "1" * b return x, y elif k <= a: if b > 1: x = "1" * b + "0" * a y = "1" * b1 + "0" * k + "1...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER IF VAR NUMBER RETURN ASSIGN VAR VAR BIN_OP STRING VAR RETURN VAR VAR IF VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR ASSI...
You are given three integers a, b, k. Find two binary integers x and y (x ≥ y) such that 1. both x and y consist of a zeroes and b ones; 2. x - y (also written in binary form) has exactly k ones. You are not allowed to use leading zeros for x and y. Input The only line contains three integers a, b, and k (...
a, b, k = map(int, input().strip().split()) if a == 0 or b == 1: if k == 0: print("Yes") x = "" for i in range(b): x += "1" for i in range(a): x += "0" print(x, x) else: print("No") elif k <= a + b - 2: print("Yes") x = "" for i...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR VAR STRING FOR VAR FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING IF VAR BIN_OP BIN_OP VAR VAR NUMBER EXP...
You are given three integers a, b, k. Find two binary integers x and y (x ≥ y) such that 1. both x and y consist of a zeroes and b ones; 2. x - y (also written in binary form) has exactly k ones. You are not allowed to use leading zeros for x and y. Input The only line contains three integers a, b, and k (...
a, b, k = map(int, input().strip().split()) if k == 0: S = "1" * b + "0" * a print("Yes\n" + S + "\n" + S) elif a == 0 or b == 1: print("No") elif k <= a + b - 2: S = "1" * (b - 1) + "0" * (a - 1) print( f"Yes\n{S[:a + b - k - 1]}1{S[a + b - k - 1:]}0\n{S[:a + b - k - 1]}0{S[a + b - k - 1:]}...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP STRING VAR STRING VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP STRING ...
You are given three integers a, b, k. Find two binary integers x and y (x ≥ y) such that 1. both x and y consist of a zeroes and b ones; 2. x - y (also written in binary form) has exactly k ones. You are not allowed to use leading zeros for x and y. Input The only line contains three integers a, b, and k (...
import sys input = sys.stdin.readline def stupid(a, b, k): if a + b == 1: if k == 0: return "YES", "0" if a == 1 else "1", "0" if a == 1 else "1" return "NO", 0, 0 n = a + b for x in range(2**n - 1, 2 ** (n - 1) - 1, -1): xb = bin(x) if xb.count("0") == a + 1 a...
IMPORT ASSIGN VAR VAR FUNC_DEF IF BIN_OP VAR VAR NUMBER IF VAR NUMBER RETURN STRING VAR NUMBER STRING STRING VAR NUMBER STRING STRING RETURN STRING NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR ...
You are given three integers a, b, k. Find two binary integers x and y (x ≥ y) such that 1. both x and y consist of a zeroes and b ones; 2. x - y (also written in binary form) has exactly k ones. You are not allowed to use leading zeros for x and y. Input The only line contains three integers a, b, and k (...
import sys reader = (s.rstrip() for s in sys.stdin) input = reader.__next__ a, b, k = list(map(int, input().split())) if a == 0: if k == 0: print("Yes") print("1" * b + "0" * a) print("1" * b + "0" * a) else: print("No") elif k > a: if k > a + b: print("No") else...
IMPORT ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR 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 EXPR FUNC_CALL VAR BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR EXPR FUNC_CA...
You are given three integers a, b, k. Find two binary integers x and y (x ≥ y) such that 1. both x and y consist of a zeroes and b ones; 2. x - y (also written in binary form) has exactly k ones. You are not allowed to use leading zeros for x and y. Input The only line contains three integers a, b, and k (...
a, b, k = map(int, input().split()) if b == 1: if k == 0: print("Yes") print("1" + "0" * a) print("1" + "0" * a) else: print("No") elif k <= a: print("Yes") print("1" * b + "0" * a) print("1" * (b - 1) + "0" * k + "1" + "0" * (a - k)) elif a >= 1 and a + b >= k + 2: ...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP STRING BIN_OP STRING VAR EXPR FUNC_CALL VAR BIN_OP STRING BIN_OP STRING VAR EXPR FUNC_CALL VAR STRING IF VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP STRING ...
You are given three integers a, b, k. Find two binary integers x and y (x ≥ y) such that 1. both x and y consist of a zeroes and b ones; 2. x - y (also written in binary form) has exactly k ones. You are not allowed to use leading zeros for x and y. Input The only line contains three integers a, b, and k (...
a, b, k = map(int, input().split(" ")) b -= 1 if k == 0: print("Yes") print("1" * (b + 1) + "0" * a) print("1" * (b + 1) + "0" * a) elif a + b <= k: print("No") elif a == 0 or b == 0: print("No") else: print("Yes") if a + b - k <= a: print("1" * (b + 1) + "0" * a) print("10" ...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP STRING BIN_OP VAR NUMBER BIN_OP STRING VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP STRING BIN_OP VAR NUMBER BIN_OP STRING VAR IF BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR STRING I...
You are given three integers a, b, k. Find two binary integers x and y (x ≥ y) such that 1. both x and y consist of a zeroes and b ones; 2. x - y (also written in binary form) has exactly k ones. You are not allowed to use leading zeros for x and y. Input The only line contains three integers a, b, and k (...
def Solve(a, b, k): if ( a + b - 2 < k and k != 0 or b == 1 and k > 0 or (b == 0 or a == 0) and k > 0 or b == 0 ): print("No") return print("Yes") x = [0] * (a + b) y = [0] * (a + b) m = a + b - 1 if k != 0: x[0]...
FUNC_DEF IF BIN_OP BIN_OP VAR VAR NUMBER VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING RETURN EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR NU...
You are given three integers a, b, k. Find two binary integers x and y (x ≥ y) such that 1. both x and y consist of a zeroes and b ones; 2. x - y (also written in binary form) has exactly k ones. You are not allowed to use leading zeros for x and y. Input The only line contains three integers a, b, and k (...
from sys import stdin, stdout nmbr = lambda: int(stdin.readline()) lst = lambda: list(map(int, stdin.readline().split())) for _ in range(1): z, o, k = lst() if o == 1 and k != 0 or z == 0 and k != 0: print("No") continue if k > z: sel = o + z - k - 1 if sel <= 0: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER IF VAR NUMBER EXP...
You are given three integers a, b, k. Find two binary integers x and y (x ≥ y) such that 1. both x and y consist of a zeroes and b ones; 2. x - y (also written in binary form) has exactly k ones. You are not allowed to use leading zeros for x and y. Input The only line contains three integers a, b, and k (...
a, b, k = input().split() a = int(a) b = int(b) k = int(k) z = a o = b n = a + b s1 = [] s2 = [] for i in range(n): s1.append("0") s2.append("0") s1[0] = "1" s2[0] = "1" b -= 1 if a == 0 and b == 0 and k == 0: print("YES") print("1") print("1") exit(0) if k > n - 2: print("NO") exit(0) i...
ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER STRING...
You are given three integers a, b, k. Find two binary integers x and y (x ≥ y) such that 1. both x and y consist of a zeroes and b ones; 2. x - y (also written in binary form) has exactly k ones. You are not allowed to use leading zeros for x and y. Input The only line contains three integers a, b, and k (...
import itertools def main(): a, b, k = map(int, input().split()) maxi = 2 ** (a + b) - 2**a - 2 mini = 2 ** (a + b - 1) + 2 ** (b - 1) - 1 mini_k_ones = 2**k - 1 if b == 1 or a == 0: if k == 0: print("Yes") print("1" * b + "0" * a) print("1" * b + "0" * ...
IMPORT FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER BIN_OP VAR VAR BIN_OP NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER BIN_OP BIN_OP VAR VAR NUMBER BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER IF VAR NUMBER ...
You are given three integers a, b, k. Find two binary integers x and y (x ≥ y) such that 1. both x and y consist of a zeroes and b ones; 2. x - y (also written in binary form) has exactly k ones. You are not allowed to use leading zeros for x and y. Input The only line contains three integers a, b, and k (...
a, b, k = list(map(int, input().split())) if k == 0: print("Yes") print("1" * b + "0" * a) print("1" * b + "0" * a) elif a + b - 1 <= k: print("No") elif a >= k: if b == 1 and k > 0: print("No") elif a == 0 and k == 0: print("Yes") print("1" * b) print("1" * b) ...
ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR IF BIN_OP BIN_OP VAR VAR NUMBER VAR EXPR FUNC_CALL VAR STRING IF VAR VAR IF VAR N...
You are given three integers a, b, k. Find two binary integers x and y (x ≥ y) such that 1. both x and y consist of a zeroes and b ones; 2. x - y (also written in binary form) has exactly k ones. You are not allowed to use leading zeros for x and y. Input The only line contains three integers a, b, and k (...
a, b, k = map(int, input().split()) if b == 1: if k == 0: print("Yes") print("1" + "0" * a) print("1" + "0" * a) else: print("No") elif a == 0: if k == 0: print("Yes") print("1" * b) print("1" * b) else: print("No") elif k <= a: print("...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP STRING BIN_OP STRING VAR EXPR FUNC_CALL VAR BIN_OP STRING BIN_OP STRING VAR EXPR FUNC_CALL VAR STRING IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_...
You are given three integers a, b, k. Find two binary integers x and y (x ≥ y) such that 1. both x and y consist of a zeroes and b ones; 2. x - y (also written in binary form) has exactly k ones. You are not allowed to use leading zeros for x and y. Input The only line contains three integers a, b, and k (...
z, o, k = map(int, input().split()) if k == 0: print("YES") print("1" * o + "0" * z) print("1" * o + "0" * z) elif z == 0 or o == 0: print("NO") elif z >= 1 and o >= 2 and k < z + o - 1: print("YES") z -= 1 o -= 2 zz = min(k - 1, z) oo = min(k - 1 - zz, o) a = "1" * (o - oo) + "1...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER VAR BIN_OP BIN_OP V...
You are given three integers a, b, k. Find two binary integers x and y (x ≥ y) such that 1. both x and y consist of a zeroes and b ones; 2. x - y (also written in binary form) has exactly k ones. You are not allowed to use leading zeros for x and y. Input The only line contains three integers a, b, and k (...
def answer(v): if (k >= a + b - 1 or b == 1) and k != 0: print("No") return x, y = ["0"] * (a + b), ["0"] * (a + b) stop = -1 if k != 0: x[k], y[0] = "1", "1" v -= 1 stop += 1 for i in range(a + b - 1, stop, -1): if v == 0: break if...
FUNC_DEF IF VAR BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING RETURN ASSIGN VAR VAR BIN_OP LIST STRING BIN_OP VAR VAR BIN_OP LIST STRING BIN_OP VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR VAR NUMBER STRING STRING VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR...
You are given three integers a, b, k. Find two binary integers x and y (x ≥ y) such that 1. both x and y consist of a zeroes and b ones; 2. x - y (also written in binary form) has exactly k ones. You are not allowed to use leading zeros for x and y. Input The only line contains three integers a, b, and k (...
a, b, k = map(int, input().split()) if not k: print("Yes") print("1" * b + "0" * a) print("1" * b + "0" * a) elif a + b <= k + 1 or not a or b == 1: print("No") else: s = "1" * (b - 1) + "0" * (a - 1) i = a + b - k - 1 print("Yes") print(s[:i] + "1" + s[i:] + "0") print(s[:i] + "0" +...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR IF BIN_OP VAR VAR BIN_OP VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP ...
You are given three integers a, b, k. Find two binary integers x and y (x ≥ y) such that 1. both x and y consist of a zeroes and b ones; 2. x - y (also written in binary form) has exactly k ones. You are not allowed to use leading zeros for x and y. Input The only line contains three integers a, b, and k (...
import sys a, b, k = [int(_) for _ in input().split()] if b == 1: if k != 0: print("No") else: print("Yes") print("1" + "0" * a) print("1" + "0" * a) sys.exit() if a == 0: if k != 0: print("No") else: print("Yes") print("1" * b) print(...
IMPORT ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP STRING BIN_OP STRING VAR EXPR FUNC_CALL VAR BIN_OP STRING BIN_OP STRING VAR EXPR FUNC_CALL VAR IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR ...
You are given three integers a, b, k. Find two binary integers x and y (x ≥ y) such that 1. both x and y consist of a zeroes and b ones; 2. x - y (also written in binary form) has exactly k ones. You are not allowed to use leading zeros for x and y. Input The only line contains three integers a, b, and k (...
zeroes, ones, k = map(int, input().split()) s = [0] * (zeroes + ones) t = [0] * (zeroes + ones) n = zeroes + ones exists = False if k == 0: s = [1] * ones + [0] * zeroes t = s.copy() exists = True elif zeroes: s[0] = 1 t[0] = 1 ones -= 1 t[n - 1] = 1 diff = min(k, zeroes) k -= diff ...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP LIST NUMBER VAR BIN_OP LIST NUMBER VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER IF V...
You are given three integers a, b, k. Find two binary integers x and y (x ≥ y) such that 1. both x and y consist of a zeroes and b ones; 2. x - y (also written in binary form) has exactly k ones. You are not allowed to use leading zeros for x and y. Input The only line contains three integers a, b, and k (...
a, b, k = map(int, input().split()) if b == 1 and k != 0: print("NO") elif a == 0 and k != 0: print("NO") elif k == 0: print("YES") print("1" * b + "0" * a) print("1" * b + "0" * a) elif k >= a + b - 1: print("NO") elif k <= a: print("YES") print("1" * (b - 1) + "0" * (a - k) + "1" + "0"...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER 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 EXPR FUNC_CALL VAR BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP STRING VAR BIN_OP STRI...
You are given three integers a, b, k. Find two binary integers x and y (x ≥ y) such that 1. both x and y consist of a zeroes and b ones; 2. x - y (also written in binary form) has exactly k ones. You are not allowed to use leading zeros for x and y. Input The only line contains three integers a, b, and k (...
a, b, k = map(int, input().split()) a, b = b, a k1 = k if b == 0: if k == 0: print("Yes") print("1" * a) print("1" * a) else: print("No") exit(0) if a == 1: if k == 0: print("Yes") print("1" + "0" * b) print("1" + "0" * b) else: print("...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CAL...
You are given three integers a, b, k. Find two binary integers x and y (x ≥ y) such that 1. both x and y consist of a zeroes and b ones; 2. x - y (also written in binary form) has exactly k ones. You are not allowed to use leading zeros for x and y. Input The only line contains three integers a, b, and k (...
import sys sys.setrecursionlimit(10**5) int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.buffer.readline()) def MI(): return map(int, sys.stdin.buffer.readline().split()) def LI(): return list(map(int, sys.stdin.buffer.readline().split())) def LLI(rows_...
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...
You are given three integers a, b, k. Find two binary integers x and y (x ≥ y) such that 1. both x and y consist of a zeroes and b ones; 2. x - y (also written in binary form) has exactly k ones. You are not allowed to use leading zeros for x and y. Input The only line contains three integers a, b, and k (...
def mnm(a, b, k): if k == 0: s = "1" * b + "0" * a return [s, s] if a < 1 or b < 2: return ["0", "0"] if k > a + b - 2: return ["0", "0"] if a < k: s1 = "1" + "1" * (a + b - k - 2) + "1" + "1" * (k - a) + "0" * (a - 1) + "0" s2 = "1" + "1" * (a + b - k - 2...
FUNC_DEF IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR RETURN LIST VAR VAR IF VAR NUMBER VAR NUMBER RETURN LIST STRING STRING IF VAR BIN_OP BIN_OP VAR VAR NUMBER RETURN LIST STRING STRING IF VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP STRING BIN_OP STRING BIN_OP BIN_OP BIN_OP VAR VAR VAR...
You are given three integers a, b, k. Find two binary integers x and y (x ≥ y) such that 1. both x and y consist of a zeroes and b ones; 2. x - y (also written in binary form) has exactly k ones. You are not allowed to use leading zeros for x and y. Input The only line contains three integers a, b, and k (...
def check(a, b, k): if a == 0 or b == 1: if k == 0: return "1" * b + "0" * a, "1" * b + "0" * a return False if k >= a + b - 1: if k == 0: return "1" * b + "0" * a, "1" * b + "0" * a return False x = "1" * b + "0" * a y = "1" * (b - 1) + "0" * min(...
FUNC_DEF IF VAR NUMBER VAR NUMBER IF VAR NUMBER RETURN BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR RETURN NUMBER IF VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR NUMBER RETURN BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR RETURN NUMBER ASSIGN V...