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):
S=str(bin(abs(int(input()))))
print(S[2:])

s=int(input())
s=0
x=s
list=[]
for i in range(1000000000000000000):
    y=x%(-2)
    if y == -1:
        x = (x-1)//(-2)
        y = 1
    else:
        x=x//(-2)
    list.insert(0, y)
    if x == 0:
        print(*list, sep="")
        break

S=str(bin(int(input())))
if S[0]=="-":
    print(S[3:])
else:
    print(S[2:])

s=int(input())
x=s
list=[]
for i in range(1000000000000000000):
    y=x%(-2)
    if y == -1:
        x = (x-1)//(-2)
        y = 1
    else:
        x=x//(-2)
    list.insert(0, y)
    if x == 0:
        print(*list, sep="")
        break

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):
# -*- coding:utf-8 -*-
import math

def solve(N):
    bin_str = bin(N)
    if bin_str[0] == "-":
        bin_str = bin_str[3:]
    else:
        bin_str = bin_str[2:]

    print(bin_str)
    exit()
    j = 0
    for k in range(len(bin_str)-1, -1, -1):
        ans = bin_str[i] * j

def solve2(N):
    """
    1011
    1001111001000111011100111111
    """
    if N <= 0:
        N *= -1
        print(bin(N)[2:])
        exit()

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

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

    solve(N)


# -*- coding:utf-8 -*-

def solve():
    N = int(input())
    ans = ""
    
    if N==0:
        print(N)
        return

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


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):
N=int(input())
res=""
while N!=0:
	if N%2==0:
		res+="0"
	else:
		N-=1
		res+="1"
	print(N)
	N//=-2
if len(res)==0:
	res="0"
print(res[::-1])


N=int(input())
res=""
while N!=0:
	if N%2==0:
		res+="0"
	else:
		N-=1
		res+="1"
	#print(N)
	N//=-2
if len(res)==0:
	res="0"
print(res[::-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):
x=int(input())

LIST2=[1]
LIST2X=[-2]

N=1
for i in range(1,30):
    N=N+4**i
    LIST2.append(N)
N=-2
for i in range(1,30):
    N=N-2*4**i
    LIST2X.append(N)



LIST=[0]*60

def nex(N):
    if N>0:
        for i in range(30):
            if N<=LIST2[i]:
                break
        LIST[i*2]+=1
        return N-(-2)**(i*2)

    if N<0:
        for i in range(30):
            if N>=LIST2X[i]:
                break
        LIST[i*2+1]+=1
        return N-(-2)**(i*2+1)

while x!=0:
    x=nex(x)
    print(x)

for i in range(59,-1,-1):
    if LIST[i]==1:
        break

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

        


N=int(input())
if N==0:
    print(0)
s=""
while N:
    if N%2==1:
        s="1"+s
        N-=1
    else:
        s="0"+s
    N=-N//2
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())
a=""
while n:
    a+=str(n%2)
    n//=-2
print(a[::-1] if n else 0)

n=-int(input())
a=""
while n:
    a+=str(n%2)
    n//=-2
print(a[::-1] if a 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):
#coding:utf-8
n = int(input())

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

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


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

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

i=0
s=''
while(n!=0):
    if n%(2**(i+1))!=0:
        s+='1'
        n-=(-2)**i
    else:
        s+='0'
    i+=1
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())
ans = ''

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

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

while N:
    if N % 2:
        N -= 1
        ans += '1'
    else:
        ans += '0'
    N //= -2
if len(ans):
    print(ans[::-1])
else:
    print(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())
absn=abs(n)
sign=[1,-1]

b,cnt=1,0
while b<absn*2:
    b*=2
    cnt+=1
ans=[]
while cnt >= 0:
    sub=n-b*sign[cnt%2]
    if abs(sub)<abs(b) or abs(sub)<=abs(n):
        ans.append("1")
        n=sub
    else:
        ans.append("0")
    b//=2
    cnt-=1
for i in range(3):
    if ans[i]=="1":break
print("".join(ans[i::]))



n=int(input())
ans=[]
if n%2==1:
    ans.append("1")
    n-=1
else:ans.append("0")
n//=2
while n!=0:
    ans.append("1") if n%2==1 else ans.append("0")
    n//=-2
print("".join(ans[::-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())
ansl = []
if n == 0:
	print(0)
    exit()
while n != 0:
	if n % 2 == 1:
		ansl.append("1")
		n -= 1
	else:
		ansl.append("0")
	n //= -2
print("".join(ansl)[::-1])

n = int(input())
ansl = []
if n == 0:
	print(0)
	exit()
while n != 0:
	if n % 2 == 1:
		ansl.append("1")
		n -= 1
	else:
		ansl.append("0")
	n //= -2
print("".join(ansl)[::-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())
s=''
while n!=0:
  s=str(n%2)+s
  n=-(n//2)
print(s*(if s)else 0)

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

m=2**33//3;print(bin(int(input())+m^m)[2:])

Verdicts: 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())
a = []
if N == 0:
    a = ["0"]
while N != 0:
    a.append(str(N % 2))
    N = -(N - N % 2) 
print("".join(list(reversed(a))))

N = int(input())
a = []
if N == 0:
    a = ["0"]
while N != 0:
    a.append(str(N % 2))
    # N = -(N - N % 2) 
print("".join(list(reversed(a))))

N = int(input())
a = []
if N == 0:
  a.append("0")
while N != 0:
  a.append(str(N % 2))
  N = -(N // 2)
print("".join(reversed(a)))

Verdicts: Time Limit Exceeded

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 = int(input())
S = ""
while N:
     S = chr(N % (-2)) + S
     N /= (-2)
print(S)
    

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


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


Verdicts: 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())
S = []
ans = "0"
while(abs(N) > 1):
  S.append(str(abs(-N % (-2))))
  N += N % (-2)
  N = N // (-2)
  
S.append(str(abs(N)))
S.append("1")
S.reverse()

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

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

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

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 sys
input = sys.stdin.readline
N, M = map(int, input().split(" "))
A = [int(i) for i in input().split()]
count = 0
for i in range(N):
    for k in range(i,N):
        S = sum(A[i:k+1])
        if S % M ==0:
            count = count +1
 
print(count)


n=int(input())
s=''
while n != 0:
    s = str( n % 2 ) + s
    n = - ( n // 2 )
print(s*(s != '') or 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):
# coding:utf-8

n = input()

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

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

print(ans[::-1])

# coding:utf-8

n = int(input())

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

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

print(ans[::-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())

a = []
while n != 0:
    if n%2 == 0:
        a.append(0)
    else:
        a.append(1)
        n -= 1
    n//=(-2)
    
if n == 0:
    print(0)
else:
    print(''.join(map(str, a[::-1])))

n = int(input())

if n == 0:
    print(0)
    
else:
    a = []
    while n != 0:
        if n%2 == 0:
            a.append(0)
        else:
            a.append(1)
            n -= 1
        n//=(-2)
    
    print(''.join(map(str, a[::-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):
import math
n = int(input())
if n == 0:
  print(0)
  exit()
else:
  pass

m = math.floor(math.log2(abs(n)))
ans = []
for i in range(m+2):
  ans.append(n//((-2)**(m+1-i)))

while True:
  if ans[0] == 0:
    ans = ans[1:len(ans)]
  else:
    break

ANS = [str(ans[i]) for i in range(len(ans))]
print(int("".join(ANS)))

n = int(input())

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

s = ""

while True:
    if n == 0:
        break
    if n%2 == 0:
        s += "0"
        n = n//(-2)
    else:
        s += "1"
        n = (n-1)//(-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())
ans=""
while n!=0:
  if n%2==0:
    ans = "0"+ans
  else
    n-=1
    ans = "1"+ans
  n//=-2  

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

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

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


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())
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]:
            print(ranges[j-1], j)
            tmp += "1"
            print(tmp)
            return base_minus2(m-(-2)**j, j, tmp)
        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"))


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, 60):
        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, 60, "")
    print(result.lstrip("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())
if n == 0:
    print(0)
    exit(0)

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

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

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

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

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

bits = []
for keta in range(int(math.log2(abs(N))) + 1)[::-1]:
    print(N, keta)
    if abs(N - (-2)**keta) <= abs(N):
        bits.append("1")
        N -= (-2)**keta
    else:
        bits.append("0")


print("".join(bits))

import math

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

bits = []
for keta in range(5 + int(math.log2(abs(N)))):
    if N % 2 == 1:
        bits.append("1")
        N -= 1
    else:
        bits.append("0")
    N //= -2
    if N == 0:
        break

print("".join(bits[::-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:
    if N % 2 != 0:
        N -= 1
        ans = "1" + ans
    else:
        ans = "0" + ans
        N /= -2
    if ans == "":
        ans = "0"

print(ans) 

N = int(input())
ans = ""

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

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())
i = 1
ans = []
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)))

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




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%2==0:
  ans='0'
else:
  ans='1'
  
i=2
while abs(tmp)<=abs(N):
  if N%((-2)**i)==0:
    ans='0'+ans
  else:
    ans='1'+ans
    
print(ans)

N=int(input())

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

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:
	s = str(n%2) + s
	s = -(s//2)

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

n = int(input())

s = ""

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

print(s if s != "" else 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):
import sys
from collections import deque

sys.setrecursionlimit(10 ** 6)


def input(): return sys.stdin.readline().rstrip()


N = int(input())
l = deque()
while N != 0:
    x = (-2) ** len(l)
    y = (-2) * x
    if abs(N) % abs(y) != 0:
        N -= x
        l.appendleft('1')
    else:
        l.appendleft('0')
print(0 if N == 0 else ''.join(l))

import sys
from collections import deque

sys.setrecursionlimit(10 ** 6)


def input(): return sys.stdin.readline().rstrip()


N = int(input())
l = deque()
if N == 0:
    print(0)
else:
    while N != 0:
        x = (-2) ** len(l)
        y = (-2) * x
        if abs(N) % abs(y) != 0:
            N -= x
            l.appendleft('1')
        else:
            l.appendleft('0')
    print(''.join(l))

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
  print("-n//2 : {}, -(n//2) : {}".format(-n//2,-(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):
a=int(input())
b=''
while a:
 b=str(a&1)+b
 a= a>>1
print(b if b else 0)


a=int(input())
b=''
while a:
 b=str(a&1)+b
 a=-(a<<1)
print(b if b else 0)


a=int(input())
b=''
while a:
 b=str(a&1)+b
 a= (a>>1)
print(b if b else 0)

a=int(input())
b=''
while a:
 b=str(a&1)+b
 a=-(a>>1)
print(b if b else 0)


Verdicts: Wrong Answer

Time Limit Exceeded

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())
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(n)
    print(L)
    print(int(''.join(L[::-1])))


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


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=""
for i in range(50):
    if N%(-2)==0:
        S=S+"0"
    else:
        S=S+"1"
        N-=1
    N=N//(-2)
print(int(S))


N=int(input())
S=""
for i in range(50):
    if N%(-2)==0:
        S="0"+S
    else:
        S="1"+S
        N-=1
    N=N//(-2)
print(int(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())
ans = ''
a = 2
while True:
	if n == 0:
		break
	if n % a == 0:
		ans += '0'
	else:
		ans += '1'
		n -= (a//2)

	n = n//2
	if a == 2:
		a = -2
	else:
		a = 2


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

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

	n = n//2
	if a == 2:
		a = -2
	else:
		a = 2


ans = ans[::-1]
if nn == 0:
	print(0)
else:
	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):
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])

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 len(ans) == 0:
    print("0")
else:
    for i in range(len(ans)):
        if i != len(ans)-1:
            print(ans[i],end="")
        else:
            print(ans[i])

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 = list()
if N==0:
  print(0)
  exit()
elif N>0:
  while N>0:
    S.append(N%2)
    N//=2
  S.append(0)
  S.append(0)
  for i in range(len(S)-1):
    if i%2==1 and S[i]==1:
      S[i+1] += 1
    if S[i]==2:
      S[i]=0
      S[i+1]+=1
else:
  N *= -1
  while N>0:
    S.append(N%2)
    N//=2
  S.append(0)
  S.append(0)
  for i in range(len(S)-1):
    if i%2==0 and S[i]==1:
      S[i+1] += 1
    if S[i]==2:
      S[i]=0
      S[i+1]+=1
  
S.reverse()
if S[0]==0:
  S = S[1:]
ans = ""
for s in S:
  ans += str(s)
print(ans)


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


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=abs(int(input()))
m=n
i=0
nn=0
while m//2>0:
  nn+=m%2*(2**i)
  i+=1
  m//=2
n+=nn
a=[]
while n//2>2:
  a.append(n%2)
  n//=2
ans=""
for i in range(len(a)-1,-1,-1):
  ans+=str(a[i])
print(ans)

n=abs(int(input()))
m=n
i=0
nn=0
while m//2>0:
  nn+=m%2*(2**(i+1))
  i+=1
  m//=2
n+=nn
a=[]
while n//2>2:
  a.append(n%2)
  n//=2
ans=""
for i in range(len(a)-1,-1,-1):
  ans+=str(a[i])
print(ans)

n,i,a,r=int(input()),0,0,1
while n:
  r*=-2;i-=1
  if (n-r)%(-2*r)==0:a+=10**i;n-=r
print(a)
    


n,i,a=int(input()),0,0
while n:
  r=-2**i
  if (n-r)%(-2*r)==0:
    a+=10**i;n-=r
  i+=1
print(a)
    

n=abs(int(input()))
m=n
i=0
nn=0
while m//2>0:
  if i%2==0:
    nn+=m%2*(2**(i+1))
  i+=1
  m//=2
n+=nn
a=[]
while n//2>2:
  a.append(n%2)
  n//=2
ans=""
for i in range(len(a)-1,-1,-1):
  ans+=str(a[i])
print(ans)

n,i,a=int(input()),0,0
while n:
  r=(-2)**i
  if (n-r)%(-2*r)==0:
    a+=10**i;n-=r
  i+=1
print(a)
    


Verdicts: Wrong Answer

Wrong Answer

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

ans = ""

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

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

n = int(input())
N = n

ans = ""

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

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

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 :
    if N % (-2) == 0 :
        S = "0"+S
    else :
        S = "1"+S
        N -= 1
    N = N / 2
if len(S) != 0 :
    print(S)
else :
    print(0)



N = int(input())
S = ""
while N != 0 :
    if N % (-2) != 0 :
        S = "1" + S
        N -= 1
    else :
        S = "0" + S
    N /= (-2)
if len(S) == 0 :
    print(0)
else :
    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())
ans = ""
while N != 0:
  if(N%2 == 0):
    ans += "0"
  else:
    ans += "1"
    N -= 1
  N //= -2
if(bit == ""):
  ans = ""
print(ans[::-1])  

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

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

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

    print(ans)

import math
N = int(input())

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

    print(ans)

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

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

idx = 0
while True:
    idx += 1
    left = sum([(-2)**i for i in range(idx+1) if i%2==1])
    right = sum([(-2)**i for i in range(idx+1) if i%2==0])
    if left <= N <= right:
        break
        
max_idx = idx
coeff = [0 for _ in range(max_idx+1)]
for idx in range(max_idx, 0-1, -1):
    left = sum([(-2)**i for i in range(idx) if i%2==1])
    right = sum([(-2)**i for i in range(idx) if i%2==0])
    print(left, N, right)
    if not left <= N <= right:
        N -= (-2)**(idx)
        coeff[idx] = 1
#     print(N)
# print(reversed(coeff)
print(''.join(map(str, reversed(coeff))))

# C
N = int(input())

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

    idx = 0
    while True:
        idx += 1
        left = sum([(-2)**i for i in range(idx+1) if i%2==1])
        right = sum([(-2)**i for i in range(idx+1) if i%2==0])
        if left <= N <= right:
            break

    max_idx = idx
    coeff = [0 for _ in range(max_idx+1)]
    for idx in range(max_idx, 0-1, -1):
        left = sum([(-2)**i for i in range(idx) if i%2==1])
        right = sum([(-2)**i for i in range(idx) if i%2==0])
        print(left, N, right)
        if not left <= N <= right:
            N -= (-2)**(idx)
            coeff[idx] = 1
    #     print(N)
    # print(reversed(coeff)
    print(''.join(map(str, reversed(coeff))))

# C
N = int(input())

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

    idx = 0
    while True:
        idx += 1
        left = sum([(-2)**i for i in range(idx+1) if i%2==1])
        right = sum([(-2)**i for i in range(idx+1) if i%2==0])
        if left <= N <= right:
            break

    max_idx = idx
    coeff = [0 for _ in range(max_idx+1)]
    for idx in range(max_idx, 0-1, -1):
        left = sum([(-2)**i for i in range(idx) if i%2==1])
        right = sum([(-2)**i for i in range(idx) if i%2==0])
#         print(left, N, right)
        if not left <= N <= right:
            N -= (-2)**(idx)
            coeff[idx] = 1
    #     print(N)
    # print(reversed(coeff)
    print(''.join(map(str, reversed(coeff))))

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())
if n==0:
  print('0')
else:
  ls=[]
  while(n!=0):
    ls.append(n%2)
    n=-1*(n-n%2)//2
ls.sort(reverse:True)
print(ls)
    
  
    

N=int(input())
ls=[]
while True:
  ls.append(N%2)
  N=-(N//2)
  if N==0:
    break
print(*reversed(ls),sep="")

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 math
N = int(input())

def order2(x):
  if x > 0 :
    k = 0
    check = 0
    while check == 0 :
      s = 0
      for i in range(0, k+1, 2):
        s += (-2)**i
        ans = i
      if s >= x:
        check = 1
      k += 2
  elif x < 0 :
    k = 1
    check = 0
    while check == 0 :
      s = 0
      for i in range(1, k+1, 2):
        s += (-2)**i
        ans = i
      if s <= x:
        check = 1
      k += 2
  return ans

if N!= 0 :


  l = [] 
  a = N
  i = order2(N)
  while i >= 0:
    if a == 0 :
      l.append(0)
    if a > 0 and (-2)**i >0 :
        s = 0
        for j in range(0, i, 2):
          s += (-2)**j
        print(a,s)
        if a > s :
          l.append('1')
          a -= (-2)**i
        else :
          l.append('0')
    elif a > 0 and (-2)**i < 0:
        l.append('0')
    elif a < 0 and (-2)**i > 0:
        l.append('0')
    elif a < 0 and (-2)**i < 0:
        s = 0
        for j in range(1, i, 2):
          s += (-2)**j
        if a < s :
          l.append('1')
          a -= (-2)**i
        else :
          l.append('0')
    i -= 1

  print(''.join(l))

else :
  print(0)

N = int(input())

def order2(x):
  if x > 0 :
    k = 0
    check = 0
    while check == 0 :
      s = 0
      for i in range(0, k+1, 2):
        s += (-2)**i
        ans = i
      if s >= x:
        check = 1
      k += 2
  elif x < 0 :
    k = 1
    check = 0
    while check == 0 :
      s = 0
      for i in range(1, k+1, 2):
        s += (-2)**i
        ans = i
      if s <= x:
        check = 1
      k += 2
  return ans

if N!= 0 :


  l = [] 
  a = N
  i = order2(N)
  while i >= 0:
    if a == 0 :
      l.append('0')
    if a > 0 and (-2)**i >0 :
        s = 0
        for j in range(0, i, 2):
          s += (-2)**j
        if a > s :
          l.append('1')
          a -= (-2)**i
        else :
          l.append('0')
    elif a > 0 and (-2)**i < 0:
        l.append('0')
    elif a < 0 and (-2)**i > 0:
        l.append('0')
    elif a < 0 and (-2)**i < 0:
        s = 0
        for j in range(1, i, 2):
          s += (-2)**j
        if a < s :
          l.append('1')
          a -= (-2)**i
        else :
          l.append('0')
    i -= 1

  print(''.join(l))

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())
x = ""
while n!=0:
    x = str(n%2) + x
    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)
if x == "":
    print(0)
else:
    print(x)


Verdicts: Runtime Error

Accepted