criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void){
    int N, M;
    cin >> N >> M;

    vector<int> A(N);
    for(int i=0; i<N; i++)
        cin >> A[i];
    vector<int> B(M), C(M);
    for(int i=0; i<M; i++)
        cin >> B[i] >> C[i];

    sort(A.begin(), A.end());

    int max = accumulate(A.begin(),A.end(),0);
    for(int i=0; i<M; i++){
        vector<int> tmp = A;
        for(int j=0; j<B[i]; j++)
            tmp[j] = C[i];
        int sum = accumulate(tmp.begin(),tmp.end(),0);
        if(max <= sum)
            max = sum;
    }

    cout << max << endl;
    
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:15: error: 'accumulate' was not declared in this scope
   20 |     int max = accumulate(A.begin(),A.end(),0);
      |               ^~~~~~~~~~
Language: Java

mport java.util.Arrays;
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] first = splitInt(sc.nextLine(), " ");
		int[] table = splitInt(sc.nextLine(), " ");
		Arrays.sort(table);
		
		int[][] array2 = new int[2][first[1]];
		for(int i=0; i<first[1];i++) {
			int[] array = splitInt(sc.nextLine(), " ");
			array2[0][i] = array[0];
			array2[1][i] = array[1];
		}
		for(int i=0; i<first[1]; i++) {
			int d = 0;
			int n=0;
			for(; n<array2[0][i] ;n++) {
				if(array2[1][i]>table[d]) {
					table[d] = array2[1][i];
					d++;
				}else {
					break;
				}
			}
			if(n==array2[0][i]) {
				Arrays.sort(table);
			}
		}
		long result = 0;
		for(int a:table) {
			result+=a;
		}
		System.out.println(result);
		
	}
	public static int[] splitInt(String str, String split) {
		String[] array = str.split(split);
		int[] array2 = new int[array.length];
	
		for(int i=0; i<array.length; i++) {
				array2[i] = Integer.parseInt(array[i]);
		}
		return array2;
	}
}


Compiler output:
Main.java:1: error: class, interface, enum, or record expected
mport java.util.Arrays;
^
Main.java:2: error: class, interface, enum, or record expected
import java.util.Scanner;
^
2 errors
Language: Java

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] first = splitInt(sc.nextLine(), " ");
		int[] table = splitInt(sc.nextLine(), " ");
		Arrays.sort(table);
		
		int[][] array2 = new int[2][first[1]];
		for(int i=0; i<first[1];i++) {
			int[] array = splitInt(sc.nextLine(), " ");
			array2[0][i] = array[0];
			array2[1][i] = array[1];
		}
		for(int i=0; i<first[1]; i++) {
			int d = 0;
			int n=0;
			for(; n<array2[0][i] ;n++) {
				if(array2[1][i]>table[d]) {
					table[d] = array2[1][i];
					d++;
				}else {
					break;
				}
			}
			if(n==array2[0][i]) {
				Arrays.sort(table);
			}
		}
		long result = 0;
		for(int a:table) {
			result+=a;
		}
		System.out.println(result);
		
	}
	public static int[] splitInt(String str, String split) {
		String[] array = str.split(split);
		int[] array2 = new int[array.length];
	
		for(int i=0; i<array.length; i++) {
				array2[i] = Integer.parseInt(array[i]);
		}
		return array2;
	}
}

Compiler output:
Main.java:4: error: cannot find symbol
		Scanner sc = new Scanner(System.in);
		^
  symbol:   class Scanner
  location: class Main
Main.java:4: error: cannot find symbol
		Scanner sc = new Scanner(System.in);
		                 ^
  symbol:   class Scanner
  location: class Main
Main.java:7: error: cannot find symbol
		Arrays.sort(table);
		^
  symbol:   variable Arrays
  location: class Main
Main.java:27: error: cannot find symbol
				Arrays.sort(table);
				^
  symbol:   variable Arrays
  location: class Main
4 errors
Language: C++

#include<bits/stdc++.h>
#include<queue>
#include<algorithm>
#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define REP(i,n) FOR(i,0,n)
using namespace std;

/*
2019/05/27
*/

int main(){//RE
  int n,m;
  cin>>n>>m;
  vector<int> a(n);
  vector<int>b(m);
  vector<int>c(m);
  priority_queue<pair<int,int>> q;//順位付きque//O(log要素数)
  //pair?最初が大きい方が優先される。
  //大きいもの順に出てくる
  //小さいもの順のときは？--ダイクストラの実装とか…
  REP(i,n){
    cin>>a[i];
    q.push(make_pair(a[i],i));
  }
  REP(i,m){
    cin>>b[i]>>c[i];
    q.push(make_pair(c[i],b[i]));
  }

  long long ans=0;//64bit
  REP(i,n){//n回の操作//qから取り出す
    pair<int,int> p=q.top();//最大をpに加える
    q.pop();//qから最大のカードを一枚を取り除く
    ans+=p.first;//初めの要素を答えに
    if(p.second>1){//1より大きいならカードが残っているということで、qに戻す
      p.second--;
      q.push(p);
    }
  }
  cour<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:41:3: error: 'cour' was not declared in this scope
   41 |   cour<<ans<<endl;
      |   ^~~~
Language: C++

int main(){//RE
  int n,m;
  cin>>n>>m;
  vector<int> a(n);
  vector<int>b(m);
  vector<int>c(m);
  priority_queue<pair<int,int>> q;//順位付きque//O(log要素数)
  //pair?最初が大きい方が優先される。
  //大きいもの順に出てくる
  //小さいもの順のときは？--ダイクストラの実装とか…
  REP(i,n){
    cin>>a[i];
    q.push(make_pair(a[i],i));
  }
  REP(i,m){
    cin>>b[i]>>c[i];
    q.push(make_pair(c[i],b[i]));
  }

  long long ans=0;//64bit
  REP(i,n){//n回の操作//qから取り出す
    pair<int,int> p=q.top();//最大をpに加える
    q.pop();//qから最大のカードを一枚を取り除く
    ans+=p.first;//初めの要素を答えに
    if(p.second>1){//1より大きいならカードが残っているということで、qに戻す
      p.second--;
      q.push(p);
    }
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:3:3: error: 'cin' was not declared in this scope
    3 |   cin>>n>>m;
      |   ^~~
a.cc:4:3: error: 'vector' was not declared in this scope
    4 |   vector<int> a(n);
      |   ^~~~~~
a.cc:4:10: error: expected primary-expression before 'int'
    4 |   vector<int> a(n);
      |          ^~~
a.cc:5:10: error: expected primary-expression before 'int'
    5 |   vector<int>b(m);
      |          ^~~
a.cc:6:10: error: expected primary-expression before 'int'
    6 |   vector<int>c(m);
      |          ^~~
a.cc:7:3: error: 'priority_queue' was not declared in this scope
    7 |   priority_queue<pair<int,int>> q;//順位付きque//O(log要素数)
      |   ^~~~~~~~~~~~~~
a.cc:7:18: error: 'pair' was not declared in this scope
    7 |   priority_queue<pair<int,int>> q;//順位付きque//O(log要素数)
      |                  ^~~~
a.cc:7:23: error: expected primary-expression before 'int'
    7 |   priority_queue<pair<int,int>> q;//順位付きque//O(log要素数)
      |                       ^~~
a.cc:11:7: error: 'i' was not declared in this scope
   11 |   REP(i,n){
      |       ^
a.cc:11:3: error: 'REP' was not declared in this scope
   11 |   REP(i,n){
      |   ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;

const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); ++i)
#define RFOR(i,r,n) for(ll i = (ll)(n-1); i >= r; --i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()

using ll = long long int;
using ull = unsigned long long int;
using vi = vector<ll>;
using vp = vector<pair<ll, ll>>;
using vs = vector<string>;
using vc = vector<char>;
using lst = list<ll>;

ll a, b, n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/

int main() {
	cin >> n >> m;
    ll card[n];
    vp opr;
    REP(i,n) cin >> card[i];
    sort(card,card+n);
    REP(i,m) {
    	cin >> b >> k;
        if (accumulate(card,card+b,0)<b*k) {
        	replace(card,card+b,k);
            sort(card,card+n);
            
        }
        opr.push_back(make_pair(b,k));
    }
    sum = accumulate(card,card+n,0);
    cout << sum << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:38:24: error: no matching function for call to 'replace(ll [n], ll*, ll&)'
   38 |                 replace(card,card+b,k);
      |                 ~~~~~~~^~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algo.h:4280:5: note: candidate: 'template<class _FIter, class _Tp> void std::replace(_FIter, _FIter, const _Tp&, const _Tp&)'
 4280 |     replace(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4280:5: note:   candidate expects 4 arguments, 3 provided
In file included from /usr/include/c++/14/algorithm:86:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:174:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::replace(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&, const _Tp&)'
  174 | replace(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __old_value,
      | ^~~~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:174:1: note:   candidate expects 5 arguments, 3 provided
Language: Java

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] input = scanner.nextLine().split(" ");
        long n = Long.valueOf(input[0]);
        long m = Long.valueOf(input[1]);

        String[] a = scanner.nextLine().split(" ");

        PriorityQueue<Pair> priorityQueue = new PriorityQueue<>((p1, p2) -> Long.compare(p2.number, p1.number));
        for (String ai : a) {
            priorityQueue.add(new Pair(Long.valueOf(ai), 1L));
        }
        String[] in;
        for (int i = 0; i < m; i++) {
            in = scanner.nextLine().split(" ");
            priorityQueue.add(new Pair(Long.valueOf(in[1]), Long.valueOf(in[0])));
        }

        long sum = 0;
        Pair pair;
        for (int num = 0; num < a.length; num++) {
            pair = priorityQueue.poll();
            sum += pair.number;
            while (pair.amount > 1 && num + 1 < a.length) {
                sum += pair.number;
                pair.amount--;
                num++;
            }
        }
        System.out.println(sum);

    }

    public static class Pair {
        public long number;
        public long amount;

        public Pair(long number, long amount) {
            this.number = number;
            this.amount = amount;
        }
    }

Compiler output:
Main.java:45: error: reached end of file while parsing
    }
     ^
1 error
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)

int main(){
  int N, A;
  cin >> N >> A;
  int card[N];
  rep(i,N){
    cin >> card[i];
  }
  int B[A];
  int C[A];
  rep(i,A){
    cin >> B[i] >> C[i];
  }

  priority_queue <pair<int,int>> q;
  rep(i,N){
    q.push(make_pair(A[i],1));
  }
  rep(i,M){
    q.push(make_pair(C[i],B[i]));
  }

  ll ans = 0;

  rep(i,N){
    auto p = q.top();
    q.pop();
    ans += p.first;
    if(p.seconf>1){
      p.second--;
      q.push(p);
    }
  }

  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:23: error: invalid types 'int[long long int]' for array subscript
   21 |     q.push(make_pair(A[i],1));
      |                       ^
a.cc:23:9: error: 'M' was not declared in this scope
   23 |   rep(i,M){
      |         ^
a.cc:4:42: note: in definition of macro 'rep'
    4 | #define rep(i, n) for (ll i = 0; i < (ll)n; i++)
      |                                          ^
a.cc:33:10: error: 'struct std::pair<int, int>' has no member named 'seconf'; did you mean 'second'?
   33 |     if(p.seconf>1){
      |          ^~~~~~
      |          second
Language: C++

#include <bits/stdc++.h>
using namespace std;

/* #pragma */
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

/*alias*/
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
int GCD(int a,int b){return b?GCD(b,a%b):a;}
long long GCD(long long a, long long b){return b ? GCD(b, a%b) : a;}
int LCM(int a, int b){return a * b / GCD(a, b);}
long long LCM(long long a, long long b){return a * b / GCD(a, b);}

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
const int INF = 1001001001;
const long long LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const double EPS = 1e-9;
const int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right

//#define int long long

//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//chcp 65001

signed main()
{
	int n, m; cin >> n >> m;
	vector<int> a(n+m);
	for(int i = 0, i_len = (int)n; i < i_len; ++i) cin >> a[i];
	
	for(int i = 0, i_len = (int)m; i < i_len; ++i){
		int b; cin >> b;
		for(int j = 0, j_len = (int)b; j < j_len; ++j){
			cin >> c;//後で一回だけ読み込むようにする
			a[n+j] = c;
			cout << a[n+j];
		}
	}
	sort(a.begin(), a.end());

	cout << accumulate(a.begin()+m, a.end(), 0LL) << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:63:32: error: 'c' was not declared in this scope
   63 |                         cin >> c;//後で一回だけ読み込むようにする
      |                                ^
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <climits>
#include <cmath>
#include <unordered_map>

using namespace std;

typedef long long ll;

bool compare(pair<int, int> a, pair<int, int> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

int main(void) {
  int N, M; cin >> N >> M;
  vector<int> A(N, 0);
  for (int i = 0; i < N; i++) { cin >> A[i]; }
  vector<pair<int,int>> BC;
  for (int i = 0; i < M; i++) {
    int bi, ci; cin >> bi >> ci;
    BC.push_back(make_pair(bi, ci));
  }
  std::sort(BC.begin(), BC.end(), compare);
  reverse(BC.begin(), BC.end());

  int now = 0;
  ll ans = 0LL;
  for (int i = 0; i < M; i++) {
    if (A[i] < BC[now].first) {
      A[i] = BC[now].first;
      BC[now].second--;
      if (BC[now].second == 0) {
        now++;
      }
    } else {
      break;
    }
  }

  ll res = 0;
  for (int i = 0; i < n; i++) {
    res += A[i];
  }
  cout << res << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:49:23: error: 'n' was not declared in this scope
   49 |   for (int i = 0; i < n; i++) {
      |                       ^
Language: C++

#include <algorithm>
using namespace std;
int main(void){
   int N,M;
   cin >> N >> M;
   vector<int> v(N),d;
   
   for(int i=0;i<N;i++){
       cin >> v[i];
   }
   
   sort(v.begin(),v.end());
   
   int b,c;
   for(int i=0;i<M;i++){
       cin >> b >> c;
       d.insert(d.begin(),b,c);
   }
   
   sort(d.begin(),d.end(),greater<int>());
   
   long total=0;
   for(auto itr=v.begin();itr!=v.end();++itr){
       total+= *itr;
   }
   
   long res=total;
   for(int i=0;i<N;i++){
       total = total - v[i] + d[i];
       if(res < total) res = total;
   }
   
   
   cout << res << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:5:4: error: 'cin' was not declared in this scope
    5 |    cin >> N >> M;
      |    ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    1 | #include <algorithm>
  +++ |+#include <iostream>
    2 | using namespace std;
a.cc:6:4: error: 'vector' was not declared in this scope
    6 |    vector<int> v(N),d;
      |    ^~~~~~
a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    1 | #include <algorithm>
  +++ |+#include <vector>
    2 | using namespace std;
a.cc:6:11: error: expected primary-expression before 'int'
    6 |    vector<int> v(N),d;
      |           ^~~
a.cc:9:15: error: 'v' was not declared in this scope
    9 |        cin >> v[i];
      |               ^
a.cc:12:9: error: 'v' was not declared in this scope
   12 |    sort(v.begin(),v.end());
      |         ^
a.cc:17:8: error: 'd' was not declared in this scope
   17 |        d.insert(d.begin(),b,c);
      |        ^
a.cc:20:9: error: 'd' was not declared in this scope
   20 |    sort(d.begin(),d.end(),greater<int>());
      |         ^
a.cc:20:27: error: 'greater' was not declared in this scope
   20 |    sort(d.begin(),d.end(),greater<int>());
      |                           ^~~~~~~
a.cc:20:35: error: expected primary-expression before 'int'
   20 |    sort(d.begin(),d.end(),greater<int>());
      |                                   ^~~
a.cc:34:4: error: 'cout' was not declared in this scope
   34 |    cout << res << endl;
      |    ^~~~
a.cc:34:4: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:34:19: error: 'endl' was not declared in this scope
   34 |    cout << res << endl;
      |                   ^~~~
a.cc:2:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    1 | #include <algorithm>
  +++ |+#include <ostream>
    2 | using namespace std;
Language: Java


import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[m];
		int[] c = new int[m];
		for(int i = 0; i < n; i++){
			a[i] = sc.nextInt();
		}
		Cards cards = new Cards(a);
		for(int i = 0; i < m; i++){
			b[i] = sc.nextInt();
			c[i] = sc.nextInt();
		}
		cards.operate(b, c);
		cards.printAns();
		
	}
}
class Cards{
	int[] a;
	Command[] commands;
	int[] operate;
	Cards(int[] a){
		this.a = a;
		Arrays.sort(a);
		operate = new int[a.length];
	}
	void operate(int[] b, int[] c){
		int m = b.length;
		commands = new Command[m];
		for(int i = 0; i < m; i++){
			commands[i] = new Command(b[i], c[i]);
		}
		Arrays.sort(commands, (com1, com2) -> com2.val - com1.val);
		int count = 0;
		loop:
		for(int i = 0; i < commands.length; i++){
			int value = commands[i].val;
			int nextNum = commands[i].num + count;
			if(a.length - 1 < nextNum) {
				nextNum = a.length - 1;
			}
			for(; count < nextNum; count++){
				if(a[count] < value){
					a[count] = value;
				}else{
					break loop;
				}
			}
		}
	}
	void printAns(){
		long ans = 0;
		for(int i = 0; i < a.length; i++){
			ans += a[i];
		}
		System.out.println(ans);
	}
}
class Command {
	int num;
	int val;
	Command(int b, int c){
		this.num = b;
		this.val = c;
	}
	
}
package ABC127;

import java.util.Arrays;
import java.util.Scanner;

public class IntegerCards {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[m];
		int[] c = new int[m];
		for(int i = 0; i < n; i++){
			a[i] = sc.nextInt();
		}
		Cards cards = new Cards(a);
		for(int i = 0; i < m; i++){
			b[i] = sc.nextInt();
			c[i] = sc.nextInt();
		}
		cards.operate(b, c);
		cards.printAns();
		
	}
}
class Cards{
	int[] a;
	Command[] commands;
	int[] operate;
	Cards(int[] a){
		this.a = a;
		Arrays.sort(a);
		operate = new int[a.length];
	}
	void operate(int[] b, int[] c){
		int m = b.length;
		commands = new Command[m];
		for(int i = 0; i < m; i++){
			commands[i] = new Command(b[i], c[i]);
		}
		Arrays.sort(commands, (com1, com2) -> com2.val - com1.val);
		int count = 0;
		loop:
		for(int i = 0; i < commands.length; i++){
			int value = commands[i].val;
			int nextNum = commands[i].num + count;
			if(a.length - 1 < nextNum) {
				nextNum = a.length - 1;
			}
			for(; count < nextNum; count++){
				if(a[count] < value){
					a[count] = value;
				}else{
					break loop;
				}
			}
		}
	}
	void printAns(){
		long ans = 0;
		for(int i = 0; i < a.length; i++){
			ans += a[i];
		}
		System.out.println(ans);
	}
}
class Command {
	int num;
	int val;
	Command(int b, int c){
		this.num = b;
		this.val = c;
	}
	
}


Compiler output:
Main.java:76: error: class, interface, enum, or record expected
package ABC127;
^
Main.java:78: error: class, interface, enum, or record expected
import java.util.Arrays;
^
Main.java:79: error: class, interface, enum, or record expected
import java.util.Scanner;
^
3 errors
Language: C++

#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrep(i,a,b) for(int i=(int)(a);i>=(int)(b);--i)
#define fore(i,a) for(auto &i:a)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define isin(i,a,b) ((a) <= (i) && (i) < (b))
#define uni(a) (a).erase(unique(all(a)),(a).end())
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)(a).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll  = long long;
using unit= unsigned;
using ull = unsigned long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vvi = vector<vi>;
using vp  = vector<P>;
void _main(); int main(){ cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T>void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T>void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T>void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T>void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T>bool chmax(T &a, const T &b){ if (a<b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if (b<a){ a = b; return 1; } return 0; }
template<class T>T gcd(T a, T b){ if (b==0){ return a; }else{ return gcd(b, a%b); }}
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
constexpr double eps = 1e-10;
constexpr int inf = INT_MAX / 2;
constexpr ll infl = 1LL << 60;

void _main() {
  int N, M;
  cin >> N >> M;
  priority_queue<P> que;
  rep(i, 0, N) {
    int a; cin >> a;
    que.push({a, 1});
  }
  rep(i, 0, M) {
    int b, c; cin >> b >> c;
    que.push({c, b});
  }

  ll ans = 0;
  rep(i, 0, N) {
    P p = que.pop();
    ans += p.fi;
    --p.se;
    if (p.se != 0) {
      que.push(p);
    }
  }

  cout << ans << endl;
}

Compiler output:
a.cc: In function 'void _main()':
a.cc:52:18: error: conversion from 'void' to non-scalar type 'P' {aka 'std::pair<int, int>'} requested
   52 |     P p = que.pop();
      |           ~~~~~~~^~
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL)
	// ll n,m, db,dc, b,c, maxi = INT_MIN, sum =0; cin>>n>>m; //tle aaya tha but impelementation dekh;
	// vector<ll> a(n);
	// for(ll i = 0 ; i < n ; i++) cin>>a[i]; 
	// sort(a.begin(),a.end());
	// vector<ll>::iterator it;
	// for(ll i = 0 ; i < m ; i++)
	// {
	// 	cin>>b>>c;
	// 	it = lower_bound(a.begin(), a.end(), c);
	// 	ll pos = it - a.begin()-1;
	// 	if(pos>=0)
	// 	fill(a.begin(), a.begin()+min(b,pos),c);
	// 	sort(a.begin(),a.end());
	// }
	// for(int i = 0 ; i< n; i++)
	// 	sum+=a[i];
	// cout<<sum<<endl;
	ll n,m, b,c, sum =0; cin>>n>>m;
	map<ll,ll> freq;
	for(int i = 0 ; i < n; i++)
	{
		cin>>b; freq[b]++;
	}
	for(int i = 0 ; i < m;i++)
	{
		cin>>b>>c;
		freq[c]+=b;
	}
	map<ll,ll>::iterator it;
	it = freq.end();
	--it;
	ll req = n;
	for(; it!=freq.begin(); it--)
	{
		if(it->second>=req)
			{
				sum+=it->first*req;
				req = 0;
				break;
			}
		else
		{
			sum+=it->first*it->second;
			req-=it->second;
		}

	}
	if(req)
	{
		it= freq.begin();
		sum+=it->first*req;
	}
	cout<<sum<<endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:17: error: expected ';' before 'll'
    8 |   cout.tie(NULL)
      |                 ^
      |                 ;
......
   26 |         ll n,m, b,c, sum =0; cin>>n>>m;
      |         ~~       
a.cc:26:35: error: 'n' was not declared in this scope; did you mean 'yn'?
   26 |         ll n,m, b,c, sum =0; cin>>n>>m;
      |                                   ^
      |                                   yn
a.cc:26:38: error: 'm' was not declared in this scope; did you mean 'tm'?
   26 |         ll n,m, b,c, sum =0; cin>>n>>m;
      |                                      ^
      |                                      tm
a.cc:30:22: error: 'b' was not declared in this scope
   30 |                 cin>>b; freq[b]++;
      |                      ^
a.cc:34:22: error: 'b' was not declared in this scope
   34 |                 cin>>b>>c;
      |                      ^
a.cc:34:25: error: 'c' was not declared in this scope
   34 |                 cin>>b>>c;
      |                         ^
a.cc:45:33: error: 'sum' was not declared in this scope
   45 |                                 sum+=it->first*req;
      |                                 ^~~
a.cc:51:25: error: 'sum' was not declared in this scope
   51 |                         sum+=it->first*it->second;
      |                         ^~~
a.cc:59:17: error: 'sum' was not declared in this scope
   59 |                 sum+=it->first*req;
      |                 ^~~
a.cc:61:15: error: 'sum' was not declared in this scope
   61 |         cout<<sum<<endl;
      |               ^~~
Language: C++

#include <iostream>
#include <map>
#include <vector>
#include <numeric>
using namespace std;

int main() {

  int n, m;
  cin >> n >> m;

  vector<int> a(n);
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }

  sort(a.begin(), a.end());

  for(int i = 0; i < n; i++) cout << a[i] << " ";
  cout << endl;

  vector< pair<int, int> > p(m);
  for(int i = 0; i < m; i++) {
    cin >> p[i].second >> p[i].first;
  }

  sort(p.rbegin(), p.rend());

  for(int i = 0; i < m; i++) cout << p[i].second << " " << p[i].first << endl;

  int j = 0, cnt = 1;
  for(int i = 0; i < n; i++) {

    if(cnt > p[j].second) {
      cnt = 1;
      j++;
    }

    if(a[i] >= p[j].first) break;
    else {
      a[i] = p[j].first;
      cnt++;
    }
  }

  for(int i = 0; i < n; i++) cout << a[i] << " ";

  auto sum_ll = accumulate(a.begin(), a.end(), 0LL);
  cout << "sum_ll : " << sum_ll << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   17 |   sort(a.begin(), a.end());
      |   ^~~~
      |   short
Language: C++

#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 1000000007;
//const int MOD = 998244353;
//const long long int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> N >> M;
	vector<long long int>v(N);
	for (auto &i : v)cin >> i;
	priority_queue<pair<int, int>>PQ;
	for (auto i : v) {
		PQ.push({ -i,1 });
	}
	for (int i = 0; i < M; i++) {
		cin >> L >> R;
		R *= -1;
		int sum=0:
		while (L&&!PQ.empty()&&PQ.top().first > R) {
			auto box = PQ.top();
			PQ.pop();
			int num = min((int)L, box.second);
			L -= num;
			sum += num;
			box.second -= num;
			if (box.second)PQ.push({ box.first,box.second });
		}
		PQ.push({ R,sum });
	}
	long long int ans = 0;
	while (!PQ.empty()) {
		//cout << PQ.top().first << " " << PQ.top().second << endl;
		ans += 1LL * PQ.top().second*PQ.top().first;
		PQ.pop();
	}
	ans *= -1;
	cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:45:26: error: expected ',' or ';' before ':' token
   45 |                 int sum=0:
      |                          ^
Language: C++

#include<bits/stdc++.h>
#include<utility>
using namespace std;
int main () {
  int N, M;
  cin >> N >> M;
  vector<long long>ca(N);
  vector<pair<long long, int>>ha(M);
  for (int i = 0; i < N; i ++) cin >> ca[i];
  sort(ca.begin(), ca.end());
  for (int i = 0; i < M; i ++) {
    int a;
    long long b;
    cin >> a >> b;
    ha[i] = make_pair(b, a);
  }
  sort(ha.begin(), ha.end());
  int j = M - 1;
  for (int i = 0; i < N;) {
    bool ok = true;
    int b = ha[j].second();
    long long a = ha[j].first();
    for (int k = 0; k < b; k ++) {
      if (ca[i + k] > a || i + k >= N) {
        ok = false;
        break;
      }
      ca[k] = a;
    }
    if (!ok) break;
    i += b;
    j --;
  }
  long long ans = 0;
  for (int i = 0; i < N; i ++) {
    ans += ca[i];
  }
  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:25: error: expression cannot be used as a function
   21 |     int b = ha[j].second();
      |             ~~~~~~~~~~~~^~
a.cc:22:30: error: expression cannot be used as a function
   22 |     long long a = ha[j].first();
      |                   ~~~~~~~~~~~^~
Language: C++

#include<iostream>
#include<vector>
#include<map>
using namespace std;
using ll = long long;
vector<ll> a;
int main(){
    ll n,m,b,c,x;
    map<ll,ll> mp;
    vector<ll> a;
    cin >> n >> m;
    for(ll i=0;i<n;i++){
        cin >> x;
        mp[x]++;
        a.push_back(x);
    }
    for(ll i=0;i<m;i++){
        cin >> b >> c;
        mp[c]+=b;
        a.push_back(c);
    }
    sort(a.begin(),a.end());
    ll sum=n,ans=0;
    for(ll i=a.size()-1;sum>0;i--){
        if(mp[a[i]]>=0){
            ans+=a[i]*min(sum,mp[a[i]]);
            sum-=mp[a[i]];
            mp[a[i]]=0;
        }
    }
    cout << ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   22 |     sort(a.begin(),a.end());
      |     ^~~~
      |     short
Language: C++

#include<bits/stdc++.h>
#include<utility>
using namespace std;
int main () {
  int N, M;
  cin >> N >> M;
  vector<long long>ca(N);
  vector<pair<long long, int>>ha(M);
  for (int i = 0; i < N; i ++) cin >> ca[i];
  sort(ca.begin(), ca.end());
  for (int i = 0; i < M; i ++) {
    int a;
    long long b;
    cin >> a >> b;
    ha[i] = make_pair(b, a);
  }
  sort(ha.begin(), ha.end());
  reverce(ha.begin(), ha.end());
  int j = 0;
  for (int i = 0; i < N;) {
    bool ok = true;
    int b = ha[j].second();
    long long a = ha[j].first();
    for (int k = 0; k < b; k ++) {
      if (ca[i + k] > a || i + k >= N) {
        ok = false;
        break;
      }
      ca[k] = a;
    }
    if (!ok) break;
    i += k;
    j ++;
  }
  long long ans = 0;
  for (int i = 0; i < N; i ++) {
    ans += ca[i];
  }
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:3: error: 'reverce' was not declared in this scope
   18 |   reverce(ha.begin(), ha.end());
      |   ^~~~~~~
a.cc:22:25: error: expression cannot be used as a function
   22 |     int b = ha[j].second();
      |             ~~~~~~~~~~~~^~
a.cc:23:30: error: expression cannot be used as a function
   23 |     long long a = ha[j].first();
      |                   ~~~~~~~~~~~^~
a.cc:32:10: error: 'k' was not declared in this scope
   32 |     i += k;
      |          ^
Language: C++

#include<iostream>
using namespace std ;

void quicksort(int,int,int) ;  //クイックソートを行う関数
void insertionSort(int,int) ;  //挿入ソートを行う関数 

int main()
{
  int N,M ;
  cin>>N>>M ;
  int i ;
  unsigned long int A[N],C[M] ;
  for(i=0;i<N;i++) cin>>A[i] ;
  int B[M] ;
  int j ;
  for(j=0;j<M;j++) cin>>B[j]>>C[j] ;
  
  /*A[i]を小さい順にソート*/
  quicksort(A,0,N-1) ;
  
  for(j=0;j<M;j++){
    for(i=0;C[j]>A[i+1]&&i<=B[j];i++) A[i]=C[j] ;
  }
  
  unsigned long long int Sum=0 ;
  for(i=0;i<N;i++) Sum+=A[i] ;
  
  cout<<Sum<<endl ;
  
  return 0 ;
}

void insertionSort(int a[],int length){
  int idx ; /*新たに挿入するデータの要素番号*/
  int pos ; /*比較するデータの要素番号*/
  int tmp ; /*値を一時的に逃がすための変数*/
  
  for(idx=1;idx<length;idx++){
    pos=idx ;
    while(pos>0&&a[pos-1]>a[pos]){
      tmp=a[pos] ;
      a[pos]=a[pos-1] ;
      a[pos-1]=tmp ;
      pos-- ;
    }
  }
}

void quicksort(int a[],int left,int right){
  int mid ; /*配列の中央の要素番号*/
  int pivot ; /*基準値*/
  int idxL ; /*配列を左端からたどる要素番号*/
  int idxR ; /*配列を右端からたどる要素番号*/
  int tmp ; /*値を一時的に逃がすための変数*/
  int length ; /*配列の要素数*/
  
  /*配列の要素数が12個以下なら挿入ソートを行う*/
  length=right-left+1 ;
  if(length<=12){
    insertionSort(&a[left],length) ;
    return ;
  }
  
  /*配列の要素数が1個になるまで以下を繰り返す*/
  if(left<right){
    /*配列の中央の要素番号を得る*/
    mid=left+(right-left)/2 ;
    
    /*左端、右端、中央の3つの値の真ん中を基準値とする*/
    if(a[left]<a[mid]){
      if(a[right]<a[left]) pivot=a[left] ;
      else if(a[mid]<a[right]) pivot=a[mid] ;
      else pivot=a[right] ;
    }
    else{
      if(a[right]>a[left]) pivot=a[left] ;
      else if(a[mid]>a[right]) pivot=a[mid] ;
      else pivot=a[right] ;
    }
    
    /*基準値より小さい値と大きい値に配列の要素を分割*/
    idxL=left ;
    idxR=right ;
    while(-1){
      while(a[idxL]<pivot) idxL++ ;
      while(pivot<a[idxR]) idxR-- ;
      if(idxL>=idxR) break ;
      tmp=a[idxL] ;
      a[idxL]=a[idxR] ;
      a[idxR]=tmp ;
      idxL++ ;
      idxR-- ;
    }
    
    /*分割した前側の配列に同じ処理を行う*/
    quicksort(a,left,idxL-1) ;
    
    /*分割した後ろ側の配列に同じ処理を行う*/
    quicksort(a,idxR+1,right) ;
  }
}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:13: error: invalid conversion from 'long unsigned int*' to 'int' [-fpermissive]
   19 |   quicksort(A,0,N-1) ;
      |             ^
      |             |
      |             long unsigned int*
a.cc:4:16: note:   initializing argument 1 of 'void quicksort(int, int, int)'
    4 | void quicksort(int,int,int) ;  //クイックソートを行う関数
      |                ^~~
a.cc: At global scope:
a.cc:102:1: error: expected declaration before '}' token
  102 | }
      | ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)

int main()
{   
   int n,m;
   cin>>n>>m;
   vector<pair<int,int>> all;
   REP(i,n)
   {
       int a;
       cin>>a;
       all.push_back(make_pair(a,1));
   }
   REP(i,m)
   {
       int b,c;
       cin>>b>>c;
       all.push_back(make_pair(c,b));
   }
   sort(all.begin(),all.end(),greater<pair<int,int>>());
　　int64_t ans=0;
   int j=0;
   REP(i,n)
   {
       if(all.at(j).second<=0)
       {
           j++;
           i--;
       }
       else
       {
           ans+=all.at(j).first;
           all.at(j).second--;
       }  
   }
   cout<<ans<<endl;
}

Compiler output:
a.cc:24:1: error: extended character 　 is not valid in an identifier
   24 | 　　int64_t ans=0;
      | ^
a.cc:24:1: error: extended character 　 is not valid in an identifier
a.cc: In function 'int main()':
a.cc:24:1: error: '\U00003000\U00003000int64_t' was not declared in this scope
   24 | 　　int64_t ans=0;
      | ^~~~~~~~~~~
a.cc:35:12: error: 'ans' was not declared in this scope; did you mean 'abs'?
   35 |            ans+=all.at(j).first;
      |            ^~~
      |            abs
a.cc:39:10: error: 'ans' was not declared in this scope; did you mean 'abs'?
   39 |    cout<<ans<<endl;
      |          ^~~
      |          abs
Language: C++

#include <bits/stdc++.h>

typedef long long ll;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YesNo(x)      cout << ((x) ? "Yes" : "No") << endl
#define YESNO(x)      cout << ((x) ? "YES" : "NO") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )

#define pr(v) for(auto x : v) cerr << x << " "; cerr << endl;

bool f(pair<ll, ll> a, pair<ll, ll> b) {
	return (a.second > b.second)
}

int main(int argc, const char* argv[]) {
	ll n, m;
	cin >> n >> m;

	vector<ll> a(n);
	vector<pair<ll, ll>> bc(m);	
	rep(i, n) {
		cin >> a.at(i);
	}
	rep(i, m) {
		cin >> bc[i].first >> bc[i].second;
	}
	sort(bc.begin(), bc.end(), f);

	vector<ll> d;
	rep(i, m) {
		vector<ll> tmp(bc[i].first, bc[i].second);
		d.insert(d.end(), tmp.begin(), tmp.end());
		if(n <= d.size()) break;
	}

	d.insert(d.end(), a.begin(), a.end());
	sort(d.begin(), d.end(), greater<ll>());

	ll ret = 0;
	rep(i, n) {
		ret += d[i];
	}

	cout << ret << endl;
	return 0;
}


Compiler output:
a.cc: In function 'bool f(std::pair<long long int, long long int>, std::pair<long long int, long long int>)':
a.cc:19:37: error: expected ';' before '}' token
   19 |         return (a.second > b.second)
      |                                     ^
      |                                     ;
   20 | }
      | ~
Language: C++

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

#define MAX 100010
#define INF 2140000000
#define MOD 1000000007

int main() {
	int n,m;
 	cin>>n>>m;
    vector<int> a(n);
  	vector<pair<int,int>> v(m);
	for(int i=0;i<n;i++)
    {
      cin>>a[i];
    }
    for(int i=0;i<m;i++)
    {
       cin>>v[i].second>>v[i].first;
    }
    sort(a.begin(),a.end());
  	sort(v.rbegin(),v.rend());
	int k=0;
    for(int i=0;i<m;i++)
    {
      int s = v[i].second,val = v[i].first;
      
      while(k<a.size() && a[k]<val %% s--)
      {
        a[k]=val;
        k++;
      }
    }
    long long ans = 0;

	for (int i = 0; i < (int) a.size(); ++i) {
		ans += a[i];
	}

	cout << ans << endl;
     return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:48:37: error: expected primary-expression before '%' token
   48 |       while(k<a.size() && a[k]<val %% s--)
      |                                     ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
typedef long long int ll;
ll max(ll a, ll b){
    return a > b? a : b;
}
bool comp(pair<ll,ll>p1, pair<ll, ll>p2)
{
    if(p1.ff > p2.ff)
        return true;
    if(p1.ff == p2.ff)
        return p1.ss > p2.ss;
    return false;
}
int main()
{
    ll n, m;
    cin >> n >> m;
    ll a[n] = {0};
    for(int i = 0; i < n; i++)
        cin >> a[i];
    sort(a, a + n);
    vector<pair<ll, ll> >v(m);
    for(int i = 0; i < m ;i++)
        cin >> v[i].ss >> v[i].ff;
    sort(v.begin(), v.end(), comp);
    // for(auto it : v)
    //     cout << it.ff << " " << it.ss << endl;
    ll sum = 0; 
    ll x = 0;
    for(int i = 0; i < n ;i++)
    {
        if(x >= m)
            sum += a[i];
        else
        {
            sum += max(a[i], v[x].ff);
            v[x].ss--;
            if(v[x].ss == 0)
                x++;
        }
  
    }
    cout << sum << endl;


    return 0;
}-

Compiler output:
a.cc:50:2: error: expected unqualified-id before '-' token
   50 | }-
      |  ^
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main() {
  int N,M,B,C;
  int i,j;
  cin >> N >> M;
  int A[N];
  for(i=0;i<N;i++)
    cin >> A[i];
  cout << endl;
  for(i=0;i<M;i++){
    sort(A,A+N);
    cin >> B >> C;
    for(j=0;j<B;j++){
      if(A[j]<C)
        A[j]=C;
      else
        break;
      }
    }
  long s=0;
  for(i=0;i<N;i++)
    s+=A[i];
  cout << s << endl;#include <bits/stdc++.h>
using namespace std;

int main() {
  int N,M,B,C;
  int i,j,k,l;
  cin >> N >> M;
  int A[N];
  for(i=0;i<N;i++)
    cin >> A[i];
  sort(A,A+N);
  for(i=0;i<M;i++){
    k=0;
    cin >> B >> C;
    for(j=0;j<B;j++){
      if(A[j]<C){
        A[j]=C;
        k+=1;
        }
      else
        break;
      }
    if(k=B)
      for(j=k;j<N;j++){
        if(A[j]<C)
          A[j-k]=A[j],A[j]=C;
        else
          break;
      }
    }
  long s=0;
  for(i=0;i<N;i++)
    s+=A[i];
  cout << s << endl;
}

Compiler output:
a.cc:25:21: error: stray '#' in program
   25 |   cout << s << endl;#include <bits/stdc++.h>
      |                     ^
a.cc: In function 'int main()':
a.cc:25:22: error: 'include' was not declared in this scope
   25 |   cout << s << endl;#include <bits/stdc++.h>
      |                      ^~~~~~~
a.cc:25:31: error: 'bits' was not declared in this scope
   25 |   cout << s << endl;#include <bits/stdc++.h>
      |                               ^~~~
a.cc:25:36: error: 'stdc' was not declared in this scope; did you mean 'std'?
   25 |   cout << s << endl;#include <bits/stdc++.h>
      |                                    ^~~~
      |                                    std
a.cc:26:1: error: expected primary-expression before 'using'
   26 | using namespace std;
      | ^~~~~
a.cc:28:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   28 | int main() {
      |         ^~
a.cc:28:9: note: remove parentheses to default-initialize a variable
   28 | int main() {
      |         ^~
      |         --
a.cc:28:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:28:12: error: a function-definition is not allowed here before '{' token
   28 | int main() {
      |            ^
a.cc:59:2: error: expected '}' at end of input
   59 | }
      |  ^
a.cc:4:12: note: to match this '{'
    4 | int main() {
      |            ^
Language: C++

 #include "bits/stdc++.h"

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl
#define lint long long
#define yes "Yes"
#define no "No"

typedef pair<int, int> P;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m; cin>>n>>m;
    int N = n;
    vector<int> a(n);
    vector<P > p(m);
    REP(i,n){
        cin>>a[i];
    }
    sort(all(a));
    REP(i,m){
        cin>>p[i].second>>p[i].first;
    }
    sort(all(p));
    REP(i,n){
        print(i);
        if(a[i]<p[j].first&&p[j].second>0){
            a[i]=p[j].first;
            p[j].second--;
        } else if(p[j].second==0){
            if(j>0) j--;
            else break;
            if(a[i]<p[i].first&&p[j].second>0){
                a[i]=p[j].first;
                p[j].second--;
            }
            else if(a[i]<p[i].first) break; 
        } 
    }
    lint ans = 0;
    REP(i,n) ans+=a[i];
    print(ans);
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:35:19: error: 'j' was not declared in this scope
   35 |         if(a[i]<p[j].first&&p[j].second>0){
      |                   ^
Language: Java

import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		List<Integer> a = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			a.add(sc.nextInt());
		} 
		Collections.sort(a);
		List<Integer> b = new ArrayList<>();
		List<Integer> c = new ArrayList<>();
		for (int i = 0; i < m; i++) {
			b.add(sc.nextInt());
			c.add(sc.nextInt());
		}
		List<Integer> csort = new ArrayList<>(c);
		Collections.sort(csort);
		int index = 0;
		int numB = 0;
		int numA = 0;
		int count = 0;
		long ansnum = 0;
		for (int i = 0; i < m; i++) {
			numA = csort.get(m - 1 - i);
			index = c.indexOf(numA);
			c.set(index, 0);
			numB = b.get(index);
			for (int j = 0; j < numB; j++) {
				if (a.get(j + count) >= numA) {
					for (int k = 0; k < n; k++) {
						ansnum += a.get(k);
					}
					System.out.println(ansnum);
					return;
				}
				a.set(j + count, numA);
			}
			count += numB;
			if (j + 1 + count > n) {
				break;
			}
		}
		for (int k = 0; k < n; k++) {
			ansnum += a.get(k);
		}
		System.out.println(ansnum);
		return;
	}
}

Compiler output:
Main.java:42: error: cannot find symbol
			if (j + 1 + count > n) {
			    ^
  symbol:   variable j
  location: class Main
1 error
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main()
{
    int n,m; cin >> n >> m;
    vector<int> a;
    vector<int> d;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    vector<P> cb;
    for(int i = 0; i < m; i++){
        int b,c;
        cin >> b >> c;
        cb[i] = make_pair(c,b);
    }
    sort(cb.rbegin(),cb.rend());
    int cnt = 0;
    for(int i = 0; i < n; i++){
        if(cnt >= m){
            break;
        }
        if(cb[i].second == 0){
            cnt++;
            break;
        }
        if(a[i] < cb[i].first){
            a[i] = cb[i].first;
            cb[i].second--;
        }
    }
    for(int i = 0; i < n; i++){
        ans += a[i];
    }
    cout << ans;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:47:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   47 |         ans += a[i];
      |         ^~~
      |         abs
a.cc:49:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   49 |     cout << ans;
      |             ^~~
      |             abs
Language: Java

import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int M = sc.nextInt();

        ArrayList<Long> bc = new ArrayList<>();

        for (int i=0; i<N; i++){
            bc.add(sc.nextInt());
        }
        int[] B = new int[N];
        long[] C = new long[N];
        for (int i=0; i < M; i++){
            B[i] = sc.nextInt();
            C[i] = sc.nextInt();
        }
        sc.close();

        for (int i=0; i<M; i++){
            for (int j=0; j<B[i]; j++){
                bc.add(C[i]);
            }
        }

        Collections.sort(bc, Comparator.reverseOrder());

        long result=0;
        for (int i=0; i<N; i++){
            result += bc.get(i);
        }

        System .out.println(result);

    }
}

Compiler output:
Main.java:15: error: incompatible types: int cannot be converted to Long
            bc.add(sc.nextInt());
                             ^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
1 error
Language: Java

import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int M = sc.nextInt();

        ArrayList<long> bc = new ArrayList<>();

        for (int i=0; i<N; i++){
            bc.add(sc.nextInt());
        }
        int[] B = new int[N];
        long[] C = new long[N];
        for (int i=0; i < M; i++){
            B[i] = sc.nextInt();
            C[i] = sc.nextInt();
        }
        sc.close();

        for (int i=0; i<M; i++){
            for (int j=0; j<B[i]; j++){
                bc.add(C[i]);
            }
        }

        Collections.sort(bc, Comparator.reverseOrder());

        long result=0;
        for (int i=0; i<N; i++){
            result += bc.get(i);
        }

        System .out.println(result);

    }
}

Compiler output:
Main.java:12: error: unexpected type
        ArrayList<long> bc = new ArrayList<>();
                  ^
  required: reference
  found:    long
1 error