description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
Chef has two non negative integers N and X. He now wants to find the number of integers K such that 0 ≤ K < N, and (N \oplus K) \And X = 0.
Note that \oplus denotes the bitwise XOR operator and \And denotes the bitwise AND operator.
Help Chef in finding the total required count.
------ Input Format ------
- The f... | def fun(n, v1, v2, f, dp):
if n == -1:
return 1
if dp[n][f] != -1:
return dp[n][f]
if f == 0:
if 1 << n & v1 and 1 << n & v2:
ans = fun(n - 1, v1, v2, 0, dp)
elif 1 << n & v1 and 1 << n & v2 == 0:
ans = fun(n - 1, v1, v2, 0, dp) + fun(n - 1, v1, v2, 1,... | FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR VAR VAR NUMBER RETURN VAR VAR VAR IF VAR NUMBER IF BIN_OP BIN_OP NUMBER VAR VAR BIN_OP BIN_OP NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR NUMBER VAR IF BIN_OP BIN_OP NUMBER VAR VAR BIN_OP BIN_OP NUMBER VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_O... |
Chef has two non negative integers N and X. He now wants to find the number of integers K such that 0 ≤ K < N, and (N \oplus K) \And X = 0.
Note that \oplus denotes the bitwise XOR operator and \And denotes the bitwise AND operator.
Help Chef in finding the total required count.
------ Input Format ------
- The f... | def prod(arr):
res = 1
for el in arr:
res *= el
return res
def to_binary(n, l):
if n == 0:
return [0] * l
res = []
while n > 0 or len(res) < l:
b = n % 2
n //= 2
res.append(b)
return list(reversed(res))
def get_values(n, x):
bn = to_binary(n, 3... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR VAR VAR RETURN VAR FUNC_DEF IF VAR NUMBER RETURN BIN_OP LIST NUMBER VAR ASSIGN VAR LIST WHILE VAR NUMBER FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN ... |
We are stacking blocks to form a pyramid. Each block has a color which is a one letter string, like `'Z'`.
For every block of color `C` we place not in the bottom row, we are placing it on top of a left block of color `A` and right block of color `B`. We are allowed to place the block there only if `(A, B, C)` is an... | class Solution:
def pourWater(self, heights, total, index):
if not heights or total <= 0 or index < 0 or index >= len(heights):
return heights
for _ in range(total):
left = -1
for i in range(index - 1, -1, -1):
if heights[i] > heights[i + 1]:
... | CLASS_DEF FUNC_DEF IF VAR VAR NUMBER VAR NUMBER VAR FUNC_CALL VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_... |
We are stacking blocks to form a pyramid. Each block has a color which is a one letter string, like `'Z'`.
For every block of color `C` we place not in the bottom row, we are placing it on top of a left block of color `A` and right block of color `B`. We are allowed to place the block there only if `(A, B, C)` is an... | class Solution:
def pourWater(self, heights, V, K):
for i in range(V):
if not self.fallLeft(K, heights):
if not self.fallRight(K, heights):
heights[K] += 1
return heights
def fallLeft(self, K, heights):
minBlock = K
for i in range... | CLASS_DEF FUNC_DEF FOR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR IF FUNC_CALL VAR VAR VAR VAR VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR VAR VAR ASSIGN VAR VAR IF VAR VAR VAR VAR IF VAR VAR RETURN NUMBER VAR VAR NUMBER RETURN NUMBER FUNC_DEF ASSIG... |
We define f(x)=\begin{cases} f(x \oplus reverse(x))+1 & \text{if } x \neq 0 \\ 0 & \text{otherwise} \end{cases}
Here, \oplus denotes the [bitwise XOR operation] and reverse is a function that takes a postive integer, reverses its binary representation (without any leading zeros) and returns the resulting number. For... | def main():
n = int(input())
mod = 998244353
if n == 1:
return 1
if n == 2:
return 4
if n == 3:
return 10
a = 10 * pow(2, n - 2, mod) + 2
b = 2 * pow(2, (n + 1) // 2, mod)
c = 2 * pow(2, n // 2, mod)
return (a - b - c) % mod
for _ in range(int(input())):
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP NUMBER FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER VAR ASSIGN... |
We define f(x)=\begin{cases} f(x \oplus reverse(x))+1 & \text{if } x \neq 0 \\ 0 & \text{otherwise} \end{cases}
Here, \oplus denotes the [bitwise XOR operation] and reverse is a function that takes a postive integer, reverses its binary representation (without any leading zeros) and returns the resulting number. For... | t = int(input())
mod = 998244353
while t:
t = t - 1
n = int(input())
if n == 1:
print(1)
elif n == 2:
print(4)
else:
if n % 2 == 0:
tot = (pow(2, n, mod) - 1) % mod
pal = 2 * (pow(2, n // 2, mod) - 1) % mod
nonpal = pow(2, n - 1, mod) % mod... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR NUMBER VAR VAR NUMBER VAR ASSIGN VAR B... |
We define f(x)=\begin{cases} f(x \oplus reverse(x))+1 & \text{if } x \neq 0 \\ 0 & \text{otherwise} \end{cases}
Here, \oplus denotes the [bitwise XOR operation] and reverse is a function that takes a postive integer, reverses its binary representation (without any leading zeros) and returns the resulting number. For... | from sys import setrecursionlimit, stdin
input = stdin.readline
mod = 998244353
def add(a, b):
return (a % mod + b % mod) % mod
def mul(a, b):
return a % mod * (b % mod) % mod
def sub(a, b):
return (a - b + mod) % mod
def answer():
if n == 1:
return 1
even = pow(2, n - 1, mod)
a... | ASSIGN VAR VAR ASSIGN VAR NUMBER FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC... |
Read problems statements in Mandarin chinese, Russian and Vietnamese as well.
Chef is baking a large cake! The cake consists of $N$ different ingredients numbered $1$ through $N$. Chef can choose how much of each ingredient to use in his cake recipe; let's denote the amount of the $i$-th ingredient used in the cake b... | import sys
t = int(input())
for _ in range(t):
n, k = input().strip().split(" ")
n, k = [int(n), int(k)]
i = 0
while 2**i <= k:
i += 1
ka = 2**i - 1
if k == 1:
for _ in range(n):
print(k, end=" ")
print()
continue
elif k == 2 and n % 2 != 0:
... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR LIST FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE BIN_OP NUMBER VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR ... |
Read problems statements in Mandarin chinese, Russian and Vietnamese as well.
Chef is baking a large cake! The cake consists of $N$ different ingredients numbered $1$ through $N$. Chef can choose how much of each ingredient to use in his cake recipe; let's denote the amount of the $i$-th ingredient used in the cake b... | for _ in range(int(input())):
n, k = [int(x) for x in input().split()]
if n == 1:
print(k)
continue
if k == 1:
ans = [1] * n
print(*ans)
continue
if k == 2:
if n & 1:
ans = [2]
for i in range(n - 1):
ans.append(1)
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR EXPR FUNC_CALL VAR VAR IF VAR NUMBER IF BIN_OP VAR NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXP... |
Read problems statements in Mandarin chinese, Russian and Vietnamese as well.
Chef is baking a large cake! The cake consists of $N$ different ingredients numbered $1$ through $N$. Chef can choose how much of each ingredient to use in his cake recipe; let's denote the amount of the $i$-th ingredient used in the cake b... | t = int(input())
for ijk in range(0, t):
n, k = map(int, input().strip().split())
bit = []
req = []
c = 0
length = 0
f = int(k)
while k != 0:
w = k % 2
length += 1
bit.append(w)
k = k // 2
if w == 0:
c += 1
req.append(1)
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR ASSI... |
Read problems statements in Mandarin chinese, Russian and Vietnamese as well.
Chef is baking a large cake! The cake consists of $N$ different ingredients numbered $1$ through $N$. Chef can choose how much of each ingredient to use in his cake recipe; let's denote the amount of the $i$-th ingredient used in the cake b... | t = int(input())
for _ in range(t):
n, k = map(int, input().split())
ans = []
if n % 2 == 0:
bo = ""
c = bin(k)[2:]
for i in c:
if i == "0":
bo += "1"
else:
bo += "0"
d = int(bo, 2)
for i in range(n - 2):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER FOR VAR VAR IF VAR STRING VAR STRING VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CAL... |
Read problems statements in Mandarin chinese, Russian and Vietnamese as well.
Chef is baking a large cake! The cake consists of $N$ different ingredients numbered $1$ through $N$. Chef can choose how much of each ingredient to use in his cake recipe; let's denote the amount of the $i$-th ingredient used in the cake b... | for _ in range(int(input())):
n, k = map(int, input().split())
if n == 1:
print(k)
elif k == 1:
for _ in range(n):
print(1, end=" ")
print()
elif n % 2 != 0 and k == 2:
for _ in range(n - 1):
print(1, end=" ")
print(2)
else:
ans... | 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 NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER STRING EXPR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR ... |
You are given a simple code of a function and you would like to know what it will return.
F(N, K, Answer, Operator, A[N]) returns int;
begin
for i=1..K do
for j=1..N do
Answer=(Answer operator A_{j})
return Answer
end
Here N, K, Answer and the value returned by the function F are integers; A is an array of N integer... | def solve():
n, k, answer = map(int, input().split())
array = list(map(int, input().split()))
operator = input()
if k == 0:
print(answer)
else:
if operator[0] == "X":
if k % 2 == 0:
pass
else:
for i in array:
... | FUNC_DEF ASSIGN VAR 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 IF VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER STRING IF BIN_OP VAR NUMBER NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER STRING FOR VAR VAR A... |
You are given a simple code of a function and you would like to know what it will return.
F(N, K, Answer, Operator, A[N]) returns int;
begin
for i=1..K do
for j=1..N do
Answer=(Answer operator A_{j})
return Answer
end
Here N, K, Answer and the value returned by the function F are integers; A is an array of N integer... | t = int(input())
for z in range(t):
N, K, Answer = map(int, input().split())
A = map(int, input().split())
operator = input().strip()
if K:
for a in A:
if operator == "OR":
Answer = Answer | a
elif operator == "XOR" and K % 2:
Answer = Answ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF VAR FOR VAR VAR IF VAR STRING ASSIGN VAR BIN_OP VAR VAR IF VAR STRING BIN_OP VAR NUMBER ASSIGN VAR BIN_... |
You are given a simple code of a function and you would like to know what it will return.
F(N, K, Answer, Operator, A[N]) returns int;
begin
for i=1..K do
for j=1..N do
Answer=(Answer operator A_{j})
return Answer
end
Here N, K, Answer and the value returned by the function F are integers; A is an array of N integer... | def fnc(n, k, answer, s, a):
for i in range(k):
for j in range(n):
if s == "XOR":
answer ^= a[j]
elif s == "OR":
answer |= a[j]
else:
answer &= a[j]
return answer
t = int(input())
for T in range(t):
n, k, answer = ... | FUNC_DEF FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR STRING VAR VAR VAR IF VAR STRING VAR VAR VAR VAR VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL V... |
You are given a simple code of a function and you would like to know what it will return.
F(N, K, Answer, Operator, A[N]) returns int;
begin
for i=1..K do
for j=1..N do
Answer=(Answer operator A_{j})
return Answer
end
Here N, K, Answer and the value returned by the function F are integers; A is an array of N integer... | test = int(input())
for t in range(test):
a, b, answer = map(int, input().strip().split())
seanswerond = list(map(int, input().strip().split()))
operation = input().strip()
if b == 0 or b % 2 == 0 and operation == "XOR":
print(answer)
else:
for i in seanswerond:
if operat... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER BIN_OP VAR NUMBER NUMBER VAR STRING EXPR FUNC_CALL VAR VAR... |
You are given a simple code of a function and you would like to know what it will return.
F(N, K, Answer, Operator, A[N]) returns int;
begin
for i=1..K do
for j=1..N do
Answer=(Answer operator A_{j})
return Answer
end
Here N, K, Answer and the value returned by the function F are integers; A is an array of N integer... | for _ in range(int(input())):
N, K, Ans = map(int, input().split())
A = list(map(int, input().split()))
oper = input()
Ans_0 = Ans
oper = oper.strip()
if K % 2 == 0:
m = 2
else:
m = 1
if oper == "AND":
for j in range(m):
for i in range(N):
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR 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 ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR STRING... |
You are given a simple code of a function and you would like to know what it will return.
F(N, K, Answer, Operator, A[N]) returns int;
begin
for i=1..K do
for j=1..N do
Answer=(Answer operator A_{j})
return Answer
end
Here N, K, Answer and the value returned by the function F are integers; A is an array of N integer... | for _ in range(int(input())):
n, k, answer = map(int, input().split())
a = list(map(int, input().split()))
o = input()
if k == 0:
print(answer)
else:
if o[0] == "X":
if k % 2:
for i in range(n):
answer ^= a[i]
elif o[0] == "O":
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR 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 IF VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER STRING IF BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR ... |
You are given a simple code of a function and you would like to know what it will return.
F(N, K, Answer, Operator, A[N]) returns int;
begin
for i=1..K do
for j=1..N do
Answer=(Answer operator A_{j})
return Answer
end
Here N, K, Answer and the value returned by the function F are integers; A is an array of N integer... | import sys
def input():
return sys.stdin.readline().strip()
def iinput():
return int(input())
def rinput():
return map(int, sys.stdin.readline().strip().split())
def get_list():
return list(map(int, sys.stdin.readline().strip().split()))
for _ in range(iinput()):
n, k, ans = rinput()
a... | IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR... |
You are given a simple code of a function and you would like to know what it will return.
F(N, K, Answer, Operator, A[N]) returns int;
begin
for i=1..K do
for j=1..N do
Answer=(Answer operator A_{j})
return Answer
end
Here N, K, Answer and the value returned by the function F are integers; A is an array of N integer... | for _ in range(int(input())):
n, k, a = map(int, input().split())
arr = map(int, input().split())
oper = input()
if not k:
print(a)
else:
if oper[0] == "X":
if k % 2 == 0:
pass
else:
for j in arr:
a = a ^ j
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF VAR EXPR FUNC_CALL VAR VAR IF VAR NUMBER STRING IF BIN_OP VAR NUMBER NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER ... |
You are given a simple code of a function and you would like to know what it will return.
F(N, K, Answer, Operator, A[N]) returns int;
begin
for i=1..K do
for j=1..N do
Answer=(Answer operator A_{j})
return Answer
end
Here N, K, Answer and the value returned by the function F are integers; A is an array of N integer... | testcases = int(input())
while testcases != 0:
N, K, answer = list(map(int, input().split()))
inputArray = list(map(int, input().split()))
operat = input()
if K == 0:
print(answer)
elif K % 2 == 0 and operat[0] == "X":
print(answer)
else:
if operat[0] == "X":
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR VAR 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 FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER STRING EXPR FUNC_CALL... |
You are given a simple code of a function and you would like to know what it will return.
F(N, K, Answer, Operator, A[N]) returns int;
begin
for i=1..K do
for j=1..N do
Answer=(Answer operator A_{j})
return Answer
end
Here N, K, Answer and the value returned by the function F are integers; A is an array of N integer... | for tc in range(int(input().strip())):
N, K, Ans = map(int, input().strip().split())
A = [int(x) for x in input().strip().split()]
op = input().strip()
for i in A:
if K > 0:
if op == "AND":
Ans = Ans & i
elif op == "OR":
Ans = Ans | i
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR FOR VAR VAR IF VAR NUMBER IF VAR STRING ASSIGN VAR BIN_OP VAR VAR IF VAR STRING ASSIGN ... |
You are given a simple code of a function and you would like to know what it will return.
F(N, K, Answer, Operator, A[N]) returns int;
begin
for i=1..K do
for j=1..N do
Answer=(Answer operator A_{j})
return Answer
end
Here N, K, Answer and the value returned by the function F are integers; A is an array of N integer... | t = int(input())
while t:
n, k, ans = map(int, input().strip().split())
a = list(map(int, input().strip().split()))
operator = input().strip()
if operator == "XOR":
if k > 0:
if k % 2 == 0:
ans = ans ^ 0
else:
for j in range(n):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF VAR STRING IF VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR... |
You are given a simple code of a function and you would like to know what it will return.
F(N, K, Answer, Operator, A[N]) returns int;
begin
for i=1..K do
for j=1..N do
Answer=(Answer operator A_{j})
return Answer
end
Here N, K, Answer and the value returned by the function F are integers; A is an array of N integer... | for _ in range(int(input())):
n, k, a = map(int, input().split())
l = list(map(int, input().split()))
s = input().strip()
if k == 0:
print(a)
else:
if s == "AND":
for x in l:
a = a & x
elif s == "OR":
for x in l:
a = a |... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR 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 FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR STRING FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR STRING FOR ... |
You are given a simple code of a function and you would like to know what it will return.
F(N, K, Answer, Operator, A[N]) returns int;
begin
for i=1..K do
for j=1..N do
Answer=(Answer operator A_{j})
return Answer
end
Here N, K, Answer and the value returned by the function F are integers; A is an array of N integer... | T = int(input())
for t in range(T):
n, k, ans = map(int, input().split())
arr = list(map(int, input().split()))
op = input().strip()
if op == "XOR":
k = k % 2
for j in range(k):
for i in range(n):
ans ^= arr[i]
else:
k = min(1, k)
for j in ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR 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 FUNC_CALL VAR IF VAR STRING ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR V... |
You are given a simple code of a function and you would like to know what it will return.
F(N, K, Answer, Operator, A[N]) returns int;
begin
for i=1..K do
for j=1..N do
Answer=(Answer operator A_{j})
return Answer
end
Here N, K, Answer and the value returned by the function F are integers; A is an array of N integer... | t = int(input())
while t > 0:
n, k, a = map(int, input().split())
l = list(map(int, input().split()))
s = input().strip()
if k > 0:
if s == "XOR":
if k % 2 != 0:
for i in l:
a ^= i
elif s == "AND":
for i in l:
a ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR 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 FUNC_CALL VAR IF VAR NUMBER IF VAR STRING IF BIN_OP VAR NUMBER NUMBER FOR VAR VAR VAR VAR IF VAR STRING FOR VAR VAR... |
You are given a simple code of a function and you would like to know what it will return.
F(N, K, Answer, Operator, A[N]) returns int;
begin
for i=1..K do
for j=1..N do
Answer=(Answer operator A_{j})
return Answer
end
Here N, K, Answer and the value returned by the function F are integers; A is an array of N integer... | T = int(input())
for i in range(T):
n, k, ans = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = input()
if k == 0:
print(ans)
else:
if b[0] == "A":
for i in a:
ans &= i
elif b[0] == "O":
for i in a:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR 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 FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER STRING FOR VAR VAR VAR VAR IF VAR NUMBER STRING FOR VAR V... |
You are given a simple code of a function and you would like to know what it will return.
F(N, K, Answer, Operator, A[N]) returns int;
begin
for i=1..K do
for j=1..N do
Answer=(Answer operator A_{j})
return Answer
end
Here N, K, Answer and the value returned by the function F are integers; A is an array of N integer... | T = int(input())
ans = []
for _ in range(T):
N, K, Ans = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
S = input().strip()
if S == "XOR":
x = A[0]
for i in range(1, N):
x ^= A[i]
if K % 2 != 0:
Ans ^= x
elif S == "AND":
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR 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 FUNC_CALL FUNC_CALL VAR IF VAR STRING ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR I... |
You are given a simple code of a function and you would like to know what it will return.
F(N, K, Answer, Operator, A[N]) returns int;
begin
for i=1..K do
for j=1..N do
Answer=(Answer operator A_{j})
return Answer
end
Here N, K, Answer and the value returned by the function F are integers; A is an array of N integer... | def f(N, K, ans, A, str1):
if str1 == "XOR":
if K > 0:
if K % 2 == 1:
for j in range(N):
ans = ans ^ A[j]
elif str1 == "AND":
if K > 0:
for j in range(N):
ans = ans & A[j]
elif K > 0:
for j in range(N):
... | FUNC_DEF IF VAR STRING IF VAR NUMBER IF BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR IF VAR STRING IF VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR IF VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VA... |
You are given a simple code of a function and you would like to know what it will return.
F(N, K, Answer, Operator, A[N]) returns int;
begin
for i=1..K do
for j=1..N do
Answer=(Answer operator A_{j})
return Answer
end
Here N, K, Answer and the value returned by the function F are integers; A is an array of N integer... | import sys
T = int(sys.stdin.readline())
Ans = ""
for t in range(T):
N, k, Answer = map(int, sys.stdin.readline().split())
A = list(map(int, sys.stdin.readline().split()))
Q = sys.stdin.readline().split()
for item in Q:
if item[0] == "A" or item[0] == "O" or item[0] == "X":
op = ite... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR 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 FUNC_CALL VAR FOR VAR VAR IF VAR NUMBER STRING VAR NUMBER STRING VAR NUMBER STRIN... |
You are given a simple code of a function and you would like to know what it will return.
F(N, K, Answer, Operator, A[N]) returns int;
begin
for i=1..K do
for j=1..N do
Answer=(Answer operator A_{j})
return Answer
end
Here N, K, Answer and the value returned by the function F are integers; A is an array of N integer... | 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 apply_op(op, A, n, ans):
for i in range(n):
if op == "AND":
ans &= A[i]
elif o... | 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 FOR VAR FUNC_CALL VAR VAR IF VAR STRING VAR VAR VAR IF VAR STRING VAR VAR VAR IF VAR STRING VAR V... |
You are given a simple code of a function and you would like to know what it will return.
F(N, K, Answer, Operator, A[N]) returns int;
begin
for i=1..K do
for j=1..N do
Answer=(Answer operator A_{j})
return Answer
end
Here N, K, Answer and the value returned by the function F are integers; A is an array of N integer... | def f(N, K, A, op, arr):
if K == 0:
return A
orig = A
for j in range(N):
if op == "XOR":
A = A ^ arr[j]
elif op == "AND":
A = A & arr[j]
elif op == "OR":
A = A | arr[j]
if op == "XOR" and K % 2 == 0:
return orig
return A
t... | FUNC_DEF IF VAR NUMBER RETURN VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR STRING ASSIGN VAR BIN_OP VAR VAR VAR IF VAR STRING ASSIGN VAR BIN_OP VAR VAR VAR IF VAR STRING ASSIGN VAR BIN_OP VAR VAR VAR IF VAR STRING BIN_OP VAR NUMBER NUMBER RETURN VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_... |
You are given a simple code of a function and you would like to know what it will return.
F(N, K, Answer, Operator, A[N]) returns int;
begin
for i=1..K do
for j=1..N do
Answer=(Answer operator A_{j})
return Answer
end
Here N, K, Answer and the value returned by the function F are integers; A is an array of N integer... | from sys import stdin, stdout
def sin():
return stdin.readline().rstrip()
def listInput():
return list(map(int, sin().split()))
def printBS(li):
if not li:
return
for i in range(len(li) - 1):
stdout.write("%d " % li[i])
stdout.write("%d\n" % li[-1])
t = int(sin())
for _ in ra... | FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR RETURN FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP STRING VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR... |
You are given a simple code of a function and you would like to know what it will return.
F(N, K, Answer, Operator, A[N]) returns int;
begin
for i=1..K do
for j=1..N do
Answer=(Answer operator A_{j})
return Answer
end
Here N, K, Answer and the value returned by the function F are integers; A is an array of N integer... | __author__ = "star-lord"
def calc(n, k, ans, op, array):
if k == 0 or k % 2 == 0 and op == "XOR":
return ans
else:
for element in array:
if op == "XOR":
ans ^= element
elif op == "AND":
ans &= element
else:
ans... | ASSIGN VAR STRING FUNC_DEF IF VAR NUMBER BIN_OP VAR NUMBER NUMBER VAR STRING RETURN VAR FOR VAR VAR IF VAR STRING VAR VAR IF VAR STRING VAR VAR VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR F... |
You are given a simple code of a function and you would like to know what it will return.
F(N, K, Answer, Operator, A[N]) returns int;
begin
for i=1..K do
for j=1..N do
Answer=(Answer operator A_{j})
return Answer
end
Here N, K, Answer and the value returned by the function F are integers; A is an array of N integer... | for _ in range(int(input())):
_, k, ans = map(int, input().split())
a = map(int, input().split())
op = input()
if not k or not k & 1 and op[0] == "X":
print(ans)
else:
for n in a:
if op[0] == "X":
ans ^= n
elif op[0] == "O":
ans... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF VAR BIN_OP VAR NUMBER VAR NUMBER STRING EXPR FUNC_CALL VAR VAR FOR VAR VAR IF VAR NUMBER STRING VAR VAR IF VAR NUMBER STRING VAR... |
You are given a simple code of a function and you would like to know what it will return.
F(N, K, Answer, Operator, A[N]) returns int;
begin
for i=1..K do
for j=1..N do
Answer=(Answer operator A_{j})
return Answer
end
Here N, K, Answer and the value returned by the function F are integers; A is an array of N integer... | def F(n, k, answer, op, a):
if k == 0:
return answer
op_cal = a[0]
if op == "XOR":
for i in a[1:]:
op_cal = op_cal ^ i
if k % 2 == 0:
op_cal = 0
answer = answer ^ op_cal
elif op == "AND":
for i in a[1:]:
op_cal = op_cal & i
... | FUNC_DEF IF VAR NUMBER RETURN VAR ASSIGN VAR VAR NUMBER IF VAR STRING FOR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR STRING FOR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR STRING FOR VAR VAR NUMBER ASSIGN VAR BIN_... |
Chef's last task in his internship requires him to construct 2 permutations, each having length N, such that the [bitwise AND] of each pair of elements at every index is the same.
Formally, if the permutations are A and B, then, the value A_{i} \& B_{i} must be constant over all 1≤ i ≤ N.
Help Chef by providing him 2... | import sys
def get_arr():
return list(map(int, sys.stdin.readline().strip().split()))
def get_ints():
return map(int, sys.stdin.readline().strip().split())
t = int(sys.stdin.readline())
for _ in range(t):
n = int(sys.stdin.readline())
if n == 1:
print(1)
print(1)
continue
... | IMPORT FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR 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 ... |
Chef's last task in his internship requires him to construct 2 permutations, each having length N, such that the [bitwise AND] of each pair of elements at every index is the same.
Formally, if the permutations are A and B, then, the value A_{i} \& B_{i} must be constant over all 1≤ i ≤ N.
Help Chef by providing him 2... | def convert(n):
ss = bin(n)[2:]
s = ""
for i in ss:
if i == "0":
s += "1"
else:
s += "0"
if int(s, 2) == 0:
s = "1" + s
return int(s, 2)
result = []
MAX = 4294967295
def solve(n):
A = [i for i in range(1, n + 1)]
B = [MAX for i in range(n, ... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR STRING FOR VAR VAR IF VAR STRING VAR STRING VAR STRING IF FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP STRING VAR RETURN FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR V... |
Chef's last task in his internship requires him to construct 2 permutations, each having length N, such that the [bitwise AND] of each pair of elements at every index is the same.
Formally, if the permutations are A and B, then, the value A_{i} \& B_{i} must be constant over all 1≤ i ≤ N.
Help Chef by providing him 2... | def is_2_pow(N):
return N == 1 or "0" not in bin(N - 1)[2:]
for _ in range(int(input())):
N = int(input())
if N == 1:
print(1)
print(1)
elif N % 2 == 0:
N_copy = N
ret = []
while N > 0:
l = len(bin(N)) - 2
start = (1 << l) - 1 - N
... | FUNC_DEF RETURN VAR NUMBER STRING FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR LIST WHILE VAR NUMBER ASSIGN VAR BIN_O... |
Chef's last task in his internship requires him to construct 2 permutations, each having length N, such that the [bitwise AND] of each pair of elements at every index is the same.
Formally, if the permutations are A and B, then, the value A_{i} \& B_{i} must be constant over all 1≤ i ≤ N.
Help Chef by providing him 2... | from sys import stdin
input = stdin.readline
for _ in range(int(input())):
N = int(input())
if N == 1:
print(1)
print(1)
continue
if N % 2 == 0:
N_copy = N
ret = []
while N > 0:
l = len(bin(N)) - 2
start = (1 << l) - 1 - N
... | ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR LIST WHILE VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP... |
Chef's last task in his internship requires him to construct 2 permutations, each having length N, such that the [bitwise AND] of each pair of elements at every index is the same.
Formally, if the permutations are A and B, then, the value A_{i} \& B_{i} must be constant over all 1≤ i ≤ N.
Help Chef by providing him 2... | def msb(x):
p = 1
while p <= x:
p <<= 1
return p
for t in range(int(input())):
n = int(input())
if n == 1:
a = ["1"]
b = a
else:
a = []
b = []
l = n
while l > 1:
p = msb(l) - 1
r = p >> 1
for i in range... | FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR LIST STRING ASSIGN VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR VAR WHILE VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VA... |
Chef's last task in his internship requires him to construct 2 permutations, each having length N, such that the [bitwise AND] of each pair of elements at every index is the same.
Formally, if the permutations are A and B, then, the value A_{i} \& B_{i} must be constant over all 1≤ i ≤ N.
Help Chef by providing him 2... | def f(n):
x = 1
while x <= n:
x <<= 1
return x - 1
t = int(input())
for _ in range(t):
n = int(input())
if n == 1:
print(1)
print(1)
elif n % 2 == 0:
ar = [(False) for i in range(f(n) + 1)]
x = f(n)
tm = n
for i in range(n, 0, -1):
... | FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER RETURN BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR 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 NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP FU... |
Chef's last task in his internship requires him to construct 2 permutations, each having length N, such that the [bitwise AND] of each pair of elements at every index is the same.
Formally, if the permutations are A and B, then, the value A_{i} \& B_{i} must be constant over all 1≤ i ≤ N.
Help Chef by providing him 2... | try:
t = int(input())
for _ in range(t):
n = int(input())
if n == 1:
print(1)
print(1)
elif n & 1:
print(-1)
else:
print(*[i for i in range(1, n + 1)])
B = []
num = n
while len(B) < num:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR 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 NUMBER IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR LIST ASSIGN VAR VAR WHILE ... |
Chef's last task in his internship requires him to construct 2 permutations, each having length N, such that the [bitwise AND] of each pair of elements at every index is the same.
Formally, if the permutations are A and B, then, the value A_{i} \& B_{i} must be constant over all 1≤ i ≤ N.
Help Chef by providing him 2... | def setBitNumber(n):
if n == 0:
return 0
msb = 0
n = int(n / 2)
while n > 0:
n = int(n / 2)
msb += 1
return 1 << msb
def find(n, a, b):
temp = setBitNumber(n) + 1
i = 0
while temp + i <= n:
a.append(temp + i)
b.append(temp - i - 3)
b.appe... | FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER RETURN BIN_OP NUMBER VAR FUNC_DEF ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR V... |
Chef's last task in his internship requires him to construct 2 permutations, each having length N, such that the [bitwise AND] of each pair of elements at every index is the same.
Formally, if the permutations are A and B, then, the value A_{i} \& B_{i} must be constant over all 1≤ i ≤ N.
Help Chef by providing him 2... | t = int(input())
for i in range(t):
n = int(input())
if n == 1:
print(1)
print(1)
continue
if n % 2:
print(-1)
continue
a = [(0) for i in range(n)]
b = [(0) for i in range(n)]
kk = 0
maxi = 1
while maxi * 2 <= n:
maxi = maxi * 2
vis = [... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR 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 NUMBER IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIG... |
Chef's last task in his internship requires him to construct 2 permutations, each having length N, such that the [bitwise AND] of each pair of elements at every index is the same.
Formally, if the permutations are A and B, then, the value A_{i} \& B_{i} must be constant over all 1≤ i ≤ N.
Help Chef by providing him 2... | import sys
input = sys.stdin.readline
M = int(1000000000.0) + 7
def bitflip(x):
bitx = bin(x)[2:]
ans = ""
for i in bitx:
if i == "0":
ans += "1"
else:
ans += "0"
return int(ans, 2)
def solve():
n = int(input())
if n == 1:
print(1)
pri... | IMPORT ASSIGN VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR STRING FOR VAR VAR IF VAR STRING VAR STRING VAR STRING RETURN FUNC_CALL VAR VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NU... |
Chef's last task in his internship requires him to construct 2 permutations, each having length N, such that the [bitwise AND] of each pair of elements at every index is the same.
Formally, if the permutations are A and B, then, the value A_{i} \& B_{i} must be constant over all 1≤ i ≤ N.
Help Chef by providing him 2... | def counter(n):
val = 0
c = 0
while n:
if n % 2 == 0:
val += 2**c
c += 1
n //= 2
return val
for _ in range(int(input())):
n = int(input())
if n == 1:
print(1)
print(1)
elif n % 2 == 0:
dict = [False] * (n + 1)
a = []
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR IF BIN_OP VAR NUMBER NUMBER VAR BIN_OP NUMBER VAR VAR NUMBER VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER NUMBER... |
Given a long integer $\boldsymbol{x}$, count the number of values of $\class{ML__boldsymbol}{\boldsymbol{a}}$ satisfying the following conditions:
$a\oplus x>x$
$0<a<x$
where $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{x}$ are long integers and $\oplus$ is the bitwise XOR operator.
You are given $\... | q = int(input())
for i in range(q):
x = int(input())
x = bin(x)[2:]
if "0" not in x:
print(0)
else:
n = len(x) - x.find("0")
total = 2**n - 1
ms = []
for i, b in enumerate(x[::-1]):
if i == n:
break
elif b == "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 NUMBER IF STRING VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VA... |
Given a long integer $\boldsymbol{x}$, count the number of values of $\class{ML__boldsymbol}{\boldsymbol{a}}$ satisfying the following conditions:
$a\oplus x>x$
$0<a<x$
where $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{x}$ are long integers and $\oplus$ is the bitwise XOR operator.
You are given $\... | import sys
q = int(input().strip())
for a0 in range(q):
x = int(input().strip())
zeros = pow(2, x.bit_length()) - 1 ^ x
print(zeros) | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR NUMBER FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR VAR |
Given a long integer $\boldsymbol{x}$, count the number of values of $\class{ML__boldsymbol}{\boldsymbol{a}}$ satisfying the following conditions:
$a\oplus x>x$
$0<a<x$
where $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{x}$ are long integers and $\oplus$ is the bitwise XOR operator.
You are given $\... | import sys
q = int(input().strip())
x = []
for a0 in range(q):
x.append(int(input().strip()))
for i in range(len(x)):
print(int("".join([str(1 - int(i)) for i in "{0:b}".format(x[i])]), 2)) | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR BIN_OP NUMBER FUNC_CALL VAR VAR VAR FUNC_CALL STRING VAR VAR ... |
Given a long integer $\boldsymbol{x}$, count the number of values of $\class{ML__boldsymbol}{\boldsymbol{a}}$ satisfying the following conditions:
$a\oplus x>x$
$0<a<x$
where $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{x}$ are long integers and $\oplus$ is the bitwise XOR operator.
You are given $\... | q = int(input().strip())
for a0 in range(q):
x = int(input().strip())
t = bin(x)[2:]
t = list(map(int, t.strip()))
for i in range(len(t)):
if t[i] == 0:
t[i] = 1
else:
t[i] = 0
x = "".join(map(str, t))
x = int(x, 2)
print(x) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER A... |
Given a long integer $\boldsymbol{x}$, count the number of values of $\class{ML__boldsymbol}{\boldsymbol{a}}$ satisfying the following conditions:
$a\oplus x>x$
$0<a<x$
where $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{x}$ are long integers and $\oplus$ is the bitwise XOR operator.
You are given $\... | import sys
def Cur(x, less, greater):
if less and greater:
return 2 ** len(x)
if not x:
return 0
ans = 0
for i in "01":
if not less and i > x[0]:
continue
if not greater and i == "1" and x[0] == "1":
continue
ans += Cur(x[1:], less or i <... | IMPORT FUNC_DEF IF VAR VAR RETURN BIN_OP NUMBER FUNC_CALL VAR VAR IF VAR RETURN NUMBER ASSIGN VAR NUMBER FOR VAR STRING IF VAR VAR VAR NUMBER IF VAR VAR STRING VAR NUMBER STRING VAR FUNC_CALL VAR VAR NUMBER VAR VAR VAR NUMBER VAR VAR STRING RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR NUMBER RETURN FUNC_CALL VAR VA... |
Given a long integer $\boldsymbol{x}$, count the number of values of $\class{ML__boldsymbol}{\boldsymbol{a}}$ satisfying the following conditions:
$a\oplus x>x$
$0<a<x$
where $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{x}$ are long integers and $\oplus$ is the bitwise XOR operator.
You are given $\... | q = int(input())
for i in range(q):
x = int(input())
s = 1
while s < x:
s *= 2
if s != x:
print(s - 1 - x)
else:
print(x - 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 NUMBER WHILE VAR VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER |
Given a long integer $\boldsymbol{x}$, count the number of values of $\class{ML__boldsymbol}{\boldsymbol{a}}$ satisfying the following conditions:
$a\oplus x>x$
$0<a<x$
where $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{x}$ are long integers and $\oplus$ is the bitwise XOR operator.
You are given $\... | import sys
q = int(input().strip())
for a0 in range(q):
x = int(input().strip())
a = bin(x)
a = a[2:]
a = a[::-1]
s = 0
for i in range(len(a)):
if a[i] == "0":
s += pow(2, i)
print(s) | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_C... |
Given a long integer $\boldsymbol{x}$, count the number of values of $\class{ML__boldsymbol}{\boldsymbol{a}}$ satisfying the following conditions:
$a\oplus x>x$
$0<a<x$
where $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{x}$ are long integers and $\oplus$ is the bitwise XOR operator.
You are given $\... | import sys
q = int(input().strip())
for a0 in range(q):
x = int(input().strip())
a = list(reversed(list(bin(x)[2:])))
counter = 0
for idx in range(len(a)):
if int(a[idx]) == 0:
counter += 2**idx
print(counter) | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR NUMBER VAR BIN_OP NUMBER VAR... |
Given a long integer $\boldsymbol{x}$, count the number of values of $\class{ML__boldsymbol}{\boldsymbol{a}}$ satisfying the following conditions:
$a\oplus x>x$
$0<a<x$
where $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{x}$ are long integers and $\oplus$ is the bitwise XOR operator.
You are given $\... | import sys
q = int(input().strip())
for a0 in range(q):
x = int(input().strip())
len_x = len(bin(x)) - 2
c = 0
for i in range(len_x - 1):
v = 1 << i
if x & v != v:
c += 2**i
val = x - 2 ** (len_x - 1) + 1
v = 1 << len_x - 1
if x & v != v:
c += val
pri... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR IF BIN_OP VAR VAR VAR VAR BIN_OP NUMBER VAR A... |
Given a long integer $\boldsymbol{x}$, count the number of values of $\class{ML__boldsymbol}{\boldsymbol{a}}$ satisfying the following conditions:
$a\oplus x>x$
$0<a<x$
where $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{x}$ are long integers and $\oplus$ is the bitwise XOR operator.
You are given $\... | import sys
q = int(input().strip())
for a0 in range(q):
x = int(input().strip())
s = 0
cnt = 0
while x > 0:
if x % 2 == 0:
s += int(pow(2, cnt))
cnt += 1
x = int(x / 2)
print(s) | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_C... |
Given a long integer $\boldsymbol{x}$, count the number of values of $\class{ML__boldsymbol}{\boldsymbol{a}}$ satisfying the following conditions:
$a\oplus x>x$
$0<a<x$
where $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{x}$ are long integers and $\oplus$ is the bitwise XOR operator.
You are given $\... | q = int(input())
for _ in range(q):
n = int(input())
b = 1
count = 0
while b < n:
if n & b == 0:
count += b
b <<= 1
print(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 NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR VAR NUMBER VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
Given a long integer $\boldsymbol{x}$, count the number of values of $\class{ML__boldsymbol}{\boldsymbol{a}}$ satisfying the following conditions:
$a\oplus x>x$
$0<a<x$
where $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{x}$ are long integers and $\oplus$ is the bitwise XOR operator.
You are given $\... | import sys
def greater_a(x):
result = 0
for i, d in enumerate(bin(x)[2:]):
if d == "0":
result += 2 ** len(bin(x)[2 + i + 1 :])
return result
q = int(input().strip())
for a0 in range(q):
x = int(input().strip())
print(greater_a(x)) | IMPORT FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER IF VAR STRING VAR BIN_OP NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP BIN_OP NUMBER VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR EXPR... |
Given a long integer $\boldsymbol{x}$, count the number of values of $\class{ML__boldsymbol}{\boldsymbol{a}}$ satisfying the following conditions:
$a\oplus x>x$
$0<a<x$
where $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{x}$ are long integers and $\oplus$ is the bitwise XOR operator.
You are given $\... | import sys
q = int(input().strip())
for a0 in range(q):
x = int(input().strip())
count = 0
term = 1
while x:
if x & 1 == 0:
count += term
term *= 2
x //= 2
print(count) | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR IF BIN_OP VAR NUMBER NUMBER VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR |
Given a long integer $\boldsymbol{x}$, count the number of values of $\class{ML__boldsymbol}{\boldsymbol{a}}$ satisfying the following conditions:
$a\oplus x>x$
$0<a<x$
where $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{x}$ are long integers and $\oplus$ is the bitwise XOR operator.
You are given $\... | import sys
q = int(input().strip())
for a0 in range(q):
x = int(input().strip())
s = "{0:b}".format(x)
n = len(s)
ans = 0
for i in range(n):
if s[i] == "0":
ans += 2 ** (n - 1 - i)
print(ans) | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL STRING VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR BIN_OP NUMBER BIN_OP BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR ... |
Given a long integer $\boldsymbol{x}$, count the number of values of $\class{ML__boldsymbol}{\boldsymbol{a}}$ satisfying the following conditions:
$a\oplus x>x$
$0<a<x$
where $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{x}$ are long integers and $\oplus$ is the bitwise XOR operator.
You are given $\... | import sys
def BinaryOf(x):
l = []
r = x
n = x
while n != 1:
r = n % 2
l.append(r)
n = n // 2
l.append(n)
return l
q = int(input().strip())
for a0 in range(q):
x = int(input().strip())
count = 0
l = BinaryOf(x)
index = []
for i in range(len(l)):
... | IMPORT FUNC_DEF ASSIGN VAR LIST ASSIGN VAR VAR ASSIGN VAR VAR WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR AS... |
Given a long integer $\boldsymbol{x}$, count the number of values of $\class{ML__boldsymbol}{\boldsymbol{a}}$ satisfying the following conditions:
$a\oplus x>x$
$0<a<x$
where $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{x}$ are long integers and $\oplus$ is the bitwise XOR operator.
You are given $\... | import sys
q = int(input().strip())
for a0 in range(q):
x = int(input().strip())
cnt = 0
for pos, bit in enumerate(bin(x)[::-1]):
if bit == "b":
break
if bit == "0":
cnt += int(2**pos)
print(cnt) | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER IF VAR STRING IF VAR STRING VAR FUNC_CALL VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR VAR |
Given a long integer $\boldsymbol{x}$, count the number of values of $\class{ML__boldsymbol}{\boldsymbol{a}}$ satisfying the following conditions:
$a\oplus x>x$
$0<a<x$
where $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{x}$ are long integers and $\oplus$ is the bitwise XOR operator.
You are given $\... | num_queries = int(input())
for each_query in range(num_queries):
count = digits = 0
num = int(input())
while num > 0:
if num & 1 == 0:
count += 1 << digits
digits += 1
num >>= 1
print(count) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR BIN_OP NUMBER VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR |
Given a long integer $\boldsymbol{x}$, count the number of values of $\class{ML__boldsymbol}{\boldsymbol{a}}$ satisfying the following conditions:
$a\oplus x>x$
$0<a<x$
where $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{x}$ are long integers and $\oplus$ is the bitwise XOR operator.
You are given $\... | import sys
q = int(input().strip())
for a0 in range(q):
x = int(input().strip())
q = bin(x)[2:]
c = ""
for i in q:
if i == "1":
c += "0"
else:
c += "1"
print(int(c, 2)) | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR STRING FOR VAR VAR IF VAR STRING VAR STRING VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER |
Given a long integer $\boldsymbol{x}$, count the number of values of $\class{ML__boldsymbol}{\boldsymbol{a}}$ satisfying the following conditions:
$a\oplus x>x$
$0<a<x$
where $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{x}$ are long integers and $\oplus$ is the bitwise XOR operator.
You are given $\... | import sys
def num_great_xors(n):
st_n = "{0:b}".format(n)
result = 0
for i in range(len(st_n)):
if st_n[-1 - i] == "0":
result += 2**i
return result
q = int(input().strip())
for a0 in range(q):
x = int(input().strip())
print(num_great_xors(x)) | IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL STRING VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR BIN_OP NUMBER VAR STRING VAR BIN_OP NUMBER VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_C... |
Given a long integer $\boldsymbol{x}$, count the number of values of $\class{ML__boldsymbol}{\boldsymbol{a}}$ satisfying the following conditions:
$a\oplus x>x$
$0<a<x$
where $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{x}$ are long integers and $\oplus$ is the bitwise XOR operator.
You are given $\... | import sys
q = int(input().strip())
for a0 in range(q):
x = int(input().strip())
b = bin(x)[2:]
print(2 ** len(b) - 1 - x) | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP NUMBER FUNC_CALL VAR VAR NUMBER VAR |
Given a long integer $\boldsymbol{x}$, count the number of values of $\class{ML__boldsymbol}{\boldsymbol{a}}$ satisfying the following conditions:
$a\oplus x>x$
$0<a<x$
where $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{x}$ are long integers and $\oplus$ is the bitwise XOR operator.
You are given $\... | import sys
q = int(input().strip())
for a0 in range(q):
x = int(input().strip())
a = 1
sum2 = 0
while x // a != 0:
a = a * 2
print(a - x - 1) | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER |
Given a long integer $\boldsymbol{x}$, count the number of values of $\class{ML__boldsymbol}{\boldsymbol{a}}$ satisfying the following conditions:
$a\oplus x>x$
$0<a<x$
where $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{x}$ are long integers and $\oplus$ is the bitwise XOR operator.
You are given $\... | import sys
q = int(input())
for i in range(q):
a = list(map(int, list("{0:b}".format(int(input())))))
ans = 0
n = len(a)
for i in range(n):
if not a[i]:
ans += 1 << n - i - 1
print(ans) | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR BIN_OP NUMBER BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL ... |
Given a long integer $\boldsymbol{x}$, count the number of values of $\class{ML__boldsymbol}{\boldsymbol{a}}$ satisfying the following conditions:
$a\oplus x>x$
$0<a<x$
where $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{x}$ are long integers and $\oplus$ is the bitwise XOR operator.
You are given $\... | import sys
q = int(input().strip())
for a0 in range(q):
x = int(input().strip())
y = bin(x)[2:]
z = "0b"
for c in y:
if c == "1":
z = z + "0"
else:
z = z + "1"
x = int(z, 2)
print(x) | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR STRING FOR VAR VAR IF VAR STRING ASSIGN VAR BIN_OP VAR STRING ASSIGN VAR BIN_OP VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL ... |
Given a long integer $\boldsymbol{x}$, count the number of values of $\class{ML__boldsymbol}{\boldsymbol{a}}$ satisfying the following conditions:
$a\oplus x>x$
$0<a<x$
where $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{x}$ are long integers and $\oplus$ is the bitwise XOR operator.
You are given $\... | import sys
q = int(input().strip())
for a0 in range(q):
x = int(input().strip())
count_a = 0
bx = bin(x)[2:]
for i in range(1, len(bx)):
if bx[i] == "1":
continue
count_a += 2 ** (len(bx[1:]) - i)
print(count_a) | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR STRING VAR BIN_OP NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER VAR EXPR FUNC_CALL V... |
Given a long integer $\boldsymbol{x}$, count the number of values of $\class{ML__boldsymbol}{\boldsymbol{a}}$ satisfying the following conditions:
$a\oplus x>x$
$0<a<x$
where $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{x}$ are long integers and $\oplus$ is the bitwise XOR operator.
You are given $\... | import sys
q = int(input().strip())
for a0 in range(q):
x = int(input().strip())
x_bin = bin(x)[2:]
res = 0
for i in range(1, len(x_bin)):
if not int(x_bin[-i]):
res += 2 ** (i - 1)
print(res) | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR VAR BIN_OP NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR |
Given a long integer $\boldsymbol{x}$, count the number of values of $\class{ML__boldsymbol}{\boldsymbol{a}}$ satisfying the following conditions:
$a\oplus x>x$
$0<a<x$
where $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{x}$ are long integers and $\oplus$ is the bitwise XOR operator.
You are given $\... | import sys
data = sys.stdin.read().splitlines()
for x in map(int, data[1:]):
y = 2 ** (len("{0:b}".format(x)) - 1) - 1
print(2 * y - x + 1) | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER BIN_OP FUNC_CALL VAR FUNC_CALL STRING VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP NUMBER VAR VAR NUMBER |
Given a long integer $\boldsymbol{x}$, count the number of values of $\class{ML__boldsymbol}{\boldsymbol{a}}$ satisfying the following conditions:
$a\oplus x>x$
$0<a<x$
where $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{x}$ are long integers and $\oplus$ is the bitwise XOR operator.
You are given $\... | def solve(n):
_bin = "{0:b}".format(n)
i = len(_bin) - 1
ans = 0
for bit in _bin:
if bit == "0":
ans += pow(2, i)
i -= 1
print(ans)
for i in range(int(input())):
solve(int(input())) | FUNC_DEF ASSIGN VAR FUNC_CALL STRING VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR FUNC_CALL VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR |
Given a long integer $\boldsymbol{x}$, count the number of values of $\class{ML__boldsymbol}{\boldsymbol{a}}$ satisfying the following conditions:
$a\oplus x>x$
$0<a<x$
where $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{x}$ are long integers and $\oplus$ is the bitwise XOR operator.
You are given $\... | import sys
q = int(input().strip())
for a0 in range(q):
x = int(input().strip())
bits = x.bit_length()
if 2**bits > x:
bits -= 1
num = x - 2**bits
print(x - (num * 2 + 1)) | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF BIN_OP NUMBER VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP BIN_OP VAR NUMBER NUMBER |
Given a long integer $\boldsymbol{x}$, count the number of values of $\class{ML__boldsymbol}{\boldsymbol{a}}$ satisfying the following conditions:
$a\oplus x>x$
$0<a<x$
where $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{x}$ are long integers and $\oplus$ is the bitwise XOR operator.
You are given $\... | import sys
q = int(input().strip())
for a0 in range(q):
count = 0
x = int(input().strip())
a = bin(x)
a = a[2:]
a = a[::-1]
c = -1
for i in a:
c = c + 1
if i == "0":
count = count + 2**c
print(count) | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR STRING ASSIGN VAR BIN_OP VAR BIN... |
Given a long integer $\boldsymbol{x}$, count the number of values of $\class{ML__boldsymbol}{\boldsymbol{a}}$ satisfying the following conditions:
$a\oplus x>x$
$0<a<x$
where $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{x}$ are long integers and $\oplus$ is the bitwise XOR operator.
You are given $\... | import sys
q = int(input().strip())
for a0 in range(q):
x = int(input().strip())
binary = list(bin(x))[2:]
binary.reverse()
summ = 0
for idx, item in enumerate(binary):
if item == "0":
summ += 2**idx
print(summ) | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR STRING VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR VAR |
Given a long integer $\boldsymbol{x}$, count the number of values of $\class{ML__boldsymbol}{\boldsymbol{a}}$ satisfying the following conditions:
$a\oplus x>x$
$0<a<x$
where $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{x}$ are long integers and $\oplus$ is the bitwise XOR operator.
You are given $\... | import sys
def torevbin(n):
b = ""
while n > 0:
b += str(n % 2)
n //= 2
return b
q = int(input().strip())
for a0 in range(q):
x = int(input().strip())
b = torevbin(x)
ans = 0
for i in range(len(b)):
if b[i] == "0":
ans += 2**i
print(ans) | IMPORT FUNC_DEF ASSIGN VAR STRING WHILE VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ... |
Given a long integer $\boldsymbol{x}$, count the number of values of $\class{ML__boldsymbol}{\boldsymbol{a}}$ satisfying the following conditions:
$a\oplus x>x$
$0<a<x$
where $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{x}$ are long integers and $\oplus$ is the bitwise XOR operator.
You are given $\... | import sys
q = int(input().strip())
for a0 in range(q):
c = 0
x = int(input().strip())
for i in range(35):
if 2**i - 1 >= x:
break
print(2**i - x - 1) | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP BIN_OP NUMBER VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP NUMBER VAR VAR NUMBER |
Given a long integer $\boldsymbol{x}$, count the number of values of $\class{ML__boldsymbol}{\boldsymbol{a}}$ satisfying the following conditions:
$a\oplus x>x$
$0<a<x$
where $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{x}$ are long integers and $\oplus$ is the bitwise XOR operator.
You are given $\... | import sys
q = int(input().strip())
for a0 in range(q):
x = int(input().strip())
temp = x
count = 0
while temp != 0:
temp = temp >> 1
count += 1
maxm = pow(2, count) - 1
print(maxm ^ x) | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR |
Given a long integer $\boldsymbol{x}$, count the number of values of $\class{ML__boldsymbol}{\boldsymbol{a}}$ satisfying the following conditions:
$a\oplus x>x$
$0<a<x$
where $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{x}$ are long integers and $\oplus$ is the bitwise XOR operator.
You are given $\... | def theGreatXOR(L, x):
if x in L:
return 0
i = 0
while L[i] < x and i < len(L) - 1:
i += 1
return L[i - 1] - (x - L[i - 1] - 1)
L = [
1,
3,
7,
15,
31,
63,
127,
255,
511,
1023,
2047,
4095,
8191,
16383,
32767,
65535,
131... | FUNC_DEF IF VAR VAR RETURN NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR NUMBER RETURN BIN_OP VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER... |
Given a long integer $\boldsymbol{x}$, count the number of values of $\class{ML__boldsymbol}{\boldsymbol{a}}$ satisfying the following conditions:
$a\oplus x>x$
$0<a<x$
where $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{x}$ are long integers and $\oplus$ is the bitwise XOR operator.
You are given $\... | import sys
def get_binary(n):
bn = str(bin(n))[2:]
return bn
def get_xor_vals(n):
cnt = 0
bn = get_binary(n)
l = len(bn)
for i in range(l):
if bn[i] == "0":
cnt = cnt + pow(2, l - 1 - i)
return cnt
q = int(input().strip())
for a0 in range(q):
x = int(input().str... | IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR BIN_OP VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR NUMBER VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_C... |
Given a long integer $\boldsymbol{x}$, count the number of values of $\class{ML__boldsymbol}{\boldsymbol{a}}$ satisfying the following conditions:
$a\oplus x>x$
$0<a<x$
where $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{x}$ are long integers and $\oplus$ is the bitwise XOR operator.
You are given $\... | import sys
totals = []
q = int(input().strip())
for a0 in range(q):
total = 0
x = int(input().strip())
length = len(bin(x)) - 2
for pos, val in enumerate(bin(x)[2:]):
if val == "0":
total += pow(2, length - pos - 1)
totals.append(total)
for i in totals:
print(i) | IMPORT ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER IF VAR STRING VAR FUNC_CALL VAR NUMBER BIN_OP B... |
Given a long integer $\boldsymbol{x}$, count the number of values of $\class{ML__boldsymbol}{\boldsymbol{a}}$ satisfying the following conditions:
$a\oplus x>x$
$0<a<x$
where $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{x}$ are long integers and $\oplus$ is the bitwise XOR operator.
You are given $\... | def bits(n):
m = 1
while m <= n:
yield n & m
m <<= 1
for _ in range(int(input())):
x = int(input())
mask = (1 << len(bin(x)) - 2) - 1
print(sum(bits(x ^ mask))) | FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR EXPR BIN_OP VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR |
Given a long integer $\boldsymbol{x}$, count the number of values of $\class{ML__boldsymbol}{\boldsymbol{a}}$ satisfying the following conditions:
$a\oplus x>x$
$0<a<x$
where $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{x}$ are long integers and $\oplus$ is the bitwise XOR operator.
You are given $\... | import sys
q = int(input().strip())
for a0 in range(q):
x = int(input().strip())
l = list(bin(x)[2:])
for i in range(len(l)):
if l[i] == "0":
l[i] = "1"
else:
l[i] = "0"
print(int("".join(l), 2)) | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR VAR STRING ASSIGN VAR VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC... |
Given a long integer $\boldsymbol{x}$, count the number of values of $\class{ML__boldsymbol}{\boldsymbol{a}}$ satisfying the following conditions:
$a\oplus x>x$
$0<a<x$
where $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{x}$ are long integers and $\oplus$ is the bitwise XOR operator.
You are given $\... | import sys
q = int(input().strip())
for a0 in range(q):
x = int(input().strip())
count = 0
for i in range(x.bit_length()):
mask = x >> 1
mask <<= 1
last_bit = x ^ mask
if last_bit == 0:
count += 2**i
x >>= 1
print(count) | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER VAR BIN_OP NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
Given a long integer $\boldsymbol{x}$, count the number of values of $\class{ML__boldsymbol}{\boldsymbol{a}}$ satisfying the following conditions:
$a\oplus x>x$
$0<a<x$
where $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{x}$ are long integers and $\oplus$ is the bitwise XOR operator.
You are given $\... | import sys
q = int(input().strip())
for a0 in range(q):
x = int(input().strip())
mask = 1
while mask < x:
mask += mask + 1
print(mask ^ x) | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR |
Given a long integer $\boldsymbol{x}$, count the number of values of $\class{ML__boldsymbol}{\boldsymbol{a}}$ satisfying the following conditions:
$a\oplus x>x$
$0<a<x$
where $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{x}$ are long integers and $\oplus$ is the bitwise XOR operator.
You are given $\... | q = int(input())
for _ in range(q):
x = bin(int(input()))[2:]
ans = 0
for i in range(len(x)):
tmp = len(x) - i - 1
if x[tmp] == "0":
ans += 2**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 FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER IF VAR VAR STRING VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR VAR |
Given a long integer $\boldsymbol{x}$, count the number of values of $\class{ML__boldsymbol}{\boldsymbol{a}}$ satisfying the following conditions:
$a\oplus x>x$
$0<a<x$
where $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{x}$ are long integers and $\oplus$ is the bitwise XOR operator.
You are given $\... | for _ in range(int(input())):
n = int(input())
s = bin(n)[2:][::-1]
try:
i = s.rindex("0") + 1
k = 2**i - 1
for j in range(0, i):
if s[j] == "1":
k -= 2**j
except ValueError:
k = 0
print(k) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR STRING NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING VAR BIN_OP NUMBER VAR VAR ASSIGN VAR NUMBER EXPR... |
Given a long integer $\boldsymbol{x}$, count the number of values of $\class{ML__boldsymbol}{\boldsymbol{a}}$ satisfying the following conditions:
$a\oplus x>x$
$0<a<x$
where $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{x}$ are long integers and $\oplus$ is the bitwise XOR operator.
You are given $\... | import sys
def es_potencia_de_dos(numero):
if numero < 1:
return False
return 0 == numero & numero - 1
q = int(input().strip())
for a0 in range(q):
x = int(input().strip())
if x < 2:
print(0)
elif x & x - 1 is 0:
print(x - 1)
else:
i = 1 << x.bit_length() - 1
... | IMPORT FUNC_DEF IF VAR NUMBER RETURN NUMBER RETURN NUMBER BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR ... |
Given a long integer $\boldsymbol{x}$, count the number of values of $\class{ML__boldsymbol}{\boldsymbol{a}}$ satisfying the following conditions:
$a\oplus x>x$
$0<a<x$
where $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{x}$ are long integers and $\oplus$ is the bitwise XOR operator.
You are given $\... | import sys
def c(x):
rv = 0
t = 1
while x > 0:
if x & 1 == 0:
rv += t
x >>= 1
t <<= 1
return rv
q = int(input().strip())
for a0 in range(q):
x = int(input().strip())
print(c(x)) | IMPORT FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR VAR VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR |
Given a long integer $\boldsymbol{x}$, count the number of values of $\class{ML__boldsymbol}{\boldsymbol{a}}$ satisfying the following conditions:
$a\oplus x>x$
$0<a<x$
where $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{x}$ are long integers and $\oplus$ is the bitwise XOR operator.
You are given $\... | import sys
def largestTwo(n):
return 2 ** (len(bin(n)[2:]) - 1)
q = int(input().strip())
values = []
dictionary = {}
for a0 in range(q):
x = int(input().strip())
if x in dictionary:
print(dictionary[x])
else:
twoPower = largestTwo(x)
modValue = x % twoPower
val = twoP... | IMPORT FUNC_DEF RETURN BIN_OP NUMBER BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN ... |
Given a long integer $\boldsymbol{x}$, count the number of values of $\class{ML__boldsymbol}{\boldsymbol{a}}$ satisfying the following conditions:
$a\oplus x>x$
$0<a<x$
where $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{x}$ are long integers and $\oplus$ is the bitwise XOR operator.
You are given $\... | import sys
q = int(input().strip())
for a0 in range(q):
x = int(input().strip())
xt = "{0:035b}".format(x)
at = "{0:035b}".format(a0)
st_inx = xt.index("1")
res = 0
for inx in range(st_inx + 1, len(xt)):
if xt[inx] == "0":
res += int(2 ** (len(xt) - 1 - inx))
print(res) | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL STRING VAR ASSIGN VAR FUNC_CALL STRING VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR STRING... |
Given a long integer $\boldsymbol{x}$, count the number of values of $\class{ML__boldsymbol}{\boldsymbol{a}}$ satisfying the following conditions:
$a\oplus x>x$
$0<a<x$
where $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{x}$ are long integers and $\oplus$ is the bitwise XOR operator.
You are given $\... | for _ in range(int(input())):
ans, t = 0, 1
for c in bin(int(input()))[:2:-1]:
ans += t * (c == "0")
t <<= 1
print(ans) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER NUMBER VAR BIN_OP VAR VAR STRING VAR NUMBER EXPR FUNC_CALL VAR VAR |
Given a long integer $\boldsymbol{x}$, count the number of values of $\class{ML__boldsymbol}{\boldsymbol{a}}$ satisfying the following conditions:
$a\oplus x>x$
$0<a<x$
where $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{x}$ are long integers and $\oplus$ is the bitwise XOR operator.
You are given $\... | import sys
q = int(input().strip())
for a0 in range(q):
x = int(input().strip())
count = 0
bi = []
while x != 0:
bi.insert(0, x % 2)
x = x // 2
l = len(bi)
for i in range(1, l):
if bi[i] == 0:
count += 2 ** (l - i - 1)
print(count) | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR NUMBER EXPR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF ... |
Given a long integer $\boldsymbol{x}$, count the number of values of $\class{ML__boldsymbol}{\boldsymbol{a}}$ satisfying the following conditions:
$a\oplus x>x$
$0<a<x$
where $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{x}$ are long integers and $\oplus$ is the bitwise XOR operator.
You are given $\... | import sys
def findXor(n):
binary = "{0:b}".format(n)
count = 0
for i in range(0, len(binary)):
if binary[i] == "0":
count += 2 ** (len(binary) - 1 - i)
print(count)
q = int(input().strip())
for a in range(q):
x = int(input().strip())
findXor(x) | IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL STRING VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR STRING VAR BIN_OP NUMBER BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_... |
Given a long integer $\boldsymbol{x}$, count the number of values of $\class{ML__boldsymbol}{\boldsymbol{a}}$ satisfying the following conditions:
$a\oplus x>x$
$0<a<x$
where $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{x}$ are long integers and $\oplus$ is the bitwise XOR operator.
You are given $\... | import sys
q = int(input().strip())
for a0 in range(q):
x = int(input().strip())
if x == 0 or x == 1:
print(0)
else:
bina = bin(x)[3:]
l = len(bina)
maxi = 2**l
ans = maxi - int(bina, 2) - 1
print(ans) | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR V... |
Given a long integer $\boldsymbol{x}$, count the number of values of $\class{ML__boldsymbol}{\boldsymbol{a}}$ satisfying the following conditions:
$a\oplus x>x$
$0<a<x$
where $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{x}$ are long integers and $\oplus$ is the bitwise XOR operator.
You are given $\... | import sys
q = int(input().strip())
for a0 in range(q):
x = int(input().strip())
x = bin(x)
x = x[2:]
x = [i for i in x]
x.reverse()
x = "".join(x)
S = 0
for i in range(0, len(x)):
if x[i] == "0":
S = S + 2**i
print(str(S)) | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL STRING VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR... |
Given a long integer $\boldsymbol{x}$, count the number of values of $\class{ML__boldsymbol}{\boldsymbol{a}}$ satisfying the following conditions:
$a\oplus x>x$
$0<a<x$
where $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{x}$ are long integers and $\oplus$ is the bitwise XOR operator.
You are given $\... | T = int(input())
for _ in range(0, T):
s = bin(int(input()))
cnt = 0
n = len(s)
for x in range(3, n):
if s[x] == "0":
cnt += 1 << n - 1 - x
print(cnt) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING VAR BIN_OP NUMBER BIN_OP BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR VAR |
Given a long integer $\boldsymbol{x}$, count the number of values of $\class{ML__boldsymbol}{\boldsymbol{a}}$ satisfying the following conditions:
$a\oplus x>x$
$0<a<x$
where $\class{ML__boldsymbol}{\boldsymbol{a}}$ and $\boldsymbol{x}$ are long integers and $\oplus$ is the bitwise XOR operator.
You are given $\... | import sys
q = int(input().strip())
for a0 in range(q):
x = int(input().strip())
x = bin(x)
l = [int(s) for s in x[2:]]
ans = 0
n = len(l)
for i in range(n):
if l[i] == 0:
ans += 2 ** (n - i - 1)
print(ans) | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR BIN_OP NUMBER BIN_OP ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.