description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef got interested in bits and wanted to learn about them, so his friend Pintu gave him a special function $F(X,Y,Z) = (X \wedge Z) \cdot (Y \wedge Z)$, where $\wedge$ is the [bitwise AND] operator and $X, Y, Z$ ar... | shifts = [(2**p) for p in range(62, -1, -1)]
def solve(x, y, l, r):
if l == 0 and r >= 2 * max(x, y):
if x * y == 0:
return 0
return x | y
result = l
current = l
best = (x & current) * (y & current)
while True:
last0 = ~current
last0 = last0 & -last0
... | ASSIGN VAR BIN_OP NUMBER VAR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER FUNC_DEF IF VAR NUMBER VAR BIN_OP NUMBER FUNC_CALL VAR VAR VAR IF BIN_OP VAR VAR NUMBER RETURN NUMBER RETURN BIN_OP VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR WHILE NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR ... |
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef got interested in bits and wanted to learn about them, so his friend Pintu gave him a special function $F(X,Y,Z) = (X \wedge Z) \cdot (Y \wedge Z)$, where $\wedge$ is the [bitwise AND] operator and $X, Y, Z$ ar... | def rangingl(lmin, ans):
global l
if lmin & lmin - 1 == 0:
x = lmin | ans
return x
else:
y = rangingl(lmin & lmin - 1, ans)
if y >= l:
return y
return lmin | ans
t = int(input())
for test in range(t):
x, y, l, r = map(int, input().split())
p = x ... | FUNC_DEF IF BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER VAR IF VAR VAR RETURN VAR RETURN BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASS... |
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef got interested in bits and wanted to learn about them, so his friend Pintu gave him a special function $F(X,Y,Z) = (X \wedge Z) \cdot (Y \wedge Z)$, where $\wedge$ is the [bitwise AND] operator and $X, Y, Z$ ar... | def initial(x, y, l, r):
ton = l
isan = 0
for i in reversed(range(41)):
flag = 1 << i & r
if flag >> i == 0:
continue
mtan = (1 << i) - 1 | r - (1 << i)
use = (x & mtan) * (y & mtan)
if use > isan and mtan >= l:
isan = use
ton = mta... | FUNC_DEF ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER BIN_OP VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR IF VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VA... |
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef got interested in bits and wanted to learn about them, so his friend Pintu gave him a special function $F(X,Y,Z) = (X \wedge Z) \cdot (Y \wedge Z)$, where $\wedge$ is the [bitwise AND] operator and $X, Y, Z$ ar... | for _ in range(int(input())):
x, y, l, r = list(map(int, input().split()))
if l == r:
print(l)
continue
xb = bin(x).replace("0b", "")
yb = bin(y).replace("0b", "")
rb = bin(r).replace("0b", "")
lb = bin(l).replace("0b", "")
t_1, t_2, poss = "", "", []
maxLen = max(len(xb)... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR STRING STRING ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR STRING STRING ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR STRING STRIN... |
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef got interested in bits and wanted to learn about them, so his friend Pintu gave him a special function $F(X,Y,Z) = (X \wedge Z) \cdot (Y \wedge Z)$, where $\wedge$ is the [bitwise AND] operator and $X, Y, Z$ ar... | def f(q):
fi = []
ch = False
for i in range(q, 0, -1):
if b[-i] == a[-i]:
fi.append(a[-i])
elif b[-i] == "1":
if ch:
fi.append("0")
else:
fi.append("1")
elif b[-i] == "0":
ch = True
fi.append(... | FUNC_DEF ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR IF VAR VAR STRING IF VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING IF VAR VAR STRING ASSIGN VAR NUMBER EXPR FUNC_CALL VAR STRING RETURN FUNC_CALL STRING VAR FOR VAR FUNC_CALL VAR FU... |
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef got interested in bits and wanted to learn about them, so his friend Pintu gave him a special function $F(X,Y,Z) = (X \wedge Z) \cdot (Y \wedge Z)$, where $\wedge$ is the [bitwise AND] operator and $X, Y, Z$ ar... | from sys import stdin
def solve(X, Y, L, R):
mx, mxz = -1, -1
def search(i, Z, freeL, freeR):
nonlocal mx, mxz
if i < 0:
res = (X & Z) * (Y & Z)
if res > mx or res == mx and Z < mxz:
mx, mxz = res, Z
return
if freeL and freeR:
... | FUNC_DEF ASSIGN VAR VAR NUMBER NUMBER FUNC_DEF IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR IF VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR RETURN IF VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR... |
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef got interested in bits and wanted to learn about them, so his friend Pintu gave him a special function $F(X,Y,Z) = (X \wedge Z) \cdot (Y \wedge Z)$, where $\wedge$ is the [bitwise AND] operator and $X, Y, Z$ ar... | def solve(ind, restriction, ans):
sol = []
flag = 0
for i in range(ind, m):
if x[i] == "1" or y[i] == "1":
if not restriction:
ans += "1"
elif r[i] == "0":
ans += "0"
else:
sol.extend(solve(i + 1, 1, ans + "1"))
... | FUNC_DEF ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR IF VAR VAR STRING VAR VAR STRING IF VAR VAR STRING IF VAR VAR STRING VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER BIN_OP VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER BIN_OP VAR STRING ASSIGN VAR NUMB... |
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef got interested in bits and wanted to learn about them, so his friend Pintu gave him a special function $F(X,Y,Z) = (X \wedge Z) \cdot (Y \wedge Z)$, where $\wedge$ is the [bitwise AND] operator and $X, Y, Z$ ar... | from sys import stdin
def decimalToBinary(n):
return bin(n).replace("0b", "")
t = int(stdin.readline())
for test in range(t):
X, Y, L, R = map(int, stdin.readline().split())
maxi = str(decimalToBinary(X | Y))
binL = str(decimalToBinary(L))
binR = str(decimalToBinary(R))
maxLen = max(len(maxi... | FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR VAR STRING STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL ... |
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef got interested in bits and wanted to learn about them, so his friend Pintu gave him a special function $F(X,Y,Z) = (X \wedge Z) \cdot (Y \wedge Z)$, where $\wedge$ is the [bitwise AND] operator and $X, Y, Z$ ar... | def chandf(x, y, l, r):
a = (x & l) * (y & l)
id = l
Z = x | y
for i in range(64):
if r & 1 << i:
k = r ^ 1 << i | (1 << i) - 1
if k < l:
continue
for j in range(i - 1, -1, -1):
if Z & 1 << j == 0:
if k ^ 1 <... | FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP NUMBER VAR BIN_OP BIN_OP NUMBER VAR NUMBER IF VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF BIN_OP VAR BIN... |
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef got interested in bits and wanted to learn about them, so his friend Pintu gave him a special function $F(X,Y,Z) = (X \wedge Z) \cdot (Y \wedge Z)$, where $\wedge$ is the [bitwise AND] operator and $X, Y, Z$ ar... | mxB = 1 << 40
def f(x, y, z):
return (z & x) * (z & y)
def lcomp(a, b):
return a & -b - 1
def find(x, y, l, r, b=mxB):
z = x | y
w = x & y
ans = z
lans = lcomp(z, l)
while b > 0 and r & b == 0:
b >>= 1
z = 0 if b == 0 else z & 2 * b - 1
rb = b
pv = 0
while b > 0... | ASSIGN VAR BIN_OP NUMBER NUMBER FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR FUNC_DEF RETURN BIN_OP VAR BIN_OP VAR NUMBER FUNC_DEF VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR WHILE VAR NUMBER BIN_OP VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER NUMBE... |
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef got interested in bits and wanted to learn about them, so his friend Pintu gave him a special function $F(X,Y,Z) = (X \wedge Z) \cdot (Y \wedge Z)$, where $\wedge$ is the [bitwise AND] operator and $X, Y, Z$ ar... | a = int(input())
for i in range(a):
x, y, l, r = map(int, input().split())
if x == 0 or y == 0:
print(l)
continue
ans = x | y
if l == 0 and r >= ans:
print(ans)
continue
arr = []
prev = 0
if l == r:
print(l)
continue
for j in range(43):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR FOR... |
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef got interested in bits and wanted to learn about them, so his friend Pintu gave him a special function $F(X,Y,Z) = (X \wedge Z) \cdot (Y \wedge Z)$, where $\wedge$ is the [bitwise AND] operator and $X, Y, Z$ ar... | def duvidha(binary, ini):
for i in range(ini, len(binary)):
a1 = 2 ** (len(binary) - i - 1)
if (
int(binary, 2) + a1 <= l
or i == len(binary) - 1
and (binary_x[i] == "1" or binary_y[i] == "1")
and int(binary, 2) + a1 <= r
):
binary ... | FUNC_DEF FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR STRING VAR VAR STRING BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR STRING VAR BIN_OP... |
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef got interested in bits and wanted to learn about them, so his friend Pintu gave him a special function $F(X,Y,Z) = (X \wedge Z) \cdot (Y \wedge Z)$, where $\wedge$ is the [bitwise AND] operator and $X, Y, Z$ ar... | def process(v, l, x, y, m):
p = 50
while p >= 0:
if v >> p & 1 == 1:
k = v ^ 1 << p
if (k & x) * (k & y) == m and k >= l:
v = k
p -= 1
return v
t = int(input())
while t > 0:
inp = input()
inp = inp.split()
x = int(inp[0])
y = int(inp[... | FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR IF BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR AS... |
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef got interested in bits and wanted to learn about them, so his friend Pintu gave him a special function $F(X,Y,Z) = (X \wedge Z) \cdot (Y \wedge Z)$, where $\wedge$ is the [bitwise AND] operator and $X, Y, Z$ ar... | def rcom(no, x, y):
orr = x | y
return no & orr
def samelen(b, l):
m = max(len(b), len(l))
b = "0" * (m - len(b)) + b
l = "0" * (m - len(l)) + l
return b, l
def round1(x, y, l, r):
x = bin(x)[2:]
y = bin(y)[2:]
l = bin(l)[2:]
r = bin(r)[2:]
rini = r
mv = (int(x, 2) & ... | FUNC_DEF ASSIGN VAR BIN_OP VAR VAR RETURN BIN_OP VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP VAR FUNC_CALL VAR VAR VAR RETURN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASS... |
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef got interested in bits and wanted to learn about them, so his friend Pintu gave him a special function $F(X,Y,Z) = (X \wedge Z) \cdot (Y \wedge Z)$, where $\wedge$ is the [bitwise AND] operator and $X, Y, Z$ ar... | def checkset(n, k):
if n & 1 << k - 1:
return 1
else:
return 0
def setKthBit(n, k):
return 1 << k | n
def correct(a, b, l, r):
ans = -1
cur = 0
for i in range(l, r + 1):
if (a & i) * (b & i) > ans:
ans = (a & i) * (b & i)
cur = i
elif (... | FUNC_DEF IF BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF RETURN BIN_OP BIN_OP NUMBER VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR ... |
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef got interested in bits and wanted to learn about them, so his friend Pintu gave him a special function $F(X,Y,Z) = (X \wedge Z) \cdot (Y \wedge Z)$, where $\wedge$ is the [bitwise AND] operator and $X, Y, Z$ ar... | def F(X, Y, Z):
return (X & Z) * (Y & Z)
def gettingabovel(lm, s):
global l
if lm & lm - 1 == 0:
x = lm | s
return x
else:
y = gettingabovel(lm & lm - 1, s)
if y >= l:
return y
return lm | s
for _ in range(int(input())):
x, y, l, r = list(map(i... | FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR FUNC_DEF IF BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER VAR IF VAR VAR RETURN VAR RETURN BIN_OP VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CA... |
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef got interested in bits and wanted to learn about them, so his friend Pintu gave him a special function $F(X,Y,Z) = (X \wedge Z) \cdot (Y \wedge Z)$, where $\wedge$ is the [bitwise AND] operator and $X, Y, Z$ ar... | def calF(zIn):
return (x & zIn) * (y & zIn)
def makeEql(str1, dis):
toAdd = ""
for _ in range(dis):
toAdd += "0"
str1 = toAdd + str1
return str1
def calZ(length, dis, ch, curList, binZ):
prev = 0
pz = l
az = r
if lenZ < length:
binZ = makeEql(binZ, dis)
di... | FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR FUNC_DEF ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR VAR STRING ASSIGN VAR BIN_OP VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR... |
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef got interested in bits and wanted to learn about them, so his friend Pintu gave him a special function $F(X,Y,Z) = (X \wedge Z) \cdot (Y \wedge Z)$, where $\wedge$ is the [bitwise AND] operator and $X, Y, Z$ ar... | t = int(input())
for i in range(t):
x, y, l, r = map(int, input().split(" "))
if l > r:
t = l
l = r
r = t
a = x | y
b = bin(a)[2:]
c = bin(l)[2:]
r1 = bin(r)[2:]
l1 = bin(l)[2:]
st = ""
st1 = ""
if len(r1) < len(b):
for k in range(len(b) - len(r1))... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ... |
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef got interested in bits and wanted to learn about them, so his friend Pintu gave him a special function $F(X,Y,Z) = (X \wedge Z) \cdot (Y \wedge Z)$, where $\wedge$ is the [bitwise AND] operator and $X, Y, Z$ ar... | try:
for _ in range(int(input())):
x, y, l, r = map(int, input().split())
_or = x | y | l
if 0 in [x, y, r]:
print(l)
continue
if l == 0 and r > 2 * max(x, y):
print(x | y)
continue
rBin = bin(r)[2:]
lBin = bin(l)[2:]
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR IF NUMBER LIST VAR VAR VAR EXPR FUNC_CALL VAR VAR IF VAR NUMBER VAR BIN_OP NUMBER FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR N... |
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef got interested in bits and wanted to learn about them, so his friend Pintu gave him a special function $F(X,Y,Z) = (X \wedge Z) \cdot (Y \wedge Z)$, where $\wedge$ is the [bitwise AND] operator and $X, Y, Z$ ar... | def chk(oppo):
return (x & oppo) * (y & oppo)
t = int(input())
for _ in range(t):
x, y, l, r = map(int, input().split())
possible_ans = x | y
lbin = bin(l)[2:]
rbin = bin(r)[2:]
lbin = "0" * (len(rbin) - len(lbin)) + lbin
if possible_ans > r:
possible_ans = possible_ans & 2 ** len(... | FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP ... |
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef got interested in bits and wanted to learn about them, so his friend Pintu gave him a special function $F(X,Y,Z) = (X \wedge Z) \cdot (Y \wedge Z)$, where $\wedge$ is the [bitwise AND] operator and $X, Y, Z$ ar... | for _ in range(int(input())):
x, y, l, r = map(int, input().split())
x_or_y = x | y
if l == 0 and r >= 2 * max(x, y):
if x == 0 or y == 0:
print(0)
continue
print(x_or_y)
continue
maxp = (x & l) * (y & l)
m_val = l
binr = bin(r)
binr = binr[2:]... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER VAR BIN_OP NUMBER FUNC_CALL VAR VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASS... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | import sys as _sys
def main():
n, p = _read_ints()
try:
result = find_min_terms_n(n, p)
except ValueError:
result = -1
print(result)
def _read_line():
result = _sys.stdin.readline()
assert result[-1] == "\n"
return result[:-1]
def _read_ints():
return map(int, _read... | IMPORT FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR NUMBER STRING RETURN VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | n, p = map(int, input().split())
l = 1
k = 1
while n - l * p > 0:
s = bin(n - l * p)[2:]
l1 = 0
l2 = 0
last = 0
for i in s:
if i == "1":
l1 += 1
l2 += 1
last = 1
elif last > 0:
l2 += 2 ** (last - 1)
last += 1
if l >= l1 ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR NUM... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | def Dec_to_Bin(N):
b = ""
while N > 0:
b = str(N % 2) + b
N = N // 2
if b == "":
return "0"
return b
if True:
n, p = list(map(int, input().split()))
j = 1
while True:
if n - p * j <= 0:
print(-1)
break
S = Dec_to_Bin(n - p * j... | FUNC_DEF ASSIGN VAR STRING WHILE VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR STRING RETURN STRING RETURN VAR IF NUMBER ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE NUMBER IF BIN_OP VAR BIN_OP VAR VAR NUMBER EXPR F... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | n, p = map(int, input().split())
count = 100
if n - p == 0:
print(-1)
exit(0)
k = 0
while k <= 32:
if n - p * k >= k:
temp = bin(n - p * k)
c = str(temp)[2:].count("1")
if c <= k and c != 0:
print(k)
break
k += 1
else:
print(-1) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER STR... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | n, p = map(int, input().split())
for i in range(100000):
x = n - p * i
bina = bin(x)[2:].count("1")
if bina <= i and x >= i:
print(i)
exit()
print(-1) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER STRING IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | n, p = map(int, input().split())
ans = -1
for i in range(10001):
if n - i * p >= i:
c = bin(n - i * p)[2:].count("1")
if c <= i:
ans = i
break
print(ans) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR NUMBER STRING IF VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | def ones(n):
result = 0
while n > 0:
n = n & n - 1
result = result + 1
return result
def can(n, p, cnt):
nn = n - p * cnt
if nn < cnt:
return False
if ones(nn) > cnt:
return False
return True
def solve(n, p):
i = 1
while i * p <= n:
if can(... | FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR IF VAR VAR RETURN NUMBER IF FUNC_CALL VAR VAR VAR RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR IF FUNC_CALL VAR VAR... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | n, p = map(int, input().split())
k = 1
while n - p * k > 0:
count = 0
temp = n - p * k
while temp > 0:
if temp & 1:
count += 1
temp = temp >> 1
if count <= k:
break
k += 1
if n - p * k >= k:
print(k)
else:
print(-1) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE BIN_OP VAR BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR WHILE VAR NUMBER IF BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR VAR NUMBER IF BIN_OP VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | def kol(a):
if a <= 0:
return -1
elif a == 1:
return 1
elif a % 2 == 1:
return kol(a // 2) + 1
else:
return kol(a // 2)
n, p = map(int, input().split())
prov = False
for i in range(1, 1000):
z = kol(n - i * p)
if z != -1 and z <= i and n - i * p >= i:
pr... | FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER IF BIN_OP VAR NUMBER NUMBER RETURN BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER RETURN FUNC_CALL VAR BIN_OP VAR NUMBER 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... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | ls = list(map(int, input().split()))
n = ls[0]
p = ls[1]
k = 1
success = False
if p > 0:
while n - k * p > 0:
x = str(bin(n - k * p))[2:]
count1 = 0
for j in x:
if j == "1":
count1 += 1
if count1 <= k and k <= n - k * p:
print(k)
su... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER WHILE BIN_OP VAR BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR ... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | n, p = list(map(int, input().split()))
for q in range(5757):
s = bin(n)
if n >= q >= s.count("1"):
print(q)
break
n -= p
else:
print(-1) | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR NUMBER |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | [n, m] = list(map(int, input().split()))
def cnt(x):
y = bin(x)
y = y[2:]
return y.count("1")
ans = 1
for i in range(1, 32):
if n - i * m >= i and cnt(n - i * m) <= i:
print(i)
ans = 0
break
if ans:
print(-1) | ASSIGN LIST VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER RETURN FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER IF BIN_OP VAR BIN_OP VAR VAR VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR AS... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | def ones(n):
cnt = 0
while n > 0:
cnt += n % 2
n >>= 1
return cnt
n, p = map(int, input().split())
least = -1
for i in range(1, 40):
pbinar = n - i * p
if pbinar < 0:
break
pone = ones(pbinar)
if pone <= i <= pbinar:
least = i
break
print(least if le... | FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER RETURN 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 BIN_OP VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR EXPR FUNC_C... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | n, p = list(map(int, input().split()))
k = 1
z = []
while len(bin(n - k * p)) - 2 >= k and n - k * p > 0:
if bin(n - k * p).count("1") <= k:
z.append(k)
k += 1
if len(z) > 0:
print(min(z))
else:
print(-1) | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE BIN_OP FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR NUMBER VAR BIN_OP VAR BIN_OP VAR VAR NUMBER IF FUNC_CALL FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR STRING VAR EXPR FUNC_CALL VAR VAR VAR NUMBER IF FUN... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | n, p = list(map(int, input().split()))
ans = 1
n2 = n
while n2 > 0:
n2 = n - ans * p
count1 = bin(n2).count("1", 2)
if count1 <= ans and ans <= n2:
print(ans)
break
ans += 1
else:
print(-1) | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR STRING NUMBER IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | n, p = map(int, input().split())
if n <= p:
print(-1)
exit()
for ans in range(1, 10**6):
x = n - p * ans
if x >= ans and bin(x).count("1") <= ans:
print(ans)
break
else:
print(-1) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR IF VAR VAR FUNC_CALL FUNC_CALL VAR VAR STRING VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | def check(k, n, p):
t = n - p * k
s = bin(t)[2:]
count = 0
for i in range(len(s)):
if s[i] == "1":
count += 1
return count <= k and t >= k
def main():
n, p = map(int, input().split())
i = 1
while i < 10000:
if check(i, n, p):
print(i)
... | FUNC_DEF ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER RETURN VAR VAR VAR VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR NUMBER IF FUNC_CALL VAR VAR VAR VA... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | def set_bits(n):
cout = 0
while n > 0:
if n & 1 == 1:
cout += 1
n >>= 1
return cout
flag = 0
n, p = map(int, input().split())
for i in range(65):
num = n - i * p
ans = set_bits(num)
if i >= ans and i <= num:
flag = 1
break
if flag == 0:
print(-1)... | FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR N... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | def pro(g, v):
if g == 0:
if v == 0:
return True
else:
return False
y = 2**100
ans = 0
x = g
while x != 0:
if x >= y:
x -= y
ans += 1
y //= 2
if ans <= v and v <= g:
return True
else:
return False... | FUNC_DEF IF VAR NUMBER IF VAR NUMBER RETURN NUMBER RETURN NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR NUMBER IF VAR VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FU... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | def cnt(n, a):
count = 0
p = 1
while n:
count += (n & 1) * p
if a:
p *= 2
n >>= 1
return count
def main():
n, p = map(int, input().split())
s = 1 if p < 0 else -1
ans = 10000000000
cop = n
if p == 0:
print(cnt(n, False))
return
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR BIN_OP BIN_OP VAR NUMBER VAR IF VAR VAR NUMBER VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | N, P = map(int, input().split())
def chk(k):
x = N - k * P
if x > 0 and sum(map(int, bin(x)[2:])) <= k <= x:
return 1
return 0
for i in range(1, 100):
if chk(i):
print(i)
break
else:
print(-1) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR IF VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER VAR VAR RETURN NUMBER RETURN NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER IF FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | def min_summies(n, p):
for k in range(1, 50):
num = bin(n - k * p)
if num.count("1") <= k <= n - k * p:
return k
return -1
n, p = map(int, input().split())
print(min_summies(n, p)) | FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR IF FUNC_CALL VAR STRING VAR BIN_OP VAR BIN_OP VAR VAR RETURN VAR RETURN NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | n, p = map(int, input().split())
ans = 1
while n:
n -= p
if n < ans:
print(-1)
break
if bin(n).count("1") <= ans:
print(ans)
break
ans += 1
else:
print(-1) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER IF FUNC_CALL FUNC_CALL VAR VAR STRING VAR EXPR FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | x, p = map(int, input().split())
ans = float("inf")
for i in range(0, 100001):
y = x - i * p
if y <= 0:
continue
aaa = 0
for j, el in enumerate(reversed(bin(y))):
if el == "1":
aaa += 2**j
if aaa >= i:
break
bbb = bin(y).count("1")
if bbb <... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR STRING VAR BIN_OP NUMBER VAR IF VAR VAR ASSIGN VAR FUNC_CALL ... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | a, b = map(lambda x: int(x), input().split())
k = 0
s = 1
f = True
while k < s:
a = a - b
if a <= 0:
break
c = a
k += 1
s = 1
while c != 1:
s += c % 2
c = c // 2
q = k - s
q1 = k
for i in range(q):
a = a - b
if a <= 0:
break
c = a
k += 1
s = 1
... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASS... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | def bin(x):
return "{0:b}".format(x)
n, p = [int(i) for i in input().split()]
nA = True
k = 1
while k < 33:
if k == 32:
print(-1)
else:
t = bin(n - k * p)
a = t.count("1")
if a <= k and a > 0 and n >= k * (p + 1):
print(k)
break
k += 1 | FUNC_DEF RETURN FUNC_CALL STRING VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR STRING IF VAR VAR VAR NUMBER VAR BIN_OP VAR BIN_OP VA... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | def bitcount(n):
count = 0
while n > 0:
count = count + 1
n = n & n - 1
return count
n, p = input("").split()
n = int(n)
p = int(p)
for i in range(1, 31):
m = n
m = m - i * p
count = bitcount(m)
if m <= 0:
print(-1)
break
elif count == i:
print(i... | FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER RETURN VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR ASSI... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | import time
n, p = map(int, input().split())
nt = time.time()
for i in range(1, 10000, 1):
if n - p * i < i:
break
now = bin(n - p * i)[2:].count("1")
if now <= i and now != 0:
print(i)
exit(0)
print(-1) | IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF BIN_OP VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR NUMBER STRING IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | n, p = [int(k) for k in input().split(" ")]
def cb(n):
res = 0
while n:
if n % 2:
res += 1
n >>= 1
return res
k = 0
res = -1
while n - k * p > 0:
nbb = cb(n - k * p)
if nbb <= k and n - k * p >= k:
res = k
break
k += 1
print(res) | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF ASSIGN VAR NUMBER WHILE VAR IF BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR IF VAR VAR BIN_OP VAR BIN_OP VAR VA... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | n, p = map(int, input().split())
for i in range(1, 100):
x = n - i * p
if x <= 0:
print(-1)
exit()
if bin(x).count("1") <= i <= x:
print(i)
exit()
print(-1)
exit() | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR IF FUNC_CALL FUNC_CALL VAR VAR STRING VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VA... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | n, p = map(int, input().split())
def term_counter(n, counter):
if n == 1:
return counter + 1
if n % 2 == 1:
n -= 1
counter += 1
return term_counter(n, counter)
else:
while n != 1 and n % 2 != 1:
n = int(n / 2)
if n == 1:
return counte... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR NUMBER RETURN BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER RETURN FUNC_CALL VAR VAR VAR WHILE VAR NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR NUMBER RETURN BIN_OP VAR NUMBER VAR NUMBER V... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | n, p = map(int, input().split())
out = 1
while n:
n -= p
if n < out:
print(-1)
break
s = bin(n)
if s.count("1") <= out:
print(out)
break
out += 1 | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR STRING VAR EXPR FUNC_CALL VAR VAR VAR NUMBER |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | n, p = map(int, input().split())
m = 10000000000
q = 0
for i in range(1, 100):
a = n - i * p
if a > 0:
u = a
o = 0
while u > 0:
if u % 2 == 1:
o += 1
u //= 2
else:
u //= 2
mi = o
if i >= mi and a >= i... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR VAR IF VAR VAR VAR... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | def solve():
n, p = map(int, input().split())
for i in range(1, 32):
if n - i * p >= i and bin(n - i * p).count("1") <= i:
return i
return -1
print(solve()) | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER IF BIN_OP VAR BIN_OP VAR VAR VAR FUNC_CALL FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR STRING VAR RETURN VAR RETURN NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | n, p = map(int, input().split())
ans = 1
fl = False
if n == p:
print(-1)
else:
while n - p * ans >= 0:
b = bin(n - p * ans)[2:].count("1")
if b <= ans <= n - p * ans:
fl = True
break
ans += 1
if fl:
print(ans)
else:
print(-1) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER WHILE BIN_OP VAR BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR NUMBER STRING IF VAR VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR NUMBER VAR NUMBER IF VAR EXP... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | n, p = map(int, input().split())
f = 0
for i in range(1, 31):
x = n - i * p
b = bin(x)
if x < 0:
b = b[3:]
else:
b = b[2:]
if x >= i:
ones = 0
for j in range(len(b)):
if b[j] == "1":
ones += 1
if ones <= i:
f = 1
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRIN... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | def bn(x):
b = []
i = 1
j = 0
while j < 32:
b.append(int(x & i != 0))
i = i << 1
j += 1
b.reverse()
return sum(b)
n, p = map(int, input().split())
for i in range(1, 32):
bi = bn(n - i * p)
if bi <= i <= n - i * p:
print(i)
exit()
print(-1) | FUNC_DEF ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR RETURN FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | inputs = [int(x) for x in input().split()]
n = inputs[0]
y = inputs[1]
pos = False
for i in range(1000000100):
if n - i * y < i:
break
if bin(n - i * y).count("1") <= i:
print(i)
pos = True
break
if pos == False:
print(-1) | ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR BIN_OP VAR VAR VAR IF FUNC_CALL FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR STRING VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR N... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | n, p = map(int, input().split())
i = 1
while 1:
m = n - p * i
if m <= 0:
break
if i > m:
i += 1
continue
pc = bin(m).count("1")
if pc <= i:
print(i)
exit()
i += 1
print(-1) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR IF VAR NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR STRING IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | def get_n(bin_n):
ans = 0
while bin_n > 0:
ans += bin_n & 1
bin_n >>= 1
return ans
n, p = map(int, input().split())
ans = 1
while ans < 10**5 * 2 and not n - p * ans >= ans >= get_n(n - p * ans):
ans += 1
if ans == 10**5 * 2:
print(-1)
else:
print(ans) | FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER BIN_OP VAR BIN_OP VAR VAR VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR VAR NUMBER IF VAR BIN_OP BIN_OP NUMBER NUM... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | n, p = list(map(int, input().split()))
ans = -1
l = 1
while n - l * p > 0:
if p == 0:
s = bin(n)[2:]
for i in range(len(s)):
if s[i] == "1":
ans += 1
ans += 1
break
k = n - l * p
v1, v2 = 0, 0
s = bin(k)[2:]
for i in range(len(s)):
... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR BIN_OP VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN ... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | def count1(n):
return bin(n).count("1")
n, p = map(int, input().split())
if p == 0:
print(count1(n))
else:
for k in range(1, 10**8):
n1 = n - k * p
if n1 <= 0:
print(-1)
break
k1 = count1(n1)
if k1 == k:
print(k)
break
... | FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR VAR STRING ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VA... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | def check(n, p, m):
a = n - p * m
if a <= 0:
return False
b = bin(a)[2:][::-1]
l = len(b)
c = 0
res = 0
q = []
for i in range(l):
if b[i] == "1":
q += [2**i]
c += 1
res += max(0, 2 ** (i - 1))
d = c - m
if d > 0:
return ... | FUNC_DEF ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR IF VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR LIST BIN_OP NUMBER VAR VAR NUMBER VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER B... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | n, p = [int(i) for i in input().split()]
i = 1
f = True
while n - i * p >= 1:
if bin(n - i * p)[2:].count("1") <= i and i <= n - i * p:
print(i)
f = False
break
i += 1
if f:
print("-1") | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR BIN_OP VAR VAR NUMBER IF FUNC_CALL FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR NUMBER STRING VAR VAR BIN_OP VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR NUMBER IF VAR EXPR FUNC_CALL VAR STRIN... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | n, k = map(int, input().split())
i = 1
n -= k
while n > 0 and not bin(n).count("1") <= i <= n:
n -= k
i += 1
if n > 0:
print(i)
else:
print(-1) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR VAR WHILE VAR NUMBER FUNC_CALL FUNC_CALL VAR VAR STRING VAR VAR VAR VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | n, p = map(int, input().split())
ans = 10**18
for k in range(10**5 + 1):
x = n - k * p
if x < 0:
break
s = str(bin(x)[2:])
l = 0
r = 0
for i in range(len(s))[::-1]:
if s[i] == "1":
l += 1
r += 2 ** (len(s) - 1 - i)
if l <= k <= r:
ans = min(ans... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR V... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | def get_n(n, k):
if bin(n).count("1") > k or k > n:
return False
return True
n, p = list(map(int, input().split()))
if p - n >= 0:
print(-1)
elif p - n == -1:
print(1)
else:
for i in range(1, 10101):
if get_n(n - p * i, i):
print(i)
return
print(-1) | FUNC_DEF IF FUNC_CALL FUNC_CALL VAR VAR STRING VAR VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER IF FUNC_CALL VAR BIN_OP ... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | n, p = map(int, input().split())
aws = 1
while True:
min_number = aws * (2**0 + p)
if min_number > n:
aws = -1
break
elif min_number == n:
break
elif bin(n - aws * p).count("1") <= aws:
break
aws += 1
print(aws) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP NUMBER NUMBER VAR IF VAR VAR ASSIGN VAR NUMBER IF VAR VAR IF FUNC_CALL FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR STRING VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | a, b = map(int, input().split())
def bn(x):
m = 0
while x > 0:
m += x % 2
x //= 2
return m
mn = 100000000
idx = 0
if b == 0:
print(bn(a))
exit(0)
else:
for n in range(1, 100):
j = n * b
if a <= j:
break
elif bn(a - j) <= n and a - j >= n:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR ... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | n, p = map(int, input().split())
for k in range(41):
m = n - k * p
if m <= 0:
print(-1)
break
s = bin(m)
sumk = 0
for i in range(len(s)):
if s[-i - 1] == "1":
sumk += 2**i
if s.count("1") <= k <= sumk:
print(k)
break
else:
print(-1) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP NUMBER VAR IF FUNC_CALL VAR... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | n, p = input("").split()
n = int(n)
p = int(p)
for i in range(1, 31):
m = n
m = m - i * p
b = bin(m)
str1 = str(b)
count = str1.count("1", 0, len(str1))
if m <= 0:
print(-1)
break
elif count == i:
print(i)
break
elif count < i:
if m > i:
... | ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR VAR IF VAR NUMBER... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | BitsSetTable256 = [0] * 256
def initialize():
BitsSetTable256[0] = 0
for i in range(256):
BitsSetTable256[i] = (i & 1) + BitsSetTable256[i // 2]
initialize()
def countSetBits(n):
return (
BitsSetTable256[n & 255]
+ BitsSetTable256[n >> 8 & 255]
+ BitsSetTable256[n >> 16... | ASSIGN VAR BIN_OP LIST NUMBER NUMBER FUNC_DEF ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR BIN_... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | def f(n, j):
k = 0
while n > 0 and k <= j:
m = 1
while m <= n:
m *= 2
n -= m // 2
k += 1
if k <= j:
return k
return -1
mini = 10**9
ans = -1
n, p = map(int, input().split())
for i in range(1, 10**9):
if n - p * i > 0:
if n - p * i < i:
... | FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR RETURN VAR RETURN NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER NUMBER... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | import sys
def get_one(n):
cnt = 0
while n > 0:
if n % 2 == 1:
cnt += 1
n //= 2
return cnt
n, p = map(int, input().split())
for i in range(10000):
if n > i * p and get_one(n - i * p) <= i <= n - i * p:
print(i)
sys.exit()
print(-1) | IMPORT FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER IF VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR VAR BIN_OP VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR EXPR FU... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | import sys
input = lambda: sys.stdin.readline().rstrip()
n, p = map(int, input().split())
ans, i = -1, 1
while True:
n -= p
if n <= 0:
break
if bin(n).count("1") <= i and i <= n:
ans = i
break
i += 1
print(ans) | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER WHILE NUMBER VAR VAR IF VAR NUMBER IF FUNC_CALL FUNC_CALL VAR VAR STRING VAR VAR VAR ASSIGN VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | def get(n, k):
return n >> k & 1
def cal(n):
sum = 0
for i in range(30):
sum += get(n, i)
return sum
n, k = map(int, input().split())
rs = -1
for i in range(30):
X = n - i * k
if cal(X) <= i and X >= i:
rs = i
break
print(rs) | FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR VAR VAR RETURN 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 VAR BIN_OP VAR VAR IF FUNC_CALL VAR VAR VAR VAR VAR ASSIGN V... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | out = -1
n, p = [int(i) for i in input().split()]
for i in range(1, 10000, 1):
if n - p * i < i:
break
answer = str(bin(n - p * i)[2:]).count("1")
if answer <= i and answer != 0:
out = i
break
print(out) | ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF BIN_OP VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR NUMBER STRING IF VAR VAR VAR NUMBER ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | n, p = map(int, input().split())
n -= p
f = False
for i in range(100):
s = bin(n)
if len(s) - 2 >= i + 1 >= s.count("1") > 0 and n > 0:
k = i + 1
f = True
break
else:
n -= p
if f:
print(k)
else:
print(-1) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER BIN_OP VAR NUMBER FUNC_CALL VAR STRING NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR VAR IF VAR EXPR FUNC_CALL VAR VAR EX... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | n, p = map(int, input().split())
def count(s):
c = 0
b = list(bin(s))
b.pop(0)
b.pop(0)
for i in b:
if i == "1":
c += 1
return c
i = 1
if p > 0:
l = n / (p + 1)
while i <= l:
if count(n - i * p) <= i:
print(i)
break
else:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER RETURN VAR ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER WHILE VAR VAR IF FUNC... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | n, p = map(int, input().split())
def countSetBits(num):
binary = bin(num)
if num < 0:
binary = binary[1:]
setBits = [ones for ones in binary[2:] if ones == "1"]
return len(setBits)
found = False
for i in range(1, 33):
if n - i * p >= i and countSetBits(n - i * p) <= i:
found = Tr... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER VAR STRING RETURN FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER IF BIN_OP VAR BIN_OP VAR VAR VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR ... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | n, p = map(int, input().split())
i = 0
while True:
if n - p * i < 0:
print(-1)
break
if bin(n - p * i).count("1") <= i and i <= n - p * i:
print(i)
break
i += 1 | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE NUMBER IF BIN_OP VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF FUNC_CALL FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR STRING VAR VAR BIN_OP VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | n, p = map(int, input().split())
ans = -1
i = 1
while True:
n -= p
if n < i:
print(ans)
break
k = str(bin(n)[2:]).count("1")
if i >= k:
print(i)
break
i += 1 | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER STRING IF VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | n, p = map(int, input().split())
ones = "{0:b}".format(n).count("1")
t = 0
while (ones > t or n < t) and n > 0:
n -= p
t += 1
ones = "{0:b}".format(n).count("1")
if n <= 0:
print(-1)
else:
print(t) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL STRING VAR STRING ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL STRING VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | import sys
def count_1(n):
ans = 0
while n > 0:
if n % 2 == 1:
ans += 1
n //= 2
return ans
n, p = list(map(int, input().split()))
for i in range(1, 40):
n -= p
if n <= 0:
break
if count_1(n) <= i and n >= i:
print(i)
return
print(-1) | IMPORT FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER VAR VAR IF VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR RETURN EXPR FUNC_CALL V... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | def bit_count(A, i):
answ = 0
j = 0
d = []
while A > 0:
if A & 1:
answ += 1
A >>= 1
d.append(j)
j += 1
if answ > 0:
while answ < i and d:
if d[-1] > 1:
answ += 1
nj = d.pop()
d.append(nj)
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR NUMBER IF BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER IF VAR NUMBER WHILE VAR VAR VAR IF VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR IF VAR NUMBER NUMBER VAR NUMBE... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | n, p = map(int, input().split())
if p == 0:
dv = str(bin(n))[2:]
colvo = dv.count("1")
print(colvo)
else:
m = 1
while n - m * p >= 0:
a = n - m * p
dv = str(bin(a))[2:]
colvo = dv.count("1")
if colvo <= m and m <= a:
print(m)
exit(0)
m ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE BIN_OP VAR BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | def dectobin(n, out):
s = 0
while n:
s += n % 2
n //= 2
return s <= out
n, p = list(map(int, input().split()))
out = 0
f = 0
while n - p >= out + 1:
n -= p
out += 1
if dectobin(n, out):
f = 1
break
if f == 1:
print(out)
else:
print(-1) | FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR BIN_OP VAR NUMBER VAR VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CAL... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | n, p = map(int, input().split())
for k in range(1, 50):
num = bin(n - k * p)
if num.count("1") <= k <= n - k * p:
print(k)
exit()
print(-1) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR IF FUNC_CALL VAR STRING VAR BIN_OP VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | def countSetBits(n):
count = 0
while n:
n &= n - 1
count += 1
return count
t = 1
for _ in range(t):
n, p = map(int, input().split())
count = 0
found = False
while n > 0 and not found and count < 32:
n -= p
count += 1
if n < 0:
break
... | FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR VAR NUMBER VAR VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR V... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | n, p = map(int, input().split())
for i in range(1, 33):
k = n - i * p
if k >= i and bin(abs(k)).count("1") <= i:
print(i)
exit(0)
print(-1) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR IF VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR VAR STRING VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | def decimal_to_binary(x):
res = []
while x > 0:
res.append(x % 2)
x //= 2
return res[::-1]
n, p = list(map(int, input().split()))
for k in range(50):
x = n - k * p
if x < 0:
break
res = decimal_to_binary(x).count(1)
if res <= k and res > 0 and n - k * p >= k:
... | FUNC_DEF ASSIGN VAR LIST WHILE VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR ... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | def f(x):
return range(sum([int(e) for e in bin(x)[2:]]), x + 1)
def main():
n, p = [int(e) for e in input().split()]
b = 1
while n - b * p >= 0:
d = f(n - b * p)
if b in d:
print(b)
return
if b > d[-1]:
break
b += 1
print(-1)
m... | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR NUMBER BIN_OP VAR NUMBER FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE BIN_OP VAR BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | def f(n, p, k):
n = n - k * p
ans = 0
l = 0
z = []
while n >= 1:
ans += n % 2
z.append(n % 2)
n //= 2
for i in range(len(z)):
l += z[i] * 2**i
if ans <= k <= l:
return ans
else:
return 10**4
n, p = map(int, input().split())
k = 10000
ans ... | FUNC_DEF ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR BIN_OP NUMBER VAR IF VAR VAR VAR RETURN VAR RETURN BIN_OP NUMBER NUMBER ASSI... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | n, k = map(int, input().split())
f = 0
c = 0
for i in range(35):
d = n
c = 0
d = n - i * k
t = d
while d > 0:
c += d % 2
d //= 2
if c <= i and i <= t:
f = 1
print(i)
break
if f == 0:
print(-1) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR VAR WHILE VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR IF ... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | n, p = [int(x) for x in input().split()]
l = 1
for mid in range(1, 32):
k = n - mid * p
u = 0
if k < mid:
continue
for i in range(50, -1, -1):
if k >= 2**i:
k -= 2**i
u += 1
if k == 0:
break
if u <= mid and u != 0:
print(mid)
... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR NUMBER IF VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF VAR BIN_OP NUMBER VAR VAR BIN_OP NUMBER VAR VAR NUMBER IF VAR NUMBER IF VAR VAR VAR NUMBER EX... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | def solve():
n, p = map(int, input().split())
for k in range(1, 32):
n1 = n - k * p
if n1 < k:
continue
b = 0
while n1 > 0:
b += n1 % 2
n1 //= 2
if b <= k:
print(k)
return
print(-1)
solve() | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR RETURN EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | def Find(n, k):
sum = k
A = [(1) for i in range(k)]
i = k - 1
while i >= 0:
while sum + A[i] <= n:
sum += A[i]
A[i] *= 2
i -= 1
if sum != n:
return -1
else:
return 0
n, p = map(int, input().split())
k = 1
f = 0
while k <= 40:
if Find(... | FUNC_DEF ASSIGN VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER WHILE BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR N... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | n, p = [int(i) for i in input().split()]
def g(x: int, k: int) -> list:
q = bin(x)[2:][::-1]
r1, r2, r3, r = [], [], [], []
s = sum(map(int, list(q)))
i = len(q) - 1
while s < k:
qq = int(q[i]) * 2 + int(q[i - 1])
ost = ""
if len(q[i:]) > 1:
ost = "0" + q[i + 1 ... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR VAR VAR VAR LIST LIST LIST LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR... |
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $p$ (which may be positive, negative, or zero). To combine their tastes, they invented $p$-binary numbers of the form $2^x + p$, where $x$ is a non-negative integer.
For ... | n, p = map(int, input().split())
power = []
power.append(1)
for i in range(1, 31):
power.append(power[len(power) - 1] * 2)
ans = -1
i = 1
while i < 31:
y = n - i * p
if y <= 0 or y < i:
break
a = []
while y:
a.append(y % 2)
y = y // 2
count = 0
for x in a:
if ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR IF VAR NUMBER VAR VAR ASSI... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.