TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: There are N one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the day you do it.  You can take and complete at most one of these jobs in a day.  However, you cannot retake a job that you have already done.  Find the maximum total reward that you can earn no later than M days from today.  You can already start working today.

Submission attempts (in order):

import numpy as np

N, M = map(int, input().split())

pairs = []
for i in range(N):
    pairs.append(list(map(int, input().split())))

pairs = sorted(pairs, key=lambda elm: -elm[1])


finish_day = -1
out = 0

#not_done = [True for _ in range(M)]

counts = [0 for _ in range(M)]
cumsum_counts = np.zeros(0, dtype=int)

all_sum = 0

ue_end_i = M-1
for A, B in pairs:
    if A > M:
        continue
    ue_start_i = M-A+1
    if ue_start_i <= ue_end_i:
        ue_limit = ue_end_i - ue_start_i + 1
        
        ue_sum = cumsum(ue_start_i)
        hamidashi = max(ue_sum - ue_limit, 0)
    else:
        # ue_start_i == M
        ue_sum = 0
        hamidashi = 0
    

    cur_limit = M- A + 1 - hamidashi # 0 ~ M-A
    sudeni = all_sum - ue_sum
    aki = cur_limit - sudeni

    if aki >= 1:
        out += B
        #counts[M-A] += 1
        cumsum_counts[M-A:] += 1
        all_sum += 1

print(out)


#import numpy as np

from heapq import heappush, heappop

N, M = map(int, input().split())

values = [[] for i in range(M+1)]
for i in range(N):
    A, B = map(int, input().split())
    if M >= A:
        values[A].append(-B)

#print(values)
out = 0
elms = []
for i in range(1, M+1):
    #print("values[i]", values[i])
    for elm in values[i]:
        heappush(elms, elm)
        
    if len(elms) >= 1:
        max_val = - heappop(elms)
        #print("mval", max_val)
        out += max_val

print(out)

Verdicts: Runtime Error

Accepted
Problem: There are N one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the day you do it.  You can take and complete at most one of these jobs in a day.  However, you cannot retake a job that you have already done.  Find the maximum total reward that you can earn no later than M days from today.  You can already start working today.

Submission attempts (in order):
from heapq import *
from collections import defaultdict

N, M = map(int, input().split())
arbeits = defaultdict(list)
for _ in range(N):
    a, b = map(int, input().split())
    arbeits[a].append(b)
heap = []
ans = 0
for i in range(1, M+1):
    for b in arbeits[i]:
        heappush(heap, -b)
    ans += - heappop(heap)
print(ans)

from heapq import *
from collections import defaultdict

N, M = map(int, input().split())
arbeits = defaultdict(list)
for _ in range(N):
    a, b = map(int, input().split())
    arbeits[a].append(b)
heap = []
ans = 0
for i in range(1, M+1):
    for b in arbeits[i]:
        heappush(heap, -b)
    if heap:
        ans += - heappop(heap)
print(ans)

Verdicts: Runtime Error

Accepted
Problem: There are N one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the day you do it.  You can take and complete at most one of these jobs in a day.  However, you cannot retake a job that you have already done.  Find the maximum total reward that you can earn no later than M days from today.  You can already start working today.

Submission attempts (in order):
N, M = map(int,input().split())
A_B = [list(map(int, input().split())) for i in range(N)]

day = 0
ans = 0
A_B = sorted(A_B, key=lambda x:(-x[1], -x[0]))
print(A_B)
for i in range(N):
  print(day)
  if day + A_B[i][0] <= M:
    print("a")
    ans += A_B[i][1]
  day += 1
print(ans)

N, M = map(int,input().split())
A_B = [list(map(int, input().split())) for i in range(N)]


jobs = {m: [] for m in range(1, M + 1)}
for ab in A_B:
  if a in jobs:
    jobs[ab[0]].append(ab[1])
#print(jobs)


import heapq
q = []
ans = 0

for m in range(1, M + 1):
    for b in jobs[m]:
      
      heapq.heappush(q, -b)
    #print(q)
    
    if len(q) > 0:
      
      neg_b = heapq.heappop(q)
      ans += -neg_b

print(ans)

N, M = map(int,input().split())
A_B = [list(map(int, input().split())) for i in range(N)]


jobs = {m: [] for m in range(1, M + 1)}
for ab in A_B:
  if ab[0] in jobs:
    jobs[ab[0]].append(ab[1])
#print(jobs)


import heapq
q = []
ans = 0

for m in range(1, M + 1):
    for b in jobs[m]:
      
      heapq.heappush(q, -b)
    #print(q)
    
    if len(q) > 0:
      
      neg_b = heapq.heappop(q)
      ans += -neg_b

print(ans)

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: There are N one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the day you do it.  You can take and complete at most one of these jobs in a day.  However, you cannot retake a job that you have already done.  Find the maximum total reward that you can earn no later than M days from today.  You can already start working today.

Submission attempts (in order):
n,m = map(int,input().split())
l = [list(map(int,input().split())) for _ in [0]*n]
l.sort(key=lambda x:x[0])
ans = 0
tmpl = []
d = 1
flag = True

while d<=m:
  while  len(l)>=1 and l[0][0] <= d:
    tmpl.append(l[0][1])
    del l[0]
  if len(tmpl) == 0:
    d+=1
    break
  print('day',d)
  maxindex = tmpl.index(max(tmpl))
  ans += tmpl[maxindex]
  del tmpl[maxindex]
  d+= 1
print(ans)


n,m = map(int,input().split())
l = [list(map(int,input().split())) for _ in [0]*n]
l.sort(key=lambda x:x[1])
ans = 0
tmpl = []
d = 1
flag = True

while len(l)>=1 and d<=m:
  while l[0][0] <= d and len(l)>=1:
    tmpl.append(l[0][i])
    del l[0]
  maxindex = tmpl.index(max(tmpl))
  ans += tmpl[maxindex]
  del tmpl[maxindex]
print(tmp)

from heapq import heappush,heappop
n,m = map(int,input().split())
l = [list(map(int,input().split())) for _ in [0]*n]
l.sort(key=lambda x:x[0])
ans = 0
tmpl = []
i = 0
for d in range(1,m+1):
  while i<=n-1 and l[i][0] <= d:
    #tmpl.append(l[i][1])
    heappush(tmpl,-l[i][1])
    i += 1
  if len(tmpl) > 0:
    #maxindex = tmpl.index(max(tmpl))
    
    
    ans -= heappop(tmpl)
print(ans)


Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: There are N one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the day you do it.  You can take and complete at most one of these jobs in a day.  However, you cannot retake a job that you have already done.  Find the maximum total reward that you can earn no later than M days from today.  You can already start working today.

Submission attempts (in order):
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]

AB.sort()
B = [[] for _ in range(M + 2)]
i = 1
j = 0
while i <= M:
  while j < N or AB[j][0] <= i:
    B[i].append(AB[j][1])
    j += 1
  B[i] = B[i - 1].copy()
  i += 1

ans = 0
for i in range(1, M + 1):
  if len(B[i]) > 0:
    m = max(B[i])
    ans += m
    for j in range(i, M + 1):
      if len(B[j]) > 0:
        B[j].remove(m)

print(ans)

from heapq import heappush, heappop

N, M = map(int, input().split())
jobs = [[] for _ in range(M)]

for i in range(N):
  ab = list(map(int, input().split()))
  
  if ab[0] <= M:
    jobs[ab[0] - 1].append(ab[1])



hq = []
ans = 0
for i in range(M):
  for b in jobs[i]:
    heappush(hq, -1 * b)
  if len(hq) > 0:
    m = -1 * heappop(hq)
    ans += m

print(ans)

Verdicts: Runtime Error

Accepted
Problem: There are N one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the day you do it.  You can take and complete at most one of these jobs in a day.  However, you cannot retake a job that you have already done.  Find the maximum total reward that you can earn no later than M days from today.  You can already start working today.

Submission attempts (in order):

N, M = map(int, input().split())

Data = [list(map(int, input().split())) for _ in range(N)]

ans = 0
for i in range(1, M+1):
    temp = 0
    index = -1
    for j in range(len(Data)):
        if (Data[j][0] <= i) and (temp < Data[j][1]):
            temp = Data[j][1]
            index = j
    if index != -1:
        print(index)
        ans += temp
        Data[index][1] = -1
print(ans)


from heapq import heappush, heappop
N, M = map(int, input().split())

Data = [list(map(int, input().split())) for _ in range(N)]
Data.sort(reverse = True)

heap = [0] * M
ans = 0
for i in range(1, M+1):
    N = len(Data)
    for j in range(N-1, -1, -1):
        if Data[j][0] > i:
            break
        if (Data[j][0] <= i):
            heappush(heap, -(Data.pop(j)[1]))

    ans += -(heappop(heap))

print(ans)


Verdicts: Wrong Answer

Accepted
Problem: There are N one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the day you do it.  You can take and complete at most one of these jobs in a day.  However, you cannot retake a job that you have already done.  Find the maximum total reward that you can earn no later than M days from today.  You can already start working today.

Submission attempts (in order):
n,m=map(int,input().split())
l=[]
for i in range(n):
  a,b=map(int,input().split())
  if a<=m:
    l.append([a,b])
n=len(l)
l.sort()
p=0
t=l[0][0]
for i in range(n):
  if l[i][0]!=t:
    p+=l[i-1][1]
    t=l[i][0]
print(p)

import heapq as h
n,m=map(int, input().split())
a=[list(map(int, input().split())) for _ in range(n)]
a.sort(key=lambda x:x[0])
hq=[]
x=0;d=0
for i in range(1,m+1):
  while d<n and a[d][0]<=i:
    h.heappush(hq,-a[d][1])
    d+=1
  if len(hq):
    x+=-h.heappop(hq)
print(x)

Verdicts: Runtime Error

Accepted
Problem: There are N one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the day you do it.  You can take and complete at most one of these jobs in a day.  However, you cannot retake a job that you have already done.  Find the maximum total reward that you can earn no later than M days from today.  You can already start working today.

Submission attempts (in order):
import heapq
N,M = map(int,input().split())
AB = []
for i in range(N):
    a,b = list(map(int,input().split()))
    AB.append([-b,a])
work = [0 for i in range(M)]
for i in range(1,M+1):
    AB2 = list(filter(lambda x:x[1]<=i+1,AB))
    heapq.heapify(AB2)
    if not AB2:
        continue
    b,a = heapq.heappop(AB2)
    work[i-1] = -b
    AB.remove([b,a])
print(sum(work))

from heapq import heapify, heappush, heappop
N,M = map(int,input().split())
AB = [[] for i in range(M+1)]
for i in range(N):
    a,b = map(int,input().split())
    if a <= M:
        AB[a].append(-b)
AB2 = []
work = 0
heapify(AB2)
for i in range(1,M+1):
    for j in AB[i]:
        heappush(AB2,j)
    if len(AB2):
        b = heappop(AB2)
        work -= b
print(work)

Verdicts: Wrong Answer

Accepted
Problem: There are N one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the day you do it.  You can take and complete at most one of these jobs in a day.  However, you cannot retake a job that you have already done.  Find the maximum total reward that you can earn no later than M days from today.  You can already start working today.

Submission attempts (in order):
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)

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)

Verdicts: Runtime Error

Accepted
Problem: There are N one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the day you do it.  You can take and complete at most one of these jobs in a day.  However, you cannot retake a job that you have already done.  Find the maximum total reward that you can earn no later than M days from today.  You can already start working today.

Submission attempts (in order):
import heapq

N, M = map(int, input().split())
l = [0 for i in range(N)]

for i in range(N):
    A, B = map(int, input().split())
    l[i] = [A,-B]
l.sort()

tmp = []
ans = 0

for i in range(1, M + 1):
    while l[i][0] <= i:
        heapq.heappush(tmp, l[i])
    ans -= heapq.heappop(tmp)[1]
print(ans)

import heapq

N, M = map(int, input().split())
l = [0 for i in range(N)]

for i in range(N):
    A, B = map(int, input().split())
    l[i] = [A,-B]
l.sort()

tmp = []
ans = 0
j = 0

for i in range(1, M + 1):
    while j < N:
        A, B = l[j][0], -l[j][1]
        memo = [-B, A]
        if A <= i:
            heapq.heappush(tmp, memo)
            j += 1
        else:
            break
    if len(tmp) > 0:
        ans -= heapq.heappop(tmp)[0]
print(ans)

Verdicts: Runtime Error

Accepted
Problem: There are N one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the day you do it.  You can take and complete at most one of these jobs in a day.  However, you cannot retake a job that you have already done.  Find the maximum total reward that you can earn no later than M days from today.  You can already start working today.

Submission attempts (in order):
import heapq
def main(n,m,c):
    cost_map = dict([(i, [])for i in range(1,m+1)])
    print(cost_map)
    for a, b in c:
        if a <= m:
            cost_map[a].append(b)
        
    hp =[]
    ret = 0
    for i in range(1, m+1):
        costs = cost_map[i]
        [heapq.heappush(hp, -c) for c in costs]
        if(len(hp) > 0):
            c = heapq.heappop(hp)
            ret -= c
    return ret
if __name__ == "__main__":
    n,m = map(lambda x: int(x), input().strip().split())
    c = [ list(map(lambda x: int(x), input().strip().split())) for i in range(n)]
    print(main(n,m,c))

import heapq
def main(n,m,c):
    cost_map = dict([(i, [])for i in range(1,n+1)])
    for a, b in c:
        if a <= m:
            cost_map[a].append(b)
        
    hp =[]
    ret = 0
    for i in range(1, m+1):
        costs = cost_map[i]
        [heapq.heappush(hp, -c) for c in costs]
        if(len(hp) > 0):
            c = heapq.heappop(hp)
            ret -= c
    return ret
if __name__ == "__main__":
    n,m = map(lambda x: int(x), input().strip().split())
    c = [ list(map(lambda x: int(x), input().strip().split())) for i in range(n)]
    print(main(n,m,c))

import heapq
def main(n,m,c):
    cost_map = dict([(i, [])for i in range(1,m+1)])
    for a, b in c:
        if a <= m:
            cost_map[a].append(b)
        
    hp =[]
    ret = 0
    for i in range(1, m+1):
        costs = cost_map[i]
        [heapq.heappush(hp, -c) for c in costs]
        if(len(hp) > 0):
            c = heapq.heappop(hp)
            ret -= c
    return ret
if __name__ == "__main__":
    n,m = map(lambda x: int(x), input().strip().split())
    c = [ list(map(lambda x: int(x), input().strip().split())) for i in range(n)]
    print(main(n,m,c))

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: There are N one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the day you do it.  You can take and complete at most one of these jobs in a day.  However, you cannot retake a job that you have already done.  Find the maximum total reward that you can earn no later than M days from today.  You can already start working today.

Submission attempts (in order):
import heapq
N, M = map(int, input().split())
X = sorted([list(map(int, input().split())) for _ in range(N)], key = lambda x: x[0])

hq = []
ans, j = 0, 0

for i in range(1, M + 1): 
    while (j < N) and (X[j][0] <= i):
        heappush(hq, -X[j][1]) 
        j += 1
    if len(hq):
        ans += -heappop(hq)

print(ans)

import heapq
N,M=map(int, input().split())
X=sorted([list(map(int, input().split())) for _ in range(N)], key=lambda x:x[0])

a=[]
ans, j = 0, 0

for i in range(1, M + 1):
  
  while (j < N) and (X[j][0] <= i):
    
    heapq.heappush(a, -X[j][1])  
    j += 1
  if len(a):
    ans += -heapq.heappop(a)  
    
print(ans)

Verdicts: Runtime Error

Accepted
Problem: There are N one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the day you do it.  You can take and complete at most one of these jobs in a day.  However, you cannot retake a job that you have already done.  Find the maximum total reward that you can earn no later than M days from today.  You can already start working today.

Submission attempts (in order):
N_baito,M_days = map(int,input().split())
baitoList = np.array([list(map(int,input().split())) for i in range(N_baito)])
workList = []
hosyu = 0
for day in range(M_days+1):
    workList.extend(baitoList[baitoList[:,0]==day][:,1].tolist())
    workList.sort(reverse=True)
    if workList:
        hosyu += workList[0]
        del workList[0]
print(hosyu)


import heapq
N_baito,M_days = map(int,input().split())
hosyuList = [[] for _ in range(M_days)]

for _ in range(N_baito):
    days,hosyu = map(int,input().split())
    if days <= M_days:
        hosyuList[days-1].append(hosyu)

workList = []
hosyu = 0
for day in range(M_days):
    for baito in hosyuList[day]:
        heapq.heappush(workList,-1*baito)
    if workList:
        hosyu += heapq.heappop(workList)
print(-1*hosyu)


Verdicts: Runtime Error

Accepted
Problem: There are N one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the day you do it.  You can take and complete at most one of these jobs in a day.  However, you cannot retake a job that you have already done.  Find the maximum total reward that you can earn no later than M days from today.  You can already start working today.

Submission attempts (in order):
Copy
# -*- coding: utf-8 -*-
 
 
def main():
    
    from heapq import heappush, heappop
 
    n, m = map(int, input().split())
    jobs = [[] for _ in range(m)]  
 
    # See:
    # https://www.youtube.com/watch?v=1Z6ofKN03_Y
    for i in range(n):
        ai, bi = map(int, input().split())
 
        
        if ai > m:
            continue
 
        
        
        deadline = m - ai
        jobs[deadline].append(-bi)
 
    ans = 0
    reward = []
 
    
    
    
    for i in range(m - 1, -1, -1):
        for job in jobs[i]:
            
            heappush(reward, job)
 
        
        if reward:
            ans += heappop(reward)
 
    
    print(-ans)
 
 
if __name__ == '__main__':
    main()

def main():
    
    from heapq import heappush, heappop
 
    n, m = map(int, input().split())
    jobs = [[] for _ in range(m)]  
 
    # See:
    # https://www.youtube.com/watch?v=1Z6ofKN03_Y
    for i in range(n):
        ai, bi = map(int, input().split())
 
        
        if ai > m:
            continue
 
        
        
        deadline = m - ai
        jobs[deadline].append(-bi)
 
    ans = 0
    reward = []
 
    
    
    
    for i in range(m - 1, -1, -1):
        for job in jobs[i]:
            
            heappush(reward, job)
 
        
        if reward:
            ans += heappop(reward)
 
    
    print(-ans)
 
 
if __name__ == '__main__':
    main()

Verdicts: Runtime Error

Accepted
Problem: There are N one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the day you do it.  You can take and complete at most one of these jobs in a day.  However, you cannot retake a job that you have already done.  Find the maximum total reward that you can earn no later than M days from today.  You can already start working today.

Submission attempts (in order):
import heapq

n,m = map(int,input().split())

a = [[] for i in range(100000)]
d = []
heapq.heapify(d)

for _ in range(n):
    b,c = map(int,input().split())
    a[b-1].append(-1 * c)

#print(a)

ans = 0
for i in range(m):
    for j in range(len(a[i])):
        heapq.heappush(d,a[i][j])
    if d == []:
        break
    ans -= heapq.heappop(d)

print(ans)

import heapq

n,m = map(int,input().split())

a = [[] for i in range(m)]
d = []
heapq.heapify(d)

for _ in range(n):
    b,c = map(int,input().split())
    a[b-1].append(-1 * c)

#print(a)

ans = 0
for i in range(m):
    for j in range(len(a[i])):
        heapq.heappush(d,a[i][j])
    ans -= heapq.heappop(d)

print(ans)

import heapq

n,m = map(int,input().split())

a = [[] for i in range(100000)]
d = []
heapq.heapify(d)

for _ in range(n):
    b,c = map(int,input().split())
    a[b-1].append(-1 * c)

#print(a)

ans = 0
for i in range(m):
    for j in range(len(a[i])):
        heapq.heappush(d,a[i][j])
    if d != []:
        ans -= heapq.heappop(d)

print(ans)

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: There are N one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the day you do it.  You can take and complete at most one of these jobs in a day.  However, you cannot retake a job that you have already done.  Find the maximum total reward that you can earn no later than M days from today.  You can already start working today.

Submission attempts (in order):
from heapq import heappush, heappop

def solve():
    N, M = map(int , input().split())
    arbeit_A_B = list(list(map(int , input().split())) for _ in range(N))
    arbeit_A_B = sorted(arbeit_A_B, key=lambda x: (x[0], -x[1]))
    
    day = 1
    result = 0
    index_arbeit = 0
    heap_q = []
    while day <= M:
        while index_arbeit < N:
            A,B = arbeit_A_B[index_arbeit]
            if A <= day:
                heappush(heap_q, (-1)*B)
            else: break
            index_arbeit += 1
            
        result -= heappop(heap_q)
        day += 1
            
    print(result)
    
solve()

from heapq import heappush, heappop

def solve():
    N, M = map(int , input().split())
    arbeit_A_B = list(list(map(int , input().split())) for _ in range(N))
    arbeit_A_B = sorted(arbeit_A_B, key=lambda x: (x[0], -x[1]))
    
    day = 1
    result = 0
    index_arbeit = 0
    heap_q = []
    while day <= M:
        while index_arbeit < N:
            A,B = arbeit_A_B[index_arbeit]
            if A <= day:
                heappush(heap_q, (-1)*B)
            else: break
            index_arbeit += 1
            
        result -= heappop(heap_q)
        day += 1
            
    print(result)

from heapq import heappush, heappop

def solve():
    N, M = map(int , input().split())
    arbeit_A_B = list(list(map(int , input().split())) for _ in range(N))
    arbeit_A_B = sorted(arbeit_A_B, key=lambda x: (x[0], -x[1]))
    
    day = 1
    result = 0
    index_arbeit = 0
    heap_q = []
    while day <= M:
        while index_arbeit < N:
            A,B = arbeit_A_B[index_arbeit]
            if A <= day:
                heappush(heap_q, (-1)*B)
            else: break
            index_arbeit += 1
            
        if heap_q:
            result -= heappop(heap_q)
        day += 1
            
    print(result)
    
solve()

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: There are N one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the day you do it.  You can take and complete at most one of these jobs in a day.  However, you cannot retake a job that you have already done.  Find the maximum total reward that you can earn no later than M days from today.  You can already start working today.

Submission attempts (in order):
n, m = map(int, input().split())
r = [list(map(int, input().split())) for i in range(n)]
r.sort(key=lambda x: x[1], reverse=True)
rev = 0
print(r)
#day j
for j in range(m):
    if len(r) == 0:
        break
    for i in r:
        if i[0] <= m-j:
            rev += i[1]
            r.remove(i)
            break
        else:
            r.remove(i)
print(rev)

n, m = map(int, input().split())
r = [list(map(int, input().split())) for i in range(n)]
r.sort(key=lambda x: x[1], reverse=True)
rev = 0
print(r)
#day j
for j in range(m):
    for i in r:
        if i[0] <= m-j:
            rev += i[1]
            r.remove(i)
            break
        else:
            r.remove(i)
print(rev)

import heapq
n, m = map(int, input().split())
byte = [[] for _ in range(m+2)]

for _ in range(n):
    a, b = map(int, input().split())
    if a > m+1:
        continue
    byte[a].append(b)
search = []
day = 1
ans = 0
while day-1 != m:
    for b in byte[day]:
        heapq.heappush(search, -b)
    if not search:
        day += 1
        continue
    tmp = -heapq.heappop(search)
    ans += tmp
    day += 1

print(ans)





Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: There are N one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the day you do it.  You can take and complete at most one of these jobs in a day.  However, you cannot retake a job that you have already done.  Find the maximum total reward that you can earn no later than M days from today.  You can already start working today.

Submission attempts (in order):
N,M = list(map(int, input().split()))
X = [list(map(int, input().split())) for i in range(N)]

l = M
result = 0
while l > 0:
    index_lis = [i for i, v in enumerate(X) if v[1] == max(X, key=lambda xx: xx[1])[1]]
    if len(index_lis) >= 2:
        a = max(X, key=lambda xx: xx[index_lis][0])
    else:
        a = X[index_lis[0]]
    if a[0] > l:
        X.remove(a)
    elif a[0] <= l:
        result += a[1]
        l -= 1
        X.remove(a)
print(result)

import sys
import heapq
 
N, M = list(map(int, input().split()))
jobs = []


for line in sys.stdin:
    A, B = map(int, line.split())
    if A > M:
        continue
    jobs.append((A, B))


jobs.sort(reverse=True)


q = []
ans = 0

for i in range(1, M + 1):
    
    while jobs and jobs[-1][0] <= i:
        A, B = jobs.pop()
        heapq.heappush(q, -B)
 
    if q:
        
        ans += -heapq.heappop(q)
print(ans)

Verdicts: Runtime Error

Accepted
Problem: There are N one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the day you do it.  You can take and complete at most one of these jobs in a day.  However, you cannot retake a job that you have already done.  Find the maximum total reward that you can earn no later than M days from today.  You can already start working today.

Submission attempts (in order):
from collections import defaultdict
import heapq
n,m=map(int,input().split())
dic=defaultdict(list)
for i in range(n):
    a,b=map(int,input().split())
    dic[a]+=[-b]
    
li=[]
ans=0
print(dic)
for i in range(1,m+1):
    if dic[i]:
        for j in dic[i]:
            heapq.heappush(li,j)
    if li:
        ans+=heapq.heappop(li)
print(-ans)

from collections import defaultdict
import heapq
n,m=map(int,input().split())
dic=defaultdict(list)
for i in range(n):
    a,b=map(int,input().split())
    dic[a]+=(-b)
    
li=[]
ans=0

for i in range(1,m+1):
    if dic[i]:
        for j in dic[i]:
            heapq.heappush(li,j)
    if li:
        ans+=heapq.heappop(li)
print(-ans)

from collections import defaultdict
import heapq

n,m=map(int,input().split())
ab=[[int(i) for i in input().split()] for j in range(n)]

dic=defaultdict(list)
for a,b in ab:
    dic[a]+=[-b]

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

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: There are N one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the day you do it.  You can take and complete at most one of these jobs in a day.  However, you cannot retake a job that you have already done.  Find the maximum total reward that you can earn no later than M days from today.  You can already start working today.

Submission attempts (in order):
import copy
n, m = map(int, input().split())
ab_lis = []
for i in range(n):
    ab_lis.append(list(map(int, input().split())))
def rec(ab_lis, path, rew, r_day, m_ans):
    if r_day == 0:
        m_ans[0] = max(m_ans[0], rew)
        return
    for t_lis in ab_lis:
        if t_lis in path:
            continue
        elif t_lis[0] > r_day:
            m_ans[0] = max(m_ans[0], rew)
            continue
        path_c = copy.copy(path)
        path_c.append(t_lis)
        rec(ab_lis, path_c, rew + t_lis[1], r_day - 1, ans)    
m_ans = [0]
rec(ab_lis, [], 0, m, m_ans)        
print(m_ans[0])

import collections
import heapq
n, m = map(int, input().split())
c = collections.defaultdict(list)
for i in range(n):
    a, b = map(int, input().split())
    if a > m:
        continue
    c[m - a].append(b)
h = []
heapq.heapify(h)    
ans = 0
for i in range(m - 1, -1, -1):
    for b in c[i]:
        heapq.heappush(h, -b)
    if len(h) >0:
        ans += -1 * heapq.heappop(h)
print(ans)        

Verdicts: Runtime Error

Accepted
Problem: There are N one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the day you do it.  You can take and complete at most one of these jobs in a day.  However, you cannot retake a job that you have already done.  Find the maximum total reward that you can earn no later than M days from today.  You can already start working today.

Submission attempts (in order):
import sys
from heapq import heappush, heappop

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M = lr()
works = [[] for _ in range(M+1)]

for _ in range(N):
    a, b = lr()
    works[a].append(b)

cand = []
answer = 0
for i in range(1, M+1):
    for work in works[i]:
        heappush(cand, -work)
    answer -= heappop(cand)

print(answer)


import sys
from heapq import heapify, heappop, heappush

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M = lr()
jobs = [[] for _ in range(M+1)]
for _ in range(N):
    a, b = lr()
    if a > M:
        continue
    jobs[a].append(b)

answer = 0
candidate = []
for i in range(1, M+1):
    for job in jobs[i]:
        heappush(candidate, -job)
    if candidate:
        answer += heappop(candidate)

answer *= -1
print(answer)
# 31

Verdicts: Runtime Error

Accepted
Problem: There are N one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the day you do it.  You can take and complete at most one of these jobs in a day.  However, you cannot retake a job that you have already done.  Find the maximum total reward that you can earn no later than M days from today.  You can already start working today.

Submission attempts (in order):

def input2():
	return map(int,input().split())

n,m=input2()
AB=[[] for _ in range(m)]


for i in range(n):
	a,b=input2()
	if a-1 < m: 
		AB[a-1].append(-b) 

ans=0
heap=[]
for i in range(m):
	for b in AB[i]:
		heapq.heappush(heap,b)
	
	if len(heap)>0:
		MAX=heapq.heappop(heap)
		ans+= -MAX
print(ans)

from math import factorial as fact
import math
import sys
from itertools import product
import numpy as np
from collections import Counter
import datetime
from collections import deque
from bisect import bisect_left, bisect_right
import heapq




def input1():
	return int(input())


def input2():
	return map(int,input().split())


def input_array():
	return list(map(int,input().split()))


n,m=input2()
AB=[[] for _ in range(m)]


for i in range(n):
	a,b=input2()
	if a-1 < m: 
		AB[a-1].append(-b) 

ans=0
heap=[]
for i in range(m):
	for b in AB[i]:
		heapq.heappush(heap,b)
	
	if len(heap)>0:
		MAX=heapq.heappop(heap)
		ans+= -MAX
print(ans)












Verdicts: Runtime Error

Accepted
Problem: There are N one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the day you do it.  You can take and complete at most one of these jobs in a day.  However, you cannot retake a job that you have already done.  Find the maximum total reward that you can earn no later than M days from today.  You can already start working today.

Submission attempts (in order):
import heapq
n,m=map(int,input().split())
ab=[[] for _ in range(m+1)]
for i in range(n):
  a,b=map(int,input().split())
  if a<=m:
    a[i].append(-b)

cand=[]
heapq.heapify(cand)
ans=0
for i in range(1,m+1):
  for j in range(len(ab[i])):
    heapq.heappush(cand,ab[i][j])
  if len(cand)>0:
    ans-=heapq.heappop(cand)

print(ans)

import heapq
n,m=map(int,input().split())
ab=[[] for _ in range(m+1)]
for i in range(n):
  a,b=map(int,input().split())
  if a<=m:
    ab[a].append(-b)

cand=[]
heapq.heapify(cand)
ans=0
for i in range(1,m+1):
  for j in range(len(ab[i])):
    heapq.heappush(cand,ab[i][j])
  if len(cand)>0:
    ans-=heapq.heappop(cand)

print(ans)

Verdicts: Runtime Error

Accepted
Problem: There are N one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the day you do it.  You can take and complete at most one of these jobs in a day.  However, you cannot retake a job that you have already done.  Find the maximum total reward that you can earn no later than M days from today.  You can already start working today.

Submission attempts (in order):
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")


dp = [0 for _ in range(100000)]

def main():
    N, M = map(int, input().split())
    A_B = [list(map(int, input().split()))[::-1] for _ in range(N)]
    logging.info("Hello!")

    sorted_A_B = sorted(A_B, reverse=True)
    logging.info(sorted_A_B)


    total = 0
    for i in range(M):
        if sorted_A_B[i][1] + i <= M:
            total += sorted_A_B[i][0]


    print(total)
    
if __name__ == "__main__":
    main()


import logging
import heapq

logging.basicConfig(level=logging.INFO, format="%(message)s")



def main():
    N, M = map(int, input().split())
    A_B = [list(map(int, input().split())) for _ in range(N)]
    logging.info("Hello!")

    A_B.sort()
    logging.info(A_B)


    heap_Q = []
    curr = 0
    total = 0
    for i in range(1, M + 1):
        while curr < N and  A_B[curr][0] <= i:
            heapq.heappush(heap_Q, A_B[curr][1] * (-1))
            curr += 1

        if heap_Q:
            total += (-1) * heapq.heappop(heap_Q)

    print(total)
    
if __name__ == "__main__":
    main()


Verdicts: Runtime Error

Accepted
Problem: There are N one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the day you do it.  You can take and complete at most one of these jobs in a day.  However, you cannot retake a job that you have already done.  Find the maximum total reward that you can earn no later than M days from today.  You can already start working today.

Submission attempts (in order):
import heapq
import numpy as np

N, M = [int(a) for a in input().split()]

jobs = [[] for _ in range(M)]
print(jobs)

for _ in range(N):
    a, b = map(lambda x: int(x), input().split())
    print(a, b, M-a)
    if a > M:
      continue
    jobs[M-a].append(b)

heap = []
ans = 0
for i in range(M-1, -1, -1):
    for b in jobs[i]:
        
        heapq.heappush(heap, -b)
    if len(heap) != 0:
        
        ans += -heapq.heappop(heap)
print(ans)

import heapq
import numpy as np

N, M = [int(a) for a in input().split()]

jobs = [[] for _ in range(M)]

for _ in range(N):
    a, b = map(lambda x: int(x), input().split())
    if a > M:
      continue
    jobs[M-a].append(b)

heap = []
ans = 0
for i in range(M-1, -1, -1):
    for b in jobs[i]:
        
        heapq.heappush(heap, -b)
    if len(heap) != 0:
        
        ans += -heapq.heappop(heap)
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: There are N one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the day you do it.  You can take and complete at most one of these jobs in a day.  However, you cannot retake a job that you have already done.  Find the maximum total reward that you can earn no later than M days from today.  You can already start working today.

Submission attempts (in order):
from heapq import heappush,heappop

N,M = (int(i) for i in input().split())
C=[0]*N
T = []

for i in range(N):
    C[i] = [int(j) for j in input().split()]

C.sort()
print(C)
k = 0
ans = 0
for j in range(1,M+1):
    for i in range(k,N):
        if C[i][0] > j:
            k = i
            break
        else:
            heappush(T,-1*C[i][1])
    if T != []:
        ans += -1 * heappop(T)

print(ans)


from heapq import heappush,heappop

N,M = (int(i) for i in input().split())
a = [0] *N
b = [0] *N
T = []
list = [[] for i in range(M+1)]

for i in range(N):
    a[i],b[i] = map(int,input().split())
    if a[i] <= M:
        list[a[i]].append(b[i])

k = 0
ans = 0
for j in range(1,M+1):
    for i in list[j]:
        heappush(T,-1 * i)
    if T != []:
        ans += -1 * heappop(T)

print(ans)


Verdicts: Wrong Answer

Accepted
Problem: There are N one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the day you do it.  You can take and complete at most one of these jobs in a day.  However, you cannot retake a job that you have already done.  Find the maximum total reward that you can earn no later than M days from today.  You can already start working today.

Submission attempts (in order):
import heapq
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]

AB = sorted(AB, key=lambda x: x[0])

x = 0
res = 0

hq = []
heapq.heapify(hq)

for i in range(M):
    for j in range(x, N):
        if AB[j][0] > i+1:
            x = j
            break
        heapq.heappush(hq, AB[j][1]*-1)
    else:
        x = N
    
    print(hq)
    if hq:
        res += heapq.heappop(hq)*-1

print(res)


import heapq
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]

AB = sorted(AB, key=lambda x: x[0])

x = 0
res = 0

hq = []
heapq.heapify(hq)

for i in range(M):
    for j in range(x, N):
        if AB[j][0] > i+1:
            x = j
            break
        heapq.heappush(hq, AB[j][1]*-1)
    else:
        x = N
    
    if hq:
        res += heapq.heappop(hq)*-1

print(res)


Verdicts: Runtime Error

Accepted
Problem: There are N one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the day you do it.  You can take and complete at most one of these jobs in a day.  However, you cannot retake a job that you have already done.  Find the maximum total reward that you can earn no later than M days from today.  You can already start working today.

Submission attempts (in order):
N, M = map(int, input().split())

ab = []

for _ in range(N):
    ab.append(tuple(map(int, input().split())))


l = sorted(ab, key = lambda x: (x[1], x[0]))

ans = 0

print(';;;;;;;')

for i in range(1, N+1):
    
    while l:
        a, b = l.pop()
        print(a, b)
        
        if i + a-1 <= M:
            ans += b
            break
    
    if not l:
        break

print(ans)



import heapq
from collections import defaultdict

N, M = map(int, input().split())

jobs = []
cnts = defaultdict(int)
rets = []

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

    heapq.heappush(jobs, (a, -b))
    cnts[a] += 1


ans = 0
for i in range(1, M+1):

    cnt = cnts.get(i)

    if cnt:
        while cnt > 0:
            a, b = heapq.heappop(jobs)
            heapq.heappush(rets, b)
            cnt -= 1

    if rets:
        b = heapq.heappop(rets)
        ans -= b

print(ans)

Verdicts: Wrong Answer

Accepted
Problem: There are N one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the day you do it.  You can take and complete at most one of these jobs in a day.  However, you cannot retake a job that you have already done.  Find the maximum total reward that you can earn no later than M days from today.  You can already start working today.

Submission attempts (in order):
import  heapq

N, M = map(int, input().split())
data = [[int(x) for x in input().split()] for i in range(N)]
data.sort(reverse=True, key=lambda x: (-x[0], x[1]))

day = M
reward = 0


q = []
i = 0
for d in range(1, M + 1):
    print(d)
    for t in range(i, N):
        if data[t][0] > d:
            break
        i += 1
        heapq.heappush(q, -1 * data[t][1])
    if q:
        reward += heapq.heappop(q)

print(-1 * reward)





import  heapq

N, M = map(int, input().split())
data = [[int(x) for x in input().split()] for i in range(N)]

data.sort(reverse=True, key=lambda x: (-x[0], x[1]))

day = M
reward = 0


q = []
i = 0
for d in range(1, M + 1):
    for t in range(i, N):
        if data[t][0] > d:
            break
        i += 1
        heapq.heappush(q, -1 * data[t][1])
    reward += heapq.heappop(q)

print(-1 * reward)





import  heapq
 
N, M = map(int, input().split())
data = [[int(x) for x in input().split()] for i in range(N)]
data.sort(reverse=True, key=lambda x: (-x[0], x[1]))
 
day = M
reward = 0
 

q = []
i = 0
for d in range(1, M + 1):
    for t in range(i, N):
        if data[t][0] > d:
            break
        i += 1
        heapq.heappush(q, -1 * data[t][1])
    if q:
        reward += heapq.heappop(q)
 
print(-1 * reward)

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: There are N one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the day you do it.  You can take and complete at most one of these jobs in a day.  However, you cannot retake a job that you have already done.  Find the maximum total reward that you can earn no later than M days from today.  You can already start working today.

Submission attempts (in order):
N, M = map(int, input().split())
AB = [[] for _ in range(M + 10)]
ans = 0
for _ in range(N):
  a, b = map(int, input().split())
  if a > m:
    continue
  AB[a].append(b)
import heapq
reward = []
heapq.heapify(reward)
for i in range(1, M + 1):
  for item in AB[i]:
    heapq.heappush(reward, -item)
  if reward:
    ans -= heapq.heappop(reward)
print(ans)

N, M = map(int, input().split())
AB = [[] for _ in range(M + 10)]
ans = 0
for _ in range(N):
  a, b = map(int, input().split())
  if a > M:
    continue
  AB[a].append(b)
import heapq
reward = []
heapq.heapify(reward)
for i in range(1, M + 1):
  for item in AB[i]:
    heapq.heappush(reward, -item)
  if reward:
    ans -= heapq.heappop(reward)
print(ans)

Verdicts: Runtime Error

Accepted
Problem: There are N one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the day you do it.  You can take and complete at most one of these jobs in a day.  However, you cannot retake a job that you have already done.  Find the maximum total reward that you can earn no later than M days from today.  You can already start working today.

Submission attempts (in order):
from heapq import*
N,M,*t=map(int,open(0).read().split())
v=[[]for _ in'_'*M]
for i in range(N):
	if M<t[2*i]:v[t[2*i]-1]+=[t[2*i+1]]
z=0
q=[]
for i in v:
	for j in i:heappush(q,-j)
	z-=len(q)and heappop(q)
print(z)

from heapq import*
N,M,*t=map(int,open(0).read().split())
v=[[]for _ in'_'*M]
for i in range(N):M<t[2*i]or v[t[2*i]-1].append(t[2*i+1])
z=0
q=[]
for i in v:
	for j in i:heappush(q,-j)
	z-=q[0]and heappop(q)
print(z)

from heapq import*
(N,M),*t=[map(int,s.split())for s in open(0)]
q=[0]*M
v=[[]for _ in q]
z=0
for a,b in t:
	if a<=M:v[a-1]+=[b]
for i in v:
	for j in i:heappush(q,-j)
	z-=heappop(q)
print(z)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: There are N one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the day you do it.  You can take and complete at most one of these jobs in a day.  However, you cannot retake a job that you have already done.  Find the maximum total reward that you can earn no later than M days from today.  You can already start working today.

Submission attempts (in order):
n, m = map(int, input().split())
a_b = []
for i in range(n):
    a_b.append(list(map(int, input().split())))
a_b = sorted(a_b, key=lambda x:x[1], reverse=True)
ans = 0
for i in range(m):
    ans += a_b[i][1]
print(ans)

import heapq
n, m = map(int, input().split())
a_b = [[] for _ in range(m)]
for i in range(n):
    a, b = map(int, input().split())
    if a < m+1:
        a_b[a-1].append(-b)
h = []
heapq.heapify(h)
ans = 0
for i in range(m):
    for j in a_b[i]:
        heapq.heappush(h, j)
    if len(h) == 0:
        continue
    ans += heapq.heappop(h)*(-1)
print(ans)

Verdicts: Runtime Error

Accepted
Problem: There are N one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the day you do it.  You can take and complete at most one of these jobs in a day.  However, you cannot retake a job that you have already done.  Find the maximum total reward that you can earn no later than M days from today.  You can already start working today.

Submission attempts (in order):
n,m = map(int,input().split())
lst = [list(map(int,input().split())) for _ in range(n)]

lst.sort(key = lambda x:x[0],reverse = True)
lst.sort(key = lambda x:x[1],reverse = True)

done = [0 for _ in range(n)]
gain = 0

for i in reversed(range(1,m+1)): 
    for j in range(n): 
        if lst[j][0] <= i and done[j] == 0: 
            gain += lst[j][1]
            done[j] = 1　
            break 

print(gain)

import heapq
n,m = list(map(int,input().split()))
jobs = [[] for _ in range(m)]
for i in range(n):
    d,r = list(map(int,input().split()))
    if d-1 < m:
        jobs[d-1].append(-r)
rewords = 0
heap = []
for i in range(m):
    for reword in jobs[i]:
        heapq.heappush(heap,reword)
    if len(heap) > 0:
        reword = heapq.heappop(heap)
        rewords += -reword
print(rewords)

Verdicts: Runtime Error

Accepted
Problem: There are N one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the day you do it.  You can take and complete at most one of these jobs in a day.  However, you cannot retake a job that you have already done.  Find the maximum total reward that you can earn no later than M days from today.  You can already start working today.

Submission attempts (in order):
a,b = map(int,input().split())
jobs = []
while True:
    try:
        jobs.append(list(map(int,input().split())))
    except:
        break;
print(jobs)
score = 0
for i in range(b):
  max_now = 0
  deli = []
  for j in range(len(jobs)):
    job = jobs[j]
    if job[0] <= i + 1:
      if max_now < job[1]:
        max_now = job[1]
        deli = job
  score += max_now 
  if deli != []:
    jobs.remove(deli)
print(score)

import heapq

n ,m = map(int,input().split())
li = []
for i in range(n):
    x, y= map(int,input().split())
    li.append([x,y])
li.sort()
heap = []

ans = 0
j = 0
for i in range(1, m + 1):
    while j < n and li[j][0] <= i:
        heapq.heappush(heap,-li[j][1])
        j += 1
    if heap:
        ans += -heapq.heappop(heap)
 
print(ans)

Verdicts: Wrong Answer

Accepted