Language: C++

#include <bits/stdc++.h>
#define il inline
#define vd void
#define rg register
#define rep(i,x,y) for(rg int i=x;i<=y;++i)
#define drp(i,x,y) for(rg int i=x;i>=y;--i)
using namespace std;
char buf[Len],*p1=buf,*p2=buf,duf[Len],*q1=duf;
il char gc(); il int rd(); il vd pc(char c); il vd rt(int x); il vd flush();
int n,m,a,b,ans;
vector <int> V[100005];
priority_queue <int> q;
int main(){
	n=rd(),m=rd();
	rep(i,1,n) a=rd(),b=rd(),V[a].push_back(b);
	drp(i,m-1,0){
		for(rg int j=0;j<(int)V[m-i].size();++j) q.push(V[m-i][j]);
		if(!q.empty()) ans+=q.top(),q.pop();
	}
	rt(ans);
	return flush(),0;
}
il char gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,Len,stdin),p1==p2)?-1:*p1++;}
il int rd(){char c;
	while(!isdigit(c=gc())&&c!='-');
	int f=c=='-'?c=gc(),1:0,x=c^48;
	while(isdigit(c=gc())) x=((x+(x<<2))<<1)+(c^48);
	return f?-x:x;
}
il vd pc(char c){q1==duf+Len&&fwrite(q1=duf,1,Len,stdout),*q1++=c;}
il vd rt(int x){x<0?pc('-'),x=-x:0,pc((x>=10?rt(x/10),x%10:x)+48);}
il vd flush(){fwrite(duf,1,q1-duf,stdout);}

Compiler output:
a.cc:8:10: error: 'Len' was not declared in this scope
    8 | char buf[Len],*p1=buf,*p2=buf,duf[Len],*q1=duf;
      |          ^~~
a.cc:8:19: error: 'buf' was not declared in this scope
    8 | char buf[Len],*p1=buf,*p2=buf,duf[Len],*q1=duf;
      |                   ^~~
a.cc: In function 'int main()':
a.cc:15:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   15 |         rep(i,1,n) a=rd(),b=rd(),V[a].push_back(b);
      |             ^
a.cc:5:31: note: in definition of macro 'rep'
    5 | #define rep(i,x,y) for(rg int i=x;i<=y;++i)
      |                               ^
a.cc:16:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   16 |         drp(i,m-1,0){
      |             ^
a.cc:6:31: note: in definition of macro 'drp'
    6 | #define drp(i,x,y) for(rg int i=x;i>=y;--i)
      |                               ^
a.cc:17:28: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   17 |                 for(rg int j=0;j<(int)V[m-i].size();++j) q.push(V[m-i][j]);
      |                            ^
a.cc: In function 'char gc()':
a.cc:23:25: error: 'p2' was not declared in this scope; did you mean 'pc'?
   23 | il char gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,Len,stdin),p1==p2)?-1:*p1++;}
      |                         ^~
      |                         pc
a.cc:23:37: error: 'buf' was not declared in this scope
   23 | il char gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,Len,stdin),p1==p2)?-1:*p1++;}
      |                                     ^~~
a.cc:23:54: error: 'Len' was not declared in this scope
   23 | il char gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,Len,stdin),p1==p2)?-1:*p1++;}
      |                                                      ^~~
a.cc: In function 'void pc(char)':
a.cc:30:18: error: 'q1' was not declared in this scope; did you mean 'y1'?
   30 | il vd pc(char c){q1==duf+Len&&fwrite(q1=duf,1,Len,stdout),*q1++=c;}
      |                  ^~
      |                  y1
a.cc:30:22: error: 'duf' was not declared in this scope; did you mean 'dup'?
   30 | il vd pc(char c){q1==duf+Len&&fwrite(q1=duf,1,Len,stdout),*q1++=c;}
      |                      ^~~
      |                      dup
a.cc:30:26: error: 'Len' was not declared in this scope
   30 | il vd pc(char c){q1==duf+Len&&fwrite(q1=duf,1,Len,stdout),*q1++=c;}
      |                          ^~~
a.cc: In function 'void flush()':
a.cc:32:22: error: 'duf' was not declared in this scope; did you mean 'dup'?
   32 | il vd flush(){fwrite(duf,1,q1-duf,stdout);}
      |                      ^~~
      |                      dup
a.cc:32:28: error: 'q1' was not declared in this scope; did you mean 'y1'?
   32 | il vd flush(){fwrite(duf,1,q1-duf,stdout);}
      |                            ^~
      |                            y1