Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict, deque
import sys, heapq, bisect, math, itertools, string, queue, copy, time
from fractions import gcd
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
EPS = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
a = 0
b = 0
k = 0

for i in itertools.permutations(range(1,n+1)):
    k += 1
    if i == p:
        a = k
    if i == q:
        b = k
ans = abs(a-b)
print(ans)

Fixed submission:
from collections import defaultdict, deque
import sys, heapq, bisect, math, itertools, string, queue, copy, time
from fractions import gcd
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
EPS = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

k, x = map(int, input().split())
ans = 'No'
if 500 * k >= x:
    ans = 'Yes'

print(ans)
Buggy python submission (verdict: Runtime Error):
 from collections import defaultdict, deque
import sys, heapq, bisect, math, itertools, string, queue, copy, time
from fractions import gcd
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
EPS = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
a = 0
b = 0
k = 0

for i in itertools.permutations(range(1,n+1)):
    k += 1
    if i == p:
        a = k
    if i == q:
        b = k
ans = abs(a-b)
print(ans)

Fixed submission:
from collections import defaultdict, deque
import sys, heapq, bisect, math, itertools, string, queue, copy, time
from fractions import gcd
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
EPS = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
a = 0
b = 0
k = 0

for i in itertools.permutations(range(1,n+1)):
    k += 1
    if i == p:
        a = k
    if i == q:
        b = k
ans = abs(a-b)
print(ans)
Buggy python submission (verdict: Runtime Error):
import math

a, b, x = map(int, input().split())
ans = 0
if a*a*b > 2*x:
    ans =180.0/np.pi*math.atan((a*b*b)/(2*x))
else:
    ans = 180.0/np.pi*math.atan((2*(a*a*b-x))/a**3)

print(ans)



Fixed submission:
import numpy as np

a, b, x = map(float, input().split())
ans = 0
if a*a*b > 2*x:
    ans =180.0/np.pi*np.arctan((a*b*b)/(2*x))
else:
    ans = 180.0/np.pi*np.arctan((2*(a*a*b-x))/a**3)

print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict, deque
import sys, heapq, bisect, math, itertools, string, queue, copy, time
from fractions import gcd
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
EPS = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())




N = int(input())
alist = list(map(int, input().split()))
ans_list = []

for i in range(N, 0, -1):
    if i > N//2:
        if alist[i-1]:
            ans_list.append(i)
    else:
        if sum(alist[i-1::i])%2 != alist[i-1]:
            ans_list.append(i)
print(len(ans_list))
if len(ans_list >0):
    print(*ans_list)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
 
b = [0] * n
 
for i in range(n, 0, -1):
    if sum(b[i-1::i]) % 2 == a[i-1]:
        continue
    else:
        b[i-1] = 1
 
c = []
for i in range(n):
    if b[i] == 1:
        c.append(i+1)
print(sum(b))
if len(c) > 0:
    print(*c)
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict,deque, Counter
import sys,heapq,bisect,math,itertools,string,queue,copy,time
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
ans = 1

[n,m] = inpl()
fibsec = [0]*n
fibsec[0] = 1
fibsec[1] = 1
fibsec[-1] = 0
for i in range(2,n-1):
    fibsec[i] = fibsec[i-1]+fibsec[i-2]

firsta = -1
for k in range(m):
    seconda = inp()
    ans = ans*(fibsec[seconda-firsta -2 ])%mod
    firsta = seconda

ans = ans*(fibsec[n-firsta-1])%mod
    
print(ans)

Fixed submission:
from collections import defaultdict,deque, Counter
import sys,heapq,bisect,math,itertools,string,queue,copy,time
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
ans = 1

[n,m] = inpl()
fibsec = [0]*(n+2)
fibsec[0] = 1
fibsec[1] = 1
fibsec[-1] = 0
for i in range(2,n+1):
    fibsec[i] = fibsec[i-1]+fibsec[i-2]

firsta = -1
for k in range(m):
    seconda = inp()
    ans = ans*(fibsec[seconda-firsta -2 ])%mod
    firsta = seconda

ans = ans*(fibsec[n-firsta-1])%mod
    

print(ans)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
h_list = list(map(int, input().split()))
dp = [0]*n

for i in range(1,n):
    temp = []
    for j in range(1,min(k,i)+1):
        temp.append(dp[i-j]+abs(h_list[i]-h_list[i-j]))
        dp[i] = min(temp)

print(dp[n-1])

Fixed submission:
from collections import defaultdict, deque
import sys, heapq, bisect, math, itertools, string, queue, copy, time
from fractions import gcd
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
EPS = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

n = int(input())
h_list = list(map(int, input().split()))
dp = [0]*n
dp[1] = abs(h_list[1]-h_list[0])

for i in range(2,n):
    dp[i] = min(dp[i-1]+abs(h_list[i]-h_list[i-1]), dp[i-2]+abs(h_list[i]-h_list[i-2]))

print(dp[n-1])

Buggy python submission (verdict: Runtime Error):
#from collections import defaultdict, deque
#import sys, heapq, bisect, math, itertools, string, queue, copy, time
#from fractions import gcd
#import numpy as np
#sys.setrecursionlimit(10**8)
#INF = float('inf')
#MOD = 10**9+7
#EPS = 10**-7
#def inp(): return int(sys.stdin.readline())
#def inpl(): return list(map(int, sys.stdin.readline().split()))
#def inpl_str(): return list(sys.stdin.readline().split())

n, k = map(int, input().split())
h_list = list(map(int, input().split()))
dp = [0]*n

for i in range(1,n):
    temp = []
    for j in range(1,min(k,i)+1):
        temp.append(dp[i-j]+abs(h_list[i]-h_list[i-j]))
        dp[i] = min(temp)

print(dp[n-1])


Fixed submission:
from collections import defaultdict, deque
import sys, heapq, bisect, math, itertools, string, queue, copy, time
from fractions import gcd
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
EPS = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

n = int(input())
h_list = list(map(int, input().split()))
dp = [0]*n
dp[1] = abs(h_list[1]-h_list[0])

for i in range(2,n):
    dp[i] = min(dp[i-1]+abs(h_list[i]-h_list[i-1]), dp[i-2]+abs(h_list[i]-h_list[i-2]))

print(dp[n-1])
Buggy python submission (verdict: Runtime Error):
def main():
    s = input()
    ans = []
    count = 0
    for char in s:
        if char in ["A", "C", "G", "T"]:
            count += 1
        else:
            ans.append(count)
            count = 0
    print(max(ans))

if __name__ == '__main__':
   main()

Fixed submission:
def main():
    s = input()
    ans = [0]
    count = 0
    for char in s:
        if char in ["A", "C", "G", "T"]:
            count += 1
        else:
            ans.append(count)
            count = 0
    ans.append(count)
    print(max(ans))

if __name__ == '__main__':
   main()
Buggy python submission (verdict: Runtime Error):
n = int(input())
p = [int(input()) for i in range(n)]

print(int(sum(p)-max(p)/2))

Fixed submission:
D = input()

if D == "25":
    print("Christmas\n")
elif D == "24":
    print("Christmas Eve\n")
elif D == "23":
    print("Christmas Eve Eve\n")
else:
    print("Christmas Eve Eve Eve\n")

Buggy python submission (verdict: Runtime Error):
D = input()

if D == 25:
    print("Christmas")
elif D == 24:
    print("Christmas Eve")
elif D == 23:
    print("Christmas Eve Eve")
elif:
    print("Christmas Eve Eve Eve")

Fixed submission:
D = input()

if D == "25":
    print("Christmas\n")
elif D == "24":
    print("Christmas Eve\n")
elif D == "23":
    print("Christmas Eve Eve\n")
else:
    print("Christmas Eve Eve Eve\n")
Buggy python submission (verdict: Runtime Error):
def main():
    n = int(input())
    a = list(map(int, input().split()))


    a.append(0)
    a.insert(0, 0)
    costs = []
    for i in range(n + 1):
        costs.append(abs(a[i + 1] - a[i]))

    s = sum(costs)
    for i in range(n):
        print(s - costs[i] - costs[i + 1] + abs(a[i] - a[i + 2]))

main()

Fixed submission:
a, b, c, d = map(int, [input() for i in range(4)])
print(min([a, b]) + min([c, d]))

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
    b = 0
    bud = 0
    for ai in a:
        if a[i] != ai:
            bud += abs(ai - b)
            b = ai
    bud += abs(b)
    print(bud)


Fixed submission:
a, b, c, d = map(int, [input() for i in range(4)])
print(min([a, b]) + min([c, d]))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
a.append(0)
a.insert(0, 0)
costs = []
for i in xrange(n + 1):
    costs.append(abs(a[i + 1] - a[i]))
s = sum(costs)
for i in xrange(n):
    print(s - costs[i] - costs[i + 1] + abs(a[i] - a[i + 2]))


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
a.append(0)
a.insert(0, 0)
costs = []
for i in range(n + 1):
    costs.append(abs(a[i + 1] - a[i]))

s = sum(costs)
for i in range(n):
    print(s - costs[i] - costs[i + 1] + abs(a[i] - a[i + 2]))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
    b = 0
    bud = 0
    for ai in a:
        if a[i] != ai:
            bud += abs(ai - b)
            b = ai
    bud += abs(b)
    print(bud)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
a.append(0)
a.insert(0, 0)
costs = []
for i in range(n + 1):
    costs.append(abs(a[i + 1] - a[i]))

s = sum(costs)
for i in range(n):
    print(s - costs[i] - costs[i + 1] + abs(a[i] - a[i + 2]))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
    b = 0
    bud = 0
    for j, ai in enumerate(a):
        if i != j:
            bud += abs(ai - b)
            b = ai
    bud += abs(b)
    print(bud)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
a.append(0)
a.insert(0, 0)
costs = []
for i in range(n + 1):
    costs.append(abs(a[i + 1] - a[i]))

s = sum(costs)
for i in range(n):
    print(s - costs[i] - costs[i + 1] + abs(a[i] - a[i + 2]))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
    b = 0
    bud = 0
    for j, ai in enumerate(a):
        if i != j:
            bud += abs(ai - b)
            b = ai
    bud += abs(b)
    print(bud)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
a.append(0)
a.insert(0, 0)
costs = []
for i in range(n + 1):
    costs.append(abs(a[i + 1] - a[i]))

s = sum(costs)
for i in range(n):
    print(s - costs[i] - costs[i + 1] + abs(a[i] - a[i + 2]))
Buggy python submission (verdict: Runtime Error):
import math
n = input()
a = list(map(int, input().split()))
ans = float('inf')
for i in a:
    ans = min(ans, len(bin(i)) - bin(i).refind('1') - 1)

Fixed submission:
import math
n = input()
a = list(map(int, input().split()))
ans = float("inf")
for i in a:
    ans = min(ans, len(bin(i)) - bin(i).rfind("1") - 1)
print(round(ans))

Buggy python submission (verdict: Runtime Error):
import math
n = input()
a = list(map(int, input().split()))
ans = float('inf')
for i in a:
    ans = min(ans, len(bin(i)) - bin(i).refind('1') - 1)

Fixed submission:
import math
n = input()
a = list(map(int, input().split()))
ans = float("inf")
for i in a:
    ans = min(ans, len(bin(i)) - bin(i).rfind("1") - 1)
print(round(ans))
Buggy python submission (verdict: Runtime Error):
D, T, S = list(map(input().split()))

if D <= S * T:
    print("Yes")
else:
    print("No")


Fixed submission:
D, T, S = list(map(int, input().split()))

if D <= S * T:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
a = 0
while N >= 1000:
  N = N - 1000
else:
  a += N
print(a)

Fixed submission:
N = int(input())
while N > 1000:
  N = N - 1000
N = 1000 - N
print(N)

Buggy python submission (verdict: Runtime Error):
my_result = 0
while N >= 1000:
    N = N - 1000
else:
    my_result += N
return my_result

Fixed submission:
N = int(input())
while N > 1000:
  N = N - 1000
N = 1000 - N
print(N)
Buggy python submission (verdict: Runtime Error):
a = input()
my_result = a + a*a + a*a*a
print(my_result)

Fixed submission:
a = int(input())
my_result = a + a**2 + a**3
print(my_result)

Buggy python submission (verdict: Runtime Error):
a = input()
my_result = a + a**2 + a**3
print(my_result)

Fixed submission:
a = int(input())
my_result = a + a**2 + a**3
print(my_result)

Buggy python submission (verdict: Runtime Error):
a = int(input())
my_result = a + a**2 + a ***3
my_result

Fixed submission:
a = int(input())
my_result = a + a**2 + a**3
print(my_result)
Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())
my_result = N * np(pi)
print(my_result)

Fixed submission:
N = int(input())
my_result = N * 2 * 3.14159265
print(my_result)
Buggy python submission (verdict: Runtime Error):
a, b, c = list(map(intl, input().split()))
if a * b >= c:
  print(c)
else:
  print(a * b)

Fixed submission:
a, b, c = list(map(int, input().split()))
if a * b >= c:
  print(c)
else:
  print(a * b)
Buggy python submission (verdict: Runtime Error):
s = input()
if s[0] == s[1] == s[2] == s[3]:
  print('No')
else:
  if s[0] == s[1]:
      if s[2] == s[3]:
        print('Yes')
      else:
        print('No')
    elif s[0] == s[2]:
      if s[1] == s[3]:
        print('Yes')
      else:
        print('No')
    elif s[0] == s[3]:
      if s[1] == s[2]:
        print('Yes')
      else:
        print('No')

Fixed submission:
s = input()
if s[0] == s[1] == s[2] == s[3]:
  print('No')
else:
  if s[0] == s[1]:
      if s[2] == s[3]:
        print('Yes')
      else:
        print('No')
  elif s[0] == s[2]:
      if s[1] == s[3]:
        print('Yes')
      else:
        print('No')
  elif s[0] == s[3]:
      if s[1] == s[2]:
        print('Yes')
      else:
        print('No')
  else:
    print('No')
Buggy python submission (verdict: Runtime Error):
a = [list(map(int, input().split())) for i in range(2)]
a[0][0] = H
a[0][1] = W
a[1][0] = h
a[1][1] = w
my_result = H * W - h * W - H * w + h * w
print(my_result)

Fixed submission:
a = [list(map(int, input().split())) for i in range(2)]
H = a[0][0] 
W = a[0][1] 
h = a[1][0] 
w = a[1][1] 
my_result = H * W - h * W - H * w + h * w
print(my_result)
Buggy python submission (verdict: Runtime Error):
a, b, c = list(map(int, input().split()))
my_result = max(a+b, a-b, a*b)
print(my_result)

Fixed submission:
a, b = list(map(int, input().split()))
my_result = max(a + b, a - b, a * b)
print(my_result)
Buggy python submission (verdict: Runtime Error):
a = [int(input()) for i in range(2)]
n = a[0] % 500
if a >= n:
  print('Yes')
else:
  print('No')

Fixed submission:
a = [int(input()) for i in range(2)]
n = a[0] % 500
if a[1] >= n:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
s = input()
s[3] = '8'
print(s)

Fixed submission:
s = input()
s_2 = s[4:10]
print('2018' + s_2)
Buggy python submission (verdict: Runtime Error):
x = [list(map(str, input().split())) for i in range(2)]
if x[0][0] == x[1][2] and x[0][1] == x[1][1] and x[1][0] == x[0][2]:
  print('YES')
else:
  print('NO')

Fixed submission:
x = [input() for i in range(2)]
if x[0][0] == x[1][2] and x[0][1] == x[1][1] and x[1][0] == x[0][2]:
  print('YES')
else:
  print('NO')

Buggy python submission (verdict: Runtime Error):
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if a[0] == b[2] and a[1] == b[1] and a[2] == b[0]:
  print('YES')
else:
  print('NO')

Fixed submission:
x = [input() for i in range(2)]
if x[0][0] == x[1][2] and x[0][1] == x[1][1] and x[1][0] == x[0][2]:
  print('YES')
else:
  print('NO')

Buggy python submission (verdict: Runtime Error):
a = [list(map(str, input().split())) for i in range(2)]
if a[0][0] == a[1][2] and a[0][1] == a[1][1] and a[0][2] == a[1][0]:
  print('YES')
else:
  print('NO')

Fixed submission:
x = [input() for i in range(2)]
if x[0][0] == x[1][2] and x[0][1] == x[1][1] and x[1][0] == x[0][2]:
  print('YES')
else:
  print('NO')
Buggy python submission (verdict: Runtime Error):
a, b, c = list(map(str, input().split()))
print(a[0].upper() + a[1].upper() + a[2].upper())

Fixed submission:
a, b, c = list(map(str, input().split()))
print(a[0].upper() + b[0].upper() + c[0].upper())

Buggy python submission (verdict: Runtime Error):
a, b, c = list(map(int, input().split()))
print(a[0].upper() + a[1].upper() + a[2].upper())

Fixed submission:
a, b, c = list(map(str, input().split()))
print(a[0].upper() + b[0].upper() + c[0].upper())
Buggy python submission (verdict: Runtime Error):
a, b = list(map(int, input().split()))
if a == 1:
  a = 14
else:
  break
if b == 1:
  b = 14
else:
  break
if a > b:
  print('Alice')
elif a == b:
  print('Draw')
else:
  print('Bob')


Fixed submission:
a, b = list(map(int, input().split()))
if a == 1:
  a = 14
else:
  a = a
if b == 1:
  b = 14
else:
  b = b
if a > b:
  print('Alice')
elif a == b:
  print('Draw')
else:
  print('Bob')
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
from collections import defaultdict 
# from bisect import *
# from heapq import *
# import math
# mod = 10**9+7

H, W, M = map(int, input().split())
raw = defaultdict(int)
col = defaultdict(int)
hw = set()
for i in range(M):
    h, w = map(int, stdin.readline().split())
    raw[h] += 1
    col[w] += 1
    hw.add((h, w))
rawkey = raw.keys()
colkey = col.keys()
ans = 0
for h in rawkey:
    for w in colkey:
        tmp = raw[h] + col[w]
        if (h, w) in hw:
            tmp -= 1
        ans = max(ans, tmp)
print(ans)

Fixed submission:
from sys import stdin
from collections import defaultdict 
# from bisect import *
# from heapq import *
# import math
# mod = 10**9+7

H, W, M = map(int, input().split())
raw = defaultdict(int)
col = defaultdict(int)
hw = set()
for i in range(M):
    h, w = map(int, stdin.readline().split())
    raw[h] += 1
    col[w] += 1
    hw.add((h, w))
mh = max(raw.values())
mw = max(col.values())
rawkey = [h for h in raw.keys() if raw[h] == mh]
colkey = [w for w in col.keys() if col[w] == mw]
for h in rawkey:
    for w in colkey:
        if (h, w) not in hw:
            print(mh + mw)
            exit()
print(mh + mw -1)
Buggy python submission (verdict: Runtime Error):
from bisect import *
from heapq import *
import math
mod = 10**9+7
N, K = map(int, input().split())
A = list(map(lambda x: (-int(x), int(x), 1), input().split()))
heapify(A)
k = 0
while K > 0:
    x, _x, c1 = A[0]
    heappop(A)
    y, _y, c2 = A[0]
    c3 = math.ceil(_x/(-y))
    print(c3)
    if c3-c1 > K:
        c3 = c1+K
        K = 0
    else:
        K -= c3-c1
    heappush(A, (-(_x/c3), _x, c3))
print(math.ceil(-A[0][0]))
print(A)

Fixed submission:
from bisect import *
from heapq import *
import math
mod = 10**9+7
N, K = map(int, input().split())
A = list(map(int, input().split()))
l = 0
r = 10**9+1
while l+1 < r:
    x = (l+r)//2
    k = 0
    for a in A:
        k += math.ceil(a/x)-1
        if k > K:
            break
    if K < k:
        l = x
    else:
        r = x
print(r)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = list(map(int, input().split()))
X = 1
for i in range(K):
    X *= A[i]
Y = X
for i in range(K, N):
    X = X * A[i] // A[i-K]
    if Y < X:
        print("Yes")
    else:
        print("No")
    Y = X

Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))
for i in range(K, N):
    if A[i-K] < A[i]:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
def popcnt(n):
    c = (n & 0x5555555555555555) + ((n>>1) & 0x5555555555555555)
    c = (c & 0x3333333333333333) + ((c>>2) & 0x3333333333333333)
    c = (c & 0x0f0f0f0f0f0f0f0f) + ((c>>4) & 0x0f0f0f0f0f0f0f0f)
    c = (c & 0x00ff00ff00ff00ff) + ((c>>8) & 0x00ff00ff00ff00ff)
    c = (c & 0x0000ffff0000ffff) + ((c>>16) & 0x0000ffff0000ffff)
    c = (c & 0x00000000ffffffff) + ((c>>32) & 0x00000000ffffffff)
    return c


N = int(input())
X = input()
pc = X.count('1')
modX1 = 0
modX2 = 0
Xi = [None] * N
x1 = 1
x2 = 1
for i in range(N):
    if X[-i-1] == '1':
        Xi[-i-1] = x1
        modX1 = (modX1+x1) % (pc-1)
        modX2 = (modX2+x2) % (pc+1)
    else:
        Xi[-i-1] = x2
    x1 = x1 * 2 % (pc-1)
    x2 = x2 * 2 % (pc+1)
for i in range(N):
    ans = 1
    x = (modX1 - Xi[i]) % (pc-1) if X[i] == '1' else (modX2 + Xi[i]) % (pc+1)
    while x != 0:
        x = x % popcnt(x)
        ans += 1
    print(ans)

Fixed submission:
def popcnt(n):
    c = (n & 0x5555555555555555) + ((n>>1) & 0x5555555555555555)
    c = (c & 0x3333333333333333) + ((c>>2) & 0x3333333333333333)
    c = (c & 0x0f0f0f0f0f0f0f0f) + ((c>>4) & 0x0f0f0f0f0f0f0f0f)
    c = (c & 0x00ff00ff00ff00ff) + ((c>>8) & 0x00ff00ff00ff00ff)
    c = (c & 0x0000ffff0000ffff) + ((c>>16) & 0x0000ffff0000ffff)
    c = (c & 0x00000000ffffffff) + ((c>>32) & 0x00000000ffffffff)
    return c


N = int(input())
X = input()
pc = X.count('1')
if pc == 0:
    for i in range(N):
        print(1)
elif pc == 1:
    if X[-1] == '1':
        for i in range(N-1):
            print(2)
        print(0)
    else:
        for i in range(N-1):
            if X[i] == '1':
                print(0)
            else:
                print(1)
        print(2)
else:
    modX1 = 0
    modX2 = 0
    Xi = [None] * N
    x1 = 1
    x2 = 1
    for i in range(N):
        if X[-i-1] == '1':
            Xi[-i-1] = x1
            modX1 = (modX1+x1) % (pc-1)
            modX2 = (modX2+x2) % (pc+1)
        else:
            Xi[-i-1] = x2
        x1 = x1 * 2 % (pc-1)
        x2 = x2 * 2 % (pc+1)
    for i in range(N):
        ans = 1
        x = (modX1 - Xi[i]) % (pc-1) if X[i] == '1' else (modX2 + Xi[i]) % (pc+1)
        while x != 0:
            x = x % popcnt(x)
            ans += 1
        print(ans)