description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
A positive integer x is called a power of two if it can be represented as x = 2^y, where y is a non-negative integer. So, the powers of two are 1, 2, 4, 8, 16, ....
You are given two positive integers n and k. Your task is to represent n as the sum of exactly k powers of two.
Input
The only line of the input contain... | n, k = list(map(int, input().split()))
ans = []
def myrec(dig):
a = 1
if dig == 0:
return
while a <= dig:
a *= 2
a //= 2
dig -= a
ans.append(a)
myrec(dig)
myrec(n)
ans.sort(reverse=True)
i = 0
while len(ans) < k and i <= len(ans) - 1:
if ans[i] == 1:
i += 1
... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FUNC_DEF ASSIGN VAR NUMBER IF VAR NUMBER RETURN WHILE VAR VAR VAR NUMBER VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR VAR ... |
A positive integer x is called a power of two if it can be represented as x = 2^y, where y is a non-negative integer. So, the powers of two are 1, 2, 4, 8, 16, ....
You are given two positive integers n and k. Your task is to represent n as the sum of exactly k powers of two.
Input
The only line of the input contain... | n, k = map(int, input().split())
now = 2**30
nn = 30
ans = []
while now > n:
nn -= 1
now //= 2
ans.append(now)
n -= now
k -= 1
if k == 0 and n == 0:
print("YES")
print(ans[0])
else:
while n != 0:
while now > n:
nn -= 1
now //= 2
n -= now
ans.append(now... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR NUMBER WHILE VAR NUMBER WHILE VAR VAR VAR NUM... |
A positive integer x is called a power of two if it can be represented as x = 2^y, where y is a non-negative integer. So, the powers of two are 1, 2, 4, 8, 16, ....
You are given two positive integers n and k. Your task is to represent n as the sum of exactly k powers of two.
Input
The only line of the input contain... | n, kk = map(int, input().split())
bn = str(bin(n))[2:]
if bn.count("1") > kk or n < kk:
print("NO")
else:
k = [0] * 50
k[0] = n
s = n
i = 0
while 1:
if s <= kk:
break
if s - k[i] // 2 < kk:
k[i + 1] = s - kk
k[i] -= (s - kk) * 2
bre... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR STRING VAR VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER VAR ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE NUMBER IF VAR VAR IF BIN_OP VAR BIN_OP VAR VAR NUMBER... |
A positive integer x is called a power of two if it can be represented as x = 2^y, where y is a non-negative integer. So, the powers of two are 1, 2, 4, 8, 16, ....
You are given two positive integers n and k. Your task is to represent n as the sum of exactly k powers of two.
Input
The only line of the input contain... | MOD = 10**9 + 7
I = lambda: list(map(int, input().split()))
l = []
i = 0
while 2**i <= 10**9:
l.append(2**i)
i += 1
n, k = I()
res = []
temp = n
for i in reversed(l):
while k > 0 and n - i >= k - 1:
res.append(i)
n -= i
k -= 1
if sum(res) != temp:
print("NO")
else:
print("YES... | ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE BIN_OP NUMBER VAR BIN_OP NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR VAR FOR VAR FUNC_CALL VA... |
A positive integer x is called a power of two if it can be represented as x = 2^y, where y is a non-negative integer. So, the powers of two are 1, 2, 4, 8, 16, ....
You are given two positive integers n and k. Your task is to represent n as the sum of exactly k powers of two.
Input
The only line of the input contain... | def solve(n, k):
arr = [(1) for i in range(k)]
sm = k
i = k - 1
while i >= 0:
while sm + arr[i] <= n:
sm += arr[i]
arr[i] *= 2
i -= 1
return arr
n, k = map(int, input().split())
res = solve(n, k)
if sum(res) == n:
print("YES")
print(*res)
else:
p... | FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN 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 RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VA... |
A positive integer x is called a power of two if it can be represented as x = 2^y, where y is a non-negative integer. So, the powers of two are 1, 2, 4, 8, 16, ....
You are given two positive integers n and k. Your task is to represent n as the sum of exactly k powers of two.
Input
The only line of the input contain... | n, k = map(int, input().split())
h = [int(_) for _ in bin(n)[2:]]
plz = list(reversed(h))
options = []
i = 0
for char in range(len(plz)):
if plz[char] == 1:
options.append(2**char)
if len(options) > k:
print("NO")
else:
while len(options) < k:
try:
if options[i] != 1:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER VAR IF FUNC_CALL VAR VAR VAR EXPR FUN... |
A positive integer x is called a power of two if it can be represented as x = 2^y, where y is a non-negative integer. So, the powers of two are 1, 2, 4, 8, 16, ....
You are given two positive integers n and k. Your task is to represent n as the sum of exactly k powers of two.
Input
The only line of the input contain... | entrada = input().split(" ")
n = int(entrada[0])
k = int(entrada[1])
lista = [1] * k
total = k
for i in range(k - 1, -1, -1):
while total + lista[i] <= n:
total = total + lista[i]
lista[i] = lista[i] * 2
if total != n:
print("NO")
else:
print("YES")
print(*lista, sep=" ") | ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER WHILE BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR NUMBER IF VAR ... |
A positive integer x is called a power of two if it can be represented as x = 2^y, where y is a non-negative integer. So, the powers of two are 1, 2, 4, 8, 16, ....
You are given two positive integers n and k. Your task is to represent n as the sum of exactly k powers of two.
Input
The only line of the input contain... | n, k = map(int, input().split())
s = [i for i in bin(n)[2:]]
if n < k or s.count("1") > k:
print("NO")
else:
print("YES")
L = []
for i in range(31):
L.append(2**i)
a = []
for i in reversed(range(31)):
while k > 0 and n - L[i] >= k - 1:
a.append(L[i])
k -= ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR NUMBER IF VAR VAR FUNC_CALL VAR STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL V... |
A positive integer x is called a power of two if it can be represented as x = 2^y, where y is a non-negative integer. So, the powers of two are 1, 2, 4, 8, 16, ....
You are given two positive integers n and k. Your task is to represent n as the sum of exactly k powers of two.
Input
The only line of the input contain... | t, k = input().split()
t = int(t)
k = int(k)
a = []
b = []
l = 0
if k > t:
print("NO")
else:
j = 0
while t > 0:
if t % 2 == 1:
a.append(2**j)
l += 1
t //= 2
j += 1
if k < l:
print("NO")
else:
while 1:
if len(a) == k:
... | ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER VAR VAR NUMBER VAR NUMBER VAR NUMBER IF ... |
A positive integer x is called a power of two if it can be represented as x = 2^y, where y is a non-negative integer. So, the powers of two are 1, 2, 4, 8, 16, ....
You are given two positive integers n and k. Your task is to represent n as the sum of exactly k powers of two.
Input
The only line of the input contain... | n, k = map(int, input().split())
if k > n:
print("NO")
else:
a = []
f = n
summ = 0
i = 0
while n != 0:
if n % 2 != 0:
a.append(i)
n //= 2
i += 1
if len(a) > k:
print("NO")
else:
a.sort()
c = dict()
for i in a:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER VAR NUMBER IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR... |
A positive integer x is called a power of two if it can be represented as x = 2^y, where y is a non-negative integer. So, the powers of two are 1, 2, 4, 8, 16, ....
You are given two positive integers n and k. Your task is to represent n as the sum of exactly k powers of two.
Input
The only line of the input contain... | n, m = map(int, input().split())
b = bin(n)[2:]
j = b.count("1")
if j <= m <= n:
print("YES")
else:
exit(print("NO"))
heap = []
t = 0
for i in b[::-1]:
if i == "1":
heap.append(int(2**t))
t += 1
heap.sort()
p = 0
if heap[0] == 1:
heap = heap[1:]
m = m - 1
p = 1
while len(heap) != m:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR NUMBER IF VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP NUMBER ... |
A positive integer x is called a power of two if it can be represented as x = 2^y, where y is a non-negative integer. So, the powers of two are 1, 2, 4, 8, 16, ....
You are given two positive integers n and k. Your task is to represent n as the sum of exactly k powers of two.
Input
The only line of the input contain... | def pr(d):
print("YES")
for k in d:
for _ in range(d[k]):
print(2**k, end=" ")
n, k = map(int, input().split())
d = {}
for p, v in enumerate(bin(n)[:1:-1]):
d[p] = int(v)
b = sum(d.values())
i = max(d.keys())
if k > n or k < b:
print("NO")
else:
while b < k:
if d[i]:
... | FUNC_DEF EXPR FUNC_CALL VAR STRING FOR VAR VAR FOR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP NUMBER VAR STRING ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL ... |
A positive integer x is called a power of two if it can be represented as x = 2^y, where y is a non-negative integer. So, the powers of two are 1, 2, 4, 8, 16, ....
You are given two positive integers n and k. Your task is to represent n as the sum of exactly k powers of two.
Input
The only line of the input contain... | n, k = map(int, input().split())
i = 0
s = bin(n)[2:][::-1]
d = {}
while pow(2, i) <= 10**9:
d[pow(2, i)] = 0
i += 1
p = -1
c = 0
flag = 0
for i in range(len(s)):
if s[i] == "1":
d[pow(2, i)] = 1
c += 1
p = i
m = 0
for i in d.items():
m += i[1]
x = d.items()
x = sorted(x, key=lam... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR DICT WHILE FUNC_CALL VAR NUMBER VAR BIN_OP NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC... |
A positive integer x is called a power of two if it can be represented as x = 2^y, where y is a non-negative integer. So, the powers of two are 1, 2, 4, 8, 16, ....
You are given two positive integers n and k. Your task is to represent n as the sum of exactly k powers of two.
Input
The only line of the input contain... | def output_successful_answer(count):
print("YES")
power = 1
for i in range(len(count) - 1, -1, -1):
while count[i] > 0:
print(power, end=" ")
count[i] -= 1
power *= 2
print()
def get_ans(count, total_powers, k, i):
while total_powers < k and i + 1 < len(coun... | FUNC_DEF EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER WHILE VAR VAR NUMBER EXPR FUNC_CALL VAR VAR STRING VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_DEF WHILE VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMB... |
A positive integer x is called a power of two if it can be represented as x = 2^y, where y is a non-negative integer. So, the powers of two are 1, 2, 4, 8, 16, ....
You are given two positive integers n and k. Your task is to represent n as the sum of exactly k powers of two.
Input
The only line of the input contain... | def mlt():
return map(int, input().split())
x, y = mlt()
if x == y:
print("YES")
print("1 " * x)
exit(0)
s = []
pw = 0
v = x
while x:
if x % 2:
s.append(1 << pw)
pw += 1
x //= 2
if y > v or y < len(s):
print("NO")
exit(0)
res = []
s.reverse()
cur = -1
n = 0
while n < len(s)... | FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER VAR VAR NUMBER VAR N... |
A positive integer x is called a power of two if it can be represented as x = 2^y, where y is a non-negative integer. So, the powers of two are 1, 2, 4, 8, 16, ....
You are given two positive integers n and k. Your task is to represent n as the sum of exactly k powers of two.
Input
The only line of the input contain... | n, k = [int(x) for x in input().split()]
b = bin(n)[2:][::-1]
if b.count("1") > k or k > n:
print("NO")
else:
nums = []
ans = ""
for i in range(len(b)):
if b[i] == "1":
nums.append(2**i)
_k = 0
while _k + len(nums) < k:
num = nums.pop()
if num == 1:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER NUMBER IF FUNC_CALL VAR STRING VAR VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER WHILE B... |
A positive integer x is called a power of two if it can be represented as x = 2^y, where y is a non-negative integer. So, the powers of two are 1, 2, 4, 8, 16, ....
You are given two positive integers n and k. Your task is to represent n as the sum of exactly k powers of two.
Input
The only line of the input contain... | n, k = map(int, input().split())
a = bin(n)[2:]
c = 0
l = []
for i in range(len(a)):
if a[i] == "1":
c += 1
l.append(pow(2, len(a) - i - 1))
if c == k:
print("YES")
s = ""
for i in l:
s += str(i) + " "
print(s)
elif c < k:
i = 0
while c != k and i < len(l):
a ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR STRING ASSI... |
A positive integer x is called a power of two if it can be represented as x = 2^y, where y is a non-negative integer. So, the powers of two are 1, 2, 4, 8, 16, ....
You are given two positive integers n and k. Your task is to represent n as the sum of exactly k powers of two.
Input
The only line of the input contain... | n, k = [int(x) for x in input().split()]
if n < k:
print("NO")
else:
p = []
t = n
i = 1
j = 0
while t != 0:
if t & i != 0:
p.append(2**j)
t = t & t - 1
j += 1
i <<= 1
if len(p) > k:
print("NO")
else:
print("YES")
i =... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER IF FUNC_CALL V... |
A positive integer x is called a power of two if it can be represented as x = 2^y, where y is a non-negative integer. So, the powers of two are 1, 2, 4, 8, 16, ....
You are given two positive integers n and k. Your task is to represent n as the sum of exactly k powers of two.
Input
The only line of the input contain... | n, k = map(int, input().split())
b = bin(n)[2:][::-1]
t = b.count("1")
if k < t:
print("NO")
exit(0)
s, i = [], 1
for j in b:
if j == "1":
s.append(i)
i *= 2
j = len(s) - 1
ans = []
while k - t > 0:
if s[j] != 1:
s[j] //= 2
s.append(s[j])
t += 1
j += 1
eli... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR LIST NUMBER FOR VAR VAR IF VAR STRING EXPR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NU... |
A positive integer x is called a power of two if it can be represented as x = 2^y, where y is a non-negative integer. So, the powers of two are 1, 2, 4, 8, 16, ....
You are given two positive integers n and k. Your task is to represent n as the sum of exactly k powers of two.
Input
The only line of the input contain... | def solve():
n, k = [int(i) for i in input().split(" ")]
a = [1] * k
s = k
for i in range(k):
while s + a[i] <= n:
s += a[i]
a[i] *= 2
if s != n:
return "NO"
o = "YES\n"
o += " ".join(str(i) for i in a)
return o
print(solve()) | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR WHILE BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR VAR NUMBER IF VAR VAR RETURN STRING ASSIGN VAR STRING VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR RETURN VAR EXPR FUNC_C... |
A positive integer x is called a power of two if it can be represented as x = 2^y, where y is a non-negative integer. So, the powers of two are 1, 2, 4, 8, 16, ....
You are given two positive integers n and k. Your task is to represent n as the sum of exactly k powers of two.
Input
The only line of the input contain... | n, k = list(map(int, input().split()))
x = []
ones = 0
while n:
if n % 2 == 0:
x.append(0)
else:
x.append(1)
ones += 1
n = int(n / 2)
x.reverse()
n = ones
if n > k:
print("NO")
else:
for i in range(len(x)):
if n == k:
break
if x[i] != 0 and i + 1 <... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR VAR IF VAR VAR EXPR FUNC_CALL VAR STRING ... |
A positive integer x is called a power of two if it can be represented as x = 2^y, where y is a non-negative integer. So, the powers of two are 1, 2, 4, 8, 16, ....
You are given two positive integers n and k. Your task is to represent n as the sum of exactly k powers of two.
Input
The only line of the input contain... | a, b = map(int, input().split())
c = 0
s = str(bin(a))[2:][::-1]
lol = []
for i in range(len(s)):
if s[i] == "1":
lol.append(pow(2, i))
c += 1
if b > a or b < c:
print("NO")
else:
k = b - c
while len(lol) < b:
yo = []
for i in range(len(lol)):
if lol[i] > 1:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER VAR VAR NUMBER IF VAR VAR VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN... |
A positive integer x is called a power of two if it can be represented as x = 2^y, where y is a non-negative integer. So, the powers of two are 1, 2, 4, 8, 16, ....
You are given two positive integers n and k. Your task is to represent n as the sum of exactly k powers of two.
Input
The only line of the input contain... | n, k = [int(i) for i in input().split()]
a = [0] * 33
c = 0
for i in range(33):
if n >> i & 1 == 1:
a[i] += 1
c += 1
if c > k:
print("NO")
else:
pos = 32
while c < k and pos > 0:
if a[pos] == 0:
pos -= 1
continue
c += 1
a[pos] -= 1
... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR VAR NUMBER VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER IF VAR VAR NUMBER VAR NUMBER V... |
A positive integer x is called a power of two if it can be represented as x = 2^y, where y is a non-negative integer. So, the powers of two are 1, 2, 4, 8, 16, ....
You are given two positive integers n and k. Your task is to represent n as the sum of exactly k powers of two.
Input
The only line of the input contain... | n, k = map(int, input().split())
twolist = [1]
indexStart = 0
for i in range(1, 30):
twolist.append(twolist[-1] * 2)
if twolist[-1] <= n:
indexStart = i
remainSum = n
ans = []
while remainSum > 0:
if twolist[indexStart] <= remainSum:
ans.append(twolist[indexStart])
remainSum -= twoli... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER IF VAR NUMBER VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR LIST WHILE VAR NUMBER IF VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR NUM... |
A positive integer x is called a power of two if it can be represented as x = 2^y, where y is a non-negative integer. So, the powers of two are 1, 2, 4, 8, 16, ....
You are given two positive integers n and k. Your task is to represent n as the sum of exactly k powers of two.
Input
The only line of the input contain... | x, y = map(int, input().split())
a = 0
b = 0
ind = 0
s = []
while x > 0:
if x % 2 == 1:
a += 1
b += 1 << ind
s.append(1 << ind)
x >>= 1
ind += 1
if y < a or y > b:
print("NO")
exit(0)
if x == y:
print("YES")
for n in range(x):
print(1, end=" ")
exit(0)... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR BIN_OP NUMBER VAR VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_C... |
A positive integer x is called a power of two if it can be represented as x = 2^y, where y is a non-negative integer. So, the powers of two are 1, 2, 4, 8, 16, ....
You are given two positive integers n and k. Your task is to represent n as the sum of exactly k powers of two.
Input
The only line of the input contain... | inp = input().split()
n = int(inp[0])
k = int(inp[1])
a = []
cc = 0
ck = k
while n != 0:
a.append(n % 2)
cc += n % 2
n //= 2
a = a[::-1]
if k < cc:
print("NO")
else:
k -= cc
for i in range(len(a) - 1):
if a[i] > 0:
temp2 = min(k, a[i])
a[i] -= temp2
a[... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR STRING VAR VAR FOR VAR FU... |
A positive integer x is called a power of two if it can be represented as x = 2^y, where y is a non-negative integer. So, the powers of two are 1, 2, 4, 8, 16, ....
You are given two positive integers n and k. Your task is to represent n as the sum of exactly k powers of two.
Input
The only line of the input contain... | import sys
input = sys.stdin.readline
def swaparr(arr, a, b):
temp = arr[a]
arr[a] = arr[b]
arr[b] = temp
def gcd(a, b):
if b == 0:
return a
return gcd(b, a % b)
def nCr(n, k):
if k > n - k:
k = n - k
res = 1
for i in range(k):
res = res * (n - i)
r... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR FUNC_DEF IF VAR NUMBER RETURN VAR RETURN FUNC_CALL VAR VAR BIN_OP VAR VAR FUNC_DEF IF VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR BIN_O... |
A positive integer x is called a power of two if it can be represented as x = 2^y, where y is a non-negative integer. So, the powers of two are 1, 2, 4, 8, 16, ....
You are given two positive integers n and k. Your task is to represent n as the sum of exactly k powers of two.
Input
The only line of the input contain... | n, k = map(int, input().split())
l = []
while n >= 1:
l.append(n % 2)
n = n // 2
p = []
for i in range(len(l)):
if l[i] != 0:
p.append(2**i * l[i])
c = 0
pl = len(p)
if pl > k:
c = -1
else:
y = 1
cn = 0
k = k - pl
fg = 0
while k > 0:
if y > pl:
c = -1
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST WHILE VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL... |
A positive integer x is called a power of two if it can be represented as x = 2^y, where y is a non-negative integer. So, the powers of two are 1, 2, 4, 8, 16, ....
You are given two positive integers n and k. Your task is to represent n as the sum of exactly k powers of two.
Input
The only line of the input contain... | def ii():
return int(input())
def mi():
return map(int, input().split())
def li():
return list(mi())
n, k = mi()
if k < bin(n).count("1") or k > n:
print("NO")
else:
ans = []
cur = bin(n).count("1")
for i in range(30):
if n >> i & 1:
st = [1 << i]
while ... | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR IF VAR FUNC_CALL FUNC_CALL VAR VAR STRING VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR STRING FOR VAR... |
A positive integer x is called a power of two if it can be represented as x = 2^y, where y is a non-negative integer. So, the powers of two are 1, 2, 4, 8, 16, ....
You are given two positive integers n and k. Your task is to represent n as the sum of exactly k powers of two.
Input
The only line of the input contain... | import sys
n, k = map(int, sys.stdin.readline().split())
def find(n, k):
pow = 0
tmp_two = 1
two = []
while tmp_two <= 10**9:
pow += 1
two.append(tmp_two)
tmp_two = 2**pow
if k > n:
return "NO"
else:
numbers = {}
for t in two:
number... | IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR BIN_OP NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER VAR IF VAR VAR RETURN STRING ASSIGN VAR DICT FOR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN V... |
A positive integer x is called a power of two if it can be represented as x = 2^y, where y is a non-negative integer. So, the powers of two are 1, 2, 4, 8, 16, ....
You are given two positive integers n and k. Your task is to represent n as the sum of exactly k powers of two.
Input
The only line of the input contain... | n, k = map(int, input().split())
Bin = [0] * 32
One = i = 0
while n > 0:
if n % 2 == 1:
Bin[i] = 1
One += 1
i += 1
n //= 2
if One > k:
print("NO")
exit()
for i in range(31, 0, -1):
if One == k:
break
if Bin[i] >= 1:
while Bin[i] != 0 and One < k:
B... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF VA... |
A positive integer x is called a power of two if it can be represented as x = 2^y, where y is a non-negative integer. So, the powers of two are 1, 2, 4, 8, 16, ....
You are given two positive integers n and k. Your task is to represent n as the sum of exactly k powers of two.
Input
The only line of the input contain... | n, k = [int(i) for i in input().split()]
s = bin(n)
stack = []
j = 0
for i in reversed(s):
if i == "1":
stack.append(2**j)
j += 1
if len(stack) > k or n < k:
print("NO")
exit(0)
ones = 0
while len(stack) != k - ones:
while True:
tmp = stack.pop()
if tmp != 1:
brea... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR STRING EXPR FUNC_CALL VAR BIN_OP NUMBER VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER WHILE... |
A positive integer x is called a power of two if it can be represented as x = 2^y, where y is a non-negative integer. So, the powers of two are 1, 2, 4, 8, 16, ....
You are given two positive integers n and k. Your task is to represent n as the sum of exactly k powers of two.
Input
The only line of the input contain... | N, K = [int(x) for x in input().split()]
binary = list(bin(N))
binary = binary[2:]
binary.reverse()
checker = []
for i in range(len(binary)):
if binary[i] == "1":
checker.append(2**i)
if binary.count("1") > K or N < K:
print("NO")
exit()
else:
x = 0
counter = len(checker)
if counter == K... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR BIN_OP NUMBER VAR IF FUNC_CALL VAR STRING VAR VAR VAR EXPR FUNC_CALL VAR STRING EX... |
A positive integer x is called a power of two if it can be represented as x = 2^y, where y is a non-negative integer. So, the powers of two are 1, 2, 4, 8, 16, ....
You are given two positive integers n and k. Your task is to represent n as the sum of exactly k powers of two.
Input
The only line of the input contain... | n, k = map(int, input().split(" "))
s = []
if n < k:
print("NO")
else:
while n > 0:
s.append(int(n % 2))
n = int(n / 2)
if k < sum(s):
print("NO")
else:
print("YES")
for i in range(len(s)):
while s[len(s) - i - 1] != 0:
if sum(s) == k:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST IF VAR VAR EXPR FUNC_CALL VAR STRING WHILE VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CA... |
A positive integer x is called a power of two if it can be represented as x = 2^y, where y is a non-negative integer. So, the powers of two are 1, 2, 4, 8, 16, ....
You are given two positive integers n and k. Your task is to represent n as the sum of exactly k powers of two.
Input
The only line of the input contain... | n, u = map(int, input().split())
jj = u
k = str(bin(n))
k = k[2:]
lis = []
for i in range(len(k)):
if k[i] == "1":
lis.append(2 ** (len(k) - i - 1))
if len(lis) > u:
print("NO")
exit()
u = u - len(lis)
i = 0
while u > 0 and len(lis) > i:
if lis[i] == 1:
i = i + 1
else:
lis[i]... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR BIN_OP NUMBER BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR EXPR FUN... |
A positive integer x is called a power of two if it can be represented as x = 2^y, where y is a non-negative integer. So, the powers of two are 1, 2, 4, 8, 16, ....
You are given two positive integers n and k. Your task is to represent n as the sum of exactly k powers of two.
Input
The only line of the input contain... | n, k = map(int, input().split())
if k > n:
print("NO")
elif k == n:
print("YES")
for i in range(n):
print("1", end=" ")
print()
else:
pows = [0] * 30
l = i = 0
nc = n
while nc > 0:
pows[i] = nc % 2
l += pows[i]
nc //= 2
i += 1
if k < l:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR STRING IF VAR VAR EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING STRING EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR WHILE VAR NUMBER ASSIGN VAR VAR BIN_O... |
A positive integer x is called a power of two if it can be represented as x = 2^y, where y is a non-negative integer. So, the powers of two are 1, 2, 4, 8, 16, ....
You are given two positive integers n and k. Your task is to represent n as the sum of exactly k powers of two.
Input
The only line of the input contain... | n, k = map(int, input().split())
m = bin(n)
m = m[2:]
if m.count("1") > k:
print("NO")
elif m.count("1") == k:
print("YES")
for i in range(len(m)):
if m[i] == "1":
print(2 ** (len(m) - 1 - i), end=" ")
else:
a = [0] * (len(m) + 1)
for i in range(len(m)):
a[i] = int(m[len(... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER IF FUNC_CALL VAR STRING VAR EXPR FUNC_CALL VAR STRING IF FUNC_CALL VAR STRING VAR EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR BIN_OP NUMBER BIN_OP BIN_OP... |
A positive integer x is called a power of two if it can be represented as x = 2^y, where y is a non-negative integer. So, the powers of two are 1, 2, 4, 8, 16, ....
You are given two positive integers n and k. Your task is to represent n as the sum of exactly k powers of two.
Input
The only line of the input contain... | n, k = map(int, input().split())
if k > n:
print("NO")
exit()
nb = bin(n)[-1:1:-1]
ans = {}
c = 0
for i in range(len(nb)):
if nb[i] == "1":
if nb[i] not in ans:
ans[2**i] = 1
else:
ans[2**i] += 1
c += 1
if k < c:
print("NO")
exit()
while c != k:
fo... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR VAR VAR ASSIGN VAR BIN_OP NUMBER VAR NUMBER VAR BIN_OP NUM... |
A positive integer x is called a power of two if it can be represented as x = 2^y, where y is a non-negative integer. So, the powers of two are 1, 2, 4, 8, 16, ....
You are given two positive integers n and k. Your task is to represent n as the sum of exactly k powers of two.
Input
The only line of the input contain... | xs = list(map(int, input().split(" ")))
b = bin(xs[0])[2:]
k = xs[1]
r = b.count("1")
ks = []
for i, q in enumerate(reversed(list(b))):
if q == "1":
ks.append(i)
if k < len(ks):
print("NO")
else:
stack = ks
ans = []
p = 0
q = len(ks)
while q < xs[1] and len(stack) > 0:
x = st... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR STRING EXPR FUNC_CALL VAR VAR IF VAR FUNC_CALL VAR VAR EXPR FUNC_CAL... |
A positive integer x is called a power of two if it can be represented as x = 2^y, where y is a non-negative integer. So, the powers of two are 1, 2, 4, 8, 16, ....
You are given two positive integers n and k. Your task is to represent n as the sum of exactly k powers of two.
Input
The only line of the input contain... | n, k = map(int, input().split())
binN = list(map(int, bin(n)[2:]))
c = binN.count(1)
if k < c or k > n:
print("NO")
else:
i = 0
while i < len(binN) - 1 and c < k:
while binN[i] > 0 and c < k:
c = c + 1
binN[i] = binN[i] - 1
binN[i + 1] = binN[i + 1] + 2
i ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER IF VAR VAR VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR WHILE VAR VAR NUMBER VAR VAR ASSIGN VAR BIN_OP VAR... |
A positive integer x is called a power of two if it can be represented as x = 2^y, where y is a non-negative integer. So, the powers of two are 1, 2, 4, 8, 16, ....
You are given two positive integers n and k. Your task is to represent n as the sum of exactly k powers of two.
Input
The only line of the input contain... | def main():
a = input()
n, k = [int(i) for i in a.split(" ")]
if k > n:
print("NO")
return
c = [0] * 30
cnt = 0
for i in range(30):
if n & 1 << i != 0:
c[i] += 1
cnt += 1
if cnt > k:
print("NO")
return
print("YES")
k -= ... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING IF VAR VAR EXPR FUNC_CALL VAR STRING RETURN ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR BIN_OP NUMBER VAR NUMBER VAR VAR NUMBER VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR STRIN... |
A positive integer x is called a power of two if it can be represented as x = 2^y, where y is a non-negative integer. So, the powers of two are 1, 2, 4, 8, 16, ....
You are given two positive integers n and k. Your task is to represent n as the sum of exactly k powers of two.
Input
The only line of the input contain... | n, k = map(int, input().split())
if k > n:
print("NO")
else:
b = bin(n)[2:]
if b.count("1") == k:
b = b[::-1]
print("YES")
for i in range(len(b)):
if b[i] == "1":
print(1 << i, end=" ")
print("")
elif b.count("1") < k:
l = []
x ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR STRING VAR ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR BIN_OP NUMBER VAR STRING EXPR FUNC_CA... |
A positive integer x is called a power of two if it can be represented as x = 2^y, where y is a non-negative integer. So, the powers of two are 1, 2, 4, 8, 16, ....
You are given two positive integers n and k. Your task is to represent n as the sum of exactly k powers of two.
Input
The only line of the input contain... | import sys
n, k = map(int, input().split())
m = bin(n)[2:]
m = [int(i) for i in m]
def val(a):
l = len(a)
x = 0
p = 1
for i in range(l):
x += a[i] * p
p *= 2
return x
while True:
if sum(m) == k:
print("YES")
m = m[::-1]
x = 1
for i in m:
... | IMPORT 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 VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR VAR NUMBER RETURN VAR WHILE NUMBER IF FUNC_CALL VAR VAR VAR ... |
A positive integer x is called a power of two if it can be represented as x = 2^y, where y is a non-negative integer. So, the powers of two are 1, 2, 4, 8, 16, ....
You are given two positive integers n and k. Your task is to represent n as the sum of exactly k powers of two.
Input
The only line of the input contain... | n, x = map(int, input().split())
v = n
l = []
i = 0
for k in range(32):
if (n & 1 << k) >> k:
l.append(pow(2, k))
x -= len(l)
if x < 0:
print("NO")
else:
i = 0
while x > 0:
while i < len(l) and l[i] == 1:
i += 1
if i == len(l):
print("NO")
exit... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP BIN_OP VAR BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER WHILE VAR NUMBER W... |
Sereja has an n Γ m rectangular table a, each cell of the table contains a zero or a number one. Sereja wants his table to meet the following requirement: each connected component of the same values forms a rectangle with sides parallel to the sides of the table. Rectangles should be filled with cells, that is, if a co... | read_line = lambda: [int(i) for i in input().split()]
n, m, k = read_line()
a = [read_line() for i in range(n)]
if n < m:
n, m, a = m, n, list(zip(*a))
xs = []
for y in a:
x = 0
for b in y:
x = 2 * x + b
xs.append(x)
def work(y):
tot = 0
for x in xs:
c = bin(x ^ y).count("1")
... | ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR VAR EXPR FUNC_CALL ... |
You've got a string $S$ consisting of $n$ lowercase English letters from your friend. It turned out that this is a number written in poman numerals. The poman numeral system is long forgotten. All that's left is the algorithm to transform number from poman numerals to the numeral system familiar to us. Characters of $S... | _, T = [int(x) for x in input().split()]
L = [(ord(x) - ord("a")) for x in input()]
T -= 2 ** L[-1]
T += 2 ** L[-2]
L = L[:-2]
L.sort(reverse=True)
for c in L:
T += (1 if T < 0 else -1) * (1 << c)
print("Yes" if T == 0 else "No") | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING VAR FUNC_CALL VAR VAR BIN_OP NUMBER VAR NUMBER VAR BIN_OP NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR VAR VAR BIN_OP VAR NUMBER NUMBER NUMBER BIN_OP NUMBER VAR EXPR FUNC_CA... |
You've got a string $S$ consisting of $n$ lowercase English letters from your friend. It turned out that this is a number written in poman numerals. The poman numeral system is long forgotten. All that's left is the algorithm to transform number from poman numerals to the numeral system familiar to us. Characters of $S... | import sys
input = sys.stdin.readline
n, T = map(int, input().split())
S = input().strip()
L = [(ord(s) - 97) for s in S]
T += pow(2, L[-2]) - pow(2, L[-1])
L = L[:-2]
L.sort(reverse=True)
for i in range(len(L)):
if T > 0:
T -= 1 << L[i]
else:
T += 1 << L[i]
if T == 0:
print("Yes")
else:
... | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR VAR BIN_OP FUNC_CALL VAR NUMBER VAR NUMBER FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL ... |
You've got a string $S$ consisting of $n$ lowercase English letters from your friend. It turned out that this is a number written in poman numerals. The poman numeral system is long forgotten. All that's left is the algorithm to transform number from poman numerals to the numeral system familiar to us. Characters of $S... | n, t = input().split()
n, t = int(n), int(t)
s = list(input())
if n == 1:
if 2 ** (ord(s) - 97) == t:
print("Yes")
else:
print("No")
elif n == 2:
if 2 ** (ord(s[1]) - 97) - 2 ** (ord(s[0]) - 97) == t:
print("Yes")
else:
print("No")
else:
t -= 2 ** (ord(s[-1]) - 97) - ... | ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER IF BIN_OP NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING IF VAR NUMBER IF BIN_OP BIN_OP NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER NU... |
You have unweighted tree of n vertices. You have to assign a positive weight to each edge so that the following condition would hold:
* For every two different leaves v_{1} and v_{2} of this tree, [bitwise XOR](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of weights of all edges on the simple path between v_... | n = int(input())
v = [0] * n
g = [[] for _ in range(n)]
for _ in range(n - 1):
a, b = map(int, input().split())
g[a - 1].append(b - 1)
g[b - 1].append(a - 1)
v[a - 1] += 1
v[b - 1] += 1
for i in range(n):
if v[i] > 1:
p = i
break
s = [p]
d = [-1] * n
d[p] = 0
x = -1
minans = 1
ma... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER VA... |
You have unweighted tree of n vertices. You have to assign a positive weight to each edge so that the following condition would hold:
* For every two different leaves v_{1} and v_{2} of this tree, [bitwise XOR](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of weights of all edges on the simple path between v_... | import sys
input = sys.stdin.readline
graph, leaves = {(i + 1): [] for i in range(int(input()))}, []
dist, queue, second = {(i + 1): (0) for i in range(len(graph))}, [], set()
for _ in range(len(graph) - 1):
a, b = map(int, input().split())
graph[a].append(b)
graph[b].append(a)
for node in graph:
if le... | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER LIST VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR LIST ASSIGN VAR VAR VAR BIN_OP VAR NUMBER NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR LIST FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR... |
You have unweighted tree of n vertices. You have to assign a positive weight to each edge so that the following condition would hold:
* For every two different leaves v_{1} and v_{2} of this tree, [bitwise XOR](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of weights of all edges on the simple path between v_... | n = int(input())
ls = [[] for x in range(n)]
for inp in range(n - 1):
point1, point2 = [(int(x) - 1) for x in input().split()]
ls[point1].append(point2)
ls[point2].append(point1)
bottom = []
e = [0] * n
max_res = n - 1
for i in range(n):
temp = ls[i]
if len(temp) == 1:
if e[temp[0]] == 1:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP VAR NU... |
You have unweighted tree of n vertices. You have to assign a positive weight to each edge so that the following condition would hold:
* For every two different leaves v_{1} and v_{2} of this tree, [bitwise XOR](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of weights of all edges on the simple path between v_... | import sys
input = sys.stdin.buffer.readline
n = int(input())
childs = [set() for i in range(n + 1)]
marker = [False] * (n + 1)
for i in range(n - 1):
a, b = map(int, input().split())
childs[a].add(b)
childs[b].add(a)
for i in range(1, n + 1):
if len(childs[i]) == 1:
father = list(childs[i])[0]... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR... |
You have unweighted tree of n vertices. You have to assign a positive weight to each edge so that the following condition would hold:
* For every two different leaves v_{1} and v_{2} of this tree, [bitwise XOR](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of weights of all edges on the simple path between v_... | n = int(input())
g = [[] for x in range(n + 1)]
vis, fMax, lenFlag, leafCount, parent = [([0] * (n + 1)) for x in range(5)]
for i in range(n - 1):
u, v = map(int, input().split())
g[u].append(v)
g[v].append(u)
for i in range(1, n + 1):
if len(g[i]) > 1:
root = i
break
i = 0
q = [root]
vi... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR VAR VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL V... |
You have unweighted tree of n vertices. You have to assign a positive weight to each edge so that the following condition would hold:
* For every two different leaves v_{1} and v_{2} of this tree, [bitwise XOR](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of weights of all edges on the simple path between v_... | class Nd:
def __init__(self):
self.link = []
def bind(self, other):
self.link.append(other)
other.link.append(self)
def hang(self):
br = set()
lv = set()
cnt = 0
self.level = 0
self.par = None
que = [self]
while que:
... | CLASS_DEF FUNC_DEF ASSIGN VAR LIST FUNC_DEF EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NONE ASSIGN VAR LIST VAR WHILE VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR N... |
You have unweighted tree of n vertices. You have to assign a positive weight to each edge so that the following condition would hold:
* For every two different leaves v_{1} and v_{2} of this tree, [bitwise XOR](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of weights of all edges on the simple path between v_... | import sys
input = sys.stdin.readline
n = int(input())
g = [[] for i in range(n)]
for _ in range(n - 1):
a, b = map(int, input().split())
g[a - 1].append(b - 1)
g[b - 1].append(a - 1)
leaf = []
for i in range(n):
if len(g[i]) == 1:
leaf.append(i)
q = [0]
use = [-1] * n
use[0] = 0
while q:
v... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR LIS... |
You have unweighted tree of n vertices. You have to assign a positive weight to each edge so that the following condition would hold:
* For every two different leaves v_{1} and v_{2} of this tree, [bitwise XOR](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of weights of all edges on the simple path between v_... | n = int(input().strip())
conns = [set() for i in range(n + 1)]
for i in range(n - 1):
a, b = [int(d) for d in input().strip().split()]
conns[a].add(b)
conns[b].add(a)
even = False
odd = False
for i in range(1, n + 1):
if len(conns[i]) > 1:
first = i
break
q = [(first, -1, 0)]
index = 0
w... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR F... |
You have unweighted tree of n vertices. You have to assign a positive weight to each edge so that the following condition would hold:
* For every two different leaves v_{1} and v_{2} of this tree, [bitwise XOR](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of weights of all edges on the simple path between v_... | import sys
input = sys.stdin.readline
n = int(input())
ab = [list(map(int, input().split())) for i in range(n - 1)]
graph = [[] for i in range(n + 1)]
deg = [(0) for i in range(n + 1)]
if n == 3:
print(1, 1)
exit()
for a, b in ab:
graph[a].append(b)
graph[b].append(a)
deg[a] += 1
deg[b] += 1
ro... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXP... |
You have unweighted tree of n vertices. You have to assign a positive weight to each edge so that the following condition would hold:
* For every two different leaves v_{1} and v_{2} of this tree, [bitwise XOR](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of weights of all edges on the simple path between v_... | import sys
def I():
return sys.stdin.readline().rstrip()
n = int(I())
adj = [list() for _ in range(n + 1)]
for e in range(n - 1):
i, j = map(int, I().split())
adj[i].append(j)
adj[j].append(i)
ischild = [None] + [(len(adj[i]) == 1) for i in range(1, n + 1)]
childs = [None] + [sum(ischild[j] for j in... | IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP LIST... |
You have unweighted tree of n vertices. You have to assign a positive weight to each edge so that the following condition would hold:
* For every two different leaves v_{1} and v_{2} of this tree, [bitwise XOR](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of weights of all edges on the simple path between v_... | n = int(input())
u = []
for i in range(n):
u.append([])
for i in range(n - 1):
a, b = map(int, input().split())
u[a - 1].append(b - 1)
u[b - 1].append(a - 1)
for i in range(n):
if len(u[i]) == 1:
st = i
q = [st]
q0 = 0
d = [n + 1] * n
d[st] = 0
ans1 = 1
ans2 = n - 1
while len(q) > q0:
v ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER FOR VAR ... |
You have unweighted tree of n vertices. You have to assign a positive weight to each edge so that the following condition would hold:
* For every two different leaves v_{1} and v_{2} of this tree, [bitwise XOR](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of weights of all edges on the simple path between v_... | import sys
n = int(sys.stdin.readline())
edge = [
list(map(lambda x: int(x) - 1, sys.stdin.readline().split())) for _ in range(n - 1)
]
nbhd = [[] for _ in range(n)]
for e in edge:
nbhd[e[0]].append(e[1])
nbhd[e[1]].append(e[0])
leaf = [(len(nbhd[i]) == 1) for i in range(n)]
level = [None] * n
i = 0
level[... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR LIST VAR FUNC_CALL VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR ... |
You have unweighted tree of n vertices. You have to assign a positive weight to each edge so that the following condition would hold:
* For every two different leaves v_{1} and v_{2} of this tree, [bitwise XOR](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of weights of all edges on the simple path between v_... | def push(g, u, v):
if u not in g:
g[u] = []
if v not in g:
g[v] = []
g[u].append(v)
g[v].append(u)
n = int(input())
g = {}
p = {}
for _ in range(n - 1):
u, v = map(int, input().split())
push(g, u, v)
for u in g:
if len(g[u]) >= 2:
root = u
break
p[root] = 0
... | FUNC_DEF IF VAR VAR ASSIGN VAR VAR LIST IF VAR VAR ASSIGN VAR VAR LIST EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR DICT FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR ... |
You have unweighted tree of n vertices. You have to assign a positive weight to each edge so that the following condition would hold:
* For every two different leaves v_{1} and v_{2} of this tree, [bitwise XOR](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of weights of all edges on the simple path between v_... | import sys
input = sys.stdin.buffer.readline
n = int(input())
neig = [0] * n
lev = [0] * n
for i in range(n):
neig[i] = [0]
lev[i] = [-1]
lev[0][0] = 0
for i in range(n - 1):
a, b = map(int, input().split())
a -= 1
b -= 1
neig[a][0] += 1
neig[b][0] += 1
neig[a].append(b)
neig[b].app... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR LIST NUMBER ASSIGN VAR VAR LIST NUMBER ASSIGN VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_C... |
You have unweighted tree of n vertices. You have to assign a positive weight to each edge so that the following condition would hold:
* For every two different leaves v_{1} and v_{2} of this tree, [bitwise XOR](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of weights of all edges on the simple path between v_... | tree = {}
n = int(input())
for i in range(1, n + 1):
tree[i] = []
for i in range(n - 1):
u, v = [int(x) for x in input().strip().split()]
tree[u].append(v)
tree[v].append(u)
depth = [None for i in range(n + 1)]
def dfs(i):
stack = [(i, 1, -1)]
while len(stack) > 0:
curr, curr_depth, pr... | ASSIGN VAR DICT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NONE VAR FUNC_CALL VAR... |
You have unweighted tree of n vertices. You have to assign a positive weight to each edge so that the following condition would hold:
* For every two different leaves v_{1} and v_{2} of this tree, [bitwise XOR](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of weights of all edges on the simple path between v_... | import sys
input = sys.stdin.readline
N = int(input())
graph = [[] for _ in range(N)]
for _ in range(N - 1):
a, b = map(int, input().split())
graph[a - 1].append(b - 1)
graph[b - 1].append(a - 1)
q = [0]
color = [-1] * N
color[0] = 0
while q:
qq = []
for p in q:
for np in graph[p]:
... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR LIS... |
You have unweighted tree of n vertices. You have to assign a positive weight to each edge so that the following condition would hold:
* For every two different leaves v_{1} and v_{2} of this tree, [bitwise XOR](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of weights of all edges on the simple path between v_... | import sys
input = sys.stdin.readline
n = int(input())
G = [[] for _ in range(n)]
for _ in range(n - 1):
a, b = map(int, input().split())
G[a - 1].append(b - 1)
G[b - 1].append(a - 1)
cur = 0
prev = -1
while len(G[cur]) > 1:
for y in G[cur]:
if y == prev:
continue
prev = cur... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUM... |
Pikachu had an array with him. He wrote down all the non-empty subsequences of the array on paper. Note that an array of size n has 2^{n} - 1 non-empty subsequences in it.
Pikachu being mischievous as he always is, removed all the subsequences in which Maximum_element_of_the_subsequence - Minimum_element_of_subsequ... | x, d = [int(i) for i in input().split()]
gr = []
a = [(2**i - 1) for i in range(31)]
j = 30
while x > 0:
while a[j] > x:
j -= 1
gr.append(j)
x -= a[j]
n = sum(gr)
if n > 10**4:
print(-1)
exit()
print(n)
cur = 1
for i in gr:
for j in range(i):
print(cur, end=" ")
cur += d | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER WHILE VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR BIN_OP NUMBER NUMBER EXPR FUNC_CALL VAR ... |
Pikachu had an array with him. He wrote down all the non-empty subsequences of the array on paper. Note that an array of size n has 2^{n} - 1 non-empty subsequences in it.
Pikachu being mischievous as he always is, removed all the subsequences in which Maximum_element_of_the_subsequence - Minimum_element_of_subsequ... | x, d = map(int, input().split())
start = 1
ans = []
for i in range(61):
if x & 1 << i:
for j in range(i):
ans.append(start)
start += d
ans.append(start)
start += d
print(len(ans))
print(" ".join(map(str, ans))) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CA... |
Pikachu had an array with him. He wrote down all the non-empty subsequences of the array on paper. Note that an array of size n has 2^{n} - 1 non-empty subsequences in it.
Pikachu being mischievous as he always is, removed all the subsequences in which Maximum_element_of_the_subsequence - Minimum_element_of_subsequ... | x, k = list(map(int, input().split()))
tot = 0
now = 1
d = 1
ans = []
def add(am, el):
global ans
ans += [el] * am
def rec(l):
global d
global tot
now = 1
while True:
if tot + (2**now - 1) > x:
if tot - len(ans) != 0:
rec(x - len(ans))
break
... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FUNC_DEF VAR BIN_OP LIST VAR VAR FUNC_DEF ASSIGN VAR NUMBER WHILE NUMBER IF BIN_OP VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR IF BIN_OP VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VA... |
Pikachu had an array with him. He wrote down all the non-empty subsequences of the array on paper. Note that an array of size n has 2^{n} - 1 non-empty subsequences in it.
Pikachu being mischievous as he always is, removed all the subsequences in which Maximum_element_of_the_subsequence - Minimum_element_of_subsequ... | from sys import stdin, stdout
X, d = stdin.readline().strip().split(" ")
X, d = int(X), int(d)
di = {}
ctr = 1
y = 0
ctr1 = 0
while 1 << y <= X:
if 1 << y & X & (1 << y & X) - 1 == 0 and 1 << y & X != 0:
ctr1 += y + 1
di[ctr] = y
ctr += d + 1
di[ctr] = 1
ctr += d + 1
y +... | ASSIGN VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR DICT ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP NUMBER VAR VAR IF BIN_OP BIN_OP BIN_OP NUMBER VAR VAR BIN_OP BIN_OP BIN_OP NUMBER VAR VAR NUMBER NUMBER BIN_OP BIN_OP NUMBER VAR V... |
Pikachu had an array with him. He wrote down all the non-empty subsequences of the array on paper. Note that an array of size n has 2^{n} - 1 non-empty subsequences in it.
Pikachu being mischievous as he always is, removed all the subsequences in which Maximum_element_of_the_subsequence - Minimum_element_of_subsequ... | x, d = map(int, input().split())
n = 1
ans = []
cnt = 0
for i in range(60, 0, -1):
if x >> i & 1:
for j in range(1, i + 1):
ans.append(n)
n += d
cnt += 1
while cnt:
ans.append(n)
n += d
cnt -= 1
if x & 1:
ans.append(n)
print(len(ans))
for i in ans:
print(i, en... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR VAR NUMBER WHILE VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR NU... |
Pikachu had an array with him. He wrote down all the non-empty subsequences of the array on paper. Note that an array of size n has 2^{n} - 1 non-empty subsequences in it.
Pikachu being mischievous as he always is, removed all the subsequences in which Maximum_element_of_the_subsequence - Minimum_element_of_subsequ... | x, d = map(int, input().split())
c = 1
r = "\n"
e = 29
b = 2**e - 1
while x:
while x < b:
e -= 1
b >>= 1
r += f"{c * d} " * e
c += e
x -= b
print(c - 1, r) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER WHILE VAR WHILE VAR VAR VAR NUMBER VAR NUMBER VAR BIN_OP BIN_OP VAR VAR STRING VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR |
Pikachu had an array with him. He wrote down all the non-empty subsequences of the array on paper. Note that an array of size n has 2^{n} - 1 non-empty subsequences in it.
Pikachu being mischievous as he always is, removed all the subsequences in which Maximum_element_of_the_subsequence - Minimum_element_of_subsequ... | x, d = map(int, input().split())
pw = [(2**i - 1) for i in range(31, -1, -1)]
p = [i for i in range(31, -1, -1)]
ans = []
el = 1
i = 0
while x > 0:
while pw[i] > x:
i += 1
for z in range(p[i]):
ans.append(el)
x -= pw[i]
el += d
if x != 0:
print("-1")
else:
print(len(ans))
pri... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER WHILE VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR... |
Pikachu had an array with him. He wrote down all the non-empty subsequences of the array on paper. Note that an array of size n has 2^{n} - 1 non-empty subsequences in it.
Pikachu being mischievous as he always is, removed all the subsequences in which Maximum_element_of_the_subsequence - Minimum_element_of_subsequ... | import sys
input = sys.stdin.buffer.readline
x, d = map(int, input().split())
bit = 0
count = 1
lst = []
total = 1
remind = 0
while x:
count = 0
bit = 0
while bit <= x:
bit = 1 << count
count += 1
bit = bit >> 1
count -= 2
if not lst:
for i in range(count):
l... | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP NUMBER VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR FOR VA... |
Pikachu had an array with him. He wrote down all the non-empty subsequences of the array on paper. Note that an array of size n has 2^{n} - 1 non-empty subsequences in it.
Pikachu being mischievous as he always is, removed all the subsequences in which Maximum_element_of_the_subsequence - Minimum_element_of_subsequ... | x, d = list(map(int, input().split()))
arr = []
n = 0
s = ""
while x > 0:
s += str(x % 2)
x //= 2
f = 1
l = 999999999999999999
for i in range(len(s)):
if int(s[i]):
arr += [f] * i + [l]
f += d
l -= d
n += i + 1
if n == -1:
print(-1)
else:
print(n)
print(*arr) | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR STRING WHILE VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR VAR BIN_OP BIN_OP LIST VAR VAR L... |
Pikachu had an array with him. He wrote down all the non-empty subsequences of the array on paper. Note that an array of size n has 2^{n} - 1 non-empty subsequences in it.
Pikachu being mischievous as he always is, removed all the subsequences in which Maximum_element_of_the_subsequence - Minimum_element_of_subsequ... | x, d = map(int, input().split())
def get_next(x):
if bin(x + 1).count("1") == 1:
return bin(x).count("1")
return len(bin(x)) - 3
a = []
w = 1
while x:
c = get_next(x)
a += c * [w]
w += d + 1
x -= 2**c - 1
print(len(a))
print(*a) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF FUNC_CALL FUNC_CALL VAR BIN_OP VAR NUMBER STRING NUMBER RETURN FUNC_CALL FUNC_CALL VAR VAR STRING RETURN BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR FUNC_CALL VAR VAR VAR BIN_OP VAR LIST VAR VAR... |
Pikachu had an array with him. He wrote down all the non-empty subsequences of the array on paper. Note that an array of size n has 2^{n} - 1 non-empty subsequences in it.
Pikachu being mischievous as he always is, removed all the subsequences in which Maximum_element_of_the_subsequence - Minimum_element_of_subsequ... | X, d = map(int, input().split())
a = list()
cur = 1
for i in range(32):
if X & 1 << i:
for j in range(i):
a.append(cur)
cur = cur + d
a.append(cur)
cur = cur + d
print(len(a))
for i in a:
print(i, end=" ") | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VA... |
Pikachu had an array with him. He wrote down all the non-empty subsequences of the array on paper. Note that an array of size n has 2^{n} - 1 non-empty subsequences in it.
Pikachu being mischievous as he always is, removed all the subsequences in which Maximum_element_of_the_subsequence - Minimum_element_of_subsequ... | x, d = map(int, input().split())
a = []
pot = 2**30
e = 30
last = 0
while x > 0:
while x < pot - 1:
e -= 1
pot //= 2
x -= pot - 1
a += [(last + d) for i in range(e)]
last += d
print(len(a))
print(" ".join(map(str, a))) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER WHILE VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR VAR VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR... |
Pikachu had an array with him. He wrote down all the non-empty subsequences of the array on paper. Note that an array of size n has 2^{n} - 1 non-empty subsequences in it.
Pikachu being mischievous as he always is, removed all the subsequences in which Maximum_element_of_the_subsequence - Minimum_element_of_subsequ... | x, d = map(int, input().split())
ans = []
cur = 1
while x > 0:
k = 1
while 2**k - 1 <= x:
k += 1
k -= 1
for i in range(k):
ans.append(cur)
x -= 2**k - 1
cur += d
print(len(ans))
print(*ans) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP BIN_OP NUMBER VAR NUMBER VAR VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ... |
Pikachu had an array with him. He wrote down all the non-empty subsequences of the array on paper. Note that an array of size n has 2^{n} - 1 non-empty subsequences in it.
Pikachu being mischievous as he always is, removed all the subsequences in which Maximum_element_of_the_subsequence - Minimum_element_of_subsequ... | x, d = [int(i) for i in input().split()]
if x == 1:
print(1)
print(1)
exit()
ind = 0
tmp = 1
counter = 0
ans = []
while x > 0:
t = x & 1
if t == 1:
for j in range(ind):
ans.append(tmp)
counter += 1
tmp += d + 1
x >>= 1
ind += 1
for i in range(counter):
... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR... |
Pikachu had an array with him. He wrote down all the non-empty subsequences of the array on paper. Note that an array of size n has 2^{n} - 1 non-empty subsequences in it.
Pikachu being mischievous as he always is, removed all the subsequences in which Maximum_element_of_the_subsequence - Minimum_element_of_subsequ... | x, d = list(map(int, input().split()))
def dmax(x):
i = 0
while 2**i - 1 <= x:
i += 1
return i - 1
tec = 1
n = 0
step = dmax(x)
stroka = ""
while step != 0:
stroka += (str(tec) + " ") * step
tec += d
x -= 2**step - 1
n += step
step = dmax(x)
print(n)
print(stroka) | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER WHILE BIN_OP BIN_OP NUMBER VAR NUMBER VAR VAR NUMBER RETURN BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING WHILE VAR NUMBER VAR BIN_OP BIN_OP FUNC_CALL VAR VAR STRING V... |
Pikachu had an array with him. He wrote down all the non-empty subsequences of the array on paper. Note that an array of size n has 2^{n} - 1 non-empty subsequences in it.
Pikachu being mischievous as he always is, removed all the subsequences in which Maximum_element_of_the_subsequence - Minimum_element_of_subsequ... | import sys
[X, d] = map(int, sys.stdin.readline().strip().split())
a = []
m = 1 - d
i = 31
while i > 0:
if 2**i - 1 > X:
i -= 1
continue
a.extend([m + d] * i)
m += d
X -= 2**i - 1
print(len(a))
print(" ".join(map(str, a))) | IMPORT ASSIGN LIST VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP BIN_OP NUMBER VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP LIST BIN_OP VAR VAR VAR VAR VAR VAR BIN_OP BIN_OP NUMBER VAR NUMBER EXPR FUNC_CALL VA... |
Pikachu had an array with him. He wrote down all the non-empty subsequences of the array on paper. Note that an array of size n has 2^{n} - 1 non-empty subsequences in it.
Pikachu being mischievous as he always is, removed all the subsequences in which Maximum_element_of_the_subsequence - Minimum_element_of_subsequ... | x, d = map(int, input().split())
l = []
a = 1
while x >= 0:
c = 1
while 2**c - 1 <= x:
c += 1
c -= 1
l = l + [a] * c
a += d
x -= 2**c - 1
if c == 0:
x -= 1
a -= d
if len(l) > 10**4 or l[-1] > 10**18:
exit(print(-1))
print(len(l))
ans = ""
for i in l:
ans += "{} ".form... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP BIN_OP NUMBER VAR NUMBER VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP LIST VAR VAR VAR VAR VAR BIN_OP BIN_OP NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER VAR VAR IF FUNC_CAL... |
Pikachu had an array with him. He wrote down all the non-empty subsequences of the array on paper. Note that an array of size n has 2^{n} - 1 non-empty subsequences in it.
Pikachu being mischievous as he always is, removed all the subsequences in which Maximum_element_of_the_subsequence - Minimum_element_of_subsequ... | p2 = [(i, 2**i - 1) for i in range(1, 40)]
X, d = map(int, input().split(" "))
lens = []
for i in p2[::-1]:
if X >= i[1]:
X -= i[1]
lens.append(i[0])
el = 1
if sum(lens) >= 10000:
print(-1)
exit(0)
print(sum(lens) + X)
for i in lens:
print((str(el) + " ") * i, end="")
el += d
for i i... | ASSIGN VAR VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR VAR NUMBER IF VAR VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FU... |
Pikachu had an array with him. He wrote down all the non-empty subsequences of the array on paper. Note that an array of size n has 2^{n} - 1 non-empty subsequences in it.
Pikachu being mischievous as he always is, removed all the subsequences in which Maximum_element_of_the_subsequence - Minimum_element_of_subsequ... | x, d = map(int, input().split())
result = []
added = 0
while x > 0:
b = "{0:b}".format(x + 1)
result += [1 + added * d] * (len(b) - 1)
x = x - (1 << len(b) - 1) + 1
added += 1
if len(result) > 10000 or result[-1] >= 10**18:
print(-1)
else:
print(len(result))
print(" ".join(map(str, result))) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR FUNC_CALL STRING BIN_OP VAR NUMBER VAR BIN_OP LIST BIN_OP NUMBER BIN_OP VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER VAR NUM... |
Pikachu had an array with him. He wrote down all the non-empty subsequences of the array on paper. Note that an array of size n has 2^{n} - 1 non-empty subsequences in it.
Pikachu being mischievous as he always is, removed all the subsequences in which Maximum_element_of_the_subsequence - Minimum_element_of_subsequ... | p = [1]
def powers_():
global p
for i in range(1, 31):
p.append(p[i - 1] * 2)
for i in range(1, 31):
p[i] = p[i] - 1
powers_()
xn = input().split(" ")
x = int(xn[0])
vc = []
temp = 1
sum = 0
while x != 0:
for i in range(30, 0, -1):
if p[i] <= x:
x = x - int(p[i])
... | ASSIGN VAR LIST NUMBER FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR ... |
Pikachu had an array with him. He wrote down all the non-empty subsequences of the array on paper. Note that an array of size n has 2^{n} - 1 non-empty subsequences in it.
Pikachu being mischievous as he always is, removed all the subsequences in which Maximum_element_of_the_subsequence - Minimum_element_of_subsequ... | ii = lambda: int(input())
kk = lambda: map(int, input().split())
ll = lambda: list(kk())
x, d = kk()
v = 1
s = []
for i in range(35):
if 2**i > x:
break
if 2**i & x:
s.extend([v] * i)
s.append(v + 10**9)
v += 2 * 10**9
print(len(s))
print(*s) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP NUMBER VAR VAR IF BIN_OP BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR BIN_OP LIST VAR VAR E... |
Pikachu had an array with him. He wrote down all the non-empty subsequences of the array on paper. Note that an array of size n has 2^{n} - 1 non-empty subsequences in it.
Pikachu being mischievous as he always is, removed all the subsequences in which Maximum_element_of_the_subsequence - Minimum_element_of_subsequ... | x, d = map(int, input().split())
r = []
e = 29
b = 2**e - 1
while x:
while x < b:
e -= 1
b >>= 1
r += [str((len(r) + 1) * d)] * e
x -= b
print(len(r))
print(" ".join(r)) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER WHILE VAR WHILE VAR VAR VAR NUMBER VAR NUMBER VAR BIN_OP LIST FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR... |
Pikachu had an array with him. He wrote down all the non-empty subsequences of the array on paper. Note that an array of size n has 2^{n} - 1 non-empty subsequences in it.
Pikachu being mischievous as he always is, removed all the subsequences in which Maximum_element_of_the_subsequence - Minimum_element_of_subsequ... | def m2(n):
r = 1
d = 0
while (r << 1) - 1 <= n:
r <<= 1
d += 1
return r - 1, d
x, d = [int(x) for x in input().split()]
le = 0
ost = x
nums = []
kols = []
inf = 10**18
last_num = 1 - d
while ost != 0:
n, deg = m2(ost)
ost -= n
le += deg
last_num += d
nums.append(las... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP BIN_OP VAR NUMBER NUMBER VAR VAR NUMBER VAR NUMBER RETURN BIN_OP VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER... |
Pikachu had an array with him. He wrote down all the non-empty subsequences of the array on paper. Note that an array of size n has 2^{n} - 1 non-empty subsequences in it.
Pikachu being mischievous as he always is, removed all the subsequences in which Maximum_element_of_the_subsequence - Minimum_element_of_subsequ... | from sys import stdin, stdout
x, d = map(int, stdin.readline().split())
psze = 100
cur = 1
ans = []
while x:
for z in range(1, psze):
v = (1 << z) - 1
if v > x:
i = z - 1
x = x - (1 << i) + 1
break
for j in range(i):
ans.append(cur)
cur += d
stdou... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR ... |
Pikachu had an array with him. He wrote down all the non-empty subsequences of the array on paper. Note that an array of size n has 2^{n} - 1 non-empty subsequences in it.
Pikachu being mischievous as he always is, removed all the subsequences in which Maximum_element_of_the_subsequence - Minimum_element_of_subsequ... | s = [(2**i - 1) for i in range(31, 0, -1)]
z = [i for i in range(31, 0, -1)]
x, d = map(int, input().split())
st = 1
p = 0
ret = []
while x > 0:
while s[p] > x:
p += 1
for i in range(z[p]):
ret.append(st)
st += d
x -= s[p]
if x != 0:
print("-1")
else:
print(len(ret))
print(" ... | ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR NUMBER WHILE VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR... |
Pikachu had an array with him. He wrote down all the non-empty subsequences of the array on paper. Note that an array of size n has 2^{n} - 1 non-empty subsequences in it.
Pikachu being mischievous as he always is, removed all the subsequences in which Maximum_element_of_the_subsequence - Minimum_element_of_subsequ... | x, d = [int(i) for i in input().split()]
cr = 1
ans = []
while x:
i = 0
while (1 << i) - 1 <= x:
i += 1
for j in range(i - 1):
ans.append(cr)
x -= (1 << i - 1) - 1
cr += d
print(len(ans))
print(*ans) | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR ASSIGN VAR NUMBER WHILE BIN_OP BIN_OP NUMBER VAR NUMBER VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER VAR VAR EXPR FUNC_CALL VAR FUNC... |
Pikachu had an array with him. He wrote down all the non-empty subsequences of the array on paper. Note that an array of size n has 2^{n} - 1 non-empty subsequences in it.
Pikachu being mischievous as he always is, removed all the subsequences in which Maximum_element_of_the_subsequence - Minimum_element_of_subsequ... | n, d = [int(c) for c in input().split(" ")]
n_copy = n
groupsize_cases = [(2**c - 1) for c in range(100)]
groups = []
i = 1
while n >= groupsize_cases[i]:
i += 1
i -= 1
while n > 0:
while n >= groupsize_cases[i]:
groups.append(i)
n -= groupsize_cases[i]
i -= 1
ans = []
current_number = 1
for... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR NUMBER VAR NUMBER WHILE VAR NUMBER WHILE VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR LIS... |
Pikachu had an array with him. He wrote down all the non-empty subsequences of the array on paper. Note that an array of size n has 2^{n} - 1 non-empty subsequences in it.
Pikachu being mischievous as he always is, removed all the subsequences in which Maximum_element_of_the_subsequence - Minimum_element_of_subsequ... | x, d = map(int, input().split())
A = []
a = 1
k = 0
while a < x:
a *= 2
a //= 2
x = bin(x)[2:][::-1]
y = 1
for i in range(len(x) - 1, -1, -1):
if x[i] == "1":
A += i * [y]
k += 1
y += d + 1
while k:
A.append(y)
y += d + 1
k -= 1
print(len(A))
for i in A:
print(i, end=" ") | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF VAR VAR STRING VAR BIN_OP VAR LIST VAR VAR ... |
Pikachu had an array with him. He wrote down all the non-empty subsequences of the array on paper. Note that an array of size n has 2^{n} - 1 non-empty subsequences in it.
Pikachu being mischievous as he always is, removed all the subsequences in which Maximum_element_of_the_subsequence - Minimum_element_of_subsequ... | import itertools
def subsequence_counter(x, d):
ans = []
new = "{0:b}".format(x)
counter = 1
for i in range(len(new)):
if new[i] == "1":
ans.extend(list(itertools.repeat(counter, len(new) - i - 1)))
ans.append(d + counter + 1)
if new[i] == "0":
conti... | IMPORT FUNC_DEF ASSIGN VAR LIST ASSIGN VAR FUNC_CALL STRING VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR STRING VAR BIN_OP BIN_OP BI... |
Pikachu had an array with him. He wrote down all the non-empty subsequences of the array on paper. Note that an array of size n has 2^{n} - 1 non-empty subsequences in it.
Pikachu being mischievous as he always is, removed all the subsequences in which Maximum_element_of_the_subsequence - Minimum_element_of_subsequ... | x, d = map(int, input().split())
s = str(bin(x))[2:]
wqa = 1
ans = []
koms = 0
for i in range(len(s)):
if s[i] == "1":
for idq in range(len(s) - i - 1):
ans.append(wqa)
koms += 1
wqa += d + 1
for ii in range(koms):
ans.append(wqa)
wqa += d
print(len(ans))
print(*ans) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING FOR VAR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER VAR ... |
Pikachu had an array with him. He wrote down all the non-empty subsequences of the array on paper. Note that an array of size n has 2^{n} - 1 non-empty subsequences in it.
Pikachu being mischievous as he always is, removed all the subsequences in which Maximum_element_of_the_subsequence - Minimum_element_of_subsequ... | X, d = map(int, input().split())
x = X
ans = list()
ln = 0
last = 1
while x > 0:
if last >= 10**18:
print(-1)
exit()
i = 0
while 2 ** (i + 1) - 1 <= x:
i += 1
t = 2**i - 1
x -= t
if ln + i > 10000:
print(-1)
exit()
for _ in range(i):
ans.append... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER IF VAR BIN_OP NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER VAR VAR NUMBER ASSIGN VAR B... |
Pikachu had an array with him. He wrote down all the non-empty subsequences of the array on paper. Note that an array of size n has 2^{n} - 1 non-empty subsequences in it.
Pikachu being mischievous as he always is, removed all the subsequences in which Maximum_element_of_the_subsequence - Minimum_element_of_subsequ... | x, d = [int(s) for s in input().split()[:2]]
def getd(y):
if y <= 1:
return y
da = 1
num = 0
while da * 2 <= y:
da *= 2
num += 1
return num
f = 1
ans = []
while x > 0:
num = getd(x)
n = 2**num - 1
for i in range(num):
ans.append(f)
f += d + 1
x... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER FUNC_DEF IF VAR NUMBER RETURN VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR NUMBER VAR VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBE... |
Pikachu had an array with him. He wrote down all the non-empty subsequences of the array on paper. Note that an array of size n has 2^{n} - 1 non-empty subsequences in it.
Pikachu being mischievous as he always is, removed all the subsequences in which Maximum_element_of_the_subsequence - Minimum_element_of_subsequ... | X, D = map(int, input().split())
cn = 1
add0 = 1 if X & 1 else 0
ans = []
for i in range(30, 0, -1):
if not X & 1 << i:
continue
ans += [cn] * i
add0 += 1
cn += D
for i in range(add0):
ans.append(cn)
cn += D
print(len(ans))
print(" ".join(map(str, ans))) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF BIN_OP VAR BIN_OP NUMBER VAR VAR BIN_OP LIST VAR VAR VAR NUMBER VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_C... |
Jamie is preparing a Codeforces round. He has got an idea for a problem, but does not know how to solve it. Help him write a solution to the following problem:
Find k integers such that the sum of two to the power of each number equals to the number n and the largest integer in the answer is as small as possible. As t... | n, k = map(int, input().split())
a = list(bin(n))
a = a[2:]
b = []
for i in range(100005):
b.append(0)
l = len(a)
c = 0
for i in range(l):
if a[i] == "1":
b[65 - (l - i - 1)] = 1
c += 1
lini = 65 - (l - i - 1)
if c <= k:
gfati = 0
for i in range(129):
if gfati == 1:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR BIN_OP NUMBER BIN_OP BIN_... |
Jamie is preparing a Codeforces round. He has got an idea for a problem, but does not know how to solve it. Help him write a solution to the following problem:
Find k integers such that the sum of two to the power of each number equals to the number n and the largest integer in the answer is as small as possible. As t... | n, k = map(int, input().split())
bits = [(0) for i in range(128)]
tmp = n
sumBits = 0
for i in range(64):
if tmp % 2 == 1:
bits[63 - i] = 1
sumBits += 1
tmp = tmp >> 1
if sumBits > k:
print("No")
elif sumBits == k:
print("Yes")
res = []
for i in range(63, -1, -1):
if bits... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR STRING IF VAR VAR EXPR F... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.