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
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0), cin.tie(0);
#define ll long long
#define endl '\n';
#define chuj 500000
using namespace std;
const int N = 1e6+69, mini = -1e9, maks = 1e9;
int tab[N], pref[N];



void solve(){
    int n, w, res=0, m;
    stack<int> s;
    cin>>n;
    m = n;
    w=__builtin_popcount(n);
    for(int i = 1; i <= chuj; i++){
        pref[i] += pref[i-1] + __builtin_popcount(i);
    }
    vector<int> v;

    int k;
    for(int i = chuj; i > 0; i--){
        if(pref[i]
           <
           m){
            v.push_back(i+1);
            m-=__builtin_popcount(i+1);
        }
    }
    if(m == 1)v.push_back(1);
    cout<<v.size()<<endl;
    for(int i = 0; i < v.size(); i++){
        cout<<v[i]<<' ';
    }
}

int main()
{
    fast;
    solve();
    return 0;
}