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
28
29
30
31
32
def main(n):
    suma = 0
    i = 1
    tab = []
    while suma<n:
        t=0
        a = bin(i)[2:]
        for j in a:
            t += int(j)
        suma += t
        tab.append(i)
        i+=1
    s = len(tab) -1
    j = 0
    while suma > n:
        l = s-j
        j += 1
        a = bin(tab[l])[2:]
        t = 0
        for r in a:
            t += int(r)
        if (suma - t) >=n:
            suma = suma - t
            tab.remove(tab[l])

    tab = tab[::-1]
    print(len(tab))
    for i in tab:
        print(i,end=' ')

if __name__ == '__main__':  
    main(int(input()))