Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
L, R = map(int, input().split())
a = []
b = []
flag = False
if R - L >= 2019:
    print(0)
else:
    for i in range(L,R):
        for j in range(i+1, R+1):
            mod = (i*j)%2019
            a.append(mod)
        b.append(min(a))
    print(min(b))

Fixed submission:
l, r = map(int, input().split())
m = []
if r-l >= 2018:
  print(0)
else:
  L = l%2019
  R = r%2019
  if L == 0 or R == 0:
    print(0)
  elif L>R:
    print(0)
  else:
    for i in range(L, R+1):
      for j in range(i+1, R+1):
        m.append(i*j%2019)
    print(min(m))

Buggy python submission (verdict: Runtime Error):
L. R = map(int, input().split())
a = []
b = []
flag = False
if R - L >= 2019:
    print(0)
else:
    for i in range(L,R):
        for j in range(i+1, R+1):
            mod = (i*j)%2019
            if mod != 1:
                 a.append(mod)
            else:
                flag = True
                break
        if flag:
            break
        else:
            b.append(min(a))
    if flag:
        print(1)
    else:
        print(min(b))

Fixed submission:
l, r = map(int, input().split())
m = []
if r-l >= 2018:
  print(0)
else:
  L = l%2019
  R = r%2019
  if L == 0 or R == 0:
    print(0)
  elif L>R:
    print(0)
  else:
    for i in range(L, R+1):
      for j in range(i+1, R+1):
        m.append(i*j%2019)
    print(min(m))

Buggy python submission (verdict: Time Limit Exceeded):
L, R = map(int, input().split())
a = []
b = []
for i in range(L,R):
    for j in range(i+1, R+1):
        a.append((i*j)%2019)
    b.append(min(a))
print(min(b))

Fixed submission:
l, r = map(int, input().split())
m = []
if r-l >= 2018:
  print(0)
else:
  L = l%2019
  R = r%2019
  if L == 0 or R == 0:
    print(0)
  elif L>R:
    print(0)
  else:
    for i in range(L, R+1):
      for j in range(i+1, R+1):
        m.append(i*j%2019)
    print(min(m))
Buggy python submission (verdict: Runtime Error):
import math
a, b, c, d = map(int, input().split())
e = (c*d)/math.gcd(c,d)
bb = b-(b//c + b//d- b//e)
aa = a-1-((a-1)//c+(a-1)//d-(a-1)//e)
z = bb-aa
print(z)

Fixed submission:
S = input()
A = sorted(S)
if A[0] == A[1] == A[2]:
    print('No')
elif A[0] == A[1] and A[2] == A[3]:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
import fractions
a, b, c, d = map(int, input().split())
e = (c*d)/fractions.gcd(c,d)
bb = b-((b//c) + (b//d)- (b//e))
aa = a-1-(((a-1)//c)+((a-1)//d)-((a-1)//e))
z = bb-aa
print(int(z))

Fixed submission:
n = int(input())
d = list(map(int, input().split()))
d.sort()
if d[int((n/2))] == d[int(n/2)-1]:
    print(0)
else:
    print(d[int(n/2)]-d[int((n/2)-1)])

Buggy python submission (verdict: Runtime Error):
import fractions
a, b, c, d = map(int, input().split())
e = (c*d)/fractions.gcd(c,d)
bb = b-(b//c + b//d- b//e)
aa = a-1-((a-1)//c+(a-1)//d-(a-1)//e)
z = bb-aa
print(int(z))

Fixed submission:
n = int(input())
d = list(map(int, input().split()))
d.sort()
if d[int((n/2))] == d[int(n/2)-1]:
    print(0)
else:
    print(d[int(n/2)]-d[int((n/2)-1)])
Buggy python submission (verdict: Runtime Error):
a, b, c, d = map(int, input().split())
m=0
for i in range(a,b+1):
    if (i%c == 0 or i%d == 0):
        continue
    m += 1
print(m)

Fixed submission:
s = input()
m = 0
for i in range(3):
    if s[i] == s[i+1]:
        m += 1
if m == 0:
    print('Good')
else:
    print('Bad')
Buggy python submission (verdict: Runtime Error):
import math
a, b, c, d = map(int, input().split())
e = (c*d)/math.gcd(c,d)
bb = b-(int(b/c) + int(b/d)- int(b/e))
aa = a-1-(int((a-1)/c)+int((a-1)/d)-int((a-1)/e))
z = bb-aa
print(z)

Fixed submission:
from fractions import gcd
a, b, c, d = map(int, input().split())

e = (c*d)//gcd(c,d)

def calc(x):
    return x - (x//c)-(x//d)+(x//e)

print(calc(b)-calc(a-1))

Buggy python submission (verdict: Runtime Error):
import math
a, b, c, d = map(int, input().split())
m=0
e = c * d/math.gcd(c,d)
num_c = int(b/c)-int((a-1)/c)
num_d = int(b/d)-int((a-1)/d)
num_e = int(b/e)-int((a-1)/e)
m = num_c + num_d - num_e
print(b-a+1-m)

Fixed submission:
from fractions import gcd
a, b, c, d = map(int, input().split())

e = (c*d)//gcd(c,d)

def calc(x):
    return x - (x//c)-(x//d)+(x//e)

print(calc(b)-calc(a-1))

Buggy python submission (verdict: Runtime Error):
import fraction
a, b, c, d = map(int, input().split())
m=0
e = c * d/fraction.gcd(c,d)
num_c = int(b/c)-int((a-1)/c)
num_d = int(b/d)-int((a-1)/d)
num_e = int(b/e)-int((a-1)/e)
m = num_c + num_d - num_e
print(b-a+1-m)

Fixed submission:
from fractions import gcd
a, b, c, d = map(int, input().split())

e = (c*d)//gcd(c,d)

def calc(x):
    return x - (x//c)-(x//d)+(x//e)

print(calc(b)-calc(a-1))

Buggy python submission (verdict: Time Limit Exceeded):
a, b, c, d = map(int, input().split())
m=0
for i in range(a,b+1):
    if (i%c == 0 or i%d == 0):
        continue
    m += 1
print(m)

Fixed submission:
from fractions import gcd
a, b, c, d = map(int, input().split())

e = (c*d)//gcd(c,d)

def calc(x):
    return x - (x//c)-(x//d)+(x//e)

print(calc(b)-calc(a-1))

Buggy python submission (verdict: Runtime Error):
a, b, c, d = map(int, input().split())
m=0
for i in range(a,b+1):
    if i%c == 0　or i % d == o:
        continue
    m += 1
print(m)

Fixed submission:
from fractions import gcd
a, b, c, d = map(int, input().split())

e = (c*d)//gcd(c,d)

def calc(x):
    return x - (x//c)-(x//d)+(x//e)

print(calc(b)-calc(a-1))

Buggy python submission (verdict: Time Limit Exceeded):
a, b, c, d = map(int, input().split())
m=0
for i in range(a,b+1):
    if i%c == 0:
        continue
    elif i % d == 0:
        continue
    else:
        m += 1
print(m)

Fixed submission:
from fractions import gcd
a, b, c, d = map(int, input().split())

e = (c*d)//gcd(c,d)

def calc(x):
    return x - (x//c)-(x//d)+(x//e)

print(calc(b)-calc(a-1))
Buggy python submission (verdict: Runtime Error):
def Fib(n):
    a, b = 1, 1
    if n == 1:
        return a
    elif n == 2:
        return b
    else:
        for i in range(n-2):
            a, b = b, a + b
        return b
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
m = Fib(a[0])*Fib(N-a[M-1])
flag = True
for i in range(M-1):
    if a[i] + 1 == a[i+1]:
        print(0)
        flag = False
        break
if flag:
    for j in range(M-1):
        dev = a[j+1]-a[j]
        m = m*Fib(dev)
    print(m%1000000007)

Fixed submission:
def Fib(n):
    a, b = 1, 1
    if n == 1:
        return a
    elif n == 2:
        return b
    else:
        for i in range(n-2):
            a, b = b, a + b
        return b
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]

flag = True
if M == 1:
    print(Fib(a[0])*Fib(N-a[M-1]))
elif M == 0:
    print(Fib(N+1)%1000000007)
else:
    m = Fib(a[0])*Fib(N-a[M-1])
    for i in range(M-1):
        if a[i] + 1 == a[i+1]:
            print(0)
            flag = False
            break
    if flag:
        for j in range(M-1):
            dev = a[j+1]-a[j]-1
            m = m*Fib(dev)%1000000007
        print(m%1000000007)

Buggy python submission (verdict: Runtime Error):
def Fib(n):
    a, b = 1, 1
    if n == 1:
        return a
    elif n == 2:
        return b
    else:
        for i in range(n-2):
            a, b = b, a + b
        return b
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
m = Fib(a[0])*Fib(N-a[M-1])
flag = True
for i in range(M-1):
  if a[i] + 1 == a[i+1]:
    print(0)
    flag = False
    break
if flag:
    for j in range(M-1):
        dev = a[j+1]-a[j]
        m = m*Fib(dev)
    print(m%1000000007)

Fixed submission:
def Fib(n):
    a, b = 1, 1
    if n == 1:
        return a
    elif n == 2:
        return b
    else:
        for i in range(n-2):
            a, b = b, a + b
        return b
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]

flag = True
if M == 1:
    print(Fib(a[0])*Fib(N-a[M-1]))
elif M == 0:
    print(Fib(N+1)%1000000007)
else:
    m = Fib(a[0])*Fib(N-a[M-1])
    for i in range(M-1):
        if a[i] + 1 == a[i+1]:
            print(0)
            flag = False
            break
    if flag:
        for j in range(M-1):
            dev = a[j+1]-a[j]-1
            m = m*Fib(dev)%1000000007
        print(m%1000000007)
Buggy python submission (verdict: Runtime Error):
n = int(input())
sp = []
for i in range(n):
    sp.append(input().split())
    sp[i].append(i)
    sp[i][1] = int(sp[i][1])
sp = sorted(sp, key = lambda x : x[1], reverse = True)
sp = sorted(sp, key = lambda x : x[0])
fo ri in range(n):
    print(sp[i][2]+1)

Fixed submission:
n = int(input())
sp = []
for i in range(n):
    sp.append(input().split())
    sp[i].append(i)
    sp[i][1] = int(sp[i][1])
sp = sorted(sp, key = lambda x : x[1], reverse = True)
sp = sorted(sp, key = lambda x : x[0])
for i in range(n):
    print(sp[i][2]+1)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
lr = [[int(l), int(r)] for l, r in [input().split() for i in range(m)]]
for j in range(m):
  lr[j] = [l for l in range(lr[j][0], lr[j][1]+1)]
  lr[j] = set(lr[j])
lr_intersection = lr[0]
for k in range(1,m):
  lr_intersection = lr_intersection.intersection(lr[k])
print(len(lr_intersection))

Fixed submission:
import heapq
n, m = map(int, input().split())
lr = []
heap1 = []
heap2 = []
for i in range(m):
    lr.append(list(map(int, input().split())))
for j in range(m):
    heapq.heappush(heap1, -lr[j][0])
    heapq.heappush(heap2, lr[j][1])
d = heapq.heappop(heap2) + heapq.heappop(heap1) +1 
if d < 0:
    print(0)
else:
    print(d)
Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()
A = [0 for _ in range(n-1)]
for i in range(n-1):
  if s[i:i+2] == 'AC':
    A[i] = 1
LR = []
for i in range(q):
  LR.append(list(map(int, input().split())))
  print(sum(a for a in A[LR[i][0]-1:LR[i][1]-1]))

Fixed submission:
n, q = map(int, input().split())
s = input()
A = [0 for _ in range(n+1)]
for i in range(n-1):
  A[i+1] = A[i] + (1 if s[i:i+2] == 'AC' else 0)
for j in range(q):
  l, r = map(int, input().split())
  print(A[r-1] - A[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()
LR = []
for i in range(q):
  LR.append(list(map(int, input().split())))
  num = s[LR[i][0]-1:LR[i][1]].count('AC')
  print(num)

Fixed submission:
n, q = map(int, input().split())
s = input()
A = [0 for _ in range(n+1)]
for i in range(n-1):
  A[i+1] = A[i] + (1 if s[i:i+2] == 'AC' else 0)
for j in range(q):
  l, r = map(int, input().split())
  print(A[r-1] - A[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()
LR = []
for i in range(q):
  LR.append(list(map(int, input().split())))
for i in range(q):
  num = s[LR[i][0]-1:LR[i][1]].count('AC')
  print(num)

Fixed submission:
n, q = map(int, input().split())
s = input()
A = [0 for _ in range(n+1)]
for i in range(n-1):
  A[i+1] = A[i] + (1 if s[i:i+2] == 'AC' else 0)
for j in range(q):
  l, r = map(int, input().split())
  print(A[r-1] - A[l-1])
Buggy python submission (verdict: Runtime Error):
import fractions
n = int(input())
A = list(map(int, input().split()))
min_A = min(A)
for i in range(n):
  A[i] = A[i]%min_A
if all(A[i] == 0 for i in range(n)):
  print(min_A)
else:
  print(fractions.gcd(A[j] for j in range(n)))

Fixed submission:
import fractions
n = int(input())
A = list(map(int, input().split()))
min_A = min(A)
B = []
for i in range(n):
  B.append(A[i]%min_A)
if all(B[i] == 0 for i in range(n)):
  print(min_A)
else:
  m = A[0]
  for i in range(1,n):
    m = fractions.gcd(m, A[i])
  print(m)
Buggy python submission (verdict: Runtime Error):
n, t = map(int, input().split())
A = []
for i in range(n):
  a = list(map(int, input().split()))
  if a[1] =< t:
    A.append(a[0])
if len(A) == 0:
  print('TLE')
else:
  print(min(A))

Fixed submission:
n, t = map(int, input().split())
A = []
for i in range(n):
  a = list(map(int, input().split()))
  if a[1] <= t:
    A.append(a[0])
if len(A) == 0:
  print('TLE')
else:
  print(min(A))

Buggy python submission (verdict: Runtime Error):
n, t = map(int, input().split())
A = []
for i in range(n):
  a = list(map(int, input().split()))
  if a[1] < t:
    A.append(a[0])
print(min(A))

Fixed submission:
n, t = map(int, input().split())
A = []
for i in range(n):
  a = list(map(int, input().split()))
  if a[1] <= t:
    A.append(a[0])
if len(A) == 0:
  print('TLE')
else:
  print(min(A))
Buggy python submission (verdict: Runtime Error):
import numpy as np
n = int(input())
v = list(map(int, input().split()))
v_odd = []
v_even = []
for i in range(n):
  if i%2 == 0:
    v_odd.append(v[i])
  else:
    v_even.append(v[i])

vs_odd = np.array(v_odd)
vs_even = np.array(v_even)
count_odd = np.bincount(vs_odd)
count_even = np.bincount(vs_even)
mode_odd = np.argmax(count_odd)
mode_even = np.argmax(count_even)
a = v_odd.count(mode_odd)
b = v_even.count(mode_even)
if mode_odd != mode_even:
  print(n-a-b)
else:
  if len(v_odd) != v_odd.count(mode_odd):
    v_odd2 = [i for i in v_odd if i != mode_odd]
    vs_odd2 = np.array(v_odd2)
    count_odd2 = np.bincount(vs_odd2)
    mode_odd2 = np.argmax(count_odd2)
    a2 = v_odd.count(mode_odd2)
  else:
    a2 = 0
    if len(v_even) != v_even.count(mode_even):
      v_even2 = [i for i in v_even if i != mode_even]
      vs_even2 = np.array(v_even2)
      count_even2 = np.bincount(vs_even2)
      mode_even2 = np.argmax(count_even2)
      b2 = v_even.count(mode_even2)
    else:
      b2 = 0
  if a2 > b2:
    print(n-a2-b)
  else:
    print(n-a-b2)

Fixed submission:
import numpy as np
n = int(input())
v = list(map(int, input().split()))
v_odd = []
v_even = []
for i in range(n):
  if i%2 == 0:
    v_odd.append(v[i])
  else:
    v_even.append(v[i])

vs_odd = np.array(v_odd)
vs_even = np.array(v_even)
count_odd = np.bincount(vs_odd)
count_even = np.bincount(vs_even)
mode_odd = np.argmax(count_odd)
mode_even = np.argmax(count_even)
a = v_odd.count(mode_odd)
b = v_even.count(mode_even)
if mode_odd != mode_even:
  print(n-a-b)
else:
  if len(v_odd) != v_odd.count(mode_odd):
    v_odd2 = [i for i in v_odd if i != mode_odd]
    vs_odd2 = np.array(v_odd2)
    count_odd2 = np.bincount(vs_odd2)
    mode_odd2 = np.argmax(count_odd2)
    a2 = v_odd.count(mode_odd2)
  else:
    a2 = 0
  if len(v_even) != v_even.count(mode_even):
    v_even2 = [i for i in v_even if i != mode_even]
    vs_even2 = np.array(v_even2)
    count_even2 = np.bincount(vs_even2)
    mode_even2 = np.argmax(count_even2)
    b2 = v_even.count(mode_even2)
  else:
    b2 = 0
  if a2 > b2:
    print(n-a2-b)
  else:
    print(n-a-b2)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
readline = sys.stdin.readline
MOD = 998244353

def comb(n, r, mod=MOD):
    r = min(n - r, r)
    res = 1
    fac = 1
    for i in range(r):
        res *= n - i
        res %= mod
        fac *= i + 1
        fac %= mod
    return res * pow(fac, mod-2, mod) % mod

def main():
    N, M, K = map(int, readline().rstrip().split())
    res = 0
    for k in range(K+1):
        n = N - k
        res += comb(N-1, k, MOD) * pow(M-1, n-1, MOD) * M
        res %= MOD
    
    print(res)


if __name__ == '__main__':
    main()

Fixed submission:
import sys
readline = sys.stdin.readline
MOD = 998244353

N, M, K = map(int, readline().rstrip().split())
fact = [1] * (N+1)
finv = [1] * (N+1)
inv = [1] * (N+1)
inv[0] = 0
for i in range(2, N+1):
    fact[i] = (fact[i-1] * i % MOD)
    inv[i] = (-inv[MOD%i] * (MOD // i)) % MOD
    finv[i] = (finv[i-1] * inv[i]) % MOD

def comb(n, r, mod=MOD):
    if r < 0 or n < r:
        return 0
    return fact[n] * finv[r] * finv[n-r] % mod

def main():
    res = 0
    for k in range(K+1):
        res += comb(N-1, k, MOD) * pow(M-1, N-k-1, MOD) * M
        res %= MOD
    
    print(res)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
readline = sys.stdin.readline
from itertools import combinations_with_replacement

def main():
    N, M, Q = map(int, readline().rstrip().split())
    P = [tuple(map(int, readline().rstrip().split())) for _ in range(Q)]
    ans = 0    
    for pair in combinations_with_replacement([i for i in range(1, M+1)], M):
        score = 0
        for a, b, c, d in P:
            if pair[b-1] - pair[a-1] == c:
                score += d
        ans = max(ans, score)
    
    print(ans)

if __name__ == '__main__':
    main()

Fixed submission:
import sys
readline = sys.stdin.readline
from collections import deque

def main():
    N, M, Q = map(int, readline().rstrip().split())
    P = [tuple(map(int, readline().rstrip().split())) for _ in range(Q)]
    ans = 0
    l = [[i] for i in range(1, M+1)]
    que = deque(l)
    for i in range(N):
        for _ in range(len(que)):
            ll = que.popleft()
            for j in range(ll[-1], M+1):
                que.append(ll + [j])
    
    for pair in que:
        score = 0
        for a, b, c, d in P:
            if pair[b-1] - pair[a-1] == c:
                score += d
        ans = max(ans, score)
    
    print(ans)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
readline = sys.stdin.readline
from collections import Counter
MOD = 2019

def main():
    S = readline().rstrip()
    N = len(S)
    T = [0] * (N+1)
    for i in range(N-1, -1, -1):
        T[i] = (T[i+1] + int(S[i]) * 10**(N-1-i)) % MOD
    
    c = Counter(T)
    ans = 0
    for k, v in c.items():
        ans += (v * (v-1)) // 2
    print(ans)


if __name__ == '__main__':
    main()

Fixed submission:
import sys
readline = sys.stdin.readline
from collections import Counter
MOD = 2019

def main():
    S = list(map(int, list(readline().rstrip())))
    N = len(S)
    T = [0] * (N+1)
    e = 1
    for i in range(N-1, -1, -1):
        T[i] = (T[i+1] + int(S[i]) * e) % MOD
        e = e * 10 % MOD
    
    T = [t % MOD for t in T]
    c = Counter(T)
    ans = 0
    for k, v in c.items():
        ans += (v * (v-1)) // 2
    print(ans)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
readline = sys.stdin.readline
from collections import Counter
MOD = 2019

def main():
    S = readline().rstrip()
    N = len(S)
    T = [0] * (N+1)
    for i in range(N-1, -1, -1):
        T[i] = T[i+1] + int(S[i]) * 10 ** (N-1-i)
    
    T = [t % MOD for t in T]
    c = Counter(T)
    ans = 0
    for k, v in c.items():
        ans += (v * (v-1)) // 2
    print(ans)


if __name__ == '__main__':
    main()

Fixed submission:
import sys
readline = sys.stdin.readline
from collections import Counter
MOD = 2019

def main():
    S = list(map(int, list(readline().rstrip())))
    N = len(S)
    T = [0] * (N+1)
    e = 1
    for i in range(N-1, -1, -1):
        T[i] = (T[i+1] + int(S[i]) * e) % MOD
        e = e * 10 % MOD
    
    T = [t % MOD for t in T]
    c = Counter(T)
    ans = 0
    for k, v in c.items():
        ans += (v * (v-1)) // 2
    print(ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
from collections import deque

def main():
  	K = int(input())
    que = deque(['1', '2', '3', '4', '5', '6', '7', '8', '9'])

    while K:
        if K == 1:
            ans = que.popleft()
            break
        K -= 1
        v = que.popleft()
        if v[-1] == '0':
            que.append(v + '0')
            que.append(v + '1')
        elif v[-1] == '9':
            que.append(v + '8')
            que.append(v + '9')
        else:
            que.append(v + str(int(v[-1]) - 1))
            que.append(v + str(int(v[-1])))
            que.append(v + str(int(v[-1]) + 1))

    print(ans)

if __name__ == '__main__':
    main()

Fixed submission:
from collections import deque
K = int(input())

que = deque(['1', '2', '3', '4', '5', '6', '7', '8', '9'])

while K:
    if K == 1:
        ans = que.popleft()
        break
    K -= 1
    v = que.popleft()
    if v[-1] == '0':
        que.append(v + '0')
        que.append(v + '1')
    elif v[-1] == '9':
        que.append(v + '8')
        que.append(v + '9')
    else:
        que.append(v + str(int(v[-1]) - 1))
        que.append(v + str(int(v[-1])))
        que.append(v + str(int(v[-1]) + 1))

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
P = list(map(int, input().split()))

max_val = -1
max_pairs = None
for i in range(N-K+1):
    if sum(P[i:i+K]) > max_val:
        max_val = sum(P[i:i+K])
        max_pairs = P[i:i+K]

print(sum([(1+p)/2 for p in max_pairs]))

Fixed submission:
def main():
    N, K = map(int, input().split())
    P = list(map(int, input().split()))

    P = [(1+p)/2 for p in P]
    p_sum = [sum(P[:K])]
    for i in range(K, N):
        p_sum.append(p_sum[-1] - P[i-K] + P[i])
    print(max(p_sum))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
H = list(map(int, input().split()))

for _ in range(K):
    if len(H) == 0:
        break
    H.remove(max(H))

print(sum(H))

Fixed submission:
from heapq import heapify, heappush, heappop
N, K = map(int, input().split())
H = list(map(int, input().split()))

H = [-h for h in H]
heapify(H)
for _ in range(K):
    if len(H) == 0:
        break
    heappop(H)

print(-sum(H))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
readline = sys.stdin.readline
INF = 10 ** 8


def main():
    H, N = map(int, readline().rstrip().split())
    dp = [INF] * (H + 1)  # HPを減らすのに必要な最小のMP
    dp[0] = 0

    for _ in range(N):
        hp, mp = map(int, readline().rstrip().split())

        for i in range(H):
            j = min(i+hp, H)
            dp[j] = min(dp[j], dp[i] + mp)

    print(dp[-1])


if __name__ == '__main__':
    main()

Fixed submission:
INF = 10 ** 9

def main():
    H, N = map(int, input().split())
    dp = [INF] * (H+1)
    dp[0] = 0
    for _ in range(N):
        a, b = map(int, input().split())
        for j in range(H):
            nj = min(j+a, H)
            dp[nj] = min(dp[nj], dp[j]+b)

    print(dp[H])

    
if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
import sys
readline = sys.stdin.readline
INF = 10 ** 10


def main():
    H, N = map(int, readline().rstrip().split())
    dp = [INF] * (H + 1)  # HPを減らすのに必要な最小のMP
    dp[0] = 0

    for _ in range(N):
        hp, mp = map(int, readline().rstrip().split())

        for i in range(hp):
            dp[i] = min(dp[i], mp)

        for i in range(hp, H+1):
            dp[i] = min(dp[i-hp] + mp, dp[i])

    print(dp[-1])


if __name__ == '__main__':
    main()

Fixed submission:
INF = 10 ** 9

def main():
    H, N = map(int, input().split())
    dp = [INF] * (H+1)
    dp[0] = 0
    for _ in range(N):
        a, b = map(int, input().split())
        for j in range(H):
            nj = min(j+a, H)
            dp[nj] = min(dp[nj], dp[j]+b)

    print(dp[H])

    
if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
INF = 10 ** 9

def main():
    H, N = map(int, input().split())
    dp = [INF] * (H+1)
    dp[0] = 0
    for _ in range(N):
        a, b = map(int, input().split())
        for j in range(H):
            nj = min(j+a, H)
            dp[nj] = min(dp[nj], dp[j]+b)

    print(dp[H])

    
if __name__ == "__main__":
    main()

Fixed submission:
INF = 10 ** 9

def main():
    H, N = map(int, input().split())
    dp = [INF] * (H+1)
    dp[0] = 0
    for _ in range(N):
        a, b = map(int, input().split())
        for j in range(H):
            nj = min(j+a, H)
            dp[nj] = min(dp[nj], dp[j]+b)

    print(dp[H])

    
if __name__ == "__main__":
    main()