qyliang/CodeNanoFix huggingface dataset:
Buggy code:
a=input()
if a=='hi' or
   a=='hihi' or
   a=='hihihi' or
    a=='hihihihi' or
    a=='hihihihihi' :    
    print('Yes')
else:
    print('No')
 

Fixed code:
a=input()
if a=='hi' or a=='hihi' or a=='hihihi' or  a=='hihihihi' or a=='hihihihihi' :    
    print('Yes')
else :
    print('No')
Buggy code:
s = input()
if s == "hi" or "hihi" or "hihihi" or "hihihihi" or "hihihihihi":
  print("Yes")
else:
  print("No")

Fixed code:
s = input()
if s == "hi" or s == "hihi" or s == "hihihi" or s == "hihihihi" or s == "hihihihihi":
    print("Yes")
else:
    print("No")
Buggy code:
A,B,M = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

min = min(a)+min(b)

for i in range(M):
    c =list(map(int,input().split()))
    s = a[c[0]-1]+b[c[1]-1]-c[2]
    min = min(s,min)

print(min)


Fixed code:
A,B,M = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

min = min(a)+min(b)

for i in range(M):
    c =list(map(int,input().split()))
    s = a[c[0]-1]+b[c[1]-1]-c[2]
    min = (s if s < min else min)

print(min)
Buggy code:
_, _, M = map(int, input().split(" "))
a = list(map(int, input().split(" ")))
b = list(map(int, input().split(" ")))
min = min(a) + min(b)
for i in range(M):
  x, y, c = map(int, input().split(" "))
  s = a[x] + b[y] - c
  if min > s:
    min = s
print(min)

Fixed code:
_, _, M = map(int, input().split(" "))
a = list(map(int, input().split(" ")))
b = list(map(int, input().split(" ")))
min = min(a) + min(b)
for i in range(M):
  x, y, c = map(int, input().split(" "))
  s = a[x-1] + b[y-1] - c
  if min > s:
    min = s
print(min)
Buggy code:
A,B,M = [int(i) for i in input().split()]
A = sorted([int(i) for i in input().split()])
B = sorted([int(i) for i in input().split()])
min = 99999999999
for i in range(M):
  x,y,c = [int(i) for i in input().split()]
  buf = A[x-1]+B[y-1]-c
  if buf<min:
    min = buf
print(buf)

Fixed code:
A,B,M = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
min = min(A)+min(B)
for i in range(M):
  x,y,c = [int(i) for i in input().split()]
  buf = A[x-1]+B[y-1]-c
  if buf<min:
    min = buf
print(min)
Buggy code:
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

for i in range(M):
    if i==0:
        tmp = list(map(int, input().split()))
        checkout = a[tmp[0]-1] + b[tmp[1]-1] - tmp[2]
    else:
        tmp = list(map(int, input().split()))
        checkout = min(checkout, a[tmp[0]-1] + b[tmp[1]-1] - tmp[2])

print(checkout)



Fixed code:
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
checkout = min(a)+min(b)

for i in range(M):
    tmp = list(map(int, input().split()))
    checkout = min(checkout, a[tmp[0]-1] + b[tmp[1]-1] - tmp[2])

print(checkout)
Buggy code:
a, b, m = map(int, input().split())
reizo = list(map(int, input().split()))
renji = list(map(int, input().split()))
p = [list(map(int,input().split())) for i in range(m)]
ans = []
for i in range(m):
  cost = reizo[p[i][0]] + renji[p[i][1]] - p[i][2]
  ans.append(cost)
ans.append(min(reizo) + min(renji))
print(min(ans))

Fixed code:
a, b, m = map(int, input().split())
reizo = list(map(int, input().split()))
renji = list(map(int, input().split()))
p = [list(map(int,input().split())) for i in range(m)]
ans = []
for i in range(m):
  cost = reizo[p[i][0] - 1] + renji[p[i][1] - 1] - p[i][2]
  ans.append(cost)
ans.append(min(reizo) + min(renji))
print(min(ans))
Buggy code:
while True:
    try:
        listA.append(list(map(int,input().split())))

    except:
        break;
        

money = min(listA[1]) + min(listA[2]) 

for k in range(listA[0][2]):
    wari = 1000
    a = listA[k+3][0]
    b = listA[k+3][1]
    if wari > listA[1][a-1] + listA[2][b-1] - listA[k+3][2]:
        wari = listA[1][a-1] + listA[2][b-1] - listA[k+3][2]

if money <= wari:
    print(money)
        
else:
    print(wari)


Fixed code:
listA=[]

while True:
    try:
        listA.append(list(map(int,input().split())))

    except:
        break;
        

money = min(listA[1]) + min(listA[2]) 
wari = 100000000

for k in range(listA[0][2]):
    a = listA[k+3][0]
    b = listA[k+3][1]
    if wari > listA[1][a-1] + listA[2][b-1] - listA[k+3][2]:
        wari = listA[1][a-1] + listA[2][b-1] - listA[k+3][2]

if money <= wari:
    print(money)
        
else:
    print(wari)
Buggy code:
A, B, M = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

min_cost = min(a) + min(b)

for i in range(M):
  x = list(map(int,input().split()))
  cost = a[x[0]] + b[x[1]] - x[2]

  if min_cost > cost:
    min_cost = cost

print(min_cost)

Fixed code:
A, B, M = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

min_cost = min(a) + min(b)

for i in range(M):
  x = list(map(int,input().split()))
  cost = a[x[0] - 1] + b[x[1] - 1] - x[2]

  if min_cost > cost:
    min_cost = cost

print(min_cost)
Buggy code:
A,B,M=map(int,input().split())
vecA=list(map(int,input().split()))
vecB=list(map(int,input().split()))
matX=[input().split() for k in range(M)]
price = 10**6
for i in range(0,M):
    pricecom = int(vecA[int(matX[i][0]) -1]) + int(vecB[int(matX[i][1]) -1]) - int(matX[i][2])
    if pricecom<= price:
        price=pricecom
    else:
        pass
print(price)

Fixed code:
A,B,M=map(int,input().split())
vecA=list(map(int,input().split()))
vecB=list(map(int,input().split()))
matX=[input().split() for k in range(M)]
price = 10**6
for i in range(0,M):
    pricecom = int(vecA[int(matX[i][0]) -1]) + int(vecB[int(matX[i][1]) -1]) - int(matX[i][2])
    if pricecom<= price:
        price=pricecom
    else:
        pass
price2=int(min(vecA)) + int(min(vecB))
if price2<=price:
    price=price2
print(price)
Buggy code:
# Author: cr4zjh0bp
# Created: Sun Mar  8 12:19:06 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

A, B, M = na()
a = na()
b = na()
xyc = nan(M)
ans = inf
for i in range(M):
    x, y, c = xyc[i]
    x -= 1
    y -= 1
    ans = min(ans, a[x] + b[y] - c)

print(ans)

Fixed code:
# Author: cr4zjh0bp
# Created: Sun Mar  8 12:19:06 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

A, B, M = na()
a = na()
b = na()
xyc = nan(M)
ans = min(a) + min(b)
for i in range(M):
    x, y, c = xyc[i]
    x -= 1
    y -= 1
    ans = min(ans, a[x] + b[y] - c)

print(ans)
Buggy code:
A, B, M = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))
ans = int(1e18)
for i in range(M):
    x, y, c = map(int, input().split(' '))
    ans = min(ans, a[x - 1] + b[y - 1] - c)
print(ans)

Fixed code:
A, B, M = map(int, input().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

ans = min(a)+min(b)

for i in range(M):
    x, y, c = map(int, input().split())
    ans = min(ans, a[x-1]+b[y-1]-c)

print(ans)
Buggy code:
a,b,m=map(int,input().split())
fri=list(map(int,input().split()))
mic=list(map(int,input().split()))
wari=[list(map(int,input().split())) for i in range(m)]
fri.sort()
mic.sort()
mi=fri[0]+mic[0]
for i in range(m):
    if fri[wari[i][0]-1]+mic[wari[i][1]-1]<mi:
        mi=fri[wari[i][0]-1]+mic[wari[i][1]-1]
print(mi)


Fixed code:
a,b,m=map(int,input().split())
fri=list(map(int,input().split()))
mic=list(map(int,input().split()))
wari=[list(map(int,input().split())) for i in range(m)]
mi=min(fri)+min(mic)
for i in range(m):
    if fri[wari[i][0]-1]+mic[wari[i][1]-1]-wari[i][2]<mi:
        mi=fri[wari[i][0]-1]+mic[wari[i][1]-1]-wari[i][2]
print(mi)
Buggy code:
A,B,M = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = 100000000
for i in range(M):
    x,y,c = map(int,input().split())
    ans = min(ans,a[x-1]+b[y-1]-c)
print(ans)

Fixed code:
A,B,M=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=min(a)+min(b)
for i in range(M):
    x,y,c=map(int,input().split())
    ans=min(ans,a[x-1]+b[y-1]-c)
print(ans)
Buggy code:
a,b,m=map(int, input().split())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
buf=min(A)+min(B)
for i in range(m):
    x,y,c=map(int, input().split())
    cp=A[x-1]+B[y-1]-c
    if buf>=cp:
        buf==cp
print(buf)

Fixed code:
a,b,m=map(int, input().split())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
buf=min(A)+min(B)
for i in range(m):
    x,y,c=map(int, input().split())
    cp=A[x-1]+B[y-1]-c
    if buf>=cp:
        buf=cp
print(buf)
Buggy code:
def main():
    _, _, m_num = map(int, input().split())
    a = [int(s) for s in input().split()]
    b = [int(s) for s in input().split()]

    min_price = min(a) + min(b)

    m = []
    for _ in range(m_num):
        price = a[x - 1] + b[y - 1] - c
        print(x, y, c, price)
        min_price = min(min_price, price)
    
    print(min_price)

main()

Fixed code:
def main():
    _, _, m_num = map(int, input().split())
    a = [int(s) for s in input().split()]
    b = [int(s) for s in input().split()]

    min_price = min(a) + min(b)

    m = []
    for _ in range(m_num):
        x, y, c = map(int, input().split())
        price = a[x - 1] + b[y - 1] - c
        min_price = min(min_price, price)
    
    print(min_price)

main()
Buggy code:
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, a[k[0]-1]+b[k[1]-1]-k[2])


print(MIN)

Fixed code:
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 code:
A,B,M = map(int,input().split())

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

discount = []
for i in [0]*M:
    discount.append(list(map(int,input().split())))

min_comb = min(a)+min(b)

for i in range(M):
    min_comb = min(min_comb,a[discount[i][0]-1]+b[discount[i][1]-1]-discount[i][2])
ans = 0
print(ans)

Fixed code:
A,B,M = map(int,input().split())

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

discount = []
for i in [0]*M:
    discount.append(list(map(int,input().split())))

min_comb = min(a)+min(b)

for i in range(M):
    min_comb = min(min_comb,a[discount[i][0]-1]+b[discount[i][1]-1]-discount[i][2])
ans = min_comb
print(ans)
Buggy code:
a, b, m = map(int, input().split())
A = [int(ae) for ae in input().split()]
B = [int(be) for be in input().split()]

amin = min(A)
bmin = min(B)
smin = amin + bmin

for i in range(m):
  x, y, c= map(int, input().split())
  th = smin -c
  apmin = A[x]
  if apmin > th:
    pass
  else:
    bpmin = B[y]
    spmin = apmin + bpmin -c
    if spmin < smin:
      smin = spmin
    else:
      pass
print(smin)


Fixed code:
a, b, m = map(int, input().split())
A = [int(ae) for ae in input().split()]
B = [int(be) for be in input().split()]

amin = min(A)
bmin = min(B)
smin = amin + bmin

for i in range(m):
  x, y, c= map(int, input().split())
  th = smin + c
  apmin = A[x-1]
  if apmin > th:
    pass
  else:
    bpmin = B[y-1]
    spmin = apmin + bpmin -c
    if spmin < smin:
      smin = spmin
    else:
      pass
print(smin)
Buggy code:
A , B , M = int(input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = []
for i in range(M-1):
    q = input().split()
    x = a[q[0]-1] + b[q[1]-1] - q[2]
    ans.append(x)
print(min(ans))

Fixed code:
A , B , M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = [min(a) + min(b)]
for i in range(M):
    q = list(map(int, input().split()))
    x = a[q[0]-1] + b[q[1]-1] - q[2]
    ans.append(x)
print(min(ans))
Buggy code:
s=list(map(int,input().split()))
t=list(map(int,input().split()))
u=list(map(int,input().split()))
v=[list(map(int,input().split())) for i in range(s[2])]
a=10**6
d=0
e=0
for i in range(s[2]):
  d=v[i][0]-1
  e=v[i][0]-1
  b=t[d]+u[e]-v[i][2]
  a=min(a,b)
print(a)

Fixed code:
s=list(map(int,input().split()))
t=list(map(int,input().split()))
u=list(map(int,input().split()))
v=[list(map(int,input().split())) for i in range(s[2])]
a=10**6
d=0
e=0
for i in range(s[2]):
  d=v[i][0]-1
  e=v[i][1]-1
  b=t[d]+u[e]-v[i][2]
  a=min(a,b)
f=min(t)
e=min(u)+f
a=min(a,e)
print(a)
Buggy code:
a,b,m=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
ans=10**5+10**5
for i in range(m):
    x,y,c=map(int,input().split())
    num=A[x-1]+B[y-1]-c
    ans=min(num,ans)
print(ans)

Fixed code:
a,b,m=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
ans=min(A)+min(B)
for i in range(m):
    x,y,c=map(int,input().split())
    num=A[x-1]+B[y-1]-c
    ans=min(num,ans)
print(ans)
Buggy code:
a,b,m=map(int,input().split())
al=list(map(int,input().split()))
bl=list(map(int,input().split()))
x=min(al)+min(bl)
for i in range(m):
  x,y,c=map(int,input().split())
  t=a[x-1]+b[y-1]-c
  x=min(x,t)
print(x)

Fixed code:
a,b,m=map(int,input().split())
al=list(map(int,input().split()))
bl=list(map(int,input().split()))
z=min(al)+min(bl)
for i in range(m):
  x,y,c=map(int,input().split())
  t=al[x-1]+bl[y-1]-c
  z=min(z,t)
print(z)
Buggy code:
_, _, M = map(int, input().split())
# price list
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
# min price
min_price = min(a_list) + min(b_list)
for _ in range(M):
  x, y, c = map(int, input().split())
  discount_price = a_list[x] + b_list[y] - c
  if discount_price < min_price:
    min_price = discount_price
print(min_price)

Fixed code:
_, _, M = map(int, input().split())
# price list
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
# min price
min_price = min(a_list) + min(b_list)
for _ in range(M):
  x, y, c = map(int, input().split())
  discount_price = a_list[x-1] + b_list[y-1] - c
  min_price = min(min_price, discount_price)
print(min_price)
Buggy code:
a,b,m = map(int,input().split())
ref = list(map(int,input().split()))
ran = list(map(int,input().split()))

ans = min(ref) + min(ran)

for i in range(m):
  t = list(map(int,input().split()))
  p = t[0] 
  q = t[1]
  c = t[2]
  if (len(ref) <= p and len(ran) <= q):
    if ref[p - 1] + ran[p - 1] - c < ans:
      ans = ref[p - 1] + ran[p - 1] - c
      
print(ans)

Fixed code:
a,b,m = map(int,input().split())
ref = list(map(int,input().split()))
ran = list(map(int,input().split()))

ans = min(ref) + min(ran)

for i in range(m):
  t = list(map(int,input().split()))
  p = t[0] 
  q = t[1]
  c = t[2]
  if (len(ref) >= p and len(ran) >= q):
    if ref[p - 1] + ran[q - 1] - c < ans:
      ans = ref[p - 1] + ran[q - 1] - c
      
print(ans)
Buggy code:
numA, numB, numCoupon = map(int, input().split(' '))
priceA = map(int, input().split(' '))
priceB = map(int, input().split(' '))

# initial best price
bestPrice = min(priceA) + min(priceB)

for n in range(numCoupon):
  # get coupon details
  typeA, typeB, discount = map(int, coupon.split(' '))
  # calculate price when this coupon is used
  currentPrice = priceA[typeA-1] + priceB[typeB-1] - discount
  # update best price
  if currentPrice < bestPrice:
    bestPrice = currentPrice

print(bestPrice)

Fixed code:
numA, numB, numCoupon = map(int, input().split(' '))
priceA = list(map(int, input().split(' ')))
priceB = list(map(int, input().split(' ')))

# initial best price
bestPrice = min(priceA) + min(priceB)

for n in range(numCoupon):
  # get coupon details
  typeA, typeB, discount = map(int, input().split(' '))
  # calculate price when this coupon is used
  currentPrice = priceA[typeA-1] + priceB[typeB-1] - discount
  # update best price
  if currentPrice < bestPrice:
    bestPrice = currentPrice

print(bestPrice)
Buggy code:
A, B, M = list(map(int,input().split()))
list_a = list(map(int,input().split()))
list_b = list(map(int,input().split()))
for i in range(M):
    x, y, c = list(map(int,input().split()))
buy = []
buy.append(min(list_a) + min(list_b))
buy.append(list_a[x] + list_b[y] - c)
answer = min(buy)
print(answer, buy)


Fixed code:
A, B, M = list(map(int,input().split()))
list_a = list(map(int,input().split()))
list_b = list(map(int,input().split()))
buy = []
buy.append(min(list_a) + min(list_b))
for i in range(M):
    x, y, c = list(map(int,input().split()))
    buy.append(list_a[x-1] + list_b[y-1] - c)
answer = min(buy)
print(answer)
Buggy code:
a, b, m = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = float('inf')
for _ in range(m):
    x, y, c = map(int, input().split())
    ans = min(ans, A[x-1] + B[y-1] - c)
print(ans)

Fixed code:
a, b, m = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = min(A) + min(B)
for _ in range(m):
    x, y, c = map(int, input().split())
    ans = min(ans, A[x-1] + B[y-1] - c)

print(ans)
Buggy code:
# coding: utf-8
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a1 = sorted(a)
b1 = sorted(b)
z = [list(map(int, input().split())) for _ in range(M)]

num1 = a1[0] + b1[0]
# print("num1:", num1)        
num1 = min(num1)
# print("num1:", num1)
for i in range(M):
    x, y, c = z[i]
    num = a[x - 1] + b[y - 1] - c
    if num < num1:
        num1 = num
print(num1)

Fixed code:
# coding: utf-8
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a1 = sorted(a)
b1 = sorted(b)
z = [list(map(int, input().split())) for _ in range(M)]

num1 = a1[0] + b1[0]
# print("num1:", num1)
for i in range(M):
    x, y, c = z[i]
    num = a[x - 1] + b[y - 1] - c
    if num < num1:
        num1 = num
print(num1)
Buggy code:
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
dis = []
for i in range(M):
  dis.append(list(map(int, input().split())))
  
total = []
for i in range(A):
  for j in range(B):
    plus = a[i] + b[j]
    total.append(plus)


for k in range(M):
  x = dis[k][0] - 1
  y = dis[k][1] - 1
  c = dis[k][2] - 1
  discount = a[x] + b[y] - c
  total.append(discount)
  
  
print(min(total))

Fixed code:
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
dis = []
for i in range(M):
  dis.append(list(map(int, input().split())))
  
total = []
total.append(min(a) + min(b))

for k in range(M):
  x = dis[k][0] - 1
  y = dis[k][1] - 1
  c = dis[k][2]
  discount = a[x] + b[y] - c
  total.append(discount)
  
  
print(min(total))
Buggy code:
a = list(map(int,input().split()))
b = list(map(int,input().split()))
li2=[input() for i in range(m)]
c = []
for i in range(m):
    c.append( [int(x.strip()) for x in li2[i].split()])

ans = min(a) + min (b)

for i in range(m):
    keep = a[c[i][0]-1] + b[c[i][1]-1] - c[i][2]
    if keep < ans:
        ans = keep

print(ans)

Fixed code:
A,B,m = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
li2=[input() for i in range(m)]
c = []
for i in range(m):
    c.append( [int(x.strip()) for x in li2[i].split()])

ans = min(a) + min (b)

for i in range(m):
    keep = a[c[i][0]-1] + b[c[i][1]-1] - c[i][2]
    if keep < ans:
        ans = keep

print(ans)
Buggy code:
x,y,m = map(int,input().split());an=10**9
p=list(map(int,input().split()));q=list(map(int,input().split()))
for i in range(m):
  a,b,c = map(int,input().split())
  an=min(an,p[a-1]+q[b-1]-c)
print(an)

Fixed code:
x,y,m = map(int,input().split());an=10**9
p=list(map(int,input().split()));q=list(map(int,input().split()))
for i in range(m):
  a,b,c = map(int,input().split())
  an=min(an,p[a-1]+q[b-1]-c)
an=min(an,min(p)+min(q))
print(an)
Buggy code:
A,B,M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
m = 100000000
waribiki= [[0,0,0]for i in range(M)]
for i in range(M):
    waribiki[i] = list(map(int, input().split()))
for i in range(M):
    S = a[waribiki[i][0]-1] +b[waribiki[i][1]-1] -waribiki[i][2]
    if m> S:
        m = S
print(m)

Fixed code:
A,B,M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
m = 0
m += min(a)
m += min(b)
waribiki= [[0,0,0]for i in range(M)]
for i in range(M):
    waribiki[i] = list(map(int, input().split()))
for i in range(M):
    S = a[waribiki[i][0]-1] +b[waribiki[i][1]-1] - waribiki[i][2]
     
    if m> S:
        m = S
print(m)
Buggy code:
a,b,m=map(int,input().split())
price_A=list(map(int,input().split()))
price_B=list(map(int,input().split()))
coupon=[]
for _ in range(m):
  coupon.append(list(map(int,input().split())))
ans=min(price_A)+min(price_B[0])
for i in range(m):
  deprice=price_A[coupon[i][0]-1]+price_B[coupon[i][1]-1]-coupon[i][2]
  if deprice < ans:
    ans = deprice
print(ans)


Fixed code:
a,b,m=map(int,input().split())
price_A=list(map(int,input().split()))
price_B=list(map(int,input().split()))
coupon=[]
for _ in range(m):
  coupon.append(list(map(int,input().split())))
ans=min(price_A)+min(price_B)
for i in range(m):
  deprice=price_A[coupon[i][0]-1]+price_B[coupon[i][1]-1]-coupon[i][2]
  if deprice < ans:
    ans = deprice
print(ans)
Buggy code:
A,B,M = map(int, input().split())
a = map(int, input().split())
b = map(int, input().split())
a_min = min(a)
b_min = min(b)
ans = a_min + b_min
for i in range(M):
  x,y,c = map(int, input().split())
  x -= 1
  y -= 1
  ans = min(ans, a[x]+b[y]-c)
print(ans)

Fixed code:
A,B,M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = min(a) + min(b)
for i in range(M):
  x,y,c = map(int, input().split())
  ans = min(ans, a[x-1]+b[y-1]-c)
print(ans)
Buggy code:
A, B, M = input().split()
A=int(A)
B=int(B)
M=int(M)
a = list(map(int, input().split()))
b = list(map(int, input().split()))
x = [list(map(int, input().split())) for i in range(M)]

dis = []
for i in range(M):
    m = x[i][0]
    n = x[i][0]
    dis.append(a[m] + b[n] - x[i][2])
    
a.sort()
b.sort()

dis.append(a[0]+b[0])

print(min(dis))

Fixed code:
A, B, M = input().split()
A=int(A)
B=int(B)
M=int(M)
a = list(map(int, input().split()))
b = list(map(int, input().split()))
x = [list(map(int, input().split())) for i in range(M)]
 
dis = []
for i in range(M):
    m = x[i][0]-1
    n = x[i][1]-1
    dis.append(a[m] + b[n] - x[i][2])
    
a.sort()
b.sort()
 
dis.append(a[0]+b[0])
 
print(min(dis))
Buggy code:
R = lambda: tuple(map(int, input().split()))
A, B, M = R()
a, b = R(), R()
l = (R() for _ in range(M))
print(min(a[x - 1] + b[x - 1] - c for x, y, c in l))


Fixed code:
R = lambda: tuple(map(int, input().split()))
A, B, M = R()
a, b = R(), R()
d = (R() for _ in range(M))
print(min([min(a) + min(b)] + [a[x - 1] + b[y - 1] - c for x, y, c in d]))