Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N, M = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(N)]
a.sort()
a.append([np.inf, np.inf])
ans = 0
ind = 0
check = -1
for i in range(1, M+1):
    while a[ind][0] <= i:
        ind += 1
    if a[:ind]:
        m = max(a[:ind], key = lambda x:x[1])
        ans += m[1]
        a.remove(m)
        a.insert(0, [0, 0])
print(ans)

Fixed submission:
import heapq as hq
import numpy as np

N, M = map(int, input().split())
job = [list(map(int, input().split())) for _ in range(N)]
ans = 0
job.sort()
job.append([np.inf, np.inf])
jobhq = []
index = 0
for day in range(1, M + 1):
    while day >= job[index][0]:
        hq.heappush(jobhq, - job[index][1])
        index += 1
    if jobhq:
        ans += - hq.heappop(jobhq)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N, M = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(N)]
a.sort()
a.append([np.inf, np.inf])
job = []
ans = 0
ind = 0
for i in range(1, M+1):
    while a[ind][0] <= i:
        job.append(a[ind][1])
        ind += 1
        if ind == N:
            break
    if job:
        m = max(job)
        ans += m
        job.remove(m)
print(ans)

Fixed submission:
import heapq as hq
import numpy as np

N, M = map(int, input().split())
job = [list(map(int, input().split())) for _ in range(N)]
ans = 0
job.sort()
job.append([np.inf, np.inf])
jobhq = []
index = 0
for day in range(1, M + 1):
    while day >= job[index][0]:
        hq.heappush(jobhq, - job[index][1])
        index += 1
    if jobhq:
        ans += - hq.heappop(jobhq)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N, M = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(N)]
a.sort()
a.append([np.inf, np.inf])
job = []
ans = 0
ind = 0
for i in range(1, M+1):
    while a[ind][0] <= i:
        job.append(a[ind][1])
        ind += 1
        if ind == N:
            break
    if job:
        job.sort()
        ans += job.pop(-1)
print(ans)

Fixed submission:
import heapq as hq
import numpy as np

N, M = map(int, input().split())
job = [list(map(int, input().split())) for _ in range(N)]
ans = 0
job.sort()
job.append([np.inf, np.inf])
jobhq = []
index = 0
for day in range(1, M + 1):
    while day >= job[index][0]:
        hq.heappush(jobhq, - job[index][1])
        index += 1
    if jobhq:
        ans += - hq.heappop(jobhq)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(N)]
a.sort()
job = []
ans = 0
ind = 0
for i in range(1, M+1):
    if ind != N:
        while a[ind][0] <= i:
            job.append(a[ind][1])
            ind += 1
            if ind == N:
                break
    if job:
        job.sort()
        ans += job.pop(-1)
print(ans)

Fixed submission:
import heapq as hq
import numpy as np

N, M = map(int, input().split())
job = [list(map(int, input().split())) for _ in range(N)]
ans = 0
job.sort()
job.append([np.inf, np.inf])
jobhq = []
index = 0
for day in range(1, M + 1):
    while day >= job[index][0]:
        hq.heappush(jobhq, - job[index][1])
        index += 1
    if jobhq:
        ans += - hq.heappop(jobhq)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(N)]
a.sort(key = lambda x:x[1], reverse = True)
day = {i+1 for i in range(M)}
ans = 0
for i in range(N):
    check = {a[i][0] + j for j in range(N)}
    if check & day:
        ans += a[i][1]
        day -= {min(check & day)}
print(ans)

Fixed submission:
import heapq as hq
import numpy as np

N, M = map(int, input().split())
job = [list(map(int, input().split())) for _ in range(N)]
ans = 0
job.sort()
job.append([np.inf, np.inf])
jobhq = []
index = 0
for day in range(1, M + 1):
    while day >= job[index][0]:
        hq.heappush(jobhq, - job[index][1])
        index += 1
    if jobhq:
        ans += - hq.heappop(jobhq)
print(ans)