Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = int(input())
if n < 1 or n > 100:
    exit()

n1 = input()

i = len(n1)
if i < 1 or i > 100:
    exit()

n2 = '...'

if n >= i:
    print(n1)
else:
    print(n1[:n] + n2)

Fixed submission:
n = list(input())

i = len(n) - 1

if n[i] == '3':
    print('bon')
elif n[i] == '0' or n[i] == '1' or n[i] == '6' or n[i] == '8':
    print('pon')
else:
    print('hon')
Buggy python submission (verdict: Runtime Error):
s, t = map(input().split())

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

u = input()

if s == u:
    print(a - 1, b)
elif t == u:
    print(a, b - 1)


Fixed submission:
s, t = input().split()

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

u = input()

if s == u:
    print(a - 1, b)
elif t == u:
    print(a, b - 1)
Buggy python submission (verdict: Runtime Error):
a,b,c = map(input().split())

print(min(a+b,a+c,b+c))

Fixed submission:
a,b,c = map(int,input().split())

print(min(a+b,a+c,b+c))
Buggy python submission (verdict: Runtime Error):
n = int(input())

if n == 1:
    print('Hello World')
if n == 2:
    a, b = map(int,input().split())
    print(a + b)

Fixed submission:
n = int(input())

if n == 1:
    print('Hello World')
if n == 2:
    a = int(input())
    b = int(input())
    print(a + b)
Buggy python submission (verdict: Runtime Error):
a,b,c,d = map(int,input().split())

print(min(a,b)+min(c,d))

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())

print(min(a,b)+min(c,d))
Buggy python submission (verdict: Runtime Error):
n = int(input())

if n[0] != 9 and n[1] != 9:
    print('No')
else:
    print('Yes')

Fixed submission:
n = input()

if n[0] != '9' and n[1] != '9':
    print('No')
else:
    print('Yes')
Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np
from math import ceil as C, floor as F, sqrt, gcd as G
from collections import defaultdict as D, Counter as CNT
from functools import reduce as R
import heapq as HQ

class Heap:
  def __init__(self, data, reverse=False):
    self.reverse = -1 if reverse else 1
    self.data = [self.reverse * d for d in data]
    HQ.heapify(self.data)
  def push(self, x): return HQ.heappush(self.data, self.reverse * x)
  def pop(self): return self.reverse * HQ.heappop(self.data) 

ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def Ss(): return list(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Is(): return _Is(I())

n, k = I()
# steps = set()
steps = [0] * (n+1)
mod = 998244353

for _ in range(k):
    l, r = I()
    for i in range(l, r+1):
        steps[i] = 1
    # steps.update([i for i in range(l, r+1)])

ans = 0
# heap = Heap([1])
# seen = set([1])
# cache = D(int)
# cache[1] = 1
cache = np.array([0] * (n+1))
cache[1] = 1

# def go(i):
for i in range(1, n):
    if cache[i] == 0:
        continue
    now = np.array([0] * i + steps[:-i])
    cache = cache + (cache[i] * now)
    # for step in steps:
        # print(heap.data, seen, cache)
        # t = i + step
        # if t <= n:
            # cache[t] += cache[i]
            # cache[t] %= mod

    
print(cache[n] % mod)
    




Fixed submission:
import sys
from math import ceil as C, floor as F, sqrt, gcd as G
from collections import defaultdict as D, Counter as CNT
from functools import reduce as R
import heapq as HQ

class Heap:
  def __init__(self, data, reverse=False):
    self.reverse = -1 if reverse else 1
    self.data = [self.reverse * d for d in data]
    HQ.heapify(self.data)
  def push(self, x): return HQ.heappush(self.data, self.reverse * x)
  def pop(self): return self.reverse * HQ.heappop(self.data) 

ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def Ss(): return list(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Is(): return _Is(I())

word = S()
word += 'es' if word[-1] == 's' else 's'
print(word)
Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np
from math import ceil
from collections import defaultdict as D
 
def S(): return sys.stdin.readline().rstrip().split(' ')
def Ss(): return list(S())
def I(): return _I(S())
def Is(): return list(I())
def _I(ss): return map(int, ss) if len(ss) > 1 else int(ss[0])
 
N, K = I()
xs = sorted(Is())
print(np.sum(xs[:K]))

Fixed submission:
import sys
import numpy as np
from math import ceil as C, floor as F
from collections import defaultdict as D
from functools import reduce as R

ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def _Ss(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Ss(): return _Ss(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Is(): return _Is(I())

N, K = I()
xs = sorted(Is())
print(np.sum(xs[:K]))

Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np
from math import ceil
from collections import defaultdict as D

def S(): return sys.stdin.readline().rstrip().split(' ')
def Ss(): return list(S())
def I(): return _I(Ss())
def Is(): return list(I())
def _I(ss): return map(int, ss) if len(ss) > 1 else int(ss[0])

N, K = I()
xs = sorted(Is())
print(np.sum(xs[:K]))

Fixed submission:
import sys
import numpy as np
from math import ceil as C, floor as F
from collections import defaultdict as D
from functools import reduce as R

ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def _Ss(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Ss(): return _Ss(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Is(): return _Is(I())

N, K = I()
xs = sorted(Is())
print(np.sum(xs[:K]))
Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np
from math import ceil as C, floor as F
from collections import defaultdict as D
 
alp = 'abcdefghijklmnopqrstuvwxyz'
def S(): return sys.stdin.readline().rstrip().split(' ')
def Ss(): return list(S())
def I(): return _I(S())
def Is(): return list(I())
def _I(ss): return map(int, ss) if len(ss) > 1 else int(ss[0])
 
_ = I()
xs = Is()
 
sss = 0
count = D(int)
for x in xs:
  sss += x
  count[x] += 1
  
q = I()
for _ in range(q):
  b, c = I()
  sss += (c - b) * count[b]
  print(sss)
  count[c] += count[b]
  count[b] = 0

Fixed submission:
import sys
import numpy as np
from math import ceil as C, floor as F
from collections import defaultdict as D
from functools import reduce as R

ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def _Ss(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Ss(): return _Ss(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Is(): return _Is(I())

_ = I()
xs = Is()
 
sss = 0
count = D(int)
for x in xs:
  sss += x
  count[x] += 1
  
q = I()
for _ in range(q):
  b, c = I()
  sss += (c - b) * count[b]
  print(sss)
  count[c] += count[b]
  count[b] = 0

Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np
from math import ceil as C, floor as F
from collections import defaultdict as D
 
alp = 'abcdefghijklmnopqrstuvwxyz'
def S(): return sys.stdin.readline().rstrip().split(' ')
def Ss(): return list(S())
def I(): return _I(S())
def Is(): return list(I())
def _I(ss): return map(int, ss) if len(ss) > 1 else int(ss[0])
 
_ = I()
xs = Is()

count = D(int)
for x in xs:
  count[x] += 1

q = I()
for _ in range(q):
  b, c = I()
  count[c] += count[b]
  count[b] = 0
  print(np.sum([k*v for k, v in count.items()]))
  

Fixed submission:
import sys
import numpy as np
from math import ceil as C, floor as F
from collections import defaultdict as D
from functools import reduce as R

ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def _Ss(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Ss(): return _Ss(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Is(): return _Is(I())

_ = I()
xs = Is()
 
sss = 0
count = D(int)
for x in xs:
  sss += x
  count[x] += 1
  
q = I()
for _ in range(q):
  b, c = I()
  sss += (c - b) * count[b]
  print(sss)
  count[c] += count[b]
  count[b] = 0
Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np
from math import ceil as C, floor as F, sqrt
from collections import defaultdict as D, Counter as CNT
from functools import reduce as R
 
ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def Ss(): return list(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Is(): return _Is(I())

a, b, c, k = Is()
nums = sorted([1] * a + [0] * b + [-1] * c, reverse=True)
print(np.sum(nums[:k]))

Fixed submission:
import sys
import numpy as np
from math import ceil as C, floor as F, sqrt
from collections import defaultdict as D, Counter as CNT
from functools import reduce as R
 
ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def Ss(): return list(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Is(): return _Is(I())

a, b, c, k = Is()

a = min(a, k)
k -= a

b = min(b, k)
k -= b

c = min(c, k)
k -= c

print(a-c)
Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np
from math import ceil as C, floor as F, sqrt
from collections import defaultdict as D, Counter as CNT
from functools import reduce as R
 
ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def Ss(): return list(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Is(): return _Is(I())

_, e = I()
hs = Is()

obs = sorted([(i, h) for i, h in enumerate(hs, 1)], key=lambda x:x[1], reverse=True)
seen = D(bool)

roads = D(set)
for _ in range(e):
  a, b = I()
  roads[a].add(b)
  roads[b].add(a)
  
ans = 0
for ob in obs:
  if not seen[ob[0]]:
    if all(ob[1] > hs[r] for r in roads[ob[0]]):
      ans += 1
    seen[ob[0]] = True
    for r in roads[ob[0]]:
      seen[r] = True
      
print(ans)

Fixed submission:
import sys
import numpy as np
from math import ceil as C, floor as F, sqrt
from collections import defaultdict as D, Counter as CNT
from functools import reduce as R
 
ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def Ss(): return list(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Is(): return _Is(I())

_, e = I()
hs = Is()

obs = sorted([(i, h) for i, h in enumerate(hs, 1)], key=lambda x:x[1], reverse=True)
seen = D(bool)

roads = D(set)
for _ in range(e):
  a, b = I()
  roads[a].add(b)
  roads[b].add(a)
  
ans = 0
for ob in obs:
  if not seen[ob[0]]:
    if all(ob[1] > hs[r-1] for r in roads[ob[0]]):
      ans += 1
    seen[ob[0]] = True
    for r in roads[ob[0]]:
      seen[r] = True
      
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np
from math import ceil as C, floor as F, sqrt
from collections import defaultdict as D, Counter as CNT
from functools import reduce as R
 
ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def Ss(): return list(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Is(): return _Is(I())

x = I()

As = []
Bs = []

for i in range(64):
  n = i ** 5
  As.append(n)
  Bs.append(n)
  Bs.append(-n)

xs = [(a, x-a) for a in As]
for x in xs:
  if x[1] in Bs:
    print(x[0], -int(pow(x[1], 1/5)))
    break


Fixed submission:
import sys
import numpy as np
from math import ceil as C, floor as F, sqrt
from collections import defaultdict as D, Counter as CNT
from functools import reduce as R
 
ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def Ss(): return list(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Is(): return _Is(I())

x = I()

A = []
As = []
B = []
Bs = []

for i in range(250):
  n = i ** 5
  A.append(i)
  As.append(n)
  B.append(i)
  Bs.append(n)
  B.append(-i)
  Bs.append(-n)

xs = [a-x for a in As]
for i, x in enumerate(xs):
  if x in Bs:
    print(A[i], B[Bs.index(x)])
    break
Buggy python submission (verdict: Runtime Error):
from scipy.sparse.csgraph import connected_components
from scipy.sparse import csr_matrix
from sys import stdin


def makeConnected(n, connections):
    l = list(zip(*connections))
    d = [1] * len(connections)
    a = csr_matrix((d, (l[0], l[1])), (n, n))
    return connected_components(a, return_labels=0)


def main():
    input = lambda: stdin.readline()[:-1]
    N, M = map(int, input().split())
    AB = [tuple(map(int, input().split())) for _ in [0] * M]

    ans = makeConnected(N, AB) - 1
    print(ans)


main()


Fixed submission:
from scipy.sparse.csgraph import connected_components
from scipy.sparse import csr_matrix
from sys import stdin


def makeConnected(n, connections):
    l = list(zip(*connections))
    d = [1] * len(connections)
    a = csr_matrix((d, (l[0], l[1])), (n, n))
    return connected_components(a, return_labels=0)


def main():
    input = lambda: stdin.readline()[:-1]
    N, M = map(int, input().split())
    AB = [tuple(map(int, input().split())) for _ in [0] * M]

    ab = [[a - 1, b - 1] for a, b in AB]
    ans = makeConnected(N, ab) - 1
    print(ans)


main()
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import accumulate
from operator import mul
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N, K = map(int, input().split())
    A = tuple(map(int, input().split()))

    point = list(accumulate(A[:K], mul))
    for i in range(K, N):
        point.append(point[-1] * A[i] // A[i - K])
    for i in range(K, N):
        if point[i - 1] < point[i]:
            print("Yes")
        else:
            print("No")


main()


Fixed submission:
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N, K = map(int, input().split())
    A = tuple(map(int, input().split()))

    for i in range(K, N):
        if A[i - K] < A[i]:
            print("Yes")
        else:
            print("No")


main()

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import accumulate
from operator import mul
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N, K = map(int, input().split())
    A = tuple(map(int, input().split()))

    point = list(accumulate(A[:K], mul))
    for i in range(K, N):
        point.append(point[-1] * A[i] // A[i - K])
    for i in range(K, N):
        if point[i - 1] < point[i]:
            print("Yes")
        else:
            print("No")


main()


Fixed submission:
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N, K = map(int, input().split())
    A = tuple(map(int, input().split()))

    for i in range(K, N):
        if A[i - K] < A[i]:
            print("Yes")
        else:
            print("No")


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


def main():
    input = lambda: stdin.readline()[:-1]
    N = int(input())

    ans = defaultdict(int)
    for x in range(1, 101):
        for y in range(1, 10):
            for z in range(1, 101):
                n = x * x + y * y + z * z + x * y + y * z + z * x
                ans[n] += 1

    for i in range(1, N + 1):
        print(ans[i])


main()


Fixed submission:
from collections import defaultdict
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N = int(input())

    ans = defaultdict(int)
    for x in range(1, 101):
        for y in range(1, 101):
            for z in range(1, 101):
                n = x * x + y * y + z * z + x * y + y * z + z * x
                ans[n] += 1

    for i in range(1, N + 1):
        print(ans[i])


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


def main():
    input = lambda: stdin.readline()[:-1]
    S = input()
    Q = int(input())

    s = deque(S)
    for _ in [0] * Q:
        T = input().split()
        if T[0] == '1':
            s.reverse()
        else:
            f, c = T[1], T[2]
            if f == '1':
                s.appendleft(c)
            else:
                s.append(c)
    print(''.join(s))


main()


Fixed submission:
from collections import deque
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    S = input()
    Q = int(input())

    s = deque(S)
    left, right = s.appendleft, s.append
    rev = 0
    for _ in [0] * Q:
        T = input().split()
        if T[0] == '1':
            left, right = right, left
            rev += 1
        else:
            f, c = T[1], T[2]
            if f == '1':
                left(c)
            else:
                right(c)

    if rev % 2:
        s.reverse()
    print(''.join(s))


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


def main():
    input = lambda: stdin.readline()[:-1]
    N = int(input())
    L = list(map(int, input().split()))

    L.sort()
    ans = 0
    for i in range(N - 2):
        for j in range(i + 1, N - 1):
            n = bisect_left(L[j+1:], L[i] + L[j])
            ans += n
    print(ans)


main()


Fixed submission:
from bisect import bisect_left
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N = int(input())
    L = list(map(int, input().split()))

    L.sort()
    ans = 0
    for i in range(N - 2):
        for j in range(i + 1, N - 1):
            n = bisect_left(L, L[i] + L[j])
            ans += n - (j + 1)
    print(ans)


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

def main():
    input = lambda: stdin.readline()[:-1]
    H, W, A, B = map(int, input().split())

    if all((A > 0 and H % A, B > 0 and W % B)):
        print('No')
        return

    grid = [[0] * W for _ in [0] * H]
    grid[0][0] = 1
    for h in range(H):
        i = h // B if h else 0
        for w in range(A):
            grid[h][w+i] = 1

    for s in grid:
        print(*s, sep='')

main()


Fixed submission:
from sys import stdin

def main():
    input = lambda: stdin.readline()[:-1]
    H, W, A, B = map(int, input().split())

    grid = [[1] * A + [0] * (W - A) for _ in range(B)]
    grid += [[0] * A + [1] * (W - A) for _ in range(H - B)]
    for n in grid:
        print(*n, sep='')

main()
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
from heapq import heapify, heappop, heappush
from sys import stdin

def main():
    N, M = map(int, input().split())
    AB = [tuple(map(int, input().split())) for _ in [0] * N]

    ab = defaultdict(list)
    for a, b in AB:
        ab[a].append(b * -1)

    ans = 0
    flag = 1
    for i in range(1, M + 1):
        if flag:
            reward = heapify(ab[1])
            flag = 0
        if ab[i]:
            for n in ab[i]:
                heappush(reward, n * -1)
            ans += heappop(reward) * -1
    print(ans)

input = lambda: stdin.readline()
main()


Fixed submission:
from collections import defaultdict
from heapq import heapify, heappop, heappush
from sys import stdin

def main():
    N, M = map(int, input().split())
    AB = [tuple(map(int, input().split())) for _ in [0] * N]

    ab = defaultdict(list)
    for a, b in AB:
        ab[a].append(b)

    ans = 0
    reward = []
    for i in range(1, M + 1):
        if ab[i]:
            for n in ab[i]:
                heappush(reward, n * -1)
        if reward:
            ans += heappop(reward) * -1
    print(ans)

input = lambda: stdin.readline()
main()

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

def main():
    N, M = map(int, input().split())
    AB = [tuple(map(int, input().split())) for _ in [0] * N]

    ab = defaultdict(list)
    for a, b in AB:
        ab[a].append(b)

    ans = 0
    reward = []
    for i in range(1, M + 1):
        if ab[i]:
            reward += ab[i]
            reward.sort()
        if reward:
            ans += reward[-1]
            reward.pop()
    print(ans)

input = lambda: stdin.readline()
main()


Fixed submission:
from collections import defaultdict
from heapq import heapify, heappop, heappush
from sys import stdin

def main():
    N, M = map(int, input().split())
    AB = [tuple(map(int, input().split())) for _ in [0] * N]

    ab = defaultdict(list)
    for a, b in AB:
        ab[a].append(b)

    ans = 0
    reward = []
    for i in range(1, M + 1):
        if ab[i]:
            for n in ab[i]:
                heappush(reward, n * -1)
        if reward:
            ans += heappop(reward) * -1
    print(ans)

input = lambda: stdin.readline()
main()
Buggy python submission (verdict: Runtime Error):
from sys import stdin

def main():
    S = int(input())

    p1, p2, p3 = (0, 0), (1, S), (2, 0)
    print(*p1, *p2, *p3)

input = lambda: stdin.readline()
main()


Fixed submission:
from math import ceil
from sys import stdin

def main():
    S = int(input())

    a = d = ceil(S ** 0.5)
    b = a * d - S
    c = 1
    print(0, 0, a, b, c, d)

input = lambda: stdin.readline()
main()