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
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 1e6+7;
bool NIEEEEEEEEEEEEEEEEEEEEEEEEEEE[MAXN];

int ile1(int x){
    int ile=0;
    while (x > 0){
        if (x&1){
            ile++;
        }
        x >>= 1;
    }
    return ile;
}

int main(){
    int n;
    cin>>n;
    int suma = 0;
    int wsk = 0;
    while (suma < n){
        wsk++;
        suma += ile1(wsk);
    }
    vector<int>wyn;
    for (int i = wsk; i > 0; i--){
        if (suma - ile1(i) >= n){
            suma -= ile1(i);
        }
        else{
            wyn.push_back(i);
        }
    }
    cout<<wyn.size()<<"\n";
    for (auto i : wyn){
        cout<<i<<" ";
    }
    cout<<"\n";
    return 0;
}