Language: C++

#include<iostream>
#include<functional>
#include<cmath>
#include<numeric>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define int64 long long
#define modbig (10*10*10*10*10*10*10*10*10+7)
using namespace std;

int main(){
  ll n,m,ans=0,tmp;
  cin>>n>>m;
  map<ll,ll> mp;
  vector<ll> v;
  ll a[n],b[m],c[m];
  rep(i,n){
    cin>>a[i];
    mp[a[i]]++;
  }
  rep(i,m){
    cin>>b[i]>>c[i];
    mp[c[i]]+=b[i];
  }
  for(auto p:mp){
    v.push_back(p.first());
  }
  sort(v.begin(),v.end(),greater<ll>());
  ll kosuu=0;
  rep(i,n+m){
    tmp=mp[v[i]];
    if(kosuu+tmp>n){
      ans+=v[i]*(n-kosuu);
      break;
    }else{
      ans+=v[i]*tmp;
      kosuu+=tmp;
    }
  }
  cout<<ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:3: error: 'll' was not declared in this scope
   16 |   ll n,m,ans=0,tmp;
      |   ^~
a.cc:17:8: error: 'n' was not declared in this scope; did you mean 'yn'?
   17 |   cin>>n>>m;
      |        ^
      |        yn
a.cc:17:11: error: 'm' was not declared in this scope; did you mean 'tm'?
   17 |   cin>>n>>m;
      |           ^
      |           tm
a.cc:18:12: error: template argument 3 is invalid
   18 |   map<ll,ll> mp;
      |            ^
a.cc:18:12: error: template argument 4 is invalid
a.cc:19:12: error: template argument 2 is invalid
   19 |   vector<ll> v;
      |            ^
a.cc:20:5: error: expected ';' before 'a'
   20 |   ll a[n],b[m],c[m];
      |     ^~
      |     ;
a.cc:22:10: error: 'a' was not declared in this scope
   22 |     cin>>a[i];
      |          ^
a.cc:26:10: error: 'b' was not declared in this scope
   26 |     cin>>b[i]>>c[i];
      |          ^
a.cc:26:16: error: 'c' was not declared in this scope
   26 |     cin>>b[i]>>c[i];
      |                ^
a.cc:29:14: error: 'begin' was not declared in this scope; did you mean 'std::begin'?
   29 |   for(auto p:mp){
      |              ^~
      |              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:29:14: error: 'end' was not declared in this scope; did you mean 'std::end'?
   29 |   for(auto p:mp){
      |              ^~
      |              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:30:7: error: request for member 'push_back' in 'v', which is of non-class type 'int'
   30 |     v.push_back(p.first());
      |       ^~~~~~~~~
a.cc:32:10: error: request for member 'begin' in 'v', which is of non-class type 'int'
   32 |   sort(v.begin(),v.end(),greater<ll>());
      |          ^~~~~
a.cc:32:20: error: request for member 'end' in 'v', which is of non-class type 'int'
   32 |   sort(v.begin(),v.end(),greater<ll>());
      |                    ^~~
a.cc:33:5: error: expected ';' before 'kosuu'
   33 |   ll kosuu=0;
      |     ^~~~~~
      |     ;
a.cc:35:5: error: 'tmp' was not declared in this scope; did you mean 'mp'?
   35 |     tmp=mp[v[i]];
      |     ^~~
      |     mp
a.cc:35:13: error: invalid types 'int[int]' for array subscript
   35 |     tmp=mp[v[i]];
      |             ^
a.cc:36:8: error: 'kosuu' was not declared in this scope
   36 |     if(kosuu+tmp>n){
      |        ^~~~~
a.cc:37:7: error: 'ans' was not declared in this scope; did you mean 'abs'?
   37 |       ans+=v[i]*(n-kosuu);
      |       ^~~
      |       abs
a.cc:37:13: error: invalid types 'int[int]' for array subscript
   37 |       ans+=v[i]*(n-kosuu);
      |             ^
a.cc:40:7: error: 'ans' was not declared in this scope; did you mean 'abs'?
   40 |       ans+=v[i]*tmp;
      |       ^~~
      |       abs
a.cc:40:13: error: invalid types 'int[int]' for array subscript
   40 |       ans+=v[i]*tmp;
      |             ^
a.cc:44:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   44 |   cout<<ans;
      |         ^~~
      |         abs