1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <bits/stdc++.h>
#define iamspeed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;

int n, t[1000006];
vector<int> V;

int main(){
	iamspeed;
	cin >> n;
	for(int i = 1 ; i <= 120207 ; i++){
		t[i + 1] = t[i] + __builtin_popcount(i);
	}
	for(int i = 120207 ; i >= 0 ; i--){
		if(t[i] < n){
			V.push_back(i);
			n -= __builtin_popcount(i);
		}
	}
	cout << V.size() << endl;
	for(int i = 0 ; i < V.size() ; i++){
		cout << V[i] << " ";
	}
}