Language: C++

#include <bits/stdc++.h>

using namespace std;
#define sz(x) (int)(x).size()
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define ll long long

const int N=3e5+5;

ll ans;

int n;


bool operator()(const pair<int,int> &a,const pair<int,int> &b){
        if (a.second>b.second)
            return true;
        if(b.second>a.second)
           return false;
        return a.first<b.first;
    }

pair<int,int> a[N];

int main(){ 
    scanf("%d %d",&n,&m);
    priority_queue<pair<int,int>,vector<pair<int,int> >,cmp > curr;
    priority_queue<pair<int,int>,vector<pair<int,int> > > pq;
    for(int i=0;i<n;i++){
        scanf("%d %d",&a[i].first,&a[i].second);
        if (a[i].first<=m)
            pq.push(a[i]);
    }
    int last=m+1;
    while(!pq.empty()){
        pair<int,int> x=pq.top();
        pq.pop();
        if (x.first<last){
            curr.push(x);
            last--;
        }
        else{
            int y=curr.top().second;
            if (x.second>y){
                curr.pop(),curr.push(x);
            }
        }
    }
    while(!curr.empty()){
        ans+=curr.top().second;
        curr.pop();
    }
    printf("%lld\n",ans);
}

Compiler output:
a.cc:16:6: error: 'bool operator()(const std::pair<int, int>&, const std::pair<int, int>&)' must be a member function
   16 | bool operator()(const pair<int,int> &a,const pair<int,int> &b){
      |      ^~~~~~~~
a.cc: In function 'int main()':
a.cc:27:23: error: 'm' was not declared in this scope; did you mean 'tm'?
   27 |     scanf("%d %d",&n,&m);
      |                       ^
      |                       tm
a.cc:28:57: error: 'cmp' was not declared in this scope; did you mean 'bcmp'?
   28 |     priority_queue<pair<int,int>,vector<pair<int,int> >,cmp > curr;
      |                                                         ^~~
      |                                                         bcmp
a.cc:28:61: error: template argument 3 is invalid
   28 |     priority_queue<pair<int,int>,vector<pair<int,int> >,cmp > curr;
      |                                                             ^
a.cc:40:18: error: request for member 'push' in 'curr', which is of non-class type 'int'
   40 |             curr.push(x);
      |                  ^~~~
a.cc:44:24: error: request for member 'top' in 'curr', which is of non-class type 'int'
   44 |             int y=curr.top().second;
      |                        ^~~
a.cc:46:22: error: request for member 'pop' in 'curr', which is of non-class type 'int'
   46 |                 curr.pop(),curr.push(x);
      |                      ^~~
a.cc:46:33: error: request for member 'push' in 'curr', which is of non-class type 'int'
   46 |                 curr.pop(),curr.push(x);
      |                                 ^~~~
a.cc:50:17: error: request for member 'empty' in 'curr', which is of non-class type 'int'
   50 |     while(!curr.empty()){
      |                 ^~~~~
a.cc:51:19: error: request for member 'top' in 'curr', which is of non-class type 'int'
   51 |         ans+=curr.top().second;
      |                   ^~~
a.cc:52:14: error: request for member 'pop' in 'curr', which is of non-class type 'int'
   52 |         curr.pop();
      |              ^~~