TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: 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.

Submission attempts (in order):
n = map(int,input())


def base-2(n):
    a = ()
    while n! = 0:
        r = n % 2:
        if (r < 0):
            r += 2

            n = (n - r)/2
            a.append(str(r))
    if(a = ""):
    a = "0"
    reversed(a)
print(base(n))

n = int(input())
def basen(n):
    a = []
    while n!= 0:
        r = n % 2
        if (r < 0):
            r += 2

        n = (n - r)//(-2)
        a.append(r)
        if(a == " "):
            a.append(0)
        reversed(a)
    return a
print(basen(n))

n = map(int,input())

def basen(n):
    a = []
    while n!= 0:
        r = n % 2
        if (r < 0):
            r += 2

        n = (n - r)//(-2)
        a.append(r)
        if(a == " "):
            a.append(0)
        reversed(a)
    return a
 
print(basen(n))

n = int(input())
def basen(n):
    a = []
    while n!= 0:
        r = n % 2
        if (r < 0):
            r += 2

        n = (n - r)//(-2)
        a.append(r)
        if(a == " "):
            a.append(0)
        reversed(a)
    return "".join(map(str,a))
print(basen(n))

n = int(input())

def basen(n):
    a = []
    while n!= 0:
        r = n % 2
        if (r < 0):
            r += 2

        n = (n - r)//(-2)
        a.append(r)
    if a == []:
        a.append(0)
    a.reverse()
    return "".join(map(str,a))
print(basen(n))

            

Verdicts: Runtime Error

Wrong Answer

Runtime Error

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())
str = ''

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


N = int(input())
str = ''

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


N = int(input())
str = ''

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

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


Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import math
N = int(input())

def minus_2(n):
    ans = ''
    
    if n == 1:
        ans += '1'
    elif n == 0:
        ans += '0'
    else:
        for i in range(10**9):
            if n % 2 == 0:
                ans += '0'
            else:
                ans += '1'
            n = math.ceil(n/-2)
            if n == 1:
                break
            ans += '1'
            ans = ans[::-1]
        
    return ans

print(minus_2(N))

import math
N = int(input())
ans = ''

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


Verdicts: Wrong Answer

Accepted
Problem: 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.

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

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

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

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())

dp =[0]*40

if n ==0:
    print(0)

elif n >0:
    x = bin(n)
    bx = x[2:]
    lx = len(bx)
    for i in range(lx-1,-1,-1):
        dp[i] = int(bx[lx-1-i])
    for i in range(40):
        if i % 2 ==1 and dp[i]==1:
            dp[i+1] +=1
    while max(dp) >1:
        for i in range(40):
            if dp[i] >=2:
                dp[i] -=2
                if dp[i+1] >0:
                    dp[i+1] -=1
                else:
                    dp[i+1] +=1
                    dp[i+2] +=1
    dpr = list(reversed(dp))
    dprs = list(map(lambda x :str(x),dpr))
    dprj = "".join(dprs)
    print(int(dprj))    

else:
    x = bin(n)
    bx = x[2:]
    lx = len(bx)
    for i in range(lx-1,-1,-1):
        dp[i] = int(bx[lx-1-i])
    for i in range(40):
        if i % 2 ==1 and dp[i]==1:
            dp[i+1] +=1
    while max(dp) >1:
        for i in range(40):
            if dp[i] >=2:
                dp[i] -=2
                if dp[i+1] >0:
                    dp[i+1] -=1
                else:
                    dp[i+1] +=1
                    dp[i+2] +=1
    dpr = list(reversed(dp))
    dprs = list(map(lambda x :str(x),dpr))
    dprj = "".join(dprs)
    print(int(dprj))    

n = int(input())

dp =[0]*40

if n ==0:
    print(0)

elif n >0:
    x = bin(n)
    bx = x[2:]
    lx = len(bx)
    for i in range(lx-1,-1,-1):
        dp[i] = int(bx[lx-1-i])
    for i in range(40):
        if i % 2 ==1 and dp[i]==1:
            dp[i+1] +=1
    while max(dp) >1:
        for i in range(40):
            if dp[i] >=2:
                dp[i] -=2
                if dp[i+1] >0:
                    dp[i+1] -=1
                else:
                    dp[i+1] +=1
                    dp[i+2] +=1
    dpr = list(reversed(dp))
    dprs = list(map(lambda x :str(x),dpr))
    dprj = "".join(dprs)
    print(int(dprj))    

else:
    x = bin(-n)
    bx = x[2:]
    lx = len(bx)
    for i in range(lx-1,-1,-1):
        dp[i] = int(bx[lx-1-i])
    for i in range(40):
        if i % 2 ==0 and dp[i]==1:
            dp[i+1] +=1
    while max(dp) >1:
        for i in range(40):
            if dp[i] >=2:
                dp[i] -=2
                if dp[i+1] >0:
                    dp[i+1] -=1
                else:
                    dp[i+1] +=1
                    dp[i+2] +=1
    dpr = list(reversed(dp))
    dprs = list(map(lambda x :str(x),dpr))
    dprj = "".join(dprs)
    print(int(dprj))    

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import sys
import math
y = int(input().split()[0])
result = ""
i = 0
while True:
    print(i)
    z = (-2) ** (i+1)
    x = y % z
    print(x)
    if x != 0:
        y = y + x
        result = "1" + result
    else:
        result = "0" + result
    if y == 0:
        break
    i = i + 1
print(result)

import sys
import math
y = int(input().split()[0])
result = ""
i = 0
while True:
    z = (-2) ** (i+1)
    x = y % z
    if x != 0:
        y = y + x
        result = "1" + result
    else:
        result = "0" + result
    if y == 0:
        break
    i = i + 1
print(result)


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):

def change_2r(N):
    if N==0:
        return [0]
    list=[]
    while N>=2:
        list.append(N%2)
        N=int((N-N%2)/2)
    list.append(1)
    return list
  

def moveup(N,i):
    if len(N)<=i:
        N.append(1)
    else:
        if N[i]==0:
            N[i]=1
        elif N[i]==1:
            N[i]=0
            moveup(N,i+1)

N=int(input())
i=0
if N>=0:
    Nlist=change_2r(N)
    while i<len(Nlist):
        if i%2!=0 and Nlist[i]==1:
            moveup(Nlist,i+1)
        i+=1
else:
    N=-N
    Nlist=change_2r(N)
    while i<len(Nlist):
        if i%2==0 and Nlist[i]==1:
            moveup(Nlist,i+1)
        i+=1
        
Nlist.reverse()
print(Nlist)
print(''.join(map(str,Nlist)))


def change_2r(N):
    if N==0:
        return [0]
    list=[]
    while N>=2:
        list.append(N%2)
        N=int((N-N%2)/2)
    list.append(1)
    return list
  

def moveup(N,i):
    if len(N)<=i:
        N.append(1)
    else:
        if N[i]==0:
            N[i]=1
        elif N[i]==1:
            N[i]=0
            moveup(N,i+1)

N=int(input())
i=0
if N>=0:
    Nlist=change_2r(N)
    while i<len(Nlist):
        if i%2!=0 and Nlist[i]==1:
            moveup(Nlist,i+1)
        i+=1
else:
    N=-N
    Nlist=change_2r(N)
    while i<len(Nlist):
        if i%2==0 and Nlist[i]==1:
            moveup(Nlist,i+1)
        i+=1
        
Nlist.reverse()
print(''.join(map(str,Nlist)))

Verdicts: Wrong Answer

Accepted
Problem: 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.

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

print(int(ans))

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

    N //= -2

print(int(ans))

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from math import ceil

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

ans=''

while n!=0:
    ans+=str(abs(n)%2)
    n=ceil(n/-2)
    print(n)
print(ans[::-1])

from math import ceil

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

ans=''

while n!=0:
    ans+=str(abs(n)%2)
    n=ceil(n/-2)
print(ans[::-1])

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())

ans = ''

while n != 0:
    r = n % 2 
    print(r)

    if r < 0:
        r = r + 2
    
    n = (n-r) / (-2)

    ans = ans + str(int(r))

ans = list(ans)    
print(ans)
ans.reverse()
print(''.join(ans))

n = int(input())

ans = ''

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

while n != 0:
    r = n % 2 

    if r < 0:
        r = r + 2
    
    n = (n-r) / (-2)

    ans = ans + str(int(r))

ans = list(ans)    
ans.reverse()
print(''.join(ans))

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n=int(input())

#n=-9
#ans=1011

#n=123456789
#ans=11000101011001101110100010101
#ans="01 10 00 10 10 11 00 11 01 11 01 00 01 01 01"

#n=4

#n=0
#ans=0

kp=0
km=0
k=0
while not(km<=n and n<=kp):
    k=k+1
    km=-int(2*(4**k-1)/(4-1))
    kp=int((4**k-1)/(4-1))
#    print("n=",n,"k=",k,"km=",km,"kp=",kp)        
#print("n=",n,"n-km=",n-km)

n=n-km
#s=[]
#t=[]
u=""
while n>0:
    n0=n
    n=n//4
    n2=n0%4
#    n1=n0-n*4
#    print(n0,n,n2)
#    s.append(n2)
    if n2==0:
#        t.append("10")
        u="10"+u
    elif n2==1:
#        t.append("11")
        u="11"+u
    elif n2==2:
#        t.append("00")
        u="00"+u
    elif n2==3:
#        t.append("01")
        u="01"+u
        
if len(u)>0:
    while u[0]=="0":
        u=u[1:]

#s.reverse()    
#print(s)
#t.reverse()    
#print(t)
print(u)
#print(ans)


n=int(input())

kp=-10
km=10
k=0
while not(km<=n and n<=kp):
    k=k+1
    km=-int(2*(4**k-1)/(4-1))
    kp=int((4**k-1)/(4-1))
    print("n=",n,"k=",k,"km=",km,"kp=",kp)        
#print("n=",n,"n-km=",n-km)

n=n-km

v=""
for kk in range(k):
    np=n//4**(k-kk-1)
    n=n-np*4**(k-kk-1)
    if np==0:
        v=v+"10"
    elif np==1:
        v=v+"11"
    elif np==2:
        v=v+"00"
    elif np==3:
        v=v+"01"
#print("v=",v)

if len(v)>0 and v[0]=="0":
    v=v[1:]
if len(v)>0:
    print(v)
else:
    print(0)

n=int(input())

s=[]
if n%2==0:
    s.append(0)
else:
    s.append(1)
nn=n
ii=0
while nn<=-1 or 2<=nn:
    nn=(nn-s[ii])//(-2)
    if nn%2==0:
        s.append(0)
    else:
        s.append(1)
    ii+=1

ss=""
for i in range(len(s)):
    ss=str(s[i])+ss
print(ss)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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 == 1 or p == 0:
		ans = str(p) + ans
		break
	N = p
	ans = str(q) + ans
print(ans)

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)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
# -*- coding: utf-8 -*-
n = int(input())

if n == 0:
    print(0)

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


# -*- coding: utf-8 -*-
n = int(input())

if n == 0:
    print(0)

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


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N=int(input())

x=[]
if N != 0:
	flag = N // abs(N)
N=abs(N)
while N != 0:
	x.insert(0,N % 2 * flag )
	N //= 2
	flag *= -1
x.insert(0,0)
x.insert(0,0)

# 2 = (-1)*(-2) = (-2+1)*(-2) = (-2)^2+(-2)
for i in range(len(x))[::-1]:
	if x[i] == -1:
		x[i] = 1
		x[i-1] += 1
	if x[i] == 2:
		x[i] = 0
		x[i-1] += 1
		x[i-2] += 1

if x[0]==1:
	print(1,end="")
elif len(x)==1:
	print(0)
for i in range(1,len(x)):
	print(x[i],end="")


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

Verdicts: Wrong Answer

Accepted
Problem: 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.

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

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())
if n == 0:
    print("0")
    exit()
ans = ""
while n != 0:
    if n % (2) == 0:
        n = n // (-2)
        ans = ans + "0"
    else:
        n = (n - 1) // (-2)
        ans = ans + "1"
print(ans)

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

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

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

Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())
print(bin(N)[2:])

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

# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

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

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


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

def solve():
    n = int(input())
    ans, m = "", 1
    while n != 0:
        m *= (-2)
        if abs(n) % abs(m) > 0:
            ans += "1"
            n -= m // (-2)
        else:
            ans += "0"
    print(ans if ans else 0)

if __name__=="__main__":
    solve()

#!/usr/bin/env python
# -*- coding: utf-8 -*-

def solve():
    n = int(input())
    ans, m = "", 1
    while n != 0:
        m *= (-2)
        if abs(n) % abs(m) > 0:
            ans += "1"
            n -= m // (-2)
        else:
            ans += "0"
    print(ans[::-1] if ans else 0)

if __name__=="__main__":
    solve()

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from sys import stdin
stdin = open('sample.txt')


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


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


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())
s = ''
s2 = ''
while N != 0:
  if N % 2 == 0:
    s += '0'
    N //= (-2)
  if N % 2 == -1 or N % 2 == 1:
    s += '1'
    N //= (-2)
    N += 1
s2 = s[::1]
print(s2)
      
    
  

import sys
N = int(input())
s = ''
s2 = ''
if N == 0:
  print(0)
  sys.exit(0)
while N != 0:
  if N % 2 == 0:
    s += '0'
    N //= (-2)
  if N % 2 == -1 or N % 2 == 1:
    s += '1'
    N //= (-2)
    N += 1
s2 = s[::-1]
print(s2)


Verdicts: Wrong Answer

Accepted
Problem: 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.

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

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

Verdicts: Time Limit Exceeded

Accepted
Problem: 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.

Submission attempts (in order):
N = input()
a = ""
if N ==0:
  a =0
while N !=0:
  if N%2 != 0:
    a = "1" + a
  else:
    a = "0" + a
  N = - (N//2)
print(a)

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

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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)

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!="" else 0)


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())

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


n = int(input())

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


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())
ret = ''
while n > 0:
  d, r = n / (-2), n % (-2)
  if r == -1: # (d+1) * (-2) + 1 = n
    r = 1
    d += 1
  ret += str(r)
  n = d
if ret == '':
  ret = '0'
else:
  ret = ret[::-1]
print(ret)
  

n = int(input())
ret = ''
while n != 0:
  d, r = n // (-2), n % (-2)
  if r == -1: # (d+1) * (-2) + 1 = n
    r = 1
    d += 1
  ret += str(r)
  n = d
if ret == '':
  ret = '0'
else:
  ret = ret[::-1]
print(ret)
  

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
input()
print('11000101011001101110100010101')

def determine_digit(digit_num, acm, n):
    mod = 2 ** (digit_num + 1)
    if (n - acm) % mod:
        return 1
    else:
        return 0


def convert(n):
    if n == 0:
        return '0'

    result = ''
    acm = 0
    digit_num = 0
    # print('n:', n)
    while n != acm:
        # print(digit_num, acm, result)
        d = determine_digit(digit_num, acm, n)
        # print('d: ', d)

        # incremental procedure
        acm += d * (-2)**digit_num
        digit_num += 1
        result += str(d)

    return result[::-1]


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

    print(convert(n))


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())

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

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

print(s[::-1])

n = int(input())

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

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

print(s[::-1])


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())
x = ''
while n != 0:
  x += str(n%2)
  n = -(n//2)
  
if x == '':
  print(0)
else:
  print(x)


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


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

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


Verdicts: Wrong Answer

Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import sys
N = int(sys.stdin.readline())

def div(a):
    return -(a // 2), a % 2


res = []
while N < 0 or 2 <= N:
    N, a = div(N)
    print(N, a)
    res.append(a)
res.append(N)

print(''.join(map(str, reversed(res))))


import sys
N = int(sys.stdin.readline())

def div(a):
    return -(a // 2), a % 2


res = []
while N < 0 or 2 <= N:
    N, a = div(N)
    res.append(a)
res.append(N)

print(''.join(map(str, reversed(res))))


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import math

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

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

		i += 1

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

if __name__ == '__main__':
	main()

import math

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

	i = 0

	if n == 0:
		print(0)
		return 

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

		i += 1

	print(ans[::-1])

if __name__ == '__main__':
	main()

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
# C
N = int(input())

data = N
re = ''

while True:
    print(data)
    if data == 1:
        re = '1' + re
        break
    elif data == -1:
        re = '11' + re
        break
    elif data % -2 != 0:
        data += data // abs(data) 
        re = '1' + re
    else:
        if data // -2 != 0:
            re = '0' + re
        else:
            break
    data = data // -2
    
print(re)

# C
N = int(input())

data = N
if data == 0:
    re = '0'
else:
    re = ''

    while True:
        if data % 2 == 1:
            data -= 1 
            re = '1' + re
        else:
            if data // -2 != 0:
                re = '0' + re
            else:
                break
        data = data // -2
    
print(re)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())

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

N = int(input())

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

N = int(input())

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

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

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

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

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

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

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())
if n > 0:key = 1
if n < 0:key = 0
lis = []
while abs(n) >= 1:
  if n % 2 == 1:
    n -= 1
    lis.insert(0,"1")
  else:
    lis.insert(0,"0")
  n = n // (-2)
if n == 0:
  lis.append("0")
print("".join(lis))

n = int(input())
if n > 0:key = 1
if n < 0:key = 0
lis = []
if n == 0:
  lis.append("0")
while abs(n) >= 1:
  if n % 2 == 1:
    n -= 1
    lis.insert(0,"1")
  else:
    lis.insert(0,"0")
  n = n // (-2)
print("".join(lis))
  

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())
result = '1'

if N > 0:
    s = 1
    e = 1
    r = 4
    degit = 0
    
    while True:
        if N <= e:
            for i in range(degit):
                if i % 2 == 0:
                    if N <= (s+e)//2:
                        result += '1'
                        e = (s+e)//2
                    else:
                        result += '0'
                        s = (s+e)//2+1
                else:
                    if N <= (s+e)//2:
                        result += '0'
                        e = (s+e)//2
                    else:
                        result += '1'
                        s = (s+e)//2+1
            break
            
        s = e + 1
        e = e + r
        r *= 4
        degit += 2
        

elif N < 0:
    s = -1
    e = -2
    r = -8
    degit = 1

    while True:
        if N >= e:
            for i in range(degit):
                print((s+e)//2+1)
                if i % 2 == 0:
                    if N >= (s+e)//2+1:
                        result += '1'
                        e = (s+e)//2+1
                    else:
                        result += '0'
                        s = (s+e)//2
                else:
                    if N >= (s+e)//2+1:
                        result += '0'
                        e = (s+e)//2+1
                    else:
                        result += '1'
                        s = (s+e)//2
            break
                    
        s = e - 1
        e = e + r
        r *= 4
        degit += 2
    

else:
    result = '0'

print(result)


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

print(result)    


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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("-",""))

N=int(input())
S=""
if N==0:
  print(0)
  exit(0)    
while N!=0:
  r=N%(-2)
  N=N//(-2)
  if r<0:
    r+=2
    N+=1
  S+=str(r)
print(S[::-1])


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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)


a=int(input())
sum=0
s=''

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)


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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)

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())
a = []
while n > 0:
  if n%2 ==0:
    n = n/(-2)
    a.append("0")
  else:
    n = (n-1)(-2)
    a.append("1")
    
b = ""
for i in range(len(a)):
  b += a[len(a)-i-1]
  
print(b)
  
  

n = int(input())
a = []
if n ==0:
  print(0)
else:
  while n != 0:
  if n%2 ==0:
    n = n/(-2)
    a.append("0")
  else:
    n = (n-1)/(-2)
    a.append("1")
    
b = ""
for i in range(len(a)):
  b += a[len(a)-i-1]

print(b)

  
  

n = int(input())
a = []
while n > 0:
  if n%2 ==0:
    n = n/(-2)
    a.append("0")
  else:
    n = (n-1)(-2)
    a.append("1")
    
b = ""
for i in range(len(a)):
  b += a[len(a)-i-1]
  
print("b")
  
  

n = int(input())
a = []
if n ==0:
  print(0)
else:
  while n != 0:
    if n%2 ==0:
      n = n/(-2)
      a.append("0")
    else:
      n = (n-1)/(-2)
      a.append("1")
    
  b = ""
  for i in range(len(a)):
    b += a[len(a)-i-1]

  print(b)

  
  

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())

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

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)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n =int(input())

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

l = [(-2)**_ for _ in range(100) if abs((-2)**_) <= 10**10]

if n > 0:
    x = [1]
    for i in range(len(l)):
        if abs(l[i]) < abs(n):
            x.append(l[i+1])

elif n < 0:
    x = []
    for j in range(len(l)):
        if abs(l[j]) < abs(n):
            x.append(l[j])

#print(len(x))

y = []
from itertools import combinations
for __ in range(len(x)):
    y += list(combinations(x, __))

for k in y:
    if sum(k) == n:
        z = list(k)

#print(y)
#print(z)

p = []
for q in range(len(x)):
    if x[q] in z:
        p.append(1)
    else:
        p.append(0)

p.reverse()
print(p)


def f_10_to_m2(n):
    if n == 0:
        return 0 

    digits = []
    i = 0
    base = 1
    while n != 0:
        if n % (base*2) == 0:
            digits.append(0)
        else:
            digits.append(1)
            n -= base
        i += 1
        base *= -2
    return ''.join(map(str, reversed(digits)))

print(f_10_to_m2(int(input())))

Verdicts: Runtime Error

Accepted