Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
S=str(input())
lst=['A','C','G','T']
ans=0

for i in range(len(S)):
    cnt=0
    if S[i] in lst:
        cnt+=1
        if i==len(S)-1:
            ans = max(ans,cnt)
            break
        while S[i+1] in lst:
            cnt+=1
            i+=1
            if i+1==len(S)-1:
                break
    ans=max(ans,cnt)

print(ans)

Fixed submission:
S=str(input())
lst=['A','C','G','T']
ans=0

for i in range(len(S)):
    cnt=0
    if S[i] in lst:
        cnt+=1
        if i==len(S)-1:
            ans = max(ans,cnt)
            break
        while S[i+1] in lst:
            cnt+=1
            i+=1
            if i+1==len(S):
                break
    ans=max(ans,cnt)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

m = 998244353
N, K = map(int, input().split())
L = []
R = []
for K in range(K):
    l , r = map(int, input().split())
    L.append(l)
    R.append(r)

s = []
for i in range(len(L)):
    tmp = [n for n in range(L[i], R[i]+1)]
    s += tmp

s.sort()
ans = [1]
for i in range(1,N):
    tmp = 0
    for ss in s:
        if len(ans) < ss:
            break
#         print("i ", i)
#         print(ss)
        tmp += ans[i - ss]%m
#         print(ans)
    ans.append(tmp%m)

print(ans[-1])

Fixed submission:
import numpy as np

m = 998244353
N, K = map(int, input().split())
span = []
for K in range(K):
    l , r = map(int, input().split())
    span.append([l, r])

add = [0,1]# 累積和
ans = [1]

for i in range(2,N+1):
    tmp = 0
    for s in span:
        l, r = s[0], s[1]+1
        if l > len(ans):
            continue
        elif r >= len(ans)+1:
            r = len(ans)+1
        tmp += (add[i-l] - add[i-r])%m
    ans.append(tmp%m)
    add.append(add[-1]+tmp)

print(ans[-1]%m)
Buggy python submission (verdict: Runtime Error):
import numpy as np
import matplotlib.pyplot as plt

inpt = input()
inpt_list = inpt.split(" ")
X, K, D = [int(x) for x in inpt_list]

X_abs = np.abs(X)
num = X_abs // D
rem = K - num
if rem < 0:
    out = X_abs - D*K
else:
    if rem%2==0:
        out = X_abs - num*D
    else:
        out = np.abs(X_abs - num*D - D)
print(out)

Fixed submission:
import numpy as np

inpt = input()
inpt_list = inpt.split(" ")
X, K, D = [int(x) for x in inpt_list]

X_abs = np.abs(X)
num = X_abs // D
rem = K - num
if rem < 0:
    out = X_abs - D*K
else:
    if rem%2==0:
        out = X_abs - num*D
    else:
        out = np.abs(X_abs - num*D - D)
print(out)
Buggy python submission (verdict: Runtime Error):
C:\Users\satosyuuta\Anaconda3\python.exe C:/Users/satosyuuta/PycharmProjects/untitled/xtb/AtCorder/test.py
0
1

Process finished with exit code 0


Fixed submission:
N = int(input())
if N == 1:
    print(int(0))
else:
    print(int(1))
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = -float('inf')
for s in range(N):
    ### Step1
    S = []  # 累積和S. ただし, 初項は0ではなく1回目の移動後の得点とする.
    # 1回目の移動
    i = P[s] - 1
    S.append(C[i])
    # 2回目以降の移動. スタート地点に戻ってくるまで繰り返し.
    while i != s:
        i = P[i] - 1
        S.append(S[-1] + C[i])

    ### Step2: KとSの長に応じて場合分けして, 得点の最大値を求める.
    # 1周未満しか移動できない場合:
    if K <= len(S):
        score = max(S[:K])
    # 1周以上回ることができるが, ループを1周したときに得点が減る場合:
    elif S[-1] <= 0:
        score = max(S)
    # 1週以上回ることができ, かつループを1週するごとに得点が増える場合:
    else:
        # ループを (K // len(S) - 1)回 廻る場合:
        score1 = S[-1] * (K // len(S) - 1)
        score1 += max(S)
        # ループを (K // len(S))回 廻る場合:
        score2 = S[-1] * (K // len(S))
        r = K % len(S)
        if r != 0:
            score2 += max(0, max(S[:r]))
        # score1 と score2 の大きい方がこの場合の得点の最大値
        score = max(score1, score2)

    ans = max(ans, score)

print(ans)

Fixed submission:
X, K, D = map(int,input().split())
res = 0
X = abs(X)
if X >= K * D:
    res = X - K * D
else:
    i = X // D
    j = K - i
    if j % 2 == 0:
        res = X - D * i
    else:
        res = X - D * (i + 1)
print(abs(res))
Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())



i = 0
ai = 0
while True:
    ai = (ai * 10 + 7) % K
    i += 1
    if ai == 0:
        break
print(i)

Fixed submission:
K = int(input())

if K % 2 == 0 or K % 5 == 0:
    print(-1)
    exit()

i = 0
ai = 0
while True:
    ai = (ai * 10 + 7) % K
    i += 1
    if ai == 0:
        break
print(i)

Buggy python submission (verdict: Runtime Error):
K = int(input())
a = [0] * 1000000000
a[1] = 7 % K
for i in range(2,K):
    a[i] = (a[i-1]*10 + 7) % K
for i in range(1,K):
    if a[i] == 0:
        print(i)
        exit()
print("-1")

Fixed submission:
K = int(input())

if K % 2 == 0 or K % 5 == 0:
    print(-1)
    exit()

i = 0
ai = 0
while True:
    ai = (ai * 10 + 7) % K
    i += 1
    if ai == 0:
        break
print(i)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int,input().split())
A = list(map(int,input().split()))
S = 1
for i in range(K):
    S *= A[i]
for i in range(N-K):
    s = S / A[i] * A[i+K]
    if  S < s:
        print("Yes")
    else:
        print("No")
    S = s



Fixed submission:
N, K = map(int,input().split())
A = list(map(int,input().split()))
for i in range(N-K):
    if  A[i] < A[i+K]:
        print("Yes")
    else:
        print("No")

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int,input().split())
A = list(map(int,input().split()))
for i in range(N-K):
    if sum(A[i:i+K]) < sum(A[i+1:i+K+1]):
        print("Yes")
    else:
        print("No")



Fixed submission:
N, K = map(int,input().split())
A = list(map(int,input().split()))
for i in range(N-K):
    if  A[i] < A[i+K]:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Time Limit Exceeded):
def make_divisors(n: int):
    cnt = 0
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            cnt += 1
            if i != n // i:
                cnt += 1

    return cnt
res = 0
for i in range(int(input())):
    res += make_divisors(i+1) * (i+1)
print(res)

Fixed submission:
ans = 0
N = int(input())
for i in range(1,N+1):
    for j in range(i,N+1,i):
        ans += j
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
A.sort()
B = []
C = []
Q = int(input())
for i in range(Q):
    b, c = map(int,input().split())
    for j, a in enumerate(A):
        if a == b:
            A[j] = c
    print(sum(A))


Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
Q = int(input())
counter = Counter(A)
res = sum(A)
for i in range(Q):
    b, c = map(int,input().split())
    res -= counter[b] * b
    res += counter[b] * c
    counter[c] += counter[b]
    counter[b] = 0
    print(res)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = []
a = map(int,input().split())
ans = 1
for val in a:
    ans *= val
if ans > 10**18:
    print("-1")
    break
else:
    print(ans)

Fixed submission:
n = int(input())
a = []
a = map(int,input().split())
a = sorted(a)
ans = 1
for val in a:
    ans *= val
    if ans > 10**18:
        print(-1)
        break
else:
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,c,k=map(int,input().split())
a_arr = [1 for i in range(a)]
b_arr = [0 for i in range(b)]
c_arr = [-1 for i in range(c)]
arr = a_arr + b_arr + c_arr
print(sum(arr[:k]))


Fixed submission:
a,b,c,k=map(int,input().split())
if k <= a:
    print(k)
elif k <= a+b:
    print(a)
else:
    print(2*a-k+b)
Buggy python submission (verdict: Runtime Error):
N, K = map(int,input().split())
A = list(map(int,input().split()))
A.insert(0,0)
list = []
replist = []
judge = [True] * (2 * 10 ** 5)
cnt = 1
pos = 1
owari = True
while cnt < 2 * 10 ** 5 and owari:
    judge[pos] = False
    list.append(pos)
    pos = A[pos]
    if not judge[pos]:
        while True:
            replist.append(pos)
            judge[pos] = True
            pos = A[pos]
            if judge[pos]:
                owari = False
                break
if K <= len(list)-1:
    print(list[K])
else:
    K = K - len(list) + 1
    print(replist[( K % len(replist) ) -1])



Fixed submission:
N, K = map(int,input().split())
A = list(map(int,input().split()))
A.insert(0,0)
list = []
replist = []
judge = [True] * (2 * 10 ** 5 + 1)
pos = 1
owari = True
while owari:
    judge[pos] = False
    list.append(pos)
    pos = A[pos]
    if not judge[pos]:
        while True:
            replist.append(pos)
            judge[pos] = True
            pos = A[pos]
            if judge[pos]:
                owari = False
                break
if K <= len(list)-1:
    print(list[K])
else:
    K = K - len(list) + 1
    print(replist[( K % len(replist) ) -1])
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
h = list(map(int, input().split()))
ab = [0] * m
for i in range(m):
    ab[i] = list(map(int, input().split()))
check = [1] * n

for i in range(m):
    #低かったほうのチェックリストを0にしていく
    if h[ab[i][0]-1] = h[ab[i][1]-1]:
        check[ab[i][0]-1] = 0
        check[ab[i][1] - 1] = 0
    elif h[ab[i][0] - 1] < h[ab[i][1]-1]:
        check[ab[i][0] - 1] = 0
    else:
        check[ab[i][1]-1] = 0
print(sum(check))


Fixed submission:
n, m = map(int, input().split())
h = list(map(int, input().split()))
ab = [0] * m
for i in range(m):
    ab[i] = list(map(int, input().split()))
check = [1] * n

for i in range(m):
    #低かったほうのチェックリストを0にしていく
    if h[ab[i][0]-1] == h[ab[i][1]-1]:
        check[ab[i][0]-1] = 0
        check[ab[i][1] - 1] = 0
    elif h[ab[i][0] - 1] < h[ab[i][1]-1]:
        check[ab[i][0] - 1] = 0
    else:
        check[ab[i][1]-1] = 0
print(sum(check))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
Sn = set()
for i in range(N):
    s = {input()}
    Sn = Sn | s
print(len(Sn))


Fixed submission:
N = int(input())
Sn = []
for i in range(N):
    s = input()
    Sn.append(s)
print(len(set(Sn)))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
Sn = []
result = 0
for i in range(N):
    s = input()
    if s in Sn:
        result += 1
    Sn.append(s)
print(N-result)


Fixed submission:
N = int(input())
Sn = []
for i in range(N):
    s = input()
    Sn.append(s)
print(len(set(Sn)))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
Sn = []
result = 0
for i in  range (N):
    s = input()
    judge = 0
    for Si in Sn:
        if Si == s:
            judge = 1
    if judge == 0:
        result += 1
    Sn.append(s)
print(result)


Fixed submission:
N = int(input())
Sn = []
for i in range(N):
    s = input()
    Sn.append(s)
print(len(set(Sn)))
Buggy python submission (verdict: Time Limit Exceeded):
"""
def gcd(a, b ):
    if a < b:
        a, b = b, a
    while a % b != 0:
        a, b = b, a % b
    return b
"""
import math as f


K = int(input())
result = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            result += f.gcd(f.gcd(i, j), k)
print(result)

Fixed submission:
"""
def gcd(a, b ):
    if a < b:
        a, b = b, a
    while a % b != 0:
        a, b = b, a % b
    return b
"""
import math as f


K = int(input())
result = 0
for i in range(1,K+1):
    for j in range(1,i+1):
        for k in range(1,j+1):
            if i == j == k:
                result += f.gcd(f.gcd(i, j), k)
            elif i == j or j == k or k == i:
                result += 3 * f.gcd(f.gcd(i, j), k)
            else:
                result += 6 * f.gcd(f.gcd(i, j), k)

print(result)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
temp = N
while True:
    if temp < abs(temp - K):
        break
    temp -= K
print(abs(temp))

Fixed submission:
N, K = map(int, input().split())
t = N % K
print(min(K-t, t))

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
temp = N
mini = float("inf")
while True:
    mini = min(temp, mini)
    temp = abs(temp - K)
    if temp >= mini:
        break
print(mini)

Fixed submission:
N, K = map(int, input().split())
t = N % K
print(min(K-t, t))
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
Digit = [0] * N
Count = 0
for i in range(M):
    s, c = map(int, input().split())
    if Digit[s - 1] == c or Digit[s - 1] == 0:
        Digit[s - 1] = c
        Count += 1
    else:
        print("-1")
        exit()
if Digit[0] == 0 and M >= 1:
    if Digit[1] == 0 and M >=2:
        if Digit[2] == 0 and Count == 0:
            print("".join(map(str,Digit)))
            exit()
        else:
            print("-1")
            exit()
    else:
        print("-1")
        exit()
print("".join(map(str,Digit)))

Fixed submission:
N, M = map(int, input().split())
st = 1 * 10 ** (N-1)
en = st * 10
SC = []
for i in range(M):
    sc = list(map(int,input().split()))
    SC.append(sc)
if N == 1:
    for i in range(0, 10):
        t = str(i)
        judge = True
        for j in range(M):
            if t[SC[j][0] - 1] != str(SC[j][1]):
                judge = False
        if judge:
            print(i)
            exit()
    print("-1")
    exit()
    
for i in range(st,en):
    t = str(i)
    judge = True
    for j in range(M):
        if t[SC[j][0]-1] != str(SC[j][1]):
            judge = False
    if judge:
        print(i)
        exit()
print("-1")

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
Digit = [0] * N
Count = 0
for i in range(M):
    s, c = map(int, input().split())
    if Digit[s - 1] == c or Digit[s - 1] == 0:
        Digit[s - 1] = c
        Count += 1
    else:
        print("-1")
        exit()
if Digit[0] == 0:
    if Digit[1] == 0:
        if Digit[2] == 0 and Count == 0:
            print("".join(map(str,Digit)))
            exit()
        else:
            print("-1")
            exit()
    else:
        print("-1")
        exit()
print("".join(map(str,Digit)))

Fixed submission:
N, M = map(int, input().split())
st = 1 * 10 ** (N-1)
en = st * 10
SC = []
for i in range(M):
    sc = list(map(int,input().split()))
    SC.append(sc)
if N == 1:
    for i in range(0, 10):
        t = str(i)
        judge = True
        for j in range(M):
            if t[SC[j][0] - 1] != str(SC[j][1]):
                judge = False
        if judge:
            print(i)
            exit()
    print("-1")
    exit()
    
for i in range(st,en):
    t = str(i)
    judge = True
    for j in range(M):
        if t[SC[j][0]-1] != str(SC[j][1]):
            judge = False
    if judge:
        print(i)
        exit()
print("-1")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
res = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            tnp = [i,j,k]
            flag = 0
            for s in S:
                if int(s) == tnp[flag]:
                    flag += 1
                if flag == 3:
                    res += 1
                    break
print(res)

Fixed submission:
N = int(input())
S = input()
res = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            tnp = [i,j,k]
            flag = 0
            for s in S:
                if int(s) == tnp[flag]:
                    flag += 1
                if flag == 3:
                    res += 1
                    break
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
N, Y = map(int,input().split())
for i in range(N+1):
    for j in range(N+1-i):
        for k in range(N+1-i-j):
            if i + j + k == N and 10000 * i + 5000 * j + 1000 * k == Y:
                print(i,j,k)
                exit()
print("-1 -1 -1")

Fixed submission:
N, Y = map(int,input().split())
for i in range(N+1):
    for j in range(N+1-i):
        if  10000 * (N - i - j)+ 5000 * j + 1000 * i == Y:
            print(N - i - j,j,i)
            exit()
print("-1 -1 -1")
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())

AB = [map(int, input().split()) for _ in range(M)]

AB.reverse()

UF = [i for i in range(10**5)]
cnt = [1 for i in range(10**5)]


def uf(a):
    if UF[a] == a:
        return a
    t = uf(UF[a])
    UF[a] = t
    return UF[a]

def unite(a, b):
    if uf(a) == uf(b):
        return
    if cnt[uf(a)] > cnt[uf(b)]:
        cnt[uf(a)] += cnt[uf(b)]
        UF[uf(b)] = UF[uf(a)]
    else:
        cnt[uf(b)] += cnt[uf(a)]
        UF[uf(a)] = UF[uf(b)]
    return

cost = N * (N - 1) // 2

ans = []

for a, b in AB:
    ans.append(cost)
    if uf(a) != uf(b):
        cnt_a = cnt[uf(a)]
        cnt_b = cnt[uf(b)]
        cost -= cnt_a * cnt_b
        unite(a, b)

ans.reverse()

for a in ans:
    print(a)

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

AB = [map(int, input().split()) for _ in range(M)]

AB.reverse()

UF = [i for i in range(10**5)]
cnt = [1 for i in range(10**5)]


def uf(a):
    if UF[a] == a:
        return a
    t = uf(UF[a])
    UF[a] = t
    return UF[a]

def unite(a, b):
    if uf(a) == uf(b):
        return
    if cnt[uf(a)] > cnt[uf(b)]:
        cnt[uf(a)] += cnt[uf(b)]
        UF[uf(b)] = UF[uf(a)]
    else:
        cnt[uf(b)] += cnt[uf(a)]
        UF[uf(a)] = UF[uf(b)]
    return

cost = N * (N - 1) // 2

ans = []

for a, b in AB:
    a -= 1
    b -= 1
    ans.append(cost)
    if uf(a) != uf(b):
        cnt_a = cnt[uf(a)]
        cnt_b = cnt[uf(b)]
        cost -= cnt_a * cnt_b
        unite(a, b)

ans.reverse()

for a in ans:
    print(a)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
counta=0
tmp=n

for a in range(1,n):
    for b in range(1,n):
        #print(a,b)
        if a * b +1 <= n:
            counta+=1
        else:
            break
print(counta)

Fixed submission:
n = int(input())
counta=0
for a in range(1,n):
    for b in range(1,n):
        #print(a,b)
        if a * b +1 <= n:
            counta+=1
        else:
            break
print(counta)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = list(map(int, input().split()))
A = list(map(int, input().split()))
def kakeru(ary):
    result = 1
    for i in ary:
        result *= i
    return result

tmp =  kakeru(A[0:k])
point = tmp
for i in range(n-k):
    point = point * A[k+i] / A[i]
    if point > tmp:
        tmp = point
        print('Yes')
    else:
        tmp = point
        print('No')

Fixed submission:
n, k = list(map(int, input().split()))
A = list(map(int, input().split()))
for i in range(n-k):
    if A[k+i] > A[i]:
        print('Yes')
    else:
        print('No')

Buggy python submission (verdict: Time Limit Exceeded):
n, k = list(map(int, input().split()))
A = list(map(int, input().split()))
def kakeru(ary):
    result = 1
    for i in ary:
        result *= i
    return result

tmp =  kakeru(A[0:k])
point = tmp
for i in range(n-k):
    point = point * A[k+i] / A[i]
    if point > tmp:
        tmp = point
        print('Yes')
    else:
        tmp = point
        print('No')

Fixed submission:
n, k = list(map(int, input().split()))
A = list(map(int, input().split()))
for i in range(n-k):
    if A[k+i] > A[i]:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Runtime Error):
import sys
n, m, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))

a_=[]
b_=[]
tmp = 0
for i in a:
    tmp += i
    a_.append(tmp)
tmp = 0
for i in b:
    tmp += i
    b_.append(tmp)

if a_[0]>k and b_[0]>k:
    print(0)
    sys.exit()

if a_[0]>k:
    asn=0
    for i in b_:
        asn+=1
        if i > k:
            print(asn)
            sys.exit()

if b_[0]>k:
    asn=0
    for i in a_:
        asn+=1
        if i > k:
            print(asn)
            sys.exit()

ans=0
j = m-1
for i in range(n):
    if a_[i] > k:
        continue
    while b_[j] + a_[i] > k:
        j -= 1
    ans = max(ans,i+j+2)
print(ans)


Fixed submission:
import sys
n, m, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))

a_=[0]
b_=[0]
tmp = 0
for i in a:
    tmp += i
    a_.append(tmp)
tmp = 0
for i in b:
    tmp += i
    b_.append(tmp)

ans=0
j = m
for i in range(n+1):
    if a_[i] > k:
        continue
    while b_[j] + a_[i] > k:
        j -= 1
    ans = max(ans,i+j)
print(ans)

Buggy python submission (verdict: Runtime Error):
n, m, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))

a_=[]
b_=[]
tmp = 0
for i in a:
    tmp += i
    a_.append(tmp)
tmp = 0
for i in b:
    tmp += i
    b_.append(tmp)

if a_[0]>k and b_[0]>k:
    print(0)
    exit()

if a_[0]>k:
    asn=0
    for i in b_:
        asn+=1
        if i > k:
            print(asn)
            exit()

if b_[0]>k:
    asn=0
    for i in a_:
        asn+=1
        if i > k:
            print(asn)
            exit()


ans=0
j = m-1
for i in range(n):
    if a_[i] > k:
        continue
    while b_[j] + a_[i] > k:
        j -= 1
    ans = max(ans,i+j+2)
print(ans)


Fixed submission:
import sys
n, m, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))

a_=[0]
b_=[0]
tmp = 0
for i in a:
    tmp += i
    a_.append(tmp)
tmp = 0
for i in b:
    tmp += i
    b_.append(tmp)

ans=0
j = m
for i in range(n+1):
    if a_[i] > k:
        continue
    while b_[j] + a_[i] > k:
        j -= 1
    ans = max(ans,i+j)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, m, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
result=0
for i in range(len(a)+1):
    for j in range(len(b)+1):
        if sum(a[:i]) + sum(b[:j]) <= k:
            if result < i+j:
                result=i+j
print(result)

Fixed submission:
import sys
n, m, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))

a_=[0]
b_=[0]
tmp = 0
for i in a:
    tmp += i
    a_.append(tmp)
tmp = 0
for i in b:
    tmp += i
    b_.append(tmp)

ans=0
j = m
for i in range(n+1):
    if a_[i] > k:
        continue
    while b_[j] + a_[i] > k:
        j -= 1
    ans = max(ans,i+j)
print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
q = int(input())
lead = ''
end = ''
inversion_flg = -1

for j in range(q):
    query = input().split()
    if query[0] == "1":
        inversion_flg *= -1
    else:
        if inversion_flg == 1:
            if query[1] == "1":
                query[1] = "2"
            else:
                query[1] = "1"
        if query[1] == "1":
            lead += query[2]
        else:
            end += query[2]

lead = lead[::-1]
s = lead + s + end
if inversion_flg == 1:
    s = s[::-1]
print(s)


Fixed submission:
a = input()
if a.count('A') == 2 or a.count('B') ==2:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
p = 1
maxp = 10 ** 18
for i in range(n):
  p *= a[i]
if p > maxp:
  print('-1')
else:
  print(p)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
p = 1
maxp = 10 ** 18
overFlag = False
if 0 in a:
  p = 0
else:
  for i in range(n):
    p *= a[i]
    if p > maxp:
      overFlag = True
      break
if overFlag == True:
    print('-1')
else:
  print(p)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
bucket = [0] * max(a)
for i in a:
  bucket[i - 1] += 1
if max(bucket) >= 2:
  print('NO')
else:
  print('YES')

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
sorta = sorted(a)
sflag = False
for i in range(n - 1):
  if sorta[i] == sorta[i + 1]:
    sflag = True
    break
if sflag == True:
  print('NO')
else:
  print('YES')

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
countalist = []
for i in a:
  countalist.append(a.count(i))
if max(countalist) >= 2:
  print('NO')
else:
  print('YES')

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
sorta = sorted(a)
sflag = False
for i in range(n - 1):
  if sorta[i] == sorta[i + 1]:
    sflag = True
    break
if sflag == True:
  print('NO')
else:
  print('YES')