Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

A = [sum(A[:i+1]) for i in range(len(A)) if sum(A[:i+1]) <= K]
B = [sum(B[:i+1]) for i in range(len(B)) if sum(B[:i+1]) <= K]

len_B = len(B)
res = []
for i, a in enumerate(A):
    for j in range(len_B)[::-1]:
        # print(i+1, j+1, a, B[j], a+B[j], K)
        if a + B[j] <= K:
            res.append(i+j+2)
            break
    len_B = j+1

print(max(res))

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

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

len_B = M+1
res = []
for i, a_ in enumerate(a):
    for j in range(len_B)[::-1]:
        # print(i+1, j+1, a, B[j], a+B[j], K)
        if a_ + b[j] <= K:
            res.append(i+j)
            break
    len_B = j+1

print(0 if len(res) < 1 else max(res))

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

A_ = [sum(A[:i+1]) for i in range(len(A)) if sum(A[:i+1]) <= K]
B_ = [sum(B[:i+1]) for i in range(len(B)) if sum(B[:i+1]) <= K]

x = [i+j+2 for i in range(len(A_)) for j in range(len(B_)) if A_[i]+B_[j] <= K]
print(max(x))

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

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

len_B = M+1
res = []
for i, a_ in enumerate(a):
    for j in range(len_B)[::-1]:
        # print(i+1, j+1, a, B[j], a+B[j], K)
        if a_ + b[j] <= K:
            res.append(i+j)
            break
    len_B = j+1

print(0 if len(res) < 1 else max(res))
Buggy python submission (verdict: Runtime Error):
import sys
X, Y = map(int, input().split())

for x in range(0, X+1):
    if 2 * x + 4 * (X-x) == Y:
        print('Yes')
        sys.exit()
print('No'

Fixed submission:
import sys
X, Y = map(int, input().split())

for x in range(0, X+1):
    if 2 * x + 4 * (X-x) == Y:
        print('Yes')
        sys.exit()
print('No')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(a) for a in input().split()]
s = set(A)
x = [0] * N

for i in s:
    x[i-1] += A.count(i)

for i in x:
    print(i)


Fixed submission:
N = int(input())
A = [int(a) for a in input().split()]
x = [0] * N

for i in A:
    x[i-1] += 1

for i in x:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(a) for a in input().split()]
s = set(A)
x = [0] * N

for i in s:
    x[i-1] += A.count(i)


o = '\n'.join(map(str, x))
print(o)


Fixed submission:
N = int(input())
A = [int(a) for a in input().split()]
x = [0] * N

for i in A:
    x[i-1] += 1

for i in x:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(a) for a in input().split()]
s = set(A)
x = [0] * N

for i in s:
    x[i-1] += A.count(i)


o = '\n'.join(map(str, x))
print(o)


Fixed submission:
N = int(input())
A = [int(a) for a in input().split()]
x = [0] * N

for i in A:
    x[i-1] += 1

for i in x:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(a) for a in input().split()]

o = '\n'.join([str(A.count(i)) for i in range(1, N+1)])
print(o)


Fixed submission:
N = int(input())
A = [int(a) for a in input().split()]
x = [0] * N

for i in A:
    x[i-1] += 1

for i in x:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(a) for a in input().split()]

for i in range(1, N+1):
    print(A.count(i))


Fixed submission:
N = int(input())
A = [int(a) for a in input().split()]
x = [0] * N

for i in A:
    x[i-1] += 1

for i in x:
    print(i)
Buggy python submission (verdict: Runtime Error):
arr=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

K=input()
print(arr[int(K)])

Fixed submission:
arr=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

K=input()
K=int(K)
print(arr[K-1])
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n = int(input())
an = np.array(list(map(int, input().split())))
q = int(input())
bici=[[] for i in range(q)]
for i in range(q):
    bici[i] = list(map(int, input().split()))
    an = np.where(an == bici[i][0],bici[i][1],an)
    Ans = np.sum(an)
    print(Ans)

Fixed submission:
n = int(input())
Ans = 0
num = [0] * 100000
an = list(map(int, input().split()))
for i in range(n):
    num[an[i]-1] += 1
    Ans += an[i]
q = int(input())
for i in range(q):
    bici = list(map(int, input().split()))
    Ans += num[bici[0]-1]*(bici[1]-bici[0])
    num[bici[1]-1] += num[bici[0]-1]
    num[bici[0]-1] = 0
    print(Ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int, input().split())
pn = list(map(int, input().split()))
ex_list = []
for i in range(n-k+1):
    ex = 0
    for j in range(k):
        ex += (pn[i+j]+1)/2
    ex_list.append(ex)
print(max(ex_list))

Fixed submission:
n,k=map(int, input().split())
pn = list(map(int, input().split()))
ex_list = [(pn[i]+1)/2 for i in range(len(pn))]
ex_wa_list = []
wa = 0
for i in range(len(ex_list)):
    wa += ex_list[i]
    ex_wa_list.append(wa)
Ans_list = []
wa2 = 0
for i in range(n-k+1):
    if i == 0:
        wa2 = ex_wa_list[k-1]
    else:
        wa2 = ex_wa_list[k-1+i] - ex_wa_list[i-1]
    Ans_list.append(wa2)
print(max(Ans_list))
Buggy python submission (verdict: Time Limit Exceeded):
import collections
s = list(input())
Ans = 0
c = collections.Counter(s)
d = c['B']
for i in range(len(s)):
    if s[i] == 'B':
        for j in range(len(s)-i-1):
            if s[i+j+1]=='W':
                Ans += j+1
                s[i] = 'W'
                s[i+1] = 'B'
                s[i+j+1] = 'B'
                break
    if i == d:
        break
print(Ans)

Fixed submission:
s = list(input())
Ans = 0
W_put_place = 0
for i in range(len(s)):
    if s[i] == 'W':
        Ans += i - W_put_place
        W_put_place += 1
print(Ans)

Buggy python submission (verdict: Runtime Error):
import collections
s = list(input())
Ans = 0
c = collections.Counter(s)
d = c['B']
for i in range(len(s)):
    if s[i] == 'B':
        for j in range(len(s)-i-1):
            if s[i+j+1]=='W':
                Ans += j+1
                s[i] = 'W'
                s[i+1] = 'B'
                s[i+j+1] = 'B'
                break
    if i = d:
        break
print(Ans)

Fixed submission:
s = list(input())
Ans = 0
W_put_place = 0
for i in range(len(s)):
    if s[i] == 'W':
        Ans += i - W_put_place
        W_put_place += 1
print(Ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
Ans = 0
for i in range(len(s)):
    if s[i] == 'B':
        for j in range(len(s)-i-1):
            if s[i+j+1]=='W':
                Ans += j+1
                s[i] = 'W'
                s[i+1] = 'B'
                s[i+j+1] = 'B'
                break
print(Ans)

Fixed submission:
s = list(input())
Ans = 0
W_put_place = 0
for i in range(len(s)):
    if s[i] == 'W':
        Ans += i - W_put_place
        W_put_place += 1
print(Ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,y=map(int, input().split())
nums=[i for i in range(n+1)]
combi_list = []
for i in range(n+1):
    for j in range(n+1-i):
        combi = [0 for i in range(3)]
        combi[0] = i
        combi[1] = j
        combi[2] = n - i - j
        combi_list.append(combi)
Ans_list = []
judge = 0
for i in range(len(combi_list)):
    price = combi_list[i][0] * 10000 + combi_list[i][1] * 5000 + combi_list[i][2] * 1000
    if y == price:
        judge += 1
        Ans_list.append(combi_list[i][0])
        Ans_list.append(combi_list[i][1])
        Ans_list.append(combi_list[i][2])
        break

if judge>=1:
    print(str(Ans_list[0])+ " " + str(Ans_list[1]) + " " + str(Ans_list[2]))
else:
    print("-1 -1 -1")

Fixed submission:
n,y=map(int, input().split())
nums=[i for i in range(n+1)]
judge = 0
for i in range(n+1):
    for j in range(n+1-i):
        price = i * 10000 + j * 5000 + (n-i-j) * 1000
        if y == price:
            judge += 1
            print(str(i) + " " + str(j) + " " + str(n-i-j))
            break
    if judge == 1:
        break
if judge == 0:
    print("-1 -1 -1")
Buggy python submission (verdict: Runtime Error):
import sys

n = int(input())
dn = list(map(int, input().split()))
m = int(input())
tn = list(map(int, input().split()))

d_num = [0 for i in range(200001)]
t_num = [0 for i in range(200001)]

for i in range(len(dn)):
    d_num[dn[i]] += 1

for i in range(len(tn)):
    t_num[tn[i]] += 1
    
for i in range(len(t_num)):
    if d_num[i] < t_num[i]:
        print("NO")
        sys.exit()
print("YES")

Fixed submission:
import sys

n = int(input())
dn = list(map(int, input().split()))
m = int(input())
tn = list(map(int, input().split()))

num_dict = {}

for i in range(n):
    if str(dn[i]) in num_dict.keys():
        num_dict[str(dn[i])] += 1
    else:
        num_dict[str(dn[i])] = 1

for i in range(m):
    if str(tn[i]) in num_dict.keys():
        num_dict[str(tn[i])] += -1
    else:
        print("NO")
        sys.exit()

result_list = list(num_dict.values())
for i in range(len(result_list)):
    if result_list[i] < 0:
        print("NO")
        sys.exit()
print("YES")

Buggy python submission (verdict: Runtime Error):
import sys

n = int(input())
dn = list(map(int, input().split()))
m = int(input())
tn = list(map(int, input().split()))

d_num = [0 for i in range(200001)]
t_num = [0 for i in range(200001)]

for i in range(len(dn)):
    d_num[dn[i]] += 1

for i in range(len(tn)):
    t_num[tn[i]] += 1
    
for i in range(len(t_num)):
    if d_num[i] < t_num[i]:
        print("NO")
        sys.exit()
print("yes")

Fixed submission:
import sys

n = int(input())
dn = list(map(int, input().split()))
m = int(input())
tn = list(map(int, input().split()))

num_dict = {}

for i in range(n):
    if str(dn[i]) in num_dict.keys():
        num_dict[str(dn[i])] += 1
    else:
        num_dict[str(dn[i])] = 1

for i in range(m):
    if str(tn[i]) in num_dict.keys():
        num_dict[str(tn[i])] += -1
    else:
        print("NO")
        sys.exit()

result_list = list(num_dict.values())
for i in range(len(result_list)):
    if result_list[i] < 0:
        print("NO")
        sys.exit()
print("YES")
Buggy python submission (verdict: Runtime Error):
def multply(a: int, b: float) -> int:
    return int(a * b)

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

Fixed submission:
import decimal


def multply(a: str, b: str) -> int:
    return int(decimal.Decimal(a) * decimal.Decimal(b))

a, b =  input().split()
print(multply(a, b))
Buggy python submission (verdict: Time Limit Exceeded):
x  = int(input())

line  = [int(y) for y in input().split()]

yeet  = 1

for i in range(0,x):
    yeet = yeet*line[i]

if yeet > 10**18:
    print(-1)
else:
    print(yeet)


Fixed submission:
x  = int(input())

line  = [int(y) for y in input().split()]
line.sort()

yeet  = 1
solved  = False

if line[0] == 0:
    print(0)
else:
    for i in range(0,x):
        yeet = yeet*line[i]
        if yeet > 10**18:
            solved = True
            print(-1)
            break

    if solved == False:
        print(yeet)
Buggy python submission (verdict: Time Limit Exceeded):
#D

line = [int(x) for x in input().split()]
n = line[0]
x = line[1]
y = line[2]

results =[0]*(n+2)

for i in range(1, n):
    for j in range(i+1,n+1):
        yeet = min([abs(j-i), abs(x-i) + 1 + abs(j-y), abs(y-i) + 1 + abs(j-x)])
        results[yeet-1] += 1

for i in range(0, n-1):
    print(results[i])



Fixed submission:
#D

line = [int(x) for x in input().split()]
n = line[0]
x = line[1]
y = line[2]

results =[0]*(n+2)

for i in range(1, n):
    for j in range(i+1,n+1):
        results[min([abs(j-i), abs(x-i) + 1 + abs(j-y)])-1] += 1

for i in range(0, n-1):
    print(results[i])

Buggy python submission (verdict: Time Limit Exceeded):
#D

line = [int(x) for x in input().split()]
n = line[0]
x = line[1]
y = line[2]

results =[0]*(n+2)

for i in range(1, n+1):
    for j in range(i,n+1):
        yeet = min([abs(j-i), abs(x-i) + 1 + abs(j-y), abs(y-i) + 1 + abs(j-x)])
        results[yeet] = results[yeet] + 1

for i in range(1, n):
    print(results[i])



Fixed submission:
#D

line = [int(x) for x in input().split()]
n = line[0]
x = line[1]
y = line[2]

results =[0]*(n+2)

for i in range(1, n):
    for j in range(i+1,n+1):
        results[min([abs(j-i), abs(x-i) + 1 + abs(j-y)])-1] += 1

for i in range(0, n-1):
    print(results[i])

Buggy python submission (verdict: Time Limit Exceeded):
#D

line = [int(x) for x in input().split()]
n = line[0]
x = line[1]
y = line[2]

results =[0]*(n+2)

for i in range(1, n+1):
    for j in range(i,n+1):
        results[min([abs(j-i), abs(x-i) + 1 + abs(j-y), abs(y-i) + 1 + abs(j-x)])] = results[min([abs(j-i), abs(x-i) + 1 + abs(j-y)])] + 1

for i in range(1, n):
    print(results[i])



Fixed submission:
#D

line = [int(x) for x in input().split()]
n = line[0]
x = line[1]
y = line[2]

results =[0]*(n+2)

for i in range(1, n):
    for j in range(i+1,n+1):
        results[min([abs(j-i), abs(x-i) + 1 + abs(j-y)])-1] += 1

for i in range(0, n-1):
    print(results[i])
Buggy python submission (verdict: Runtime Error):
import math

l = [int(x) for x in input().split]

print(math.ceil(l[0]*l[1]))

Fixed submission:
import math
 
l = [int(x) for x in input().split()]

if l[0] == 1 or l[1] == 1:
  print(1)
else:
  print(math.ceil((l[0]*l[1])/2))
Buggy python submission (verdict: Runtime Error):
x = [int(x) for x in input().split()]

import math

print(math.ceil(x[0]/x[1])

Fixed submission:
x = [int(x) for x in input().split()]

import math

print(math.ceil(x[0]/x[1]))
Buggy python submission (verdict: Runtime Error):
defB():
    n = int(input())
    s = [list(map(str,input().split())) for i in range(n)]
    import collections
    c = collections.Counter(s)
    ret_l = ["AC","WA","TLE","RE"]
    for t in ret_l:
        print(t +  " x " + str(c[t]))
B()

Fixed submission:
def B():
    n = int(input())
    s = []
    for _ in range(n):
        s.append(input())
    import collections
    c = collections.Counter(s)
    ret_l = ["AC","WA","TLE","RE"]
    for t in ret_l:
        print(t +  " x " + str(c[t]))
B()
Buggy python submission (verdict: Time Limit Exceeded):
def B():
    n = int(input())
    a = list(map(int, input().split()))
    ret = 1
    for d in a:
        ret *= d
    if ret > pow(10, 18) :
        print(-1)
    else:
        print(ret)
B()

Fixed submission:
def B():
    n = int(input())
    a = list(map(int, input().split()))
    if 0 in a:
        print(0)
        return
    ret = 1
    for d in a:
        ret *= d
        if ret > pow(10, 18) :
            print(-1)
            return
    print(ret)
B()
Buggy python submission (verdict: Time Limit Exceeded):
n,m = list(map(int,input().split()))
h = list(map(int,input().split()))
a_list = []
b_list = []
for i in range(m):
    a,b = list(map(int,input().split()))
    a_list.append(a)
    b_list.append(b)
good_list = list(range(1,n+1))
for a,b in zip(a_list,b_list):
    if a in good_list:
        if h[a-1] < h[b-1] or h[a-1] == h[b-1]:
            good_list.remove(a)
    if b in good_list:
        if h[a-1] > h[b-1] or h[a-1] == h[b-1]:
            good_list.remove(b)
print(len(good_list))

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

not_good = []
for i in range(m):
    a,b = list(map(int,input().split()))
    if h[a-1] <= h[b-1]:
        not_good.append(a)
    if h[a-1] >= h[b-1]:
        not_good.append(b)
print(n-len(set(not_good)))

Buggy python submission (verdict: Time Limit Exceeded):
n,m = list(map(int,input().split()))
h = list(map(int,input().split()))
a_list = []
b_list = []
good_list = list(range(1,n+1))
for i in range(m):
    a,b = list(map(int,input().split()))
    a_list.append(a)
    b_list.append(b)
    if a in good_list:
        if h[a-1] < h[b-1] or h[a-1] == h[b-1]:
            good_list.remove(a)
    if b in good_list:
        if h[a-1] > h[b-1] or h[a-1] == h[b-1]:
            good_list.remove(b)
print(len(good_list))

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

not_good = []
for i in range(m):
    a,b = list(map(int,input().split()))
    if h[a-1] <= h[b-1]:
        not_good.append(a)
    if h[a-1] >= h[b-1]:
        not_good.append(b)
print(n-len(set(not_good)))
Buggy python submission (verdict: Runtime Error):
k = int(input())
a,b = list(map(int,input().slplit()))
ret = ""
q = a//k
if a <= q*k or (q+1)*k <= b:
    ret = "OK"
else:
    ret ="NG"
print(ret)

Fixed submission:
k = int(input())
a,b = list(map(int,input().split()))
ret = ""
q = a//k
if a <= q*k or (q+1)*k <= b:
    ret = "OK"
else:
    ret ="NG"
print(ret)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
for i in range(1,n+1):
    print(a.count(i))

Fixed submission:
import collections
n = int(input())
a = list(map(int, input().split()))
c = collections.Counter(a)
for i in range(1,n+1):
    print(c[i])
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce

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

k = int(input())
ans = 0
for a in range(1,k+1):
    for b in range(1,k+1):
        for c in range(1, k+1):
            ans += gcd_list([a,b,c])
print(ans)

Fixed submission:
import math
from functools import reduce
def gcd_list(numbers):
    return reduce(math.gcd, numbers)
def calc_same_num(s):
    if s[0]==s[1] and s[1]==s[2]:
        return 1
    elif s[0]==s[1] or s[1]==s[2]:
        return 3
    else:
        return 6
    
k = int(input())
sum_check = 0
a,b,c = 1,1,1
ans = 0
while a<=k and b<=k and c<=k:
    gcd = gcd_list([a,b,c])
    ans += gcd*calc_same_num([a,b,c])
    if c<k:
        c += 1
    elif b<k:
        b += 1
        c = b
    else:
        a += 1
        b = a
        c = a
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s = str(input())
q = int(input())
w = [list(map(str,input().split())) for i in range(q)]

change = False
str_list = list(s)
for data in w:
    if int(data[0]) == 1:
        change = not change
    else:
        if change:
            change = False
            str_list.reverse()
        if int(data[1]) == 1:
            str_list.insert(0, data[2])
        else:
            str_list.append(data[2])
if change:
    str_list.reverse()
print("".join(str_list))

Fixed submission:
s = list(str(input()))
q = int(input())
w = [list(map(str,input().split())) for i in range(q)]

reverse = False
front_list = []
end_list = []

for data in w:
    if int(data[0]) == 1:
        reverse = not reverse
    else:
        if (int(data[1]) == 1 and not reverse) or (int(data[1]) == 2 and reverse):
            front_list.append(data[2])
        else:
            end_list.append(data[2])
if not reverse:
    front_list.reverse()
    print("".join(front_list + s + end_list))
else:
    end_list.reverse()
    s.reverse()
    print("".join(end_list + s + front_list))

Buggy python submission (verdict: Runtime Error):
def change_fb(str_list):
    tmp = str_list[0]
    str_list[0] = str_list[-1]
    str_list[-1] = tmp

s = str(input())
q = int(input())
w = [input() for i in range(q)]

change = False
str_list = list(s)
for data in w:
    if int(data[0]) == 1:
        change = not change
    else:
        if change:
            change = False
            change_fb(str_list)
        t,f,c = data.split()
        if int(f) == 1:
            str_list.insert(0, c)
        else:
            str_list.append(c)
    print(str_list)

if change:
    change_fb(str_list)

print("".join(str_list))

Fixed submission:
s = list(str(input()))
q = int(input())
w = [list(map(str,input().split())) for i in range(q)]

reverse = False
front_list = []
end_list = []

for data in w:
    if int(data[0]) == 1:
        reverse = not reverse
    else:
        if (int(data[1]) == 1 and not reverse) or (int(data[1]) == 2 and reverse):
            front_list.append(data[2])
        else:
            end_list.append(data[2])
if not reverse:
    front_list.reverse()
    print("".join(front_list + s + end_list))
else:
    end_list.reverse()
    s.reverse()
    print("".join(end_list + s + front_list))
Buggy python submission (verdict: Runtime Error):
def B():
    n,r = list(map(int, input().split()))
    i = 1
    while True:
        if n < k**i:
            print(i)
            return
        i += 1
B()

Fixed submission:
def B():
    n,k = list(map(int, input().split()))
    i = 1
    while True:
        if n < k**i:
            print(i)
            return
        i += 1
B()
Buggy python submission (verdict: Time Limit Exceeded):
r,g,b,n = list(map(int, input().split()))
cnt = 0
i=0
while r*i <= n:
  j=0
  while (r*i+g*j) <= n:
    if ( (n-(r*i+g*j)) % b ) == 0 :
      cnt += 1
    j += 1
  i += 1
print(str(cnt))

Fixed submission:
r,g,b,n = list(map(int, input().split()))
cnt = 0
for i in range(0, n+1, r):
  if i == n:
    cnt += 1
    continue
  for j in range(0, n-i+1, g):
    if ( (n-(i+j)) % b ) == 0 :
      cnt += 1
print(str(cnt))
Buggy python submission (verdict: Runtime Error):
n = int(input())
w = [input() for i in range(N)]

if n != len(set(w)):
    print('No')
    exit()
for i in range(n-1):
    if w[i][-1] != w[i+1][0]:
        print('No')
        exit()

print('Yes')

Fixed submission:
n = int(input())
w = [input() for i in range(n)]

if n != len(set(w)):
    print('No')
    exit()
for i in range(n-1):
    if w[i][-1] != w[i+1][0]:
        print('No')
        exit()

print('Yes')

Buggy python submission (verdict: Runtime Error):
def check_words(w):
    if len(w) != len(set(w)):
        return False
    for i in range(n-1):
        if w[i][-1] != w[i+1][0]:
            return False
    return True

n = int(input())
w = list(map(str, input().split()))
if check_words(w):
    ret = 'Yes'
else:
    ret = 'No'
print(ret)

Fixed submission:
n = int(input())
w = [input() for i in range(n)]

if n != len(set(w)):
    print('No')
    exit()
for i in range(n-1):
    if w[i][-1] != w[i+1][0]:
        print('No')
        exit()

print('Yes')

Buggy python submission (verdict: Runtime Error):
def check_words(w):
    if len(w) != len(set(w)):
        return False
    for i in range(n-1):
        if w[i][-1] != w[i+1][0]:
            return False
    return True

n = int(input())
w = list(map(str, input().split()))
ret = 'Yes' if check_words(w) else 'No'
print(ret)

Fixed submission:
n = int(input())
w = [input() for i in range(n)]

if n != len(set(w)):
    print('No')
    exit()
for i in range(n-1):
    if w[i][-1] != w[i+1][0]:
        print('No')
        exit()

print('Yes')

Buggy python submission (verdict: Runtime Error):
def check_words(w):
    if len(w) != len(set(w)):
        return False
    for i in range(n-1):
        if w[i][-1] != w[i+1][0]:
            return False
    return True

n = int(input())
w = list(map(str, input().split()))
ret = 'Yes' if check_words(w) else 'No'
print(ret)

Fixed submission:
n = int(input())
w = [input() for i in range(n)]

if n != len(set(w)):
    print('No')
    exit()
for i in range(n-1):
    if w[i][-1] != w[i+1][0]:
        print('No')
        exit()

print('Yes')
Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

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

n,x = list(map(int, input().split()))
pos = list(map(int, input().split()))

pos.append(x)
pos.sort()

dist = []
for i in range(len(pos)-1):
    dist.append(pos[i+1]-pos[i])

print(gcd_list(dist))

Fixed submission:
import math
import fractions
from functools import reduce

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

n,x = list(map(int, input().split()))
pos = list(map(int, input().split()))

pos.append(x)
pos.sort()

dist = []
for i in range(len(pos)-1):
    dist.append(pos[i+1]-pos[i])

print(gcd_list(dist))