Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input());
A = list(map(int, input().split()));

ans = 0;

for i in range(len(A)):
  if min(A[:i+1]) == A[i]:
    ans += 1;
  else:
    pass;
  
print(ans);

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

ans = 0;
min_ = 2 * (10 ** 5);

for i in range(n):
  min_ = min(A[i], min_);
  if min_ == A[i]:
    ans += 1;
  else:
    pass;
print(ans);
Buggy python submission (verdict: Runtime Error):
n = int(input());
s = input();

ans = 0;

for i in range(len(s)):
  3_str = s[i:i+2];
  ans += int(3_str == "ABC");

print(ans);

Fixed submission:
n = int(input());
s = input();

ans = 0;

for i in range(n):
  three = s[i:i+3];
  ans += int(three == "ABC");

print(ans);
Buggy python submission (verdict: Runtime Error):
x = int(input());

for i in range(x + 1, 10**5 + 1):
  for k in range(2, i):
    if i % k != 0: #割り切れない
      continue;
    else: #割り切れた
      break;
  else:
    break;
  
print(i)

Fixed submission:
x = int(input());

for i in range(x, 10**6):
  for k in range(2, i):
    if i % k != 0: #割り切れない
      continue;
    else: #割り切れた
      break;
  else:
    break;
  
print(i)

Buggy python submission (verdict: Runtime Error):
x = int(input());

for i in range(x + 1, 10**5 + 1):
  for k in range(1, i):
    if i % k != 0: #割り切れない
      continue;
    else: #割り切れた
      break;
  else:
    continue;
  break;
  
print(i)
      

Fixed submission:
x = int(input());

for i in range(x, 10**6):
  for k in range(2, i):
    if i % k != 0: #割り切れない
      continue;
    else: #割り切れた
      break;
  else:
    break;
  
print(i)
Buggy python submission (verdict: Runtime Error):
import math;
a, b = map(int, input().split());
def lcm(x, y):
    return (x * y) // math.gcd(x, y);

print(lcm(a, b))

Fixed submission:
import fractions;
a, b = map(int, input().split());
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y);

print(lcm(a, b))
Buggy python submission (verdict: Runtime Error):
a, b, x = map(int, input().split())

for n in range(int(x / a), 10**9 + 1):
  if x >= a * n + b * len(str(n)):
    continue;
  else:
    break;
  
print(n - 1)

Fixed submission:
S = input();
day = ["SUN","MON","TUE","WED","THU","FRI","SAT"];

print(7 - day.index(S))

Buggy python submission (verdict: Runtime Error):
S = input();
day = [SUN,MON,TUE,WED,THU,FRI,SAT];

print(day.index(S)]

Fixed submission:
S = input();
day = ["SUN","MON","TUE","WED","THU","FRI","SAT"];

print(7 - day.index(S))
Buggy python submission (verdict: Runtime Error):
n = int(input());
s = input();

if n % 2 !== 0:
  print("No")
else:
  t = s[int(n/2) - 1]
  if t * 2 == s:
    print("Yes")
  else:
    print("No");
    


Fixed submission:
n = int(input());
s = input();

if n % 2 != 0:
  print("No")
else:
  t = s[:int(n/2)]
  if t * 2 == s:
    print("Yes")
  else:
    print("No");

Buggy python submission (verdict: Runtime Error):
n = int(input());
s = input();

if n % 2 !== 0:
  print("No")
else:
  t = s[n/2 - 1]
  if t * 2 == s:
    print("Yes")
  else:
    print("No");
    

Fixed submission:
n = int(input());
s = input();

if n % 2 != 0:
  print("No")
else:
  t = s[:int(n/2)]
  if t * 2 == s:
    print("Yes")
  else:
    print("No");
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())

print(max[a - 2 * b, 0])

Fixed submission:
a, b = map(int, input().split())
n = max([a - 2 * b, 0])
print(n)
Buggy python submission (verdict: Runtime Error):
import itertools

n = int(input())
D = list(map(int, input().split()))

list_ = itertools.combinations(range(n),2))
count = 0;

for i in range(len(list_)):
  count += D[list_[i][0]] + D[list_[i][1]];
  
print(count)


Fixed submission:
import itertools

n = int(input())
D = list(map(int, input().split()))

list_ = list(itertools.combinations(range(n),2))
count = 0;

for i in range(len(list_)):
  count += D[list_[i][0]] * D[list_[i][1]];
  
print(count)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input().split("")

s = list(set(s))

print(len(s))

Fixed submission:
n = int(input())
s = input()

new = s[0]
count = 1

for i in s:
  if new == i:
    continue;
  else:
    count += 1
    new = i
  
print(count)
Buggy python submission (verdict: Runtime Error):
x,k,d = map(int, input().split())
x = abs(x)
m = min(k,x//d)
x -= m*d
k -= m
if k%2: x = abs(x-d)
print(x)

Fixed submission:
s = input()
for i in ['RRR','RR','R']:
    if i in s:
        print(len(i));break
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
x,k,d = map(int, input().split())
x= abs(x)
m= min(k,x//d)
x -= m*d
k -= m
if k%2:
  x = abs(x-d)
print(x)

Fixed submission:
s = input()
for i in ['RRR','RR','R']:
    if i in s:
        print(len(i));break
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int, input().split())
a = list(map(int, input().split()))
limit, mul, m = n-k+1, [], 1
for i in range(limit):
    if i == 0:
        for j in a[i: k+i]:
            m *= j
    else:    
        print('Yes' if m < (m//a[i-1])*a[k+i-1] else 'No')
        m = (m//a[i-1])*a[k+i-1]

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

for i in range(n - k):
    if a[k+i] > a[i]:
        print('Yes')
    else:
        print('No')

Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int, input().split())
a = list(map(int, input().split()))
limit, mul, m = n-k+1, [], 1

for i in range(limit):
    if i == 0:
        for j in a[i: k+i]:
            m *= j
    else:
        m = (m//a[i-1])*a[k+i-1]
    mul.append(m)

for i in range(len(mul)-1):
    print('Yes' if mul[i]<mul[i+1] else 'No')

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

for i in range(n - k):
    if a[k+i] > a[i]:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
count = 0
for i in range(0, n+1, 2):
    if a[i]%2:
        count += 1
print(count)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
print(sum([i % 2 == 1 for i in a[::2]]))
Buggy python submission (verdict: Runtime Error):
def freq(my_list):
    count = {} 
    for i in my_list: 
        count[i] = count.get(i, 0) + 1
    return count

n = int(input())
l = list(map(int, input().split()))
s,f = sum(l), freq(l)
for _ in range(int(input())):
    x, y = map(int, input().split())
    if x in f:
        v = f[x]
        if y in f:
            f[y]+=v
            f.pop(x)
        else:
            f[y]=f.pop(x)
        s += (y-x)*v
    print(s)

Fixed submission:
i= input()
print('A' if (ord(i)>64 and ord(i)<91) else 'a')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int, input().split()))
for _ in range(int(input())):
    x, y = map(int, input().split())
    for i in range(n):
        if l[i] == x:
            l[i] = y
    print(sum(l))

Fixed submission:
def freq(my_list):
    count = {} 
    for i in my_list: 
        count[i] = count.get(i, 0) + 1
    return count

n = int(input())
l = list(map(int, input().split()))
s,f = sum(l), freq(l)
for _ in range(int(input())):
    x, y = map(int, input().split())
    if x in f.keys():
        v = f[x]
        if y in f.keys():
            f[y]+=v
            f.pop(x)
        else:
            f[y]=f.pop(x)
        s += (y-x)*v
    print(s)

Buggy python submission (verdict: Time Limit Exceeded):
input()
ip = "-".join(list(input().split()))
for _ in range(int(input())):
    x,y = input().split()
    ip = ip.replace(x,y)
    print(sum(list(map(int, ip.split('-')))))

Fixed submission:
def freq(my_list):
    count = {} 
    for i in my_list: 
        count[i] = count.get(i, 0) + 1
    return count

n = int(input())
l = list(map(int, input().split()))
s,f = sum(l), freq(l)
for _ in range(int(input())):
    x, y = map(int, input().split())
    if x in f.keys():
        v = f[x]
        if y in f.keys():
            f[y]+=v
            f.pop(x)
        else:
            f[y]=f.pop(x)
        s += (y-x)*v
    print(s)
Buggy python submission (verdict: Time Limit Exceeded):
mul = 1
input()
l = map(int, input().split())
for i in l:
    mul = mul * i
    if mul == 0:
        break
print(-1 if mul>1000000000000000000 else mul)

Fixed submission:
mul,f = 1, 0
input()
l = list(map(int, input().split()))
if l.__contains__(0):
    print(0)
    f = 1
else:
    for i in l:
        mul = mul * i
        if mul>1000000000000000000:
            print(-1); break;
    else:
        print( mul)
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
l, count = [], 0
for _ in range(k):
    input()
    l.append(list(map(int,input().split())))
for i in range(1,n):
    if i not in l[i-1]:
        count += 1
print(count)

Fixed submission:
n, k = map(int, input().split())
s = set(range(1, n+1))
for _ in range(k):
    d = int(input())
    for i in input().split():
        s.discard(int(i))
print(len(s))
Buggy python submission (verdict: Time Limit Exceeded):
a,b,n = map(int, input().split())
ans = 0
p = int(pow(n,0.5))
for x in range(n,p,-1):
    ans = max(int(a*x/b) - (a*int(x/b)),ans)
print(ans)

Fixed submission:
a, b, n = map(int,input().split())
x = min(n,b-1)
print(int(a*(x%b) / b))

Buggy python submission (verdict: Time Limit Exceeded):
a,b,n = map(int, input().split())
ans = 0
for x in range(n,n//4,-1):
    ans = max(int(a*x/b) - (a*int(x/b)),ans)
print(ans)

Fixed submission:
a, b, n = map(int,input().split())
x = min(n,b-1)
print(int(a*(x%b) / b))

Buggy python submission (verdict: Time Limit Exceeded):
a,b,n = map(int, input().split())
ans = 0
for x in range(n+1):
    ans = max(int(a*x/b) - (a*int(x/b)),ans)
print(ans)

Fixed submission:
a, b, n = map(int,input().split())
x = min(n,b-1)
print(int(a*(x%b) / b))

Buggy python submission (verdict: Time Limit Exceeded):
import math
result=[]; a, b, n = list(map(int,input().split()))
for x in range(n+1):
     result.append((math.floor(a*x / b)) - (a* math.floor(x/b)))
else:
    print(max(result))

Fixed submission:
a, b, n = map(int,input().split())
x = min(n,b-1)
print(int(a*(x%b) / b))

Buggy python submission (verdict: Runtime Error):
result=[]; a,b,n = list(map(int,input().split()))
for x in range(n+1):
  result.append((math.floor(a*x/b))-(a*math.floor(x/b)))
else:
  print(max(result))

Fixed submission:
a, b, n = map(int,input().split())
x = min(n,b-1)
print(int(a*(x%b) / b))
Buggy python submission (verdict: Runtime Error):
print('unsafe') if input() <= input() else print('safe')

Fixed submission:
s, w = list(map(int, input().split()))
print('safe' if s > w else 'unsafe')

Buggy python submission (verdict: Runtime Error):
print('unsafe') if input('w') >= input('s') else print('safe')

Fixed submission:
s, w = list(map(int, input().split()))
print('safe' if s > w else 'unsafe')
Buggy python submission (verdict: Time Limit Exceeded):
n= int(input())
l = list(map(int, input().split()))
print(*[l.count(i) for i in range(1,n+1)],sep='\n')

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = [0]*n
for i, a in enumerate(a):
     ans[a-1] += 1
print(*ans, sep="\n")
Buggy python submission (verdict: Runtime Error):
print((int(input()))**3/27)

Fixed submission:
n, m = list(map(int,input().strip().split()))
print(((n- 1)*(n))//2 + ((m-1)*(m))//2)
Buggy python submission (verdict: Runtime Error):
s=input().strip();	n=len(S)
print("Yes" if s==s[::-1] and s[:(n-1)//2]==s[:(n-1)//2][::-1] and s[(n+3)//2-1:]==s[(n+3)//2-1:][::-1] else "No")

Fixed submission:
s = list(input())
n = len(s); flag= 0
if s == s[::-1]:    flag += 1 ;
start, end = 0, ((n-1)//2)-1
while(end > start and flag == 1):
    if not(s[start] == s[end]):        break;
    start += 1 ; end -= 1
else:    flag += 1
start, end = (n+3)//2 -1, (n-1)
while(end > start and flag == 2):
    if not(s[start] == s[end]):        break;
    start += 1 ; end -= 1
else:    flag += 1
print('Yes' if flag == 3 else 'No')
Buggy python submission (verdict: Runtime Error):
print((int(input))**3/27)

Fixed submission:
n = float(input())
value = pow(n,3)/27
print(value)
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
low = int(min(a//0.08,b//0.1))
high = int(max((a+1)//0.08,(b+1)//0.1))
for i in range(low,high+1):
    if int(i*0.08)==a and int(i*0.1)==b:
        print(i);  break
else:
    print(-1)

Fixed submission:
s = input() 
print('No' if (s == 'BBB' or s == 'AAA') else 'Yes')
Buggy python submission (verdict: Runtime Error):
N = int(input())
X = sorted(list(map(int, readline().split())))
ans = 10**9+7
for p in range(0, 102):
    res = 0
    for x in X:
        res += (p-x)**2 
    ans = min(ans, res)
print(ans)

Fixed submission:
import sys
readline = sys.stdin.readline
N = int(readline())
X = list(map(int, readline().split()))
X.sort()

INF = 10**9+7
ans = INF
for p in range(0, 102):
    res = 0
    for x in X:
        res += (p-x)**2
    ans = min(ans, res)
print(ans)
Buggy python submission (verdict: Runtime Error):
def SieveOfEratosthenes(n): 
    prime = [True for i in range(10**5 + 1)] 
    p = 2
    while (p * p <= n): 
        if (prime[p] == True): 
            for i in range(p * 2, 10**5 + 1, p): 
                if prime[i]:
                    prime[i] = False
        p += 1
    prime[0], prime[1]= False, False
    count = 1
    while(True):
        if prime[p] and p>n:
            print(p)
            break
        p += 1
            
n = int(input())
SieveOfEratosthenes(n)

Fixed submission:
def SieveOfEratosthenes(n): 
    prime = [True for i in range(10**6 + 1)] 
    p = 2
    while (p * p <= n): 
        if (prime[p] == True): 
            for i in range(p * 2, 10**6 + 1, p): 
                if prime[i]:    prime[i] = False
        p += 1
    prime[0], prime[1] = False, False
    count = 1
    while(True):
        if prime[p] and p>=n:
            print(p);    break
        p += 1
            
n = int(input())
SieveOfEratosthenes(n)

Buggy python submission (verdict: Runtime Error):
def SieveOfEratosthenes(n): 
    prime = [True for i in range(10**5 + 1)] 
    p = 2
    while (p * p <= n): 
        if (prime[p] == True): 
            for i in range(p * 2, 10**5 + 1, p): 
                if prime[i]:
                    prime[i] = False
        p += 1
    prime[0], prime[1]= False, False
    count = 1
    while(True):
        if prime[p] and p>n:
            print(p)
            break
        p += 1
            
x = int(input())
SieveOfEratosthenes(n)

Fixed submission:
def SieveOfEratosthenes(n): 
    prime = [True for i in range(10**6 + 1)] 
    p = 2
    while (p * p <= n): 
        if (prime[p] == True): 
            for i in range(p * 2, 10**6 + 1, p): 
                if prime[i]:    prime[i] = False
        p += 1
    prime[0], prime[1] = False, False
    count = 1
    while(True):
        if prime[p] and p>=n:
            print(p);    break
        p += 1
            
n = int(input())
SieveOfEratosthenes(n)
Buggy python submission (verdict: Runtime Error):
input()
l = list(map(int,input().split()))
s = 0
s += 1/i for i in l
print(round(1/s,3))

Fixed submission:
input()
l = list(map(int,input().split()))
s = sum(1/i for i in l)
print(1/s)
Buggy python submission (verdict: Runtime Error):
n, x = map(int,input().split())
l = list(map(int, input().split()))
s = 0
count = 1
for i in L:
    s += i
    if s > x:
        break
    count += 1
print(count)

Fixed submission:
n, x = map(int,input().split())
l = list(map(int, input().split()))
s = 0
count = 1
for i in l:
    s += i
    if s > x:
        break
    count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
ab=sorted([list(map(int,input().split())) for i in range(n)])
shop,cost,rest=m,0,0
while True:
    if ab[shop][1]<rest:
        cost+=ab[shop][1]*ab[shop][0]
        rest-=ab[shop][1]
        shop+=1
    else:
        cost+=ab[shop][0]*rest
        break
print(cost)

Fixed submission:
n,m = map(int,input().split())
ab = sorted([list(map(int,input().split())) for i in range(n)])
shop,cost,rest=0,0,m
while True:
    if ab[shop][1]<rest:
        cost += ab[shop][1]*ab[shop][0]
        rest -= ab[shop][1]
        shop+=1
    else:
        cost+=ab[shop][0]*rest
        break
print(cost)
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
h = sorted([int(input()) for _ in range(n)])
print(min(h[j+k-1]-h[j] for j in range(n-k+1)))

Fixed submission:
n = int(input())
print("Christmas" + " Eve" * (25-n))
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
h = sorted([int(input()) for _ in range(n)])
print(min(ans[j+k-1]-ans[j] for j in range(n-k+1)))

Fixed submission:
n,k = map(int,input().split())
h = sorted([int(input()) for _ in range(n)])
ans = h[k-1]-h[0]
for i in range(n-k+1):
    m = h[i+k-1]-h[i]
    ans = min(m,ans)
print(ans)
Buggy python submission (verdict: Runtime Error):
l, ans = len(s), []
for i in range(0,l-2):
    n = s[i:i+3]
    ans.append(abs(753-int(n)))
print(min(ans))

Fixed submission:
s = input()
l, ans = len(s), []
for i in range(0,l-2):
    n = s[i:i+3]
    ans.append(abs(753-int(n)))
print(min(ans))
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
print(':(' if a > 8 or b > 8 'Yay!')

Fixed submission:
a,b = map(int,input().split())
print(':(' if a > 8 or b > 8 else 'Yay!')
Buggy python submission (verdict: Runtime Error):
a,b,c,x,y = map(int, input().split())
ans = 10**12
for i in range(0, max(x,y)*2+1, 2):
    xr = max(x-i//2, 0)
    yr = max(0, y-i//2)

    if ans > (i*c)+(xr*a)+(yr*b):
        ans = (i*c)+(xr*a)+(yr*B)

print(ans)

Fixed submission:
a,b,c,x,y = map(int, input().split())
ans = 10**12
for i in range(0, (max(x,y)*2)+1, 2):
    xr = max(x-(i//2), 0)
    yr = max(0, y-(i//2))

    if ans > (i*c)+(xr*a)+(yr*b):
        ans = (i*c)+(xr*a)+(yr*b)

print(ans)

Buggy python submission (verdict: Runtime Error):
ab,c,x,y=map(int,input().split())
ans=10**12
for i in range(0,(max(x,y)*2)+1,2):
    xr=max(x-i//2,0)
    yr=max(0,y-i//2)

    if ans>(i*c)+(xr*a)+(yr*b):
        ans=(i*c)+(xr*a)+(yr*B)

print(ans)

Fixed submission:
a,b,c,x,y = map(int, input().split())
ans = 10**12
for i in range(0, (max(x,y)*2)+1, 2):
    xr = max(x-(i//2), 0)
    yr = max(0, y-(i//2))

    if ans > (i*c)+(xr*a)+(yr*b):
        ans = (i*c)+(xr*a)+(yr*b)

print(ans)
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
l = list(map(int, input().split()))
freq = [0]*n+1
for i in l:
    freq[i]+=1
freq.sort()
vf = len(freq) - k if len(freq)> k else 0
print(sum(freq[:vf]))

Fixed submission:
n,k = map(int,input().split())
l = list(map(int, input().split()))
freq = [0]*(n+1)
for i in l:
    freq[i]+=1
freq.sort()
vf = len(freq) - k if len(freq)> k else 0
print(sum(freq[:vf]))

Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
l = list(map(int, input().split()))
freq = [0]*n
for i in l:
    freq[i]+=1
freq.sort()
print(sum(freq[:n-k+1]))

Fixed submission:
n,k = map(int,input().split())
l = list(map(int, input().split()))
freq = [0]*(n+1)
for i in l:
    freq[i]+=1
freq.sort()
vf = len(freq) - k if len(freq)> k else 0
print(sum(freq[:vf]))

Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
l = list(map(int, input().split()))
freq = [0]*n
for i in l:
    freq[i]+=1
freq.sort()
vf = len(freq) - k if len(freq)> k else 0
print(sum(freq[:vf]))

Fixed submission:
n,k = map(int,input().split())
l = list(map(int, input().split()))
freq = [0]*(n+1)
for i in l:
    freq[i]+=1
freq.sort()
vf = len(freq) - k if len(freq)> k else 0
print(sum(freq[:vf]))

Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
l = list(map(int, input().split()))
def counter(l):
    count = {}
    for i in l:
        count[i] = l.count(i)
    return sorted(count.values())

freq = counter(l)
vf = len(freq) - k if len(freq)> k else 0
print(sum(freq[:vf]))

Fixed submission:
n,k = map(int,input().split())
l = list(map(int, input().split()))
freq = [0]*(n+1)
for i in l:
    freq[i]+=1
freq.sort()
vf = len(freq) - k if len(freq)> k else 0
print(sum(freq[:vf]))

Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
l = map(int, input().split())
def counter(l):
    count = {}
    for i in l:
        count[i] = l.count(i)
    return sorted(count.values())

freq = counter(l)
print(len(freq) - k if len(freq)> k else 0)

Fixed submission:
n,k = map(int,input().split())
l = list(map(int, input().split()))
freq = [0]*(n+1)
for i in l:
    freq[i]+=1
freq.sort()
vf = len(freq) - k if len(freq)> k else 0
print(sum(freq[:vf]))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
result = 0
i = 0
for x in A[:N]:
  for y in A[i+1:]:
    result += x * y
  i += 1

print(result.__mod__(10**9 + 7))

Fixed submission:
D, T, S = map(int, input().split())
if D / S > T:
  print('No')
else:
  print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
pn = N

while True:
  if N%K == 0:
    print(0)
    break
  else:
    N = abs(N-K)
    if pn <= N:
      print(pn)
      break
    elif N == 0:
      print(0)
      break
    else:
      pn = N


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

result = N % K
if result <= abs(result-K):
  print(result)
elif result > abs(result-K):
  result = abs(result-K)
  print(result)
Buggy python submission (verdict: Time Limit Exceeded):
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
price_list = []

for s in a:
  for t in b:
    price_list.append(s + t)


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


min_price = price_list[0]

for n in price_list:
  if min_price >= n:
    min_price = n
  elif min_price < n:
    pass


print(min_price)

Fixed submission:
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
price_list = []

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


a.sort()
b.sort()
price_list.append(a[0]+b[0])
min_price = price_list[0]

for n in price_list:
  if min_price >= n:
    min_price = n
  elif min_price < n:
    pass


print(min_price)
Buggy python submission (verdict: Runtime Error):
N = int(input())
X = list(map(int, input().split()))
P = sum(X) // N
result1 = 0
result2 = 0

for x in X:
  result1 += (x - P)**2
  result2 += (x - P - 1)**2

if result1 < result2:
  result = result1
elif result1 > result2:
  result = result2


print(result)

Fixed submission:
N = int(input())
X = list(map(int, input().split()))
P = sum(X) // N
result1 = 0
result2 = 0

for x in X:
  result1 += (x - P)**2
  result2 += (x - P - 1)**2

if result1 <= result2:
  result = result1
elif result1 > result2:
  result = result2


print(result)
Buggy python submission (verdict: Runtime Error):
S = input()
i = 0
result = []
for a in S:
  if a == "A" or a == "C" or a == "G" or a == "T":
    i += 1
  else:
    result.append(i)
    i = 0


result.sort()
print(result[-1])

Fixed submission:
S = input()
i = 0
result = []
for a in S:
  if a == "A" or a == "C" or a == "G" or a == "T":
    i += 1
  else:
    result.append(i)
    i = 0

result.append(i)
result.sort()
print(result[-1])
Buggy python submission (verdict: Runtime Error):
D,T,S = map(input().split())
result = D / S
if T <= result :
  print('Yes')
else:
  print('No')  

Fixed submission:
D,T,S = map(int,input().split())
result = D / S
if T >= result:
  print('Yes')
else:
  print('No')