Buggy python submission (verdict: Runtime Error):
a, b, m = input().split()
a, b, m = int(a), int(b), int(m)
a_values = input().split()
b_values = input().split()
m_values = {}
for i in range(m):
    m_values[i] = input().split()

min = int(a_values[int(m_values[0][0])-1]) + int(b_values[int(m_values[0][1])-1]) - int(m_values[0][2])
for i in range(1, m):
    now = int(a_values[int(m_values[i][0])-1]) + int(b_values[int(m_values[i][1])-1]) - int(m_values[i][2])
    if min > now:
        min = now
now = int(min(a_values)) + int(min(b_values))
if min > now:
  print(now)
else:
  print(min)

Fixed submission:
a, b, m = input().split()
a, b, m = int(a), int(b), int(m)
a_values = input().split()
b_values = input().split()
m_values = {}
for i in range(m):
    m_values[i] = input().split()

min_num = int(a_values[int(m_values[0][0]) - 1]) + int(b_values[int(m_values[0][1]) - 1]) - int(m_values[0][2])
for i in range(1, m):
    now = int(a_values[int(m_values[i][0]) - 1]) + int(b_values[int(m_values[i][1]) - 1]) - int(m_values[i][2])
    if min_num > now:
        min_num = now
now = int(min(a_values)) + int(min(b_values))
if min_num > now:
    print(now)
else:
    print(min_num)

Buggy python submission (verdict: Time Limit Exceeded):
a, b, m = input().split()
a, b, m = int(a), int(b), int(m)
a_values = input().split()
b_values = input().split()
m_values = {}
for i in range(m):
    m_values[i] = input().split()

min = int(a_values[int(m_values[0][0])-1]) + int(b_values[int(m_values[0][1])-1]) - int(m_values[0][2])
for i in range(1, m):
    now = int(a_values[int(m_values[i][0])-1]) + int(b_values[int(m_values[i][1])-1]) - int(m_values[i][2])
    if min > now:
        min = now
for i in a_values:
    for j in b_values:
        now = int(i) + int(j)
        if min > now:
            min = now
print(min)

Fixed submission:
a, b, m = input().split()
a, b, m = int(a), int(b), int(m)
a_values = input().split()
b_values = input().split()
m_values = {}
for i in range(m):
    m_values[i] = input().split()

min_num = int(a_values[int(m_values[0][0]) - 1]) + int(b_values[int(m_values[0][1]) - 1]) - int(m_values[0][2])
for i in range(1, m):
    now = int(a_values[int(m_values[i][0]) - 1]) + int(b_values[int(m_values[i][1]) - 1]) - int(m_values[i][2])
    if min_num > now:
        min_num = now
now = int(min(a_values)) + int(min(b_values))
if min_num > now:
    print(now)
else:
    print(min_num)

Buggy python submission (verdict: Runtime Error):
a, b, m = input().split()
a, b, m = int(a), int(b), int(m)
a_values = input().split()
b_values = input().split()
m_values = {}
for i in range(m):
  m[i] = input().split()

min = int(a_values[m[0][0]]) + int(b_values[m[0][1]]) - int(m[0][2])
for i in range(1, m):
  now = int(a_values[m[i][0]]) + int(b_values[m[i][1]]) - int(m[i][2])
  if min > now:
    min = now
print(min)

Fixed submission:
a, b, m = input().split()
a, b, m = int(a), int(b), int(m)
a_values = input().split()
b_values = input().split()
m_values = {}
for i in range(m):
    m_values[i] = input().split()

min_num = int(a_values[int(m_values[0][0]) - 1]) + int(b_values[int(m_values[0][1]) - 1]) - int(m_values[0][2])
for i in range(1, m):
    now = int(a_values[int(m_values[i][0]) - 1]) + int(b_values[int(m_values[i][1]) - 1]) - int(m_values[i][2])
    if min_num > now:
        min_num = now
now = int(min(a_values)) + int(min(b_values))
if min_num > now:
    print(now)
else:
    print(min_num)