Language: C++

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
#include <map>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    long long n,m,result=0;
    cin>>n>>m;
    map<pair<long long int,long long int>,long long int> mp;
    long long int tmpa,tmpb,tmpc;
    
    REP(i,n){
        scanf("%lld %lld",&tmpa,&tmpb);
        mp[make_pair(tmpa,tmpb)]++;
    }
    map<long long int,priority_queue<pair<long long int,long long int>>> mp2;
    
    for(auto x:mp){
        mp2[x.first.first].push(x.first.second,x.second);
    }
    bool firstflag;
    FOR(i,1,m+1){

        firstflag=true;
        tmpa=0;
        tmpb=0;
        for(auto x:mp2){
            if(firstflag){
                tmpc=max(x.first,i);
                firstflag=false;
            }
            if(tmpb<x.second.top().first&&i>=x.first.first&&x.second.top().second>0){
                tmpa=x.first;
                tmpb=x.second.top().first;
            }else if(i<x.first){
                break;
            }
        }
        
        result+=tmpb;
        mp2[tmpa].top().second--;
        if(mp2[tmpa].top().second==0){
            mp2[tmpa].top().pop();

        }
        if(mp2[tmpa].size()==0){
            mp2.erase(tmpa);
        }
        i=tmpc;
    }


    cout<<result<<endl;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:35:23: error: 'priority_queue' was not declared in this scope
   35 |     map<long long int,priority_queue<pair<long long int,long long int>>> mp2;
      |                       ^~~~~~~~~~~~~~
a.cc:11:1: note: 'std::priority_queue' is defined in header '<queue>'; this is probably fixable by adding '#include <queue>'
   10 | #include <map>
  +++ |+#include <queue>
   11 | using namespace std;
a.cc:35:70: error: template argument 2 is invalid
   35 |     map<long long int,priority_queue<pair<long long int,long long int>>> mp2;
      |                                                                      ^~
a.cc:35:70: error: template argument 4 is invalid
a.cc:35:72: error: expected unqualified-id before '>' token
   35 |     map<long long int,priority_queue<pair<long long int,long long int>>> mp2;
      |                                                                        ^
a.cc:38:9: error: 'mp2' was not declared in this scope; did you mean 'mp'?
   38 |         mp2[x.first.first].push(x.first.second,x.second);
      |         ^~~
      |         mp
a.cc:46:20: error: 'mp2' was not declared in this scope; did you mean 'mp'?
   46 |         for(auto x:mp2){
      |                    ^~~
      |                    mp
a.cc:60:9: error: 'mp2' was not declared in this scope; did you mean 'mp'?
   60 |         mp2[tmpa].top().second--;
      |         ^~~
      |         mp