1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
#include <bits/stdc++.h>
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> t(50,0);
	int cnt = 0;
	int i = 1;
	while(cnt < n){
		cnt += __builtin_popcount(i);
		t[__builtin_popcount(i)] = i;
		i++;
	}
	cout << i - 2 + (cnt == n) << "\n";
	for(int j = i - 1; j > 0; j--)
		if(t[cnt - n] != j)
			cout << j << " ";
}