require 'prime' K = gets.to_i k = K cnt = 0 if K == 0 puts 0 exit end while k % 2 == 0 k /= 2 cnt += 1 end def f(n) n * (n - 1) / 2 end cnt.downto(1) do |x| ng = 0 ok = 10 ** 7 while (ok - ng).abs >= 2 n = (ok + ng) / 2 if k <= f(n) ok = n else ng = n end end if f(ok) == k puts cnt + ok puts [[0] * cnt + [1] * ok].join(' ') exit end cnt -= 1 k *= 2 end