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
n = int(input())

i = 0
s = 0
d = {0: 0}
while s < n:
    i += 1
    s += bin(i).count('1')
    d[i] = s

r = [i]

n -= bin(i).count('1')
i -= 1

while n:
    if d[i - 1] < n:
        n -= bin(i).count('1')
        r += [i]
    i -= 1

print(len(r))
for i in r:
    print(i, end=' ')
print()