Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
S = []
T = []
for i in range(1,N+1):
    S.append(i+A[i-1])
    T.append(i-A[i-1])

L = [0]*max(S)
for i in range(N):
    if (S[i]-1>=0)and(len(L)-1>=S[i]-1):
        L[S[i]-1]+=1

out = 0
for i in range(N):
    if (T[i]-1>=0)and(len(L)-1>=T[i]-1):
        out += L[T[i]-1]
        if T[i]==S[i]:
            out += -1
print(out)


Fixed submission:
N = int(input())
A = list(map(int,input().split()))
S = []
T = []
for i in range(1,N+1):
    S.append(i+A[i-1])
    T.append(i-A[i-1])

L = []
for i in range(N):
    L.append(S[i]-1)

from collections import Counter
M = Counter(L)
out = 0
for i in range(N):
    if (T[i]-1>=0)and(len(L)-1>=T[i]-1):
        out += M[T[i]-1]
        if T[i]==S[i]:
            out += -1
print(out)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
S = []
T = []
for i in range(1,N+1):
    S.append(i+A[i-1])
    T.append(i-A[i-1])

L = [0]*max(S)
for i in range(N):
    L[S[i]-1]+=1

out = 0
for i in range(N):
    if (T[i]-1>=0)and(len(L)-1>=T[i]-1):
        out += L[T[i]-1]
        if T[i]==S[i]:
            out += -1
print(out)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
S = []
T = []
for i in range(1,N+1):
    S.append(i+A[i-1])
    T.append(i-A[i-1])

L = []
for i in range(N):
    L.append(S[i]-1)

from collections import Counter
M = Counter(L)
out = 0
for i in range(N):
    if (T[i]-1>=0)and(len(L)-1>=T[i]-1):
        out += M[T[i]-1]
        if T[i]==S[i]:
            out += -1
print(out)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
S = []
T = []
for i in range(1,N+1):
    S.append(i+A[i-1])
    T.append(i-A[i-1])

L = [0]*max(S)
for i in range(N):
    L[S[i]-1]+=1

out = 0
for i in range(N):
    if T[i]>0:
        out += L[T[i]-1]
        if T[i]==S[i]:
            out += -1
print(out)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
S = []
T = []
for i in range(1,N+1):
    S.append(i+A[i-1])
    T.append(i-A[i-1])

L = []
for i in range(N):
    L.append(S[i]-1)

from collections import Counter
M = Counter(L)
out = 0
for i in range(N):
    if (T[i]-1>=0)and(len(L)-1>=T[i]-1):
        out += M[T[i]-1]
        if T[i]==S[i]:
            out += -1
print(out)
Buggy python submission (verdict: Runtime Error):
import fractions
K = int(input())
out = 0
L = [0]*K
gcd = [[0]*K for i in range(K)]
for i in range(1,201):
    for j in range(1,201):
        A = fractions.gcd(i,j)
        gcd[i-1][j-1] = A
        L[A-1]+=1


for i in range(1,201):
    for j in range(1,201):
        out+=gcd[i-1][j-1]*L[j-1]

print(out)

Fixed submission:
import fractions
K = int(input())
out = 0
L = [0]*K
gcd = [[0]*K for i in range(K)]
for i in range(1,K+1):
    for j in range(1,K+1):
        A = fractions.gcd(i,j)
        gcd[i-1][j-1] = A
        L[A-1]+=1


for i in range(1,K+1):
    for j in range(1,K+1):
        out+=gcd[i-1][j-1]*L[j-1]

print(out)
Buggy python submission (verdict: Runtime Error):
N,K,C = list(map(int,input().split()))
S = list(input())
L = []
R = []
life = 0
cnt = K
for i in range(N):
    if cnt==0:
        break
    if S[i]=="o":
        if life <= 0:
            life = C
            L.append(i)
            cnt += -1
        else:
            life += -1
    elif S[i]=="x":
        life += -1

life = 0
cnt = K
for i in range(N):
    if cnt==0:
        break
    if S[N-1-i]=="o":
        if life <= 0:
            life = C
            R.append(N-1-i)
            cnt += -1
        else:
            life += -1
    elif S[N-1-i]=="x":
        life += -1

out = set(L) & set(R)
out.sort()
for a in out:
    print(a+1)

Fixed submission:
N,K,C = list(map(int,input().split()))
S = list(input())
L = []
R = []
life = 0
cnt = K
for i in range(N):
    if cnt==0:
        break
    if S[i]=="o":
        if life <= 0:
            life = C
            L.append(i)
            cnt += -1
        else:
            life += -1
    elif S[i]=="x":
        life += -1

life = 0
cnt = K
for i in range(N):
    if cnt==0:
        break
    if S[N-1-i]=="o":
        if life <= 0:
            life = C
            R.append(N-1-i)
            cnt += -1
        else:
            life += -1
    elif S[N-1-i]=="x":
        life += -1

L.sort()
R.sort()
for i in range(min(len(L),len(R))):
    if L[i]==R[i]:
        print(L[i]+1)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
B = ""
C = ""
t = 1
for i in range(Q):
    A = input()
    if A=="1":
        t*=-1
    else:
        AL = list(A.split())
        if AL[1]=="1":
            if t==1:
                B +=AL[2]
            else:
                C +=AL[2]
        elif AL[1]=="2":
            if t==1:
                C +=AL[2]
            else:
                B +=AL[2]

if t==-1:
    print(C[::-1]+S[::-1]+B)
else:
    print(B[::-1]+S+C)

Fixed submission:
S = input()
Q = int(input())
B = []
C = []
t = 1
for i in range(Q):
    A = input()
    if A=="1":
        t*=-1
    else:
        AL = list(A.split())
        if AL[1]=="1":
            if t==1:
                B.append(AL[2])
            else:
                C.append(AL[2])
        elif AL[1]=="2":
            if t==1:
                C.append(AL[2])
            else:
                B.append(AL[2])

B = ''.join(B)
C = ''.join(C)

if t==-1:
    print(C[::-1]+S[::-1]+B)
else:
    print(B[::-1]+S+C)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
B = ""

t = 1
for i in range(Q):
    A = input()
    if A=="1":
        t*=-1
    else:
        AL = list(A.split())
        if AL[1]=="1":
            if t==1:
                B +=AL[2]
            else:
                S +=AL[2]
        elif AL[1]=="2":
            if t==1:
                S +=AL[2]
            else:
                B +=AL[2]

if t==-1:
    print(S[::-1]+B)
else:
    print(B[::-1]+S)

Fixed submission:
S = input()
Q = int(input())
B = []
C = []
t = 1
for i in range(Q):
    A = input()
    if A=="1":
        t*=-1
    else:
        AL = list(A.split())
        if AL[1]=="1":
            if t==1:
                B.append(AL[2])
            else:
                C.append(AL[2])
        elif AL[1]=="2":
            if t==1:
                C.append(AL[2])
            else:
                B.append(AL[2])

B = ''.join(B)
C = ''.join(C)

if t==-1:
    print(C[::-1]+S[::-1]+B)
else:
    print(B[::-1]+S+C)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())

t = 1
for i in range(Q):
    A = input()
    if A=="1":
        t*=-1
    else:
        AL = list(A.split())
        if AL[1]=="1":
            if t==1:
                S = AL[2]+S
            else:
                S = S+AL[2]
        elif AL[1]=="2":
            if t==1:
                S = S+AL[2]
            else:
                S = AL[2]+S

if t==-1:
    print(S[::-1])
else:
    print(S)

Fixed submission:
S = input()
Q = int(input())
B = []
C = []
t = 1
for i in range(Q):
    A = input()
    if A=="1":
        t*=-1
    else:
        AL = list(A.split())
        if AL[1]=="1":
            if t==1:
                B.append(AL[2])
            else:
                C.append(AL[2])
        elif AL[1]=="2":
            if t==1:
                C.append(AL[2])
            else:
                B.append(AL[2])

B = ''.join(B)
C = ''.join(C)

if t==-1:
    print(C[::-1]+S[::-1]+B)
else:
    print(B[::-1]+S+C)
Buggy python submission (verdict: Runtime Error):
N = int(input())
K = int(input())
SN = str(N)
LN = list(SN)
keta =len(LN)
Nzer = keta-K
Nsei = K
output = 0
if keta>=K:
    output += comb(keta,K,10**9+7)*9**K
    t = 0
    while K-1-t>=0:
        output -= (9-int(LN[t]))*comb(keta-1-t,K-1-t,10**9+7)*9**(K-1-t)
        t += 1
print(output)

Fixed submission:
def framod(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
    return a
def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod
def comb(n, k, mod):
    a=framod(n, mod)
    b=framod(k, mod)
    c=framod(n-k, mod)
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod



N = int(input())
K = int(input())
SN = str(N)
LN = list(SN)
keta =len(LN)
Nzer = keta-K
Nsei = K
output = 0
if keta>=K:
    output += comb(keta,K,10**9+7)*9**K
    t = 0
    s = 0
    while (s<=K-1)and(t<=keta-1):
        if LN[t]!="0":
            output -= (9-int(LN[t]))*comb(keta-1-t,K-1-s,10**9+7)*9**(K-1-s)
            t += 1
            s += 1
        elif LN[t]=="0":
            output -= (9-int(LN[t]))*comb(keta-1-t,K-1-s,10**9+7)*9**(K-1-s)
            t+=1
print(int(output))

Buggy python submission (verdict: Runtime Error):
def framod(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
    return a
def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod
def comb(n, k, mod):
    a=framod(n, mod)
    b=framod(k, mod)
    c=framod(n-k, mod)
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod



N = int(input())
K = int(input())
SN = str(N)
LN = list(SN)
keta =len(LN)
Nzer = keta-K
Nsei = K
output = 0

output += comb(keta,K,10**9+7)*9**K
t = 0
while K-1-t>=0:
    output -= (9-int(LN[t]))*comb(keta-1-t,K-1-t,10**9+7)*9**(K-1-t)
    t += 1
print(output)

Fixed submission:
def framod(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
    return a
def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod
def comb(n, k, mod):
    a=framod(n, mod)
    b=framod(k, mod)
    c=framod(n-k, mod)
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod



N = int(input())
K = int(input())
SN = str(N)
LN = list(SN)
keta =len(LN)
Nzer = keta-K
Nsei = K
output = 0
if keta>=K:
    output += comb(keta,K,10**9+7)*9**K
    t = 0
    s = 0
    while (s<=K-1)and(t<=keta-1):
        if LN[t]!="0":
            output -= (9-int(LN[t]))*comb(keta-1-t,K-1-s,10**9+7)*9**(K-1-s)
            t += 1
            s += 1
        elif LN[t]=="0":
            output -= (9-int(LN[t]))*comb(keta-1-t,K-1-s,10**9+7)*9**(K-1-s)
            t+=1
print(int(output))
Buggy python submission (verdict: Time Limit Exceeded):
[N,K,S] = list(map(int,input().split()))
if S != 1:
    output = ""
    for i in range(K):
        output += "{} ".format(S)
    for i in range(N-K):
        output += "1 "
else:
    output = ""
    for i in range(K):
        output += "{} ".format(S)
    for i in range(N-K):
        output += "2 "

print(output[0:-1])

Fixed submission:
[N,K,S] = list(map(int,input().split()))
cnt = 0
if S != 1:
    output = []
    for i in range(K):
        output.append(S)
    for i in range(N-K):
        cnt += 1
        if cnt < S:
            output.append(1)
        else:
            output.append(S+1)
            cnt = 0
else:
    output = []
    for i in range(K):
        output.append(S)
    for i in range(N-K):
        output.append(2)

print(" ".join(map(str, output)))
Buggy python submission (verdict: Time Limit Exceeded):
H,W = list(map(int,input().split()))

M = []
for i in range(H):
    M.append(list(input()))

from collections import deque

out = 0
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

for sx in range(0,W):
    for gx in range(0,W):
        for sy in range(0,H):
            for gy in range(0,H):
                if M[sy][sx]=="#":
                    continue
                if (sx==gx)and(sy==gy):
                    continue
                d = [[10**4] * W for i in range(H)]
                que = deque([])
                que.append((sy, sx))
                d[sy][sx] = 0
                while que:
                    p = que.popleft()
                    if p[0] == gy and p[1] == gx:
                        break
                    for i in range(4):
                        ny = p[0] + dy[i]
                        nx = p[1] + dx[i]
                        if (0<=nx<W)and(0<=ny<H)and(M[ny][nx]!="#")and(d[ny][nx]==10**4):
                            que.append((ny, nx))
                            d[ny][nx] = d[p[0]][p[1]] + 1
                if out < d[gy][gx] and M[gy][gx]!="#":
                    out=d[gy][gx]
print(out)

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

M = []
for i in range(H):
    M.append(list(input()))

from collections import deque

out = 0
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

for sx in range(0,W):
    for sy in range(0,H):
        if M[sy][sx]=="#":
            continue
        d = [[10**4] * W for i in range(H)]
        que = deque([])
        que.append((sy, sx))
        d[sy][sx] = 0
        while que:
            p = que.popleft()
            for i in range(4):
                ny = p[0] + dy[i]
                nx = p[1] + dx[i]
                if (0<=nx<W)and(0<=ny<H)and(M[ny][nx]!="#")and(d[ny][nx]==10**4):
                    que.append((ny, nx))
                    d[ny][nx] = d[p[0]][p[1]] + 1
                    out = max(d[ny][nx],out)
print(out)
Buggy python submission (verdict: Runtime Error):
[N,K] = list(map(int,input().split()))
A = list(map(int,input().split()))

A.sort()

X = A[:(N-K+1)]
Y = A[(K-1):]
Y.sort(reverse=True)
output = 0
Z = len(X)
C = 1
l=K
r=1
for i in range(Z):
    output += (Y[-1*(i+1)]-X[-1*(i+1)])*C
    if output >= 10**9+7:
        output = output % (10**9+7)
    C = int(C*l/r)
    l+=1
    r+=1
print(output)

Fixed submission:
N,K = list(map(int,input().split()))
A = list(map(int,input().split()))

A.sort()

MAXN = 10**5+10
p = 10**9+7
MOD = p
f = [1]
for i in range(MAXN):
    f.append(f[-1] * (i+1) % MOD)
def nCr(n, r, mod=MOD):
    return f[n] * pow(f[r], mod-2, mod) * pow(f[n-r], mod-2, mod) % mod

MA = 0
for i in range(N-K+1):
    MA = (MA + A[N-1-i]*nCr(N-1-i,K-1))%p

MI = 0
for i in range(N-K+1):
    MI = (MI + A[i]*nCr(N-1-i,K-1))%p

out = MA-MI
if out<0:
    out += p
print(out)

Buggy python submission (verdict: Runtime Error):
[N,K] = list(map(int,input().split()))
A = list(map(int,input().split()))

A.sort()


C = [1]
r = 1
l = K
for i in range(1,N-K+1):
    C.append(int(C[i-1]*l/r))
    l+=1
    r+=1

C = C[::-1]

X = A[:(N-K+1)]
Y = A[(K-1):]
Y.sort(reverse=True)
output = 0
Z = len(X)
for i in range(Z):
    output += (Y[i]-X[i])*C[i]
    if output >= 10**9+7:
        output = output % (10**9+7)

print(output)

Fixed submission:
N,K = list(map(int,input().split()))
A = list(map(int,input().split()))

A.sort()

MAXN = 10**5+10
p = 10**9+7
MOD = p
f = [1]
for i in range(MAXN):
    f.append(f[-1] * (i+1) % MOD)
def nCr(n, r, mod=MOD):
    return f[n] * pow(f[r], mod-2, mod) * pow(f[n-r], mod-2, mod) % mod

MA = 0
for i in range(N-K+1):
    MA = (MA + A[N-1-i]*nCr(N-1-i,K-1))%p

MI = 0
for i in range(N-K+1):
    MI = (MI + A[i]*nCr(N-1-i,K-1))%p

out = MA-MI
if out<0:
    out += p
print(out)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())
L = ["0","1","2","3","4","5","6","7","8","9"]
cnt = 0
for a in L:
    for b in L:
        for c in L:
            target = [a,b,c]
            T = 0
            for i in range(N):
                see = S[i]
                if target[T]==see:
                    T+=1
                    if T==3:
                        cnt += 1
                        break
print(cnt)

Fixed submission:
N = int(input())
S = list(input())
L = ["0","1","2","3","4","5","6","7","8","9"]
cnt = 0
for a in L:
    for b in L:
        for c in L:
            target = [a,b,c]
            T = 0
            for i in range(N):
                see = S[i]
                if target[T]==see:
                    T+=1
                    if T==3:
                        cnt += 1
                        break
print(cnt)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = []
for i in range(N):
    A.append(list(map(int,input().split())))

output = 0
memo = [0] * N
newmemo = [0] * N
owari = [0] * N
flag = 0
while flag < N:
    ng = 0
    for i in range(N):
        check = A[i][memo[i]]-1
        if i==A[check][memo[check]]-1:
            if memo[i] < N-2:
                newmemo[i]+=1
            elif (memo[i] == N-2) and (owari[i]==0):
                owari[i] = 1
                flag += 1
            else:
                continue
        else:
            ng += 1
    if ng == N:
        output = -1
        break
    memo = newmemo[:]
    output += 1

print(output)

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

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
output = 0
for i in range(1,N):
    output += i
print(output)

Fixed submission:
N = int(input())
output = int(N*(N-1)//2)
print(output)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
output = [0]*N

output[N//2:]=A[N//2:]

t = N//2-1
for j in range(N//2):
    for i in range(N//(t+1)-1):
        output[t]= (output[t]+output[(t+1)*(i+2)-1])%2
    output[t]=int(output[t] != A[t])
    t -= 1

ans = ""
flag = 0
for j in range(N):
    if output[j]==1:
        ans += str(j+1) + " "
        flag += 1
print(flag)
if flag > 0:
    ans = ans[:-1]
    print(ans)

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

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

B = [0]*N
for i in range(N):
    X = N-i
    P = B[X-1]
    Q = A[X-1]
    if P==Q:
        B[X-1] = 0
    else:
        XDL = make_divisors(X)
        for XD in XDL:
            if XD==X:
                B[XD-1] = 1
            else:
                B[XD-1] = 1 - B[XD-1]
out = []
cnt = 0
for i in range(N):
    if B[i]==1:
        out.append(i+1)
        cnt+=1
print(cnt)
if len(out)>0:
    print(*out)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
A = np.array(list(map(int,input().split())))
output = np.zeros(N)

output[N//2:]=A[N//2:]

t = N//2-1
for j in range(N//2):
    for i in range(N//(t+1)-1):
        output[t]= (output[t]+output[(t+1)*(i+2)-1])%2
    output[t]=int(output[t] != A[t])
    t -= 1

ans = ""
flag = 0
for j in range(N):
    if output[j]==1:
        ans += str(j+1) + " "
        flag += 1
print(flag)
if flag > 0:
    ans = ans[:-1]
    print(ans)

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

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

B = [0]*N
for i in range(N):
    X = N-i
    P = B[X-1]
    Q = A[X-1]
    if P==Q:
        B[X-1] = 0
    else:
        XDL = make_divisors(X)
        for XD in XDL:
            if XD==X:
                B[XD-1] = 1
            else:
                B[XD-1] = 1 - B[XD-1]
out = []
cnt = 0
for i in range(N):
    if B[i]==1:
        out.append(i+1)
        cnt+=1
print(cnt)
if len(out)>0:
    print(*out)
Buggy python submission (verdict: Runtime Error):
N = int(input())
XY = []
for i in range(N):
    XY.append(list(map(int,input().split())))

pqs = []
for i in range(N):
    for j in range(i+1,N):
        X1 = XY[i][0]
        Y1 = XY[i][1]
        X2 = XY[j][0]
        Y2 = XY[j][1]
        pqs.append(str(X1-X2)+","+str(Y1-Y2))
        pqs.append(str(X2-X1)+","+str(Y2-Y1))

from collections import Counter
C = dict(Counter(pqs))
out = N - max(C.values())
print(out)

Fixed submission:
N = int(input())
XY = []
for i in range(N):
    XY.append(list(map(int,input().split())))

if N!=1:
    pqs = []
    for i in range(N):
        for j in range(i+1,N):
            X1 = XY[i][0]
            Y1 = XY[i][1]
            X2 = XY[j][0]
            Y2 = XY[j][1]
            pqs.append(str(X1-X2)+","+str(Y1-Y2))
            pqs.append(str(X2-X1)+","+str(Y2-Y1))

    from collections import Counter
    C = dict(Counter(pqs))
    out = N - max(C.values())
    print(out)
else:
    print(1)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
NM = list(map(int,input().split()))
N = NM[0]
M = NM[1]
A = list(map(int,input().split()))
listBC =[]
while True:
    try:
        listBC.append(list(map(int,input().split())))
    except:
        break;
B = []
C = []
for i in range(0,len(listBC)):
    B.append(listBC[i][0])
    C.append(listBC[i][1])
B = np.array(B)
C = np.array(C)
BC = np.vstack([B,C])
# BCnum = np.argsort(BC[0,:])[::-1]
# BCs = BC[:,BCnum]
Cjun = []
for i in range(len(B)):
    for j in range(BC[0,i]):
        Cjun.append(BC[1,i])
Cjun.sort(reverse=True)
A.sort()
keyi = min(len(A),len(Cjun))
for i in range(min(len(A),len(Cjun))):
    if A[i]>=Cjun[i]:
        keyi = i
        break
output = sum(Cjun[0:keyi])+sum(A[keyi:])
print(output)

Fixed submission:
import numpy as np
NM = list(map(int,input().split()))
N = NM[0]
M = NM[1]
A = list(map(int,input().split()))
listBC =[]
while True:
    try:
        listBC.append(list(map(int,input().split())))
    except:
        break;
BC = np.array(listBC)
BCnum = np.argsort(BC[:,1])[::-1]
BC = BC[BCnum,:]

A.sort()
j=0
for i in range(len(A)):
    times = BC[j,0]
    if BC[j,0]==0:
        j+=1
        if j == BC.shape[0]:
            break
        times = BC[j,0]
    if A[i]<BC[j,1]:
        A[i]=BC[j,1]
        BC[j,0] += -1
output = sum(A)
print(output)
Buggy python submission (verdict: Runtime Error):
istNK = list(map(int,input().split()))
S = list(input())

if S[listNK[1]-1]=="A":
    S[listNK[1]-1] = "a"
if S[listNK[1]-1]=="B":
    S[listNK[1]-1] = "b"
if S[listNK[1]-1]=="C":
    S[listNK[1]-1] = "c"

output = ""
for i in range(listNK[0]):
    output = output + S[i]

print(output)

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

if S[listNK[1]-1]=="A":
    S[listNK[1]-1] = "a"
if S[listNK[1]-1]=="B":
    S[listNK[1]-1] = "b"
if S[listNK[1]-1]=="C":
    S[listNK[1]-1] = "c"

output = ""
for i in range(listNK[0]):
    output = output + S[i]

print(output)
Buggy python submission (verdict: Runtime Error):
import numpy as np

N = int(input())

listX =[]
while True:
    try:
        listX.append(list(map(int,input().split())))
    except:
        break;

table = np.zeros((N,N))
point = np.zeros(N)
for i in range(N-1):
    x = listX[i][0]
    y = listX[i][1]
    table[x-1,y-1] = listX[i][2]
    table[y-1,x-1] = listX[i][2]

for j in range(0,N):
    for k in range(j+1,N):
        point[k] += table[j,k]

output = (point%2==0)
output = list(map(int,output))

outstr = str(output[0])

for i in range(1,N):
    outstr += "\n"+str(output[i])

print(outstr)

Fixed submission:
N = int(input())
G = [[] for i in range(N)]
for i in range(N-1):
    A,B,C = list(map(int,input().split()))
    G[A-1].append([C,B-1]) #重み、向かう先の順番
    G[B-1].append([C,A-1])

from collections import deque
dist = [None]*N
que = deque([0])
dist[0] = 0
while que:
    v = que.popleft()
    d = dist[v]
    for c,w in G[v]:
        if dist[w] is not None:
            continue
        dist[w] = d + c
        que.append(w)
for i in range(N):
    print(dist[i]%2)
Buggy python submission (verdict: Runtime Error):
N,M = list(map(int,input().split()))

MAXN = (10**5)+10
p = 10**9+7
MOD = p
f = [1]
for i in range(MAXN):
    f.append(f[-1] * (i+1) % MOD)
def nCr(n, r, mod=MOD):
    return f[n] * pow(f[r], mod-2, mod) * pow(f[n-r], mod-2, mod) % mod

def prime(X):
    pf={}
    m=X
    for i in range(2,int(m**0.5)+1):
        while m%i==0:
            pf[i]=pf.get(i,0)+1
            m//=i
    if m>1:pf[m]=1
    return pf

pf = prime(M)
powers = list(pf.values())

out = 1
for power in powers:
    out = out*nCr(power+N-1,power)%p

print(out)

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

MAXN = 2*(10**5)+10
p = 10**9+7
MOD = p
f = [1]
for i in range(MAXN):
    f.append(f[-1] * (i+1) % MOD)
def nCr(n, r, mod=MOD):
    return f[n] * pow(f[r], mod-2, mod) * pow(f[n-r], mod-2, mod) % mod

def prime(X):
    pf={}
    m=X
    for i in range(2,int(m**0.5)+1):
        while m%i==0:
            pf[i]=pf.get(i,0)+1
            m//=i
    if m>1:pf[m]=1
    return pf

pf = prime(M)
powers = list(pf.values())

out = 1
for power in powers:
    out = out*nCr(power+N-1,power)%p

print(out)