Buggy python submission (verdict: Runtime Error):
NM = input()
N = int(NM.split(' ')[0])
M = int(NM.split(' ')[1])
each_days_map = {}
max_sort_list = [0]

def insert_max_sort(b):
    for idx in range(len(max_sort_list)):
        if b > max_sort_list[idx]:
            max_sort_list.insert(idx,b)
            if len(max_sort_list) > M:
                max_sort_list.pop()
            break

for i in range(N):
    ab = input()
    a = int(ab.split(' ')[0])
    b = int(ab.split(' ')[1])
    if a > M or b < max_sort_list[len(max_sort_list)-1]:
        continue
    if a in each_days_map.keys():
        a_len = len(each_days_map[a])
        if b > each_days_map[a][a_len-1]:
            for idx in range(a_len):
                if b > each_days_map[a][idx]:
                    each_days_map[a].insert(idx,b)
                    if a_len > (M - a + 1):
                        removed_num = each_days_map[a][a_len-1]
                        each_days_map[a].pop()
                        max_sort_list.remove(removed_num)
                    insert_max_sort(b)
                    break
        else:
            if M > a_len and (M - a + 1) > a_len:
                each_days_map[a].append(b)
                insert_max_sort(b)
    else:
        each_days_map[a] = [b]
        insert_max_sort(b)
print(sum(max_sort_list))

Fixed submission:
import heapq
NM = input()
N = int(NM.split(' ')[0])
M = int(NM.split(' ')[1])
each_days_list = [[] for _ in range(M)]
 
for i in range(N):
    ab = input()
    a = int(ab.split(' ')[0])
    b = int(ab.split(' ')[1])
    if a <= M:
        each_days_list[a-1].append(b)

max_list = []
salary_count = 0
for i in range(M):
    for j in range(len(each_days_list[i])): 
        heapq.heappush(max_list,-each_days_list[i][j])
    if len(max_list) > 0:
        salary_count += -heapq.heappop(max_list)
        
print(salary_count)

Buggy python submission (verdict: Runtime Error):
NM = input()
N = int(NM.split(' ')[0])
M = int(NM.split(' ')[1])
each_days_map = {}
max_sort_list = [0]

def insert_max_sort(b):
    for idx in range(len(max_sort_list)):
        if b > max_sort_list[idx]:
            max_sort_list.insert(idx,b)
            if len(max_sort_list) > M:
                max_sort_list.pop()
            break

for i in range(N):
    ab = input()
    a = int(ab.split(' ')[0])
    b = int(ab.split(' ')[1])
    insert_flag = True
    if a > M or b < max_sort_list[len(max_sort_list)-1]:
        continue
    if a in each_days_map.keys():
        a_len = len(each_days_map[a])
        for idx in range(a_len):
            if b > each_days_map[a][idx]:
                each_days_map[a].insert(idx,b)
                if a_len > (M - a + 1):
                    removed_num = each_days_map[a][a_len-1]
                    each_days_map[a].pop()
                    max_sort_list.remove(removed_num)
                insert_max_sort(b)
                insert_flag = False
                break
        if insert_flag and M > a_len and (M - a + 1) > a_len:
            each_days_map[a].append(b)
            insert_max_sort(b)
    else:
        each_days_map[a] = [b]
        insert_max_sort(b)
print(sum(max_sort_list))

Fixed submission:
import heapq
NM = input()
N = int(NM.split(' ')[0])
M = int(NM.split(' ')[1])
each_days_list = [[] for _ in range(M)]
 
for i in range(N):
    ab = input()
    a = int(ab.split(' ')[0])
    b = int(ab.split(' ')[1])
    if a <= M:
        each_days_list[a-1].append(b)

max_list = []
salary_count = 0
for i in range(M):
    for j in range(len(each_days_list[i])): 
        heapq.heappush(max_list,-each_days_list[i][j])
    if len(max_list) > 0:
        salary_count += -heapq.heappop(max_list)
        
print(salary_count)