Language: C++

#include "bits/stdc++.h"
using namespace std;
typedef int64_t ll;
typedef vector<int64_t> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())

int main(){
  int n,m;
  cin>>n>>m;
  vll a(n);
  REP(i,n){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  REP(i,m){
    ll b,c;
    cin>>b>>c;
    auto key=lower_bound(a.begin(),a.end(),c);
    int x=key-a.begin();
    REP(j,min(x,b)){
    a[j]=c;
    }
    sort(a.begin(),a.end());
  }
  ll ans=0;
  REP(i,n){
    ans+=a[i];
  }
  cout<<ans<<endl;
  
}



Compiler output:
a.cc: In function 'int main()':
a.cc:28:14: error: no matching function for call to 'min(int&, ll&)'
   28 |     REP(j,min(x,b)){
      |           ~~~^~~~~
a.cc:11:37: note: in definition of macro 'FOR'
   11 | #define FOR(i,a,b) for(int i=(a);i<(b);++i)
      |                                     ^
a.cc:28:5: note: in expansion of macro 'REP'
   28 |     REP(j,min(x,b)){
      |     ^~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:28:14: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long int'})
   28 |     REP(j,min(x,b)){
      |           ~~~^~~~~
a.cc:11:37: note: in definition of macro 'FOR'
   11 | #define FOR(i,a,b) for(int i=(a);i<(b);++i)
      |                                     ^
a.cc:28:5: note: in expansion of macro 'REP'
   28 |     REP(j,min(x,b)){
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:28:14: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   28 |     REP(j,min(x,b)){
      |           ~~~^~~~~
a.cc:11:37: note: in definition of macro 'FOR'
   11 | #define FOR(i,a,b) for(int i=(a);i<(b);++i)
      |                                     ^
a.cc:28:5: note: in expansion of macro 'REP'
   28 |     REP(j,min(x,b)){
      |     ^~~