Language: C++

#include <iostream>
#include <queue>

// #define rep(i, a, n)  for(ll i=a; i<n; i++)
// #define per(i, a, n)  for(ll i=n-1; i>=a; i--)
// #define fill0(n)  setfill('0') << right << setw(n)
// #define all(x)  (x).begin(), (x).end()
// #define rall(x) (x).rbegin(), (x).rend()
// #define LONGMAX 1e18
// #define intMAX 1000000000
// using namespace std;
// typedef long long ll;
// typedef pair<ll,ll> P;
// const ll mod = 1e9+7;

int n,m;

int main(){
	cin >> n >> m;
	vector<int>a(n),b(n);
	for(int i=0; i < n; i++) cin >> a[i] >> b[i];
	ll ans = 0;
	priority_queue<int> que;

	for(int i = 1; i < m + 1; i++){
		for(int j = 0; j < n; j++){
			if(a[j] == i) que.push(b[j]);
		}
		if(!que.empty()){
			ans += que.top();
			que.pop();
		}
		
	}
	cout << ans << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:9: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   19 |         cin >> n >> m;
      |         ^~~
      |         std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:20:9: error: 'vector' was not declared in this scope
   20 |         vector<int>a(n),b(n);
      |         ^~~~~~
a.cc:20:9: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/queue:63,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/vector:93:13: note:   'std::pmr::vector'
   93 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
a.cc:20:16: error: expected primary-expression before 'int'
   20 |         vector<int>a(n),b(n);
      |                ^~~
a.cc:21:41: error: 'a' was not declared in this scope
   21 |         for(int i=0; i < n; i++) cin >> a[i] >> b[i];
      |                                         ^
a.cc:21:49: error: 'b' was not declared in this scope
   21 |         for(int i=0; i < n; i++) cin >> a[i] >> b[i];
      |                                                 ^
a.cc:22:9: error: 'll' was not declared in this scope
   22 |         ll ans = 0;
      |         ^~
a.cc:23:9: error: 'priority_queue' was not declared in this scope; did you mean 'std::priority_queue'?
   23 |         priority_queue<int> que;
      |         ^~~~~~~~~~~~~~
      |         std::priority_queue
In file included from /usr/include/c++/14/queue:66:
/usr/include/c++/14/bits/stl_queue.h:496:11: note: 'std::priority_queue' declared here
  496 |     class priority_queue
      |           ^~~~~~~~~~~~~~
a.cc:23:24: error: expected primary-expression before 'int'
   23 |         priority_queue<int> que;
      |                        ^~~
a.cc:27:28: error: 'a' was not declared in this scope
   27 |                         if(a[j] == i) que.push(b[j]);
      |                            ^
a.cc:27:39: error: 'que' was not declared in this scope
   27 |                         if(a[j] == i) que.push(b[j]);
      |                                       ^~~
a.cc:27:48: error: 'b' was not declared in this scope
   27 |                         if(a[j] == i) que.push(b[j]);
      |                                                ^
a.cc:29:21: error: 'que' was not declared in this scope
   29 |                 if(!que.empty()){
      |                     ^~~
a.cc:30:25: error: 'ans' was not declared in this scope; did you mean 'abs'?
   30 |                         ans += que.top();
      |                         ^~~
      |                         abs
a.cc:35:9: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   35 |         cout << ans << endl;
      |         ^~~~
      |         std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:35:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   35 |         cout << ans << endl;
      |                 ^~~
      |                 abs
a.cc:35:24: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   35 |         cout << ans << endl;
      |                        ^~~~
      |                        std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~