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

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<long long int> A(N);
  for(int i=0; i < N; i++){
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());

  vector<pair<long long int,long long int>> cb(M);
  for(int i=0; i < M; i++){
    long long int B, C; cin >> B >> C;
    cb.at(i) = make_pair(C, B);
  }

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

  int now = 0;
  bool flag = false;
  for(int i = 0; i < M; i++){
    for(int j = 0; j < cb.at(i).second; j++){
      if( (now+j) >= N || A.at(now+j) >= cb.at(i).first){
        flag = true;
        break;
      }
      A.at(now+j) = cb.at(i).first;
      }
    }
    now+=cb.at(i).second;
    if(flag) {
      break;
    }
  }

  long long int sum = 0;
  for(int i=0; i < N; i++){
    sum += A.at(i);
  }

  cout << sum << endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:32:16: error: 'i' was not declared in this scope
   32 |     now+=cb.at(i).second;
      |                ^
a.cc:34:7: error: break statement not within loop or switch
   34 |       break;
      |       ^~~~~
a.cc: At global scope:
a.cc:39:3: error: expected unqualified-id before 'for'
   39 |   for(int i=0; i < N; i++){
      |   ^~~
a.cc:39:16: error: 'i' does not name a type
   39 |   for(int i=0; i < N; i++){
      |                ^
a.cc:39:23: error: 'i' does not name a type
   39 |   for(int i=0; i < N; i++){
      |                       ^
a.cc:43:3: error: 'cout' does not name a type
   43 |   cout << sum << endl;
      |   ^~~~
a.cc:44:1: error: expected declaration before '}' token
   44 | }
      | ^
Language: C++

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

using namespace std;
int main(){
 int n,m,i,j;
 int count=0;
 int s=0;
 cin >> n >> m;
 vector<ulong> a(n);
vector<ulong> b(m);
vector<ulong> c(m);
for(i=0;i<n;i++){
 cin >> a[i];
}
for(i=0;i<m;i++){
 cin >> b[i] >>c[i];
}
sort(a.begin(), a.end());
for(i=0;i<m;i++){
 j=0;
 while(s==0 && count<=b[i]){
  if(a[j]<c[i]){
   a[j]=c[i];
   count +=1;
   j++;
  }else{
 s=1;
}
}
sort(a.begin(), a.end());
}
cout << accumulate(a.begin(), a.end()) <<endl;

return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:35:19: error: no matching function for call to 'accumulate(std::vector<long unsigned int>::iterator, std::vector<long unsigned int>::iterator)'
   35 | cout << accumulate(a.begin(), a.end()) <<endl;
      |         ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/numeric:62,
                 from a.cc:4:
/usr/include/c++/14/bits/stl_numeric.h:134:5: note: candidate: 'template<class _InputIterator, class _Tp> _Tp std::accumulate(_InputIterator, _InputIterator, _Tp)'
  134 |     accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)
      |     ^~~~~~~~~~
/usr/include/c++/14/bits/stl_numeric.h:134:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_numeric.h:161:5: note: candidate: 'template<class _InputIterator, class _Tp, class _BinaryOperation> _Tp std::accumulate(_InputIterator, _InputIterator, _Tp, _BinaryOperation)'
  161 |     accumulate(_InputIterator __first, _InputIterator __last, _Tp __init,
      |     ^~~~~~~~~~
/usr/include/c++/14/bits/stl_numeric.h:161:5: note:   candidate expects 4 arguments, 2 provided
Language: C++

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

using namespace std;
int main(){
 int n,m,i,j;
 int count=0;
 int s=0;
 cin >> n >> m;
 vector<ulong> a(n);
vector<ulong> b(m);
vector<ulong> c(m);
for(i=0;i<n;i++){
 cin >> a[i];
}
for(i=0;i<m;i++){
 cin >> b[i] >>c[i];
}
sort(a.begin(), a.end());
for(i=0;i<m;i++){
 j=0;
 while(s==0 && count<=b[i]){
  if(a[j]<c[i]){
   a[j]=c[i];
   count +=1;
   j++;
  }else{
 s=1;
}
}
sort(a.begin(), a.end());
}
cout << accumulate(a.begin(), a.end()) <<endl;




Compiler output:
a.cc: In function 'int main()':
a.cc:34:9: error: 'accumulate' was not declared in this scope
   34 | cout << accumulate(a.begin(), a.end()) <<endl;
      |         ^~~~~~~~~~
a.cc:34:47: error: expected '}' at end of input
   34 | cout << accumulate(a.begin(), a.end()) <<endl;
      |                                               ^
a.cc:6:11: note: to match this '{'
    6 | int main(){
      |           ^
Language: C++

#include <iostream>
#include <queue>
#include<map>
#include<functional>
#include<utility>
using namespace std;

int n;
int m;
priority_queue<int,vector<int >,greater<int> >a;
queue<int>bc;
int b[1000000];
int c[1000000];
long long ans=0;
int main(){
    cin >> n >> m;
    vector<pair<int ,int > >p(m);
    for(int i=0;i<n;i++){
        int tmp;
        cin >> tmp;
        a.push(tmp);
    }
    for(int i=0;i<m;i++){
        int tmp1,tmp2;
        cin >> tmp1 >>tmp2 ;
        p[i] = make_pair(tmp1,tmp2);
    }
    sort(p.begin(),p.end(),greater<pair<int,int> >());
    for(int i=0;i<m;i++){
        for(int j=0;j<p[i].first;j++){
            bc.push(p[i].second);
        }
        if(bc.size() == n){
            break;
        }
    }
    while(!bc.empty()){
        if(a.top()>bc.front()){
            bc.pop();
        }
        else{
            a.pop();
            a.push(bc.front());
            bc.pop();
        }
    }
    while(!a.empty()){
        ans += a.top();
        //cout << a.top() << endl;
        a.pop();
    }
    cout << ans << endl;
}

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

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

int main(){
 long long N,M,l,r,c,lm,rm,ans,k;
  cin>>N>>M;
  k=0;
  int s=0;
  ans=0;
  vector<long long>A(N),B(M),C(M);
  vector<pair<long long,long long>> pair(M);
    for(int i=0;i<N;i++){
   cin>>A[i];
  }
  sort(A.begin(),A.end());
      for(int i=0;i<M;i++){
   cin>>B[i]>>C[i];
    pair[i]=make_pair(C[i],B[i]);
  }
    sort(pair.begin(),pair.end());
  reverse(pair.begin(),pair.end());
      for(int i=0;i<M;i++){
            for(int j=0;j<pair[i].second;j++){
   if(A[k]>=pair[i].first){
goto good;
   }
	 else{
       A[k]=pair[i].first;
       k++;
     }
  }
  }
  good;
  for(int i=0;i<N;i++){
   ans+=A[i];
  }
 
       cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:33:3: error: 'good' was not declared in this scope
   33 |   good;
      |   ^~~~
a.cc:25:6: error: label 'good' used but not defined
   25 | goto good;
      |      ^~~~
Language: C++

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

int main(){
  vector<int> d;
  int n,m;
  cin >>n >>m;
  int a;
  for (int i=0; i<n; i++){
    cin >>a;
    d.push_back(a);
  }
  int b,c;
  for (int i=0; i<m; i++){
  	cin >> b >> c;
    for (int j=0; j<b; j++){
      d.puch_back(c);
    }
  }
  sort(d.begin(),d.end());
  int ans=0;
  for (int i=d.size()-1; i>=d.size()-n; i--){
    ans += d[i];
  }
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:9: error: 'class std::vector<int>' has no member named 'puch_back'; did you mean 'push_back'?
   17 |       d.puch_back(c);
      |         ^~~~~~~~~
      |         push_back
Language: C++

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

int main () {
    
    int N, M;
    cin >> N >> M;
    long long answer = 0;

    vector<int> A (N);
    vector<int> BC (2 * M);
    for (int i=0; i < N; i++){
        cin >> A .at(i);
    }
    for (int i=0; i < 2*M; i++){
        cin >> BC .at(i);
    }

    for (int i=0; i < N; i++){
        for (int l=0; l < N - 1; l++){
            if(A .at(l) < A .at(l+1)){
                int s = A.at(l);
                A.at(l) = A.at(l+1);
                A.at(l+1)=s;
            }
        }
    }

    for(int l = 0;l < M; l++){
        

        for (int i=0; i < BC .at(2 * l); i++){
            if (A .at(N - i - 1) < BC .at(2*l + 1)){
                A .at(N - i - 1) = BC .at(2*l +1);
            }
        }
        for (int b=0; b < N; b++){
            for (int c=0; c < N - 1; c++){
                if(A .at(c) < A .at(c+1)){
                    int s = A.at(c);
                    A.at(c) = A.at(c+1);
                    A.at(c+1)=s;
                }
            }
        }

    }
    
    for (int i=0; i < N; i++){
        answer += A .at(i);

        }
    }

    cout << answer << endl;
}


Compiler output:
a.cc:55:5: error: 'cout' does not name a type
   55 |     cout << answer << endl;
      |     ^~~~
a.cc:56:1: error: expected declaration before '}' token
   56 | }
      | ^
Language: C++

#include<stdio.h>
#include <vector> 
using namespace std;
 int main(){
     int N,M,i,j;
     long ans=0;
     //long A[N];
     long tmp;
     vector<long> A; 
     long B[2];
     scanf("%d %d",&N,& M);
     for(i=0;i<N;i++){
         //scanf("%d",&A[i]);
         scanf("%ld",&tmp);
         A.push_back(tmp);
     }
     for(i=0;i<M;i++){
         scanf("%ld %ld",&B[0],&B[1]);
         for(j=0;j<B[0];j++){
             A.push_back(B[1]);
         }
     }
     sort(A.begin(), A.end(), greater<int>() );
     for(i=0;i<N;i++){
         ans+=A[i];
     }
     printf("%ld\n",ans);


 }

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

#include<stdio.h>
#include <vector> 
 int main(){
     int N,M,i,j;
     long ans=0;
     //long A[N];
     long tmp;
     std::vector<long> A; 
     long B[2];
     scanf("%d %d",&N,& M);
     for(i=0;i<N;i++){
         //scanf("%d",&A[i]);
         scanf("%ld",&tmp);
         A.push_back(tmp);
     }
     for(i=0;i<M;i++){
         scanf("%ld %ld",&B[0],&B[1]);
         for(j=0;j<B[0];j++){
             A.push_back(B[1]);
         }
     }
     std::sort(A.begin(), A.end(), std::greater<int>() );
     for(i=0;i<N;i++){
         ans+=A[i];
     }
     printf("%ld",ans);


 }

Compiler output:
a.cc: In function 'int main()':
a.cc:22:11: error: 'sort' is not a member of 'std'
   22 |      std::sort(A.begin(), A.end(), std::greater<int>() );
      |           ^~~~
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <set>

using namespace std;

typedef pair<long long, long long> P;
bool pairCompare(const P& firstElof, const P& secondElof)
{
    return firstElof.second < secondElof.second;
}

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

    vector<long long> A;
    //vector<long long> D;
    for(int i=0; i<N; i++) {
        int tmp; cin >> tmp;
        A.push_back(tmp);
    }

    int B,C;
    for(int i=0; i<M; i++) {
        cin >> B >> C;
        for(int j=0; j < B; j++) {
            A.push_back(C);
        }
    }

    sort(A.begin(), A.end(), greater<int>());

    int ans = 0;
    for(int i=0; i<N; i++) {
        ans += A[i];
    }

    cout << ans << endl;

    return 0;
}



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

#include <iostream>
#include <algorithm>
#include <vector>
#include<queue>
using namespace std;
ll h[100005][2] = {0};
typedef long long ll;
priority_queue <ll,vector<ll>,greater<ll>>P;
int main()
{
	long long int n, m,a;
	cin >> n >> m;
	ll ZZ = n;
	long long int sum = 0;
	for (ll i = 1; i <= n; i++) {
		cin >> a;
		P.push(a);
	}
	for (ll i = 1; i <= n; i++) {
		h[i][0]=P.top();
		P.pop();
	}
	priority_queue <pair<ll, ll>>Q;

	for (ll i = 1; i <= m;i++) {
		long long int b, c;
		cin >> b >> c;
		Q.push(make_pair(c, b));
	}
	long long int Nsum=0;
	ll k = 1;
	while (Q.empty()==0) {

		for (ll i = 1; i <=  Q.top().second; i++) {
			h[k][1] = Q.top().first;
		//	cout << "#" << h[k][1] << endl;/////////////////////
			k++;

			if (k >= ZZ)break;
		}
		if(k>=ZZ) break;
		Q.pop();
	}

	for (ll i = 1; i <= ZZ; i++) {
		//cout << max(h[i][0], h[i][1]) << endl;
		Nsum += max(h[i][0], h[i][1]);
	}


	cout << Nsum <<endl;




}


Compiler output:
a.cc:6:1: error: 'll' does not name a type
    6 | ll h[100005][2] = {0};
      | ^~
a.cc: In function 'int main()':
a.cc:20:17: error: 'h' was not declared in this scope
   20 |                 h[i][0]=P.top();
      |                 ^
a.cc:35:25: error: 'h' was not declared in this scope
   35 |                         h[k][1] = Q.top().first;
      |                         ^
a.cc:47:29: error: 'h' was not declared in this scope
   47 |                 Nsum += max(h[i][0], h[i][1]);
      |                             ^
Language: C++

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

int main() {
    int N, M;
    int long sum = 0;
    int count = 0;
    cin >> N >> M;
    vector<long int> A(N);
    vector<pair <long int,int>> BC(M);
    vector<long int> D(0);

    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    for (int i = 0; i < M; i++) {
        cin >> BC.at(i).second >> BC.at(i).first;
    }
    sort(BC.begin(), BC.end());
    reverse(BC.begin(), BC.end());
    sort(A.begin(), A.end());

    for (int j = 0; j < M; j++) {
        for (int k = 0; k < BC.at(j).second; k++) {
            count++;
            D.push_back(BC.at(j).first);
            if (count == N) {
                break;
            }
        }
        if (count == N) {
            break;
        }
    }

    for (int i = 0; i < N; i++) {
        D.push_back(0);
    }

    for (int i = 0; i < N; i++) {
        sum += max(D.at(i), A.at(i));
    }

    cout << sum << endl;
}

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

#include <cstdio>
#include <iostream>
#include <vector>

struct Kakikae
{
public:
    long b, c;
    bool operator<(const Kakikae& e) const{
        return c > e.c;
    }
};

int main()
{
    int N, M;
    std::vector<long> A;
    std::vector<Kakikae> BC;
    scanf("%d %d", &N, &M);
    A.resize(N);
    BC.resize(M);
    for(int i=0; i<N; i++)
        scanf(" %ld", &A[i]);
    for(int i=0; i<M; i++)
        scanf(" %ld %ld", &BC[i].b, &BC[i].c);

    std::sort(A.begin(), A.end());
    std::sort(BC.begin(), BC.end());
    
    int index = 0;
    for(int i=0; i<M; i++){
        if(index >= N) break;
        if(A[index] >= BC[i].c) break;
        for(int j=0; j<BC[i].b; j++){
            if(index >= N) break;
            if(A[index] >= BC[i].c) break;
            A[index] = BC[i].c;
            index++;
        }
    }

    long sum = 0;
    for(int i=0; i<N; i++){
        sum += A[i];
    }
    printf("%ld\n", sum);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:27:10: error: 'sort' is not a member of 'std'; did you mean 'qsort'?
   27 |     std::sort(A.begin(), A.end());
      |          ^~~~
      |          qsort
a.cc:28:10: error: 'sort' is not a member of 'std'; did you mean 'qsort'?
   28 |     std::sort(BC.begin(), BC.end());
      |          ^~~~
      |          qsort
Language: C++

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,M;
    cin >> N >> M;
    vector<ll> A(N);
    vector<pair<ll,ll>> B(M);
    REP(i,N)cin >> A.at(i);
    REP(i,M){
        int x,y;
        cin >> x;
        cin >> y;
        B.at(i) = make_pair(y,x);
    }
    sort(B.rbegin(),B.rend());
    sort(A.begin(),A.end());
    int x = 0;
    bool ok =0;
    REP(i,M){
        REP(l,B.at(i).second){
            if(A.at(x)<B.at(i).first){
                A.at(x) = B.at(i).first;
                x++;
                if(x >= N)ok = 1;
            }else{
                ok = 1;
            if(ok == 1)break;
        }
        if(ok == 1)break;
    }
    ll answer = 0;
    REP(i,N)answer+=A.at(i);
    cout <<answer<< "\n";
}


Compiler output:
a.cc: In function 'int main()':
a.cc:39:2: error: expected '}' at end of input
   39 | }
      |  ^
a.cc:6:11: note: to match this '{'
    6 | int main(){
      |           ^
Language: C++

#include <cstdio>
#include <cstdlib>
#include <vector>

struct kakikae
{
public:
    long b, c;
    bool operator<(const kakikae& e) const{
        return c > e.c;
    }
};

int main()
{
    int N, M;
    std::vector<long> A;
    std::vector<kakikae> BC;
    scanf("%d %d", &N, &M);
    A.resize(N);
    BC.resize(M);
    for(int i=0; i<N; i++)
        scanf(" %ld", &A[i]);
    for(int i=0; i<M; i++)
        scanf(" %ld %ld", &BC[i].b, &BC[i].c);

    std::sort(A.begin(), A.end());
    std::sort(BC.begin(), BC.end());
    
    int index = 0;
    for(int i=0; i<M; i++){
        if(index >= N) break;
        if(A[index] >= BC[i].c) break;
        for(int j=0; j<BC[i].b; j++){
            if(index >= N) break;
            if(A[index] >= BC[i].c) break;
            A[index] = BC[i].c;
            index++;
        }
    }

    long sum = 0;
    for(int i=0; i<N; i++){
        sum += A[i];
    }
    printf("%ld\n", sum);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:27:10: error: 'sort' is not a member of 'std'; did you mean 'qsort'?
   27 |     std::sort(A.begin(), A.end());
      |          ^~~~
      |          qsort
a.cc:28:10: error: 'sort' is not a member of 'std'; did you mean 'qsort'?
   28 |     std::sort(BC.begin(), BC.end());
      |          ^~~~
      |          qsort
Language: C++


if __name__ == '__main__':
    n,m = list(map(int, input().split()))
    a = list(map(int, input().split()))
    bc = []
    for i in range(m):
        bc.append(list(map(int, input().split())))

    bc.sort(key=lambda x: x[1], reverse=True)
    a.sort()

    bcn = 0
    for i in range(n):
        if(a[i] < bc[bcn][1]):
            a[i] = bc[bcn][1]
            bc[bcn][0] -= 1
            if(bc[bcn][0] == 0):
                bcn += 1
                if(bcn == m):
                    break

    print(sum(a))


Compiler output:
a.cc:2:16: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes
    2 | if __name__ == '__main__':
      |                ^~~~~~~~~~
a.cc:2:1: error: expected unqualified-id before 'if'
    2 | if __name__ == '__main__':
      | ^~
Language: Java

import java.io.Serializable;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.Objects;
import java.util.PriorityQueue;
import java.util.Scanner;

import atcoder.abc127.f.Main.Problem.Sushi;

public class Main {

	/**
	 * problem solver
	 */
	public static class Problem {

		/**
		 * paramters
		 */
		private int n;
		private int m;
		private ArrayList<Long> a;
		private ArrayList<Long> c;
		private ArrayList<Integer> b;

		/**
		 * constructor
		 */
		Problem() {
			a = new ArrayList<Long>();
			c = new ArrayList<Long>();
			b = new ArrayList<Integer>();
			n = 0;
			m = 0;
		}

		/**
		 * standard input
		 */
		void input() {
			Scanner sc = new Scanner(System.in);
			n = sc.nextInt();
			m = sc.nextInt();

			for (int i = 0; i < n; i++) {
				a.add(sc.nextLong());
			}
			
			for (int i = 0; i < m; i++) {
				b.add(sc.nextInt());
				c.add(sc.nextLong());
			}
			sc.close();
		}


		public static class Bc implements Comparable<Bc>, Serializable {

			private static final long serialVersionUID = 7126883977005996870L;

			public int b;
			public long c;

			Bc(int b, long c) {
				this.b = b;
				this.c = c;
			}

//            @Override
//            public int hashCode() {
//            	return Objects.hash(t,d);
//            }

			@Override
			public boolean equals(Object other) {
				if (other == this) {
					return true;
				}

				if (other instanceof Bc) {
					Bc that = (Bc) other;
					return Objects.equals(that.b, this.b) && Objects.deepEquals(that.c, this.c);
				}
				return false;
			}

			@Override
			public int compareTo(Bc that) {
				Comparator<Long> naturalOrder = Comparator.naturalOrder();
				return Objects.compare(this.c, that.c, naturalOrder);
			}

			@Override
			public String toString() {
				Object[] params = { b, c };
				MessageFormat mf = new MessageFormat("({0},{1})");
				return mf.format(params);
			}
		}
		

		/**
		 * solver
		 */
		void solve() {
			PriorityQueue<Long> pque = new PriorityQueue<>();
			ArrayList<Bc> bcs = new ArrayList<>();
			ArrayList<Long> candidates = new ArrayList<>();

			for (Long e : a) {
				pque.add(e);
			}
			
			for (int i =0; i < m;i++) {
				Bc bc = new Bc(b.get(i), c.get(i));
				bcs.add(bc);				
			}
			
			Collections.sort(bcs, Collections.reverseOrder());
			
			
			for(Bc bc : bcs) {
				for(int i=0;i<bc.b;i++) {
					candidates.add(bc.c);
					
					if(candidates.size() == n) {
						break;
					}
				}
				if (candidates.size() == n) {
					break;
				}
			}

			for(long l: candidates) {
				long amin = pque.peek();
				if (amin < l) {
					pque.poll();
					pque.add(l);
				}
			}
			
			
			long ans = 0;
			for (long e: pque) {
				ans += e;
			}
			
			System.out.println(ans);

		}

	}

	public static void main(String args[]) {

		Problem p = new Problem();

		p.input();

		p.solve();
	}
}


Compiler output:
Main.java:12: error: package atcoder.abc127.f.Main.Problem does not exist
import atcoder.abc127.f.Main.Problem.Sushi;
                                    ^
1 error
Language: C++

#include <cstdio>
#include <cstdlib>
#include <vector>

struct kakikae
{
public:
    long b, c;
    bool operator<(const kakikae& e) const{
        return c > e.c;
    }
};

int main()
{
    int N, M;
    std::vector<long> A;
    std::vector<kakikae> BC;
    scanf("%d %d", &N, &M);
    A.resize(N);
    BC.resize(M);
    for(int i=0; i<N; i++)
        scanf(" %ld", &A[i]);
    for(int i=0; i<M; i++)
        scanf(" %ld %ld", &BC[i].b, &BC[i].c);

    sort(A.begin(), A.end());
    sort(BC.begin(), BC.end());
    
    int index = 0;
    for(int i=0; i<M; i++){
        if(index >= N) break;
        if(A[index] >= BC[i].c) break;
        for(int j=0; j<BC[i].b; j++){
            if(index >= N) break;
            if(A[index] >= BC[i].c) break;
            A[index] = BC[i].c;
            index++;
        }
    }

    long sum = 0;
    for(int i=0; i<N; i++){
        sum += A[i];
    }
    printf("%ld\n", sum);
}


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

#include <iostream>
#include <string>
#include <cstring>
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#define int long long
using namespace std;
signed main(){
    int n,m;
    cin>>n>>m;
    int a[114514];
    for(int i=0;i<n;i++)cin>>a[i];
    vector<pair<int,int> > b(m);
    for(int i=0;i<m;i++){
        int k,l;
        cin>>k>>l;
        b[i]=make_pair(l, k);
    }
    sort(a,a+n);
    sort(b.begin(),b.end());
    reverse(b.begin(),b.end());
    int c=0;
    while(1){
        int i=0;
        bool fin=false;
        while(1){
            if(b[i].second>0)break;
            else if(b[m-1].second==0){
                fin=true;
                break;
            }else{
                i++;
            }
        }
        if(fin==true)break;
        if(a[c]=>b[i].first)break;
        else a[c]=b[i].first;
        b[i].second--;
        c++;
        
    }
    int ans=0;
    for(int i=0;i<n;i++)ans+=a[i];
    cout<<ans<<endl;
    return 0;
}


















Compiler output:
a.cc: In function 'int main()':
a.cc:43:17: error: expected primary-expression before '>' token
   43 |         if(a[c]=>b[i].first)break;
      |                 ^
Language: C++

#include <iostream>
#include<algorithm>
using namespace std;

long binarySearch(long arr[], long l, long r, long x) 
{ 
    long n=r;
    while (r >= l) { 
        int mid = l + (r - l) / 2; 
        if (arr[mid] == x) 
            return mid-1; 
        if (arr[mid] > x) 
         r= mid - 1;
         else
        if(arr[mid]<x) 
           l= mid + 1; 
        if(arr[mid]>x && arr[mid-1]<x && mid!=l)
         return mid-1;
        if(arr[mid]<x && x<arr[mid+1])
         return mid;
        if(l==n)
        return n;
    } 
  
    // We reach here when element is not 
    // present in array 
    return -1; 
} 
int main() {
    long n,m;
    cin>>n>>m;
    long a[n];
    for(long i=0;i<n;i++)
    cin>>a[i];
    sort(a,a+n);
    //long max=0;
    pair<long,long> p[m];
// max.first=0;
    for(long i=0;i<m;i++)
    {
       cin>>p[i].second>>p[i].first;
     }
    sort(p,p+m);
    long t=0,pm=0,
  long long s=0;
    for(long i=0;i<m;i++)
    {
       pm=binarySearch(a,t,n-1,p[m-i-1].first);
      // cout<<p[m-i-1].first<<" "<<pm<<endl;
       if(pm==-1) break;
     if((pm-t+1)<=p[m-i-1].second)
        {
            s+= (p[m-i-1].second-(pm-t+1)+1)*p[i].first;
            t+=p[m-i-1].second-(pm-t+1)+1;
            //cout<<"last="<<p[m-i-1].first<<"  "<<s<<endl;
            break;
        }
    else {
        s+= p[m-i-1].second * p[m-1-i].first;
          t+= p[m-1-i].second;
         // cout<<"--)"<<p[m-i-1].first<<" "<<s<<endl;
    }
}
for(long i=t;i<n;i++){
    s+=a[i];
}
cout<<s;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:45:3: error: expected unqualified-id before 'long'
   45 |   long long s=0;
      |   ^~~~
a.cc:53:13: error: 's' was not declared in this scope
   53 |             s+= (p[m-i-1].second-(pm-t+1)+1)*p[i].first;
      |             ^
a.cc:59:9: error: 's' was not declared in this scope
   59 |         s+= p[m-i-1].second * p[m-1-i].first;
      |         ^
a.cc:65:5: error: 's' was not declared in this scope
   65 |     s+=a[i];
      |     ^
a.cc:67:7: error: 's' was not declared in this scope
   67 | cout<<s;
      |       ^
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;

int main()
{
    int n,m;
    cin >> n >> m;
    int a[n];
    ll ans = 0;
    vector<int> v;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a,a+n);
    for(int i = 0; i < m; i++){
        int b,c;
        cin >> c >> b;
        for(int j = 0; j < c; j++){
            v.push_back(b);
            if(v.size() == n) break;
        }
    }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    for(int i = 0; i < n; i++){
        if(a[i] < v[i]){
            ans += v[i;
            cnt++;
        }else{
            ans += a[i];
        }
    }
    cout << ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:23: error: expected ']' before ';' token
   39 |             ans += v[i;
      |                       ^
      |                       ]
a.cc:40:13: error: 'cnt' was not declared in this scope; did you mean 'int'?
   40 |             cnt++;
      |             ^~~
      |             int
Language: C++

#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
using namespace std;
#define REP(i,n); for(int i = 0;i < (int)(n);i++)

int main() {
	vector<pair<int,int>> so;
	vector<int> a;
	long long ans=0;
	int n,m,count=0;
	cin >> n >> m;
	a.resize(n);
	so.resize(m);
	REP(i,n){
		cin >> a[i];
	}
	REP(i,m){
		cin >> so[i].second >> so[i].first;
	}
	sort(a.begin(),a.end(),greater<int>());
	sort(so.begin(),so.end(),greater<pair<int,int>>());
	int j=0;
	int su=0;
	while(su < n){
		REP(i,so[j].second){
			a.push_back(so[j].first);
		}
		su += so[i].second;
		j++;
	}	
	sort(a.begin(),a.end(),greater<int>());
	REP(i,n){
		ans += a[i];
	}
	cout << ans;
	return(0);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:26: error: 'i' was not declared in this scope
   35 |                 su += so[i].second;
      |                          ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int A[100100];
pair<int,int> BC[100100];
int main()
{
	int N,M;
	scanf("%d%d",&n,&m);
	for(int i=0;i<N;i++)
		scanf("%d",A+i);
	for(int i=0;i<M;i++)
		scanf("%d",&BC[i].first,&BC[i].second);
	sort(BC,BC+M);
	reverse(BC,BC+M);
	for(int i=0;i<M;i++)
	{
		sort(A,A+N);
		int j;
		for(j=0;j<BC[i].second;j++)
		{
			if(A[j]>=BC[i].first)
				break;
			A[j]=BC[i].first;
		}
		if(!j)
			break;
	}
	long long Sum=0;
	for(int i=0;i<N;i++)
		Sum+=A[i];
	cout<<Sum<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:23: error: 'n' was not declared in this scope
    8 |         scanf("%d%d",&n,&m);
      |                       ^
a.cc:8:26: error: 'm' was not declared in this scope
    8 |         scanf("%d%d",&n,&m);
      |                          ^
Language: C

#include<stdio.h>

int main() {
	int n, m, b, c, tmp, i, k;
	int a[100000] = { 0 };
	int j = 0;
	scanf_s("%d%d", &n, &m);

	scanf_s("%d", &a[0]);

	for (i = 1; i < n; ++i) {
		scanf_s("%d", &a[i]);
		int h = i;
		while (a[h] < a[h - 1] && h > 0) {
			tmp = a[h];
			a[h] = a[h - 1];
			a[h - 1] = tmp;
			--h;
			
		}
		if (a[1] < a[0]) {
			tmp = a[0];
			a[0] = a[1];
			a[1] = tmp;
		}
	}

	for (int i = 0; i < m; ++i) {
		scanf_s("%d%d", &b, &c);
		for (k = 0; k < b; ++k) {
			if (a[k] < c)
				a[k] = c;
		}
		
		while (a[k] <= c && k < n) {
			tmp = a[k];
			a[k++] = a[j];
			a[j++] = tmp;
		}
	}
	int sum = 0;
	for (i = 0; i < n; ++i)
		sum += a[i];

	printf("%d\n", sum);


		return 0;
}

Compiler output:
main.c: In function 'main':
main.c:7:9: error: implicit declaration of function 'scanf_s'; did you mean 'scanf'? [-Wimplicit-function-declaration]
    7 |         scanf_s("%d%d", &n, &m);
      |         ^~~~~~~
      |         scanf
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>


using namespace std;
#define ll long long


int main(void){
    ll N,M;
    cin>>N>>M;
    vector<ll> A(N),B(M),C(M);
    vector<pair<ll,ll>> CB(M);
    for(ll i=0;i<N;i++) cin>>A.at(i);
    for(ll i=0;i<M;i++) {
        cin>>B.at(i)>>C.at(i);
        CB.at(i)=make_pair(C.at(i),B.at(i))
    }
    
    sort(A.begin(),A.end());
    sort(CB.begin(),CB.end());
    
    for(ll i=0;i<M;i+=0){
        ll j=1;
        while(C.at(i)==C.at(i+j)){
            B.at(i)+=B.at(i+j);
            B.at(i+j)=0;
            C.at(i+j)=0;
            j++;
        }
        i+=j;
    }
    sort(CB.begin(),CB.end());
    reverse(CB.begin(),CB.end());
    
    for(ll i=0;i<M;i++){
        if(C.at(i)<=A.at(0)) break;
        for(ll j=0;j<B.at(i);j++){
            if(A.at(j)<C.at(i)) A.at(j)=C.at(i);
            else break;
        }
        sort(A.begin(),A.end());
    }
    ll ans=0;
    for(ll i=0;i<N;i++) ans+=A.at(i);
    cout<<ans<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:23:44: error: expected ';' before '}' token
   23 |         CB.at(i)=make_pair(C.at(i),B.at(i))
      |                                            ^
      |                                            ;
   24 |     }
      |     ~
Language: C++

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
constexpr ll MOD = 1000000007LL;

int main(void) {
    int N, M;
    cin >> N >> M;
    vector<ll> A(N,0);
    for (int i=0;i<N;i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    vector<int> B(M);
    vector<ll> C(M);
    for (int j=0;j<M;j++) {
        cin >> B[j] >> C[j];
    }
    for (int j=0;j<M;j++) {
        auto itr = lower_bound(A.begin(), A.end(), C[j]);
        int dist = min(B[j], (int)(itr - A.begin()));
        if (dist > 0) {
            for (int i=0;i<dist;i++) A[i] = C[j];
            auto itr2 = upper_bound(A.begin(), A.end(), C[j])
            sort(A.begin(), itr2);
        }
    }

    ll Y = accumulate(A.begin(), A.end(), 0LL);
    cout << Y << endl;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:34:13: error: expected ',' or ';' before 'sort'
   34 |             sort(A.begin(), itr2);
      |             ^~~~
Language: Java

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

public class Atcoder{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n,m;
		long[] a;
		long b;
		long c;
		long sum=0;

		n=sc.nextInt();
		m=sc.nextInt();
		a = new long[n];

		for(int i=0; i<a.length; i++){
			a[i] = sc.nextLong();
		}
		Arrays.sort(a);

		for(int i=0; i<m; i++){
			b = sc.nextLong();
			c = sc.nextLong();
			for(int j=0; j<b; j++){
				if(a[j]<c){ a[j]=c; }
				else {break;}
			}
			Arrays.sort(a);
		}
		for(int i=0; i<a.length; i++){
			sum += a[i];
		}
		System.out.println(sum);
	}
}

Compiler output:
Main.java:4: error: class Atcoder is public, should be declared in a file named Atcoder.java
public class Atcoder{
       ^
1 error
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin >> N >> M;
  vector<int> A(N);
  for(int i=0;i<N;i++){
 cin >> A.at(i);
  }  
sort(A.begin(), A.end());
  vector<int> B(M);
  vector<int> C(M);
  for(int i=0;i<M;i++){
 cin >> B.at(i) >> C.at(i);
  } 
  int a=0;
for(int i=0;i<M;i++){
a+=B.at(i)
}
 vector<int> (N+a);
for(int i=0;i<N;i++) {
D.at(i)=A.at(i);
}
for(int i=0;i<M;i++) {
D.at(N+a-1)=
}
 
}
}if(A.at(i)<C.at(j)){
A.at(i)=C.at(j);
sort(A.begin(), A.end());
  int a=0;
  for(int i=0;i<N;i++){
  a+=A.at(i);
  }
  cout << a << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:11: error: expected ';' before '}' token
   18 | a+=B.at(i)
      |           ^
      |           ;
   19 | }
      | ~          
a.cc:22:1: error: 'D' was not declared in this scope
   22 | D.at(i)=A.at(i);
      | ^
a.cc:25:1: error: 'D' was not declared in this scope
   25 | D.at(N+a-1)=
      | ^
a.cc:26:1: error: expected primary-expression before '}' token
   26 | }
      | ^
a.cc: At global scope:
a.cc:29:1: error: expected declaration before '}' token
   29 | }if(A.at(i)<C.at(j)){
      | ^
a.cc:29:2: error: expected unqualified-id before 'if'
   29 | }if(A.at(i)<C.at(j)){
      |  ^~
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
int N,M;
cin>>N>>M;
vector<ll>A(N),B(M),C(M);
vector<P> Q(M);
for(int s=0;s<N;s++){
        cin>>A.at(s);
}
for(int t=0;t<M;t++){
        cin>>B.at(t)>>C.at(t);
        Q.at(i)=P(C.at(t),B.at(t));
}
sort(Q.begin(),Q.end());
reverse(Q.begin(),Q.end());
sort(A.begin(),A.end());
ll sum=0,S=0,T=0;
int j=0;
for(int i=0;i<M;i++){
      S=Q.at(i).second;
      T=Q.at(i).first;
      if(A.at(j)>T ||j>=N) break;
      while(S>0 &&j<N){
          if(A.at(j)<T && j<N){
              A.at(j)=T;
              S--;
          }
          else break;
          j++;
      }
}
for(int k=0;k<N;k++){
    sum+=A.at(k);
}
cout<<sum<<endl;
return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:18:14: error: 'i' was not declared in this scope
   18 |         Q.at(i)=P(C.at(t),B.at(t));
      |              ^
Language: C

#include <stdio.h>

int* bubbleSort(int* N, int len){
  int i,j;

  for(i=0; i<len; i++){
    for(j=len-1; j>i; j--){
      if(N[j] < N[j-1]){
        temp = N[j];
        N[j] = N[j-1];
        N[j-1] = temp;
      }
    }
  }

  return N;
}

int main(void){
    int N,M;
    scanf("%d %d".&N,&M);
    int* a = new int[N];
    int i = 0;
    int j;
    for (i = 0; i < N; i++){
        scanf("%d", &a[i]);
    }
    
    int B, C;
    for (i = 0; i < M; i++){
        a = bubbleSort(a,N);
        scanf("%d %d".&B,&C);
        for(j = 0;j < B;j++){
            if(A[j] < C){
                A[j] = C
            } else {
                break;
            }
        }
    }
    ans = [0]
    for (i = 0; i < N; i++){
        ans += a[i]
    }
    printf("%d,ans");    
}



Compiler output:
main.c: In function 'bubbleSort':
main.c:9:9: error: 'temp' undeclared (first use in this function)
    9 |         temp = N[j];
      |         ^~~~
main.c:9:9: note: each undeclared identifier is reported only once for each function it appears in
main.c: In function 'main':
main.c:21:19: error: expected identifier before '&' token
   21 |     scanf("%d %d".&N,&M);
      |                   ^
main.c:22:14: error: 'new' undeclared (first use in this function)
   22 |     int* a = new int[N];
      |              ^~~
main.c:22:18: error: expected ',' or ';' before 'int'
   22 |     int* a = new int[N];
      |                  ^~~
main.c:32:23: error: expected identifier before '&' token
   32 |         scanf("%d %d".&B,&C);
      |                       ^
main.c:34:16: error: 'A' undeclared (first use in this function)
   34 |             if(A[j] < C){
      |                ^
main.c:35:25: error: expected ';' before '}' token
   35 |                 A[j] = C
      |                         ^
      |                         ;
   36 |             } else {
      |             ~            
main.c:41:5: error: 'ans' undeclared (first use in this function)
   41 |     ans = [0]
      |     ^~~
main.c:41:11: error: expected expression before '[' token
   41 |     ans = [0]
      |           ^
Language: C++

#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;

//#define int long long
//using ll = boost::multiprecision::cpp_int;
using ll = long long;
//const int INF = 1e9;//INT_MAX=1<<31-1=2147483647
const ll INF = (ll)1e18;//1<<63-1=9223372036854775807
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var) std::cout<<var<<std::endl
#define PI (acos(-1))
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(ll i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define pb push_back
inline bool isnatural(double a) { return a>=0 && ceil(a)==floor(a); }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/

const ll N_MAX = 100000;
const ll M_MAX = 100000;
const ll C_I_MAX = 1000000000;

ll N, M;

priority_queue<ll, vector<ll>, greater<ll> > que;
vector<ll> v;
ll ans=0;
void input() {
	scanf("%lld%lld", &N, &M);
	v=vector<ll>(N,0);
	rep(i, N) {
		ll a;
		cin >>a;
		v[i]=a;
		ans+=a;
	}


}

void solve() {

	
	rep(i,M){
		ll count,num;
		cin >>count>>num;
		rep(i,count)v.pb(num);
	



		
	}
	ll aaa=0
	sort(v.begin(), v.end(), greater<int>());
	rep(i,N){aaa+=v[i];}
	/*
	while(!que.empty()){
		ll t=que.top();que.pop();
		ans+=t;
	}
	*/
	printf("%lld\n", aaa);
}

signed main() {
	input();
	solve();
	return 0;
}


Compiler output:
a.cc:2:10: fatal error: boost/multiprecision/cpp_int.hpp: No such file or directory
    2 | #include <boost/multiprecision/cpp_int.hpp>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>

#define ll long long

using namespace std;

int main(){

    int n,m;
    vector<ll> a;

    cin >> n >> m;

    for(int i = 0; i < n; i++){
        ll tmp;
        cin >> tmp;
        a.push_back(tmp);
    }

    for(int i = 0; i < m; i++){
        int b;
        ll c;
        cin >> b >>c;
        for(int j = 0; j < b; j++){
            a.push_back(c);
        }
    }

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

    ll sum = 0;

    for(int i = 0; i < n; i++){
        sum = sum + a[a.size()- i - 1]
    }

    cout << sum << endl;

    return 0;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:38:39: error: expected ';' before '}' token
   38 |         sum = sum + a[a.size()- i - 1]
      |                                       ^
      |                                       ;
   39 |     }
      |     ~
Language: C

#include<stdio.h>
#include<stdlib.h>



int main(void) {
	int N, M, i, j, *a, *b, *c, tmp, tmp2, cnt = 0;
	long int total = 0;
	scanf("%d %d", &N, &M);
	a = (int *)malloc(sizeof(int) * N);
	b = (int *)malloc(sizeof(int) * M);
	c = (int *)malloc(sizeof(int) * M);

	for (i = 0; i < N; i++) {
		scanf("%d", &a[i]);
	}
	for (i = 0; i < M; i++) {
		scanf("%d %d", &b[i], &c[i]);
	}

	/* 数値を昇順にソート */
	for (i = 0; i < N; ++i) {
		for (j = i + 1; j < M; ++j) {
			if (a[i] < a[j]) {
				tmp =  a[i];
				a[i] = a[j];
				a[j] = tmp;
			}
		}
	}

	for (i = 0; i < M; ++i) {
		for (j = i + 1; j < M; ++j) {
			if (c[i] < c[j]) {
				tmp =  c[i];
				c[i] = c[j];
				c[j] = tmp;

				tmp2 =  b[i];
				b[i] = b[j];
				b[j] = tmp2;
			}
		}
	}
	j = 0;

	for (i = 0; i < M; i++) {
		if (c[i] > a[j]) {
			for (k = 0; k < b[i]; k++) {
				if (N > 0) {
					total +=c[i];
					N--;
				}
				else{
					break;
				}
			}
		}
		else {
			total+=a[j];
			j++;
			N--;
		}
	}

	printf("%ld",total);


	return 0;
}



Compiler output:
main.c: In function 'main':
main.c:49:30: error: 'k' undeclared (first use in this function)
   49 |                         for (k = 0; k < b[i]; k++) {
      |                              ^
main.c:49:30: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin >>N>>M;
  vector<int>A;
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  vector<vector<int>>data(M,vector<int>(2));
  for(int i=0;i<M;i++){
    for(int j=0;j<2;j++){
      cin>>data.at(i).at(j);
    }
  }
  
  for(int i=0;i<M;i++){
    for(int k=0;k<data.at(i).at(0);k++){
      sort(A.begin(),A.end())
      for(int i=0;i<data.at(i).at(0);i++){
        A.at(i)=data.at(i).at.(1);
      }
    }
  }
  
  int answer=0;
  for(int i=0;i<N;i++){
    answer+=A.at(i);
  }
  cout << answer <<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:30: error: expected ';' before 'for'
   19 |       sort(A.begin(),A.end())
      |                              ^
      |                              ;
   20 |       for(int i=0;i<data.at(i).at(0);i++){
      |       ~~~                     
a.cc:20:41: error: expected ';' before ')' token
   20 |       for(int i=0;i<data.at(i).at(0);i++){
      |                                         ^
      |                                         ;
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdio>
#define REP(i, n) for (int i = 0; i < (n); i++)

int A[N], B[M], C[M];
int S[sum + N];
 
using namespace std;
 
int main() {
    int N, M;
    cin >> N >> M;
    long sum = 0;
    long long ans = 0;
    for (int i = 0; i < N; i++)
        cin >> A[i];
    for (int i = 0; i < M; i++){
        cin >> B[i] >> C[i];
        sum += B[i];
    }
 
    for (int i = 0; i < N; i++)
        S[i] = A[i];
    int j = N;
    for (int i = 0; i < M; i++){
        while (B[i] > 0) {
            S[j] = C[i];
            B[i]--;
            j++;
        }
    }
    sort(S, S + N + sum, std::greater<>());
    for (int i = 0; i < N; i++){
        ans += S[i];
    }
    cout << ans << endl;
}


Compiler output:
a.cc:8:7: error: 'N' was not declared in this scope
    8 | int A[N], B[M], C[M];
      |       ^
a.cc:8:13: error: 'M' was not declared in this scope
    8 | int A[N], B[M], C[M];
      |             ^
a.cc:8:19: error: 'M' was not declared in this scope
    8 | int A[N], B[M], C[M];
      |                   ^
a.cc:9:7: error: 'sum' was not declared in this scope
    9 | int S[sum + N];
      |       ^~~
a.cc:9:13: error: 'N' was not declared in this scope
    9 | int S[sum + N];
      |             ^
a.cc: In function 'int main()':
a.cc:19:16: error: 'A' was not declared in this scope
   19 |         cin >> A[i];
      |                ^
a.cc:21:16: error: 'B' was not declared in this scope
   21 |         cin >> B[i] >> C[i];
      |                ^
a.cc:21:24: error: 'C' was not declared in this scope
   21 |         cin >> B[i] >> C[i];
      |                        ^
a.cc:26:9: error: 'S' was not declared in this scope
   26 |         S[i] = A[i];
      |         ^
a.cc:26:16: error: 'A' was not declared in this scope
   26 |         S[i] = A[i];
      |                ^
a.cc:29:16: error: 'B' was not declared in this scope
   29 |         while (B[i] > 0) {
      |                ^
a.cc:30:13: error: 'S' was not declared in this scope
   30 |             S[j] = C[i];
      |             ^
a.cc:30:20: error: 'C' was not declared in this scope
   30 |             S[j] = C[i];
      |                    ^
a.cc:35:10: error: 'S' was not declared in this scope
   35 |     sort(S, S + N + sum, std::greater<>());
      |          ^
Language: C++

#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>

using namespace std;
typedef long long ll;

int gcd(int x, int y) {
  if (x < y) swap(x, y);
  while (y > 0) {
    int r = x % y;
    x = y;
    y = r;
  }
  return x;
}

/*迷路
const int INF = 50;

typedef pair<int,int> P;
char field[52][52];
int d[51][51];
int r,c;
int sx,sy;
int gx,gy;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int bfs(){
    queue<P> que;
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            d[i+1][j+1] = INF;
        }
    }
    que.push(P(sy,sx));
    d[sy][sx]=0;
while(que.size()){
    P p=que.front();
    que.pop();
    if(p.second==gx&&p.first==gy) break;
    for(int i=0;i<4;i++){
        int nx=p.second+dx[i];
        int ny=p.first+dy[i];

        if(1<=nx&&nx<=c&&1<=ny&&ny<=r&&field[ny][nx]!='#'&&d[ny][nx]==INF){
            que.push(P(ny,nx));
            d[ny][nx] = d[p.first][p.second] + 1;
        }
    }
}
return d[gy][gx];
}
*/

int main(){
  int n,m,tmp;
  cin>>n>>m;
  long a[n];
  for(int i = 0;i<n; i++) cin>>a[i];
  int b[m];
  long c[m];
 vector<pair<int,int> > v(m);
  for(int i = 0; i<m;i++) {
      cin>>b[i]>>c[i];
  }
  for(int i = 0; i<m;i++) {
      for(int j = i+1; j<m;j++){
          if(c[i]>c[j]){
              tmp = c[i];
              c[i] = c[j];
              c[j] = tmp;
              tmp = b[i];
              b[i] = b[j];
              b[j] = tmp;
          }
      }
  }
  
  sort(a,a+n);
  int checker = -1;
  int sum = 0;
  for(int i = 0; i<n;i++){
      if(a[i]<c[m-1]) checker = i;
      else sum+=a[i];
  }
  while(checker+1>0){
      for(int i = m-1; i>=0;i--){
          if(checker+1<b[i]) sum += (checker+1)*c[i]; checker=0;
          else sum+=b[i]*c[i]; checker-=b[i];
      }
  }
  cout<<sum<<endl;
return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:100:11: error: 'else' without a previous 'if'
  100 |           else sum+=b[i]*c[i]; checker-=b[i];
      |           ^~~~