Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
S = input()

ans = 0
pre = ''

while True:
    flag = 1
    for i, c in enumerate(S):
        if pre == '':
            pre = c
            continue

        if (pre == '1' and c == '0') or (pre == '0' and c == '1'):
            if i + 1 != len(S):
                S = S[:i - 1] + S[i + 1:]
            else:
                S = S[:i - 1]
            ans += 2
            flag = 0
            break
        pre = c
    if flag:
        break
print(ans)


Fixed submission:
S = input()

# while True:
#     flag = 1
#     for i, c in enumerate(S):
#         if pre == '':
#             pre = c
#             continue

#         if (pre == '1' and c == '0') or (pre == '0' and c == '1'):
#             if i + 1 != len(S):
#                 S = S[:i - 1] + S[i + 1:]
#             else:
#                 S = S[:i - 1]
#             ans += 2
#             flag = 0
#             break
#         pre = c
#     if flag:
#         break
a = S.count("1")
b = S.count("0")
print(min(a, b) * 2)

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

ans = 0
pre = ''

while True:
    flag = 1
    for i, c in enumerate(S):
        if pre == '':
            pre = c
            continue

        if (pre == '1' and c == '0') or (pre == '0' and c == '1'):
            if i + 1 != len(S):
                S = S[:i - 1] + S[i + 1:]
            else:
                S = S[:i - 1]
            ans += 2
            flag = 0
            break
    if flag:
        break
print(ans)


Fixed submission:
S = input()

# while True:
#     flag = 1
#     for i, c in enumerate(S):
#         if pre == '':
#             pre = c
#             continue

#         if (pre == '1' and c == '0') or (pre == '0' and c == '1'):
#             if i + 1 != len(S):
#                 S = S[:i - 1] + S[i + 1:]
#             else:
#                 S = S[:i - 1]
#             ans += 2
#             flag = 0
#             break
#         pre = c
#     if flag:
#         break
a = S.count("1")
b = S.count("0")
print(min(a, b) * 2)
Buggy python submission (verdict: Runtime Error):
import numpy as np
N = input()
h = np.array(list(map(int, input().split())))

a = np.zeros(N)
h_min = min(h)
tmp = (h >= h_min+1)*1

cnt = 0
for idx, i in enumerate(tmp):
    if idx==0:
        a0 = i
        if i==1:
            cnt+=1
        continue
        
    if idx==a0:
        continue
    else:
        cnt+=1
else:
    if i==0:
        cnt-=1
        
print(cnt+h_min)

Fixed submission:
import numpy as np
N = int(input())
h = np.array(list(map(int, input().split())))

# N =  8
# h = np.array(list(map(int, "4 23 75 0 23 96 50 100".split())))

a = np.zeros(N)
h_min = min(h)
h_max = max(h)
n_loop = h_max - h_min

cnt = 0
for zzz in range(n_loop):
    tmp = (h >= h_min+1+zzz)*1
#     print(tmp)
    for idx, i in enumerate(tmp):
        if idx==0:
            first = i
            a0 = i
            continue
            
        if i==a0:
            continue
        else:
            if i==1:
                cnt+=1
            a0 = i
    else:
        if first==1:
            cnt+=1
            
print(cnt+h_min)

Buggy python submission (verdict: Runtime Error):
import numpy as np
N = input()
h = list(map(int, input().split()))

a = np.zeros(N)
h_min = min(h)
tmp = (h >= h_min+1)*1

cnt = 0
for idx, i in enumerate(tmp):
    if idx==0:
        a0 = i
        if i==1:
            cnt+=1
        continue
        
    if idx==a0:
        continue
    else:
        cnt+=1
else:
    if i==0:
        cnt-=1
        
print(cnt+h_min)

Fixed submission:
import numpy as np
N = int(input())
h = np.array(list(map(int, input().split())))

# N =  8
# h = np.array(list(map(int, "4 23 75 0 23 96 50 100".split())))

a = np.zeros(N)
h_min = min(h)
h_max = max(h)
n_loop = h_max - h_min

cnt = 0
for zzz in range(n_loop):
    tmp = (h >= h_min+1+zzz)*1
#     print(tmp)
    for idx, i in enumerate(tmp):
        if idx==0:
            first = i
            a0 = i
            continue
            
        if i==a0:
            continue
        else:
            if i==1:
                cnt+=1
            a0 = i
    else:
        if first==1:
            cnt+=1
            
print(cnt+h_min)
Buggy python submission (verdict: Runtime Error):
def main():
    n = input()
    before = ''
    words = set()

    for i in range(n):
        w = input()
        if w not in words:
            words.add(w)
        else:
            print('No')
            return

        if before == '':
            before = w
            continue

        if before[-1] != w[0]:
            print('No')
            return

    print('Yes')


main()


Fixed submission:
def main():
    n = int(input())
    before = ''
    words = set()

    for i in range(n):
        w = input()
        if w not in words:
            words.add(w)
        else:
            print('No')
            return

        if before == '':
            before = w
            continue

        if before[-1] != w[0]:
            print('No')
            return
        before = w

    print('Yes')


main()
Buggy python submission (verdict: Runtime Error):
import numpy as np


def yoko(row):
    cnt = sum(row)
    return cnt == len(row)


def main():
    h, w = map(int, input().split(' '))
    a = []

    for i in range(h):
        b = input()
        a += [1 if c == '.' else 0 for c in b]
    a = np.array(a).reshape(h, w)

    while True:
        cnt = 0
        del_list = []
        for i in range(len(a)):
            judge = yoko(a[i])
            if judge:
                del_list.append(i)

        if len(del_list):
            for idx in del_list:
                a = np.delete(a, idx, axis=0)
        else:
            cnt += 1

        a = a.T

        del_list = []
        for i in range(len(a)):
            judge = yoko(a[i])
            if judge:
                del_list.append(i)

        if len(del_list):
            for idx in del_list:
                a = np.delete(a, idx, axis=0)
        else:
            cnt += 1

        a = a.T

        if cnt >= 2:
            break

    for i in range(len(a)):
        r = ''
        for j in a[i]:
            if j == 1:
                r += '.'
            else:
                r += '#'
        print(r)


main()


Fixed submission:
import numpy as np


def yoko(row):
    cnt = sum(row)
    return cnt == len(row)


def main():
    h, w = map(int, input().split(' '))
    a = []

    for i in range(h):
        b = input()
        a += [1 if c == '.' else 0 for c in b]
    a = np.array(a).reshape(h, w)

    while True:
        cnt = 0
        del_list = []
        for i in range(len(a)):
            judge = yoko(a[i])
            if judge:
                del_list.append(i)

        if len(del_list):
            del_cnt = 0
            for idx in del_list:
                a = np.delete(a, idx - del_cnt, axis=0)
                del_cnt += 1
        else:
            cnt += 1

        a = a.T

        del_list = []
        for i in range(len(a)):
            judge = yoko(a[i])
            if judge:
                del_list.append(i)

        if len(del_list):
            del_cnt = 0
            for idx in del_list:
                a = np.delete(a, idx - del_cnt, axis=0)
                del_cnt += 1
        else:
            cnt += 1

        a = a.T

        if cnt >= 2:
            break

    for i in range(len(a)):
        r = ''
        for j in a[i]:
            if j == 1:
                r += '.'
            else:
                r += '#'
        print(r)


main()
Buggy python submission (verdict: Runtime Error):
A, B = list(map(int, input().split()))

begin = int(min(A // 0.08, B // 0.10))
end = int(max((A + 1) // 0.08, (B + 1) // 0.10))

for n in range(begin, end+1):
  if int(n * 0.08) == A and int(n * 0.1) == B:
    print(n)
    break
    else:
      print(-1)


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

begin = int(min(A // 0.08, B // 0.10))
end = int(max((A + 1) // 0.08, (B + 1) // 0.10))

for n in range(begin, end+1):
    if int(n * 0.08) == A and int(n * 0.1) == B:
        print(n)
        break
else:
    print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
Query = []

for _ in range(Q):
    Query += [input()]

reversed = False
for i, q in enumerate(Query):
    if q == "1":
        reversed = not reversed
        # S = S[::-1]
    else:
        Ti, Fi, Ci = list(q.split())
        # print(f"Fi:{Fi} S:{S} reversed:{reversed} Ci:{Ci}")
        if Fi == "1":
            if not reversed:
                S = Ci + S
            else:
                S = S + Ci
        elif Fi == "2":
            # print(f"S:{S} reversed:{reversed} Ci:{Ci}")
            if not reversed:
                S = S + Ci
            else:
                S = Ci + S
    # print(f"i:{i} S:{S}")

if reversed:
    print(S[::-1])
else:
    print(S)


Fixed submission:
from collections import deque
S = input()
Q = int(input())
Query = []

S = deque([S])

for _ in range(Q):
    Query += [input()]

reversed = False
for i, q in enumerate(Query):
    if q == "1":
        reversed = not reversed
        # S = S[::-1]
    else:
        Ti, Fi, Ci = list(q.split())
        # print(f"Fi:{Fi} S:{S} reversed:{reversed} Ci:{Ci}")
        if Fi == "1":
            if not reversed:
                S.appendleft(Ci)
                # S = Ci + S
            else:
                S.append(Ci)
                # S = S + Ci
        elif Fi == "2":
            # print(f"S:{S} reversed:{reversed} Ci:{Ci}")
            if not reversed:
                S.append(Ci)
                # S = S + Ci
            else:
                S.appendleft(Ci)
                # S = Ci + S
    # print(f"i:{i} S:{S}")

s = "".join(S)

if reversed:
    print(s[::-1])
else:
    print(s)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
Query = []

for _ in range(Q):
    Query += [input()]

for i, q in enumerate(Query):
    if q == "1":
        S = S[::-1]
    else:
        Ti, Fi, Ci = list(q.split())
        if Fi == "1":
            S = Ci + S
        elif Fi == "2":
            S = S + Ci
    # print(f"i:{i} S:{S}")

print(S)


Fixed submission:
from collections import deque
S = input()
Q = int(input())
Query = []

S = deque([S])

for _ in range(Q):
    Query += [input()]

reversed = False
for i, q in enumerate(Query):
    if q == "1":
        reversed = not reversed
        # S = S[::-1]
    else:
        Ti, Fi, Ci = list(q.split())
        # print(f"Fi:{Fi} S:{S} reversed:{reversed} Ci:{Ci}")
        if Fi == "1":
            if not reversed:
                S.appendleft(Ci)
                # S = Ci + S
            else:
                S.append(Ci)
                # S = S + Ci
        elif Fi == "2":
            # print(f"S:{S} reversed:{reversed} Ci:{Ci}")
            if not reversed:
                S.append(Ci)
                # S = S + Ci
            else:
                S.appendleft(Ci)
                # S = Ci + S
    # print(f"i:{i} S:{S}")

s = "".join(S)

if reversed:
    print(s[::-1])
else:
    print(s)
Buggy python submission (verdict: Runtime Error):
    N = int(input())
    print(int((N / 2) + 0.9))

Fixed submission:
N = int(input())
print(int((N / 2) + 0.9))
Buggy python submission (verdict: Time Limit Exceeded):
N, K = list(map(int, input().split()))
p = list(map(int, input().split()))

expected_value = []
for i in range(len(p)):
    value = 0
    for j in range(1, p[i] + 1):
        value += j / p[i]
    expected_value.append(value)

### K個合算した数値の配列
cumsum = []
cumsum_temp = 0
for i in range(len(p) - K + 1):
    if i == 0:
        cumsum_temp = sum(expected_value[:K])
    else:
        cumsum_temp = cumsum_temp - expected_value[i - 1] + expected_value[i + K - 1]
    cumsum.append(cumsum_temp)
# print(f"N:{N} K:{K} expected_value:{expected_value} cumsum:{cumsum}")

print(max(cumsum))



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

expected_value = []
for i in range(len(p)):
    expected_value.append((p[i] + 1)/ 2)

### K個合算した数値の配列
cumsum = []
cumsum_temp = 0
for i in range(len(p) - K + 1):
    if i == 0:
        cumsum_temp = sum(expected_value[:K])
    else:
        cumsum_temp = cumsum_temp - expected_value[i - 1] + expected_value[i + K - 1]
    cumsum.append(cumsum_temp)
# print(f"N:{N} K:{K} expected_value:{expected_value} cumsum:{cumsum}")

print(max(cumsum))

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

expected_value = []
for i in range(len(p)):
    value = 0
    for j in range(1, p[i] + 1):
        value += j / p[i]
    expected_value.append(value)

### K個合算した数値の配列
cumsum = []
cumsum_temp = 0
for i in range(len(p) - K):
    if i == 0:
        cumsum_temp = sum(expected_value[:K])
    else:
        cumsum_temp = cumsum_temp - expected_value[i - 1] + expected_value[i + K]
    cumsum.append(cumsum_temp)

print(max(cumsum))



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

expected_value = []
for i in range(len(p)):
    expected_value.append((p[i] + 1)/ 2)

### K個合算した数値の配列
cumsum = []
cumsum_temp = 0
for i in range(len(p) - K + 1):
    if i == 0:
        cumsum_temp = sum(expected_value[:K])
    else:
        cumsum_temp = cumsum_temp - expected_value[i - 1] + expected_value[i + K - 1]
    cumsum.append(cumsum_temp)
# print(f"N:{N} K:{K} expected_value:{expected_value} cumsum:{cumsum}")

print(max(cumsum))
Buggy python submission (verdict: Runtime Error):
S = '_' + input()
### dp[i文字目][直前に見た文字] = 分割数
dp = []
for _ in range(len(S)):
    dp += [{}]
dp[1][S[1:2]] = 1
index = 1
while index < len(S):
    for k, v in dp[index].items():
        if index + 1 < len(S):
            s = S[index: index + 1]
            if s != k:
                if not s in dp[index + 1]:
                    dp[index + 1][s] = v + 1
                elif s in dp[index + 1] and dp[index + 1][s] < v + 1:
                    dp[index + 1][s] = v + 1
        if index + 2 < len(S):
            s = S[index: index + 2]
            if s != k:
                if not s in dp[index + 2]:
                    dp[index + 2][s] = v + 1
                elif s in dp[index + 2] and dp[index + 2][s] < v + 1:
                    dp[index + 2][s] = v + 1
    index += 1
# print(f'dp:{dp}', file=sys.stderr)
print(max([v for k, v in dp[-1].items()]))

Fixed submission:
S = '_' + input()
### dp[i文字目まで読んだ][直前に読んだ文字] = 分割数
dp = []
for _ in range(len(S) + 1):
    dp += [{}]
if len(S) == 2:
    print(1)
else:
    dp[2][S[1:2]] = 1
    dp[3][S[1:3]] = 1
    index = 2
    while index < len(S):
        for k, v in dp[index].items():
            if index + 1 <= len(S):
                s = S[index: index + 1]
                # print(f"index:{index} k:{k} v:{v} s:{s}", file=sys.stderr)
                if s != k:
                    if not s in dp[index + 1]:
                        dp[index + 1][s] = v + 1
                    elif s in dp[index + 1] and dp[index + 1][s] < v + 1:
                        dp[index + 1][s] = v + 1
            if index + 2 <= len(S):
                s = S[index: index + 2]
                if s != k:
                    if not s in dp[index + 2]:
                        dp[index + 2][s] = v + 1
                    elif s in dp[index + 2] and dp[index + 2][s] < v + 1:
                        dp[index + 2][s] = v + 1
        index += 1
    # print(f'len:{len(S)} dp:{dp}', file=sys.stderr)
    print(max([v for k, v in dp[-1].items()]))
Buggy python submission (verdict: Runtime Error):
from math import gcd

N, X = list(map(int, input().split()))
x = list(map(int, input().split()))

x2 = x.copy() + [X]
x2 = sorted(x2)
diffs = []
for i in range(1, len(x2)):
    diffs.append(x2[i] - x2[i - 1])
if len(diffs) == 1:
    print(diffs[0])
else:
    diffs_gcd = gcd(diffs[0], diffs[1])
    for i in range(2, len(diffs)):
        diffs_gcd = gcd(diffs_gcd, diffs[i])
    print(diffs_gcd)

Fixed submission:
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

N, X = list(map(int, input().split()))
x = list(map(int, input().split()))

x2 = x.copy() + [X]
x2 = sorted(x2)
diffs = []
for i in range(1, len(x2)):
    diffs.append(x2[i] - x2[i - 1])
if len(diffs) == 1:
    print(diffs[0])
else:
    diffs_gcd = gcd(diffs[0], diffs[1])
    for i in range(2, len(diffs)):
        diffs_gcd = gcd(diffs_gcd, diffs[i])
    print(diffs_gcd)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = list(map(int, input().split()))
result = 0
pos = [(-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 0), (0, 1), (1, -1), (1, 0), (1, 1)]
for i in range(N):
    for j in range(M):
        num = 0
        for p in pos:
            i_dest = i + p[0]
            j_dest = j + p[1]
            if 0 <= i_dest < N and 0 <= j_dest < M:
                num += 1
        if num % 2 != 0:
            result += 1
print(result)


Fixed submission:
N, M = list(map(int, input().split()))
result = 0
if N == 1 and M == 1:
    result = 1
elif N == 1:
    result = M - 2
elif M == 1:
    result = N - 2
else:
    result = (N - 2) * (M - 2)
print(result)
Buggy python submission (verdict: Time Limit Exceeded):
N, Y = list(map(int, input().split()))

q = [(N, 0, 0)]
while len(q) > 0:
    hyp = q.pop()
    num = hyp[0] + hyp[1] + hyp[2]
    currency = 10000 * hyp[0] + 5000 * hyp[1] + 1000 * hyp[2]
    if num == N and currency == Y:
        q.append(hyp)
        break
    if currency < Y:
        continue
    
    if hyp[0] >= 1:
        #### 10000円札 → 5000円札 の場合
        q.append((hyp[0] - 1, hyp[1] + 1, hyp[2]))
        #### 10000円札 → 1000円札 の場合
        q.append((hyp[0] - 1, hyp[1], hyp[2] + 1))

    #### 5000円札 x 1 → 1000円札 の場合
    if hyp[1] >= 1:
        q.append((hyp[0], hyp[1] - 1, hyp[2] + 1))

if len(q) > 0:
    print("{} {} {}".format(q[-1][0], q[-1][1], q[-1][2]))
else:
    print("-1 -1 -1")

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

result = (-1, -1, -1)
for x in range(N + 1):
    for y in range(N + 1):
        if x + y > N:
            break
        if 10000 * x + 5000 * y + 1000 * (N - x - y) == Y:
            result = (x, y, N - x - y)
print("{} {} {}".format(result[0], result[1], result[2]))

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

q = [(N, 0, 0)]
while len(q) > 0:
    hyp = q.pop()
    num = hyp[0] + hyp[1] + hyp[2]
    currency = 10000 * hyp[0] + 5000 * hyp[1] + 1000 * hyp[2]
    if num == N and currency == Y:
        q.append(hyp)
        break
    if currency < Y:
        continue
    
    #### 10000円札 → 5000円札 x 2 の場合
    q.append((hyp[0] - 1, hyp[1] + 1, hyp[2]))
    q.append((hyp[0] - 1, hyp[1], hyp[2] + 1))

    #### 5000円札 x 1 → 1000円札 x 5 の場合
    if hyp[1] >= 1:
        q.append((hyp[0], hyp[1] - 1, hyp[2] + 1))

if len(q) > 0:
    print(f"{q[-1][0]} {q[-1][1]} {q[-1][2]}")
else:
    print("-1 -1 -1")

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

result = (-1, -1, -1)
for x in range(N + 1):
    for y in range(N + 1):
        if x + y > N:
            break
        if 10000 * x + 5000 * y + 1000 * (N - x - y) == Y:
            result = (x, y, N - x - y)
print("{} {} {}".format(result[0], result[1], result[2]))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

X = int(input())

q = deque()
q.append((0, 1))

while len(q) > 0:
    pos = q.popleft()
    if pos[0] + pos[1] == X or pos[0] - pos[1] == X:
        print(pos[1])
        break
    q.append((pos[0] + pos[1], pos[1] + 1))
    q.append((pos[0] - pos[1], pos[1] + 1))
    q.append((pos[0]         , pos[1] + 1))


Fixed submission:
X = int(input())
t = 1

while True:
    if t * (t + 1) / 2 >= X:
        print(t)
        break
    t += 1
Buggy python submission (verdict: Time Limit Exceeded):
import sys

n = int(sys.stdin.readline().rstrip())
s = sys.stdin.readline().rstrip()
r = []
b = []
g = []
for i, si in enumerate(s):
    if si == 'R':
        r.append(i + 1)
    elif si == 'G':
        g.append(i + 1)
    elif si == 'B':
        b.append(i + 1)
count = 0
gb = sorted(g + b)
br = sorted(b + r)
rg = sorted(r + g)
for i, si in enumerate(s):
    tmp = None
    if si == 'R':
        tmp = gb
    elif si == 'G':
        tmp = br
    else:
        tmp = rg
    for j in tmp:
        if j < i + 1:
            continue
        tmp2 = None
        # print(si, s[j-1])
        if (si == 'R' and s[j-1] == 'G') or (si == 'G' and s[j-1] == 'R'):
            tmp2 = b
        elif (si == 'R' and s[j-1] == 'B') or (si == 'B' and s[j-1] == 'R'):
            tmp2 = g
        elif (si == 'G' and s[j-1] == 'B') or (si == 'B' and s[j-1] == 'G'):
            tmp2 = r
        for k in tmp2:
            if k < j:
                continue
            if j - (i + 1) != k - j:
                # print(i + 1, j, k)
                count += 1
print(count)

Fixed submission:
import sys

n = int(sys.stdin.readline().rstrip())
s = sys.stdin.readline().rstrip()
r = []
b = []
g = []
for i, si in enumerate(s):
    if si == 'R':
        r.append(i + 1)
    elif si == 'G':
        g.append(i + 1)
    elif si == 'B':
        b.append(i + 1)
count = 0
for i in range(n):
    for j in range(i + 1, n):
        k = j + j - i
        if k < n and s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            count += 1
print(len(r) * len(g) * len(b) - count)
Buggy python submission (verdict: Runtime Error):
import sys

A, B, M = map(int, sys.stdin.readline().rstrip().split())
a = list(map(int, sys.stdin.readline().rstrip().split()))
b = list(map(int, sys.stdin.readline().rstrip().split()))
xyc = [list(map(int, sys.stdin.readline().rstrip().split())) for i in range(M)]
mans = min(a) + min(b)
ans = mans
for xyci in xyc:
    tmp = a[xyci[0] - 1] + a[xyci[1] - 1] - xyci[2]
    if ans > tmp:
        ans = tmp

print(ans)

Fixed submission:
import sys

A, B, M = map(int, sys.stdin.readline().rstrip().split())
a = list(map(int, sys.stdin.readline().rstrip().split()))
b = list(map(int, sys.stdin.readline().rstrip().split()))
xyc = [list(map(int, sys.stdin.readline().rstrip().split())) for i in range(M)]
ans = min(a) + min(b)

for xyci in xyc:
    x, y, c = xyci
    tmp = a[x - 1] + b[y - 1] - c
    if ans > tmp:
        ans = tmp

print(ans)

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

A, B, M = map(int, sys.stdin.readline().rstrip().split())
a = list(map(int, sys.stdin.readline().rstrip().split()))
b = list(map(int, sys.stdin.readline().rstrip().split()))
xyc = [list(map(int, sys.stdin.readline().rstrip().split())) for i in range(M)]
ans = 10 ** 9 + 7
mans = min(a) + min(b)
for xyci in xyc:
    tmp = a[xyci[0] - 1] + a[xyci[1] - 1] - xyci[2]
    if ans > tmp:
        ans = tmp

print(min(tmp, mans))


Fixed submission:
import sys

A, B, M = map(int, sys.stdin.readline().rstrip().split())
a = list(map(int, sys.stdin.readline().rstrip().split()))
b = list(map(int, sys.stdin.readline().rstrip().split()))
xyc = [list(map(int, sys.stdin.readline().rstrip().split())) for i in range(M)]
ans = min(a) + min(b)

for xyci in xyc:
    x, y, c = xyci
    tmp = a[x - 1] + b[y - 1] - c
    if ans > tmp:
        ans = tmp

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin

n = int(stdin.readline().rstrip())
ans = 0
for i in range(n):
    ans += i
print(ans)

Fixed submission:
from sys import stdin

n = int(stdin.readline().rstrip())
ans = 0
ans = (n-1) * (n) // 2

print(ans)

Buggy python submission (verdict: Runtime Error):
from sys import stdin

n = int(stdin.readline().rstrip())
ans = 0

def solve(n):
    for i in range(n):
        ans += i
    return ans

print(solve(n))

Fixed submission:
from sys import stdin

n = int(stdin.readline().rstrip())
ans = 0
ans = (n-1) * (n) // 2

print(ans)

Buggy python submission (verdict: Runtime Error):
from sys import stdin

n = int(stdin.readline().rstrip())
ans = 0

from numba import njit

@njit
def solve(n):
    for i in range(n):
        ans += i
    return ans

print(solve(n))

Fixed submission:
from sys import stdin

n = int(stdin.readline().rstrip())
ans = 0
ans = (n-1) * (n) // 2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin

n = int(stdin.readline().rstrip())
ans = 0
for i in range(n):
    ans += i
print(ans)

Fixed submission:
from sys import stdin

n = int(stdin.readline().rstrip())
ans = 0
ans = (n-1) * (n) // 2

print(ans)