1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
#include <bits/stdc++.h>
using namespace std;
int main() {
	// freopen("in.	xt", "r", stdin);
	ios::sync_with_stdio(false), cin.tie(0);
	int n, sum = 0;
	cin >> n;
	for(int i = 1; i <= n; i ++) sum += __builtin_popcount(i);
	vector<int> ans;
	for(int i = n; i >= 1; i --) {
		int cur = __builtin_popcount(i);
		if(sum - cur >= n) sum -= cur;
		else ans.emplace_back(i);
	}
	cout << ans.size() << '\n';
	for(int x : ans) cout << x << ' ';
	return 0;
}