description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
"Humankind cannot gain anything without first giving something in return. To obtain, something of equal value must be lost. That is alchemy's first law of Equivalent Exchange. In those days, we really believed that to be the world's one, and only truth."
-- Alphonse Elric
Now, here we have an equivalent exchange law fo... | for t in range(int(input())):
n = int(input())
l = [(int(j) - 1) for j in input().split()]
d = dict()
st = 0
d[st] = -1
ans = 1
for i in range(n):
st = st ^ 1 << l[i]
for j in range(30):
st1 = st
st1 = st1 ^ 1 << j
if st1 in d and d[st1] !=... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR VAR FOR VAR... |
"Humankind cannot gain anything without first giving something in return. To obtain, something of equal value must be lost. That is alchemy's first law of Equivalent Exchange. In those days, we really believed that to be the world's one, and only truth."
-- Alphonse Elric
Now, here we have an equivalent exchange law fo... | def answers():
answ, x = 0, 0
e = dict()
e[x] = -1
for i in range(n):
x ^= 1 << a[i] - 1
if x not in e.keys():
e[x] = i
for j in range(30):
answ = max(answ, i - e.get(x ^ 1 << j, i))
return answ // 2
for T in range(int(input())):
n = int(input())... | FUNC_DEF ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP NUMBER BIN_OP VAR VAR NUMBER IF VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR FUNC_CALL VAR BIN_OP VAR BIN_OP NUMBER VAR VAR RETURN BIN_OP... |
"Humankind cannot gain anything without first giving something in return. To obtain, something of equal value must be lost. That is alchemy's first law of Equivalent Exchange. In those days, we really believed that to be the world's one, and only truth."
-- Alphonse Elric
Now, here we have an equivalent exchange law fo... | for t in range(int(input())):
n = int(input())
c = list(map(int, input().split()))
dictionary = {(0): 0}
parity = 0
k = 0
for i in range(n):
parity ^= 1 << c[i] - 1
if parity not in dictionary:
dictionary[parity] = i + 1
for j in range(30):
x = par... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP NUMBER BIN_OP VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR BIN_OP... |
"Humankind cannot gain anything without first giving something in return. To obtain, something of equal value must be lost. That is alchemy's first law of Equivalent Exchange. In those days, we really believed that to be the world's one, and only truth."
-- Alphonse Elric
Now, here we have an equivalent exchange law fo... | for _ in range(int(input())):
input()
cs = [(int(x) - 1) for x in input().split()]
first = {(0): 0}
last = {}
v = 0
for i, c in enumerate(cs):
v ^= 1 << c
if v not in first:
first[v] = i + 1
last[v] = i + 1
ans = max(
last.get(v ^ 1 << c, 0) - i
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT NUMBER NUMBER ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR VAR BIN_OP NUMBER VAR IF VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_O... |
You are given an integer N. Construct a permutation A of length N which is attractive.
A permutation is called attractive if the [bitwise XOR] of all absolute differences of adjacent pairs of elements is equal to 0.
Formally, a permutation A = [A_{1}, A_{2}, \ldots, A_{N}] of length N is said to be attractive if:
|A... | def function(N):
if N < 3:
return -1
if N % 2 != 0:
return " ".join([str(i) for i in range(1, N + 1)])
else:
return " ".join(["2", "3", "1"] + [str(i) for i in range(4, N + 1)])
def main():
T = int(input())
for _ in range(T):
N = int(input())
val = function(... | FUNC_DEF IF VAR NUMBER RETURN NUMBER IF BIN_OP VAR NUMBER NUMBER RETURN FUNC_CALL STRING FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER RETURN FUNC_CALL STRING BIN_OP LIST STRING STRING STRING FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR ... |
You are given an integer N. Construct a permutation A of length N which is attractive.
A permutation is called attractive if the [bitwise XOR] of all absolute differences of adjacent pairs of elements is equal to 0.
Formally, a permutation A = [A_{1}, A_{2}, \ldots, A_{N}] of length N is said to be attractive if:
|A... | for i in range(int(input())):
n = int(input())
if n == 2:
print(-1)
elif n % 2 != 0:
for i in range(1, n + 1):
print(i, end=" ")
print()
else:
ll = []
co = [2, 3, 1, 4]
if n <= 4:
ll = co[:n]
else:
ll.extend(co)
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER IF VAR ... |
You are given an integer N. Construct a permutation A of length N which is attractive.
A permutation is called attractive if the [bitwise XOR] of all absolute differences of adjacent pairs of elements is equal to 0.
Formally, a permutation A = [A_{1}, A_{2}, \ldots, A_{N}] of length N is said to be attractive if:
|A... | t = int(input())
while t != 0:
n = int(input())
if n == 2:
print(-1)
t = t - 1
continue
l = []
if n % 2 == 1:
for i in range(1, n + 1):
l.append(i)
print(*l)
else:
x = 1
for i in range(0, n):
l.append(x)
x = ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR LIST IF BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER F... |
You are given an integer N. Construct a permutation A of length N which is attractive.
A permutation is called attractive if the [bitwise XOR] of all absolute differences of adjacent pairs of elements is equal to 0.
Formally, a permutation A = [A_{1}, A_{2}, \ldots, A_{N}] of length N is said to be attractive if:
|A... | for i in range(int(input())):
n = int(input())
if n == 2:
print(-1)
elif n & 1 == 1:
print(*list(range(1, n + 1)))
elif n & 1 == 0:
print(2, 3, 1, end=" ")
print(*list(range(4, n + 1))) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER NUMBER STRING EXPR FUNC_CALL V... |
You are given an integer N. Construct a permutation A of length N which is attractive.
A permutation is called attractive if the [bitwise XOR] of all absolute differences of adjacent pairs of elements is equal to 0.
Formally, a permutation A = [A_{1}, A_{2}, \ldots, A_{N}] of length N is said to be attractive if:
|A... | for _ in range(int(input())):
N = int(input())
if N == 2:
print(-1)
elif N % 2:
print(*range(1, N + 1))
else:
print(2, 3, 1, 4, *range(5, N + 1)) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER NUMBER NUMBER FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER |
You are given an integer N. Construct a permutation A of length N which is attractive.
A permutation is called attractive if the [bitwise XOR] of all absolute differences of adjacent pairs of elements is equal to 0.
Formally, a permutation A = [A_{1}, A_{2}, \ldots, A_{N}] of length N is said to be attractive if:
|A... | for _ in range(int(input())):
n = int(input())
if n == 2:
print(-1)
elif n % 2 == 1:
q = []
for i in range(1, n + 1):
q.append(i)
print(*q)
else:
q = []
for i in range(1, n + 1):
q.append(i)
g = q.pop()
q.insert(1, g... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VA... |
You are given an integer N. Construct a permutation A of length N which is attractive.
A permutation is called attractive if the [bitwise XOR] of all absolute differences of adjacent pairs of elements is equal to 0.
Formally, a permutation A = [A_{1}, A_{2}, \ldots, A_{N}] of length N is said to be attractive if:
|A... | from itertools import permutations
x = int(input())
for y in range(x):
def main(l, n):
main_list = []
for k in range(n - 1):
main_list.append(abs(l[k] - l[k + 1]))
return xorOfArray(main_list, n)
def xorOfArray(main_list, n):
xor_arr = 0
for i in range(n - ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER RETURN FUNC_CALL VAR VAR VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VA... |
You are given an integer N. Construct a permutation A of length N which is attractive.
A permutation is called attractive if the [bitwise XOR] of all absolute differences of adjacent pairs of elements is equal to 0.
Formally, a permutation A = [A_{1}, A_{2}, \ldots, A_{N}] of length N is said to be attractive if:
|A... | for _ in range(int(input())):
n = int(input())
if n == 2:
print(-1)
elif n % 2 != 0:
for i in range(1, n + 1):
print(i, end=" ")
else:
l = [2, 3, 1, 4]
for i in l:
print(i, end=" ")
for i in range(5, n + 1):
print(i, end=" ")
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR STRING ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING ... |
You are given an integer N. Construct a permutation A of length N which is attractive.
A permutation is called attractive if the [bitwise XOR] of all absolute differences of adjacent pairs of elements is equal to 0.
Formally, a permutation A = [A_{1}, A_{2}, \ldots, A_{N}] of length N is said to be attractive if:
|A... | for tc in range(int(input())):
n = int(input())
if n == 2:
print(-1)
elif n % 2 == 0:
ans = [2, 3, 1, 4]
for i in range(n - 4):
ans.append(5 + i)
print(*ans)
else:
print(*[i for i in range(1, n + 1)]) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ... |
You are given an integer N. Construct a permutation A of length N which is attractive.
A permutation is called attractive if the [bitwise XOR] of all absolute differences of adjacent pairs of elements is equal to 0.
Formally, a permutation A = [A_{1}, A_{2}, \ldots, A_{N}] of length N is said to be attractive if:
|A... | for i in range(int(input())):
x = int(input())
if x == 2:
print(-1)
elif x % 2 == 1:
a = [i for i in range(x, 0, -1)]
print(*a)
else:
b = [i for i in range(5, x + 1)]
c = [2, 3, 1, 4]
print(*c, end=" ")
print(*b) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER N... |
You are given an integer N. Construct a permutation A of length N which is attractive.
A permutation is called attractive if the [bitwise XOR] of all absolute differences of adjacent pairs of elements is equal to 0.
Formally, a permutation A = [A_{1}, A_{2}, \ldots, A_{N}] of length N is said to be attractive if:
|A... | t = input()
for c in range(0, int(t)):
n = int(input())
res = []
for i in range(n):
res.append(i + 1)
if n == 2:
print(-1)
elif n % 2 == 0:
temp = res[-1]
res[-1] = res[-3]
res[-3] = temp
temp = res[-1]
res[-1] = res[-2]
res[-2] = temp
... | ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR ... |
You are given an integer N. Construct a permutation A of length N which is attractive.
A permutation is called attractive if the [bitwise XOR] of all absolute differences of adjacent pairs of elements is equal to 0.
Formally, a permutation A = [A_{1}, A_{2}, \ldots, A_{N}] of length N is said to be attractive if:
|A... | for _ in range(int(input())):
n = int(input())
if n == 2:
print(-1)
else:
if n % 2:
print(*range(1, n + 1))
else:
l = list(range(1, n + 1))
l.insert(1, l.pop())
print(*l)
print() | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER FUNC_CALL VAR EXPR FUN... |
You are given an integer N. Construct a permutation A of length N which is attractive.
A permutation is called attractive if the [bitwise XOR] of all absolute differences of adjacent pairs of elements is equal to 0.
Formally, a permutation A = [A_{1}, A_{2}, \ldots, A_{N}] of length N is said to be attractive if:
|A... | for _ in range(int(input())):
n = int(input())
if n % 2 != 0:
temp = list(range(n, 0, -1))
print(*temp)
elif n == 2:
print(-1)
else:
li = [2, 3, 1, 4]
if n == 4:
print(*li)
else:
li += range(5, n + 1)
print(*li) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR VA... |
You are given an integer N. Construct a permutation A of length N which is attractive.
A permutation is called attractive if the [bitwise XOR] of all absolute differences of adjacent pairs of elements is equal to 0.
Formally, a permutation A = [A_{1}, A_{2}, \ldots, A_{N}] of length N is said to be attractive if:
|A... | t = int(input())
for i in range(t):
n = int(input())
a = []
for j in range(n):
a.append(j + 1)
if n % 2 != 0:
print(*a)
elif n <= 2:
print(-1)
else:
a[0] = 2
a[1] = 3
a[2] = 1
print(*a) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUM... |
You are given an integer N. Construct a permutation A of length N which is attractive.
A permutation is called attractive if the [bitwise XOR] of all absolute differences of adjacent pairs of elements is equal to 0.
Formally, a permutation A = [A_{1}, A_{2}, \ldots, A_{N}] of length N is said to be attractive if:
|A... | def inparr():
tmparr = [int(i) for i in input().split()]
return tmparr
for _ in range(int(input())):
N = int(input())
if N % 2:
bstr = "1"
for i in range(2, N + 1):
bstr += f" {i}"
print(bstr)
elif N >= 4:
bstr = "2 3 1 4"
for i in range(5, N + 1... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR STRING VAR EXPR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR STRIN... |
You are given an integer N. Construct a permutation A of length N which is attractive.
A permutation is called attractive if the [bitwise XOR] of all absolute differences of adjacent pairs of elements is equal to 0.
Formally, a permutation A = [A_{1}, A_{2}, \ldots, A_{N}] of length N is said to be attractive if:
|A... | T = int(input())
for i in range(T):
n = int(input())
lst = []
if n == 2:
print(-1)
elif n % 2 != 0:
for i in range(1, n + 1):
lst.append(str(i))
else:
lst.extend(["2", "3", "1", "4"])
for i in range(5, n + 1):
lst.append(str(i))
print(" ".j... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST STRING STRING STRING STR... |
You are given an integer N. Construct a permutation A of length N which is attractive.
A permutation is called attractive if the [bitwise XOR] of all absolute differences of adjacent pairs of elements is equal to 0.
Formally, a permutation A = [A_{1}, A_{2}, \ldots, A_{N}] of length N is said to be attractive if:
|A... | tests = int(input())
for i in range(tests):
n = int(input())
ans = []
if n == 2:
ans = [-1]
elif n & 1:
ans = [i for i in range(n, 0, -1)]
else:
ans = [i for i in range(n, 4, -1)]
ans.extend([4, 1, 3, 2])
print(*ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST IF VAR NUMBER ASSIGN VAR LIST NUMBER IF BIN_OP VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR LIST NUMBER NUMBER NU... |
You are given an integer N. Construct a permutation A of length N which is attractive.
A permutation is called attractive if the [bitwise XOR] of all absolute differences of adjacent pairs of elements is equal to 0.
Formally, a permutation A = [A_{1}, A_{2}, \ldots, A_{N}] of length N is said to be attractive if:
|A... | for i in range(int(input())):
n = int(input())
list1 = [2, 3, 1]
list2 = [3, 2, 1]
if n == 2:
print(-1)
elif n == 3:
for x in list2:
print(x, end=" ")
print("")
elif n % 2 != 0:
for x in range(1, n + 1):
print(x, end=" ")
print(" ")... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR STRING IF BIN_OP VAR NUMBER NUMBER FOR VAR... |
You are given an integer N. Construct a permutation A of length N which is attractive.
A permutation is called attractive if the [bitwise XOR] of all absolute differences of adjacent pairs of elements is equal to 0.
Formally, a permutation A = [A_{1}, A_{2}, \ldots, A_{N}] of length N is said to be attractive if:
|A... | t = int(input())
for _ in range(t):
n = int(input())
if n == 2:
print(-1)
elif n % 2 == 0:
a = [2, 3, 1, 4]
for i in range(5, n + 1):
a.append(i)
print(*a)
else:
a = [*range(1, n + 1)]
print(*a) | 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 IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR ... |
You are given an integer N. Construct a permutation A of length N which is attractive.
A permutation is called attractive if the [bitwise XOR] of all absolute differences of adjacent pairs of elements is equal to 0.
Formally, a permutation A = [A_{1}, A_{2}, \ldots, A_{N}] of length N is said to be attractive if:
|A... | from itertools import permutations
def xor(a, s):
temp = abs(s[0] - s[1])
for i in range(1, a - 1):
temp = temp ^ abs(s[i] - s[i + 1])
if temp == 0:
return True
return False
for _ in range(int(input())):
n = int(input())
if n % 2 != 0:
print(*list(range(n, 0, -1)))
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER IF VAR NUMBER RETURN NUMBER RETURN NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN... |
You are given an integer N. Construct a permutation A of length N which is attractive.
A permutation is called attractive if the [bitwise XOR] of all absolute differences of adjacent pairs of elements is equal to 0.
Formally, a permutation A = [A_{1}, A_{2}, \ldots, A_{N}] of length N is said to be attractive if:
|A... | for _ in range(int(input())):
n = int(input())
if n % 2 != 0:
print(" ".join([str(i) for i in range(1, n + 1)]))
elif n == 2:
print(-1)
elif n == 4:
print("1 4 2 3")
else:
li = [str(n - 1), str(n), str(n - 3), str(n - 2), str(n - 4)] + [
str(i) for i in ra... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST FUN... |
You are given an integer N. Construct a permutation A of length N which is attractive.
A permutation is called attractive if the [bitwise XOR] of all absolute differences of adjacent pairs of elements is equal to 0.
Formally, a permutation A = [A_{1}, A_{2}, \ldots, A_{N}] of length N is said to be attractive if:
|A... | for _ in range(int(input())):
n = int(input())
if n % 2 == 1:
for i in range(1, n + 1):
print(i, end=" ")
print()
else:
if n == 2:
print(-1)
continue
for i in range(1, n - 2):
print(i, end=" ")
a = n
b = n - 1
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR V... |
You are given an integer N. Construct a permutation A of length N which is attractive.
A permutation is called attractive if the [bitwise XOR] of all absolute differences of adjacent pairs of elements is equal to 0.
Formally, a permutation A = [A_{1}, A_{2}, \ldots, A_{N}] of length N is said to be attractive if:
|A... | t = int(input())
for _ in range(t):
n = int(input())
if n == 2:
print(-1)
elif n % 2:
arr = [i for i in range(1, n + 1)]
print(*arr)
else:
arr = [i for i in range(1, n + 1)]
arr[0] = 2
arr[1] = 3
arr[2] = 1
print(*arr) | 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 IF BIN_OP VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBE... |
You are given an integer N. Construct a permutation A of length N which is attractive.
A permutation is called attractive if the [bitwise XOR] of all absolute differences of adjacent pairs of elements is equal to 0.
Formally, a permutation A = [A_{1}, A_{2}, \ldots, A_{N}] of length N is said to be attractive if:
|A... | for _ in range(int(input())):
n = int(input())
if n <= 2:
print(-1)
continue
else:
if n % 2 != 0:
for i in range(n, 0, -1):
print(i, end=" ")
else:
print("2 3 1 4", end=" ")
for i in range(1, n - 3):
print(i ... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR STRING STRING FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CAL... |
You are given an integer N. Construct a permutation A of length N which is attractive.
A permutation is called attractive if the [bitwise XOR] of all absolute differences of adjacent pairs of elements is equal to 0.
Formally, a permutation A = [A_{1}, A_{2}, \ldots, A_{N}] of length N is said to be attractive if:
|A... | vojj = int(input())
for vishnesh in range(vojj):
n = int(input())
if n % 2:
for i in range(1, n + 1):
print(i, end=" ")
print()
elif n == 2:
print(-1)
else:
for i in range(1, n - 2):
print(i, end=" ")
print(n, end=" ")
print(n - 2, ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CA... |
You are given an integer N. Construct a permutation A of length N which is attractive.
A permutation is called attractive if the [bitwise XOR] of all absolute differences of adjacent pairs of elements is equal to 0.
Formally, a permutation A = [A_{1}, A_{2}, \ldots, A_{N}] of length N is said to be attractive if:
|A... | for _ in range(int(input())):
n = int(input())
if n == 2:
print(-1)
continue
a = [(x + 1) for x in range(n)]
if n & 1 == 0:
a[0], a[1], a[2] = a[1], a[2], a[0]
print(*a) | 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 ASSIGN VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR |
You are given an integer N. Construct a permutation A of length N which is attractive.
A permutation is called attractive if the [bitwise XOR] of all absolute differences of adjacent pairs of elements is equal to 0.
Formally, a permutation A = [A_{1}, A_{2}, \ldots, A_{N}] of length N is said to be attractive if:
|A... | t = int(input())
for i in range(0, t):
lst = []
n = int(input())
if n == 2:
print(-1)
continue
if n % 2 != 0:
for k in range(n, 0, -1):
lst.append(k)
print(*lst, sep=" ")
else:
for j in range(1, n - 2):
lst.append(j)
lst.append(... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR STRING FOR VAR FUNC_CALL VAR NUMBER BIN... |
You are given an integer N. Construct a permutation A of length N which is attractive.
A permutation is called attractive if the [bitwise XOR] of all absolute differences of adjacent pairs of elements is equal to 0.
Formally, a permutation A = [A_{1}, A_{2}, \ldots, A_{N}] of length N is said to be attractive if:
|A... | p = int(input())
for i in range(p):
n = int(input())
if n == 2:
print("-1")
elif n == 4:
print("2 3 1 4")
elif n % 2 != 0:
l = []
for i in range(1, n + 1):
l.append(i)
print(*l)
elif n % 2 == 0:
l = [2, 3, 1, 4]
for i in range(5, n ... | 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 STRING IF VAR NUMBER EXPR FUNC_CALL VAR STRING IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR... |
You are given an integer N. Construct a permutation A of length N which is attractive.
A permutation is called attractive if the [bitwise XOR] of all absolute differences of adjacent pairs of elements is equal to 0.
Formally, a permutation A = [A_{1}, A_{2}, \ldots, A_{N}] of length N is said to be attractive if:
|A... | for _ in range(int(input())):
n = int(input())
if n == 2:
print(-1)
elif n % 2 == 1:
a = list(range(1, n + 1))
print(*a)
continue
elif n == 4:
a = [2, 3, 1, 4]
print(*a)
continue
else:
a = [2, 3, 1, 4]
b = list(range(5, n + 1))
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR... |
You are given an integer N. Construct a permutation A of length N which is attractive.
A permutation is called attractive if the [bitwise XOR] of all absolute differences of adjacent pairs of elements is equal to 0.
Formally, a permutation A = [A_{1}, A_{2}, \ldots, A_{N}] of length N is said to be attractive if:
|A... | for _ in range(int(input())):
n = int(input())
if n == 2:
print(-1)
elif n % 2:
print(*[c for c in range(1, n + 1)])
else:
ans = [c for c in range(1, n + 1)]
temp = ans[-3:]
temp1 = [temp[2], temp[0], temp[1]]
print(*list(ans[:-3] + temp1)) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIST VAR NUMB... |
You are given an integer N. Construct a permutation A of length N which is attractive.
A permutation is called attractive if the [bitwise XOR] of all absolute differences of adjacent pairs of elements is equal to 0.
Formally, a permutation A = [A_{1}, A_{2}, \ldots, A_{N}] of length N is said to be attractive if:
|A... | n = int(input())
a = []
for i in range(n):
l = int(input())
a.append(l)
for i in a:
if i == 2:
print(-1)
elif i % 2:
print(*list(range(1, i + 1)))
else:
n = [(i - j) for j in range(i)]
res = n[:-4] + [4, 1, 3, 2]
print(*res) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR FOR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR FU... |
You are given an integer N. Construct a permutation A of length N which is attractive.
A permutation is called attractive if the [bitwise XOR] of all absolute differences of adjacent pairs of elements is equal to 0.
Formally, a permutation A = [A_{1}, A_{2}, \ldots, A_{N}] of length N is said to be attractive if:
|A... | sl = int(input())
while sl:
sl -= 1
n = int(input())
if n == 2:
print(-1)
elif n == 4:
print(4, 1, 3, 2)
elif n % 2 == 1:
for i in range(n):
print(i + 1, end=" ")
print()
else:
for i in range(n - 4):
print(n - i, end=" ")
pr... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR 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 NUMBER NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR FOR... |
You are given an integer N. Construct a permutation A of length N which is attractive.
A permutation is called attractive if the [bitwise XOR] of all absolute differences of adjacent pairs of elements is equal to 0.
Formally, a permutation A = [A_{1}, A_{2}, \ldots, A_{N}] of length N is said to be attractive if:
|A... | for _ in range(int(input())):
n = int(input())
if n == 2:
print(-1)
else:
if n % 2:
print(*range(1, n + 1))
elif n % 4 == 0:
a = range(1, n // 2 + 1)
b = range(n, n // 2, -1)
for i in range(n):
if i % 2:
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL... |
You are given an integer N. Construct a permutation A of length N which is attractive.
A permutation is called attractive if the [bitwise XOR] of all absolute differences of adjacent pairs of elements is equal to 0.
Formally, a permutation A = [A_{1}, A_{2}, \ldots, A_{N}] of length N is said to be attractive if:
|A... | n = int(input())
while n:
n -= 1
N = int(input())
if N == 2 or N == 1 or N == 0:
print(-1)
elif N % 2:
l = [int(x) for x in range(1, N + 1)]
print(*l)
else:
ans = list(range(N, 3, -1)) + [1, 3, 2]
print(*ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL V... |
You are given an integer N. Construct a permutation A of length N which is attractive.
A permutation is called attractive if the [bitwise XOR] of all absolute differences of adjacent pairs of elements is equal to 0.
Formally, a permutation A = [A_{1}, A_{2}, \ldots, A_{N}] of length N is said to be attractive if:
|A... | for _ in range(int(input())):
n = int(input())
result = [2, 3, 1, 4]
if n == 2:
print(-1)
elif n % 2 == 1:
print(*[i for i in range(1, n + 1)])
else:
for i in range(5, n + 1):
result.append(i)
print(*result) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR F... |
You are given an integer N. Construct a permutation A of length N which is attractive.
A permutation is called attractive if the [bitwise XOR] of all absolute differences of adjacent pairs of elements is equal to 0.
Formally, a permutation A = [A_{1}, A_{2}, \ldots, A_{N}] of length N is said to be attractive if:
|A... | testcases = int(input())
for i in range(testcases):
n = int(input())
if n % 2 == 1:
for i in range(n, 0, -1):
print(i, end=" ")
print()
else:
if n == 2:
print(-1)
continue
for i in range(n, 3, -1):
print(i, end=" ")
prin... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR ... |
You are given an integer N. Construct a permutation A of length N which is attractive.
A permutation is called attractive if the [bitwise XOR] of all absolute differences of adjacent pairs of elements is equal to 0.
Formally, a permutation A = [A_{1}, A_{2}, \ldots, A_{N}] of length N is said to be attractive if:
|A... | for _ in range(int(input())):
m = int(input())
if m == 2:
print(-1)
else:
ans = [*range(1, m + 1)]
if m % 2 == 0:
ans[m - 1], ans[m - 2], ans[m - 3] = m - 1, m - 2, m
print(*ans) | 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 ASSIGN VAR LIST FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER... |
Raj is a math pro and number theory expert. One day, he met his age-old friend Chef. Chef claimed to be better at number theory than Raj, so Raj gave him some fuzzy problems to solve. In one of those problems, he gave Chef a 3$3$-tuple of non-negative integers (a0,b0,c0)$(a_0, b_0, c_0)$ and told Chef to convert it to ... | t = int(input())
for _ in range(t):
arr1 = [int(i) for i in input().split()]
a, b, c = arr1[:3]
x, y, z = arr1[3:]
ans = 0
if arr1[:3] == arr1[3:]:
print(0)
elif (a == 0 and b == 0 and c == 0) and (x == 0 and y == 0 and z == 0):
print(0)
else:
ans = 0
a1 = a %... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER ... |
Raj is a math pro and number theory expert. One day, he met his age-old friend Chef. Chef claimed to be better at number theory than Raj, so Raj gave him some fuzzy problems to solve. In one of those problems, he gave Chef a 3$3$-tuple of non-negative integers (a0,b0,c0)$(a_0, b_0, c_0)$ and told Chef to convert it to ... | for _ in range(int(input())):
a, b, c, x, y, z = map(int, input().split())
if a == 0 and b == 0 and c == 0 and x == 0 and y == 0 and z == 0:
print(0)
continue
ans = 0
if a == 0 and b == 0 and c == 0:
st = set((abs(x - a) % 2, abs(y - b) % 2, abs(z - c) % 2))
if st == {0, ... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR BI... |
Raj is a math pro and number theory expert. One day, he met his age-old friend Chef. Chef claimed to be better at number theory than Raj, so Raj gave him some fuzzy problems to solve. In one of those problems, he gave Chef a 3$3$-tuple of non-negative integers (a0,b0,c0)$(a_0, b_0, c_0)$ and told Chef to convert it to ... | def ch(a, b, c, d, e, f):
d1, d2, d3 = abs(a - d), abs(b - e), abs(c - f)
if a + b + c == 0 or d + e + f == 0:
print(2) if d1 % 2 == d2 % 2 and d2 % 2 == d3 % 2 else print(1)
else:
print(0) if (d1 % 2 + d2 % 2 + d3 % 2) % 3 == 0 else print(1)
for z in range(int(input())):
a, b, c, d, e... | FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR VAR IF BIN_OP BIN_OP VAR VAR VAR NUMBER BIN_OP BIN_OP VAR VAR VAR NUMBER EXPR BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER FUNC_CALL VAR NUMBER FUNC_CALL VAR NUMBER EXPR BIN_OP BIN_O... |
Dreamoon likes sequences very much. So he created a problem about the sequence that you can't find in OEIS:
You are given two integers d, m, find the number of arrays a, satisfying the following constraints:
* The length of a is n, n ≥ 1
* 1 ≤ a_1 < a_2 < ... < a_n ≤ d
* Define an array b of length n as foll... | power = [1]
def solve(d, m):
bit = 0
for i in range(31, -1, -1):
bit = i
if 1 << i & d:
break
dp = []
for i in range(35):
l = []
for j in range(35):
l.append(0)
dp.append(l)
save = []
for i in range(0, bit + 1):
save.appen... | ASSIGN VAR LIST NUMBER FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR IF BIN_OP BIN_OP NUMBER VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUM... |
Dreamoon likes sequences very much. So he created a problem about the sequence that you can't find in OEIS:
You are given two integers d, m, find the number of arrays a, satisfying the following constraints:
* The length of a is n, n ≥ 1
* 1 ≤ a_1 < a_2 < ... < a_n ≤ d
* Define an array b of length n as foll... | t = int(input())
powers_of_two = set(2**n for n in range(100))
def f(d):
if d < 4:
return 2 * d - 1
if d in powers_of_two:
return 2 * f(d - 1) + 1
bpo2b = max(x for x in powers_of_two if x < d)
bpov = f(bpo2b - 1)
return (bpov + 1) * (d - bpo2b + 2) - 1
for _ in range(t):
d, ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER VAR VAR FUNC_CALL VAR NUMBER FUNC_DEF IF VAR NUMBER RETURN BIN_OP BIN_OP NUMBER VAR NUMBER IF VAR VAR RETURN BIN_OP BIN_OP NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN... |
Dreamoon likes sequences very much. So he created a problem about the sequence that you can't find in OEIS:
You are given two integers d, m, find the number of arrays a, satisfying the following constraints:
* The length of a is n, n ≥ 1
* 1 ≤ a_1 < a_2 < ... < a_n ≤ d
* Define an array b of length n as foll... | t = int(input())
while t > 0:
n, m = input().split()
n = int(n)
m = int(m)
i = 0
j = 0
while pow(2, i) <= n:
i = i + 1
i = i - 1
ans = 1
while i > j:
x = pow(2, j + 1) - pow(2, j) + 1
ans = ans * x
j = j + 1
if pow(2, j) != n:
x = n - pow(2... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE FUNC_CALL VAR NUMBER VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN... |
Dreamoon likes sequences very much. So he created a problem about the sequence that you can't find in OEIS:
You are given two integers d, m, find the number of arrays a, satisfying the following constraints:
* The length of a is n, n ≥ 1
* 1 ≤ a_1 < a_2 < ... < a_n ≤ d
* Define an array b of length n as foll... | a = [0] * 31
a[0] = 1
for i in range(1, 31):
a[i] = a[i - 1] + (a[i - 1] + 1) * 2**i
d = [(2**i - 1, a[i - 1], i) for i in range(1, 31)]
t = int(input())
for i in range(t):
m, n = map(int, input().split())
for j in range(31):
if m < d[j][0]:
st = d[j - 1][0]
base = d[j - 1][1... | ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER BIN_OP NUMBER VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_... |
Dreamoon likes sequences very much. So he created a problem about the sequence that you can't find in OEIS:
You are given two integers d, m, find the number of arrays a, satisfying the following constraints:
* The length of a is n, n ≥ 1
* 1 ≤ a_1 < a_2 < ... < a_n ≤ d
* Define an array b of length n as foll... | for _ in range(int(input())):
d, m = map(int, input().split())
ans = 1
for i in range(30):
v = 1 << i
if v > d:
break
ans = ans % m * (min(2 * v - 1, d) - v + 2) % m % m
ans -= 1
if ans < 0:
ans += m
print(ans) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR IF VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR VAR NUMBER VAR ... |
Dreamoon likes sequences very much. So he created a problem about the sequence that you can't find in OEIS:
You are given two integers d, m, find the number of arrays a, satisfying the following constraints:
* The length of a is n, n ≥ 1
* 1 ≤ a_1 < a_2 < ... < a_n ≤ d
* Define an array b of length n as foll... | T = int(input())
for _ in range(T):
d, m = map(int, input().split())
dp = [0] * 31
dp[1] = 1
dp[0] = 1
bit = int.bit_length(d)
for i in range(2, bit + 1):
delta = min(d, (1 << i) - 1) - (1 << i - 1) + 1
for j in range(i):
dp[i] = (dp[i] + delta * dp[j]) % m
ans = ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP FUNC_CALL ... |
Dreamoon likes sequences very much. So he created a problem about the sequence that you can't find in OEIS:
You are given two integers d, m, find the number of arrays a, satisfying the following constraints:
* The length of a is n, n ≥ 1
* 1 ≤ a_1 < a_2 < ... < a_n ≤ d
* Define an array b of length n as foll... | import sys
def main():
import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
d, m = map(int, input().split())
k = 0
d_ = d
while d_:
d_ //= 2
k += 1
mod = [1] * (k + 1)
for i in range(k):
mod[i + 1... | IMPORT FUNC_DEF IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR... |
Dreamoon likes sequences very much. So he created a problem about the sequence that you can't find in OEIS:
You are given two integers d, m, find the number of arrays a, satisfying the following constraints:
* The length of a is n, n ≥ 1
* 1 ≤ a_1 < a_2 < ... < a_n ≤ d
* Define an array b of length n as foll... | diff = [
1,
2,
6,
30,
270,
4590,
151470,
9845550,
1270075950,
326409519150,
167448083323950,
171634285407048750,
351678650799042888750,
1440827432323678715208750,
11804699153027899713705288750,
193419995622362136809061156168750,
63381798365491848610961... | ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR VAR FUNC_CALL VA... |
Dreamoon likes sequences very much. So he created a problem about the sequence that you can't find in OEIS:
You are given two integers d, m, find the number of arrays a, satisfying the following constraints:
* The length of a is n, n ≥ 1
* 1 ≤ a_1 < a_2 < ... < a_n ≤ d
* Define an array b of length n as foll... | def solve():
d, m = map(int, input().split())
res = 1 % m
pw2 = 1
for _ in range(1, 31):
np = pw2 * 2
if np > d:
res = res * (d + 1 - pw2 + 1) % m
break
else:
res = res * (np - pw2 + 1) % m
pw2 = np
return (res - 1 + m) % m
t ... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMB... |
Dreamoon likes sequences very much. So he created a problem about the sequence that you can't find in OEIS:
You are given two integers d, m, find the number of arrays a, satisfying the following constraints:
* The length of a is n, n ≥ 1
* 1 ≤ a_1 < a_2 < ... < a_n ≤ d
* Define an array b of length n as foll... | t = int(input())
while t:
t -= 1
n, m = [int(i) for i in input().split()]
i = 1
ans = []
while i < n + 1:
if n - i >= i - 1:
ans.append(i)
else:
ans.append(n - i + 1)
i *= 2
p = 1
for i in ans:
p *= i + 1
print((p - 1) % m) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER F... |
Dreamoon likes sequences very much. So he created a problem about the sequence that you can't find in OEIS:
You are given two integers d, m, find the number of arrays a, satisfying the following constraints:
* The length of a is n, n ≥ 1
* 1 ≤ a_1 < a_2 < ... < a_n ≤ d
* Define an array b of length n as foll... | import sys
for _ in range(int(sys.stdin.readline())):
d, m = map(int, sys.stdin.readline().split())
i = 0
while 1 << i <= d:
i += 1
prod = 1
for j in range(i - 1):
prod *= (1 << j) + 1
prod %= m
prod *= d + 2 - (1 << i - 1)
prod %= m
print((prod - 1) % m) | IMPORT FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE BIN_OP NUMBER VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR VAR VAR BIN_OP BIN_OP VAR NUMBER BIN_OP NUMBER BIN_... |
Dreamoon likes sequences very much. So he created a problem about the sequence that you can't find in OEIS:
You are given two integers d, m, find the number of arrays a, satisfying the following constraints:
* The length of a is n, n ≥ 1
* 1 ≤ a_1 < a_2 < ... < a_n ≤ d
* Define an array b of length n as foll... | def kr(a, md):
ans = 1
for i in a:
ans *= i
ans %= mod
return ans
for t in range(int(input())):
num, mod = map(int, input().split())
a = [1] * 31
step = 1
hod = 0
while num > 0:
if num > step:
a[hod] += step
num -= step
else:
... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR VAR VAR VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER IF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR NUM... |
Dreamoon likes sequences very much. So he created a problem about the sequence that you can't find in OEIS:
You are given two integers d, m, find the number of arrays a, satisfying the following constraints:
* The length of a is n, n ≥ 1
* 1 ≤ a_1 < a_2 < ... < a_n ≤ d
* Define an array b of length n as foll... | def func(a):
b = 1
c = 1
d = 1
for i in range(1, a + 1):
c = 2 * b + 1
d = 2**i - 1
if i != a:
b = c + (b + 1) * d
return b, c
for _ in range(int(input())):
d, m = list(map(int, input().split()))
s = 1
while 1 > 0:
if 2**s > d:
br... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR NUMBER VAR RETURN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL V... |
Dreamoon likes sequences very much. So he created a problem about the sequence that you can't find in OEIS:
You are given two integers d, m, find the number of arrays a, satisfying the following constraints:
* The length of a is n, n ≥ 1
* 1 ≤ a_1 < a_2 < ... < a_n ≤ d
* Define an array b of length n as foll... | for _ in range(int(input())):
d, m = list(map(lambda x: int(x), input().split()))
p = 1
ans = 1
while True:
if p * 2 <= d:
ans = ans * (1 + p)
p = p * 2
else:
ans = ans * (1 + d - p + 1)
break
ans %= m
print((ans - 1 + m) % m) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER IF BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP BIN_OP... |
Dreamoon likes sequences very much. So he created a problem about the sequence that you can't find in OEIS:
You are given two integers d, m, find the number of arrays a, satisfying the following constraints:
* The length of a is n, n ≥ 1
* 1 ≤ a_1 < a_2 < ... < a_n ≤ d
* Define an array b of length n as foll... | for _ in range(int(input())):
d, m = map(int, input().split())
power2 = 1
total = 1
while 2 * power2 + 1 <= d:
total = (total + (power2 + 1) % m * ((total + 1) % m) % m) % m
power2 = power2 * 2 + 1
total = (total + (d - power2) * ((total + 1) % m) % m) % m
print(total) | 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 WHILE BIN_OP BIN_OP NUMBER VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER VAR BIN_OP BIN_OP VAR NUMBER VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP V... |
Dreamoon likes sequences very much. So he created a problem about the sequence that you can't find in OEIS:
You are given two integers d, m, find the number of arrays a, satisfying the following constraints:
* The length of a is n, n ≥ 1
* 1 ≤ a_1 < a_2 < ... < a_n ≤ d
* Define an array b of length n as foll... | import sys
def main():
import sys
input = sys.stdin.readline
for _ in range(int(input())):
d, mod = map(int, input().split())
LV = d.bit_length()
ans = 0
for lv in range(1, LV):
new = (ans + 1) * (1 << lv - 1) % mod
ans += new
ans %= mod... | IMPORT FUNC_DEF 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 ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP NUMBER BIN_OP VAR NUMBER VAR VAR VAR VAR VAR ASSI... |
Dreamoon likes sequences very much. So he created a problem about the sequence that you can't find in OEIS:
You are given two integers d, m, find the number of arrays a, satisfying the following constraints:
* The length of a is n, n ≥ 1
* 1 ≤ a_1 < a_2 < ... < a_n ≤ d
* Define an array b of length n as foll... | for _ in range(int(input())):
n, m = map(int, input().split())
ans = 1
power = 1
while power * 2 + 1 <= n:
ans = ((ans + power + 1) % m + ans * (power + 1) % m) % m
power = power * 2 + 1
ans = ((ans + n - power - 1 + 1) % m + ans * (n - power - 1 + 1) % m) % m
print(ans) | 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 WHILE BIN_OP BIN_OP VAR NUMBER NUMBER VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR BIN_OP BIN_OP V... |
Dreamoon likes sequences very much. So he created a problem about the sequence that you can't find in OEIS:
You are given two integers d, m, find the number of arrays a, satisfying the following constraints:
* The length of a is n, n ≥ 1
* 1 ≤ a_1 < a_2 < ... < a_n ≤ d
* Define an array b of length n as foll... | def calc(d, n, m, max_n):
f = [([0] * max_n) for i in range(n)]
for i in range(max_n - 1):
f[0][i] = 2 ** (i + 1) - 2**i
f[0][max_n - 1] = d - 2 ** (max_n - 1) + 1
for i in range(1, n):
k = 0
for j in range(0, max_n - 1):
f[i][j] = k * 2**j % m
k = (k + f[... | FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR NUMBER BIN_OP VAR NUMBER BIN_OP BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR... |
Dreamoon likes sequences very much. So he created a problem about the sequence that you can't find in OEIS:
You are given two integers d, m, find the number of arrays a, satisfying the following constraints:
* The length of a is n, n ≥ 1
* 1 ≤ a_1 < a_2 < ... < a_n ≤ d
* Define an array b of length n as foll... | t = int(input())
while t:
t -= 1
n, m = map(int, input().split())
x = bin(n)[2:]
r = 1
for i in range(len(x)):
x = min(2 ** (i + 1) - 1, n) - 2**i + 2
r = r * x
print((r - 1) % m) | 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 FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER VAR BIN_OP NUMBER VAR NU... |
Dreamoon likes sequences very much. So he created a problem about the sequence that you can't find in OEIS:
You are given two integers d, m, find the number of arrays a, satisfying the following constraints:
* The length of a is n, n ≥ 1
* 1 ≤ a_1 < a_2 < ... < a_n ≤ d
* Define an array b of length n as foll... | import sys
def RL():
return map(int, sys.stdin.readline().rstrip().split())
def N():
return int(input())
for _ in range(N()):
d, m = RL()
bl = d.bit_length()
sm = 1
res = [1]
lst = d - ((1 << bl - 1) - 1)
for i in range(2, bl + 1):
num = (1 << i) - (1 << i - 1)
if i... | IMPORT FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER FO... |
Dreamoon likes sequences very much. So he created a problem about the sequence that you can't find in OEIS:
You are given two integers d, m, find the number of arrays a, satisfying the following constraints:
* The length of a is n, n ≥ 1
* 1 ≤ a_1 < a_2 < ... < a_n ≤ d
* Define an array b of length n as foll... | t = int(input())
for _ in range(t):
d, m = list(map(int, input().split()))
a = 1
sz = len(bin(d)) - 2
for l in range(sz):
a += a * (d + 1 - (1 << l) if l == sz - 1 else 1 << l)
print((a - 1) % m) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER BIN_OP NUMBER VAR BIN... |
Dreamoon likes sequences very much. So he created a problem about the sequence that you can't find in OEIS:
You are given two integers d, m, find the number of arrays a, satisfying the following constraints:
* The length of a is n, n ≥ 1
* 1 ≤ a_1 < a_2 < ... < a_n ≤ d
* Define an array b of length n as foll... | e = [(1 << i) for i in range(0, 31)]
for i in range(int(input())):
d, m = map(int, input().split())
x = {(0): 1, (1): 3}
if 1 == d:
print(1 % m)
continue
if 2 == d:
print(3 % m)
continue
j = 1
s = 3
p = 2
while d >= e[j + 1]:
s = abs(p) * (e[j] - 1... | ASSIGN VAR BIN_OP NUMBER VAR VAR FUNC_CALL VAR 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 DICT NUMBER NUMBER NUMBER NUMBER IF NUMBER VAR EXPR FUNC_CALL VAR BIN_OP NUMBER VAR IF NUMBER VAR EXPR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN... |
Dreamoon likes sequences very much. So he created a problem about the sequence that you can't find in OEIS:
You are given two integers d, m, find the number of arrays a, satisfying the following constraints:
* The length of a is n, n ≥ 1
* 1 ≤ a_1 < a_2 < ... < a_n ≤ d
* Define an array b of length n as foll... | t = int(input())
for _ in range(t):
d, m = map(int, input().split())
l = len(bin(d)) - 2
f = 0
for i in range(2, l + 1):
f = (2 ** (i - 2) + f * (1 + 2 ** (i - 2))) % m
ans = d - 2 ** (l - 1) + 1 + f * (d - 2 ** (l - 1) + 2)
ans %= m
print(ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER BIN_OP VAR BIN_OP N... |
Dreamoon likes sequences very much. So he created a problem about the sequence that you can't find in OEIS:
You are given two integers d, m, find the number of arrays a, satisfying the following constraints:
* The length of a is n, n ≥ 1
* 1 ≤ a_1 < a_2 < ... < a_n ≤ d
* Define an array b of length n as foll... | t = int(input())
for q in range(t):
n, m = map(int, input().split())
st = 1
ans = 1
while st <= n:
ans *= min(st * 2 - st + 1, n - st + 2)
st *= 2
print((ans - 1) % m) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR |
Dreamoon likes sequences very much. So he created a problem about the sequence that you can't find in OEIS:
You are given two integers d, m, find the number of arrays a, satisfying the following constraints:
* The length of a is n, n ≥ 1
* 1 ≤ a_1 < a_2 < ... < a_n ≤ d
* Define an array b of length n as foll... | for _ in range(int(input())):
d, mod = map(int, input().split())
s = 0
ind = []
for i in range(41):
if s + (1 << i) < d:
s += 1 << i
ind.append(1 << i)
else:
ind.append(d - s)
break
def vie(roots, n):
coeff = [0] * (n + 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 NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR BIN_OP NUMBER VAR VAR VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR FUNC_DEF ASSIGN VAR B... |
Dreamoon likes sequences very much. So he created a problem about the sequence that you can't find in OEIS:
You are given two integers d, m, find the number of arrays a, satisfying the following constraints:
* The length of a is n, n ≥ 1
* 1 ≤ a_1 < a_2 < ... < a_n ≤ d
* Define an array b of length n as foll... | import sys
input = sys.stdin.readline
Q = int(input())
Query = [list(map(int, input().split())) for _ in range(Q)]
for D, mod in Query:
L = D.bit_length()
A = []
for i in range(L - 1):
A.append(1 << i)
A.append(D - (1 << L - 1) + 1)
ans = 1
for a in A:
ans = ans * (a + 1) % mod
... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR... |
Dreamoon likes sequences very much. So he created a problem about the sequence that you can't find in OEIS:
You are given two integers d, m, find the number of arrays a, satisfying the following constraints:
* The length of a is n, n ≥ 1
* 1 ≤ a_1 < a_2 < ... < a_n ≤ d
* Define an array b of length n as foll... | import sys
from itertools import accumulate
def input():
return sys.stdin.readline().strip()
def list2d(a, b, c):
return [([c] * b) for i in range(a)]
def list3d(a, b, c, d):
return [[([d] * c) for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e):
return [[[([e] * d) for j in range(c)... | IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN BIN_OP LIST VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF RETURN BIN_OP LIST VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF RETURN BIN_OP LIST VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF NUMBER RETURN FUNC_CALL ... |
Dreamoon likes sequences very much. So he created a problem about the sequence that you can't find in OEIS:
You are given two integers d, m, find the number of arrays a, satisfying the following constraints:
* The length of a is n, n ≥ 1
* 1 ≤ a_1 < a_2 < ... < a_n ≤ d
* Define an array b of length n as foll... | t = int(input())
while t:
d, m = map(int, input().split())
power = [1]
for i in range(50):
power.append(power[-1] * 2 % m)
ans = 1
for i in range(1, 32):
if d >= 2**i:
ans *= power[i - 1] + 1
ans %= m
else:
ans *= d - power[i - 1] + 2
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER IF VAR BIN_OP NUMBER VAR VAR BIN_OP VAR BIN_OP VAR NU... |
Dreamoon likes sequences very much. So he created a problem about the sequence that you can't find in OEIS:
You are given two integers d, m, find the number of arrays a, satisfying the following constraints:
* The length of a is n, n ≥ 1
* 1 ≤ a_1 < a_2 < ... < a_n ≤ d
* Define an array b of length n as foll... | from sys import gettrace, stdin
if not gettrace():
def input():
return next(stdin)[:-1]
def modInt(mod):
class ModInt:
def __init__(self, value):
self.value = value % mod
def __int__(self):
return self.value
def __eq__(self, other):
ret... | IF FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR NUMBER FUNC_DEF CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP VAR VAR FUNC_DEF RETURN VAR FUNC_DEF RETURN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_DEF RETURN FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR VAR FUNC_DEF RETURN FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR VAR FUNC_DEF RET... |
Dreamoon likes sequences very much. So he created a problem about the sequence that you can't find in OEIS:
You are given two integers d, m, find the number of arrays a, satisfying the following constraints:
* The length of a is n, n ≥ 1
* 1 ≤ a_1 < a_2 < ... < a_n ≤ d
* Define an array b of length n as foll... | def msb(x):
return len(bin(x)) - 2
def solve():
d, mod = map(int, input().split())
way = 1
for i in range(msb(d) - 1):
way += way * (1 << i)
way += way * (d + 1 - (1 << msb(d) - 1))
print((way - 1) % mod)
for _ in range(int(input())):
solve() | FUNC_DEF RETURN BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR BIN_OP VAR BIN_OP NUMBER VAR VAR BIN_OP VAR BIN_OP BIN_OP VAR NUMBER BIN_OP NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER E... |
Dreamoon likes sequences very much. So he created a problem about the sequence that you can't find in OEIS:
You are given two integers d, m, find the number of arrays a, satisfying the following constraints:
* The length of a is n, n ≥ 1
* 1 ≤ a_1 < a_2 < ... < a_n ≤ d
* Define an array b of length n as foll... | t = int(input())
maxd = 32
for case_num in range(t):
d, m = map(int, input().split(" "))
cnt = [0] * maxd
num = 2
i = 1
while num - 1 <= d:
cnt[i] = num // 2
num *= 2
i += 1
cnt[i] = d - num // 2 + 1
ans = 1
for l in range(1, maxd):
ans = ans * (cnt[l] + 1... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR VAR BIN_O... |
Dreamoon likes sequences very much. So he created a problem about the sequence that you can't find in OEIS:
You are given two integers d, m, find the number of arrays a, satisfying the following constraints:
* The length of a is n, n ≥ 1
* 1 ≤ a_1 < a_2 < ... < a_n ≤ d
* Define an array b of length n as foll... | def log(x):
p = 0
v = 1
while v <= x:
p += 1
v *= 2
return p
ans = []
def ps(arr, m):
n = len(arr)
ans = 1
for i in range(0, n):
ans = ans * ((arr[i] + 1) % m) % m
return ans - 1
for _ in range(int(input())):
[d, m] = [int(i) for i in input().split()]
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR LIST FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR RETURN BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL ... |
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef's good friend Shubham has an assignment to complete, but he is too lazy to do it, so he asked Chef to help him. On the other hand, Chef was busy in the kitchen, so he in turn asked you to help Shubham.
You are... | for _ in range(int(input())):
n, k = map(int, input().split())
arr = list(map(int, input().split()))
set_bits = [0] * 30
for i in arr:
x = bin(i)[2:]
x = x[::-1]
for j in range(len(x)):
if x[j] == "1":
set_bits[j] += 1
dct = {}
for i in range(3... | 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 BIN_OP LIST NUMBER NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR... |
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef's good friend Shubham has an assignment to complete, but he is too lazy to do it, so he asked Chef to help him. On the other hand, Chef was busy in the kitchen, so he in turn asked you to help Shubham.
You are... | class SlotInfo:
pos = 0
count = 0
unitValue = 0
totalValue = 0
def __repr__(self):
return repr(self.__dict__)
def debug(*args, **kwargs):
pass
def main():
noOfTests = int(input())
for i in range(noOfTests):
print(runATest(i))
def runATest(_testIndex):
[aCount, ... | CLASS_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN LIST VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NU... |
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef's good friend Shubham has an assignment to complete, but he is too lazy to do it, so he asked Chef to help him. On the other hand, Chef was busy in the kitchen, so he in turn asked you to help Shubham.
You are... | for _ in range(int(input())):
n, k = map(int, input().split())
count = [0] * 30
ar = list(map(int, input().split()))
for elm in ar:
for i in range(30):
if elm & 1 << i > 0:
count[i] += 1
val = []
for i in range(30):
val.append((-count[i] * (1 << i), i)... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR BIN_OP NUMBER VAR NUMBER VAR VAR NUMBER ASSIGN VAR LIS... |
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef's good friend Shubham has an assignment to complete, but he is too lazy to do it, so he asked Chef to help him. On the other hand, Chef was busy in the kitchen, so he in turn asked you to help Shubham.
You are... | for test in range(int(input())):
n, k = map(int, input().split())
a = [0] * 30
for A in input().split():
A = int(A)
for i in range(30):
if 1 << i & A:
a[i] += 1 << i
ans = 0
for i in sorted(list(range(30)), key=lambda i: (-a[i], i))[:k]:
ans |= 1 <... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP BIN_OP NUMBER VAR VAR VAR VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER FOR VAR FU... |
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef's good friend Shubham has an assignment to complete, but he is too lazy to do it, so he asked Chef to help him. On the other hand, Chef was busy in the kitchen, so he in turn asked you to help Shubham.
You are... | t = int(input())
for _ in range(t):
n, k = map(int, input().split())
l = list(map(int, input().split()))
d = {}
for j in range(30):
c = 0
t = 1 << j
for i in l:
if i & t:
c += 1
d[j] = c * 2**j
sd = sorted(d.items(), key=lambda x: x[1], rev... | 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 DICT FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR FOR VAR VAR IF BIN_OP VAR VAR VAR NUMBE... |
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef's good friend Shubham has an assignment to complete, but he is too lazy to do it, so he asked Chef to help him. On the other hand, Chef was busy in the kitchen, so he in turn asked you to help Shubham.
You are... | for _ in range(int(input())):
values = [[0, 2**i] for i in range(30)]
n, k = map(int, input().split())
arr = list(map(int, input().split()))
for a in arr:
for value in values:
value[0] += value[1] & a
values.sort(key=lambda x: x[0], reverse=True)
ans = 0
for i in range(k)... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER BIN_OP NUMBER VAR VAR FUNC_CALL VAR NUMBER 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 FOR VAR VAR FOR VAR VAR VAR NUMBER BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR VAR ... |
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef's good friend Shubham has an assignment to complete, but he is too lazy to do it, so he asked Chef to help him. On the other hand, Chef was busy in the kitchen, so he in turn asked you to help Shubham.
You are... | t = int(input())
while t:
s = input().split()
n, k = int(s[0]), int(s[1])
a = input().split()
for i in range(n):
a[i] = int(a[i])
count = []
for i in range(31):
count.append(0)
for i in a:
bit = 0
while i != 0:
if i % 2 == 1:
count[... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE 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 FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER FO... |
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef's good friend Shubham has an assignment to complete, but he is too lazy to do it, so he asked Chef to help him. On the other hand, Chef was busy in the kitchen, so he in turn asked you to help Shubham.
You are... | t = int(input())
while t > 0:
n, k = map(int, input().split())
arr = [int(x) for x in input().split()]
brep = []
length = 30
for ele in arr:
brep.append("0" * (length - len(bin(ele)[2:])) + bin(ele)[2:])
dic = dict()
for i in range(0, length):
count = 0
for ele in bre... | 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 LIST ASSIGN VAR NUMBER FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP STRING BIN_OP VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR ... |
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef's good friend Shubham has an assignment to complete, but he is too lazy to do it, so he asked Chef to help him. On the other hand, Chef was busy in the kitchen, so he in turn asked you to help Shubham.
You are... | t = int(input())
while t > 0:
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
d = [0] * 35
for i in range(n):
c = a[i]
i = 0
while c > 0:
e = c % 2
z = e * pow(2, i)
d[i] += z
c = c // 2
i += 1... | 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 BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VA... |
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef's good friend Shubham has an assignment to complete, but he is too lazy to do it, so he asked Chef to help him. On the other hand, Chef was busy in the kitchen, so he in turn asked you to help Shubham.
You are... | for _ in range(int(input())):
n, k = list(map(int, input().split()))
l = list(map(int, input().split()))
l1 = [0] * 32
for t in l:
for i in range(32):
if t % 2 == 1:
l1[i] += 2**i
t = t // 2
if t == 0:
break
l2 = l1[:]
l... | 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 BIN_OP LIST NUMBER NUMBER FOR VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR VAR BIN_OP NUMBER VAR ... |
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef's good friend Shubham has an assignment to complete, but he is too lazy to do it, so he asked Chef to help him. On the other hand, Chef was busy in the kitchen, so he in turn asked you to help Shubham.
You are... | def decimalToBinary(n):
return bin(n).replace("0b", "")
for _ in range(int(input())):
N, K = map(int, input().split())
array = list(map(int, input().split()))
for j in range(0, len(array)):
ans = decimalToBinary(array[j])
array[j] = "0" * (30 - len(ans)) + ans
lookup = {}
for i... | 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 FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN V... |
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef's good friend Shubham has an assignment to complete, but he is too lazy to do it, so he asked Chef to help him. On the other hand, Chef was busy in the kitchen, so he in turn asked you to help Shubham.
You are... | t = int(input())
while t != 0:
t = t - 1
n, k = map(int, input().split())
a = list(map(int, input().split()))
a1 = [0] * 30
for i in a:
s1 = bin(i)
n1 = len(s1)
for j in range(n1 - 1, 1, -1):
a1[n1 - 1 - j] = a1[n1 - 1 - j] + int(s1[j])
flag = 1
for i in r... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR ... |
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef's good friend Shubham has an assignment to complete, but he is too lazy to do it, so he asked Chef to help him. On the other hand, Chef was busy in the kitchen, so he in turn asked you to help Shubham.
You are... | try:
t = int(input())
for _ in range(t):
n, z = map(int, input().split())
l = [int(a) for a in input().split()]
b = [bin(c)[2:] for c in l]
m = max(len(i) for i in b)
final_sum = []
for j in range(m):
k = sum(2**j & i for i in l)
final_sum.... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSI... |
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef's good friend Shubham has an assignment to complete, but he is too lazy to do it, so he asked Chef to help him. On the other hand, Chef was busy in the kitchen, so he in turn asked you to help Shubham.
You are... | t = int(input())
def isSet(elem, k):
if elem & 1 << k:
return 1
return 0
for _ in range(t):
n, k = map(int, input().split())
x = list(map(int, input().split()))
gem = [0] * 30
kii = [0] * 30
for i in range(len(x)):
for j in range(30):
if isSet(x[i], j):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF IF BIN_OP VAR BIN_OP NUMBER VAR RETURN NUMBER RETURN NUMBER 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 BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NU... |
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef's good friend Shubham has an assignment to complete, but he is too lazy to do it, so he asked Chef to help him. On the other hand, Chef was busy in the kitchen, so he in turn asked you to help Shubham.
You are... | t = int(input())
for _ in range(t):
n, k = map(int, input().split(" "))
arr = list(map(int, input().split(" ")))
bit_set = [0] * 30
for i in range(30):
for j in arr:
if j & 1 << i:
bit_set[i] += 1
sum_arr = []
digit_arr = []
for i in range(30):
dig... | 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 BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR VAR IF BIN_OP VAR BIN_OP NUMBER VAR VAR VAR... |
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef's good friend Shubham has an assignment to complete, but he is too lazy to do it, so he asked Chef to help him. On the other hand, Chef was busy in the kitchen, so he in turn asked you to help Shubham.
You are... | for _ in range(int(input())):
n, k = map(int, input().split())
a = list(map(int, input().split()))
c = [0] * 30
for i in range(n):
b = bin(a[i]).replace("0b", "")
b = b[::-1]
for j in range(len(b)):
c[j] += int(b[j])
for i in range(30):
c[i] = c[i] * 2**i
... | 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 BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR VAR STRING STRING ASSIGN VAR VAR NUMBER FOR ... |
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef's good friend Shubham has an assignment to complete, but he is too lazy to do it, so he asked Chef to help him. On the other hand, Chef was busy in the kitchen, so he in turn asked you to help Shubham.
You are... | def insert(a):
for i in range(1, len(a)):
key = a[i].copy()
j = i - 1
while j >= 0 and a[j][1] >= key[1]:
a[j + 1][0] = a[j][0]
a[j + 1][1] = a[j][1]
j -= 1
a[j + 1][0] = key[0]
a[j + 1][1] = key[1]
return a
for _ in range(int(input()... | FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER ASS... |
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef's good friend Shubham has an assignment to complete, but he is too lazy to do it, so he asked Chef to help him. On the other hand, Chef was busy in the kitchen, so he in turn asked you to help Shubham.
You are... | for _ in range(int(input())):
n, k = map(int, input().split())
l = list(map(int, input().split()))
mask = 1
t = [0] * 30
for j in range(30):
for i, x in enumerate(l):
if x & mask << j:
t[j] += 1
c = 1
for i, x in enumerate(t):
t[i] *= c
c *... | 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 BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF BIN_OP VAR BIN_OP VAR VAR VAR... |
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef's good friend Shubham has an assignment to complete, but he is too lazy to do it, so he asked Chef to help him. On the other hand, Chef was busy in the kitchen, so he in turn asked you to help Shubham.
You are... | for _ in range(int(input())):
N, K = [int(i) for i in input().split(" ")]
A = [int(i) for i in input().split(" ")]
H = max(A)
sett = len(str(bin(H))) - 2
tab = [0] * sett
for i in range(N):
for j in range(1, len(str(bin(A[i]))) - 1):
if str(bin(A[i]))[-j] == "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 STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR ... |
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef's good friend Shubham has an assignment to complete, but he is too lazy to do it, so he asked Chef to help him. On the other hand, Chef was busy in the kitchen, so he in turn asked you to help Shubham.
You are... | for _ in range(int(input())):
n, k = map(int, input().split())
arr = list(map(int, input().split()))
bins = []
bit = [0] * 30
ans = [0] * 30
w = [i for i in range(29, -1, -1)]
for i in range(n):
b = bin(arr[i])[2:]
bins.append("0" * (30 - len(b)) + b)
for i in range(30):
... | 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 LIST ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER FO... |
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef's good friend Shubham has an assignment to complete, but he is too lazy to do it, so he asked Chef to help him. On the other hand, Chef was busy in the kitchen, so he in turn asked you to help Shubham.
You are... | for test in range(int(input())):
bits = [(0) for i in range(32)]
n, k = map(int, input().split())
l = list(map(int, input().split()))
for i in l:
c = 0
t = i
while t:
if t & 1:
bits[c] += 1
c += 1
t >>= 1
val = [(bits[i] * 2... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER 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 FOR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR IF BIN_OP VAR NUMBER VAR VAR NUMBER VAR NUMBER V... |
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef's good friend Shubham has an assignment to complete, but he is too lazy to do it, so he asked Chef to help him. On the other hand, Chef was busy in the kitchen, so he in turn asked you to help Shubham.
You are... | def f(n):
l = []
while n > 0:
l.append(n % 2)
n = n // 2
return l
t = int(input())
while t > 0:
t = t - 1
n, k = map(int, input().split())
a = input()
A = list(map(int, list(a.split())))
y = 0
d = [0] * 30
for i in range(n):
l = f(A[i])
m = len(l... | FUNC_DEF ASSIGN VAR LIST WHILE VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL... |
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef's good friend Shubham has an assignment to complete, but he is too lazy to do it, so he asked Chef to help him. On the other hand, Chef was busy in the kitchen, so he in turn asked you to help Shubham.
You are... | T = int(input())
for _ in range(T):
n, k = map(int, input().split())
a = list(map(int, input().split()))
l = []
for i in range(31):
s = 0
for j in range(n):
if a[j] & 1 << i:
s += 1
l.append((s * (1 << i), 1 << i))
l.sort(key=lambda x: (-x[0], x[1]... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR BIN_OP NUMBER VAR VAR NU... |
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef's good friend Shubham has an assignment to complete, but he is too lazy to do it, so he asked Chef to help him. On the other hand, Chef was busy in the kitchen, so he in turn asked you to help Shubham.
You are... | t = int(input())
for _ in range(t):
n, b = map(int, input().split())
arr = list(map(int, input().split()))
o = 0
for i in range(n):
o |= arr[i]
m = {}
for k in range(0, 30):
m[k] = 0
for i in range(n):
s = bin(arr[i])[2:][::-1]
for j in range(len(s)):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER F... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.