Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
def intlist(x):
    y = []
    for i in range(len(x)):
        y.append(int(x[i]))
    return y
 
N, M, X = map(int, input().split())
price = -1
 
L = []
a = []
c = []
suit =[]
for i in range(M+1):
    a.append(0)
    
for i in range(N):
    text = input().split()
    L.append(intlist(text))
 
def buy(x,y):
    
    if x + y <= N:
        
        for i in range(0,M+1):
            
            a[i] += L[x+y-1][i]
            
       
        if x + y == N:
            score = a[1:len(a)]
            
            if min(score) >= X:
                suit.append(a.copy())
                
        elif x + y != N:
            buy(x+1,y)
            for i in range(0,M+1):
                a[i] -= L[x+y][i]
           
            notbuy(x,y+1)
 
 
def notbuy(x,y):
   
    if x + y <= N:
        
        if x + y == N:
            score = a[1:len(a)]
            if min(score) >= X:
                suit.append(a.copy())
                    
             
        elif x + y != N:
            buy(x+1,y)
            for i in range(0,M+1):
                a[i] -= L[x+y][i]
            notbuy(x,y+1)    
 
def textbook(x,y):
    buy(x+1,y)
    for i in range(0,M+1):
        a[i] -= L[x+y][i]
    notbuy(x,y+1)
 
textbook(0,0)
 
b = []
 
if suit != []:
    for i in range(len(suit)):
        for j in range(len(suit)-1):
            if suit[j] > suit[j+1]:
                b = suit[j]
                suit[j] = suit[j+1]
                suit[j+1] = b
    price = suit[0][0]
 

print(price)


Fixed submission:
def intlist(x):
    y = []
    for i in range(len(x)):
        y.append(int(x[i]))
    return y
 
N, M, X = map(int, input().split())
price = -1
 
L = []
a = []
c = []
suit =[]
for i in range(M+1):
    a.append(0)
    
for i in range(N):
    text = input().split()
    L.append(intlist(text))
 
def buy(x,y):
    
    if x + y <= N:
        
        for i in range(0,M+1):
            
            a[i] += L[x+y-1][i]
            
       
        if x + y == N:
            score = a[1:len(a)]
            
            if min(score) >= X:
                suit.append(a.copy())
                
        elif x + y != N:
            buy(x+1,y)
            for i in range(0,M+1):
                a[i] -= L[x+y][i]
           
            notbuy(x,y+1)
 
 
def notbuy(x,y):
   
    if x + y <= N:
        
        if x + y == N:
            score = a[1:len(a)]
            if min(score) >= X:
                suit.append(a.copy())
                    
             
        elif x + y != N:
            buy(x+1,y)
            for i in range(0,M+1):
                a[i] -= L[x+y][i]
            notbuy(x,y+1)    
 
def textbook(x,y):
    buy(x+1,y)
    for i in range(0,M+1):
        a[i] -= L[x+y][i]
    notbuy(x,y+1)
 
textbook(0,0)
 



if suit != []:
    if len(suit) >= 2:
    
        cheaper = suit[0][0]
        for i in range(len(suit)):
            if cheaper > suit[i][0]:
                cheaper = suit[i][0]
        price = cheaper
    elif len(suit) == 1:
        price = suit[0][0]
 


print(price)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

clip = []
for i in range(N):
    S = input()
    if S not in clip:
        
        clip.append(S)
        
    
print(len(clip))

Fixed submission:
N = int(input())

clip = set()
for i in range(N):
    S = input()
    clip.add(S)

    
print(len(clip))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
count = 0
clip = []
for i in range(N):
    S = input()
    if S not in clip:
        
        clip.append(S)
        count = count + 1
    
print(count)

Fixed submission:
N = int(input())

clip = set()
for i in range(N):
    S = input()
    clip.add(S)

    
print(len(clip))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
count = 0
clip = []
for i in range(N):
    S = input()
    if S in clip:
        pass
    else:
        clip.append(S)
        count = count + 1
    
print(count)

Fixed submission:
N = int(input())

clip = set()
for i in range(N):
    S = input()
    clip.add(S)

    
print(len(clip))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
box = []
S = input()
box.append(S)
count = N
for i in range(N-1):
    S = input()
    for j in range(len(box)):
        if S == box[j]:
            count = count - 1
            break
        box.append(S)
print(count)

Fixed submission:
N = int(input())

clip = set()
for i in range(N):
    S = input()
    clip.add(S)

    
print(len(clip))
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

N, K = map(int, input().split())
P = list(map(int, input().split()))

# tmp = itertools.combinations_with_replacement(P, K)
tmp = itertools.combinations(P, K)

hoge = []
for i in tmp:
    hoge.append(sum(i))

print(min(hoge))


Fixed submission:
# import itertools

N, K = map(int, input().split())
P = list(map(int, input().split()))

# tmp = itertools.combinations_with_replacement(P, K)
# tmp = itertools.combinations(P, K)

P.sort()
print(sum(P[0:K]))

# hoge = []
# for i in tmp:
#     hoge.append(sum(i))

# print(min(hoge))
Buggy python submission (verdict: Runtime Error):
X, N = map(int, input().split())
A = list(map(int, input().split()))

tmp = 1000
result = []
result2 = []
for i in range(1, 101):
    if i in A:
        continue

    hoge = abs(X - i)
    if hoge <= tmp:
        tmp = hoge
        result2.append(tmp)
        result.append(i)

result3 = []
for i, v in enumerate(result2):
    if v == min(result2):
        result3.append(result[i])

print(min(result3))


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

tmp = 1000
result = []
result2 = []
for i in range(0, 102):
    if i in A:
        continue

    hoge = abs(X - i)
    if hoge <= tmp:
        tmp = hoge
        result2.append(tmp)
        result.append(i)

result3 = []
for i, v in enumerate(result2):
    if v == min(result2):
        result3.append(result[i])

print(min(result3))
Buggy python submission (verdict: Runtime Error):

A, B, C, K = map(int, input().split())

backup = K
AB = A + B
flag = False
ans = 0
if K <= A:
    print(K)
    # print("hogeD")
else:
    if A < K:
        K = K - A
        ans = ans + (A * 1)
        # print(1)

    if B <= K:
        K = K - B
        flag = True

    if K > 0 and flag:
        ans = ans + (-1) * (backup - AB)
        # print(3)

    print(ans)


Fixed submission:
A = input()
B = input()

if A == B[:len(A)]:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce


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


K = int(input())

hoge = []
for i in range(1, K + 1):
    for j in range(1, K + 1):
        for k in range(1, K + 1):
            hoge.append(gcd(i, j, k))

print(sum(hoge))


Fixed submission:
import math
from functools import reduce

K = int(input())

sum = 0
for i in range(1, K + 1):
    for j in range(1, K + 1):
        for k in range(1, K + 1):
            sum += reduce(math.gcd, (i, j, k))

print(sum)

Buggy python submission (verdict: Runtime Error):
import numpy as np
import functools
import math
from functools import reduce

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

# def euclid(a, b):
#     if b == 0:
#         return a
#     else:
#         return euclid(b, a%b)

# def gcd(nums):
#     return functools.reduce(euclid, nums)


K = int(input())

hoge = []
for i in range(1, K + 1):
    for j in range(1, K + 1):
        for k in range(1, K + 1):
            hoge.append(gcd(i, j, k))

print(sum(hoge))


Fixed submission:
import math
from functools import reduce

K = int(input())

sum = 0
for i in range(1, K + 1):
    for j in range(1, K + 1):
        for k in range(1, K + 1):
            sum += reduce(math.gcd, (i, j, k))

print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
import collections
# from collections import OrderedDict

N = int(input())
S = [input() for _ in range(N)]

c = collections.Counter(S)

hoge = []
for k, v in c.items():
    if max(c.values()) == v:
        hoge.append(k)

hoge = sorted(hoge)
for i in hoge:
    print(i)

Fixed submission:
import collections
# from collections import OrderedDict

N = int(input())
S = [input() for _ in range(N)]

c = collections.Counter(S)
max_vale = c.most_common()[0][1]

hoge = []
for k, v in c.items():
    if max_vale == v:
        hoge.append(k)

hoge = sorted(hoge)
for i in hoge:
    print(i)



# for i in c.most_common():
#     print(i)

Buggy python submission (verdict: Time Limit Exceeded):
import collections
# from collections import OrderedDict

N = int(input())
S = []
for _ in range(N):
    S.append(input())

c = collections.Counter(S)

max_k_list = [kv[0] for kv in c.items() if kv[1] == max(c.values())]
max_k_list = sorted(max_k_list)
for i in max_k_list:
    print(i)

Fixed submission:
import collections
# from collections import OrderedDict

N = int(input())
S = [input() for _ in range(N)]

c = collections.Counter(S)
max_vale = c.most_common()[0][1]

hoge = []
for k, v in c.items():
    if max_vale == v:
        hoge.append(k)

hoge = sorted(hoge)
for i in hoge:
    print(i)



# for i in c.most_common():
#     print(i)

Buggy python submission (verdict: Time Limit Exceeded):
import collections
# from collections import OrderedDict

N = int(input())
S = []
for _ in range(N):
    S.append(input())

c = collections.Counter(S)

max_k_list = [kv[0] for kv in c.items() if kv[1] == max(c.values())]
max_k_list = sorted(max_k_list)
for i in max_k_list:
    print(i)

Fixed submission:
import collections
# from collections import OrderedDict

N = int(input())
S = [input() for _ in range(N)]

c = collections.Counter(S)
max_vale = c.most_common()[0][1]

hoge = []
for k, v in c.items():
    if max_vale == v:
        hoge.append(k)

hoge = sorted(hoge)
for i in hoge:
    print(i)



# for i in c.most_common():
#     print(i)
Buggy python submission (verdict: Runtime Error):
a,b,c,k=map(int, input().split())
if a+b-k>=0:
    print(min(a,k))
else:
    print(a-(k-(a+b))


Fixed submission:
a,b,c,k=map(int, input().split())
if a+b-k>=0:
    print(min(a,k))
else:
    print(2*a-k+b)
Buggy python submission (verdict: Runtime Error):
n,k,m=map(int, input().split())
for i in range(n-1):
  a[i]=int(input()) 
  Sum+=a[i]
if (Sum+k)/n<m:
  print(-1)
  break
else:
  print(n＊m-Sum)

Fixed submission:
print(chr(ord(input())+1))
Buggy python submission (verdict: Runtime Error):
a,b=map(int, input().split())
if a-2b>0:
  print(a-2b)
else: 
  print(0)

Fixed submission:
a,b=map(int, input().split())
if a-2*b>0:
  print(a-2*b)
else: 
  print(0)

Buggy python submission (verdict: Runtime Error):
a,b=map(int, input().split())
if a-2b>0:
  print(a-2b)
else:
   print(0)

Fixed submission:
a,b=map(int, input().split())
if a-2*b>0:
  print(a-2*b)
else: 
  print(0)
Buggy python submission (verdict: Runtime Error):
s=input()
t=input()
ans=0
for i in range(len(s)):
  if s[i]=t[i]:
    ans+=1
print(ans)

Fixed submission:
s=input()
t=input()
ans=0
for i in range(len(s)):
  if s[i]==t[i]:
    ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
n,a,b=map(int, input().split())
print(min(n*a,b)

Fixed submission:
n,a,b=map(int, input().split())
print(min(n*a,b))
Buggy python submission (verdict: Time Limit Exceeded):
a,b,c=map(int, input().split())
krps=0
while krps<c:
  if b-a>=0:
    krps+=1
    b-=a
print(krps)

Fixed submission:
a,b,c=map(int, input().split())
krps=0
while krps<c:
  if b-a>=0:
    krps+=1
    b-=a
  if b-a<0:
    break
print(krps)
Buggy python submission (verdict: Runtime Error):
a,b,c,d  =map(int, input().split())

if(a==0):
    print("1")

elif(b==0):
    print("1")

elif(c==0):
    print("1")

elif(d==0):
    print("1")

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

if(a==0):
    print("1")

elif(b==0):
    print("2")

elif(c==0):
    print("3")

elif(d==0):
    print("4")
    
elif(e==0):
    print("5")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
ad = {}
for i in a:
  if i not in ad:
  	ad[i] = a.count(i)
q = int(input())
ll = []
for i in range(q):
	l = list(map(int, input().split()))
	ll.append(l)
	if l[1] not in ad:
		ad[l[1]] = 0

for i in ll:
  if i[0] in ad:
    ad[i[1]] = ad[i[1]] + ad[i[0]]
    ad[i[0]] = 0
    adsum = 0
    for j in ad:
      adsum += j*ad[j]
    print(adsum)
  else:
    adsum = 0
    for j in ad:
      adsum += j*ad[j]
    print(adsum)

Fixed submission:
import collections
n = int(input())
a = list(map(int, input().split()))
q = int(input())
b = [list(map(int,input().split(" "))) for i in range(0,q)]

ans = sum(a)
anum = collections.Counter(a)

for i in range(q):
    x, y = b[i][0], b[i][1]
    ans += anum[x] * (y - x)
    anum[y] += anum[x]
    anum[x] = 0
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
q = int(input())
ll = []
for i in range(q):
	l = list(map(int, input().split()))
	ll.append(l)
    
for i in ll:
  if i[0] in a:
    a = [i[1] if j == i[0] else j for j in a]
    print(sum(a))
  else:
    print(sum(a))

Fixed submission:
import collections
n = int(input())
a = list(map(int, input().split()))
q = int(input())
b = [list(map(int,input().split(" "))) for i in range(0,q)]

ans = sum(a)
anum = collections.Counter(a)

for i in range(q):
    x, y = b[i][0], b[i][1]
    ans += anum[x] * (y - x)
    anum[y] += anum[x]
    anum[x] = 0
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
h = list(map(int, input().split()))

a = 0
for i in range(n+1):
  c = 0
  for j in range(n-i-1):
    if h[i:][j] >= h[i:][j+1]:
      c += 1
    else:
      break
  if c > a:
    a = c
        
print(a)
    

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

c = 0
a = 0   
for i in range(n-1):
  if h[i] >= h[i+1]:
    c += 1
  else:
    a = max(c, a)
    c = 0
    
#最後のcはelseで引っかからない
a = max(c, a)    
        
print(a)
Buggy python submission (verdict: Runtime Error):
n = int(input())
if n <= 9:
  print(n)
elif n <= 99:
  print(9)
elif n <= 999:
  print(9+n-100+1)
elif n <= 9999:
  print(909)
elif n <= 99999:
  print(909+n-10000+1)
else:
  print(90909)

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

if n[2]-n[0]+n[1] > 0:
  print(n[2]-n[0]+n[1])
else:
  print(0)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
h = list(map(int,input().split()))

for i in range(len(h)-1):
  if h[i] > h[i+1]:
    h[i] = h[i] - 1
  elif h[i] == h[i+1]:
    if h[i] == min(h[i:])+1:
      h[i] = h[i] - 1
if h == sorted(h):
  print('Yes')
else:
  print('No')

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

for i in reversed(range(1,n)):
  if h[i-1] - h[i] == 1:
    h[i-1] -= 1
  elif h[i-1] - h[i] > 1:
    print('No')
    exit()
print('Yes')

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

for i in range(len(h)-1):
  if h[i] > h[i+1]:
    h[i] = h[i] - 1
  elif h[i] == h[i+1]:
    if h[i] == min(h[i:])-1:
      h[i] = h[i] - 1
if h == sorted(h):
  print('Yes')
else:
  print('No')

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

for i in reversed(range(1,n)):
  if h[i-1] - h[i] == 1:
    h[i-1] -= 1
  elif h[i-1] - h[i] > 1:
    print('No')
    exit()
print('Yes')
Buggy python submission (verdict: Runtime Error):
n = int(input())
ls = list(map(int, input().split()))

c = 0
for i in range(1, n-1):
  if ls[i] > ls[i-1] and ls[i] < ls[i+1]:
    c += 1
  elif  ls[i] < ls[i-1] and ls[i] > ls[i+1]:
    c += 1
    
print(c)

Fixed submission:
ls = list(input())
if ls[0] == ls[1] and ls[2] == ls[3] and ls[0] != ls[2]:
  print('Yes')
elif ls[0] == ls[2] and ls[1] == ls[3] and ls[0] != ls[1]:
  print('Yes')
elif ls[0] == ls[3] and ls[1] == ls[2] and ls[0] != ls[1]:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
x, n = list(map(int, input().split(" ")))
if n != 0:

    p = list(map(int, input().split(" ")))

    p_ = [abs(x - n) for n in p]

    m_p_ = p_.index(min(p_))

    start = p[m_p_]

    for v in range(100):
        a = start - v - 1
        if a not in p:
            ans = a
        b = start + v + 1
        if b not in p:
            if ans > b:
                ans = b
            break
            
else:
    ans = x
    
print(ans)

Fixed submission:
x, n = list(map(int, input().split(" ")))
if n != 0:

    p = list(map(int, input().split(" ")))

    p_ = [abs(x - n) for n in p]

    m_p_ = p_.index(min(p_))

    start = p[m_p_]

    for v in range(100):
        a = start - v - 1
        b = start + v + 1
        if (a not in p) and (b in p):
            ans = a
            break

        elif (a in p) and (b not in p):
            ans = b
            break
            
        elif (a not in p) and (b not in p):
            if a > b:
                ans = b
                break
            else:
                ans = a
                break
                
else:
    ans = x
    
print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np

a, b, h, m = list(map(int, input().split(" ")))

h_a = (h + m/60) * 30
m_a = m * 6
angle = abs(h_a - m_a)
if angle > 180:
    angle = 360 - angle

if angle == 0:
    ans = abs(a-b)
else:
    angle = angle * np.pi / 180
    ans = np.sqrt(a**2 + b**2 - 2 * a * b * np.cos(angle))

print(ans)

Fixed submission:
import numpy as np
import math

a, b, h, m = list(map(int, input().split(" ")))

h_a = (h + m/60) * 30
m_a = m * 6
angle = abs(h_a - m_a)
if angle > 180:
    angle = 360 - angle

if angle == 0:
    ans = abs(a-b)
else:
    angle = angle * np.pi / 180
    ans = np.sqrt(a**2 + b**2 - 2 * a * b * np.cos(angle))

print(ans)

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

a, b, h, m = list(map(int, input().split(" ")))

h_a = h * 30
m_a = m * 6
angle = abs(h_a - m_a)
if angle > 180:
    angle = 360 - angle

if angle == 0:
    ans = abs(a-b)
else:
    angle = angle * np.pi / 180
    ans = math.sqrt(a**2 + b**2 - 2 * a * b * math.cos(angle))

print(ans)

Fixed submission:
import numpy as np
import math

a, b, h, m = list(map(int, input().split(" ")))

h_a = (h + m/60) * 30
m_a = m * 6
angle = abs(h_a - m_a)
if angle > 180:
    angle = 360 - angle

if angle == 0:
    ans = abs(a-b)
else:
    angle = angle * np.pi / 180
    ans = np.sqrt(a**2 + b**2 - 2 * a * b * np.cos(angle))

print(ans)

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

a, b, h, m = list(map(int, input().split(" ")))

h_a = h * 30
m_a = m * 6
angle = abs(h_a - m_a)
if angle > 180:
    angle = 360 - angle

if angle == 0:
    ans = abs(a-b)
else:
    angle = angle * np.pi / 180
    ans = math.sqrt(a**2 + b**2 - 2 * a * b * math.cos(angle))

print(ans)

Fixed submission:
import numpy as np
import math

a, b, h, m = list(map(int, input().split(" ")))

h_a = (h + m/60) * 30
m_a = m * 6
angle = abs(h_a - m_a)
if angle > 180:
    angle = 360 - angle

if angle == 0:
    ans = abs(a-b)
else:
    angle = angle * np.pi / 180
    ans = np.sqrt(a**2 + b**2 - 2 * a * b * np.cos(angle))

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

ans = 0

for v in range(1, n+1):
    m = ((a * v)/ b) // 1
    l = a * ((v/b)//1)
    if ans < (m - l):
        ans = (m - l)
print(int(ans))

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

ans = "NG"

for v in range(a, b+1):
    c = v % k
    if c == 0:
        ans = "OK"
        break

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
ans = 0
import math
import itertools
from functools import reduce

def gcd(num):
    return reduce(math.gcd, num)

numlist = list(range(1, k+1))
l = list(itertools.product(numlist, repeat=3))

ans = sum(map(gcd, l))

print(ans)

Fixed submission:
k = int(input())
ans = 0
import math
from functools import reduce

def gcd(*num):
    return reduce(math.gcd, num)

for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            ans += gcd(a, b, c)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
ans = 0
import math
from functools import reduce
import itertools

def gcd(num):
    return reduce(math.gcd, num)
numlist = list(range(1, k+1))
l = list(itertools.product(numlist, repeat=3))
l2 = map(gcd, l)

ans = sum(l2)

print(ans)

Fixed submission:
k = int(input())
ans = 0
import math
from functools import reduce

def gcd(*num):
    return reduce(math.gcd, num)

for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            ans += gcd(a, b, c)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
ans = 0
import math
from functools import reduce
import itertools

def gcd(num):
    return reduce(math.gcd, num)
numlist = list(range(1, k+1))
l = list(itertools.product(numlist, repeat=3))

for v in l:
    ans += gcd(v)

print(ans)

Fixed submission:
k = int(input())
ans = 0
import math
from functools import reduce

def gcd(*num):
    return reduce(math.gcd, num)

for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            ans += gcd(a, b, c)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
ans = 0
import math
from functools import reduce

def gcd(*num):
    return reduce(math.gcd, num)

for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            ans += gcd(a, b, c)
print(ans)

Fixed submission:
k = int(input())
ans = 0
import math
from functools import reduce

def gcd(*num):
    return reduce(math.gcd, num)

for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            ans += gcd(a, b, c)
print(ans)
Buggy python submission (verdict: Runtime Error):
print((int(input())/3)**3)

Fixed submission:
m, n = list(map(int, input().split(" ")))
ans = int((m * (m - 1))/ 2) + int((n * (n - 1))/ 2)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s = list(map(int, input().split(" ")))

a = s[0]
b = s[1]
m = s[2]

a_l = list(map(int, input().split(" ")))
b_l = list(map(int, input().split(" ")))

ans = a_l[0] + b_l[0]

for i in range(m):
    x = list(map(int, input().split(" ")))
    if ans > (a_l[x[0] - 1] + b_l[x[1] -1] - x[2]):
        ans = a_l[x[0] -1] + b_l[x[1] -1] - x[2]
        
while len(a_l) > 0:
    a_ = a_l.pop(0)
    for v in b_l:
        if ans > (a_ + v):
            ans = a_ + v

print(ans)

Fixed submission:
s = list(map(int, input().split(" ")))

a = s[0]
b = s[1]
m = s[2]

a_l = list(map(int, input().split(" ")))
b_l = list(map(int, input().split(" ")))

ans = min(a_l) + min(b_l)

for i in range(m):
    x = list(map(int, input().split(" ")))
    if ans > (a_l[x[0] - 1] + b_l[x[1] -1] - x[2]):
        ans = a_l[x[0] -1] + b_l[x[1] -1] - x[2]


print(ans)

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

a = s[0]
b = s[1]
m = s[2]

a_l = list(map(int, input().split(" ")))
b_l = list(map(int, input().split(" ")))

ans = a_l[0] + b_l[0]

for i in a_l:
    for t in b_l:
        if (i + t) < ans:
            ans = i + t

for i in range(m):
    x = list(map(int, input().split(" ")))
    if ans > (a_l[x[0] - 1] + b_l[x[1] -1] - x[2]):
        ans = a_l[x[0] -1] + b_l[x[1] -1] - x[2]
print(ans)

Fixed submission:
s = list(map(int, input().split(" ")))

a = s[0]
b = s[1]
m = s[2]

a_l = list(map(int, input().split(" ")))
b_l = list(map(int, input().split(" ")))

ans = min(a_l) + min(b_l)

for i in range(m):
    x = list(map(int, input().split(" ")))
    if ans > (a_l[x[0] - 1] + b_l[x[1] -1] - x[2]):
        ans = a_l[x[0] -1] + b_l[x[1] -1] - x[2]


print(ans)