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())
i = 1
ans = [0 for i in range(1) if N == 0]
while N != 0:
    if N % (-2 ** i) == 0:
        ans.append(0)
    else:
        ans.append(1)
        N -= ((-2)**(i-1))
    i += 1
print("".join(map(str, ans))[::-1])

"""
N = bin(int(input()))
N_str = str(N)[:1:-1]+"0"  
N_list = list(N_str)
print(N_list)
for i in range(len(N_list)+1):
    if i % 2 == 1:


        
        for j in range(i+1, len(N_list)):
            
            
            N_list[j] = str(int(N_list[j])+1)
            
            if N_list[j] == "2":
                N_list[j] = "0"
                continue
            else:
                break

ans = "".join(N_list[::-1])
print(ans)
        """

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=='':
    ans=0
print(ans)

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

if N == 0:
    print(0)
else:
    curr = N
    ans = ""
    idx = 0
    while curr != 0:
        c = curr // pow(2, idx)
        if c % 2 == 1:
            ans = "1" + ans
            curr -= pow(-2, idx)
        else:
            ans = "0" + ans
        idx += 1
    print(ans)

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

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

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

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

while n != 0:
  ans = str(n%base)+ans
  n = -(n//base)
if ans:
  print(ans)
else:
  print(0)

Solution (Python):

import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  
 
n = ni()
 
if n == 0:
    print(0)
else:
    s = ""
    while n != 0:
        
        if n % 2 != 0:
            n -= 1
            s = "1" + s
        else:
            s = "0" + s
        n //= -2
    print(s)

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

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

while abs(n) > 0:
    if(abs(n) % 2 == 0):
        s = "0" + s
    else:
        s = "1" + s
        n -= 1
    n = n // (-2)
print(s)

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

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

print(ans[::-1])

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

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

else:
    ans = []
    r = 1
    while n != 0:
        if n % (r*-2) == 0:
            ans.append('0')
        else:
            ans.append('1')
            n -= r
        r *= -2
print(''.join(reversed(ans)))

Solution (Python):
N = int(input())
s = []
if N == 0:
    print(N)
    exit()
while N:
    s.append(abs(N)%2)
    N -= 1
    N //= -2
for i in range(1,len(s)+1):
    print(s[-i], end='')

Solution (Python):
def main():
    N = int(input())
    S = ""

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

    else:
        while N:
            if N % 2:
                N -= 1
                S = "1" + S

            else:
                S = "0" + S

            N //= -2

        print(S)

    return


main()

Solution (Python):
def main():
    N = int(input())
    S = ''

    if N == 0:
        print(0)

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

            else:
                S = '0' + S

            N //= -2

        print(S)

    return


main()

Solution (Python):
def main():
    N = int(input())
    S = ""

    if N == 0:
        print(0)

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

            else:
                S = '0' + S

            N //= -2

        print(S)

    return


main()

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

Solution (Python):
from collections import deque

S = deque()


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

    while N:
        if (abs(N % -2) == 1):
            S.appendleft('1')
            N -= 1
        else:
            S.appendleft('0')
        N //= -2

    if not S:
        S.append('0')

    print(''.join(list(S)))
    return


main()

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

Solution (Python):
n = int(input())
ans = []
i=2
j=0
k = 0
while True:
    if k==n:
        break
    if (n-k)%i==0:
        ans.append(0)
    else:
        k += i>>1 if j%2==0 else -i>>1
        ans.append(1)
    i = i<<1
    j+=1

if n==0:
    print(0)
else:
    for i in ans[::-1]:
        print(i,end='')
    print()

Solution (Python):
def div_minus2(n: int)->tuple:
    """n を -2 で割ったときの商とあまりを計算する。
    """
    d = n // (-2)
    r = n % (-2)
    if r == -1:
        return d+1, 1
    return d, r


def base_2number(N: int) -> int:
    if N == 0:
        return '0'
    
    s = ''
    while N != 0:
        d, r = div_minus2(N)
        N = d
        s = str(r) + s

    return s


if __name__ == "__main__":
    N = int(input())
    ans = base_2number(N)
    print(ans)

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

Solution (Python):
n = int(input())
res = ""
if n == 0:
    print(0)
    exit(0)
while n!=1 and n != 0:
    if n%(-2):
        res = "1" + res
    else:
        res = "0" + res
    n = (-(n//2))
if n == 1:
    res = "1" + res
print(res)

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

Solution (Python):
import itertools
import bisect
N = int(input())
right = 0
left = 0
length = 0
for i in range(34):
    if N in [0,1]:
        break
    if (-2) ** i + left <= N and N <= (-2) ** i + right:
        length = i + 1
        break
    if i % 2 == 0:
        right += (-2) ** i
    else:
        left += (-2) ** i
ans = []
def bi(arr):
    if len(ans) >= length:
        return
    if (length-len(ans)) % 2 == 0:
        if bisect.bisect_right(arr,N) > len(arr)//2:
            ans.append(0)
            bi(arr[len(arr)//2:])
        else:
            ans.append(1)
            bi(arr[:len(arr)//2])
    else:
        if bisect.bisect_right(arr,N) > len(arr)//2:
            ans.append(1)
            bi(arr[len(arr)//2:])
        else:
            ans.append(0)
            bi(arr[:len(arr)//2])

if N == 0:
    print(0)
elif N == 1:
    print(1)
else:
    ans.append(1)
    bi(range((-2) ** (length-1) + left , (-2) ** (length-1) + right +1))
    ans = map(str, ans)
    print("".join(ans))

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

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

Solution (Python):
N = int(input())
ans = []
if N == 0:
    print(0)
    exit()
while not(N==0):
    a = -(N%(-2))
    b = (N-a)//(-2)
    N = b
    ans.append(str(a))
ans = [ans[-i-1] for i in range(len(ans))]
print("".join(ans))

Solution (Python):
n = int(input())
ans=[]
if n==0:
    print(0)
    exit()
while not(n==0):
    amari=-(n%(-2))
    shou=(n-amari)//(-2)
    n=shou
    ans.append(str(amari))
ans=[ans[-i-1] for i in range(len(ans))]
print(''.join(ans))

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

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

    print("1"+ans)

Solution (Python):
def solve():
    N = int(input())
    if N == 0:
        return 0
    ans = ''
    plusvalue = True
    plusbit = True
    if N < 0:
        N = -N
        plusvalue = False
    c = 0
    while N != 0 or c == 1:
        b = (N & 1) + c
        if b < 2:
            c = 0
        else:
            b -= 2
            c = 1
        N >>= 1
        if b == 0:
            ans = '0' + ans
        else:
            if plusvalue:
                ans = '1' + ans
                if not plusbit:
                    c += 1
            else:
                ans = '1' + ans
                if plusbit:
                    c += 1
        plusbit = not plusbit
    return ans

print(solve())

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

def hoge(x):
    if x%2==0:
        return x//(-2),0
    else:
        return x//(-2)+1,1


def base10_to_minus2(x):
    shou,amari=hoge(x)
    if shou:
        return base10_to_minus2(shou)+str(amari)
    return str(amari)

print(base10_to_minus2(n))

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

if N==0 or N==1:
  S=str(N)
else:
  while N!=1:
    if N%(-2)==-1:
      N=N//(-2)+1
      remainder=1
    else:
      N=N//(-2)
      remainder=0
    S=str(remainder)+S
    if N==1:
      S='1'+S

print(S)

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

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

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

print(S)

Solution (Python):
def main():
    N = int(input())
    ans = ""
    while N != 0:
        tmp = (-2) ** len(ans)
        if N % (tmp*-2) == 0:
            ans = "0" + ans
        else:
            ans = "1" + ans
            N -= tmp
    if ans == "":
        ans = "0"
    print(ans)


if __name__ == "__main__":
    main()

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

s = ""

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

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

Solution (Python):

import math
import sys


def solve(N):
  N_str = ''
  if N == 0:
    return('0')

  while(N != 0):
    r = N % 2
    if r < 0:
      r += 2
    N = (N-r)//(-2)
    N_str += str(r)
  return(N_str[::-1])


if __name__ == "__main__":
  N = int(sys.stdin.readline().rstrip())
  print(solve(N))

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

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

while n :
    if n%2 == 1:
        amari += "1"
        n -= 1
    else:
        amari += "0"
    n = n//-2
    
print(amari[::-1])

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

s=''
k=1
if n==0:
    s='0'
else:
    while n!=0:
        if abs(n)%abs((-2)**k)!=0:
            n-=(-2)**(k-1)
            s='1'+s
        else:
            s='0'+s
        k+=1
    
print(s)

Solution (Python):
n=int(input())
s=''
while n != 0:
    s = str( n % 2 ) + s
    n = - ( n // 2 )
print(s*(s != '') or 0)

Solution (Python):
N = int(input())
dig = []
def dmod(a, b):
  if a % b < 0:
    return [1, a//b+1]
  else:
    return [a%b, a//b]
while abs(N) > 1 :
  d, N = dmod(N, -2)
  dig.append(d)
if N == -1:
  dig += [1, 1]
else:
  dig.append(N)
dig.reverse()

n = ''.join(map(str, dig))
print(int(n))

Solution (Python):
N = int(input())
A = [[0,1] for _ in range(31)]
a = 1
for i in range(1,31):
    a *= -2
    A[i][0] = A[i-1][0] + min(0,a)
    A[i][1] = A[i-1][1] + max(0,a)
a = 1
for i in range(0,31):
    a *= -2
    A[i][0] += a
    A[i][1] += a
A = [[1,1]] + A
A = A[:32]

def main():
    if N==0:
        return '0'
    s = ''
    n = N
    flg = False
    for i in range(31, -1, -1):
        if A[i][0]<=n and n<=A[i][1]:
            s += '1'
            n -= (-2)**i
            flg = True
        else:
            if flg:
                s += '0'
    return s

print(main())

Solution (Python):
import sys

def main():
  input = sys.stdin.readline
  N = int(input())
  ans = ''
  if N == 0:
    ans = '0'
  else:
    while N != 0:
      if N % 2 == 0:
        ans = '0' + ans
        N //= -2
      else:
        ans = '1' + ans
        N = (N - 1) // -2
  print(ans)


if __name__ == '__main__':
  main()

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

s=''
k=1
if n==0:
    s='0'
else:
    while n!=0:
        if abs(n)%abs((-2)**k)!=0:
            n-=(-2)**(k-1)
            s='1'+s
        else:
            s='0'+s
        k+=1
    
print(s)

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

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

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

Solution (Python):

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

if S=="":
    S="0"

print(S)

Solution (Python):
import numpy as np
from functools import reduce

n = int(input())

X = 35
i = np.arange(X, dtype=np.int64)[::-1]


i = (-2)**i

ans = np.zeros(X, dtype=np.int64)

for digit in range(X):

	i[digit]
	sum_of_opposite = i[digit+1::2].sum() 

	if i[digit] > 0 and i[digit] + sum_of_opposite > n:
		ans[digit] = 0
	elif i[digit] < 0 and i[digit] + sum_of_opposite < n:
		ans[digit] = 0
	else:
		ans[digit] = 1
		n -= i[digit]


print(int(reduce(lambda x, y: str(x) + str(y), ans)))

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

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

Solution (Python):
from itertools import permutations


class Solver(object):
    def __init__(self):
        self.n = int(input())

    def solve(self):
        number_string = ""
        n = -self.n
        while True:
            remainder = abs(n % (-2))
            number_string = str(remainder) + number_string
            quotient = n // (-2)
            if quotient == 0:
                break
            n = quotient
        if (number_string == "") or (number_string == "0"):
            print("0")
        else:
            print(number_string.lstrip("0"))


if __name__ == "__main__":
    s = Solver()
    s.solve()

Solution (Python):

n=int(input())
L=[]
if n==0:
    print('0')
else:

    while n!=0:
        if n>0 and n%2==0:
            n=-n//2
            L.append('0')
        elif n>0 and n%2==1:
            n=(-n+1)//2
            L.append('1')
        elif n<0 and -n%2==0:
            n=-n//2
            L.append('0')
        elif n<0 and -n%2==1:
            n=(-n+1)//2
            L.append('1')
    print(int(''.join(L[::-1])))

Solution (Python):
n=int(input())
L=[]
if n==0:
    print('0')
else:    
    while n!=0:
        if n>0 and n%2==0:
            n=-n//2
            L.append('0')
        elif n>0 and n%2==1:
            n=(-n+1)//2
            L.append('1')
        elif n<0 and -n%2==0:
            n=-n//2
            L.append('0')
        elif n<0 and -n%2==1:
            n=(-n+1)//2
            L.append('1')
    print(int(''.join(L[::-1])))

Solution (Python):
n=int(input())
X=[]
i=0
while n!=0:
    t=2**i
    if n%(2*t)==0:
        X.append('0')
    else:
        X.append('1')
        if i%2:
            n+=t
        else:
            n-=t
    i+=1
if X==[]:
    print(0)
else:
    print(''.join(X[::-1]))

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

po_lst = [0]
a = 0
for i in range(0, 33, 2):
    a += 2**i
    po_lst.append(a)

ne_lst = [0]
a = 0
for i in range(1, 33, 2):
    a += (-2)**i
    ne_lst.append(a)

if n == 0:
    max_index = 0
elif n > 0:
    for k, i in enumerate(po_lst):
        if n < i:
            max_index = 2*(k-1)
            break
else:
    for k, i in enumerate(ne_lst):
        if n > i:
            max_index = 2*k-1
            break

def calcu(a, index, ans, po_lst, ne_lst):
    if index == -1:
        return ans
    elif a == 0:
        ans += '0'
        return calcu(a, index-1, ans, po_lst, ne_lst)
    else:
        b = (-2)**index
        if b > 0:
            k = (index // 2) + 1
            if a > po_lst[k-1]:
                a -= b
                ans += '1'
            else:
                ans += '0'
        else:
            k = (index+1) // 2
            if a < ne_lst[k-1]:
                a -= b
                ans += '1'
            else:
                ans += '0'
        return calcu(a, index-1, ans, po_lst, ne_lst)

print(calcu(n, max_index, '', po_lst, ne_lst))

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

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

print(ans[::-1])

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

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

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

Solution (Python):
def r(k):
    if k == -1:
        return 0, 0
    if k == 0:
        return 0, 1
    else:
        low, high = r(k - 1)
        d = pow(-2, k)
        if d < 0:
            return low + d, high
        else:
            return low, high + d


def solve(N):
    if N == 0:
        return "0"
    ar = []
    for k in range(50, -1, -1):
        low1, high1 = r(k - 1)
        low2, high2 = r(k)
        if not (low1 <= N <= high1) and low2 <= N <= high2:
            ar.append("1")
            N -= pow(-2, k)
        else:
            ar.append("0")
    ans = "".join(ar)
    ans = ans[ans.find("1"):]
    return ans


if __name__ == "__main__":
    N = int(input())
    print(solve(N))

Solution (Python):
N = int(input())
s = ""
while N != 0:
    s = str(N%2)+s
    N = - (N//2)

print(s * (s != "") or 0)

Solution (Python):


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

if N >= 0:
    b = bin(N)[2:]

    lst = [0 for _ in range(len(b)+10)]

    for e,s in enumerate(reversed(b)):
        if e % 2 == 0:
            lst[e] += int(s)
        elif e % 2 == 1:
            lst[e] += int(s)
            lst[e+1] += int(s)

    for e,s in enumerate(lst):
        if s >= 2:
            
            while lst[e] > 1:
                lst[e] -= 2
                if lst[e+1] > 0:
                    lst[e+1] -= 1
                else:
                    lst[e+1] += 1
                    lst[e+2] += 1
            
            
            
            
            
            
            
            

    flag = False
    for s in "".join(map(str, reversed(lst))):
        if not flag and s=="0":
            continue
        else:
            flag = True
            print(s, end="")
    print()
else:
    b = bin(N)[3:]
    lst = [0 for _ in range(100)]
    for e,s in enumerate(reversed(b)):
        if e % 2 == 0:
            lst[e] += int(s)
            lst[e+1] += int(s)
        else:
            lst[e] += int(s)


    for e,s in enumerate(lst):
        if s >= 2:
            while lst[e] > 1:
                lst[e] -= 2
                if lst[e+1] > 0:
                    lst[e+1] -= 1
                else:
                    lst[e+1] += 1
                    lst[e+2] += 1

    flag = False


    for s in "".join(map(str, reversed(lst))):
        if not flag and s == "0":
            continue
        else:
            flag = True
            print(s, end="")
    print()

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

plus = []
minus = []
plus_sum = []
minus_sum = []

s_p = 0
s_m = 0
for i in range(31):
    if i % 2 == 0:
        plus.append(2**i)
        s_p += 2**i
        plus_sum.append(s_p)
    else:
        minus.append(2**i)
        s_m += 2**i
        minus_sum.append(s_m)

def ten_four(num):
    def for_four(num, arr):
        if num == 0:
            if arr == []:
                return '0'
            else:
                arr_str = map(str, arr[::-1])
                ans = (''.join(arr_str))
                return ans
        else:
            s = num // 4
            a = num % 4
            arr.append(a)
            return for_four(s, arr)
    
    arr = []
    return for_four(num, arr)


if n == 0:
    print(0)
elif n == 1:
    print(1)
elif n == -1:
    print(11)
elif n == -2:
    print(10)

elif n > 0:
    for i in range(len(plus_sum)):
        if n <= plus_sum[i]:
            max_4 = i - 1
            n_4 = n - 1 - plus_sum[max_4]
            break
        else:
            pass
    n_4zf = ten_four(n_4).zfill(max_4 + 1)
    n_ans = n_4zf.translate(str.maketrans({'0': '10', '1': '11', '2': '00', '3': '01'}))
    print('1'+n_ans)

elif n < 0:
    n_1 = n % 2
    n = int(abs((n - n_1)/2))
    for i in range(len(plus_sum)):
        if n <= plus_sum[i]:
            max_4 = i - 1
            n_4 = n - 1 - plus_sum[max_4]
            break
        else:
            pass
    n_4zf = ten_four(n_4).zfill(max_4 + 1)
    n_ans = n_4zf.translate(str.maketrans({'0': '10', '1': '11', '2': '00', '3': '01'}))
    print('1'+n_ans+str(n_1))

Solution (Python):


















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


N = int(input())

ans = ""
cnt = 0

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

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

Solution (Python):
import math


def division(a, b):
    if b == 0:
        raise ZeroDivisionError()
    if a == 0:
        return 0, 0
    if a > 0 and b > 0:
        q = math.floor(a / b)
        return q, a - b * q
    if a > 0 and b < 0:
        q = math.ceil(a / b)
        return q, a - b * q
    if a < 0 and b > 0:
        q = math.floor(a / b)
        return q, a - b * q
    if a < 0 and b < 0:
        q = math.ceil(a / b)
        return q, a - b * q


def Ans(N, B):
    ans = ''
    while(N != 0):
        N, r = division(N, B)
        ans += str(r)
    if ans:
        print(ans[::-1])
    else:
        print(0)


if __name__ == '__main__':
    N = int(input())
    Ans(N, -2)

Solution (Python):
n = int(input())
s = ''
i = 1
while(n != 0):
  nt = abs(n)
  res = 1 if (nt & abs(i)) else 0
  s = str(res) + s
  n -= res * i
  i *= -2
print(s if len(s) else 0)

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

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

S = []

while abs(N)>0:
    x = N%2
    S.append(str(x))
    if len(S)%2 ==0:
        N = (N+x)//2
    else:
        N //= 2

S.reverse()

if len(S)==0:
    S=['0']
    
print(''.join(S))

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

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

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

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

if ans == '':
    ans = '0'

print(ans[::-1])

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

def solve(n):

    tmp = 0
    ans = 0
    if n > 0:
        b = bin(n)[2:]
        for i,c in enumerate(b):
            if (len(b)-i)%2 == 0:
                if int(c) == 1:
                    tmp += 11*10**(len(b)-i-1)
            else:
                tmp += int(c)*10**(len(b)-i-1)
    elif n < 0:
        b = bin(abs(n))[2:]
        for i,c in enumerate(b):
            if(len(b)-i)%2 == 1:
                if int(c) == 1:
                    tmp += 11*10**(len(b)-i-1)
            else:
                tmp += int(c)*10**(len(b)-i-1)

    tmp = str(tmp)
    while '2' in tmp:
        ans = 0
        for i,c in enumerate(tmp):
            o = len(tmp)-i-1
            if int(c) >= 2:
                if (ans//(10**(len(tmp)-i)))%10 > 0:
                    ans += (int(c)-2-10)*10**o
                else:
                    ans += (110+int(c)-2)*10**o
            else:
                ans += int(c)*10**(len(tmp)-i-1)
        
        tmp = str(ans)
    
    return tmp


print(solve(n))

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

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

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


main()

Solution (Python):

import sys
import bisect


"""Template"""


class IP:
    """
    入力を取得するクラス
    """
    def __init__(self):
        self.input = sys.stdin.readline

    def I(self):
        """
        1文字の取得に使います
        :return: 数
        """
        return int(input())

    def IL(self):
        """
        1行を空白で区切りリストにします(int
        :return: リスト
        """
        return list(map(int, self.input().split()))

    def SL(self):
        """
        1行の文字列を空白区切りでリストにします
        :return: リスト
        """
        return list(map(str, self.input().split()))

    def ILS(self, n):
        """
        1列丸々取得します(int
        :param n: 行数
        :return: リスト
        """
        return [int(self.input()) for _ in range(n)]

    def SLS(self, n):
        """
        1列丸々取得します（str
        :param n: 行数
        :return: リスト
        """
        return [self.input() for _ in range(n)]


class Idea:
    def __init__(self):
        pass

    def HF(self, p):
        """
        Half enumeration
        半分全列挙です
        pの要素の和の組み合わせを作ります。
        ソート、重複削除行います
        :param p: list : 元となるリスト
        :return: list : 組み合わせられた和のリスト
        """
        return sorted(set(p[i] + p[j] for i in range(len(p)) for j in range(i, len(p))))

    def Bfs2(self, a):
        """
        bit_full_search2
        bit全探索の改良版
        全探索させたら2進数のリストと10進数のリストを返す
        :return: list２つ : １個目 2進数(16桁)  2個目 10進数で合計
        """
        
        
        
        value = []
        for i in range(1 << len(a)):
            output = []

            for j in range(len(a)):
                if ((i >> j) & 1) == 1:
                    """右からj+1番目のiが1かどうか判定"""
                    
                    output.append(a[j])
            value.append([format(i, 'b').zfill(16), sum(output)])

        value.sort(key=lambda x: x[1])
        bin = [value[k][0] for k in range(len(value))]
        val = [value[k][1] for k in range(len(value))]
        return bin, val


"""ここからメインコード"""


def main():
    """クラス呼び出し等行うよ"""
    
    r, e = range, enumerate
    ip = IP()
    id = Idea()

    """この下から書いてね"""

    """コピーコードです。"""
    n = ip.I()
    s = ''
    while True:
        r = n % (-2)
        n //= -2
        if r < 0:
            r += 2
            n += 1
        s += str(r)
        if n == 0: break
    print(s[::-1])


main()

Solution (Python):

import sys
import bisect


"""Template"""


class IP:
    """
    入力を取得するクラス
    """
    def __init__(self):
        self.input = sys.stdin.readline

    def I(self):
        """
        1文字の取得に使います
        :return: 数
        """
        return int(input())

    def IL(self):
        """
        1行を空白で区切りリストにします(int
        :return: リスト
        """
        return list(map(int, self.input().split()))

    def SL(self):
        """
        1行の文字列を空白区切りでリストにします
        :return: リスト
        """
        return list(map(str, self.input().split()))

    def ILS(self, n):
        """
        1列丸々取得します(int
        :param n: 行数
        :return: リスト
        """
        return [int(self.input()) for _ in range(n)]

    def SLS(self, n):
        """
        1列丸々取得します（str
        :param n: 行数
        :return: リスト
        """
        return [self.input() for _ in range(n)]


class Idea:
    def __init__(self):
        pass

    def HF(self, p):
        """
        Half enumeration
        半分全列挙です
        pの要素の和の組み合わせを作ります。
        ソート、重複削除行います
        :param p: list : 元となるリスト
        :return: list : 組み合わせられた和のリスト
        """
        return sorted(set(p[i] + p[j] for i in range(len(p)) for j in range(i, len(p))))

    def Bfs2(self, a):
        """
        bit_full_search2
        bit全探索の改良版
        全探索させたら2進数のリストと10進数のリストを返す
        :return: list２つ : １個目 2進数(16桁)  2個目 10進数で合計
        """
        
        
        
        value = []
        for i in range(1 << len(a)):
            output = []

            for j in range(len(a)):
                if ((i >> j) & 1) == 1:
                    """右からj+1番目のiが1かどうか判定"""
                    
                    output.append(a[j])
            value.append([format(i, 'b').zfill(16), sum(output)])

        value.sort(key=lambda x: x[1])
        bin = [value[k][0] for k in range(len(value))]
        val = [value[k][1] for k in range(len(value))]
        return bin, val


"""ここからメインコード"""


def main():
    
    r, e = range, enumerate
    ip = IP()
    id = Idea()

    """コピーコードです。https://atcoder.jp/contests/abc105/submissions/4088632 
    こちらを参考にテストを行っています。"""
    n = ip.I()
    
    list1 = [(-2) ** i for i in r(16)]
    list2 = [(-2) ** (i + 16) for i in r(16)]
    list1_bin, list1_val = id.Bfs2(list1)
    list2_bin, list2_val = id.Bfs2(list2)

    
    ans = 0
    for i in r(len(list1_val)):
        j = bisect.bisect_left(list2_val, n - list1_val[i])

        if j < len(list2_val) and list1_val[i] + list2_val[j] == n:
            ans = list2_bin[j] + list1_bin[i]
            break
    print(int(ans))


main()