criyle/codenet-compile-errors huggingface dataset:
Language: Java

import java.util.*;
public class Replacing {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        long n = in.nextLong();
        long sum = 0;
        long i = 0;
        HashMap<Long , Long> map = new HashMap<>();
        for(i = 0; i < n ; i++){
            long ai = in.nextLong();
            if(map.containsKey(ai)) {
                Long f = map.get(ai);
                map.remove(ai);
                map.put(ai , f+1);
            } else {
                Long one = new Long(1);
                map.put(ai , one);
            }
            sum = sum + ai;
        }
        long q = in.nextInt();
        for(i = 0 ; i < q; i++){
            long bi = in.nextLong();
            long ci = in.nextLong();
            if(map.containsKey(bi)){
                long f = map.get(bi);
                sum = sum - bi*f;
                sum = sum + ci*f;
                map.remove(bi);
                if(map.containsKey(ci)){
                    f += map.get(ci);
                    map.remove(ci);
                }
                map.put(ci,f);
            }
            System.out.println(sum);
        }
    }
}


Compiler output:
Main.java:2: error: class Replacing is public, should be declared in a file named Replacing.java
public class Replacing {
       ^
Main.java:16: warning: [removal] Long(long) in Long has been deprecated and marked for removal
                Long one = new Long(1);
                           ^
1 error
1 warning
Language: Java

import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        long n = in.nextLong();
        long sum = 0;
        long i = 0;
        HashMap<Long , Long> map = new HashMap<>();
        for(i = 0; i < n ; i++){
            long ai = in.nextLong();
            if(map.containsKey(ai)) {
                Long f = map.get(ai);
                map.remove(ai);
                map.put(ai , f+1);
            } else {
                map.put(ai , 1);
            }
            sum = sum + ai;
        }
        long q = in.nextInt();
        for(i = 0 ; i < q; i++){
            long bi = in.nextLong();
            long ci = in.nextLong();
            if(map.containsKey(bi)){
                long f = map.get(bi);
                sum = sum - bi*f;
                sum = sum + ci*f;
                map.remove(bi);
                if(map.containsKey(ci)){
                    f += map.get(ci);
                    map.remove(ci);
                }
                map.put(ci,f);
            }
            System.out.println(sum);
        }
    }
}

Compiler output:
Main.java:16: error: incompatible types: int cannot be converted to Long
                map.put(ai , 1);
                             ^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
1 error
Language: Java

import java.util.*;
public class AtCoder_Replacing
{
 public static void main(String[] args)
  {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int a[]=new int[n];
    int sum=0;
    for(int i=0;i<n;i++)
    {a[i]=sc.nextInt();sum+=a[i];}
    int q=sc.nextInt();
   while(q-->0)
   {
     int b=sc.nextInt();
     int c=sc.nextInt();
     for(int i=0;i<n;i++)
     {
       if(a[i]==b)
       {a[i]=c;sum=sum-b+c;}
     }System.out.println(sum);
   } 
 }
}


Compiler output:
Main.java:2: error: class AtCoder_Replacing is public, should be declared in a file named AtCoder_Replacing.java
public class AtCoder_Replacing
       ^
1 error
Language: Java

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();

        long S = 0;
        long A[] = new long[N];
        Map<Long, Long> p = new HashMap();

        for (int i = 0; i < N; i++) {
            A[i] = scan.nextLong();
            if (p.containsKey(A[i])) {
                p.put(A[i], p.get(i) + 1);
            } else {
                p.put(A[i], (long)1);
            }

            S = S + A[i];
        }

        int Q = scan.nextInt();
        long B[] = new long[Q];
        long C[] = new long[Q];

        for (int i = 0; i < Q; i++) {
            B[i] = scan.nextLong();
            C[i] = scan.nextLong();

        }
        for (int i = 0; i < Q; i++) {
            if (p.containsKey(B[i])) {
                S = S + ( C[i]-B[i]) * p.get(B[i]);
              if(p.containsKey(C[i])) { p.put(C[i],p.get(C[i])+p.get(B[i]));}
              else{p.put(C[i],p.get(B[i]));}
              p.put(B[i],0);
            }
            System.out.println(S);
        }
    }


}

Compiler output:
Main.java:40: error: incompatible types: int cannot be converted to Long
              p.put(B[i],0);
                         ^
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
1 error
Language: C

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

int main(void)
{
	long int n,q,a[100000],b[100000],c[100000],i,j,k,sum=0;
	scanf("%ld",&n);
	for(i=0;i<n;i++){
		scanf("%ld",&a[i]);
	}
	scanf("%ld",&q);
	for(i=0;i<q;i++){
		scanf("%ld %ld",&b[i],&c[i]);
	}
	for(i=0;i<q;i++){
		for(j=0;j<n;j++){
			if(a[j] == b[i]) a[j] = c[i];
		}
		sum = 0;
		for(k=0;k<n;k++){
			sum = sum +a[k];
		}
	
		printf("%ld"\n,sum);
	}
	
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:24:29: error: stray '\' in program
   24 |                 printf("%ld"\n,sum);
      |                             ^
main.c:24:29: error: expected ')' before 'n'
   24 |                 printf("%ld"\n,sum);
      |                       ~     ^~
      |                             )
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
 long long  int n;
  cin>>n;
  long long int sum=0;
  unordered_map<long long int,long long int>m;
   long long int mod=1000000007;
  for(long long int i=0;i<n;i++)
  {
   long long  int temp;
    cin>>temp;
    sum=sum+temp;
    m[temp]++;
  }
  long long int t;
  cin>>t;
 
  while(t--)
  {
    long long int a,b;
    cin>>a>>b;
    if(m[a]!=0)
    {
      sum=(sum-(a*m[a])+(b*m[a]));
      m[b]=m[b]+m[a];
      m[a]=0;
      cout<<(sum<<endl;
    }
    else
    {
      cout<<(sum)<<endl;
    }
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:17: error: invalid operands of types 'long long int' and '<unresolved overloaded function type>' to binary 'operator<<'
   29 |       cout<<(sum<<endl;
      |              ~~~^~~~~~
a.cc:29:23: error: expected ')' before ';' token
   29 |       cout<<(sum<<endl;
      |             ~         ^
      |                       )
Language: Java

import java.util.*;

public class Main {

    public static void main(String args[]) {


        Scanner scan = new Scanner(System.in);

        int n = scan.nextInt();
        List<Integer> list = new ArrayList<>();
        List<Long> sumList = new ArrayList<>();
        long sum =0;

        for (int i = 0; i < n; i++) {
            int a = scan.nextInt();
            sum+= a;
            list.add(a);
        }

        Collections.sort(list);

        int q = scan.nextInt();

        for (int j = 0;j<q; j++ ) {
            int b = scan.nextInt();
            int c = scan.nextInt();

            Collections.sort(list);

            if (Collections.binarySearch(list, b) >=0) {

                int lowerResult = ~Collections.binarySearch(list, b, (x, y) -> x.compareTo(y) >= 0 ? 1 : -1);
                int upperResult = ~Collections.binarySearch(list, b, (x, y) -> x.compareTo(y) > 0 ? 1 : -1);

                if (Collections.binarySearch(list, b+1) >=0) {
                    for (int k = lowerResult; k < upperResult; k++) {
                        if (list.get(k) == b) {
                            list.set(k, c);
                            sum = sum + c - b;
                        }
                    }
                } else {
                    for (int k = lowerResult; k <n; k++) {
                        if (list.get(k) == b) {
                            list.set(k, c);
                            sum = sum + c - b;
                        }
                    }
                }
            }
        }
            sumList.add(j, sum);
        }


        for(long i: sumList) {
            System.out.println(i);
        }
    }

}


Compiler output:
Main.java:57: error: illegal start of type
        for(long i: sumList) {
        ^
Main.java:57: error: ';' expected
        for(long i: sumList) {
                  ^
Main.java:57: error: <identifier> expected
        for(long i: sumList) {
                           ^
Main.java:62: error: class, interface, enum, or record expected
}
^
4 errors
Language: C++

#include<bits/stdc++.h>

using namespace std;

int main(){
    int N, a, Q, B, C;
    cin >> N;
    vector<int> A_count(10 ** 5);
    for (int i=0; i < N; i++) {
        cin >> a;
        A_count[a - 1]++;
    }
    int ans = 0;
    for (int j = 0; j < int(A_count.size()); j++) {
        ans += (j+1) * A_count[j];
    }
    cin >> Q;
    for (int i=0; i < Q; i++) {
        cin >> B >> C;
        if (A_count[B - 1] != 0) {
            ans += (C - B) * A_count[B - 1];
            A_count[C - 1] += A_count[B - 1];
            A_count[B - 1] = 0;
        }

        cout << ans << endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:29: error: invalid type argument of unary '*' (have 'int')
    8 |     vector<int> A_count(10 ** 5);
      |                             ^~~
Language: C++

#include<bits/stdc++.h>

using namespace std;

int main(){
    int N, a, Q, B, C;
    cin >> N;
    vector<int> A_count(10 ** 5);
    for (int i=0; i < N; i++) {
        cin >> a;
        A_count[a - 1]++;
    }
    int ans = 0;
    for (int j = 0; j < A_count.size(); j++) {
        ans += (j+1) * A_count[j];
    }
    cin >> Q;
    for (int i=0; i < Q; i++) {
        cin >> B >> C;
        if (A_count[B - 1] != 0) {
            ans += (C - B) * A_count[B - 1];
            A_count[C - 1] += A_count[B - 1];
            A_count[B - 1] = 0;
        }

        cout << ans << endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:29: error: invalid type argument of unary '*' (have 'int')
    8 |     vector<int> A_count(10 ** 5);
      |                             ^~~
Language: Java

import java.util.*;
import java.lang.*;
class Main
{
  public static void main(String args[])
  {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    HashMap<Integer,Integer> m=new HashMap<Integer,Integer>();
    long sum=0;
    for(int i=0;i<n;i++)
    {
      int val=sc.nextInt();
      m.put(val,m.getOrDefault(val,0)+1);
      sum+=val;
    }
    int q=sc.nextInt();
    for(int j=0;j<q;j++)
    {
      int b=sc.nextInt();
      int c=sc.nextInt();
      if(m.containsKey(b))
      {
        int num=m.get(b);
       // sum+=num*(c-b);
        m.remove(b);
        m.put(c,m.getOrDefault(c,0)+num);   
        long m=(num*c);
        long k=(num*b);
        sum=sum+m-k;
      }
      System.out.println(sum);
    }
  }
}


Compiler output:
Main.java:28: error: variable m is already defined in method main(String[])
        long m=(num*c);
             ^
1 error
Language: C++

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

int main(){
        int n,q,i,b,c,tmp;
        long long sum=0,t;
        cin >> n;
        vector<int> a(n);
        vector<int> cnt(1000000);
        vector<long long> ans;
        for(i=0;i<n;++i){
                cin >> tmp;
                ++cnt.at(tmp);
                a.at(i) = tmp;
                sum += tmp
        }
        cin >> q;
        for(i=0;i<q;++i){
                cin >> b >> c;
                t = (c-b)*cnt.at(b);
                cnt.at(c) += cnt.at(b);
                cnt.at(b) = 0;
                sum += t;
                ans.push_back(sum);
        }
        i = 0;
        while(true){
                cout << ans.at(i) << endl;
                ++i;
                if(i==q) break;
        }
        return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:27: error: expected ';' before '}' token
   17 |                 sum += tmp
      |                           ^
      |                           ;
   18 |         }
      |         ~
Language: C++

#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define int long long
using namespace std;
using P=pair<int,int>;
using Graph=vector<vector<int>>;
using ll=long long;


signed main(){ 
    int n; cin>>n;
    vector<int> A(20000000,0);
    int a[n];
    rep(i, n) a[i] = 0;
    for(int i=0;i<n;i++){
        int ai; cin>>ai;
        a[i]=ai;
        A[ai]+=1;
    }

    int q; cin>>q;
    
    vector<int> scores;

    //cout<<result<<endl;
    int result = accumulate(a,a+n,0);
    for(int i=0;i<q;i++){
        int b,c;
        cin>>b>>c;
        result=result+(c-b)*A[b];
        A[c]+=A[b];
        A[b]=0;

        scores.push_back(result);
    }

    for(int i=0;i<q;i++){
        cout<<scores[i]<<endl;
    }
}  


Compiler output:
a.cc:17:13: error: macro "rep" requires 3 arguments, but only 2 given
   17 |     rep(i, n) a[i] = 0;
      |             ^
a.cc:2:9: note: macro "rep" defined here
    2 | #define rep(i,s,n) for(int i=s;i<n;i++)
      |         ^~~
a.cc: In function 'int main()':
a.cc:17:5: error: 'rep' was not declared in this scope
   17 |     rep(i, n) a[i] = 0;
      |     ^~~
Language: C++

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

int main() {
    int N;
    cin >> N;
    
    vector<int> A(N);

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

    for(int i = 0; i < Q; i++) {
        cin >> B[i] >> C[i];
    }
    long long s = 0;
    vector<int> flag(1000001);
    for(int i = 0; i < N; i++) {
        s += A[i];
        flag[A[i]] = 1;
    }

    for(int i = 0; i < Q; i++) {
        if(flag) cout << s - B[i] + C[i] << endl;
        else cout << s << endl;
    }
    

    }

Compiler output:
a.cc: In function 'int main()':
a.cc:29:12: error: could not convert 'flag' from 'std::vector<int>' to 'bool'
   29 |         if(flag) cout << s - B[i] + C[i] << endl;
      |            ^~~~
      |            |
      |            std::vector<int>
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
  int t;
  cin>>t;
  int a[t];
 long long int sum=0;
  for(int i=0;i<t;i++)
  {
    cin>>a[i];
    sum+=a[i];
  }
  int q;
  cin>>q;
  for(int i=0;i<q;i++)
  {
    int a,b;
    cin>>a>>b;
    sum=sum-a;
    sum+=b;
    cout<<sum<<"\n;
  }
  
  
  

Compiler output:
a.cc:22:16: warning: missing terminating " character
   22 |     cout<<sum<<"\n;
      |                ^
a.cc:22:16: error: missing terminating " character
   22 |     cout<<sum<<"\n;
      |                ^~~~
a.cc: In function 'int main()':
a.cc:23:3: error: expected primary-expression before '}' token
   23 |   }
      |   ^
a.cc:23:4: error: expected '}' at end of input
   23 |   }
      |    ^
a.cc:4:1: note: to match this '{'
    4 | {
      | ^
Language: Java

import java.util.HashMap;
import java.util.Scanner;

/**
 *
 * @author HP
 */
public class Main {
   public static void main(String[] args) {
       Scanner s = new Scanner(System.in);
       int n = s.nextInt();
       HashMap<Integer,Integer> map = new HashMap<>();
       int temp;
       long sum=0;
       for(int i =0; i < n; i++) {
           temp = s.nextInt();
           sum+=temp;
           map.put(temp,map.getOrDefault(temp,0));
           }
       }
//       System.out.println(map);
       int q = s.nextInt();
       int b,c=0,count=0;
       while(q>0) {
           b = s.nextInt();
           c = s.nextInt();
           count=0;
           if(map.containsKey(b)) {
               temp = map.get(b);
               map.remove(b);
               int x=temp*b;
             int y=temp*c;
               sum = sum -x+y;
              map.put(c,map.getOrDefault(c,0)+temp);
           }
//           System.out.println(map);
           System.out.println(sum);q--;
       }
   }
}


Compiler output:
Main.java:24: error: illegal start of type
       while(q>0) {
       ^
Main.java:24: error: <identifier> expected
       while(q>0) {
              ^
Main.java:40: error: class, interface, enum, or record expected
}
^
3 errors
Language: Java


import java.util.HashMap;
import java.util.Scanner;

/**
 *
 * @author HP
 */
public class Main {
   public static void main(String[] args) {
       Scanner s = new Scanner(System.in);
       int n = s.nextInt();
       HashMap<Integer,Integer> map = new HashMap<>();
       int temp;
       long sum=0;
       for(int i =0; i < n; i++) {
           temp = s.nextInt();
           sum+=temp;
           map.put(temp,map.getOrDefault(temp,0));
           }
       }
//       System.out.println(map);
       int q = s.nextInt();
       int b,c=0,count=0;
       while(q-->0) {
           b = s.nextInt();
           c = s.nextInt();
           count=0;
           if(map.containsKey(b)) {
               temp = map.get(b);
               map.remove(b);
               int x=temp*b;
             int y=temp*c;
               sum = sum -x+y;
              map.put(c,map.getOrDefault(c,0)+temp);
           }
//           System.out.println(map);
           System.out.println(sum);
       }
   }
}


Compiler output:
Main.java:25: error: illegal start of type
       while(q-->0) {
       ^
Main.java:25: error: <identifier> expected
       while(q-->0) {
              ^
Main.java:41: error: class, interface, enum, or record expected
}
^
3 errors
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll mod = 1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

int main() {
  ll n;
  cin >> n;
  map<ll, ll> mp;
  rep(i,n) {
    ll a;
    cin >> a;
    mp[a]++;
  }

  ll q;
  cin >> q;

  vector<vector<ll>> array(q);


  rep(i,q) {
    ll a, b;
    cin >> a >> b;
    mp[b] += mp[a];
    mp[a] = 0;
    for (int j = 1; j <= 10000; j++) {
      array[i][j] = mp[j];
    }
  }

  rep(i,q) {
    ll sum = 0
    for (int j = 1; j <= 10000; j++) {
      sum += array[i][j] * j;
    }
    cout << sum << endl;
  }

  return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:38:5: error: expected ',' or ';' before 'for'
   38 |     for (int j = 1; j <= 10000; j++) {
      |     ^~~
a.cc:38:21: error: 'j' was not declared in this scope
   38 |     for (int j = 1; j <= 10000; j++) {
      |                     ^
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll mod = 1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

int main() {
  ll n;
  cin >> n;
  map<ll, ll> mp;
  rep(i,n) {
    ll a;
    cin >> a;
    mp[a]++;
  }

  ll q;
  cin >> q;

  vector<vector<ll>> array(q);


  rep(i,q) {
    ll a, b;
    cin >> a >> b;
    mp[b] += mp[a];
    mp[a] = 0;
    rep(j,10001) {
      array[i][j] = mp[j];
    }
  }

  rep(i,q) {
    ll sum = 0
    rep(j,10001) {
      sum += array[i][j] * j;
    }
    cout << sum << endl;
  }

  return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:2:19: error: expected ',' or ';' before 'for'
    2 | #define rep(i, n) for (int i = 0; i < (n); ++i)
      |                   ^~~
a.cc:38:5: note: in expansion of macro 'rep'
   38 |     rep(j,10001) {
      |     ^~~
a.cc:38:9: error: 'j' was not declared in this scope
   38 |     rep(j,10001) {
      |         ^
a.cc:2:35: note: in definition of macro 'rep'
    2 | #define rep(i, n) for (int i = 0; i < (n); ++i)
      |                                   ^
Language: Java

import java.lang.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int num = scan.nextInt();
        int[] arr = new int[num];

        for (int i = 0; i < num; i++) {
            arr[i] = scan.nextInt();
        }
        
        int q = scan.nextInt();

        for (int i = 0; i < q; i++) {
            int b = scan.nextInt();
            int c = scan.nextInt();
            int sum = 0;
            for (int i = 0; i < num; i++) {
                if (arr[i] == b) {
                    arr[i] = c;
                    sum += c;
                } else
                    sum += arr[i];
            }
            System.out.println(sum);
        }
    }
}


Compiler output:
Main.java:21: error: variable i is already defined in method main(String[])
            for (int i = 0; i < num; i++) {
                     ^
1 error
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll mod = 1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

int main() {
  ll n;
  cin >> n;
  map<ll, ll> mp;
  rep(i,n) {
    ll a;
    cin >> a;
    mp[a]++;
  }

  ll q;
  cin >> q;

  vector<vector<ll>> array2(q);


  rep(i,q) {
    ll a, b;
    cin >> a >> b;
    mp[b] += mp[a];
    mp[a] = 0;
    rep(j,10001) {
      array[i][j] = mp[j];
    }
  }

  rep(i,q) {
    ll sum = 0
    rep(j,10001) {
      sum += array2[i][j] * j;
    }
    cout << sum << endl;
  }

  return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:32:15: error: expected initializer before '[' token
   32 |       array[i][j] = mp[j];
      |               ^
a.cc:32:15: error: expected ';' before '[' token
a.cc:2:19: error: expected ',' or ';' before 'for'
    2 | #define rep(i, n) for (int i = 0; i < (n); ++i)
      |                   ^~~
a.cc:38:5: note: in expansion of macro 'rep'
   38 |     rep(j,10001) {
      |     ^~~
a.cc:38:9: error: 'j' was not declared in this scope
   38 |     rep(j,10001) {
      |         ^
a.cc:2:35: note: in definition of macro 'rep'
    2 | #define rep(i, n) for (int i = 0; i < (n); ++i)
      |                                   ^
Language: C++

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

int main() {
  int N;
  cin >> N;
  vector <int> A(100003);
  vector <int> b(100003);
  vector <int> c(100003);
  queue <int> que;

  for (int i=1; i<N+1; i++){
    int j=0;
    cin >> j;
    A.at(j)++;

    if(b.at(j)==0){
      b.at(j)==j;
    }

  }

  int Q;
  cin >> Q;

  vector <int> B(Q),C(Q);
  for(int i=0; i<Q; i++){
    cin >> B.at(i) >> C.at(i);
  }

  for(int i=0; i<Q; i++){
    A.at(C.at(i)) += A.at(B.at(i));
    A.at(B.at(i)) = 0;
    if(b.at(C.at(i))!=0){
      b.at(C.at(i))=C.at(i);
    }
    b.at(B.at(i))=0;
    c=b;
    sort(c.begin(),c.end()greater<int>());

    int sum=0;
    int k=0;
    while(c.at(k)!=0){
      sum += c.at(k)*A.at(c.at(k));
      k++;
    }

    cout << sum << endl;
  }

}


Compiler output:
a.cc: In function 'int main()':
a.cc:39:27: error: expected ')' before 'greater'
   39 |     sort(c.begin(),c.end()greater<int>());
      |         ~                 ^~~~~~~
      |                           )
Language: C++

#include <iostream>
using namespace std;

int N;
int A[N];
int Q;
int B[Q];
int C[Q];

int main(){
  cin>>N;
  for(int i=0;i<N;i++)cin>>A[i];
  for(int i=0;i<Q;i++){
  	for(int j=0;j<N;j++){
    	if(B[i]==A[j]){
          A[j]=C[i];
        }
    }
  }
 int sum=0;
  for(int i=0;i<N;i++)sum=sum+A[i];
  cout<<sum<<endl;
}


Compiler output:
a.cc:5:7: error: size of array 'A' is not an integral constant-expression
    5 | int A[N];
      |       ^
a.cc:7:7: error: size of array 'B' is not an integral constant-expression
    7 | int B[Q];
      |       ^
a.cc:8:7: error: size of array 'C' is not an integral constant-expression
    8 | int C[Q];
      |       ^
Language: C++

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

int main(){
  int n;
  long long ans=0;
  cin >> n;
  vector<int> cnt(100000);
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
    ans += a.at(i);
    cnt(a.at(i))++;
  }
  sort(a.begin(),a.end());
  int q;
  cin >> q;
  vector<int> b(q),c(q);
  for(int i=0;i<q;i++){
    cin >> b.at(i) >> c.at(i);
  }
  
  for(int i=0;i<q;i++){
    if(cnt(b.at(i)) == 0) cout << ans << endl;
    else {
      ans -= cnt(b.at(i))*b.at(i);
      ans += cnt(b.at(i))*c.at(i);
      cnt(c.at(i)) += cnt(b.at(i));
      cnt(b.at(i)) = 0;
      cout << ans << endl;
    }
  }
     
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:8: error: no match for call to '(std::vector<int>) (__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   13 |     cnt(a.at(i))++;
      |     ~~~^~~~~~~~~
a.cc:24:11: error: no match for call to '(std::vector<int>) (__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   24 |     if(cnt(b.at(i)) == 0) cout << ans << endl;
      |        ~~~^~~~~~~~~
a.cc:26:17: error: no match for call to '(std::vector<int>) (__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   26 |       ans -= cnt(b.at(i))*b.at(i);
      |              ~~~^~~~~~~~~
a.cc:27:17: error: no match for call to '(std::vector<int>) (__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   27 |       ans += cnt(b.at(i))*c.at(i);
      |              ~~~^~~~~~~~~
a.cc:28:10: error: no match for call to '(std::vector<int>) (__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   28 |       cnt(c.at(i)) += cnt(b.at(i));
      |       ~~~^~~~~~~~~
a.cc:28:26: error: no match for call to '(std::vector<int>) (__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   28 |       cnt(c.at(i)) += cnt(b.at(i));
      |                       ~~~^~~~~~~~~
a.cc:29:10: error: no match for call to '(std::vector<int>) (__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   29 |       cnt(b.at(i)) = 0;
      |       ~~~^~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)                                 //g++ template.cpp -o template.exe
#define zeroes(x) memset(x,0,sizeof(x))                                        //all elements to 0  |  \
#define all(x) (x).begin(), (x).end()
typedef long long int ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e9+7;
const ll maxn=100000;
#define MAX 50 







bool sortbysec(const pair<int,int> &a,                         //sorting of elements wrt second
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 


void countFreq(int arr[], long long  int n, vector< pair <long long int, long long int> > &v) 
{ 
    // Mark all array elements as not visited 
    vector<bool> visited(n, false); 
  
    // Traverse through array elements and 
    // count frequencies 
    for (int i = 0; i < n; i++) { 
  
        // Skip this element if already processed 
        if (visited[i] == true) 
            continue; 
  
        // Count frequency 
        int count = 1; 
        for (int j = i + 1; j < n; j++) { 
            if (arr[i] == arr[j]) { 
                visited[j] = true; 
                count++; 
            } 
        } 
        vect.push_back( make_pair(arr[i],count) );
    } 
} 






int main()
{
	long long int k,n,i,sum=0,q,b,c,k,sum1;
	vector< pair <long long int, long long int> > v;
	cin>>n;
	int ar[n];
	for(i=0;i<n;i++)
	{
		cin>>ar[i];
		sum+=ar[i];
	}
	countFreq(ar,n.v);

	cin>>q;
	while(q--)
	{
		cin>>b>>c;
		k=0;
		for(i=0;i<n;i++)
	    {
	    	if(v[i].first==b)
	    	{
	    		k=1;
	    		v[i].first=c;
	    		break;
	    	}
	    }
	    if(k==1)
	    {
	    	sum=sum+(c-b)*v[i].second;
	    	cout<<sum;

	    }


	}


	

	cout<<sum;


	return 0;
}

Compiler output:
a.cc: In function 'void countFreq(int*, long long int, std::vector<std::pair<long long int, long long int> >&)':
a.cc:63:9: error: 'vect' was not declared in this scope
   63 |         vect.push_back( make_pair(arr[i],count) );
      |         ^~~~
a.cc: In function 'int main()':
a.cc:74:41: error: redeclaration of 'long long int k'
   74 |         long long int k,n,i,sum=0,q,b,c,k,sum1;
      |                                         ^
a.cc:74:23: note: 'long long int k' previously declared here
   74 |         long long int k,n,i,sum=0,q,b,c,k,sum1;
      |                       ^
a.cc:83:24: error: request for member 'v' in 'n', which is of non-class type 'long long int'
   83 |         countFreq(ar,n.v);
      |                        ^
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll mod = 1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

int main() {
  ll n;
  cin >> n;
  map<ll, ll> mp;
  rep(i,n) {
    ll a;
    cin >> a;
    mp[a]++;
  }

  ll q;
  cin >> q;

  vector<vector<ll>> array2(q);


  rep(i,q) {
    ll a, b, sum = 0;
    cin >> a >> b;
    mp[b] += mp[a];
    mp[a] = 0;
    rep(j,10001) {
      array[i][j] = mp[j];
    }
  }

  rep(i,q) {
    ll sum = 0
    rep(j,10001) {
      sum += array2[i][j] * j;
    }
    cout << sum << endl;
  }

  return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:32:15: error: expected initializer before '[' token
   32 |       array[i][j] = mp[j];
      |               ^
a.cc:32:15: error: expected ';' before '[' token
a.cc:2:19: error: expected ',' or ';' before 'for'
    2 | #define rep(i, n) for (int i = 0; i < (n); ++i)
      |                   ^~~
a.cc:38:5: note: in expansion of macro 'rep'
   38 |     rep(j,10001) {
      |     ^~~
a.cc:38:9: error: 'j' was not declared in this scope
   38 |     rep(j,10001) {
      |         ^
a.cc:2:35: note: in definition of macro 'rep'
    2 | #define rep(i, n) for (int i = 0; i < (n); ++i)
      |                                   ^
Language: C++

#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
 
using namespace std; 
using namespace __gnu_pbds;
 
typedef long long ll;
typedef double db;
typedef long double ld;
typedef string str;
 
typedef pair<int,int> pi;
typedef pair<ll, ll> pll;
typedef pair<db, db> pdb;
typedef pair<ld, ld> pld;
typedef pair<str, str> pstr;
 
typedef vector<int> vi; 
typedef vector<ll> vll; 
typedef vector<db> vdb; 
typedef vector<ld> vld;
typedef vector<str> vstr; 
typedef vector<pi> vpi;
typedef vector<pll> vpll; 
typedef vector<pdb> vpdb; 
 
#define fi first
#define se second
#define mp make_pair
#define pf push_front 
#define pb push_back
#define ins insert 
#define eb emplace_back 
#define fbo find_by_order
#define ook order_of_key
#define rsz resize
#define lb lower_bound 
#define ub upper_bound 

#define len(s) (int)s.length()
#define sz(v) (int)v.size()
#define all(v) v.begin(), v.end()
#define srt(v) sort(all(v))

#define rep(a, b, c) for(int a=b; a<c; a++) 
#define per(a, b, c) for(int a=b; a>c; a--) //do not include boundaries on the right
#define repn(a, b, c) for(int a=b; a<=c; a++) 
#define pern(a, b, c) for(int a=b; a>=c; a--) //include boundaries on the right
 
#define yes cout << "YES"<< "\n" 
#define no cout << "NO" << "\n" 
#define out(x) cout << x << "\n"
#define outs(x) cout << x << " "
#define el cout << "\n"

#define navi ios_base::sync_with_stdio(false); cin.tie(NULL)    
 
const ll mod = 1e9+7;
const double eps = 1e-9;

int main(){
	navi;
	ll n; cin >> n;
  ll a[100003];
  sum=0;
  rep(i,0,n){
   a[i]=0;
  }
  rep(j,0,n){
   ll m; cin >> m;
    a[m]++;
    sum+=m;
  }
  ll q; cin >> q;
  rep(k,0,n){
    ll x, y; cin >> x >> y;
    sum+=a[x]*(y-x);
    a[y]+=a[x];
    a[x]=0;
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:66:3: error: 'sum' was not declared in this scope
   66 |   sum=0;
      |   ^~~
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll mod = 1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

int main() {
  ll n;
  cin >> n;
  map<ll, ll> mp;
  set<ll> array;
  rep(i,n) {
    ll a;
    cin >> a;
    array.push_back(a);
    mp[a]++;
  }

  ll q;
  cin >> q;

  vector<vector<ll>> array2(q);


  rep(i,q) {
    ll a, b, sum = 0;
    cin >> a >> b;
    mp[b] += mp[a];
    mp[a] = 0;
    rep(j,10001) {
      array[i][j] = mp[j];
    }
  }

  rep(i,q) {
    ll sum = 0
    rep(j,10001) {
      sum += array2[i][j] * j;
    }
    cout << sum << endl;
  }

  return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:18:11: error: 'class std::set<long long int>' has no member named 'push_back'
   18 |     array.push_back(a);
      |           ^~~~~~~~~
a.cc:34:12: error: no match for 'operator[]' (operand types are 'std::set<long long int>' and 'int')
   34 |       array[i][j] = mp[j];
      |            ^
a.cc:2:19: error: expected ',' or ';' before 'for'
    2 | #define rep(i, n) for (int i = 0; i < (n); ++i)
      |                   ^~~
a.cc:40:5: note: in expansion of macro 'rep'
   40 |     rep(j,10001) {
      |     ^~~
a.cc:40:9: error: 'j' was not declared in this scope
   40 |     rep(j,10001) {
      |         ^
a.cc:2:35: note: in definition of macro 'rep'
    2 | #define rep(i, n) for (int i = 0; i < (n); ++i)
      |                                   ^
Language: C++

#include <iostream>
int N,A[N],Q;
int B[Q],C[Q];

int main(){
  cin>>N;
  for(int i=0;i<N;i++)cin>>A[i];
  for(int i=0;i<Q;i++){
  	for(int j=0;j<N;j++){
    	if(B[i]==A[j]){
          A[j]=C[i];
        }
    }
  }
 int sum=0;
  for(int i=0;i<N;i++)sum=sum+A[i];
  cout<<sum<<endl;
}

Compiler output:
a.cc:2:9: error: size of array 'A' is not an integral constant-expression
    2 | int N,A[N],Q;
      |         ^
a.cc:3:7: error: size of array 'B' is not an integral constant-expression
    3 | int B[Q],C[Q];
      |       ^
a.cc:3:12: error: size of array 'C' is not an integral constant-expression
    3 | int B[Q],C[Q];
      |            ^
a.cc: In function 'int main()':
a.cc:6:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    6 |   cin>>N;
      |   ^~~
      |   std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:17:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   17 |   cout<<sum<<endl;
      |   ^~~~
      |   std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:17:14: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   17 |   cout<<sum<<endl;
      |              ^~~~
      |              std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
Language: C++

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

int main(){
  int n;
  long long ans=0;
  cin >> n;
  vector<int> count(100000);
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
    ans += a.at(i);
    count(a.at(i))++;
  }
  sort(a.begin(),a.end());
  int q;
  cin >> q;
  vector<int> b(q),c(q);
  for(int i=0;i<q;i++){
    cin >> b.at(i) >> c.at(i);
  }
  vector<int> count(100000);
  
  for(int i=0;i<q;i++){
    if(count(b.at(i)) == 0) cout << ans << endl;
    else {
      ans -= count(b.at(i))*b.at(i);
      ans += count(b.at(i))*c.at(i);
      count(c.at(i)) += count(b.at(i));
      count(b.at(i)) = 0;
      cout << ans << endl;
    }
  }
     
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:10: error: no match for call to '(std::vector<int>) (__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   13 |     count(a.at(i))++;
      |     ~~~~~^~~~~~~~~
a.cc:22:15: error: redeclaration of 'std::vector<int> count'
   22 |   vector<int> count(100000);
      |               ^~~~~
a.cc:8:15: note: 'std::vector<int> count' previously declared here
    8 |   vector<int> count(100000);
      |               ^~~~~
a.cc:25:13: error: no match for call to '(std::vector<int>) (__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   25 |     if(count(b.at(i)) == 0) cout << ans << endl;
      |        ~~~~~^~~~~~~~~
a.cc:27:19: error: no match for call to '(std::vector<int>) (__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   27 |       ans -= count(b.at(i))*b.at(i);
      |              ~~~~~^~~~~~~~~
a.cc:28:19: error: no match for call to '(std::vector<int>) (__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   28 |       ans += count(b.at(i))*c.at(i);
      |              ~~~~~^~~~~~~~~
a.cc:29:12: error: no match for call to '(std::vector<int>) (__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   29 |       count(c.at(i)) += count(b.at(i));
      |       ~~~~~^~~~~~~~~
a.cc:29:30: error: no match for call to '(std::vector<int>) (__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   29 |       count(c.at(i)) += count(b.at(i));
      |                         ~~~~~^~~~~~~~~
a.cc:30:12: error: no match for call to '(std::vector<int>) (__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   30 |       count(b.at(i)) = 0;
      |       ~~~~~^~~~~~~~~
Language: C++

#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int N, A[100001], Q, B[100000], C[100000];

void load(void);
void calc(void);

int main(){
	load();
	calc();
	output();
	return 0;
}

void load(void){
	int i;
	cin >> N;
	for(i = 0;i < N;i++){
		cin >> A[i];
	}
	cin >> Q;
	for(i = 0;i < Q;i++){
		cin >> B[i] >> C[i];
	}
}

void calc(void){
	int i, j, res;
	int mapp[100000];
	for(i = 0;i < 100000;i++){
		mapp[i] = 0;
	}
	for(i = 0;i < N;i++){
		mapp[A[i]]++;
	}
	for(i = 0;i < Q;i++){
		mapp[C[i]] += mapp[B[i]];
		mapp[B[i]] = 0;
		res = 0;
		for(j = 1;j < 100001;j++){
			res += j * mapp[j];
		}
		cout << res;
	}

}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:9: error: 'output' was not declared in this scope
   17 |         output();
      |         ^~~~~~
Language: C++

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a.at(i);
  }
  int q;
  cin >> q;
  vector<vector<int>> data(q, vector<int>(2));
  for(int j = 0; j < q; j++){
    for(int k = 0; k < 2; k++){
      cin >> data.at(j).at(k);
    }
  }
  ans = 0;
  for(int l = 0; l < q; l++){
    for(int m = 0; m < n; m++){
      if('a.at(m)' == 'data.at(l)at.(0)'){
        'a.at(m)' = 'data.at(l)at.(0)';
        ans += a.at(m);
        cout << ans << "\n" << endl;
      }
    }
  }
  return 0;
}


Compiler output:
a.cc:22:10: warning: multi-character literal with 7 characters exceeds 'int' size of 4 bytes
   22 |       if('a.at(m)' == 'data.at(l)at.(0)'){
      |          ^~~~~~~~~
a.cc:22:23: warning: multi-character literal with 16 characters exceeds 'int' size of 4 bytes
   22 |       if('a.at(m)' == 'data.at(l)at.(0)'){
      |                       ^~~~~~~~~~~~~~~~~~
a.cc:23:9: warning: multi-character literal with 7 characters exceeds 'int' size of 4 bytes
   23 |         'a.at(m)' = 'data.at(l)at.(0)';
      |         ^~~~~~~~~
a.cc:23:21: warning: multi-character literal with 16 characters exceeds 'int' size of 4 bytes
   23 |         'a.at(m)' = 'data.at(l)at.(0)';
      |                     ^~~~~~~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:19:3: error: 'ans' was not declared in this scope; did you mean 'abs'?
   19 |   ans = 0;
      |   ^~~
      |   abs
a.cc:23:9: error: lvalue required as left operand of assignment
   23 |         'a.at(m)' = 'data.at(l)at.(0)';
      |         ^~~~~~~~~
Language: C++

#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
 
using namespace std; 
using namespace __gnu_pbds;
 
typedef long long ll;
typedef double db;
typedef long double ld;
typedef string str;
 
typedef pair<int,int> pi;
typedef pair<ll, ll> pll;
typedef pair<db, db> pdb;
typedef pair<ld, ld> pld;
typedef pair<str, str> pstr;
 
typedef vector<int> vi; 
typedef vector<ll> vll; 
typedef vector<db> vdb; 
typedef vector<ld> vld;
typedef vector<str> vstr; 
typedef vector<pi> vpi;
typedef vector<pll> vpll; 
typedef vector<pdb> vpdb; 
 
#define fi first
#define se second
#define mp make_pair
#define pf push_front 
#define pb push_back
#define ins insert 
#define eb emplace_back 
#define fbo find_by_order
#define ook order_of_key
#define rsz resize
#define lb lower_bound 
#define ub upper_bound 

#define len(s) (int)s.length()
#define sz(v) (int)v.size()
#define all(v) v.begin(), v.end()
#define srt(v) sort(all(v))

#define rep(a, b, c) for(int a=b; a<c; a++) 
#define per(a, b, c) for(int a=b; a>c; a--) //do not include boundaries on the right
#define repn(a, b, c) for(int a=b; a<=c; a++) 
#define pern(a, b, c) for(int a=b; a>=c; a--) //include boundaries on the right
 
#define yes cout << "YES"<< "\n" 
#define no cout << "NO" << "\n" 
#define out(x) cout << x << "\n"
#define outs(x) cout << x << " "
#define el cout << "\n"

#define navi ios_base::sync_with_stdio(false); cin.tie(NULL)    
 
const ll mod = 1e9+7;
const double eps = 1e-9;

int main(){
	navi;
	ll n; cin >> n;
  ll a[100003];
  sum=0;
  rep(i,0,n){
   a[i]=0;
  }
  rep(j,0,n){
   ll m; cin >> m;
    a[m]++;
    sum+=m;
  }
  ll q cin >> q;
  rep(k,0,n){
    ll x, y; cin >> x >> y;
    sum+=a[x]*(y-x);
    
    a[y]+=m;
    a[x]=0;
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:66:3: error: 'sum' was not declared in this scope
   66 |   sum=0;
      |   ^~~
a.cc:75:8: error: expected initializer before 'cin'
   75 |   ll q cin >> q;
      |        ^~~
a.cc:80:11: error: 'm' was not declared in this scope
   80 |     a[y]+=m;
      |           ^
Language: C

#include <stdio.h>
#include <math.h>
#include <string.h>
 
int gcd(int a,int b){
    if(a<b){
        int now=a;
        a=b;
        b=a;
    }
 
    int r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
 
    return b;
}
 
 
 
/* 値を入れ替える関数 */
void swap (int *x, int *y) {
  int temp;    // 値を一時保存する変数
 
  temp = *x;
  *x = *y;
  *y = temp;
}
 
/***
* pivotを決め、
* 全データをpivotを境目に振り分け、
* pivotの添え字を返す
***/
int partition (int array[], int left, int right) {
  int i, j, pivot;
  i = left;
  j = right + 1;
  pivot = left;   // 先頭要素をpivotとする
 
  do {
    do { i++; } while (array[i] < array[pivot]);
    do { j--; } while (array[pivot] < array[j]);
    // pivotより小さいものを左へ、大きいものを右へ
    if (i < j) { swap(&array[i], &array[j]); }
  } while (i < j);
 
  swap(&array[pivot], &array[j]);   //pivotを更新
 
  return j;
}
 
/* クイックソート */
void quick_sort (int array[], int left, int right) {
  int pivot;
 
  if (left < right) {
    pivot = partition(array, left, right);
    quick_sort(array, left, pivot-1);   // pivotを境に再帰的にクイックソート
    quick_sort(array, pivot+1, right);
  }
}
 
 
 
int main(void){
    #include <stdio.h>
#include <math.h>
 
int main(void){
  int n;
  scanf("%d", &n);
  
  int a[n];
  int i;
  int m;
  for(i=0; i<n; i++){
    scanf("%d", &a[i]);
  }
  quick_sort(a, 0, n-1);
  
  int q;
  scanf("%d", &q);
  
  int b[q], c[q];
  for(i=0; i<q; i++){
    scanf("%d%d", &b[i], &c[i]);
  }
  
  long int s;
  int j;
  for(i=0; i<q; i++){
    s=0;
    if(n%2==0){
      if(b[i] <= a[i]/2){
        for(j=0; j<n/2; j++){
          if(b[i]==a[j]){
            a[j]=c[i];
          }
          s+=a[j];
        }
      }else{
        if(b[i] >= a[i]/2){
          for(j=(n/2)+1; j<n; j++){
            if(b[i]==a[j]){
              a[j]=c[i];
            }
            s+=a[j];
          }
        }
      }
    }else{
      if(b[i] <= a[i]/2){
        for(j=0; j<n/2; j++){
          if(b[i]==a[j]){
            a[j]=c[i] 
          }
          s+=a[j];
        }
      }else{
        if(b[i] >= (a[i]/2)+1){
          for(j=(n/2)+1; j<n; j++){
            if(b[i]==a[j]){
              a[j]=c[i];
            }
            s+=a[j];
          }
        }
      }
    }
    printf("%ld\n", s);
  }
 
  return 0;
}
}

Compiler output:
main.c: In function 'main':
main.c:119:22: error: expected ';' before '}' token
  119 |             a[j]=c[i]
      |                      ^
      |                      ;
  120 |           }
      |           ~
Language: C++

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


int main() {
  int N;
  cin >> N;
  map<int, int> p;
  for(int i=0;i<N;i++){
    int n;
    cin >> n;
    if (p.count(n))
      p[n] += 1;
    else
      p[n] = 1;
  }
  
  int Q;
  cin >> Q;
  int sum =0;
  for(int i=0;i<Q;i++){
    int a,b;
    cin >> a >> b;
    if (p.count(a)){
      p[b] += p[a];
      p[a] = 0;
    }
    
  for (auto q : p) {
    auto k = q.first;
    auto v = q.second;
    sum += k*v;
  }
    
  cout << sum <<endl;
}

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

#include<stdio.h>
int main(){
  int A[100001][1] ={0};
  int N=0;
  int Q=0;
  int sum=0;
  scanf("%d",&N);
  for(int i=0;i<N;i++){
    int num=0;
    scanf("%d ",&num);
    A[num][0]++;
    sum += num;
  }
  scanf("%d",&Q);
  for(int j=0;j<Q;j++){
    int b=0;
    int c=0;
    scanf("%d %d",&b,&c);
    sum = sum-(b*A[b][0])+(c*A[b][0]);
    A[c][0]+=A[b][0];
    A[b][0]={0};
    printf("%d\n",sum);
  }
  
}

Compiler output:
main.c: In function 'main':
main.c:21:13: error: expected expression before '{' token
   21 |     A[b][0]={0};
      |             ^
Language: C++

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

int main(){
  int N;
  cin >> N;
  ll M;
  // vector<int> A(N);
  vector<int> X(100005,0);
  rep(i,N){
    int a;
    cin >> a;
    // A.at(i) = a;
    M += a;
    X.at(i)++;
  }
  int Q;
  cin >> Q;
  vector<int> B(100005);
  vector<int> D(100005);
  rep(i,Q){
    int b,c;
    cin >> b >> c;
    // B.at(i) = b;
    // D.at(i) = c-b;
    M += X.at(b) * (c-b);
    cout << M << endl;
    int v = X.at(c)
    X.at(c) += X.at(b);
    X.at(b) -= v;
  }
//   for(int c: X){
//     if(X.at(c)>0){
//       M += X.at(c)*D.at(c);
//     }
//   }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:5: error: expected ',' or ';' before 'X'
   32 |     X.at(c) += X.at(b);
      |     ^
Language: C++

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

vector<int> f(vector<int> &X,int N,int B,int C){
  for(int j=0;j<N;j++){
    if(X.at(j)==B){
      X.at(j)=C;
    }
  }
  return X;
}

int64_t S(vector<int> &X,int N){
  int64_t sum=0;
  for(int p=0;p<N;p++){
    sum+=X.at(p);
  }
  return sum;
}


int main() {
  int N;
  cin>>N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    A.at(i)=a;
  }
  int Q;
  cin>>Q;
  
  for(int k=0;K<Q;k++){
    int64_t sum=0;
    int B,C;
    cin>>B>>C;
    A=f(A,N,B,C);
    cout<<S(A,N)<<endl;
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:34:15: error: 'K' was not declared in this scope
   34 |   for(int k=0;K<Q;k++){
      |               ^
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:6:16: error: expected ']' before ';' token
    6 |   int A[1000001;
      |                ^
      |                ]
a.cc:7:28: error: 'A' was not declared in this scope
    7 |   for(int i=0;i<N;i++)cin>>A[i];
      |                            ^
a.cc:13:10: error: 'A' was not declared in this scope
   13 |       if(A[j]==B)A[j]=C;
      |          ^
a.cc:14:12: error: 'A' was not declared in this scope
   14 |       ans+=A[j];
      |            ^