Problem:
Score : 1000 points

Problem Statement

We will call a string x good if it satisfies the following condition:

Condition: x can be represented as a concatenation of two copies of another string y of length at least 1.

For example, aa and bubobubo are good; an empty string, a, abcabcabc and abba are not good.

Eagle and Owl created a puzzle on good strings.
Find one string s that satisfies the following conditions. It can be proved that such a string always exists under the constraints in this problem.

1 ≤ |s| ≤ 200

Each character of s is one of the 100 characters represented by the integers 1 through 100.

Among the 2^{|s|} subsequences of s, exactly N are good strings.

Constraints

1 ≤ N ≤ 10^{12}

Input

Input is given from Standard Input in the following format:

N

Output

In the first line, print |s|, the length of s.
In the second line, print the elements in s in order, with spaces in between. Any string that satisfies the above conditions will be accepted.

Sample Input 1

7

Sample Output 1

4
1 1 1 1

There are two good strings that appear as subsequences of s: (1,1) and (1,1,1,1). There are six occurrences of (1,1) and one occurrence of (1,1,1,1), for a total of seven.

Sample Input 2

299

Sample Output 2

23
32 11 11 73 45 8 11 83 83 8 45 32 32 10 100 73 32 83 45 73 32 11 10

Solution in C++ (Clang 10.0.0) (judge verdict: Wrong Answer)

#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d>>(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

void comb(vector<vector <long long int> > &v){
  for(int i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(int k = 1;k <v.size();k++){
    for(int j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

vector<vector<long long int> > V(51,vector<long long int>(51,0));
map<ll, pair<ll, vll>> mp;//val -> num


void calc(){
  ll N;std::cin >> N;
  ll idx = 1;
  vll ans;
  while(N){
    //引ける最も大きいもの
    auto itr = --mp.upper_bound(N);
    ll max_num = (*itr).second.first;
    vll add = (*itr).second.second;
    for(int i=0;i<add.size();i++) ans.push_back(idx + add[i]);
    N -= (*itr).first;
    idx+=max_num;
  }
  std::cout << ans.size() << '\n';
  for(int i=0;i<ans.size();i++) std::cout << ans[i] << (i==ans.size()-1?"\n":" ");
}

ll INF = 1000000000000;
int main(int argc, char const *argv[]) {
  comb(V);

  for(ll i=2;i<=100;i++){
    //全部同じ
    ll s = 0;
    for(ll j=2;j<=i;j+=2){
      if(V[i][j] > INF) goto nxt;
      s += V[i][j];
    }
    if(s > INF) break;
    mp.emplace(s, pair<ll, vll>(1, vll(i, 0)));

    if(i>40) continue;
    //2個挟む

    for(int l=0;l<=i;l++){
      for(int r=0;l+r<=i;r++){ //左に何個、右に何個
        ll t = s;
        bool flag = true;
        for(int A=0;A<=l;A++){
          for(int B=0;B<=r&&(i-l-r)>=(A+B);B++){
            if(V[l][A] > INF || V[l][A]*V[r][B]>INF || V[l][A]*V[r][B]*V[i-l-r][A+B] > INF){
              flag = false;
              break;
            }
            t += V[l][A] * V[r][B] * V[i-l-r][A+B];
          }
          if(!flag) break;
        }
        if((t>INF)||(!flag)) continue;
        vll ret(i+2, 0);
        ret[l] = ret[i+1-r] = 1;
        mp.emplace(t, pair<ll, vll>(2, ret));
      }
    }

  }
  nxt:
  /*
  for(auto itr=mp.begin();itr!=mp.end();itr++){
    std::cout << (*itr).first << " " << (*itr).second.first << " " << (*itr).second.second.size() << '\n';
  }
  */
  calc();
  return 0;
}