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

if N<0:
  negative = True
elif N==0:
  print(0)
  exit()
else:
  negative = False

N = abs(N)

a = bin(N)
a = a[2:]
a = [int(i) for i in a]
a.reverse()

if len(a)%2 == 0 and a[-1]==1:
  a.append(0)
for i,num in enumerate(a[-2::-1]):
  digit = len(a)-2-i
  if digit % 2:
    a[digit+1] += num
  


a.append(0)
if negative:
  for i,num in enumerate(a[-2::-1]):
    digit = len(a)-2-i
    a[digit+1] += num


for i,num in enumerate(a):
  while a[i]>1:
    if i < len(a)-1:
      a.append(0)
      a.append(0)
    a[i] -= 2
    if a[i+1] > 0:
      a[i+1] -= 1
    else:
      a[i+1] += 1
      a[i+2] += 1

flag = 0
for i in a[::-1]:
  if i == 1:
    flag = i
  if flag:
    print(i,end='')

Solution (Python):
n=int(input())
if n==0:
    print(0)
    exit()
s=list(str(bin(n)))[2:][::-1]
t=[0]*(len(s)+2)
for i in range(len(s)):
    if s[i]=="1":
        if n>=0:
            if i%2==0:
                t[i]+=1
            else:
                t[i]+=1
                t[i+1]+=1
        else:
            if i%2==0:
                t[i]+=1
                t[i+1]+=1
            else:
                t[i]+=1
    else:
        pass
for i in range(len(t)):
    if t[i]==2:
        if i%2==1:
            t[i]=0
            if t[i+1]>0:
                t[i+1]-=1
            else:
                t[i+1]+=1
                t[i+2]+=1
        else:
            t[i]=0
            t[i+1]+=1
            t[i+2]+=1
t=t[::-1]
i=0
while t[i]==0:
    i+=1
print("".join(map(str,t[i:])))

Solution (Python):
li = list(map(int,input().split()))
n=li[0]
ans = 0

def asd(x):
    global ans
    if x>0:
        for i in range(0,35):
            max = 0
            l=0
            for j in range (0,i,2):
                max += pow(-2,j)
            if max >= x:
                ans += pow(10,i-1)
                
                return asd(x-(pow(-2,i-1)))
                
    elif x<0:
        for i in range(0,35):
            min =0
            for j in range (1,i,2):
                min += pow(-2,j)
            if min <= x:
                ans += pow(10,i-1)
                
                return asd(x-(pow(-2,i-1)))
                
                


    elif x==0:
        return 0
asd(n)
print(ans)

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

d = N
ans = []
while d != 0:
    d, m = divmod(d, -2)
    if m == -1:
        d += 1
    ans.append(abs(m))
print(*reversed(ans), sep='')

Solution (Python):
n = int(input())
if n == 0:
    print(0)
else:
    d = 0
    pows = [(0, 1)]
    for i in range(1, 50):
        a, b = pows[i-1]
        if i%2 == 1:
            min_ = b-2**(i+1)+1
            pows.append((min_, min_+2**i-1))
        else:
            max_ = a+2**(i+1)-1
            pows.append((max_-2**i+1, max_))
    pows[0] = (1, 1)
    

    ans = ''
    d = len(pows)-1
    for p in pows[::-1]:
        pmin, pmax = p
        if n >= pmin and n <= pmax:
            ans += '1'
            n -= (-2)**d
            
        else:
            ans += '0'

        d -= 1
    print(ans.lstrip('0'))

Solution (Python):
import math
def Base_10_to_m2(n):
  if int(n / (-2)) or n < 0:
    a = math.ceil(n / (-2))
    ans.append(n - a * (-2))
    return Base_10_to_m2(a)
  ans.append(n - math.ceil(n / (-2)) * (-2))
  return ans

n = int(input())
ans = []
print("".join(map(str, Base_10_to_m2(n)[::-1])))

Solution (Python):


n = int(input())

v = []

tmp_n = n
plus = 0

if tmp_n < 0:
    plus = 1
    tmp_n *= -1

while tmp_n > 0:
    v.append(tmp_n & 1)
    tmp_n = tmp_n >> 1

r = [0 for _ in range(len(v) + 10)]
for i in range(len(v)):
    if i % 2 == plus:
        r[i] += v[i]
    else:
        r[i] += v[i]
        r[i + 1] += v[i]

for i in range(len(r)):
    while (r[i] >= 2 and r[i + 1] >= 1):
        r[i] -= 2
        r[i + 1] -= 1
    while r[i] >= 2:
        r[i + 1] += 1
        r[i + 2] += 1
        r[i] -= 2

started = False
res = ""
for i in range(len(r)):
    idx = len(r) - 1 - i
    if r[idx] == 1:
        res = res + "1"
        started = True
    elif started == True:
        res = res + "0"

if res == "": res = "0"
print(res)

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

Solution (Python):
import sys
n = int(input())
A = [0]*100
B = [0]*100

if n == 0:
    print(0)
    sys.exit(0)
if n == 1:
    print(1)
    sys.exit(0)
A[0] = (0, 1)
B[0] = (1, 1)
i = 1
v = -2
while(True):
    if v < 0:
        A[i] = (A[i-1][0]+v, A[i-1][1])
        B[i] = (A[i-1][0]+v, A[i-1][1]+v)
    else:
        A[i] = (A[i-1][0]  , A[i-1][1]+v)
        B[i] = (A[i-1][0]+v, A[i-1][1]+v)
    if A[i][0] <= n and n <= A[i][1]:
        break
    i += 1
    v *= -2

S = ''
for j in range(i, -1, -1):
    if B[j][0] <= n and n <= B[j][1]:
        S += '1'
        n -= v
    else:
        S += '0'
    v /= -2
print(S)

Solution (Python):
def f(n):
    n = int(n)
    if n in [0, 1]:
        return str(n)
    return f((n - (abs(n) % 2)) / -2) + str(abs(n) % 2)

print(f(int(input())))

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

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

Solution (Python):
import sys
n = int(input())
if n == 0:
  print(0)
  sys.exit()
s = ""
while n!= 0:
  if ((n<0 and (-n)%2==0) or (n>0 and n%2==0)):
    s = "0" + s
  else:
    s = "1" + s
    n-=1
  n/=-2
print(s)

Solution (Python):
n = int(input())
m = n
s = ''

if m == 0 :
   print('0')

while m != 0 :

   if m%2 == 0 :
      s = '0' + s
      m = m / (-2)
   else :
      s = '1' + s
      m = (m-1) / (-2)

print(s)

Solution (Python):
N = int(input())
base = 1
pos = 0
ans = ''
while N != 0:
    if abs(N) & (1 << pos):
        N -= base
        ans += '1'
    else:
        ans += '0'
    pos += 1
    base *= -2

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

Solution (Python):
N = int(input())
str2N = bin(abs(N))[2:]
S = ''
inc = 0
for i, s in enumerate(str2N[::-1]):
  S += str((int(s) + inc) % 2)
  if N > 0:
    if i % 2 == 0:
      inc = (int(s) + inc) // 2
    else:
      inc = 1 if (int(s) + inc) else 0
  else:
    if i % 2 == 0:
      inc = 1 if (int(s) + inc) else 0
    else:
      inc = (int(s) + inc) // 2
S += str(inc)
if abs(N) > 0:
  S = S[::-1][S[::-1].find('1'):]
  if N > 0:
    if len(S) % 2 == 0:
      S = '1' + S
  else:
    if len(S) % 2 != 0:
      S = '1' + S
  print(S)
else:
  print('0')

Solution (Python):
import sys

N=int(input())
if N==0:
    print(0)
    sys.exit()

walist=[0]*50
walist[0]=1
walist[1]=-2
for i in range(1,25):
    walist[2*i]=walist[2*i-2]+2**(2*i)
    walist[2*i+1]=walist[2*i-1]-2**(2*i+1)


    


def near(k):
    if k>=0:
        for i in range(16):
            if 2**i<=k<=walist[2*i]:
                return 2*i
            if 2**(2*i)>=k:
                return 2*i
    else:
        for i in range(16):
            if walist[(2*i)+1]<=k<=-2**((2*i)+1):
                return 2*i+1
            if -2**((2*i)+1)<=k:
                return 2*i+1


ANSSTR=[0]*50

while True:
    k=near(N)
    ANSSTR[k]=1
    N=N-(-2)**k
    if N==0:
        break

for i in range(49,-1,-1):
    if ANSSTR[i]==1:
        break

for j in range(i,-1,-1):
    print(ANSSTR[j],end="")

Solution (Python):
def c_base_minus2_number(N):
    
    def negabinary(n):  
        if n == 0:
            return '0'
        digits = []
        while n != 0:
            
            n, remainder = divmod(n, -2)
            if remainder < 0:
                n, remainder = n + 1, remainder + 2  
            digits.append(str(remainder))
        return ''.join(digits[::-1])

    ans = negabinary(N)
    return ans

N = int(input())
print(c_base_minus2_number(N))

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

Solution (Python):
n = int(input())
s = ""
p = 1
while n != 0:
    if n % (p*-2) == 0:
        s += "0"
    else:
        s += "1"
        n -= p
    p *= -2

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

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

def g(n):
    b = format(-n, 'b')
    ret = [0] * (len(b) + 2)
    for i, x in enumerate(reversed(b)):
        if x == '0': continue
        if i & 1:
            if ret[i]:
                ret[i] = 0
                ret[i+2] = ret[i+1] = 1
            else:
                ret[i] = 1
        else:
            if ret[i]:
                ret[i] = 0
            else:
                ret[i] = ret[i + 1] = 1
    ret = ret[::-1]
    return ret[ret.index(1):]

def f(n):
    b = format(n, 'b')
    ret = [0] * (len(b) + 2)
    for i, x in enumerate(reversed(b)):
        if x == '0': continue
        if i & 1:
            if ret[i]:
                ret[i] = 0
            else:
                ret[i] = ret[i + 1] = 1
        else:
            if ret[i]:
                ret[i] = 0
                ret[i+2] = ret[i+1] = 1
            else:
                ret[i] = 1
    ret = ret[::-1]
    return ret[ret.index(1):]

if N == 0:
    print(0)
elif N > 0:
    print("".join([str(x) for x in f(N)]))
else:
    print("".join([str(x) for x in g(N)]))

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

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

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

Solution (Python):
N = int(input())
if N==0:
    print(0)
    exit()
ans = ""
p = True
while N!=0:
    d, m = divmod(N, 2)
    if p:
        N -= m
    else:
        N += m
    ans = str(m) + ans
    N //= 2
    p = not p
print(ans)

Solution (Python):
from sys import stdin

N = int(stdin.readline().rstrip())

ans = ""

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

print(ans)

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

Solution (Python):
N=int(input())
S = []
for i in range(16):
  if   N%4==0: S.append('00'); N-=0
  elif N%4==1: S.append('01'); N-=1
  elif N%4==2: S.append('10'); N+=2
  else       : S.append('11'); N+=1
  N = N//4
  if N == 0: break
ans=''.join(reversed(S))
if ans[0]=='0': ans = ans[1:]
print(ans)

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

a = []
s = 0
while (-2)**s<10000000000:
    a.append((-2)**s)
    s += 1


def judge(n):
    sum = 0
    count = 0
    dig = 0
    if n >0:
        for num in a:
            count += 1
            if num >0:
                sum += num
            if sum >= n:
                dig = count
                break
    else:
        for num in a:
            count += 1
            if num <0:
                sum += num
            if sum <= n:
                dig = count
                break
            
    return dig
    
ans = ["0" for i in range(judge(n))]


while n!=0:
    ans[judge(n)-1] = "1"
    n -= a[judge(n)-1]

    
answer = ""
for i in range(len(ans)-1,-1,-1):
    answer += ans[i]
    
print(answer)

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

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

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

print(ans)

Solution (Python):
N = int(input())
a = [0]*32
i = 0
ans = 0

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

else:
  while N != 1 :
    if(N%2==0):
      a[i] = 0
      N=N/(-2)
      i = i+1
    else:
      a[i] = 1
      N = (N-1)/(-2)
      i = i+1
  a[i] = 1
  for k in range(i+1):
    ans = ans + a[k] * 10**k
  print(ans)

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


def convert(n, b):
    if n == 0:
        return "0"
    out = []
    while n != 0:
        n, rem = divmod(n, b)
        if rem < 0:
            n += 1
            rem -= b
        out.append(rem)
    return "".join(map(str, out[::-1]))


print(convert(N, -2))

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

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

Solution (Python):
a=int(input())
sum=0
s=''
'''if a<0:
    b = abs(a)
    if b%2==1:
        b=b+1
        print(str(bin(b))[2:-1]+'1')
    else:
        print(str(bin(b))[2:-1])'''
if a!=0:
    while(a!=1):
        if a%(-2)==-1:
            s=s+'1'
            a=a-1
            a=a/-2
        else:
            s = s + '0'
            a=a/-2
    s=s+'1'
    for i in range(len(s)):
        print(s[len(s)-1-i],end='')
    print()
else:
    print(0)

Solution (Python):
from sys import stdin


def main():
    N = int(stdin.readline().rstrip())

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

    ans = ''
    base = 2
    while N != 1:
        ans = str(abs(N % base)) + ans
        N = N // base
        N = -1 * N
    print('1' + ans)


if __name__ == '__main__':
    main()

Solution (Python):

import math

N = int(input())



ans = ''
i = 0


while True:
	a = math.ceil(N/-2)
	p = N - (-2 * a)
	if p == 1:
		ans = '1' + ans 
	else:
		ans = '0' + ans 
	N = a
	if N == 0:
		break


print(ans)

Solution (Python):
import math
N = int(input())
a = math.ceil(N/(-2))
r = 0
s = ""
if N == 0:
    print(0)
else:
    while a != 1:
        r = N-a*(-2)
        s = str(r) + s
        N = a
        a = math.ceil(N/(-2))
    if a == 1:
        r = N-a*(-2)
        s = str(r) + s
        s = "1" + s   
    print(s)

Solution (Python):
N = int(input())
l = [0]*31
for i in range(0,30):
    l[i+1] = l[i] + 4**i

mlist = [0] * 61
for i in range(30):
    mlist[i*2+1] = l[i]
    mlist[i*2] = l[i]
mlist = mlist[1:-1]

def zojudge(N, d):
    if ((N-1) // 2**d) % 2 == 0:
        return "1"
    else:
        return "0"

L = [zojudge(N - m, i) for (i, m) in enumerate(mlist)]
S = int("".join(reversed(L)))
print(S)

Solution (Python):
import sys

N = int(input())
m = 1

min = 0
max = 1

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

i = 0
while True:
    m *= 2

    if i % 2 == 0:
        min -= m
    else:
        max += m

    if min <= N <= max:
        break

    i += 1




ans = []

while True:
    if (min + max)/2 < N:
        if i % 2 == 0:
            ans.append("0")
        else:
            ans.append("1")
        min += m

    elif N < (min + max)/2 :
        if i % 2 == 0:
            ans.append("1")
        else:
            ans.append("0")
        max -= m

    else:
        break

    m /= 2
    i -= 1

print("".join(ans))

Solution (Python):
a=int(input())
sum=0
s=''
'''if a<0:
    b = abs(a)
    if b%2==1:
        b=b+1
        print(str(bin(b))[2:-1]+'1')
    else:
        print(str(bin(b))[2:-1])'''
if a!=0:
    while(a!=1):
        if a%(-2)==-1:
            s=s+'1'
            a=a-1
            a=a/-2
        else:
            s = s + '0'
            a=a/-2
    s=s+'1'
    for i in range(len(s)):
        print(s[len(s)-1-i],end='')
    print()
else:
    print(0)

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

def getMaxBit(x):
    if x==0:
        return None
    elif x>0:
        s=0
        i=0
        while s<x:
            s+=2**i
            i+=2
        return i-2
    else:
        s=0
        i=1
        while s>x:
            s-=2**i
            i+=2
        return i-2
ans=set()
while N!=0:
    a=getMaxBit(N)
    ans.add(a)
    N-=(-2)**a
S=""
if len(ans):
    for i in range(max(ans)+1):
        S=("1" if i in ans else "0")+S
else:
    S="0"
print(S)

Solution (Python):
n = int(input())
if n==0:
  print("0")
  exit()
s=""
t=-2
while n != 0:
  z = 0 if n % t ==0 else 1
  s = str(z)+s
  n = n - z*t/(-2)
  t = t*(-2)
print(s)

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

if n == 0:
    print('0')
else:
    ans = []
    x = n
    while x != 1:
        if x % -2 == 0:
            ans.append('0')
            x //= -2
        else:
            ans.append('1')
            x //= -2
            x += 1
    ans.append('1')
    t_ans = ''
    for i in range(len(ans)-1, -1, -1):
        t_ans += ans[i]
    print(t_ans)

Solution (Python):
n=int(input())
s=''
if n==0:
  print('0')
  exit()
while(n!=0):
  m=abs(n)
  if m%2==1:
    n-=1
    n=n//(-2)
    s='1'+s
  else:
    n=n//(-2)
    s='0'+s
print(s)

Solution (Python):
N = int(input())
ans = [0]*36

def bit(inp,ans):
    if inp == 0:
        ans[0] = 0
        inp2 = 0
    
    if inp > 0:
        b = [1,5,21,85,341,1365,5461,21845,87381,349525,1398101,5592405,22369621,89478485,357913941,1431655765]
        pcount = 0
        for ii in range(len(b)):
            if inp <= b[ii]:
                inp2 = inp - 4**ii
                break
            pcount = pcount + 1
        ans[pcount*2] = 1
        
    if inp < 0:
        b2 = [-2,-10,-42,-170,-682,-2730,-10922,-43690,-174762,-699050,-2796202,-11184810,-44739242,-178956970,-715827882,-2863311530]
        pcount = 0
        for ii in range(len(b2)):
            if inp >= b2[ii]:
                inp2 = inp + 2 * (4**ii)
                break
            pcount = pcount + 1
        ans[pcount*2+1] = 1
        
    return inp2,ans

    
while N != 0:
    N,ans = bit(N,ans)

fi = ans[::-1]
fistr = [str(n) for n in fi]
m = ''.join(fistr)
mm = int(m)

print(mm)

Solution (Python):
N = int(input())
S = ""
for i in range(1000):
    if N%((-2)**(i+1))==0:
        S="0"+S
        if N==0:
            break
    else:
        S="1"+S
        N-=(-2)**i
        if N==0:
            break
print(S)

Solution (Python):
N = int(input())
S = []
if N == 0:
    print('0')
    exit()
while N != 1:
    if N % (-2) == -1:
        S.append(1)
        N = (N - 1) // -2
    else:
        S.append(0)
        N = N // -2
S.append(1)
ans = ''
for s in S[::-1]:
    ans += str(s)
print(ans)

Solution (Python):

n = int(input())
pos = [ 0 ] * 64
neg = [ 0 ] * 64
for i in range(32):
    if n >= 0:
        if n & (1 << i):
            pos[i] += 1
    else:
        if (- n) & (1 << i):
            neg[i] += 1
for i in range(32):
    delta = min(pos[i], neg[i])
    pos[i] -= delta
    neg[i] -= delta
    if i % 2 == 1:
        if pos[i]:
            pos[i + 1] += pos[i]
            neg[i] += pos[i]
            pos[i] = 0
        neg[i + 1] += neg[i] // 2
        neg[i] %= 2
    else:
        if neg[i]:
            neg[i + 1] += neg[i]
            pos[i] += neg[i]
            neg[i] = 0
        pos[i + 1] += pos[i] // 2
        pos[i] %= 2
s = ''
for i in reversed(range(64)):
    if pos[i] or neg[i]:
        s += '1'
    else:
        s += '0'
print(s.lstrip('0') or '0')

Solution (Python):
n = int(input())
b = -2

remains = []
if n == 0:
    print(0)
else:
    while n != 0:
        remain = n%b
        n = n//b

        if remain<0:
            remain += -b
            n += 1
        remains.append(remain)

    remains = list(map(str,remains))
    ans = ''.join(remains)[::-1]
    print(ans)

Solution (Python):
def main():
    n = int(input())
    if n==0:
        return 0

    ans,up = '',0
    flg = 0
    if n<0:
        flg = 1
        n = -n

    for i in range(40):
        d = (n>>i&1)+up
        if i%2==flg:
            if d==0:
                ans,up = '0'+ans,0
            elif d==1:
                ans,up = '1'+ans,0
            elif d==2:
                ans,up = '0'+ans,1
            else:
                assert(False)
        else:
            if d==0:
                ans,up = '0'+ans,0
            elif d==1:
                ans,up = '1'+ans,1
            elif d==2:
                ans,up = '0'+ans,1
            else:
                assert(False)

    return ans[ans.find('1'):]

if __name__ == '__main__':
    print(main())

Solution (Python):
N = int(input())
if N == 0:
        print("0")
else:
        ans = []
        while N != 0:
                if N%2 == 1:
                        ans.append(1)
                        N -= 1
                        N = N//(-2)
                else:
                        ans.append(0)
                        N = N//(-2)
        ans_str = ""
        for i in ans:
                ans_str = str(i) + ans_str
        print(ans_str)

Solution (Python):
n=int(input())
a=[]
t=n
while(abs(t)>0):
    a.append(abs(t%(-2)))
    if t%(-2)==0:
        t//=-2
    else:
        t//=-2
        t+=1
a=list(map(str, a))
if n==0:
    print(0)
else:
    print("".join(a[::-1]))

Solution (Python):
N=int(input())
L=[]
M=""
while N!=0:
  M=int((-1)*(N%(-2)))
  if N<0:
    N=int((N-1)/(-2))
  else:
    N=int(N/(-2))
  L.insert(0,str(M))
if len(L)==0:
  L=["0"]
print("".join(L))

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

Solution (Python):
n = int(input())
ans = '00' if n == 0 else '0'
i = 1
pm = 1
while n != 0:
    a = 2**i
    b = abs(n) % a
    if b == 0:
        ans = ans + '0'
    else:
        ans = ans + '1'
        n -= pm*a/2
    pm = -pm
    i += 1
print(int(ans[i:0:-1]))

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

def plus(k):
    j = 0
    while (2**(j+2) - 1)/3 < k:
        j += 2
    return 10**j,k-2**j

def minus(k):
    j = 1
    while ((-2)**(j+2)-(-2))/3 > k:
        j += 2
    return 10**j,k-(-2)**j

ans = 0    
while n != 0:
    if n > 0:
        a,n = plus(n)
        ans += a
    else:
        a,n = minus(n)
        ans += a

print(ans)

Solution (Python):
from functools import reduce

n = int(input())

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

res = []

while True:
  if n == 0:
    break
  if n == 1:
    res.append(1)
    break
  if n%2 == 0:
    res.append(0)
    n //= -2
  else:
    res.append(1)
    n = (n-1)//(-2)


print(reduce(lambda s, x: s + str(x), reversed(res) ,""))

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

ans = ''

def divide(n):
	if n % (-2) != 0:
		p = (n//(-2))+1
		q = n - p * (-2)
	else:
		p = n//(-2)
		q = n - p * (-2)
	return p,q

while True:
	p,q = divide(N)
	if p == 0:
		ans = str(p) + ans
		break
	N = p
	ans = str(q) + ans
	if p == 1:
		ans = str(p) + ans
		break
print(ans)

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

oddsum = [2, 10, 42, 170, 682, 2730, 10922, 43690, 174762, 699050, 2796202, 11184810, 44739242, 178956970, 715827882, 2863311530]
evensum = [1, 5, 21, 85, 341, 1365, 5461, 21845, 87381, 349525, 1398101, 5592405, 22369621, 89478485, 357913941, 1431655765]
two = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824, 2147483648, 4294967296, 8589934592, 17179869184]
ans = 0
while n != 0:
    if n < 0:
        x = 1
        for i in oddsum:
            if n >= -1 * i:
                break
            x += 2
        n += two[x]
    else:
        x = 0
        for i in evensum:
            if n <= i:
                break
            x += 2
        n -= two[x]
    v = 1 << x
    ans += v
print(bin(ans)[2:])

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

if N == 0:
    print("0")
else:
    r = ''
    while N != 0:
        N, rem = divmod(N, -2)
        if rem < 0:
            N += 1
            rem -= -2
        r = str(rem) + r
    print(r)

Solution (Python):
X=int(input())
if X==0:
	print(0)
else:
	A = []
	while(X!=0):
		X,R = divmod(X,-2)
		if (R<0):
			R-=(-2)
			X+=1
		A.append(R)
	print("".join(map(str,A[::-1])))

Solution (Python):
n = int(input()) * -1 

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

if s:
    print(s)
else:
    print(0)

Solution (Python):
N = int(input())
k=0
j=0
neg = 1
if N > 1:
	M = -2*N
	neg = 0
else:
	M = N
for i in range(-1*M):
	j = j - 2**(2*i + 1)
	if j <= M:
		k = i+1
		M = N-j
		break
	
out = ""
for i in range(2*k):
	if i%2 == 0:
		pl = M%2
		out = str(pl)+out
		M = int((M - pl)/2)
	else:
		pl = 1-(M%2)
		out = str(pl)+out
		M = int((M-1+pl)/2)

if N == 0:
	out="0"
elif out[0] == "0":
	out = out[1:]
	
print(out)

Solution (Python):
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())


def Base_10_to_n(X, n):

    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

N = int(input())

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

ans = []
def calc(x):
	global ans

	if x%4 == 0:
		ans.append(0)
		ans.append(0)

	elif x%4 == 1:
		ans.append(1)
		ans.append(0)
		x -= 1
	elif x%4 == 2:
		ans.append(0)
		ans.append(1)
		x += 2
	elif x%4 == 3:
		ans.append(1)
		ans.append(1)
		x += 3

	return x//4

while N !=0:
	N = calc(N)


ans.reverse()
print(int(''.join(map(str,ans))))

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

output = ""

num = 1

if n == 0:
    print(0)

else:
    while n != 0:
        
        

        if n % (-2 * num) == 0:
            output = "0" + output
        else:
            output = "1" + output
            n -= num

        num = num * (-2)
        

    print(output)

Solution (Python):
N = int(input())
S = []
ans = "0"
while(abs(N) > 0):
  S.append(str(abs(N % (-2))))
  N += N % (-2)
  N = N // (-2)
  
S.reverse()

if S == []:
  print(ans)
else:
  ans = ""
  for i in S:
    ans += i
    
  print(ans)

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

















ans = ""
n_array = []

if N == 0:
    ans = "0"

while N != 0:
    if N % 2 == 0:
        s = 0
    else:
        s = 1

    n_array.insert(0, s)

    if N > 0:
        N = (N // 2)*(-1)
    else:
        N = (-1)*N
        if N % 2:
            N += 1
        N = N // 2

maped_list = map(str, n_array)
for cc in maped_list:
    ans += cc


print(ans)

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

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

Solution (Python):


import math

def main():
    n = int(input())
    if n == 0:
        print('0')
        return

    bits = []
    while n != 0:
        qf = n / -2
        q = math.ceil(qf)
        m = n % -2
        bits.append('0' if m == 0 else '1')
        n = q

    print(''.join(reversed(bits)))


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
t = n
k = 0
i = 0
ans = []
if n == 0:
    print(0)
else:
    while k != n:
        if i % 2 == 0:
            if t % 2 == 0:
                ans += "0"
            else:
                ans += "1"
                t -= 1
                k += (-2)**i
        else:
            if t % 2 == 0:
                ans += "0"
            else:
                ans += "1"
                t += 1
                k += (-2)**i
        t = int(t / 2)
        i += 1
    ans.reverse()
    print("".join(ans))

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

s = []

a = n
b = 0

while (a !=0):
    if a%-2 ==0:
        b = a % -2
        a = a//-2
        s.insert(0,str(b))
    elif a%-2==-1:
        b = abs(a % -2)
        a = a//-2+1
        s.insert(0,str(b))

print(''.join(s) if len(s)!=0 else 0)

Solution (Python):





def main(input_str):
    n = int(input_str)
    if n == 0:
        print(0)
        return
    chi = -2
    bai = -2
    dif = n
    ret = ""
    while dif != 0:
        
        
        if 0 != dif % chi:
            
            ret = '1' + ret
            
            dif -= chi/bai
        else:
            
            
            ret = '0' + ret
        chi *= bai

    print(ret)
        
    
if __name__ == '__main__':
    try:
        main(input().strip())
    except EOFError:
        pass

Solution (Python):
N = input()
if N  == 0:
    print 0
elif N > 0:
    A = []
    B = []
    carry = 0
    cnt = 0
    while N > 0:
        if cnt == 0:
            B.append(0)
            if N % 2 == 1 and carry == 0:
                A.append(1)
            elif N % 2 == 1 and carry == 1:
                A.append(0)
            elif N % 2 == 0 and carry == 0:
                A.append(0)
            elif N % 2 == 0 and carry == 1:
                A.append(1)
                carry = 0
        else:
            A.append(0)
            if N % 2 == 1 and carry == 0:
                B.append(1)
                carry = 1
            elif N % 2 == 1 and carry == 1:
                B.append(0)
            elif N % 2 == 0 and carry == 0:
                B.append(0)
            elif N % 2 == 0 and carry == 1:
                B.append(1)
        N /= 2
        cnt ^= 1
    if carry:
        if cnt == 0:
            A.append(1)
            B.append(0)
        else:
            A.append(0)
            B.append(1)
            A.append(1)
            B.append(0)
    A.reverse()
    B.reverse()
    ans = []
    for a, b in zip(A, B):
        ans.append(a + b)
    print "".join(map(str, ans))
else:
    N *= -1
    A = []
    B = []
    carry = 0
    cnt = 0
    while N > 0:
        if cnt == 0:
            B.append(0)
            if N % 2 == 1 and carry == 0:
                A.append(1)
                carry = 1
            elif N % 2 == 1 and carry == 1:
                A.append(0)
            elif N % 2 == 0 and carry == 0:
                A.append(0)
            elif N % 2 == 0 and carry == 1:
                A.append(1)
        else:
            A.append(0)
            if N % 2 == 1 and carry == 0:
                B.append(1)
            elif N % 2 == 1 and carry == 1:
                B.append(0)
            elif N % 2 == 0 and carry == 0:
                B.append(0)
            elif N % 2 == 0 and carry == 1:
                B.append(1)
                carry = 0
        N /= 2
        cnt ^= 1
    if carry:
        if cnt == 1:
            B.append(1)
            A.append(0)
        else:
            B.append(0)
            A.append(1)
            B.append(1)
            A.append(0)
    A.reverse()
    B.reverse()
    ans = []
    for a, b in zip(A, B):
        ans.append(a + b)
    print "".join(map(str, ans))

Solution (Python):
def div(x):
    a = x //(-2)
    if a*(-2) > x:
        a+=1
    return a
n = int(input())
bi = ""
flag = 0
if n == 0:
    flag = 1
while n != 0:
    x = div(n)
    if n % (-2) != 0:
        bi = "1"+bi
    elif x != 0:
        bi = "0"+bi 
    n = x
print("0" if flag == 1 else bi)