Jamie is preparing a Codeforces round. He has got an idea for a problem, but does not know how to solve it. Help him write a solution to the following problem:

Find k integers such that the sum of two to the power of each number equals to the number n and the largest integer in the answer is as small as possible. As there may be multiple answers, you are asked to output the lexicographically largest one. 

To be more clear, consider all integer sequence with length k (a_1, a_2, ..., a_{k}) with $\sum_{i = 1}^{k} 2^{a_{i}} = n$. Give a value $y = \operatorname{max}_{1 \leq i \leq k} a_{i}$ to each sequence. Among all sequence(s) that have the minimum y value, output the one that is the lexicographically largest.

For definitions of powers and lexicographical order see notes.


-----Input-----

The first line consists of two integers n and k (1 ≤ n ≤ 10^18, 1 ≤ k ≤ 10^5) — the required sum and the length of the sequence.


-----Output-----

Output "No" (without quotes) in a single line if there does not exist such sequence. Otherwise, output "Yes" (without quotes) in the first line, and k numbers separated by space in the second line — the required sequence.

It is guaranteed that the integers in the answer sequence fit the range [ - 10^18, 10^18].


-----Examples-----
Input
23 5

Output
Yes
3 3 2 1 0 

Input
13 2

Output
No

Input
1 2

Output
Yes
-1 -1 



-----Note-----

Sample 1:

2^3 + 2^3 + 2^2 + 2^1 + 2^0 = 8 + 8 + 4 + 2 + 1 = 23

Answers like (3, 3, 2, 0, 1) or (0, 1, 2, 3, 3) are not lexicographically largest.

Answers like (4, 1, 1, 1, 0) do not have the minimum y value.

Sample 2:

It can be shown there does not exist a sequence with length 2.

Sample 3:

$2^{-1} + 2^{-1} = \frac{1}{2} + \frac{1}{2} = 1$

Powers of 2:

If x > 0, then 2^{x} = 2·2·2·...·2 (x times).

If x = 0, then 2^{x} = 1.

If x < 0, then $2^{x} = \frac{1}{2^{-x}}$.

Lexicographical order:

Given two different sequences of the same length, (a_1, a_2, ... , a_{k}) and (b_1, b_2, ... , b_{k}), the first one is smaller than the second one for the lexicographical order, if and only if a_{i} < b_{i}, for the first i where a_{i} and b_{i} differ.

Source: codeforces | Difficulty: HARD
Tags: Bit manipulation

Mathematics

Greedy algorithms


Solutions:
import sys, os

def main():
	(n, k) = list(map(int, sys.stdin.readline().split()))
	x = bin(n)[2:]
	if x.count('1') > k:
		print('No')
		return
	ans = [0] * 10 ** 5
	val = len(x) - 1
	idx = len(x) - 1
	cnt = 0
	for i in x:
		if int(i):
			ans[val] = 1
			cnt += 1
		val -= 1
	for i in range(k - cnt):
		ans[idx] -= 1
		ans[idx - 1] += 2
		if ans[idx] == 0:
			idx -= 1
	maxIdx = idx - 1
	minIdx = idx - 1
	nonZeroIdx = idx - 1
	while 1:
		if minIdx < 0 and ans[minIdx] == 0:
			minIdx += 1
			break
		if ans[minIdx]:
			nonZeroIdx = minIdx
		minIdx -= 1
	minIdx = nonZeroIdx
	while 1:
		if ans[maxIdx] > 2 or (ans[maxIdx] == 2 and maxIdx != minIdx):
			ans[minIdx] -= 1
			ans[minIdx - 1] += 2
			ans[maxIdx] -= 2
			ans[maxIdx + 1] += 1
			minIdx -= 1
		else:
			maxIdx -= 1
		if maxIdx <= minIdx:
			break
	print('Yes')
	x = []
	while 1:
		for i in range(ans[idx]):
			x.append(idx)
		idx -= 1
		if idx < 0 and ans[idx] == 0:
			break
	print(' '.join(map(str, x)))

def __starting_point():
	main()
__starting_point()


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)
mod = 998244353
INF = float('inf')
from math import factorial
from collections import Counter, defaultdict, deque
from heapq import heapify, heappop, heappush
from math import log2

def main():
	(n, k) = RL()
	ones = bin(n).count('1')
	if ones > k:
		print('No')
	else:
		res = []
		carr = 0
		pt = -60
		for i in range(60, 0, -1):
			if n >> i & 1:
				ones -= 1
				carr += 1
			if carr * 2 + ones > k:
				res.extend([i] * carr)
				pt = i - 1
				for j in range(pt, -1, -1):
					if n >> j & 1:
						res.append(j)
				break
			carr *= 2
		else:
			if n & 1:
				carr += 1
			now = 0
			while carr * 2 <= k:
				carr *= 2
				now -= 1
			res.extend([now] * carr)
		dif = k - len(res)
		if dif > 0:
			lst = res.pop()
			dif += 1
			now = 1
			pos = lst
			res.extend([lst - i for i in range(1, dif - 1)])
			res.extend([lst - dif + 1] * 2)
		print('Yes')
		print(*res)
main()


ii = lambda : int(input())
kk = lambda : map(int, input().split())
ll = lambda : list(kk())
from math import log
elems = [0] * 126
(n, k) = kk()
c = 0
for i in range(63):
	if n & 2 ** i:
		elems[i] = 1
		c += 1
if c > k:
	print('No')
	exit()
for i in range(63, -63, -1):
	if elems[i]:
		if elems[i] > k - c:
			break
		c += elems[i]
		elems[i - 1] += elems[i] * 2
		elems[i] = 0
prin = []
for i in range(63, -63, -1):
	prin.extend([i] * elems[i])
while len(prin) < k:
	prin[-1] -= 1
	prin.append(prin[-1])
print('Yes')
print(' '.join(map(str, prin)))


import math
(x, k) = list(map(int, input().split()))
kori = k
a = bin(x)
qtz = 0
s = []
for i in range(2, len(a)):
	if a[i] == '1':
		k -= 1
		s.append(1)
	else:
		qtz += 1
		s.append(0)
v = []
for i in range(len(s)):
	if s[i] != 0:
		v.append(len(s) - 1 - i)
if k < 0:
	print('No')
	return
else:
	tam = len(s)
	print('Yes')
	if k > 0:
		p = 0
		while 1:
			if tam - 1 <= p:
				s.append(0)
			if s[p] > k:
				break
			else:
				k -= s[p]
				s[p + 1] += s[p] * 2
				s[p] = 0
				p += 1
		if k > 0:
			j = len(s) - 1
			while k > 0:
				while s[j] == 0:
					j -= 1
				s[j] -= 1
				if j == len(s) - 1:
					s.append(2)
					j += 1
				else:
					s[j + 1] += 2
					j += 1
				k -= 1
		v = []
		for i in range(len(s)):
			for j in range(s[i]):
				v.append(tam - 1 - i)
		print(*v)
	else:
		v = []
		for i in range(len(s)):
			for j in range(s[i]):
				v.append(len(s) - 1 - i)
		print(*v)


from collections import defaultdict

def solve(n, k):
	as_bin = bin(n)[2:]
	cnt = defaultdict(int)
	cnt.update({i: 1 for (i, b) in enumerate(reversed(as_bin)) if b == '1'})
	curr_len = len(cnt)
	curr_pow = len(as_bin) - 1
	if curr_len > k:
		return None
	while True:
		new_len = curr_len + cnt[curr_pow]
		if new_len > k:
			break
		cnt[curr_pow - 1] += 2 * cnt[curr_pow]
		del cnt[curr_pow]
		curr_pow -= 1
		curr_len = new_len
	i = min(cnt.keys())
	while curr_len < k:
		cnt[i] -= 1
		cnt[i - 1] += 2
		curr_len += 1
		i -= 1
	ans = []
	for i in sorted(cnt.keys(), reverse=True):
		ans.extend([i] * cnt[i])
	return ans
(n, k) = [int(v) for v in input().split()]
ans = solve(n, k)
if ans is None:
	print('No')
else:
	print('Yes')
	print(' '.join((str(c) for c in ans)))


read = lambda : map(int, input().split())
(n, k) = read()
b = bin(n)[2:]
bl = len(b)
k -= b.count('1')
if k < 0:
	print('No')
	return
print('Yes')
m = -2
a = {}
for _ in range(bl):
	if b[_] == '1':
		a[bl - _ - 1] = 1
		if m is -2:
			m = bl - _ - 1
while k > 0:
	if k >= a[m]:
		k -= a[m]
		a[m - 1] = a.get(m - 1, 0) + a[m] * 2
		a.pop(m)
		m -= 1
	else:
		break
m = min(a.keys())
while k > 0:
	k -= 1
	if a[m] is 1:
		a.pop(m)
	else:
		a[m] -= 1
	a[m - 1] = a.get(m - 1, 0) + 2
	m -= 1
for k in sorted(list(a.keys()), reverse=True):
	print('%d ' % k * a[k], end='')


import math
import random
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
import sys
from collections import defaultdict
mod = 10 ** 9 + 7
mod1 = 998244353
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class TreeNode:

	def __init__(self, k, v):
		self.key = k
		self.value = v
		self.left = None
		self.right = None
		self.parent = None
		self.height = 1
		self.num_left = 1
		self.num_total = 1

class AvlTree:

	def __init__(self):
		self._tree = None

	def add(self, k, v):
		if not self._tree:
			self._tree = TreeNode(k, v)
			return
		node = self._add(k, v)
		if node:
			self._rebalance(node)

	def _add(self, k, v):
		node = self._tree
		while node:
			if k < node.key:
				if node.left:
					node = node.left
				else:
					node.left = TreeNode(k, v)
					node.left.parent = node
					return node.left
			elif node.key < k:
				if node.right:
					node = node.right
				else:
					node.right = TreeNode(k, v)
					node.right.parent = node
					return node.right
			else:
				node.value = v
				return

	@staticmethod
	def get_height(x):
		return x.height if x else 0

	@staticmethod
	def get_num_total(x):
		return x.num_total if x else 0

	def _rebalance(self, node):
		n = node
		while n:
			lh = self.get_height(n.left)
			rh = self.get_height(n.right)
			n.height = max(lh, rh) + 1
			balance_factor = lh - rh
			n.num_total = 1 + self.get_num_total(n.left) + self.get_num_total(n.right)
			n.num_left = 1 + self.get_num_total(n.left)
			if balance_factor > 1:
				if self.get_height(n.left.left) < self.get_height(n.left.right):
					self._rotate_left(n.left)
				self._rotate_right(n)
			elif balance_factor < -1:
				if self.get_height(n.right.right) < self.get_height(n.right.left):
					self._rotate_right(n.right)
				self._rotate_left(n)
			else:
				n = n.parent

	def _remove_one(self, node):
		replacement = node.left or node.right
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = replacement
			else:
				node.parent.right = replacement
			replacement.parent = node.parent
			node.parent = None
		else:
			self._tree = replacement
			replacement.parent = None
		node.left = None
		node.right = None
		node.parent = None
		self._rebalance(replacement)

	def _remove_leaf(self, node):
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = None
			else:
				node.parent.right = None
			self._rebalance(node.parent)
		else:
			self._tree = None
		node.parent = None
		node.left = None
		node.right = None

	def remove(self, k):
		node = self._get_node(k)
		if not node:
			return
		if AvlTree._is_leaf(node):
			self._remove_leaf(node)
			return
		if node.left and node.right:
			nxt = AvlTree._get_next(node)
			node.key = nxt.key
			node.value = nxt.value
			if self._is_leaf(nxt):
				self._remove_leaf(nxt)
			else:
				self._remove_one(nxt)
			self._rebalance(node)
		else:
			self._remove_one(node)

	def get(self, k):
		node = self._get_node(k)
		return node.value if node else -1

	def _get_node(self, k):
		if not self._tree:
			return None
		node = self._tree
		while node:
			if k < node.key:
				node = node.left
			elif node.key < k:
				node = node.right
			else:
				return node
		return None

	def get_at(self, pos):
		x = pos + 1
		node = self._tree
		while node:
			if x < node.num_left:
				node = node.left
			elif node.num_left < x:
				x -= node.num_left
				node = node.right
			else:
				return (node.key, node.value)
		raise IndexError('Out of ranges')

	@staticmethod
	def _is_left(node):
		return node.parent.left and node.parent.left == node

	@staticmethod
	def _is_leaf(node):
		return node.left is None and node.right is None

	def _rotate_right(self, node):
		if not node.parent:
			self._tree = node.left
			node.left.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.left
			node.left.parent = node.parent
		else:
			node.parent.right = node.left
			node.left.parent = node.parent
		bk = node.left.right
		node.left.right = node
		node.parent = node.left
		node.left = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	def _rotate_left(self, node):
		if not node.parent:
			self._tree = node.right
			node.right.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.right
			node.right.parent = node.parent
		else:
			node.parent.right = node.right
			node.right.parent = node.parent
		bk = node.right.left
		node.right.left = node
		node.parent = node.right
		node.right = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	@staticmethod
	def _get_next(node):
		if not node.right:
			return node.parent
		n = node.right
		while n.left:
			n = n.left
		return n

class SegmentTree1:

	def __init__(self, data, default=300006, func=lambda a, b: min(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: a + b):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD

def powm(a, n, m):
	if a == 1 or n == 0:
		return 1
	if n % 2 == 0:
		s = powm(a, n // 2, m)
		return s * s % m
	else:
		return a * powm(a, n - 1, m) % m

def sort_list(list1, list2):
	zipped_pairs = zip(list2, list1)
	z = [x for (_, x) in sorted(zipped_pairs)]
	return z

def product(l):
	por = 1
	for i in range(len(l)):
		por *= l[i]
	return por

def binarySearchCount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = int((right + left) / 2)
		if arr[mid] < key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

def countdig(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def binary(x, length):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y

def countGreater(arr, n, k):
	l = 0
	r = n - 1
	leftGreater = n
	while l <= r:
		m = int(l + (r - l) / 2)
		if arr[m] > k:
			leftGreater = m
			r = m - 1
		else:
			l = m + 1
	return n - leftGreater

class TrieNode:

	def __init__(self):
		self.children = [None] * 26
		self.isEndOfWord = False

class Trie:

	def __init__(self):
		self.root = self.getNode()

	def getNode(self):
		return TrieNode()

	def _charToIndex(self, ch):
		return ord(ch) - ord('a')

	def insert(self, key):
		pCrawl = self.root
		length = len(key)
		for level in range(length):
			index = self._charToIndex(key[level])
			if not pCrawl.children[index]:
				pCrawl.children[index] = self.getNode()
			pCrawl = pCrawl.children[index]
		pCrawl.isEndOfWord = True

	def search(self, key):
		pCrawl = self.root
		length = len(key)
		for level in range(length):
			index = self._charToIndex(key[level])
			if not pCrawl.children[index]:
				return False
			pCrawl = pCrawl.children[index]
		return pCrawl != None and pCrawl.isEndOfWord

class Node:

	def __init__(self, data):
		self.data = data
		self.count = 0
		self.left = None
		self.right = None

class BinaryTrie:

	def __init__(self):
		self.root = Node(0)

	def insert(self, pre_xor):
		self.temp = self.root
		for i in range(31, -1, -1):
			val = pre_xor & 1 << i
			if val:
				if not self.temp.right:
					self.temp.right = Node(0)
				self.temp = self.temp.right
				self.temp.count += 1
			if not val:
				if not self.temp.left:
					self.temp.left = Node(0)
				self.temp = self.temp.left
				self.temp.count += 1
		self.temp.data = pre_xor

	def query(self, xor):
		self.temp = self.root
		for i in range(31, -1, -1):
			val = xor & 1 << i
			if not val:
				if self.temp.left and self.temp.left.count > 0:
					self.temp = self.temp.left
				elif self.temp.right:
					self.temp = self.temp.right
			elif self.temp.right and self.temp.right.count > 0:
				self.temp = self.temp.right
			elif self.temp.left:
				self.temp = self.temp.left
			self.temp.count -= 1
		return xor ^ self.temp.data
(n, k) = map(int, input().split())
t = 1
c = 0
while t <= n:
	t *= 2
	c += 1
t //= 2
c -= 1
l = []
l1 = []
while n > 0:
	if t <= n:
		l.append(c)
		l1.append(-c)
		n -= t
	else:
		t //= 2
		c -= 1
if k < len(l):
	print('No')
elif k == len(l):
	print('Yes')
	l.sort(reverse=True)
	print(*l)
else:
	print('Yes')
	heapq.heapify(l1)
	while len(l1) < k:
		e = heapq.heappop(l1)
		heapq.heappush(l1, e + 1)
		heapq.heappush(l1, e + 1)
	l1.sort()
	l1 = [-l1[i] for i in range(len(l1))]
	ma = max(l1)
	heapq.heapify(l1)
	ans = []
	while len(l1) != 0:
		e = heapq.heappop(l1)
		if len(l1) == 0:
			l1.append(e)
			break
		e1 = heapq.heappop(l1)
		if e1 == e and e != ma:
			heapq.heappush(l1, e + 1)
		else:
			ans.append(e)
			heapq.heappush(l1, e1)
	for i in l1:
		ans.append(i)
	heapq.heapify(ans)
	while len(ans) < k:
		e = heapq.heappop(ans)
		heapq.heappush(ans, e - 1)
		heapq.heappush(ans, e - 1)
	ans.sort(reverse=True)
	print(*ans)


from sys import stdin, stdout
from decimal import Decimal
(n, k) = map(int, stdin.readline().split())
s = list(map(int, list(bin(n)[2:])))
ans = {}
pw = len(s) - 1
for i in range(len(s)):
	if s[i]:
		ans[len(s) - i - 1] = 1
k -= s.count(1)
if k < 0:
	stdout.write('No')
else:
	for i in range(pw, -100, -1):
		if i in ans and ans[i] <= k:
			if i - 1 in ans:
				ans[i - 1] += 2 * ans[i]
			else:
				ans[i - 1] = 2 * ans[i]
			k -= ans[i]
			ans[i] = 0
		elif i in ans and ans[i] > k:
			break
	if k:
		ind = min(list(ans.keys()))
		ans[ind] -= 1
		ind -= 1
		for i in range(k):
			if i + 1 == k:
				if ind in ans:
					ans[ind] += 2
				else:
					ans[ind] = 2
			elif ind in ans:
				ans[ind] += 1
			else:
				ans[ind] = 1
			ind -= 1
	stdout.write('Yes\n')
	values = sorted(list(ans.keys()), reverse=True)
	for v in values:
		if ans[v]:
			stdout.write(' '.join(list(map(str, [v for i in range(ans[v])]))) + ' ')


(n, k) = map(int, input().split())
cnt = [0] * 200010
ans = ''
for i in range(64):
	if n >> i & 1:
		k -= 1
		cnt[i] = 1
if k < 0:
	print('No')
else:
	print('Yes')
	for i in range(64, -64, -1):
		if k >= cnt[i]:
			cnt[i - 1] += cnt[i] * 2
			k -= cnt[i]
			cnt[i] = 0
		else:
			break
	for i in range(-64, 64):
		if cnt[i]:
			while k:
				cnt[i] -= 1
				cnt[i - 1] += 2
				i -= 1
				k -= 1
			break
	for i in range(64, -100010, -1):
		ans += (str(i) + ' ') * cnt[i]
	print(ans)


(n, k) = map(int, input().split())
a = list(bin(n))
a = a[2:]
b = []
for i in range(100005):
	b.append(0)
l = len(a)
c = 0
for i in range(l):
	if a[i] == '1':
		b[65 - (l - i - 1)] = 1
		c += 1
		lini = 65 - (l - i - 1)
if c <= k:
	gfati = 0
	for i in range(129):
		if gfati == 1:
			break
		if c == k:
			break
		if b[i] == 0:
			continue
		else:
			if i > lini:
				lini = i
			if c + b[i] <= k:
				b[i + 1] += 2 * b[i]
				c += b[i]
				b[i] = 0
			else:
				gfati = 1
	if 1:
		for i in range(lini, 1000005, 1):
			if c == k:
				break
			if b[i] != 0:
				if c + 1 <= k:
					b[i] -= 1
					c += 1
					b[i + 1] += 2
	print('Yes')
	for i in range(100005):
		if b[i] != 0:
			for j in range(b[i]):
				print(65 - i, end=' ')
else:
	print('No')


(n, k) = map(int, input().split())
bits = [0 for i in range(128)]
tmp = n
sumBits = 0
for i in range(64):
	if tmp % 2 == 1:
		bits[63 - i] = 1
		sumBits += 1
	tmp = tmp >> 1
if sumBits > k:
	print('No')
elif sumBits == k:
	print('Yes')
	res = []
	for i in range(63, -1, -1):
		if bits[63 - i] == 1:
			res.append(i)
	print(*res)
else:
	ind = 0
	while k != sumBits:
		if bits[ind] != 0:
			if bits[ind] <= k - sumBits:
				bits[ind + 1] += 2 * bits[ind]
				sumBits += bits[ind]
				bits[ind] = 0
			else:
				break
		ind += 1
	if k != sumBits:
		for i in range(127, -1, -1):
			if bits[i] != 0:
				bits[i] -= 1
				first = i + 1
				break
		if k - sumBits < 128 - first:
			for i in range(first, k - sumBits + first):
				bits[i] = 1
			bits[k - sumBits + first - 1] = 2
		else:
			for i in range(first, 128):
				bits[i] = 1
			bits += [1] * (k - sumBits + first - 128)
			bits[-1] = 2
	print('Yes')
	res = []
	for i in range(len(bits)):
		if bits[i] != 0:
			res += [63 - i] * bits[i]
	print(*res)


from collections import Counter
bits = (10 ** 18).bit_length()
(n, k) = map(int, input().split())
num = Counter((i for i in range(bits) if n >> i & 1))
k -= len(num)
if k >= 0:
	print('Yes')
	for i in range(bits, -bits, -1):
		if num[i] > k:
			break
		num[i - 1] += num[i] * 2
		k -= num.pop(i, 0)
	i = next(filter(num.get, range(-bits, bits)))
	for k in range(k):
		num[i] -= 1
		num[i - 1] += 2
		i -= 1
	s = sorted(num.elements(), reverse=True)
	print(' '.join(map(str, s)))
else:
	print('No')


inp = lambda : map(int, input().split())
(n, k) = inp()
n2 = n
a = [0] * 100
i = 0
while n2 > 0:
	a[i] = n2 % 2
	n2 //= 2
	i += 1
cnt = i - 1
cnt2 = cnt
sum = 0
arr = [0] * (10 ** 7 + 1)
q = [0] * (10 ** 7 + 1)
for i in range(cnt, -1, -1):
	sum += a[i]
	q[i] = a[cnt - i]
if sum > k:
	print('No')
	quit()
k2 = k - sum
beg = 0
while k2 > 0:
	if q[beg] <= k2:
		k2 -= q[beg]
		q[beg + 1] += 2 * q[beg]
		q[beg] = 0
		beg += 1
	else:
		break
cnt += 1000
while q[cnt] == 0:
	cnt -= 1
while k2 > 0:
	q[cnt] -= 1
	q[cnt + 1] += 2
	cnt += 1
	k2 -= 1
print('Yes')
for i in range(beg, cnt + 1):
	for j in range(1, q[i] + 1):
		print(cnt2 - i, '', end='')


(n, m) = list(map(int, input().split()))
max_pows = -1
temp = n
list_pow = {}
while temp > 0:
	factor = -1
	index = 1
	while index <= temp:
		index *= 2
		factor += 1
	temp = temp - index // 2
	if max_pows == -1:
		max_pows = factor
	list_pow[factor] = 1
min_pows = factor
if len(list_pow) > m:
	print('No')
else:
	pow_count = len(list_pow)
	cur_pow = max_pows
	while pow_count + list_pow[cur_pow] <= m:
		list_pow[cur_pow] -= 1
		if cur_pow - 1 in list_pow:
			list_pow[cur_pow - 1] += 2
		else:
			list_pow[cur_pow - 1] = 2
		pow_count += 1
		if list_pow[cur_pow] == 0:
			cur_pow -= 1
		min_pows = min(min_pows, cur_pow)
	cur_pow = min_pows
	while pow_count != m:
		list_pow[cur_pow] -= 1
		if cur_pow - 1 in list_pow:
			list_pow[cur_pow - 1] += 2
		else:
			list_pow[cur_pow - 1] = 2
		pow_count += 1
		cur_pow -= 1
	print('Yes')
	cur_count = 0
	while cur_count != m:
		if max_pows in list_pow:
			for i in range(list_pow[max_pows]):
				cur_count += 1
				print(max_pows, end=' ')
		max_pows -= 1


from collections import *
(N, K) = list(map(int, input().split()))
a = deque()
for i in range(60):
	if N & 1 << i:
		a.appendleft([i, 1])
k = len(a)
if k > K:
	print('No')
	return
while k + a[0][1] <= K:
	(e, c) = a.popleft()
	if len(a) == 0 or a[0][0] != e - 1:
		a.appendleft([e - 1, 0])
	a[0][1] += 2 * c
	k += c
if K - k:
	a[-1][1] -= 1
	count = K - k
	first = a[-1][0] - 1
	last = first - count + 1
	for i in range(first, last - 1, -1):
		a.append([i, 1])
	a.append([last, 1])
	k = K
ans = []
for i in a:
	ans += [i[0]] * i[1]
ans = list(map(str, ans))
ans = 'Yes\n' + ' '.join(ans)
print(ans)


def solve(n, k):
	bn = binary(n)
	if k < len(bn):
		return 'No'
	cur_dec = len(bn)
	next_dec = cur_dec + 1
	while True:
		if k < next_dec:
			dif = k - cur_dec
			bn = list(reversed(bn))
			for _ in range(dif):
				e = bn.pop()
				bn += [e - 1, e - 1]
			return 'Yes\n' + ' '.join(map(str, bn))
		cur_dec = next_dec
		cnt = bn.count(bn[-1])
		bn = bn[:-cnt] + [bn[-1] - 1] * (cnt * 2)
		next_dec = cur_dec + bn.count(bn[-1])

def binary(x):
	out = []
	for i in reversed(list(range(64 + 1))):
		if x >= 2 ** i:
			x -= 2 ** i
			out.append(i)
	return list(reversed(out))

def __starting_point():
	(n, k) = list(map(int, input().split()))
	print(solve(n, k))
__starting_point()


(h, k) = [int(n) for n in input().split(' ')]
level = 0
ret = []
while h > 0:
	if h % 2 == 0:
		h //= 2
		level += 1
	else:
		ret.append(level)
		h -= 1
if len(ret) > k:
	print('No')
else:
	print('Yes')
	cntnum = {}
	maxn = ret[0]
	minn = ret[0]
	total_len = len(ret)
	for i in ret:
		if i not in cntnum:
			cntnum[str(i)] = 0
		cntnum[str(i)] += 1
		if maxn < i:
			maxn = i
		if minn > i:
			minn = i
	while total_len <= k:
		if total_len + cntnum[str(maxn)] <= k:
			if str(maxn - 1) not in cntnum:
				cntnum[str(maxn - 1)] = 0
			cntnum[str(maxn - 1)] += 2 * cntnum[str(maxn)]
			total_len += cntnum[str(maxn)]
			cntnum[str(maxn)] = 0
			maxn -= 1
			minn = min(minn, maxn)
		else:
			break
	while total_len < k:
		cntnum[str(minn - 1)] = 2
		cntnum[str(minn)] -= 1
		minn -= 1
		total_len += 1
	ans = []
	for (num, v) in cntnum.items():
		for i in range(0, v):
			ans.append(int(num))
	ans.sort(reverse=True)
	print(' '.join([str(x) for x in ans]))


(n, k) = map(int, input().split())
s = list()
b = list()
base = 0
while n > 0:
	s.append(n % 2)
	b.append(base)
	n //= 2
	base += 1
s.reverse()
b.reverse()
t = sum(s)
if t > k:
	print('No')
	exit(0)
pos = 0
while t < k:
	if pos + 1 == len(s):
		s.append(0)
		b.append(b[-1] - 1)
	if t + s[pos] <= k:
		t += s[pos]
		s[pos + 1] += 2 * s[pos]
		s[pos] = 0
		pos += 1
	else:
		for i in range(len(s) - 1, -1, -1):
			if s[i] > 0:
				while t < k:
					if i + 1 == len(s):
						s.append(0)
						b.append(b[-1] - 1)
					s[i] -= 1
					s[i + 1] += 2
					t += 1
					i += 1
				break
res = list()
for i in range(len(s)):
	for j in range(s[i]):
		res.append(b[i])
print('Yes')
print(' '.join(map(str, res)))


(n, k) = map(int, input().split())
c = [0] * 200010
k -= c.count(1)
for i in range(64):
	if n >> i & 1:
		k -= 1
		c[i] = 1
if k < 0:
	print('No')
else:
	print('Yes')
	for i in range(64, -64, -1):
		if k >= c[i]:
			c[i - 1] += c[i] * 2
			k -= c[i]
			c[i] = 0
		else:
			break
	for i in range(-64, 64):
		if c[i]:
			while k:
				c[i] -= 1
				c[i - 1] += 2
				i -= 1
				k -= 1
			break
	for i in range(64, -100010, -1):
		print('{} '.format(i) * c[i], end='')


from heapq import heapify, heappop, heappush
(n, k) = map(int, input().split())
heap1 = []
heap2 = []
MAX = int(100000.0) + 10
s = []
heapify(heap1)
heapify(heap2)
i = 0
cnt = 0
while 1 << i <= n:
	if 1 << i & n:
		heappush(heap1, -i)
		heappush(heap2, -i)
		cnt += 1
	i += 1
if cnt > k:
	print('NO')
	exit()
temp = cnt
while temp < k:
	x = -1 * heappop(heap1) - 1
	heappush(heap1, -x)
	heappush(heap1, -x)
	temp += 1
temp = heap1[0] * -1
while cnt < k:
	if temp == heap2[0] * -1:
		break
	x = heappop(heap2) * -1 - 1
	heappush(heap2, -x)
	heappush(heap2, -x)
	cnt += 1
while heap2:
	s.append(heappop(heap2) * -1)
while cnt < k:
	s[-1] = s[-1] - 1
	s.append(s[-1])
	cnt += 1
print('YES')
print(*s)


def count1(n):
	count = 0
	while n > 0:
		n &= n - 1
		count += 1
	return count

def find(n, k):
	ones = count1(n)
	l = list()
	if ones > k:
		print('No')
	else:
		tmp = n
		pow2 = 1
		index = 0
		while tmp > 0:
			if tmp % 2 == 1:
				l.append(index)
			tmp //= 2
			pow2 *= 2
			index += 1
		length = len(l)
		while length < k:
			m = max(l)
			c = l.count(m)
			rem = [i for i in l if i < m]
			if k - length >= c:
				rem += [m - 1] * (2 * c)
				l = rem
				length = len(l)
			else:
				mini = min(l)
				to_fill = k - length
				l.remove(mini)
				for i in range(to_fill):
					mini -= 1
					l.append(mini)
				l.append(mini)
				break
		print('Yes')
		l.sort(reverse=True)
		print(' '.join([str(i) for i in l]))
(nn, kk) = list(map(int, input().strip().split()))
find(nn, kk)