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
n=int(input())
x=0
i=0
list=[]
list.append(0)
while x<n:
    i+=1
    maska=1
    ile=x
    while maska<=i:
        if maska&i:
            x+=1
        maska<<=1
    list.append(x-ile)
ile=i
licz=i
while x>n:
    if x-list[i-1]>=n:
        x-=list[i-1]
        list[i-1]=0
        ile-=1
    i-=1
print(ile)
for i in range(licz,0,-1):
    if list[i]:
        print(i,end=' ')