1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import math

inp = int(input())
a = []
sum = 0
i = 1
b = []
while sum < inp:
    x = bin(i)
    sum += x.count('1')
    a.append(i)
    b.append(x.count('1'))
    i += 1
i = len(a)-1
answ = ''
k = 0
sum = sum - inp
while i >= 0:
    if sum >= (b[i]):
        sum -= b[i]
    else:
        answ += str(a[i]) + ' '
        k+=1
    i -= 1
answ = answ[0:-1]
print(k)
print(answ)