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

#include<cstdio>
#include<iostream>
using namespace std;
long long n,q,a[100001],sum;
int tm[100001];
int main()
{
    while(~scanf("%lld",&n))
    {
        sum=0;
        for(int i=0;i<n;++i)
        {
            scanf("%lld",&a[i]);
            sum+=a[i];
            tm[a[i]]++;
        }
        scanf("%lld",&q);
        ll b,c;
        for(int i=0;i<q;++i)
        {
            scanf("%lld %lld",&b,&c);
            sum+=(c-b)*tm[b];
            tm[c]+=tm[b];
            tm[b]=0;
            printf("%lld\n",sum);
        }
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:9: error: 'll' was not declared in this scope
   18 |         ll b,c;
      |         ^~
a.cc:21:32: error: 'b' was not declared in this scope
   21 |             scanf("%lld %lld",&b,&c);
      |                                ^
a.cc:21:35: error: 'c' was not declared in this scope
   21 |             scanf("%lld %lld",&b,&c);
      |                                   ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  int a[n];
  long long sum=0;
  map<int,int>m;
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    m[a[i]]++;
    sum+=a[i];  
  }
  
  int q;
  cin>>q;
  int x,y;
  while(q--)
  {
    cin>>x>>y;
    int count = m[x];
    if(x>0)
    {
      m[x]=0;
      m[y]=m[y]+count;
      sum = (sum-(x*count)+(count*y))
      cout<< sum;
    }
    else
      cout<<sum;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:38: error: expected ';' before 'cout'
   27 |       sum = (sum-(x*count)+(count*y))
      |                                      ^
      |                                      ;
   28 |       cout<< sum;
      |       ~~~~
Language: C++

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


int main() {
    int n;
    cin>>n;
    vector<int> a(n);
    int sum=0;
    rep(i,n){
        cin>>a[i];
        sum+=a[i];
    }
    int q;
    cin>>q;
    vector<int> b(q);
    vector<int> c(q);
    rep(i,q){
        cin>>b[i]>>c[i];
    }
    sort(a.begin(),a.ebd());
    vector<int> what(1,a[0]);
    vector<int> kosu(1,0);
    int temp=a[0];
    rep2(i,1,n){
        if(temp==a[i]){
            kosu.end()++;
        }
        else{
            temp=a[i];
            what.push_back(a[i]);
            kosu.push_back(0);
        }
    }
    rep(i,q){
        rep(j,what.size()){
            if(b[i]==what[j]){
                sum+=kosu[j]*(c[i]-b[i]);
            }
        }
        cout<<sum<<endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:22: error: 'class std::vector<int>' has no member named 'ebd'; did you mean 'end'?
   25 |     sort(a.begin(),a.ebd());
      |                      ^~~
      |                      end
Language: C++

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


int main() {
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n){
        cin>>a[i];
        sum+=a[i];
    }
    int q;
    cin>>q;
    vector<int> b(q);
    vector<int> c(q);
    rep(i,q){
        cin>>b[i]>>c[i];
    }
    vector<int> sum(q);
    int basesum=0;
    rep(i,n){
        basesum+=a[i];
    }
    rep(i,n){
        rep(j,q){
            if(a[i]==b[j]){
                a[i]=c[j];
                sum[j]+=c[j]-b[j];
            }
        }
    }
    rep(i,q){
        count<<basesum+sum[j]<<endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:9: error: 'sum' was not declared in this scope
   15 |         sum+=a[i];
      |         ^~~
a.cc:38:28: error: 'j' was not declared in this scope
   38 |         count<<basesum+sum[j]<<endl;
      |                            ^
Language: C++

#include <numeric>
#include <utility>

using namespace std;


int main(void) {
        int n, q;
        vector<long long> a;
        vector<pair<int, int>> v;
        long long sum = 0;

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

        cin >> q;
        for (int i = 0; i < q; i++) {
                int b, c;
                cin >> b >> c;
                v.push_back(make_pair(b, c));
        }
         vector<long long> sum_log;
        for (auto p : v) {
                int b = p.first;
                int c = p.second;

                size_t cnt = 0;
                for (size_t i = 0; i < a.size(); i++) {
                        if (a[i] == b) {
                                a[i] = c;
                                cnt++;
                        }
                }

                int diff = b - c;

                sum = sum - cnt * diff;

                cout << sum << endl;
        }


        return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:9: error: 'vector' was not declared in this scope
    9 |         vector<long long> a;
      |         ^~~~~~
a.cc:3:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    2 | #include <utility>
  +++ |+#include <vector>
    3 | 
a.cc:9:16: error: expected primary-expression before 'long'
    9 |         vector<long long> a;
      |                ^~~~
a.cc:10:29: error: expected primary-expression before '>' token
   10 |         vector<pair<int, int>> v;
      |                             ^~
a.cc:10:32: error: 'v' was not declared in this scope
   10 |         vector<pair<int, int>> v;
      |                                ^
a.cc:13:9: error: 'cin' was not declared in this scope
   13 |         cin >> n;
      |         ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    2 | #include <utility>
  +++ |+#include <iostream>
    3 | 
a.cc:18:17: error: 'a' was not declared in this scope
   18 |                 a.push_back(tmp);
      |                 ^
a.cc:27:17: error: expected primary-expression before 'long'
   27 |          vector<long long> sum_log;
      |                 ^~~~
a.cc:33:40: error: 'a' was not declared in this scope
   33 |                 for (size_t i = 0; i < a.size(); i++) {
      |                                        ^
a.cc:44:17: error: 'cout' was not declared in this scope
   44 |                 cout << sum << endl;
      |                 ^~~~
a.cc:44:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:44:32: error: 'endl' was not declared in this scope
   44 |                 cout << sum << endl;
      |                                ^~~~
a.cc:3:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    2 | #include <utility>
  +++ |+#include <ostream>
    3 |
Language: Java

mport java.util.*;
public class Main
{
    public static void main(String[] args)  {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int a[]=new int[n];
        for(int i=0;i<n;i++){
            a[i]=sc.nextInt();
        }
        int k=sc.nextInt();
        int b[]=new int[k];
        int c[]=new int[k];

        for(int i=0;i<k;i++) {
            b[i] =sc.nextInt();
            c[i] =sc.nextInt();
        }
        for(int i=0;i<k;i++) {
            int sum=0;
            for(int j=0;j<n;j++){
                if(a[j]==b[i]){
                    a[j]=c[i];
                }
                sum=sum+a[j];
            }
            System.out.println(sum);
        }
    }
}



Compiler output:
Main.java:1: error: class, interface, enum, or record expected
mport java.util.*;
^
1 error
Language: C++

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

int main() {
  int n,q,cnt=0;
  cin >> n;
  vector<int> a(n),d(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
    cnt += a.at(i);
    d.at(a,at(i))++;
  }
  cin >> q;
  vector<int> b(q),c(q);
  for(int i=0;i<q;i++){
    cin >> b.at(i) >> c.at(i);
    cnt += d.at(b.at(i)) * c.at(i);
    cnt -= d.at(b.at(i)) * b.at(i);
    d.at(b.at(i)) = 0;
    cout << cnt;
  }
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:12: error: 'at' was not declared in this scope; did you mean 'a'?
   11 |     d.at(a,at(i))++;
      |            ^~
      |            a
Language: Java

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

public class AnswerD {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int sum = 0;

        HashMap<Integer, Integer> values = new HashMap<>();
        for (int i = 0; i < n; i++) {
            int num = scanner.nextInt();
            if (values.containsKey(num)) {
                values.put(num, values.get(num) + 1);
            } else {
                values.put(num, 1);
            }
            sum += num;
        }

        int k = scanner.nextInt();
        for (int i = 0; i < k; i++) {
            int x = scanner.nextInt();
            int y = scanner.nextInt();

            int freq = values.get(x);
            sum -= (freq * x);
            sum += (freq * y);

            if(values.containsKey(x)){
                if (values.containsKey(y)) {
                    values.put(y, values.remove(x) + values.get(y));
                } else {
                    values.put(y, values.remove(x));
                }
            }

            System.out.println(sum);
        }
    }
}


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

#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int A[n]={};
  for(int i=0;i<n;i++){
    cin >> A[i];
  }
  int q;
  cin >> q;
  int B[q]={}.C[q]={};
  for(int i=0;i<q;i++){
    int64_t sum=0;
    cin >> B[i] >> C[i];
    for(int j=0;j<n;j++){
      if(A[j]==B[i])A[j]=C[i];
      sum+=A[j];
    }
    cout << sum << endl;
  }
}
  
    
  

Compiler output:
a.cc: In function 'int main()':
a.cc:12:14: error: expected ',' or ';' before '.' token
   12 |   int B[q]={}.C[q]={};
      |              ^
a.cc:15:20: error: 'C' was not declared in this scope
   15 |     cin >> B[i] >> C[i];
      |                    ^
Language: C++

//AnkitCode99 here....
//every ups and downs matter!

#include<bits/stdc++.h>
#define endl "\n"
#define Ryuga ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr)
typedef long long int ll;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back

using namespace std;

const ll sz=1e5+5;
const ll szz=1e6+6;
const ll mod=1e9+7;

int main()
{
	Ryuga;

	
	clock_t startTime=clock();

	ll n,sum=0;
	cin>>n;
    ll arr[n];
    map <ll,ll> mp;
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
        mp[arr[i]]++;
        sum+=arr[i];
    }
    cin>>k;
    for(i=0;i<k;i++)
    {
        cin>>a>>b;

        sum-=a*mp[a];
        sum+=b*mp[a];
        mp[b]+=mp[a];
        mp[a]=0;
        cout<<sum<<endl;
    }

	cerr << endl <<setprecision(20)<< double( clock() - startTime ) / (double)CLOCKS_PER_SEC<< " seconds." << endl;

}//Goodbye...

Compiler output:
a.cc: In function 'int main()':
a.cc:28:9: error: 'i' was not declared in this scope
   28 |     for(i=0;i<n;i++)
      |         ^
a.cc:34:10: error: 'k' was not declared in this scope
   34 |     cin>>k;
      |          ^
a.cc:35:9: error: 'i' was not declared in this scope
   35 |     for(i=0;i<k;i++)
      |         ^
a.cc:37:14: error: 'a' was not declared in this scope
   37 |         cin>>a>>b;
      |              ^
a.cc:37:17: error: 'b' was not declared in this scope
   37 |         cin>>a>>b;
      |                 ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
  int q,n,i,l,r;
  cin>>n;
  int p,b[n]={0};
  for(i=1;i<=n;i++)
  {
    cin>>p;
    sum=sum+p;
    b[p]++;
  }
  while(q--)
  {
    cin>>l>>r;
    sum=sum+(b[l]*(r-l));
    b[r]=b[l]+b[r];
    b[l]=0;
  }
  cout<<sum<<endl;
}
}
    
  
  

Compiler output:
a.cc: In function 'int main()':
a.cc:11:5: error: 'sum' was not declared in this scope
   11 |     sum=sum+p;
      |     ^~~
a.cc:17:5: error: 'sum' was not declared in this scope
   17 |     sum=sum+(b[l]*(r-l));
      |     ^~~
a.cc:21:9: error: 'sum' was not declared in this scope
   21 |   cout<<sum<<endl;
      |         ^~~
a.cc: At global scope:
a.cc:23:1: error: expected declaration before '}' token
   23 | }
      | ^
Language: C++

int main() {
  int n;
  cin >> n;
  vector<int>a(n);
  rep(i,n){
    cin >> a[i];
  }
  int q;
  cin >> q;
  ll fin=0;
  rep(i,q){
    int b,c;
    cin >> b >> c;
    ll ans=0;
    rep(j,n){
      if(a[j]==b){
        ans+=c;
      }
      else{
        ans+=b;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:3:3: error: 'cin' was not declared in this scope
    3 |   cin >> n;
      |   ^~~
a.cc:4:3: error: 'vector' was not declared in this scope
    4 |   vector<int>a(n);
      |   ^~~~~~
a.cc:4:10: error: expected primary-expression before 'int'
    4 |   vector<int>a(n);
      |          ^~~
a.cc:5:7: error: 'i' was not declared in this scope
    5 |   rep(i,n){
      |       ^
a.cc:5:3: error: 'rep' was not declared in this scope
    5 |   rep(i,n){
      |   ^~~
a.cc:10:3: error: 'll' was not declared in this scope
   10 |   ll fin=0;
      |   ^~
Language: C++


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

void c_p_c()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

bool sortKhela(const pair< int, int > &a,
               const pair< int, int > & b)
{
    return (a.first < b.first);
}

int main()
{
    c_p_c();
    int n;
    cin >> n;
    int arr[n];
    long 
    for (int i = 0; i < n; i++) cin >> arr[i];

    int m;
    cin >> m;
    long long sum;
    while (m--) {
        sum = 0;
        int from, to;
        cin >> from >> to;
        for (int i = 0; i < n; i++) {
            if (arr[i] == from) {
                arr[i] = to;
            }
            sum += arr[i];
        }
        cout << sum << endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:5: error: expected unqualified-id before 'for'
   29 |     for (int i = 0; i < n; i++) cin >> arr[i];
      |     ^~~
a.cc:29:21: error: 'i' was not declared in this scope
   29 |     for (int i = 0; i < n; i++) cin >> arr[i];
      |                     ^
Language: Java

import java.math.BigInteger;
import java.util.*;
public class Main3 {
	static Map<Long,ArrayList<String>> l=new TreeMap<Long,ArrayList<String>>();
	static long p[];
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		
		int a[]=new int[100002];
		long sum=0;
		for(int i=0;i<n;i++) {
			int m=sc.nextInt();
			a[m]++;
			sum+=m;
		}
		
		int k=sc.nextInt();
		for(int i=0;i<k;i++) {
			int p=sc.nextInt();
			int q=sc.nextInt();
			int d=a[p];
			a[p]=0;
			sum-=p*d;
			
			int add=q*d;
			sum+=add;
			a[q]+=d;
			
			System.out.println(sum);
		}
	}
	
	
}

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

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


int main()
{
 int N,Q,A,B,C;
 int S = 0;
 cin >> N;
 int oc[100001] = {0};
 for (int i=0; i<N; i++){
    cin >> A;
    oc[A]++;
    S += A;
 }
 cin >> Q;
 for (int j=0; j<Q; j++){
    cin >> B >> C;
    S += (C-B)*oc[B];
    oc[C] += oc[B];
    oc[B] = 0;
    cout << S << "\n";
 }
}

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


int main()
{
 int N,Q,A,B,C;
 int S = 0;
 cin >> N;
 int oc[100001] = {0};
 for (int i=0; i<N; i++){
    cin >> A;
    oc[A]++;
    S += A;
 }
 cin >> Q;
 for (int j=0; j<Q; j++){
    cin >> B >> C;
    S += (C-B)*oc[B];
    oc[C] += oc[B];
    oc[B] = 0;
    cout << S << "\n";
 }
}



Compiler output:
a.cc:36:5: error: redefinition of 'int main()'
   36 | int main()
      |     ^~~~
a.cc:8:5: note: 'int main()' previously defined here
    8 | int main()
      |     ^~~~
Language: C

#include<stdio.h>
 
void replace(int *arr, int k, int v, int leng){
    for (int i=0; i< leng; i++){
        if (*(arr+i) == k){
            *(arr+i) = v; 
          sum=sum-k+v;
        }
    }
}
 
int main(){
    int N, A[100000], Q, B[100000], C[100000], sum=0;
 
    
    //Nhập
    scanf("%d", &N);
    for (int i=0; i<N; i++){
        scanf("%d", &A[i]);
    }
    scanf("%d", &Q);
    for (int i=0; i<Q; i++){        
        scanf("%d", &B[i]);
        scanf("%d", &C[i]);
    }
 
    //Xử lý 
    
    for (int i=0; i<Q; i++){  
        replace(A, B[i],C[i], N);
        printf("%d\n", sum);
    }
 
    return 0;
}

Compiler output:
main.c: In function 'replace':
main.c:7:11: error: 'sum' undeclared (first use in this function)
    7 |           sum=sum-k+v;
      |           ^~~
main.c:7:11: note: each undeclared identifier is reported only once for each function it appears in
Language: Java

package atCoderBeginnerContest171;

import java.util.Scanner;

public class DReplacing2 {

	//例題は正解
	public static void main(String[] args) {
		//input
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt(); //N個の自然数

		int[] A = new int[N]; //N個の数列A
		for(int i=0; i<N; i++) {
			A[i] = sc.nextInt();
		}

		int Q = sc.nextInt(); //操作を行う回数

		int[][] BC = new int[2][Q]; //BとCを格納する配列
		for(int i=0; i<Q; i++) {
			BC[0][i] = sc.nextInt(); //Bを格納
			BC[1][i] = sc.nextInt(); //Cを格納
		}

		//メイン処理
		int[] list = new int[100001]; //メイン処理用配列
		int sum = 0; //合計

		//各数字が何回でてくるかカウント
		for(int i=0; i<N; i++) {
			list[A[i]]++;
		}

		//合計初期値
		for(int i=0; i<N; i++) {
			sum += A[i];
		}

		int r = 0;
		for(int i=0; i<Q; i++) {
			r = list[BC[1][i]]; //計算用に退避
			list[BC[1][i]] += list[BC[0][i]]; //Cに変えた分カウントアップ
			sum += BC[1][i] * (list[BC[1][i]] - r); //増えた分sumに追加
			sum -= BC[0][i] * list[BC[0][i]]; //Bの部分は合計から減算
			list[BC[0][i]] = 0; //Bは数列から消える
			System.out.println(sum);
		}
	}

}


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

#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
// Begin Template IO/Utility
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
void dbg_out(){
	cerr<<endl;
}
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T){
	cerr<<' '<< H; 
	dbg_out(T...);
}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &V){
	os<<'[';
	for(int i=0;i<(int)V.size();i++)
		os<<V[i]<<",]"[i==(int)V.size()-1];
	return os;
}
template<typename T> istream& operator>>(istream &is, vector<T> &V){
	for(T &x:V)
		is>>x;
	return is;
}
template<typename T, typename U> ostream& operator<<(ostream &os, const pair<T,U> &p){
	os<<'{'<<p.first<<','<<p.second<<'}';
	return os;
}
template<typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){
	is>>p.first>>p.second;
	return is;
}
// End Template IO/Utility
int const MAXN=100100;
int cnt[MAXN];
int solve(){
	int n;
	long long sum=0LL;
	cin>>n;
	for(int i=0;i<n;i++){
		int tmp;
		cin>>tmp;
		cnt[tmp]++;
		sum+=tmp;
	}
	int q;
	cin>>q;
	while(q--){
		int a, b;
		cin>>a>>b;
		cnt[b]+=cnt[a];
		sum-?cnt[a]*a;
		sum+=cnt[a]*b;
		cnt[a]=0;
		cout<<sum<<endl;
	}
	return 0;
}
int main(){
	cin.tie(0),cin.sync_with_stdio(0),cout.tie(0),cout.sync_with_stdio(0);
	int T=1;
	//cin>>T;
	while(T--){
		solve();
	}
}


Compiler output:
a.cc: In function 'int solve()':
a.cc:51:21: error: expected primary-expression before '?' token
   51 |                 sum-?cnt[a]*a;
      |                     ^
a.cc:51:30: error: expected ':' before ';' token
   51 |                 sum-?cnt[a]*a;
      |                              ^
      |                              :
a.cc:51:30: error: expected primary-expression before ';' token
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<int> B(Q);
  vector<int> C(Q);
  for(int i=0;i<Q;i++){
    cin>>B.at(i);
    cin>>C.at(i);
  }
  
  vector<int64_t> S(Q);
  vector<int64_t> T(Q+1);
  for(int j=0;j<N;j++) T.at(0) +=A.at(j);
  for(int i=0;i<Q;i++){
    int count=0;
    int dis=C.at(i)-B.at(i)
    for(int k=0;k<N;k++){
      if(A.at(k)==B.at(i)){
        count++;
        A.at(k) =C.at(i);
      }
    }
    T.at(i+1)=T.at(i)+dis*count;
    S.at(i)=T.at(i+1);
  }
  for(int i=0;i<Q;i++) cout<<S.at(i)<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:5: error: expected ',' or ';' before 'for'
   22 |     for(int k=0;k<N;k++){
      |     ^~~
a.cc:22:17: error: 'k' was not declared in this scope
   22 |     for(int k=0;k<N;k++){
      |                 ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
long long a1=100000;
int main()
{
 long long n,q,i;
  long long a[a1],b[a1],c[a1];
  cin>>n;
  for(i=0;i<n;i++)
  {
    cin>>a[i];
  }
  cin>>q;
  for(i=0;i<q;i++)
  {
    cin>>b[i] >>c[i];
  }
  for(j=0;j<q;j++)
  {
   int sum=0;
  for(i=0;i<n;i++)
  {
    if(a[i]==b[i])
    {
      a[i]=c[i]
    }
    sum=sum+a[i];
  }
    cout<<sum<<endl;
  }
  
    return 0;
}




Compiler output:
a.cc: In function 'int main()':
a.cc:18:7: error: 'j' was not declared in this scope
   18 |   for(j=0;j<q;j++)
      |       ^
a.cc:25:16: error: expected ';' before '}' token
   25 |       a[i]=c[i]
      |                ^
      |                ;
   26 |     }
      |     ~
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(false),cout.tie(false);
	const int MAX = 100010;
	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> cnt(MAX);
	long long sum = 0;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		++cnt[a[i]];
		sum+=a[i];
	}
	int q; cin >> q;
	while(q--){
		int b,d; cin >> b >> d;
		sum -= cnt[b] * b;
		sum += cnt[b] * d;
		cnt[d] += cnt[b];
		cnt[b] = 0;
		cout << sum << "\n";
	}
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:16: error: no matching function for call to 'std::basic_istream<char>::tie(bool)'
    7 |         cin.tie(false),cout.tie(false);
      |         ~~~~~~~^~~~~~~
In file included from /usr/include/c++/14/ios:46,
                 from /usr/include/c++/14/istream:40,
                 from /usr/include/c++/14/sstream:40,
                 from /usr/include/c++/14/complex:45,
                 from /usr/include/c++/14/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127,
                 from a.cc:1:
/usr/include/c++/14/bits/basic_ios.h:299:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>* std::basic_ios<_CharT, _Traits>::tie() const [with _CharT = char; _Traits = std::char_traits<char>]'
  299 |       tie() const
      |       ^~~
/usr/include/c++/14/bits/basic_ios.h:299:7: note:   candidate expects 0 arguments, 1 provided
/usr/include/c++/14/bits/basic_ios.h:311:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>* std::basic_ios<_CharT, _Traits>::tie(std::basic_ostream<_CharT, _Traits>*) [with _CharT = char; _Traits = std::char_traits<char>]'
  311 |       tie(basic_ostream<_CharT, _Traits>* __tiestr)
      |       ^~~
/usr/include/c++/14/bits/basic_ios.h:311:43: note:   no known conversion for argument 1 from 'bool' to 'std::basic_ostream<char>*'
  311 |       tie(basic_ostream<_CharT, _Traits>* __tiestr)
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
a.cc:7:32: error: no matching function for call to 'std::basic_ostream<char>::tie(bool)'
    7 |         cin.tie(false),cout.tie(false);
      |                        ~~~~~~~~^~~~~~~
/usr/include/c++/14/bits/basic_ios.h:299:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>* std::basic_ios<_CharT, _Traits>::tie() const [with _CharT = char; _Traits = std::char_traits<char>]'
  299 |       tie() const
      |       ^~~
/usr/include/c++/14/bits/basic_ios.h:299:7: note:   candidate expects 0 arguments, 1 provided
/usr/include/c++/14/bits/basic_ios.h:311:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>* std::basic_ios<_CharT, _Traits>::tie(std::basic_ostream<_CharT, _Traits>*) [with _CharT = char; _Traits = std::char_traits<char>]'
  311 |       tie(basic_ostream<_CharT, _Traits>* __tiestr)
      |       ^~~
/usr/include/c++/14/bits/basic_ios.h:311:43: note:   no known conversion for argument 1 from 'bool' to 'std::basic_ostream<char>*'
  311 |       tie(basic_ostream<_CharT, _Traits>* __tiestr)
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
Language: C++

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

int main() {
    int n;
    cin >> n;
    int a;
    long long s = 0;
    vector<int> an(100001, 0);
    for (int i = 0; i < n; i++) {
        cin >> a;
        s += a;
        an[a]++;
    }
    
    int q;
    cin >> q;
    vector<int> b(q + 1);
    vector<int> c(q + 1);
    for (int i = 1; i <= q; i++) {
        cin >> b[i] >> c[i];
    }
    
    for (int i = 1; i <= q; i++) {
        s += an[b[q]] * (c[q] - b[q]);
        an[c[q]] += an[b[q]];
        an[b[q]] = 0;
        
        cout << s << endl;
    }
}

Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include <bits/stdc++.h>
      | ^~~~~~~
a.cc: In function 'int main()':
a.cc:6:5: error: 'cin' was not declared in this scope
    6 |     cin >> n;
      |     ^~~
a.cc:9:5: error: 'vector' was not declared in this scope
    9 |     vector<int> an(100001, 0);
      |     ^~~~~~
a.cc:9:12: error: expected primary-expression before 'int'
    9 |     vector<int> an(100001, 0);
      |            ^~~
a.cc:13:9: error: 'an' was not declared in this scope; did you mean 'a'?
   13 |         an[a]++;
      |         ^~
      |         a
a.cc:18:12: error: expected primary-expression before 'int'
   18 |     vector<int> b(q + 1);
      |            ^~~
a.cc:19:12: error: expected primary-expression before 'int'
   19 |     vector<int> c(q + 1);
      |            ^~~
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:25:14: error: 'an' was not declared in this scope; did you mean 'a'?
   25 |         s += an[b[q]] * (c[q] - b[q]);
      |              ^~
      |              a
a.cc:25:17: error: 'b' was not declared in this scope
   25 |         s += an[b[q]] * (c[q] - b[q]);
      |                 ^
a.cc:25:26: error: 'c' was not declared in this scope
   25 |         s += an[b[q]] * (c[q] - b[q]);
      |                          ^
a.cc:29:9: error: 'cout' was not declared in this scope
   29 |         cout << s << endl;
      |         ^~~~
a.cc:29:22: error: 'endl' was not declared in this scope
   29 |         cout << s << endl;
      |                      ^~~~
Language: Java

import java.util.*;
public class Main{

     public static void main(String []args){
    
        int n;
        
        HashMap<Integer,Integer> map=new HashMap<Integer,Integer>();
        
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        
        int arr[]= new int[n];
        
        int sum = 0;
        
        for(int i=0;i<n;i++){
            
            int a = in.nextInt();
            arr[i]=a;
            sum = sum+a;
            map.put(A[i],map.getOrDefault(A[i],0) + 1);

        }
        
        int q= in.nextInt();
        
        while(q>0){
            
            int b = in.nextInt();
            int c = in.nextInt();
            
            if(map.containsKey(b))
            {
              sum = b * map.get(b) - c *map.get(b);
              System.out.println(sum);
            }
            else
                System.out.println(sum);
            
            q--;
        }
             
              }
}


Compiler output:
Main.java:22: error: cannot find symbol
            map.put(A[i],map.getOrDefault(A[i],0) + 1);
                    ^
  symbol:   variable A
  location: class Main
Main.java:22: error: cannot find symbol
            map.put(A[i],map.getOrDefault(A[i],0) + 1);
                                          ^
  symbol:   variable A
  location: class Main
2 errors
Language: C++

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

int main(){
  ll N,Q;
  cin >>N;
  vector<ll> a(N);
  vector<ll> b(Q);
  vector<ll> c(Q);
  
  for(ll i=0;i<N;i++){
    cin >>a[i];
    
  }
  cin >>Q;
  for(ll i=0;i<Q;i++){
    cin >> b[i];
    cin >> c[i];
  }
  
  vector<int> d(pow(10,5),0);
  ll s=0;
  for(ll i=0;i<N;i++){
    d[a[i]-1]++;
    s +=a[i];
  }
  
  for(ll i=0;i<Q;i++){
    s +=(c[i]-b[i])*d[b[i]-1];
    d[c[i]-1] +=d[b[i]-1];
    d[b[i]-1] -=d[b[i]-1];
    cout << s <<endl;
  }
}

  
  


Compiler output:
a.cc:3:10: error: 'longlong' does not name a type
    3 | using ll=longlong;
      |          ^~~~~~~~
a.cc: In function 'int main()':
a.cc:6:3: error: 'll' was not declared in this scope
    6 |   ll N,Q;
      |   ^~
a.cc:7:9: error: 'N' was not declared in this scope
    7 |   cin >>N;
      |         ^
a.cc:8:12: error: template argument 2 is invalid
    8 |   vector<ll> a(N);
      |            ^
a.cc:9:12: error: template argument 2 is invalid
    9 |   vector<ll> b(Q);
      |            ^
a.cc:9:16: error: 'Q' was not declared in this scope
    9 |   vector<ll> b(Q);
      |                ^
a.cc:10:12: error: template argument 2 is invalid
   10 |   vector<ll> c(Q);
      |            ^
a.cc:12:9: error: expected ';' before 'i'
   12 |   for(ll i=0;i<N;i++){
      |         ^~
      |         ;
a.cc:12:14: error: 'i' was not declared in this scope
   12 |   for(ll i=0;i<N;i++){
      |              ^
a.cc:17:9: error: expected ';' before 'i'
   17 |   for(ll i=0;i<Q;i++){
      |         ^~
      |         ;
a.cc:17:14: error: 'i' was not declared in this scope
   17 |   for(ll i=0;i<Q;i++){
      |              ^
a.cc:23:5: error: expected ';' before 's'
   23 |   ll s=0;
      |     ^~
      |     ;
a.cc:24:9: error: expected ';' before 'i'
   24 |   for(ll i=0;i<N;i++){
      |         ^~
      |         ;
a.cc:24:14: error: 'i' was not declared in this scope
   24 |   for(ll i=0;i<N;i++){
      |              ^
a.cc:26:5: error: 's' was not declared in this scope
   26 |     s +=a[i];
      |     ^
a.cc:29:9: error: expected ';' before 'i'
   29 |   for(ll i=0;i<Q;i++){
      |         ^~
      |         ;
a.cc:29:14: error: 'i' was not declared in this scope
   29 |   for(ll i=0;i<Q;i++){
      |              ^
a.cc:30:5: error: 's' was not declared in this scope
   30 |     s +=(c[i]-b[i])*d[b[i]-1];
      |     ^
Language: C++

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

typedef long long ll;

int hoge4(){
  ll N;
  std::cin >> N;
  std::map<ll, ll> A;
  for(ll i = 0 ; i < N ; i++){
    ll temp;
    std::cin >> temp;
    A[temp]++;
  }
  ll Q;
  std::cin >> Q;
  std::vector<ll> B(Q);
  std::vector<ll> C(Q);
  for(ll i = 0 ; i < Q ; i++){
    std::cin >> B[i] >> C[i];
  }
  ll sum = 0;
  for(auto it = A.begin() ; it != A.end(); it++){
    sum += (it -> second) * (it -> first);
  }
  for(int i = 0 ; i < Q ; i++){
    if(A[B[i]] != 0){
      A[C[i]] += A[B[i]];
      sum += (C[i] - B[i]) * A[B[i]];
      A[B[i]] = 0;
      // for(auto it = A.begin(); it != A.end() ; it++){
      // 	std::cout << "f : " << it -> first << " s : " << it -> second << std::endl;
      // }
    }
    std::cout << sum << std::endl;
  }
  return 0;
}



Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,
    cin>>n;
    int arr[n];
    int i;
    for(i=0;i<n;i++)
        cin>>arr[i];
    int s=0;
    for(i=0;i<n;i++)
        s+=arr[i];
    int q;
    int b,c;
    cin>>q;
    while(q--)
    {
        cin>>b>>c;
        for(i=0;i<n;i++)
        {
            if(arr[i]==b)
            {
                arr[i]=c;
                s=s-b;
                s+=c;
            }
        }
        cout<<s<<"\n";
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:8: error: expected initializer before '>>' token
    6 |     cin>>n;
      |        ^~
Language: C++

#include <iostream>
#include <map>
#include <cstdint>

int main() {
    uint32_t n, q;
    uint64_t s = 0;
    map<uint32_t, uint32_t> a;

    cin >> n;
    for (uint32_t i = 0; i < n; ++i) {
        uint32_t a_; cin >> a_;
        ++a[a_];
        s += a_;
    }
    cin >> q;

    while (q--) {
        uint32_t b, c;
        cin >> b >> c;

        if (auto it = a.find(b); it != a.end()) {
            s -= it->second * b;
            s += it->second * c;
            a[c] += it->second;
            a.erase(it);
        }

        cout << s << endl;
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:8:5: error: 'map' was not declared in this scope
    8 |     map<uint32_t, uint32_t> a;
      |     ^~~
a.cc:8:5: note: suggested alternatives:
In file included from /usr/include/c++/14/map:63,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_map.h:102:11: note:   'std::map'
  102 |     class map
      |           ^~~
/usr/include/c++/14/map:89:13: note:   'std::pmr::map'
   89 |       using map
      |             ^~~
a.cc:8:17: error: expected primary-expression before ',' token
    8 |     map<uint32_t, uint32_t> a;
      |                 ^
a.cc:8:27: error: expected primary-expression before '>' token
    8 |     map<uint32_t, uint32_t> a;
      |                           ^
a.cc:8:29: error: 'a' was not declared in this scope
    8 |     map<uint32_t, uint32_t> a;
      |                             ^
a.cc:10:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   10 |     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:29:9: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   29 |         cout << s << 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:29:22: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   29 |         cout << s << 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;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char> cvec;
typedef vector<double> dvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
#define fs first
#define sc second
int main()	{
  int n;
  ll sum=0;
  cin>>n;
  vector<int>d(10001);
  rep(i,n){
    int a;
    cin>>a;
    d[a]++;
    sum+=a;
  }
  int q;
  cin>>q;
  rep(i,q){
    int b,c;
    cin>>b>>c;
    sum-=b*d[b];
    d[c]+=d[b];
    sum+=c*d[c];
  }
  cout<<sum<<endl;

Compiler output:
a.cc: In function 'int main()':
a.cc:38:19: error: expected '}' at end of input
   38 |   cout<<sum<<endl;
      |                   ^
a.cc:18:17: note: to match this '{'
   18 | int main()      {
      |                 ^
Language: C++

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

int main() {
    int n;
    cin >> n;
    
    vector<long> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
        
    int q;
    cin >> q;
    
    vector<int> b(q);
    vector<int> c(q);
    for (int i = 0; i < q; i++)
        cin >> b[i] >> c[i];
        
    for (int i = 0; i < q; i++) {
        for (int j = 0; j < n; j++) {
            if (a[j] == b[i])
                a[j] = c[i];
        }
        cout << accumlate(a.begin(), a.end(), 0);
    }
    
    cout << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:17: error: 'accumlate' was not declared in this scope
   25 |         cout << accumlate(a.begin(), a.end(), 0);
      |                 ^~~~~~~~~
Language: C++

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

int main() {
    int n;
    cin >> n;
    
    vector<long> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
        
    int q;
    cin >> q;
    
    vector<int> b(q);
    vector<int> c(q);
    for (int i = 0; i < q; i++)
        cin >> b[i] >> c[i];
        
    for (int i = 0; i < q; i++) {
        for (int j = 0, j < n; j++) {
            if (a[j] == b[i])
                a[j] = c[i];
        }
        cout << accumlate(a.begin(), a.end(), 0);
    }
    
    cout << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:26: error: expected ';' before '<' token
   21 |         for (int j = 0, j < n; j++) {
      |                          ^~
      |                          ;
a.cc:21:27: error: expected primary-expression before '<' token
   21 |         for (int j = 0, j < n; j++) {
      |                           ^
a.cc:25:17: error: 'accumlate' was not declared in this scope
   25 |         cout << accumlate(a.begin(), a.end(), 0);
      |                 ^~~~~~~~~
Language: C++

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

int main() {
	int n = 0;
	cin >> n;
	vector <int> vect(n);
	int sum = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> vect[i];
		sum = sum + vect[i];
	}
	int q = 0;
	cin >> q;
	int t1 = 0;
	int t2 = 0;
	sort(vect.begin(),vect.end());
	for (int i = 0; i < q; i++)
	{
		cin >> t1 >> t2;
		for (int j = 0; j < vect.size();j++)
		{
			if (vect[j] == t1)
			{
				vect[j] = t2;
				sum = sum - t1 + t2;
			}
		}
		cout << sum << endl;
	}
	return 0;
}

Compiler output:
a.cc:3:2: error: invalid preprocessing directive #onclude; did you mean #include?
    3 | #onclude <alogrithm>
      |  ^~~~~~~
      |  include
a.cc: In function 'int main()':
a.cc:20:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   20 |         sort(vect.begin(),vect.end());
      |         ^~~~
      |         short
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char> cvec;
typedef vector<double> dvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
#define fs first
#define sc second
int main()	{
  int n;
  cin>>n;
  vector<int>a(n),d(10001);
  rep(i,n){
    cin>>a[i];
    d[a[i]]++;
  }
  int q;
  cin>>q;
  vector<int>b(q),c(q);
  rep(i,q){
    cin>>b[i]>>c[i];

Compiler output:
a.cc: In function 'int main()':
a.cc:30:21: error: expected '}' at end of input
   30 |     cin>>b[i]>>c[i];
      |                     ^
a.cc:29:11: note: to match this '{'
   29 |   rep(i,q){
      |           ^
a.cc:30:21: error: expected '}' at end of input
   30 |     cin>>b[i]>>c[i];
      |                     ^
a.cc:18:17: note: to match this '{'
   18 | int main()      {
      |                 ^
Language: Java

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

public class Main{

public static void main(String[] args) {
		
		Scanner scanner = new Scanner(System.in);
		int length = Integer.parseInt(scanner.nextLine());

		String numbers = scanner.nextLine();

		int quantity = Integer.parseInt(scanner.nextLine());

		String[] numberForChange = new String[quantity];
		
		SumSum sussm = new SumSum(numbers, quantity);
		
		for (int i = 0; i < quantity; i++) {
			numberForChange[i] = scanner.nextLine();
		}
		
		sussm.run(numberForChange);
		
	}


}




public class SumSum {
	
//	public static void main(String[] args) {
//		Va.main(null);
//	}

	private String[] array;
	private int[] arrayNumbers = new int[100001];
	private long sum;
	private long[] arrayOfSum;
	

	public SumSum(String numbers, int quantityNumbersForChage) {
		this.array = numbers.split(" ");
		this.arrayOfSum = new long[quantityNumbersForChage];
		createIntArray();
	}

	public void run(String[] numbersForChage) {
		String[] twoNumber;
		int oldNumber = 0;
		int newNumber = 0;
		int quantity = 0;
		int difference = 0;
		int i = 0;
		for(String str : numbersForChage) {
			twoNumber = str.split(" ");
			oldNumber = Integer.parseInt(twoNumber[0]);
			newNumber = Integer.parseInt(twoNumber[1]);
			quantity = arrayNumbers[oldNumber];
			if (quantity == 0) {
				System.out.println("AAA");
				//System.out.println(sum);
				arrayOfSum[i++] = sum;
				continue;
			}

			difference = newNumber - oldNumber;
			sum += (difference * quantity);
			//System.out.println(sum);
			arrayOfSum[i++] = sum;
			arrayNumbers[oldNumber] = 0;
			arrayNumbers[newNumber] += quantity;
		}
		
		for(long n : arrayOfSum) {
			System.out.println(n);
		}
		
}

	private void createIntArray() {
		for (String s : array) {
			int number = Integer.parseInt(s);
			arrayNumbers[number] += 1;
			sum += number;
		}
	}
	
}

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

#include <vector> 
#include <map>
#include <queue>
#include <iostream>
#include <iterator>
#define pb push_back 
#define int long long
using namespace std; 

int main() 
{ 
	int n,q,s=0; 
	cin >> n; 
	vector<int> v(100069,0); 
	for(int i=0, t;i<n;i++)
	{
		cin >> t;
		v[t]++;
		s+=t;
	}
	cin >> q;
	int b, c; 
	while(q--) { 
		cin >> b >> c; 
		s-=v[b]*b;
		s+=v[b]*c;	
		v[c]+=v[b];
		v[b]=0;
		cout<<s<<"\n";
		
	} 

	

	return 0; 
} 


Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include <vector> 
#include <map>
#include <queue>
#include <iostream>
#include <iterator>
#include "bits/stdc++.h"
#define int long long
#define all(c) (c).begin(), (c).end()
#define cpresent(c,x) ((c).find(x) != (c).end()) 
#define vpresent(c,x) (find(all(c),x) != (c).end())
#define endl '\n'
#ifdef LOCAL
#include "/home/iggaboi/Desktop/CP/debug.h"
#else
#define debug(x...)
#endif
#define pb push_back 

using namespace std; 

int main() 
{ 
	int n,q,s=0; 
	cin>>n; 
	vector<int> v(100069,0); 
	for(int i=0, t;i<n;i++)
	{
		cin>>t;
		v[t]++;
		s+=t;
	}
	cin>>q;
	int b, c; 
	for (int i = 0; i < q; i++) { 
		cin>>b>>c; 
		s-=v[b]*b;
		s+=v[b]*c;	
		v[c]+=v[b];
		v[b]=0;
		cout<<s<<"\n";
		
	} 

	

	return 0; 
} 


Compiler output:
cc1plus: error: '::main' must return 'int'
Language: Java

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long ans = 0;
    HashMap<Long, Long> map = new HashMap<Long, Long>();
    for(int i = 0; i < n; i++) {
      long a = sc.nextLong();
      ans += a;
      if(map.containsKey(a)) {
        map.put(a, map.get(a) + 1);
      } else {
        map.put(a, 1);
      }
    }
    int q = sc.nextInt();
    for(int i = 0; i < q; i++) {
      long b = sc.nextLong();
      long c = sc.nextLong();
      if(map.containsKey(b)) {
        long g = map.get(b);
        ans += (g * (c - b));
        map.put(b, 0);
        if(map.containsKey(c)) {
          map.put(c, map.get(c) + g);
        } else {
          map.put(c, g);
        }
      } else {

      }
      System.out.println(ans);
    }
  }
}

Compiler output:
Main.java:15: error: incompatible types: int cannot be converted to Long
        map.put(a, 1);
                   ^
Main.java:25: error: incompatible types: int cannot be converted to Long
        map.put(b, 0);
                   ^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
2 errors
Language: C++

#include<bits/stdc++.h>
using namespace std;
int u=100005,n,q,a[u],o,x,b,c,i;
int main()
{
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>x;
		a[x]++;
		o+=x;
	}
	cin>>q;
	while(q--)
	{
		cin>>b>>c;
		o+=(c-b)*a[b];
		a[c]+=a[b];
		a[b]=0;
		cout<<o<<endl;
	}
	return 0;
}

Compiler output:
a.cc:3:20: error: size of array 'a' is not an integral constant-expression
    3 | int u=100005,n,q,a[u],o,x,b,c,i;
      |                    ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int g=100005,n,a,b[g],c,d,e,f,i;
int main()
{
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>e;
		a[e]++;
		f+=e;
	}
	cin>>a;
	while(a--)
	{
		cin>>c>>d;
		f+=(d-c)*b[c];
		b[d]+=b[c];
		b[c]=0;
		cout<<f<<endl;
	}
	return 0;
}

Compiler output:
a.cc:3:20: error: size of array 'b' is not an integral constant-expression
    3 | int g=100005,n,a,b[g],c,d,e,f,i;
      |                    ^
a.cc: In function 'int main()':
a.cc:10:18: error: invalid types 'int[int]' for array subscript
   10 |                 a[e]++;
      |                  ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int g=100005;
int n,a,b[g],c,d,e,f,i;
int main()
{
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>e;
		a[e]++;
		ans+=e;
	}
	cin>>a;
	while(a--)
	{
		cin>>c>>d;
		f+=(d-c)*b[c];
		b[d]+=b[c];
		b[c]=0;
		cout<<f<<endl;
	}
	return 0;
}

Compiler output:
a.cc:4:11: error: size of array 'b' is not an integral constant-expression
    4 | int n,a,b[g],c,d,e,f,i;
      |           ^
a.cc: In function 'int main()':
a.cc:11:18: error: invalid types 'int[int]' for array subscript
   11 |                 a[e]++;
      |                  ^
a.cc:12:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   12 |                 ans+=e;
      |                 ^~~
      |                 abs
Language: C++

#include <iostrem>
#include <unordered_map>

int main()
{
    int n = 0;
    std::cin >> n;
    
	std::unordered_map<int, int> numArray;
    long long sum = 0;
    
    for(int count = 0; count < n; ++count)
    {
        int element = 0;
        std::cin >> element;
        ++numArray[element];
        sum += element;
    }
    
    int q = 0;
    std::cin >> q;
    
    for(int count = 0; count < q; ++count)
    {
        int b = 0;
        int c = 0;
        std::cin >> b >> c;
        if(numArray.find(b) != numArray.end())
        {
            int const changedNum = numArray.at(b);
            numArray[c] += changedNum;
            sum += (c - b) * changedNum;
        }
        std::cout << sum << std::endl;
    }
}

Compiler output:
a.cc:1:10: fatal error: iostrem: No such file or directory
    1 | #include <iostrem>
      |          ^~~~~~~~~
compilation terminated.
Language: Java

import collections

def main():
    n = int(input())
    a = list(map(int, input().split()))
    
    cnt = collections.defaultdict(int)
    for var in a:
        cnt[var] += 1
    
    sum_a = sum[a]
    
    q = int(input())
    for _ in range(q):
        b, c = list(map(int, input().split()))
        diff = (c-b) * cnt[b]
        sum_a += diff
        print(sum_a)
        cnt[c] += cnt[b]
        cnt[b] = 0
  
    

if __name__ == '__main__':
    main()

Compiler output:
Main.java:1: error: '.' expected
import collections
                  ^
Main.java:3: error: ';' expected
def main():
   ^
Main.java:24: error: unclosed character literal
if __name__ == '__main__':
               ^
Main.java:24: error: unclosed character literal
if __name__ == '__main__':
                        ^
4 errors