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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = map(int, input().split())
if n < k:
print("NO")
elif bin(n).count("1") > k:
print("NO")
else:
print("YES")
ans = []
t1 = 0
while n:
b = n & -n
if b == 1:
t1 += 1
else:
ans.append(b)
n -= b
while len(ans) + t1 < k:
p = ans.pop()
if p == 2:
t1 += 2
else:
ans.append(p // 2)
ans.append(p // 2)
print(*([1] * t1 + sorted(ans))) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR STRING IF FUNC_CALL FUNC_CALL VAR VAR STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR WHILE BIN_OP FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP LIST NUMBER VAR FUNC_CALL 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = tuple(map(int, input().split()))
b = bin(n)[2:]
count = 0
d = dict()
for i in range(1, len(b) + 1):
if b[-i] == "1":
d[i - 1] = 1
count += 1
for i in range(max(d.keys()) - 1, -1, -1):
if i not in d.keys():
d[i] = 0
if k > n or k < count:
print("NO")
else:
print("YES")
for i in range(k - count):
max_key = max(d.keys())
d[max_key] = d[max_key] - 1
d[max_key - 1] = d[max_key - 1] + 2
if d[max_key] == 0:
d.pop(max_key)
A = list(d.items())
for item in A:
for i in range(item[1]):
print(2 ** item[0], end=" ") | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER IF VAR VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER NUMBER IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR VAR FOR VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER VAR NUMBER 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = tuple(map(int, input().split()))
pow2 = []
m = n
p = 1
while m > 0:
if m % 2 == 1:
pow2.append(p)
m >>= 1
p *= 2
if n < k or len(pow2) > k:
print("NO")
else:
print("YES")
i = 0 if pow2[0] > 1 else 1
while len(pow2) < k:
pow2[i] //= 2
pow2.insert(i, pow2[i])
if pow2[i] == 1:
i += 2
print(" ".join([str(a) for a in pow2])) | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER VAR NUMBER IF VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER NUMBER NUMBER NUMBER WHILE FUNC_CALL VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR IF VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = map(int, input().split())
a = []
p = 0
c = 0
while n > 1:
if n % 2 == 1:
a.append(2**p)
c += 1
p += 1
n = n // 2
if n % 2 == 1:
a.append(2**p)
c += 1
flag = True
if c > k:
flag = False
l = c
ans = []
while c < k and l > 0:
q = a.pop()
l -= 1
if q == 1:
ans.append(q)
if q // 2 >= 1:
a.append(q // 2)
a.append(q // 2)
c += 1
l += 2
if c < k or flag == False:
print("NO")
else:
print("YES")
for i in ans:
print(i, end=" ")
a.sort()
for i in a:
print(i, end=" ")
print("") | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR LIST WHILE VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = map(int, input().split())
tot = k
array = [1] * k
flag = False
if n < k:
print("NO")
elif n == k:
print("YES")
print(*([1] * k))
else:
for i in range(k - 1, -1, -1):
while tot + array[i] <= n:
tot += array[i]
array[i] *= 2
if tot == n:
flag = True
break
if flag:
print("YES")
print(*array)
else:
print("NO") | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR STRING IF VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER WHILE BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER IF VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | [n, k] = list(map(int, input().split(" ")))
n_ = n
ans = []
index = 1
while n != 0:
if n % 2 == 1:
ans.append(index)
index *= 2
n //= 2
if len(ans) <= k and n_ >= k:
num_1 = 0
k_ = len(ans)
while k_ != k:
if ans[-1] == 1:
num_1 += 1
ans = ans[:-1]
continue
last = ans[-1]
ans = ans[:-1]
ans.append(last // 2)
ans.append(last // 2)
k_ += 1
for _ in range(num_1):
ans.append(1)
print("YES")
print(" ".join(map(str, ans)))
else:
print("NO") | ASSIGN LIST VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR ASSIGN VAR LIST 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 VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR VAR IF VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = map(int, input().split())
u = list(bin(n))[2:]
u = list(map(int, u))
s = sum(u)
if s > k or k > n:
print("NO")
else:
k -= s
while k > 0:
for i in range(len(u) - 1):
if u[i] > 0:
u[i] -= 1
u[i + 1] += 2
k -= 1
break
print("YES")
ans = []
for i in range(len(u)):
for _ in range(u[i]):
ans.append(2 ** (len(u) - i - 1))
print(*ans[::-1]) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR STRING VAR VAR WHILE VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR NUMBER VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP NUMBER BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = map(int, input().split())
a = []
p = n
while n > 0:
a.append(n % 2)
n //= 2
i = len(a) - 1
if sum(a) <= k <= p:
while sum(a) < k:
if a[i] == 0:
i -= 1
else:
a[i - 1] += 2
a[i] -= 1
print("YES")
for i in range(len(a)):
print((str(2**i) + " ") * a[i], end="")
else:
print("NO") | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR VAR WHILE VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR WHILE FUNC_CALL VAR VAR VAR IF VAR VAR NUMBER VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR BIN_OP NUMBER VAR STRING VAR VAR STRING 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | ran = input()
ran = ran.split()
n = int(ran[0])
k = int(ran[1])
bin = format(n, "b")
binary = [int(i) for i in bin]
if k > n:
print("NO")
elif sum(binary) > k:
print("NO")
else:
print("YES")
l = [(2**i) for i in range(0, len(binary)) if binary[len(binary) - i - 1] == 1]
dl = len(l)
cur_ind = 0
while dl < k:
if l[cur_ind] > 1:
l[cur_ind] = l[cur_ind] / 2
l.append(l[cur_ind])
dl = len(l)
else:
cur_ind += 1
l = [str(int(i)) for i in l]
print(" ".join(l)) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR STRING IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP NUMBER VAR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = map(int, input().split())
s = n - k
c = []
for i in range(1, 35):
c.append(pow(2, i) - 1)
c.reverse()
l = []
def supress(c, k):
l = []
s = 0
while k > 0:
if k >= c[s]:
k -= c[s]
l.append(c[s])
else:
s += 1
return l
l = supress(c, s)
if len(l) > k or s < 0:
print("NO")
else:
a = [1] * k
for i in range(len(l)):
a[i] += l[i]
print("YES")
print(*a) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR LIST FUNC_DEF ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR NUMBER IF VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF FUNC_CALL VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = map(int, input().split())
L = []
L2 = []
i = 1
n2 = n
while i <= n:
L2.append(i)
i *= 2
while n != 0:
x = L2[len(L2) - 1]
while x <= n:
n -= x
L.append(x)
L2 = L2[: len(L2) - 1]
if len(L) > k or n2 < k:
print("NO")
else:
Ljedan = []
L2 = L[:]
while len(L2) + len(Ljedan) != k:
x = L2[len(L2) - 1]
if x % 2 == 0:
L2.pop()
L2 = L2 + [x // 2, x // 2]
else:
L2.pop()
Ljedan.append(1)
L2.sort()
L2 = Ljedan + L2
print("YES")
for i in range(k):
print(L2[i], end=" ") | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER WHILE VAR NUMBER ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR VAR WHILE BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR LIST BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = map(int, input().strip().split())
a = []
newN = n
while newN:
a.append(newN % 2)
newN = newN // 2
index = []
count = [0] * len(a)
for i in range(len(a)):
if a[i] == 1:
index.append(i)
count[i] += 1
m = len(index)
ans = []
if m > k or n < k:
print("NO")
else:
print("YES")
if m == k:
for i in range(m):
ans.append(2 ** index[i])
if m < k:
i = len(a) - 1
cnt = sum(count)
while sum(count) < k:
if i == 0:
i = len(a) - 1
while count[i] > 0:
tmp = 2 ** (i - 1)
count[i] -= 1
count[i - 1] += 2
cnt += 1
if k == sum(count):
break
i -= 1
for i in range(len(count)):
if count[i]:
ans.extend([2**i] * count[i])
print(" ".join(map(str, ans))) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR VAR WHILE VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST IF VAR VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING IF VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP NUMBER VAR VAR IF VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE FUNC_CALL VAR VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR VAR NUMBER ASSIGN VAR BIN_OP NUMBER BIN_OP VAR NUMBER VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER IF VAR FUNC_CALL VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP LIST BIN_OP NUMBER VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = map(int, input().split())
a = [1] * k
n -= k
i = 0
while i < k and n > 0:
while a[i] <= n:
n -= a[i]
a[i] *= 2
i += 1
if n != 0:
print("NO")
else:
print("YES")
for i in range(k):
print(a[i], end=" ") | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER WHILE VAR VAR VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | def findYes(arr, m, k, ans):
ans_string = ""
print("YES")
if ans == k:
for i in range(m):
if arr[i] == 1:
seq = pow(2, i)
ans_string += str(seq) + " "
else:
p = m - 1
while ans != k:
while arr[p] >= 1:
arr[p] -= 1
arr[p - 1] += 2
ans += 1
if ans == k:
break
p -= 1
i = m - 1
while i >= 0:
if arr[i] >= 1:
for j in range(arr[i]):
seq2 = pow(2, i)
ans_string += str(seq2) + " "
i -= 1
return ans_string
values = input()
n, k = values.split()
n = int(n)
k = int(k)
ans = 0
arr = [0] * 1000
m = 0
temp_n = n
while temp_n:
arr[m] = temp_n % 2
temp_n //= 2
m += 1
i = m - 1
while i >= 0:
if arr[i] == 1:
ans += 1
i -= 1
if k > n or k < ans:
print("NO")
else:
ans_string = findYes(arr, m, k, ans)
print(ans_string) | FUNC_DEF ASSIGN VAR STRING EXPR FUNC_CALL VAR STRING IF VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER VAR VAR BIN_OP FUNC_CALL VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR WHILE VAR VAR NUMBER VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER IF VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER VAR VAR BIN_OP FUNC_CALL VAR VAR STRING VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR ASSIGN VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER IF VAR VAR NUMBER VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = [int(x) for x in input().split()]
def reversebinary(n):
L = []
while n != 0:
L.append(n % 2)
n = n // 2
return L
def split(exp, pieces):
if pieces == 1:
return [exp]
else:
return split(exp - 1, pieces // 2) + split(exp - 1, pieces - pieces // 2)
R = reversebinary(n)
low = sum(R)
if k <= n and k >= low:
print("YES")
digits = []
for i in range(0, len(R)):
if R[i] == 1:
digits.append(i)
s = 0
c = 0
while s - c < k - low:
s += 2 ** digits[c]
c += 1
if c > 0:
c -= 1
if s - c == k - low:
print("1 " * (k - low), end="")
for j in range(c, len(digits)):
print(2 ** digits[j], end=" ")
else:
s -= 2 ** digits[c]
remaining = k - low - s + c
print("1 " * s, end="")
for el in split(digits[c], remaining + 1):
print(2**el, end=" ")
if c + 1 <= len(digits):
for j in range(c + 1, len(digits)):
print(2 ** digits[j], end=" ")
else:
print("NO") | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR LIST WHILE VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR FUNC_DEF IF VAR NUMBER RETURN LIST VAR RETURN BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR BIN_OP VAR VAR VAR BIN_OP NUMBER VAR VAR VAR NUMBER IF VAR NUMBER VAR NUMBER IF BIN_OP VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING BIN_OP VAR VAR STRING FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP NUMBER VAR VAR STRING VAR BIN_OP NUMBER VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR STRING FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER VAR STRING IF BIN_OP VAR NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP NUMBER VAR VAR STRING 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = list(map(int, input().strip().split()))
l = []
p = 0
nn = n
length = 0
while n:
if n % 2 == 1:
l.append(2**p)
p += 1
n = n // 2
if len(l) <= k <= nn:
print("YES")
i = 0
while 1:
if len(l) + length == k:
print(" ".join(map(str, l)))
break
if l[0] != 1:
toappendat0 = l.pop(0) // 2
l = [toappendat0] * 2 + l
else:
length += 1
print(l.pop(0), end=" ")
else:
print("NO") | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER WHILE NUMBER IF BIN_OP FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR IF VAR NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP LIST VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER STRING 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | a, b = map(int, input().split())
l = [int(1) for i in range(b)]
sum = b
for i in range(b):
while sum + l[i] <= a:
sum += l[i]
l[i] *= 2
if sum == a:
print("YES")
for i in l:
print(i, end=" ")
else:
print("NO") | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR 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 EXPR FUNC_CALL VAR STRING FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | def decimalToBinary(n):
bits = []
bits.append(0 if n % 2 == 0 else 1)
while n > 1:
n = n // 2
bits.append(0 if n % 2 == 0 else 1)
return bits
n, k = map(int, input().split())
bits = decimalToBinary(n)
i = 0
arr = []
for r in bits:
if r == 1:
arr.append(pow(2, i))
i += 1
cnt = len(arr)
if cnt > k:
print("NO")
else:
ones = []
while cnt < k and len(arr) > 0:
z = arr[0]
del arr[0]
if z > 1:
half = z // 2
arr.append(half)
arr.append(half)
cnt += 1
else:
ones.append(1)
if cnt < k:
print("NO")
else:
print("YES")
for o in ones:
arr.append(o)
arr.sort()
for i in arr:
print(i, end=" ") | FUNC_DEF ASSIGN VAR LIST EXPR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER NUMBER RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR LIST WHILE VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING FOR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FOR VAR VAR EXPR FUNC_CALL VAR 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = map(int, input().split())
if k > n:
print("NO")
else:
a = bin(n)
a = a[2:]
b = [(0) for i in range(31)]
for i in range(len(a)):
if a[i] == "1":
b[len(a) - 1 - i] = 1
if b.count(1) <= k:
print("YES")
for i in range(31):
if sum(b) == k:
break
while b[31 - 1 - i] > 0 and sum(b) < k:
b[31 - 1 - i] -= 1
b[31 - i - 2] += 2
i += 1
c = []
for i in range(31):
for j in range(b[i]):
c.append(2**i)
print(*c)
else:
print("NO") | 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 ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER VAR NUMBER IF FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR VAR VAR WHILE VAR BIN_OP BIN_OP NUMBER NUMBER VAR NUMBER FUNC_CALL VAR VAR VAR VAR BIN_OP BIN_OP NUMBER NUMBER VAR NUMBER VAR BIN_OP BIN_OP NUMBER VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP NUMBER VAR EXPR FUNC_CALL 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = map(int, input().split())
li = {}
tmpn = n
beki = 2**31
s = 0
while beki > 0:
if tmpn >= beki:
li[beki] = 1
tmpn -= beki
s += 1
else:
li[beki] = 0
beki //= 2
if s > k or n < k:
print("NO")
quit()
beki = 2**31
while s != k:
if li[beki] == 0:
beki //= 2
else:
li[beki] -= 1
li[beki // 2] += 2
s += 1
print("YES")
ans = []
for i in li:
for j in range(li[i]):
ans.append(i)
print(" ".join(map(str, ans))) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER IF VAR VAR ASSIGN VAR VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER WHILE VAR VAR IF VAR VAR NUMBER VAR NUMBER VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR VAR FOR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | ni, k = map(int, input().split(" "))
n = ni
a = 0
cont = 0
vetor = [0] * 35
while n:
vetor[cont] = n % 2
if vetor[cont]:
a += 1
n //= 2
cont += 1
if ni < k or k < a:
print("NO")
exit()
else:
while cont > 0 and a < k:
while vetor[cont] and a < k:
vetor[cont] -= 1
vetor[cont - 1] += 2
a += 1
cont -= 1
if a > k:
print("NO")
exit()
else:
print("YES")
b = 1
for i in range(32):
while vetor[i]:
print(b, end=" ")
vetor[i] -= 1
b = b * 2 | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER WHILE VAR ASSIGN VAR VAR BIN_OP VAR NUMBER IF VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR WHILE VAR NUMBER VAR VAR WHILE VAR VAR VAR VAR VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER WHILE VAR VAR EXPR FUNC_CALL VAR VAR STRING VAR VAR NUMBER ASSIGN VAR BIN_OP 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | import sys
n, k = [int(s) for s in input().split()]
copy_n = n
counter = 1
while 2**counter < n:
counter += 1
if 2**counter != n:
counter -= 1
n -= 2**counter
array = [0] * (counter + 1)
array[counter] = 1
for i in range(len(array) - 1, -1, -1):
if n >= 2**i:
array[i] += 1
n -= 2**i
if sum(array) > k or copy_n // k == 0:
print("NO")
sys.exit(0)
print("YES")
diff = k - sum(array)
while diff != 0:
array[counter - 1] += 2
array[counter] -= 1
if array[counter] == 0:
counter -= 1
diff -= 1
answer = []
for i in range(len(array)):
for j in range(array[i]):
answer.append(str(2**i))
print(" ".join(answer)) | IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE BIN_OP NUMBER VAR VAR VAR NUMBER IF BIN_OP NUMBER VAR VAR VAR NUMBER VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF VAR BIN_OP NUMBER VAR VAR VAR NUMBER VAR BIN_OP NUMBER VAR IF FUNC_CALL VAR VAR VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR WHILE VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR VAR NUMBER IF VAR VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL STRING 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | def read(type=1):
if type:
file = open("input.dat", "r")
line = list(map(int, file.readline().split()))
file.close()
else:
line = list(map(int, input().strip().split()))
return line[0], line[1]
def solve(n, k):
sol = []
m = n
p = 1
while p <= n:
p *= 2
p //= 2
a = []
while n:
if p <= n:
n -= p
a.append(p)
p //= 2
a.sort()
if k < len(a) or k > m:
return sol
b = [m]
for v in a:
if len(b):
b.append(b[-1] - v)
else:
b.append(m - v)
tot = 0
step = 0
while k:
if b[step + 1] < k:
v = a[step]
vk = k - b[step + 1]
while v:
p = 1
while p <= vk:
p *= 2
p //= 2
bit = v // 2 // p
if vk == p:
if bit:
bit *= 2
else:
bit = 1
for i in range(p):
sol.append(bit)
v -= bit
k -= 1
vk -= 1
step += 1
else:
sol.append(a[step])
step += 1
k -= 1
sol.sort()
return sol
def write(sol):
line = ""
for v in sol:
line += str(v) + " "
print(line)
n, k = read(0)
sol = solve(n, k)
if len(sol):
print("YES")
write(sol)
else:
print("NO") | FUNC_DEF NUMBER IF VAR ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR RETURN VAR NUMBER VAR NUMBER FUNC_DEF ASSIGN VAR LIST ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR LIST WHILE VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR IF VAR FUNC_CALL VAR VAR VAR VAR RETURN VAR ASSIGN VAR LIST VAR FOR VAR VAR IF FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR IF VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR BIN_OP VAR NUMBER WHILE VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR IF VAR VAR IF VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR RETURN VAR FUNC_DEF ASSIGN VAR STRING FOR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR IF FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = tuple(map(int, input().split(" ")))
ans = "YES"
bits = bin(n)[2:]
n_bits = bits.count("1")
if k > n or k < n_bits:
ans = "NO"
power = []
[power.append(int(bits[i]) * 2 ** (len(bits) - i - 1)) for i in range(len(bits))]
power.reverse()
reqd = k - n_bits
ans_bits = []
if ans == "YES":
while reqd > 0 or len(power) > 0:
if power[len(power) - 1] == 1 or reqd == 0:
ans_bits.append(power.pop())
else:
val = power.pop()
if val != 0:
power.append(val // 2)
power.append(val // 2)
reqd -= 1
print(ans)
for i in ans_bits:
if i != 0:
print(i, end=" ")
else:
print(ans) | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF VAR VAR VAR VAR ASSIGN VAR STRING ASSIGN VAR LIST EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR BIN_OP NUMBER BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR LIST IF VAR STRING WHILE VAR NUMBER FUNC_CALL VAR VAR NUMBER IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | ina = input().split()
n = int(ina[0])
k = int(ina[1])
n1 = n
ans = 0
c = []
s = 1
while n > 0:
if n & 1:
ans += 1
c.append(s)
s *= 2
n = n >> 1
if ans <= k and k <= n1:
print("YES")
t = 0
while len(c) < k:
if c[t] > 1:
c.append(c[t] // 2)
c[t] = c[t] // 2
else:
t += 1
for i in c:
print(i, end=" ")
else:
print("NO") | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR VAR NUMBER VAR NUMBER FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | def bits(n):
arr = []
i = 0
while n > 0:
a = n & 1
if a == 1:
arr.append(2**i)
i += 1
n = n >> 1
return arr
def check(n, k):
if k > n:
print("NO")
return
arr = bits(n)
i = 0
while i <= len(arr):
if len(arr) == k:
print("YES")
for i in arr:
print(i, end=" ")
break
elif len(arr) > k:
print("NO")
break
if arr[i] == 1:
i += 1
else:
x = arr[i]
arr[i] = arr[i] // 2
x = x // 2
arr.append(x)
n, k = [int(x) for x in input().split()]
check(n, k) | FUNC_DEF ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR FUNC_DEF IF VAR VAR EXPR FUNC_CALL VAR STRING RETURN ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING IF VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = map(int, input().split())
c = 0
s = dict()
ans = []
r = n
f = 0
while n > 0:
c += 1
if n % 2 == 1:
f += 1
s.update({(2 ** (c - 1)): 1})
n //= 2
n = r
if k > n:
print("NO")
elif k < f:
print("NO")
else:
print("YES")
r = k - f
while r > 0:
for j in s:
if j != 1:
if j // 2 not in s:
s.update({(j // 2): 2})
else:
s[j // 2] += 2
s[j] -= 1
if s[j] == 0:
del s[j]
r -= 1
break
for j in s:
for k in range(s[j]):
ans.append(j)
print(*ans, sep=" ") | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR DICT BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR VAR IF VAR VAR EXPR FUNC_CALL VAR STRING IF VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR VAR WHILE VAR NUMBER FOR VAR VAR IF VAR NUMBER IF BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR DICT BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR VAR NUMBER IF VAR VAR NUMBER VAR VAR VAR NUMBER FOR VAR VAR FOR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = map(int, input().split())
b = list(bin(n)[2:])
c1 = b.count("1")
l = len(b)
if k < c1 or k > n:
print("NO")
else:
print("YES")
d = k - c1
powers = []
newp = []
for i in range(l - 1, -1, -1):
if b[i] == "1":
powers.append(2 ** int(l - 1 - i))
while d > 0:
p = powers.pop()
if p == 1:
newp.append(p)
else:
powers.append(p >> 1)
powers.append(p >> 1)
d -= 1
powers.extend(newp)
powers.sort()
print(" ".join(map(str, powers))) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR STRING EXPR FUNC_CALL VAR BIN_OP NUMBER FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL STRING 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = map(int, input().split())
if bin(n).count("1") > k or n < k:
print("NO")
else:
a = []
s = bin(n)[2:]
s = s[::-1]
for i in range(len(s)):
if s[i] == "1":
a.append(2**i)
a.sort()
while len(a) < k and a[-1] != 1:
x = a.pop()
b = [x // 2, x // 2]
while len(a) > 0 and a[-1] == x and len(a) + len(b) < k and a[-1] != 1:
a.pop()
b += [x // 2, x // 2]
a += b
if len(a) == k:
print("YES")
print(*a)
else:
print("NO") | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL FUNC_CALL VAR VAR STRING VAR VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR WHILE FUNC_CALL VAR VAR VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST BIN_OP VAR NUMBER BIN_OP VAR NUMBER WHILE FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR LIST BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | import sys
def input():
return sys.stdin.readline().rstrip("\r\n")
def List():
return list(map(int, input().split()))
def Num():
return int(input())
def solve():
n, k = List()
tot, i = k, k - 1
a = [(1) for i in range(k)]
while i >= 0:
while tot + a[i] <= n:
tot += a[i]
a[i] *= 2
i -= 1
if tot == n:
print("YES")
print(*a)
else:
print("NO")
solve() | IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR WHILE VAR NUMBER WHILE BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | l = list()
n, k = tuple(map(int, input().split()))
num = n
ones = 0
while num > 0:
if num % 2 == 1:
l.append(1)
ones += 1
else:
l.append(0)
num //= 2
if k > n or k < ones:
print("NO")
else:
print("YES")
m = len(l) - 1
while ones < k:
if k - ones > l[m]:
l[m - 1] += 2 * l[m]
ones += l[m]
l[m] = 0
else:
l[m - 1] += 2 * (k - ones)
l[m] -= k - ones
ones = k
m -= 1
num = 1
i = 0
while i < len(l):
for j in range(l[i]):
print(num, end=" ")
num *= 2
i += 1 | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR VAR IF BIN_OP VAR VAR VAR VAR VAR BIN_OP VAR NUMBER BIN_OP NUMBER VAR VAR VAR VAR VAR ASSIGN VAR VAR NUMBER VAR BIN_OP VAR NUMBER BIN_OP NUMBER BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR STRING VAR NUMBER 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = map(int, input().split())
arr = [(1) for i in range(k)]
s = k
ptr = k - 1
while ptr > -1:
while s + arr[ptr] <= n:
s += arr[ptr]
arr[ptr] *= 2
ptr -= 1
if s != n:
print("NO")
else:
print("YES")
print(*arr) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR 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 IF VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | mod = 1000000007
ii = lambda: int(input())
si = lambda: input()
dgl = lambda: list(map(int, input()))
f = lambda: map(int, input().split())
il = lambda: list(map(int, input().split()))
it = lambda: tuple(map(int, input().split()))
ls = lambda: list(input())
n, k = f()
m = n
l = []
x = 1
while x < 10**9:
l.append(x)
x = x << 1
res = []
l.reverse()
for i in l:
while k > 0 and n - i >= k - 1:
res.append(i)
n -= i
k -= 1
if sum(res) != m:
print("NO")
else:
print("YES")
print(*res) | ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR BIN_OP NUMBER NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR LIST EXPR FUNC_CALL VAR FOR VAR VAR WHILE VAR NUMBER BIN_OP VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = map(int, input().split())
if k > n or k < bin(n)[2:].count("1"):
print("NO")
else:
print("YES")
a = bin(n)[2:][::-1]
ind = 0
powers = []
for char in a:
if char == "1":
powers.append(2**ind)
ind += 1
ind = 0
tot = len(powers)
while tot < k:
if powers[ind] > 1:
powers[ind] //= 2
powers.append(powers[ind])
tot += 1
else:
ind += 1
out = ""
for guy in powers:
out += str(guy) + " "
print(out) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR IF VAR STRING EXPR FUNC_CALL VAR BIN_OP NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR VAR IF VAR VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR STRING FOR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR STRING EXPR FUNC_CALL 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | import sys
a = input().split()
n = int(a[0])
k = int(a[1])
def factor(x):
w = str(bin(x))[2:]
return [(len(w) - e[0] - 1) for e in enumerate(w) if int(e[1])]
f = factor(n)
if k < len(f):
print("NO")
sys.exit(0)
w = [(2**x) for x in f]
if sum(w) < k:
print("NO")
sys.exit(0)
print("YES")
while True:
if len(w) == k:
print(" ".join(map(str, w)))
sys.exit(0)
if w[0] == 2:
w = w[1:] + [1, 1]
elif w[0] < k - len(w):
w = w[1:] + [1] * w[0]
else:
w = [w[0] // 2, w[0] // 2] + w[1:] | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER RETURN BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR VAR VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR STRING WHILE NUMBER IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER LIST NUMBER NUMBER IF VAR NUMBER BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER BIN_OP LIST NUMBER VAR NUMBER ASSIGN VAR BIN_OP LIST BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | def init_split(n):
ind = 1
mask = ~0
res = []
while n != 0:
if n & ind != 0:
res.append(n & ind)
ind <<= 1
mask <<= 1
n &= mask
return res
def split(n, k):
init = list(reversed(init_split(n)))
if len(init) > k:
return []
offset = k - len(init)
while offset != 0:
if init[0] == 1:
return []
elif init[0] < offset + 1:
init.extend([1] * init[0])
offset -= init[0] - 1
del init[0]
else:
init[:1] = [int(init[0] / 2)] * 2
offset -= 1
return init
n, k = map(int, input().split())
res = split(n, k)
if not res:
print("NO")
else:
print("YES")
print(" ".join(map(str, res))) | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR NUMBER IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR NUMBER VAR NUMBER VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR RETURN LIST ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR WHILE VAR NUMBER IF VAR NUMBER NUMBER RETURN LIST IF VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP LIST NUMBER VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR NUMBER BIN_OP LIST FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER 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 VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL STRING 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | params = list(map(int, list(input().split())))
n = params[0]
size = params[1]
seq = list(map(int, list(bin(n)[2:])))
u = 0
z = 0
for s in seq:
if s == 1:
u += 1
else:
z += 1
if size < u or size > n:
print("NO")
else:
print("YES")
r = u
while r in range(u, size):
if seq[0] == 0:
seq.pop(0)
seq[0] -= 1
seq[1] += 2
r += 1
ans = ""
for r in range(0, len(seq)):
ans += (str(2 ** (len(seq) - r - 1)) + " ") * seq[r]
print(ans[:-1]) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR VAR WHILE VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER VAR NUMBER NUMBER VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR VAR BIN_OP BIN_OP FUNC_CALL VAR BIN_OP NUMBER BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER STRING VAR VAR EXPR FUNC_CALL 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | import sys
n, k = map(int, input().split())
a = [(1) for i in range(k)]
j = 1
s1 = []
x = 1
while True:
s1.append(x)
x = 2**j
if x > n:
break
j += 1
for i in range(len(a)):
for j in range(len(s1)):
a[i] = s1[j]
if sum(a) == n:
print("YES")
for i in a:
print(i, end=" ")
sys.exit()
elif sum(a) > n:
a[i] = s1[j - 1]
break
print("NO") | IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER VAR IF VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR IF FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR BIN_OP VAR NUMBER 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | e, b = map(int, input().split())
s = []
d = []
a = e
while a:
s += [a % 2]
a = a // 2
for i in range(len(s)):
if s[i]:
d += [2**i]
if b > e or len(d) > b:
print("NO")
elif e == b:
print("YES")
print(e * "1 ")
else:
i = 0
while i < len(d) and len(d) != b:
if d[i] != 1:
d += [d[i] // 2, d[i] // 2]
d.pop(i)
else:
i += 1
print("YES")
d.sort()
s = ""
for i in d:
s += str(i) + " "
print(s) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR VAR WHILE VAR VAR LIST BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR LIST BIN_OP NUMBER VAR IF VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING IF VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR STRING ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR NUMBER VAR LIST BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR STRING FOR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR STRING EXPR FUNC_CALL 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | pt = []
for i in range(31):
pt.append(2**i)
pt = pt[::-1]
n, k = map(int, input().split())
def divide(a, g):
i = 0
while len(a) != g:
if a[i] == 1:
i += 1
else:
e = a.pop(i)
a.append(e // 2)
a.append(e // 2)
return a
if k > n:
print("NO")
else:
ps = []
for i in pt:
if i <= n:
n = n - i
ps.append(i)
if len(ps) > k:
print("NO")
elif len(ps) < k:
print("YES")
print(" ".join(map(str, divide(ps, k))))
else:
print("YES")
print(" ".join(map(str, ps))) | ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR VAR IF VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER RETURN VAR IF VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL STRING 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = map(int, input().split())
jog = k
a = k * [1]
for i in range(k - 1, -1, -1):
while jog + a[i] <= n:
jog += a[i]
a[i] *= 2
if jog == n:
print("YES")
print(*a)
else:
print("NO") | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR LIST NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER WHILE BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, m = map(int, input().split())
x = bin(n)[2:]
ones = x.count("1")
if m < ones or m > n:
print("NO")
else:
print("YES")
x = x[::-1]
s = [(0) for i in range(35)]
for i in range(len(x)):
if x[i] == "1":
s[i] += 1
status = False
while ones != m:
if status == True:
break
for i in range(1, 35):
if s[i] != 0:
s[i] -= 1
s[i - 1] += 2
ones += 1
if ones == m:
status = True
break
for i in range(0, 35):
for j in range(0, s[i]):
print(2**i, end=" ")
print() | 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 VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER IF VAR VAR NUMBER VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR EXPR FUNC_CALL VAR BIN_OP NUMBER 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = input().split()
n = int(n)
k = int(k)
binary = str(bin(n)[2:])
ctr = 0
ans = []
for i in range(len(binary)):
if binary[i] == "1":
ctr += 1
ans.append(2 ** (len(binary) - i - 1))
ans.sort(reverse=True)
if k > n:
print("NO")
elif ctr == k:
print("YES")
ans.sort()
for i in ans:
print(i)
elif ctr > k:
print("NO")
else:
i = 0
while len(ans) < k:
if ans[i] != 1:
ans[i] = int(ans[i] / 2)
ans.append(ans[i])
else:
i += 1
if len(ans) == k:
print("YES")
ans.sort()
for i in ans:
print(i) | ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL 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 BIN_OP NUMBER BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR STRING IF VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FOR VAR VAR EXPR FUNC_CALL 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = map(int, input().split())
st = 1
old_n = n
while st <= n:
st *= 2
st //= 2
a = list()
while n > 0:
if n >= st:
n -= st
a.append(st)
else:
st //= 2
n = old_n
if len(a) > k:
print("NO")
elif k > n:
print("NO")
else:
i = 0
while len(a) < k:
if a[i] != 1:
a[i] //= 2
a.append(a[i])
else:
i += 1
print("YES")
print(*a) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR WHILE VAR NUMBER IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING IF VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR VAR IF VAR VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = list(map(int, input().split()))
n = bin(n)[2:]
cont = 0
for i in n:
if i == "1":
cont += 1
n = list(map(int, n))
k -= cont
while k > 0:
for i in range(len(n)):
if n[i] != 0:
if i + 1 >= len(n):
print("NO")
exit(0)
else:
n[i + 1] += 2
n[i] -= 1
k -= 1
break
if k == 0:
print("YES")
res = ""
cont = 0
for i in range(len(n) - 1, -1, -1):
res = res + (str(2**cont) + " ") * n[i]
cont += 1
print(res)
else:
print("NO") | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR WHILE VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER IF BIN_OP VAR NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR VAR NUMBER VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP FUNC_CALL VAR BIN_OP NUMBER VAR STRING VAR VAR VAR NUMBER EXPR FUNC_CALL 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = map(int, input().split())
a = bin(n)[:1:-1]
d = dict()
m = 0
for i, x in enumerate(a):
d[1 << i] = x == "1"
m += d[1 << i]
if k > n or k < m:
print("NO")
exit()
print("YES")
while m < k:
p = k - m
g = min(d[1 << i], p)
d[1 << i] -= g
i -= 1
d[1 << i] += 2 * g
m += g
r = []
for x in d:
r += [x] * d[x]
print(*r) | 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 ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER VAR VAR STRING VAR VAR BIN_OP NUMBER VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR STRING WHILE VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP NUMBER VAR VAR VAR BIN_OP NUMBER VAR VAR VAR NUMBER VAR BIN_OP NUMBER VAR BIN_OP NUMBER VAR VAR VAR ASSIGN VAR LIST FOR VAR VAR VAR BIN_OP LIST VAR VAR VAR EXPR FUNC_CALL 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = map(int, input().split())
b = []
a = []
for i in range(31):
a.append(2**i)
for i in range(30, -1, -1):
q = n - k + 1
counter = 0
while a[i] <= q:
n -= a[i]
k -= 1
counter += 1
q = n - k + 1
if k == 0:
break
for j in range(counter):
b.append(a[i])
if k == 0:
break
if n == 0 and k == 0:
print("YES")
print(*b)
else:
print("NO") | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR IF VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | import sys
def solve(io):
N = io.read_int()
K = io.read_int()
B = [0] * 32
cnt = 0
for i in range(0, len(B)):
if N >> i & 1 != 0:
B[i] += 1
cnt += 1
if K > N or cnt > K:
io.println("NO")
return
p = len(B) - 1
while cnt < K:
while B[p] == 0:
p -= 1
B[p] -= 1
B[p - 1] += 2
cnt += 1
io.println("YES")
for i, x in enumerate(B):
for _ in range(0, x):
io.print(1 << i)
io.print(" ")
io.println()
class IO:
in_stream = None
out_stream = None
raw = ""
buf = []
pos = 0
def __init__(self, input_stream, output_stream):
self.in_stream = input_stream
self.out_stream = output_stream
def read_to_buffer(self):
self.raw = self.in_stream.readline().rstrip("\n")
self.buf = self.raw.split()
self.pos = 0
def read_string(self):
while self.pos == len(self.buf):
self.read_to_buffer()
ans = self.buf[self.pos]
self.pos += 1
return ans
def read_int(self):
return int(self.read_string())
def read_float(self):
return float(self.read_string())
def read_string_array(self, N, offset=0):
arr = [None] * offset
for _ in range(0, N):
arr.append(self.read_string())
return arr
def read_int_array(self, N, offset=0):
arr = [None] * offset
for _ in range(0, N):
arr.append(self.read_int())
return arr
def read_float_array(self, N, offset=0):
arr = [None] * offset
for _ in range(0, N):
arr.append(self.read_float())
return arr
def read_line(self):
while self.pos == len(self.buf):
self.read_to_buffer()
if self.pos > 0:
raise ValueError("Cannot call read_line in the middle of a line.")
self.pos = len(self.buf)
return self.raw
def print(self, *args):
self.out_stream.write(" ".join([str(x) for x in args]))
def println(self, *args):
self.print(*args)
self.print("\n")
def println_array(self, arr, sep=" "):
self.println(sep.join(str(x) for x in arr))
def flush_output(self):
self.out_stream.flush()
pythonIO = IO(sys.stdin, sys.stdout)
solve(pythonIO)
pythonIO.flush_output() | IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR EXPR FUNC_CALL VAR STRING RETURN ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR VAR WHILE VAR VAR NUMBER VAR NUMBER VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING FOR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR CLASS_DEF ASSIGN VAR NONE ASSIGN VAR NONE ASSIGN VAR STRING ASSIGN VAR LIST ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FUNC_DEF WHILE VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER RETURN VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF NUMBER ASSIGN VAR BIN_OP LIST NONE VAR FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR RETURN VAR FUNC_DEF NUMBER ASSIGN VAR BIN_OP LIST NONE VAR FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR RETURN VAR FUNC_DEF NUMBER ASSIGN VAR BIN_OP LIST NONE VAR FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR RETURN VAR FUNC_DEF WHILE VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR IF VAR NUMBER FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR RETURN VAR FUNC_DEF EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR FUNC_DEF EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING FUNC_DEF STRING EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR FUNC_DEF EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | while True:
try:
def soln(n, k):
res = {}
queue = []
for i in range(44):
if n & 1 << i:
if i > 0:
queue.append(1 << i)
res[1 << i] = 1
if len(res) > k:
print("NO")
return
cnt = len(res)
i = 0
while cnt < k and i < len(queue):
v = queue[i]
i += 1
res[v] -= 1
if res.get(v // 2) != None:
res[v // 2] += 2
else:
res[v // 2] = 2
if v // 2 > 1:
queue.append(v // 2)
queue.append(v // 2)
cnt += 1
if cnt < k:
print("NO")
return
print("YES")
finl_res = []
for x in res:
for j in range(res[x]):
finl_res.append(x)
print(*finl_res)
def read():
n, k = map(int, input().split())
soln(n, k)
if __name__ == "__main__":
read()
except EOFError:
break | WHILE NUMBER FUNC_DEF ASSIGN VAR DICT ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR BIN_OP NUMBER VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP NUMBER VAR NUMBER IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING RETURN ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR NUMBER VAR VAR NUMBER IF FUNC_CALL VAR BIN_OP VAR NUMBER NONE VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR STRING RETURN EXPR FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR VAR FOR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR IF VAR STRING EXPR FUNC_CALL 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | def FindAllElements(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
for i in range(0, k, 1):
print(A[i], end=" ")
n, k = [int(x) for x in input().split()]
temp = n
ans = 1
curr = 0
c = 0
while n > 0:
bit = n & 1
if bit:
c += 1
ans *= 2**curr
n = n >> 1
curr += 1
if ans >= k and c <= k and temp >= k:
print("YES")
FindAllElements(temp, k)
print()
else:
print("NO") | 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 FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR STRING ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR NUMBER VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = map(int, input().split())
if n < k:
print("NO")
exit(0)
c = [0] * 32
for i in range(32):
if 1 << i & n:
c[i] += 1
k -= 1
if k < 0:
print("NO")
exit(0)
print("YES")
for _ in range(k):
for i in range(1, 32):
if c[i] > 0:
c[i] -= 1
c[i - 1] += 2
break
res = []
for i in range(32):
for _ in range(c[i]):
res.append(1 << i)
print(" ".join(map(str, res))) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP BIN_OP NUMBER VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER IF VAR VAR NUMBER VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL STRING 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = map(int, input().split())
tab = list(map(int, str(bin(n))[2:]))
nb = sum(tab)
n_tab = len(tab)
p = len(tab)
while nb < k and n_tab > 1:
if tab[p - n_tab] == 0:
n_tab -= 1
else:
tab[p - n_tab] -= 1
tab[p - n_tab + 1] += 2
nb += 1
if nb == k:
print("YES")
l = []
for i in range(p):
for j in range(tab[p - i - 1]):
l.append(pow(2, i))
print(" ".join(map(str, l)))
else:
print("NO") | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR VAR VAR NUMBER IF VAR BIN_OP VAR VAR NUMBER VAR NUMBER VAR BIN_OP VAR VAR NUMBER VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | GI = lambda: int(input())
GIS = lambda: map(int, input().split())
LGIS = lambda: list(GIS())
def main():
n, k = GIS()
l = []
ones = 0
while n:
n, m = divmod(n, 2)
l.append(m)
ones += m
if ones > k:
print("NO")
return
i = len(l) - 1
while ones < k and i > 0:
if l[i] == 0:
i -= 1
else:
l[i] -= 1
l[i - 1] += 2
ones += 1
if ones < k:
print("NO")
else:
print("YES")
for i, c in enumerate(l):
if c:
print("%i " % 2**i * c, end="")
print()
main() | 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 FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR STRING RETURN ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR VAR VAR NUMBER IF VAR VAR NUMBER VAR NUMBER VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING FOR VAR VAR FUNC_CALL VAR VAR IF VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP STRING BIN_OP NUMBER VAR VAR STRING EXPR FUNC_CALL VAR 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = [int(x) for x in input().split()]
bi = bin(n)[2:]
max_bits = 100
arr = [0] * max_bits
for idx, bit in enumerate(bi):
arr[len(bi) - idx - 1] = int(bit)
K = sum(arr)
def spread_one():
global K
for idx in range(1, max_bits):
if arr[idx] > 0:
arr[idx - 1] += 2
arr[idx] -= 1
K += 1
break
if sum(1 for x in bi if x == "1") <= k and n >= k:
print("YES")
while K < k:
spread_one()
pow_2s = [(2**idx) for i, m in enumerate(arr) for idx in [i] * m]
print(" ".join([str(x) for x in pow_2s]))
else:
print("NO") | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR VAR NUMBER VAR NUMBER IF FUNC_CALL VAR NUMBER VAR VAR VAR STRING VAR VAR VAR EXPR FUNC_CALL VAR STRING WHILE VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER VAR VAR VAR FUNC_CALL VAR VAR VAR BIN_OP LIST VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | def dec_to_bin(n):
ans = ""
while n // 2 != 0 or n % 2 != 0:
ans += str(n % 2)
n //= 2
return ans[::-1]
def bin_to_dec(n):
ans = 0
length = len(n) - 1
for _ in range(len(n)):
ans += int(n[_]) * 2**length
length -= 1
return ans
a = []
n, k = map(int, input().split())
init = n
n = dec_to_bin(n)
if n.count("1") > k or k > init:
print("NO")
exit()
for i in range(len(n)):
if n[i] == "1":
a.append("1" + (len(n) - i - 1) * "0")
k -= len(a)
j = 0
ones_cnt = 0
while k > 0:
if a[0] != "1":
if bin_to_dec(a[0]) < k:
for h in range(bin_to_dec(a[0])):
ones_cnt += 1
k -= 1
k += 2
del a[0]
else:
a.append(dec_to_bin(bin_to_dec(a[0]) // 2))
a.append(dec_to_bin(bin_to_dec(a[0]) // 2))
del a[0]
else:
ones_cnt += 1
del a[0]
k += 1
k -= 1
print("YES")
for _ in range(len(a)):
print(bin_to_dec(a[_]), end=" ")
if ones_cnt != 0:
for b in range(ones_cnt):
print(1, end=" ") | FUNC_DEF ASSIGN VAR STRING WHILE BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR BIN_OP NUMBER VAR VAR NUMBER RETURN VAR ASSIGN VAR LIST ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR STRING VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR BIN_OP STRING BIN_OP BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER STRING VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER IF VAR NUMBER STRING IF FUNC_CALL VAR VAR NUMBER VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR STRING IF VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = map(int, input().split())
b = len(bin(n)[2:])
b1 = bin(n)[2:]
if k < b1.count("1") or k > n:
print("NO")
exit()
cand = []
print("YES")
for i in range(b):
if b1[i] == "1":
cand.append(2 ** (b - i - 1))
cand.sort(reverse=True)
diff = k - b1.count("1")
while diff:
for i in range(len(cand)):
if cand[i] == 1:
continue
else:
if diff == 0:
continue
r = cand[i] // 2
cand.pop(i)
cand.append(r)
cand.append(r)
diff -= 1
print(*cand) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR FUNC_CALL VAR STRING VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR BIN_OP NUMBER BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR STRING WHILE VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | def altro(n, d):
for i in range(len(d)):
if n < d[i]:
return d[i - 1]
def mini(n, d):
if n == 1:
return 1
if n > d[-1]:
return d[-1]
if n in d:
return n
return altro(n, d)
def f(n, k, d):
m = n
flag = True
lista = []
while flag:
if k == 1:
flag = False
if m in d:
lista.append(str(m))
res = ["YES", lista]
else:
res = ["NO", []]
elif k > m:
flag = False
res = ["NO", []]
elif k == m:
flag = False
res = ["YES", lista + [str(1)] * k]
else:
diff = m - k + 1
el = mini(diff, d)
lista.append(str(el))
m -= el
k -= 1
return res
lista = list(map(int, input().rstrip().split()))
n = lista[0]
k = lista[1]
d = [
1,
2,
4,
8,
16,
32,
64,
128,
256,
512,
1024,
2048,
4096,
8192,
16384,
32768,
65536,
131072,
262144,
524288,
1048576,
2097152,
4194304,
8388608,
16777216,
33554432,
67108864,
134217728,
268435456,
536870912,
]
[ans, lista] = f(n, k, d)
print(ans)
if ans == "NO":
pass
else:
print(" ".join(lista)) | FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR RETURN VAR BIN_OP VAR NUMBER FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR VAR NUMBER RETURN VAR NUMBER IF VAR VAR RETURN VAR RETURN FUNC_CALL VAR VAR VAR FUNC_DEF ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR IF VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR LIST STRING VAR ASSIGN VAR LIST STRING LIST IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST STRING LIST IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST STRING BIN_OP VAR BIN_OP LIST FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN LIST VAR VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR IF VAR STRING EXPR FUNC_CALL VAR FUNC_CALL STRING 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | def print_arr(arr, maxi):
for i in range(40):
if arr[i] != 0:
if i != maxi:
for j in range(arr[i]):
print(2**i, end=" ")
else:
for j in range(arr[i] - 1):
print(2**i, end=" ")
print(2**i)
n, k = map(int, input().split())
tmp = n
arr = [(0) for _ in range(40)]
count = 0
maxi = 0
for i in range(40)[::-1]:
if tmp >= 2**i:
arr[i] += 1
tmp -= 2**i
count += 1
if maxi < i:
maxi = i
if k < count or n < k:
print("NO")
elif k == count:
print("YES")
print_arr(arr, maxi)
else:
while k != count:
if count + arr[maxi] <= k:
count += arr[maxi]
arr[maxi - 1] += 2 * arr[maxi]
arr[maxi] = 0
maxi -= 1
elif k < count + arr[maxi]:
temp = k - count
arr[maxi] -= temp
arr[maxi - 1] += 2 * temp
count = k
print("YES")
print_arr(arr, maxi) | FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR NUMBER IF VAR VAR FOR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP NUMBER VAR STRING FOR VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER VAR STRING EXPR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER IF VAR BIN_OP NUMBER VAR VAR VAR NUMBER VAR BIN_OP NUMBER VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR STRING IF VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR VAR WHILE VAR VAR IF BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR BIN_OP VAR NUMBER BIN_OP NUMBER VAR VAR ASSIGN VAR VAR NUMBER VAR NUMBER IF VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR VAR VAR BIN_OP VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR STRING EXPR 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = [int(i) for i in input().split()]
if n < k:
print("NO")
else:
lst = [1] * k
delta = n - k
for k in range(len(lst)):
while lst[k] - 1 <= delta:
lst[k] *= 2
lst[k] = lst[k] // 2
delta -= lst[k] - 1
if delta == 0:
print("YES")
print(" ".join([str(i) for i in lst]))
break
else:
print("NO") | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR WHILE BIN_OP VAR VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | import sys
def fprint(x):
print(x, flush=True)
def qprint(x):
sys.stdout.write(str(x) + "\n")
def input():
return sys.stdin.readline()
N, K = map(int, input().split())
n_bits = format(N, "b")
n_bits = str(n_bits)
num_1s = n_bits.count("1")
print_list = []
if K < num_1s:
print("NO")
elif K > N:
print("NO")
else:
print("YES")
for index, ele in enumerate(n_bits):
if ele == "1":
print_list.append(2 ** (len(n_bits) - index - 1))
while len(print_list) != K:
if print_list[0] == 1:
print(print_list.pop(0), end=" ")
K -= 1
else:
element = print_list.pop(0)
print_list.append(int(element / 2))
print_list.append(int(element / 2))
print(" ".join(map(str, print_list))) | IMPORT FUNC_DEF EXPR FUNC_CALL VAR VAR NUMBER FUNC_DEF EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR STRING FUNC_DEF RETURN FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR LIST IF VAR VAR EXPR FUNC_CALL VAR STRING IF VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING FOR VAR VAR FUNC_CALL VAR VAR IF VAR STRING EXPR FUNC_CALL VAR BIN_OP NUMBER BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER WHILE FUNC_CALL VAR VAR VAR IF VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER STRING VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | def main():
n, k = [int(i) for i in input().split()]
if n < k:
print("NO")
return
res = [1] * k
if n == k:
print("YES")
print(*res)
return
n -= k
i = 0
while i < k and n:
while res[i] <= n:
n -= res[i]
res[i] *= 2
i += 1
if n:
print("NO")
else:
print("YES", *res)
main() | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR STRING RETURN ASSIGN VAR BIN_OP LIST NUMBER VAR IF VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR RETURN VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR WHILE VAR VAR VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING VAR 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = map(int, input().split())
a = [(2**i) for i in range(31)]
ans = []
temp = n
for i in reversed(a):
while k > 0 and temp - i >= k - 1:
ans.append(i)
temp -= i
k -= 1
if sum(ans) != n:
print("NO")
else:
print("YES")
print(*ans) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR LIST ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR WHILE VAR NUMBER BIN_OP VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = map(int, input().split())
l1 = []
s = bin(n)
for i in range(len(s)):
if s[i] == "1":
l1.append(2 ** (len(s) - 1 - i))
if k < len(l1) or k > n:
print("NO")
else:
i = 0
while len(l1) != k:
if i >= len(l1):
i = 0
if l1[i] != 1:
l1[i] = int(l1[i] / 2)
l1.append(int(l1[i]))
i += 1
print("YES")
for i in l1:
print(i, end=" ") | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR 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 NUMBER VAR IF VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR VAR IF VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR STRING FOR VAR VAR EXPR FUNC_CALL VAR 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, m = map(int, input().split())
k = n
d = {(0): n}
i = 1
while k > m:
c = int(d[i - 1] / 2)
d[i - 1] -= c * 2
if c == 0:
print("NO")
exit()
d[i] = c
i += 1
k -= c
p = abs(k - m)
i -= 1
while p > 0:
if i == 0:
print("NO")
exit()
v1 = min(p, d[i])
p -= v1
d[i] -= v1
d[i - 1] += v1 * 2
s = ""
for x in d:
s += (str(2**x) + " ") * d[x]
print("YES")
print(s) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR DICT NUMBER VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR NUMBER WHILE VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR STRING FOR VAR VAR VAR BIN_OP BIN_OP FUNC_CALL VAR BIN_OP NUMBER VAR STRING VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | def break_in_pow2(num, arr):
divisor = 1
index = 0
while num >= divisor * 2:
divisor *= 2
index += 1
arr[index] += 1
if num - divisor > 0:
break_in_pow2(num - divisor, arr)
line = input().split()
n = int(line[0])
k = int(line[1])
max_k = n
pots = [0] * 31
break_in_pow2(n, pots)
biggest_potency = 0
min_k = 0
for i in range(len(pots)):
potency = pots[i]
min_k += potency
if potency != 0:
biggest_potency = i
if k < min_k or k > max_k:
print("NO")
else:
print("YES")
for curr_k in range(min_k, k):
pots[biggest_potency] -= 1
pots[biggest_potency - 1] += 2
if pots[biggest_potency] == 0:
biggest_potency -= 1
curr_pot = 1
for pot in pots:
for i in range(pot):
print(curr_pot, end=" ")
curr_pot *= 2
print() | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR IF VAR NUMBER ASSIGN VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER IF VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR STRING VAR NUMBER 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | def no():
print("NO")
exit(0)
n, k = map(int, input().split())
bina = list(map(int, bin(n)[2:]))
cur = bina.count(1)
if k > n or cur > k:
no()
while cur < k:
index = bina.index(next(x for x in bina if x > 0))
to = index
while to < len(bina) - 1 and pow(2, to - index + 1) - 1 <= k - cur:
to += 1
if to == index:
no()
bina[index] -= 1
bina[to] += pow(2, to - index)
cur += pow(2, to - index) - 1
print("YES")
for i in range(len(bina)):
num = pow(2, len(bina) - i - 1)
for j in range(bina[i]):
print(num, end=" ") | FUNC_DEF EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER IF VAR VAR VAR VAR EXPR FUNC_CALL VAR WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER BIN_OP FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER NUMBER BIN_OP VAR VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR VAR BIN_OP FUNC_CALL VAR NUMBER BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | import sys
n, k = map(int, input().split())
l = []
cop = n
t = 0
while cop > 0:
x = cop % 2 * pow(2, t)
cop //= 2
t += 1
if x != 0:
l.append(x)
l.sort(reverse=True)
if k > n or k < len(l):
print("NO")
sys.exit()
u = len(l) - 1
while len(l) != k:
if l[u] == 1:
u -= 1
if u == -1:
u += len(l)
else:
l[u] = l[u] // 2
l.append(l[u])
l.sort()
print("YES")
print(*l) | IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER FUNC_CALL VAR NUMBER VAR VAR NUMBER VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE FUNC_CALL VAR VAR VAR IF VAR VAR NUMBER VAR NUMBER IF VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = map(int, input().rstrip().split())
oldn = n
klist = [1] * k
n -= k
i = 0
while n > 0 and i < k:
while n >= klist[i]:
n -= klist[i]
klist[i] = 2 * klist[i]
i += 1
if sum(klist) == oldn:
print("YES")
print(*klist)
else:
print("NO") | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER VAR VAR WHILE VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR BIN_OP NUMBER VAR VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = map(int, input().split())
if n < k:
print("NO")
else:
le = len(bin(n)) - 3
st = 1
li = []
for i in range(le + 1):
if st & n:
li.append(st)
st <<= 1
dif = len(li) - k
if dif > 0:
print("NO")
elif dif == 0:
print("YES")
print(*li)
else:
dif = abs(dif)
print("YES")
stack = []
while dif > 0:
for i in li:
if dif == 0:
print(i, end=" ")
elif i == 1:
print(1, end=" ")
else:
dif -= 1
stack.append(i // 2)
stack.append(i // 2)
if dif == 0:
print(*stack)
li = stack.copy()
stack = [] | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR LIST WHILE VAR NUMBER FOR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST |
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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | def powersOfTwo(n, k):
if k > n:
return []
bin = []
while n > 0:
bin.append(n % 2)
n //= 2
s = sum(bin)
if s > k:
return []
idx = len(bin) - 1
for i in range(k - s):
bin[idx] -= 1
bin[idx - 1] += 2
if bin[idx] == 0:
idx -= 1
arr = []
for i in range(idx + 1):
if bin[i] > 0:
power = 2**i
for j in range(bin[i]):
arr.append(power)
return arr
[n, k] = list(map(int, input().split(" ")))
arr = powersOfTwo(n, k)
if not arr:
print("NO")
else:
print("YES")
for n in arr:
print(n, end=" ") | FUNC_DEF IF VAR VAR RETURN LIST ASSIGN VAR LIST WHILE VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR RETURN LIST ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER IF VAR VAR NUMBER VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR RETURN VAR ASSIGN LIST VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING FOR VAR VAR EXPR FUNC_CALL VAR 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, m = map(int, input().split())
if n < m:
print("NO")
exit()
mas = [int(2**i) for i in range(31)]
i = 30
while n < mas[i]:
i -= 1
ans = []
while n != 0:
if n - mas[i] >= 0:
n -= mas[i]
ans.append(mas[i])
else:
i -= 1
ans.sort()
if len(ans) > m:
print("NO")
exit()
else:
i = 0
while len(ans) != m:
if ans[i] != 1:
ans[i] //= 2
ans.append(ans[i])
else:
i += 1
print("YES")
print(*ans) | 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 BIN_OP NUMBER VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR NUMBER ASSIGN VAR LIST WHILE VAR NUMBER IF BIN_OP VAR VAR VAR NUMBER VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR VAR IF VAR VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | from sys import stdin
n, m = map(int, stdin.readline().strip().split())
p = [(0) for i in range(30)]
s = bin(n)[::-1]
x = 0
for i in range(len(s)):
if s[i] == "1":
p[i] = 1
x += 1
if x > m:
print("NO")
exit(0)
y = 29
while y > 0 and x != m:
if p[y] > 0:
x += 1
p[y] -= 1
p[y - 1] += 2
else:
y -= 1
if x == m:
print("YES")
ans = []
for i in range(len(p)):
for j in range(p[i]):
ans.append(2**i)
print(*ans)
else:
print("NO") | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR VAR NUMBER VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR VAR IF VAR VAR NUMBER VAR NUMBER VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP NUMBER VAR EXPR FUNC_CALL 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | k, n = map(int, input().split())
if n > k:
print("NO")
elif n == k:
print("YES")
print("1 " * n)
else:
bits = []
count = 1
x = 1
while x < k.bit_length() + 1:
if k & count:
bits.append(x - 1)
count = 1 << x
x += 1
if len(bits) > n:
print("NO")
else:
print("YES")
if len(bits) == n:
for el in bits:
print(1 << el, end=" ")
print()
elif len(bits) << 1 > n:
diff = abs(len(bits) - n)
ans, count = "", 0
for x in range(len(bits) - 1, -1, -1):
if count < diff:
ans += str(1 << bits[x] - 1) + " " + str(1 << bits[x] - 1) + " "
count += 1
else:
ans += str(1 << bits[x]) + " "
print(ans)
else:
ans = ""
hmm = n - len(bits)
while hmm > 0:
ans = ""
current = []
for el in bits[::-1]:
cnt = 0
while True:
a = (1 << el - cnt) - 1
if a <= hmm:
hmm -= a
ans += (str(1 << cnt) + " ") * (a + 1)
current.extend([cnt] * (a + 1))
break
cnt += 1
bits = current
print(ans) | 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 EXPR FUNC_CALL VAR BIN_OP STRING VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR NUMBER IF BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING IF FUNC_CALL VAR VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP NUMBER VAR STRING EXPR FUNC_CALL VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR ASSIGN VAR VAR STRING NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF VAR VAR VAR BIN_OP BIN_OP BIN_OP FUNC_CALL VAR BIN_OP NUMBER BIN_OP VAR VAR NUMBER STRING FUNC_CALL VAR BIN_OP NUMBER BIN_OP VAR VAR NUMBER STRING VAR NUMBER VAR BIN_OP FUNC_CALL VAR BIN_OP NUMBER VAR VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR STRING ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR WHILE VAR NUMBER ASSIGN VAR STRING ASSIGN VAR LIST FOR VAR VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER BIN_OP VAR VAR NUMBER IF VAR VAR VAR VAR VAR BIN_OP BIN_OP FUNC_CALL VAR BIN_OP NUMBER VAR STRING BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP LIST VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR EXPR FUNC_CALL 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | def go():
n, k = [int(i) for i in input().split(" ")]
o = "YES\n"
if n < k:
return "NO"
if k == n:
o += " ".join(str(1) for i in range(n))
return o
b = [i for i in bin(n).replace("0b", "")]
i = len(b) - 2
ones = 0
if b[-1] == "1":
ones += 1
stack = []
while i >= 0:
if b[i] == "1":
stack.append(2 ** (len(b) - i - 1))
i -= 1
if len(stack) + ones == k:
o += " ".join(str(i) for i in stack + [1] * ones)
return o
if len(stack) + ones > k:
return "NO"
while len(stack) + ones != k and stack:
x = stack.pop()
if x == 2:
ones += 2
else:
stack.append(x // 2)
stack.append(x // 2)
if len(stack) + ones == k:
o += " ".join(str(i) for i in stack + [1] * ones)
return o
return "NO"
print(go()) | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR STRING IF VAR VAR RETURN STRING IF VAR VAR VAR FUNC_CALL STRING FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR VAR RETURN VAR ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR STRING STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER STRING VAR NUMBER ASSIGN VAR LIST WHILE VAR NUMBER IF VAR VAR STRING EXPR FUNC_CALL VAR BIN_OP NUMBER BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR BIN_OP VAR BIN_OP LIST NUMBER VAR RETURN VAR IF BIN_OP FUNC_CALL VAR VAR VAR VAR RETURN STRING WHILE BIN_OP FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR BIN_OP VAR BIN_OP LIST NUMBER VAR RETURN VAR RETURN STRING EXPR FUNC_CALL VAR 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = map(int, input().split())
a = [1]
i = 2
while i <= n:
a.append(i)
i *= 2
ans = []
j = len(a) - 1
x = n
while x != 0:
if x >= a[j]:
x -= a[j]
ans.append(a[j])
else:
j -= 1
mk = len(ans)
ans = ans[::-1]
c = 0
if k >= mk and k <= n:
i = mk
j = mk - 1
while i < k:
if ans[j] > 2:
y = ans.pop()
ans.append(y // 2)
ans.append(y // 2)
j += 1
elif ans[j] == 2:
y = ans.pop()
j -= 1
c += 1
i += 1
print("YES")
for i in range(c):
print("1 1", end=" ")
for ele in ans:
print(ele, end=" ")
else:
print("NO") | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER WHILE VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR WHILE VAR NUMBER IF VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR IF VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING STRING FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = map(int, input().split())
s = bin(n)[2:]
st = []
if s.count("1") > k or k > n:
print("NO")
else:
st = []
for i in range(len(s)):
if int(s[i]):
st.append(int(s[i]) * 2 ** (len(s) - 1 - i))
ans = k - len(st)
st1 = []
while ans:
if st[-1] == 1:
st1.append(st.pop())
else:
temp = st.pop()
st.append(temp // 2)
st.append(temp // 2)
ans -= 1
while st:
st1.append(st.pop())
print("YES")
print(*st1) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST IF FUNC_CALL VAR STRING VAR VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR BIN_OP NUMBER BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR LIST WHILE VAR IF VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER WHILE VAR EXPR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = map(int, input().split())
bin_exp = [int(x) for x in list(bin(n)[2:])]
if k > n or k < bin_exp.count(1):
print("NO")
else:
print("YES")
while sum(bin_exp) < k:
bin_exp[0] = bin_exp[0] - 1
bin_exp[1] = bin_exp[1] + 2
if bin_exp[0] == 0:
del bin_exp[0]
ans = ""
for x in range(len(bin_exp)):
ans += (str(2 ** (len(bin_exp) - 1 - x)) + " ") * bin_exp[x]
print(ans[:-1]) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING WHILE FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER NUMBER IF VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP BIN_OP FUNC_CALL VAR BIN_OP NUMBER BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER VAR STRING VAR VAR EXPR FUNC_CALL 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = map(int, input().split())
d = dict()
step = 1
kol = 0
while step <= n:
d[step] = 0
step *= 2
if step > n:
step //= 2
while n != 0:
i = 0
stepen = 1
while stepen <= n:
stepen *= 2
i += 1
if stepen > n:
stepen //= 2
d[stepen] += 1
kol += 1
n -= stepen
if kol > k:
print("NO")
exit()
while kol != k:
if step == 1:
print("NO")
exit()
if d[step] != 0:
d[step] -= 1
d[step // 2] += 2
kol += 1
else:
step //= 2
print("YES")
for i in d:
if d[i] != 0:
for j in range(d[i]):
print(i, end=" ") | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR VAR NUMBER VAR NUMBER IF VAR VAR VAR NUMBER WHILE VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER VAR NUMBER IF VAR VAR VAR NUMBER VAR VAR NUMBER VAR NUMBER VAR VAR IF VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR WHILE VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR IF VAR VAR NUMBER VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING FOR VAR VAR IF VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | def minimum_k(x):
arr = []
ans = []
while x > 0:
arr.append(x % 2)
x //= 2
for i in range(len(arr)):
if arr[i] == 1:
ans.append(2**i)
return ans
def solve():
n, k = map(int, input().split())
result = minimum_k(n)
min_len = len(result)
if k < min_len or k > n:
print("NO")
return
i = 0
while min_len < k:
while result[i] == 1:
i += 1
x = result[i] // 2
result[i] = x
result.append(x)
min_len += 1
print("YES")
print(" ".join(str(k) for k in sorted(result)))
solve() | FUNC_DEF ASSIGN VAR LIST ASSIGN VAR LIST WHILE VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER VAR RETURN VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR STRING RETURN ASSIGN VAR NUMBER WHILE VAR VAR WHILE VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = map(int, input().split())
a = list(map(int, list(str(bin(n)).lstrip("0b"))))
c = a.count(1)
j = 0
while c < k:
if j > len(a) - 2:
break
if a[j]:
c += 1
a[j] -= 1
a[j + 1] += 2
else:
j += 1
if c != k:
print("NO")
else:
print("YES")
for i in range(len(a)):
for k in range(a[i]):
print(2 ** (len(a) - i - 1), end=" ") | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR VAR STRING ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR NUMBER VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP NUMBER BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = map(int, input().split())
b = list(bin(n)[2:])
b.reverse()
r = []
sm = 0
for i in range(len(b)):
if b[i] == "1":
sm += 2 ** int(i)
r.append(int(i))
if len(r) > k or k > sm:
print("NO")
elif len(r) == k:
print("YES")
for i in r:
print(2**i, end=" ")
else:
print("YES")
s = len(r)
while s != k:
if r[0] == 0:
print(2 ** r[0], end=" ")
r.pop(0)
else:
r.insert(0, r[0] - 1)
r[1] = r[0]
s += 1
for i in r:
print(2**i, end=" ") | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR BIN_OP NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR STRING IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP NUMBER VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR VAR IF VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER VAR NUMBER STRING EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER VAR NUMBER VAR NUMBER FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP NUMBER 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | i, k = map(int, input().split())
pows = []
c = 0
while i > 0:
pows.append(i & 1)
c += 1
i = i >> 1
pows.reverse()
s = sum(pows)
c = 0
l = len(pows) - 1
while s != k:
while c < l and pows[c] == 0:
c += 1
if c >= l or s > k:
print("NO")
break
pows[c] -= 1
pows[c + 1] += 2
s += 1
else:
print("YES")
for i, el in enumerate(pows):
if el > 0:
for _ in range(el):
print(2 ** (l - i), end=" ")
print() | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR VAR WHILE VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR EXPR FUNC_CALL VAR STRING VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING FOR VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP NUMBER BIN_OP VAR 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = map(int, input().split(" "))
ans = [(2**i) for i in range(31)]
var = n
l = []
for i in reversed(ans):
while k > 0 and var - i >= k - 1:
l.append(i)
var -= i
k -= 1
if k == 0:
break
if sum(l) != n:
print("NO")
else:
print("YES")
for i in l:
print(i, end=" ")
print("") | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP NUMBER VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR WHILE VAR NUMBER BIN_OP VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR VAR NUMBER IF VAR NUMBER IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = [int(j) for j in input().split()]
x = bin(n)[2:]
q = x.count("1")
res = []
if k < q or k > n:
print("NO")
else:
print("YES")
x = [int(j) for j in x]
r = 0
c = k - q
while c > 0:
while x[r] == 0:
r += 1
x[r] -= 1
x[r + 1] += 2
c -= 1
x = x[::-1]
res = ""
for i in range(len(x)):
for j in range(x[i]):
res += str(2**i) + " "
print(res[:-1]) | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR LIST IF VAR VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR WHILE VAR NUMBER WHILE VAR VAR NUMBER VAR NUMBER VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP FUNC_CALL VAR BIN_OP NUMBER VAR STRING EXPR FUNC_CALL 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | def get_bit(n):
count_shifts = 0
while n > 1:
n = n >> 1
count_shifts += 1
return pow(2, count_shifts)
str_input = input().split()
array = []
n = int(str_input[0])
k = int(str_input[1])
eh_possivel = True
if k > n:
print("NO")
eh_possivel = False
else:
if n % 2 != 0:
array.append(1)
n -= 1
k -= 1
while n > 0:
if k == 0:
print("NO")
eh_possivel = False
break
bit_mais_sig = get_bit(n)
n -= bit_mais_sig
k -= 1
array.append(bit_mais_sig)
i = 0
while k > 0:
if array[i] != 1:
metade = array[i] // 2
array[i] = metade
array.append(metade)
k -= 1
else:
i += 1
if eh_possivel:
print("YES")
print(" ".join([str(x) for x in array])) | FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER RETURN FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER VAR NUMBER VAR NUMBER WHILE VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER IF VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER VAR NUMBER IF VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = map(int, input().split())
n = bin(n)[2:]
if n.count("1") > k:
print("NO")
else:
l = []
for i in range(len(n)):
if n[i] == "1":
l.append(2 ** (len(n) - i - 1))
l.sort(reverse=True)
j = 0
while k - len(l) > 0:
while j < len(l) and l[j] == 1:
j = j + 1
if j >= len(l):
print("NO")
exit(0)
l[j] = l[j] // 2
l.append(l[j])
l.sort()
print("YES")
for i in l:
print(i, end=" ") | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR STRING VAR EXPR FUNC_CALL VAR STRING 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 EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR FUNC_CALL VAR VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR STRING FOR VAR VAR EXPR FUNC_CALL VAR 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = map(int, input().split())
def move_byte(s, times):
k = s[0]
if s[0] < times:
s = move_byte(s, k)
return move_byte(s, times - k)
if s[0] == times:
s[1] += s[0] * 2
s = s[1:]
return s
elif times == 0:
return s
else:
s[1] += times * 2
s[0] -= times
return s
def s2print(s):
top_byte = len(s)
tv = 2 ** (top_byte - 1)
k = []
for n in s:
k.extend([tv] * n)
tv = tv // 2
return " ".join(map(str, k))
binn = "{0:b}".format(n)
s = list(map(int, binn))
ones = sum(s)
if ones > k or k > n:
print("NO")
else:
s = move_byte(s, k - ones)
print("YES")
print(s2print(s)) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR NUMBER IF VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR VAR RETURN FUNC_CALL VAR VAR BIN_OP VAR VAR IF VAR NUMBER VAR VAR NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER RETURN VAR IF VAR NUMBER RETURN VAR VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER VAR RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP LIST VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN FUNC_CALL STRING FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL STRING VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | s, k = [int(x) for x in input().split()]
bina = []
o = 0
n = s
tot2 = []
while n > 0:
l = 0
while 1:
if 2**l > n // 2:
bina.append(2**l)
n -= 2**l
break
else:
l += 1
if len(bina) > k:
print("NO")
elif k > s:
print("NO")
else:
bina.sort()
for item in range(k - len(bina)):
a = bina.pop()
while 1:
if a == 1:
a = bina.pop()
tot2.append(1)
else:
break
bina.append(a // 2)
bina.append(a // 2)
if o == 0:
print("YES")
bina = bina + tot2
tot = ""
for item in bina:
tot += str(item) + " "
print(tot[:-1]) | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR LIST WHILE VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER IF BIN_OP NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER VAR VAR BIN_OP NUMBER VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING IF VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR WHILE NUMBER IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR STRING FOR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR STRING EXPR FUNC_CALL 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = map(int, input().split())
arr = [(1) for _ in range(k)]
total = k
for i in range(k - 1, -1, -1):
while total + arr[i] <= n:
total += arr[i]
arr[i] *= 2
if sum(arr) == n:
print("YES")
print(" ".join(map(str, arr)))
else:
print("NO") | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER WHILE BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | import sys
line = sys.stdin.readline().strip().split()
n = int(line[0])
k = int(line[1])
powers = []
p = 0
if n < k:
print("NO")
else:
if k > 32:
powers = [1] * (k - 32)
n = n - k + 32
k = 32
while n > 0:
while n - 1 < 2 ** (k - 1) and n != 0 and k != 0:
powers.append(2**p)
n = n - 1
k = k - 1
if n > 0:
if n % 2 == 1:
powers.append(2**p)
n = n - 1
k = k - 1
else:
n = n // 2
p = p + 1
if k == 0:
print("YES")
print(" ".join(list(map(str, powers))))
else:
print("NO") | IMPORT ASSIGN VAR FUNC_CALL 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 IF VAR VAR EXPR FUNC_CALL VAR STRING IF VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER WHILE BIN_OP VAR NUMBER BIN_OP NUMBER BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR FUNC_CALL VAR 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = map(int, input().split())
n1 = n
mas = []
while n != 0:
mas.append(n % 2)
n = n // 2
if sum(mas) > k or k > n1:
print("NO")
else:
flag = True
s = sum(mas)
i = len(mas) - 1
while flag:
if s - mas[i] + 2 * mas[i] < k:
mas[i - 1] += mas[i] * 2
s += mas[i]
mas[i] = 0
i -= 1
else:
b = k - s
mas[i] -= b
mas[i - 1] += 2 * b
flag = False
s = ""
print("YES")
for i in range(0, i + 1):
for j in range(mas[i]):
print(2**i, end=" ") | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR LIST WHILE VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR IF BIN_OP BIN_OP VAR VAR VAR BIN_OP NUMBER VAR VAR VAR VAR BIN_OP VAR NUMBER BIN_OP VAR VAR NUMBER VAR VAR VAR ASSIGN VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR VAR VAR VAR BIN_OP VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR STRING EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP NUMBER 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n = list(map(int, input().split(" ")))
s = ""
r = n[0]
k = n[0]
z = n[1]
a = []
b = 0
while k != 0:
if k % 2 == 0:
s += "0"
else:
s += "1"
a += [2**b]
b += 1
k = k // 2
if len(a) > z or z > r:
print("NO")
else:
c = 0
print("YES")
while len(a) < z:
if a[c] != 1:
a.append(a[c] // 2)
a[c] = a[c] // 2
else:
c += 1
for i in a:
print(i) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR STRING VAR STRING VAR LIST BIN_OP NUMBER VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER EXPR FUNC_CALL VAR STRING WHILE FUNC_CALL VAR VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR VAR NUMBER VAR NUMBER FOR VAR VAR EXPR FUNC_CALL 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | try:
n, k = map(int, input().split())
except:
exit()
if n < k:
print("NO")
exit(0)
q = []
s = {}
i = 1
while n:
if n & 1 != 0:
if i > 1:
q.append(i)
if i not in s.keys():
s[i] = 0
s[i] += 1
i = i << 1
n = n >> 1
if len(s) > k:
print("NO")
exit(0)
i = len(s)
while i < k and q:
top = q.pop(0)
s[top] -= 1
if top // 2 not in s.keys():
s[top // 2] = 0
s[top // 2] += 2
if top // 2 > 1:
q.append(top // 2)
q.append(top // 2)
i += 1
if i < k:
print("NO")
exit(0)
print("YES", *[k for k in s.keys() for i in range(s[k])]) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST ASSIGN VAR DICT ASSIGN VAR NUMBER WHILE VAR IF BIN_OP VAR NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER VAR VAR NUMBER IF BIN_OP VAR NUMBER FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR STRING VAR VAR FUNC_CALL VAR VAR 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = map(int, input().split())
bn = bin(n)[2:][::-1]
mx = 0
mst = [0] * len(bn)
for i in range(len(bn)):
if bn[i] == "1":
mst[i] = 1
mx += 1
mst = mst[::-1]
lmst = len(mst)
if mx <= k and n >= k:
i = 0
while sum(mst) != k:
if sum(mst) - mst[i] + mst[i] * 2 <= k:
mst[i + 1] += mst[i] * 2
mst[i] = 0
else:
ost = sum(mst[:i] + mst[i + 1 :])
x = k - ost - mst[i]
mst[i + 1] += 2 * x
mst[i] -= x
i += 1
mst = mst[::-1]
print("YES")
for i in range(lmst):
print((str(2**i) + " ") * mst[i], end="")
else:
print("NO") | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR VAR IF BIN_OP BIN_OP FUNC_CALL VAR VAR VAR VAR BIN_OP VAR VAR NUMBER VAR VAR BIN_OP VAR NUMBER BIN_OP VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR BIN_OP VAR NUMBER BIN_OP NUMBER VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR BIN_OP NUMBER VAR STRING VAR VAR STRING 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = map(int, input().split())
sum2 = {}
p2 = 1
while n:
if n % 2:
sum2[p2] = 1
p2 *= 2
n //= 2
if k < sum(sum2.values()):
print("NO")
else:
while sum(sum2.values()) < k and list(sum2.keys()) != [1]:
for i in sum2.keys():
if i == 1:
continue
else:
sum2[i] -= 1
try:
sum2[i // 2] += 2
except:
sum2[i // 2] = 2
if sum2[i] == 0:
sum2.pop(i)
break
if sum(sum2.values()) == k:
print("YES")
for i in sum2.keys():
for j in range(sum2[i]):
print(i, end=" ")
else:
print("NO") | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR NUMBER WHILE VAR IF BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER VAR NUMBER IF VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR STRING WHILE FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR LIST NUMBER FOR VAR FUNC_CALL VAR IF VAR NUMBER VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR STRING 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = map(int, input().split())
b = bin(n)[2:]
min1 = b.count("1")
if n < k:
print("NO")
elif min1 > k:
print("NO")
else:
print("YES")
i = 0
pows = []
while i < len(b):
idx = len(b) - 1 - i
if b[idx] == "1":
pows.append(2**i)
i += 1
while len(pows) != k:
i = len(pows) - 1
while pows[i] == 1 or pows[i] == 0:
i -= 1
while pows[i] != 1 and len(pows) != k:
pows.append(pows[i] // 2)
pows[i] //= 2
ans = " ".join(map(str, pows))
print(ans) | 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 EXPR FUNC_CALL VAR STRING IF VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER VAR IF VAR VAR STRING EXPR FUNC_CALL VAR BIN_OP NUMBER VAR VAR NUMBER WHILE FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR VAR NUMBER VAR VAR NUMBER VAR NUMBER WHILE VAR VAR NUMBER FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR EXPR FUNC_CALL 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = map(int, input().split())
st = []
ones = bin(n).count("1")
if k == 1:
if ones == 1:
print("YES")
print(n)
else:
print("NO")
elif ones > k:
print("NO")
else:
po = 0
bi = bin(n)[2:]
for i in range(len(bi) - 1, -1, -1):
if bi[i] == "1" and po != 0:
st.append(2**po)
po += 1
st.sort()
excess = k - ones
ans = []
if excess == 0:
print("YES")
if n % 2 == 1:
st.append(1)
print(" ".join(map(str, st)))
elif sum(st) < excess:
print("NO")
else:
ans = []
while excess > 0 and len(st) != 0:
curr = st[-1]
st.pop()
if curr // 2 > 1:
st.append(curr // 2)
st.append(curr // 2)
excess -= 1
if excess != 0:
print("NO")
else:
ans = [i for i in st]
rem = n - sum(ans)
for j in range(rem):
ans.append(1)
print("YES")
print(" ".join(map(str, ans))) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR STRING IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING IF VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF VAR VAR STRING VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR LIST IF VAR NUMBER EXPR FUNC_CALL VAR STRING IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR LIST WHILE VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL STRING 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = map(int, input().split())
x = bin(n).count("1")
y = list(map(int, bin(n)[2:]))
if x <= k <= n:
print("YES")
for i in range(k - x):
for j in range(len(y)):
if y[j] > 0:
y[j + 1] += 2
y[j] -= 1
break
y = y[::-1]
for i in range(len(y)):
for j in range(y[i]):
print(2**i, end=" ")
else:
print("NO") | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP NUMBER VAR STRING 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = map(int, input().strip().split())
arr = []
c = 0
m = n
def po(c):
if c == 0:
return 1
elif c == 1:
return 2
else:
return 2 << c - 1
while m != 0:
if m % 2 != 0:
arr.append(po(c))
c += 1
m = m // 2
if len(arr) > k:
print("NO")
elif k > n:
print("NO")
elif k == len(arr):
print("YES")
print(*arr)
else:
c = len(arr)
while len(arr) != k:
c -= 1
a = [arr[c]]
i = 0
while len(a) != arr[c]:
if len(a) + len(arr) - 1 == k:
break
if a[i] != 1:
a.append(a[i] // 2)
a[i] = a[i] // 2
i = (i + 1) % len(a)
arr.extend(a)
arr[c], arr[len(arr) - 1] = arr[len(arr) - 1], arr[c]
arr.pop()
print("YES")
print(*arr) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER RETURN BIN_OP NUMBER BIN_OP VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING IF VAR VAR EXPR FUNC_CALL VAR STRING IF VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR WHILE FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR LIST VAR VAR ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR VAR VAR IF BIN_OP BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL 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 contains two integers n and k (1 β€ n β€ 10^9, 1 β€ k β€ 2 β
10^5).
Output
If it is impossible to represent n as the sum of k powers of two, print NO.
Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and β _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.
Examples
Input
9 4
Output
YES
1 2 2 4
Input
8 1
Output
YES
8
Input
5 1
Output
NO
Input
3 7
Output
NO | n, k = input().split()
n = int(n)
k = int(k)
binary_array = [0] * 31
def get_min(binary, binary_array):
minimum = 0
for digit_idx in range(len(binary)):
if binary[digit_idx] == "1":
minimum += 1
binary_array[len(binary) - digit_idx - 1] += 1
return minimum
def reduce_element(binary_array, count, k):
idx = len(binary_array) - 1
while idx > 0:
if count == k:
break
if binary_array[idx] > 0:
binary_array[idx] -= 1
binary_array[idx - 1] += 2
count += 1
else:
idx -= 1
def convert(binary_array):
answer = []
for idx, i in enumerate(binary_array):
if i > 0:
array = [2**idx] * i
if array != []:
answer.extend(array)
return answer
binary = format(n, "b")
minimum = get_min(binary, binary_array)
maximum = n
if k < minimum or k > maximum:
print("NO")
else:
print("YES")
count = minimum
reduce_element(binary_array, count, k)
answer = convert(binary_array)
answer = [str(x) for x in answer]
answer = " ".join(answer)
print(answer) | ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER RETURN VAR FUNC_DEF ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR NUMBER IF VAR VAR IF VAR VAR NUMBER VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER FUNC_DEF ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP LIST BIN_OP NUMBER VAR VAR IF VAR LIST EXPR FUNC_CALL VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL STRING VAR EXPR FUNC_CALL VAR VAR |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.