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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

const int MAKS = 1e6 + 2;

const ll INF = 1e9;

ll tab[MAKS];


int main()
{

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    for(ll i = 1 ; i < MAKS; i++)
    {
        tab[i] = tab[i-1] + __builtin_popcountll(i);
        //cout << tab[i] << " ";
    }



    ll n; cin >> n;
    
    ll ans = 0;
    vector<ll> vec;
    while(n > 0)
    {
        ll l = 0, p = n;
        while(l < p)
        {
            ll m = (l+p)/2;
            //cout << m << " " << tab[m] << "\n";
            if(tab[m] >= n)
            {
                p = m;
            } else
            {
                l = m+1;
            }
        }
        ans ++;
        vec.pb(l);
        n -= __builtin_popcountll(l);
    }
   cout << ans << "\n";
   for (auto it : vec)
       cout << it << " ";


}