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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a;
	cin>>a;
	int x;
	for(x=1;;x++)
    {
        a-=__builtin_popcount(x);
        if(a <= 0)
            break;
    }
    vector<int> v;
    a *= -1;
    for(;x > 0; x--)
    {
        if(__builtin_popcount(x) <= a)
            a -= __builtin_popcount(x);
        else
            v.push_back(x);
    }
    cout<<v.size()<<'\n';
    for(auto x : v)
        cout<<x<<" ";
	return 0;
}