Language: C++

int main() {
    int N, M;
    std::cin >> N >> M;

    std::vector<int> A(N);
    for (int i = 0; i < N; i++) {
        std::cin >> A[i];
    }
    std::sort(A.begin(), A.end(), [](auto lhs, auto rhs) {return lhs < rhs;});

    std::vector<std::pair<int, int>> re(N, std::pair<int, int>());
    for (int i = 0; i < M; i++) {
        std::cin >> re[i].first >> re[i].second;
    }

    std::sort(re.begin(), re.end(), [](auto lhs, auto rhs) {return lhs.second > rhs.second;});

    long long int s = 0;
    int re_idx = 0;
    for (int i = 0; i < N; i++) {
        int val = A[i];
        if (re[re_idx].second > val) {
            val = re[re_idx].second;
            re[re_idx].first--;
            if (re[re_idx].first == 0) {
                re_idx++;
            }
        }
        s += static_cast<long long int>(val);
    }
    std::cout << s << std::endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:3:10: error: 'cin' is not a member of 'std'
    3 |     std::cin >> N >> M;
      |          ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | int main() {
a.cc:5:10: error: 'vector' is not a member of 'std'
    5 |     std::vector<int> A(N);
      |          ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | int main() {
a.cc:5:17: error: expected primary-expression before 'int'
    5 |     std::vector<int> A(N);
      |                 ^~~
a.cc:7:14: error: 'cin' is not a member of 'std'
    7 |         std::cin >> A[i];
      |              ^~~
a.cc:7:14: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:7:21: error: 'A' was not declared in this scope
    7 |         std::cin >> A[i];
      |                     ^
a.cc:9:10: error: 'sort' is not a member of 'std'
    9 |     std::sort(A.begin(), A.end(), [](auto lhs, auto rhs) {return lhs < rhs;});
      |          ^~~~
a.cc:9:15: error: 'A' was not declared in this scope
    9 |     std::sort(A.begin(), A.end(), [](auto lhs, auto rhs) {return lhs < rhs;});
      |               ^
a.cc:11:10: error: 'vector' is not a member of 'std'
   11 |     std::vector<std::pair<int, int>> re(N, std::pair<int, int>());
      |          ^~~~~~
a.cc:11:10: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
a.cc:11:22: error: 'pair' is not a member of 'std'
   11 |     std::vector<std::pair<int, int>> re(N, std::pair<int, int>());
      |                      ^~~~
a.cc:1:1: note: 'std::pair' is defined in header '<utility>'; this is probably fixable by adding '#include <utility>'
  +++ |+#include <utility>
    1 | int main() {
a.cc:11:27: error: expected primary-expression before 'int'
   11 |     std::vector<std::pair<int, int>> re(N, std::pair<int, int>());
      |                           ^~~
a.cc:13:14: error: 'cin' is not a member of 'std'
   13 |         std::cin >> re[i].first >> re[i].second;
      |              ^~~
a.cc:13:14: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:13:21: error: 're' was not declared in this scope
   13 |         std::cin >> re[i].first >> re[i].second;
      |                     ^~
a.cc:16:10: error: 'sort' is not a member of 'std'
   16 |     std::sort(re.begin(), re.end(), [](auto lhs, auto rhs) {return lhs.second > rhs.second;});
      |          ^~~~
a.cc:16:15: error: 're' was not declared in this scope
   16 |     std::sort(re.begin(), re.end(), [](auto lhs, auto rhs) {return lhs.second > rhs.second;});
      |               ^~
a.cc:31:10: error: 'cout' is not a member of 'std'
   31 |     std::cout << s << std::endl;
      |          ^~~~
a.cc:31:10: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:31:28: error: 'endl' is not a member of 'std'
   31 |     std::cout << s << std::endl;
      |                            ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | int main() {