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

Fixed submission:
def resolve():
    N = int(input())
    H = list(map(int, input().split()))
    ans = [0]
    count = 0
    for i in range(len(H) - 1):
        if H[i] >= H[i + 1]:
            count += 1
        else:
            ans.append(count)
            count = 0
    if count != 0:
        ans.append(count)
    print(max(ans))
resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    N = int(input())
    H = list(map(int, input().split()))
    ans = []
    count = 0
    for i in range(len(H) - 1):
        if H[i] >= H[i + 1]:
            count += 1
        else:
            ans.append(count)
            count = 0
    if count != 0:
        ans.append(count)
    print(max(ans))
resolve()

Buggy submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))
ans = []
count = 0
for i in range(len(H)-1):
  if H[i] >= H[i+1]:
    count += 1
  else:
    ans.append(count)
    count = 0
print(max(ans))

Buggy submission (verdict: Runtime Error):
N = int(input())
List = list(map(int, input().split()))
Lists = []
count = 0
idou = 0
while idou < N-1:
  while List[idou] >= List[idou+1]:
    idou = idou+1
    count = count+1
  Lists.addent(count)
  count = 0
print(max(count))
Problem p02934 (python)

Fixed submission:
def resolve():
    N = int(input())
    all = list(map(int, input().split()))
    ans = 0
    for i in all:
        mom = 1/i
        ans += mom
    dad = 1/ans
    print(dad)
resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    N = int(input())
    all = list(map(int, input().split()))
    ans = 0
    for i in all:
        ans += 1/i
    print(dad)
resolve()
Problem p02995 (python)

Fixed submission:
def resolve():
    A, B, C, D = map(int, input().split())
    d = D
    c = C
    gcd = 0
    while gcd == 0:
        if d % c == 0:
            gcd = c
        else:
            e = d%c
            d = c
            c = e
    lcm = C*D//gcd
    A = A-1
    print((B-B//C-B//D+B//lcm)-(A-A//C-A//D+A//lcm))
resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    A, B, C, D = map(int, input().split())
    d = D
    c = C
    gcd = 0
    while gcd == 0:
        if d % c == 0:
            gcd = c
            break
        else:
            d = c
            c = d % c
    lcm = C*D//gcd
    A = A-1
    print((B-B//C-B//D+B//lcm)-(A-A//C-A//D+A//lcm))
resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    import math
    A, B, C, D = map(int, input().split())
    lcm = C*D//math.gcd(C, D)
    A = A-1
    print((B-B//C-B//D+B//lcm)-(A-A//C-A//D+A//lcm))
resolve()
Problem p03080 (python)

Fixed submission:
def resolve():
    N = int(input())
    S = input()
    print("Yes" if S.count("R") > S.count("B") else "No")
resolve()

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
print("Yes" if S.count(B) > S.count(R) else "No")
Problem p03085 (python)

Fixed submission:
b = input()
print("A" if b=="T" else "T" if b=="A" else "G" if b=="C" else "C")

Buggy submission (verdict: Runtime Error):
b = int(input())
print("A" if b=="T" else "T" if b=="A" else "G" if b=="C" else "C")
Problem p03101 (python)

Fixed submission:
H, W = map(int, input().split())
h, w = map(int, input().split())
print((H-h)*(W-w))

Buggy submission (verdict: Runtime Error):
H W = map(int, input().split())
h w = map(int, input().split())
print((H-h)*(W-w))
Problem p03103 (python)

Fixed submission:
def resolve():
    N, M = map(int, input().split())
    A = []
    for _ in range(N):
        a = list(map(int, input().split()))
        A.append(a)
    ans = 0
    for i, j in sorted(A, key=lambda x: x[0]):
        if j >= M:
            ans += M * i
            print(ans)
            exit()
        ans += i * j
        M -= j
resolve()

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = []
B = []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
C = sorted(A)
while M > 0:
Problem p03109 (python)

Fixed submission:
S = input()
print("Heisei" if S <= "2019/04/30" else "TBD")

Buggy submission (verdict: Runtime Error):
S = input()
print("Heisei" if S<=2019/4/30 else "TBD")
Problem p03136 (python)

Fixed submission:
N = int(input())
list = list(map(int, input().split()))
print("Yes" if 2*max(list) < sum(list) else "No")

Buggy submission (verdict: Runtime Error):
N = int(input())
list = list(map(int, input().split()))
print("Yes" if (max(list))<((sum(list))-(max(list))) else "No"))

Buggy submission (verdict: Runtime Error):
N = int(input())
list = list(map(int, input().split()))
print("Yes" if max(list) < (sum(list))-(max(list)) else "No"))

Buggy submission (verdict: Runtime Error):
N = int(input())
list = list(map(int, input().split()))
print("Yes" if max(list)*2 < sum(list) else "No"))

Buggy submission (verdict: Runtime Error):
N = int(input())
list = list(map(int, input().split()))
print("Yes" if max(list) < sum(list) - max(list) else "No"))
Problem p03146 (python)

Fixed submission:
def resolve():
    s = int(input())
    ans = [s]
    count = 0
    while True:
        if ans[count]%2 == 0:
            ans.append(ans[count]/2)
        else:
            ans.append(ans[count]*3+1)
        count += 1
        for i in range(count):
            if ans[i] == ans[count]:
                print(count+1)
                exit()
resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    s = int(input())
    ans = [s]
    count = 0
    while True:
        if ans[count]%2 == 0:
            ans.append(ans[count]//2)
        else:
            ans.append(ans[count]*3+1)
        count += 1
        for i in range(count):
            if ans[i] == ans[count]:
                print(k+1)
                exit()
resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    s = int(input())
    ans = [s]
    count = 0
    while True:
        if ans[count]%2 == 0:
            ans.append(ans[count]/2)
        else:
            ans.append(ans[count]*3+1)
        count += 1
        for i in range(count):
            if ans[i] == ans[count]:
                print(k+1)
                exit()
resolve()
Problem p03238 (python)

Fixed submission:
N = int(input())
if N == 1:
  print("Hello World")
else:
  A, B = [int(input()) for i in range(2)]
  print(A+B)

Buggy submission (verdict: Runtime Error):
N = int(input())
A, B = map(int, input().split())
print("Hello World" if N == 1 else A+B)
Problem p03292 (python)

Fixed submission:
a, b, c = sorted(map(int, input().split()))
print(c-a)

Buggy submission (verdict: Runtime Error):
list = list(map(int(input().split())))
print(max(list)-min(list))
Problem p03325 (python)

Fixed submission:
def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 0
    for i in A:
        while i%2 == 0:
            ans += 1
            i = i//2
    print(ans)
resolve()

Buggy submission (verdict: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main(){
  int N;
  int ans = 0;
  for (int i = 0; i < N; i++){
    int A;
    cin >> A;
    while (A%2 == 0){
      ans++;
      A = A/2
    }
  }
  cout << ans << endl;
}
Problem p03377 (python)

Fixed submission:
A, B, X= map(int, input().split())
print("YES" if A<=X and A+B>=X else "NO")

Buggy submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
print("YES" if A+B>X else "NO")
Problem p03399 (python)

Fixed submission:
A, B, C, D = [int(input()) for i in range (4)]
print(min(A, B)+min(C, D))

Buggy submission (verdict: Runtime Error):
A, B, C, D = map(int, input().split())
print(min(A, B)+min(C, D))
Problem p03473 (python)

Fixed submission:
M = int(input())
print(48-M)

Buggy submission (verdict: Runtime Error):
    M = int(input())
    print(48-M)
Problem p03474 (python)

Fixed submission:
def resolve():
    A, B = map(int, input().split())
    S = input()
    C = "1234567890"
    for i in range(A):
        if S[i] in C:
            continue
        else:
            print("No")
            exit()
    if S[A] != "-":
        print("No")
        exit()
    for i in range(A+1, len(S)):
        if S[i] in C:
            continue
        else:
            print("No")
            exit()
    print("Yes")
resolve()

Buggy submission (verdict: Runtime Error):
    A, B = map(int, input().split())
    S = input()
    C = "1234567890"
    for i in range(len(S)):
        if i == A:
            if S[i] == "-":
                continue
            else:
                print("No")
                exit()
        else:
            if S[i] in C:
                continue
            else:
                print("No")
                exit()
    print("Yes")
resolve()

Buggy submission (verdict: Runtime Error):
    A, B = map(int, input().split())
    S = input()
    C = "1234567890"
    for i in range(len(S)):
        if i == A:
            if S[i] == "-":
                continue
            else:
                print("No")
                exit()
        else:
            if S[i] in C:
                continue
            else:
                print("No")
                exit()
    print("Yes")
    exit()
resolve()

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
S = input()
C = "1234567890"
if S[A] == "-":
  for i in range(len(S)):
    if i != A-1:
      if A[i] in C:
        continue
      else:
        print("No")
        exit()
else:
  print("No")
  exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
S = input()
C = "1234567890"
if S[A] == "-":
  for i in range(len(S)):
    if i != A-1:
      if A[i] in C:
        continue
      else:
        print("No")
        exit()
else:
  print("No")
Problem p03485 (python)

Fixed submission:
import math
a, b = map(int, input().split())
print(math.ceil((a+b)/2))

Buggy submission (verdict: Runtime Error):
import math
a, b = map(int, input().split)
print(math.ceil(a+b)/2)
Problem p03486 (python)

Fixed submission:
s = sorted(input())
t = sorted(input())[::-1]
print("Yes" if s<t else "No")

Buggy submission (verdict: Runtime Error):
s = input()
t = sorted(input())[::-1]
print("Yes" if s<t else "No")
Problem p03502 (python)

Fixed submission:
N = input()
print("Yes" if int(N)%(sum(map(int, N))) == 0 else "No")

Buggy submission (verdict: Runtime Error):
N = input()
print("Yes" if N%(sum(map(int, N))) == 0 else "No")
Problem p03555 (python)

Fixed submission:
c1 = input()
c2 = input()
print("YES" if c1 == c2[::-1] else "NO")

Buggy submission (verdict: Runtime Error):
c1 = map(int, input().split())
c2 = map(int, input().split())
print("YES" if c1 == c2[::-1] else "NO")

Buggy submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
A, B, C = map(int, input().split())
print("YES" if a==C and b==B and c==A else "NO")
Problem p03605 (python)

Fixed submission:
N = input()
if "9" in N:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
N = int(input())
if "9" in N:
  print("Yes")
else:
  print("No")
Problem p03611 (python)

Fixed submission:
def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    count = [0] * 10 ** 5
    for i in A:
        if i > 1:
            count[i - 1] += 1
        count[i] += 1
        if i < 10**5-1:
            count[i + 1] += 1
    print(max(count))
resolve()

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
count = [0]*10**5
for i in A:
    count[i-1] += 1
    count[i] += 1
    count[i+1] += 1
print(max(count))
Problem p03635 (python)

Fixed submission:
n, m = map(int, input().split())
print((n-1)*(m-1))

Buggy submission (verdict: Runtime Error):
n, m = input().split()
print((n-1)*(m-1))
Problem p03699 (python)

Fixed submission:
N = int(input())
S = [int(input()) for _ in range(N)]
if sum(S)%10 != 0:
  print(sum(S))
else:
  A = sorted(S)
  for i in A:
    if (sum(S)-i)%10 != 0:
      print(sum(S)-i)
      exit()
  print(0)

Buggy submission (verdict: Runtime Error):
import itertools
N = int(input())
S = [int(input()) for _ in range(N)]
cos = []
for i in list(itertools.product([0,1], repeat=N)):
  ans = 0
  for j in range(N):
    if i[j] == "1":
      ans += S[j]
  if ans%10 != 0:
    cos.append(ans)
print(max(cos))
Problem p03738 (python)

Fixed submission:
A = int(input())
B = int(input())
print("GREATER" if A>B else "EQUAL" if A==B else "LESS")

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
print("GREATER" if A<B else "EQUAL" if A==B else "LESS")
Problem p03773 (python)

Fixed submission:
A, B = map(int, input().split())
print((A+B) % 24)

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().slipt())
print((A+B) % 24)

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().slipt())
print((A+B)%24)
Problem p03795 (python)

Fixed submission:
N = int(input())
n = N//15
print(N*800-n*200)

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
print(math.factrial(N) % (10**9+7))
Problem p03796 (python)

Fixed submission:
import math
N = int(input())
print(math.factorial(N) % (10**9+7))

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
print(math.factorial(N)-math.factorial(N)/(10**9+7)*math.factorial(N))

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
print(math.factrial(N)%(10**9+7))
Problem p03813 (python)

Fixed submission:
x = int(input())
print("ABC" if x<1200 else "ARC")

Buggy submission (verdict: Runtime Error):
x = input()
if x<1200:
  print("ABC")
else:
  print("ARC")

Buggy submission (verdict: Runtime Error):
x = input()
if x<1200:
  print("ABC")
else:
  pritn("ARC")
Problem p03844 (python)

Fixed submission:
A, B, C = map(str, input().split())
print(int(A)+int(C) if B=="+" else int(A)-int(C))

Buggy submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
print(A+C if str(B)=="+" else A-C)

Buggy submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
B = str(B)
print(ABC)

Buggy submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
b = str(B)
print(A+C if b == "+" else A-C)

Buggy submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
print(A+C if B == "+" else A-C)
Problem p03845 (python)

Fixed submission:
N = int(input())
t = list(map(int, input().split()))
T = sum(t)
M = int(input())
for _ in range(M):
  p, x = map(int, input().split())
  print(T-(t[p-1]-x))

Buggy submission (verdict: Runtime Error):
N = int(input())
t = list(map(int, input().split()))
T = sum(t)
M = int(input())
for _ in range(M):
  p, x = map(int, input().split())
  print(T+(T[p-1]-x))
Problem p03957 (python)

Fixed submission:
def resolve():
    S = input()
    c = 0
    f = 0
    C = []
    F = []
    for i in range(len(S)):
        if S[i] == "C":
            c = 1
            C.append(i)
        elif S[i] == "F":
            f = 1
            F.append(i)
    print("Yes" if c == 1 and f == 1 and min(C) < max(F) else "No")
resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    S = input()
    i = S.index("C")
    s = S[i+1:]
    if "C" in S and "F" in s:
        print("Yes")
    else:
        print("No")
resolve()
Problem p03999 (python)

Fixed submission:
def dfs(i, f):
    if i == n-1:
        return sum(list(map(int, f.split("+"))))
    return dfs(i+1, f+s[i+1])+\
           dfs(i+1, f+"+"+s[i+1])

s = input()
n = len(s)
print(dfs(0, s[0]))

Buggy submission (verdict: Runtime Error):
def dfs(i, f):
    if i == n:
        return sum(list(map(int, f.split("+"))))
    return dfs(i+1, f+s[i+1])+\
           dfs(i+1, f+"+"+s[i+1])

s = input()
n = len(s)
print(dfs(0, s[0]))
Problem p04029 (python)

Fixed submission:
N = int(input())
print(N*(N+1)//2)

Buggy submission (verdict: Runtime Error):
N = int(input())
list = []
for i in range(N):
  list.attend(N)
  N -= 1
print(sum(list))
Problem p02691 (python)

Fixed submission:
from collections import Counter

N,*A = map(int,open(0).read().split())
#j - i = Aj + Ai
#j - Aj = Ai + i
#L = i + Ai, R = j - Aj とおく
L = []
R = []
for i in range(N):
    L.append(i+1 + A[i])
    R.append(i+1 - A[i])
l = Counter(L)
r = Counter(R)
 
#print(l)
#print(r)

cnt = 0
a=[]
for i in range(1,N+1):
    if i in l and i in r:
        cnt += l[i]*r[i]
        a.append(i)
print(cnt)

Buggy submission (verdict: Runtime Error):
from collections import Counter

N,*A = map(int,open(0).read().split())
#j - i = Aj + Ai
#j - Aj = Ai + i
#L = i + Ai, R = j - Aj とおく
L = []
R = []
for i in range(N):
    L.append(i+1 + A[i])
    R.append(i+1 - A[i])
l = Counter(L)
r = Counter(R)
 
cnt = 0
for i in range(1,N+1):
    if i in l and i in r:
        cnt += l[i] * r[i]
        a.append(i)
print(cnt)
Problem p02658 (python)

Fixed submission:
n=int(input())
arr=list(map(int,input().split()))
ans=int(1)
temp=int(0)
for i in range(n):
  if(ans>(10**18)):
    ans=-1
  if(ans!=-1):
  	ans*=arr[i]
  if(arr[i]==0):
    temp=int(1)
if(ans>(10**18)):
  ans=-1
if(temp==1):
  ans=0
print(int(ans))

Buggy submission (verdict: Runtime Error):
def m(list1,n): 
    mul=1
    for i in range(n): 
         mul=mul*list1[i] 
    return mul 
      
n=int(input())
arr=list(map(int,input().split()))
if m(arr)>pow(10,18):
    print(-1)
else:
    print(m(arr))
Problem p02579 (python)

Fixed submission:
from collections import deque
import sys
input=sys.stdin.readline
inf=float("inf")


def BFS():
    D=[[inf for _ in range(w)] for _ in range(h)]
    queue=deque()
    queue.append([Cx-1,Cy-1,0])
    D[Cx-1][Cy-1]=0

    while len(queue)>0:
        x,y,cnt=queue.popleft()
        for i,j in [[1,0],[0,1],[-1,0],[0,-1]]:
            X,Y=x+i,y+j
            if 0<=X<h and 0<=Y<w:
                if S[X][Y]=="." and D[X][Y]>cnt:
                    D[X][Y]=cnt
                    queue.appendleft([X,Y,cnt])

        for X in range(max(0,x-2),min(h,x+3)):
            for Y in range(max(0,y-2),min(w,y+3)):
                if S[X][Y]=="." and D[X][Y]>cnt+1:
                    D[X][Y]=cnt+1
                    queue.append([X,Y,cnt+1])

    return D[Dx-1][Dy-1]


h,w=map(int,input().split())
Cx,Cy=map(int,input().split())
Dx,Dy=map(int,input().split())
S=[list(input()) for _ in range(h)]

D=BFS()
print(D if D!=inf else -1)

Buggy submission (verdict: Runtime Error):
from collections import deque
inf=float("inf")

import numpy as np
def BFS():
    color=[["white" for _ in range(w)] for _ in range(h)]
    D=[[inf for _ in range(w)] for _ in range(h)]
    queue=deque([])

    x,y=C
    x -=1
    y -=1
    queue.append([x,y])
    D[x][y]=0

    for i in range(h):
        for j in range(w):
            if S[i][j]=="#":
                color[i][j]="black"

    while len(queue)>0:
        x,y=queue.popleft()
        for X in range(max(0,x-3),min(h,x+3)):
            for Y in range(max(0,y-3),min(w,y+3)):
                if color[X][Y]!="black":
                    D[X][Y]=min(D[X][Y],D[x][y])
                    if color[X][Y]=="white":
                        queue.append([X,Y])
                    color[X][Y]="gray"
        color[x][y]="black"

    return D


def Check():
    point=0
    color=[["white" for _ in range(w)] for _ in range(h)]
    for i in range(h):
        for j in range(w):
            if D[i][j]==inf:
                color[i][j]="black"

    queue=deque([])
    for i in range(h):
        for j in range(w):
            if D[i][j]==0 and color[i][j]=="white":
                queue.append([i,j])
                while len(queue)>0:
                    x,y=queue.popleft()
                    for a,b in [[1,0],[0,1],[0,-1],[-1,0]]:
                        X,Y=x+a,y+b
                        if 0<=X<h and 0<=Y<w:
                            if color[X][Y]=="white":
                                color[X][Y]="gray"
                                queue.append([X,Y])
                    color[x][y]="black"
                point +=1

    return point


h,w=map(int,input().split())
C=list(map(int,input().split()))
G=list(map(int,input().split()))
S=[list(input()) for _ in range(h)]

D=BFS()
ans=True if D[G[0]-1][G[1]-1]!=inf else False
if ans==False:print(-1);exit()
print(Check()-1)
Problem p02609 (python)

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def popcnt(n):
    return bin(n).count("1")


def mod(n, cnt):
    if n == 0:
        return cnt
    n = n % popcnt(n)
    cnt += 1
    return mod(n, cnt)


n = int(readline())
x2 = list(readline().decode().rstrip())
x10 = int(''.join(x2), 2)

c = x2.count('1')
mod1 = x10 % (c + 1)
mod2 = x10 % (c - 1) if c - 1 != 0 else 0

for i in range(n):
    if x2[i] == '0':
        t = (mod1 + pow(2, n - i - 1, c + 1)) % (c + 1)
    else:
        if c - 1 != 0:
            t = (mod2 - pow(2, n - i - 1, c - 1)) % (c - 1)
        else:
            print(0)
            continue
    print(mod(t, 1))

Buggy submission (verdict: Runtime Error):
def popcount(x):
    '''xの立っているビット数をカウントする関数
    (xは64bit整数)'''

    # 2bitごとの組に分け、立っているビット数を2bitで表現する
    x = x - ((x >> 1) & 0x5555555555555555)

    # 4bit整数に 上位2bit + 下位2bit を計算した値を入れる
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)

    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f # 8bitごと
    x = x + (x >> 8) # 16bitごと
    x = x + (x >> 16) # 32bitごと
    x = x + (x >> 32) # 64bitごと = 全部の合計
    return x & 0x0000007f


n=int(input())
x=input()
num=int(x,2)
cnt=popcount(num)
mod1,mod2=num%(cnt+1),num%(cnt-1)

for i in range(n):
    if x[i]=="0":
        ans=(mod1+pow(2,n-i-1,cnt+1))%(cnt+1)
    elif x[i]=="1" and cnt<=1:
        print(0)
        continue
    else:
        ans=(mod2-pow(2,n-i-1,cnt-1))%(cnt-1)
    point=1
    while ans!=0:
        ans %=popcount(ans)
        point +=1
    print(point)

Buggy submission (verdict: Runtime Error):
from numba import jit

@jit
def popcount(x):
    '''xの立っているビット数をカウントする関数
    (xは64bit整数)'''

    # 2bitごとの組に分け、立っているビット数を2bitで表現する
    x = x - ((x >> 1) & 0x5555555555555555)

    # 4bit整数に 上位2bit + 下位2bit を計算した値を入れる
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)

    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f # 8bitごと
    x = x + (x >> 8) # 16bitごと
    x = x + (x >> 16) # 32bitごと
    x = x + (x >> 32) # 64bitごと = 全部の合計
    return x & 0x0000007f


n=int(input())
x=int(input(),2)
A=[]
for i in range(n):
    num=x^(2**i)
    cnt=0
    while num!=0:
        num %=popcount(num)
        cnt +=1
    A.append(cnt)

for i in A[::-1]:
    print(i)

Buggy submission (verdict: Runtime Error):
def popcount(x):
    '''xの立っているビット数をカウントする関数
    (xは64bit整数)'''

    # 2bitごとの組に分け、立っているビット数を2bitで表現する
    x = x - ((x >> 1) & 0x5555555555555555)

    # 4bit整数に 上位2bit + 下位2bit を計算した値を入れる
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)

    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f # 8bitごと
    x = x + (x >> 8) # 16bitごと
    x = x + (x >> 16) # 32bitごと
    x = x + (x >> 32) # 64bitごと = 全部の合計
    return x & 0x0000007f


n=int(input())
x=int(input(),2)

A=[]
for i in range(n):
    num=x^(2**i)
    cnt=0
    while num!=0:
        num %=popcount(num)
        cnt +=1
    A.append(cnt)

for i in A[::-1]:
    print(i)