Problem:
Score : 300 points

Problem Statement

Given an integer N, find the base -2 representation of N.

Here, S is the base -2 representation of N when the following are all satisfied:

S is a string consisting of 0 and 1.

Unless S = 0, the initial character of S is 1.

Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N.

It can be proved that, for any integer M, the base -2 representation of M is uniquely determined.

Constraints

Every value in input is integer.

-10^9 \leq N \leq 10^9

Input

Input is given from Standard Input in the following format:

N

Output

Print the base -2 representation of N.

Sample Input 1

-9

Sample Output 1

1011

As (-2)^0 + (-2)^1 + (-2)^3 = 1 + (-2) + (-8) = -9, 1011 is the base -2 representation of -9.

Sample Input 2

123456789

Sample Output 2

11000101011001101110100010101

Sample Input 3

0

Sample Output 3

0

Solution in C++14 (GCC 5.4.1) (judge verdict: Accepted)

#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(long long i=(long long)(a);i<(long long)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	ll n, d;

	cin>>n;

	if(n==0){
		cout<<0<<endl;
		return 0;
	}

	vll a, b;

	rep(i, 40){
		ll temp=pow(-2.0, (double)i);
		if(temp>0){
			a.push_back(temp);
		} else{
			b.push_back(temp);
		}
	}
	sort(all(a)); sort(all(b));
	reverse(all(b));

	vll asum(a.size()+1, 0), bsum(b.size()+1, 0);

	rep(i, a.size()){
		asum[i+1]=asum[i]+a[i];
		bsum[i+1]=bsum[i]+b[i];
		//cout<<bsum[i]<<endl;
	}

	rep(i, bsum.size()){
		bsum[i]*=(-1);
	}

	vll::iterator itr;
	if(n>0){
		itr=lower_bound(all(asum), n);
		d=(ll)(itr-asum.begin())*2-1;
	}else{
		itr=lower_bound(all(bsum), -n);
		d=(ll)(itr-bsum.begin())*2;
	}

	n-=pow(-2.0, (double)(d-1));

	vb ans(d, false);

	ans[d-1]=true;

	while(n!=0){
		if(n>0){
			itr=lower_bound(all(asum), n);
			d=(ll)(itr-asum.begin())*2-1;
		} else{
			itr=lower_bound(all(bsum), -n);
			d=(ll)(itr-bsum.begin())*2;
		}
		n-=pow(-2.0, (double)(d-1));
		//cout<<n<<","<<d<<endl;
		ans[d-1]=true;
	}
	reprev(i, ans.size()) cout<<ans[i];
	cout<<endl;
}