Buggy python submission (verdict: Runtime Error):
import heapq

n, m = map(int,input().split())
joblist = {}
for i in range(n):
    a,b = map(int,input().split())
    if a in joblist:
        joblist[a].append(-1*b)
    else:
        joblist[a] = [-1*b]

kouho = []
 
ans =0
 
for i in range(1,m+1):
    if i in joblist:
        for j in joblist[i]:
            heapq.heappush(kouho,j)
    
    ans += heapq.heappop(kouho)
 
print(-1*ans)

Fixed submission:
import heapq

n, m = map(int,input().split())
joblist = {}
for i in range(n):
    a,b = map(int,input().split())
    if a in joblist:
        joblist[a].append(-1*b)
    else:
        joblist[a] = [-1*b]

kouho = []
 
ans =0
 
for i in range(1,m+1):
    if i in joblist:
        for j in joblist[i]:
            heapq.heappush(kouho,j)
    if kouho:
        ans += heapq.heappop(kouho)
 
print(-1*ans)

Buggy python submission (verdict: Runtime Error):
import heapq

n, m = map(int,input().split())
joblist = {}
for i in range(n):
    a,b = map(int,input().split())
    if a in joblist:
        joblist[a].append(-1*b)
    else:
        joblist[a] = [-1*b]

kouho = []
 
ans =0
 
for i in range(1,m+1):
    if i in joblist:
        for j in joblist[i]:
            heapq.heappush(kouho,j)
    
    ans += heapq.heappop(kouho)
 
print(-1*ans)

Fixed submission:
import heapq

n, m = map(int,input().split())
joblist = {}
for i in range(n):
    a,b = map(int,input().split())
    if a in joblist:
        joblist[a].append(-1*b)
    else:
        joblist[a] = [-1*b]

kouho = []
 
ans =0
 
for i in range(1,m+1):
    if i in joblist:
        for j in joblist[i]:
            heapq.heappush(kouho,j)
    if kouho:
        ans += heapq.heappop(kouho)
 
print(-1*ans)

Buggy python submission (verdict: Time Limit Exceeded):
import heapq

n, m = map(int,input().split())
joblist = []
for i in range(n):
    a,b = map(int,input().split())
    joblist.append([a,b])
joblist.sort(key=lambda x :x[0])
kouho = []
 
ans =0
 
for i in range(1,m+1):
    count=0
    if joblist:
        for j,job in enumerate(joblist):
            if job[0]==i:
                
                heapq.heappush(kouho,(-1*job[1]))
                
                
            if job[0]!=i:
                if count:
                    for _ in range(count-1):
                        joblist.pop(0)
        if kouho:
            ans += -1*heapq.heappop(kouho)
 
print(ans)

Fixed submission:
import heapq

n, m = map(int,input().split())
joblist = {}
for i in range(n):
    a,b = map(int,input().split())
    if a in joblist:
        joblist[a].append(-1*b)
    else:
        joblist[a] = [-1*b]

kouho = []
 
ans =0
 
for i in range(1,m+1):
    if i in joblist:
        for j in joblist[i]:
            heapq.heappush(kouho,j)
    if kouho:
        ans += heapq.heappop(kouho)
 
print(-1*ans)

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!

n, m = map(int,input().split())
joblist = []
for i in range(n):
    a,b = map(int,input().split())
    joblist.append([a,b])
joblist.sort(key=lambda x :x[0])
kouho = []

ans =0

for i in range(1,m+1):
    count=0
    if joblist:
        for j,job in enumerate(joblist):
            if job[0]==i:
                
                kouho.append(job[1])
                
                
            if job[0]!=i:
                if count:
                    for _ in range(count-1):
                        joblist.pop(0)
        if kouho:
            kouho.sort(reverse=True)
            ans += kouho.pop(0)

print(ans)
    

Fixed submission:
import heapq

n, m = map(int,input().split())
joblist = {}
for i in range(n):
    a,b = map(int,input().split())
    if a in joblist:
        joblist[a].append(-1*b)
    else:
        joblist[a] = [-1*b]

kouho = []
 
ans =0
 
for i in range(1,m+1):
    if i in joblist:
        for j in joblist[i]:
            heapq.heappush(kouho,j)
    if kouho:
        ans += heapq.heappop(kouho)
 
print(-1*ans)