description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
You are given positive integers $L$ and $R$. You have to find the sum
S=∑i=LR(L∧(L+1)∧…∧i),S=∑i=LR(L∧(L+1)∧…∧i),S = \sum_{i=L}^R \left(L \wedge (L+1) \wedge \ldots \wedge i\right) \,,
where $\wedge$ denotes the bitwise AND operation. Since the sum could be large, compute it modulo $10^9+7$.
-----Input-----
- The first... | from sys import stdin
mod = 1000 * 1000 * 1000 + 7
for i in range(int(stdin.readline())):
l, r = map(int, stdin.readline().split())
act = 0
req = 0
ans = 0
for i in range(60):
val = min(r - l + 1, req - act + 1)
val %= mod
if l & 1 << i:
ans += val * ((1 << i) % ... | ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER NUMBER NUMBER 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 ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VA... |
You are given positive integers $L$ and $R$. You have to find the sum
S=∑i=LR(L∧(L+1)∧…∧i),S=∑i=LR(L∧(L+1)∧…∧i),S = \sum_{i=L}^R \left(L \wedge (L+1) \wedge \ldots \wedge i\right) \,,
where $\wedge$ denotes the bitwise AND operation. Since the sum could be large, compute it modulo $10^9+7$.
-----Input-----
- The first... | t = int(input())
while t:
t -= 1
l, r = map(int, input().split())
ans = 0
for i in range(60):
if l >> i & 1 ^ 1:
continue
l2 = min((l >> i) + 1 << i, r + 1)
ans += (l2 - l) * (1 << i) % (10**9 + 7)
ans %= 10**9 + 7
print(ans % (10**9 + 7)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP BIN_OP BIN_OP VA... |
You are given positive integers $L$ and $R$. You have to find the sum
S=∑i=LR(L∧(L+1)∧…∧i),S=∑i=LR(L∧(L+1)∧…∧i),S = \sum_{i=L}^R \left(L \wedge (L+1) \wedge \ldots \wedge i\right) \,,
where $\wedge$ denotes the bitwise AND operation. Since the sum could be large, compute it modulo $10^9+7$.
-----Input-----
- The first... | def rand(l, r):
mod = 10**9 + 7
binary = bin(l)[2:]
a, b, res = 1, 0, 0
for i in range(len(binary) - 1, -1, -1):
if binary[i] == "1":
res += a * min(a - b, r - l + 1)
res %= mod
b += a
a *= 2
return res
for _ in range(int(input())):
a, b = ma... | FUNC_DEF ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF VAR VAR STRING VAR BIN_OP VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR VAR VAR VAR NUMBER RET... |
You are given positive integers $L$ and $R$. You have to find the sum
S=∑i=LR(L∧(L+1)∧…∧i),S=∑i=LR(L∧(L+1)∧…∧i),S = \sum_{i=L}^R \left(L \wedge (L+1) \wedge \ldots \wedge i\right) \,,
where $\wedge$ denotes the bitwise AND operation. Since the sum could be large, compute it modulo $10^9+7$.
-----Input-----
- The first... | t = int(input())
mod = 10**9 + 7
for _ in range(t):
l, r = map(int, input().split())
if l == r:
print(l % mod)
continue
a = bin(l)[2:]
b = bin(r)[2:]
a = "0" * (len(b) - len(a)) + a
ind = 0
while a[ind] == b[ind]:
ind += 1
ans = 0
cnt = 0
flag = 0
for ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP STRING BIN... |
You are given positive integers $L$ and $R$. You have to find the sum
S=∑i=LR(L∧(L+1)∧…∧i),S=∑i=LR(L∧(L+1)∧…∧i),S = \sum_{i=L}^R \left(L \wedge (L+1) \wedge \ldots \wedge i\right) \,,
where $\wedge$ denotes the bitwise AND operation. Since the sum could be large, compute it modulo $10^9+7$.
-----Input-----
- The first... | from sys import stdin
def solve():
for _ in range(int(stdin.readline())):
l, r = map(int, stdin.readline().split())
a = bin(l)[2:]
n = len(a)
ci, k, res = 0, 0, 0
for i in range(n):
if a[n - 1 - i] == "1":
k = l + (2**i - (2**i - 1 & l))
... | FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR BIN_OP BIN_OP VAR NUMBER VAR STRING ASSIGN VAR BIN_OP VAR BIN_OP B... |
You are given positive integers $L$ and $R$. You have to find the sum
S=∑i=LR(L∧(L+1)∧…∧i),S=∑i=LR(L∧(L+1)∧…∧i),S = \sum_{i=L}^R \left(L \wedge (L+1) \wedge \ldots \wedge i\right) \,,
where $\wedge$ denotes the bitwise AND operation. Since the sum could be large, compute it modulo $10^9+7$.
-----Input-----
- The first... | MVAL = 1000000007
def rangeand(low, hi):
ra = 0
p2 = 1
lmd = 0
ldv = low
hdv = hi
while p2 <= low:
thisbit = low & p2
p2 *= 2
ldv //= 2
hdv //= 2
if ldv == hdv:
ra += (hi + 1 - low) * (low - lmd) % MVAL
break
elif thisbit ... | ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER IF VAR VAR VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR VAR VAR IF VAR NUMBER VAR VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR ... |
You are given positive integers $L$ and $R$. You have to find the sum
S=∑i=LR(L∧(L+1)∧…∧i),S=∑i=LR(L∧(L+1)∧…∧i),S = \sum_{i=L}^R \left(L \wedge (L+1) \wedge \ldots \wedge i\right) \,,
where $\wedge$ denotes the bitwise AND operation. Since the sum could be large, compute it modulo $10^9+7$.
-----Input-----
- The first... | T = int(input())
for _ in range(T):
a, b = map(int, input().split())
a1 = a
b1 = b
p = a
ans = 0
x = 1
y = a - 1
z = a
while a > 0:
r = a % 2
if r == 1:
z = p + x - 1
if z <= b:
ans = ans + p * (z - y)
else:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR BI... |
You are given positive integers $L$ and $R$. You have to find the sum
S=∑i=LR(L∧(L+1)∧…∧i),S=∑i=LR(L∧(L+1)∧…∧i),S = \sum_{i=L}^R \left(L \wedge (L+1) \wedge \ldots \wedge i\right) \,,
where $\wedge$ denotes the bitwise AND operation. Since the sum could be large, compute it modulo $10^9+7$.
-----Input-----
- The first... | mod = 10**9 + 7
for _ in range(int(input())):
l, r = map(int, input().split())
z = 2
while z <= l:
z *= 2
if r > z:
r = z - 1
z = z // 2
ans = l
lb = bin(l).replace("0b", "")
for i in lb:
if i != "0":
h = l % z
h = z - h - 1
if ... | ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER 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 WHILE VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR S... |
Petya learned a new programming language CALPAS. A program in this language always takes one non-negative integer and returns one non-negative integer as well.
In the language, there are only three commands: apply a bitwise operation AND, OR or XOR with a given constant to the current integer. A program can contain an... | n = int(input())
a, b = 1023, 0
for _ in range(n):
c, d = input().split()
d = int(d)
if c == "|":
a, b = a | d, b | d
elif c == "&":
a, b = a & d, b & d
elif c == "^":
a, b = a ^ d, b ^ d
print("2\n| {}\n^ {}".format(a ^ b ^ 1023, a ^ 1023)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR STRING ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR IF VAR STRING ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR IF VAR STRING ASSIGN VAR VAR BIN_OP VAR ... |
Petya learned a new programming language CALPAS. A program in this language always takes one non-negative integer and returns one non-negative integer as well.
In the language, there are only three commands: apply a bitwise operation AND, OR or XOR with a given constant to the current integer. A program can contain an... | import sys
input = sys.stdin.readline
n = int(input())
start1 = 0
start2 = 1023
for _ in range(n):
a, b = map(str, input().split())
b = int(b)
if a == "|":
start1 = b | start1
start2 = b | start2
elif a == "^":
start1 = b ^ start1
start2 = b ^ start2
else:
st... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR STRING ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR STRING ASSIGN VAR BIN_OP VAR VAR ASSIG... |
Petya learned a new programming language CALPAS. A program in this language always takes one non-negative integer and returns one non-negative integer as well.
In the language, there are only three commands: apply a bitwise operation AND, OR or XOR with a given constant to the current integer. A program can contain an... | n = int(input())
m = 2**10 - 1
a = 0
b = m
for _ in range(n):
op, l = input().split()
v = int(l)
if op == "|":
a |= v
b |= v
elif op == "&":
a &= v
b &= v
else:
a ^= v
b ^= v
print(3)
print("&", a | b)
print("|", a & b)
print("^", a & (b ^ m)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR STRING VAR VAR VAR VAR IF VAR STRING VAR VAR VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR F... |
Petya learned a new programming language CALPAS. A program in this language always takes one non-negative integer and returns one non-negative integer as well.
In the language, there are only three commands: apply a bitwise operation AND, OR or XOR with a given constant to the current integer. A program can contain an... | from sys import stdin, stdout
def input():
return stdin.readline().strip()
def run_program(n, program):
for op, a in program:
assert op in "&|^"
if op == "&":
n = n & a
if op == "|":
n = n | a
if op == "^":
n = n ^ a
return n
N = int(... | FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF FOR VAR VAR VAR VAR STRING IF VAR STRING ASSIGN VAR BIN_OP VAR VAR IF VAR STRING ASSIGN VAR BIN_OP VAR VAR IF VAR STRING ASSIGN VAR BIN_OP VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR ... |
Petya learned a new programming language CALPAS. A program in this language always takes one non-negative integer and returns one non-negative integer as well.
In the language, there are only three commands: apply a bitwise operation AND, OR or XOR with a given constant to the current integer. A program can contain an... | import sys
n = int(sys.stdin.readline())
zero_result = 0
ones_result = 1023
while n > 0:
[op, val] = sys.stdin.readline().split(" ")
val = int(val)
n -= 1
if op == "&":
zero_result = zero_result & val
ones_result = ones_result & val
elif op == "|":
zero_result = zero_result ... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN LIST VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER IF VAR STRING ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR STRING ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VA... |
Petya learned a new programming language CALPAS. A program in this language always takes one non-negative integer and returns one non-negative integer as well.
In the language, there are only three commands: apply a bitwise operation AND, OR or XOR with a given constant to the current integer. A program can contain an... | from sys import stdin
data = stdin.readlines()
remain = -10
invert = -20
m = [remain] * 10
for i, st in enumerate(data):
if i == 0:
continue
op, x = st.strip().split()
x = int(x)
for j in range(10):
bit = x % 2
if op == "&" and bit == 0:
m[j] = 0
elif op == "... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR STRING VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR S... |
Petya learned a new programming language CALPAS. A program in this language always takes one non-negative integer and returns one non-negative integer as well.
In the language, there are only three commands: apply a bitwise operation AND, OR or XOR with a given constant to the current integer. A program can contain an... | n = int(input())
zero = 0
ones = 1023
for _ in range(n):
op, num = input().split()
num = int(num)
if op == "&":
zero &= num
ones &= num
elif op == "|":
zero |= num
ones |= num
else:
zero ^= num
ones ^= num
and_bits = 0
or_bits = 0
xor_bits = 0
for i in... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR STRING VAR VAR VAR VAR IF VAR STRING VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR... |
Petya learned a new programming language CALPAS. A program in this language always takes one non-negative integer and returns one non-negative integer as well.
In the language, there are only three commands: apply a bitwise operation AND, OR or XOR with a given constant to the current integer. A program can contain an... | from sys import stdin, stdout
n = int(stdin.readline())
a = list()
y = 0
for i in range(n):
oper, x = stdin.readline().split()
x = int(x)
a.append((oper, x))
if oper == "&":
y &= x
elif oper == "|":
y |= x
elif oper == "^":
y ^= x
AND = (1 << 10) - 1
OR = 0
XOR = 0
for k... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR IF VAR STRING VAR VAR IF VAR STRING VAR VAR IF VAR STRING VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIG... |
Petya learned a new programming language CALPAS. A program in this language always takes one non-negative integer and returns one non-negative integer as well.
In the language, there are only three commands: apply a bitwise operation AND, OR or XOR with a given constant to the current integer. A program can contain an... | def execute(prg, n):
for op, x in prg:
if op == "|":
n |= x
elif op == "&":
n &= x
elif op == "^":
n ^= x
return n
n = int(input())
prg = []
for i in range(n):
op, x = map(str, input().split())
x = int(x)
prg.append((op, x))
zeroes = exec... | FUNC_DEF FOR VAR VAR VAR IF VAR STRING VAR VAR IF VAR STRING VAR VAR IF VAR STRING VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR... |
Petya learned a new programming language CALPAS. A program in this language always takes one non-negative integer and returns one non-negative integer as well.
In the language, there are only three commands: apply a bitwise operation AND, OR or XOR with a given constant to the current integer. A program can contain an... | z = 0
o = 1023
n = int(input())
for i in range(n):
a, b = input().split()
b = int(b)
if a == "&":
z = z & b
o = o & b
if a == "^":
z = z ^ b
o = o ^ b
if a == "|":
z = z | b
o = o | b
z = "{:010b}".format(z)
o = "{:010b}".format(o)
an = 0
r = 0
xo = 0
... | ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR STRING ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR STRING ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR STRING ASSIG... |
Petya learned a new programming language CALPAS. A program in this language always takes one non-negative integer and returns one non-negative integer as well.
In the language, there are only three commands: apply a bitwise operation AND, OR or XOR with a given constant to the current integer. A program can contain an... | from sys import stdin
n = int(input())
s = []
c = 0
c1 = 1023
for i in range(n):
st, num = map(str, stdin.readline().split())
num = int(num)
if st == "&":
c &= num
c1 &= num
elif st == "|":
c |= num
c1 |= num
else:
c ^= num
c1 ^= num
xornum = ~c1
ornu... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR STRING VAR VAR VAR VAR IF VAR STRING VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR ... |
Petya learned a new programming language CALPAS. A program in this language always takes one non-negative integer and returns one non-negative integer as well.
In the language, there are only three commands: apply a bitwise operation AND, OR or XOR with a given constant to the current integer. A program can contain an... | q = int(input())
def calc(f):
ret1 = 0
ret2 = 1023
for op in f:
if op[0] == "&":
ret1 &= op[1]
ret2 &= op[1]
elif op[0] == "|":
ret1 |= op[1]
ret2 |= op[1]
elif op[0] == "^":
ret1 ^= op[1]
ret2 ^= op[1]
ret... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER STRING VAR VAR NUMBER VAR VAR NUMBER IF VAR NUMBER STRING VAR VAR NUMBER VAR VAR NUMBER IF VAR NUMBER STRING VAR VAR NUMBER VAR VAR NUMBER RETURN VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIG... |
Petya learned a new programming language CALPAS. A program in this language always takes one non-negative integer and returns one non-negative integer as well.
In the language, there are only three commands: apply a bitwise operation AND, OR or XOR with a given constant to the current integer. A program can contain an... | def fun(n1, o, n2):
if o == "|":
return n1 | n2
elif o == "&":
return n1 & n2
else:
return n1 ^ n2
def fun2(n):
l = [(0) for i in range(10)]
for i in range(9, -1, -1):
if 1 << i <= n:
l[i] = 1
n -= 1 << i
return l
n = int(input())
a = 0... | FUNC_DEF IF VAR STRING RETURN BIN_OP VAR VAR IF VAR STRING RETURN BIN_OP VAR VAR RETURN BIN_OP VAR VAR FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF BIN_OP NUMBER VAR VAR ASSIGN VAR VAR NUMBER VAR BIN_OP NUMBER VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASS... |
Petya learned a new programming language CALPAS. A program in this language always takes one non-negative integer and returns one non-negative integer as well.
In the language, there are only three commands: apply a bitwise operation AND, OR or XOR with a given constant to the current integer. A program can contain an... | def simu(P, i):
for c, x in P:
if c == "&":
i &= x
elif c == "|":
i |= x
else:
i ^= x
return i
def simpl(P):
out0, out1 = simu(P, 0), simu(P, 1023)
A, O, X = 1023, 0, 0
for i in range(10):
B01 = out0 >> i & 1, out1 >> i & 1
... | FUNC_DEF FOR VAR VAR VAR IF VAR STRING VAR VAR IF VAR STRING VAR VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER IF VAR NUMBER NUMBER... |
Petya learned a new programming language CALPAS. A program in this language always takes one non-negative integer and returns one non-negative integer as well.
In the language, there are only three commands: apply a bitwise operation AND, OR or XOR with a given constant to the current integer. A program can contain an... | def solve():
n = int(input())
a = 0
b = 1023
for i in range(n):
op, k = input().split()
k = int(k)
if op == "|":
a |= k
b |= k
if op == "^":
a ^= k
b ^= k
if op == "&":
a &= k
b &= k
p = 1... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR STRING VAR VAR VAR VAR IF VAR STRING VAR VAR VAR VAR IF VAR STRING VAR VAR VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN V... |
Petya learned a new programming language CALPAS. A program in this language always takes one non-negative integer and returns one non-negative integer as well.
In the language, there are only three commands: apply a bitwise operation AND, OR or XOR with a given constant to the current integer. A program can contain an... | import sys
n = int(sys.stdin.readline())
zero_model, one_model = 0, (1 << 10) - 1
commands = []
for i in range(n):
c, k = sys.stdin.readline()[:-1].split()
k = int(k)
commands.append((c, k))
def process(n, commands):
for comm in commands:
c, k = comm
if c == "|":
n |= k
... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR FUNC_DEF FOR VAR VAR ASSIGN VAR VAR VAR IF VAR STRING VAR VAR IF VAR STRI... |
Petya learned a new programming language CALPAS. A program in this language always takes one non-negative integer and returns one non-negative integer as well.
In the language, there are only three commands: apply a bitwise operation AND, OR or XOR with a given constant to the current integer. A program can contain an... | from sys import stdin
BITCOUNT = 10
xONES = (1 << 10) - 1
xZEROS = 0
n = int(stdin.readline())
for i in range(n):
op, num = stdin.readline().split()
num = int(num)
if op == "&":
xONES &= num
xZEROS &= num
elif op == "|":
xONES |= num
xZEROS |= num
else:
xONES... | ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR STRING VAR VAR VAR VAR IF VAR STRING VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR ... |
Petya learned a new programming language CALPAS. A program in this language always takes one non-negative integer and returns one non-negative integer as well.
In the language, there are only three commands: apply a bitwise operation AND, OR or XOR with a given constant to the current integer. A program can contain an... | n = int(input())
mask_ans1 = 1023
mask_ans2 = 0
for i in range(n):
com, x = input().split()
x = int(x)
if com == "&":
mask_ans1 &= x
mask_ans2 &= x
elif com == "|":
mask_ans1 |= x
mask_ans2 |= x
elif com == "^":
mask_ans1 ^= x
mask_ans2 ^= x
ans11 = 10... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR STRING VAR VAR VAR VAR IF VAR STRING VAR VAR VAR VAR IF VAR STRING VAR VAR VAR VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP... |
Petya learned a new programming language CALPAS. A program in this language always takes one non-negative integer and returns one non-negative integer as well.
In the language, there are only three commands: apply a bitwise operation AND, OR or XOR with a given constant to the current integer. A program can contain an... | from sys import stdin, stdout
class Solve:
def __init__(self):
R = stdin.readline
W = stdout.write
n = int(input())
z, o = 0, 1023
for i in range(n):
op, x = R().split()
x = int(x)
if op == "|":
z |= x
o |... | CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR STRING VAR VAR VAR VAR IF VAR STRING VAR VAR VAR VAR IF VAR STRING VAR VAR VAR VAR ASSIGN VAR DICT STR... |
Petya learned a new programming language CALPAS. A program in this language always takes one non-negative integer and returns one non-negative integer as well.
In the language, there are only three commands: apply a bitwise operation AND, OR or XOR with a given constant to the current integer. A program can contain an... | n = int(input())
A = 1023
B = 0
a = 1023
b = 0
print(4)
for i in range(n):
s = str(input())
if s[0] == "&":
a = a & int(s[2:])
b = b & int(s[2:])
elif s[0] == "|":
a = a | int(s[2:])
b = b | int(s[2:])
elif s[0] == "^":
a = a ^ int(s[2:])
b = b ^ int(s[2:]... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER STRING ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR NUMBER IF ... |
Petya learned a new programming language CALPAS. A program in this language always takes one non-negative integer and returns one non-negative integer as well.
In the language, there are only three commands: apply a bitwise operation AND, OR or XOR with a given constant to the current integer. A program can contain an... | n = int(input())
bits0 = [0] * 10
bits1 = [1] * 10
b0 = 0
b1 = 1023
fname = ["&", "|", "^"]
f = [[[0, 0], [0, 1]], [[0, 1], [1, 1]], [[0, 1], [1, 0]]]
for i in range(n):
s = input()
e = str(bin(int(s[2:])))
d = int(s[2:])
if s[0] == "^":
b0 = b0 ^ d
b1 = b1 ^ d
elif s[0] == "|":
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST STRING STRING STRING ASSIGN VAR LIST LIST LIST NUMBER NUMBER LIST NUMBER NUMBER LIST LIST NUMBER NUMBER LIST NUMBER NUMBER LIST LIST NUMBER NUMBER LIST NUM... |
Petya learned a new programming language CALPAS. A program in this language always takes one non-negative integer and returns one non-negative integer as well.
In the language, there are only three commands: apply a bitwise operation AND, OR or XOR with a given constant to the current integer. A program can contain an... | n = int(input())
a = 0
b = 1023
for i in range(n):
s, d = input().split()
d = int(d)
if s == "|":
a |= d
b |= d
elif s == "&":
a &= d
b &= d
elif s == "^":
a ^= d
b ^= d
ans = []
ans.append(("|", 1023 ^ a ^ b))
ans.append(("^", 1023 ^ b))
print(len(ans... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR STRING VAR VAR VAR VAR IF VAR STRING VAR VAR VAR VAR IF VAR STRING VAR VAR VAR VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR STRING BIN_OP BIN_OP NUMBE... |
Petya learned a new programming language CALPAS. A program in this language always takes one non-negative integer and returns one non-negative integer as well.
In the language, there are only three commands: apply a bitwise operation AND, OR or XOR with a given constant to the current integer. A program can contain an... | n = int(input())
i0 = 0
i1 = 1023
for i in range(n):
cmd, ks = input().split()
k = int(ks)
if cmd == "&":
i0 &= k
i1 &= k
elif cmd == "|":
i0 |= k
i1 |= k
elif cmd == "^":
i0 ^= k
i1 ^= k
xor_i = 0
or_i = 0
and_i = 1023
for i in range(10):
b0 = i0 ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR STRING VAR VAR VAR VAR IF VAR STRING VAR VAR VAR VAR IF VAR STRING VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR... |
Petya learned a new programming language CALPAS. A program in this language always takes one non-negative integer and returns one non-negative integer as well.
In the language, there are only three commands: apply a bitwise operation AND, OR or XOR with a given constant to the current integer. A program can contain an... | def n2b(n):
b = bin(n)[2:]
r = 10 - len(b)
return list("0" * r + b)
def b2n(b):
return int("".join(b), 2)
def dump_encoded(s):
ops = []
op = "&"
b = ""
for i in range(10):
if s[i] == "0":
b += "0"
else:
b += "1"
ops.append((op, b2n(b)))
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP NUMBER FUNC_CALL VAR VAR RETURN FUNC_CALL VAR BIN_OP BIN_OP STRING VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL STRING VAR NUMBER FUNC_DEF ASSIGN VAR LIST ASSIGN VAR STRING ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR STRING VAR STRING VAR S... |
Petya learned a new programming language CALPAS. A program in this language always takes one non-negative integer and returns one non-negative integer as well.
In the language, there are only three commands: apply a bitwise operation AND, OR or XOR with a given constant to the current integer. A program can contain an... | a, b = 0, 1023
n = int(input())
for i in range(n):
l, r = input().split(" ")
r = int(r)
if l == "|":
a, b = a | r, b | r
elif l == "&":
a, b = a & r, b & r
elif l == "^":
a, b = a ^ r, b ^ r
print("3")
print("&", 1023 & a | b)
print("^", a & (1023 ^ b))
print("|", a & b) | ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR IF VAR STRING ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR IF VAR STRING ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR IF VAR STRING ASSIGN VAR VAR BIN_... |
Petya learned a new programming language CALPAS. A program in this language always takes one non-negative integer and returns one non-negative integer as well.
In the language, there are only three commands: apply a bitwise operation AND, OR or XOR with a given constant to the current integer. A program can contain an... | a, b = 0, 1023
n = int(input())
for i in range(n):
cmd = input()
c, x = cmd.split()
x = int(x)
if c == "|":
a, b = a | x, b | x
elif c == "&":
a, b = a & x, b & x
else:
a, b = a ^ x, b ^ x
x = 0
y = 1023
z = 0
for i in range(10):
a_i = a >> i & 1
b_i = b >> i & 1
... | ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR STRING ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR IF VAR STRING ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR BIN_OP VAR... |
Petya learned a new programming language CALPAS. A program in this language always takes one non-negative integer and returns one non-negative integer as well.
In the language, there are only three commands: apply a bitwise operation AND, OR or XOR with a given constant to the current integer. A program can contain an... | from sys import stdin
input = stdin.readline
def check(x, b, c):
if b == "|":
if c == "1":
return 1
else:
return x
elif b == "&":
if c == "1":
return x
else:
return 0
elif c == "1":
if x == 3:
return 2
... | ASSIGN VAR VAR FUNC_DEF IF VAR STRING IF VAR STRING RETURN NUMBER RETURN VAR IF VAR STRING IF VAR STRING RETURN VAR RETURN NUMBER IF VAR STRING IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIS... |
Petya learned a new programming language CALPAS. A program in this language always takes one non-negative integer and returns one non-negative integer as well.
In the language, there are only three commands: apply a bitwise operation AND, OR or XOR with a given constant to the current integer. A program can contain an... | import sys
n = int(sys.stdin.readline())
stat = [0] * 10
for i in range(n):
op, arg = sys.stdin.readline().split()
arg = int(arg)
if op == "&":
for j in range(10):
if arg & 1 << j == 0:
stat[j] = 3
elif op == "|":
for j in range(10):
if arg & 1 <<... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR STRING FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR BIN_OP NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR STRING FOR VAR FUNC_CALL VAR NUM... |
Petya learned a new programming language CALPAS. A program in this language always takes one non-negative integer and returns one non-negative integer as well.
In the language, there are only three commands: apply a bitwise operation AND, OR or XOR with a given constant to the current integer. A program can contain an... | import sys
input = sys.stdin.readline
n = int(input())
com = []
for _ in range(n):
l = input().split()
com.append((l[0], int(l[1])))
AND, OR, XOR = [], [], []
for i in range(10):
res1 = 0
res2 = 1
for s, n in com:
b = n >> i & 1
if s == "&":
res1 &= b
res2 &=... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR LIST LIST LIST FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR ASSIGN VAR B... |
Petya learned a new programming language CALPAS. A program in this language always takes one non-negative integer and returns one non-negative integer as well.
In the language, there are only three commands: apply a bitwise operation AND, OR or XOR with a given constant to the current integer. A program can contain an... | f = lambda t: t | k if s == "|" else t & k if s == "&" else t ^ k
a, b = 1023, 0
for i in range(int(input())):
s, k = input().split()
k = int(k)
a, b = f(a), f(b)
print("2\n|", b ^ a ^ 1023, "\n^", 1023 ^ a) | ASSIGN VAR VAR STRING BIN_OP VAR VAR VAR STRING BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING BIN_OP BIN_OP VAR ... |
Petya learned a new programming language CALPAS. A program in this language always takes one non-negative integer and returns one non-negative integer as well.
In the language, there are only three commands: apply a bitwise operation AND, OR or XOR with a given constant to the current integer. A program can contain an... | n = int(input())
queries = list(input().split() for _ in range(n))
a, b = 0, (1 << 10) - 1
for c, x in queries:
x = int(x)
if c == "|":
a, b = a | x, b | x
elif c == "&":
a, b = a & x, b & x
elif c == "^":
a, b = a ^ x, b ^ x
x, y, z = 0, (1 << 10) - 1, 0
for i in range(10):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER BIN_OP BIN_OP NUMBER NUMBER NUMBER FOR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR STRING ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR IF VAR STRING ASSIGN VAR VAR BIN_OP VAR VAR BIN_O... |
Petya learned a new programming language CALPAS. A program in this language always takes one non-negative integer and returns one non-negative integer as well.
In the language, there are only three commands: apply a bitwise operation AND, OR or XOR with a given constant to the current integer. A program can contain an... | from sys import *
d = {"|": lambda t: t | k, "&": lambda t: t & k, "^": lambda t: t ^ k}
a, b = 1023, 0
for i in range(int(input())):
s, q = stdin.readline().split()
k = int(q)
a = d[s](a)
b = d[s](b)
t = [2]
for u in range(1024):
for v in range(1024):
if 1023 ^ v == a and u ^ v == b:
... | ASSIGN VAR DICT STRING STRING STRING BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR LIST NUMBER FO... |
You are given an array A and an integer X. You are allowed to perform the following operation on the array:
Select two distinct indices i and j and set both A_{i} and A_{j} as ((A_{i} \oplus A_{j}) \mid X) simultaneously. Here \oplus and \mid denote the [bitwise XOR] and [bitwise OR] operations respectively.
Find the ... | for t in range(int(input())):
n, x = map(int, input().split())
l = list(map(int, input().split()))
e = 0
for i in l:
if i % 2 == 0:
e += 1
if x % 2 == 0 and len(l) - e == 0:
print(-1)
elif x % 2 == 1:
print((e + 1) // 2)
else:
print(e) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER IF BIN_OP VAR NUMBER NUMBER BIN_OP FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CAL... |
You are given an array A and an integer X. You are allowed to perform the following operation on the array:
Select two distinct indices i and j and set both A_{i} and A_{j} as ((A_{i} \oplus A_{j}) \mid X) simultaneously. Here \oplus and \mid denote the [bitwise XOR] and [bitwise OR] operations respectively.
Find the ... | t = int(input())
for _ in range(t):
n, x = map(int, input().split(" "))
arr = list(map(int, input().split(" ")))
even, odd = 0, 0
for ele in arr:
if ele % 2 == 0:
even += 1
else:
odd += 1
if x % 2 == 1:
if even % 2:
print(even // 2 + 1)
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER NUMBE... |
You are given an array A and an integer X. You are allowed to perform the following operation on the array:
Select two distinct indices i and j and set both A_{i} and A_{j} as ((A_{i} \oplus A_{j}) \mid X) simultaneously. Here \oplus and \mid denote the [bitwise XOR] and [bitwise OR] operations respectively.
Find the ... | z = int(input())
for _ in range(z):
n, x = map(int, input().split(" "))
count = 0
l = list(map(int, input().split(" ")))
even = 0
for a in l:
if a % 2 == 0:
even += 1
if even == n and x % 2 == 0:
print("-1")
elif even == 0:
print("0")
elif x % 2 == 0:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER N... |
You are given an array A and an integer X. You are allowed to perform the following operation on the array:
Select two distinct indices i and j and set both A_{i} and A_{j} as ((A_{i} \oplus A_{j}) \mid X) simultaneously. Here \oplus and \mid denote the [bitwise XOR] and [bitwise OR] operations respectively.
Find the ... | for _ in range(int(input())):
n, k = list(map(int, input().split()))
arr = list(map(int, input().split()))
c = 0
for i in range(n):
if arr[i] % 2 == 0:
c += 1
if c == 0:
print(0)
continue
if k % 2 == 1:
print((c + 1) // 2)
elif c == n:
prin... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER NUMBER VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BI... |
You are given an array A and an integer X. You are allowed to perform the following operation on the array:
Select two distinct indices i and j and set both A_{i} and A_{j} as ((A_{i} \oplus A_{j}) \mid X) simultaneously. Here \oplus and \mid denote the [bitwise XOR] and [bitwise OR] operations respectively.
Find the ... | t = int(input())
for i in range(t):
arr_det = input().split(" ")
arr = input().split(" ")
l_odd, l_even = [], []
for j in range(int(arr_det[0])):
if int(arr[j]) % 2 == 0:
l_even.append(int(arr[j]))
else:
l_odd.append(int(arr[j]))
if len(l_odd) == len(arr):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR LIST LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CA... |
You are given an array A and an integer X. You are allowed to perform the following operation on the array:
Select two distinct indices i and j and set both A_{i} and A_{j} as ((A_{i} \oplus A_{j}) \mid X) simultaneously. Here \oplus and \mid denote the [bitwise XOR] and [bitwise OR] operations respectively.
Find the ... | t = int(input())
for tt in range(t):
n, x = map(int, input().split())
l = list(map(int, input().split()))
even = 0
for i in l:
if i % 2 == 0:
even += 1
odd = n - even
if odd == n:
print("0")
elif x % 2 == 0:
if even == n:
print("-1")
el... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR VAR EXPR FUNC_CALL VAR STRING... |
You are given an array A and an integer X. You are allowed to perform the following operation on the array:
Select two distinct indices i and j and set both A_{i} and A_{j} as ((A_{i} \oplus A_{j}) \mid X) simultaneously. Here \oplus and \mid denote the [bitwise XOR] and [bitwise OR] operations respectively.
Find the ... | for i in range(int(input())):
n, x = map(int, input().split())
a = list(map(int, input().split()))
o = 0
e = 0
for i in range(n):
if a[i] % 2 == 0:
e += 1
else:
o += 1
if e == 0:
print(0)
elif o == 0 and x % 2 == 0:
print(-1)
elif x... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL V... |
You are given an array A and an integer X. You are allowed to perform the following operation on the array:
Select two distinct indices i and j and set both A_{i} and A_{j} as ((A_{i} \oplus A_{j}) \mid X) simultaneously. Here \oplus and \mid denote the [bitwise XOR] and [bitwise OR] operations respectively.
Find the ... | for _ in range(int(input())):
n, x = list(map(int, input().split()))
l = list(map(int, input().split()))
d = {}
d[0] = 0
d[1] = 0
for i in l:
d[i % 2] += 1
if d[0] == 0:
print(0)
elif x % 2 == 1:
if d[0] % 2 == 1:
d[0] += 1
c = d[0] // 2
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR VAR VAR BIN_OP VAR NUMBER NUMBER IF VAR NUMBER NUMBER EXPR... |
You are given an array A and an integer X. You are allowed to perform the following operation on the array:
Select two distinct indices i and j and set both A_{i} and A_{j} as ((A_{i} \oplus A_{j}) \mid X) simultaneously. Here \oplus and \mid denote the [bitwise XOR] and [bitwise OR] operations respectively.
Find the ... | t = int(input())
for _ in range(t):
n, x = map(int, input().split())
arr = list(map(int, input().lstrip().split()))
even = []
odd = []
count = 0
j = 0
k = len(odd) - 1
for i in range(n):
if arr[i] % 2 == 0:
even.append(arr[i])
else:
odd.append(arr[... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FU... |
You are given an array A and an integer X. You are allowed to perform the following operation on the array:
Select two distinct indices i and j and set both A_{i} and A_{j} as ((A_{i} \oplus A_{j}) \mid X) simultaneously. Here \oplus and \mid denote the [bitwise XOR] and [bitwise OR] operations respectively.
Find the ... | for t in range(int(input())):
n, x = [int(i) for i in input().split()]
ai = [int(i) for i in input().split()]
count = 0
for i in ai:
if i % 2 == 0:
count += 1
print(int((count + 1) / 2) if x % 2 != 0 else -1 if count == n else count) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER ... |
You are given an array A and an integer X. You are allowed to perform the following operation on the array:
Select two distinct indices i and j and set both A_{i} and A_{j} as ((A_{i} \oplus A_{j}) \mid X) simultaneously. Here \oplus and \mid denote the [bitwise XOR] and [bitwise OR] operations respectively.
Find the ... | for w in range(int(input())):
s1 = input().split()
s, x = int(s1[0]), int(s1[1])
arr = input().split()
evenc = 0
ans = 0
for i in arr:
if int(i) % 2 == 0:
evenc += 1
oc = s - evenc
if x % 2 == 0:
if oc > 0:
ans = evenc
else:
ans... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF BIN_O... |
You are given an array A and an integer X. You are allowed to perform the following operation on the array:
Select two distinct indices i and j and set both A_{i} and A_{j} as ((A_{i} \oplus A_{j}) \mid X) simultaneously. Here \oplus and \mid denote the [bitwise XOR] and [bitwise OR] operations respectively.
Find the ... | t = int(input())
for _ in range(t):
n, x = map(int, input().split())
l = list(map(int, input().split()))
odds = 0
for i in l:
if i % 2:
odds += 1
evens = n - odds
ans = -1
if x % 2:
ans = evens // 2
if evens % 2:
ans += 1
elif odds != 0:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER ASSI... |
You are given an array A and an integer X. You are allowed to perform the following operation on the array:
Select two distinct indices i and j and set both A_{i} and A_{j} as ((A_{i} \oplus A_{j}) \mid X) simultaneously. Here \oplus and \mid denote the [bitwise XOR] and [bitwise OR] operations respectively.
Find the ... | t = int(input())
for _ in range(t):
n, x = map(int, input().split())
l = list(map(int, input().split()))
o = len(list(filter(lambda x: x % 2 != 0, l)))
if o == len(l):
print(0)
elif x % 2 == 0:
if o > 0:
print(n - o)
else:
print(-1)
elif (n - o) % ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER VAR IF VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBE... |
You are given an array A and an integer X. You are allowed to perform the following operation on the array:
Select two distinct indices i and j and set both A_{i} and A_{j} as ((A_{i} \oplus A_{j}) \mid X) simultaneously. Here \oplus and \mid denote the [bitwise XOR] and [bitwise OR] operations respectively.
Find the ... | t = int(input())
for i in range(t):
n, x = map(int, input().split())
arr = list(map(int, input().split()))
count_even = 0
count_odd = 0
for i in arr:
if i % 2 == 0:
count_even += 1
else:
count_odd += 1
if count_even == n:
if x % 2:
if n... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER IF VAR VAR IF BIN_OP VAR NUMBER I... |
You are given an array A and an integer X. You are allowed to perform the following operation on the array:
Select two distinct indices i and j and set both A_{i} and A_{j} as ((A_{i} \oplus A_{j}) \mid X) simultaneously. Here \oplus and \mid denote the [bitwise XOR] and [bitwise OR] operations respectively.
Find the ... | for _ in range(int(input())):
n, x = map(int, input().split())
mao = [int(i) for i in input().split()]
even, odd = 0, 0
for num in mao:
if num % 2:
odd += 1
even = n - odd
if x % 2 == 0 and even == n:
print(-1)
elif even == 0:
print(0)
elif x & 1:
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR IF BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR VAR EXPR FUNC_CALL VAR NU... |
You are given an array A and an integer X. You are allowed to perform the following operation on the array:
Select two distinct indices i and j and set both A_{i} and A_{j} as ((A_{i} \oplus A_{j}) \mid X) simultaneously. Here \oplus and \mid denote the [bitwise XOR] and [bitwise OR] operations respectively.
Find the ... | for _ in range(int(input())):
N, X = map(int, input().split())
A = list(map(int, input().split()))
cnt_odd = sum([(1) for i in A if i % 2 == 1])
if cnt_odd == N:
print(0)
elif X % 2 == 0 and cnt_odd == 0:
print(-1)
elif X % 2 == 0 and cnt_odd != 0:
print(N - cnt_odd)
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER VAR VAR BIN_OP VAR NUMBER NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER EXPR ... |
You are given an array A and an integer X. You are allowed to perform the following operation on the array:
Select two distinct indices i and j and set both A_{i} and A_{j} as ((A_{i} \oplus A_{j}) \mid X) simultaneously. Here \oplus and \mid denote the [bitwise XOR] and [bitwise OR] operations respectively.
Find the ... | t = int(input())
while t > 0:
n, x = map(int, input().split())
a = [int(i) for i in input().split()]
o, e = 0, 0
for i in a:
if i & 1:
o += 1
else:
e += 1
if x & 1:
print(e % 2 + e // 2)
elif o == 0:
print(-1)
else:
print(e)
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR IF BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER B... |
You are given an array A and an integer X. You are allowed to perform the following operation on the array:
Select two distinct indices i and j and set both A_{i} and A_{j} as ((A_{i} \oplus A_{j}) \mid X) simultaneously. Here \oplus and \mid denote the [bitwise XOR] and [bitwise OR] operations respectively.
Find the ... | for _ in range(int(input())):
n, x = [int(x) for x in input().split()]
odds, evens = 0, 0
for i in input().split():
if int(i) % 2 == 1:
odds += 1
else:
evens += 1
if evens == 0:
print(0)
elif x % 2 == 1:
print(evens // 2 + evens % 2)
elif n... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL V... |
You are given an array A and an integer X. You are allowed to perform the following operation on the array:
Select two distinct indices i and j and set both A_{i} and A_{j} as ((A_{i} \oplus A_{j}) \mid X) simultaneously. Here \oplus and \mid denote the [bitwise XOR] and [bitwise OR] operations respectively.
Find the ... | t = int(input())
while t > 0:
n, x = list(map(int, input().split()))
a = list(map(int, input().split()))
codd = 0
for i in range(n):
if a[i] % 2 == 1:
codd += 1
if x % 2 == 1:
ans = (n - codd) // 2 + (n - codd) % 2
elif codd == 0:
ans = -1
else:
an... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN 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 NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER NUMBER VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR ... |
You are given an array A and an integer X. You are allowed to perform the following operation on the array:
Select two distinct indices i and j and set both A_{i} and A_{j} as ((A_{i} \oplus A_{j}) \mid X) simultaneously. Here \oplus and \mid denote the [bitwise XOR] and [bitwise OR] operations respectively.
Find the ... | for k in range(int(input())):
n, x = map(int, input().split())
a = list(map(int, input().split()))
even_count = 0
for i in a:
if i % 2 == 0:
even_count += 1
if x % 2 == 0:
if even_count == n:
print(-1)
else:
print(even_count)
elif x % 2... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER IF BIN_OP VAR NUMBER NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CA... |
You are given an array A and an integer X. You are allowed to perform the following operation on the array:
Select two distinct indices i and j and set both A_{i} and A_{j} as ((A_{i} \oplus A_{j}) \mid X) simultaneously. Here \oplus and \mid denote the [bitwise XOR] and [bitwise OR] operations respectively.
Find the ... | t = int(input())
while t:
n, x = map(int, input().split())
a = list(map(int, input().split()))
c = sum(p & 1 for p in a)
if x % 2 == 0:
if c >= 1:
print(n - c, end="\n")
else:
print(-1, end="\n")
else:
print((n - c) // 2 + (n - c) % 2, end="\n")
t ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR IF BIN_OP VAR NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR STRING EXPR FUNC_CAL... |
You are given an array A and an integer X. You are allowed to perform the following operation on the array:
Select two distinct indices i and j and set both A_{i} and A_{j} as ((A_{i} \oplus A_{j}) \mid X) simultaneously. Here \oplus and \mid denote the [bitwise XOR] and [bitwise OR] operations respectively.
Find the ... | for i in range(int(input())):
x, y = map(int, input().split())
l = list(map(int, input().split()))
e = 0
for i in range(x):
if l[i] % 2 == 0:
e = e + 1
if y % 2:
c = e // 2
if e % 2 == 0:
print(c)
else:
print(c + 1)
elif e == x:... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VA... |
You are given an array A and an integer X. You are allowed to perform the following operation on the array:
Select two distinct indices i and j and set both A_{i} and A_{j} as ((A_{i} \oplus A_{j}) \mid X) simultaneously. Here \oplus and \mid denote the [bitwise XOR] and [bitwise OR] operations respectively.
Find the ... | for i in range(int(input())):
n, x = map(int, input().split())
l = list(map(int, input().split()))
l1 = list(filter(lambda x: x % 2 == 0, l))
r1 = len(l1)
r2 = len(l) - r1
if n == 1:
if l[0] % 2 == 0:
print("-1")
else:
print("1")
exit()
if x % ... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR IF VAR NU... |
You are given an array A and an integer X. You are allowed to perform the following operation on the array:
Select two distinct indices i and j and set both A_{i} and A_{j} as ((A_{i} \oplus A_{j}) \mid X) simultaneously. Here \oplus and \mid denote the [bitwise XOR] and [bitwise OR] operations respectively.
Find the ... | for tc in range(int(input())):
n, k = map(int, input().split())
arr = list(map(int, input().split()))
e, o = 0, 0
for ele in arr:
if ele % 2 == 0:
e += 1
else:
o += 1
if k % 2 == 1:
if e % 2 == 0:
req = e // 2
else:
req ... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER... |
You are given an array A and an integer X. You are allowed to perform the following operation on the array:
Select two distinct indices i and j and set both A_{i} and A_{j} as ((A_{i} \oplus A_{j}) \mid X) simultaneously. Here \oplus and \mid denote the [bitwise XOR] and [bitwise OR] operations respectively.
Find the ... | for i in range(int(input())):
a, b = map(int, input().split())
l = list(map(int, input().split()))
counteven = 0
countodd = 0
for j in range(a):
if l[j] % 2 == 0:
counteven += 1
else:
countodd += 1
if counteven == 0:
print(0)
elif b % 2 == 0:
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL V... |
You are given an array A and an integer X. You are allowed to perform the following operation on the array:
Select two distinct indices i and j and set both A_{i} and A_{j} as ((A_{i} \oplus A_{j}) \mid X) simultaneously. Here \oplus and \mid denote the [bitwise XOR] and [bitwise OR] operations respectively.
Find the ... | testcases = int(input())
for eachcase in range(testcases):
length, x = map(int, input().split())
array = list(map(int, input().split()))
oddcount = 0
for nums in array:
if nums & 1:
oddcount += 1
evencount = length - oddcount
if evencount == length and x % 2 == 0:
pri... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR VAR BIN_OP VAR NUMBER NUMBER EXPR FU... |
You are given an array A and an integer X. You are allowed to perform the following operation on the array:
Select two distinct indices i and j and set both A_{i} and A_{j} as ((A_{i} \oplus A_{j}) \mid X) simultaneously. Here \oplus and \mid denote the [bitwise XOR] and [bitwise OR] operations respectively.
Find the ... | def makeOddg():
g1, g2, gc = 0, 0, 0
g1, g2 = map(int, input().split())
gupta = [int(g2) for g2 in input().split()]
for m in range(g1):
if gupta[m] % 2 == 0:
gc = gc + 1
if g2 % 2:
if gc % 2:
print(gc // 2 + 1)
else:
print(gc // 2)
elif... | FUNC_DEF ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BI... |
You are given an array A and an integer X. You are allowed to perform the following operation on the array:
Select two distinct indices i and j and set both A_{i} and A_{j} as ((A_{i} \oplus A_{j}) \mid X) simultaneously. Here \oplus and \mid denote the [bitwise XOR] and [bitwise OR] operations respectively.
Find the ... | def main():
n, X = map(int, input().split())
l = list(map(int, input().split()))
even = []
odd = []
for i in l:
if i % 2 == 1:
odd.append(i)
else:
even.append(i)
if len(even) == 0:
print(0)
elif X % 2 == 0:
if len(odd) == 0:
... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR N... |
You are given a set of $n$ ($n$ is always a power of $2$) elements containing all integers $0, 1, 2, \ldots, n-1$ exactly once.
Find $\frac{n}{2}$ pairs of elements such that:
Each element in the set is in exactly one pair.
The sum over all pairs of the bitwise AND of its elements must be exactly equal to $k$. Forma... | import sys
input = sys.stdin.readline
num_test_cases = int(input())
for test_case_ittr in range(num_test_cases):
n, target = [int(x) for x in input().split()]
if n == 4 and target == 3:
print(-1)
continue
range_max = n - 1
if target == range_max:
print(n - 1, n - 2)
prin... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP ... |
You are given a set of $n$ ($n$ is always a power of $2$) elements containing all integers $0, 1, 2, \ldots, n-1$ exactly once.
Find $\frac{n}{2}$ pairs of elements such that:
Each element in the set is in exactly one pair.
The sum over all pairs of the bitwise AND of its elements must be exactly equal to $k$. Forma... | test_case = int(input())
for i in range(test_case):
n, k = input().split()
n, k = int(n), int(k)
isvisited = set()
i = 0
if k == n - 1:
if n == 4:
print(-1)
else:
k -= 1
while i < n:
if i in isvisited:
i += 1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR NUMBER WHILE VAR VAR IF VAR VAR VAR NUMBER EXPR FUNC_... |
You are given a set of $n$ ($n$ is always a power of $2$) elements containing all integers $0, 1, 2, \ldots, n-1$ exactly once.
Find $\frac{n}{2}$ pairs of elements such that:
Each element in the set is in exactly one pair.
The sum over all pairs of the bitwise AND of its elements must be exactly equal to $k$. Forma... | for _ in range(int(input())):
n, k = map(int, input().split())
l = []
for i in range(int(n // 2)):
l.append([i, n - i - 1])
if n == 4 and k == 3:
print(-1)
continue
if k != n - 1:
if k < n / 2:
l[0][0], l[k][0] = l[k][0], l[0][0]
else:
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR LIST VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR BIN_OP VAR NUMBER IF VAR BIN... |
You are given a set of $n$ ($n$ is always a power of $2$) elements containing all integers $0, 1, 2, \ldots, n-1$ exactly once.
Find $\frac{n}{2}$ pairs of elements such that:
Each element in the set is in exactly one pair.
The sum over all pairs of the bitwise AND of its elements must be exactly equal to $k$. Forma... | for tc in range(int(input())):
n, m = map(int, input().split())
if m < n - 1:
print(m, n - 1)
for i in range(1, n // 2):
if i == m:
print(0, n - 1 - i)
elif i == n - m - 1:
print(0, i)
else:
print(i, n - 1 - i)
... | 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 BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR NUMBER VAR IF VAR BIN_OP BIN_OP VAR VAR NUMBE... |
You are given a set of $n$ ($n$ is always a power of $2$) elements containing all integers $0, 1, 2, \ldots, n-1$ exactly once.
Find $\frac{n}{2}$ pairs of elements such that:
Each element in the set is in exactly one pair.
The sum over all pairs of the bitwise AND of its elements must be exactly equal to $k$. Forma... | t = int(input())
while t > 0:
t -= 1
li = list(map(int, input().split()))
a = li[0]
b = li[1]
if a == 4 and b == 3:
print(-1)
continue
if a - b == 1:
print(a - 1, a // 2 - 1)
print(1, a // 2 - 2)
print(a // 2 + 1, a - 2)
print(0, a // 2)
li... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMB... |
You are given a set of $n$ ($n$ is always a power of $2$) elements containing all integers $0, 1, 2, \ldots, n-1$ exactly once.
Find $\frac{n}{2}$ pairs of elements such that:
Each element in the set is in exactly one pair.
The sum over all pairs of the bitwise AND of its elements must be exactly equal to $k$. Forma... | for i in range(int(input())):
n, k = map(int, input().split())
a = [int(x) for x in range(n)]
if k < n - 1:
print(k, n - 1)
if k != 0:
print(0, n - 1 - k)
for i in range(1, n // 2):
if i == k or i == n - 1 - k:
continue
print(i, n -... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBE... |
You are given a set of $n$ ($n$ is always a power of $2$) elements containing all integers $0, 1, 2, \ldots, n-1$ exactly once.
Find $\frac{n}{2}$ pairs of elements such that:
Each element in the set is in exactly one pair.
The sum over all pairs of the bitwise AND of its elements must be exactly equal to $k$. Forma... | def solve(n, k):
n = n - 1
pairs = [(i, n - i) for i in range(n // 2 + 1)]
if k == 0:
pass
elif k == n:
if n == 3:
return "-1"
pairs[0] = n - 1, n
pairs[1] = 1, 3
pairs[3] = n - 3, 0
elif k <= n // 2:
pairs[k] = k, n
pairs[0] = n - ... | FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR VAR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF VAR NUMBER IF VAR VAR IF VAR NUMBER RETURN STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VA... |
You are given a set of $n$ ($n$ is always a power of $2$) elements containing all integers $0, 1, 2, \ldots, n-1$ exactly once.
Find $\frac{n}{2}$ pairs of elements such that:
Each element in the set is in exactly one pair.
The sum over all pairs of the bitwise AND of its elements must be exactly equal to $k$. Forma... | t = int(input())
for _ in range(t):
n, k = map(int, input().strip().split())
if k == n - 1:
if n == 4:
print("-1")
continue
print(f"{n - 2} {n - 1}")
print(f"1 3")
print(f"0 {n - 4}")
print(f"2 {n - 3}")
for x in range(4, 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 FUNC_CALL VAR IF VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER STRING BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING BIN_OP VA... |
You are given a set of $n$ ($n$ is always a power of $2$) elements containing all integers $0, 1, 2, \ldots, n-1$ exactly once.
Find $\frac{n}{2}$ pairs of elements such that:
Each element in the set is in exactly one pair.
The sum over all pairs of the bitwise AND of its elements must be exactly equal to $k$. Forma... | for _ in range(int(input())):
n, k = map(int, input().split())
l = [i for i in range(n)]
if n == 4 and k == 3:
print(-1)
continue
if n - 1 == k:
l[0], l[k - 1] = l[k - 1], l[0]
l[k - 2], l[k - 1] = l[k - 1], l[k - 2]
else:
l[k], l[0] = l[0], l[k]
for i in ... | 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 VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBE... |
You are given a set of $n$ ($n$ is always a power of $2$) elements containing all integers $0, 1, 2, \ldots, n-1$ exactly once.
Find $\frac{n}{2}$ pairs of elements such that:
Each element in the set is in exactly one pair.
The sum over all pairs of the bitwise AND of its elements must be exactly equal to $k$. Forma... | for _ in range(int(input())):
n, k = map(int, input().split())
if n == 4 and k == 3:
print(-1)
continue
vis, ans = [0] * n, []
if k == n - 1:
k -= 3
ans.append([k, n - 1])
ans.append([n - 1 - k, 0])
vis[k] = vis[n - 1] = vis[n - 1 - k] = vis[0] = 1
... | 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 VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR BIN_OP LIST NUMBER VAR LIST IF VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR LIST VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR LIST BIN_OP BIN_OP... |
You are given a set of $n$ ($n$ is always a power of $2$) elements containing all integers $0, 1, 2, \ldots, n-1$ exactly once.
Find $\frac{n}{2}$ pairs of elements such that:
Each element in the set is in exactly one pair.
The sum over all pairs of the bitwise AND of its elements must be exactly equal to $k$. Forma... | t = int(input())
for _ in range(t):
n, k = map(int, input().split())
if k == n - 1:
if n == 4:
print(-1)
continue
print(0, 2)
print(1, n - 3)
for i in range(3, n // 2):
print(i, n - i - 1)
print(k, k - 1)
continue
use = [Fal... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC... |
You are given a set of $n$ ($n$ is always a power of $2$) elements containing all integers $0, 1, 2, \ldots, n-1$ exactly once.
Find $\frac{n}{2}$ pairs of elements such that:
Each element in the set is in exactly one pair.
The sum over all pairs of the bitwise AND of its elements must be exactly equal to $k$. Forma... | import sys
input = sys.stdin.readline
def inp():
return int(input())
def inlt():
return list(map(int, input().split()))
def insr():
s = input()
return list(s[: len(s) - 1])
def invr():
return map(int, input().split())
t = inp()
for _ in range(t):
[n, k] = inlt()
if k >= n:
... | IMPORT ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR RETURN FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR ... |
You are given a set of $n$ ($n$ is always a power of $2$) elements containing all integers $0, 1, 2, \ldots, n-1$ exactly once.
Find $\frac{n}{2}$ pairs of elements such that:
Each element in the set is in exactly one pair.
The sum over all pairs of the bitwise AND of its elements must be exactly equal to $k$. Forma... | t = int(input())
for _ in range(t):
n, k = map(int, input().split())
if k == 3 and n == 4:
print(-1)
elif k == n - 1:
print(n - 1, n - 2)
print(1, 3)
print(0, n - 1 - 3)
for j in range(n // 2):
if j == 0 or j == 1 or j == 3:
continue
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER BIN_OP B... |
You are given a set of $n$ ($n$ is always a power of $2$) elements containing all integers $0, 1, 2, \ldots, n-1$ exactly once.
Find $\frac{n}{2}$ pairs of elements such that:
Each element in the set is in exactly one pair.
The sum over all pairs of the bitwise AND of its elements must be exactly equal to $k$. Forma... | t = int(input())
for _ in range(t):
n, k = map(int, input().split())
arr1 = [i for i in range(n)]
if k == 0:
for i in range(n // 2):
print(arr1[i], arr1[n - i - 1])
if k > 0 and k < n - 1:
arr1[k & n - 1], arr1[0] = arr1[0], arr1[k & n - 1]
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 VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR ... |
You are given a set of $n$ ($n$ is always a power of $2$) elements containing all integers $0, 1, 2, \ldots, n-1$ exactly once.
Find $\frac{n}{2}$ pairs of elements such that:
Each element in the set is in exactly one pair.
The sum over all pairs of the bitwise AND of its elements must be exactly equal to $k$. Forma... | t = int(input())
for _ in range(t):
n, k = map(int, input().split())
if n == 4 and k == 3:
print(-1)
continue
if k == n - 1:
print(n - 1, n - 2)
print(1, 3)
print(0, n - 4)
for i in range(2, n // 2):
if i == 3:
pass
else... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER BIN_OP V... |
You are given a set of $n$ ($n$ is always a power of $2$) elements containing all integers $0, 1, 2, \ldots, n-1$ exactly once.
Find $\frac{n}{2}$ pairs of elements such that:
Each element in the set is in exactly one pair.
The sum over all pairs of the bitwise AND of its elements must be exactly equal to $k$. Forma... | for _ in range(int(input())):
n, k = list(map(int, input().split()))
mapping = {}
for i in range(n // 2):
mapping[i] = n - i - 1
if k == 0:
for key, val in mapping.items():
print(key, val)
elif k < n - 1:
print(k, n - 1)
print(0, n - k - 1)
for key... | 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 DICT FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR NUMBER FOR VAR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR IF VAR BIN_OP VAR NUMBER EXPR FU... |
You are given a set of $n$ ($n$ is always a power of $2$) elements containing all integers $0, 1, 2, \ldots, n-1$ exactly once.
Find $\frac{n}{2}$ pairs of elements such that:
Each element in the set is in exactly one pair.
The sum over all pairs of the bitwise AND of its elements must be exactly equal to $k$. Forma... | from sys import stdin, stdout
def decimalToBinary(n):
return bin(n).replace("0b", "")
for _ in range(int(stdin.readline())):
n, k = map(int, stdin.readline().split())
ans = []
if n == 4 and k == 3:
print("-1")
continue
aa = []
if k != n - 1 and k != 0:
ans.append([k, ... | FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR VAR STRING STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR LIST IF VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR LIST VAR BIN_OP V... |
You are given a set of $n$ ($n$ is always a power of $2$) elements containing all integers $0, 1, 2, \ldots, n-1$ exactly once.
Find $\frac{n}{2}$ pairs of elements such that:
Each element in the set is in exactly one pair.
The sum over all pairs of the bitwise AND of its elements must be exactly equal to $k$. Forma... | for t in range(int(input())):
n, k = map(int, input().split())
if n == 4 and k == 3:
print(-1)
else:
A = []
for i in range(n // 2):
A.append([i, n - i - 1])
if k == n - 1:
A[0][1], A[1][0] = A[1][0], A[0][1]
A[-1][1], A[-2][1] = A[-2][1], A... | 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 VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR LIST VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER... |
You are given a set of $n$ ($n$ is always a power of $2$) elements containing all integers $0, 1, 2, \ldots, n-1$ exactly once.
Find $\frac{n}{2}$ pairs of elements such that:
Each element in the set is in exactly one pair.
The sum over all pairs of the bitwise AND of its elements must be exactly equal to $k$. Forma... | def solve():
n, k = map(int, input().split())
if n == 4 and k == 3:
print(-1)
return
arr = []
for i in range(n // 2):
arr.append([i, n - 1 - i])
if k < n // 2:
arr[0][0], arr[k][0] = arr[k][0], arr[0][0]
elif k < n - 1:
arr[0][0], arr[n - 1 - k][1] = arr[n... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR LIST VAR BIN_OP BIN_OP VAR NUMBER VAR IF VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER VAR VAR NUMBER VAR VAR NUMBER VAR... |
You are given a set of $n$ ($n$ is always a power of $2$) elements containing all integers $0, 1, 2, \ldots, n-1$ exactly once.
Find $\frac{n}{2}$ pairs of elements such that:
Each element in the set is in exactly one pair.
The sum over all pairs of the bitwise AND of its elements must be exactly equal to $k$. Forma... | t = int(input())
while t:
t = t - 1
n, k = list(map(int, input().split()))
a = [1] * n
if k == n - 1:
if n == 4:
print(-1)
continue
p = 0
l1 = []
l2 = []
while 2**p < n:
l1 += [2**p]
l2 += [n - 1 - 2**p]
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR IF VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST WHILE BIN_OP NUMBER VA... |
You are given a set of $n$ ($n$ is always a power of $2$) elements containing all integers $0, 1, 2, \ldots, n-1$ exactly once.
Find $\frac{n}{2}$ pairs of elements such that:
Each element in the set is in exactly one pair.
The sum over all pairs of the bitwise AND of its elements must be exactly equal to $k$. Forma... | def solve(n, k):
if k == n - 1:
if n == 4:
print(-1)
else:
a = n >> 1
b = n >> 1 | n >> 2
for i in range(1, n // 2):
if i not in [a, b, n - 1 ^ a, n - 1 ^ b]:
print(i, n - 1 ^ i)
print(a, b)
p... | FUNC_DEF IF VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR LIST VAR VAR BIN_OP BIN_OP VAR NUMBER VAR BIN_OP BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR VAR BIN_OP BIN_OP V... |
You are given a set of $n$ ($n$ is always a power of $2$) elements containing all integers $0, 1, 2, \ldots, n-1$ exactly once.
Find $\frac{n}{2}$ pairs of elements such that:
Each element in the set is in exactly one pair.
The sum over all pairs of the bitwise AND of its elements must be exactly equal to $k$. Forma... | t = int(input())
for _ in range(t):
n, k = map(int, input().split())
a = [[i, n - i - 1] for i in range(n // 2)]
if k == n - 1:
if n == 4:
print(-1)
continue
else:
a[0][1], a[1][1], a[3][0], a[3][1] = a[3][1], a[3][0], a[1][1], a[0][1]
elif k < 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 VAR BIN_OP BIN_OP VAR VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER NUMBER VAR NUMBER NUMBER VAR N... |
You are given a set of $n$ ($n$ is always a power of $2$) elements containing all integers $0, 1, 2, \ldots, n-1$ exactly once.
Find $\frac{n}{2}$ pairs of elements such that:
Each element in the set is in exactly one pair.
The sum over all pairs of the bitwise AND of its elements must be exactly equal to $k$. Forma... | import sys
input = sys.stdin.readline
for _ in range(int(input())):
n, k = map(int, input().split())
if n == 4 and k == 3:
print(-1)
else:
ans = []
visted = [False] * n
if k != n - 1:
visted[k] = visted[n - 1 - k] = visted[0] = visted[n - 1] = True
an... | IMPORT ASSIGN VAR VAR 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 VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER VAR IF VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR BIN_OP BIN_OP VAR NUMBER VAR VAR NUMBER VAR BI... |
You are given a set of $n$ ($n$ is always a power of $2$) elements containing all integers $0, 1, 2, \ldots, n-1$ exactly once.
Find $\frac{n}{2}$ pairs of elements such that:
Each element in the set is in exactly one pair.
The sum over all pairs of the bitwise AND of its elements must be exactly equal to $k$. Forma... | def solve():
n, k = map(int, input().split())
if n == 4 and k == 3:
print(-1)
return
if k == 0:
for i in range(n // 2):
print(i, n - i - 1)
elif k == n - 1:
print(0, n - 4)
print(1, 3)
print(2, n - 3)
print(n - 2, n - 1)
for i i... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN IF VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NU... |
You are given a set of $n$ ($n$ is always a power of $2$) elements containing all integers $0, 1, 2, \ldots, n-1$ exactly once.
Find $\frac{n}{2}$ pairs of elements such that:
Each element in the set is in exactly one pair.
The sum over all pairs of the bitwise AND of its elements must be exactly equal to $k$. Forma... | def main():
N, K = [int(i) for i in input().split()]
l = [(i, N - i - 1) for i in range(N // 2)]
if K == 3 and N == 4:
print(-1)
return
elif K == 2 and N == 4:
print("0 1")
print("2 3")
return
try:
if K == 0:
pass
elif K < N - 1:
... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP BIN_OP VAR VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING RETURN IF VAR NUMBER IF VAR BIN_OP ... |
You are given a set of $n$ ($n$ is always a power of $2$) elements containing all integers $0, 1, 2, \ldots, n-1$ exactly once.
Find $\frac{n}{2}$ pairs of elements such that:
Each element in the set is in exactly one pair.
The sum over all pairs of the bitwise AND of its elements must be exactly equal to $k$. Forma... | import sys
def solution(n, k):
if k != n - 1:
for i in range(n // 2):
if i == 0:
print(i, n - k - 1)
elif i == k:
print(i, n - 1)
elif i == n - k - 1:
print(k, n - 1)
else:
print(i, n - i - 1)
... | IMPORT FUNC_DEF IF VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR... |
You are given a set of $n$ ($n$ is always a power of $2$) elements containing all integers $0, 1, 2, \ldots, n-1$ exactly once.
Find $\frac{n}{2}$ pairs of elements such that:
Each element in the set is in exactly one pair.
The sum over all pairs of the bitwise AND of its elements must be exactly equal to $k$. Forma... | def decode(n, k):
res = []
for i in range(n // 2):
res.append([i, n - 1 - i])
if k == n - 1:
res[0][0] = n - 2
res[1][1] = n - 3
res[2][1] = 0
return res
replace_index = min(k, n - 1 - k)
if replace_index == k:
res[replace_index][0] = 0
else:
... | FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR LIST VAR BIN_OP BIN_OP VAR NUMBER VAR IF VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP V... |
You are given a set of $n$ ($n$ is always a power of $2$) elements containing all integers $0, 1, 2, \ldots, n-1$ exactly once.
Find $\frac{n}{2}$ pairs of elements such that:
Each element in the set is in exactly one pair.
The sum over all pairs of the bitwise AND of its elements must be exactly equal to $k$. Forma... | def main():
test_no = int(input())
for _ in range(test_no):
line = input().split()
n, k = int(line[0]), int(line[1])
if k == n - 1 and n == 4:
print(-1)
continue
elif k == n - 1 and n != 4:
print(n - 1, n - 2)
print(1, n // 2 - 1)
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR ... |
You are given a set of $n$ ($n$ is always a power of $2$) elements containing all integers $0, 1, 2, \ldots, n-1$ exactly once.
Find $\frac{n}{2}$ pairs of elements such that:
Each element in the set is in exactly one pair.
The sum over all pairs of the bitwise AND of its elements must be exactly equal to $k$. Forma... | def executeCases():
n, k = list(map(int, input().split()))
pairs = list()
for i in range(n // 2):
pairs.append([i, n - i - 1])
if k < n // 2:
swap(pairs, k, 0)
elif k < n - 1:
swap(pairs, n - k - 1, 1)
elif len(pairs) > 2:
swap(pairs, n - k, 1)
temp = pair... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR LIST VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP BIN_... |
You are given a set of $n$ ($n$ is always a power of $2$) elements containing all integers $0, 1, 2, \ldots, n-1$ exactly once.
Find $\frac{n}{2}$ pairs of elements such that:
Each element in the set is in exactly one pair.
The sum over all pairs of the bitwise AND of its elements must be exactly equal to $k$. Forma... | for _ in range(int(input())):
n = []
a, b = map(int, input().split())
for z in range(a):
n.append(z)
if a == b + 1 and a == 4:
print(-1)
elif b == 0:
for zzz in range(len(n) // 2):
print(n[0 + zzz], n[-1 - zzz])
elif a == b + 1:
print(a - 1, a - 2)
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR... |
You are given a set of $n$ ($n$ is always a power of $2$) elements containing all integers $0, 1, 2, \ldots, n-1$ exactly once.
Find $\frac{n}{2}$ pairs of elements such that:
Each element in the set is in exactly one pair.
The sum over all pairs of the bitwise AND of its elements must be exactly equal to $k$. Forma... | t = int(input())
def solve(n, k):
ans = [[k, n - 1]]
ans2 = []
if k == n - 1:
ans2.append([n - 2, n - 1])
ans2.append([1, 5])
ans2.append([0, n - 6])
for i in range(2, n // 2):
if i not in [n - 6, 5]:
ans2.append([i, n - i - 1])
return an... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR LIST LIST VAR BIN_OP VAR NUMBER ASSIGN VAR LIST IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR LIST BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR LIST NUMBER NUMBER EXPR FUNC_CALL VAR LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR N... |
You are given a set of $n$ ($n$ is always a power of $2$) elements containing all integers $0, 1, 2, \ldots, n-1$ exactly once.
Find $\frac{n}{2}$ pairs of elements such that:
Each element in the set is in exactly one pair.
The sum over all pairs of the bitwise AND of its elements must be exactly equal to $k$. Forma... | for _ in range(int(input())):
n, k = map(int, input().split())
if k == n - 1 and n == 4:
print(-1)
elif k == n - 1:
lis = []
for i in range(n // 2):
lis.append((i, n - 1 - i))
lis[0] = n - 2, n - 1
lis[1] = 0, n - 3 - 1
lis[3] = 1, 3
for j ... | 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 BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.