qyliang/CodeNanoFix huggingface dataset:
Buggy 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())
    tmp=A[x-1]+B[y-1]+c
    ans=min(ans,tmp)
print(ans)

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

norm=min(a)+min(b)

for i in range(m):
    x,y,c=map(int,input().split())
    x-=1
    y-=1
    norm=min(norm,a[x]+b[y]-c)
print(norm)
Buggy code:
A,B,M=map(int,input().split())
a=list(map(int,input().split())
b=list(map(int,input().split())
min_price=min(a)+min(b)
for i in range(M):
    m=list(map(int,input().split())
    tmp_price=a[m[0]]+b[m[1]]-m[2]
    if min_price>tmp_price:
        min_price=tmp_price
print(min_price)

Fixed code:
A,B,M=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
min_price=min(a)+min(b)
for i in range(M):
    tmp_price=10000
    m=list(map(int,input().split()))
    tmp_price=a[m[0]-1]+b[m[1]-1]-m[2]
    if min_price>tmp_price:
        min_price=tmp_price
print(min_price)
Buggy 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())
  k=A[x]+B[y]-c
  if k<ans:
    ans=k
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())
  k=A[x-1]+B[y-1]-c
  if k<ans:
    ans=k
print(ans)
Buggy code:
A, B, N = map(int, input().split())
La =list(map(int, input().split())) 
Lb =list(map(int, input().split()))
ans = 10**10
for i in range (N):
  W = list(map(int, input().split())) 
  x = W[0]-1
  y = W[1]-1
  c = W[2]
  price = La[x] + Lb[y] -c
  if price < ans:
    ans = price
print(ans)

Fixed code:
A, B, N = map(int, input().split())
La =list(map(int, input().split())) 
Lb =list(map(int, input().split()))
ans = min(La)+min(Lb)
for i in range (N):
  W = list(map(int, input().split())) 
  x = W[0]-1
  y = W[1]-1
  c = W[2]
  price = La[x] + Lb[y] -c
  if price < ans:
    ans = price
print(ans)
Buggy code:
na,nb,M=map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = [[0 for i in range(3)] for j in range(M)]
#C = [[0]*3]*M
s=min(A)+min(B)
t=0

#print(A)
#print(B)

for i in range(M):
	C[i][0],C[i][1],C[i][2] = map(int, input().split())

#print(C)

for j in range(M):
	print(j)
	t=A[C[j][0]-1]+B[C[j][1]-1]-C[j][2]
	if t<s:
		s=t

print(s)

Fixed code:
na,nb,M=map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = [[0 for i in range(3)] for j in range(M)]
#C = [[0]*3]*M
s=min(A)+min(B)
t=0

#print(A)
#print(B)

for i in range(M):
	C[i][0],C[i][1],C[i][2] = map(int, input().split())

#print(C)

for j in range(M):
	#print(j)
	t=A[C[j][0]-1]+B[C[j][1]-1]-C[j][2]
	if t<s:
		s=t

print(s)
Buggy code:
A = list(map(int,input().split()))
B = list(map(int,input().split()))
M = int(input())
C = [list(map(int,input().split())) for _ in range(M)]
ans = min(A) + min(B)
for cp in C:
    temp = A[cp[0]-1] + B[cp[1]-1] + cp[2]
    ans = min(ans,temp)
    
print(ans)

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

B = list(map(int,input().split()))
C = [list(map(int,input().split())) for _ in range(M)]
ans = min(A) + min(B)
for cp in C:
    temp = A[cp[0]-1] + B[cp[1]-1] - cp[2]
    ans = min(ans,temp)

print(ans)
Buggy code:
a, b, m = map(int, input().split())
priceOfMicrowaves = list(map(int, input().split()))
priceOfRefrigerators = list(map(int, input().split()))
priceTable = [list(map(int,input().split())) for i in range(m)]
cheepest = priceOfMicrowaves[0] + priceOfRefrigerators[0]
for p in priceOfMicrowaves:
    if p >= cheepest:
        continue
    for q in priceOfRefrigerators:
        if q >= cheepest:
            continue
        if p + q < cheepest:
            cheepest = p + q
for price in priceTable:
    if price[2] + 100 >= cheepest:
        continue
    elif priceOfMicrowaves[price[0]-1]-price[2] >= cheepest:
        continue
    elif priceOfRefrigerators[price[1]-1]-price[2] >= cheepest:
        continue
    elif priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2] < cheepest:
        cheepest = priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2]
print(cheepest)


Fixed code:
a, b, m = map(int, input().split())
priceOfMicrowaves = list(map(int, input().split()))
priceOfRefrigerators = list(map(int, input().split()))
priceTable = [list(map(int,input().split())) for i in range(m)]
cheepest = priceOfMicrowaves[0] + priceOfRefrigerators[0]
for price in priceTable:
    if priceOfMicrowaves[price[0]-1]-price[2] >= cheepest:
        continue
    elif priceOfRefrigerators[price[1]-1]-price[2] >= cheepest:
        continue
    elif priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2] < cheepest:
        cheepest = priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2]
if cheepest > min(priceOfMicrowaves) + min(priceOfRefrigerators):
    cheepest = min(priceOfMicrowaves) + min(priceOfRefrigerators)
print(cheepest)
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]

ans = min(a) + min(b)

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

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()]

ans = min(a) + min(b)

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

ans=min(As)+min(Bs)
for i in As:
  for j in Bs:
    ans=min(ans, i+j)
for l in List:
  candidate=As[l[0]-1]+Bs[l[1]-1]-l[2]
  ans = min(ans, candidate)
print(ans)

Fixed code:
A,B,M=map(int, input().split())
As=list(map(int, input().split()))
Bs=list(map(int, input().split()))
List=[]
for i in range(M):
  List.append(list(map(int, input().split())))

ans=min(As)+min(Bs)
for l in List:
  candidate=As[l[0]-1]+Bs[l[1]-1]-l[2]
  ans = min(ans, candidate)
print(ans)
Buggy code:
def resolve():
    input = sys.stdin.readline
    A, B, M = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    grid=[list(map(int,input().split())) for i in range(M)]

    res = min(a) + min(b)

    for x, y, c in grid:
        res = min(res, a[x-1]+b[y-1]-c)

    print(res)
    
resolve()

Fixed code:
def resolve():
    A, B, M = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    grid=[list(map(int,input().split())) for i in range(M)]

    res = min(a) + min(b)

    for x, y, c in grid:
        res = min(res, a[x-1]+b[y-1]-c)

    print(res)
    
resolve()
Buggy code:
A, B, M = map(int, input().split())
ref = list(map(int, input().split()))
mic = list(map(int, input().split()))
coupons = [ list(map(int, input().split())) for i in range(M)]
ans = min(ref) + min(mic)

for i in coupons:
  print(i)
  price = ref[i[0]-1] + mic[i[1]-1] - i[2]
  if price < ans:
    ans = price

print(ans)


Fixed code:
A, B, M = map(int, input().split())
ref = list(map(int, input().split()))
mic = list(map(int, input().split()))
coupons = [ list(map(int, input().split())) for i in range(M)]
ans = min(ref) + min(mic)

for i in coupons:
  price = ref[i[0]-1] + mic[i[1]-1] - i[2]
  if price < ans:
    ans = price

print(ans)
Buggy code:
from collections import defaultdict
import numpy as np

A, B, M = map(int, input().split())
a = np.array(list(map(int, input().split())))
b = np.array(list(map(int, input().split())))

C = defaultdict(int)

for i in range(M):
    x, y, c = map(int, input().split())
    C[tuple([x-1, y-1])] = c

ans = a.min() + b.min()

for c in C:
    ans = min(ans, a[c[0]] - b[c[1]] - C[c])
    
print(ans)

Fixed code:
from collections import defaultdict
import numpy as np

A, B, M = map(int, input().split())
a = np.array(list(map(int, input().split())))
b = np.array(list(map(int, input().split())))

ans = a.min() + b.min()

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()))

vals = []
for _ in range(M):
    i, j, v = map(int, input().split())
    print(i, j, v)
    vals.append( a[i - 1] + b[j - 1] - v)

vals.append(min(a) + min(b))
print(min(vals))

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

vals = []
for _ in range(M):
    i, j, v = map(int, input().split())
    vals.append( a[i - 1] + b[j - 1] - v)

vals.append(min(a) + min(b))
print(min(vals))
Buggy code:
A,B,M=map(int,input().split())
a_1=list(map(int,input().split()))
b_1=list(map(int,input().split()))
L=[list(map(int,input().split())) for _ in range(M)]

count=[]
for i in a_1:
    for j in b_1:
        count.append(i+j)

for k in range(M):
    count.append(a_1[L[k][0]]+b_1[L[k][1]]-L[k][2])

print(min(count))

Fixed code:
A,B,M=map(int,input().split())
a_1=list(map(int,input().split()))
b_1=list(map(int,input().split()))
L=[list(map(int,input().split())) for _ in range(M)]

count=[]
count.append(min(a_1)+min(b_1))

for k in range(M):
    count.append(a_1[L[k][0]-1]+b_1[L[k][1]-1]-L[k][2])

print(min(count))
Buggy code:
A,B,M=list(map(int, input().split()))
a=list(map(int, input().split()))
b=list(map(int, input().split()))
mi=min(a)+min(b)
for i in range(0,M):
  Data=list(map(int, input().split()))
  wari=a[Data[0]]+b[Data[1]]-Data[2]
  if(mi>wari):
    mi=wari
print(mi)

Fixed code:
A,B,M=list(map(int, input().split()))
a=list(map(int, input().split()))
b=list(map(int, input().split()))
mi=min(a)+min(b)
for i in range(0,M):
  Data=list(map(int, input().split()))
  wari=a[Data[0]-1]+b[Data[1]-1]-Data[2]
  if(mi>wari):
    mi=wari
print(mi)
Buggy code:
A, B, M = map(int, input().split())
F = list(map(int, input().split()))
M = list(map(int, input().split()))
C = []

for _ in range(M):
    x, y, c = map(int, input().split())
    x -= 1
    y -= 1
    C.append((x,y,c))

minF = min(F)
minM = min(M)
ans = minF + minM

for x, y, z in C:
    tmp = F[x] + F[y] - z
    if tmp < ans:
        ans = tmp

print(ans)

Fixed code:
A, B, M = map(int, input().split())
Frz = list(map(int, input().split()))
Mic = list(map(int, input().split()))
C = []

for _ in range(M):
    x, y, c = map(int, input().split())
    x -= 1
    y -= 1
    C.append((x,y,c))

minF = min(Frz)
minM = min(Mic)
ans = minF + minM

for x, y, z in C:
    tmp = Frz[x] + Mic[y] - z
    if tmp < ans:
        ans = tmp

print(ans)
Buggy code:
# -*- coding: utf-8 -*-
A,B,M = list(map(int,input().split()))

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

mini = min(a)+ min(b)

def check(Mlist, mini):
    if mini > a[Mlist[0]]+b[Mlist[1]]-Mlist[2]:
        return a[Mlist[0]]+b[Mlist[1]]-Mlist[2]
for i in range(M):
    mini = check(list(map(int,input().split())),mini)

print(mini)

Fixed code:
# -*- coding: utf-8 -*-
A,B,M = list(map(int,input().split()))

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

mini = min(a)+ min(b)

def check(Mlist, mini):
    #print(Mlist)
    if mini > a[Mlist[0]-1]+b[Mlist[1]-1]-Mlist[2]:
        return a[Mlist[0]-1]+b[Mlist[1]-1]-Mlist[2]
    return mini
for i in range(M):
    mini = check(list(map(int,input().split())),mini)

print(mini)
Buggy code:
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
minA = a[0]
for reizou in a[1:]:
    if reizou < minA:
        minA = reizou
minB = b[0]
for renzi in b:
    if renzi < minB:
        minB = renzi
min = minA + minB
for i in range(M):
    x,y,c = map(int,input().split())
    sum = a[x-1] + b[y-1] - c
    if sum < min:
        min = sum

print(sum)

Fixed code:
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
minA = a[0]
for reizou in a[1:]:
    if reizou < minA:
        minA = reizou
minB = b[0]
for renzi in b:
    if renzi < minB:
        minB = renzi
kakaku = minA + minB
for i in range(M):
    x,y,c = map(int,input().split())
    sumKakaku = a[x-1] + b[y-1] - c
    if sumKakaku < kakaku:
        kakaku = sumKakaku

print(kakaku)
Buggy code:
A,B,M = map(int, input().split())

la = list(map(int, input().split()))
lb = list(map(int, input().split()))

d = []
for i in range(M):
  d.append(list(map(int, input().split())))
           
for i in range(M):
  d[i] = la[(d[i][0]-1)] + lb[(d[i][1]-1)] - d[i][2]

print(min(d))

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

la = list(map(int, input().split()))
lb = list(map(int, input().split()))

d = []
for i in range(M):
  d.append(list(map(int, input().split())))
           
for i in range(M):
  d[i] = la[(d[i][0]-1)] + lb[(d[i][1]-1)] - d[i][2]
  
o = min(la) + min(lb)
d.append(o)

print(min(d))
Buggy code:
a,b,m=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
lst=[]
for i in range(m):
  x,y,c=map(int,input().split())
  lst.append([x,y,c])
v=min(A)+min(B)
for i in range(m):
  V=a[A[i][0]-1]+B[lst[i][1]-1]-lst[i][2]
  if v>V:
    v=V
print(v)
  
  

Fixed code:
a,b,m=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
lst=[]
for i in range(m):
  x,y,c=map(int,input().split())
  lst.append([x,y,c])
v=min(A)+min(B)
for i in range(m):
  V=A[lst[i][0]-1]+B[lst[i][1]-1]-lst[i][2]
  if v>V:
    v=V
print(v)
Buggy code:
a, b, m = map(int, input().split())
a_list = [int(i) for i in input().split()]
b_list = [int(i) for i in input().split()]
money = []

for _ in range(m):
    x, y, c = map(int, input().split())
    x -= 1
    y -= 1
    total = a_list[x] +b_list[y] - c
    money.append(total)
print(min(money))

Fixed code:
a, b, m = map(int, input().split())
a_list = [int(i) for i in input().split()]
b_list = [int(i) for i in input().split()]
money = []

for _ in range(m):
    x, y, c = map(int, input().split())
    x -= 1
    y -= 1
    total = a_list[x] +b_list[y] - c
    money.append(total)
money.append(min(a_list) + min(b_list))
print(min(money))
Buggy code:
a,b,m = list(map(int, input().split()))
a1 = list(map(int, input().split()))
b1 = list(map(int, input().split()))
xyc = [ list(map(int, input().split())) for _ in range(m)]

ans = []
for x,y,c in xyc:
    ans.append(a1[x-1] + b1[y-1] - c)
print(min(ans))

Fixed code:
a,b,m = list(map(int, input().split()))
a1 = list(map(int, input().split()))
b1 = list(map(int, input().split()))
xyc = [ list(map(int, input().split())) for _ in range(m)]

ans = []
for x,y,c in xyc:
    ans.append(a1[x-1] + b1[y-1] - c)
ans.append(min(a1) + min(b1))
print(min(ans))
Buggy code:
#B
a,b,m=map(int,input().split())
al=list(map(int,input().split()))
bl=list(map(int,input().split()))
amin=min(al)
bmin=min(bl)
minp=amin+bmin
print(amin,bmin)
for i in range(m):
    num=list(map(int,input().split()))
    price=al[num[0]-1]+bl[num[1]-1]-num[2]
    minp=min(price,minp)
print(minp)

Fixed code:
#B
a,b,m=map(int,input().split())
al=list(map(int,input().split()))
bl=list(map(int,input().split()))
amin=min(al)
bmin=min(bl)
minp=amin+bmin
for i in range(m):
    num=list(map(int,input().split()))
    price=al[num[0]-1]+bl[num[1]-1]-num[2]
    minp=min(price,minp)
print(minp)
Buggy code:
a,b,m=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
ans=1162513825187421
for _ in range(m):
    i,j,c=map(int,input().split())
    ans=min(ans, A[i-1]+B[i-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):
    i,j,c=map(int,input().split())
    ans=min(ans, A[i-1]+B[j-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()))
xyc = [list(map(int, input().split())) for _ in range(M)]
# print(xyc)
cost = []
cost.append(min(a) + min(b))
for x, y, c in xyc:
    tmp = a[x - 1] + b[y - 1] - c
    cost.append(tmp)
print(cost)


Fixed code:
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
xyc = [list(map(int, input().split())) for _ in range(M)]
# print(xyc)
cost = []
cost.append(min(a) + min(b))
for x, y, c in xyc:
    tmp = a[x - 1] + b[y - 1] - c
    cost.append(tmp)
print(min(cost))
Buggy code:
A, B, C = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
mi = 10**6
for i in range(M):
  x, y, c = map(int, input().split())
  tmp = A[x-1] + B[y-1] - c
  if mi > tmp:
    mi = tmp
A.sort()
B.sort()
tmp = A[0] + B[0]
if mi > tmp:
  mi = tmp
print(mi)

Fixed code:
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
mi = 10**6
for i in range(M):
  x, y, c = map(int, input().split())
  tmp = a[x-1] + b[y-1] - c
  if mi > tmp:
    mi = tmp
a.sort()
b.sort()
tmp = a[0] + b[0]
if mi > tmp:
  mi = tmp
print(mi)
Buggy code:
# coding: utf-8
# Your code here!

x, y, m = [int(i) for i in input().split()]

a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
num = [min(a)+min(b)]

for _ in range(m):
    tmp = [int(i) for i in input().split()]
    num.append(a[tmp[0]]-1+b[tmp[1]]-1-tmp[2])

print(min(num))

Fixed code:
# coding: utf-8
# Your code here!

x, y, m = [int(i) for i in input().split()]

a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
num = [min(a)+min(b)]

for _ in range(m):
    tmp = [int(i) for i in input().split()]
    num.append(a[tmp[0]-1]+b[tmp[1]-1]-tmp[2])

print(min(num))
Buggy code:
# input
a_n, b_n, m = map(int, input().split())
a = input().split()
b = input().split()
x = [input().split() for i in range(m)]

# calc
min_price = 200000
for p in x:
   tmp_price = int(a[int(p[0])-1]) + int(b[int(p[1])-1]) - int(p[2])
   if tmp_price < min_price:
       min_price = tmp_price
print(min_price)       

Fixed code:
# input
a_n, b_n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
x = [input().split() for i in range(m)]

# calc
min_price = min(a) + min(b)
for p in x:
   tmp_price = int(a[int(p[0])-1]) + int(b[int(p[1])-1]) - int(p[2])
   if tmp_price < min_price:
       min_price = tmp_price
print(min_price)
Buggy code:
import sys
#input = sys.stdin.readline
A,B,M=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
xyc=[list(map(int,input().split())) for i in range(M)]
ans=[]
for i in range(M):
    ans.append(a[xyc[i][0]-1]+b[xyc[i][1]-1]-xyc[i][2])
print(min(ans))

Fixed code:
import sys
#input = sys.stdin.readline
A,B,M=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
xyc=[list(map(int,input().split())) for i in range(M)]
ans=min(a)+min(b)
for i in range(M):
    ans=min((a[xyc[i][0]-1]+b[xyc[i][1]-1]-xyc[i][2]),ans)
print(ans)
Buggy code:
    _,_,M=map(int,input().split())
    A=list(map(int,input().split()))
    B=list(map(int,input().split()))
    ans=min(A)+min(B)
    for a in range(M):
        x,y,c=map(int,input().split())
        x-=1
        y-=1
        ans=min(ans,A[x]+A[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 = map(int, input().split())
a = list(map(int, input().split())) 
b = list(map(int, input().split())) 

x = [0] * M
y = [0] * M
c = [0] * M

ans = 10 ** 5
for i in range(M):
    x[i], y[i], c[i] = map(int, input().split())
    p = a[x[i]-1] + b[y[i]-1] - c[i]
    if ans > p:
        ans = p
    
if ans > min(a) + min(b):
    ans = min(a) + min(b)
elif ans > min(a):
    ans = min(a)
else:
    ans = min(b)

print(ans)

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

x = [0] * M
y = [0] * M
c = [0] * M

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

print(ans)
Buggy code:
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a.sort()
b.sort()
disc = []
for i in range(M):
  disc.append(list(map(int,input().split())))
ans = a[0] + b[0]
for i in range(M):
  ans = min(a[disc[i][0]-1] + b[disc[i][1]-1] - disc[i][2], ans)     
    
print(a,b,ans)

Fixed code:
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
disc = []
for i in range(M):
  disc.append(list(map(int,input().split())))
ans = min(a) + min(b)
for i in range(M):
  ans = min(a[disc[i][0]-1] + b[disc[i][1]-1] - disc[i][2], ans)     
    
print(ans)
Buggy code:
a,b,m = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = [tuple(map(int,input().split())) for i in range(m)]
p = [min(a)+min(b)]
for t in c:
    p.append((p,a[t[0]-1]+b[t[1]-1]-t[2])
print(min(p))

Fixed code:
a,b,m = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = [tuple(map(int,input().split())) for i in range(m)]
p = min(a)+min(b)
for t in c:
    p = min(p,a[t[0]-1]+b[t[1]-1]-t[2])
print(p)
Buggy code:
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
x = [0]*M
y = [0]*M
c = [0]*M
for i in range(M):
    x[i], y[i], c[i] = map(int, input().split())
price = min(a) + min(b)
for j in range(M):
    if x[j] + y[j] - c[j] < price:
        price = x[j] + y[j] - c[j]
print(price)

Fixed code:
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
x = [0]*M
y = [0]*M
c = [0]*M
for i in range(M):
    x[i], y[i], c[i] = map(int, input().split())
price = min(a) + min(b)
for j in range(M):
    cprice = a[x[j]-1] + b[y[j]-1] - c[j]
    if cprice < price:
        price = cprice
print(price)
Buggy code:
A, B, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
l = [input().split() for i in range(m)]
ans = min(a) + min(b)
for i in range(m):
    ai = a[int(l[i][0]) - 1]
    bi = b[int(l[i][1]) - 1]
    ci = int(l[i][2])
    nc = ai + bi - ci
    ans = min(ans, nc)
print(nc)

Fixed code:
A, B, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
l = [input().split() for i in range(m)]
ans = min(a) + min(b)

for i in range(m):
    ai = a[int(l[i][0]) - 1]
    bi = b[int(l[i][1]) - 1]
    ci = int(l[i][2])
    nc = ai + bi - ci
    ans = min(ans, nc)
print(ans)
Buggy code:
import numpy as np
A, B, M = map(int,input().split())
a = np.array([int(num) for num in input().split()])
a_min = np.min(a)

b = np.array([int(num) for num in input().split()])
b_min = np.min(b)
total_min= a_min + b_min
for i in range(0, M):
    x, y, c = map(int,input().split())
    min_can = a[x-1] + b[y-1] -c
    if total_min > min_can:
        taotal_min = min_can
print(min_can)

Fixed code:
import numpy as np
A, B, M = map(int,input().split())
a = np.array([int(num) for num in input().split()])
a_min = np.min(a)

b = np.array([int(num) for num in input().split()])
b_min = np.min(b)
total_min= a_min + b_min

for i in range(0, M):
    x, y, c = map(int,input().split())
    min_can = a[x-1] + b[y-1] -c
    if total_min > min_can:
        total_min = min_can
print(total_min)