description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
Today is Chef's birthday. His mom decided to surprise him with a truly fantastic gift: his favourite binary string B. But, unfortunately, all the stocks of binary string B have been sold out, and only a binary string A (A ≠ B) is available in the market.
She purchases the string A and tries to convert it to string B by... | t = int(input())
for i in range(t):
a = input()
b = input()
n = len(a)
z, o = 0, 0
for j in a:
if j == "0":
z = 1
else:
o = 1
if z == 0 or o == 0:
print("Unlucky Chef")
else:
n1, n2 = 0, 0
for j in range(n):
e = a[j]... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR IF VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER NUMBER FOR V... |
Today is Chef's birthday. His mom decided to surprise him with a truly fantastic gift: his favourite binary string B. But, unfortunately, all the stocks of binary string B have been sold out, and only a binary string A (A ≠ B) is available in the market.
She purchases the string A and tries to convert it to string B by... | for _ in range(int(input())):
A = input()
B = input()
cnt0 = 0
cnt1 = 0
if "0" not in A or "1" not in A:
print("Unlucky Chef")
continue
for i in range(len(A)):
if A[i] == "0" and B[i] == "1":
cnt0 += 1
elif A[i] == "1" and B[i] == "0":
cnt1... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF STRING VAR STRING VAR EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR VAR STRING VAR NUMBER EXPR ... |
Today is Chef's birthday. His mom decided to surprise him with a truly fantastic gift: his favourite binary string B. But, unfortunately, all the stocks of binary string B have been sold out, and only a binary string A (A ≠ B) is available in the market.
She purchases the string A and tries to convert it to string B by... | T = int(input())
while T > 0:
T -= 1
A = input()
B = input()
p = 0
q = 0
o = 0
z = 0
for i in range(len(A)):
if A[i] == B[i]:
if A[i] == "1" and B[i] == "1":
o += 1
elif A[i] == "0" and B[i] == "0":
z += 1
elif A[i] ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR IF VAR VAR STRING VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR VAR ST... |
Today is Chef's birthday. His mom decided to surprise him with a truly fantastic gift: his favourite binary string B. But, unfortunately, all the stocks of binary string B have been sold out, and only a binary string A (A ≠ B) is available in the market.
She purchases the string A and tries to convert it to string B by... | t = int(input())
while t:
t -= 1
a = input()
b = input()
n = len(a)
c1a = 0
c1b = 0
cdiff = 0
for i in range(n):
if a[i] == "1":
c1a += 1
if b[i] == "1":
c1b += 1
if b[i] != a[i]:
cdiff += 1
c1diff = abs(c1a - c1b)
if c1... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER IF VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FU... |
Today is Chef's birthday. His mom decided to surprise him with a truly fantastic gift: his favourite binary string B. But, unfortunately, all the stocks of binary string B have been sold out, and only a binary string A (A ≠ B) is available in the market.
She purchases the string A and tries to convert it to string B by... | t = int(input())
for i in range(t):
a = input()
b = input()
o = 0
z = 0
s = set(a)
if len(s) < 2:
print("Unlucky Chef")
else:
l = len(a)
for j in range(l):
if a[j] != b[j]:
if a[j] == "0":
z += 1
else:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR IF VAR VAR S... |
Today is Chef's birthday. His mom decided to surprise him with a truly fantastic gift: his favourite binary string B. But, unfortunately, all the stocks of binary string B have been sold out, and only a binary string A (A ≠ B) is available in the market.
She purchases the string A and tries to convert it to string B by... | def fun(a, b):
if "1" not in a or "0" not in a:
return "Unlucky Chef"
at = tuple(a)
bt = tuple(b)
a1 = 0
a0 = 0
for i in range(len(at)):
if at[i] != bt[i]:
if at[i] == "1":
a1 += 1
else:
a0 += 1
return min(a0, a1) + abs(... | FUNC_DEF IF STRING VAR STRING VAR RETURN STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR IF VAR VAR STRING VAR NUMBER VAR NUMBER RETURN BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR FUN... |
Today is Chef's birthday. His mom decided to surprise him with a truly fantastic gift: his favourite binary string B. But, unfortunately, all the stocks of binary string B have been sold out, and only a binary string A (A ≠ B) is available in the market.
She purchases the string A and tries to convert it to string B by... | for t in range(int(input())):
a = input()
b = input()
f0 = f1 = c10 = c01 = 0
for i in range(len(a)):
if a[i] == "0":
f0 = 1
if b[i] == "1":
c01 += 1
else:
f1 = 1
if b[i] == "0":
c10 += 1
if f0 == 0 or f1... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR NUMBER IF VAR VAR STRING VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR STRING VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CAL... |
Today is Chef's birthday. His mom decided to surprise him with a truly fantastic gift: his favourite binary string B. But, unfortunately, all the stocks of binary string B have been sold out, and only a binary string A (A ≠ B) is available in the market.
She purchases the string A and tries to convert it to string B by... | from sys import stdin, stdout
def main():
from sys import stdin, stdout
for _ in range(int(stdin.readline())):
a = stdin.readline().strip()
b = stdin.readline().strip()
count = 0
ac1 = a.count("1")
ac0 = a.count("0")
a1 = 0
a0 = 0
for i in range... | FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR IF VAR VAR STR... |
Today is Chef's birthday. His mom decided to surprise him with a truly fantastic gift: his favourite binary string B. But, unfortunately, all the stocks of binary string B have been sold out, and only a binary string A (A ≠ B) is available in the market.
She purchases the string A and tries to convert it to string B by... | def is_possible(a, b):
return set(a) >= set(b)
t = int(input())
for _ in range(t):
a = input()
b = input()
if not is_possible(a, b):
print("Unlucky Chef")
continue
wrong_ones = sum(1 for x, y in zip(a, b) if x == "1" and y == "0")
wrong_zeroes = sum(1 for x, y in zip(a, b) if x... | FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR NUMBER VAR VAR FUNC_CALL VAR VAR VAR VAR STRING VAR STRING ASSIGN VAR FUNC_CA... |
Today is Chef's birthday. His mom decided to surprise him with a truly fantastic gift: his favourite binary string B. But, unfortunately, all the stocks of binary string B have been sold out, and only a binary string A (A ≠ B) is available in the market.
She purchases the string A and tries to convert it to string B by... | t = int(input())
for i in range(t):
zeroes = 0
ones = 0
zflag = 0
oflag = 0
a = str(input())
b = str(input())
for i in range(0, len(a)):
if a[i] == "0":
zflag = 1
if a[i] == "1":
oflag = 1
if a[i] != b[i]:
if b[i] == "1":
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR NUMBER IF VAR VAR STRING ASSI... |
Today is Chef's birthday. His mom decided to surprise him with a truly fantastic gift: his favourite binary string B. But, unfortunately, all the stocks of binary string B have been sold out, and only a binary string A (A ≠ B) is available in the market.
She purchases the string A and tries to convert it to string B by... | t = int(input())
for _ in range(t):
a = str(input())
b = str(input())
cnt = 0
cnt1 = 0
for i in range(len(a)):
if a[i] == "0" and b[i] == "1":
cnt += 1
elif a[i] == "1" and b[i] == "0":
cnt1 += 1
x = max(cnt, cnt1)
if a.count("1") == len(a) or a.count(... | 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 ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR VAR STRING VAR NUMBER ASSIGN VAR FU... |
Today is Chef's birthday. His mom decided to surprise him with a truly fantastic gift: his favourite binary string B. But, unfortunately, all the stocks of binary string B have been sold out, and only a binary string A (A ≠ B) is available in the market.
She purchases the string A and tries to convert it to string B by... | t = input()
t = int(t)
while t > 0:
a = list(input())
b = list(input())
if "1" in b and "1" not in a or "0" in b and "0" not in a:
print("Unlucky Chef")
else:
print("Lucky Chef")
ans = 0
zero_to_one = 0
one_to_zero = 0
i = 0
n = len(a)
whil... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF STRING VAR STRING VAR STRING VAR STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ... |
Today is Chef's birthday. His mom decided to surprise him with a truly fantastic gift: his favourite binary string B. But, unfortunately, all the stocks of binary string B have been sold out, and only a binary string A (A ≠ B) is available in the market.
She purchases the string A and tries to convert it to string B by... | t = int(input())
while t > 0:
t = t - 1
a = str(input())
b = str(input())
f = len(a)
c = a.count("1")
d = a.count("0")
e = b.count("1")
g = b.count("0")
z = 0
x = 0
y = 0
k = 0
if f == 1:
k = 1
elif a == b:
k = 2
y = 1
elif c == f or d ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ... |
Today is Chef's birthday. His mom decided to surprise him with a truly fantastic gift: his favourite binary string B. But, unfortunately, all the stocks of binary string B have been sold out, and only a binary string A (A ≠ B) is available in the market.
She purchases the string A and tries to convert it to string B by... | def zero_and_one_count(string):
zero = 0
one = 0
for char in string:
if char == "0":
zero += 1
else:
one += 1
return zero, one
def right_position(string1, string2):
zero = 0
one = 0
for i in range(len(string1)):
zero += string1[i] == string2[... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER VAR NUMBER RETURN VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR VAR VAR STRING VAR VAR VAR VAR VAR VAR VAR STRING RETURN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR... |
Today is Chef's birthday. His mom decided to surprise him with a truly fantastic gift: his favourite binary string B. But, unfortunately, all the stocks of binary string B have been sold out, and only a binary string A (A ≠ B) is available in the market.
She purchases the string A and tries to convert it to string B by... | T = int(input())
for t in range(T):
A = input()
B = input()
N = len(A)
c0, c1, c01, c10 = 0, 0, 0, 0
for i in range(N):
if A[i] == "0":
c0 += 1
c01 += B[i] == "1"
else:
c1 += 1
c10 += B[i] == "0"
if c01 and c0 == N or c10 and c1 == ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER VAR VAR VAR STRING VAR NUMBER VAR VAR VAR STRING IF VAR VAR VAR VAR VA... |
Today is Chef's birthday. His mom decided to surprise him with a truly fantastic gift: his favourite binary string B. But, unfortunately, all the stocks of binary string B have been sold out, and only a binary string A (A ≠ B) is available in the market.
She purchases the string A and tries to convert it to string B by... | for i in range(0, int(input())):
a = input()
b = input()
c = 0
d = 0
if len(a) != len(b):
print("Unlucky Chef")
print(1)
else:
for i in a:
if i == "0":
c = c + 1
else:
d = d + 1
if c == 0 or d == 0:
... | FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER FOR VAR VAR IF VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF... |
Today is Chef's birthday. His mom decided to surprise him with a truly fantastic gift: his favourite binary string B. But, unfortunately, all the stocks of binary string B have been sold out, and only a binary string A (A ≠ B) is available in the market.
She purchases the string A and tries to convert it to string B by... | t = int(input())
while t != 0:
zero = 0
one = 0
t = t - 1
A = input()
B = input()
for i in range(len(A)):
if A[i] != B[i]:
if A[i] == "0":
zero = zero + 1
else:
one = one + 1
if "0" not in A or "1" not in A:
print("Unluc... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR IF VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF STRING VAR ... |
Read problems statements in Russian here
Polo, the Penguin, likes the XOR operation. Please read NOTE if you are not familiar with XOR operation.
XOR-sum of a list of numbers is the result of XOR-ing all of them. XOR-sum of (A[1] XOR A[2] XOR ... XOR A[N]) is defined as A[1] XOR (A[2] XOR (A[3] XOR ( ... XOR A[N]))).... | t = int(input())
while t:
t -= 1
n = int(input())
s = input()
s = s.split()
li = []
for i in s:
li += [int(i)]
res = 0
for i in range(0, 31):
s = 0
ones = 0
e = 0
o = 0
zero = 0
for j in li:
if 1 << i & j == 0:
... | 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 ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR VAR LIST FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN V... |
Read problems statements in Russian here
Polo, the Penguin, likes the XOR operation. Please read NOTE if you are not familiar with XOR operation.
XOR-sum of a list of numbers is the result of XOR-ing all of them. XOR-sum of (A[1] XOR A[2] XOR ... XOR A[N]) is defined as A[1] XOR (A[2] XOR (A[3] XOR ( ... XOR A[N]))).... | import sys
data = sys.stdin.read().split()
data.reverse()
def read():
return int(data.pop())
def readStr():
return data.pop()
T = read()
res = []
for test in range(T):
n = read()
A = [read() for i in range(n)]
ans = 0
for b in range(30):
cnt = 0
V = []
sum = [0, 0]... | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER... |
Read problems statements in Russian here
Polo, the Penguin, likes the XOR operation. Please read NOTE if you are not familiar with XOR operation.
XOR-sum of a list of numbers is the result of XOR-ing all of them. XOR-sum of (A[1] XOR A[2] XOR ... XOR A[N]) is defined as A[1] XOR (A[2] XOR (A[3] XOR ( ... XOR A[N]))).... | for _ in range(int(input())):
n = int(input())
arr = [int(c) for c in input().split()]
s = []
xorval = 0
for i in arr:
xorval ^= i
s.append(xorval)
count = [(0) for i in range(32)]
ans = sum(s)
for i in range(32):
if s[0] & 1 << i:
count[i] += 1
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 VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUM... |
Read problems statements in Russian here
Polo, the Penguin, likes the XOR operation. Please read NOTE if you are not familiar with XOR operation.
XOR-sum of a list of numbers is the result of XOR-ing all of them. XOR-sum of (A[1] XOR A[2] XOR ... XOR A[N]) is defined as A[1] XOR (A[2] XOR (A[3] XOR ( ... XOR A[N]))).... | import sys
def bin_one(num):
s = bin(num)[2:]
return set([(len(s) - i - 1) for i in range(len(s)) if s[i] == "1"])
t = int(sys.stdin.readline())
for _ in range(t):
n = int(sys.stdin.readline())
A = [int(i) for i in sys.stdin.readline().rstrip().split()]
max_bin_len = len(bin(max(A))[2:])
C =... | IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR NUMBER RETURN FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR STRING 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_C... |
Read problems statements in Russian here
Polo, the Penguin, likes the XOR operation. Please read NOTE if you are not familiar with XOR operation.
XOR-sum of a list of numbers is the result of XOR-ing all of them. XOR-sum of (A[1] XOR A[2] XOR ... XOR A[N]) is defined as A[1] XOR (A[2] XOR (A[3] XOR ( ... XOR A[N]))).... | def solver():
T = int(input())
for _ in range(T):
ans = 0
n = int(input())
arr = [int(x) for x in input().split()]
for i in range(1, len(arr)):
arr[i] = arr[i] ^ arr[i - 1]
for i in range(32, -1, -1):
t = 1 << i
cnt = 0
for ... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMB... |
You are given arrays A and B with N non-negative integers each.
An array X of length N is called *good*, if:
All elements of the array X are non-negative;
X_{1} | X_{2} | \ldots | X_{i} = A_{i} for all (1≤ i≤ N);
X_{i} \& X_{(i+1)} \& \ldots \& X_{N} = B_{i} for all (1≤ i≤ N).
Find the maximum bitwise XOR of all elem... | import sys
input = sys.stdin.readline
for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
first_1 = [-1] * 31
last_1 = [n] * 31
for i in range(n):
for bit in range(30):
if a[i] & 1 << bit and first_1[bit] == ... | 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 FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST VAR NUMBER FOR ... |
You are given arrays A and B with N non-negative integers each.
An array X of length N is called *good*, if:
All elements of the array X are non-negative;
X_{1} | X_{2} | \ldots | X_{i} = A_{i} for all (1≤ i≤ N);
X_{i} \& X_{(i+1)} \& \ldots \& X_{N} = B_{i} for all (1≤ i≤ N).
Find the maximum bitwise XOR of all elem... | import sys
def mi():
return map(int, input().split())
def li():
return list(mi())
def si():
return str(input())
def lsi():
return si().strip().split(" ")
def ni():
return int(input())
input = sys.stdin.readline
for _ in range(ni()):
n = ni()
a = li()
b = li()
first_1 = [-... | IMPORT FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC... |
You are given arrays A and B with N non-negative integers each.
An array X of length N is called *good*, if:
All elements of the array X are non-negative;
X_{1} | X_{2} | \ldots | X_{i} = A_{i} for all (1≤ i≤ N);
X_{i} \& X_{(i+1)} \& \ldots \& X_{N} = B_{i} for all (1≤ i≤ N).
Find the maximum bitwise XOR of all elem... | def read_int():
return int(input())
def read_ints():
return [int(x) for x in input().split()]
def read_case():
n = read_int()
a = read_ints()
b = read_ints()
return n, a, b
def solve(n, a, b):
x = 0
bit = 1
while bit <= 2**30:
first_1 = 0
while first_1 < len(a) ... | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR RETURN VAR VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CA... |
You are given arrays A and B with N non-negative integers each.
An array X of length N is called *good*, if:
All elements of the array X are non-negative;
X_{1} | X_{2} | \ldots | X_{i} = A_{i} for all (1≤ i≤ N);
X_{i} \& X_{(i+1)} \& \ldots \& X_{N} = B_{i} for all (1≤ i≤ N).
Find the maximum bitwise XOR of all elem... | def check_bit(n, a, b, bit):
required = 0
possible = False
for i in range(n):
must_be_0 = must_be_1 = False
ai = a[i] >> bit & 1
must_be_0 = must_be_0 or ai == 0
if i > 0:
aim1 = a[i - 1] >> bit & 1
must_be_1 = must_be_1 or aim1 == 0 and ai == 1
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_... |
You are given an array A consisting of N integers.
From array A, we create a new array B containing all pairwise bitwise ANDs of elements from A. That is, B consists of N\cdot(N-1)/2 elements, each of the form A_{i} \mathbin{\&} A_{j} for some 1 ≤ i < j ≤ N.
In array B, we repeat the following process till there is o... | t = int(input())
for t1 in range(t):
n = int(input())
a = list(map(int, input().split()))
x = [0] * 10000
k = 0
for i in a:
j = i
z = 0
while j > 0:
if j % 2 == 1:
x[z] = x[z] + 1
k = max(k, z)
z = z + 1
j = j //... | 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 LIST NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSI... |
You are given an array A consisting of N integers.
From array A, we create a new array B containing all pairwise bitwise ANDs of elements from A. That is, B consists of N\cdot(N-1)/2 elements, each of the form A_{i} \mathbin{\&} A_{j} for some 1 ≤ i < j ≤ N.
In array B, we repeat the following process till there is o... | T = int(input())
while T > 0:
n = int(input())
arr = list(map(int, input().strip().split()))
setcount = []
for i in range(30):
temp = 0
setcount.append(temp)
for i in range(n):
for j in range(30):
if arr[i] & 1 * 2**j:
setcount[j] += 1
answer =... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF BIN_... |
You are given an array A consisting of N integers.
From array A, we create a new array B containing all pairwise bitwise ANDs of elements from A. That is, B consists of N\cdot(N-1)/2 elements, each of the form A_{i} \mathbin{\&} A_{j} for some 1 ≤ i < j ≤ N.
In array B, we repeat the following process till there is o... | t = int(input())
while t:
n = int(input())
a = list(map(int, input().strip().split()))
b = [(0) for i in range(30)]
for i in range(n):
for j in range(30):
if a[i] & 1 << j:
b[j] += 1
ans = 0
for i in range(30):
if b[i] > 1:
ans |= 1 << i
... | 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 FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR VAR BIN_OP NUMBER VAR VAR VAR NUMBER ASSIGN... |
You are given an array A consisting of N integers.
From array A, we create a new array B containing all pairwise bitwise ANDs of elements from A. That is, B consists of N\cdot(N-1)/2 elements, each of the form A_{i} \mathbin{\&} A_{j} for some 1 ≤ i < j ≤ N.
In array B, we repeat the following process till there is o... | T = int(input())
for i in range(T):
N = int(input())
arrA = [int(x) for x in input().split()]
BinArr = [0] * 32
for num in arrA:
i = -1
while i >= -32:
if num % 2 == 1:
BinArr[i] += 1
num = num // 2
i -= 1
sum = 0
for j in range... | 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 NUMBER NUMBER FOR VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR... |
You are given an array A consisting of N integers.
From array A, we create a new array B containing all pairwise bitwise ANDs of elements from A. That is, B consists of N\cdot(N-1)/2 elements, each of the form A_{i} \mathbin{\&} A_{j} for some 1 ≤ i < j ≤ N.
In array B, we repeat the following process till there is o... | for _ in range(int(input())):
n = int(input())
arr = list(map(int, input().split()))
cn = 1
ans = 0
for j in range(32):
c = 0
for k in range(n):
if arr[k] % 2:
c += 1
arr[k] = arr[k] // 2
if c > 1:
ans += cn
cn *= 2
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR BIN_... |
You are given an array A consisting of N integers.
From array A, we create a new array B containing all pairwise bitwise ANDs of elements from A. That is, B consists of N\cdot(N-1)/2 elements, each of the form A_{i} \mathbin{\&} A_{j} for some 1 ≤ i < j ≤ N.
In array B, we repeat the following process till there is o... | t = int(input())
for l in range(t):
n = int(input())
a = [k for k in map(int, input().split())]
b = [(0) for i in range(32)]
j = 0
for k in range(0, n):
z = 0
for m in range(0, 31):
if a[k] % 2 == 1:
b[z] += 1
z += 1
a[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 VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER IF BIN_... |
You are given an array A consisting of N integers.
From array A, we create a new array B containing all pairwise bitwise ANDs of elements from A. That is, B consists of N\cdot(N-1)/2 elements, each of the form A_{i} \mathbin{\&} A_{j} for some 1 ≤ i < j ≤ N.
In array B, we repeat the following process till there is o... | t = int(input())
while t:
n = int(input())
li = list(map(int, input().strip().split()))
l = []
di = {}
ml = 0
c = 0
for i in range(32):
di[i] = "0"
for i in li:
bs = bin(i)
l.append(bs[::-1])
lon = len(l[len(l) - 1])
if ml < lon:
ml = l... | 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 FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR DICT ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR STRING FOR VAR VAR ASSIGN VAR FUNC_CALL VAR... |
You are given an array A consisting of N integers.
From array A, we create a new array B containing all pairwise bitwise ANDs of elements from A. That is, B consists of N\cdot(N-1)/2 elements, each of the form A_{i} \mathbin{\&} A_{j} for some 1 ≤ i < j ≤ N.
In array B, we repeat the following process till there is o... | t = int(input())
for i in range(t):
n = int(input())
li = input().split()
for j in range(n):
li[j] = int(li[j])
m = [0] * 40
for j in range(n):
temp = bin(li[j])[2:]
for k in range(len(temp)):
m[-k - 1] = m[-k - 1] + int(temp[-k - 1])
ans = 0
for j in rang... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER FOR VAR FUNC_CA... |
You are given an array A consisting of N integers.
From array A, we create a new array B containing all pairwise bitwise ANDs of elements from A. That is, B consists of N\cdot(N-1)/2 elements, each of the form A_{i} \mathbin{\&} A_{j} for some 1 ≤ i < j ≤ N.
In array B, we repeat the following process till there is o... | T = int(input())
for i in range(T):
N = int(input())
Arr = [int(i) for i in input().split()]
pos = 1
ans = 0
for i in range(32):
count = 0
for j in range(len(Arr)):
if Arr[j] % 2 == 1:
count += 1
Arr[j] = Arr[j] // 2
if count > 1:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER NUMBER VAR ... |
You are given an array A consisting of N integers.
From array A, we create a new array B containing all pairwise bitwise ANDs of elements from A. That is, B consists of N\cdot(N-1)/2 elements, each of the form A_{i} \mathbin{\&} A_{j} for some 1 ≤ i < j ≤ N.
In array B, we repeat the following process till there is o... | case = int(input())
for i in range(case):
n = int(input())
arr = list(map(int, input().split(" ")))
i = 30
onebits = []
while i > 0:
count = 0
for j in range(n):
count += arr[j] & 1
arr[j] = arr[j] >> 1
onebits.append(count)
i -= 1
res = 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 FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR NUMBER ASSIGN VAR VAR BIN_OP... |
You are given an array A consisting of N integers.
From array A, we create a new array B containing all pairwise bitwise ANDs of elements from A. That is, B consists of N\cdot(N-1)/2 elements, each of the form A_{i} \mathbin{\&} A_{j} for some 1 ≤ i < j ≤ N.
In array B, we repeat the following process till there is o... | t = int(input())
def solve(ar):
n = len(ar)
out = [0] * 32
for i in range(n):
idx = 0
tmp = ar[i]
while tmp != 0:
if tmp & 1 == 1:
out[idx] += 1
tmp = tmp >> 1
idx += 1
res = 0
p = 0
for i in out:
if i > 1:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR... |
You are given an array A consisting of N integers.
From array A, we create a new array B containing all pairwise bitwise ANDs of elements from A. That is, B consists of N\cdot(N-1)/2 elements, each of the form A_{i} \mathbin{\&} A_{j} for some 1 ≤ i < j ≤ N.
In array B, we repeat the following process till there is o... | t = int(input())
while t:
n = int(input())
l = [int(i) for i in input().split()]
if n == 1:
print(l[0])
x = ans = 0
for i in range(n - 1, 0, -1):
x |= l[i]
ans |= l[i - 1] & x
print(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 VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER VAR VAR VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR EXPR F... |
You are given an array A consisting of N integers.
From array A, we create a new array B containing all pairwise bitwise ANDs of elements from A. That is, B consists of N\cdot(N-1)/2 elements, each of the form A_{i} \mathbin{\&} A_{j} for some 1 ≤ i < j ≤ N.
In array B, we repeat the following process till there is o... | for _ in range(int(input())):
n = int(input())
l = list(map(int, input().split()))
nl = [0] * 32
for i in range(n):
for j in range(32):
nl[j] += l[i] & 1 << j > 0
ans = 0
for i in range(32):
if nl[i] >= 2:
ans |= 1 << i
print(ans) | 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 FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR VAR BIN_OP VAR VAR BIN_OP NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR VA... |
You are given an array A consisting of N integers.
From array A, we create a new array B containing all pairwise bitwise ANDs of elements from A. That is, B consists of N\cdot(N-1)/2 elements, each of the form A_{i} \mathbin{\&} A_{j} for some 1 ≤ i < j ≤ N.
In array B, we repeat the following process till there is o... | num = int(input())
while num:
num -= 1
length = int(input())
a1 = input().split()
if length == 2:
print(int(a1[0]) & int(a1[1]))
continue
length = 0
answer = ""
for i in a1:
length = max(length, len(bin(int(i))))
for j in range(0, length):
gotans = False
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_... |
You are given an array A consisting of N integers.
From array A, we create a new array B containing all pairwise bitwise ANDs of elements from A. That is, B consists of N\cdot(N-1)/2 elements, each of the form A_{i} \mathbin{\&} A_{j} for some 1 ≤ i < j ≤ N.
In array B, we repeat the following process till there is o... | t = int(input())
while t:
n = int(input())
l = list(map(int, input().split()))
b = [0] * 30
ct = 0
for c in l:
bi = format(c, "030b")
for i in range(29, -1, -1):
if bi[i] == "1":
b[i] += 1
op = "0b"
for k in range(30):
if b[k] > 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 BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR STRING FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF VAR VAR STRING V... |
You are given an array A consisting of N integers.
From array A, we create a new array B containing all pairwise bitwise ANDs of elements from A. That is, B consists of N\cdot(N-1)/2 elements, each of the form A_{i} \mathbin{\&} A_{j} for some 1 ≤ i < j ≤ N.
In array B, we repeat the following process till there is o... | for i in range(int(input())):
n = int(input())
setbits = [0] * 32
num = list(map(int, input().split()))[:n]
for j in range(n):
for k in range(32):
if num[j] & 1 << k:
setbits[k] += 1
ans = 0
for j in range(32):
if setbits[j] > 1:
ans |= 1 <... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR VAR BIN_OP NUMBER VAR VAR VAR NUMBER ASSIGN VAR NUMBER... |
You are given an array A consisting of N integers.
From array A, we create a new array B containing all pairwise bitwise ANDs of elements from A. That is, B consists of N\cdot(N-1)/2 elements, each of the form A_{i} \mathbin{\&} A_{j} for some 1 ≤ i < j ≤ N.
In array B, we repeat the following process till there is o... | def main():
for _ in range(int(input())):
n = int(input())
arr = list(map(lambda x: "{0:032b}".format(int(x)), input().split()))
ans = ["0" for _ in range(32)]
for i in range(32):
counter = 0
for element in arr:
if element[i] == "1":
... | FUNC_DEF 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 FUNC_CALL STRING FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR STRING VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR STRING IF V... |
You are given an array A consisting of N integers.
From array A, we create a new array B containing all pairwise bitwise ANDs of elements from A. That is, B consists of N\cdot(N-1)/2 elements, each of the form A_{i} \mathbin{\&} A_{j} for some 1 ≤ i < j ≤ N.
In array B, we repeat the following process till there is o... | for _ in range(int(input())):
n = int(input())
X = [int(x) for x in input().split()]
l = []
for i in X:
l.append(format(i, "032b"))
ans = ""
for i in range(32):
count = 0
for s in l:
if s[i] == "1":
count += 1
if count >= 2:
... | 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 LIST FOR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR STRING ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR STRING VAR NUM... |
You are given an array A consisting of N integers.
From array A, we create a new array B containing all pairwise bitwise ANDs of elements from A. That is, B consists of N\cdot(N-1)/2 elements, each of the form A_{i} \mathbin{\&} A_{j} for some 1 ≤ i < j ≤ N.
In array B, we repeat the following process till there is o... | for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
or_Array = [0] * len(a)
or_Array[n - 1] = a[n - 1]
for i in range(n - 2, 0, -1):
or_Array[i] = a[i] | or_Array[i + 1]
res = 0
for j in range(n - 2):
res = res | a[j] & or_Array[j + 1]
res =... | 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 FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR ... |
You are given an array A consisting of N integers.
From array A, we create a new array B containing all pairwise bitwise ANDs of elements from A. That is, B consists of N\cdot(N-1)/2 elements, each of the form A_{i} \mathbin{\&} A_{j} for some 1 ≤ i < j ≤ N.
In array B, we repeat the following process till there is o... | for _ in range(int(input())):
n = int(input())
res = list(map(int, input().split()))
vect = [0] * 30
for i in res:
s = bin(i)[2:]
k = -1
for j in range(len(s) - 1, -1, -1):
if s[j] == "1":
vect[k] += 1
k -= 1
final_result = ["0"] * 30
... | 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 ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ... |
You are given an array A consisting of N integers.
From array A, we create a new array B containing all pairwise bitwise ANDs of elements from A. That is, B consists of N\cdot(N-1)/2 elements, each of the form A_{i} \mathbin{\&} A_{j} for some 1 ≤ i < j ≤ N.
In array B, we repeat the following process till there is o... | mod = 1000000007
read_int = lambda: int(input().strip())
read_str = lambda: input().strip()
read_str_arr = lambda: input().strip().split()
read_int_arr = lambda: [int(x) for x in input().strip().split()]
def solve():
N = read_int()
A = read_int_arr()
ans = 0
or_acc = A[N - 1]
for i in range(N - 2,... | ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUM... |
You are given an array A consisting of N integers.
From array A, we create a new array B containing all pairwise bitwise ANDs of elements from A. That is, B consists of N\cdot(N-1)/2 elements, each of the form A_{i} \mathbin{\&} A_{j} for some 1 ≤ i < j ≤ N.
In array B, we repeat the following process till there is o... | t = int(input())
for i in range(t):
n = int(input())
l = list(map(int, list(input().split())))
arr = [0] * 35
for j in range(n):
count = 0
while l[j] > 0:
x = l[j] & 1
if x == 1:
arr[count] = arr[count] + 1
count = count + 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 VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER ... |
You are given an array A consisting of N integers.
From array A, we create a new array B containing all pairwise bitwise ANDs of elements from A. That is, B consists of N\cdot(N-1)/2 elements, each of the form A_{i} \mathbin{\&} A_{j} for some 1 ≤ i < j ≤ N.
In array B, we repeat the following process till there is o... | for t in range(int(input())):
n = int(input())
a = [int(i) for i in input().split()]
byte_list = [0] * 32
ans = 0
for num in a:
i = 0
bit = num >> i
while bit > 0:
byte_list[i] = byte_list[i] + (bit & 1)
i += 1
bit = num >> i
for i, bit... | 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 BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR WHILE VAR NUMBER ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP VAR NUMBE... |
You are given an array A consisting of N integers.
From array A, we create a new array B containing all pairwise bitwise ANDs of elements from A. That is, B consists of N\cdot(N-1)/2 elements, each of the form A_{i} \mathbin{\&} A_{j} for some 1 ≤ i < j ≤ N.
In array B, we repeat the following process till there is o... | def binary(l, num):
j = 0
while num != 0:
rem = num % 2
l[j] = l[j] + rem
j += 1
num //= 2
return l, num
n = int(input())
for _ in range(n):
l = [0] * 30
x = int(input())
y = list(map(int, input().split()))
for i in range(x):
binary(l, y[i])
for ... | FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR VAR VAR VAR NUMBER VAR NUMBER RETURN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL ... |
You are given an array A consisting of N integers.
From array A, we create a new array B containing all pairwise bitwise ANDs of elements from A. That is, B consists of N\cdot(N-1)/2 elements, each of the form A_{i} \mathbin{\&} A_{j} for some 1 ≤ i < j ≤ N.
In array B, we repeat the following process till there is o... | T = int(input())
for t in range(T):
n = int(input())
a = list(map(int, input().split()))
lenA = len(a)
if lenA == 2:
print(a[0] & a[1])
continue
acc = 0
x = a[lenA - 1]
for i in range(lenA - 2, -1, -1):
acc = acc | a[i] & x
x = x | a[i]
print(acc) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER FOR VAR... |
You are given an array A consisting of N integers.
From array A, we create a new array B containing all pairwise bitwise ANDs of elements from A. That is, B consists of N\cdot(N-1)/2 elements, each of the form A_{i} \mathbin{\&} A_{j} for some 1 ≤ i < j ≤ N.
In array B, we repeat the following process till there is o... | t = int(input())
for _ in range(t):
n = int(input())
arr = list(map(int, input().split()))
x = arr[0]
left = [arr[0]]
for i in range(1, len(arr)):
x = x | arr[i]
left.append(x)
right = [arr[-1]]
x = arr[-1]
for i in range(len(arr) - 2, -1, -1):
x = x | arr[i]
... | 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 LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR ... |
You are given an array A consisting of N integers.
From array A, we create a new array B containing all pairwise bitwise ANDs of elements from A. That is, B consists of N\cdot(N-1)/2 elements, each of the form A_{i} \mathbin{\&} A_{j} for some 1 ≤ i < j ≤ N.
In array B, we repeat the following process till there is o... | T = int(input())
for _ in range(T):
N = int(input())
A = list(map(int, input().split()))
B = []
maxlen = 0
for each in A:
binary = bin(each)[2:]
B.append(binary)
if len(binary) > maxlen:
maxlen = len(binary)
for i in range(len(B)):
B[i] = "0" * (maxlen... | 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 ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CAL... |
You are given an array A consisting of N integers.
From array A, we create a new array B containing all pairwise bitwise ANDs of elements from A. That is, B consists of N\cdot(N-1)/2 elements, each of the form A_{i} \mathbin{\&} A_{j} for some 1 ≤ i < j ≤ N.
In array B, we repeat the following process till there is o... | for _ in range(int(input())):
n = int(input())
arr = list(map(int, input().split()))
d = {}
for i in range(30, -1, -1):
d[i] = 0
for bit in range(30, -1, -1):
for j in arr:
if 1 << bit & j:
d[bit] += 1
ans = 0
for i in range(30, -1, -1):
if... | 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 DICT FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER FOR VAR VAR IF BIN_OP BIN_OP NUMBER VAR ... |
You are given an array A consisting of N integers.
From array A, we create a new array B containing all pairwise bitwise ANDs of elements from A. That is, B consists of N\cdot(N-1)/2 elements, each of the form A_{i} \mathbin{\&} A_{j} for some 1 ≤ i < j ≤ N.
In array B, we repeat the following process till there is o... | T = int(input())
for _ in range(T):
n = int(input())
A = list(map(int, input().split(" ")))
B = []
if n == 2:
print(A[1] & A[0])
continue
for i in range(n - 1, 0, -1):
if i == n - 1:
B.append(A[i])
else:
B.append(B[-1] | A[i])
ans = 0
f... | 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 LIST IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR BIN... |
You are given an array A consisting of N integers.
From array A, we create a new array B containing all pairwise bitwise ANDs of elements from A. That is, B consists of N\cdot(N-1)/2 elements, each of the form A_{i} \mathbin{\&} A_{j} for some 1 ≤ i < j ≤ N.
In array B, we repeat the following process till there is o... | t = int(input())
for _ in range(t):
n = int(input())
p = [int(i) for i in input().split()]
l = []
temp = 0
for i in range(n - 1):
temp = temp | p[n - i - 1]
l.append(temp)
temp = 0
for i in range(n - 1):
temp = temp | p[i] & l[n - i - 2]
print(temp) | 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 LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN ... |
You are given an array A consisting of N integers.
From array A, we create a new array B containing all pairwise bitwise ANDs of elements from A. That is, B consists of N\cdot(N-1)/2 elements, each of the form A_{i} \mathbin{\&} A_{j} for some 1 ≤ i < j ≤ N.
In array B, we repeat the following process till there is o... | t = int(input())
while t > 0:
n = int(input())
a = input().split()
for i in range(n):
a[i] = int(a[i])
b = [(0) for i in range(32)]
for i in range(n):
r = 0
while a[i] > 0:
if a[i] % 2:
b[r] += 1
a[i] = a[i] // 2
r += 1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR NUMBER IF BIN_OP VAR VAR N... |
You are given an array A consisting of N integers.
From array A, we create a new array B containing all pairwise bitwise ANDs of elements from A. That is, B consists of N\cdot(N-1)/2 elements, each of the form A_{i} \mathbin{\&} A_{j} for some 1 ≤ i < j ≤ N.
In array B, we repeat the following process till there is o... | t = int(input())
for i in range(t):
n = int(input())
A = list(map(int, input().split(" ")))
A = A[:n]
li = [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NU... |
You are given an array A consisting of N integers.
From array A, we create a new array B containing all pairwise bitwise ANDs of elements from A. That is, B consists of N\cdot(N-1)/2 elements, each of the form A_{i} \mathbin{\&} A_{j} for some 1 ≤ i < j ≤ N.
In array B, we repeat the following process till there is o... | for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
a.sort()
res = 0
for i in range(32, -1, -1):
cnt = 0
for j in range(n):
if a[j] & 1 << i:
cnt += 1
if cnt > 1:
res += pow(2, i)
print(res) | 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 EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR BIN_OP NUMBER VAR VAR ... |
You are given an array A consisting of N integers.
From array A, we create a new array B containing all pairwise bitwise ANDs of elements from A. That is, B consists of N\cdot(N-1)/2 elements, each of the form A_{i} \mathbin{\&} A_{j} for some 1 ≤ i < j ≤ N.
In array B, we repeat the following process till there is o... | for _ in range(int(input())):
n = int(input())
l = list(map(int, input().split()))
ma = format(max(l), "b")
l1 = [0] * len(ma)
i = 0
for x in l:
a = format(x, "b")
z = 0
for y in a[::-1]:
if y == "1":
if l1[z] == 2:
pass
... | 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 FUNC_CALL VAR VAR STRING ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR STRING ... |
You are given an array A consisting of N integers.
From array A, we create a new array B containing all pairwise bitwise ANDs of elements from A. That is, B consists of N\cdot(N-1)/2 elements, each of the form A_{i} \mathbin{\&} A_{j} for some 1 ≤ i < j ≤ N.
In array B, we repeat the following process till there is o... | def solve(ar):
t = 0
ans = 0
for i in range(32):
t = 0
for x in ar:
if x & 1 << i:
t += 1
if t > 1:
ans |= 1 << i
return ans
for i in range(int(input())):
n = int(input())
l = list(map(int, input().split()))
print(solve(l)) | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR BIN_OP NUMBER VAR VAR NUMBER IF VAR NUMBER VAR BIN_OP NUMBER VAR RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VA... |
You are given an array A consisting of N integers.
From array A, we create a new array B containing all pairwise bitwise ANDs of elements from A. That is, B consists of N\cdot(N-1)/2 elements, each of the form A_{i} \mathbin{\&} A_{j} for some 1 ≤ i < j ≤ N.
In array B, we repeat the following process till there is o... | t = int(input())
while t > 0:
n = int(input())
lst = list(map(int, input().split()))
or_lst = []
initial_or = 0
for i in range(n - 1, -1, -1):
or_lst.insert(0, initial_or)
initial_or |= lst[i]
or_component = 0
for i in range(n):
temp = or_lst[i] & lst[i]
or_co... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE 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 LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FU... |
You are given an array A consisting of N integers.
From array A, we create a new array B containing all pairwise bitwise ANDs of elements from A. That is, B consists of N\cdot(N-1)/2 elements, each of the form A_{i} \mathbin{\&} A_{j} for some 1 ≤ i < j ≤ N.
In array B, we repeat the following process till there is o... | t = int(input())
for tc in range(0, t):
n = int(input())
arr = list(map(int, input().split()))
out = [(0) for i in range(32)]
for j in range(len(arr)):
for i in range(32):
k = arr[j] >> i
if k & 1:
out[i] += 1
ans = 0
for i in range(32):
if... | 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 VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR ... |
You are given an array A consisting of N integers.
From array A, we create a new array B containing all pairwise bitwise ANDs of elements from A. That is, B consists of N\cdot(N-1)/2 elements, each of the form A_{i} \mathbin{\&} A_{j} for some 1 ≤ i < j ≤ N.
In array B, we repeat the following process till there is o... | try:
for _ in range(int(input())):
n = int(input())
arr = list(map(int, input().split()))
matrix = []
for i in arr:
s = "0" * 30
temp = bin(i).replace("0b", "")
matrix.append(s[len(temp) :] + temp)
result = ["0"] * 30
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 LIST FOR VAR VAR ASSIGN VAR BIN_OP STRING NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR STRING STRING EXPR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR VAR VAR... |
You are given an array A consisting of N integers.
From array A, we create a new array B containing all pairwise bitwise ANDs of elements from A. That is, B consists of N\cdot(N-1)/2 elements, each of the form A_{i} \mathbin{\&} A_{j} for some 1 ≤ i < j ≤ N.
In array B, we repeat the following process till there is o... | def main():
n = int(input())
a = list(map(int, input().split()))
ai = [(0) for j in range(30)]
for j in a:
n = 0
while n < 31:
if j & 1 << 0 + n >= 1:
ai[n] += 1
n += 1
for k in range(30):
if ai[k] < 2:
ai[k] = 0
els... | FUNC_DEF 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 VAR FUNC_CALL VAR NUMBER FOR VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR BIN_OP NUMBER BIN_OP NUMBER VAR NUMBER VAR VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR ... |
You are given an array A consisting of N integers.
From array A, we create a new array B containing all pairwise bitwise ANDs of elements from A. That is, B consists of N\cdot(N-1)/2 elements, each of the form A_{i} \mathbin{\&} A_{j} for some 1 ≤ i < j ≤ N.
In array B, we repeat the following process till there is o... | t = int(input())
while t > 0:
n = int(input())
a = list(map(int, input().split()))
ans = 0
c = a[0]
for i in range(1, n):
ans = ans | c & a[i]
c |= a[i]
print(ans)
t -= 1 | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBE... |
You are given an array A consisting of N integers.
From array A, we create a new array B containing all pairwise bitwise ANDs of elements from A. That is, B consists of N\cdot(N-1)/2 elements, each of the form A_{i} \mathbin{\&} A_{j} for some 1 ≤ i < j ≤ N.
In array B, we repeat the following process till there is o... | for i in range(int(input())):
n = int(input())
ar = [int(x) for x in input().split()]
l = []
m = 1
for i in range(0, 32):
count = 0
for j in ar:
if j >> i & m == 1:
count += 1
if count == 2:
l.append(2)
break
... | 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 LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP BIN_OP VAR VAR VAR NUMBER VAR NUMBER IF VAR NUMBER EXPR FUNC_CAL... |
You are given an array A consisting of N integers.
From array A, we create a new array B containing all pairwise bitwise ANDs of elements from A. That is, B consists of N\cdot(N-1)/2 elements, each of the form A_{i} \mathbin{\&} A_{j} for some 1 ≤ i < j ≤ N.
In array B, we repeat the following process till there is o... | t = int(input())
while t:
t = t - 1
n = int(input())
arr = list(map(int, input().split()))
res = []
for i in range(0, 32, 1):
res.append(0)
ans = 0
for i in range(0, 32, 1):
for j in range(n):
if arr[j] % 2 == 1:
res[i] = res[i] + 1
els... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR BIN_OP 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 LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMB... |
You are given an array A consisting of N integers.
From array A, we create a new array B containing all pairwise bitwise ANDs of elements from A. That is, B consists of N\cdot(N-1)/2 elements, each of the form A_{i} \mathbin{\&} A_{j} for some 1 ≤ i < j ≤ N.
In array B, we repeat the following process till there is o... | for t in range(int(input())):
N = int(input())
A = list(map(int, input().split()))
suffixOR = [0]
for i in range(len(A) - 1, 0, -1):
suffixOR.append(suffixOR[-1] | A[i])
suffixOR.reverse()
ans = 0
for i in range(N - 1):
ans = ans | A[i] & suffixOR[i]
print(ans) | 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 FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL VAR ASSIGN VA... |
You are given an array A consisting of N integers.
From array A, we create a new array B containing all pairwise bitwise ANDs of elements from A. That is, B consists of N\cdot(N-1)/2 elements, each of the form A_{i} \mathbin{\&} A_{j} for some 1 ≤ i < j ≤ N.
In array B, we repeat the following process till there is o... | t = int(input())
for _ in range(t):
n = int(input())
a = [int(x) for x in input().split()]
ans = 0
for i in range(32):
c = 0
for x in a:
if x & 1 << i:
c += 1
if c > 1:
ans = ans | 1 << i
print(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 VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR BIN_OP NUMBER VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR BIN... |
You are given an array A consisting of N integers.
From array A, we create a new array B containing all pairwise bitwise ANDs of elements from A. That is, B consists of N\cdot(N-1)/2 elements, each of the form A_{i} \mathbin{\&} A_{j} for some 1 ≤ i < j ≤ N.
In array B, we repeat the following process till there is o... | for i in range(int(input())):
N = int(input())
arr = [int(x) for x in input().split()]
brr = []
dict = set()
while len(arr) > 0:
count = 0
dict = sorted(dict)
dict = reversed(dict)
for i in dict:
arr.pop(i)
n = len(arr)
dict = set()
... | 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 LIST ASSIGN VAR FUNC_CALL VAR WHILE FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR EXPR FUNC_CALL... |
You are given an array A consisting of N integers.
From array A, we create a new array B containing all pairwise bitwise ANDs of elements from A. That is, B consists of N\cdot(N-1)/2 elements, each of the form A_{i} \mathbin{\&} A_{j} for some 1 ≤ i < j ≤ N.
In array B, we repeat the following process till there is o... | t = input()
t = int(t)
while t:
n = input()
n = int(n)
a = [int(a) for a in input().split()]
setBitCount = [0] * 30
for num in a:
for i in range(0, 30):
if num & 1 << i:
setBitCount[i] += 1
ans = 0
for i in range(30):
if setBitCount[i] > 1:
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER IF BIN_OP VAR BIN_OP NUMBER VAR VAR VAR NUMBER ASSIGN VAR NU... |
You are given an array A consisting of N integers.
From array A, we create a new array B containing all pairwise bitwise ANDs of elements from A. That is, B consists of N\cdot(N-1)/2 elements, each of the form A_{i} \mathbin{\&} A_{j} for some 1 ≤ i < j ≤ N.
In array B, we repeat the following process till there is o... | try:
for _ in range(int(input())):
n = int(input())
arr = list(map(int, input().split()))
bits = []
ans = ["0"] * 32
for i in arr:
temp1 = bin(i).replace("0b", "")
temp2 = "0" * (32 - len(temp1))
bits.append(temp2 + temp1)
for i in ... | 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 ASSIGN VAR BIN_OP LIST STRING NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR STRING STRING ASSIGN VAR BIN_OP STRING BIN_OP NUMBER FUNC_CA... |
You are given an array A consisting of N integers.
From array A, we create a new array B containing all pairwise bitwise ANDs of elements from A. That is, B consists of N\cdot(N-1)/2 elements, each of the form A_{i} \mathbin{\&} A_{j} for some 1 ≤ i < j ≤ N.
In array B, we repeat the following process till there is o... | for _ in range(int(input())):
n = int(input())
q = [0] * 32
a = list(map(int, input().split()))
for i in a:
p = 0
while i:
q[p] += i & 1
i >>= 1
p += 1
for i in range(32):
if q[i] > 1:
q[i] = "1"
else:
q[i] =... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR... |
You are given an array A consisting of N integers.
From array A, we create a new array B containing all pairwise bitwise ANDs of elements from A. That is, B consists of N\cdot(N-1)/2 elements, each of the form A_{i} \mathbin{\&} A_{j} for some 1 ≤ i < j ≤ N.
In array B, we repeat the following process till there is o... | def to_find(n, ll):
b = [0] * 30
for i in range(n):
for j in range(30):
if ll[i] & 1 << j > 0:
b[j] += 1
res = 0
for i in range(30):
if b[i] >= 2:
res = res | 1 << i
return res
for i in range(int(input())):
n = int(input())
ll = list(... | FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR VAR BIN_OP NUMBER VAR NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL... |
You are given an array A consisting of N integers.
From array A, we create a new array B containing all pairwise bitwise ANDs of elements from A. That is, B consists of N\cdot(N-1)/2 elements, each of the form A_{i} \mathbin{\&} A_{j} for some 1 ≤ i < j ≤ N.
In array B, we repeat the following process till there is o... | for _ in range(int(input())):
n = int(input())
a = [int(i) for i in input().split()]
for i in range(n):
a[i] = (30 - len(bin(a[i])[2:])) * "0" + bin(a[i])[2:]
y = [0] * 30
for i in range(30):
for j in range(n):
if a[j][i] == "1":
y[i] += 1
s = ""
f... | 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 FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP BIN_OP BIN_OP NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER STRING FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUM... |
You are given an array A consisting of N integers.
From array A, we create a new array B containing all pairwise bitwise ANDs of elements from A. That is, B consists of N\cdot(N-1)/2 elements, each of the form A_{i} \mathbin{\&} A_{j} for some 1 ≤ i < j ≤ N.
In array B, we repeat the following process till there is o... | for _ in range(int(input())):
n = int(input())
num_bits = [0] * 30
res = 0
for x in input().split():
a = int(x)
for j in range(len(num_bits)):
if a & 1 << j:
num_bits[j] += 1
if num_bits[j] == 2:
res += 2**j
print(res) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR BIN_OP NUMBER VAR VAR VAR NUMBER IF VAR VAR NUMBER VAR BIN_OP... |
You are given an array A consisting of N integers.
From array A, we create a new array B containing all pairwise bitwise ANDs of elements from A. That is, B consists of N\cdot(N-1)/2 elements, each of the form A_{i} \mathbin{\&} A_{j} for some 1 ≤ i < j ≤ N.
In array B, we repeat the following process till there is o... | def Binary(n):
s = bin(n)
s1 = s[2:]
return s1
def binaryToDecimal(n):
return int(n, 2)
for i in range(int(input())):
N = int(input())
elements = list(map(int, input().split()))
newelements = [Binary(i) for i in elements]
a = max(elements)
a = Binary(a)
a = len(a)
for i i... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER RETURN VAR FUNC_DEF RETURN FUNC_CALL VAR VAR 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 FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC... |
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
For a given $N$, find the number of ways to choose an integer $x$ from the range $[0, 2^{N} - 1]$ such that $x \oplus (x+1) = (x+2) \oplus (x+3)$, where $\oplus$ denotes the bitwise XOR operator.
Since the number of valid $... | modNo = int(1000000000.0 + 7)
t = int(input())
while t > 0:
n = int(input())
print(pow(2, n - 1, modNo))
t = t - 1 | ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER |
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
For a given $N$, find the number of ways to choose an integer $x$ from the range $[0, 2^{N} - 1]$ such that $x \oplus (x+1) = (x+2) \oplus (x+3)$, where $\oplus$ denotes the bitwise XOR operator.
Since the number of valid $... | t = int(input())
for i in range(t):
n = int(input())
c = 1
n = n - 1
b = 2
while n:
if n % 2 != 0:
c = c * b % 1000000007
b = b * b % 1000000007
n //= 2
print(c % 1000000007) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN... |
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
For a given $N$, find the number of ways to choose an integer $x$ from the range $[0, 2^{N} - 1]$ such that $x \oplus (x+1) = (x+2) \oplus (x+3)$, where $\oplus$ denotes the bitwise XOR operator.
Since the number of valid $... | poww = [0]
res = 2
for i in range(1, 100001):
poww.append(res)
res *= 2
for _ in range(int(input())):
n = int(input())
print(poww[n] // 2 % 1000000007) | ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER |
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
For a given $N$, find the number of ways to choose an integer $x$ from the range $[0, 2^{N} - 1]$ such that $x \oplus (x+1) = (x+2) \oplus (x+3)$, where $\oplus$ denotes the bitwise XOR operator.
Since the number of valid $... | for i in range(int(input())):
n = int(input())
if n == 1:
print(1)
elif n == 2:
print(2)
else:
print(pow(2, n - 1, 10**9 + 7)) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER BIN_OP BIN_OP NUMBER NUMBER NUMBER |
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
For a given $N$, find the number of ways to choose an integer $x$ from the range $[0, 2^{N} - 1]$ such that $x \oplus (x+1) = (x+2) \oplus (x+3)$, where $\oplus$ denotes the bitwise XOR operator.
Since the number of valid $... | maxn = 10**5
mod = 10**9 + 7
dp = [1]
for i in range(1, maxn + 1):
dp.append(dp[i - 1] * 2 % mod)
for case in range(int(input())):
n = int(input())
print(dp[n - 1]) | ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VA... |
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
For a given $N$, find the number of ways to choose an integer $x$ from the range $[0, 2^{N} - 1]$ such that $x \oplus (x+1) = (x+2) \oplus (x+3)$, where $\oplus$ denotes the bitwise XOR operator.
Since the number of valid $... | factDp = [(-1) for i in range(10**5)]
curr = 2
factDp[0] = 1
factDp[1] = 2
MOD = 10**9 + 7
for i in range(2, 10**5):
curr = curr * 2 % MOD
factDp[i] = curr
for _ in range(int(input())):
n = int(input())
res = factDp[n - 1]
print(res) | ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC... |
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
For a given $N$, find the number of ways to choose an integer $x$ from the range $[0, 2^{N} - 1]$ such that $x \oplus (x+1) = (x+2) \oplus (x+3)$, where $\oplus$ denotes the bitwise XOR operator.
Since the number of valid $... | from sys import stdin
l = []
lim = 10000000000.0 + 7
for _ in range(int(stdin.readline())):
l.append(pow(2, int(stdin.readline()) - 1, 1000000007))
for i in l:
print(i) | ASSIGN VAR LIST ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR VAR EXPR FUNC_CALL VAR VAR |
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
For a given $N$, find the number of ways to choose an integer $x$ from the range $[0, 2^{N} - 1]$ such that $x \oplus (x+1) = (x+2) \oplus (x+3)$, where $\oplus$ denotes the bitwise XOR operator.
Since the number of valid $... | t = int(input())
while t:
count1 = 0
n = int(input())
if n == 0:
print(1)
else:
print(pow(2, n - 1, 1000000007))
t = t - 1 | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER |
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
For a given $N$, find the number of ways to choose an integer $x$ from the range $[0, 2^{N} - 1]$ such that $x \oplus (x+1) = (x+2) \oplus (x+3)$, where $\oplus$ denotes the bitwise XOR operator.
Since the number of valid $... | tum = int(input())
pum = int(1000000000.0 + 7)
for i in range(tum):
num = int(input())
if num == 1:
print(1)
else:
print((2 << num - 2) % pum) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER VAR |
Given two positive integers N and M, let S denote the set of all the arrays of size N such that each element of the array lies in the range [1, M]. Since there are M^{N} such arrays, the size of S is M^{N}.
Let X_{i} denote the [bitwise AND] of all elements of the i^{th} array in the set, where 1 ≤ i ≤ M^{N}.
Find t... | def mi():
return map(int, input().split())
def li():
return list(mi())
def si():
return str(input())
def ni():
return int(input())
mod = 998244353
for _ in range(ni()):
n, m = mi()
res = 0
for bit in range(31):
b2 = 2 << bit
count = m // b2 * (b2 >> 1) + max(0, m % b2... | FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ... |
Given two positive integers N and M, let S denote the set of all the arrays of size N such that each element of the array lies in the range [1, M]. Since there are M^{N} such arrays, the size of S is M^{N}.
Let X_{i} denote the [bitwise AND] of all elements of the i^{th} array in the set, where 1 ≤ i ≤ M^{N}.
Find t... | mod = 998244353
def power(x, y, p):
res = 1
x = x % p
if x == 0:
return 0
while y > 0:
if y & 1 == 1:
res = res * x % p
y //= 2
x = x * x % p
return res
def power_ka_function(a, b):
return a // 2 ** (b + 1) * 2**b
def rem_ka_function(a, b):
r... | ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER RETURN NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR RETURN VAR FUNC_DEF RETURN BIN_OP BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBER BIN_OP NUMBER ... |
Given two positive integers N and M, let S denote the set of all the arrays of size N such that each element of the array lies in the range [1, M]. Since there are M^{N} such arrays, the size of S is M^{N}.
Let X_{i} denote the [bitwise AND] of all elements of the i^{th} array in the set, where 1 ≤ i ≤ M^{N}.
Find t... | def pow(bg, num):
count = 1
while num:
if num % 2 == 1:
count = count * bg % 998244353
bg = bg * bg % 998244353
num //= 2
return count
def coun(arg1, arg2):
return (arg1 // (1 << arg2 + 1) << arg2) + max(
0, arg1 % (1 << arg2 + 1) - (1 << arg2) + 1
)
f... | FUNC_DEF ASSIGN VAR NUMBER WHILE VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER RETURN VAR FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBE... |
Given two positive integers N and M, let S denote the set of all the arrays of size N such that each element of the array lies in the range [1, M]. Since there are M^{N} such arrays, the size of S is M^{N}.
Let X_{i} denote the [bitwise AND] of all elements of the i^{th} array in the set, where 1 ≤ i ≤ M^{N}.
Find t... | def fast_mod_exp(n, exp, mod):
if exp == 0:
return 1 % mod
b = binary(exp, 0)
res = 1
current = n
for i in range(len(b)):
if b[len(b) - i - 1] == 1:
res *= current
res %= mod
current *= current
current %= mod
return res
def binary(n, min_... | FUNC_DEF IF VAR NUMBER RETURN BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER VAR VAR VAR VAR VAR VAR VAR VAR RETURN VAR FUNC_DEF IF VAR NUMBER RETURN LIST NUMBER ASSIGN VAR LIST WHILE... |
Given two positive integers N and M, let S denote the set of all the arrays of size N such that each element of the array lies in the range [1, M]. Since there are M^{N} such arrays, the size of S is M^{N}.
Let X_{i} denote the [bitwise AND] of all elements of the i^{th} array in the set, where 1 ≤ i ≤ M^{N}.
Find t... | P = 998244353
def max_set_bit(n: int):
k = 0
while n:
n >>= 1
k += 1
return k - 1
def numbers_with_kth_bit_set(M: int, k: int):
M += 1
b = 1 << k
n = M // b
return n // 2 * b + M % b * (n % 2)
def mod_pow(b, e, p):
ans = 1
while e > 0:
if e % 2:
... | ASSIGN VAR NUMBER FUNC_DEF VAR ASSIGN VAR NUMBER WHILE VAR VAR NUMBER VAR NUMBER RETURN BIN_OP VAR NUMBER FUNC_DEF VAR VAR VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR VAR RETURN BIN_OP BIN_OP BIN_OP VAR NUMBER VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER IF B... |
Given two positive integers N and M, let S denote the set of all the arrays of size N such that each element of the array lies in the range [1, M]. Since there are M^{N} such arrays, the size of S is M^{N}.
Let X_{i} denote the [bitwise AND] of all elements of the i^{th} array in the set, where 1 ≤ i ≤ M^{N}.
Find t... | def get_possibilities(M):
result = [0] * M.bit_length()
bits = [b for b in f"{M:b}"]
for i, b in enumerate(bits):
if b == "1":
result[i] += 1
if i == M.bit_length():
break
factor = 1 << M.bit_length() - i - 1
resid = M % factor
... | FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR ASSIGN VAR VAR VAR VAR STRING FOR VAR VAR FUNC_CALL VAR VAR IF VAR STRING VAR VAR NUMBER IF VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR V... |
Given two positive integers N and M, let S denote the set of all the arrays of size N such that each element of the array lies in the range [1, M]. Since there are M^{N} such arrays, the size of S is M^{N}.
Let X_{i} denote the [bitwise AND] of all elements of the i^{th} array in the set, where 1 ≤ i ≤ M^{N}.
Find t... | for i in range(int(input())):
n, m = map(int, input().split())
m1 = m
c = 1
xx = 1
while 1:
if m1 < xx:
c -= 1
break
elif m1 == xx:
break
c += 1
xx *= 2
ans = 0
p = 1
k = {}
h = 2
for y in range(0, c):
if... | 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 NUMBER ASSIGN VAR NUMBER WHILE NUMBER IF VAR VAR VAR NUMBER IF VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NU... |
Given two positive integers N and M, let S denote the set of all the arrays of size N such that each element of the array lies in the range [1, M]. Since there are M^{N} such arrays, the size of S is M^{N}.
Let X_{i} denote the [bitwise AND] of all elements of the i^{th} array in the set, where 1 ≤ i ≤ M^{N}.
Find t... | def coun(i, j):
return (i // (1 << j + 1) << j) + max(0, i % (1 << j + 1) - (1 << j) + 1)
def powe(b, n):
s = 1
while n:
if n % 2 == 1:
s = s * b % 998244353
b = b * b % 998244353
n = n // 2
return s
t = int(input())
for h in range(t):
n, m = map(int, input().... | FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBER BIN_OP NUMBER VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER WHILE VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NU... |
Given two positive integers N and M, let S denote the set of all the arrays of size N such that each element of the array lies in the range [1, M]. Since there are M^{N} such arrays, the size of S is M^{N}.
Let X_{i} denote the [bitwise AND] of all elements of the i^{th} array in the set, where 1 ≤ i ≤ M^{N}.
Find t... | MOD = 998244353
def K(m, i):
nai = 2**i
naii = nai * 2
return m // naii * nai + max(0, m % naii - (nai - 1))
for _ in range(int(input())):
n, m = map(int, input().split())
result = 0
for i in range(32):
result += pow(K(m, i), n, MOD) * 2**i
result %= MOD
print(result) | ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN BIN_OP BIN_OP BIN_OP VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR BIN_OP VAR 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 NUMBER FOR VAR F... |
Given two positive integers N and M, let S denote the set of all the arrays of size N such that each element of the array lies in the range [1, M]. Since there are M^{N} such arrays, the size of S is M^{N}.
Let X_{i} denote the [bitwise AND] of all elements of the i^{th} array in the set, where 1 ≤ i ≤ M^{N}.
Find t... | for _1 in range(int(input())):
n, m = map(int, input().split())
def ans(a, b):
return (a // (1 << b + 1) << b) + max(0, a % (1 << b + 1) - (1 << b) + 1)
def list1(c, d):
cou = 1
while d:
if d % 2 == 1:
cou = cou * c % 998244353
c = c * c % 99... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBER BIN_OP NUMBER VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER WHILE ... |
Given two positive integers N and M, let S denote the set of all the arrays of size N such that each element of the array lies in the range [1, M]. Since there are M^{N} such arrays, the size of S is M^{N}.
Let X_{i} denote the [bitwise AND] of all elements of the i^{th} array in the set, where 1 ≤ i ≤ M^{N}.
Find t... | mod = 998244353
for _ in range(int(input())):
n, m = map(int, input().split())
ans = 0
for bit in range(30):
ct = m // (2 << bit) * (1 << bit)
ct += max(0, m % (2 << bit) - (1 << bit) + 1)
ans += pow(ct, n, mod) << bit
print(ans % mod) | ASSIGN VAR 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 NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP NUMBER VAR BIN_OP NUMBER VAR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP BIN_OP VAR BIN_OP NUMBER VAR BIN_OP NUMBER V... |
Given two positive integers N and M, let S denote the set of all the arrays of size N such that each element of the array lies in the range [1, M]. Since there are M^{N} such arrays, the size of S is M^{N}.
Let X_{i} denote the [bitwise AND] of all elements of the i^{th} array in the set, where 1 ≤ i ≤ M^{N}.
Find t... | def count(i, j):
return (i // (1 << j + 1) << j) + max(0, i % (1 << j + 1) - (1 << j) + 1)
for _ in range(int(input())):
n, m = list(map(int, input().split()))
s = 0
for i in range(0, 32):
s += pow(count(m, i), n, 998244353) << i
print(s % 998244353) | FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBER BIN_OP NUMBER 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 NUMBER F... |
Given two positive integers N and M, let S denote the set of all the arrays of size N such that each element of the array lies in the range [1, M]. Since there are M^{N} such arrays, the size of S is M^{N}.
Let X_{i} denote the [bitwise AND] of all elements of the i^{th} array in the set, where 1 ≤ i ≤ M^{N}.
Find t... | t = int(input())
mod = 998244353
for _ in range(t):
n, m = map(int, input().split())
ans = 0
for bit in range(31):
k = m // (2 << bit) * (1 << bit) + max(0, m % (2 << bit) - (1 << bit) + 1)
ct = pow(k, n, mod)
ans = (ans + ct * (1 << bit)) % mod
print(ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP NUMBER VAR BIN_OP NUMBER VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP BIN_OP VAR BIN_OP NUMBER V... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.