description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
You are given non-negative integers A, B and C.
Does there exist a non-negative integer X such that A \oplus X+ B \oplus X = C \oplus X?
As a reminder, \oplus denotes the [bitwise XOR operation].
------ Input Format ------
- The first line of input will contain a single integer T, denoting the number of test cases... | for _ in range(int(input())):
a, b, c = map(int, input().split())
i = 0
con = 0
while i < 28:
x = a & 1
y = b & 1
z = c & 1
if x == y and x != z:
con = con + 1
i = i + 1
a = a >> 1
b = b >> 1
c = c >> 1
if con % 2:
p... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR... |
You are given non-negative integers A, B and C.
Does there exist a non-negative integer X such that A \oplus X+ B \oplus X = C \oplus X?
As a reminder, \oplus denotes the [bitwise XOR operation].
------ Input Format ------
- The first line of input will contain a single integer T, denoting the number of test cases... | def getBitSum(a, b, carry):
return a ^ b ^ carry
def getCarry(a, b, carry):
return (a & b) + (carry & (a ^ b))
def getIthBit(x, i):
return x >> i & 1
t = int(input())
while t:
t -= 1
a, b, c = map(int, input().split())
result = 0
possibleSum = 0
possibleSumWithXor = 0
carry = 0... | FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR VAR FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR BIN_OP VAR BIN_OP VAR VAR FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR N... |
You are given non-negative integers A, B and C.
Does there exist a non-negative integer X such that A \oplus X+ B \oplus X = C \oplus X?
As a reminder, \oplus denotes the [bitwise XOR operation].
------ Input Format ------
- The first line of input will contain a single integer T, denoting the number of test cases... | t = int(input())
for _ in range(t):
a, b, c = map(int, input().split())
bina = str(bin(a))[2:]
binb = str(bin(b))[2:]
binc = str(bin(c))[2:]
lena = len(bina)
lenb = len(binb)
lenc = len(binc)
n = max([lena, lenb, lenc])
bina = (n - lena) * "0" + bina
binb = (n - lenb) * "0" + bin... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC... |
You are given non-negative integers A, B and C.
Does there exist a non-negative integer X such that A \oplus X+ B \oplus X = C \oplus X?
As a reminder, \oplus denotes the [bitwise XOR operation].
------ Input Format ------
- The first line of input will contain a single integer T, denoting the number of test cases... | for _ in range(int(input())):
a, b, c = map(int, input().split())
carry = 0
for i in range(30):
v1 = a >> i & 1
v2 = b >> i & 1
v3 = c >> i & 1
for x in range(2):
if (v1 ^ x) + (v2 ^ x) + carry & 1 == v3 ^ x:
carry = int((v1 ^ x) + (v2 ^ x) + carry... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP BIN... |
You are given non-negative integers A, B and C.
Does there exist a non-negative integer X such that A \oplus X+ B \oplus X = C \oplus X?
As a reminder, \oplus denotes the [bitwise XOR operation].
------ Input Format ------
- The first line of input will contain a single integer T, denoting the number of test cases... | def has_ans(a, b, c, s):
if a == 0 and b == 0 and c == 0:
return s == 0
next_bit = 0
if ((next_bit ^ a) + (next_bit ^ b)) % 2 != ((c ^ next_bit) + s) % 2:
next_bit = 1
s += -(a % 2 ^ next_bit) - (b % 2 ^ next_bit) + (c % 2 ^ next_bit)
s /= 2
return has_ans(int(a / 2), int(b / 2),... | FUNC_DEF IF VAR NUMBER VAR NUMBER VAR NUMBER RETURN VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR NUMBER BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER ASSIGN VAR NUMBER VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER VAR BIN_OP BIN_OP VAR NUMBER VAR BIN_OP BIN_OP VAR NUMBER VAR VAR NUMBER RETURN FUNC... |
You are given non-negative integers A, B and C.
Does there exist a non-negative integer X such that A \oplus X+ B \oplus X = C \oplus X?
As a reminder, \oplus denotes the [bitwise XOR operation].
------ Input Format ------
- The first line of input will contain a single integer T, denoting the number of test cases... | def ans(a, b, c):
x = ""
carry = 0
for i in range(0, len(bin(max(a, b, c))) - 2):
ai = a >> i & 1
bi = b >> i & 1
ci = c >> i & 1
if ai == bi == ci == 1:
if carry == 0:
x += "1"
else:
x += "0"
elif ai == bi == ci... | FUNC_DEF ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR NUMBER IF VAR NUMBER VAR STRING VAR STRING ... |
You are given non-negative integers A, B and C.
Does there exist a non-negative integer X such that A \oplus X+ B \oplus X = C \oplus X?
As a reminder, \oplus denotes the [bitwise XOR operation].
------ Input Format ------
- The first line of input will contain a single integer T, denoting the number of test cases... | t = int(input())
def possible(a, b, c, carry):
if a + b + c == 0:
return carry == 0
ax = a % 2
bx = b % 2
cx = c % 2
if (ax + bx + carry) % 2 == cx:
if possible(a >> 1, b >> 1, c >> 1, (ax + bx + carry) // 2):
return True
if (1 - ax + 1 - bx + carry) % 2 == 1 - cx:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF IF BIN_OP BIN_OP VAR VAR VAR NUMBER RETURN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER VAR IF FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP BIN_OP... |
You are given non-negative integers A, B and C.
Does there exist a non-negative integer X such that A \oplus X+ B \oplus X = C \oplus X?
As a reminder, \oplus denotes the [bitwise XOR operation].
------ Input Format ------
- The first line of input will contain a single integer T, denoting the number of test cases... | def get_bin(n):
l = [(0) for _ in range(28)]
for i in range(1, 28):
l[-i] = n % 2
n //= 2
return l
for _ in range(int(input())):
a, b, c = map(int, input().split())
a1, b1, c1 = get_bin(a), get_bin(b), get_bin(c)
car = 0
for i in range(1, 28):
if a1[-i] == b1[-i] an... | FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL V... |
You are given non-negative integers A, B and C.
Does there exist a non-negative integer X such that A \oplus X+ B \oplus X = C \oplus X?
As a reminder, \oplus denotes the [bitwise XOR operation].
------ Input Format ------
- The first line of input will contain a single integer T, denoting the number of test cases... | t = int(input())
while t:
a, b, c = map(int, input().split())
k = 0
for i in range(28):
x, y, z = a >> i & 1, b >> i & 1, c >> i & 1
if x == y and y != z:
k ^= 1
if k:
print("NO")
else:
print("YES")
t -= 1 | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR VAR VAR NUMBER IF VAR EXPR FUNC_CALL VAR S... |
You are given non-negative integers A, B and C.
Does there exist a non-negative integer X such that A \oplus X+ B \oplus X = C \oplus X?
As a reminder, \oplus denotes the [bitwise XOR operation].
------ Input Format ------
- The first line of input will contain a single integer T, denoting the number of test cases... | t = int(input())
for _ in range(t):
a, b, c = list(map(int, input().split()))
ba = bin(a)[2:]
bb = bin(b)[2:]
bc = bin(c)[2:]
m = max(len(ba), len(bb), len(bc))
ba = "0" * (m - len(ba)) + ba
bb = "0" * (m - len(bb)) + bb
bc = "0" * (m - len(bc)) + bc
ba = ba[::-1]
bb = bb[::-1]
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL V... |
You are given non-negative integers A, B and C.
Does there exist a non-negative integer X such that A \oplus X+ B \oplus X = C \oplus X?
As a reminder, \oplus denotes the [bitwise XOR operation].
------ Input Format ------
- The first line of input will contain a single integer T, denoting the number of test cases... | def soln(a, b, c):
def form(s):
return "0" * (32 - len(s)) + s
a = form(bin(a)[2:])
b = form(bin(b)[2:])
c = form(bin(c)[2:])
count = 0
for i in range(31, 0, -1):
if a[i] == b[i] and a[i] != c[i]:
count += 1
return "YES" if not count & 1 else "NO"
for _ in ran... | FUNC_DEF FUNC_DEF RETURN BIN_OP BIN_OP STRING BIN_OP NUMBER FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF VAR VAR VAR VAR VAR VAR ... |
You are given non-negative integers A, B and C.
Does there exist a non-negative integer X such that A \oplus X+ B \oplus X = C \oplus X?
As a reminder, \oplus denotes the [bitwise XOR operation].
------ Input Format ------
- The first line of input will contain a single integer T, denoting the number of test cases... | def solve(a, b, c):
carry = 0
for i in range(28):
if a & 1 == b & 1 and b & 1 != c & 1:
carry ^= 1
a >>= 1
b >>= 1
c >>= 1
if carry:
return False
return True
t = int(input())
for _ in range(t):
a, b, c = [int(x) for x in input().split()]
ans ... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER IF VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC... |
You are given non-negative integers A, B and C.
Does there exist a non-negative integer X such that A \oplus X+ B \oplus X = C \oplus X?
As a reminder, \oplus denotes the [bitwise XOR operation].
------ Input Format ------
- The first line of input will contain a single integer T, denoting the number of test cases... | for _ in range(int(input())):
a, b, c = map(int, input().split())
a, b, c = bin(a)[2:], bin(b)[2:], bin(c)[2:]
m = max(len(a), len(b), len(c))
a = "0" * (m - len(a)) + a
b = "0" * (m - len(b)) + b
c = "0" * (m - len(c)) + c
f = 0
ans = True
for i in range(m):
if a[i] + b[i] +... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP STRING BIN_... |
You are given non-negative integers A, B and C.
Does there exist a non-negative integer X such that A \oplus X+ B \oplus X = C \oplus X?
As a reminder, \oplus denotes the [bitwise XOR operation].
------ Input Format ------
- The first line of input will contain a single integer T, denoting the number of test cases... | def s(a, b, c):
r = 0
for i in range(28):
x, y, z = a >> i & 1, b >> i & 1, c >> i & 1
if x == y and y != z:
r ^= 1
return r
t = int(input())
for i in range(t):
a, b, c = map(int, input().split())
p = s(a, b, c)
if p:
print("NO")
else:
print("YES... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_... |
Monisha likes to paint. She has painted $N$ paintings (numbered $1$ through $N$) and wants to choose some subset of these paintings for an exhibition. For each valid $i$, the $i$-th painting has beauty $b_i$ and the probability that it will be displayed at the exhibition is $p_i$. Each painting is chosen or excluded fr... | k = 30
for _ in range(int(input())):
n = int(input())
l1 = list(map(int, input().split()))
l2 = list(map(float, input().split()))
ans = 0
for i in range(k):
p = 0
for j in range(n):
if l1[j] & 1 << i:
p = p * (1 - l2[j]) + (1 - p) * l2[j]
ans += p ... | ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL... |
Monisha likes to paint. She has painted $N$ paintings (numbered $1$ through $N$) and wants to choose some subset of these paintings for an exhibition. For each valid $i$, the $i$-th painting has beauty $b_i$ and the probability that it will be displayed at the exhibition is $p_i$. Each painting is chosen or excluded fr... | l = [1]
for k in range(31):
l.append(l[-1] * 2)
def convert(s):
while len(s) != 32:
s = "0" + s
ans = ""
for i in s:
ans = i + ans
return ans
def main():
for _ in range(int(input())):
n = int(input())
val = list(map(int, input().split()))
p = list(map(... | ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER FUNC_DEF WHILE FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR STRING FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR RETURN VAR FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC... |
Monisha likes to paint. She has painted $N$ paintings (numbered $1$ through $N$) and wants to choose some subset of these paintings for an exhibition. For each valid $i$, the $i$-th painting has beauty $b_i$ and the probability that it will be displayed at the exhibition is $p_i$. Each painting is chosen or excluded fr... | for i in range(int(input())):
n = int(input())
b = list(map(int, input().split()))
p = list(map(float, input().split()))
ans = 0
o = [0] * 30
for i in range(n):
s = bin(b[i])[2:]
for j in range(1, len(s) + 1):
if s[-j] == "1":
o[j - 1] = (1 - o[j - 1])... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR 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 VAR ASSIGN VAR FUNC_... |
Monisha likes to paint. She has painted $N$ paintings (numbered $1$ through $N$) and wants to choose some subset of these paintings for an exhibition. For each valid $i$, the $i$-th painting has beauty $b_i$ and the probability that it will be displayed at the exhibition is $p_i$. Each painting is chosen or excluded fr... | t = int(input())
while t:
x = 0
n = int(input())
b = list(map(int, input().strip().split()))
p = list(map(float, input().strip().split()))
for i in range(30):
pb = 0.0
for j in range(n):
if b[j] & 1 << i:
pb = pb * (1 - p[j]) + (1 - pb) * p[j]
x +=... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_... |
Monisha likes to paint. She has painted $N$ paintings (numbered $1$ through $N$) and wants to choose some subset of these paintings for an exhibition. For each valid $i$, the $i$-th painting has beauty $b_i$ and the probability that it will be displayed at the exhibition is $p_i$. Each painting is chosen or excluded fr... | t = int(input())
while t > 0:
n = int(input())
B = list(map(int, input().strip().split(" ")))
P = list(map(float, input().strip().split(" ")))
l = [0] * 32
ans = 0
cur_bit = 1
for i in range(0, 31):
cur_prob = 0.0
for j in range(0, len(B)):
if cur_bit & B[j]:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER AS... |
Monisha likes to paint. She has painted $N$ paintings (numbered $1$ through $N$) and wants to choose some subset of these paintings for an exhibition. For each valid $i$, the $i$-th painting has beauty $b_i$ and the probability that it will be displayed at the exhibition is $p_i$. Each painting is chosen or excluded fr... | for _ in range(int(input())):
n = int(input())
xl = [int(x) for x in input().split()]
pl = [float(x) for x in input().split()]
tl = [0] * 30
for x, p in zip(xl, pl):
bs = bin(x)[2:][::-1]
for i in range(len(bs)):
if bs[i] == "1":
tl[i] = (1 - tl[i]) * p + ... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER NUMBER FOR... |
Monisha likes to paint. She has painted $N$ paintings (numbered $1$ through $N$) and wants to choose some subset of these paintings for an exhibition. For each valid $i$, the $i$-th painting has beauty $b_i$ and the probability that it will be displayed at the exhibition is $p_i$. Each painting is chosen or excluded fr... | def findout(P):
ans = 1
ans2 = 1
for x in P:
ans *= 2 * x - 1
if len(P) % 2 == 0:
return (1 - ans) / 2
else:
return (1 + ans) / 2
def find(b, p):
B = max(b)
okay = len(bin(B)[2:])
new_b = []
for x in b:
new_b += [("0" * (okay - len(bin(x)[2:])) + bin... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR BIN_OP BIN_OP NUMBER VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER RETURN BIN_OP BIN_OP NUMBER VAR NUMBER RETURN BIN_OP BIN_OP NUMBER VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST FOR... |
Monisha likes to paint. She has painted $N$ paintings (numbered $1$ through $N$) and wants to choose some subset of these paintings for an exhibition. For each valid $i$, the $i$-th painting has beauty $b_i$ and the probability that it will be displayed at the exhibition is $p_i$. Each painting is chosen or excluded fr... | for _ in range(int(input())):
n = int(input())
beauty, prob = list(map(int, input().split())), list(map(float, input().split()))
exp0, exp1 = [(1.0) for _ in range(31)], [(0.0) for _ in range(31)]
for i in range(n):
curr_beauty, curr_prob, j = beauty[i], prob[i], 0
while 30 >= j and 0 !=... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER VAR FUNC_CALL VAR NUMBER NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR... |
Monisha likes to paint. She has painted $N$ paintings (numbered $1$ through $N$) and wants to choose some subset of these paintings for an exhibition. For each valid $i$, the $i$-th painting has beauty $b_i$ and the probability that it will be displayed at the exhibition is $p_i$. Each painting is chosen or excluded fr... | t = int(input())
for _ in range(t):
n = int(input())
b = [int(i) for i in input().split()]
p = [float(i) for i in input().split()]
pb = [0] * 30
for i in range(n):
h = b[i]
j = 0
while h:
if h % 2 == 1:
x = pb[j]
y = p[i]
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER WH... |
Monisha likes to paint. She has painted $N$ paintings (numbered $1$ through $N$) and wants to choose some subset of these paintings for an exhibition. For each valid $i$, the $i$-th painting has beauty $b_i$ and the probability that it will be displayed at the exhibition is $p_i$. Each painting is chosen or excluded fr... | T = int(input())
for i in range(0, T):
N = int(input())
b = [int(x) for x in input().split()]
p = [float(x) for x in input().split()]
arr = [0] * 32
for j in range(0, len(b)):
st = bin(b[j])
st = st[2:]
for k in range(1, len(st) + 1):
if st[-k] == "1":
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR ... |
Monisha likes to paint. She has painted $N$ paintings (numbered $1$ through $N$) and wants to choose some subset of these paintings for an exhibition. For each valid $i$, the $i$-th painting has beauty $b_i$ and the probability that it will be displayed at the exhibition is $p_i$. Each painting is chosen or excluded fr... | t = int(input())
while t > 0:
n = int(input())
b = [int(x) for x in input().split()]
p = [float(x) for x in input().split()]
s = [0] * 10
yet = 2
mx = 0
for i in range(n):
st = bin(b[i])
rng = len(st) - 2
if rng + 2 > yet:
for ml in range(rng + 2 - yet):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR 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 \ge 1$ $1 \le a_1 < a_2 < \dots < a_n \le d$ Define an array $b$ of length... | from sys import stderr
def count_barfuls_by_ending(d, *, m):
n_total = 0
pow2 = 1
while d >= pow2:
n_total += (n_total + 1) * pow2
n_total %= m
d -= pow2
pow2 <<= 1
n_total += (n_total + 1) * d
return n_total % m
for _ in range(int(input())):
d, m = map(int, i... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR BIN_OP BIN_OP VAR NUMBER VAR VAR VAR VAR VAR VAR NUMBER VAR BIN_OP BIN_OP VAR NUMBER VAR RETURN BIN_OP 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 STRING EXPR FUNC_CALL VAR FUNC_CALL 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 \ge 1$ $1 \le a_1 < a_2 < \dots < a_n \le d$ Define an array $b$ of length... | import sys
def main():
import sys
input = sys.stdin.readline
for _ in range(int(input())):
d, mod = list(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 ... | IMPORT FUNC_DEF IMPORT ASSIGN VAR VAR 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 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 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 \ge 1$ $1 \le a_1 < a_2 < \dots < a_n \le d$ Define an array $b$ of length... | for q in range(int(input())):
dp = [0] * 35
d, m = [int(i) for i in input().split()]
for i in range(1, 35):
dp[i] = (pow(2, i - 1, m) * (dp[i - 1] + 1) + dp[i - 1]) % m
bn = bin(d)
k = len(bn) - 3
mm = d - (1 << k)
ans = (dp[k] * (mm + 2) + mm + 1) % m
print(ans) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP BIN_OP BIN_OP FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER... |
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 \ge 1$ $1 \le a_1 < a_2 < \dots < a_n \le d$ Define an array $b$ of length... | aas = []
for _ in range(int(input())):
d, m = map(int, input().split())
A = []
s = 1
sus = 0
while sus + s <= d:
A.append(s)
sus += s
s *= 2
A.append(d - sum(A))
ans = 1
for x in A:
ans *= x + 1
ans %= m
ans -= 1
ans %= m
aas.append(str... | ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR 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 \ge 1$ $1 \le a_1 < a_2 < \dots < a_n \le d$ Define an array $b$ of length... | import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
D, M = map(int, input().split())
L = []
rem = D
for i in range(40):
n = 1 << i
n = min(n, rem)
L.append(n)
rem -= n
if rem == 0:
break
ans = 1
for l in L:
ans = ... | 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 LIST ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR IF VAR NUMBER ASSIGN 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 \ge 1$ $1 \le a_1 < a_2 < \dots < a_n \le d$ Define an array $b$ of length... | t = int(input())
for _ in range(t):
d, m = map(int, input().split())
pot = [1] * 1000
for i in range(1, 1000):
pot[i] = 2 * pot[i - 1] % m
makscyfr = 0
dd = d
while dd > 0:
makscyfr += 1
dd //= 2
dp = [0] * (makscyfr + 1)
dp[1] = 1
for i in range(2, makscyfr +... | 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 FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP BIN_OP NUMBER VAR BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR NUMBER VAR NUMBER 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 \ge 1$ $1 \le a_1 < a_2 < \dots < a_n \le d$ Define an array $b$ of length... | t = int(input())
for loop in range(t):
d, mod = map(int, input().split())
sb = format(d, "b")
ans = 0
pr = 0
for i in range(len(sb)):
if i != len(sb) - 1:
ans += (ans + 1) * 2**i
else:
ans += (ans + 1) * (d - 2**i + 1)
ans %= mod
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 FUNC_CALL VAR VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR BIN_OP BIN_OP VAR NUMBER BIN_OP 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 \ge 1$ $1 \le a_1 < a_2 < \dots < a_n \le d$ Define an array $b$ of length... | import sys
lines = sys.stdin.readlines()
T = int(lines[0].strip())
def solve(d, m):
s = bin(d)[2:]
res = 1
for i in range(len(s) - 1):
res = (1 + 2**i) * res % m
res = res * (d - 2 ** (len(s) - 1) + 2) % m
res = (res - 1 + m) % m
print(res)
for t in range(1, T + 1):
d, m = map(i... | IMPORT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER BIN_OP NUMBER VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP VAR BIN_OP NUMBER... |
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 \ge 1$ $1 \le a_1 < a_2 < \dots < a_n \le d$ Define an array $b$ of length... | t = int(input())
for f in range(t):
d, m = map(int, input().split())
n = 1
p = 1
while d >= 2 * p:
n += 1
p *= 2
s = [0] * n
s[0] = 1
for i in range(n - 1):
pos = min(2 ** (i + 1), d + 1 - 2 ** (i + 1))
s[i + 1] = pos
for j in range(i + 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 NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP NUMBER VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FU... |
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 \ge 1$ $1 \le a_1 < a_2 < \dots < a_n \le d$ Define an array $b$ of length... | a = [1]
for i in range(30):
a.append(a[-1] * 2)
for t in range(int(input())):
d, m = map(int, input().split())
ans = 1
z = d.bit_length()
for i in range(z):
if i != z - 1:
ans = ans * (a[i + 1] - 1 - a[i] + 2) % m
else:
ans = ans * (d - a[i] + 2) % m
print... | ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP 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 NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER ASSIGN VAR 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 \ge 1$ $1 \le a_1 < a_2 < \dots < a_n \le d$ Define an array $b$ of length... | q = int(input())
for i in range(q):
inp = input().split()
p = int(inp[0])
n = int(inp[1])
e = 1
a = 1
t = 0
while e * 2 <= p:
t += e * a
e *= 2
a = t + 1
t %= n
t += (p - e + 1) * a
t %= n
print(t) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR NUMBER VAR VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR 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 \ge 1$ $1 \le a_1 < a_2 < \dots < a_n \le d$ Define an array $b$ of length... | import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
d, m = [int(a) for a in input().split()]
start = 1
end = 2
total = 1
while start <= d:
total *= min(end, d + 1) - start + 1
total %= m
start *= 2
end *= 2
print((total + m - 1) % m) | 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 ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR BIN_OP BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR VAR VAR NUMBER VAR NUMBER EXPR 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 \ge 1$ $1 \le a_1 < a_2 < \dots < a_n \le d$ Define an array $b$ of length... | import sys
def input():
return sys.stdin.readline().rstrip()
INF = 1 << 64
def filter(ord, M):
if 1 << ord <= M:
return min(M - (1 << ord) + 1, 1 << ord)
else:
return 0
def slv():
d, mod = map(int, input().split())
K = d.bit_length() - 1
DP = [([0] * (K + 1)) for i in ran... | IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER FUNC_DEF IF BIN_OP NUMBER VAR VAR RETURN FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP NUMBER VAR NUMBER BIN_OP NUMBER VAR RETURN NUMBER FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER 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 \ge 1$ $1 \le a_1 < a_2 < \dots < a_n \le d$ Define an array $b$ of length... | def main():
t = int(input())
power = [1]
for i in range(1, 31):
power.append(power[i - 1] * 2)
for _ in range(t):
d, m = map(int, input().split())
k = 0
p = d
while p != 0:
k += 1
p //= 2
basen = power[k - 1]
pp = [d - basen... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER 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 NUMBER VAR NUMBER VAR NUMBER ASS... |
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 \ge 1$ $1 \le a_1 < a_2 < \dots < a_n \le d$ Define an array $b$ of length... | import sys
input = sys.stdin.readline
t = int(input())
D = [((1 << i) - 1) for i in range(1, 32)]
for tests in range(t):
d, m = map(int, input().split())
ANS = [1]
B = [0]
for i in range(1, 32):
B.append(ANS[-1] + 1)
ANS.append((ANS[-1] + B[-1] * (1 << i)) % m)
for i in range(32):
... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL 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 \ge 1$ $1 \le a_1 < a_2 < \dots < a_n \le d$ Define an array $b$ of length... | T = int(input())
for case in range(T):
d, m = [int(x) for x in input().split()]
i = 0
tot = 1
while 2**i <= d:
r = 2**i, min(d + 1, 2 ** (i + 1))
nr = r[1] - r[0]
tot *= nr + 1
tot = tot % m
i += 1
tot = (tot - 1) % m
print(tot) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP NUMBER VAR VAR ASSIGN VAR BIN_OP NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER 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 \ge 1$ $1 \le a_1 < a_2 < \dots < a_n \le d$ Define an array $b$ of length... | def go():
d, m = map(int, input().split())
i = d.bit_length()
res = 0
while i >= 0:
bi = 1 << i
if d >= bi:
res += bitvals[i] % m * (d - bi + 1)
res = res % m
d = bi - 1
i -= 1
return res % m
bitvals = [1]
for i in range(33):
bitvals.... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR IF VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER RETURN BIN_OP 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 \ge 1$ $1 \le a_1 < a_2 < \dots < a_n \le d$ Define an array $b$ of length... | t = int(input())
for _ in range(t):
d, m = map(int, input().split())
ans = 1
i = 0
r = min(2 ** (i + 1) - 1, d) - 2**i + 2
while r > 0:
ans *= r
i += 1
r = min(2 ** (i + 1) - 1, d) - 2**i + 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 ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER VAR BIN_OP NUMBER VAR NUMBER WHILE VAR NUMBER VAR VAR VAR NUMBER 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 \ge 1$ $1 \le a_1 < a_2 < \dots < a_n \le d$ Define an array $b$ of length... | import sys
k = int(input())
t = -1
def input():
global t
t += 1
return data[t]
data = sys.stdin.readlines()
for _ in range(k):
d, m = map(int, input().split())
x = 1
p = 0
s = 1
while 2 * x <= d:
s *= x + 1
s %= m
p += 1
x *= 2
answer = (d - x + 2... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FUNC_DEF VAR NUMBER RETURN VAR VAR ASSIGN 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 ASSIGN VAR NUMBER WHILE BIN_OP NUMBER VAR VAR VAR BIN_OP VAR NUMBER VAR VAR 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 \ge 1$ $1 \le a_1 < a_2 < \dots < a_n \le d$ Define an array $b$ of length... | t = int(input())
for _ in range(t):
d, m = list(map(int, input().split()))
d += 1
out = 1
curr = 2
while curr < d:
out *= curr // 2 + 1
out %= m
curr *= 2
out *= d - curr // 2 + 1
print((out - 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 VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR VAR VAR NUMBER VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BI... |
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 \ge 1$ $1 \le a_1 < a_2 < \dots < a_n \le d$ Define an array $b$ of length... | import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
d, m = map(int, input().split())
ans = 1
i = 0
while pow(2, i) <= d:
ans = ans % m * (1 + min(pow(2, i + 1) - pow(2, i), d - pow(2, i) + 1) % m) % m
i += 1
print((ans - 1 + m) % m) | 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 NUMBER WHILE FUNC_CALL VAR NUMBER VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP NUMBER BIN_OP FUNC_CALL VAR BIN_OP FUNC_CALL VAR NUMBER BI... |
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 \ge 1$ $1 \le a_1 < a_2 < \dots < a_n \le d$ Define an array $b$ of length... | t = int(input())
for _ in range(t):
d, m = map(int, input().split())
a = []
i = 0
while d > (1 << i + 1) - 1:
a.append(1 << i)
i += 1
a.append((1 << i) - (1 << i + 1) + d + 1)
ans = 1
for x in a:
ans *= x + 1
ans %= m
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 LIST ASSIGN VAR NUMBER WHILE VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP BIN_OP NUMBER VAR BI... |
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 \ge 1$ $1 \le a_1 < a_2 < \dots < a_n \le d$ Define an array $b$ of length... | for _ in range(int(input())):
d, m = map(int, input().split())
ans = 1
for i in range(1, 31):
l = max(1, 1 << i - 1)
r = min(d, (1 << i) - 1)
ans = ans * (1 + (r - l + 1)) % m
if r == d:
break
print((ans - 1 + m) % m) | 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 NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP 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 \ge 1$ $1 \le a_1 < a_2 < \dots < a_n \le d$ Define an array $b$ of length... | t = int(input())
for _ in range(t):
d, m = map(int, input().split())
mm = -1
for i in range(0, 34):
if 1 << i & d != 0:
mm = i
count, temp = 1, 1
for i in range(mm + 1):
if 1 << i + 1 > d:
temp = d - (1 << i) + 2
else:
temp = (1 << i) + 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 NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER IF BIN_OP BIN_OP NUMBER VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF 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 \ge 1$ $1 \le a_1 < a_2 < \dots < a_n \le d$ Define an array $b$ of length... | import itertools
import sys
input = sys.stdin.readline
cnt = 0
log_size = (10**11).bit_length()
dp = [0] * log_size
dp[0] = 1
sum_ = 2
for i in range(log_size - 1):
dp[i + 1] = sum_
sum_ += 2 ** (i + 1) * dp[i + 1]
t = int(input())
for _ in range(t):
d, MOD = map(int, input().split())
ans = 0
for i... | IMPORT IMPORT ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER VAR BIN_OP VAR 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 \ge 1$ $1 \le a_1 < a_2 < \dots < a_n \le d$ Define an array $b$ of length... | T = int(input())
for _ in range(T):
D, M = map(int, input().split(" "))
x = D
pow2 = [1]
while x:
pow2.append(pow2[-1] * 2 % M)
x //= 2
ans = 1
for x in pow2[:-2]:
ans = ans * (x + 1) % M
ans = (ans * (D - pow2[-2] + 2 + M) % M - 1 + M) % 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 STRING ASSIGN VAR VAR ASSIGN VAR LIST NUMBER WHILE VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP 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 \ge 1$ $1 \le a_1 < a_2 < \dots < a_n \le d$ Define an array $b$ of length... | from itertools import accumulate
t = int(input())
for _ in range(t):
d, m = map(int, input().split())
per_bit = []
x = 1
while x * 2 <= d:
per_bit.append(x)
x *= 2
per_bit.append(d - sum(per_bit))
cur = per_bit[:]
total = 0
while sum(cur):
acc = list(accumulate(c... | 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 ASSIGN VAR NUMBER WHILE BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE FUNC_CALL VAR 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 \ge 1$ $1 \le a_1 < a_2 < \dots < a_n \le d$ Define an array $b$ of length... | arr = [
[1, 1, 1],
[2, 3, 2],
[4, 11, 6],
[8, 59, 30],
[16, 539, 270],
[32, 9179, 4590],
[64, 302939, 151470],
[128, 19691099, 9845550],
[256, 2540151899, 1270075950],
[512, 652819038299, 326409519150],
[1024, 334896166647899, 167448083323950],
[2048, 343268570814097499, ... | ASSIGN VAR LIST LIST NUMBER NUMBER NUMBER LIST NUMBER NUMBER NUMBER LIST NUMBER NUMBER NUMBER LIST NUMBER NUMBER NUMBER LIST NUMBER NUMBER NUMBER LIST NUMBER NUMBER NUMBER LIST NUMBER NUMBER NUMBER LIST NUMBER NUMBER NUMBER LIST NUMBER NUMBER NUMBER LIST NUMBER NUMBER NUMBER LIST NUMBER NUMBER NUMBER LIST NUMBER NUMBER... |
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 \ge 1$ $1 \le a_1 < a_2 < \dots < a_n \le d$ Define an array $b$ of length... | for _ in range(int(input())):
[n, m] = list(map(int, input().split()))
k = 1
arr = []
while n >= k:
n -= k
arr.append(k)
k *= 2
if n:
arr.append(n)
ans = 1
for i in arr:
ans *= i + 1
print((ans - 1) % m) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN LIST VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER IF VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR VAR BIN_OP VAR NUMBER EXPR 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 \ge 1$ $1 \le a_1 < a_2 < \dots < a_n \le d$ Define an array $b$ of length... | t = int(input())
def solve(d, m):
ans = 1
for i in range(30):
if d < 1 << i:
break
ans = ans * (min((1 << i + 1) - 1, d) - (1 << i) + 2) % m
ans -= 1
if ans < 0:
ans += m
return ans
while t:
t -= 1
d, m = [int(c) for c in input().split()]
print(sol... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP FUNC_CALL VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER VAR BIN_OP NUMBER VAR NUMBER VAR VAR NUMBER IF VAR NUMBER VAR VAR RETURN VAR WHILE VAR VAR NUMBER... |
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 \ge 1$ $1 \le a_1 < a_2 < \dots < a_n \le d$ Define an array $b$ of length... | for q in range(int(input())):
n, m = map(int, input().split())
st, ans = 1, 1
while st <= n:
ans *= min(st * 2 - st + 1, n - st + 2)
st *= 2
print((ans - 1) % m) | 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 NUMBER 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 \ge 1$ $1 \le a_1 < a_2 < \dots < a_n \le d$ Define an array $b$ of length... | for i in range(int(input())):
d, m = map(int, input().split())
a, k, s = [], 1, 1
while s < d:
a.append(k)
k <<= 1
s += k
a.append(d - s + k)
dp = [1]
for j in range(len(a)):
dp.append((a[j] + 1) * dp[-1])
print((dp[-1] - 1) % m) | 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 LIST NUMBER NUMBER WHILE VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_C... |
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 \ge 1$ $1 \le a_1 < a_2 < \dots < a_n \le d$ Define an array $b$ of length... | for t in range(int(input())):
d, m = [int(i) for i in input().split()]
tot = 0
p = 1
while p <= d:
p *= 2
p //= 2
while d > 0:
tot += (d - p + 1) * (tot + 1)
tot %= m
d = p - 1
p //= 2
print(tot) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER VAR NUMBER WHILE VAR NUMBER VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR NUMBER VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER EXPR 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 \ge 1$ $1 \le a_1 < a_2 < \dots < a_n \le d$ Define an array $b$ of length... | t = int(input().strip())
for k in range(t):
d, m = map(int, input().strip().split())
o = 1
oo = d
c = 0
while oo > 0:
c += 1
oo = oo // 2
while o <= d:
o = o * 2
o = o // 2
ll = [(0) for i in range(c + 1)]
start = o
fin = d
s = fin - start + 1
ll[c... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBE... |
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 \ge 1$ $1 \le a_1 < a_2 < \dots < a_n \le d$ Define an array $b$ of length... | store = []
maxes = [0]
def s(nums, M):
p = 1
for num in nums:
p = p * ((1 + num) % M) % M
if p == 0:
return M - 1
return (p - 1) % M
i = 0
while 2**i <= 10**9:
store.append(2**i)
maxes.append(2 ** (i + 1) - 1)
i += 1
T = int(input())
for t in range(T):
d, m = ... | ASSIGN VAR LIST ASSIGN VAR LIST NUMBER FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP NUMBER VAR VAR VAR IF VAR NUMBER RETURN BIN_OP VAR NUMBER RETURN BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER WHILE BIN_OP NUMBER VAR BIN_OP NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER VAR EXPR ... |
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 \ge 1$ $1 \le a_1 < a_2 < \dots < a_n \le d$ Define an array $b$ of length... | T = int(input())
for t in range(T):
d, m = map(int, input().split())
bd = bin(d)[2:]
lbd = len(bd)
ans = d - (1 << lbd - 1) + 1
for b in range(len(bd) - 1, 0, -1):
q = 1 << b - 1
ans = (ans + ans * q + q) % m
print(ans % 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 FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER 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 \ge 1$ $1 \le a_1 < a_2 < \dots < a_n \le d$ Define an array $b$ of length... | import sys
def main():
t = int(input())
allans = []
for _ in range(t):
d, m = readIntArr()
dMSB = 0
d2 = d
while d2 > 0:
dMSB += 1
d2 = d2 >> 1
nWaysAtThisMSB = [(0) for _ in range(dMSB + 1)]
for msb in range(1, dMSB):
nWa... | IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FU... |
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 \ge 1$ $1 \le a_1 < a_2 < \dots < a_n \le d$ Define an array $b$ of length... | def calc(n):
a = n.bit_length() - 1
X = [0] * 30
X[a] = n - (1 << a) + 1
for i in range(a):
X[i] = 1 << i
return X
T = int(input())
for _ in range(T):
d, m = map(int, input().split())
s = 1
for a in calc(d):
s = s * (a + 1) % m
print((s - 1) % m) | FUNC_DEF ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR VAR BIN_OP BIN_OP VAR BIN_OP NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP NUMBER VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL... |
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 \ge 1$ $1 \le a_1 < a_2 < \dots < a_n \le d$ Define an array $b$ of length... | pre = [1]
s = 1
for i in range(1, 31):
pre.append(s + 2**i * (s + 1))
s = pre[-1]
for nt in range(int(input())):
d, m = map(int, input().split())
if d == 1:
print(1 % m)
continue
if d == 2:
print(3 % m)
continue
arr = []
s = 0
ans = 0
for i in range(30... | ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP BIN_OP NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP N... |
Alice recently converted all the positive integers from 1 to 2^{N} - 1 (both inclusive) into binary strings and stored them in an array S. Note that the binary strings do not have leading zeroes.
While she was out, Bob sorted all the elements of S in lexicographical increasing order.
Let S_{i} denotes the i^{th} st... | def value(N, k):
if k == 1:
return 1
elif k <= 2 ** (N - 1):
return value(N - 1, k - 1)
else:
return value(N - 1, k - 2 ** (N - 1)) + 1
def sumk(N, k):
if k == 1:
return 1
elif k <= 2 ** (N - 1):
return 1 + sumk(N - 1, k - 1)
else:
return (
... | FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR BIN_OP NUMBER BIN_OP VAR NUMBER RETURN FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER RETURN BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR BIN_OP NUMBER BIN_OP VAR NUMBER RETURN BIN_OP N... |
Alice recently converted all the positive integers from 1 to 2^{N} - 1 (both inclusive) into binary strings and stored them in an array S. Note that the binary strings do not have leading zeroes.
While she was out, Bob sorted all the elements of S in lexicographical increasing order.
Let S_{i} denotes the i^{th} st... | def func(n, k, toggle):
if k == 2**n - 1:
return n * 2 ** (n - 1) - (toggle ^ 1) * k * 1
if n == 1:
return toggle
if k <= 2**n // 2:
return toggle * k * 1 + func(n - 1, k - 1, 0)
else:
return (
toggle * k * 1
+ func(n - 1, 2 ** (n - 1) - 1, 0)
... | FUNC_DEF IF VAR BIN_OP BIN_OP NUMBER VAR NUMBER RETURN BIN_OP BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBER BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER RETURN VAR IF VAR BIN_OP BIN_OP NUMBER VAR NUMBER RETURN BIN_OP BIN_OP BIN_OP VAR VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER RETURN B... |
Alice recently converted all the positive integers from 1 to 2^{N} - 1 (both inclusive) into binary strings and stored them in an array S. Note that the binary strings do not have leading zeroes.
While she was out, Bob sorted all the elements of S in lexicographical increasing order.
Let S_{i} denotes the i^{th} st... | T = int(input())
for line in range(T):
N, K = map(int, input().split())
digits = [1]
prior = [K - 1]
counter = K
block = 2**N - 1
for d in range(1, N):
if counter == 1:
break
counter -= 1
block = (block + 1) // 2 - 1
if counter <= block:
di... | 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 NUMBER ASSIGN VAR LIST BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP ... |
Alice recently converted all the positive integers from 1 to 2^{N} - 1 (both inclusive) into binary strings and stored them in an array S. Note that the binary strings do not have leading zeroes.
While she was out, Bob sorted all the elements of S in lexicographical increasing order.
Let S_{i} denotes the i^{th} st... | def fullcount(k, n):
pow2 = pow(2, n)
if k <= 0:
return 0
if k == 2 * pow2 - 3:
return (n - 1) * pow2 + 1
if k < pow2 - 1:
return fullcount(k - 1, n - 1)
if k >= pow2 - 1:
return fullcount(k - pow2, n - 1) + (k - pow2 + 2) + (n - 2) * pow2 // 2 + 1
return 1 / 0
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR NUMBER VAR IF VAR NUMBER RETURN NUMBER IF VAR BIN_OP BIN_OP NUMBER VAR NUMBER RETURN BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER IF VAR BIN_OP VAR NUMBER RETURN FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER RETURN BIN_OP BIN_OP BIN_OP FUNC_CALL VAR BIN_OP VA... |
Alice recently converted all the positive integers from 1 to 2^{N} - 1 (both inclusive) into binary strings and stored them in an array S. Note that the binary strings do not have leading zeroes.
While she was out, Bob sorted all the elements of S in lexicographical increasing order.
Let S_{i} denotes the i^{th} st... | def solve(n, k):
answer = 0
level = 0
curr = n
while True:
if k <= curr:
answer += (level + 1) * k
return answer
answer += (level + 1) * curr
k -= curr
i = 1
while k >= 2**i - 1:
k -= 2**i - 1
answer += (level + 1) *... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE NUMBER IF VAR VAR VAR BIN_OP BIN_OP VAR NUMBER VAR RETURN VAR VAR BIN_OP BIN_OP VAR NUMBER VAR VAR VAR ASSIGN VAR NUMBER WHILE VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP BIN_OP NUMBE... |
Alice recently converted all the positive integers from 1 to 2^{N} - 1 (both inclusive) into binary strings and stored them in an array S. Note that the binary strings do not have leading zeroes.
While she was out, Bob sorted all the elements of S in lexicographical increasing order.
Let S_{i} denotes the i^{th} st... | import sys
MAX_DEPTH = 50
def build_lookup_table():
table = [(0) for _ in range(MAX_DEPTH)]
for i in range(1, MAX_DEPTH):
table[i] = 2 * table[i - 1] + 2 ** (i - 1)
cumulative = [(0) for _ in range(MAX_DEPTH)]
for i in range(1, MAX_DEPTH):
cumulative[i] = cumulative[i - 1] + table[i]
... | IMPORT ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP BIN_OP NUMBER VAR BIN_OP VAR NUMBER BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VA... |
Alice recently converted all the positive integers from 1 to 2^{N} - 1 (both inclusive) into binary strings and stored them in an array S. Note that the binary strings do not have leading zeroes.
While she was out, Bob sorted all the elements of S in lexicographical increasing order.
Let S_{i} denotes the i^{th} st... | dp = [[0, 0], [2, 1]]
out = 0
def count(k, n, s):
global out
if k <= 0 or n <= 0:
return
if s:
out += k
if k == 1:
return
if k - (1 << n - 1) == 0:
out += dp[n - 2][1]
return
if k - (1 << n - 1) < 0:
count(k - 1, n - 1, 0)
return
out ... | ASSIGN VAR LIST LIST NUMBER NUMBER LIST NUMBER NUMBER ASSIGN VAR NUMBER FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN IF VAR VAR VAR IF VAR NUMBER RETURN IF BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER VAR VAR BIN_OP VAR NUMBER NUMBER RETURN IF BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP... |
Alice recently converted all the positive integers from 1 to 2^{N} - 1 (both inclusive) into binary strings and stored them in an array S. Note that the binary strings do not have leading zeroes.
While she was out, Bob sorted all the elements of S in lexicographical increasing order.
Let S_{i} denotes the i^{th} st... | a = [(0) for _ in range(51)]
a[1] = 1
for i in range(2, 51):
a[i] = 2 * a[i - 1] + 2 ** (i - 2)
b = [(0) for i in range(51)]
for i in range(1, 51):
b[i] = b[i - 1] + a[i]
def sol(target, n):
value = 1
sum1 = 1
num1 = 1
abnum = 2 ** (n - 1) - 1
while value != target:
if value + abnu... | ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP BIN_OP NUMBER VAR BIN_OP VAR NUMBER BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR... |
Given an integer N, Chef wants to find the smallest positive integer M such that the bitwise XOR of M and M+1 is N. If no such M exists output -1.
-----Input-----
The first line of input contain an integer T denoting the number of test cases. Each of the following T lines contains an integer N for that test case.
---... | t = int(input())
for _ in range(t):
n = int(input())
if n == 1:
print(2)
else:
x = "{0:0b}".format(n)
x = len(x)
c = pow(2, x)
if c - n == 1:
print(n - pow(2, x - 1))
else:
print(-1) | 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 ASSIGN VAR FUNC_CALL STRING VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR NUMBER BIN... |
Given an integer N, Chef wants to find the smallest positive integer M such that the bitwise XOR of M and M+1 is N. If no such M exists output -1.
-----Input-----
The first line of input contain an integer T denoting the number of test cases. Each of the following T lines contains an integer N for that test case.
---... | for _ in range(int(input())):
n = int(input())
if n == 1:
print(2)
continue
l = n.bit_length()
first = 1 << l - 1
second = n ^ first
if first - second == 1:
print(second)
else:
print(-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 ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER |
Given an integer N, Chef wants to find the smallest positive integer M such that the bitwise XOR of M and M+1 is N. If no such M exists output -1.
-----Input-----
The first line of input contain an integer T denoting the number of test cases. Each of the following T lines contains an integer N for that test case.
---... | t = int(input())
while t:
t -= 1
n = int(input())
if n == 1:
print(2)
elif n + 1 & n:
print(-1)
else:
print(n >> 1) | 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 BIN_OP BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER |
Given an integer N, Chef wants to find the smallest positive integer M such that the bitwise XOR of M and M+1 is N. If no such M exists output -1.
-----Input-----
The first line of input contain an integer T denoting the number of test cases. Each of the following T lines contains an integer N for that test case.
---... | try:
t = int(input())
while t > 0:
n = int(input())
if n == 1:
print(2)
continue
if n // 2 ^ n // 2 + 1 == n:
print(n // 2)
else:
print(-1)
t -= 1
except:
pass | 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 IF BIN_OP BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR NUMBER |
Given an integer N, Chef wants to find the smallest positive integer M such that the bitwise XOR of M and M+1 is N. If no such M exists output -1.
-----Input-----
The first line of input contain an integer T denoting the number of test cases. Each of the following T lines contains an integer N for that test case.
---... | t = int(input())
while t:
n = int(input())
if n == 1:
ans = 2
else:
p = n
p += 1
flag = 0
while p > 1:
if p % 2 == 1:
flag = 1
p = p / 2
if flag == 0:
k = bin(n)[2:].count("1")
ans = 2 ** (k - 1) ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER STRI... |
Given an integer N, Chef wants to find the smallest positive integer M such that the bitwise XOR of M and M+1 is N. If no such M exists output -1.
-----Input-----
The first line of input contain an integer T denoting the number of test cases. Each of the following T lines contains an integer N for that test case.
---... | t = int(input())
while t > 0:
n = int(input())
if n == 1:
print(2)
else:
q = 0
for i in range(1, 31):
p = 1 << i
if p ^ p - 1 == n:
print(p - 1)
q = 1
break
if q == 0:
print(-1)
t -= 1 | 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 NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER VAR IF BIN_OP VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMB... |
Given an integer N, Chef wants to find the smallest positive integer M such that the bitwise XOR of M and M+1 is N. If no such M exists output -1.
-----Input-----
The first line of input contain an integer T denoting the number of test cases. Each of the following T lines contains an integer N for that test case.
---... | def xor():
n = int(input())
a = bin(n)[2:]
if a.count("0") == 0:
if n == 1:
print(2)
else:
print(n >> 1)
else:
print(-1)
def __starting_point():
t = int(input())
while t != 0:
xor()
t -= 1
__starting_point() | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR STRING NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER EXPR FU... |
Given an integer N, Chef wants to find the smallest positive integer M such that the bitwise XOR of M and M+1 is N. If no such M exists output -1.
-----Input-----
The first line of input contain an integer T denoting the number of test cases. Each of the following T lines contains an integer N for that test case.
---... | for _ in range(int(input())):
a = int(input())
flag = 0
r = 0
if a == 1:
print("2")
elif a & a + 1 == 0:
print(a // 2)
else:
print("-1") | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING IF BIN_OP VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING |
Given an integer N, Chef wants to find the smallest positive integer M such that the bitwise XOR of M and M+1 is N. If no such M exists output -1.
-----Input-----
The first line of input contain an integer T denoting the number of test cases. Each of the following T lines contains an integer N for that test case.
---... | mod = 1000000007
read_int = lambda: int(input().strip())
read_str = lambda: input().strip()
read_str_arr = lambda: input().strip().split()
read_int_arr = lambda: [int(x) for x in input().strip().split()]
def solve():
N = read_int()
if N == 1:
ans = 2
elif N & N + 1 == 0:
ans = N >> 1
e... | ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR BIN_OP VAR NUMBER NUMBER A... |
Given an integer N, Chef wants to find the smallest positive integer M such that the bitwise XOR of M and M+1 is N. If no such M exists output -1.
-----Input-----
The first line of input contain an integer T denoting the number of test cases. Each of the following T lines contains an integer N for that test case.
---... | t = int(input())
while t != 0:
n = int(input())
b = bin(n)[2:]
if n == 1:
print(2)
elif "0" in b:
print(-1)
else:
print((n - 1) // 2)
t -= 1 | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF STRING VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR NUMBER |
Given an integer N, Chef wants to find the smallest positive integer M such that the bitwise XOR of M and M+1 is N. If no such M exists output -1.
-----Input-----
The first line of input contain an integer T denoting the number of test cases. Each of the following T lines contains an integer N for that test case.
---... | a = list()
i = 0
while i <= 30:
a.append(2**i - 1)
i += 1
for i in range(int(input())):
n = int(input())
if n == 1:
print("2")
continue
if n not in a:
print(-1)
else:
print(n // 2) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NU... |
Given an integer N, Chef wants to find the smallest positive integer M such that the bitwise XOR of M and M+1 is N. If no such M exists output -1.
-----Input-----
The first line of input contain an integer T denoting the number of test cases. Each of the following T lines contains an integer N for that test case.
---... | for _ in range(int(input())):
n = int(input())
if n == 1:
print(2)
else:
num_str = bin(n)
count = 0
for i in range(2, len(num_str)):
if num_str[i] == "0":
count += 1
if count == 0:
print(n - (n + 1) // 2)
else:
... | 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 FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP BIN_OP VAR NUMBER... |
Given an integer N, Chef wants to find the smallest positive integer M such that the bitwise XOR of M and M+1 is N. If no such M exists output -1.
-----Input-----
The first line of input contain an integer T denoting the number of test cases. Each of the following T lines contains an integer N for that test case.
---... | t = int(input())
for _ in range(t):
n = int(input())
if n == 1:
print(2)
continue
if n & n + 1 == 0:
x = (n + 1) // 2 - 1
print(x)
else:
print(-1) | 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 BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER |
Given an integer N, Chef wants to find the smallest positive integer M such that the bitwise XOR of M and M+1 is N. If no such M exists output -1.
-----Input-----
The first line of input contain an integer T denoting the number of test cases. Each of the following T lines contains an integer N for that test case.
---... | t = int(input())
for _ in range(t):
n = int(input())
for m in range(1, 30 + 1):
x = 2**m ^ 2**m - 1
y = 2**m ^ 2**m + 1
if x == n:
print(2**m - 1)
break
elif y == n:
print(2**m)
break
else:
print(-1) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR BIN_OP BIN_OP NUMBER VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR ... |
Given an integer N, Chef wants to find the smallest positive integer M such that the bitwise XOR of M and M+1 is N. If no such M exists output -1.
-----Input-----
The first line of input contain an integer T denoting the number of test cases. Each of the following T lines contains an integer N for that test case.
---... | t = int(input())
while t:
n = int(input())
if n == 1:
print(2)
t -= 1
continue
if n % 2 == 0:
print(-1)
t = t - 1
continue
idx = -1
for i in range(0, 31):
if pow(2, i) > n:
if pow(2, i) - 1 == n:
idx = n // 2
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER IF FUNC_CALL VAR NUMBER VAR VAR IF BIN_OP FU... |
Given an integer N, Chef wants to find the smallest positive integer M such that the bitwise XOR of M and M+1 is N. If no such M exists output -1.
-----Input-----
The first line of input contain an integer T denoting the number of test cases. Each of the following T lines contains an integer N for that test case.
---... | T = int(input())
ans = []
for _ in range(T):
N = int(input())
if N == 1:
ans.append(2)
elif "0" not in bin(N)[2:]:
ans.append(N // 2)
else:
ans.append(-1)
for i in ans:
print(i) | 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 IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF STRING FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR VAR EXPR FUNC_CALL VAR VAR |
Given an integer N, Chef wants to find the smallest positive integer M such that the bitwise XOR of M and M+1 is N. If no such M exists output -1.
-----Input-----
The first line of input contain an integer T denoting the number of test cases. Each of the following T lines contains an integer N for that test case.
---... | for _ in range(int(input())):
n = int(input())
i, a = 1, 0
if n == 1:
print(2)
else:
while 2**i <= n + 1:
if n == 2**i - 1:
a = 1
break
i += 1
if a == 1:
print(n // 2)
else:
print(-1) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER WHILE BIN_OP NUMBER VAR BIN_OP VAR NUMBER IF VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER E... |
Given an integer N, Chef wants to find the smallest positive integer M such that the bitwise XOR of M and M+1 is N. If no such M exists output -1.
-----Input-----
The first line of input contain an integer T denoting the number of test cases. Each of the following T lines contains an integer N for that test case.
---... | t = int(input())
while t:
t -= 1
n = int(input())
bi = bin(n)[2:]
c0 = bi.count("0")
if c0:
print("-1")
elif n == 1:
print("2")
else:
print(n // 2) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF VAR EXPR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER |
Given an integer N, Chef wants to find the smallest positive integer M such that the bitwise XOR of M and M+1 is N. If no such M exists output -1.
-----Input-----
The first line of input contain an integer T denoting the number of test cases. Each of the following T lines contains an integer N for that test case.
---... | from sys import stdin, stdout
def main():
from sys import stdin, stdout
inp = stdin.readline
out = stdout.write
res = []
t = int(inp().strip())
for i in range(t):
n = int(inp().strip())
x = n // 2
if n == 1:
res.append("2\n")
elif x ^ x + 1 == n:
... | FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING IF BIN_OP VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL ... |
Given an integer N, Chef wants to find the smallest positive integer M such that the bitwise XOR of M and M+1 is N. If no such M exists output -1.
-----Input-----
The first line of input contain an integer T denoting the number of test cases. Each of the following T lines contains an integer N for that test case.
---... | l = []
for k in range(2, 31):
l.append(2**k - 1)
for i in range(int(input())):
n = int(input())
if n == 1:
print(2)
continue
if n in l:
print(n // 2)
else:
print(-1) | ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER |
Given an integer N, Chef wants to find the smallest positive integer M such that the bitwise XOR of M and M+1 is N. If no such M exists output -1.
-----Input-----
The first line of input contain an integer T denoting the number of test cases. Each of the following T lines contains an integer N for that test case.
---... | for _ in range(int(input())):
n = int(input())
flag = 0
if n == 1:
print("2")
else:
for i in range(1, 31):
if 2**i - 1 == n:
flag = 1
t = i
break
if flag == 0:
print("-1")
else:
print(2 **... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR NUMBER NUMBER IF BIN_OP BIN_OP NUMBER VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP... |
Given an integer N, Chef wants to find the smallest positive integer M such that the bitwise XOR of M and M+1 is N. If no such M exists output -1.
-----Input-----
The first line of input contain an integer T denoting the number of test cases. Each of the following T lines contains an integer N for that test case.
---... | for _ in range(int(input())):
n = int(input())
if n == 1:
print(2)
else:
arr = []
i = 0
while True:
if 2**i <= n:
arr.append(2**i)
i += 1
else:
break
flg = 0
for i in arr:
if 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 ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE NUMBER IF BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR BIN_OP NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR BIN_OP VAR NUMBER VAR ASSIG... |
Given an integer N, Chef wants to find the smallest positive integer M such that the bitwise XOR of M and M+1 is N. If no such M exists output -1.
-----Input-----
The first line of input contain an integer T denoting the number of test cases. Each of the following T lines contains an integer N for that test case.
---... | valid_n = [(2**i - 1) for i in range(1, 31)]
T = int(input())
for tx in range(T):
N = int(input())
if N == 1:
print(2)
elif N in valid_n:
print(valid_n[valid_n.index(N) - 1])
else:
print(-1) | ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER |
Given an integer N, Chef wants to find the smallest positive integer M such that the bitwise XOR of M and M+1 is N. If no such M exists output -1.
-----Input-----
The first line of input contain an integer T denoting the number of test cases. Each of the following T lines contains an integer N for that test case.
---... | t = int(input())
ar = []
for i in range(0, 100):
ar.append(15 * 2**i + 2**i - 1)
for j in range(0, t):
n = int(input())
if n == 3:
print(1)
elif n == 1:
print(2)
elif n == 7:
print(3)
elif (n in ar) == True:
print(n // 2)
else:
print(-1) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP NUMBER BIN_OP NUMBER VAR BIN_OP NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CAL... |
Given an integer N, Chef wants to find the smallest positive integer M such that the bitwise XOR of M and M+1 is N. If no such M exists output -1.
-----Input-----
The first line of input contain an integer T denoting the number of test cases. Each of the following T lines contains an integer N for that test case.
---... | T = int(input())
for i in range(T):
N = int(input())
f = bin(N)[2:]
if f.count("0") == 0:
if N == 1:
print(2)
else:
print(N >> 1)
else:
print(-1) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR STRING NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER |
Given an integer N, Chef wants to find the smallest positive integer M such that the bitwise XOR of M and M+1 is N. If no such M exists output -1.
-----Input-----
The first line of input contain an integer T denoting the number of test cases. Each of the following T lines contains an integer N for that test case.
---... | t = int(input())
for i in range(t):
k = int(input())
if k % 2 == 0:
print(-1)
elif k % 2 != 0:
c = (k + 1) // 2
if k == c ^ c - 1:
if k != 1:
print(c - 1)
if k == 1:
print(2)
else:
print(-1) | 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 EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF VAR BIN_OP VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF V... |
Given an integer N, Chef wants to find the smallest positive integer M such that the bitwise XOR of M and M+1 is N. If no such M exists output -1.
-----Input-----
The first line of input contain an integer T denoting the number of test cases. Each of the following T lines contains an integer N for that test case.
---... | t = int(input())
s = []
for i in range(31):
s.append(2**i - 1)
for _ in range(t):
n = int(input())
if n == 1:
print(2)
elif n in s:
print(n // 2)
else:
print(-1) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER |
Given an integer N, Chef wants to find the smallest positive integer M such that the bitwise XOR of M and M+1 is N. If no such M exists output -1.
-----Input-----
The first line of input contain an integer T denoting the number of test cases. Each of the following T lines contains an integer N for that test case.
---... | __author__ = "Ronald Kaiser"
__email__ = "raios dot catodicos at gmail dot com"
def is_2n(n):
while n % 2 == 0:
n //= 2
return True if n == 1 else False
for _ in range(int(input())):
N = int(input())
if N == 1:
print(2)
elif is_2n(N + 1):
print(N // 2)
else:
p... | ASSIGN VAR STRING ASSIGN VAR STRING FUNC_DEF WHILE BIN_OP VAR NUMBER NUMBER VAR NUMBER RETURN VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.