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 <iostream>
#include <vector>
#include <bitset>

using namespace std;

constexpr int N = 2e5 + 7;
vector <int> str;
bitset <N> used;

inline int cnt(int x) {
	int ans = 0;
	while(x) {
		if(x & 1)
			ans++;
		x >>= 1;
	}
	return ans;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n, i = 1, m = 0; cin >> n;
	while(n > 0) {
		str.push_back(cnt(i++));
		n -= str.back();
	}
	i = str.size() - 1; m = str.size();
	while(n < 0) {
		if(n + str[i] <= 0) {
			used[i] = 1;
			n += str[i];
			m--;
		}
		i--;
	}
	cout << m << "\n";
	for(i = (int)str.size() - 1; i >= 0; i--)
		if(!used[i])
			cout << i + 1<< " ";
	cout << "\n";
}