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 = int(input())
k = 1
kotae = []
kotae2 = []

if n != 0:
    while n != 0:
        if n % ((-2) ** k) == 0:
            kotae.append(0)
        else:
            kotae.append(1)
            n = n - ((-2) ** (k - 1))
        k = k + 1

    for i in kotae[::-1]:
        kotae2.append(i)

    print("".join(kotae2))
else:
    print(0)

n = int(input())
k = 1
kotae = []
kotae2 = []

if n != 0:
    while n != 0:
        if n % ((-2) ** k) == 0:
            kotae.append(0)
        else:
            kotae.append(1)
            n = n - ((-2) ** (k - 1))
        k = k + 1

    for i in kotae[::-1]:
        kotae2.append(str(i))

    print("".join(kotae2))
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)
	print(x)
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: 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())
ans = []
while abs(x) > 1:
    ans.append(abs(x % -2))
    x //= -2
print(''.join([str(i) for i in ans + [abs(x)]]))

N = int(input())
ans = ''
while abs(N) > 0:
    ans = str(N % 2) + ans
    N = -(N // 2)
print(ans or 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):
#encoding utf-8

n = int(input())
answer = ""

def kenzan(ans):
    val = 0
    ans.reverse()
    for i in range(len(ans)):
        val += answer[i]*(-2)**i
    return int(val)

i = 1

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



#encoding utf-8

n = int(input())
m=n
answer = []

def kenzan(ans):
    val = 0
    for i in range(len(ans)):
        val += answer[i]*(-2)**i
    return int(val)

i = 1
while(n != 0):
    print(n)
    if n % (2**i) == 0:
        answer.append(0)
    else:
        answer.append(1)
        n = n-((-2)**(i-1))
    i += 1
answer.reverse()
print("".join(str(i) for i in answer))

#encoding utf-8

n = int(input())
answer = ""

def kenzan(ans):
    val = 0
    ans.reverse()
    for i in range(len(ans)):
        val += answer[i]*(-2)**i
    return int(val)

i = 1

while(n != 0):
    if n % 2 == 0:
        answer = "0" + answer
    else:
        answer = "1" + answer
        n -= 1
    n /= -2
if answer == "":
    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):
n=int(input())
x=""
while n!=0:
    x= 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

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:
  pi = pow(-1, i-1) * pow(2, i)
  if n % pi == pi // 2:
    ans += '1'
    n -= pi // 2
  else:
    ans += '0'
  i += 1
if n == 0:
  print(0)
else:
  print(ans[::-1])


n = int(input())

if n == 0:
  print(0)
else:
  i = 1
  ans = ''
  while n != 0:
    pi = pow(-1, i-1) * pow(2, i)
    if n % pi == pi // 2:
      ans += '1'
      n -= pi // 2
    else:
      ans += '0'
    i += 1
  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):
import sys

N = int(input())

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

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

print(ans)

import sys

N = int(input())

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

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

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())
x = ''

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

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

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


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


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


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

N = int(input())
ans = ""
while N:
    if N % 2:
        ans += "1"
        N = -((N - 1) // 2)
    else:
        ans += "0"
        N = -(N // 2)
if len(ans) == 0:
    ans = "0"
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())
def divminus2(n):
    if n%2 == 1:
        q = n // -2 + 1
        r = n % 2 + 2
    else:
        q = n // -2
        r = 0
    return q,r

ans_list = []
while n != 0:
    q,r = divminus2(n)
    n = q
    ans_list.append(str(r))

ans_list.reverse()
if ans_list == []:
    print("0")
else:
    print("".join(ans_list))


n = int(input())
def divminus2(n):
    if n%2 == 1:
        q = n // -2 + 1
        r = n % 2
    else:
        q = n // -2
        r = 0
    return q,r

ans_list = []
while n != 0:
    q,r = divminus2(n)
    n = q
    ans_list.append(str(r))

ans_list.reverse()
if ans_list == []:
    print("0")
else:
    print("".join(ans_list))


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:
    print(N, s, N % (-2) == 0)
    if N % (-2) == 0:
        s = '0' + s
    else:
        s = '1' + s
        N -= 1
    N /= (-2)

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

import numpy as np
N, M = map(int, input().split())
A = [int(i) for i in input().split()]
ar = np.eye(N) * A

for h in range(0, N):
    for w in range(1, h+1):
        ar[-h-1, -h-1+w] = ar[-h, -h-1+w] + ar[-h-1, -h-2+w] - ar[-h, -h-2+w]
print(int(sum(sum(ar % M == 0)) - sum(np.linspace(1, N-1, N-1))))

N = int(input())
s = ''

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

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

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):
n = int(input())
a = []
b = 0
while n != 0:
    c = (-2) ** b
    if n % (c*(-2)) != 0:
        n -= c
        a.append("1")
    else:
        a.append("0")
    b += 1
else:
    a.append("0")
ans = "".join(reversed(a))
print(ans)


n = int(input())
a = []
b = 0
while n != 0:
    c = (-2) ** b
    if n % (c*(-2)) != 0:
        n -= c
        a.append("1")
    else:
        a.append("0")
    b += 1
ans = "".join(reversed(a))
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())
if n == 0:
    print(0)
    exit()
flag = True
ans_str = ''
while True:
    if n // (-2) == 0:
        ans_str = '1' + ans_str
        print(int(ans_str))
        exit()
    else:
        ans_str = n%(-2) + ans_str

n = int(input())
if n == 0:
    print(0)
    exit()
flag = True
ans_str = ''
while True:
    if n == 1:
        ans_str = '1' + ans_str
        print(int(ans_str))
        exit()
    if n < 0 and (-n)%2 == 1:
        ans_str = '1' + ans_str
        n = -(n-1)//2
    elif n < 0 and (-n)%2 == 0:
        ans_str = '0' + ans_str
        n = -n//2
    elif n > 0 and n%2 ==1:
        ans_str = '1' + ans_str
        n = -(n//2)
    elif n > 0 and n%2 ==0:
        ans_str = '0' + ans_str
        n = -(n//2)

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 = ''
ans_l = []
if N != 0:
	while N != 0:
		if N % 2 == 0:
			N = N // (-2)
  			S = '0' + S
		else:
  			N = (N-1) // (-2)
  			S = '1' + S
else:
	S = '0'
print(S)


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



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

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


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

while N != 0:
    if N % 2 != 0:
        ans = "1" + ans
        N -= 1
    else:
        ans = "0" + ans
    N /= -2
if ans == "": ans = "0"
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())
if n==0:print(0)
bi=''
while n!=0:
    bi+=str(n%abs(k))
    if k<0:n=-(-n//k)
    else:n=n//k
print(bi[::-1])


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

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


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())
ans = ""
for i in range(100):
    while n != 0:
        r = (n % 2)
        n = (n - r) // (-2)
        ans = str(r) + ans
if n==0:
    print("0")
else:
    print(ans)

n = int(input())
ps = [0] * (1 << 16)
for i in range(1 << 16):
    temp = 0
    for j in range(16):
        if (i >> j) & 1:
                temp += (-2) ** (2 *j)
    ps[i] = temp

"""
for index, value in enumerate(ps):
    print(bin(index)[2:].zfill(16), value)
"""

pattern1 = None
pattern2 = None

for i in range(1 << 16):
    temp2 = 0
    for j in range(16):
        if (i >> j) & 1:
                temp2 += (-2) ** (2 *j + 1)
    n2 = n - temp2
    pattern1 = bisect.bisect_left(ps, n2)
    if pattern1 != (1 << 16) and ps[pattern1] == n2:
        pattern2 = bin(i)[2:].zfill(16)
        pattern1 = bin(pattern1)[2:].zfill(16)
        break

ans = ""
for i in range(16):
    ans += pattern2[i]
    ans += pattern1[i]
    
true_ans = ""
flag = False
for i in range(len(ans)):
    if ans[i]=="1":
        true_ans += "1"
        flag = True
    elif flag:
        true_ans += "0"

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

n = int(input())
n2 = n
ans = ""
for i in range(100):
    while n != 0:
        r = (n % 2)
        n = (n - r) // (-2)
        ans = str(r) + ans
if n2==0:
    print("0")
else:
    print(ans)

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):
n = int(input())
ans = ''`
while n != 0:
    if n % (-2) == 0:
        ans = '0' + ans
    else:
        ans = '1' + ans
        n -= 1
    n /= -2
if ans == '':
    ans = '0'
print(ans)

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

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 = str(bin(N))

string = ""

if N<0:
    for i in range(3,len(ans)):
        string = string + ans[i]
else:
    for i in range(2,len(ans)):
        string = string + ans[i]
    
print(string)

N = int(input())


ans = ""
divide = 1

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

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

N = int(input())

k = 0
S = []
while 1:
    print(k, N)
    if N % 2 == 0:
        S.append(0)
    else:
        N -= (-1) ** k
        S.append(1)
    N /= 2
    k += 1
    if N == 0:
        break

for i in S[::-1]:
    sys.stdout.write(str(i))
sys.stdout.write('\n')


import sys

N = int(input())

k = 0
S = []
while 1:
    if N % 2 == 0:
        S.append(0)
    else:
        N -= (-1) ** k
        S.append(1)
    N /= 2
    k += 1
    if N == 0:
        break

for i in S[::-1]:
    sys.stdout.write(str(i))
sys.stdout.write('\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):
import numpy as np
from functools import reduce

n = int(input())

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


i = (-2)**i
print(i.dtype)

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

for digit in range(X):

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

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


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


import numpy as np
from functools import reduce

n = int(input())

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


i = (-2)**i

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

for digit in range(X):

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

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


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


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())
  minus_bit = ''
  if N == 0:
      minus_bit = '00'
  while N != 0:
      mod = N % 4
      if mod == 0:
          minus_bit = minus_bit + '00'
          N = N//4
      elif mod == 1:
          minus_bit = minus_bit + '10'
          N = (N-1)//4
      elif mod == 2:
          minus_bit = minus_bit + '01'
          N = (N+2)//4
      else:
          minus_bit = minus_bit + '11'
          N = (N+1)//4

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

N = int(input())
minus_bit = ''
if N == 0:
    minus_bit = '0'
while N != 0:
    mod = N % 4
    if mod == 0:
        minus_bit = minus_bit + '00'
        N = N//4
        print(N)
    elif mod == 1:
        minus_bit = minus_bit + '10'
        N = (N-1)//4
        print(N)
    elif mod == 2:
        minus_bit = minus_bit + '01'
        N = (N+2)//4
        print(N)
    else:
        minus_bit = minus_bit + '11'
        N = (N+1)//4
        print(N)

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

N = int(input())
minus_bit = ''
if N == 0:
    minus_bit = '00'
while N != 0:
    mod = N % 4
    if mod == 0:
        minus_bit = minus_bit + '00'
        N = N//4
    elif mod == 1:
        minus_bit = minus_bit + '10'
        N = (N-1)//4
    elif mod == 2:
        minus_bit = minus_bit + '01'
        N = (N+2)//4
    else:
        minus_bit = minus_bit + '11'
        N = (N+1)//4

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

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

def dnt(n):
    if n >= 0:
        return (-1) * (n // 2)
    else:
        return math.ceil((-1) * (n / 2))

N = int(input())
S = ""

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

print("1"+S)

import math

def dnt(n):
    if n >= 0:
        return (-1) * (n // 2)
    else:
        return math.ceil((-1) * (n / 2))

N = int(input())
S = ""

if N == 0:
    print(0)

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

N = int(input())

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

    return return_num

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

print(ans)

import math
 
N = int(input())
 
def calc_power(num):
    if num > 1:
        m = 5
        power = 2
        while True:
            if num <= m:
                return_num = power
                break
            else:
                m = m * 4 + 1
                power += 2 
    elif num == 1:
        return_num = 0
    elif num == 0:
        print('0')
        exit()
    else:
        m = -2
        power = 1
        while True:
            if num >= m:
                return_num = power
                break
            else:
                m = m * 4 - 2
                power += 2
 
    return return_num
 
num = N
pre_power = calc_power(N) + 1
ans = ''
while num != 0:
    power = calc_power(num)
    num -= (-2) ** power
    if power == pre_power - 1:
        ans += '1'
    else:
        for _ in range(pre_power - 1 - power):
            ans += '0'
        ans += '1'
    if num == 0:
        for _ in range(power):
            ans += '0'
    pre_power = power
 
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())

m = 2
s = ""
sgn = 1
while N!=0:
    r = N % m
    s += "1" if r != 0 else "0"
    m *= -2
    N = N -r 
if N == 0:
    print(0)
else:
    print(s[::-1])


N=int(input())

if N == 0:
    print(0)
else:
    m = 2
    s = ""
    sgn = 1
    while N!=0:
        r = N % m
        s += "1" if r != 0 else "0"
        m *= -2
        N = N -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):
n = int(input())
ans = []
i=2
j=0
k = 0
while True:
    if k==n:
        break
    if (n-k)%i==0:
        ans.append(0)
    else:
        k += i>>1 if j%2==0 else -i>>1
        ans.append(1)
    print(k)
    i = i<<1
    j+=1
for i in ans[::-1]:
    print(i,end='')
print()

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

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

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

data=int(input())

a="";k=1

while data:
	t=k;k*=-2
	if n%k:n-=t;a+="1"
	else:a+="0"
print(a[::-1]or 0)

# solution
import io
import math

data = int(input())
result=""
counter=1
if data==0:
	result="0"
while data:
	t=counter
	counter*=-2
	if data%counter:
		data-=t
		result+="1"
	else:
		result+="0"
print(result[::-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:
  ans=str(N%2)+ans
  N//=(-2)
print(ans)

N=int(input())
ans=''
while N:
  ans=str(N%2)+ans
  N=-(N//2)
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 = []
div = -2
i = 0
while n!=0:
    r = n % div
    if r == 0:
        s.append(0)
    else:
        s.append(1)
        n -= (-2) ** i
    div *= 2
    i += 1
ans = ""
for i in range(len(s)):
    ans =  str(s[i]) + ans
if n != 0:
    print(ans)
else:
    print(0)

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

print("".join(s))

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

s = map(str, s)

print("".join(s))

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

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

Verdicts: Wrong Answer

Wrong Answer

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):
n = int(input())
if n == 0:
	 print ("0")
out = []
while n != 0:
	 n, rem = divmod(n, -2)
	 if rem < 0:
	 	 n += 1
	 	 rem -= ^2
	 out.append(rem)
print ("".join(map(str, out[::-1])))

n = int(input())
if n == 0:
	 print ("0")
out = []
while n != 0:
	 n, rem = divmod(n, -2)
	 if rem < 0:
	 	 n += 1
	 	 rem -= -2
	 out.append(rem)
print ("".join(map(str, out[::-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=''
i=1
k=n
while k>0:
    if n%(2**i)!=0:
        ans='1'+ans
        k-=(-2)**(i-1)
    else:
        ans='0'+ans
    i+=1
print(ans)

n=int(input())
if n==0:
    print(0)
    exit()
ans=''
i=1
k=n
while k!=0:
    if k%(2**i)!=0:
        ans='1'+ans
        k-=(-2)**(i-1)
    else:
        ans='0'+ans
    i+=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())
s=""
while n:
    print(n)
    s=str(n&1)+s
    n=-(n>>1)
    print(s)
print(s if s else 0)

n=int(input())
s=""
while n:
    s=str(n&1)+s
    n=-(n>>1)
print(s if s 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())


ans = ""

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

n = int(input())


ans = ""

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

if n == 0:
    ans = 0

print(ans)

n = int(input())

num = -n
ans = ""


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

while num!= 0:
    if num % 2 == 0:
       ans = "0" + ans
    else:
        ans = "1" + ans
    num //= (-2)
    #print(num)
    
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)


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)
elif N == 1:
  print(1)
else:
  s = 2
  j = 2
  i = 1
  while s + j**2 <= N:
    i += 1
    s += j**2
    j*= 2
  
  k = 2 * i + 1
  print('1' + bin(int('10'*i, 2)^(N-s))[2:])

N = int(input())
if N >= 0:
  if N == 0:
    print(0)
  elif N == 1:
    print(1)
  else:
    s = 2
    j = 2
    i = 1
    while s + j**2 <= N:
      i += 1
      s += j**2
      j*= 2
  
    k = 2 * i + 1
    a  = bin(int('10'*i, 2)^(N-s))[2:]
    if len(a) < k-1:
      a = '0'*(k-1-len(a)) + a
    print('1' + a)
else:
  s = -1
  j = -2
  i = 1
  while N <= s + j:
    s += j
    j *= 4
    i += 1
  k = 2 * i
  print(bin(int('10'*i, 2)^(N-(s+j)-1))[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):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

n=int(input())
l=list(map(int,str(bin(n))[2:]))
for i in range(1,len(l)+3): 
    if l[-i] == 2: 
        l[-i] = 0
        try:
            l[-(i+1)]+=1
        except:
            l.insert(0,1)
    if i%2==0 and l[-i]==1: 
        try: 
            l[-(i+1)]+=1
        except:
            l.insert(0,1)
s = ''.join([str(x) for x in l])
print(s)

n=int(input())
l=list(map(int,str(bin(n))[2:]))
for i in range(1,len(l)+3): 
    if l[-i] == 2:
        l[-i] = 0
        if i == len(l):
            l.insert(0,1)
        else:
            l[-(i+1)]+=1
    if i%2==0 and l[-i]==1:
        if i == len(l):
            l.insert(0,1)
        else:
            l[-(i+1)]+=1
s = ''.join([str(x) for x in l])
print(s)

n=int(input())
l=list(map(int,str(bin(n))[2:]))
for i in range(1,len(l)+3): 
    if l[-i] == 2:
        l[-i] = 0
        try:
            l[-(i+1)]+=1
        except:
            l.insert(0,1)
    if i%2==0 and l[-i]==1:
        try: 
            l[-(i+1)]+=1
        except:
            l.insert(0,1)
s = ''.join([str(x) for x in l])
print(s)

n=int(input())
flg = 0
if n < 0:
    n *= -1
    flg = 1
l=list(map(int,str(bin(n))[2:]))
for i in range(1,len(l)+3): 
    try:
        if l[-i] == 2:
            l[-i] = 0
            if i == len(l):
                l.insert(0,1)
            else:
                l[-(i+1)]+=1
        if i%2==flg and l[-i]==1:
            if i == len(l):
                l.insert(0,1)
            else:
                l[-(i+1)]+=1
    except:
        pass
s = ''.join([str(x) for x in l])
print(s)

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

ans = ""

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

N = int(input())

ans = ""

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

N = int(input())

ans = ""

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

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):
import sys
def input(): return sys.stdin.readline().rstrip()

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

    ans = []
    while N != 0:
        r = N % 2
        if r < 0:
            r += 2
        ans.append(r)
        N -= r
        N //= -2
    print("".join(map(str, ans)))

if __name__ == '__main__':
    main()


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

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

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

    ans = []
    while N != 0:
        r = N % 2
        if r < 0:
            r += 2
        ans.append(r)
        N -= r
        N //= -2
    print("".join(map(str, 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):
import sys
n = int(input())
s=[]
i=0
if n==0:
  print(0)
  sys.exit()
while n > 0:
  if n%(2**(i+1))!=0:
    a=1
  else:
    a=0
  s.append(a)
  n=n-a*(-2)**i
  i+=1

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

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

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

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

n = int(sys.stdin.readline().rstrip())

def base_convert(n, b):
    res = ''
    while n:
        r = abs(n % b)
        res = str(r) + res
        n = (n - r) // b

    return int(res) if res else 0

def main():
    return base_convert(n, 3)

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

import sys

def base_convert(n, b):
  if not n: return 0
  res = ''
  while n:
    n, r = divmod(n, b)
    if r < 0: n += 1; r -= b
    res += str(r)
  return int(res[::-1])

n = int(sys.stdin.readline().rstrip())

def main():
    print(base_convert(n, -2))

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):
n=int(input())
x=""
while n!=0:
    x=str(n%2)+x
    n=-(n//2)
    print(x,n)
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