Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N = input()
S = input()
# N = 10
# S = 'ZABCDBABCQ'

ans = 0

for i in range(N - 2):
    if S[i:i+3] == 'ABC':
       ans += 1
print(ans)


Fixed submission:
N = int(input())
S = input()
# N = 10
# S = 'ZABCDBABCQ'

ans = 0

for i in range(N - 2):
    if S[i:i+3] == 'ABC':
       ans += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
a, b, k = map(int, input().split())

for _ in range(k):
    if a >= 1:
        a -= 1
    elif b >= 1:
        b -= 1

print(a, b, sep=" ")


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

# TEだった
# for _ in range(k):
#     if a >= 1:
#         a -= 1
#     elif b >= 1:
#         b -= 1

ans_a = 0
ans_b = 0

if a >= k:
    ans_a = a - k
    ans_b = b
else:
    ans_a = 0
    if b >= (k - a):
        ans_b = b - (k - a)
    else:
        ans_b = 0

print(ans_a, ans_b, sep=" ")
Buggy python submission (verdict: Runtime Error):
# import math これだとエラーになる 3.4なので
from fractions import gcd
a, b = map(int, input().split())

print((a*b)//gcd(a, b))

Fixed submission:
x = int(input())

ans = 0

for _ in range(10**5):
    if x == 2:
        print(x)
        break
    for i in range(2, int(x**0.5) + 1):
        if (x % i) == 0:
            break
        elif i == int(x**0.5): # ループの最後
            ans = x
        else:
            pass

    if ans != 0:
        print(ans)
        break
    else:
        x += 1

Buggy python submission (verdict: Runtime Error):
# import math これだとエラーになる 3.4なので
from fractions import gcd
a, b = map(int, input().split())

print(int((a*b)//gcd(a, b)))

Fixed submission:
x = int(input())

ans = 0

for _ in range(10**5):
    if x == 2:
        print(x)
        break
    for i in range(2, int(x**0.5) + 1):
        if (x % i) == 0:
            break
        elif i == int(x**0.5): # ループの最後
            ans = x
        else:
            pass

    if ans != 0:
        print(ans)
        break
    else:
        x += 1

Buggy python submission (verdict: Runtime Error):
import math
a, b = map(int, input().split())

print(int((a*b)//math.gcd(a, b)))

Fixed submission:
x = int(input())

ans = 0

for _ in range(10**5):
    if x == 2:
        print(x)
        break
    for i in range(2, int(x**0.5) + 1):
        if (x % i) == 0:
            break
        elif i == int(x**0.5): # ループの最後
            ans = x
        else:
            pass

    if ans != 0:
        print(ans)
        break
    else:
        x += 1

Buggy python submission (verdict: Runtime Error):
import math
a, b = map(int, input().split())

print(int((a*b)//math.gcd(a, b)))

Fixed submission:
x = int(input())

ans = 0

for _ in range(10**5):
    if x == 2:
        print(x)
        break
    for i in range(2, int(x**0.5) + 1):
        if (x % i) == 0:
            break
        elif i == int(x**0.5): # ループの最後
            ans = x
        else:
            pass

    if ans != 0:
        print(ans)
        break
    else:
        x += 1
Buggy python submission (verdict: Runtime Error):
import math
a, b = map(int, input().split())

print((a*b)//math.gcd(a, b))

Fixed submission:
from fractions import gcd
a, b = map(int, input().split())

lcm = a * b / gcd(a, b)
print(int(lcm))

Buggy python submission (verdict: Runtime Error):
import math
a, b = map(int, input().split())

print((a*b)//math.gcd(a, b))

Fixed submission:
from fractions import gcd
a, b = map(int, input().split())

lcm = a * b / gcd(a, b)
print(int(lcm))
Buggy python submission (verdict: Runtime Error):
r = int(input())

print(r ** 2)

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

if (a >= 10) or (b >= 10):
    print(-1)
else:
    print(a * b)
Buggy python submission (verdict: Runtime Error):
import numpy as np

n = int(input())

U = np.arange(1, n, dtype = np.int64)

div = U[n % U == 0]

ans = min((n / div) + div) - 2

print(int(ans))

"""
from itertools import combinations
import numpy as np

n = int(input())

a = 2
cnt = 0
ans = []


def walk_counter(ll, n):
    left = np.prod(ll)
    right = n // left
    return left + right - 2


tmp_n = n

while tmp_n >= a:
    while tmp_n % a == 0:
        tmp_n = tmp_n // a
        # cnt += 1
        ans.append(a)
    # if cnt > 0:
    #     ans.append([a, cnt])
    #     cnt = 0
    a = a + 1

if tmp_n == a:
    ans.append(a)

fin = 0

for i in range(len(ans)):
    for v in combinations(ans, i):
        tmp = walk_counter(v, n)
        if i == 0:
            fin = tmp
        elif fin > tmp:
            fin = tmp

# 組み合わせでなく、√nまでの試し割法のほうが早い

print(fin)
"""


Fixed submission:
import numpy as np

n = int(input())

U = np.arange(1, n ** 0.5 + 1, dtype = np.int64) # +1を忘れない！

div = U[n % U == 0]
ans = min((n / div) + div) - 2

print(int(ans))

"""old


from itertools import combinations
import numpy as np

n = int(input())

a = 2
cnt = 0
ans = []


def walk_counter(ll, n):
    left = np.prod(ll)
    right = n // left
    return left + right - 2


tmp_n = n

while tmp_n >= a:
    while tmp_n % a == 0:
        tmp_n = tmp_n // a
        # cnt += 1
        ans.append(a)
    # if cnt > 0:
    #     ans.append([a, cnt])
    #     cnt = 0
    a = a + 1

if tmp_n == a:
    ans.append(a)

fin = 0

for i in range(len(ans)):
    for v in combinations(ans, i):
        tmp = walk_counter(v, n)
        if i == 0:
            fin = tmp
        elif fin > tmp:
            fin = tmp

# 組み合わせでなく、√nまでの試し割法のほうが早い

print(fin)
"""
Buggy python submission (verdict: Runtime Error):
import sys
from io import StringIO
import unittest

def resolve():
    n = int(input())

    print(sum(list(range(n + 1))) - n)

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """2"""
        output = """1"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """13"""
        output = """78"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """1"""
        output = """0"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

Fixed submission:
import sys
from io import StringIO
import unittest

def resolve():
    n = int(input())

    ans = n * (n - 1) // 2
    print(int(ans))

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """2"""
        output = """1"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """13"""
        output = """78"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """1"""
        output = """0"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()
Buggy python submission (verdict: Runtime Error):
n = int(input())
h = list(map(int, input().split()))

if max(h) - h[n - 1] > 1:
    print('No')
    exit(0)
if n == 1:
    print('Yes')
    exit(0)
else:
    cap = max[0:n-2]
    for i in range(n - 1, 0, -1):
        if max(h[i - 1] - 1, 1) > h[i]:
            print('No')
            exit(0)
        else:
            if cap >= h[i]:
                pass
            else:
                h[i - 1] = max(h[i - 1] - 1, 1)

print('Yes')

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

# if max(h) - h[n - 1] > 1:
#     print('No')
#     exit(0)
# if n == 1:
#     print('Yes')
#     exit(0)
# else:
#     cap = max(h[0:n-1])
#     for i in range(n - 1, 0, -1):
#         if max(h[i - 1] - 1, 1) > h[i]:
#             print('No')
#             exit(0)
#         else:
#             if cap > h[i]:
#                 pass
#             else:
#                 h[i - 1] = max(h[i - 1] - 1, 1)

for i in range(n - 1, 0, -1):
    if h[i - 1] - h[i] > 1:
        print('No')
        exit(0)
    elif h[i - 1] - h[i] == 1:
        h[i - 1] = max(h[i - 1] - 1, 1)
    else:
        pass


print('Yes')

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

if max(h) - h[n - 1] > 1:
    print('No')
    exit(0)
if n == 1:
    print('Yes')
    exit(0)
else:
    for i in range(n - 1 , 0):
        if max(h[i - 1] - 1, 1) > h[i]:
            print('No')
            exit(0)
        else:
            if max(h[0:i]) == h[i]:
                pass
            elif:
                h[i - 1] = max(h[i - 1] - 1, 1)

print('Yes')

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

# if max(h) - h[n - 1] > 1:
#     print('No')
#     exit(0)
# if n == 1:
#     print('Yes')
#     exit(0)
# else:
#     cap = max(h[0:n-1])
#     for i in range(n - 1, 0, -1):
#         if max(h[i - 1] - 1, 1) > h[i]:
#             print('No')
#             exit(0)
#         else:
#             if cap > h[i]:
#                 pass
#             else:
#                 h[i - 1] = max(h[i - 1] - 1, 1)

for i in range(n - 1, 0, -1):
    if h[i - 1] - h[i] > 1:
        print('No')
        exit(0)
    elif h[i - 1] - h[i] == 1:
        h[i - 1] = max(h[i - 1] - 1, 1)
    else:
        pass


print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()

# lr = [list(map(int, input().split())) for _ in range(q)]

# 愚直な計算時間
# ループn回
# リスト切り取りO(n)
# O(n^2)
# 計算リミットが2000msで、n<=10^5
# 0(n)でn=10^6くらいが限度
# O8n^2)だと、n=3000くらい

# 先に回数を数える。累積和的に
hoge = [s[0:(i + 1)].count('AC') for i in range(n)]

for _ in range(q):
    l, r = map(int, input().split())
    print(hoge[r - 1] - hoge[l - 1])


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

# lr = [list(map(int, input().split())) for _ in range(q)]

# 愚直な計算時間
# ループn回
# リスト切り取りO(n)
# O(n^2)
# 計算リミットが2000msで、n<=10^5
# 0(n)でn=10^6くらいが限度
# O8n^2)だと、n=3000くらい

# 先に回数を数える。累積和的に
# ここで結構時間かかる
# hoge = [s[0:(i + 1)].count('AC') for i in range(n)]

# 修正ver
hoge = [0]
cnt = 0
for i in range(1, n):
    if s[i - 1] + s[i] == 'AC':
        cnt += 1
    hoge.append(cnt)

for _ in range(q):
    l, r = map(int, input().split())
    print(hoge[r - 1] - hoge[l - 1])

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

# 先に回数を数える。累積和的に
hoge = [s[0:(i + 1)].count('AC') for i in range(n)]

for _ in range(q + 1):
    l, r = map(int, input().split())
    print(hoge[r - 1] - hoge[l - 1])


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

# lr = [list(map(int, input().split())) for _ in range(q)]

# 愚直な計算時間
# ループn回
# リスト切り取りO(n)
# O(n^2)
# 計算リミットが2000msで、n<=10^5
# 0(n)でn=10^6くらいが限度
# O8n^2)だと、n=3000くらい

# 先に回数を数える。累積和的に
# ここで結構時間かかる
# hoge = [s[0:(i + 1)].count('AC') for i in range(n)]

# 修正ver
hoge = [0]
cnt = 0
for i in range(1, n):
    if s[i - 1] + s[i] == 'AC':
        cnt += 1
    hoge.append(cnt)

for _ in range(q):
    l, r = map(int, input().split())
    print(hoge[r - 1] - hoge[l - 1])
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

from collections import Counter
from itertools import combinations

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

cnter = Counter(S)
alpha = set(cnter)

ans = 0

for i in range(1, len(alpha) + 1):
    if i == 1:
       ans += len(S)
    else:
        for pat in combinations(alpha, i):
            ans += np.prod([value for key, value in cnter.items() if key in pat])

print(ans % (10 ** 9 + 7))

Fixed submission:
from collections import Counter

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

cnter = Counter(S)
alpha = set(cnter)

ans = 1

for i in alpha:
    ans *= (cnter[i] + 1)

print((ans - 1) % (10 ** 9 + 7))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
from itertools import combinations

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

cnter = Counter(S)
alpha = set(cnter)

ans = 0

for i in range(1, len(alpha) + 1):
    if i == 1:
       ans += len(S)
    else:
        for pat in combinations(alpha, i):
            tmp = 1
            for v in pat:
                tmp *= cnter[v]
            ans += tmp

print(ans % (10 ** 9 + 7))

Fixed submission:
from collections import Counter

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

cnter = Counter(S)
alpha = set(cnter)

ans = 1

for i in alpha:
    ans *= (cnter[i] + 1)

print((ans - 1) % (10 ** 9 + 7))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
from itertools import combinations

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

cnter = Counter(S)
alpha = set(cnter)

ans = 0

for i in range(1, len(alpha) + 1):
    if i == 1:
       ans += len(S)
    else:
        for pat in combinations(alpha, i):
            tmp = 1
            for v in pat:
                tmp *= cnter[v]
            ans += tmp

print(ans % (10 ** 9 + 7))

Fixed submission:
from collections import Counter

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

cnter = Counter(S)
alpha = set(cnter)

ans = 1

for i in alpha:
    ans *= (cnter[i] + 1)

print((ans - 1) % (10 ** 9 + 7))
Buggy python submission (verdict: Runtime Error):
import sys
from io import StringIO
import unittest
# from fractions import gcd
from math import gcd
from functools import reduce

def gcd_list(numbers):
    return reduce(gcd, numbers)

def resolve():
    n = int(input())
    a = list(map(int, input().split()))

    gcd_num = gcd_list(a)

    print(gcd_num)

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """4
2 10 8 40"""
        output = """2"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """4
5 13 8 1000000000"""
        output = """1"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """3
1000000000 1000000000 1000000000"""
        output = """1000000000"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

Fixed submission:
import sys
from io import StringIO
import unittest
from fractions import gcd
# from math import gcd
from functools import reduce

def gcd_list(numbers):
    return reduce(gcd, numbers)

def resolve():
    n = int(input())
    a = list(map(int, input().split()))

    gcd_num = gcd_list(a)

    print(gcd_num)

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """4
2 10 8 40"""
        output = """2"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """4
5 13 8 1000000000"""
        output = """1"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """3
1000000000 1000000000 1000000000"""
        output = """1000000000"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from io import StringIO
import unittest

sys.setrecursionlimit(10 ** 7)


def memoize(f):
    cache={}
    def helper(*args):
        if args not in cache:
            cache[args] = f(*args)
        return cache[args]
    return helper


def resolve():
    n = int(input())
    h = list(map(int, input().split()))
    inf = n * 10 ** 7

    """
    ボトムアップ型: for loopを使う
    ans = [inf for _ in range(n)]
    ans[0] = 0
    ans[1] = abs(h[1] - h[0])

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

    print(ans[-1])
    """

    # トップダウン(メモ再帰型)
    memo = [inf for _ in range(n)]

    # @memoize
    def dp(n: int) -> int:
        if n == 0:
            return 0
        elif n == 1:
            return abs(h[1] - h[0])
        else:
            return min(dp(n - 1) + abs(h[n] - h[n - 1]), dp(n - 2) + abs(h[n] - h[n - 2]))

    print(dp(n - 1))

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """4
10 30 40 20"""
        output = """30"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """2
10 10"""
        output = """0"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """6
30 10 60 10 60 50"""
        output = """40"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

Fixed submission:
import sys
from io import StringIO
import unittest

def resolve():
    n = int(input())
    h = list(map(int, input().split()))

    inf = n * 10 ** 7
    ans = [inf for _ in range(n)]
    ans[0] = 0
    ans[1] = abs(h[1] - h[0])

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

    print(ans[-1])


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """4
10 30 40 20"""
        output = """30"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """2
10 10"""
        output = """0"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """6
30 10 60 10 60 50"""
        output = """40"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()
Buggy python submission (verdict: Runtime Error):
def factorial(n):
    if n == 1:
        return 1
    else:
        return n + factorial(n - 1)


a, b = map(int, input().split())

diff = b - a

print(factorial(diff) - b)

Fixed submission:
def factorial(n):
    if n == 1:
        return 1
    else:
        return n + factorial(n - 1)


a, b = map(int, input().split())

diff = b - a

print(factorial(diff - 1) - a)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect

k, s = map(int, input().split())

ans = 0

if k * 3 == s:
    print(1)
    exit(0)
else:
    for v in range(k + 1):
        for x in range(k + 1):
            if v + x > s:
                continue
            else:
                targ = s - v - x
                hoge = bisect.bisect_left([i for i in range(k + 1)], targ)
                if hoge < 0 or hoge > k:
                    pass
                else:
                    ans += 1
                    
print(ans)




Fixed submission:
# import bisect

k, s = map(int, input().split())

ans = 0

if k * 3 == s:
    print(1)
    exit(0)
else:
    for v in range(k + 1):
        # bisect.bisect_left([i for i in range(2 * k + 1)], s - v)
        for x in range(k + 1):
            if v + x > s:
                continue
            else:
                targ = s - v - x
                # hoge = bisect.bisect_left([i for i in range(k + 1)], targ)
                if targ < 0 or targ > k:
                    pass
                else:
                    ans += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations_with_replacement
import bisect

k, s = map(int, input().split())

ans = 0
# for v in combinations_with_replacement(range(k + 1), 3):
#     if sum(v) == s:
#         leng = len(set(v))
#         if leng == 1 or leng == 3:
#             ans += 1
#         else:
#             ans += 3

if k * 3 == s:
    print(1)
    exit(0)
else:
    for v in range(k + 1):
        for x in range(k + 1):
            if v + x > s:
                continue
            else:
                targ = s - v - x
                hoge = bisect.bisect_left([i for i in range(k + 1)], targ)
                if hoge < 0 or hoge > k:
                    pass
                else:
                    ans += 1

            # leng = len(set([v, x, hoge]))
            # if leng == 1 or leng == 3:
            #     ans += 1
            # else:
            #     ans += 3

print(ans)




Fixed submission:
# import bisect

k, s = map(int, input().split())

ans = 0

if k * 3 == s:
    print(1)
    exit(0)
else:
    for v in range(k + 1):
        # bisect.bisect_left([i for i in range(2 * k + 1)], s - v)
        for x in range(k + 1):
            if v + x > s:
                continue
            else:
                targ = s - v - x
                # hoge = bisect.bisect_left([i for i in range(k + 1)], targ)
                if targ < 0 or targ > k:
                    pass
                else:
                    ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
N, K = int(input().split())
H = []
H = int(input().split())
list.sort(H, reverse = True)
ANS = 0
for i in range(K, N):
    ANS += H[i]
print(ANS)

Fixed submission:
N, K = map(int, input().split())
H =  list(map(int, input().split()))
list.sort(H, reverse = True)
ANS = 0
for i in range(K, N):
    ANS += H[i]
print(ANS)
Buggy python submission (verdict: Runtime Error):
N = int(input())
X = input()
times = {}
times[0] = 0

for i in range(1,200000):
  bi = format(i, 'b')
  arr = list(map(int, bi))
  sbi = sum(arr)
  if i%sbi == 0:
    times[i] = 1
  else:
    times[i] = 1+times[i%sbi]
    
arr = list(map(int, X))
sbX = sum(arr)
X10 = int(X,2)
mo = [1,-1]
mo2 = [X10%(sbX+1),X10%(sbX-1)]

for i in range(N):
  waru = sbX+mo[int(X[i])]
  if waru == 0:
    print(0)
  else:
    print(times[(pow(2,(N-i-1),waru)+mo2[int(X[i])])%waru]+1)
  

Fixed submission:
N = int(input())
X = input()
times = {}
times[0] = 0

for i in range(1,200000):
  bi = format(i, 'b')
  arr = list(map(int, bi))
  sbi = sum(arr)
  if i%sbi == 0:
    times[i] = 1
  else:
    times[i] = 1+times[i%sbi]
    
arr = list(map(int, X))
sbX = sum(arr)
X10 = int(X,2)
mo = [1,-1]
if sbX-1 == 0:
  mo2 = [X10%(sbX+1),X10]
else:
  mo2 = [X10%(sbX+1),X10%(sbX-1)]

for i in range(N):
  waru = sbX+mo[int(X[i])]
  if waru == 0:
    print(0)
  else:
    print(times[(mo[int(X[i])]*pow(2,(N-i-1),waru)+mo2[int(X[i])])%waru]+1)

Buggy python submission (verdict: Runtime Error):
N = int(input())
X = input()
times = [0]*200000

for i in range(1,200000):
  bi = format(i, 'b')
  arr = list(map(int, bi))
  sbi = sum(arr)
  if i%sbi == 0:
    times[i] = 1
  else:
    times[i] = 1+times[i%sbi]
    
arr = list(map(int, X))
sbX = sum(arr)
mo = [1,-1]
for i in range(N):
  X10 = int(X,2)^(2**(N-i-1))
  waru = sbX+mo[int(X[i])]
  print(times[X10%waru]+1)
  

Fixed submission:
N = int(input())
X = input()
times = {}
times[0] = 0

for i in range(1,200000):
  bi = format(i, 'b')
  arr = list(map(int, bi))
  sbi = sum(arr)
  if i%sbi == 0:
    times[i] = 1
  else:
    times[i] = 1+times[i%sbi]
    
arr = list(map(int, X))
sbX = sum(arr)
X10 = int(X,2)
mo = [1,-1]
if sbX-1 == 0:
  mo2 = [X10%(sbX+1),X10]
else:
  mo2 = [X10%(sbX+1),X10%(sbX-1)]

for i in range(N):
  waru = sbX+mo[int(X[i])]
  if waru == 0:
    print(0)
  else:
    print(times[(mo[int(X[i])]*pow(2,(N-i-1),waru)+mo2[int(X[i])])%waru]+1)