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
#include <bits/stdc++.h>
using namespace std;

vector <long long> suma;
vector <long long> wynik;

void filll(long long x)
{
	suma.push_back(0);
	for (int i=1; suma[i-1] < x; i++)
		suma.push_back(suma[i-1] + __builtin_popcount(i));
}


int main()
{
	long long x, res = 0;
	cin >> x;
	filll(x);
	
	for (int i=suma.size()-1; res < x; i--)
	{
		if (res + suma[i-1] >= x) continue;
		x -= __builtin_popcount(i);
		wynik.push_back(i);
	}
	cout << wynik.size() << '\n';
	for (int i=0; i<wynik.size(); i++)
		cout << wynik[i] << " ";
	
	return 0;
}