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
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(ll i=(ll)a;i<=(ll)b;++i)
#define all(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
const int mxN = 1e6;
int p[mxN+7];

int bs(int n){
    int pocz = 1, kon = mxN;
    while(pocz < kon){
        int m = (pocz+kon)/2;
        if(p[m] < n) pocz = m+1;
        else kon = m;
    }
    return pocz;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n; cin >> n;
    rep(i,1,mxN) p[i] = p[i-1]+__builtin_popcount(i);
    vector<int> ans;
    while(n){
        int k = bs(n);
        ans.pb(k);
        n -= __builtin_popcount(k);
    }
    cout << sz(ans) << "\n";
    for(auto u : ans) cout << u << " ";
        cout << "\n";
}