description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
You are given an array A = [A_{1}, A_{2}, \ldots, A_{N}], consisting of N integers. In one move, you can take two adjacent numbers A_{i} and A_{i+1}, delete them, and then insert the number A_{i} \land A_{i+1} at the deleted position. Here, \land denotes [bitwise AND]. Note that after this operation, the length of the ... | ans = ""
for _ in range(int(input())):
n = int(input())
arr = list(map(int, input().split()))
res = (1 << 31) - 1
for i in arr:
res &= i
count = 0
cur = (1 << 31) - 1
for i in range(n):
if cur & arr[i] == res:
count += 1
cur = (1 << 31) - 1
els... | ASSIGN VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FOR VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FOR VAR FUNC_CAL... |
You are given an array A = [A_{1}, A_{2}, \ldots, A_{N}], consisting of N integers. In one move, you can take two adjacent numbers A_{i} and A_{i+1}, delete them, and then insert the number A_{i} \land A_{i+1} at the deleted position. Here, \land denotes [bitwise AND]. Note that after this operation, the length of the ... | for p in range(int(input())):
n = int(input())
l = list(map(int, input().split()))
res = l[0]
for ele in l:
res = res & ele
ans = 0
m = []
i = 0
for ele in l:
if ele == res:
m.append(ele)
elif len(m) == 0:
m.append(ele)
elif m[-1] !... | 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 FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR IF FUN... |
You are given an array A = [A_{1}, A_{2}, \ldots, A_{N}], consisting of N integers. In one move, you can take two adjacent numbers A_{i} and A_{i+1}, delete them, and then insert the number A_{i} \land A_{i+1} at the deleted position. Here, \land denotes [bitwise AND]. Note that after this operation, the length of the ... | t = int(input())
for test in range(t):
n = int(input())
v = list(map(int, input().split()))
ans = 0
r = v[0]
for i in range(0, n):
r &= v[i]
for i in range(0, n - 1):
if v[i] != r:
ans += 1
v[i + 1] &= v[i]
if v[n - 1] != r:
ans += 1
print(... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR VAR VA... |
You are given an array A = [A_{1}, A_{2}, \ldots, A_{N}], consisting of N integers. In one move, you can take two adjacent numbers A_{i} and A_{i+1}, delete them, and then insert the number A_{i} \land A_{i+1} at the deleted position. Here, \land denotes [bitwise AND]. Note that after this operation, the length of the ... | for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
mn = a[0]
for i in range(1, n):
mn &= a[i]
tm = 0
for i in range(n):
if a[i] == mn:
tm += 1
tm = n - tm
ans = 0
for i in range(n):
if a[i] == mn:
continu... | 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 FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR A... |
You are given an array A = [A_{1}, A_{2}, \ldots, A_{N}], consisting of N integers. In one move, you can take two adjacent numbers A_{i} and A_{i+1}, delete them, and then insert the number A_{i} \land A_{i+1} at the deleted position. Here, \land denotes [bitwise AND]. Note that after this operation, the length of the ... | t = int(input())
for _ in range(t):
n = int(input())
a = list(map(int, input().split()))
k = a[0]
for i in a:
k &= i
a.append(k)
tp, ct, r = a[0], 0, 0
for i in a:
ct += 1
tp &= i
if tp == k:
r += ct - 1
ct = 0
tp = 2**30 - ... | 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 VAR NUMBER FOR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER FOR VAR VAR VAR NUMBER VAR VAR IF VAR VA... |
You are given an array A = [A_{1}, A_{2}, \ldots, A_{N}], consisting of N integers. In one move, you can take two adjacent numbers A_{i} and A_{i+1}, delete them, and then insert the number A_{i} \land A_{i+1} at the deleted position. Here, \land denotes [bitwise AND]. Note that after this operation, the length of the ... | def fi():
return int(input())
def li():
return list(map(int, input().split()))
t = fi()
for i in range(t):
n = fi()
a = li()
tand = (1 << 30) - 1
for i in range(len(a)):
tand &= a[i]
groups = 0
cand = (1 << 30) - 1
for i in range(len(a)):
cand &= a[i]
if c... | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIG... |
You are given an array A = [A_{1}, A_{2}, \ldots, A_{N}], consisting of N integers. In one move, you can take two adjacent numbers A_{i} and A_{i+1}, delete them, and then insert the number A_{i} \land A_{i+1} at the deleted position. Here, \land denotes [bitwise AND]. Note that after this operation, the length of the ... | for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
z = a[0]
for i in range(1, n):
z = z & a[i]
r = 0
for i in range(n):
if a[i] == z:
continue
if i == n - 1:
r += 1
continue
a[i + 1] = a[i] & a[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 ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR IF VAR BIN_OP VAR NU... |
You are given an array A = [A_{1}, A_{2}, \ldots, A_{N}], consisting of N integers. In one move, you can take two adjacent numbers A_{i} and A_{i+1}, delete them, and then insert the number A_{i} \land A_{i+1} at the deleted position. Here, \land denotes [bitwise AND]. Note that after this operation, the length of the ... | t = int(input())
for _ in range(t):
n = int(input())
arr = list(map(int, input().split()))
fe = arr[0]
for x in arr[1:]:
fe &= x
ng = 0
ta = arr[0]
for i, x in enumerate(arr):
ta &= x
if ta == fe:
ng += 1
if i + 1 < n:
ta = arr[... | 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 VAR NUMBER FOR VAR VAR NUMBER VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR VAR VAR IF VAR VAR VAR NUMBER ... |
You are given an array A = [A_{1}, A_{2}, \ldots, A_{N}], consisting of N integers. In one move, you can take two adjacent numbers A_{i} and A_{i+1}, delete them, and then insert the number A_{i} \land A_{i+1} at the deleted position. Here, \land denotes [bitwise AND]. Note that after this operation, the length of the ... | for _ in range(int(input())):
n = int(input())
lis = list(map(int, input().split()))
count = 0
z = []
check1 = 2**30 - 1
for i in lis:
check1 &= i
check2 = 2**32 - 1
for i in lis:
check2 &= i
if check2 == check1:
count += 1
check2 = 2**32 -... | 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 LIST ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FOR VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FOR VAR VAR VAR VA... |
You are given an array A = [A_{1}, A_{2}, \ldots, A_{N}], consisting of N integers. In one move, you can take two adjacent numbers A_{i} and A_{i+1}, delete them, and then insert the number A_{i} \land A_{i+1} at the deleted position. Here, \land denotes [bitwise AND]. Note that after this operation, the length of the ... | t = int(input())
for _ in range(t):
n = int(input())
x = list(map(int, input().split(" ")))
c = 0
a = sorted(x)
if len(set(a)) == 1:
print(0)
else:
d = x[0]
for i in range(1, n):
d &= x[i]
for i in range(n):
if x[i] == d:
co... | 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 STRING ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER FOR V... |
You are given an array A = [A_{1}, A_{2}, \ldots, A_{N}], consisting of N integers. In one move, you can take two adjacent numbers A_{i} and A_{i+1}, delete them, and then insert the number A_{i} \land A_{i+1} at the deleted position. Here, \land denotes [bitwise AND]. Note that after this operation, the length of the ... | for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
ele = a[0]
for i in range(1, n):
ele = ele & a[i]
noz = a.count(ele)
calc = 0
i = 0
while i < n - 1:
if a[i] == ele:
i = i + 1
continue
a[i + 1] = a[i] & a[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 ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_... |
You are given an array A = [A_{1}, A_{2}, \ldots, A_{N}], consisting of N integers. In one move, you can take two adjacent numbers A_{i} and A_{i+1}, delete them, and then insert the number A_{i} \land A_{i+1} at the deleted position. Here, \land denotes [bitwise AND]. Note that after this operation, the length of the ... | t = int(input())
while t:
n = int(input())
arr = list(map(int, input().split()))
tot = -1
for i in range(n):
tot &= arr[i]
cur = -1
ans = 0
for i in range(n):
cur &= arr[i]
if cur == tot:
cur = -1
ans += 1
print(n - ans)
t -= 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 ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR IF VAR VAR ASSIGN VAR NUMBER VAR NU... |
You are given an array A = [A_{1}, A_{2}, \ldots, A_{N}], consisting of N integers. In one move, you can take two adjacent numbers A_{i} and A_{i+1}, delete them, and then insert the number A_{i} \land A_{i+1} at the deleted position. Here, \land denotes [bitwise AND]. Note that after this operation, the length of the ... | for _ in range(int(input())):
n = int(input())
lis = list(map(int, input().split()))
least = (1 << 30) - 1
for i in lis:
least &= i
p = lis[0]
i = 1
counti = 0
while i < n:
if p == least:
p = lis[i]
counti += 1
else:
p &= lis[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 ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FOR VAR VAR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR ASSIGN VAR VAR ... |
You are given an array A = [A_{1}, A_{2}, \ldots, A_{N}], consisting of N integers. In one move, you can take two adjacent numbers A_{i} and A_{i+1}, delete them, and then insert the number A_{i} \land A_{i+1} at the deleted position. Here, \land denotes [bitwise AND]. Note that after this operation, the length of the ... | for _ in range(int(input())):
n = int(input())
l = list(map(int, input().split()))
if len(set(l)) == 1:
print(0)
else:
c = 0
a = 0
e = l[0]
for i in range(1, n):
e &= l[i]
for i in range(n):
if l[i] == e:
continue
... | 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 FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR V... |
You are given an array A = [A_{1}, A_{2}, \ldots, A_{N}], consisting of N integers. In one move, you can take two adjacent numbers A_{i} and A_{i+1}, delete them, and then insert the number A_{i} \land A_{i+1} at the deleted position. Here, \land denotes [bitwise AND]. Note that after this operation, the length of the ... | T = int(input())
for ts in range(T):
N = int(input())
A = list(map(int, input().split(" ")))
k = A[0]
for i in range(1, N):
k &= A[i]
ans = 0
local = A[0]
for i in range(1, N):
if local == k:
local = A[i]
else:
local &= A[i]
ans += ... | 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 STRING ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF... |
You are given an array A = [A_{1}, A_{2}, \ldots, A_{N}], consisting of N integers. In one move, you can take two adjacent numbers A_{i} and A_{i+1}, delete them, and then insert the number A_{i} \land A_{i+1} at the deleted position. Here, \land denotes [bitwise AND]. Note that after this operation, the length of the ... | result = []
ones = 2**30 - 1
for _ in range(int(input())):
N = int(input())
A = [int(x) for x in input().split()]
ad = ones
for a in A:
ad &= a
tmp, c = ones, 0
ans = 0
for a in A:
tmp &= a
if tmp == ad:
ans += c
tmp, c = ones, 0
else:
... | ASSIGN VAR LIST ASSIGN VAR BIN_OP BIN_OP NUMBER 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 VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FOR VAR VAR VAR VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR VAR IF VAR VAR VA... |
You are given an array A = [A_{1}, A_{2}, \ldots, A_{N}], consisting of N integers. In one move, you can take two adjacent numbers A_{i} and A_{i+1}, delete them, and then insert the number A_{i} \land A_{i+1} at the deleted position. Here, \land denotes [bitwise AND]. Note that after this operation, the length of the ... | t = int(input())
for i in range(t):
n = int(input())
l = list([int(x) for x in input().split()])
a = (1 << 32) - 1
for i in l:
a = a & i
c = 0
ans = 0
b = (1 << 32) - 1
for i in l:
b = b & i
c += 1
if b == a:
ans += c - 1
c = 0
... | 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 VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP ... |
You are given an array A = [A_{1}, A_{2}, \ldots, A_{N}], consisting of N integers. In one move, you can take two adjacent numbers A_{i} and A_{i+1}, delete them, and then insert the number A_{i} \land A_{i+1} at the deleted position. Here, \land denotes [bitwise AND]. Note that after this operation, the length of the ... | t = int(input())
for _ in range(t):
n = int(input())
a = list(map(int, input().split()))
k = a[0]
for i in a:
k &= i
count = 0
for i in range(n - 1):
if a[i] == k:
continue
a[i + 1] &= a[i]
count += 1
print(count + (a[-1] != k)) | 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 VAR NUMBER FOR VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR ... |
You are given an array A = [A_{1}, A_{2}, \ldots, A_{N}], consisting of N integers. In one move, you can take two adjacent numbers A_{i} and A_{i+1}, delete them, and then insert the number A_{i} \land A_{i+1} at the deleted position. Here, \land denotes [bitwise AND]. Note that after this operation, the length of the ... | for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
bc = [0] * 32
for i in a:
for j in range(32):
if i >> j & 1:
bc[j] += 1
t = 0
for i, j in enumerate(bc):
if j == n:
t |= 1 << i
c = 0
p = a[0]
fo... | 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 BIN_OP LIST NUMBER NUMBER FOR VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL... |
You are given an array A = [A_{1}, A_{2}, \ldots, A_{N}], consisting of N integers. In one move, you can take two adjacent numbers A_{i} and A_{i+1}, delete them, and then insert the number A_{i} \land A_{i+1} at the deleted position. Here, \land denotes [bitwise AND]. Note that after this operation, the length of the ... | t = int(input())
for x in range(t):
n = int(input())
seq = list(map(int, input().split()))
Big = 2**31 - 1
totAnd = Big
for i in seq:
totAnd = totAnd & i
groups = 0
CurrAnd = Big
for i in seq:
CurrAnd = CurrAnd & i
if CurrAnd == totAnd:
groups += 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 BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR VAR FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR VAR ASSIG... |
You are given an array A = [A_{1}, A_{2}, \ldots, A_{N}], consisting of N integers. In one move, you can take two adjacent numbers A_{i} and A_{i+1}, delete them, and then insert the number A_{i} \land A_{i+1} at the deleted position. Here, \land denotes [bitwise AND]. Note that after this operation, the length of the ... | tc = int(input())
def reset():
return (1 << 30) - 1
for t in range(tc):
n = int(input())
a = list(map(int, input().split()))
req = reset()
for i in a:
req &= i
ans = 0
cur = reset()
for i in a:
cur &= i
if cur == req:
cur = reset()
ans ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN BIN_OP BIN_OP NUMBER NUMBER NUMBER 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 FOR VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR VA... |
You are given an array A = [A_{1}, A_{2}, \ldots, A_{N}], consisting of N integers. In one move, you can take two adjacent numbers A_{i} and A_{i+1}, delete them, and then insert the number A_{i} \land A_{i+1} at the deleted position. Here, \land denotes [bitwise AND]. Note that after this operation, the length of the ... | for i in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
x = a[0]
for i in range(1, n):
x = x & a[i]
c = a[0]
cc = 0
for i in range(1, n):
if c == x:
cc += 1
c = a[i]
c = c & a[i]
if c == x:
cc += 1
pri... | 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 FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR... |
You are given an array A = [A_{1}, A_{2}, \ldots, A_{N}], consisting of N integers. In one move, you can take two adjacent numbers A_{i} and A_{i+1}, delete them, and then insert the number A_{i} \land A_{i+1} at the deleted position. Here, \land denotes [bitwise AND]. Note that after this operation, the length of the ... | def solve(n, arr):
x = arr[0]
for i in range(n):
x &= arr[i]
groups = 0
s = arr[0]
for i in range(n):
s &= arr[i]
if s == x:
groups += 1
if i < n - 1:
s = arr[i + 1]
return n - groups
for _ in range(int(input())):
n = int(inpu... | FUNC_DEF ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR IF VAR VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER RETURN BIN_OP VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL ... |
You are given an array A = [A_{1}, A_{2}, \ldots, A_{N}], consisting of N integers. In one move, you can take two adjacent numbers A_{i} and A_{i+1}, delete them, and then insert the number A_{i} \land A_{i+1} at the deleted position. Here, \land denotes [bitwise AND]. Note that after this operation, the length of the ... | T = int(input())
for i in range(T):
N = int(input())
A = list(map(int, input().split()))
s = A[0]
res = 0
S = A[0]
for i in A:
S = S & i
for i in range(1, N):
if s == S:
s = A[i]
res += 1
s = s & A[i]
if s == S:
res += 1
print(N... | 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 VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR ASSIG... |
Eikooc and Sushi play a game.
The game is played on a tree having $n$ nodes numbered $1$ to $n$. Recall that a tree having $n$ nodes is an undirected, connected graph with $n-1$ edges.
They take turns alternately moving a token on the tree. Eikooc makes the first move, placing the token on any node of her choice. Sus... | def solution():
n = int(input())
adj = [[] for _ in range(n)]
for _ in range(n - 1):
u, v = map(lambda x: int(x) - 1, input().strip().split())
adj[u].append(v)
adj[v].append(u)
colors = [-1] * n
stk = [0]
colors[0] = 0
while stk:
u = stk.pop()
for v in... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR ... |
Eikooc and Sushi play a game.
The game is played on a tree having $n$ nodes numbered $1$ to $n$. Recall that a tree having $n$ nodes is an undirected, connected graph with $n-1$ edges.
They take turns alternately moving a token on the tree. Eikooc makes the first move, placing the token on any node of her choice. Sus... | p, r = input, range
for _ in r(int(p())):
n = int(p())
h = [set() for i in r(n)]
if n == 1:
print(1)
continue
for i in r(n - 1):
u, v = map(int, p().split())
h[u - 1].add(v - 1)
h[v - 1].add(u - 1)
c, s, g, i = [len(h[i]) for i in r(n)], [0] * n, [0], 1
wh... | ASSIGN VAR VAR 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 VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_O... |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | MAX = 64
def maxOR(L, R):
if L == R:
return L
ans = 0
for i in range(MAX - 1, -1, -1):
p = 1 << i
lbit = L >> i & 1
rbit = R >> i & 1
if rbit == 1 and lbit == 0:
ans += (p << 1) - 1
break
if rbit == 1:
ans += p
return ... | ASSIGN VAR NUMBER FUNC_DEF IF VAR VAR RETURN VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR NUMBER VAR NUMBER VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF VAR NUMBER VAR VAR RETURN ... |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | def max_bitwise_or(L, R):
v1 = []
v2 = []
v3 = []
z = 0
i = 0
ans = 0
cnt = 1
while L > 0:
v1.append(L % 2)
L = L // 2
while R > 0:
v2.append(R % 2)
R = R // 2
while len(v1) != len(v2):
v1.append(0)
for i in range(len(v2) - 1, -1, -1):
... | FUNC_DEF ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE FUNC_CALL VAR VAR F... |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | try:
t = int(input())
for i in range(t):
n, m = map(int, input().split())
r, s = bin(n), bin(m)
if len(r) != len(s):
k = max(len(r), len(s)) - 2
h = "1" * k
print(int(h, 2))
else:
i = 0
while i < len(r) and r[i] == s[i]:... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP STRING VAR EXPR... |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | for _ in range(int(input())):
l, r = map(int, input().split())
first, second = bin(l)[2:], bin(r)[2:]
if len(first) == len(second):
cur = len(first)
for i in range(len(first)):
if first[i] == second[i]:
cur -= 1
else:
break
prin... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER EXPR FUNC_... |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | def countTotalBits(num):
binary = bin(num)[2:]
return len(binary), str(binary)
def comparision(string_l, string_r):
l = len(string_l)
c = 0
for k in range(l):
if string_l[k] == string_r[k]:
c += 1
else:
break
return c
number_of_test_cases = int(input()... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR NUMBER RETURN FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIG... |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | tests = int(input())
while tests:
tests -= 1
l, r = map(int, input().split())
l, r = bin(l)[2:], bin(r)[2:]
m = max(len(l), len(r))
l = l.zfill(m)
ans = ""
for i, j in zip(l, r):
if i == j:
ans += i
else:
ans += "1"
break
for i in range... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING FOR VAR VAR FUNC_CALL VAR VAR ... |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | for _ in range(int(input())):
l, r = [int(x) for x in input().split()]
c = 1
while l != r:
l = l >> 1
r = r >> 1
c = c << 1
l = l * c
c = c - 1
l = l | c
print(l) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR EXPR FUNC... |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | for _ in range(int(input())):
x, y = map(int, input().split())
mi = str(bin(x)[2:])
ma = str(bin(y)[2:])
mi = "0" * (len(ma) - len(mi)) + mi
for i in range(len(ma)):
if mi[i] != ma[i]:
break
print(eval("0b" + ma[: i + 1] + "1" * (len(ma) - (i + 1)))) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VA... |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | for _ in range(int(input())):
l, r = map(int, input().split())
x = l ^ r
m = 1
while x:
x >>= 1
m <<= 1
print(r | m - 1) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | t = int(input())
for _ in range(t):
l, r = map(int, input().split())
a = str(bin(l).replace("0b", ""))
b = str(bin(r).replace("0b", ""))
k = ""
q = 0
if len(a) == len(b):
for i in range(len(a)):
if a[i] == "1" and b[i] == "1":
k += "1"
elif a[i] ==... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR VAR STRING STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR VAR STRING STRING ASSIGN VAR STRING ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR FUNC_CA... |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | t = int(input())
for _ in range(t):
l, r = map(int, input().split())
L = str(bin(l))[2:]
R = str(bin(r))[2:]
if len(L) == len(R):
res = ["1"] * len(R)
for i in range(len(R)):
if R[i] == L[i]:
res[i] = R[i]
else:
break
res = ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST STRING FUNC_CALL VAR VAR FOR VAR FUN... |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | a = int(input())
for i in range(a):
t, r = map(int, input().split())
s1 = bin(t)
k1 = s1[2:]
s2 = bin(r)
k2 = s2[2:]
final = ""
fin = ""
if len(k1) != len(k2):
print(2 ** len(k2) - 1)
else:
for i in range(len(k1)):
if k1[i] != k2[i]:
for j ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR STRING ASSIGN VAR STRING IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BI... |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | t = int(input())
for x0 in range(t):
l, r = input().split()
l = int(l)
r = int(r)
strs1 = "{0:b}".format(max(l, r))
strs2 = "{0:b}".format(min(l, r))
if len(strs1) != len(strs2):
ans = 2 ** max(len(strs1), len(strs2)) - 1
else:
i = 0
fin = ""
while i < len(str... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP B... |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | for _ in range(int(input())):
a, b = [int(j) for j in input().split()]
s1, s2 = bin(a)[2:], bin(b)[2:]
l1 = s1
l2 = s2
if len(l1) != len(l2):
ans = "1" * len(l2)
else:
ans = ""
for i in range(len(l1)):
if l1[i] == l2[i]:
ans = ans + l1[i]
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP STRING FUNC_CALL VAR VAR ASSIGN VAR STRING FOR VAR FUNC_C... |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | for p in range(int(input())):
l, r = map(int, input().split())
bl = bin(l)[2:]
br = bin(r)[2:]
br = str(br)
bl = str(bl)
bl = "0" * (len(br) - len(bl)) + str(bl)
a = ""
b = ""
for i in range(len(bl)):
if bl[i] == "0" and br[i] == "1" and i < len(bl) - 1:
a += "01"... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CAL... |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | t = int(input())
while t > 0:
t -= 1
l, r = list(map(int, input().split()))
l = bin(l).replace("0b", "")
r = bin(r).replace("0b", "")
if len(l) < len(r):
print(int("1" * len(r), 2))
elif len(l) == len(r):
for i in range(len(l)):
if r[i] == "1" and l[i] == "0":
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR STRING STRING ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR STRING STRING IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_... |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | for _ in range(int(input())):
l, r = map(int, input().split())
i = 0
while l | 1 << i < r:
l = l | 1 << i
i += 1
print(l | r) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE BIN_OP VAR BIN_OP NUMBER VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | for w in range(int(input())):
l, r = [int(n) for n in input().split()]
l = str(bin(l))
r = str(bin(r))
while len(l) != len(r):
l = l[0:2] + "0" + l[2:]
index = 0
if l != r:
while l[index] == r[index]:
index += 1
l = l[: index + 1] + "".join(["1" * (len(l) - in... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR WHILE FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER STRING VAR NUMBER ASSIGN VAR NUMBER IF... |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | for _ in range(int(input())):
l, r = map(int, input().split())
sl = bin(l)[2:]
sr = bin(r)[2:]
nl, nr = len(sl), len(sr)
sl = "0" * (nr - nl) + sl
idx = 0
for i in range(nr):
if sl[i] != sr[i]:
break
idx = i + 1
sl = sl[:idx] + "1" * (nr - idx)
print(int(sl, 2... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR... |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | def ans(a, b):
if a == b:
return a | b
a1 = str(bin(a)[2:])
b1 = str(bin(b)[2:])
if len(a1) > len(b1):
b1 = "0" * (len(a1) - len(b1)) + b1
elif len(b1) > len(a1):
a1 = "0" * (len(b1) - len(a1)) + a1
i = 0
s = 0
while a1[i] == b1[i]:
s += int(a1[i]) * 2 ** ... | FUNC_DEF IF VAR VAR RETURN BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN... |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | t = int(input())
for f in range(t):
L, R = map(int, input().split())
ls = bin(L)
rs = bin(R)
l = ls[2:]
r = rs[2:]
for i in range(len(rs) - len(ls)):
l = "0" + l
s = len(r)
for i in range(s):
if l[i] != r[i]:
r = r[: i + 1]
for j in range(i + 1, s)... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP STRING VAR AS... |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | from sys import stdin
t = int(stdin.readline())
while t:
l, r = [int(x) for x in stdin.readline().split()]
if l == r:
print(r)
else:
bin_l = f"{l:064b}"
bin_r = f"{r:064b}"
i = 0
max_val = ""
while bin_l[i] == bin_r[i]:
max_val += bin_l[i]
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR STRING ASSIGN VAR VAR STRING ASSIGN VAR NUMBER ASSIGN VAR STRING WHILE VAR VAR VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR ... |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | for _ in range(int(input())):
L, R = map(int, input().split())
R1 = R
L, R = bin(L)[2:], bin(R)[2:]
x, y = len(L), len(R)
L = ["0"] * (y - x) + list(L)
R = list(R)
i = 0
while i < y:
if L[i] != R[i]:
break
i += 1
L = L[:i] + ["1"] * (y - i)
L = "".join... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP LIST STRING BIN_OP VAR VAR FUNC_CALL VAR VAR ASSIGN VAR F... |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | for T in range(int(input())):
l, r = map(int, input().split())
lbit_pos = []
rbit_pos = []
for i in range(100, -1, -1):
if l >> i & 1:
lbit_pos.append(i)
if r >> i & 1:
rbit_pos.append(i)
index = min(len(lbit_pos), len(rbit_pos))
flag = True
value = 0
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUN... |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | t = int(input())
for you in range(t):
l = input().split()
L = int(l[0])
R = int(l[1])
if L == R:
print(L)
else:
num = 0
for i in range(63, -1, -1):
if L & 1 << i == 0 and R & 1 << i > 0:
num = num + (2 * (1 << i) - 1)
break
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF BIN_OP VAR BIN_OP NUMBER VAR NUMBER BIN_OP VAR BIN... |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | T = int(input())
ans = []
for _ in range(T):
L, R = [int(i) for i in input().split()]
l = bin(L)[2:]
r = bin(R)[2:]
if len(l) != len(r):
ans.append(int(max(len(l), len(r)) * "1", 2))
else:
i = 0
while i < len(r) and l[i] == r[i]:
i += 1
s = l[:i] + "1" * (... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR... |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | for ii in range(int(input())):
l, r = map(int, input().split())
lb = bin(l)[2:]
rb = bin(r)[2:]
lb = "0" * (len(rb) - len(lb)) + lb
s = ""
flag = 0
for i in range(len(rb)):
if flag or lb[i] != rb[i]:
flag = 1
s += "1"
else:
s += rb[i]
x... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC... |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | def bi(X, l):
return (l - len(bin(X)[2:])) * "0" + bin(X)[2:]
for _ in range(int(input())):
L, R = list(map(int, input().split()))
q = bin(R)[2:]
length = len(q)
p = bi(L, length)
changed = False
ans = ""
for i in range(length):
if p[i] != q[i]:
ans += (length - i) ... | FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER STRING FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL V... |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | for _ in range(int(input())):
x, y = map(int, input().split())
x = list(bin(x)[2:])
y = list(bin(y)[2:])
x = list("0" * (len(y) - len(x))) + x
for i in range(len(y)):
if y[i] == "1" and x[i] == "0":
for j in range(i + 1, len(y)):
y[j] = "1"
break
y... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP STRING BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VA... |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | t = int(input())
for _ in range(t):
L, R = map(int, input().split())
bl = bin(L)[2:]
br = bin(R)[2:]
if len(bl) < len(br):
nl = "1" * len(br)
print(int(nl, 2))
else:
com_end = 0
while com_end < len(bl):
if bl[com_end] != br[com_end]:
break
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP STRING FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ... |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | t = int(input())
while t:
t -= 1
l, r = [int(i) for i in input().split()]
bl = bin(l)[2:]
br = bin(r)[2:]
ans = ""
if l == r:
print(r)
elif len(bl) < len(br):
for i in range(len(br)):
ans += "1"
print(int("0b" + ans, 2))
else:
for i in range(le... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR STRING IF VAR VAR EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR ... |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | def IntegerCreator(x2, start, end):
for i in range(start, end):
if x2[i] == "0":
x2[i] = "1"
return x2
def preComputation():
arr = [1]
for i in range(1, 64):
arr.append(arr[-1] * 2)
return arr
t = int(input())
arr = preComputation()
while t:
t -= 1
l, r = map(... | FUNC_DEF FOR VAR FUNC_CALL VAR VAR VAR IF VAR VAR STRING ASSIGN VAR VAR STRING RETURN VAR FUNC_DEF ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR VAR FUNC_CA... |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | try:
num = int(input())
while num > 0:
l, r = map(int, input().split())
r = bin(r)
l = bin(l)
size = len(r)
count = 0
i = 2
if len(r) != len(l):
r = list(r)
while i < size:
r[i] = "1"
i += 1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR VAR AS... |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | t = int(input())
while t > 0:
n, m = map(int, input().split())
a = bin(n)
a = a[2:]
c = bin(m)
c = c[2:]
minlen = min(len(a), len(c))
if len(a) > len(c):
maxdiff = len(a) - minlen
c = "0" * maxdiff + c
else:
maxdiff = len(c) - minlen
a = "0" * maxdiff + a
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIG... |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | def convert(n, arr):
for i in range(60):
arr[-(i + 1)] = n % 2
n = n // 2
t = int(input())
for i in range(t):
l, r = [int(i) for i in input().split()]
l_bit = [(0) for i in range(60)]
r_bit = [(0) for i in range(60)]
convert(l, l_bit)
convert(r, r_bit)
ans = 0
for i in ... | FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR N... |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | t = int(input())
for _ in range(t):
a, b = input().split()
a = int(a)
b = int(b)
p = bin(a).replace("0b", "")
q = bin(b).replace("0b", "")
if len(p) < len(q):
q = q.replace("0", "1")
print(int(q, 2))
else:
temp = 0
for i in range(1, len(q) + 1):
if... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR STRING STRING ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR STRING STRING IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FU... |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | for _ in range(int(input())):
l, r = map(int, input().split())
bl, br = bin(l)[2:], bin(r)[2:]
l1, l2 = len(bl), len(br)
bl = "0" * (l2 - l1) + bl
for i in range(l2):
if bl[i] != br[i]:
break
bl = bl[: i + 1] + (l2 - (i + 1)) * "1"
print(int(bl, 2) | int(br, 2)) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP VAR VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR A... |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | t = int(input())
for i in range(t):
l, r = map(int, input().split())
binary = bin(r)
binary = binary[2:]
binary = list(binary)
ans = r
for i in range(len(binary)):
if binary[i] == "0":
num = ["1"] * (len(binary) - i)
num = int("".join(num), 2)
if num <... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR BIN_OP LIST STRING BIN_OP FUNC_CAL... |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | for _ in range(int(input())):
l, r = map(int, input().split())
if l == r:
print(l)
continue
bin_l = bin(l)[2:]
bin_r = bin(r)[2:]
if len(bin_l) < len(bin_r):
bin_l = "0" * (len(bin_r) - len(bin_l)) + bin_l
i = 0
while bin_l[i] == bin_r[i]:
i += 1
ans = bin... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP FUNC_CALL VAR VAR FUNC_CALL V... |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | def decimalToBinary(n):
return bin(n).replace("0b", "")
for _ in range(int(input())):
l, r = map(int, input().split())
a, b = decimalToBinary(l), decimalToBinary(r)
if len(a) != len(b):
print(pow(2, max(len(a), len(b))) - 1)
else:
ans = ""
index = 0
for i in range(l... | FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR VAR STRING STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR NUMBER FUNC_CALL VAR FUNC... |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | T = int(input())
for _ in range(T):
N, M = map(int, input().split())
if N == M:
print(N)
continue
a = 0
b = 0
x = N
y = M
s = 0
t = 0
while N > 0:
a = a * 10 + N % 2
N = N // 2
s += 1
while M > 0:
b = b * 10 + M % 2
M = M //... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER BIN_OP VA... |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | for _ in range(int(input())):
l, r = map(int, input().split())
lb, rb = bin(l)[2:], bin(r)[2:]
ll, rl = len(lb), len(rb)
if l == 0 and r == 0:
print(0)
continue
if l == r:
print(l)
continue
ans = ""
if ll == rl:
i = 0
for i in range(ll):
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR S... |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | def decimalToBinary(n):
return bin(n).replace("0b", "")
def binaryToDecimal(n):
return int(n, 2)
t = int(input())
for i in range(t):
a, b = map(int, input().split())
if a == 0 and b == 0:
print(0)
elif a == b:
print(a)
else:
a_bin = decimalToBinary(a)
b_bin = ... | FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR VAR STRING STRING FUNC_DEF RETURN FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUN... |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | t = int(input())
for _ in range(t):
l, r = map(int, input().split())
ans = ""
x = f"{l:64b}"
y = f"{r:64b}"
pos = 64
for i in range(64):
if x[i] != y[i]:
pos = i
break
else:
ans += x[i]
for j in range(pos, 64):
ans += "1"
print(... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR VAR STRING ASSIGN VAR VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR FOR VAR FUNC_CALL VAR VAR NUMBER VAR STRING... |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | t = int(input())
for _ in range(t):
L, R = map(int, input().split())
first = "{0:b}".format(R)
second = "{0:b}".format(L)
first = "0" * (64 - len(first)) + first
second = "0" * (64 - len(second)) + second
i = 0
while i < 64:
if first[i] == "1" and second[i] == "0":
break
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL STRING VAR ASSIGN VAR FUNC_CALL STRING VAR ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP NUMBER FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP NUMBER FUNC_CALL VAR VAR VA... |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | while True:
try:
for _ in range(int(input())):
l, r = map(int, input().split())
l, r = min(l, r), max(l, r)
binL = bin(l)[2:]
binR = bin(r)[2:]
llen = len(binL)
rlen = len(binR)
binL = "0" * (rlen - llen) + binL
... | WHILE NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR ... |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | for _ in range(int(input())):
L, R = map(int, input().split())
maxl = 1
while maxl << 1 <= R:
maxl = maxl << 1
if maxl - 1 >= L:
print(maxl - 1 | R)
else:
while L | L + 1 <= R:
L |= L + 1
print(L | R) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR WHILE BIN_OP VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER EXPR... |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | def binaryToDecimal(n):
return int(n, 2)
def decimalToBinary(n):
return bin(n).replace("0b", "")
t = int(input())
for i in range(t):
l, r = input().split()
l = int(l)
r = int(r)
str1 = decimalToBinary(l)
str2 = decimalToBinary(r)
lendiff = len(str2) - len(str1)
temp = "0" * lendi... | FUNC_DEF RETURN FUNC_CALL VAR VAR NUMBER FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR VAR STRING STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN 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 FUNC_CALL VAR VAR A... |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | def till_what_length(str1, str2):
count = 0
for i in range(len(str1)):
if str1[i] != str2[i]:
break
count += 1
return count
def get_bin(x, l):
return format(x, "b").zfill(l)
test = int(input())
for _ in range(test):
l, r = input().split()
l = int(l)
r = int(r)... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER RETURN VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR VAR STRING VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR... |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | import sys
def different_bit_pos(x, y):
max_len = max(len(x), len(y))
if len(x) == max_len:
new_y = ""
for i in range(max_len - len(y)):
new_y += "0"
new_y += y
y = new_y
elif len(y) == max_len:
new_x = ""
for i in range(max_len - len(x)):
... | IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR VAR VAR STRING VAR VAR ASSIGN VAR VAR IF FUNC_CALL VAR VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR VAR VAR STRING VAR VAR AS... |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | for i in range(int(input())):
l, r = map(int, input().split())
sr = bin(r).replace("0b", "")
sl = bin(l).replace("0b", "")
ans = 0
if len(sr) > len(sl):
for i in range(len(sr)):
ans += 2**i
print(ans)
else:
k = r
t = l
for i in range(len(sr)):
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR STRING STRING ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR STRING STRING ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP... |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | t = int(input())
for i in range(t):
l, r = map(int, input().split())
a, b = bin(l), bin(r)
a, b = a[2:], b[2:]
if len(b) > len(a):
x = len(b) - len(a)
a = "0" * x + a
ans = ""
for i in range(len(a)):
if a[i] == b[i]:
ans += a[i]
elif a[i] == "0" and b[... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER VAR NUMBER IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP... |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | test = int(input())
for _ in range(test):
l, r = map(int, input().split())
xor1 = l ^ r
max1 = 0
while xor1:
max1 = max1 << 1
max1 = max1 | 1
xor1 = xor1 >> 1
max1 = r | max1
print(max(max1, r)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VA... |
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Dr.D got so famous thanks to his first problem that he decided to commemorate it by making yet another problem with an almost identical statement — he only changed one word.
We want to choose exactly two integers (not necess... | def solve(l, r):
r = bin(r)[2:]
l = bin(l)[2:]
l = "0" * (len(r) - len(l)) + l
res, beg = "", True
for u, d in zip(r, l):
if u == d and beg:
res += u
elif beg:
beg = False
res += u
else:
res += "1"
return int(res, 2)
for _... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR STRING NUMBER FOR VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR VAR VAR VAR IF VAR ASSIGN VAR NUMBER VAR VAR VAR STRING RETURN FUNC_CALL VAR VAR NUMBE... |
You have a bag of size $n$. Also you have $m$ boxes. The size of $i$-th box is $a_i$, where each $a_i$ is an integer non-negative power of two.
You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.
For example, if $n = 10$ and $a = [1, 1, 32]$ then you have to divide the box of s... | t = int(input())
for _ in range(t):
n, m = map(int, input().split())
A = list(map(int, input().split()))
if n > sum(A):
ans = -1
else:
power = [0] * 62
for a in A:
c = 0
while a != 1:
a //= 2
c += 1
power[c] += 1... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER VAR ... |
You have a bag of size $n$. Also you have $m$ boxes. The size of $i$-th box is $a_i$, where each $a_i$ is an integer non-negative power of two.
You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.
For example, if $n = 10$ and $a = [1, 1, 32]$ then you have to divide the box of s... | import sys
input = sys.stdin.readline
Q = int(input())
Query = []
for _ in range(Q):
N, M = map(int, input().split())
A = list(map(int, input().split()))
Query.append((N, M, A))
for N, M, A in Query:
delta = sum(A) - N
if delta < 0:
print(-1)
else:
L = max(N, max(A)).bit_length(... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR FOR VAR VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR IF... |
You have a bag of size $n$. Also you have $m$ boxes. The size of $i$-th box is $a_i$, where each $a_i$ is an integer non-negative power of two.
You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.
For example, if $n = 10$ and $a = [1, 1, 32]$ then you have to divide the box of s... | import sys
sz = 1
temp = 1
while temp <= 1e18:
sz += 1
temp <<= 1
def main():
t = int(input())
allans = []
for _ in range(t):
n, m = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
if sum(a) < n:
allans.append(-1)
else:
... | IMPORT ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR VAR VAR EXPR ... |
You have a bag of size $n$. Also you have $m$ boxes. The size of $i$-th box is $a_i$, where each $a_i$ is an integer non-negative power of two.
You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.
For example, if $n = 10$ and $a = [1, 1, 32]$ then you have to divide the box of s... | def solve(n, arr):
if sum(arr) < n:
return -1
m = len(arr)
bits = [0] * 61
for num in arr:
bits[num.bit_length() - 1] += 1
i = 0
l = n.bit_length()
res = 0
while i < l:
if n >> i & 1:
if bits[i]:
bits[i] -= 1
else:
... | FUNC_DEF IF FUNC_CALL VAR VAR VAR RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR VAR BIN_OP FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR VAR NUMBER WHILE VAR VAR NUMBER V... |
You have a bag of size $n$. Also you have $m$ boxes. The size of $i$-th box is $a_i$, where each $a_i$ is an integer non-negative power of two.
You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.
For example, if $n = 10$ and $a = [1, 1, 32]$ then you have to divide the box of s... | import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
n, m = map(int, input().split())
a = list(map(int, input().split()))
sum_a = sum(a)
if sum_a < n:
print(-1)
continue
cnts = [0] * 40
for i in range(m):
bit = a[i].bit_length() - 1
cnts[bit]... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VA... |
You have a bag of size $n$. Also you have $m$ boxes. The size of $i$-th box is $a_i$, where each $a_i$ is an integer non-negative power of two.
You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.
For example, if $n = 10$ and $a = [1, 1, 32]$ then you have to divide the box of s... | def solve(num, arr):
freq = [(0) for i in range(64)]
for i in arr:
x = i
pos = 0
while x > 0:
if x & 1:
freq[pos] += 1
x = x >> 1
pos += 1
if num > sum(arr):
return -1
ans = 0
pos = 0
while num > 0:
if nu... | FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR FUNC_CALL VAR VAR RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER IF VAR VAR NUMBER... |
You have a bag of size $n$. Also you have $m$ boxes. The size of $i$-th box is $a_i$, where each $a_i$ is an integer non-negative power of two.
You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.
For example, if $n = 10$ and $a = [1, 1, 32]$ then you have to divide the box of s... | def log2(n):
i = 0
while n >> i != 1:
i += 1
return i
def solve(n, po2s):
if sum(po2s) < n:
return -1
po_cnt = [0] * 60
for x in po2s:
po_cnt[log2(x)] += 1
ans = 0
for i in range(60):
if n & 1 << i:
if po_cnt[i]:
po_cnt[i] -= ... | FUNC_DEF ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR NUMBER VAR NUMBER RETURN VAR FUNC_DEF IF FUNC_CALL VAR VAR VAR RETURN NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR BIN_OP NUMBER VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR V... |
You have a bag of size $n$. Also you have $m$ boxes. The size of $i$-th box is $a_i$, where each $a_i$ is an integer non-negative power of two.
You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.
For example, if $n = 10$ and $a = [1, 1, 32]$ then you have to divide the box of s... | t = int(input())
for _ in range(0, t):
n, m = map(int, input().split())
aa = [int(i) for i in input().split()]
bits = [0] * 70
for i in aa:
bb = bin(i)[2:][::-1]
for j in range(0, len(bb)):
bits[j] += int(bb[j])
ss = 0
ans = [0] * 70
bb = bin(n)[2:][::-1]
for ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR... |
You have a bag of size $n$. Also you have $m$ boxes. The size of $i$-th box is $a_i$, where each $a_i$ is an integer non-negative power of two.
You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.
For example, if $n = 10$ and $a = [1, 1, 32]$ then you have to divide the box of s... | def problem(n, a):
if sum(a) < n:
return -1
bit = [0] * 61
for i in a:
bit[i.bit_length() - 1] += 1
i, r, l = 0, 0, n.bit_length()
while i < l:
if n >> i & 1:
if bit[i]:
bit[i] -= 1
else:
while bit[i] == 0:
... | FUNC_DEF IF FUNC_CALL VAR VAR VAR RETURN NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR VAR BIN_OP FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR VAR NUMBER NUMBER FUNC_CALL VAR WHILE VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR VAR NUMBER WHILE VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER BIN_OP VAR ... |
You have a bag of size $n$. Also you have $m$ boxes. The size of $i$-th box is $a_i$, where each $a_i$ is an integer non-negative power of two.
You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.
For example, if $n = 10$ and $a = [1, 1, 32]$ then you have to divide the box of s... | t = int(input())
def az(i):
j = i
while j > -1:
if ab[j] != 0:
return j
j -= 1
return j
for _ in range(t):
n, m = map(int, input().split())
a = list(map(int, input().split()))
nb = [(0) for i in range(60)]
ab = [(0) for i in range(60)]
i = 59
while n >... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR WHILE VAR NUMBER IF VAR VAR NUMBER RETURN VAR VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUM... |
You have a bag of size $n$. Also you have $m$ boxes. The size of $i$-th box is $a_i$, where each $a_i$ is an integer non-negative power of two.
You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.
For example, if $n = 10$ and $a = [1, 1, 32]$ then you have to divide the box of s... | for t in range(int(input())):
n, m = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
pows = [0] * 50
for i in a:
pows[i.bit_length() - 1] += 1
p = 1
i = 0
tot = 0
make = 100
while (n > 0 or make < 100) and i < len(pows) - 1:
if n % (2 * p) != 0... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR VAR BIN_OP FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR... |
You have a bag of size $n$. Also you have $m$ boxes. The size of $i$-th box is $a_i$, where each $a_i$ is an integer non-negative power of two.
You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.
For example, if $n = 10$ and $a = [1, 1, 32]$ then you have to divide the box of s... | import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
n, m = map(int, input().split())
a = list(map(int, input().split()))
if sum(a) < n:
print(-1)
continue
c = [0] * 61
for i in range(m):
x = 0
while a[i] % 2 == 0:
a[i] //= 2
... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR... |
You have a bag of size $n$. Also you have $m$ boxes. The size of $i$-th box is $a_i$, where each $a_i$ is an integer non-negative power of two.
You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.
For example, if $n = 10$ and $a = [1, 1, 32]$ then you have to divide the box of s... | import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
n, m = map(int, input().split())
a = [int(item) for item in input().split()]
if sum(a) < n:
print(-1)
continue
comp = dict()
for i in range(65):
comp[2**i] = i
nums = [0] * 65
for item in a:
... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN... |
You have a bag of size $n$. Also you have $m$ boxes. The size of $i$-th box is $a_i$, where each $a_i$ is an integer non-negative power of two.
You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.
For example, if $n = 10$ and $a = [1, 1, 32]$ then you have to divide the box of s... | import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
def solve():
n, m = map(int, input().split())
a = list(map(int, input().split()))
if sum(a) < n:
print(-1)
return
k = 62
count = [0] * k
for ai in a:
count[ai.bit_length() - 1] += 1
ans = 0... | IMPORT ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR VAR VAR BIN_OP... |
You have a bag of size $n$. Also you have $m$ boxes. The size of $i$-th box is $a_i$, where each $a_i$ is an integer non-negative power of two.
You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.
For example, if $n = 10$ and $a = [1, 1, 32]$ then you have to divide the box of s... | import sys
input = sys.stdin.readline
def solve():
n, m = map(int, input().split())
a = list(map(int, input().split()))
cnt = [0] * 64
for i in range(m):
cnt[a[i].bit_length() - 1] += 1
sum = 0
ans = 0
for j in range(64):
bit = 1 << j
sum += cnt[j] * bit
if... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR N... |
You have a bag of size $n$. Also you have $m$ boxes. The size of $i$-th box is $a_i$, where each $a_i$ is an integer non-negative power of two.
You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.
For example, if $n = 10$ and $a = [1, 1, 32]$ then you have to divide the box of s... | t = int(input())
for case in range(t):
n, m = map(int, input().split())
a = list(map(int, input().split()))
if n > sum(a):
print(-1)
continue
last = 0
bn = bin(n)
ba = [(len(bin(i)) - 3) for i in a]
dig_a = [0] * 100
for i in ba:
dig_a[i] += 1
ans = 0
for ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR F... |
You have a bag of size $n$. Also you have $m$ boxes. The size of $i$-th box is $a_i$, where each $a_i$ is an integer non-negative power of two.
You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.
For example, if $n = 10$ and $a = [1, 1, 32]$ then you have to divide the box of s... | t = int(input())
for _ in range(t):
n, m = map(int, input().split(" "))
a = list(map(int, input().strip().split(" ")))
if sum(a) < n:
print("-1")
continue
b = [(0) for _ in range(64)]
for z in a:
for q in range(64):
b[q] += z >> q & 1
tar = [(0) for _ in range... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR VAR F... |
You have a bag of size $n$. Also you have $m$ boxes. The size of $i$-th box is $a_i$, where each $a_i$ is an integer non-negative power of two.
You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.
For example, if $n = 10$ and $a = [1, 1, 32]$ then you have to divide the box of s... | t = int(input())
for ijkl in range(t):
n, m = map(int, input().split())
a = [int(x) for x in input().split()]
f = max(a)
f = max(f, n)
number = 1
power = 2
while power <= f:
power = power * 2
number += 1
have = [(0) for i in range(number)]
for x in a:
copy = x... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ... |
You have a bag of size $n$. Also you have $m$ boxes. The size of $i$-th box is $a_i$, where each $a_i$ is an integer non-negative power of two.
You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.
For example, if $n = 10$ and $a = [1, 1, 32]$ then you have to divide the box of s... | def power(x):
ans = 0
while x != 1:
ans += 1
x >>= 1
return ans
t = int(input())
for _ in range(t):
n, m = map(int, input().split())
a = [int(x) for x in input().split()]
cnt = [0] * 80
for i in range(m):
cnt[power(a[i])] += 1
if sum(a) < n:
print(-1)
... | FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR V... |
You have a bag of size $n$. Also you have $m$ boxes. The size of $i$-th box is $a_i$, where each $a_i$ is an integer non-negative power of two.
You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.
For example, if $n = 10$ and $a = [1, 1, 32]$ then you have to divide the box of s... | import sys
input = sys.stdin.readline
TWO = {(1 << i): i for i in range(64)}
t = int(input())
for tests in range(t):
n, m = map(int, input().split())
A = list(map(int, input().split()))
if sum(A) < n:
print(-1)
continue
SUM = [0] * 64
for b in range(64):
if 1 << b & n != 0:
... | IMPORT ASSIGN VAR VAR ASSIGN VAR BIN_OP NUMBER VAR VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.