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())
ts = fetch_Hosu(N)

le = len(ts)
numl = [0]* 15

for i in range(15):
    tmp = int(ts[2*i+1:2*i+3])
    
    if tmp ==1:
        numl[i]  += 11
    elif tmp ==11:
        if i>1:
            numl[i-1]  += 11
        numl[i]  += 1
    else:
        numl[i]  += tmp
    
#     print(numl)

# print(numl)

for j in range(len(numl)):
    if numl[14-j]==21:
        numl[13-j]  += 11
        numl[14-j]  = 1

    if numl[14-j]==12:
        numl[14-j]  = 0
    
    if numl[14-j]==22:
        numl[14-j]  = 10
    
# print(numl)
outttt = ["{0:02d}".format(i) for i in numl]
# print(outttt)
ttt=""
for k in range(len(outttt)):
    ttt += outttt[k]

ttt += ts[-1]

if int(ttt)==0:
    print(0)
else:
    tetee = str(ttt)
    tpl = tetee[2:].find("1")
    print(tetee[tpl+2:])

N = int(input())
ts = fetch_Hosu(N)

le = len(ts)
numl = [0]* 15

for i in range(15):
    tmp = int(ts[2*i+1:2*i+3])
    
    if tmp ==1:
        numl[i]  += 11
    elif tmp ==11:
        if i>1:
            numl[i-1]  += 11
        numl[i]  += 1
    else:
        numl[i]  += tmp
    
#     print(numl)

# print(numl)

for j in range(len(numl)):
    if numl[14-j]==21:
        numl[13-j]  += 11
        numl[14-j]  = 1

    if numl[14-j]==12:
        numl[14-j]  = 0
    
    if numl[14-j]==22:
        numl[14-j]  = 10
    
# print(numl)
outttt = ["{0:02d}".format(i) for i in numl]
# print(outttt)
ttt=""
for k in range(len(outttt)):
    ttt += outttt[k]

ttt += ts[-1]

# print(ttt)
tetee = str(ttt)
tpl = tetee[2:].find("1")
print(tetee[tpl+2:])

N=int(input())

lr = ""
i=1

if N==0:
    print(0)

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

        i+=1

    print(lr)

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

S = str()
count = 1
memo = 0
while a:
    amari = N%(2 ** count)
#    print ('amari', amari)
    if (amari- memo) == 2 ** (count-1):
        s = 1
    else:
        s = 0
    memo = memo + s * (-2) **(count-1)
#    print ('momo', memo)
    S = str(s) + S
    count += 1
    if memo == N:
        print (S)
        a = not a


N = int(input())
ans = []

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

num = 1
while N:
    if N % (num * (-2)):
        ans.append(1)
        N -= num
    else:
        ans.append(0)
    num *= -2

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

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

n = int(input())
li = []
res = n % (-2)
ans = n // (-2)
ans1 = n
if res != 0:
    res = ans1 - (-2) * (ans + 1)
    ans = ans + 1
ans1 = ans
li.append(res)
p = 0
if ans == 0 or ans == 1:
    p = 1
    if ans == 1:
      li.append(ans)
while p == 0:
  res = ans % (-2)
  ans = ans // (-2)
  if res != 0:
      res = ans1 - (-2) * (ans + 1)
      ans = ans + 1
  ans1 = ans
  li.append(res)
  if ans == 0 or ans == 1:
    p = 1
    if ans == 1:
      li.append(ans)
li = [str(n) for n in li]
pr = ""
for i in range(len(li)):
  pr += li[-1-i]
print(pr)

Verdicts: Wrong Answer

Accepted
Problem: Given an integer N, find the base -2 representation of N.  Here, S is the base -2 representation of N when the following are all satisfied:    * S is a string consisting of `0` and `1`.   * Unless S = `0`, the initial character of S is `1`.   * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N.  It can be proved that, for any integer M, the base -2 representation of M is uniquely determined.

Submission attempts (in order):
from math import *
a = int(input())

# imax =
flag1 = a%2!=0
flag2 = a <=0

if flag1:
    a -=1

def Base_10_to_n(X, n):
    print(int(X/n))
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(abs(X%n))
    return str(abs(X%n))

x2 = Base_10_to_n(a, -2)

if flag1:
    print(x2[:-1]+"1")
else:
    print(x2)

n = int(input())

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

if s=='':
  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())

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

flag = N < 0
N = N + 1
ans = ''
for i in range(100,0,-1):
    if N == 0:
        break;
    if (flag and i % 2 == 0) or (not(flag) and i%2 == 1):
        ans = ans + '0'
        continue
    x = (-2) ** i
    if abs(N) >= abs(x):
        N = N - x
        ans = ans + '1'
    else:
        ans = ans + '0'
    


print (ans)


N = int(input())

ans = ''
N = N * (-1)
while N :
    m = abs(N%2)
    ans = ans + str(m)
    N = (N // (-2))
    

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


Verdicts: Wrong Answer

Accepted
Problem: Given an integer N, find the base -2 representation of N.  Here, S is the base -2 representation of N when the following are all satisfied:    * S is a string consisting of `0` and `1`.   * Unless S = `0`, the initial character of S is `1`.   * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N.  It can be proved that, for any integer M, the base -2 representation of M is uniquely determined.

Submission attempts (in order):
from math import log2

def main():
    N = int(input())
    if N == 0:
        print(0)
        return
    Ans = []
    while N !=  1:
        r = N%2
        Ans.append(r)
        N = -1*( N // 2)
    print(*Ans[::-1],sep="")
    return

if __name__ == "__main__":
    main()

from math import log2

def main():
    N = int(input())
    if N <= 0:
        print(0)
        return
    K = int(log2(abs(N))) + 1
    Ans = []
    for _ in range(K):
        r = N%2
        Ans.append(r)
        N = -1*( N // 2)
    print(*Ans[::-1],sep="")
    return

if __name__ == "__main__":
    main()

from math import log2

def main():
    N = int(input())
    if N == 0:
        print(0)
        return
    Ans = []
    while N !=  0:
        r = N%2
        Ans.append(r)
        N = -1*( N // 2)
    print(*Ans[::-1],sep="")
    return

if __name__ == "__main__":
    main()

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

print(N%(-2),N//(-2))

Ans = ""
while N!=0:
    Ans = str(N%2) +Ans
    N = (N - N%2)//2
    N *= -1

print(Ans)

N = int(input())

Ans = 0
while N!=0:
    Ans = str(N%2) +Ans
    N = (N - N%2)//2
    N *= -1

print(Ans)

N = int(input())

Ans = ""
while N!=0:
    Ans = str(N%2) +Ans
    N = (N - N%2)//2
    N *= -1

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

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())
if n == 0:
	print(0)
	exit()
res = ""
while True:
	if n == 0:
		break
	else:
		if n%2 == 0:
			res += '0'
		else:
			res += '1'
			n -= 1
		n //= -2
		print(n)
print(res[::-1])

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

ans = []

while N != 0:
  if N < 0:
    N = abs(N)+2
  b = N % 2
  N = N // (-2)
  ans.append(b)
  #print(N,b,ans)

ans = map(str, ans)
ans_str = "".join(ans)
print(ans_str[::-1])

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

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=[]
t=N
while t > 0:
    if t%(-2)==0:
        ans.append('0')
        t //= -2
    else:
        ans.appappend('1')
        t=(t-1)//(-2)
        
print(''.join(reversed(ans)))
        

N=int(input())
ans=[]
t=N
while t != 0:
    if t%(-2)==0:
        ans.append('0')
        t //= -2
    else:
        ans.append('1')
        t=(t-1)//(-2)
        
ans = rereversed(ans)
print(''.join(ans))
        

N = int(input())

L = [[0,1]]
i = 1
while True:
	d = (-2) ** i
	if d < 0:
		L.append([L[-1][0]+d,L[-1][1]])
	else:
		L.append([L[-1][0],L[-1][1]+d])

	a,b = L[-1]
	if a <= N <= b:
		break

	i += 1
		
ans = []
tmp = N
for i in reversed(range(len(L))):
	if i == 0:
		if tmp == 1:
			ans.append("1")
		else:
			ans.append("0")
		break

	add = (-2) ** i
	a,b = L[i]
	c,d = L[i-1]
	if a == c:
		if d < tmp <= b:
			ans.append("1")
			tmp -= add
			continue
	elif b == d:
		if a <= tmp < c:
			ans.append("1")
			tmp -= add
			continue

	ans.append("0")

if ans[0] == "0":
	ans.pop(0)

print("".join(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):
from itertools import product
def main():
    N = int(input())
    if N == 0:
        return 0
    l = set()
    while N != 0:
        if N > 0:
            r = plus(N)
            l.add(r)
            N -= pow(2, r)
        else:
            r = minus(N)
            l.add(r)
            N += pow(2, r)
    s = [0] * (max(l)+1)
    for i in range(max(l)+1):
        if i in l:
            print(i)
            s[i] = 1
    s.reverse()
    return ''.join(str(i) for i in s)

def plus(N):
    p = 0
    n = 0
    while True:
        p += pow(2, n)
        if p >= N:
            break
        n += 2
    return n
def minus(N):
    p = 0
    n = 1
    while True:
        p -= pow(2, n)
        if p <= N:
            break
        n += 2
    return n

print(main())


def main():
    N = int(input())
    if N == 0:
        return 0
    l = set()
    while N != 0:
        if N > 0:
            r = plus(N)
            l.add(r)
            N -= pow(2, r)
        else:
            r = minus(N)
            l.add(r)
            N += pow(2, r)
    s = [0] * (max(l)+1)
    for i in range(max(l)+1):
        if i in l:
            s[i] = 1
    s.reverse()
    return ''.join(str(i) for i in s)
def plus(N):
    p = 0
    n = 0
    while True:
        p += pow(2, n)
        if p >= N:
            break
        n += 2
    return n
def minus(N):
    p = 0
    n = 1
    while True:
        p -= pow(2, n)
        if p <= N:
            break
        n += 2
    return n

print(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())
i = 1
s = []
while n!=0:
    if n%2**i>0:
        s.append('1')
        n -= (-2)**(i-1)
    else:
        s.append('0')
    i += 1
if n==0:
    print('0')
else:
    print(''.join(s[::-1]))

n = int(input())
ans = []
for i in range(100):
    if n%(2**(i+1))>0:
        ans.append('1')
        n -= (-2)**i
    else:
        ans.append('0')
    if n==0:
        break
print(''.join(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())

s = ""
while abs(N) > 0:
    m = N % (-2)
    if m != 0:
        s = "1" + s
    else:
        s = "0" + s
    N = (N+m) // (-2)
    print(m, N)
print(s)


N = int(input())

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

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

        print(ans)


N = int(input())

n, ans, d = N, '', 2
while abs(n) > 0:
    ans = '0' + ans if n % d == 0 else '1' + ans
    n, d = n - n % d, d * (-2)
print('0' if N == 0 else 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,K = map(int,input().split())
Alist = list(map(int, input().strip().split()))
p = 1
for i in range(len(Alist)-1):
    if Alist[i]*Alist[i+1] <= 0:
        q = i
        p = p*(-1)
length = 10**10
ans2 = 10**10
if p == 1:
    if Alist[0] > 0:
        ans = Alist[K-1]
    if Alist[0] < 0:
        ans = -Alist[0]
if p == -1:
    for i in range(len(Alist)):
        if i + K - 1 < len(Alist):
            if i + K - 1 == q:
                length = min(abs(Alist[i]),length)
            elif i == q + 1:
                length = min((Alist[i+K-1]),length)
            else:
                length = min(min(abs(Alist[i+K-1]-Alist[i])+abs(Alist[i]),abs(Alist[i+K-1]-Alist[i]),abs(Alist[i+K-1])),length)
    ans = length
for i in range(len(Alist)):
    ans2 = min(ans2,abs(Alist[i]))
if K == 1:
    print(ans2)
else:
    if len(Alist) > 1:
        print(ans)
    if len(Alist) ==1:
        print(Alist[0])

N = int(input())
p = []
if N > 0:
    for i in range(500):
        if (2**(2*i)-1)/3 < N <= (2**(2*(i+1))-1)/3:
            q = 2*i + 1
if N < 0:
    for i in range(1,500):
        if -(2**(2*i+1)-2)/3 <= N < -(2**(2*i-1)-2)/3:
            q = 2*i
if N == 0:
    q = 1
def cal(n,i):
    if i % 2 != 0:
        if (2**(i-1)-1)/3 < n <= (2**(i+1)-1)/3:
            p.append(1)
            n = n - (-2)**(i-1)
            i = i-1
            if i > 0:
                cal(n,i)
        else:
            p.append(0)
            i = i-1
            if i > 0:
                cal(n,i)
    elif n == 0:
        p.append(0)
        i = i-1
        if i > 0:
            cal(n,i)
    else:
        if -(2**(i+1)-2)/3 <= n < -(2**(i-1)-2)/3:
            p.append(1)
            n = n - (-2)**(i-1)
            i = i-1
            if i > 0:
                cal(n,i)
        else:
            p.append(0)
            i = i-1
            if i > 0:
                cal(n,i)
            
    return p
ans = cal(N,q)
for i in range(len(ans)):
    ans[i] = str(ans[i])
print(''.join(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=""
while n!=0:
  if (n%2)!=0:
    n-=1
    ans="1"+ans
  else:
    ans="1"+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):
import sys
n = int(input())
if n == 0:
  print('0')
  sys.exit()
t = []
while n != 0:
  r = n % 2
  t.append(str(r))
  n = (n - r) // -2
print(t[::-1])


import sys
n = int(input())
if n == 0:
  print('0')
  sys.exit()
t = []
while n != 0:
  r = n % 2
  t.append(str(r))
  n = (n - r) // -2
print(''.join(t[::-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())
x = []

if n == 0:
    print(0)
else:
    if n > 0:
        a = math.ceil(math.log2(n * 3 + 1) / 2) 
        b = 2 * a - 1
        print(b)
        x = [[]] * (b)
        print(x)
    else:
        a = math.ceil(math.log2((-3 * n + 2) / 2) / 2)
        b = 2 * a
        x = [[]] * (b)
        print(x)
    while n != 0:
        if n > 0:
            a = math.ceil(math.log2(n * 3 + 1) / 2) 
            b = 2 * a - 1 
            n = n - (2) ** (b-1)
            print(n)
            print(b-1)
            x[-b] = "1"  
        else:
            a = math.ceil(math.log2((-3 * n + 2) / 2) / 2)
            b = 2 * a
            n = n - (-2) ** (b-1)
            print(n)
            print(b-1)
            x[-b] = "1"
print(x)
x_replace = ["0" if i != "1" else i for i in x]
x_replace = "".join(x_replace)
print(x_replace)

import math
n = int(input())
x = []

if n == 0:
    print(0)
else:
    if n > 0:
        a = math.ceil(math.log2(n * 3 + 1) / 2) 
        b = 2 * a - 1
        x = [[]] * (b)
    else:
        a = math.ceil(math.log2((-3 * n + 2) / 2) / 2)
        b = 2 * a
        x = [[]] * (b)
    while n != 0:
        if n > 0:
            a = math.ceil(math.log2(n * 3 + 1) / 2) 
            b = 2 * a - 1 
            n = n - (2) ** (b-1)
            x[-b] = "1"  
        else:
            a = math.ceil(math.log2((-3 * n + 2) / 2) / 2)
            b = 2 * a
            n = n - (-2) ** (b-1)
            x[-b] = "1"
x_replace = ["0" if i != "1" else i for i in x]
x_replace = "".join(x_replace)
print(x_replace)

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())
if a == 0:
    print("0")
else:
    digits = []*10
    base = 1
    i = 0
    while a != 0:
        if a%(base*2) == 0:
            digits.append('0')
        else:
            digits.append('1')
            a -= base
        i += 0
        base *= -2
    print(''.join(digits))


a = int(input())
if a == 0:
    print("0")
else:
    digits = []*10
    base = 1
    i = 0
    while a != 0:
        if a%(base*2) == 0:
            digits.append('0')
        else:
            digits.append('1')
            a -= base
        i += 0
        base *= -2
    print(''.join(digits[::-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())

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


N = int(input())

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


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

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

import itertools
N = int(input())

if N == 0:
    print(0)
    exit()
ans = []
while N !=0:
    ans.append(N%2)
    N = -(N-N%2)//2
ans.reverse()
print("".join(list(map(str,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')
else:
    k = 0
    ans = []
    while(True):
        if N % (-2) ** k == 0:
            ans.append('0')
        else:
            ans.append('1')
            N -= (-2) ** (k - 1)
        if N == 0:
            break
        else:
            k += 1
    print(''.join(ans[::-1]))

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


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


n = int(input())
if n ==0:
  print(0)
s=''
while n !=0:
  if n%2==1:
    s="1"+s
    n-=1
  else:
    s='0'+s
  n=-n//2
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):
def sigma4jou(k):
    total = 0
    for i in range(k):
        total += 4 ** (i)
    return(total)

def pketa(N):
    k = 1
    while N - sigma4jou(k) > 0:
        k += 1
    return(2 * k - 1)

def mketa(N):
    k = 1
    while N + 2 * sigma4jou(k) < 0:
        k += 1
    return(2 * k)

def getResult(N):
    result = ""
    if N == 0:
        result += "0"
    elif N > 0:
        k = pketa(N)
        for i in range(k, 0, -2):
            j = int((i+1)/2)
            if abs((sigma4jou(j) - N) // (2 ** (i-1))) % 2 == 0:
                result += "1"
            else:
                result += "0"
            if i > 1:
                if abs(((sigma4jou(j) - N)) // (2 ** (i-2))) % 2 == 1:
                    result += "1"
                else:
                    result += "0"
    elif N < 0:
        k = mketa(N)
        for i in range(k, 0, -2):
            j = int(i/2)
            if abs((N + 2 * sigma4jou(j)) // (2 ** (i-1))) % 2 == 0:
                result += "1"
            else:
                result += "0"
            if i > 1:
                if abs(((N + 2 * sigma4jou(j))) // (2 ** (i-2))) % 2 == 1:
                    result += "1"
                else:
                    result += "0"
    return(result)

N = input()
print(getResult(N))

def sigma4jou(k):
    total = 0
    for i in range(k):
        total += 4 ** (i)
    return(total)

def pketa(N):
    k = 1
    while N - sigma4jou(k) > 0:
        k += 1
    return(2 * k - 1)

def mketa(N):
    k = 1
    while N + 2 * sigma4jou(k) < 0:
        k += 1
    return(2 * k)

def getResult(N):
    result = ""
    if N == 0:
        result += "0"
    elif N > 0:
        k = pketa(N)
        for i in range(k, 0, -2):
            j = int((i+1)/2)
            if abs((sigma4jou(j) - N) // (2 ** (i-1))) % 2 == 0:
                result += "1"
            else:
                result += "0"
            if i > 1:
                if abs(((sigma4jou(j) - N)) // (2 ** (i-2))) % 2 == 1:
                    result += "1"
                else:
                    result += "0"
    elif N < 0:
        k = mketa(N)
        for i in range(k, 0, -2):
            j = int(i/2)
            if abs((N + 2 * sigma4jou(j)) // (2 ** (i-1))) % 2 == 0:
                result += "1"
            else:
                result += "0"
            if i > 1:
                if abs(((N + 2 * sigma4jou(j))) // (2 ** (i-2))) % 2 == 1:
                    result += "1"
                else:
                    result += "0"
    return(result)

N = int(input())
print(getResult(N))

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):
a=int(input())
b=[]
if a==0:
  print(0)
else:
  while a:
	b.append(a&1)
	a=int((a-(a&1))/(-2))
  print(''.join(map(str,b)))

a=int(input())
b=[]
while a:
	print(str(a)+' '+str(a&1))
	b.append(a&1)
	a=int((a-(a&1))/(-2))
print(''.join(map(str,b)))

a=int(input())
b=[]
if a==0:
	print(0)
while a:
	b.append(a&1)
	a=int((a-(a&1))/(-2))
print(''.join(map(str,b)))

a=int(input())
b=[]
if(a==0)print(0)
while a:
	b.append(a&1)
	a=int((a-(a&1))/(-2))
print(''.join(map(str,b)))

a=int(input())
b=''
while a:
  s=str(a&1)+s
  n=-(n//2)
print(b if b else 0)

a=int(input())
b=[]
if(a==0)print(0)
else:
  while a:
	b.append(a&1)
	a=int((a-(a&1))/(-2))
  print(''.join(map(str,b)))

a=int(input())
b=[]
if a==0:
	print(0)
while a:
	b.append(a&1)
	a-=a&1
	a=int(a/-2)
print(''.join(map(str,b)))

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

Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Runtime Error

Runtime Error

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())
def n_aray_notation(N, n):
  if N == 0:
    return '0'
  else:
    s = ''
    while N:
      s = str(N % abs(n)) + s
      N -= N % abs(n)
      N //= n
    return s
print(n_array_notation(N, -2))

N = int(input())
def n_ary_notation(N, n):
  if N == 0:
    return '0'
  else:
    s = ''
    while N:
      s = str(N % abs(n)) + s
      N -= N % abs(n)
      N //= n
    return s
print(n_ary_notation(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())
i=0
s=[]
n=N
while 1:
    k=pow(2,i+1)
    d=n%k
    if d!=0:
        s.append(1)
        n=n-pow(-2,i)
    elif n//k!=0:
        s.append(0)
    else:
        break
    i=i+1
while s:
    print(s.pop())
    

N=int(input())
i=0
s=[]
n=N
while 1:
    k=pow(2,i+1)
    d=n%k
    if d!=0:
        s.append(1)
        n=n-pow(-2,i)
    elif n//k!=0:
        s.append(0)
    else:
        break
    i=i+1
while s:
    print(s.pop(),end="")
if N==0:
    print(0,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):
N = int(input())
if N == 0:
    print(0)
else:
    li = []
    ind = 0
    while N != 0:
        if N % 2**(ind + 1) == 0:
            li.insert(0,0)
            ind += 1
        else:
            li.insert(0,1)
            N -= (-2)**(ind)
            ind += 1            
            x = ''.join([str(li[i]) for i in range(len(li))])
            print(x)

N = int(input())
if N == 0:
    print(0)
else:
    li = []
    ind = 0
    while N != 0:
        if N % 2**(ind + 1) == 0:
            li.insert(0,0)
            ind += 1
        else:
            li.insert(0,1)
            N -= (-2)**(ind)
            ind += 1            
    x = ''.join([str(li[i]) for i in range(len(li))])
    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):
def mainusbin(num):
    base = -2
    dst = ""
    i = 0
    if abs(base) > num:
        return num
    while abs(base**i) <= num:
        i += 1
        amari = num % base**i
        if amari:
            dst = "1" + dst
            num -= base**(i-1)
        else:
            dst = "0" + dst
    return dst
src = int(input())
dst = mainusbin(src)
print(dst)


def mainusbin(num):
    base = -2
    dst = ""
    i = 0
    if abs(base) > abs(num):
        return num
    while abs(base**i) <= abs(num):
        i += 1
        amari = num % base**i
        if amari:
            dst = "1" + dst
            num -= base**(i-1)
        else:
            dst = "0" + dst
    return dst
src = int(input())
dst = mainusbin(src)
print(dst)


Verdicts: Wrong Answer

Accepted
Problem: Given an integer N, find the base -2 representation of N.  Here, S is the base -2 representation of N when the following are all satisfied:    * S is a string consisting of `0` and `1`.   * Unless S = `0`, the initial character of S is `1`.   * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N.  It can be proved that, for any integer M, the base -2 representation of M is uniquely determined.

Submission attempts (in order):
from itertools import permutations


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

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


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

from itertools import permutations


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

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


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

Verdicts: Wrong Answer

Accepted
Problem: Given an integer N, find the base -2 representation of N.  Here, S is the base -2 representation of N when the following are all satisfied:    * S is a string consisting of `0` and `1`.   * Unless S = `0`, the initial character of S is `1`.   * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N.  It can be proved that, for any integer M, the base -2 representation of M is uniquely determined.

Submission attempts (in order):
def EncodeNegBase(n, b): #Converts from decimal
	if n == 0:
		return "0"
	out = []
	while n != 0:
		n, rem = divmod(n, b)
		if rem < 0:
			n += 1
			rem -= b
		out.append(rem)
	return "".join(map(str, out[::-1]))
 
def DecodeNegBase(nstr, b): #Converts to decimal
	if nstr == "0":
		return 0
 
	total = 0
	for i, ch in enumerate(nstr[::-1]):
		total += int(ch) * b**i
	return total

N = int(input())
ans = ''
while N != 0:
    bit = N % 2
    ans = str(bit) + ans
    N -= bit
    N //= -2
if not 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)
else:
    ans=""
    while n!=0:
        ans=str(n%2)+ans
        n=n//(-2)
ans=int(ans)
print(ans)

n=int(input())

if n==0:
    ans="0"
else:
    ans=""
    while n!=0:
        ans=str(n%2)+ans
        n=-1*(n//2)
ans=int(ans)
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())
i = 0
answ = []

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

if ( N == abs(N)):
  sign = 1
  base = 0
  i = 0
  while(1):
    if N <= (-2) ** i + base:
      break
    else:
      base = base + (-2) ** i
      i = i + 2
else:
  sign = -1
  base = 0
  i = 1
  while(1):
    if N >= (-2) ** i + base:
      break
    else:
      base = base + (-2) ** i
      i = i + 2
      #print(i, base)
# keta
#print("keta", i)

if(sign == 1):
  N = N - (-2) ** i
  answ.append('1')
  i = i - 1

while(i >= 0):
  a = N
  b = N - (-2) ** i
  c = N - (-2) ** i - (-2) ** (i-1)
  d = N - (-2) ** (i-1)
  x = min(abs(a), abs(b), abs(c), abs(d))
  if abs(a) == x:
    answ.append('00')
  elif abs(b) == x:
    answ.append('10')
    N = b
  elif abs(c) == x:
    answ.append('11')
    N = c
  else:
    answ.append('01')
    N = d
  #print(i,N)
  i = i - 2

als = ''.join(answ)
print(als[::-1])

N = int(input())
i = 0
str = ""

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

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

print(str)

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 = 0
l = []

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

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

n = 0
l = []

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

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

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

n = int(input())

l = []

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

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

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


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:
    tmp=[]
    while N!=0:
        tmp.insert(0,N%(2))
        N=-N//2
    s=''.join([str(_) for _ in tmp])
    print(s)


N=-int(input())
if N==0:
    print(0)
else:
    tmp=[]
    while N!=0:
        tmp.insert(0,N%(2))
        N=-N//2
    s=''.join([str(_) for _ in tmp])
    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):
N=int(input())
L=[]
M=""
while N!=0:
  M=int((-1)*(N%(-2)))
  if N<0:
    N=int((N-1)/(-2))
  else:
    N=int(N/(-2))
  L.insert(0,str(M))
if N=0:
  print(0)
else:
  print("".join(L))

N=int(input())
L=[]
M=""
while N!=0:
  M=int((-1)*(N%(-2)))
  if N<0:
    N=int((N-1)/(-2))
  else:
    N=int(N/(-2))
  L.insert(0,str(M))
if N==0:
  print(0)
else:
  print("".join(L))

N=int(input())
L=[]
M=""
while N!=0:
  M=int((-1)*(N%(-2)))
  if N<0:
    N=int((N-1)/(-2))
  else:
    N=int(N/(-2))
  L.insert(0,str(M))
if len(L)==0:
  L=["0"]
print("".join(L))


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

ans = []
tmp = 0

def algo(n):
    if n == 0:
        return
    
    if n%2 == 0:
        tmp = 0 
    else:
        tmp = 1
    ans.append(tmp)
    algo((n-tmp)//(-2))

algo(N)
Str = ''
for i in range(len(ans)):
    Str=Str+str(ans[i])
print(Str)

import sys
N = int(input())
if N == 0:
    print(0)
    sys.exit()
ans = []
tmp = 0

def algo(n):
    if n == 0:
        return 
    
    if n%2 == 0:
        tmp = 0 
    else:
        tmp = 1
    ans.append(tmp)
    algo((n-tmp)//(-2))

algo(N)
Str = ''
ans.reverse()
for i in range(len(ans)):
    Str=Str+str(ans[i])
print(Str)



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=""
t=-2
while n != 0:
  z = 0 if n % t ==0 else 1
  s = s + str(z)
  n = n - z*t/(-2)
  t = t*(-2)
print(s)


n = int(input())
if n==0:
  print("0")
  exit()
s=""
t=-2
while n != 0:
  z = 0 if n % t ==0 else 1
  s = str(z)+s
  n = n - z*t/(-2)
  t = t*(-2)
print(s)

Verdicts: Wrong Answer

Accepted