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 (Python):
N = int(input())

ans = ''
while N != 0:
    if N % 2 == 0:
        ans = '0' + ans
    else:
        N -= 1
        ans = '1' + ans
    N /= -2

if ans == '':
    print(0)
else:
    print(ans)

Solution (Python):
N = int(input())

ans = ''
while N != 0:
    r = N % 2
    N = (N - r) // (-2)
    ans += str(r)

ans = ans[::-1]
if ans == '':
    ans = '0'

print(ans)

Solution (Python):

def f(n, k):
    if n == 0:
        return []
    r = n % k
    return f(-(n - r) // k, k) + [r]

N = int(input())
l = f(N, 2)
if l:
    print("".join(map(str, l)))
else:
    print(0)

Solution (Python):
ans = ''
n = int(input())
b = 1
while True:
  if n %(-2 * b) == 0:
    ans  = '0' +  ans 
  else:
    ans = '1' +  ans
    n -= b
  if n == 0:
    break
  b *= -2
print(ans)

Solution (Python):
N = int(input())


if N == 0:
    print(0)
    exit()

def num_muls(n):
    ans = 0
    while (n >> ans) & 1 == 0:
        ans += 1
    return ans

ans = ''
count = 0

while N != 0:
    m = num_muls(N)
    
    if m > 0:
        
        ans = '0'*m + ans
        N //= (2**m)
        count += m
        
    else:
        
        ans = '1' + ans
        N -= (-1)**count
        N //= 2
        count += 1
        

print(ans)

Solution (Python):
a = int(input())

if a==0:
    print(a)
    quit()
i=0
ans=0
while(a):
    amari = a%-2
    if amari<0:
        amari=1
        ans+=10**i
    a=(a-amari)/-2
    i+=1
print(ans)

Solution (Python):
a = int(input())
if a == 0:
    print("0")
else:
    digits = []*10
    base = 1
    i = 0
    while a != 0:
        if a%(base*2) == 0:
            digits.append('0')
        else:
            digits.append('1')
            a -= base
        i += 0
        base *= -2
    print(''.join(digits[::-1]))

Solution (Python):
import numpy as np
array=np.array([[0,1]])
cnt=1
N=int(input())
import sys

if 0<=N<=1:
    print(N)
    sys.exit()

while(1):
    array=np.append(array,np.array([[((-2)**cnt)+np.min(array),((-2)**cnt)+np.max(array)]]),axis=0)
    if array[-1][0]<=N<=array[-1][1]:
        break
    else:
        cnt+=1
for i in range(len(array)-1,0,-1):
    if array[i][0]<=N<=array[i][1]:
        print(1,end="")
        N=N-(-2)**(i)
    else:
        print(0,end="")
print(N)

Solution (Python):

N = int(input())
OriN = N

bul = True
cnt = 0
lis = []

while bul:

    if N % (2 ** (cnt + 1)) == 0:
        lis.append(0)

    else:
        lis.append(1)
        N = N - ( (-2) ** cnt )


    now = 0
    for i in range(len(lis)):

        now += lis[i] * ((-2) ** i )

    if now == OriN:
        break

    cnt += 1




ans = ""
for i in lis:

    ans = str(i) + ans

print (ans)

Solution (Python):
n = int(input())
ans = ""
if n==0:
  print(0)
  exit()
while n!=0:
  n, r = n//(-2), n%(-2)
  if r<0:
    r += 2
    n += 1
  ans += str(r)
print(ans[::-1])

Solution (Python):
n = int(input())
def reversed_bit(N):
    if N == 1:
        return [1]
    elif N == 0:
        return [0]
    elif N % 2 == 0:
        return reversed_bit(N / (-2)) + [0]
    else:
        return reversed_bit((N-1) / (-2)) + [1]
m = ""
for i in range(len(reversed_bit(n))):
    m += str(reversed_bit(n)[i])
print(str(m))

Solution (Python):
N = int(input())

dev = -2
ans = ''
Q = N

if Q == 0:
    ans += '0'
    
while Q != 0:

    if Q%dev != 0:
        Q -= 1
        ans = '1' + ans
    else:
        ans = '0' + ans

    Q = Q//dev


print(ans)

Solution (Python):
n = int(input())

ans = ""

if n == 0 : ans ="0"

while n != 0:
    if n % 2 != 0:
        ans = "1" + ans
        n -=1
    else:
        ans = "0" + ans
    
    n /= -2
    
print(ans)

Solution (Python):
N = int(input())
if N == 0:
    print(0)
    exit()
res = ""
while N != 1:
    res += str(abs(N%(-2)))
    if N%2 == 0:
        N //= -2
    else:
        N //= -2
        N += 1
res += '1'
print(res[::-1])

Solution (Python):
N = int(input())
ans = ''
if N == 0:
    print(0)
    quit()
while N != 1:
    if abs(N) % 2 == 1:
        ans += '1'
        N = (N-1) // -2
    else:
        ans += '0'
        N = N // -2
ans += '1'
print(ans[::-1])

Solution (Python):
N = int(input())
S = ""
if N == 1:
    print("1")
elif N == 0:
    print("0")
else:
    while N != 1:
        if abs(N)%2 == 1:
            N = (N-1)//(-2)
            S += "1"
        else:
            N = N//(-2)
            S += "0"
    S += "1"
    print(S[::-1])

Solution (Python):
n = int(input())
ans = ""
for i in range(10000):
    if not n:
        break
    if n % (-2)**(i+1):
        ans += "1"
        n -= (-2)**i
    else:
        ans += "0"
if ans == "":
    ans = "0"
print(ans[::-1])

Solution (Python):
N = int(input())
if N == 0:
  ans = 0
else:
  ans = ""
  while N != 1:
    if N % (-2) == 0:
      ans = "0" + ans
      N = N / (-2)
    else:
      ans = "1" + ans
      N = (N-1) / (-2)
  ans = "1" + ans
print(ans)

Solution (Python):
n=int(input())
if n==0:print(0)
else:
    a=""
    while n!=0:
        k=n%4
        if k==0:a="00"+a
        elif k==1:
            a="01"+a
            n-=1
        elif k==2:
            a="10"+a
            n+=2
        elif k==3:
            a="11"+a
            n+=1
        n//=4
    print(int(a))

Solution (Python):


N = int(input())
ans = ""
while(N != 0):
    if N%2 !=0:
        N -=1
        ans ="1"+ans
    else:
        ans ="0"+ans
    N = N //(-2)
print(ans if ans!="" else 0)

Solution (Python):
from bisect import bisect_left
def inpl(): return list(map(int, input().split()))
N = int(input())

U = [0]*32
L = [0]*32
U[0] = 1
for i in range(1, 32):
    if i%2:
        U[i] = U[i-1]*1
        L[i] = L[i-1] + 2**i
    else:
        U[i] = U[i-1] + 2**i
        L[i] = L[i-1] * 1

searched = [0]*32
while N:
    if N < 0:
        d = bisect_left(L, -N)
        assert searched[d] != 1
        searched[d] = 1
        N += 2**d
    else:
        d = bisect_left(U, N)
        assert searched[d] != 1
        searched[d] = 1
        N -= 2**d
print("0"*(sum(searched) == 0) + "".join(map(str, searched)).rstrip("0")[::-1])

Solution (Python):
N = int(input())
 
ans = 0
base = 1
while N != 0:
  p = abs(N%(-2))
  N = (N-p)//(-2)
  ans += p*base
  base *= 10
print(ans)

Solution (Python):
n = int(input())

ans = []

def base_mi2(x):
    if x == 1:
        ans.insert(0,'1')
        return ans
    else:
        if x % 2 != 0:
            ans.insert(0,'1')
            return base_mi2(x//(-2)+1)
        else:
            ans.insert(0,'0')
            return base_mi2(x//(-2))

if n == 0:
    print('0')
else:
    print(''.join(base_mi2(n)))

Solution (Python):
N = int(input())

def F(N):
  if N == 0:
    return ''
  if N%2 == 0:
    return F(N//(-2)) + '0'
  return F((N-1)//(-2)) + '1'

answer = F(N)
if N == 0:
  answer = '0'
print(answer)

Solution (Python):
N = int(input())

ans = 0
base = 1
N = -N
while N != 0:
    p = abs(N%(-2))
    N = (N+p)//(-2)
    ans += p*base
    base *= 10
print(ans)

Solution (Python):
def solve(n):
    if n==0:
        return '0'
    N=-n
    ans=[]
    while N!=0:
        q,r=divmod(N,-2)
        N=q
        ans.append(-r)
    return ''.join(str(x) for x in (reversed(ans)))

print(solve(int(input())))

Solution (Python):
def solve(N):
    if N == 0:
        return "0"
    n = -N
    result = []
    while n != 0:
        q, r = divmod(n, -2)
        
        n = q
        result.append(-r)
    return "".join(str(x) for x in reversed(result))

print(solve(int(input())))

Solution (Python):
import math

N = int(input())

if N == 0:
    print(0)
    exit()

S = []
while True:
    if N == 1:
        S.append(1)
        break
    tmp = N%2
    S.append(tmp)
    if tmp == 1:
        N -= 1
    N = int(N/(-2))

s = map(str, reversed(S))
ans = ''.join(s)
print(ans)

Solution (Python):
N = int(input())

def solve(N):
    s = ''
    if N==0:
        s += '0'
    elif N==1:
        s += '1'
    else:
        if N%2==0:
            s += '0'
            s += solve(int(N / (-2)))
        else:
            s += '1'
            s += solve(int((N - 1) / (-2)))
    return s

print(solve(N)[::-1])

Solution (Python):

import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import numpy as np

def main():
	N = int(input())
	
	if N == 0:
		print(0)
		sys.exit()
	
	ans = []
	if N % 2 == 0:
		ans.append("0")
	else:
		ans.append("1")
		N -= 1
		
	i = 1
	
	while True:
		tmp = (-2)**i
		i += 1
		
		if (N / tmp) % 2 == 0:
			ans.append("0")
		else:
			ans.append("1")
			N = N - tmp
		
		
		if N == 0:
			break
	
	s = ""	
	for i in ans:
		s += i
	print(s[::-1])
		
	
if __name__ == "__main__":
	main()

Solution (Python):
n=int(input())
x=""
while n!=0:
    x=str(n%2)+x
    n=-(n//2)
print(0 if x=="" else x)

Solution (Python):
n=int(input())
ans=''
while abs(n) > 0:
    ans = str(n % 2) + ans
    n = -(n // 2)
print(ans or 0)

Solution (Python):
N = int(raw_input())
ans = ''
while N != 0 and N != 1:
	if N % (-2) == 0:
		ans = '0' + ans
		N = N / (-2)
	else:
		ans = '1' + ans
		N = N / (-2) + 1
ans = str(N) + ans
print ans

Solution (Python):
N = int(input())
ans = ''
while abs(N) > 0:
    ans = str(N % 2) + ans
    N = -(N // 2)
print(ans or 0)

Solution (Python):
N = int(input())

if N == 0:
    print('0')
    exit()


ans_arr = []

while 1:
    if N == 1:
        ans_arr.append('1')
        break
    if N % 2:
        ans_arr.append('1')
        N -= 1
    else:
        ans_arr.append('0')
    N /= -2
print("".join(reversed(ans_arr)))

Solution (Python):
if __name__ == '__main__':
    N = int(input())

    rev_answer = ""
    while N != 0:
        rem = N % (-2)
        if rem < 0:
            rem += 2
        N = (N - rem) // (-2)
        rev_answer += str(rem)

    answer = rev_answer[::-1]
    if answer == "":
        answer = 0

    print(answer)

Solution (Python):
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n = f()[0]

    if n==0:
        print(0)
        return

    digit = []
    while n:
        r = abs(n)%2
        digit.append(r)
        n = (n-r)//(-2)

    for i in digit[::-1]:
        print(i, end = '')

solve()

Solution (Python):
N = int(input())

i = 0
answer = []
while True:
    if N == 0:
        break
    if N % ((-2)**(i + 1)) != 0:
        answer.append(1)
        N -= (-2)**i
        if N == 0:
            break
    else:
        answer.append(0)
    i += 1

print(''.join(map(str,reversed(answer))) if len(answer) != 0 else '0')

Solution (Python):
def nrange(n):
    if n == -1:
        return range(0, 1)
    if n == 0:
        return range(0, 2)

    if n % 2 == 0:
        np = n
        nm = n - 1
    else:
        np = n - 1
        nm = n

    ma = (4**(np // 2 + 1) - 1) // 3
    mi = -2 * (4**((nm + 1) // 2) - 1) // 3

    return range(mi, ma+1)


n = int(input())
k = 0
while n not in nrange(k):
    k += 1

s = ''
while k >= 0:
    if (n in nrange(k)) and (n not in nrange(k-1)):
        n -= (-2)**k
        s += '1'
    else:
        s += '0'

    k -= 1

print(s)

Solution (Python):
N = int(input())

if N == 0:
    print(0)
    exit()

ans = ""
while N != 0:
    if N % 2 != 0:
        N -= 1
        ans += "1"
    else:
        ans += "0"
    N //= -2
print(ans[::-1])

Solution (Python):

"""
C - Base -2 Number
https://atcoder.jp/contests/abc105/tasks/abc105_c

"""
import sys


def solve(N):
    if not N:
        return '0'
    r = []
    while N:
        r.append(N % 2)
        N = (N - N % 2) // -2
    return ''.join(map(str, r[::-1]))


def main(args):
    N = int(input())
    ans = solve(N)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Solution (Python):






def main():
    n = int( input() )

    i = 0
    ans = '' if n!=0 else '0'
    while n != 0:
        rem = n % ( 2**(i+1) )

  
        ans += '1' if rem>0 else '0'

        n += rem * ( -1 if i%2==0 else 1)
        i += 1


    print(ans[::-1])


main()

Solution (Python):
import sys
input = sys.stdin.readline

n = int(input())
x=""
while n != 0:
  x = str(n%2) + x
  n = -(n//2)
print(x if x else 0)

Solution (Python):
N = int(input())
if N == 0:
    print(0)
else:
    li = []
    ind = 0
    while N != 0:
        if N % 2**(ind + 1) == 0:
            li.insert(0,0)
            ind += 1
        else:
            li.insert(0,1)
            N -= (-2)**(ind)
            ind += 1            
    x = ''.join([str(li[i]) for i in range(len(li))])
    print(x)

Solution (Python):
import math

N = int(input())

if N == 0:
    print(0)
    exit()

s = ''
n = N
while n:
    p = math.ceil(n/-2)
    q = n - (p * -2)
    s += str(q)
    n = (n - q)//(-2)

print(s[::-1])

Solution (Python):
n = int(input())

if n == 0:
    print(0)
    exit()

s = ""
while n != 0:
    s += str(n%2)
    n = (n-n%2)//(-2)

print(s[::-1])

Solution (Python):
N = int(input())

if N == 0:
    print(0)
    exit()

s = ''
n = N
while n:
    s += str(n % 2)
    n = (n - (n % 2))//(-2)

print(s[::-1])

Solution (Python):
n = int(input())
ans = ""
while n:
    ans += str(n % 2)
    n = (n-n%2)//-2
if ans:
    print(ans[::-1])
else:
    print(0)

Solution (Python):
N = -int(input())
s = '' if N != 0 else 0
while N != 0:
  s = str(N % 2) + s
  N = N // -2
print(s)

Solution (Python):
n = -int(input())
a = ""
while n:
    a += str(n % 2)
    n //= -2
print(a[::-1] if a else 0)

Solution (Python):
import sys
N = int(input())
if N == 0:
    print(0)
    sys.exit()
ans = []
tmp = 0

def algo(n):
    if n == 0:
        return 
    
    if n%2 == 0:
        tmp = 0 
    else:
        tmp = 1
    ans.append(tmp)
    algo((n-tmp)//(-2))

algo(N)
Str = ''
ans.reverse()
for i in range(len(ans)):
    Str=Str+str(ans[i])
print(Str)

Solution (Python):
N = int(input())

def alg(N):
  if N == 0 or N == 1:
    return str(N)
  else:
    return alg(N//2*-1) + str(N%2)
print(alg(N))

Solution (Python):
n=int(input())
ans=''
for i in range(40,-1,-1):
  if i==0:
    if n==1:
      ans+='1'
      n=n-1
    else:
      ans+='0'
  elif i==1:
    if -2<=n<=-1:
      ans+='1'
      n=n-(-2)
    else:
      ans+='0'
  elif i%2==1:
    l=-(2*(4**((i+1)//2)-1)//3)
    r=-2**i+(1*(4**((i+1)//2)-1)//3)
    if l<=n<=r:
      ans+='1'
      n=n-((-2)**i)
    else:
      ans+='0'
  else:
    l=2**i-(2*(4**(i//2)-1)//3)
    r=1*(4**(i//2+1)-1)//3
    if l<=n<=r:
      n=n-((-2)**i)
      ans+='1'
    else:
      ans+='0'
if '1' not in ans:
  print(0)
else:
  ans=ans[ans.index('1'):]
  print(ans)

Solution (Python):

import sys


def solve(N: int):
    cur = N
    ret = []
    i = 0
    if N == 0:
        ret = ['0']
    while abs(cur) > 0:
        if i % 2 == 0:
            elm = (2 ** i)
        else:
            elm = -(2 ** i)
        tmp =  2 ** (i + 1)
        
        if abs(cur - elm) % tmp == 0:
            ret.append('1')
            cur -= elm
        else:
            ret.append('0')
        i += 1
    ret.reverse()
    print(''.join(ret))
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    solve(N)

if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
s = []
for i in range(100):
    if N % (2 ** (i+1)) != 0:
        N -= (-2) ** i
        s.append('1')
    else:
        s.append('0')

s.reverse()
t = ''.join(s)
print(int(t))

Solution (Python):


from sys import stdout
from bisect import bisect_left as binl
from copy import copy, deepcopy
from collections import defaultdict


mod = 1


def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * y) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def combination(x, y):
    assert(x >= y)

    if y > x // 2:
        y = x - y

    ret = 1

    for i in range(0, y):
        j = x - i
        i = i + 1

        ret = ret * j
        ret = ret // i

    return ret


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def get_factors(x):
    retlist = []
    for i in range(2, int(x**0.5) + 3):
        while x % i == 0:
            retlist.append(i)
            x = x // i
    retlist.append(x)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance





def main():
    n = intin()

    sumnow = 0
    ans = []
    bit = 0
    for i in range(64):
        if (n >> i) & 1 == 0 and bit == 1:
            if i % 2 == 0:
                bit = 0
                sumnow += 1<<i
            else:
                sumnow -= 1<<i
            ans.append('1')
        elif (n >> i) & 1 == 1 and bit == 0:
            if i % 2 == 0:
                sumnow += 1<<i
            if i % 2 == 1:
                bit = 1
                sumnow -= 1<<i
            ans.append('1')
        else:
            ans.append('0')

        if sumnow == n:
            for a in reversed(ans):
                stdout.write(a)
            print()
            return


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())

if n == 0:
  print(0)
else:
  ans = ''
  
  while n != 0:
    ans += str(n % 2)
    n //= 2
    n *= -1
  
  print(ans[::-1])

Solution (Python):
n=int(input())
def f(i,x):
    if i%2==0:
        if (2**i+2)//3<=x<=(2**(i+2)-1)//3:
            return True
        else:
            return False
    else:
        if -(2**(i+1)-1)*2//3<=x<=-(2**i+1)//3:
            return True
        else:
            return False
if n==0:
    print('0')
else:
    ans=''
    order=0
    mark=f(order,n)
    while not mark:
        order=order+1
        mark=f(order,n)
    while order>=0:
        if f(order,n):
            ans=ans+'1'
            n=n-(-2)**order
        else:
            ans=ans+'0'
        order=order-1
    print(ans)

Solution (Python):
n = int(input())

i = 1
num = ""
SUM = 0
amari = 1
if n == 0:
  num = "0"
while not(n == amari == SUM or SUM == n): 
  amari = n % 2**i
  if amari == SUM % 2**i:
    num += "0"
  else:
    SUM += (-2)**(i-1)
    num += "1"
  i += 1
  
print(num[::-1])

Solution (Python):
n = int(input())

i = 1
num = ""
SUM = 0
amari = 1
while not(n == amari == SUM or SUM == n) or num == "":
  amari = n % 2**i
  if amari == SUM % 2**i:
    num += "0"
  else:
    SUM += (-2)**(i-1)
    num += "1"
  i += 1
  
print(num[::-1])

Solution (Python):
N = int(input())

S = str()
a = True
count = 1
memo = 0
while a:
    amari = N%(2 ** count)

    if (amari- memo) == 2 ** (count-1):
        s = 1
    else:
        s = 0
    memo = memo + s * (-2) **(count-1)

    S = str(s) + S
    count += 1
    if memo == N:
        print (S)
        a = not a

Solution (Python):
n = int(input())
ans = ''
i = 0
while not n == 0:
    i += 1
    if n % 2 == 0:
        ans = '0' + ans
    else:
        ans = '1' + ans
        n += (-1) ** i
    n //= 2
if i == 0:
    ans += '0'
print(ans)

Solution (Python):
n = int(input())
s = []
if n == 0:
    print(0)
    exit()

while n != 0:
    now = n % -2
    n //= -2
    if now == -1:
        n += 1
        now *= -1
    s.append(str(now))
print(''.join(s[::-1]))

Solution (Python):
n = int(input())
tmp = 0
digit = 2
exponent = 1
baseMinor2 = ''

while(tmp!=n):
  
  if(n % digit) == (tmp % digit):
    baseMinor2 = '0' + baseMinor2
  else:
    baseMinor2 = '1' + baseMinor2 
    tmp += exponent
    
  exponent *= -2
  digit *= 2
if baseMinor2 == '':
  print(0)
else:
  print(baseMinor2)

Solution (Python):
N = int(input())
ans = ''
 
while (N!=0) :
    if (N%2) :
        ans = '1' + ans
        N -= 1
    else :
        ans = '0' + ans
    N /= -2
 
print(ans if (ans != '') else '0')

Solution (Python):
N = int(input())
ans = ''
if N == 0: ans ='0'
while N:
    ans += str(N%2)
    N = -(N // 2)
print(ans[::-1])

Solution (Python):
n=-int(input())
a=""
while n:
    a+=str(n%2)
    n//=-2
print(a[::-1] if a else 0)

Solution (Python):
n=int(input())
ans=str(n%2)
n//=2
while n:
    ans+=str(n%2)
    n//=-2
print(ans[::-1])

Solution (Python):
n=int(input())
ans=str(n%2)
n//=2
while n!=0:
    ans+=str(n%2)
    n//=-2
print(ans[::-1])

Solution (Python):
a=int(input())
if a==-1:
    print("11")
    exit()
if a==0:print("0")
b=""
c=2
d=0
n=0
if a > 0:
    m=a
else:
    m=-a-1
while m >d:
    if (a-d-1)%c < c//2:
        b+="1"
    else :
        b+="0"
    c*=2
    n=1-n
    d=d+(3*d+1)*n
if a < 0:
    if b[-1]=="0":b=b[:-1]
    if (a-d-1)%c < c//2:
        b+="1"
    

print(b[::-1])

Solution (Python):
n=int(input())
ans=[]
if n%2==1:
    ans.append("1")
    n-=1
else:ans.append("0")
n//=2
while n!=0:
    ans.append("1") if n%2==1 else ans.append("0")
    n//=-2
print("".join(ans[::-1]))

Solution (Python):
n = int(input())
if n==0:
    print(0)
    exit()
ans = ""
p = False
while n:
    n, m = divmod(n, 2)
    ans = str(m) + ans
    if p & m:
        n += 1
    p = not p
print(ans)

Solution (Python):
n = int(input())

li1 = [0]* 20
li2 = [0]* 20
count = 1

for i in range(19):
    li1[i+1] = li1[i] + 4 ** i
    li2[i+1] = li2[i] - 2 * 4 ** i

if n == 0:
    s = [0]
elif n > 0:
    for i in range(20):
        if li1[i] < n and li1[i+1] >= n:
            a = i
            s = [0] * (2*i+1)
            s[0] = 1
            n -= (-2) ** (2*i)
            
            break
    while a > 0:
        a -= 1
        if li2[a] > n and li2[a+1] <= n:
            s[count] = 1
            n -= (-2) ** (2*a+1)
            count += 1
            
        else:
            s[count] = 0
            count += 1
            
        if li1[a] < n and li1[a+1] >= n:
            s[count] = 1
            n -= (-2) ** (2*a)
            count += 1
            
        else:
            s[count] = 0
            count += 1
            
    
else:
    for i in range(20):
        if li2[i] > n and li2[i+1] <= n:
            a = i
            s = [0] * (2*(i+1))
            s[0] = 1
            n -= (-2) ** (2*i+1)
            
            break
    if li1[a] < n and li1[a+1] >= n:
        s[count] = 1
        n -= (-2) ** (2*a)
        count += 1
        
    else:
        s[count] = 0
        count += 1
        
    while a > 0:
        a -= 1
        if li2[a] > n and li2[a+1] <= n:
            s[count] = 1
            n -= (-2) ** (2*a+1)
            count += 1
            
        else:
            s[count] = 0
            count += 1
            
        
        if li1[a] < n and li1[a+1] >= n:
            s[count] = 1
            n -= (-2) ** (2*a)
            count += 1
            
        else:
            s[count] = 0
            count += 1
            
    

ans = ''

for i in range(len(s)):
    ans = ans + str(s[i])

print(ans)

Solution (Python):
def to_m2(n):
    if n == 0:
        return "0"

    digits = []
    i = 0
    base = 1
    while n != 0:
        if n % (base * 2) == 0:
            digits.append("0")
        else:
            digits.append("1")
            n -= base
        i += 1
        base *= -2
    digits.reverse()
    return "".join(digits)


N = int(input())
print(to_m2(N))

Solution (Python):
n = int(input())
b = [int(bk) for bk in format(abs(n), "b")[::-1]] + [0] * 3
if n>=0:
    for i, bk in enumerate(b):
        if i % 2 and bk:
            b[i + 1] += 1
else:
    for i, bk in enumerate(b):
        if i % 2==0 and bk:
            b[i + 1] += 1
for i, bk in enumerate(b):
    if bk > 1:
        if b[i + 1] > 0:
            b[i + 1] -= 1
        else:
            b[i + 1] += 1
            b[i + 2] += 1
        b[i] -= 2
print(int("".join(map(str,b[::-1]))))

Solution (Python):
N = int(input())
ans = ""

while N != 0:
    temp = 0 if N % -2 == 0 else 1
    ans = str(temp) + ans
    N -= temp
    N //= -2

print(ans if ans != "" else 0)

Solution (Python):
N = int(input())
L = [ ]
import math
while True:
    tmp = math.ceil(N / (-2))
    L.append(N - tmp *(-2))
    N = tmp
    if tmp == 0:
        break
L = L[::-1]
for x in L:
    print(x,end="")

Solution (Python):

"""解説
？進数の計算

 1  0  1 1
-8  4 -2 1
----------
-8 + -2 + 1 = -9

                    1   -2    4    -8      16
1のとき表現できる数  1~1 -2~1  2~5 -10~-3   6~21
0のとき表現できる数  0~1  0~1 -2~1  -2~5  -10~5
                   ----------------------------
                   0~1  -2~1 -2~5 -10~5  -10~21      


(1) -9のときを考える
-9は2で割り切れないので、0bit目は必ず1になる。(※1)

-9を-2進数で表現すると、 

?????1

になるはず。

ということは?????0は-10である。

?????の部分はいくつか？と考えたとき、
一桁減らすので、-2で割るとよい。（-2進数なので。10進数のときは10で割るでしょ？）

よって、?????の部分は5

(2) 5のときを考える
5は2で割り切れないので、0bit目は必ず1になる(※2)

5を-2進数で表現すると、

????1

になる。

ということは????0は4である。

????の部分はいくつか？と考えたとき、
一桁減らすので、-2で割る。

よって、????の部分は-2

(3) -2のときを考える
-2は2で割り切れるので、0bit目は0である。(※3)

-2を-2進数で表現すると、

???0

???の部分はいくつか？と考えたとき、
一桁減らすので、-2で割る。

よって、???の部分は1

(4) 1のときを考える
1は2で割り切れないので、0bit目は1(※4)

1を-2進数で表現すると、

??1

??0は0

??の部分はいくつか？と考えたとき、当然0でしょう。

よって、答えは、
(※4)(※3)(※2)(※1)で、
1011
になる。

この一連の計算を一般化すればよい。

"""
def solve():
    N = int(input())
    ans = ""
    
    if N==0:
        print(N)
        return

    while N!=0:
        if N%2 != 0:
            
            ans = "1" + ans
            N -= 1
            N //= -2
        else:
            ans = "0" + ans
            N //= -2
    
    print(ans)


if __name__ == "__main__":
    solve()

Solution (Python):
def c():
   
    K = int(input())
    ans = ""
    if K == 0:
        print(0)
        return 0
    while True:
        amari = -1*(K%-2) 
        
        ans += str(amari)
        K = (K-amari) / (-2)
        K = int(K)
        
        if K == 0 or K == 1:
            break
    ans += str(K)
    print(ans[::-1])
if __name__ == '__main__':
    c()

Solution (Python):
n = int(input())
rem = n
ans = ""
step = 0
if rem == 0:
    ans = "0"
while(rem!=0):
    dig = (-2)**(step+1)
    if rem%dig == 0:
        ans = "0" + ans
    else:
        ans = "1" + ans
        rem = rem - (-2)**(step)
    step+=1
print(ans)

Solution (Python):

N = int(input())

s = []
b = 2
if N == 0:
    print(0)
    exit()
while N != 0:
    if N % b == 0:
        s.append(str(0))
    else:
        s.append(str(1))
        N -= int(b/2)
    b *= -2

print(''.join(s[::-1]))

Solution (Python):
n = int(input())
bit = []
base = 2
if n==0:
    print(0)
    exit()
while n != 0:
    
    if n % (base) == 0:
        bit.insert(0,0)
    else:
        bit.insert(0, 1)
        n -= int(base/2)
    base *= -2
bit = map(str,bit)
print("".join(bit))

Solution (Python):

import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int):
    ret = []
    while 0 < abs(N):
        if N % -2  == 0:
            N //= -2
            ret.append('0')
        else:
            N = (N - 1) // -2
            ret.append('1')
    if ret == []:
        ret = ['0']
    return ''.join(reversed(ret))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    result = solve(N)
    print(result)

if __name__ == '__main__':
    main()

Solution (Python):
import math

def dnt(n):
    if n >= 0:
        return (-1) * (n // 2)
    else:
        return math.ceil((-1) * (n / 2))

N = int(input())
S = ""

if N == 0:
    print(0)

else:
    while N != 1:
        if N % 2 == 1:
            S = "1" + S
        else:
            S = "0" + S
        N = dnt(N)
    print("1"+S)

Solution (Python):
import math
N = int(input())

def frac(a):
	Q = math.ceil(a / -2)
	if a % 2 == 0:
		R = 0
	else:
		R = 1
	return Q, R

if N != 0:
	ans = []
	while N != 1:
		N, R = frac(N)
		ans.insert(0, R)
	ans = map(str, [1] + ans)
	print(''.join(ans))
else:
	print(0)

Solution (Python):
n = int(input())

if( n == 0 ):
    print(0)
    exit()
ans = []
while True:
    if(n == 0):
        break;
    elif(n % 2 == 1):
        ans.append(1)
        n -= 1
        n /= -2
    else:
        ans.append(0)
        n = n/(-2)
for i in reversed(range(len(ans))):
    print(ans[i],end='')

Solution (Python):
n = int(input())


ans = ''
if n == 0:
    ans = '0'
while n:
    if n%2 == 1:
        ans =  '1' + ans
        n -= 1
    else :
        ans = '0' + ans
    n = n/(-2)

print(ans)

Solution (Python):

def get_keta_num(num):
    keta_num = 0
    num = abs(num)
    while num > 0:
        keta_num += 1
        num //= 2
    keta_num += 2
    return keta_num




def main():
    num = int(input())
    sum_num = 0

    ans_list = []
    ind = 0
    while 1:
        now_num = 2 ** (ind + 1)
        ans_num = num % now_num
        if ans_num != 0:
            num -= (-2) ** ind
            ans_list.append(1)
        else:
            ans_list.append(0)

        if num == 0:
            break

        ind += 1


    ans_list = reversed(ans_list)
    print(''.join(map(str, ans_list)))



if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())

ans = ""

for _ in range(36):
    if N % 2 == 1:
        ans = "1" + ans
    else:
        ans = "0" + ans
    N //= 2
    N *= -1
    if N == 0:
        break

print(ans)

Solution (Python):
a=int(input())
l=[]
if a==0:
  print(a)
else:
  while a!=1:
    if a<0:
      l.append(abs(a)%2)
      if abs(a)%2==1:
        a=abs(a-1)//2
      else:
        a=abs(a)//2
    elif a>0:
      l.append(a%2)
      a=-(a//2)
  l.append(a)
  s=""
  for i in range(1,1+len(l)):
    s+=str(l[-i])
  print(s)