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

int main() {
	const int _size{120207};
	vector <int> bitss(_size);
	int i{}, n;
	do {
		++i;
		bitss[i] = bitss[i-1] + __builtin_popcount(i);
	} while (bitss[i] < 1000000);
	cin >> n;
	vector <int> odp;
	auto end{bitss.end()};
	while (n > 0) {
		odp.push_back((end = lower_bound(bitss.begin(), end, n)) - bitss.begin());
		n -= *end - *(end-1);
	}
	cout << odp.size() << '\n';
	for (auto i : odp)
	    cout << i << ' ';
}