Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02960 (python)

Fixed submission:
MOD = 10**9+7
S = input()
l = len(S)
dp = [[0] * 13 for _ in range(l+1)]
dp[0][0] = 1
p = 1
for i in range(l):
  if(S[i] != '?'):
    n = int(S[i])
    for j in range(13):
      dp[i+1][(j*10+n)%13] += dp[i][j]
  else:
    for k in range(10):
      for j in range(13):
        dp[i+1][(j*10+k)%13] += dp[i][j]
  for j in range(13):
    dp[i+1][j] = dp[i+1][j]%MOD
  p = (p*10)%MOD    
print(dp[l][5])

Buggy submission (verdict: Runtime Error):
MOD = 10**9+7
S = input()
l = len(S)
dp = [[0] * 13 for _ in range(l+1)]
p = 10
dp[1][int(S[-1])] = 1
for i in range(1, l):
  if(S[l-i-1] != '?'):
    pi = (p * int(S[l-i-1])) % 13
    for j in range(13):
      dp[i+1][(j+pi)%13] = (dp[i+1][(j+pi)%13] + dp[i][j])%MOD
  else:
    for k in range(10):
      pi2 = p*k%13
      for j in range(13):
        dp[i+1][(j+pi2)%13] = (dp[i+1][(j+pi2)%13]+dp[i][j])%MOD
  p = (p*10)%MOD    
print(dp[l][5])
Problem p03112 (python)

Fixed submission:
import bisect
INF = 10**15
A, B, Q = map(int, input().split())
s = [-INF] + [int(input()) for _ in range(A)] + [INF]
t = [-INF] + [int(input()) for _ in range(B)] + [INF]
for i in range(Q):
  x = int(input())
  sw = bisect.bisect_right(s, x)-1 #xより西で一番近い(同じ場所でもいい)神社の番号
  se = sw + 1 #xより東で一番近い神社の番号
  tw = bisect.bisect_right(t, x)-1
  te = tw + 1
  res = INF
  for S in [s[sw], s[se]]:
    for T in [t[tw], t[te]]:
      d1, d2 = abs(x-S) + abs(T-S), abs(x-T) + abs(S-T)
      res = min(res, d1, d2)
  print(res)

Buggy submission (verdict: Runtime Error):
import bisect
A, B, Q = map(int, input().split())
s = [-INF] + [int(input()) for _ in range(A)] + [INF]
t = [-INF] + [int(input()) for _ in range(B)] + [INF]
for i in range(Q):
  x = int(input())
  sw = bisect.bisect_right(s, x)-1 #xより西で一番近い(同じ場所でもいい)神社の番号
  se = sw + 1 #xより東で一番近い神社の番号
  tw = bisect.bisect_right(t, x)-1
  te = tw + 1
  res = INF
  for S in [sw, se]:
    for T in [tw, te]:
      d1, d2 = abs(x-S) + abs(T-S), abs(x-T) + abs(S-T)
      res = min(res, d1, d2)
  print(res)
Problem p03239 (python)

Fixed submission:
A, B = map(int,input().split())
cost = list()
m = B + 1
for i in range(A):
  x, y = map(int, input().split())
  if y < m:
    cost.append(x)
print(min(cost) if len(cost) != 0 else 'TLE')

Buggy submission (verdict: Runtime Error):
A, B = map(int,input().split())
cost = list()
m = B + 1
for i in range(A):
  x, y = map(int, input().split())
  if y < min:
    m = y
    cost.append(x)
print(min(cost) if m <= B else 'TLE')
Problem p03261 (python)

Fixed submission:
N = int(input())
A = list()
cnt = 0
A.append(input())
for i in range(N-1):
  x = input()
  if x in A:
    cnt = 1
  elif A[i][-1:] != x[0]:
    cnt = 1
  A.append(x)
print('Yes' if cnt == 0 else 'No')

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list()
cnt = 0
A.append(input())
for i in range(N-1):
  x = input()
  if x in A:
    cnt = 1
  elif A[i][-1:] != x[0]:
    cnt = 1
  else:
    A.append(x)
print('Yes' if cnt == 0 else 'No')
Problem p03637 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
l1 = 0
l2 = 0
l4 = 0
for i in range(len(A)):
  if(A[i] % 4 == 0):
    l4 += 1
  elif(A[i] % 2 == 0):
    l2 += 1
  else:
    l1 += 1
if(l2 == 0 and l4 + 1 == l1):
  print('Yes')
elif(l4 < l1):
  print('No')
else:
  print('Yes')

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
l1 = 0
l2 = 0
l4 = 0
for i in range(A):
  if(A[i] % 4 == 0):
    l4 += 1
  elif(A[i] % 2 == 0):
    l2 += 1
  else:
    l1 += 1
if(l4 < l1):
  print('No')
else:
  print('Yes')
Problem p02732 (python)

Fixed submission:
import collections
N = int(input())
arr = list(map(int, input().split()))
count = collections.Counter(arr)
total = 0
for i in count.values():
    total += (i*(i-1)/2)
for i in arr:
    print(int(total- count[i]+1))

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
arr = np.array(list(map(int, input().split())))
u, count = np.unique(arr, return_counts=True)
total = 0
for i in count:
    total += (i*(i-1)/2)
for i in arr:
    print(int(total- count[u==i][0]+1))

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
arr = np.array(list(map(int, input().split())))
u, count = np.unique(arr, return_counts=True)
comb = []
for i in count:
    comb.append(i*(i-1)/2)
total = np.sum(comb)
comb = np.array(comb)
for i in arr:
    print(int(total- count[u==i][0]+1))
Problem p02741 (python)

Fixed submission:
arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print(arr[K-1])

Buggy submission (verdict: Runtime Error):
#B
H,W = map(int, input().split())
s=H*W
if ((H==1) or (W==1)):
    ans = 1
elif (s%2) ==0:
    ans = (s//2)
else:
    ans = ((s+1)//2)
print(ans)
Problem p02744 (python)

Fixed submission:
N = int(input())
mojis = ["a","b","c","d","e","f","g","h","i","j"]
def append_m(moji):
    arr = []
    for i in mojis[:len(set(moji))+1]:
        arr.append(moji+i)
    return arr

arr = ["a"]
for i in range(N-1):
    tmp = []
    for j in arr:
        tmp += append_m(j)
    arr = tmp
for i in arr:
    print(i)

Buggy submission (verdict: Runtime Error):
N = input()
mojis = ["a","b","c","d","e","f","g","h","i","j"]
def append_m(moji):
    arr = []
    for i in mojis[:len(set(moji))+1]:
        arr.append(moji+i)
    return arr
arr = ["a"]
for i in range(N-1):
    tmp = []
    for j in arr:
        tmp += append_m(j)
    arr = tmp
for i in arr:
    print(i)
Problem p02760 (python)

Fixed submission:
card = []       #リスト型の変数カードを定義する。
for i in range(3):      #変数カードに三列のリスト型の数字を三行文加える。
    card.append(list(map(int,input().split())))

N = int(input())        #呼ばれる数字の数を指定する。

result = [[0,0,0],[0,0,0],[0,0,0]]      #変数resultを定義する。
for _ in range(N):      #以下の動作をN回繰り返す。
    b = int(input())        #数字を読み上げる。
    for i in range(3):      #bがAijと対応していた場合、変数resultのAijと同じ位置に1を代入する。
        for j in range(3):
            if b == card[i][j]:
                result[i][j] = 1

judge = "No"        #以下の条件に当てはまらなければNoと表示する

for i in range(3):      #横のビンゴの確認
    if result[i][0] * result[i][1] * result[i][2] == 1:
        judge = "Yes"

for i in range(3):      #縦のビンゴの確認
    if result[0][i] * result[1][i] * result[2][i] == 1:
        judge = "Yes"

if result[0][0] * result[1][1] * result[2][2] == 1:     #斜めのビンゴの確認
    judge = "Yes"

if result[0][2] * result[1][1] * result[2][0] == 1:     #斜めのビンゴの確認
    judge = "Yes"

print(judge)

Buggy submission (verdict: Runtime Error):
card = []       #リスト型の変数カードを定義する。
for i in range(3):      #変数カードに三列のリスト型の数字を三行文加える。
    card.append(list(map(int,input().split())))

N = int(input())        #呼ばれる数字の数を指定する。

result = [[0,0,0],[0,0,0],[0,0,0]]      #変数resultを定義する。
for _ in range(N):      #以下の動作をN回繰り返す。
    b = int(input())        #数字を読み上げる。
    for i in range(3):      #bがAijと対応していた場合、変数resultのAijと同じ位置に1を代入する。
        for j in range(3):
            if b == card[i][j]:
                result[i][j] = 1

judge = "No"        #以下の条件に当てはまらなければNoと表示する

for i in range(3):      #横のビンゴの確認
    if result[i][0] * result[i][1] * result[i][2] == 1:
        judge = "Yes"

for i in range(3):      #縦のビンゴの確認
    if result[0][i] * result[1][i]*result[2][i] == 1:
        judge = "Yes"

if result[0][0] * result[1][1] * result[2][2] == 1:     #斜めのビンゴの確認
    judge = "Yes"

if result[0][2] * result[1][1] : result[2][1] == 1:     #斜めのビンゴの確認
    judge = "Yes"

print(judge)
Problem p02765 (python)

Fixed submission:
n,r=map(int,input().split())

if n >= 10:
  print(r)
else:
	in_rate = r + 100 * (10-n)
	print(in_rate)

Buggy submission (verdict: Runtime Error):
count = 0       #初期値を0とするcount変数を作る.
n,k = map(int,input().split())      #整数とn進数を入力する。

while True:         #nをkで割った商が0になるまでcountに1を足し続ける。
    count = count +1
    n, amari = divmod(n,k)
    if n == 0:
        break

print(count)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input())
lis = []
ing_total = 1

while n / k == 0:
    if n > k：
        lis.append(int(n % k))
        ing_total += 1
    else:
        if n >= 10:
            ing_total = 2
        else:
            ing_total = 1

print(ing_total)

Buggy submission (verdict: Runtime Error):
n,r = map(int,input().split())

if n >== 10:
    print(r)
else:
    in_rating = r + 100 * (10-n)
    print(in_rating)

Buggy submission (verdict: Runtime Error):
n,r=map(int,input.split())

if n >= 10:
  print(r)
else:
	in_rate = r + 100 * (10-n)
	print(in_rate)

Buggy submission (verdict: Runtime Error):
n,r = int(input()),int(input()) #コンテストの参加回数と表示レーティング

if n >= 10:
  print(r)
else:
  in_rate = r + 100 * (10 - n)
  print(in_rate)

Buggy submission (verdict: Runtime Error):
n,r = int(input()),int(input()) #コンテストの参加回数と表示レーティング

if n >= 10:
  print(r)
else:
  in_rate = r + 100 * (10 - n)
  print(in_rate)

Buggy submission (verdict: Runtime Error):
n,r = int(input()),int(input) #コンテストの参加回数と表示レーティング

if n >= 10:
  print(r)
else:
  in_rate = r + 100 * (10 - n)
  print(in_rate)

Buggy submission (verdict: Runtime Error):
in_rating = 0
N = int(input())
R = int(input())

if N >= 10:
  in_rating = R
  print(in_rating)
else:
  in_rating = R + 100 * (10-N)
  print(in_rating)

Buggy submission (verdict: Runtime Error):
in_rating = 0
N = int(input())
R = int(input())

if N >= 10:
  in_rating = R
  print(in_rating)
else:
  in_rating = R + 100 * (100-N)
  print(in_rating)

Buggy submission (verdict: Runtime Error):
in_rating = 0
N = int(input())
R = int(input())

if N >= 10:
  in_rating = R
  print(in_rating)
else:
  in_rating = R + 100(10-N)
  print(in_rating)

Buggy submission (verdict: Runtime Error):
in_rating = 0
N = int(input())
R = int(input())

if N >= 10:
  in_rating = R
  print(in_rating)
else:
  in_rating = R + 100(100-N)
  print(in_rating)

Buggy submission (verdict: Runtime Error):
in_rating = 0
N = int(input())
K = int(input())

if n >= 10:
  in_rating = K
  print(K)
else:
  in_rating = K + 100(100-K)
Problem p02778 (python)

Fixed submission:
s = input()
a = len(s)
print("x" * a)

Buggy submission (verdict: Runtime Error):
s = input()
a = int(len(s))
print("x" * s)

Buggy submission (verdict: Runtime Error):
s = input()
a = len(s)
print("x" * s)
Problem p02801 (python)

Fixed submission:
al = list("abcdefghijklmnopqistuvwxyz")

c = input()

print(al[al.index(c)+1])

Buggy submission (verdict: Runtime Error):
al = list("abcdefghijklmnopqistuvwxyz")

c = input()

print(al[al.index(c)]
Problem p02812 (python)

Fixed submission:
n = int(input())
s = input()
print(s.count("ABC"))

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
s2 = "ABC"
print(n.count(s2))

Buggy submission (verdict: Runtime Error):
n = int(input())
s = list(input())
ing_total = 0
for i in range(n):
    if s[i] == "A":
        if s[i + 1] == "B":
            if s[i+2] == "C":
                ing_total+= 1
print(ing_total)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = list(input())
ing_total = 0

while i < n - 2
    if s[i] == "A":
        if s[i + 1] == "B":
            if s[i+2] == "C":
                ing_total+= 1
print(ing_total)
Problem p02885 (python)

Fixed submission:
a,b = map(int,input().split())

if a < 2 *b:
    print(0)
else:
    print(a-2*b)

Buggy submission (verdict: Runtime Error):
a,b = int(input()),int(input())

if a > 2b:
  print(int(a-2b))
else:
  print(0)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())

if a > 2b:
  print(int(a - 2b))
else:
  print(0)
Problem p02909 (python)

Fixed submission:
s = input()
weather = ["Sunny","Cloudy","Rainy"]

a = weather.index(s)
if a == 2:
    print("Sunny")
else:
    print(weather[a+1])

Buggy submission (verdict: Runtime Error):
s = input()
weather = ["Sunny","Cloudy","Rainy"]

a = weather[s]
if a == 2:
    print("Sunny")
else:
    print(weather[a+1])

Buggy submission (verdict: Runtime Error):
s = input()
weather = ["Sunny","Cloudy","Rainy"]

a = weather[s]
print(weather[a+1])
Problem p02921 (python)

Fixed submission:
s = list(input())
t = list(input())
ing_total = 0

for x in range(3):
    if s[x] == t[x]:
        ing_total+=1
    else:
        ing_total+=0
print(ing_total)

Buggy submission (verdict: Runtime Error):
s = list(input())
t = list(input())
ing_total = 0

for x in range(2):
    if s[x] == t[x]:
        ing_total+=1
    else:
        ing_total+=0
     print(ing_total)

Buggy submission (verdict: Runtime Error):
s = list(input())
t = list(input())
ing_total = 0

for x in range(2):
    if s[x] == t[x]:
        ing_total+=1
    print(ing_total
Problem p02934 (python)

Fixed submission:
n = int(input())
lis = list(map(int,input().split()))
ing_total = 0

for i in range(n):
    ing_total+= 1 / lis[i]

print(1/ing_total)

Buggy submission (verdict: Runtime Error):
n = int(input())
lis = list(map(int,input().split()))
ing_total = 0

for i in range(n):
    ing_total+= 1 / lis[i]

print(int(1/ing_total)
Problem p02946 (python)

Fixed submission:
k,x = map(int,input().split())

lis = []
for i in range(x-k+1, x+k):
    lis.append(i)

print(" ".join(map(str,lis)))

Buggy submission (verdict: Runtime Error):
k,x = map(int,input().split())

lis = [x]
x_1 = x
x_2 = x

for i in range(k-1):
    x_1 += 1
    x_2 -= 1
    lis.append(x_1)
    lis.append(x_2)
new_list = sorted(lis)

print(" ".join(new_list))

Buggy submission (verdict: Runtime Error):
k,x = map(int,input().split())

lis = [x]

for i in range(1,k):
    lis.append(x-1)
    lis.append(x+1)
new_list = sorted(lis)

print(" ".join(new_list))
Problem p02993 (python)

Fixed submission:
a = input()
for i in range(3):
    if a[i] == a[i+1]:
        print("Bad")
        quit()
print("Good")

Buggy submission (verdict: Runtime Error):
s = list(input())

for i in range(4):
    if s[i] == s[i+1]:
        print("Bad")
        exit()

print("Good")

Buggy submission (verdict: Runtime Error):
s = int(input())

for i in range(4):
    if s[i] == s[i+1]:
        print("Bad")
    else:
        print("Good")
Problem p02999 (python)

Fixed submission:
x,a = map(int,input().split())

if x <a:
    print(0)
else:
    print(10)

Buggy submission (verdict: Runtime Error):
x,a = map(int,input().split())

if x <a:
    print(o)
else:
    print(10)
Problem p03071 (python)

Fixed submission:
a,b = map(int,input().split())
if a >b:
    print(2*a-1)
elif a == b:
    print(a+b)
else:
    print(2*b-1)

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
s = max(2*a,2*b,a+b)
if s == 2 *a or s==2*b and 2*a != a+b and 2*b != a+b
    print(s-1)
else:
    print(s)
Problem p03210 (python)

Fixed submission:
x = int(input())
lis = [7,5,3]


if x in lis:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
x = int(input)
lis = [3,5,7]

for i in range(3):
    if x == lis[i]:
        print("Yes")
    else:
        print("No")
Problem p03260 (python)

Fixed submission:
a,b = map(int,input().split())

if a % 2 == 0 or b % 2 == 0:
    print('No')
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
k = int(input())

if k % 2 == 0:
    num = k * k /4
else:
    base = (k-1) / 2
    num = base * (base + 1)

print(int(num))
Problem p02717 (python)

Fixed submission:
X,Y,Z=input().split()
print(Z,X,Y)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = list(map(int, input().split()))
sum = sum(A)
A2 = sorted(A,reverse=True)
Judge = 0
for i in range(N):
    if(A2[i]>(sum/(4*M))):
        Judge = Judge+1
if Judge<M:
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = list(map(int, input().split()))
sum = sum(A)
A2 = sorted(A,reverse=True)
Judge = 0
for i in range(N):
    if(A2[i]>(sum/(4*M))):
        Judge = Judge+1
if Judge>=M:
    print("Yes")
else:
    print("No")
Problem p02778 (python)

Fixed submission:
S = input()
char_list = list(S)
new_list=[]
for char  in char_list:
    char = "x"
    new_list.append(char)
output = "".join(new_list)
print(output)

Buggy submission (verdict: Runtime Error):
S = input()
char_list = list(S)
new_list=[]
for char  in char_list:
    char = "x"
    new_list.append(char)
output = "".join(new_list)
print(output)
Problem p02582 (python)

Fixed submission:
s = input()
num = 0
num2 = 0
for i in range (3) :
#  print(s[i])

  yesterday = 'R'
  if s[i] == 'R':
    if yesterday == 'R':
      num2 += 1
    else :
      yesterday = 'R'
  else :
    yesterday = 'S'
    if num2 > num:
      num = num2
      num2 = 0


if num2 > num:
  num = num2


print(num)

Buggy submission (verdict: Runtime Error):
num_bars = 3
length_list = list(map(int,input().split()))

x = abs(length_list[0])
k = length_list[1]
d = length_list[2]

amari =  x % d
syou = x // d

#print(amari)
#print(syou)

val = x

if x - k * d > amari:
  val = x - k * d
elif (k - syou ) % 2 == 0:
  val = amari
else :
  val = d - amari
  
  
print(val)

Buggy submission (verdict: Runtime Error):
num_bars = int(input())
length_list = list(map(int,input().split()))
length_list.sort()
#print(length_list)

count = 0

for i in range(num_bars):
  a = length_list[i]
  for j in range(i + 1,num_bars):
    b = length_list[j]
    if a == b:
      continue
    else :
      for k in range(j + 1,num_bars):
        c = length_list[k]
        if b == c:
          continue
        if a + b <= c:
          continue
        count += 1

        
print(count)
        
#  for j in
Problem p02612 (python)

Fixed submission:
N = int(input())
if N%1000 == 0:
  print('0')
else:
  print(-1*(N%1000-1000))

Buggy submission (verdict: Runtime Error):

N = int(input())
if N%1000 == 0:
  print(0)
else:
Problem p02639 (python)

Fixed submission:
a,b,c,d,e = map(int,input().split())
if a == 0 :
  print('1')
elif b == 0 :
  print('2')
elif c == 0 :
  print('3')
elif d == 0 :
  print('4')  
else:
  print('5')

Buggy submission (verdict: Runtime Error):
X,Y = map(int,input().split())
if 2*X == Y or 4*X == Y or 3*X == Y or Y%X ==1 or Y%X == 2:
  print('Yes')
else:
  print('No')
Problem p02706 (python)

Fixed submission:
N,M = map(int,input().split())
A = sorted(map(int, input().split()))
ans = N-sum(A)
if N-sum(A) >= 0:
  print(ans)
else:
  print('-1')

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
A = sorted(map(int, input().split()))
ans = N-sum(A)
if = N-sum(A) >= 0:
  print(ans)
else:
  print('-1')

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
A = sorted(map(int, input().split()))
ans = sum(A)-N
if = sum(A)-N >= 0:
  print(ans)
else:
  print('-1')
Problem p02730 (python)

Fixed submission:
S = input()
N = len(S)
if S == S[::-1] and  S[:(N-1)//2] == S[(N-3)//2::-1] and S[(N+1)//2:] == S[:(N-1)//2:-1] :
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
S= input()
if S[0::] = S[::-1]
  print(Yes)
else
  print(No)

Buggy submission (verdict: Runtime Error):
S= input()
if S[0::] = S[::-1]
  print(Yes)
else
  print(No)
Problem p02608 (python)

Fixed submission:
N=int(input())
ans=[0 for _ in range(10050)]
for x in range(1,105):
    for y in range(1,105):
        for z in range(1,105):
            v=x**2+y**2+z**2+x*y+y*z+z*x
            if v<10050:
                ans[v]+=1

for i in range(N):
    print(ans[i+1])

Buggy submission (verdict: Runtime Error):
N=int(input())
ans=[0 for _ in range(10000)]
for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            v=x**2+y**2+z**2+x*y+y*z+z*x
            if v<10050:
                ans[v]+=1

for i in range(N):
    print(ans[i])
Problem p02706 (python)

Fixed submission:
input_= list(map(int, input().split()))
timeofholiday=input_[0]
sum=0
homework_num=input_[1]
que=list(map(int, input().split()))
for i in que:
  sum+=i
  
if sum > timeofholiday:
  print("-1")
else:
  print(timeofholiday-sum)

Buggy submission (verdict: Runtime Error):
timeofholiday=int(input())
sum=0
homework_num=int(input())
for i in range(homework_num):
  a=int(input())
  sum+=a
  
if sum > timeofholiday:
  print("-1")
else:
  print(timeofholiday-sum)
Problem p02609 (python)

Fixed submission:
def Base_n_to_10(X,n):
    out = 0
    for i in range(1,len(str(X))+1):
        out += int(X[-i])*(n**(i-1))
    return out#int outn=int(input())
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)
n=int(input())
x=input()
ans=[]
pc=x.count("1")
la=[float("inf")]*pc
for i in range(1,pc+1):
    i10=str(Base_10_to_n(i, 2)).count("1")
    if i%i10==0:
      la[i-1]=1
    else:
      la[i-1]=la[(i%i10)-1]+1
if pc!=1:
  x10=Base_n_to_10(x,2)
  a=x10%(pc+1)
  b=x10%(pc-1)
  for i in range(1,n+1):
    if x[i-1]=="0":
      ans.append((a+pow(2,n-i,pc+1))%(pc+1))
    else:
      ans.append((b-pow(2,n-i,pc-1))%(pc-1))
  for a in ans:
    if a==0:
      print(1)
    else:
      print(1+la[a-1])
else:
  x10=Base_n_to_10(x,2)
  for i in range(1,n+1):
    if x[i-1]=="0":
      ans.append((x10+pow(2,n-i,pc+1))%(pc+1))
    else:
      ans.append("n")
  for a in ans:
    if a==0:
      print(1)
    elif a=="n":
      print(0)
    else:
      print(1+la[a-1])

Buggy submission (verdict: Runtime Error):
def Base_n_to_10(X,n):
    out = 0
    for i in range(1,len(str(X))+1):
        out += int(X[-i])*(n**(i-1))
    return out#int outn=int(input())
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)
n=int(input())
x=input()
pc=x.count("1")
la=[float("inf")]*pc
for i in range(1,pc+1):
    i10=str(Base_10_to_n(i, 2)).count("1")
    if i%i10==0:
      la[i-1]=1
    else:
      la[i-1]=la[(i%i10)-1]+1
if pc!=1:
  x10=Base_n_to_10(x,2)
  for i in range(1,n+1):
    if x[i-1]=="0":
      lk=(x10+pow(2,n-i,pc+1))%(pc+1)
    else:
      lk=(x10-pow(2,n-i,pc-1))%(pc-1)
    if lk==0:
      print(1)
    else:
      print(1+la[lk-1])
else:
  x10=Base_n_to_10(x,2)
  for i in range(1,n+1):
    if x[i-1]=="0":
      ans.append((x10+pow(2,n-i,pc+1))%(pc+1))
    else:
      ans.append("n")
  for a in ans:
    if a==0:
      print(1)
    elif a=="n":
      print(0)
    else:
      print(1+la[a-1])

Buggy submission (verdict: Runtime Error):
def Base_n_to_10(X,n):
    out = 0
    for i in range(1,len(str(X))+1):
        out += int(X[-i])*(n**(i-1))
    return out#int outn=int(input())
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)
n=int(input())
x=input()
ans=[]
pc=x.count("1")
x10=Base_n_to_10(x,2)
for i in range(1,n+1):
  if x[i-1]=="0":
    ans.append((x10+pow(2,n-i,pc+1))%(pc+1))
  else:
    ans.append((x10+pow(2,n-i,pc-1))%(pc-1))
la=[float("inf")]*n
for i in range(1,n+1):
  i10=str(Base_10_to_n(i, 2)).count("1")
  if i%i10==0:
    la[i-1]=1
  else:
    la[i-1]=la[(i%i10)-1]+1
for a in ans:
  if a==0:
    print(1)
  else:
    print(1+la[a-1])
Problem p02612 (python)

Fixed submission:
n=int(input())
print(1000-n%1000 if n%1000!=0 else 0)

Buggy submission (verdict: Runtime Error):
import static org.hamcrest.CoreMatchers.is;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;

import org.junit.Assert;
import org.junit.Test;

public class MainTest {

	@Test
	public void 入力例_1() throws Exception {
		String input = 
			"1900";
		String output = 
			"100";

		assertIO(input, output);
	}

	@Test
	public void 入力例_2() throws Exception {
		String input = 
			"3000";
		String output = 
			"0";

		assertIO(input, output);
	}

	private void assertIO(String input, String output) throws Exception {
		ByteArrayInputStream in = new ByteArrayInputStream(input.getBytes());
		System.setIn(in);

		ByteArrayOutputStream out = new ByteArrayOutputStream();
		System.setOut(new PrintStream(out));

		Main.main(new String[0]);

		Assert.assertThat(out.toString(), is(output + System.lineSeparator()));
	}
}
n=int(input())
print(n)
Problem p02645 (python)

Fixed submission:
S=input()
print(S[0:3])

Buggy submission (verdict: Runtime Error):
import sys
n,k=map(int,input().split())
a=list(map(int,input().split()))
if n<=k:
    print(*[n]*n)
else:
    for i in range(k):
        data=[0]*(n+1)
        for j in range(n):
          data[max(j-a[j-1]-1,0)]+=1
          data[min(j+a[j-1],n)]-=1
        r=[0]*n
        r[0]=data[0]  
        for i in range(1,n):
          r[i]=r[i-1]+data[i]
        if a==r:
            print(*[n]*n)
            sys.exit()
        a=r
    print(*a)