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
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int pom[35];
ll ile(int liczba)
{
	ll p=0;
	if(liczba>0)
	{
		p+=ile(liczba/2); 
		p+=liczba%2; 
	}
	return p;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll n, sum=0, cnt=0;
	cin>>n;
	while(sum<n){
		cnt++;
		ll help=ile(cnt);
		pom[help]=cnt;
		sum+=help;
	}
	ll repair=sum-n;
	if(repair) cout<<cnt-1<<"\n";
	else cout<<cnt<<"\n";
	for(int i=cnt;i>=1;i--){
		if(i==pom[repair]) continue;
		cout<<i<<" ";
	}
	return 0;
}