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):


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N = read_int()
    S = []
    twos = 1
    sign = 1
    while N != 0:
        if N%(2*twos) != 0:
            S.append('1')
            if sign < 0:
                N += twos
            else:
                N -= twos
        else:
            S.append('0')
        sign = -sign
        twos *= 2
    if len(S) == 0:
        S = ['0']
    S.reverse()
    print(''.join(S))


if __name__ == '__main__':
    solve()

Solution (Python):
def IntBaseConvert(N,K):
    if (type(N) is int) and (type(K) is int):
        if K>=2 and N>=0:
            if N==0:
                return [0]
            else:
                ConvertNum = []
                while N>0:
                    ConvertNum.append(N%K)
                    N = N//K
                return ConvertNum[::-1]
        elif K<=-2:
            if N==0:
                return [0]
            else:
                ConvertNum = []
                while abs(N)>0:
                    ConvertNum.append(N%abs(K))
                    N = (N-N%abs(K))//K
                return ConvertNum[::-1]
        else:
            return []
    else:
        return []
      
ConvertNum = IntBaseConvert(int(input()),-2)
print(''.join(str(T) for T in ConvertNum))

Solution (Python):
def BaseM2Num(N):
    if N==0:
        return [0]
    else:
        List = []
        while abs(N)>0:
            if N%2==0:
                N //= (-2)
                List.append(0)
            else:
                N = (N-1)//(-2)
                List.append(1)
        return List[::-1]
      
List = BaseM2Num(int(input()))
print(''.join(str(T) for T in List))

Solution (Python):
def negaternary(i: int) -> str:

    if i == 0:
        digits = ['0']
    else:
        digits = []
        while i != 0:
            i, remainder = divmod(i, -2)
            if remainder < 0:
                i, remainder = i + 1, remainder + 2
            digits.append(str(remainder))
    return ''.join(digits[::-1])

n=int(input())
print(negaternary(n))

Solution (Python):
n=int(input());result=[]
while n!=0:
  r=n%2
  n=(n-r)//-2
  result.append(r)
print(''.join(map(str,result[::-1])) if result else 0)

Solution (Python):
n=int(input());result=[]
while n!=0:
  r=n%2
  n=(n-r)//-2
  result.append(r)
print(''.join(map(str,(result[::-1]))) if result else 0)

Solution (Python):


n = int(input())

if n == 0:
    print('0')
else:
    
    s = ''
    n *= -1
    while n:
        t = n % -2
        if t < 0:
            t *= -1
        s = str(t) + s
        n //= -2
    print(s)

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

Solution (Python):

def main():
	n = int(input())
	ans = ""
	while n!=0:
		rem = n%(-2)
		n= n//(-2)
		if rem<0:
			rem = rem+2
			n = n+1
		ans = ans + chr(rem + ord('0'))
	if ans =="":
		print(0)
		exit()
	print(ans[::-1])
if __name__ =="__main__":
	main()

Solution (Python):

def main():
	n = int(input())
	ans = ""
	while n!=0:
		rem = n%(-2)
		n= n//(-2)
		if rem<0:
			rem = rem+2
			n = n+1
		ans = ans + chr(rem + ord('0'))
	if ans =="":
		print(0)
		exit()
	print(ans[::-1])
if __name__ =="__main__":
	main()

Solution (Python):


n = int(input())

if n == 0:
    print(0)
    exit()
ans = []
while(n != 0):

    rem = n % 2

    n = (n-rem)//(-2)

    ans.append(rem)

ans.reverse()

print("".join(map(str, ans)))

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

if N >= 0:
  n = N
  i = 0
  while 1:
    b = bin(n)[2:]
    if i >= len(b):
      break
    if i % 2 == 1 and b[-i-1]=='1':
      n += 2**(i+1)
    i += 1
  print(bin(n)[2:])
  
else:
  n = -N
  i = 0
  while 1:
    b = bin(n)[2:]
    if i >= len(b):
      break
    if i % 2 == 0 and b[-i-1]=='1':
      n += 2**(i+1)
    i += 1
  print(bin(n)[2:])

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

b=-2
temp=N
ans=""
while True:
    if temp%b!=0:
        ans="1"+ans
        temp=temp-(b//(-2))
    else:
        ans="0"+ans
    b=b*(-2)
    if temp==0:break

print(ans)

Solution (Python):
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()

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

ans = deque()
i = 0
while n != 0:
    tmp = ( n % 2**(i+1) ) // 2**i
    ans.appendleft(tmp)
    n -= tmp * (-2)**i
    i += 1
print(*list(ans),sep="")

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

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

pos=[0]*50
neg=[0]*50

def rec(x):
    if x>0:
        m=1
        while 4**m-1<3*x:
            m+=1
        
        pos[m-1]=1
        rec(x-4**(m-1))
    elif x<0:
        m=1
        while -2*(4**m-1)>3*x:
            m+=1
        
        neg[m-1]=1
        rec(x+2*(4**(m-1)))
    else:
        return

rec(n)

s=''
for i in range(100):
    if i%2==0:
        s=str(pos[i//2])+s
    else:
        s=str(neg[(i-1)//2])+s

i=0
while s[i]=='0':
    i+=1

print(s[i:])

Solution (Python):
N = -int(input())
a = ""

while N:
  a+=str(N%2)
  N//=-2

if a=="":
  print(0)
else:
  print(a[::-1])

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

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

Solution (Python):
import sys

input = sys.stdin.readline


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

    if N == 0:
        ans = "0"
    else:
        ans = ""
        while N != 0:
            q, r = divmod(N, -2)
            if r == 0:
                ans = "".join(["0", ans])
            else:
                ans = "".join(["1", ans])
            r = r + 2 if r < 0 else r
            N = (N - r) // -2

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):


import math

import itertools
from collections import deque
from collections import Counter

from fractions  import gcd

import bisect
n=int(input())
if n==0:
    print(0)
    exit()
elif n==1:
    print(1)
    exit()
def check(_n):        
    if _n>0:
        j=0
        while True:
            if pow(2,j)-2*(pow(2,j)-1)//3<=_n<=pow(2,j)+(pow(2,j)-1)//3:
                k=j
                break
            else:
                j+=2
    elif _n<0:
        j=1
        while True:
            if -1*pow(2,j)-2*(pow(2,j-1)-1)//3<=_n<=-1*pow(2,j)+(pow(2,j+1)-1)//3:
                k=j
                break
            else:
                j+=2
    else:
        return 0,0
    return _n-pow(-2,k),k
c=n
ans=0
while True:
    res=check(c)
    if c==0:
        ans+=c
        break
    else:
        ans+=pow(10,res[1])
        c=res[0]
print(ans)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()

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

lim = 32
top = [0]*(lim+1)
bottom = [0]*(lim+1)

for i in range(1, lim+1):
	if i%2:
		t = (i+1)//2
		top[i] = (4**t-1)//3
		bottom[i] = bottom[i-1]
	else:
		b = i//2
		bottom[i] = (4**b-1)*2//3
		top[i] = top[i-1]

digit = [0]*(lim+1)
for i in range(1, lim+1):
	digit[i] = (-2)**(i-1)

if 0 <= N:
	idx = bisect_left(top, N)
else:
	idx = bisect_left(bottom, -N)

ans = ""
for i in range(idx, 0, -1):
	if -bottom[i-1] <= N <= top[i-1]:
		ans += "0"
	else:
		ans += "1"
		N -= digit[i]

print(ans)

Solution (Python):
N = int(input())
ans = []
while N != 0:
    r = N % 2
    N = (N - r) // (-2)
    ans += [r]
print(''.join(map(str, ans[::-1])) if ans else 0)

Solution (Python):
n = int(input())
ans = []
d = 0
while n:
    select = n & 1
    ans.append(select)
    if d & 1:
        n += select
    else:
        n -= select
    d += 1
    n >>= 1
if not ans:
    ans.append(0)
print(''.join(map(str, reversed(ans))))

Solution (Python):
n = int(input())
if n==0:
  print(0)
  exit()
if n==1:
  print(1)
  exit()
l = []
while n!=1:
  if n%2==0:
    n //= -2
    l.append(0)
  else:
    n = (n-1)//(-2)
    l.append(1)
l.append(1)
l = l[::-1]
print(*l,sep="")

Solution (Python):

import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil, atan, pi



import string

from bisect import bisect_left
MOD = int(1e9)+7
INF = float('inf')


def solve():
    
    
    n = -int(input())
    if n == 0:
        print(0)
        return
    ans = []
    while n != 0:
        n, m = divmod(n, -2)
        ans.append(-m)

    ans.reverse()
    print(''.join([str(x) for x in ans]))

        


t = 1

for case in range(1,t+1):
    ans = solve()


"""

"""

Solution (Python):
N = int(input())
if N == 0:
    print('0')
    exit()

ans = ''
while abs(N) > 0:
    if abs(N) % 2 == 0:
        ans += '0'
        N //= 2
    else:
        N -= 1
        N //= 2
        ans += '1'
    N *= -1
print(ans[::-1])

Solution (Python):
import sys
import itertools

import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines



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

ans = ''
while abs(N) > 0:
    if abs(N) % 2 == 0:
        ans += '0'
        N //= 2
    elif N < 0:
        N = (N - 1) // 2
        ans += '1'
    else:
        ans += '1'
        N //= 2
    N *= -1
print(ans[::-1])

Solution (Python):
n=int(input())
if n==0:
    print(0)
    exit()
ans=[]
while n!=0:
    n,mod=divmod(n,-2)
    if mod==-1:
        mod=1
        n+=1
    ans.append(mod)
ans.reverse()
print("".join(map(str,ans)))

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

def minus_binary(n, S: str):
    if n == 0:
        if S == "":
            S = "0"
        return S
    
    if n == 1:
        S = "1" + S
        return minus_binary(0, S)

    else:
        if n%2 == 1:
            n -= 1
            S = "1" + S
        else:
            S = "0" + S

        return minus_binary(n/(-2), S)

S = ""
print(minus_binary(N, S))

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

s = ""

while N != 0:
    
    
    
    r = int(N % 2)
    
    N = (N - r) / (-2)
    s += str(int(r))


if s == "":
    print(0)
    exit()
else:
    
    print(s[::-1])

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

s = ""

while N != 0:
    
    
    r = int(N % 2)
    
    N = (N - r) / (-2)
    s += str(int(r))


if s == "":
    print(0)
    exit()
else:
    
    print(s[::-1])

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

Solution (Python):

def f(n):
	if n == 0:
		return '0'
	r = []

	while(n):
		if n % 2:
			r.append(1)
		else:
			r.append(0)
		n = (n-r[-1])/-2
	return ''.join(map(str,r[::-1]))
print f(int(raw_input()))

Solution (Python):
N = int(input())
S = list()
if N==0:
  print(0)
  exit()
elif N>0:
  while N>0:
    S.append(N%2)
    N//=2
  S.append(0)
  S.append(0)
  for i in range(len(S)-1):
    if i%2==1 and S[i]==1:
      S[i+1] += 1
    if S[i]==2:
      S[i]=0
      S[i+1]+=1
else:
  N *= -1
  while N>0:
    S.append(N%2)
    N//=2
  S.append(0)
  S.append(0)
  for i in range(len(S)-1):
    if i%2==0 and S[i]==1:
      S[i+1] += 1
    if S[i]==2:
      S[i]=0
      S[i+1]+=1
  
S.reverse()
while S[0]==0:
  S = S[1:]
ans = ""
for s in S:
  ans += str(s)
print(ans)

Solution (Python):
N = int(input())
if N==0:
    print(0)
    exit()

ans = ''
while N!=1:
    d = N%2
    ans += str(d)
    N -= d
    N //= -2
ans += '1'
print(ans[::-1])

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

ans = []
N = -N
while N != 0:
    ans.append(N%2)
    N //= -2

if ans:
    ans.reverse()
    print(*ans, sep="")
else:
    print(0)

Solution (Python):
def mod(n):
    if n > 0:
        return -(n//2), n%2
    elif n < 0:
        return (-n+1)//2 ,(-n)%2
    else:
        return 0,0
    
def main():
    N = int( input())
    if N == 0:
        print(0)
        return
    ANS = []
    while N != 0:
        N, b = mod(N)
        ANS.append(b)
    print("".join( map( str, ANS[::-1])))
        
if __name__ == '__main__':
    main()

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

res = []
sign = 1
while N:
    if N%2 == 0:
        res.append(0)
    else:
        N -= sign
        res.append(1)
    N //= 2
    sign *= -1
if not res:
    res = [0]
print(*reversed(res),sep='')

Solution (Python):
import sys
from collections import defaultdict, deque, Counter
import math


from bisect import bisect_left, bisect_right
import heapq




input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)


def nck(n, k, kaijyo):
    return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD


def npk(n, k, kaijyo):
    if k == 0 or k == n:
        return n % MOD
    return (kaijyo[n] * divide(kaijyo[n-k])) % MOD


def kaijyo(n):
    ret = [1]
    for i in range(1, n + 1):
        ret.append((ret[-1] * i)% MOD)
    return ret

def solve():
    n = getN()
    if n == 0:
        print(0)
        return
    idx = 0
    pos = True
    ans = []
    while(n != 0):
        if n % 2 == 0:
            ans.append("0")
        else:
            ans.append("1")
            if pos:
                n -= 1
            else:
                n += 1

        n //= 2
        pos = not pos

    ans.reverse()
    print("".join(ans))
def main():
    n = getN()
    for _ in range(n):
        solve()


if __name__ == "__main__":
    
    solve()

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

ans = ""

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

while N != 0:
    a, b = divmod(N, 2)
    ans = str(b) + ans
    N = -a

print(ans)

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):
import sys
from collections import deque
import bisect
import copy
import heapq
import itertools
import math
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


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

    if N == 0:
        print(0)
        return 

    res = ""
    T = 1
    t = 0
    while N != 0:
        if N % 2 == 1:
            res += "1"
            N -= 1
        else:
            res += "0"
        T *= -2
        N //= -2
        t += 1

    print(res[::-1])


if __name__ == "__main__":
    main()

Solution (Python):
import sys
def I():
    return int(sys.stdin.readline().rstrip())

N = I()

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

ans = ''

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

print(ans)

Solution (Python):
import sys
def I():
    return int(sys.stdin.readline().rstrip())

N = I()

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

ANS = []
r = 0
while True:
    for i in range(10**6):
        if -((2*(4**((i+1)//2)-1))//3) <= N <= (4*(4**(i//2)-1))//3+1:
            for _ in range(r-i-1):
                ANS.append('0')
            ANS.append('1')
            r = i
            break
    N -= (-2)**r
    if N == 0:
        for _ in range(r):
            ANS.append('0')
        break

print(''.join(ANS))

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

s = ''
while True:
    if n % 2 == 0:
        s = '0' + s
        n = n // -2
    else:
        s = '1' + s
        n = (n - 1) // -2
    if n == 0:
        break
print(s)

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

if N == 0:
    print(0)
    exit()
ans = []
while N !=0:
    ans.append(N%2)
    N = -(N-N%2)//2
ans.reverse()
print("".join(list(map(str,ans))))

Solution (Python):
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import bisect_right
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")

INF = float("inf")


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

    print(s)

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

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

Solution (Python):
N=int(input())
if N==0:
  print(0)
  exit()
X=1
P=''
for i in range(32):
  if N&X:
    if i&1:
      N+=X
    else:
      N-=X
    P+='1'
  else:
    P+='0'
  X<<=1
while P[-1]=='0':
  P=P[:-1]
print(P[::-1])

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

basis = [(-2) ** d for d in range(64)]
cs = [1, -2]
for i in range(2, len(basis)):
    cs.append(cs[i - 2] + basis[i])

S = ['0'] * len(basis)

n = N
max_i = 0
while n != 0:
    if n > 0:
        for i in range(0, len(basis), 2):
            if cs[i] >= n:
                S[i] = '1'
                n -= basis[i]
                max_i = max(max_i, i)
                break
    else:
        for i in range(1, len(basis), 2):
            if cs[i] <= n:
                S[i] = '1'
                n -= basis[i]
                max_i = max(max_i, i)
                break

print(''.join(S[:max_i + 1])[::-1])

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

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

while N:
    ans = str(N % 2)+ans
    N = -(N//2)

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

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, cos, radians, pi, sin
from operator import mul
from functools import reduce
from operator import mul


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

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

        
print(ans)

Solution (Python):
n = int(input())
ans = []

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

Solution (Python):
N = int(input())
 
if N == 0:
    print(0)
    exit()
ans = []
while N:
    ans.append(N % 2)
    N = N // 2
    N *= -1
print("".join(map(str, ans[::-1])))

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

ans = ""

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

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

Solution (Python):

def solve():
    k = 0
    N = n
    ans = ""
    if n == 0:
        print(0)
        exit()
    while N:
        k+=1
        if N % 2 == 1:

            N -= 1
            ans += "1"
        else:
            ans += "0"
        N //= (-2)  


    print(ans[::-1])




if __name__=="__main__":
    n = int(input())
    solve()

Solution (Python):
import sys
import itertools
import bisect

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():

    N = in_n()
    comb = itertools.product([0, 1], repeat=16)

    p = []
    m = []
    for c in comb:
        pt, mt = 0, 0
        for i in range(len(c)):
            pt += c[i] * (4 ** i)
            mt += c[i] * 2 * (4 ** i)
        p.append(pt)
        m.append(mt)

    p.sort()
    m.sort()

    for i in range(len(p)):
        if p[i] < N:
            continue
        else:
            pred_m = -(N - p[i])
            j = bisect.bisect_left(m, pred_m)
            if m[j] == pred_m:
                pred_p = p[i]
                break

    ans = pred_p | pred_m
    print(bin(ans)[2:])


if __name__ == '__main__':
    main()

Solution (Python):
import sys
import itertools
import bisect

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():

    N = in_n()
    comb = itertools.product([0, 1], repeat=16)

    p = []
    m = []
    for c in comb:
        pt, mt = 0, 0
        for i in range(len(c)):
            pt += c[i] * (4 ** i)
            mt += c[i] * 2 * (4 ** i)
        p.append(pt)
        m.append(mt)

    p.sort()
    m.sort()

    for i in range(len(p)):
        if p[i] < N:
            continue
        else:
            pred_m = -(N - p[i])
            j = bisect.bisect_left(m, pred_m)
            if m[j] == pred_m:
                pred_p = p[i]
                break

    ans = pred_p | pred_m
    print(bin(ans)[2:])


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):
import math
N = int(input())
if N == 0:
  print(0)
  quit()
p = int(math.log2(abs(N))) + 1
ans = [0] * (p + 10)
now = 0
for i in range(p + 10):
  x = N % (2 ** (i + 1))
  y = (now + ((-1) ** i) * (2 ** i) ) % (2 ** (i + 1))
  if (y == x) or (y + 2 ** (i + 1) == x):
    now += ((-1) ** i) * (2 ** i)
    ans[i] = 1
  if now == N:
    break
  


p = 0
for i in range(1, len(ans) + 1):
  if p == 0:
    if ans[-i] != 0:
      p = 1
      print(ans[-i], end = "")
  else:
    print(ans[-i], end = "")

print("")

Solution (Python):
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
a = 2
ans = ''

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

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

print(ans)

Solution (Python):
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy

def main():
    n = int(input())
    
    if n == 0:
        print(0)
        sys.exit()

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

    print(ans[::-1])


if __name__ == "__main__":
    main()

Solution (Python):
import math

import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit


ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
    ans = ""
    if n == 0:
        print(0)
        exit()
    while n != 0:
        if n&1:
            ans += "1"
            n = -(n-1)//2
        else:
            ans += "0"
            n = -(n//2)
    print(ans[::-1])
    return

if __name__ == '__main__':
    main()

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

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

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

print(ans[::-1])

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

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

tmp=[1*(i==0) for i in ans][::-1]
print("".join(map(str,tmp)))

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

ans = ""
if N == 1:
    print("1") 
elif N == 0:
    print("0")  
elif N == -1:
    print("10")
else:
    while True:
        r = N % 2
        N = (N-r) /-2
        ans = str(int(r)) + ans
        if N == 0 or N == 1:
            ans = str(int(N)) + ans
            break

    print(ans)

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

ans = ""

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

print(ans[::-1] if N != 0 else 0)

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

if n == 0:
    print(0)
    exit()
ans = ""
digit = 1
while n != 0:
    num = 0
    if n % pow(2, digit):
        num = 1
    ans = str(num) + ans
    n -= num * pow(-2, digit - 1)
    digit += 1
print(ans)

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

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

if N == 0:
    print(0)
    exit()
ans = []
while N:
    ans.append(N % 2)
    N = N // 2
    N *= -1

print("".join(map(str, ans[::-1])))

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())
c = 0
while 1:
    c += 1
    if n == 0:
      break
    if n > 0:
        if c%2 == 1: 
            if (4**(c//2+1)-1)//3 >= n:
                break
    elif n < 0:
        if c%2 == 0:
            if abs(2*(4**(c//2)-1))//3 >= abs(n):
                break
if n == 0:
    ans = ["0"]
else:
    k = 0
    ans = []
    while k < c:
        ans.append(str(n%2))
        n = (-1)* (n//2)
        k += 1
print("".join(ans[::-1]))

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

Solution (Python):


N = int(input())

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

Solution (Python):
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]





N = ii()
ans = ''

def div(a, b=-2):
    if a >= 0:
        return -(a//(-b)), a%(-b)
    else:
        if (-a)%(-b) == 0:
            return (-a)//(-b), 0
        else:
            return (-a)//(-b)+1, 1

while True:
    N, m = div(N)
    ans += str(m)
    if abs(N) < 2:
        break

if N == -1:
    ans += '11'
elif N == 1:
    ans += '1'

print(ans[::-1])

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

a = N
S_list = []
if a == 0:
    S_list.append(a)
while a != 0:
    Si = a % (-2)
    a //= (-2)
    if Si == -1:
        a += 1
        Si = 1
    S_list.append(Si)


S = ''.join([str(i) for i in S_list[::-1]])
print(S)

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

ans = []
a = n
while a != 0:
    b = a % (-2)
    a //= (-2)
    if b == -1:
        a += 1
        b = 1
    ans.append(b)
if not ans: ans = [0]
ans.reverse()    
print(*ans, sep='')

Solution (Python):
from math import floor
n = int(input())
s = ""
if n == 0:
    print(0)
    exit()
while n:
    s += str(n%2)
    n = n//2
    n *= (-1)
    
    
    
print(s[::-1])

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

Solution (Python):
n = int(input())
s = ''
while n != 0:
    r = n % 2
    if r < 0:
        r += 2
    n = (n - r) // (-2)
    s += str(0 + r)
if s == '':
    print(0)
else:
    print(s[::-1])

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

Solution (Python):
n = int(input())
s = []
while n != 0:
    rem = n%2
    if rem < 0:
        rem += 2
    
    n = (n-rem)//(-2)
    s.append(str(0+rem))

if len(s) == 0:
    print(0)
else:
    print(''.join(s[::-1]))

Solution (Python):
n = int(input())
if n==0:
    print(0)
    exit()
res = []
while n != 0:
    x = n%-2

    if x<0:
        res.append(1)
        n -= 1
        n //= -2
    else:
        res.append(0)
        n //= -2

res.reverse()
print("".join(str(c) for c in res))