Language: C++

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long logn

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n, m;
	cin >> n >> m;
	vector<int> a(n);
	for (auto &t : a) {
		cin >> t;
	}
	vector<pair<int, int>> op(n);
	for (auto &t : op) cin >> t.first >> t.second;
	sort(op.rbegin(), op.rend(), [&](pair<int, int> x, pair<int, int> y) {
		return x.second < y.second;
	});	
	sort(a.rbegin(), a.rend());
	int pnt = 0;
	for (auto t : op) {
		while (pnt < n && a[pnt] <= t.second && t.first > 0) {
			a[pnt] = t.second;
			pnt++;
			t.first--;
		}
	}
	int s = 0;
	for (auto t : a) s += t;
	cout << s << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:32:13: error: expected initializer before 'n'
   32 |         int n, m;
      |             ^
a.cc:33:16: error: 'n' was not declared in this scope; did you mean 'yn'?
   33 |         cin >> n >> m;
      |                ^
      |                yn
a.cc:33:21: error: 'm' was not declared in this scope; did you mean 'tm'?
   33 |         cin >> n >> m;
      |                     ^
      |                     tm
a.cc:34:19: error: template argument 1 is invalid
   34 |         vector<int> a(n);
      |                   ^
a.cc:34:19: error: template argument 2 is invalid
a.cc:35:24: error: 'begin' was not declared in this scope; did you mean 'std::begin'?
   35 |         for (auto &t : a) {
      |                        ^
      |                        std::begin
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:114:37: note: 'std::begin' declared here
  114 |   template<typename _Tp> const _Tp* begin(const valarray<_Tp>&) noexcept;
      |                                     ^~~~~
a.cc:35:24: error: 'end' was not declared in this scope; did you mean 'std::end'?
   35 |         for (auto &t : a) {
      |                        ^
      |                        std::end
/usr/include/c++/14/bits/range_access.h:116:37: note: 'std::end' declared here
  116 |   template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept;
      |                                     ^~~
a.cc:38:29: error: wrong number of template arguments (1, should be 2)
   38 |         vector<pair<int, int>> op(n);
      |                             ^~
In file included from /usr/include/c++/14/string:48:
/usr/include/c++/14/bits/stl_iterator.h:3013:12: note: provided for 'template<class _T1, class _T2> struct std::pair'
 3013 |     struct pair;
      |            ^~~~
a.cc:38:36: error: template argument 1 is invalid
   38 |         vector<pair<int, int>> op(n);
      |                                    ^
a.cc:38:36: error: template argument 2 is invalid
a.cc:39:24: error: 'op' was not declared in this scope
   39 |         for (auto &t : op) cin >> t.first >> t.second;
      |                        ^~
a.cc:40:14: error: 'op' was not declared in this scope
   40 |         sort(op.rbegin(), op.rend(), [&](pair<int, int> x, pair<int, int> y) {
      |              ^~
a.cc:40:55: error: wrong number of template arguments (1, should be 2)
   40 |         sort(op.rbegin(), op.rend(), [&](pair<int, int> x, pair<int, int> y) {
      |                                                       ^
/usr/include/c++/14/bits/stl_iterator.h:3013:12: note: provided for 'template<class _T1, class _T2> struct std::pair'
 3013 |     struct pair;
      |            ^~~~
a.cc:40:73: error: wrong number of template arguments (1, should be 2)
   40 |         sort(op.rbegin(), op.rend(), [&](pair<int, int> x, pair<int, int> y) {
      |                                                                         ^
/usr/include/c++/14/bits/stl_iterator.h:3013:12: note: provided for 'template<class _T1, class _T2> struct std::pair'
 3013 |     struct pair;
      |            ^~~~
a.cc: In lambda function:
a.cc:41:26: error: request for member 'second' in 'x', which is of non-class type 'int'
   41 |                 return x.second < y.second;
      |                          ^~~~~~
a.cc:41:37: error: request for member 'second' in 'y', which is of non-class type 'int'
   41 |                 return x.second < y.second;
      |                                     ^~~~~~
a.cc: In function 'int main()':
a.cc:43:16: error: request for member 'rbegin' in 'a', which is of non-class type 'int'
   43 |         sort(a.rbegin(), a.rend());
      |                ^~~~~~
a.cc:43:28: error: request for member 'rend' in 'a', which is of non-class type 'int'
   43 |         sort(a.rbegin(), a.rend());
      |                            ^~~~
a.cc:44:13: error: expected initializer before 'pnt'
   44 |         int pnt = 0;
      |             ^~~
a.cc:46:24: error: 'pnt' was not declared in this scope; did you mean 'int'?
   46 |                 while (pnt < n && a[pnt] <= t.second && t.first > 0) {
      |                        ^~~
      |                        int
a.cc:52:13: error: expected initializer before 's'
   52 |         int s = 0;
      |             ^
a.cc:53:23: error: 'begin' was not declared in this scope; did you mean 'std::begin'?
   53 |         for (auto t : a) s += t;
      |                       ^
      |                       std::begin
/usr/include/c++/14/bits/range_access.h:114:37: note: 'std::begin' declared here
  114 |   template<typename _Tp> const _Tp* begin(const valarray<_Tp>&) noexcept;
      |                                     ^~~~~
a.cc:53:23: error: 'end' was not declared in this scope; did you mean 'std::end'?
   53 |         for (auto t : a) s += t;
      |                       ^
      |                       std::end
/usr/include/c++/14/bits/range_access.h:116:37: note: 'std::end' declared here
  116 |   template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept;
      |                                     ^~~
a.cc:53:26: error: 's' was not declared in this scope
   53 |         for (auto t : a) s += t;
      |                          ^
a.cc:54:17: error: 's' was not declared in this scope
   54 |         cout << s << endl;
      |                 ^