Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from decimal import *
a, b, c = map(int, input().split())

print("Yes" if sqrt(Decimal(a)) + sqrt(Decimal(b)) < sqrt(Decimal(c)) else "No")

Fixed submission:
from decimal import *
a, b, c = map(int, input().split())

print("Yes" if Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt() else "No")

Buggy python submission (verdict: Runtime Error):
from decimal import *
a, b, c = map(int, input().split())

print("Yes" if Decimal(a)) + sqrt(Decimal(b)) < sqrt(Decimal(c)) else "No")

Fixed submission:
from decimal import *
a, b, c = map(int, input().split())

print("Yes" if Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt() else "No")

Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
print("Yes" if sqrt(a*10000000) + sqrt(b*10000000) < sqrt(c*10000000) else "No")

Fixed submission:
from decimal import *
a, b, c = map(int, input().split())

print("Yes" if Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt() else "No")

Buggy python submission (verdict: Runtime Error):
from decimal import *
from math import *

getcontext().prec = 1000
a, b, c = map(int, input().split())

print("Yes" if Decimal(a) ** 0.5 + Decimal(b) ** 0.5 < Decimal(c) ** 0.5 else "No")

Fixed submission:
from decimal import *
a, b, c = map(int, input().split())

print("Yes" if Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt() else "No")
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())

if n == 1 and m == 0:
  print(0)
  exit()

ans = [-1] * n


for i in range(m):
    s, c = map(int, input().split())
    s -= 1
    if ans[s] != -1 and ans[s] != c:
        print(-1)
        exit()

    else:
        ans[s] = c
        
elif ans[0] == 0 and n >= 2:
    print(-1)
    exit()
    
elif ans[0] == -1:
    ans[0] = 1

a = ""
for i in ans:
    a += str(i) if i != -1 else "0"
print(a)


Fixed submission:
n, m = map(int, input().split())

if n == 1 and m == 0:
  print(0)
  exit()

ans = [-1] * n


for i in range(m):
    s, c = map(int, input().split())
    s -= 1
    if ans[s] != -1 and ans[s] != c:
        print(-1)
        exit()

    else:
        ans[s] = c

if ans[0] == 0 and n >= 2:
    print(-1)
    exit()

elif ans[0] == -1:
    ans[0] = 1

a = ""
for i in ans:
    a += str(i) if i != -1 else "0"
print(a)
Buggy python submission (verdict: Runtime Error):
from math import gcd
from fractions import gcd

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

def lcm(a,b):
    return a * b // gcd(a,b)

print(lcm(a, b))

Fixed submission:
from fractions import gcd

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

def lcm(a,b):
    return a * b // gcd(a,b)

print(lcm(a, b))
Buggy python submission (verdict: Runtime Error):
from heapq import _heapify_max, _heapreplace_max

n, m = map(int, input().split())
a = list(map(int, input().split()))

_heapify_max(a)

for i in range(m):
    _heapreplace_max(a, a[0] // 2)
    
print(sum(a))

Fixed submission:
n, m = map(int, input().split())
a = sorted(map(int, input().split()), reverse=True)

while m > 0:
    a = sorted(a, reverse=True)
    temp = a[0] // 2
    for i in range(n):
        if a[i] >= temp:
            a[i] = a[i]//2
            m -= 1
            if m <= 0:
                break
        else:
            break

count = 0
for i in a:
    count += i
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

count = 0
count_list = []
ss = []

for i in range(n):
    s = sorted(input())
    
    for num, match in enumerate(ss):
        if match == s:
            count += count_list[num]
            count_list[num] += 1
            break

    else:
        ss.append(s)
        count_list.append(1)

print(count)

Fixed submission:
from collections import Counter

n = int(input())
s =  Counter("".join(sorted(input())) for i in range(n))

print(sum(map(lambda x : x * (x - 1) // 2, s.values())))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

count = 0
count_list = []
ss = []

for i in range(n):
    s = sorted(input())
    
    for num, match in enumerate(ss):
        if match == s:
            count += count_list[num]
            count_list[num] += 1
            break

    else:
        ss.append(s)
        count_list.append(1)

print(count)

Fixed submission:
from collections import Counter

n = int(input())
s =  Counter("".join(sorted(input())) for i in range(n))

print(sum(map(lambda x : x * (x - 1) // 2, s.values())))
Buggy python submission (verdict: Runtime Error):
count = 0
for i in range(1,n+1):
    if len(str(i)) % 2 == 1:
        count += 1

print(count)

Fixed submission:
n = int(input())

count = 0
for i in range(1,n+1):
    if len(str(i)) % 2 == 1:
        count += 1

print(count)
Buggy python submission (verdict: Runtime Error):
n = int(input())
p = list(map(int, input().split()))


for i in range(n):
    for j in range(n):
        temp = list(copy(p))
        temp[i], temp[j] = temp[j], temp[i]
        sorted_temp = sorted(temp)

        if sorted_temp  == temp:
            print("YES")
            exit()

print("NO")

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

for i in range(n):
    for j in range(n):
        temp = p.copy()
        temp[i], temp[j] = temp[j], temp[i]
        sorted_temp = sorted(temp)

        if sorted_temp  == temp:
            print("YES")
            exit()

print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
r, l = map(int, (input().split()))

ans = 0 if l - r >= 2019 else 2018

for i in range(r, l):
    for j in range(i+1, l+1):
        ans = min((i * j) % 2019, ans)
    
        if ans == 0:
            break
    
print(ans)

Fixed submission:
r, l = map(int, (input().split()))

ans = 0 if l - r >= 2019 else 2018
max_l = min(l, (r//2019+1)*2019)

for i in range(r, max_l):
    for j in range(i+1, max_l+1):
        ans = min((i * j) % 2019, ans)
    
        if ans == 0:
            break
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
r, l = map(int, (input().split()))

ans = 2018

for i in range(r, l):
    for j in range(i+1, l+1):
        ans = min((i * j) % 2019, ans)
    
        if ans == 0:
            break
    
print(ans)


Fixed submission:
r, l = map(int, (input().split()))

ans = 0 if l - r >= 2019 else 2018
max_l = min(l, (r//2019+1)*2019)

for i in range(r, max_l):
    for j in range(i+1, max_l+1):
        ans = min((i * j) % 2019, ans)
    
        if ans == 0:
            break
    
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

for i in range(a[0]+1):
    ans = [i*2]
    diff = i

    for rep2 in range(1, n-1):
        dam = a[rep2] - diff
        ans += [dam*2]
        diff = dam
        if diff < 0:
            break

    if a[-1] - ans[-1]//2 == a[0]-i:
        print(*([(a[0]-i)*2] + ans))
        exit()

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

ans = [0] * (n + 1)
ans[0], ans[1] = a[0] * 2, 0
temp = 0
for num, con in enumerate(a[1:]):
    temp += con
    ans[num+2] = temp * 2
    temp *= -1

diff = (ans[-2] + ans[0]) // 2 - a[-1]

sign = -1
for i in range(n):
    ans[i] += sign * diff
    sign *= -1

print(*ans[:-1])
Buggy python submission (verdict: Runtime Error):
a, b, c, d = map(int, input().split())
print("Bad" if a == b or b == c or c == d else "Good")

Fixed submission:
s = input()
print("Bad" if s[0] == s[1] or s[1] == s[2] or s[2] == s[3] else "Good")
Buggy python submission (verdict: Runtime Error):
n = int(input())
sp = [input().split() for i in range(n)]

sorted_sp = sorted(sp,key = lambda x: int(x[1]), reverse=True)
sorted_sp = sorted(sorted_sp,key = itemgetter(0))

for i in range(n):
    for j in range(n):
        if sp[j] == sorted_sp[i]:
            print(j+1)

Fixed submission:
from operator import itemgetter

n = int(input())
sp = [input().split() for i in range(n)]

sorted_sp = sorted(sp,key = lambda x: int(x[1]), reverse=True)
sorted_sp = sorted(sorted_sp,key = itemgetter(0))

for i in range(n):
    for j in range(n):
        if sp[j] == sorted_sp[i]:
            print(j+1)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
a = sorted(list(map(int, input().split())))
bc = sorted([list(map(int, input().split())) for i in range(m)], key = itemgetter(1), reverse=True)

ans = 0
for i in range(n):
    now = a[i]
    for rep, con in enumerate(bc):
        if now < con[1] and bc[rep][0] != 0:
            ans += con[1]
            bc[rep][0] -= 1
            break

    else:
        ans += now + sum(a[i+1:])
        break

print(ans)

Fixed submission:
n, m = map(int, input().split())
lr = [list(map(int, input().split())) for i in range(m)]

max_l = float("-inf")
min_r = float("inf")

for l, r in lr:
    max_l = max(max_l, l)
    min_r = min(min_r, r + 1)

ans = min_r-max_l
print("0" if ans <= 0 else ans if ans < n else n)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
lr = [list(map(int, input().split())) for i in range(m)]

ans = set(range(lr[0][1] + 1)) - set(range(lr[0][0]))
for l, r in lr:
    ans &= (set(range(r + 1)) - set(range(l)))
print(len(ans) if n > len(ans) else n)

Fixed submission:
n, m = map(int, input().split())
lr = [list(map(int, input().split())) for i in range(m)]

max_l = float("-inf")
min_r = float("inf")

for l, r in lr:
    max_l = max(max_l, l)
    min_r = min(min_r, r + 1)

ans = min_r-max_l
print("0" if ans <= 0 else ans if ans < n else n)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
print(print a*2 if a==b else max(a,b) * 2 -1)

Fixed submission:
a, b = map(int, input().split())
print(max(a, b) * 2) if a == b else print(max(a, b) * 2 - 1)
Buggy python submission (verdict: Runtime Error):
n = int(input().split())
h = list(map(int, input().split()))
height = h[0]
counter = 0
for i in h:
    if h[i] >= height:
        counter += 1
        height = h[i]

print(counter)


Fixed submission:
n = int(input())
h = list(map(int, input().split()))
highest = 0
counter = 0

for i in range(n):
    if h[i] >= highest:
        counter += 1
        highest = h[i]

print(counter)

Buggy python submission (verdict: Runtime Error):
n = int(input().split())
h = list(map(int, input(.split()))
height = h[0]
counter = 0
for i in h:
    if h[i] >= height:
        counter += 1
        height = h[i]

print(counter)

Fixed submission:
n = int(input())
h = list(map(int, input().split()))
highest = 0
counter = 0

for i in range(n):
    if h[i] >= highest:
        counter += 1
        highest = h[i]

print(counter)
Buggy python submission (verdict: Runtime Error):
order = [int(input()) for i in range(5)]
diff = (sorted(map(lambda x: (x % 10), order)))
diff = [i for i in diff if i != 0]

sum_order = sum(list(map(lambda x: -(-x //10), order)))
print ((sum_order * 10) - 10 + diff[0])


Fixed submission:
order = [int(input()) for i in range(5)]
diff = (sorted(map(lambda x: (x % 10), order)))
diff = [i for i in diff if i != 0]

sum_order = sum(list(map(lambda x: -(-x //10), order))) * 10

if diff != []:
    sum_order += (-10 + diff[0])
    
print (sum_order)
Buggy python submission (verdict: Time Limit Exceeded):
n,q = map(int,input().split())
s = str(input())
a=[i for i in range(len(s) - 1) if s[i]+s[i+1] == "AC"]

for i in range(q):
    l1, l2 = map(int, input().split())
    b = [i for i in a if  l1 <= i+1 < l2]
    print(len(b))

Fixed submission:
n,q = map(int, input().split())
s= input()
counter = 0
countlist = [0, 0]

for i in range(1, n):
    if s[i] == "C" and s[i - 1] == "A":
        counter += 1
    countlist += [counter]

for i in range(q):
    l, r = map(int, input().split())
    print(countlist[r] - countlist[l])

Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int,input().split())
s = str(input())
for i in range(q):
    l1, l2 = map(int, input().split())
    a = s[l1-1:l2].count("AC")
    print(a)

Fixed submission:
n,q = map(int, input().split())
s= input()
counter = 0
countlist = [0, 0]

for i in range(1, n):
    if s[i] == "C" and s[i - 1] == "A":
        counter += 1
    countlist += [counter]

for i in range(q):
    l, r = map(int, input().split())
    print(countlist[r] - countlist[l])
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()

counter_s = Counter(s).most_common()
ans = 1
for i in counter_s:
    ans *= i[1] + 1

ans -= 1
print(ans)


Fixed submission:
from collections import *
from operator import *

n = int(input())
s = input()

counter_s = Counter(s).most_common()
ans = 1
for i in counter_s:
    ans = (ans * (i[1] + 1)) % (10 ** 9 + 7)

ans -= 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
a, b = map(int,input().split())
answer = b

for i in range(a, b):
    answer = answer ^ i

print(answer)

Fixed submission:
a, b = map(int, input().split())
ans = b
done = 0
for i in range(a, b+1):
    if i % 4 != 0:
        ans ^= i
    else:
        done = i
        break

for i in range(b-1, a, -1):
    if i % 4 != 3 and i >= done:
        ans ^= i
    else:
        break

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

a, b, q = map(int, input().split())
s = [int(input()) for i in range(a)]
t = [int(input()) for i in range(b)]

sentinel = lambda x: [-9e20] + x + [9e20]
s = sentinel(s)
t = sentinel(t)

for i in range(q):
    x = int(input())
    ss = bisect(s, x)
    tt = bisect(t, x)

    ll = max(s[ss], t[tt]) - x
    rr = x - min(s[ss-1], t[tt-1])
    rl = min((s[ss]- x) + s[ss] - t[tt-1], (t[tt]- x) + t[tt] - s[ss-1])
    lr = min((x - s[ss-1]) + t[tt] - s[ss-1], (x - t[tt-1]) + s[ss] - t[tt-1])

    print(min(ll, rr, rl, lr))

Fixed submission:
import bisect
 
a, b, q = map(int, input().split())
s = sorted([int(input()) for i in range(a)])
t = sorted([int(input()) for i in range(b)])

s = [-9e20] + s + [9e20]
t = [-9e20] + t + [9e20]
 
for i in range(q):
    x = int(input())
    p = bisect.bisect_left(s,x)
    m = bisect.bisect_left(t,x)
    
    ll = max(s[p], t[m]) - x
    lr = min(s[p] * 2 - t[m-1] - x, t[m] * 2 - s[p-1] - x)
    rl = min(s[p] - t[m-1] * 2 + x, t[m] - s[p-1] * 2 + x)
    rr = x - min(s[p-1], t[m-1])

    print(min(ll, lr, rl, rr))

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

a, b, q = map(int, input().split())
s = [int(input()) for i in range(a)]
t = [int(input()) for i in range(b)]
x = [int(input()) for i in range(q)]

sentinel = lambda x: [-9e20] + x + [9e20]
s = sentinel(s)
t = sentinel(t)

for i in x:
    ss = bisect(s, i)
    tt = bisect(t, i)

    ll = max(s[ss], t[tt]) - i
    rr = i - min(s[ss-1], t[tt-1])
    rl = min((s[ss]- i) + s[ss] - t[tt-1], (t[tt]- i) + t[tt] - s[ss-1])
    lr = min((i - s[ss-1]) + t[tt] - s[ss-1], (i - t[tt-1]) + s[ss] - t[tt-1])

    print(min(ll, rr, rl, lr))

Fixed submission:
import bisect
 
a, b, q = map(int, input().split())
s = sorted([int(input()) for i in range(a)])
t = sorted([int(input()) for i in range(b)])

s = [-9e20] + s + [9e20]
t = [-9e20] + t + [9e20]
 
for i in range(q):
    x = int(input())
    p = bisect.bisect_left(s,x)
    m = bisect.bisect_left(t,x)
    
    ll = max(s[p], t[m]) - x
    lr = min(s[p] * 2 - t[m-1] - x, t[m] * 2 - s[p-1] - x)
    rl = min(s[p] - t[m-1] * 2 + x, t[m] - s[p-1] * 2 + x)
    rr = x - min(s[p-1], t[m-1])

    print(min(ll, lr, rl, rr))
Buggy python submission (verdict: Runtime Error):
from math import gcd

n = int(input())
k = list(map(int, input().split()))
ans = k[0]

for i in k:
    ans = gcd(ans, i)

print(ans)

Fixed submission:
from fractions import gcd

n = int(input())
k = list(map(int, input().split()))
ans = k[0]

for i in k:
    ans = gcd(ans, i)

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

n, w = map(int, input().split())
wv = [list(map(int, input().split())) for i in range(n)]
table = np.zeros(w+1, dtype=np.int64)

for i in range(n):
    l = table[:-wv[i][0]]
    r = table[wv[i][0]:]
    np.maximum(l + wv[i][1], r, out = r)

print(table[w])

Fixed submission:
import numpy as np

n, W = map(int, input().split())
w, v = [],[]
for i in range(n):
    temp = list(map(int, input().split()))
    w.append(temp[0])
    v.append(temp[1])

table = np.full(sum(v)+1, np.inf)
table[0] = 0

for i in range(n):
    l = table[:-v[i]]
    r = table[v[i]:]
    np.minimum(l + w[i], r, out = r)
    
print(np.max(np.where(table <= W)))
Buggy python submission (verdict: Time Limit Exceeded):
from numpy import zeros

s, t = input(), input()
ls, lt = len(s), len(t)

table = zeros((ls+1, lt+1))
for ss in range(ls):
    for st in range(lt):
        table[ss+1][st+1] = table[ss][st] + 1 if s[ss] == t[st] else max(table[ss+1][st], table[ss][st+1] )

ans = ""
ss, st = ls, lt
while ss * st != 0:
    if table[ss][st] == table[ss-1][st]:
        ss -= 1
    elif table[ss][st] == table[ss][st-1]:
        st -= 1

    else:
        ss -= 1
        st -= 1
        ans = s[ss] + ans

print(ans)

Fixed submission:
s, t = input(), input()
ls, lt = len(s), len(t)

table = [[0] * (lt+1) for i in range(ls+1)]
for ss in range(ls):
    for st in range(lt):
        table[ss+1][st+1] = table[ss][st] + 1 if s[ss] == t[st] else max(table[ss+1][st], table[ss][st+1] )

ans = ""
ss, st = ls, lt
while ss * st != 0:
    if table[ss][st] == table[ss-1][st]:
        ss -= 1
    elif table[ss][st] == table[ss][st-1]:
        st -= 1

    else:
        ss -= 1
        st -= 1
        ans = s[ss] + ans

print(ans)
Buggy python submission (verdict: Runtime Error):
n, m= map(int, (input().split()))
pyi = [list(map(int, (input().split()))) + [i] for i in range(m)]
pyi.sort(key=itemgetter(1))
pyi.sort(key=itemgetter(0))
cityflag = 0
ans = []
for rep in range(m):
    if pyi[rep][0] != pyi[rep - 1][0]:
        cityflag = 0

    cityflag += 1
    ans += [[pyi[rep][0] , cityflag, pyi[rep][2]]]

for i in sorted(ans, key=itemgetter(2)):
    print(str(i[0]).zfill(6) + str(i[1]).zfill(6))

Fixed submission:
from operator import itemgetter

n, m= map(int, (input().split()))
pyi = [list(map(int, (input().split()))) + [i] for i in range(m)]
pyi.sort(key=itemgetter(1))
pyi.sort(key=itemgetter(0))
cityflag = 0
ans = []
for rep in range(m):
    if pyi[rep][0] != pyi[rep - 1][0]:
        cityflag = 0

    cityflag += 1
    ans += [[pyi[rep][0] , cityflag, pyi[rep][2]]]

for i in sorted(ans, key=itemgetter(2)):
    print(str(i[0]).zfill(6) + str(i[1]).zfill(6))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = sorted([int(input()) for i in range(n)])
l = n//2

if n % 2 == 0:
    small = a[:l]
    big = a[l:]
    ans = sum(big) * 2 - sum(small) * 2  - big[0] + small[-1]
    print(ans)

else:
    small = a[:l]
    big = a[l+1:]
    ans = sum(big) * 2 - sum(small) * 2 - min(n[l] - small[-1], big[0] - n[l])
    print(ans)

Fixed submission:
n = int(input())
a = sorted([int(input()) for i in range(n)])

if n % 2 == 0:
    small = a[:(n//2)]
    big = a[(n//2):]
    ans = sum(big) * 2 - sum(small) * 2  - big[0] + small[-1]
    print(ans)

else:
    small = a[:(n//2)]
    big = a[(n//2):]
    ans = sum(big) * 2 - sum(small) * 2  - big[0] -big[1]

    small = a[:(n//2)+1]
    big = a[(n//2)+1:]
    ans = max(ans, sum(big) * 2 - sum(small) * 2 + small[-1] + small[-2])
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())

count = 1
for i in range(1, (m//n)+1):
    temp = m - (i*n)
    if temp % i == 0:
        count = i
        
print(count)


Fixed submission:
n, m = map(int, input().split())

count = 1
for i in range((m//n), 0, -1):
    if m % i == 0:
        count = i
        break

print(count)

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())

count = 1
for i in range((m//n)+1, 1, -1):
    if m % i == 0:
        count = i
        break()

print(count)

Fixed submission:
n, m = map(int, input().split())

count = 1
for i in range((m//n), 0, -1):
    if m % i == 0:
        count = i
        break

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())

count = 1
for i in range(1, (m//n)+1):
    temp = m - (i*n)
    if temp % i == 0:
        count = i
        
print(count)

Fixed submission:
n, m = map(int, input().split())

count = 1
for i in range((m//n), 0, -1):
    if m % i == 0:
        count = i
        break

print(count)
Buggy python submission (verdict: Runtime Error):
from collections import Counter

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

counted_v1 = Counter(v[::2])
counted_v2 = Counter(v[1::2])

most_v1 = counted_v1.most_common()[0]
most_v2 = counted_v2.most_common()[0]

if  most_v1[0] != most_v2[0]:
    print(n - most_v1[1] - most_v2[1])


elif len(counted_v1) == 1 and len(counted_v2) == 1:
    print(n // 2)

elif most_v1[1] > most_v2[1]:
    second_v2 = counted_v2.most_common()[1] if len(counter_v2) >= 2 else most_v2[1]
    print(n - most_v1[1] - second_v2[1])

else:
    second_v1 = counted_v1.most_common()[1] if len(counter_v1) >= 2 else most_v1[1]
    print(n - second_v1[1] - most_v2[1])


Fixed submission:
from collections import Counter

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

v1 = v[::2]
v2 = v[1::2]

cv1 = Counter(v1).most_common(2)
cv2 = Counter(v2).most_common(2)

if cv1[0][0] != cv2[0][0]:
    print(n - cv1[0][1] - cv2[0][1])
else:
    p1 = cv1[0][1] + cv2[1][1] if len(cv2) >= 2 else n - cv1[0][1]
    p2 = cv2[0][1] + cv1[1][1] if len(cv1) >= 2 else n - cv2[0][1]
    print(n - max(p1, p2))
Buggy python submission (verdict: Runtime Error):
def lcm (x, y):
    return (x * y) // gcd(x, y)

N = int(input())
a = list(map(int, (input().split())))
l = (a[0] * a[1]) // gcd(a[0], a[1])

for i in a[2:]:
    l = lcm(l, i)

l -= 1

ans = sum(map(lambda x: l%x , a))
print(ans)

Fixed submission:
from fractions import gcd

def lcm (x, y):
    return (x * y) // gcd(x, y)

N = int(input())
a = list(map(int, (input().split())))
l = (a[0] * a[1]) // gcd(a[0], a[1])

for i in a[2:]:
    l = lcm(l, i)

l -= 1

ans = sum(map(lambda x: l%x , a))
print(ans)
Buggy python submission (verdict: Runtime Error):
N = input()
digitsum_N = 0

for i in N:
  digitsum_N += int(i)
  
print("Yes" if N % digitsum_N == 0 else "No")

Fixed submission:
N = input()
digitsum_N = 0

for i in N:
  digitsum_N += int(i)
  
print("Yes" if int(N) % digitsum_N == 0 else "No")
Buggy python submission (verdict: Runtime Error):
sorted_X = sorted(X)
left, right = sorted_X[N // 2 - 1], sorted_X[N // 2]

for x in X:
    print(right if x <= left else left)

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

sorted_X = sorted(X)
left = sorted_X[N // 2 - 1]
right = sorted_X[N // 2]

for x in X:
    if x <= left:
        print(right)
    else:
        print(left)
Buggy python submission (verdict: Time Limit Exceeded):
A, B, K = map(int, input().split())
ans = [i for i in range(A, B + 1) if A + K > i or  B - K < i]

for i in ans:
    print(i)


Fixed submission:
A, B, K = map(int, input().split())
for i in range(A, min(A + K, B + 1)):
    print(i)

for i in range(max(B - K + 1, A + K), B + 1):
    print(i)
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = [input() for i in range(N)]
march = {"M":0, "A":0, "R":0, "C":0, "H":0}

for i in S:
    if i[0] in march:
        march[i[0]] += 1

ans = 0
for first, second, third in combinations(march.values(), 3):
    ans += first * second * third

print(ans)

Fixed submission:
N = int(input())
S = [input() for i in range(N)]
march = {"M":0, "A":0, "R":0, "C":0, "H":0}

for i in S:
    if i[0] in march:
        march[i[0]] += 1

ans = 0
for key1, value1 in march.items():
    for key2, value2 in march.items():
        for key3, value3 in march.items():
            if key1 < key2 < key3:
                ans += value1 * value2 * value3

print(ans)
Buggy python submission (verdict: Runtime Error):
x1, y1, x2, y2 = map(int, input().split())

def vector(x1, y1, x2, y2):
    return x2 - (y2 - y1), y2 + (x2 - x1)

x3, y3 = vector(x1, y1, x2, y2)
x4, y4 = vector(x2, y2, x3, y3)

print(x3, y3, x4, y4)

Fixed submission:
c = [list(map(int, input().split())) for i in range(3)]

f = c[0][0]
s = c[0][1] - f
t = c[0][2] - f

for i in c:
    i_f = i[0]

    if i[1] != i_f + s or i[2] != i_f + t:
        print("No")
        exit()

print("Yes")