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

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

s = input()

count = [0] * n

for i in range(1, n):
    if s[i-1] == 'A' and s[i] == 'C':
        count[i] += 1

from itertools import accumulate

accum = list(accumulate(count))

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

Buggy submission (verdict: Runtime Error):
_, q = input().split()
s = list(input())
qs = [list(map(int, input().split())) for _ in range(int(q))]

def get_num_AC(ccond, s, count):
    if s == []:
        return count
    if ccond:
        if s.pop() == 'A':
            return get_num_AC(False, s, count+1)
        else:
            if s == []:
                return count
            else:
                return get_num_AC(s.pop() == 'C', s, count)
    return get_num_AC(s.pop() == 'C', s, count)

def get_substr(s, smaller, larger):
    s1 = s[smaller-1:larger]
    return s1

for smaller, larger in qs:
    substr = get_substr(s, smaller, larger)
    count = get_num_AC(False, substr, 0)
    print(count)

Buggy submission (verdict: Runtime Error):
import re
_, q = input().split()
s = list(input())
qs = [list(map(int, input().split())) for _ in range(int(q))]

def get_num_AC(ccond, s, count):
    if s == []:
        return count
    if ccond:
        if s.pop() == 'A':
            return get_num_AC(False, s, count+1)
        else:
            if s == []:
                return count
            else:
                return get_num_AC(s.pop() == 'C', s, count)
    return get_num_AC(s.pop() == 'C', s, count)

def get_substr(s, smaller, larger):
    s1 = s[smaller-1:larger]
    return s1

for smaller, larger in qs:
    substr = get_substr(s, smaller, larger)
    count = get_num_AC(substr)
    print(count)

Buggy submission (verdict: Runtime Error):
import re
_, q = input().split()
s = list(input())
qs = [list(map(int, input().split())) for _ in range(int(q))]

s = ['a', 'b']

def get_num_AC(ccond, s, count):
    if s == []:
        return count
    if ccond:
        if s.pop() == 'A':
            return get_num_AC(False, s, count+1)
        else:
            if s == []:
                return count
            else:
                return get_num_AC(s.pop() == 'C', s, count)
    return get_num_AC(s.pop() == 'C', s, count)

def get_substr(s, smaller, larger):
    s1 = s[smaller-1:larger]
    return s1

for smaller, larger in qs:
    substr = get_substr(s, smaller, larger)
    count = get_num_AC(substr)
    print(count)

Buggy submission (verdict: Runtime Error):
import re
import numpy as np
_, q = input()
s = input()
qs = [input().split() for _ in range(q)]

def get_num_AC(s):
    count = len(re.split(r'AC', s)) - 1
    return count

def get_substr(s, smaller, larger)
    s1 = s[smaller-1:larger]
    return s1

for smaller, larger in qs:
    substr = get_substr(s, smaller, larger)
    count = get_num_AC(substr)
    print(count)
Problem p03160 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 9)

n = int(input())

hs = list(map(int, input().split()))

cost = {n-1:0, n-2:abs(hs[n-1]-hs[n-2])}

def calc(k):
    if k not in cost:
        cost[k] = min(abs(hs[k+1] - hs[k]) + calc(k+1), abs(hs[k+2] - hs[k]) + calc(k+2))
    return cost[k]

print(calc(0))

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

hs = list(map(int, input().split()))

cost = {n-1:0}

def calc(k):
    if k not in cost:
        if k == n-2:
            cost[k] = abs(hs[k+1]-hs[k])
        else:
            cost[k] = min(abs(hs[k+1] - hs[k]) + calc(k+1), abs(hs[k+2] - hs[k]) + calc(k+2))
    return cost[k]

print(calc(0))
Problem p03163 (python)

Fixed submission:
N, W = map(int, input().split())

from collections import defaultdict

dp = defaultdict(int)

dp[0] = 0

for _ in range(N):
    w, v = map(int, input().split())
    for k, val in list(dp.items()):
        if k+w <= W:
            dp[k+w] = max(dp[k+w], val+v)



print(max(dp.values()))

Buggy submission (verdict: Runtime Error):
N, W = map(int, input().split()

items = [list(map(int, input().split())) for _ in range(N)]

d = {(W, 0)}

for w, v in items:
    tmp = set()
    for rw, rv in d:
        if rw >= w:
            tmp.add((rw-w, rv+v))
    d |= tmp

d = {elm[1] for elm in d}

print(max(d))
Problem p03363 (python)

Fixed submission:
n,*aa = map(int, open(0).read().split())

from itertools import accumulate
from collections import Counter
from math import comb

c = Counter(accumulate(aa))
c[0] += 1

ans = 0
for i,v in c.items():
    if v > 1:
        ans += comb(v,2)

print(ans)

Buggy submission (verdict: Runtime Error):
n,*aa = map(int, open(0).read().split())

from itertools import accumulate
from collections import Counter
from math import comb

c = Counter(accumulate(aa))
c[0] += 1

ans = 0
for i,v in c.items():
    if v > 1:
        ans += comb(v,2)

print(ans)
Problem p03449 (python)

Fixed submission:
import numpy as np
(n,), *aaa = [list(map(int, s.split())) for s in open(0)]

aaa = np.array(aaa, dtype='int')

cost = np.stack([np.cumsum(aaa[0]), np.zeros(n, dtype='int')])
cost[1][0] = aaa[0][0] + aaa[1][0]

for i in range(1, n):
    cost[1][i] = max(cost[1][i-1], cost[0][i]) + aaa[1][i]

print(cost[-1][-1])

Buggy submission (verdict: Runtime Error):
import numpy as np
(n,), *aaa = [list(map(int, s.split())) for s in open(0)]

aaa = np.array(aaa, dtype='int')

cost = np.stack([np.cumsum(aaa[0]), np.zeros(n, dtype='int')])
cost[1][0] = aaa[0][0] + aaa[1][0]

for i in range(1, n):
    cost[1][i] = max(cost[1][i-1], cost[0][i]) + aaa[1][i]

print(cost[-1][-1])
Problem p03469 (python)

Fixed submission:
s = input()
print(s[:3]+'8'+s[4:])

Buggy submission (verdict: Runtime Error):
s = input()
s[3] = '8'
print(s)

Buggy submission (verdict: Runtime Error):
s = input()
s[3] = 8
print(s)
Problem p03694 (python)

Fixed submission:
_,*aa = map(int, open(0).read().split())

print(max(aa) - min(aa))

Buggy submission (verdict: Runtime Error):
_,*aa = map(int, open(1).read().split())

print(max(aa) - min(aa))
Problem p03712 (python)

Fixed submission:
hw,*aaa = open(0).read().splitlines()

h,w = map(int, hw.split())

print('#'*(w+2))
for aa in aaa:
    print(f'#{aa}#')
print('#'*(w+2))

Buggy submission (verdict: Runtime Error):
hw,*aaa = open(1).read().splitlines()

h,w = map(int, hw.split())

print('#'*(w+2))
for aa in aaa:
    print(f'#{aa}#')
print('#'*(w+2))
Problem p03971 (python)

Fixed submission:
x = input()
s = input()

n, a, b = map(int, x.split())

p = 0
wp = 0

for char in s:
    if char == 'c' or p >= a+b:
        print('No')
        continue
    if char == 'a':
        p += 1
        print('Yes')
        continue
    if wp < b:
        p += 1
        wp += 1
        print('Yes')
    else:
        print('No')

Buggy submission (verdict: Runtime Error):
x, s = *open(0),
print(x)
print(s)
n, a, b = map(int, x.rstrip.split())

p = 0
wp = 0

for char in s:
    if char == 'c' or p >= a+b:
        print('No')
        continue
    if char == 'a':
        p += 1
        print('Yes')
        continue
    if wp < b:
        p += 1
        wp += 1
        print('Yes')
    else:
        print('No')
Problem p03994 (python)

Fixed submission:
from string import ascii_lowercase
s = input()
k = int(input())

def main(s, k):
    alp = ascii_lowercase
    num = {char: i for i, char in enumerate(alp)}

    ns = [num[char] for char in s]

    for i in range(len(ns)):
        v = ns[i]
        if v != 0 and 26 - v <= k:
            ns[i] = 0
            k -= 26 - v

    ns[-1] = (ns[-1] + k) % 26

    return ''.join(alp[n] for n in ns)
print(main(s, k))

Buggy submission (verdict: Runtime Error):
from string import ascii_lowercase
alp = ascii_lowercase
num = {char: i for i, char in enumerate(alp)}

s = input()
k = int(input())
ns = [num[char] for char in s]

for i in range(len(ns)):
    v = ns[i]
    if 26 - v <= k:
        ns[i] = 0
        k -= 26 - v

ns[-1] += k

print(''.join(alp[n] for n in ns))
Problem p04046 (python)

Fixed submission:
H, W, A, B = map(int, open(0).read().split())
MOD = 10**9+7

def modcomb(m, n, mod):
    if n > m - n:
        n = m - n
    p = 1
    q = 1
    for i in range(n):
        p = p * (m - i) % mod
        q = q * (i + 1) % mod
    result = p * pow(q, mod - 2, mod) % mod
    return result

total = modcomb(H + W - 2, W - 1, MOD)

tmp = modcomb(A + W - 2, W - 1, MOD)
total -= tmp

for i in range(B - 1):
    a = H - A + i
    b = i + 1
    c = W - i - 1
    d = W + A - 2 - i
#     print(a,b,c,d)
    tmp = tmp * a * c % MOD
    tmp = tmp * pow(b, -1, MOD) % MOD
    tmp = tmp * pow(d, -1, MOD) % MOD
#     print(tmp)
    total = (total - tmp) % MOD

print(total)

Buggy submission (verdict: Runtime Error):
H, W, A, B = map(int, open(0).read().split())
MOD = 10**9+7

def modperm(m, n, mod):
    p = 1
    for i in range(n):
        p = p * (m - i) % mod
    return p

def modcomb(m, n, mod):
    if n > m - n:
        n = m - n
    p = modperm(m, n, mod)
    q = pow(modperm(n, n, mod), -1, mod)
    return p * q % mod

total = modcomb(H + W - 2, W - 1, MOD)

tmp = modcomb(A + W - 2, W - 1, MOD)
total -= tmp

for i in range(B - 1):
    a = H - A + i
    b = i + 1
    c = W - i - 1
    d = W + A - 2 - i
#     print(a,b,c,d)
    tmp = tmp * a * c % MOD
    tmp = tmp * pow(b, MOD - 2, MOD) % MOD
    tmp = tmp * pow(d, MOD - 2, MOD) % MOD
#     print(tmp)
    total = (total - tmp) % MOD

print(total)
Problem p02573 (python)

Fixed submission:
class Union:
    def __init__(self, n):
        self.parents = [-1] * n
    
    def root(self, x):
        if self.parents[x] < 0:
            return x
        else:
            return self.root(self.parents[x])
    
    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]

uni = Union(n)
for a, b in ab:
    a -= 1
    b -= 1
    uni.unite(a, b)
print(-min(uni.parents))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
ab = sorted(set([tuple(map(int, input().split())) for _ in range(m)]))

c = []
flag = False
for i in ab:
    a, b = i[0], i[1]
    for i in c:
        if a in i or b in i:
            i.add(a)
            i.add(b)
            if len(i) == n:
                flag = True
            break
        else:
            c.append(set())
            c[-1].add(a)
            c[-1].add(b)
    if flag:
        break
if m == 0:
    print(1)
else:
    print(max(map(len, c)))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
c = []
for _ in range(m):
    a, b = map(int, input().split())
    for i in c:
        if a in i or b in i:
            i.add(a)
            i.add(b)
    else:
        c.append(set())
        c[-1].add(a)
        c[-1].add(b)
print(max(map(len, c)))
Problem p02642 (python)

Fixed submission:
from collections import Counter

N = int(input())
A = list(map(int, input().split()))

B = Counter(A)
Key = list(B.keys())
Key.sort()

M = 10 ** 6
table = [1] * (M + 1)
cnt = 0
for k in Key:
    if B[k] == 1 and table[k] == 1:
        cnt += 1
    
    for i in range(M):
        if k * i > M:
            break
        else:
            table[k * i] = 0
print(cnt)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = sorted(set(list(map(int, input().split()))))

la = len(a)
if la == 1:
    print(0)
    exit()
l = [True] * la
for i in range(1, n):
    for j in range(i):
        if a[i] % a[j] == 0:
            l[i] = False
            break
print(l.count(True))
Problem p02714 (python)

Fixed submission:
n = int(input())
s = input()

ans = s.count('R') * s.count('G') * s.count('B')

for i in range(n-2):
    for j in range(i+1, n-1):
        k = 2*j-i
        if k < n:
            if s[k] != s[i] and s[k] != s[j] and s[i] != s[j]:
                ans -= 1
        else:
            break
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
s = input()

c = Counter(list(s))
ans = 1
for i in list(c.values):
    ans *= i
for i in range(n-2):
    for j in range(i+1, n-1):
        k = j + (j-i)
        if k >= n:
            break
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            ans -= 1
print(ans)
Problem p02768 (python)

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

mod = 10**9 + 7

def nck(k):
    y, z = 1, 1
    for i in range(1, k+1):
        y = (y * (n+1-i)) % mod
        z = (z * pow(i, mod-2, mod)) % mod
    return (y*z) % mod

ans = (pow(2, n, mod) - 1 - nck(a) - nck(b)) % mod
print(ans)

Buggy submission (verdict: Runtime Error):
import functools
import operator

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

def nCr(n, r):
    r = min(r, n-r)
    num = functools.reduce(lambda x, y: x*y%mod, range(n, n-r, -1))
    den = functools.reduce(lambda x, y: x*y%mod, map(lambda x: pow(x, mod-2, mod), range(1, r+1)))
    return num * den % mod

mod = 10**9 + 7
print((pow(2, n, mod) - nCr(n, a) - nCr(n, b) - 1) % mod)
Problem p03801 (python)

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

b = sorted([(i+1, a[i]) for i in range(n)], key=lambda x: -x[1])
ans = [0]*(n+1)
m = float('inf')
for i in range(n-1):
    m = min(m, b[i][0])
    if b[i][1] == b[i+1][1]:
        continue
    ans[m] += (i+1)*(b[i][1]-b[i+1][1])
ans[1] += sum(a) - sum(ans)
for i in range(1, n+1):
    print(ans[i])

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

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

ans = [0]*n
d = Counter(a)
k = list(d.keys())[::-1]
for i in range(len(k)-1):
    ind = a.index(k[i])
    ans[ind] += d[k[i]]*(k[i]-k[i+1])
    d[k[i+1]] += d[k[i]]
ans[k[-1]-1] += n
for i in ans:
    print(i)
Problem p02791 (python)

Fixed submission:
n=int(input())
p=[int(i) for i in input().split()]
flag=p[0]
ans=1
for i in range(1,n):
    if (p[i]<flag):
        flag=p[i]
        ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
ans=n
for i in range(1,n):
    for j in range(i):
        if (p[i]>p[j]):
            ans-=1
            break
print(ans)
Problem p03130 (python)

Fixed submission:
ll=list()
for i in range(3):
    a=input()
    b=a.split()
    ll.append(int(b[0]))
    ll.append(int(b[1]))
c1=ll.count(1)
c2=ll.count(2)
c3=ll.count(3)
c4=ll.count(4)
if c1>2 or c2>2 or c3>2 or c4>2:
    print("NO")
else:
    print("YES")

Buggy submission (verdict: Runtime Error):
ll=list()
for i in range(3):
    a=input()
    b=a.split()
    ll.append(int(b[0]),int(b[1]))
c1=ll.count(1)
c2=ll.count(2)
c3=ll.count(3)
c4=ll.count(4)
if c1>2 or c2>2 or c3>2 or c4>2:
    print("No")
else:
    print("Yes")
Problem p04047 (python)

Fixed submission:
n=input()
a=input().split()
a=[int(i) for i in a]
a.sort()
count=0
ans=0
for i in a:
  if count%2==0:
    ans+=i
  count+=1
print(ans)

Buggy submission (verdict: Runtime Error):
n=input()
a=input().split()
a=[int(i) for i in a]
a=a.sorted()
count=0
ans=0
for i in a:
  if count%2==0:
    ans+=i
  count+=1
Problem p02588 (python)

Fixed submission:
import collections
from decimal import Decimal

n = int(input())
a = [Decimal(input()) for _ in range(n)]
a = [int(i*10**9) for i in a]
MAX = 19
p_dict = collections.defaultdict(int)

for i in a:
    b_cnt = 0
    while i % 2 == 0 and b_cnt < 18:
        i //= 2
        b_cnt += 1
    f_cnt = 0
    while i % 5 == 0 and f_cnt < 18:
        i //= 5
        f_cnt += 1
    p_dict[(b_cnt, f_cnt)] += 1

ans = 0
for b1, f1 in p_dict:
    for b2, f2 in p_dict:
        if b1+b2 >= 18 and f1+f2 >= 18:
            if b1 == b2 and f1 == f2:
                ans += p_dict[(b1, f1)] * (p_dict[(b2, f2)] - 1)
            else:
                ans += p_dict[(b1, f1)] * p_dict[(b2, f2)]
print(ans//2)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [float(input()) for _ in range(n)]
a = [i*10**9 for i in a]
MAX = 25
p_mat = [[0 for _ in range(MAX)] for _ in range(MAX)]

for i in a:
    b_cnt = 0
    while i % 2 == 0:
        i /= 2
        b_cnt += 1
    f_cnt = 0
    while i % 5 == 0:
        i /= 5
        f_cnt += 1
    p_mat[b_cnt][f_cnt] += 1

ans = 0
for b1 in range(MAX):
    for f1 in range(MAX):
        for b2 in range(MAX):
            for f2 in range(MAX):
                if b1+b2 >= 18 and f1+f2 >= 18:
                    if b1 == b2 and f1 == f2 and p_mat[b1][f1] > 0:
                        ans += p_mat[b1][f1] * (p_mat[b2][f2] - 1)
                    else:
                        ans += p_mat[b1][f1] * p_mat[b2][f2]
print(ans//2)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [float(input()) for _ in range(n)]
a = [i*10**9 for i in a]
MAX = 23
p_mat = [[0 for _ in range(MAX)] for _ in range(MAX)]

for i in a:
    b_cnt = 0
    while i % 2 == 0:
        i /= 2
        b_cnt += 1
    f_cnt = 0
    while i % 5 == 0:
        i /= 5
        f_cnt += 1
    p_mat[b_cnt][f_cnt] += 1

ans = 0
for b1 in range(MAX):
    for f1 in range(MAX):
        for b2 in range(MAX):
            for f2 in range(MAX):
                if b1+b2 >= 18 and f1+f2 >= 18:
                    if b1 == b2 and f1 == f2:
                        ans += p_mat[b1][f1] * (p_mat[b2][f2] - 1)
                    else:
                        ans += p_mat[b1][f1] * p_mat[b2][f2]
print(ans//2)
Problem p02608 (python)

Fixed submission:
N = int(input())

ans = [0 for i in range(10**4+1)]
for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            n = x*x + y*y + z*z + x*y + y*z + z*x
            if n <= 10**4:
                ans[n] += 1

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

Buggy submission (verdict: Runtime Error):
MAX = 2*10**5
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
s_map = [0 for i in range(MAX+1)]
def solve(n):
    if n == 0:
        return 1
    if s_map[n] > 0:
        return s_map[n]
    s_map[n] = 1 + solve(n % popcount(n))
    return s_map[n]

N = int(input())
X = input()
num_x = int(X, 2)
p_cnt = X.count('1')
for i in range(N):
    c_p_cnt = p_cnt+1 if X[i] == '0' else p_cnt-1
    x = num_x + 2**(N-1-i) if X[i] == '0' else num_x - 2**(N-1-i)
    if x == 0:
        print(0)
    else:
        print(solve(x % c_p_cnt))
Problem p02642 (python)

Fixed submission:
from math import ceil

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

m = 10 ** 6
n_map = {}
v_a = []
for i in a:
    if i not in n_map:
        n_map[i] = 1
    else:
        n_map[i] += 1
v_a = [(k,v) for k, v in n_map.items()]

v_a.sort(key=lambda x: x[0])
res = 0
nn_map = {}
for i, v in v_a:
    if i in nn_map:
        continue
    for j in range(1, ceil(m / i) + 1):
        nn_map[i * j] = True
    if v == 1:
        res += 1
print(res)

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

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

n_map = {}
c = Counter(a)
a = [k for k, v in c.items() if v == 1]
a.sort()
q = deque(a)

res = 0
def solve(v,c_m):
    global res
    n_q = deque()
    while len(c_m) > 0:
        c = c_m.popleft()
        if c % v != 0:
           n_q.append(c)
    if len(n_q) == 0:
        return
    n_v = n_q.popleft()
    res += 1
    solve(n_v, n_q)


if len(q) > 0:
    v = q.popleft()
    res += 1
    solve(v, q)
print(res)

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

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

n_map = {}
c = Counter(a)
a = [k for k, v in c.items() if v == 1]
a.sort()
q = deque(a)

res = 0
def solve(v,c_m):
    global res
    n_q = deque()
    while len(c_m) > 0:
        c = c_m.popleft()
        if c % v != 0:
           n_q.append(c)
    if len(n_q) == 0:
        return
    n_v = n_q.popleft()
    res += 1
    solve(n_v, n_q)


if len(q) > 0:
    v = q.popleft()
    res += 1
    solve(v, q)
print(res)
Problem p02647 (python)

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
current = a[:]
for _ in range(min(42, k)):
    nex = [0]*n
    for i, v in enumerate(current):
        l = max(0, i-v)
        r = min(n-1, i+v)
        nex[l] += 1
        if r+1 < n:
            nex[r+1] -= 1
    for i in range(1, n):
        nex[i] += nex[i-1]
    current = nex

print(*current)

Buggy submission (verdict: Runtime Error):
import numpy as np
n, k = map(int, input().split())
a = list(map(int, input().split()))
current = a[:]
for _ in range(k):
    next = [1]*n
    stack = 0
    for j, v in enumerate(current):
        next[j] += stack % 10
        stack //= 10
        if v > 0:
            stack += int('1'*v)
    stack = 0
    for j in range(n-1, -1, -1):
        next[j] += stack % 10
        stack //= 10
        if current[j] > 0:
            stack += int('1' * current[j])
    current = next
print(*current)

Buggy submission (verdict: Runtime Error):
import numpy as np
n, k = map(int, input().split())
a = list(map(int, input().split()))
current = a[:]
for _ in range(k):
    next = [1]*n
    stack = 0
    for j, v in enumerate(current):
        next[j] += int(str(stack)[-1])
        stack = str(stack)
        stack = stack[:len(stack)-1]
        if len(stack):
            stack = int(stack)
        else:
            stack = 0
        if v > 0:
            stack += int('1'*v)
    stack = 0
    for j in range(n-1, -1, -1):
        next[j] += int(str(stack)[-1])
        stack = str(stack)
        stack = stack[:len(stack) - 1]
        if len(stack):
            stack = int(stack)
        else:
            stack = 0
        if current[j] > 0:
            stack += int('1' * current[j])
    current = next
print(*current)
Problem p02658 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
m = 10**18
if 0 in a:
    print(0)
    exit()
res = 1
for i in a:
    res *= i
    if res > m:
        print(-1)
        exit()

print(res)

Buggy submission (verdict: Runtime Error):
from functools import reduce
n = int(input())
a = list(map(int, input().split()))
m = 10**18

res = reduce(lambda x,y: x*y, a)
res = 1
for n in a:
    res *= a
    if res > m:
        print(-1)
        exit()
    
print(res)
Problem p02755 (python)

Fixed submission:
import sys

A, B = map(int, input().split())
MAX = 1500

for i in range(1, MAX):
    if int(i*0.08) == A and int(i*0.1) == B:
        print(i)
        sys.exit()
print(-1)

Buggy submission (verdict: Runtime Error):
import sys

A, B = map(int, input().split())
MAX = 1500

for i in range(1, MAX):
    if int(i*0.08) == A and int(i*0.1) == B:
        print(i)
        sys.exit(1)
print(-1)

Buggy submission (verdict: Runtime Error):
import sys

A, B = map(int, input().split())

x_a = int(A/0.08)
x_b = int(B/0.1)

for i in range(x_b, x_a+1):
    if int(i*0.08) == A and int(i*0.1) == B:
        print(i)
        sys.exit(1)
print(-1)
Problem p02768 (python)

Fixed submission:
n, a, b = map(int, input().split())
MOD = 10**9+7


all_c = pow(2, n, MOD)-1
a_c = 1
b_c = 1
for i in range(n-a+1, n+1):
    a_c *= i
    a_c %= MOD
for i in range(1, a+1):
    a_c *= pow(i, MOD-2, MOD)
    a_c %= MOD
for i in range(n-b+1, n+1):
    b_c *= i
    b_c %= MOD
for i in range(1, b+1):
    b_c *= pow(i, MOD-2, MOD)
    b_c %= MOD

ans = (all_c - a_c - b_c) % MOD
print(ans)

Buggy submission (verdict: Runtime Error):
from scipy.special import comb

n, a, b = map(int, input().split())
MOD = 10**9+7


all_c = pow(2, n, MOD)-1
a_c = 1
b_c = 1
for i in range(n-a+1, n+1):
    a_c *= i
    a_c %= MOD
for i in range(1, a+1):
    a_c *= pow(i, MOD-2, MOD)
    a_c %= MOD
for i in range(n-b+1, n+1):
    b_c *= i
    b_c %= MOD
for i in range(1, b+1):
    b_c *= pow(i, MOD-2, MOD)
    b_c %= MOD

ans = (all_c - a_c - b_c) % MOD
print(ans)