Buggy python submission (verdict: Runtime Error):
import heapq
job = list()
salary = list()
n,m = map(int,input().split())

for i in range(n):
    a,b = map(int,input().split())
    job.append(a,b)
    
job.sort(reverse = True)

for x in job:
    s,t = x
    heapq.heappush(salary,t)
    if s - m > 0:
        heapq.heappop(salary)
    else:
        m -= 1

print(sum(salary))


Fixed submission:
import heapq
job = list()
salary = list()
n,m = map(int,input().split())

for i in range(n):
    a,b = map(int,input().split())
    job.append((a,b))

job.sort(reverse = True)

for x in job:
    s,t = x
    heapq.heappush(salary,t)
    if s - m > 0:
        heapq.heappop(salary)
    else:
        m -= 1

print(sum(salary))

Buggy python submission (verdict: Time Limit Exceeded):
import heapq
job = list()
salary = list()
n,m = map(int,input().split())
k = -1
def h_sort(list):
    h = []
    for v in list:
        heapq.heappush(h, v)
    return [heapq.heappop(h) for i in range(len(h))]

for i in range(n):
    a,b = map(int,input().split())
    job.append((a,b))

job = h_sort(job)
job.reverse()


for x in job:
    s,t = x
    if k == -1 or k > t:
        k = t
    salary.append(t)

    if s - m > 0:
        if salary[0] > k:
            salary = h_sort(salary)
            k = -1
        del salary[0]
    else:
        m -= 1

print(sum(salary))


Fixed submission:
import heapq
job = list()
salary = list()
n,m = map(int,input().split())

for i in range(n):
    a,b = map(int,input().split())
    job.append((a,b))

job.sort(reverse = True)

for x in job:
    s,t = x
    heapq.heappush(salary,t)
    if s - m > 0:
        heapq.heappop(salary)
    else:
        m -= 1

print(sum(salary))

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
job = [list() for _ in range(m)]
total = 0
l = list()
for _ in range(n):
    a,b = map(int,input().split())
    if a <= m :
        job[a-1].append(b)
for i in range(m):
    l += job[i]
    if l != []:
        l.sort(reverse = True)
        total += l.pop(0)
print(total)


Fixed submission:
import heapq
job = list()
salary = list()
n,m = map(int,input().split())

for i in range(n):
    a,b = map(int,input().split())
    job.append((a,b))

job.sort(reverse = True)

for x in job:
    s,t = x
    heapq.heappush(salary,t)
    if s - m > 0:
        heapq.heappop(salary)
    else:
        m -= 1

print(sum(salary))

Buggy python submission (verdict: Time Limit Exceeded):
job = list()
salary = list()
n,m = map(int,input().split())
k = -1

for i in range(n):
    a,b = map(int,input().split())
    job.append((a,b))

job.sort(reverse = True)

for x in job:
    s,t = x
    if k == -1 or k > t:
         k = t
    salary.append(t)

    if s - m > 0:
        if salary[0] > k:
              salary.sort()
              k = -1
        del salary[0]
    else:
        m -= 1

print(sum(salary))


Fixed submission:
import heapq
job = list()
salary = list()
n,m = map(int,input().split())

for i in range(n):
    a,b = map(int,input().split())
    job.append((a,b))

job.sort(reverse = True)

for x in job:
    s,t = x
    heapq.heappush(salary,t)
    if s - m > 0:
        heapq.heappop(salary)
    else:
        m -= 1

print(sum(salary))

Buggy python submission (verdict: Time Limit Exceeded):
job = list()
salary = list()
n,m = map(int,input().split())

for i in range(n):
    a,b = map(int,input().split())
    job.append((a,b))

job.sort(reverse = True)

for x in job:
    s,t = x
    salary.append(t)

    if s - m > 0:
        salary.sort()
        salary.pop(0)
    else:
        m -= 1

print(sum(salary))


Fixed submission:
import heapq
job = list()
salary = list()
n,m = map(int,input().split())

for i in range(n):
    a,b = map(int,input().split())
    job.append((a,b))

job.sort(reverse = True)

for x in job:
    s,t = x
    heapq.heappush(salary,t)
    if s - m > 0:
        heapq.heappop(salary)
    else:
        m -= 1

print(sum(salary))

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
job = [(0,0) for _ in range(n)]
salary = [0 for _ in range(n)]

for i in range(n):
    a,b= map(int,input().split())
    job[i] = a,b
    salary[i] = b
job.sort(reverse = True)
max = max(salary)
salary = [max+1 for _ in range(n)]

for j in range(n):
    s,t = job[j]
    salary[j] = t

    if s - m > 0:
        salary[salary.index(min(salary))] = max+1
    else:
        m -= 1
for k in range(n):
    if salary[k] == max+1:
        salary[k] = 0
print(sum(salary))


Fixed submission:
import heapq
job = list()
salary = list()
n,m = map(int,input().split())

for i in range(n):
    a,b = map(int,input().split())
    job.append((a,b))

job.sort(reverse = True)

for x in job:
    s,t = x
    heapq.heappush(salary,t)
    if s - m > 0:
        heapq.heappop(salary)
    else:
        m -= 1

print(sum(salary))

Buggy python submission (verdict: Time Limit Exceeded):
job = list()
salary = list()
n,m = map(int,input().split())
k = m

for i in range(n):
    a,b = map(int,input().split())
    job.append((a,b))

job.sort(reverse = True)

for x in job:
    s,t = x
    salary.append(t)

    if s - k > 0:
        salary.remove(min(salary))
    else:
        k -= 1

print(sum(salary))


Fixed submission:
import heapq
job = list()
salary = list()
n,m = map(int,input().split())

for i in range(n):
    a,b = map(int,input().split())
    job.append((a,b))

job.sort(reverse = True)

for x in job:
    s,t = x
    heapq.heappush(salary,t)
    if s - m > 0:
        heapq.heappop(salary)
    else:
        m -= 1

print(sum(salary))

Buggy python submission (verdict: Runtime Error):
job = list()
salary = list()
k = m
n,m = map(int,input().split())

for i in range(n):
    a,b = map(int,input().split())
    job.append((a,b))

job.sort(reverse = True)

for x in job:
    s,t = x
    salary.append(t)

    if s - k > 0:
        salary.remove(min(salary))
    else:
        k -= 1

print(sum(salary))


Fixed submission:
import heapq
job = list()
salary = list()
n,m = map(int,input().split())

for i in range(n):
    a,b = map(int,input().split())
    job.append((a,b))

job.sort(reverse = True)

for x in job:
    s,t = x
    heapq.heappush(salary,t)
    if s - m > 0:
        heapq.heappop(salary)
    else:
        m -= 1

print(sum(salary))

Buggy python submission (verdict: Time Limit Exceeded):
job = list()
salary = list()
n,m = map(int,input().split())
k = m

for i in range(n):
    job.append(tuple(map(int,input().split())))

job.sort(reverse = True)

for x in job:
    a,b = x
    salary.append(b)

    if a > k:
        salary.remove(min(salary))
    else:
        k -= 1

print(sum(salary))


Fixed submission:
import heapq
job = list()
salary = list()
n,m = map(int,input().split())

for i in range(n):
    a,b = map(int,input().split())
    job.append((a,b))

job.sort(reverse = True)

for x in job:
    s,t = x
    heapq.heappush(salary,t)
    if s - m > 0:
        heapq.heappop(salary)
    else:
        m -= 1

print(sum(salary))

Buggy python submission (verdict: Time Limit Exceeded):
job = list()
salary = list()
k = 0
n,m = map(int,input().split())

for i in range(n):
    job.append(tuple(map(int,input().split())))

job.sort(reverse = True)

for x in job:
    a,b = x
    salary.append(b)

    if a + k > m:
        salary.remove(min(salary))
    else:
        k += 1

print(sum(salary))


Fixed submission:
import heapq
job = list()
salary = list()
n,m = map(int,input().split())

for i in range(n):
    a,b = map(int,input().split())
    job.append((a,b))

job.sort(reverse = True)

for x in job:
    s,t = x
    heapq.heappush(salary,t)
    if s - m > 0:
        heapq.heappop(salary)
    else:
        m -= 1

print(sum(salary))

Buggy python submission (verdict: Time Limit Exceeded):
job = list()
salary = list()
k = 0
n,m = map(int,input().split())

for i in range(n):
    a,b = map(int,input().split())
    job.append((a,b))

job.sort(reverse = True)

for x in job:
    a,b = x
    salary.append(b)

    if a + k > m:
        salary.remove(min(salary))
    else:
        k += 1

print(sum(salary))


Fixed submission:
import heapq
job = list()
salary = list()
n,m = map(int,input().split())

for i in range(n):
    a,b = map(int,input().split())
    job.append((a,b))

job.sort(reverse = True)

for x in job:
    s,t = x
    heapq.heappush(salary,t)
    if s - m > 0:
        heapq.heappop(salary)
    else:
        m -= 1

print(sum(salary))

Buggy python submission (verdict: Time Limit Exceeded):
job = list()
salary = list()
k = 0
n,m = map(int,input().split())

for i in range(n):
    a,b = map(int,input().split())
    job.append((a,b))

job.sort(reverse = True)

for j in range(n):
    a,b = job[j]
    salary.append(b)

    if a + k > m :
        salary.remove(min(salary))
        continue

    k += 1

print(sum(salary))


Fixed submission:
import heapq
job = list()
salary = list()
n,m = map(int,input().split())

for i in range(n):
    a,b = map(int,input().split())
    job.append((a,b))

job.sort(reverse = True)

for x in job:
    s,t = x
    heapq.heappush(salary,t)
    if s - m > 0:
        heapq.heappop(salary)
    else:
        m -= 1

print(sum(salary))

Buggy python submission (verdict: Time Limit Exceeded):
job = list()
salary = list()
j = 0
n,m = map(int,input().split())
for i in range(n):
    a,b = map(int,input().split())
    job.append((a,b))
job.sort(reverse = True)
for i in range(n):
    a,b = job[i]
    salary.append(b)
    if a + j > m :
        salary.remove(min(salary))
        continue
    j += 1
print(sum(salary))


Fixed submission:
import heapq
job = list()
salary = list()
n,m = map(int,input().split())

for i in range(n):
    a,b = map(int,input().split())
    job.append((a,b))

job.sort(reverse = True)

for x in job:
    s,t = x
    heapq.heappush(salary,t)
    if s - m > 0:
        heapq.heappop(salary)
    else:
        m -= 1

print(sum(salary))

Buggy python submission (verdict: Time Limit Exceeded):
job = list()
salary = list()
m_total = 0
j = 0
n,m = map(int,input().split())
for i in range(n):
    a,b = map(int,input().split())
    job.append((a,b))
    job.sort(reverse = True)
for i in range(n):
    a,b = job[i]
    salary.append(b)
    if a + j > m :
        salary.remove(min(salary))
        continue
    j += 1
print(sum(salary))


Fixed submission:
import heapq
job = list()
salary = list()
n,m = map(int,input().split())

for i in range(n):
    a,b = map(int,input().split())
    job.append((a,b))

job.sort(reverse = True)

for x in job:
    s,t = x
    heapq.heappush(salary,t)
    if s - m > 0:
        heapq.heappop(salary)
    else:
        m -= 1

print(sum(salary))

Buggy python submission (verdict: Time Limit Exceeded):
job = list()
salary = list()
m_total = 0
count = 0
n,m = map(int,input().split())
for i in range(n):
    a,b = map(int,input().split())
    job.append((a,b))
job.sort()
job.reverse()
for i in range(n):
    a,b = job[i]
    salary.append(b)
    if a + i - count > m :
        count += 1
        salary.remove(min(salary))
k = n - count

print(sum(salary))


Fixed submission:
import heapq
job = list()
salary = list()
n,m = map(int,input().split())

for i in range(n):
    a,b = map(int,input().split())
    job.append((a,b))

job.sort(reverse = True)

for x in job:
    s,t = x
    heapq.heappush(salary,t)
    if s - m > 0:
        heapq.heappop(salary)
    else:
        m -= 1

print(sum(salary))

Buggy python submission (verdict: Time Limit Exceeded):
job = list()
day = list()
salary = list()
m_total = 0
count = 0
n,m = map(int,input().split())
for i in range(n):
    a,b = map(int,input().split())
    job.append((a,b))
job.sort()
job.reverse()
for i in range(n):
    a,b = job[i]
    day.append(a)
    salary.append(b)
    if a + i - count > m :
        count += 1
        salary.remove(min(salary))
k = n - count
for l in range(k):
    m_total += salary[l]
print(m_total)


Fixed submission:
import heapq
job = list()
salary = list()
n,m = map(int,input().split())

for i in range(n):
    a,b = map(int,input().split())
    job.append((a,b))

job.sort(reverse = True)

for x in job:
    s,t = x
    heapq.heappush(salary,t)
    if s - m > 0:
        heapq.heappop(salary)
    else:
        m -= 1

print(sum(salary))