1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env python3

max_val = 150 * 1000
bit_cnts = [bin(x).count('1') for x in range(max_val)]
bit_prefs = [0] * max_val

for i in range(max_val):
	bit_prefs[i] = bit_prefs[i - 1] + bit_cnts[i]

n = int(input())
ans = []

cur = max_val
while n:
	while bit_prefs[cur - 1] >= n:
		cur -= 1
	ans.append(cur)
	n -= bit_cnts[cur]

print(len(ans))
print(*ans)