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# (Mono 4.6.2.0) (judge verdict: Wrong Answer)

using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		long n = long.Parse(Console.ReadLine());
    long[] answers;
    int digit = 0;//2進数で何桁か
    int oneCount = 0;//2進数での1の個数
    bool[] isOne;//2進数で上からi桁目は1かどうか
    long memo = 1;
    long nn = n;

    while(true)
    {
      if(n >= memo)
      {
        digit++;
        memo *= 2;
      }else 
      {
        memo /= 2;
        break;
      }
    }

    isOne = new bool[digit];
    for(int i = 0; i < digit; i++)
    {
      if(nn >= memo)
      {
        isOne[i] = true;
        nn -= memo;
        oneCount++;
      }
      memo /= 2;
    }
    oneCount--;

    answers = new long[2*(digit+oneCount)];
    
    long a = 1;
    long b = digit + oneCount;
    memo = digit-1;
    for(int i = 0; i < digit + oneCount; i++)
    {
        if(isOne[memo])
        {
          answers[i] = b;
          b--;
          answers[i+1] = a;
          a++;
          i++;
          memo--;
        }
        else
        {
          answers[i] = a;
          a++;
          memo--;
        }
    }

    for(int i = digit + oneCount; i < 2*(digit + oneCount); i++)
    {
      answers[i] = i+1-(digit + oneCount);//後側を1,2,3,...で埋める
    }

    Console.WriteLine((digit + oneCount)*2);
		Console.WriteLine(string.Join(" ", answers));
	}
}