Language: C++

#include <iostream>
#include <vector>
#include <queue>

int main(){
	int n, m;
	cin >> n >> m;

	vector< vector<int> > jobs(m+1);
	for (int i = 0; i < n; i++){
		int a, b;
		cin >> a >> b;
		if (a > m) continue;
		jobs[a].push_back(b);
	}
	
	long ans = 0;
	priority_queue<int> q;
	for (int i = 1; i <= m; i++){
		for (auto j : jobs[i])
			q.push(j);
		if (q.empty()) continue;
		ans += q.top();
		q.pop();
	}

	cout << ans << endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:7:9: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    7 |         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:9:9: error: 'vector' was not declared in this scope
    9 |         vector< vector<int> > jobs(m+1);
      |         ^~~~~~
a.cc:9:9: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
                 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:9:24: error: expected primary-expression before 'int'
    9 |         vector< vector<int> > jobs(m+1);
      |                        ^~~
a.cc:14:17: error: 'jobs' was not declared in this scope
   14 |                 jobs[a].push_back(b);
      |                 ^~~~
a.cc:18:9: error: 'priority_queue' was not declared in this scope; did you mean 'std::priority_queue'?
   18 |         priority_queue<int> q;
      |         ^~~~~~~~~~~~~~
      |         std::priority_queue
In file included from /usr/include/c++/14/queue:66,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_queue.h:496:11: note: 'std::priority_queue' declared here
  496 |     class priority_queue
      |           ^~~~~~~~~~~~~~
a.cc:18:24: error: expected primary-expression before 'int'
   18 |         priority_queue<int> q;
      |                        ^~~
a.cc:20:31: error: 'jobs' was not declared in this scope
   20 |                 for (auto j : jobs[i])
      |                               ^~~~
a.cc:21:25: error: 'q' was not declared in this scope
   21 |                         q.push(j);
      |                         ^
a.cc:22:21: error: 'q' was not declared in this scope
   22 |                 if (q.empty()) continue;
      |                     ^
a.cc:23:24: error: 'q' was not declared in this scope
   23 |                 ans += q.top();
      |                        ^
a.cc:27:9: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   27 |         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:27:24: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   27 |         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)
      |     ^~~~