Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N , M = map(int,input().split())
 
H = list(map(int,input().split()))
 
A = [0]*M
B = [0]*M
for i in range(M):
  A[i] ,B[i] = map(int,input().split())
 

S=[1]*N

 
for m in range(M)
  if H[A[m]-1] == H[B[m]-1]:
    S[A[m]-1] = 0
    S[B[m]-1] = 0
  elif H[A[m]-1] <= H[B[m]-1]:
    S[A[m]-1] = 0
  elif H[A[m]-1] >= H[B[m]-1]
    S[B[m]-1] = 0

 
print(sum(S))   

Fixed submission:
N , M = map(int,input().split())
 
H = list(map(int,input().split()))
 
A = [0]*M
B = [0]*M
for i in range(M):
  A[i] ,B[i] = map(int,input().split())
 
 
S=[1]*N
 
 
for m in range(M):
  if H[A[m]-1] == H[B[m]-1]:
    S[A[m]-1] = 0
    S[B[m]-1] = 0
  elif H[A[m]-1] <= H[B[m]-1]:
    S[A[m]-1] = 0
  elif H[A[m]-1] >= H[B[m]-1]:
    S[B[m]-1] = 0
 
 
print(sum(S))

Buggy python submission (verdict: Time Limit Exceeded):
N , M = map(int,input().split())
 
H = list(map(int,input().split()))
 
A = [0]*M
B = [0]*M
for i in range(M):
  A[i] ,B[i] = map(int,input().split())
 
 
count = 0
 
for i in range(1,N+1):
  flag = 0
  for m in range(M):
    if i == A[m] and H[i-1]<= H[B[m]-1]:

      flag = 1
      continue
    elif i == B[m] and H[i-1]<=H[A[m]-1]:

      flag = 1
      continue
  if flag:
    continue
  if not flag:

    count += 1
 

print(count)   

Fixed submission:
N , M = map(int,input().split())
 
H = list(map(int,input().split()))
 
A = [0]*M
B = [0]*M
for i in range(M):
  A[i] ,B[i] = map(int,input().split())
 
 
S=[1]*N
 
 
for m in range(M):
  if H[A[m]-1] == H[B[m]-1]:
    S[A[m]-1] = 0
    S[B[m]-1] = 0
  elif H[A[m]-1] <= H[B[m]-1]:
    S[A[m]-1] = 0
  elif H[A[m]-1] >= H[B[m]-1]:
    S[B[m]-1] = 0
 
 
print(sum(S))

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

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

A = [0]*M
B = [0]*M
for i in range(M):
  A[i] ,B[i] = map(int,input().split())


count = 0

for i in range(1,N+1):
  flag = 0
  for m in range(M):
    if i == A[m] and H[i-1]<= H[B[m]-1]:
      print('a'+A[i]+','+B[i])
      print(H[i-1]+','+H[B[m]-1])
      flag = 1
      continue
    elif i == B[m] and H[i-1]<=H[A[m]-1]:
      print('b'+A[i]+','+B[i])
      print(H[i-1]+','+H[B[m]-1])
      flag = 1
      continue
     
  if not flag:
    print(i)
    count += 1

print(count)                              
                         

Fixed submission:
N , M = map(int,input().split())
 
H = list(map(int,input().split()))
 
A = [0]*M
B = [0]*M
for i in range(M):
  A[i] ,B[i] = map(int,input().split())
 
 
S=[1]*N
 
 
for m in range(M):
  if H[A[m]-1] == H[B[m]-1]:
    S[A[m]-1] = 0
    S[B[m]-1] = 0
  elif H[A[m]-1] <= H[B[m]-1]:
    S[A[m]-1] = 0
  elif H[A[m]-1] >= H[B[m]-1]:
    S[B[m]-1] = 0
 
 
print(sum(S))
Buggy python submission (verdict: Time Limit Exceeded):
import collections
N = int(input())
A = list(map(int,input().split()))


for i in range(N):
  a = A.copy()
  a[i] = 0
  c = collections.Counter(a)
  c = c.items()


  ans = 0
  for m,n in c:
    
    ans += n*(n-1)/2
  print(int(ans))



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

c = collections.Counter(A)
cc = c.items()

f_ans = 0
for m,n in cc:
  f_ans += n*(n-1)/2

for i in range(N):
  a = A[i]
  b = c[a]
  sa = b*(b-1)/2 - (b-1)*(b-2)/2

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

_ans = [str(arr_ans[i]) for i in range(N+1)]
ans = ''.join(_ans[1:])
print(ans)
  

Fixed submission:
N, M  = map(int,input().split())
s = [-1]*M
c = [-1]*M
for i in range(M):
  s[i],c[i] = map(int,input().split())
if N==1 and M==0:
  print(0)
  exit()
if N==1 and s[0]==1 and c[0]==0:
  print(0)
  exit()
arr_ans = [-1]*(N+1)
for i in range(M):
  if arr_ans[s[i]] == -1 or arr_ans[s[i]] == c[i]:
    arr_ans[s[i]] = c[i]
  else:
    print(-1)
    exit()
    
if arr_ans[1] == 0:
  print(-1)
  exit()
for i in range(1,N+1):
  if arr_ans[i] == -1:
    if i == 1:
      arr_ans[i] = 1
    else:
      arr_ans[i] = 0

_ans = [str(arr_ans[i]) for i in range(N+1)]
ans = ''.join(_ans[1:])
print(ans)
Buggy python submission (verdict: Runtime Error):
X = int(input()) 

while(1):
  for i in range(2,X):
    if X%i == 0:
      X += 1
      break
  if i == X-1:
      break

print(X)

Fixed submission:
X = int(input()) 

while(1):
  if X == 2:
    break
  for i in range(2,X):
    if X%i == 0:
      X += 1
      break
  if i == X-1:
      break

print(X)

Buggy python submission (verdict: Runtime Error):
X = input()

while(1):
  for i in range(2,X):
    if X%i == 0:
      X += 1
      break
    if i == X-1:
      break

print(X)

Fixed submission:
X = int(input()) 

while(1):
  if X == 2:
    break
  for i in range(2,X):
    if X%i == 0:
      X += 1
      break
  if i == X-1:
      break

print(X)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))

A.insert(0,0)
A.append(0)
_A = []

for i in range(1,N+1):
  _A.append(abs(A[i] - A[i-1]))
_A.append(abs(0-A[N]))
S = sum(_A)


for i in range(0,N):
  allS = sum(_A)
  allS -= (_A[i]+_A[i+1]-abs(A[i+2]-A[i]))
  print(allS)

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

A.insert(0,0)
A.append(0)
_A = []

for i in range(1,N+1):
  _A.append(abs(A[i] - A[i-1]))
_A.append(abs(0-A[N]))
S = sum(_A)


for i in range(0,N):
  allS = S
  allS -= (_A[i]+_A[i+1]-abs(A[i+2]-A[i]))
  print(allS)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))

A.insert(0,0)
A.append(0)
_A = []
for i in range(1,N+1):
  _A.append(abs(A[i] - A[i-1]))
_A.append(abs(0-A[N]))
allS = sum(_A)


for i in range(0,N):
  allS = sum(_A)
  allS -= (_A[i]+_A[i+1])
  allS += abs(A[i+2]-A[i])
  print(allS)

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

A.insert(0,0)
A.append(0)
_A = []

for i in range(1,N+1):
  _A.append(abs(A[i] - A[i-1]))
_A.append(abs(0-A[N]))
S = sum(_A)


for i in range(0,N):
  allS = S
  allS -= (_A[i]+_A[i+1]-abs(A[i+2]-A[i]))
  print(allS)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))

A.insert(0,0)
A.append(0)
_A = []
for i in range(1,N+1):
  _A.append(abs(A[i] - A[i-1]))
_A.append(abs(0-A[N]))
allS = sum(_A)


for i in range(0,N):
  allS = sum(_A)
  allS -= _A[i]
  allS -= _A[i+1]
  allS += abs(A[i+2]-A[i])
  print(allS)

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

A.insert(0,0)
A.append(0)
_A = []

for i in range(1,N+1):
  _A.append(abs(A[i] - A[i-1]))
_A.append(abs(0-A[N]))
S = sum(_A)


for i in range(0,N):
  allS = S
  allS -= (_A[i]+_A[i+1]-abs(A[i+2]-A[i]))
  print(allS)
Buggy python submission (verdict: Runtime Error):
sus = 0

for i in a:
    su = su - i
    sus = sus + i * su

"""comb = len(a) * (len(a) - 1) / 2
comb = int(comb)

sum = 0
la = len(a)

for i in range(comb):
    #print(a)
    for j in range(1, la):
        #print(a[i])
        sum = sum + a[0] * a[i]
    a = a[1:]
    la = la - 1
    #print(a)"""

print(sus % (10**9 + 7))

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

su = sum(a)
sus = 0

for i in a:
    su = su - i
    sus = sus + i * su

print(sus % (10**9 + 7))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

comb = len(a) * (len(a) - 1) / 2
comb = int(comb)

sum = 0

for i in range(comb):
    #print(a)
    for i in range(1, len(a)):
        #print(a[i])
        sum = sum + a[0] * a[i]
    a = a[1:]
    #print(a)

print(sum % (10**9 + 7))

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

su = sum(a)
sus = 0

for i in a:
    su = su - i
    sus = sus + i * su

print(sus % (10**9 + 7))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

comb = len(a) * (len(a) - 1) / 2
comb = int(comb)

sum = 0

for i in range(comb):
    #print(a)
    for i in range(1, len(a)):
        #print(a[i])
        sum = sum + a[0] * a[i]
    a = a[1:]
    #print(a)

print(sum % (10**9 + 7))

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

su = sum(a)
sus = 0

for i in a:
    su = su - i
    sus = sus + i * su

print(sus % (10**9 + 7))
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
scs = list(map(int, input().split()))
#print(scs)
#res = []
re = 1
pre = 0

for i in range(n - k + 1):
    for j in range(k):
        re = re * scs[i + j]
    if pre < re and i != 0:
        print("Yes")
    elif i != 0:
        print("No")
    pre = re
    re = 1

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

for i in range(k, n):
    if  scs[i] > scs[i - k]:
        print("Yes")
    else:
        print("No")

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
scs = list(map(int, input().split()))
#print(scs)

res = []
re = 1
pre = 0

for i in range(n - k + 1):
    for j in range(k):
        re = re * scs[i + j]
   
    if i > 0:
        if pre < re:
            print("Yes")
        else:
            print("No")
    pre = re
    re = 1

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

for i in range(k, n):
    if  scs[i] > scs[i - k]:
        print("Yes")
    else:
        print("No")

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
scs = list(map(int, input().split()))
#print(scs)

res = []
re = 1

for i in range(n - k + 1):
    #print(i)
    for j in range(k):
        #print(i + j)
        re = re * scs[i + j]
    res.append(re)
    re = 1

#print(res)

prev = res[0]

for i in range(1, n - k + 1):
    if res[i - 1] < res [i]:
        print("Yes")
    else:
        print("No")


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

for i in range(k, n):
    if  scs[i] > scs[i - k]:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
def = input(N)
while N<1000:
    N -= 1000
return N

Fixed submission:
N = int(input())
charge = 1000 -N % 1000
if charge == 1000:
    print(charge-1000)
else:
    print(charge)
Buggy python submission (verdict: Runtime Error):
a = input()
　 print('A' if a.islower() else 'a')

Fixed submission:
alpha = input()
if alpha.islower():
    print('a')
else:
    print('A')

Buggy python submission (verdict: Runtime Error):
a = input()
2 print('A' if a.islower() else 'a')

Fixed submission:
alpha = input()
if alpha.islower():
    print('a')
else:
    print('A')
Buggy python submission (verdict: Runtime Error):
X = list(map(int, input().split()))
if X[0] == 0:
  print(1)
elif X[1] == 0:
  print(2)
elif X[2] == 0:
  print(3)
elif X[3] == 0:
  print(4)
 else:
  print(5)

Fixed submission:
X = list(map(int, input().split()))
if X[0] == 0:
    print(1)
elif X[1] == 0:
    print(2)
elif X[2] == 0:
    print(3)
elif X[3] == 0:
    print(4)
else:
    print(5)
Buggy python submission (verdict: Runtime Error):
S = input()
x = 0
if S == 'RSR':
    print(1)
else:
    for i in S:
        if i == 'R':
            x += 1
    print(a)

Fixed submission:
S = input()
x = 0
if S == 'RSR':
    print(1)
else:
    for i in S:
        if i == 'R':
            x += 1
    print(x)

Buggy python submission (verdict: Runtime Error):
str = input()
if str == "RRR":
    print(3)
elif str == "SSS":
    print(0)
elif str == "RRS":
    print(2)
elif str == "SRS":
    print(1)
elif str == "SRR":
    print(2)
elif str == "RSR":
    print(1)
elif str == "RSS":
    print(1)
elif str == "SSR":
    print(1)
`

Fixed submission:
S = input()
x = 0
if S == 'RSR':
    print(1)
else:
    for i in S:
        if i == 'R':
            x += 1
    print(x)
Buggy python submission (verdict: Runtime Error):
x,k,d = map(int, input.split())
x = abs(x)
kd = k*d

if kd<=x:
    print(x-kd)
else:
    count = x // d
    k_dash = k - count
    x -= count * d
    if k_dash % 2 == 0:
        print(x)
    else:
        print(d-x)    


Fixed submission:
from itertools import combinations
n = int(input())
l = list(map(int, input().split()))
comb = list(combinations(range(n), 3))
ans = 0
for i,j,k in comb:
    a = l[i]
    b = l[j]
    c = l[k]

    if a == b:
        continue
    if b == c:
        continue
    if c == a:
        continue
    if sum([a,b,c]) <= 2 * max(a,b,c):
        continue
    ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
k = int(input())
x = 7 % k
for i in range(1, k+1):
    if x == 0:
        print(i)
        exit()
    x = (x*10+7)%k
print(-1)


Fixed submission:
x,k,d = map(int, input().split())
x = abs(x)
kd = k*d

if kd<=x:
    print(x-kd)
else:
    count = x // d
    k_dash = k - count
    x -= count * d
    if k_dash % 2 == 0:
        print(x)
    else:
        print(d-x)

Buggy python submission (verdict: Runtime Error):
k = int(input())
x = 7 % k
for i in range(1, k+1):
    if x == 0:
        print(i)
    x = (x*10+7)%k
print(-1)


Fixed submission:
x,k,d = map(int, input().split())
x = abs(x)
kd = k*d

if kd<=x:
    print(x-kd)
else:
    count = x // d
    k_dash = k - count
    x -= count * d
    if k_dash % 2 == 0:
        print(x)
    else:
        print(d-x)
Buggy python submission (verdict: Runtime Error):
  n = int(input())
    n %= 1000

    if n == 0:
        print(0)
    else:
        print(1000 - n)


Fixed submission:
import math
n = int(input())
mod = n/1000
res = (math.ceil(mod)*1000) - n
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
i = 0
ans = 0
if 0 in a:
    print(0)
else:
    while ans<10**10 and i<len(a):
        ans*=a[i]
    if (ans<=10**18):
        print(ans)
    else:
        print(-1)


Fixed submission:
i = 0
ans = 1
n = int(input())
a = list(map(int, input().split()))
if 0 in a:
    print(0)
else:
    while ans<10**18 and i<len(a):
        ans*=a[i]
        i+=1
    if (ans<=10**18):
        print(ans)
    else:
        print(-1)
Buggy python submission (verdict: Runtime Error):
n=int(input())
count=0
while n>0:
  count=count+1
  n=n//10
if n=2 or n=4 or n=5 or n=7 or n=9:
  print ("hon")
if n=0 or n=1 or n=6 or n=8:
  print ("pon")
else:
  print("bon")
  

Fixed submission:
n = int(input())
l = int(repr(n)[-1])
if l ==2 or l==4 or l==5 or l==7 or l==9:
    print('hon')
if l==0 or l==1 or l==6 or l==8:
    print('pon')
if l ==3:
    print('bon')

Buggy python submission (verdict: Runtime Error):
n=int(input())
count=0
while n>0:
  count=count+1
  n=n//10
if n=2 or n=4 or n=5 or n=7 or n=9:
  print ("hon")
if n=0 or n=1 or n=6 or n=8:
  print ("pon")
if n=3:
  print("bon")
  

Fixed submission:
n = int(input())
l = int(repr(n)[-1])
if l ==2 or l==4 or l==5 or l==7 or l==9:
    print('hon')
if l==0 or l==1 or l==6 or l==8:
    print('pon')
if l ==3:
    print('bon')
Buggy python submission (verdict: Runtime Error):
K = int(input())
S = input()
if len(S) > K:
    print(s[:k]+'...')
else:
    print(S)

Fixed submission:
K = int(input())
S = input()
if len(S) > K:
    print(S[:K]+'...')
else:
    print(S)
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
D = int(input())
while (A>0 and C>0):
    C = C - B
    if C <= 0:
        break
    A = A - D
print("Yes" if C<=0 else "NO")

Fixed submission:
S,W = map(int,input().split())
if(S<=W):
    print('unsafe')
else:
    print('safe')
Buggy python submission (verdict: Runtime Error):
A = map(int, input().split())
while (A>0 and C>0):
    C = C - B
    if C <= 0:
        break
    A = A - D
print("Yes" if C<=0 else "NO")

Fixed submission:
A, B, C, D = map(int, input().split())
while (A>0 and C > 0):
    C = C - B
    if C <= 0:
        break
    A = A - D
print("Yes" if C<=0 else "No")

Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
D = int(input())
while (A>0 and C>0):
    C = C - B
    if C <= 0:
        break
    A = A - D
print("Yes" if C<=0 else "NO")

Fixed submission:
A, B, C, D = map(int, input().split())
while (A>0 and C > 0):
    C = C - B
    if C <= 0:
        break
    A = A - D
print("Yes" if C<=0 else "No")

Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
D = int(input())
while (A>0 and C>0):
    C = C - B
    if C <= 0:
        break
    A = A - D
print("Yes" if C<=0 else "NO")

Fixed submission:
A, B, C, D = map(int, input().split())
while (A>0 and C > 0):
    C = C - B
    if C <= 0:
        break
    A = A - D
print("Yes" if C<=0 else "No")
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
if a == b and a !=c:
    print("Yes")
elif a == c and a !=b:
    print("Yes")
else:
    print("No")


Fixed submission:
A = map(int,input().split())
if len(set(A)) == 2:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
if a == b and a !=c:
    print("Yes")
elif a == c and a !=b:
    print("Yes")
else:
    print("No")


Fixed submission:
A = map(int,input().split())
if len(set(A)) == 2:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
if a == b and a !=c:
    print("Yes")
elif a == c and a !=b:
    print("Yes")
else:
    print("No")


Fixed submission:
A = map(int,input().split())
if len(set(A)) == 2:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
if a == b and a !=c:
    print("Yes")
elif a == c and a !=b:
    print("Yes")
else:
    print("No")


Fixed submission:
A = map(int,input().split())
if len(set(A)) == 2:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
S, T = input().split()
A, B = map(int, input().split())
U = input()
if U == S:    A -= 1
else: B -= 1
print(A,B)

Fixed submission:
S, a = input(), ""
for x in range(len(S)):
    a += "x"
print(a)

Buggy python submission (verdict: Runtime Error):
S, T = input().split()
A, B = map(int, input().split())
U = input()
if U == S:    A -= 1
else: B -= 1
print(A, B)

Fixed submission:
S, a = input(), ""
for x in range(len(S)):
    a += "x"
print(a)
Buggy python submission (verdict: Runtime Error):
H, A = [int(x) for x in input().split()]
print(math.ceil(H/A))

Fixed submission:
import math
H, A = [int(x) for x in input().split()]
print(math.ceil(H/A))
Buggy python submission (verdict: Runtime Error):
s = input()
if s[s.length-1] == 's':
    print(s+'es')
else:
    print(s+'s')



Fixed submission:
s = input()
if s[len(s)-1] == 's':
    print(s+'es')
else:
    print(s+'s')
Buggy python submission (verdict: Runtime Error):
str = input()

list = str.split()

odd=["R","U","D"]
even=["L","U","D"]

i = 1
flag = False
for l in list:
    if i % 2 == 0:
        if l in even:
            pass
        else:
            flag = True
            break
    else:
        if l in odd:
            pass
        else:
            flag = True
            break
if(flag):
    print(No)
else:
    print(Yes)

Fixed submission:
str = input()

list = list(str)

i = 0
f = True
for l in list:
    i+=1
    if i%2 != 0:
        if l == "L":
            f=False
            break
    else:
        if l == "R":
            f=False
            break

if(f):
    print("Yes",end="\n")
else:
    print("No",end="\n")

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

list = str.split()

odd=["R","U","D"]
even=["L","U","D"]

i = 1
flag = False
for l in list:
    if i % 2 == 0:
        if l in even:
            pass
        else:
            flag = True
            break
    else:
        if l in odd:
            pass
        else:
            flag = True
            break
if(flag):
    print(No)
else:
    print(Yes)

Fixed submission:
str = input()

list = list(str)

i = 0
f = True
for l in list:
    i+=1
    if i%2 != 0:
        if l == "L":
            f=False
            break
    else:
        if l == "R":
            f=False
            break

if(f):
    print("Yes",end="\n")
else:
    print("No",end="\n")
Buggy python submission (verdict: Time Limit Exceeded):
A, B, M = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
data = [list(map(int, input().split())) for _ in range(M)]

MIN = a[0] + b[0]

for i in range(A):
    for j in range(B):
        
        for k in data:
            if k[0]-1 == i and k[1]-1 == j:
                MIN = min(a[i]+b[j]-k[2], MIN)

        MIN = min(a[i]+b[j], MIN) 

print(MIN)

Fixed submission:
A, B, M = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
data = [list(map(int, input().split())) for _ in range(M)]

aMIN = min(a)
bMIN = min(b)

MIN = aMIN + bMIN

for k in data:
    MIN = min(MIN, a[k[0]-1]+b[k[1]-1]-k[2])


print(MIN)
Buggy python submission (verdict: Runtime Error):
S = input()

if S = "SUN":
    print(7)

elif S = "MON":
    print(6)

elif S = "TUE":
    print(5)

elif S = "WED":
    print(4)

elif S = "THU":
    print(3)

elif S = "FRI":
    print(2)

elif S = "SAT":
    print(1)

Fixed submission:
S = input()

if S == "SUN":
    print(7)

elif S == "MON":
    print(6)

elif S == "TUE":
    print(5)

elif S == "WED":
    print(4)

elif S == "THU":
    print(3)

elif S == "FRI":
    print(2)

elif S == "SAT":
    print(1)
Buggy python submission (verdict: Runtime Error):
print("前提条件を入力して下さい")
D = int(input("高橋くんの家から待ち合わせ場所までの距離D[m]を入力して下さい"))
T = int(input("待ち合わせの時刻までの時間[min]を入力した下さい"))
S = int(input("高橋くんの移動する速さ[m/min]を入力して下さい"))
# input_data = [D, T, S]
# print(input_data)
if (D / S <= T):
    print("Yes")
else:
    print("No")

Fixed submission:
input_data = list(map(int, input().strip().split()))
if (input_data[0] / input_data[2] <= input_data[1]):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
MOD = 998244353
N, K = map(int, input().split())
table = [False] * N
path = [0] * N

for i in range(K):
  l, r = map(int, input().split())
  for j in range(l-1, r):
    table[j] = True

path[0] = 1
for i in range(1, N):
  total = 0
  for j in range(i):
    if table[i-j-1]:
      total = (total + path[j]) % MOD
  path[i] = total

print(path[N-1])

Fixed submission:
MOD = 998244353
N, K = map(int, input().split())
kukan = [None] * K
sums = [0] * (N+2)
path = [0] * (N+1)

for i in range(K):
  l, r = map(int, input().split())
  kukan[i] = [l, r]


path[1] = 1
sums[0] = 0
sums[1] = 1
for i in range(2, N+1):
  total = 0
  for j in range(K):
    l, r = kukan[j]
    if l >= i:
      continue
    if r >= i:
      r = i-1
    total = (total + sums[i - l] - sums[i - r - 1] + MOD) % MOD
  path[i] = total
  sums[i] = (sums[i-1] + total) % MOD

print(path[N])
Buggy python submission (verdict: Runtime Error):
a = int(input())
if(a > = 30):
  print("Yes")
else:
  print("No")

Fixed submission:
a = int(input())
if(a >= 30):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

A.sort(reverse=True)

happiness = A.pop(0)
tree = []
tree.append(A.pop(0))

index = 0
while(len(A)>0):
  happiness += tree[index]
  tree.append(A.pop(0))
  if(len(A)==0):
    break
  happiness += tree[index]
  tree.append(A.pop(0))
  index += 1

print(happiness)




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

A.sort(reverse=True)

happiness = A.pop(0)
tree = [0] * N
tree[0] = A[0]

index = 0
appendIndex = 1
while(len(A)>appendIndex):
  happiness += tree[index]
  tree[appendIndex] = A[appendIndex]
  appendIndex += 1
  if(len(A)==appendIndex):
    break
  happiness += tree[index]
  tree[appendIndex] = A[appendIndex]
  appendIndex += 1
  index += 1

print(happiness)