Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = int(input())
# Recursion!
def detector(str):
  # Stop the operation if the number is bigger than n.
  if int(str) > n:
    return 0
  else:
    count = 0
    # Add 7, 5, or 3 after the number. 
    # Eliminate numbers that do not consist of only 3, 5, and 7.
    for i in "753":
      count += detector(str+i)
    # Check if the number has all 3, 5, and 7.
    if "3" not in str or "5" not in str or "7" not in str:
      return count
    else:
      return count += 1
# Start from 0 and do the operation until the number exceeds n.
detector("0")

Fixed submission:
n = int(input())
# Recursion!
def detector(str):
  # Stop the operation if the number is bigger than n.
  if int(str) > n:
    return 0
  else:
    count = 0
    # Add 7, 5, or 3 after the number. 
    # Eliminate numbers that do not consist of only 3, 5, and 7.
    for i in "753":
      count += detector(str+i)
    # Check if the number has all 3, 5, and 7.
    if "3" not in str or "5" not in str or "7" not in str:
      return count
    else:
      return count + 1
# Start from 0 and do the operation until the number exceeds n.
print(detector("0"))
Buggy python submission (verdict: Runtime Error):
n = int(input())
cards = []
for i in range(n):
  cards.append(int(input()))

cards.sort(reverse = True)
a = 0
b = 0
for i in range(n):
  if i%2 == 0:
    a += cards[i]
  else:
    b += cards[i]
print(a-b)

Fixed submission:
n = int(input())

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

cards.sort(reverse = True)
a = 0
b = 0
for i in range(n):
  if i%2 == 0:
    a += cards[i]
  else:
    b += cards[i]
print(a-b)
Buggy python submission (verdict: Runtime Error):
s = str(input())

T = ["dream", "dreamer", "erase", "eraser"]

new_s =reversed(s)
new_t = []
for item in T:
  new_t.append(reversed(item))

ans_t =''
  
for c in new_s:
  collector += c
  if collector in new_t:
    ans_t += collector
    collector = ''
    
if new_s == ans_t:
  print('YES')
else:
  print('NO')

Fixed submission:
s = str(input())

T = ["dream", "dreamer", "erase", "eraser"]

new_s =s[::-1]
new_t = []
for item in T:
  new_t.append(item[::-1])

ans_t =''
collector = ''

for c in new_s:
  collector += c
  if collector in new_t:
    ans_t += collector
    collector = ''
    
if new_s == ans_t:
  print('YES')
else:
  print('NO')
Buggy python submission (verdict: Time Limit Exceeded):
st = input()
cyclePos = -1
ls1 = [1] * len(st)
ls2 = [0] * len(st)
lss = []
for i in range(len(st)):
	if st[i] == 'L':
		ls2[i-1] += ls1[i]
	else:
		ls2[i+1] += ls1[i]
lss.append(ls1)
while (True):
	ls1 = ls2
	ls2 = [0] * len(st)
	for i in range(len(st)):
		if st[i] == 'L':
			ls2[i-1] += ls1[i]
		else:
			ls2[i+1] += ls1[i]
	for i in range(len(lss)):
		if ls2 == lss[i]:
			cyclePos = i
			break
	if cyclePos != -1:
		break
	lss.append(ls2)
for i in range(cyclePos):
	lss.pop(0)
Max = 10 ** 100 - cyclePos
pos = Max % len(lss)
print(*lss[pos-1], sep = " ")


Fixed submission:
Max = 10 ** 100
st = input()
val = [0] * len(st)
ls = [0] * len(st)
pos = 0
for i in range(len(st)-1):
	if st[i] == st[i+1]:
		continue
	else:
		if st[i] == 'R':
			for j in range(pos, i):
				ls[j] = i - j
		else:
			for j in range(i, pos, -1):
				ls[j] = j - pos
		pos = i + 1
if st[i] == 'R':
	for j in range(pos, len(st)):
		ls[j] = i - j
else:
	for j in range(len(st)-1, pos, -1):
		ls[j] = j - pos
for i in range(len(st)):
	temp = (Max - ls[i]) % 2
	if temp == 1:
		ls[i] += 1
	if st[i] == 'L':
		val[i - ls[i]] += 1
	else:
		val[i + ls[i]] += 1
print(*val, sep = " ")
Buggy python submission (verdict: Runtime Error):
import bisect

n = int(input())
a = [int(input()) for _ in range(n)]
t = [a[-1]]

for i in reversed(a[:-1]):
    idx = bisect.bisect_left(t, i + 1)
    print(i, idx)
    if idx == len(t):
        t.append(i)

    else:
        t[idx] = i
    print(t)

print(len(t))

Fixed submission:
import bisect
 
n = int(input())
a = [int(input()) for _ in range(n)]
# それぞれの色の最大値を入れる筒のリスト
t = [a[-1]]
 
for i in reversed(a[:-1]):
    # それぞれの色のどの値よりも小さかったとき
    idx = bisect.bisect_left(t, i+1)
    # print(i, idx)
    if idx == len(t):
        t.append(i)
    # 効率的な色の探索
    else:
        t[idx] = i
    # print(t)
 
print(len(t))

Buggy python submission (verdict: Time Limit Exceeded):
c=int(input())
l=[int(input()) for _ in range(c)]
for i in range(len(l)):

    for j in range(len(l)):
        if i <j and l[i] < l[j]:
            c=c-1
print(abs(c))

Fixed submission:
import bisect
 
n = int(input())
a = [int(input()) for _ in range(n)]
# それぞれの色の最大値を入れる筒のリスト
t = [a[-1]]
 
for i in reversed(a[:-1]):
    # それぞれの色のどの値よりも小さかったとき
    idx = bisect.bisect_left(t, i+1)
    # print(i, idx)
    if idx == len(t):
        t.append(i)
    # 効率的な色の探索
    else:
        t[idx] = i
    # print(t)
 
print(len(t))
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
ans = a * b - a - b + 1
print(ans)

Fixed submission:
inp = input()
l = list(map(int, inp.split()))
a = l[0]
b = l[1]

ans = a * b - a - b + 1
print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
t = ""
ans = 0
for i in range(len(s)):
    t += s[i]
    #print(t)
    if i+1 = len(s) or i+1+len(t) > len(s):
        ans += 1
        t = ""
    elif s[i+1:i+1+len(t)] != t:
        ans += 1
        t = ""

print(ans)

Fixed submission:
s = input()
t = ""
ans = 0
prev = 2
i = 0
while i < len(s):
    if prev == 2:
        ans += 1
        prev = 1
        i += 1
    elif s[i-1] != s[i]:
        ans += 1
        prev = 1
        i += 1
    elif (i+1) == len(s):
        break
    else:
        ans += 1
        prev = 2
        i += 2
            

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int( input() )
da = []
ans = 0
for i in range(n):
    s = input()
    d = {}
    for item in s:
        if item in d:
            d[item] += 1
        else:
            d[item] = 1

    for d1 in da:
        if d1 == d:
            ans += 1
    
    da.append(d)


print(ans)

Fixed submission:
n = int( input() )
dd = {}
ans = 0
for i in range(n):
    s = ''.join( sorted( input() ))
    if s in dd:
        ans += dd[s]
        dd[s] += 1
    else:
        dd[s] = 1

print(ans)
Buggy python submission (verdict: Runtime Error):
n,m = map(int, input().split())

lmin = 1
rmax = n
for i in range(m):
    l, r = map(int, input().split())

    if l > lmin:
        lmin = l

    if r < rmax:
        rmax = r

if rmax	< lmin:
    print(0)
else:
    print(rmax - lmin + 1)

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

if a >= 13:
    print(b)
elif a >= 6:
    print(int(b/2))
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [input() for i in range(N)]
ans = 0
Max1 = max(A)
Max2 = sorted(set(A))[-2]
indexes = [i for i, x in enumerate(A) if x == Max1]
for i in range(N):
    ans = Max2 if len(indexes) < 2 and A[i] == Max1 else Max1
    print(ans)

Fixed submission:
N = int(input())
A = [int(input()) for i in range(N)]
ans = 0
Max1 = max(A)
indexes = [i for i, x in enumerate(A) if x == Max1]
if len(A) == len(indexes):
    for i in A:
        print(i)
else:
    Max2 = sorted(set(A))[-2]
    if len(indexes) >= 2:
        for i in range(N):
            print(Max1)
    else:
        for i in range(N):
            ans = Max2 if A[i] == Max1 else Max1
            print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [input() for i in range(N)]
ans = 0
for i in range(N):
    wk = A[:]
    wk.pop(i)
    wk.sort()
    ans = wk[-1]
    print(ans)

Fixed submission:
N = int(input())
A = [int(input()) for i in range(N)]
ans = 0
Max1 = max(A)
indexes = [i for i, x in enumerate(A) if x == Max1]
if len(A) == len(indexes):
    for i in A:
        print(i)
else:
    Max2 = sorted(set(A))[-2]
    if len(indexes) >= 2:
        for i in range(N):
            print(Max1)
    else:
        for i in range(N):
            ans = Max2 if A[i] == Max1 else Max1
            print(ans)
Buggy python submission (verdict: Runtime Error):
N, Q = map(int, raw_input().split())
tree = [set() for i in range(N)]
ans = [0 for i in range(N)]


def func(_x, _p):
    ans[_x-1] += _p
    for x in tree[_x-1]:
        func(x, _p)


for i in range(0, N-1):
    a, b = map(int, raw_input().split())
    tree[a-1].add(b)

for i in range(0, Q):
    v, p = map(int, raw_input().split())
    func(v, p)

print ' '.join(map(str, ans))


Fixed submission:
N, Q = map(int, raw_input().split())
ans = [0 for i in range(N)]
tree_s = ['' for i in range(N-1)]

for i in range(0, N-1):
    a, b = map(int, raw_input().split())
    tree_s[i] = str(a).zfill(8) + '-' + str(b)

tree_s.sort()

for i in range(0, Q):
    v, p = map(int, raw_input().split())
    ans[v-1] += p

for i in range(0, N-1):
    ab = tree_s[i].split("-")
    ans[int(ab[1])-1] += ans[int(ab[0])-1]


print ' '.join(map(str, ans))
Buggy python submission (verdict: Time Limit Exceeded):
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


N = int(input())
A = map(int, raw_input().split())
C = [0 for j in range(N)]
ANS = []

for j in range(N, 0, -1):
    m = A[j-1]
    am = C[j-1] % 2
    if m != am:
        ANS.append(j)
        div = make_divisors(j)
        for k in div:
            if k != j:
                C[k-1] += 1

print(len(ANS))
str_ANS = [str(j) for j in ANS]
print(" ".join(str_ANS))


Fixed submission:
N = int(input())
A = map(int, raw_input().split())
ANS = set()

for j in range(N, 0, -1):
    s = 0
    for k in range(j+j, N+1, j):
        if k in ANS:
            s += 1

    am = s % 2
    if A[j-1] != am:
        ANS.add(j)

print(len(ANS))
str_ANS = [str(j) for j in ANS]
print(" ".join(str_ANS))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = map(int, raw_input().split())

k = 0
g = 0

for i in range(N):
    if A[i] % 2 == 0:
        g += 1
    else:
        k += 1

if k == 0 or (k % g == 0 and k / g == 2):
    print('Yes')
else:
    print('No')

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

nums = {}

for i in range(N):
    if A[i] in nums:
        nums[A[i]] += 1
    else:
        nums[A[i]] = 1

if len(nums) == 1:
    if '0' in nums:
        print('Yes')
    else:
        print('No')
elif len(nums) == 2:
    if '0' in nums and nums['0'] * 3 == len(A):
        print('Yes')
    else:
        print('No')
elif len(nums) == 3:
    keys = [x for x in nums]
    a = keys[0]
    b = keys[1]
    c = keys[2]
    if nums[a] == nums[b] and nums[a] == nums[c] and int(a) ^ int(b) == int(c) and int(b) ^ int(c) == int(a) and int(a) ^ int(c) == int(b):
        print('Yes')
    else:
        print('No')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
N = int(raw_input())
A = map(int, raw_input().split())
ans = []
sum_all = sum(A) / 2

ic = sum_all
for i in range(1, N, 2):
    ic -= A[i]
ans.append(ic*2)

for i in range(1, N):
    ans.append(A[i-1] - ans[i])

print(' '.join(map(str, ans)))


Fixed submission:
N = int(raw_input())
A = map(int, raw_input().split())
ans = []
sum_all = sum(A) / 2

ic = sum_all
for i in range(1, N, 2):
    ic -= A[i]
ans.append(ic*2)

for i in range(0, N-1):
    ans.append((A[i] - ans[i]/2)*2)

print(' '.join(map(str, ans)))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(raw_input())
A = map(int, raw_input().split())
ans = []
sum_all = sum(A) / 2

for i in range(0, N) :
    ic = sum_all
    for j in range(i+1, N, 2):
        ic -= A[j]
    for j in range(i-2, -1, -2):
        ic -= A[j]
    ans.append(ic*2)

print(' '.join(map(str, ans)))

Fixed submission:
N = int(raw_input())
A = map(int, raw_input().split())
ans = []
sum_all = sum(A) / 2

ic = sum_all
for i in range(1, N, 2):
    ic -= A[i]
ans.append(ic*2)

for i in range(0, N-1):
    ans.append((A[i] - ans[i]/2)*2)

print(' '.join(map(str, ans)))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(raw_input())
A = map(int, raw_input().split())
ans = ''
sum_all = sum(A) / 2

for i in range(0, N) :
    ic = 0
    for j in range(i+1, N, 2):
        ic += A[j]
    for j in range(i-2, -1, -2):
        ic += A[j]
    if i == 0:
        ans = str((sum_all - ic)*2)
    else:
        ans = ans + ' ' + str((sum_all - ic)*2)

print(ans)

Fixed submission:
N = int(raw_input())
A = map(int, raw_input().split())
ans = []
sum_all = sum(A) / 2

ic = sum_all
for i in range(1, N, 2):
    ic -= A[i]
ans.append(ic*2)

for i in range(0, N-1):
    ans.append((A[i] - ans[i]/2)*2)

print(' '.join(map(str, ans)))
Buggy python submission (verdict: Runtime Error):
A, B = map(long, raw_input().split())
ans = B
for i in range(A, B):
    ans = ans ^ i

print(ans)

Fixed submission:
def xor(_x) :
    if _x % 4 == 0:
        return _x
    elif _x % 4 == 1:
        return 1
    elif _x % 4 == 2:
        return 1 ^ _x
    else:
        return 0


A, B = map(long, raw_input().split())
print(xor(A - 1) ^ xor(B))

Buggy python submission (verdict: Runtime Error):
A, B = map(long, raw_input().split())
ans = A
for i in range(A + 1, B + 1):
    ans = ans ^ i

print(ans)

Fixed submission:
def xor(_x) :
    if _x % 4 == 0:
        return _x
    elif _x % 4 == 1:
        return 1
    elif _x % 4 == 2:
        return 1 ^ _x
    else:
        return 0


A, B = map(long, raw_input().split())
print(xor(A - 1) ^ xor(B))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = {}
for i in range(n):
    s[i] = int(input())

for i in range(n):
    temp = s[i]
    s.pop(i)
    max_v = max(s.values())
    print(max_v)
    s[i]=temp

Fixed submission:
n = int(input())
s = {}
for i in range(n):
    s[i] = int(input())

max_v = max(s.values())
max_k = max(s,key=s.get)
s.pop(max_k)
max_v2 = max(s.values())
max_k2 = max(s,key=s.get)

for i in range(n):
    if(i==max_k):
        print(max_v2)
    else:
        print(max_v)

"""
for i in range(n):
    temp = s[i]
    s.pop(i)
    max_v = max(s.values())
    print(max_v)
    s[i]=temp
"""
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
m = 0
cnt = 0
b = [0]*n

for i in range(n-1,-1,-1):
    if(i>=n/2):
        b[i]=a[i]
    else:
        for j in range(1,n):
            if(j*i>n):
                break
            else:
                cnt += b[i*j]%2
        if(cnt==a[i]):
            b[i]=0
        elif(cnt!=a[i]):
            b[i]=1

for i in range(n):
    m += b[i]
print(m)
for k in range(n):
    if(b[k]==1):
        print(k+1,end=" ")


                
                
    
                
            
            
    

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
a.insert(0,0)
b = [0]*(n+1)
cnt = 0
for i in range(n,0,-1):
    #print(i)
    for j in range(1,n+1):
        #print(j)
        if(i*j>n):
            break
        else:
            cnt += b[i*j]
    if((cnt%2==0 and a[i]==0) or (cnt%2==1 and a[i]==1)):
        b[i] = 0
    elif((cnt%2==0 and a[i]==1) or (cnt%2==1 and a[i]==0)):
        b[i] = 1
    else:
        b[i]=a[i]
    cnt = 0

m = sum(b)
print(m)
for k in range(1,n+1):
    if(b[k]==1):
        print(k,end=' ')
#print('')
# print(a)
#print(b)
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
mod = 10**9+7

def kai(a):
    ans = 1
    for i in range(1,a+1):
        ans *= i
    return ans
    
for i in range(1,k+1):
    if(n-k+1<i):
        print(0)
        continue
    kusan=(kai(n-k+1))//kai(i)//kwai(n-k-i+1)%mod
    haibun=(kai(k-1)//kai(k-i)//kai(i-1))%mod
    print((kusan*haibun)%mod)
    

Fixed submission:
n,k = map(int,input().split())
mod = 10**9+7

def kai(a):
    ans = 1
    for i in range(1,a+1):
        ans *= i
    return ans
    
for i in range(1,k+1):
    if(n-k+1<i):
        print(0)
        continue
    kusan=(kai(n-k+1))//kai(i)//kai(n-k-i+1)%mod
    haibun=(kai(k-1)//kai(k-i)//kai(i-1))%mod
    print((kusan*haibun)%mod)
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
s = input()
c = list(s)
c[k] = c[k].lower()

for i in c:
    print(i,end='')


Fixed submission:
n,k = map(int,input().split())
s = input()
c = list(s)
c[k-1] = c[k-1].lower()

for i in c:
    print(i,end='')
Buggy python submission (verdict: Runtime Error):
import numpy as np

A,S= map(str,input().split())
A = int(A)

if(A>=3200):
    print(S)
else:
    print("red")


Fixed submission:
import numpy as np

A = input()
A = int(A)
S = input()
S = str(S)

if(A>=3200):
    print(S)
else:
    print("red")
Buggy python submission (verdict: Runtime Error):
import pandas as pd
import numpy as np

N = input()
N = int(N)
a_np = np.ones((N,1))
a_pd = pd.DataFrame(a_np,columns=['A'])
a_pd['B']=None
a_pd['C']=None
for i in range(0,N):
    S, P = map(str, input().split())
    P = int(P)
    a_pd.loc[i,:] = [i,S,P]
    #print(i,S,P)
b_pd = a_pd.sort_values(['B','C'],ascending=[True, False])
b_pd = b_pd.reset_index()
print(b_pd)
c = b_pd.loc[:,'A']
for j in range(0,N):
    print(int(c[j]+1))
    

Fixed submission:
import numpy as np

N = input()
N = int(N)
a = []
for i in range(0,N):
    S, P = map(str,input().split())
    P = int(P)
    a.append([i,S,P])

b = sorted(a, key=lambda x:(x[1],-x[2]))
for j in range(0,N):
    print(b[j][0]+1)
Buggy python submission (verdict: Runtime Error):
a, b, k = map(int, input().split())

ans = []

for i in range(1, max(a, b)):
 	if a % i == 0 and b % i == 0:
		ans.append(i)

print(ans[-k])




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

ans = []

for i in range(1, max(a, b) + 1):
	if a % i == 0 and b % i == 0:
		ans.append(i)

print(ans[-k])

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

ans = []

for i in range(1, max(a, b) + 1):
  if a % i == 0 and b % i == 0:
    ans.append(i)

    print(ans[-k])




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

ans = []

for i in range(1, max(a, b) + 1):
	if a % i == 0 and b % i == 0:
		ans.append(i)

print(ans[-k])

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

ans = []

for i in range(1, max(a, b) + 1):
  if a % i == 0 and b % i == 0:
    ans.append(i)

    print(ans[k-1])


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

ans = []

for i in range(1, max(a, b) + 1):
	if a % i == 0 and b % i == 0:
		ans.append(i)

print(ans[-k])
Buggy python submission (verdict: Runtime Error):
a = map(int, input().split())
X, Y = a[0], a[1]
print(X + int(Y / 2))

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

print(X + Y // 2)

Buggy python submission (verdict: Runtime Error):
a = map(int, input().split())
X, Y = a[0], a[1]
print(X + int(Y // 2))

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

print(X + Y // 2)

Buggy python submission (verdict: Runtime Error):
a = map(int, input().split())
X, Y = a[0], a[1]
print(X + Y // 2)

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

print(X + Y // 2)

Buggy python submission (verdict: Runtime Error):
X, Y = input().split()

print(X + Y // 2)

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

print(X + Y // 2)

Buggy python submission (verdict: Runtime Error):
print(int(input()) + int(input()) // 2)

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

print(X + Y // 2)

Buggy python submission (verdict: Runtime Error):
print(int(input()) + int(input() / 2))

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

print(X + Y // 2)
Buggy python submission (verdict: Runtime Error):
import collections

n, T = map(int, input().split())

input_dict = collections.OrderedDict()

for _ in range(n):
    a, b = list(map(int, input().split()))
    input_dict[a] = b

t = min([value for key, value in input_dict.items() if key <= T])

ans = [i for i, x in enumerate(input_dict.values()) if x == t]

if ans is []:
    print('TLE')

else:
    print(list(input_dict.keys()).index(ans))

Fixed submission:
def abc112_b():
    n, limit_time = map(int, input().split())
    ans = 10000

    for _ in range(n):
        cost, time = map(int, input().split())

        if time <= limit_time and ans > cost:
            ans = cost

    return ans if ans != 10000 else "TLE"


if __name__ == '__main__':
    print(abc112_b())
Buggy python submission (verdict: Runtime Error):
x = str(input())

while True:
  if x[0] == x[1] == x[2]:
    print(x)
    break
  
  x += 1

Fixed submission:
x = str(input())

while True:
    if x[0] == x[1] == x[2]:
        print(x)
        break

    x = str(int(x) + 1)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import collections


N = int(input())

i = 0
W = []
while i < N:
    W.append(str(input()))
    i += 1

for i in range(len(W)):
    if W[i][-1] != W[i+1][0]:
        print('No')
        break

c = collections.Counter(W)

if c.values() in range(2, N+1):
    print('No')

else:
    print('Yes')

Fixed submission:
def abc112_b():
    n, limit_time = map(int, input().split())
    ans = 1001

    for _ in range(n):
        cost, time = map(int, input().split())

        if time <= limit_time and ans > cost:
            ans = cost

    return ans if ans != 1001 else "TLE"


def abc109_b():
    length = int(input())
    word_list = []

    for _ in range(length):
        word_list.append(input())

    for i in range(len(word_list) - 1):

        if word_list.count(word_list[i]) >= 2 or word_list[i][-1] != word_list[i+1][0]:
            return "No"

    return "Yes"


if __name__ == '__main__':
    print(abc109_b())

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import collections


N = int(input())

i = 0
W = []
while i < N:
    W.append(str(input()))
    i += 1

for i in range(len(W)):
    if W[i][0] != W[i+1][-1]:
        print('No')
        break

c = collections.Counter(W)

if c.values() in range(2, N+1):
    print('No')

else:
    print('Yes')

Fixed submission:
def abc112_b():
    n, limit_time = map(int, input().split())
    ans = 1001

    for _ in range(n):
        cost, time = map(int, input().split())

        if time <= limit_time and ans > cost:
            ans = cost

    return ans if ans != 1001 else "TLE"


def abc109_b():
    length = int(input())
    word_list = []

    for _ in range(length):
        word_list.append(input())

    for i in range(len(word_list) - 1):

        if word_list.count(word_list[i]) >= 2 or word_list[i][-1] != word_list[i+1][0]:
            return "No"

    return "Yes"


if __name__ == '__main__':
    print(abc109_b())
Buggy python submission (verdict: Runtime Error):
s = str(input())

ans = 'AC'
cnt = 0

if s[0] != 'A':
    ans = 'WA'

for i in range(1, len(s) + 1):
    if s[i].isupper():
        if i == 1 or i == len(s) - 1 or s[i] != 'C':
            ans = 'WA'
else:
    cnt += 1

if cnt != 1:
    ans = 'WA'

print(ans)

Fixed submission:
s = str(input())

ans = 'AC'

if s[0] != 'A':
    ans = 'WA'

for i in range(1, len(s)):
    if s[i].isupper():
        if i == 1 or i == len(s) - 1 or s[i] != 'C':
            ans = 'WA'

if s.count('C') != 1:
    ans = 'WA'

print(ans)

Buggy python submission (verdict: Runtime Error):
 = str(input())
s1 = ''

if len(s) == 4:
    df = len(s)
else:
    df = len(s) - 1
    s1 += s[df:]

flag = False

if s.count('C') == 1:
    for i in range(1, df):
        if s[i] == 'C' and i <= 2:
            flag = True
        else:
            s1 += s[i]
else:
    flag = False

if s1.islower() and len(s) >= 1:
    flag = True
else:
    flag = False

print(s1)

if flag and s[0] == 'A':
    print('AC')
else:
    print('WA')


Fixed submission:
s = str(input())

ans = 'AC'

if s[0] != 'A':
    ans = 'WA'

for i in range(1, len(s)):
    if s[i].isupper():
        if i == 1 or i == len(s) - 1 or s[i] != 'C':
            ans = 'WA'

if s.count('C') != 1:
    ans = 'WA'

print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())

A = [i for i in input().split()]

print(max(A) - min(A))

Fixed submission:
N = int(input())

A = [int(i) for i in input().split()]

print(max(A) - min(A))