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



Sample input:
-9


Sample output:
1011

Submission status: Wrong Answer

Solution code:
def is_even(n):
    if n % 2 == 0:
        return True
    else:
        return False

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

    k =[]
    if N == 0:
        print(0)
        exit()

    if is_even(N):
        k.append(0)
    else:
        N -= 1
        k.append(1)

    for i in range(1,100):
        if (N // (-2)**i) % 2 == 1:
            N -= (-2)**i
            k.append(1)

        else:
            k.append(0)

        if N == 0:
            break

    print(k[::-1])
    
if __name__ == "__main__":
    mainas_number()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import math

N = int(input().split()[0])
s = ""

for i in range(0, math.ceil(math.log2(10 ** 9)) + 1):
    s = str(N % 2) + s
    N = -(N // 2)

ans = s.lstrip("0")
ans = "0" if ans == "" else ans
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import math

N = int(input().split()[0])
s = ""

for i in range(1, math.ceil(math.log2(10 ** 9)) + 1):
    s = str(N % 2) + s
    N = -(N // 2)

ans = s.lstrip("0")
ans = "0" if ans == "" else ans
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

# 1 : 1
# 2 : 110
# 3 : 111
# 4 : 100
# 5 : 101
# 6 : 11010
# 7 : 11011
# 8 : 11000
# 9 : 11001

if N == 0:
    print(0)
else:
    ans = []
    k = 1
    for k in range(30):
        if (N // ((-2)**k)) % 2 == 1:
            N -= (-2)**k
            ans.append("1")
        else:
            ans.append("0")
    k = -1
    for i in reversed(range(len(ans))):
        if ans[i] == "1":
            k = i
            break

    print("".join(reversed(ans[:k+1])))

Submission status: Wrong Answer

Solution code:
N = int(input())
k=[]
if N%2==1:
  N = N-1
  k.append(1)
else:
  k.append(0)
for i in range(1,50):
  if (N//(-2)**i)%2==1:
    N -=(-2)**i 
    k.append(1)
  else:
    k.append(0)
  if N==0:
    break
for i in range(len(k)-1,-1,-1):
  print(k[i],end="")

"""
for bit in range(1<<30):
  ans = 0
  an = 0
  for i in range(30):
    if bit&(1<<i):
      an += k[i]
      ans += 1<<i
  if an==N:
    ans =  format(ans, 'b')
    print(ans)
    exit()
"""

Submission status: Wrong Answer

Solution code:
N = int(input())
k=[]
if N%2==1:
  N = N-1
  k.append(1)
for i in range(1,1000):
  if (N//(-2)**i)%2==1:
    N -=(-2)**i 
    k.append(1)
  else:
    k.append(0)
  if N==0:
    break
for i in range(len(k)-1,-1,-1):
  print(k[i],end="")

"""
for bit in range(1<<30):
  ans = 0
  an = 0
  for i in range(30):
    if bit&(1<<i):
      an += k[i]
      ans += 1<<i
  if an==N:
    ans =  format(ans, 'b')
    print(ans)
    exit()
"""

Submission status: Wrong Answer

Solution code:
N = int(input())
k=[]
if N%2==1:
  N = N-1
  k.append(1)
for i in range(1,50):
  if (N//(-2)**i)%2==1:
    N -=(-2)**i 
    k.append(1)
  else:
    k.append(0)
  if N==0:
    break
for i in range(len(k)-1,-1,-1):
  print(k[i],end="")

"""
for bit in range(1<<30):
  ans = 0
  an = 0
  for i in range(30):
    if bit&(1<<i):
      an += k[i]
      ans += 1<<i
  if an==N:
    ans =  format(ans, 'b')
    print(ans)
    exit()
"""

Submission status: Wrong Answer

Solution code:
N = int(input())
k=[]
if N%2==1:
  N = N-1
  k.append(1)
for i in range(1,31):
  if (N//(-2)**i)%2==1:
    N -=(-2)**i 
    k.append(1)
  else:
    k.append(0)
  if N==0:
    break
for i in range(len(k)-1,-1,-1):
  print(k[i],end="")

Submission status: Wrong Answer

Solution code:
N = int(input())

ans = ""

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

Submission status: Wrong Answer

Solution code:
N = int(input())

ans = ""

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = []
cnt = 0
while n != 0:
    ans.append(str(n % 2))
    n -= (n//2)
print(''.join(ans))

Submission status: Wrong Answer

Solution code:
n=int(input())
ans=""
if n==0:print("0");exit()
while n!=0:
    ans +=str(n%2)
    n=n//(-2)
print("".join(ans[::-1]))

Submission status: Wrong Answer

Solution code:
n=int(input())
ans=""
if n==0:print("0");exit()
while n!=0:
    ans +=str(n%2)
    n=n//-2
print("".join(ans[::-1]))

Submission status: Wrong Answer

Solution code:
n=int(input())
count=0
box=[]
while -10**9<=(-2)**count<=10**9:
    box.append((-2)**count)
    count +=1

box_p=[box[i] for i in range(0,len(box)-1,2)]
box_m=[box[i] for i in range(1,len(box),2)]

p_acc=[box_p[i]+sum(box_p[:i]) for i in range(len(box_p))]
m_acc=[box_m[i]+sum(box_m[:i]) for i in range(len(box_m))]

point=0
if n>0:
    for i,j in enumerate(p_acc):
        if j>=n:
            point=i*2+1
            break
elif n<0:
    for i,j in enumerate(m_acc):
        if j<=n:
            point=(i+1)*2
            break
else:print(0);exit()

ans=""
count=0
ans_box=[box[i] for i in range(point)]
if n>0:
    for i in ans_box[::-1]:
        if count==n:
            ans +="0"
        else:
            if i>0:
                if count<n:
                    count +=i
                    ans +="1"
                else:ans +="0"
            else:
                if count>n:
                    count +=i
                    ans +="1"
                else:ans +="0"
else:
    for i in ans_box[::-1]:
        if count==n:
            ans +="0"
        else:
            if i>0:
                if count<n:
                    count +=i
                    ans +="1"
                else:ans +="0"
            else:
                if count>n:
                    count +=i
                    ans +="1"
                else:ans +="0"

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
print(bin(N)[3:] if N != 0 else 0)

Submission status: Wrong Answer

Solution code:
N = int(input())
print(bin(N)[2:])

Submission status: Wrong Answer

Solution code:
invtwos = [1]
i = 0
while abs(invtwos[i]) <= 10**10:
    invtwos.append(invtwos[i]*(-2))
    i += 1
invtwos.append(invtwos[-1]*(-2))

n = int(input())
ans = []
i = 0
while n != 0:
    if n%abs(invtwos[i+1]) != 0:
        ans.append(1)
        n -= invtwos[i]
    else:
        ans.append(0)
    i += 1
ans.reverse()
if n == 0:
    print("0")
else:
    for i in range(len(ans)):
        if i != len(ans)-1:
            print(ans[i],end="")
        else:
            print(ans[i])

Submission status: Wrong Answer

Solution code:
from collections import deque
import sys
n = int(input())
k = 1
if n < 0:
    k = 0
    n = -n
if n == 0:
    print(0)
    sys.exit()
ans = deque([])
while n > 0:
    if n % 2 == 0:
        ans.appendleft("0")
    else:
        ans.appendleft("1")
    n = n // 2
if k:
    print(int("".join(ans)))
else:
    print(int("-"+"".join(ans)))

Submission status: Wrong Answer

Solution code:
N = int(input())

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

        print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

ans, d = '', 2
while abs(N) > 0:
    ans = '0' + ans if N % d == 0 else '1' + ans
    N, d = N - N % d, d * (-2)

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
n = int(input())
if n == 0:
  print('0')
  sys.exit()
t = []
while n != 0:
  r = n % 2
  t.append(str(r))
  n = (n - r) // -2
print(t[::-1])

Submission status: Wrong Answer

Solution code:
N = int(input())
ans = []

while N != 0:
    r = N % 2
    r = abs(r)
    N = (N - r) // -2
    ans.append(str(r))
ans.reverse()
print(''.join(ans))

Submission status: Wrong Answer

Solution code:
n = int(input())
digit = 1
ex = ""
while(n):
    if n%2==0:
        ex='0'+ex
    else:
        ex='1'+ex
        n-=-1+2*(digit%2)
    n=n//2
    digit+=1
print(ex)

Submission status: Wrong Answer

Solution code:
n = -9
digit = 1
ex = ""
while(n):
    if n%2==0:
        ex='0'+ex
    else:
        ex='1'+ex
        n-=-1+2*(digit%2)
    n=n//2
    digit+=1
print(ex)

Submission status: Wrong Answer

Solution code:
line = raw_input()
n = int(line)
ret = []
while n != 0:
    a = n % 2
    ret.insert(0, a)
    n = (n - a) / -2
print ''.join(str(i) for i in ret)

Submission status: Wrong Answer

Solution code:
n=int(input())
k=-2
bi=''
while n!=0:
    bi+=str(n%abs(k))
    if k<0:n=-(-n//k)
    else:n=n//k
print(bi[::-1])

Submission status: Wrong Answer

Solution code:
import sys
import math
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
ans = ""
if n == 0:
    print("0")
else:
    ans = "1"
    while True:
        s = n // (-2)
        a = n % (-2)
        if a != 0:
            ans += "0"
        else:
            ans += "1"
        n = s
        if n == 1 or n == 0:
            break
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N=int(input())
def B10n(X, n):
  if (int(X/n)):
    return B10n(int(X/n), n)+str(X%n)
  return str(X%n)
ans=B10n(N,-2)
print(ans.replace("-",""))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
x = ''

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

Submission status: Wrong Answer

Solution code:
import math

N = int(input())

def calc_power(num):
    if num > 1:
        m = 5
        power = 2
        while True:
            if num <= m:
                return_num = power
                break
            else:
                m = m * 4 + 1
                power += 2 
    elif num == 1:
        return_num = 0
    elif num == 0:
        print('0')
        exit()
    else:
        m = -2
        power = 1
        while True:
            if num >= m:
                return_num = power
                break
            else:
                m = m * 4 - 2
                power += 2

    return return_num

num = N
pre_power = calc_power(N) + 1
ans = ''
while num != 0:
    power = calc_power(num)
    num -= (-2) ** power
    if power == pre_power - 1:
        ans += '1'
    else:
        for _ in range(pre_power - 1 - power):
            ans += '0'
        ans += '1'
    if num == 0:
        for _ in range(power - 1):
            ans += '0'
    pre_power = power

print(ans)

Submission status: Wrong Answer

Solution code:
import math

N = int(input())

def calc_power(num):
    if num > 1:
        m = 5
        power = 2
        while True:
            if num <= m:
                return_num = power
                break
            else:
                m = m * 4 + 1
                power += 2 
    elif num == 1:
        return_num = 0
    elif num == 0:
        print('0')
        exit()
    else:
        m = -2
        power = 1
        while True:
            if num >= m:
                return_num = power
                break
            else:
                m = m * 4 - 2
                power += 2

    return return_num

num = N
pre_power = calc_power(N) + 1
ans = ''
while num != 0:
    power = calc_power(num)
    num -= (-2) ** power
    if power == pre_power - 1:
        ans += '1'
    else:
        for _ in range(pre_power - 1 - power):
            ans += '0'
        ans += '1'
    pre_power = power

print(ans)

Submission status: Wrong Answer

Solution code:
import math

N = int(input())

def calc_power(num):
    if num > 1:
        m = 5
        power = 2
        while True:
            if num <= m:
                return_num = power
                break
            else:
                m = m * 4 + 1
                power += 2 
    elif num == 1:
        return_num = 0
    elif num == 0:
        print('0')
        exit()
    else:
        m = -2
        power = 1
        while True:
            if num >= m:
                return_num = power
                break
            else:
                m = m * 4 - 2
                power += 2

    return return_num

num = N
pre_power = calc_power(N) + 1
ans = ''
while num != 0:
    power = calc_power(num)
    print(num, power)
    num -= (-2) ** power
    if power == pre_power - 1:
        ans += '1'
    else:
        for _ in range(pre_power - 1 - power):
            ans += '0'
        ans += '1'
    pre_power = power

print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
ans=[]
while(n!=0):
    if(n%(-2)==0):
        ans+=[0]
        n=n//-2
    else:
        ans+=[1]
        n=(n-1)//-2

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

Submission status: Wrong Answer

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

while True:
    if n % -2 == -1:
        ans.append(1)
        n //= -2
        n += 1
    else:
        ans.append(n % -2)
        n //= -2
    if n == 1 or n == 0:
        break
ans.append(n)
result = map(str, ans[::-1])
print("".join(result))

Submission status: Wrong Answer

Solution code:
n=int(input())
ans=""
while n!=0:
  ans=str(n%2)+ans
  n=-(n//2)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())

B = ""
i = 0
while N != 0:
  B = str(abs(N % (-2))) + B
  if i % 2 == 0:
    N = (N + (N % (-2))) // 2
  else:
    N = (N - (N % (-2))) // 2
  i += 1
else:
  print (0)
print (B)

Submission status: Wrong Answer

Solution code:
N = int(input())

B = ""
i = 0
while N != 0:
  B = str(abs(N % (-2))) + B
  if i % 2 == 0:
    N = (N + (N % (-2))) // 2
  else:
    N = (N - (N % (-2))) // 2
  i += 1

print (B)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = []
div = -2
i = 0
while n!=0:
    r = n % div
    if r == 0:
        s.append(0)
    else:
        s.append(1)
        n -= (-2) ** i
    div *= 2
    i += 1
ans = ""
for i in range(len(s)):
    ans =  str(s[i]) + ans
if n != 0:
    print(ans)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = []
div = -2
i = 0
while n!=0:
    r = n % div
    if r == 0:
        s.append(0)
    else:
        s.append(1)
        n -= (-2) ** i
    div *= 2
    i += 1
ans = ""
for i in range(len(s)):
    ans =  str(s[i]) + ans
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = []
div = -2
i = 0
while n!=0:
    r = n % div
    if r == 0:
        s.append(0)
    else:
        s.append(1)
        n -= (-2) ** i
    div *= 2
    i += 1
s = map(str, s)

print("".join(s))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = []
if n % 2 == 1:
    s.append(1)
elif n % 2 == 0:
    s.append(0)
a = (-2) ** 0 * s[0]
div = 4
while a != n:
    r = n % div
    r_0 = 0
    for i in range(len(s)):
        r_0 += (-2) ** i * s[i]
    if r_0 % div == r:
        s.append(0)
    else:
        s.append(1)
    div *= 2
    a += (-2) ** (len(s)-1) * s[-1]

s = map(str, s)

print("".join(s))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = 0
l = []

if n == 0:
    l.append('0')

while n:
    if n % 2:
        l.append('1')
    else:
        l.append('0')
    n = -(n // 2)

print(''.join(reversed(l)))

Submission status: Wrong Answer

Solution code:
n = 0
l = []

if n == 0:
    l.append('0')

while n:
    if n % 2:
        l.append('1')
    else:
        l.append('0')
    n = -(n // 2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

flaga=True
S='1'
N=int(input())
D=N
flag=0
p=1
K=0
if N==0:
    print(0)
    exit(0)
elif N==1:
    print(1)
    exit(0)
elif N>0:
    D-=1
    while flag==0:
        if D+1-p>0:
            D-=p
            p*=4
            K+=2
        else:
            print(D)
            for i in range(K):
                if D<p//2:
                    if flaga==True:
                        S +='1'
                    else:
                        S +='0'
                else:
                    D-=p//2
                    if flaga==True:
                        S +='0'
                    else:
                        S +='1'
                p=p//2
                flaga = not flaga
            print(S)
            exit(0)
else:
    D=abs(D)-2
    while flag==0:
        if D+1-p>0:
            D-=p
            p*=4
            K+=2
            print(D,p)
        else:
            p*=2
            print(D)
            for i in range(K+1):
                if D<p//2:
                    if flaga==True:
                        S +='1'
                    else:
                        S +='0'
                else:
                    D-=p//2
                    if flaga==True:
                        S +='0'
                    else:
                        S +='1'
                p=p//2
                flaga = not flaga
            print(S)
            exit(0)

Submission status: Wrong Answer

Solution code:
from sys import stdin
N = int(stdin.readline().rstrip())

S = ""

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

if N == 1:
    S = "0"

print(S)

Submission status: Wrong Answer

Solution code:
"""
N進数
下記を繰り返して構築
NからNで割ったあまりを引く
そっからNで割る
"""
N = int(input())
ans = ""
mod = -2 
while N!=0:
    d = N % abs(mod)
    ans = str(d) + ans
    N -= d
    N //= mod
    # print(N)
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())


ans = ""

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

if n == 0:
    ans = 0

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())


ans = ""

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

Submission status: Wrong Answer

Solution code:
n = int(input())


ans = ""

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
n = int(input())
s=[]
i=0
if n==0:
  print(0)
  sys.exit()
while n > 0:
  if n%(2**(i+1))!=0:
    a=1
  else:
    a=0
  s.append(a)
  n=n-a*(-2)**i
  i+=1

s.reverse()
m=""
for ss in s:
  m+=str(ss)
print(m)

Submission status: Wrong Answer

Solution code:
N = int(input())
M = abs(N)
if N >= 0:
    for k in range((M.bit_length()+1)//2):
        if ((M >> 2*k+1) & 1) == 1:
            N += 4**(k+1)
    print(bin(N)[2:])
else:
    for k in range((M.bit_length()+1)//2):
        if ((M >> 2*k) & 1) == 1:
            N -= 2**(2*k+1)
    print(bin(N)[3:])

Submission status: Wrong Answer

Solution code:
N = int(input())
M = abs(N)
if N >= 0:
    for k in range((M.bit_length()+1)//2):
        if ((N >> 2*k+1) & 1) == 1:
            N += 4**(k+1)
    print(bin(N)[2:])
else:
    for k in range((M.bit_length()-1)//2):
        if ((N >> 2*k) & 1) == 1:
            N -= 2*4**k
    print(bin(N)[3:])

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n, k = LI()
    if n % k:
        print(1)
    else:
        print(0)
    return

#B
def B():
    n = II()
    dp = [0] * (100 + 1)
    dp[4] = 1
    dp[7] = 1
    for i in range(8,n + 1):
        if dp[i - 4] or dp[i - 7]:
            dp[i] = 1
    print(["No", "Yes"][dp[n]])
    return

#C
def C():
    n = II()
    ans = []
    while n:
        ans.append("{}".format(n % 2))
        n = (n-1) // -2
    print("".join(ans[::-1]))
    return

#D
def D():
    return

#Solve
if __name__ == '__main__':
    C()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
#ABC105C
import sys

n = int(input())
#tmp = input().split()
#hoge = list(map(lambda a: int(a), tmp))

res=[]

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

res2=""
for i in range(0,len(res)):
	#res2=res2+str(res[len(res)-i-1])
	res2=res2+str(res[-i-1])
print(res2)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
#ABC105C
import sys

n = int(input())
#tmp = input().split()
#hoge = list(map(lambda a: int(a), tmp))

res=[]

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

res2=""
for i in range(0,len(res)):
	res2=res2+str(res[len(res)-i-1])
print(res2)

Submission status: Wrong Answer

Solution code:
n=int(input())
ans=[]
if n==0:
    print(0)
    exit()
    
for i in range(100):
    if  n==0:
        break
    if n%(2**(i+1))==0:
        ans.append('0')
    else:
        if i%2==0:
            n-=2**i
        else:
            n+=2**i
        ans.append('1')

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

Submission status: Wrong Answer

Solution code:
n=int(input())
ans=[]
if n==0:
    print(0)
    exit()
    
for i in range(100):
    if  n==0:
        break
    if n%(2**(i+1))==0:
        ans.append(0)
    else:
        if i%2==0:
            n-=2**i
        else:
            n+=2**i
        ans.append(1)
ans.reverse()
print(*ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

def max_positive_num(L):
    val = 0
    for i in range(L):
        if i % 2 == 0:
            val = val + 2 ** i
    return val


def min_negative_num(L):
    val = 0
    for i in range(L):
        if i % 2 == 1:
            val = val - 2 ** i
    return val


# 与えた数字に対して最大のビット数を返す
def maxbit(num):
    count = 0
    while not (min_negative_num(count) <= num <= max_positive_num(count)):
        count = count + 1
    return count

bitlist = [0]*maxbit(N)

rest = N
for i in range(maxbit(N), 0, -1):
    if i % 2 == 0:
        if (min_negative_num(i) <= rest < min_negative_num(i-1)):
            bitlist[i-1] = 1
            rest = rest - pow(-2,(i-1))
    else:
        if (max_positive_num(i-1) < rest <= max_positive_num(i)):
            bitlist[i-1] = 1
            rest = rest - pow(-2,(i-1))

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

Submission status: Wrong Answer

Solution code:
N = int(input())
i = 0
ans = []
while N:
  if N%(2)**(i+1) > 0:
    ans.append(1)
    N -= (-2)**i
  else:
    ans.append(0)
  i += 1
ans.reverse()
print("".join(map(str,ans)))

Submission status: Wrong Answer

Solution code:
n=int(input())
ans=""
i=1
while True:
  if n==0:break
  else:
    if n%(2**i)==0:ans="0"+ans;i+=1
    else:ans="1"+ans;n-=(-2)**(i-1);i+=1
print(ans if ans!="0" else 0)

Submission status: Wrong Answer

Solution code:
n=int(input())
ans=""
i=1
while True:
  if n==0:break
  else:
    if n%(2**i)==0:ans="0"+ans;i+=1
    else:ans="1"+ans;n-=(-2)**(i-1);i+=1
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
ans=""
i=1
while True:
  if n==0:break
  else:
    if n%(2**i)==0:ans="0"+ans;n-=2**i;i+=1
    else:ans="1"+ans;n-=2**i;i+=1
print(ans)

Submission status: Wrong Answer

Solution code:
N = input()
S = format(int(N), 'b')
print(S)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = format(N, 'b')
print(S)

Submission status: Wrong Answer

Solution code:
N = int(input())
if N < 0:
    N = N * -1
S = format(N, 'b')
print(str(S))

Submission status: Wrong Answer

Solution code:
N = int(input())

if N < 0:
    N = N * -1
S = format(N, 'b')
print(S)

Submission status: Wrong Answer

Solution code:
N = int(input())
ite = 0
ans = 0
while(abs(N) > 1):
    if abs(N) % 2 != 0:
        ans += 10**ite
    N = N//2
    ite += 1

print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
div=2
ite=1
ans=0
while(abs(N)>1):
    if abs(N) % 2 !=0:
        ans+=10**(ite-1)
    N=N//2
    ite*=2

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

ret = ''
base = 1
while N != 0:
    if N % (base * 2):
        ret = '1' + ret
        N -= base
    else:
        ret = '0' + ret
    base *= -2

print(ret)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

ret = ''
base = 1
while N != 0:
    if N % (base * 2):
        ret = '1' + ret
        N -= base
    else:
        ret = '0' + ret
    base *= -2

print(ret)

Submission status: Wrong Answer

Solution code:
n = int(raw_input())
def positive(n):
    m = 1
    d = 0
    while m < n:
        d += 2
        m += 2**d
    d -= 1
    s = "1"
    while d >= 0:
        if d % 2 == 1:
            if m + (-2)**d >= n:
                s += "1"
                m += (-2)**d
            else:
                s += "0"
        else:
            if m - 2**d >= n:
                m -= 2**d
                s += "0"
            else:
                s += "1"
        d -= 1
    return s
            
def negative(n):
    if n == -1:
        return "11"
    m = -2
    d = 1
    while m > n:
        d += 2
        m += (-2)**d
    print m
    s = "1"
    d -= 1
    while d >= 0:
        if d % 2 == 0:
            if m + 2**d <= n:
                s += "1"
                m += 2**d
            else:
                s += "0"
        else:
            if m - (-2)**d <= n:
                s += "0"
                m -= (-2)**d
            else:
                s += "1"
        d -= 1
    return s

def makeS(n):
    if n == 0:
        return "0"
    elif n > 0:
        return positive(n)
    else:
        return negative(n)
print makeS(n)

Submission status: Wrong Answer

Solution code:
## ABC105C - Base -2 Number
def main():
    n = int(input())
    ans = ""
    while n != 0:
        r = n % 2
        r += 2 if r < 0 else 0
        n = (n - r) // -2
        ans += str(r)
    print(ans[::-1])


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
bin_n = bin(n)
ranges = []

def base_minus2(m, i, s):
    tmp = s
    if i == 1:
        return tmp + str(m%2)
    for j in range(i-1, -1, -1):

        if m >= ranges[j-1][0] and m <= ranges[j-1][1]:
            tmp += "1"
            return base_minus2(m-(-2)**j, j, tmp)
        else:
            if j == 0:
                return tmp + str(m%2)
            else:
                tmp += "0"


if n == 0:
    print("0")
elif n == 1:
    print("1")
else:
    for i in range(1, 30):
        min_r = sum([(-2)**j for j in range(1, i, 2)]) + (-2)**i
        max_r = sum([(-2)**j for j in range(0, i, 2)]) + (-2)**i
        ranges.append([min_r, max_r])

    result = base_minus2(n, 30, "")
    print(result.lstrip("0"))

Submission status: Wrong Answer

Solution code:
n = int(input())
bin_n = bin(n)
ranges = []

def base_minus2(m, i, s):
    tmp = s
    if i == 1:
        return tmp + str(m%2)
    for j in range(i-1, -1, -1):

        if m >= ranges[j-1][0] and m <= ranges[j-1][1]:
            tmp += "1"
            return base_minus2(m-(-2)**j, j, tmp)
        else:
            tmp += "0"
            if j == 0:
                return tmp + str(m%2)

if n == 0:
    print("0")
elif n == 1:
    print("1")
else:
    for i in range(1, 30):
        min_r = sum([(-2)**j for j in range(1, i, 2)]) + (-2)**i
        max_r = sum([(-2)**j for j in range(0, i, 2)]) + (-2)**i
        ranges.append([min_r, max_r])

    result = base_minus2(n, 30, "")
    print(result.lstrip("0"))

Submission status: Wrong Answer

Solution code:
n = int(input())
bin_n = bin(n)
ranges = []

def base_minus2(m, i, s):
    tmp = s
    if i == 1:
        return tmp + str(m%2)
    for j in range(i-1, 0, -1):

        if m >= ranges[j-1][0] and m <= ranges[j-1][1]:
            tmp += "1"
            return base_minus2(m-(-2)**j, j, tmp)
        else:
            tmp += "0"
            if j == 1:
                return tmp + str(m%2)

if n == 0:
    print("0")
elif n == 1:
    print("1")
else:
    for i in range(1, 30):
        min_r = sum([(-2)**j for j in range(1, i, 2)]) + (-2)**i
        max_r = sum([(-2)**j for j in range(0, i, 2)]) + (-2)**i
        ranges.append([min_r, max_r])

    result = base_minus2(n, 30, "")
    print(result.lstrip("0"))