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

if r < 1200:
    print("ABC")
elif r < 2800:
    print("ARC")
else:
    print("AGC")


Fixed submission:
r = int(input())

if r < 1200:
    print("ABC")
elif r < 2800:
    print("ARC")
else:
    print("AGC")
Buggy python submission (verdict: Time Limit Exceeded):
from math import factorial


def perm(n, r):
    return factorial(n) // factorial(n - r)


def comb(n, r):
    return perm(n, r) // factorial(r)


n = int(input())
A = list(map(int, input().split()))
A.sort()
m = A.pop()
biggest = 0
biggest_r = 0
for r in A:
    var = comb(m, r)
    if var > biggest:
        biggest = var
        biggest_r = r
print(m, biggest_r)


Fixed submission:
from bisect import bisect

n = int(input())
A = list(map(int, input().split()))
A.sort()
b = A.pop()
m = b / 2
i = bisect(A, m)
A.insert(i, m)

if i == 0:
    print(b, A[1])
elif i == len(A) - 1:
    print(b, A[-2])
elif A[i] - A[i - 1] < A[i + 1] - A[i]:
    print(b, A[i - 1])
else:
    print(b, A[i + 1])
Buggy python submission (verdict: Runtime Error):
A, B, K = map(int, input().split())
print(
    *sorted(
        list(set(range(A, min(B + 1, A + K))) | set(range(max(A, B - K) + 1, B + 1)))
    ),
    sep="\n",
)


Fixed submission:
A, B, K = map(int, input().split())
R = range(A, min(B + 1, A + K))
S = range(max(A, B - K + 1), B + 1)
L = list(set(R) | set(S))
L.sort()
print(*L, sep="\n")

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


Fixed submission:
A, B, K = map(int, input().split())
R = range(A, min(B + 1, A + K))
S = range(max(A, B - K + 1), B + 1)
L = list(set(R) | set(S))
L.sort()
print(*L, sep="\n")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
A = {a: A.count(a) for a in set(A)}
ans = 0
for k, v in A.items():
    if k > v:
        ans += v
    elif k < v:
        ans += v - k
print(ans)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
S = {}
for a in A:
    if a in S:
        S[a] += 1
    else:
        S[a] = 1
ans = 0
for k, v in S.items():
    if k > v:
        ans += v
    elif k < v:
        ans += v - k
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
A = {a: A.count(a) for a in A}
ans = 0
for k, v in A.items():
    if k > v:
        ans += v
    elif k < v:
        ans += v - k
print(ans)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
S = {}
for a in A:
    if a in S:
        S[a] += 1
    else:
        S[a] = 1
ans = 0
for k, v in S.items():
    if k > v:
        ans += v
    elif k < v:
        ans += v - k
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = [int(c) for c in input().split()]

numbers = set(A)
numbers = [A.count(n) for n in numbers]
numbers.sort()
if len(numbers) <= K:
    print(0)
else:
    print(sum(numbers[:len(numbers) - K]))


Fixed submission:
from collections import defaultdict

N, K = map(int, input().split())
A = list(map(int, input().split()))
D = defaultdict(lambda: 0)
for a in A:
    D[a] += 1
V = list(D.values())
V.sort(reverse=True)
print(sum(V[K:]))

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = [int(c) for c in input().split()]

numbers = set(A)
numbers = {n: A.count(n) for n in numbers}
numbers = [A.count(n) for n in numbers]
numbers.sort()
if len(numbers) <= K:
    print(0)
else:
    print(sum(numbers[:len(numbers) - K]))


Fixed submission:
from collections import defaultdict

N, K = map(int, input().split())
A = list(map(int, input().split()))
D = defaultdict(lambda: 0)
for a in A:
    D[a] += 1
V = list(D.values())
V.sort(reverse=True)
print(sum(V[K:]))

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = [int(c) for c in input().split()]

numbers = set(A)
numbers = {n: A.count(n) for n in numbers}
numbers = list(numbers.values())
numbers.sort()
if len(numbers) <= K:
    print(0)
else:
    print(sum(numbers[:len(numbers) - K]))


Fixed submission:
from collections import defaultdict

N, K = map(int, input().split())
A = list(map(int, input().split()))
D = defaultdict(lambda: 0)
for a in A:
    D[a] += 1
V = list(D.values())
V.sort(reverse=True)
print(sum(V[K:]))

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = [int(c) for c in input().split()]

numbers = {a: A.count(a) for a in A}
numbers = list(numbers.values())
numbers.sort()
if len(numbers) <= K:
    print(0)
else:
    print(sum(numbers[:len(numbers) - K]))


Fixed submission:
from collections import defaultdict

N, K = map(int, input().split())
A = list(map(int, input().split()))
D = defaultdict(lambda: 0)
for a in A:
    D[a] += 1
V = list(D.values())
V.sort(reverse=True)
print(sum(V[K:]))

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = [int(c) for c in input().split()]

numbers = {a: A.count(a) for a in A}
numbers = list(numbers.values())
numbers.sort()
if len(numbers) <= K:
    print(0)
else:
    print(sum(numbers[:len(numbers) - K]))


Fixed submission:
from collections import defaultdict

N, K = map(int, input().split())
A = list(map(int, input().split()))
D = defaultdict(lambda: 0)
for a in A:
    D[a] += 1
V = list(D.values())
V.sort(reverse=True)
print(sum(V[K:]))
Buggy python submission (verdict: Time Limit Exceeded):
n, p = map(int, input().split())
s = input()

def twofive(n, p, s):
    res = 0
    for i in range(n):
        mostlow = int(s[i])
        if mostlow%p==0:
            res += i+1
    return res

def others(n, p, s):
    from collections import Counter
    res = 0
    
    s = s + '0'
    amari = []
    for i in range(len(s)):
        ak = int(s[i:])
        amari.append(ak%p)
    
    amaricnt = Counter(amari)
    for val in amaricnt.values():
        if val == 1:
            continue
        else:
            res += val*(val-1)//2
    
    return res

if p == 2 or p==5:
    print(twofive(n, p, s))
else:
    print(others(n, p, s))

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

def twofive(n, p, s):
    res = 0
    for i in range(n):
        mostlow = int(s[i])
        if mostlow%p==0:
            res += i+1
    return res

def others(n, p, s):
    from collections import Counter
    res = 0
    
    num = 0
    amari = [0 for _ in range(n+1)]
    for i in range(n)[::-1]:
        j = n-1-i
        num += int(s[i]) * pow(10, j, p) %p
        num %= p
        amari[j+1] = num
    
    amaricnt = Counter(amari)
    for val in amaricnt.values():
        if val == 1:
            continue
        else:
            res += val*(val-1)//2
    
    return res

if p == 2 or p==5:
    print(twofive(n, p, s))
else:
    print(others(n, p, s))

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

def twofive(n, p, s):
    res = 0
    for i in range(n):
        mostlow = int(s[i])
        if mostlow%p==0:
            res += i+1
    return res

def others(n, p, s):
    from collections import Counter
    res = 0
    
    s = s + '0'
    amari = []
    for i in range(len(s)):
        ak = int(s[i:])
        amari.append(ak%p)
    
    amaricnt = Counter(amari)
    for val in amaricnt.values():
        if val == 1:
            continue
        else:
            res += val*(val-1)//2
    
    return res

if p == 2 or p==5:
    print(twofive(n, p, s))
else:
    print(others(n, p, s))

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

def twofive(n, p, s):
    res = 0
    for i in range(n):
        mostlow = int(s[i])
        if mostlow%p==0:
            res += i+1
    return res

def others(n, p, s):
    from collections import Counter
    res = 0
    
    num = 0
    amari = [0 for _ in range(n+1)]
    for i in range(n)[::-1]:
        j = n-1-i
        num += int(s[i]) * pow(10, j, p) %p
        num %= p
        amari[j+1] = num
    
    amaricnt = Counter(amari)
    for val in amaricnt.values():
        if val == 1:
            continue
        else:
            res += val*(val-1)//2
    
    return res

if p == 2 or p==5:
    print(twofive(n, p, s))
else:
    print(others(n, p, s))
Buggy python submission (verdict: Time Limit Exceeded):
n, a, b = map(int, input().split())
mod = 10**9+7

### baseを求める
def power_func(a,n,p):
    bi=str(format(n,"b"))#2進表現に
    res=1
    for i in range(len(bi)):
        res=(res*res) %p
        if bi[i]=="1":
            res=(res*a) %p
    return res

base = power_func(2, n, mod) - 1

### baseから引く
def framod(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
    return a

def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod

def comb(n, k, mod):
    a=framod(n, mod)
    b=framod(k, mod)
    c=framod(n-k, mod)
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod

for t in [a, b]:
	base -= comb(n, t, mod)
print(base)

Fixed submission:
def main():
    MOD = 10**9 + 7
    n, a, b = map(int, input().split())
    
    def cmb(n, r):
        if n-r<r:
            r = n-r
        
        X, Y = (1, 1)
        for i in range(r):
            X = X*(n-i)%MOD
            Y = Y*(i+1)%MOD
        return X*pow(Y, MOD-2, MOD)
    
    base = pow(2, n, MOD)-1
    base -= cmb(n, a)
    base -= cmb(n, b)
    base %= MOD
    print(base)
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def ex(x):
    return (x+1)/2

n, k = map(int, input().split())
lst = list(map(int, input().split()))
source = [ex(i) for i in range(1, 1001)]
exlst = [source[l-1] for l in lst]
maxmum = -1
for i in range(n-k+1):
    val = sum(exlst[i:i+k])
    if val > maxmum:
        maxmum = val
print(maxmum)

Fixed submission:
def ex(x):
    return (x+1)/2
 
n, k = map(int, input().split())
lst = list(map(int, input().split()))
source = [ex(i) for i in range(1, 1001)]
exlst = [source[l-1] for l in lst]
maxmum = -1

cumulative = [0]
total = 0
for ex in exlst:
    total += ex
    cumulative.append(total)

maxmum = -1
for i in range(n-k+1):
    sum_ = cumulative[i+k] - cumulative[i]
    if sum_ > maxmum:
        maxmum = sum_
print(maxmum)

Buggy python submission (verdict: Time Limit Exceeded):
def ex(x):
    res = 0
    for i in range(1, x+1):
        res += i/x
    return res

n, k = map(int, input().split())
lst = list(map(int, input().split()))
source = [ex(i) for i in range(1, 1001)]
exlst = [source[l-1] for l in lst]
maxmum = -1
for i in range(n-k+1):
    val = sum(exlst[i:i+k])
    if val > maxmum:
        maxmum = val
print(maxmum)

Fixed submission:
def ex(x):
    return (x+1)/2
 
n, k = map(int, input().split())
lst = list(map(int, input().split()))
source = [ex(i) for i in range(1, 1001)]
exlst = [source[l-1] for l in lst]
maxmum = -1

cumulative = [0]
total = 0
for ex in exlst:
    total += ex
    cumulative.append(total)

maxmum = -1
for i in range(n-k+1):
    sum_ = cumulative[i+k] - cumulative[i]
    if sum_ > maxmum:
        maxmum = sum_
print(maxmum)

Buggy python submission (verdict: Time Limit Exceeded):
def ex(x):
    res = 0
    for i in range(1, x+1):
        res += i/x
    return res

n, k = map(int, input().split())
lst = list(map(int, input().split()))
exlst = [ex(l) for l in lst]
maxmum = -1
for i in range(n-k+1):
    val = sum(exlst[i:i+k])
    if val > maxmum:
        maxmum = val
print(maxmum)

Fixed submission:
def ex(x):
    return (x+1)/2
 
n, k = map(int, input().split())
lst = list(map(int, input().split()))
source = [ex(i) for i in range(1, 1001)]
exlst = [source[l-1] for l in lst]
maxmum = -1

cumulative = [0]
total = 0
for ex in exlst:
    total += ex
    cumulative.append(total)

maxmum = -1
for i in range(n-k+1):
    sum_ = cumulative[i+k] - cumulative[i]
    if sum_ > maxmum:
        maxmum = sum_
print(maxmum)
Buggy python submission (verdict: Runtime Error):
import numpy as np
n = int(input())
keta = len(str(n))
field = np.array([[0 for _ in range(0)] for _ in range(9)])
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result


for k in range(1, n+1):
    i = int(str(k)[0])
    j = int(str(k)[1])
    field[i, j] += 1
total = 0
for i in range(9):
    val = field[i,i]
    total += cmb(val+1, 2)
for i in range(9):
    for j in range(9):
        if i==j:
            continue
        else:
            val = field[i,j]
            total += 2*cmb(val, 2)
print(val)

Fixed submission:
import numpy as np
def cmb(n, r):
    if n<r:
      return 0
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

n = int(input())
field = np.array([[0 for _ in range(9)] for _ in range(9)])

for i in range(1, n+1):
    stri = str(i)
    mae = int(stri[0])
    ushiro = int(stri[-1])
    if mae != 0 and ushiro != 0:
        field[mae-1, ushiro-1] += 1

total = 0
for i in range(9):
    val = field[i, i]
    #print(val)
    #print(cmb(val, 2))
    total += val
    total += 2*cmb(val, 2)

for i in range(9):
    for j in range(i, 9):
        if i==j:
            continue
        else:
            total += 2*field[i,j]*field[j,i]
#print(field)
print(total)
Buggy python submission (verdict: Runtime Error):
x = int(input())
y = int(str(x)[:-2])
z = int(str(x)[-2:])
if x < 100:
    print(0)
    exit()
elif (y*5) < z:
    print(0)
    exit()
else:
    print(1)

Fixed submission:
x = int(input())
if x < 100:
    print(0)
    exit()
else:
    y = int(str(x)[:-2])
    z = int(str(x)[-2:])
    if (y*5) < z:
        print(0)
        exit()
    else:
        print(1)
Buggy python submission (verdict: Time Limit Exceeded):
### a<=b<=cととることとし、a,bを固定すると
### cは　c<a+b
N = int(input())
lst = list(map(int, input().split()))
sor = sorted(lst)

def BinarySearch(lst, key): ## lstの値のうち、key以上になる最初のインデックス
    left = -1  ## index=0が条件を満たす場合も存在
    right = len(lst)  ## index = len(lst)-1が条件を満たさないこともある、key以上になるものが存在しない
    
    while right != left + 1:
        mid = (left + right) // 2
        val = lst[mid]
        if val >= key:
            right = mid
        elif val < key:
            left = mid
    return right  ### key以上になるものが存在しない場合はlen(lst)が帰る

res = 0
for i in range(N):
    for j in range(i+1, N):##ここでa<=bを満たしている
        a = sor[i]
        b = sor[j]
        ab = a+b

        highbound = BinarySearch(sor, ab)
        res += highbound - j - 1
print(res)

Fixed submission:
### a<=b<=cととることとし、a,bを固定すると
### cは　c<a+b
N = int(input())
lst = list(map(int, input().split()))
sor = sorted(lst)

def BinarySearch(lst, key): ## lstの値のうち、key以上になる最初のインデックス
    left = -1  ## index=0が条件を満たす場合も存在
    right = len(lst)  ## index = len(lst)-1が条件を満たさないこともある、key以上になるものが存在しない
    
    while right != left + 1:
        mid = (left + right) // 2
        val = lst[mid]
        if val >= key:
            right = mid
        elif val < key:
            left = mid
    return right  ### key以上になるものが存在しない場合はlen(lst)が帰る

res = 0
for i in range(N):
    for j in range(i+1, N):##ここでa<=bを満たしている
        a = sor[i]
        b = sor[j]
        ab = a+b

        highbound = BinarySearch(sor, ab)
        res += highbound - j - 1
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
lst = list(map(int, input().split()))

s = np.zeros((N, N))
d = np.zeros((N, N))

for i in range(N):
    for j in range(i+1, N):
        s[i, j] += lst[i] + lst[j]
        d[i, j] += abs(lst[i] - lst[j])


res = 0
for k in range(N):
    val = lst[k]
    slow = s>val
    dhigh = d<val
    sandd = slow & dhigh
    
    sandd[k, :] = False
    sandd[:, k] = False
    
    res += np.count_nonzero(sandd)
print(res//3)

Fixed submission:
### a<=b<=cととることとし、a,bを固定すると
### cは　c<a+b
N = int(input())
lst = list(map(int, input().split()))
sor = sorted(lst)

def BinarySearch(lst, key): ## lstの値のうち、key以上になる最初のインデックス
    left = -1  ## index=0が条件を満たす場合も存在
    right = len(lst)  ## index = len(lst)-1が条件を満たさないこともある、key以上になるものが存在しない
    
    while right != left + 1:
        mid = (left + right) // 2
        val = lst[mid]
        if val >= key:
            right = mid
        elif val < key:
            left = mid
    return right  ### key以上になるものが存在しない場合はlen(lst)が帰る

res = 0
for i in range(N):
    for j in range(i+1, N):##ここでa<=bを満たしている
        a = sor[i]
        b = sor[j]
        ab = a+b

        highbound = BinarySearch(sor, ab)
        res += highbound - j - 1
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
n, k , q = map(int, input().split())
qlist = [int(input()) for _ in range(q)]

for i in range(1, n+1):
    damage = q - qlist.count(i)
    if damage < k:
        print('Yes')
    elif damage >= k:
        print('No')

Fixed submission:
from collections import Counter
n, k , q = map(int, input().split())
qlist = [int(input()) for _ in range(q)]
count = Counter(qlist)

for i in range(1, n+1):
    damage = q - count[i]
    if damage < k:
        print('Yes')
    elif damage >= k:
        print('No')
Buggy python submission (verdict: Runtime Error):
n = int(intput())
s = int(intput())

ans = 0
i = j= 0

while j <= n-1:
    if s[i:j] in s[j:]:
        ans = max(ans, j-i)
        j += 1
    else:
        i += 1
print(ans)

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

ans = 0
i = j= 0

while j <= n-1:
    if s[i:j] in s[j:]:
        ans = max(ans, j-i)
        j += 1
    else:
        i += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
hs = list(map(int, input().split()))

max_ = -5
for i in range(n):
    j = i
    count = 0
    while (j <= n-2) and (hs[j] >= hs[j+1]):
        j += 1
        count += 1
    
    if count > max_:
        max_ = count
print(max_)

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

max_ = 0
point = 0
while point <= n-2:
    j = point
    count = 0
    while hs[j] >= hs[j+1]:
        j += 1
        count += 1
        if j == n-1:
            break
    
    if count > max_:
        max_ = count
    
    point = j+1
print(max_)
Buggy python submission (verdict: Runtime Error):
n = int(input())
print(int(n(n-1)/2))

Fixed submission:
n = int(input())
print(n*(n-1)//2)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
print(sum((range(1,n))))

Fixed submission:
n = int(input())
print(n*(n-1)//2)

Buggy python submission (verdict: Runtime Error):
n = int(input())
print(sum(list(range(1,n))))

Fixed submission:
n = int(input())
print(n*(n-1)//2)

Buggy python submission (verdict: Runtime Error):
n = int(input())
print(sum(list(range(1,n))))

Fixed submission:
n = int(input())
print(n*(n-1)//2)

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

total = 0
for i in range(1, n+1):
    if i == n:
        break
    total += i % (i+1)
print(total)

Fixed submission:
n = int(input())
print(n*(n-1)//2)

Buggy python submission (verdict: Runtime Error):
n = int(input())
ns = list(range(1, n+1))
ns_ = ns[1:] + [ns[0]]

total = 0
for i in range(n):
    total += ns[i] % ns_[i]
print(total)

Fixed submission:
n = int(input())
print(n*(n-1)//2)
Buggy python submission (verdict: Runtime Error):
n = int(input())
alist = list(map(int, input().split()))
alist = np.array(alist)
gyakulist = 1 / alist
print(1/sum(gyakulist))

Fixed submission:
import numpy as np
n = int(input())
alist = list(map(int, input().split()))
alist = np.array(alist)
gyakulist = 1 / alist
print(1/sum(gyakulist))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
N = int(input())
slist = []
for _ in range(N):
    slist.append(dict(Counter(input())))

count = 0
for i in range(N):
    for j in range(i+1, N):
        if slist[i] == slist[j]:
            count += 1
print(count)

Fixed submission:
from collections import Counter
N = int(input())
SList = [''.join(sorted(input())) for _ in range(N)]

dic = {}
ans = 0
for word in SList:
    if word not in dic:
        dic[word] = 1
    else:
        ans += dic[word]
        dic[word] += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()
dic = {}
for s in S:
	if not dic[s]:
		dic[s] = 1
	if dic[s]:
		dic[s] += 1
judge = 'Yes'
for k, v in dic.items():
	if v != 2:
		judge = 'NO'
print(judge)

Fixed submission:
S = list(input())
judge = 'Yes'
for s in set(S):
	if S.count(s) != 2:
		judge = 'No'
print(judge)
Buggy python submission (verdict: Runtime Error):
def main():
    p, q, r = map(int, input().split)
    min_time = min([p+q, q+r, r+p])
    print(min_time)

if __name__ == '__main__':
	main()

Fixed submission:
def main():
    p,q,r = map(int, input().split())
    min_time = min([p+q, q+r, r+p])
    print(min_time)

if __name__ == '__main__':
	main()

Buggy python submission (verdict: Runtime Error):
pqr = list(map(int, input().split()))
kumi = [(pqr[0], pqr[1]), (pqr[1], pqr[2]), (pqr[0], pqr[2])
seki = []
for c in kumi:
	seki.append(c[0]*c[1])
print(min(seki))

Fixed submission:
def main():
    p,q,r = map(int, input().split())
    min_time = min([p+q, q+r, r+p])
    print(min_time)

if __name__ == '__main__':
	main()
Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left
def main():
    N, Q = map(int, input().split())
    W = [tuple(map(int, input().split())) for _ in range(N)]
    W.sort(key=lambda x:x[2])
    
    D = [int(input()) for _ in range(Q)]
    ans = [-1]*Q
    skip = [-1]*Q
    for s, t, x in W:
        l = bisect_left(D, s-x)
        r = bisect_left(D, t-x)
        while l < r:
            if skip[l] == -1:
                ans[l] = x
                skip[l] = r
                l+=1
            else:
                l = skip[l]
    for a in ans:
        print(a)
main()  

Fixed submission:
from bisect import bisect_left
def main():
    N, Q = map(int, input().split())
    W = [tuple(map(int, input().split())) for _ in range(N)]
    W.sort(key=lambda x:x[2])
    
    D = [int(input()) for _ in range(Q)]
    ans = [-1]*Q
    skip = [-1]*Q
    for s, t, x in W:
        l = bisect_left(D, s-x)
        r = bisect_left(D, t-x)
        while l < r:
            if skip[l] == -1:
                ans[l] = x
                skip[l] = r
                l+=1
            else:
                l = skip[l]
    for a in ans:
        print(a)
main()
Buggy python submission (verdict: Runtime Error):
import numpy as np
def main():
    N, M = map(int, input().split())
    f = np.zeros((M,N))
    for i in range(M):
        l, r = map(int, input().split())
        f[i, l-1:r] += 1
    ans = sum(np.all(f, axis=0))
    print(ans)
main()

Fixed submission:
import numpy as np
def main():
    N, M = map(int, input().split())
    maxl = -float('inf')
    minr = float('inf')
    for _ in range(M):
        l, r = map(int, input().split())
        if l >= maxl:
            maxl = l
        if r <= minr:
            minr = r
    val = minr - maxl + 1
    if val >= 0:
        print(val)
    else:
        print(0)
main()