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

include <bits/stdc++.h>
using namespace std;
 
int main() {
  long int N,s;
  s=0;
  cin >> N;
  vector<int> A(100001);
  for(int i=0;i<N;i++){
    int x;
    cin >> x;
    s += x;
    A.at(x)++;
  }
  int Q;
  cin >> Q;
  for(int j=0;j<Q;j++){
    long int B,C;
    cin >> B >> C;
    A.at(C) += A.at(B);
    s += (C-B)*A.at(B);
    cout << s << endl;
    A.at(B)=0;
  }
}

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:7:3: error: 'cin' was not declared in this scope
    7 |   cin >> N;
      |   ^~~
a.cc:8:3: error: 'vector' was not declared in this scope
    8 |   vector<int> A(100001);
      |   ^~~~~~
a.cc:8:10: error: expected primary-expression before 'int'
    8 |   vector<int> A(100001);
      |          ^~~
a.cc:13:5: error: 'A' was not declared in this scope
   13 |     A.at(x)++;
      |     ^
a.cc:20:5: error: 'A' was not declared in this scope
   20 |     A.at(C) += A.at(B);
      |     ^
a.cc:22:5: error: 'cout' was not declared in this scope
   22 |     cout << s << endl;
      |     ^~~~
a.cc:22:18: error: 'endl' was not declared in this scope
   22 |     cout << s << endl;
      |                  ^~~~
Language: C++

include <bits/stdc++.h>
using namespace std;
 
int main() {
  long int N,s;
  s=0;
  cin >> N;
  vector<long int> A(100001);
  for(int i=0;i<N;i++){
    int x;
    cin >> x;
    s += x;
    A.at(x)++;
  }
  int Q;
  cin >> Q;
  for(int j=0;j<Q;j++){
    long int B,C;
    cin >> B >> C;
    A.at(C) += A.at(B);
    s += (C-B)*A.at(B);
    cout << s << endl;
    A.at(B)=0;
  }
}

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:7:3: error: 'cin' was not declared in this scope
    7 |   cin >> N;
      |   ^~~
a.cc:8:3: error: 'vector' was not declared in this scope
    8 |   vector<long int> A(100001);
      |   ^~~~~~
a.cc:8:10: error: expected primary-expression before 'long'
    8 |   vector<long int> A(100001);
      |          ^~~~
a.cc:13:5: error: 'A' was not declared in this scope
   13 |     A.at(x)++;
      |     ^
a.cc:20:5: error: 'A' was not declared in this scope
   20 |     A.at(C) += A.at(B);
      |     ^
a.cc:22:5: error: 'cout' was not declared in this scope
   22 |     cout << s << endl;
      |     ^~~~
a.cc:22:18: error: 'endl' was not declared in this scope
   22 |     cout << s << endl;
      |                  ^~~~
Language: C++

#include <bits/stdc++.h>
 
using namespace std;
 
#define sf(n) scanf("%d", &n)
#define pd(n) printf("%.10lf", n)
#define pf(n) printf("%d", n)
#define p() printf("\n")
#define ps() printf(" ")
#define ll long long
#define ull unsigned long long
#define MAX 1e9
const int mod = 1000 * 1000 * 1000 + 7;
#define ex 1e18
#define dbl 2e09
#define qu(q) queue<int> q
#define pqu(q) priority_queue<int> q
#define len(s) s.length()
#define sz(x) int(x.size())
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second
#define clr(x) x.clear()
#define LOG(x) std::cout << x << std::endl;
 
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = 3.14159265359;
 
int dx[6] = {-1,-1,0,0,1,1};
int dy[6] = {-1,0,-1,1,0,1};

const int N=2e5+5;
int a[N];
map<int,int>mp;

int main(){
    int n,q;
    cin>>n;
    ll sum=0;
    for(int i=0;i<n;++i){
        cin>>a[i];
        mp[a[i]]+=1;
        sum+=a[i];
    }
    cin>>q;
    while(q--){
        int b,c;
        cin>>b>>c;
        //cout<<b<<" "<<c<<endl;
        //cout<<mp[b]<<" "<<mp[c]<<endl;
        sum-=b*1LL*mp[b];
        sum+=c**1LL*(mp[b]);
        mp[c]+=mp[b];
        mp[b]=0;
        cout<<sum<<endl;
        //cout<<mp[b]<<" "<<mp[c]<<endl;
    }
    return 0;
}







Compiler output:
a.cc: In function 'int main()':
a.cc:55:16: error: invalid type argument of unary '*' (have 'long long int')
   55 |         sum+=c**1LL*(mp[b]);
      |                ^~~~
Language: C++

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

int main()
{
    int n;
    cin >> n;
    map<int,int>ma;
    long long ans =0;
    while(n--){
        int x;
        scanf("%lld",&x);
        ma[x]++;
        ans += x;
    }
    int m;
    cin >> m;
    while(m--){
        int b,c;
        cin >> b >> c;
        ans -= ma[b]*b;
        ans += ma[b]*c;
        ma[c] +=ma[b];
        ma[b] = 0;
        cout << ans << endl;
    }
}

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

#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

template <typename T>
std::unordered_map<size_t, T> count_item(std::vector<T>& v) {
	int n = v.size();
	std::unordered_map<size_t, T> c;
	for(T& e : v) {
		c[e]++;
	}
	return c;
}

int main() {
	int n;
	cin >> n;
	vector<ll> input(n);
	ll sum = 0;
	REP(i, n) {
		cin >> input[i];
		sum += input[i];
	}
	unordered_map<int, ll> a = count_item<ll>(input);
	int q;
	cin >> q;
	vector<ll> result;
	REP(i, q) {
		ll b, c;
		cin >> b >> c;
		sum = sum - (b * a[b]) + (c * a[b]);
		a[c] += a[b];
		a[b] = 0;
		result.push_back(sum);
	}

	EACH(e, result) { cout << e << endl; }

	return 0;
}


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

#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

template <typename T>
std::unordered_map<size_t, T> count_item(std::vector<T>& v) {
	int n = v.size();
	std::unordered_map<size_t, T> c;
	for(T& e : v) {
		c[e]++;
	}
	return c;
}

int main() {
	int n;
	cin >> n;
	VI input(n);
	ll sum = 0;
	REP(i, n) {
		cin >> input[i];
		sum += input[i];
	}
	unordered_map<int, ll> a = count_item(input);
	int q;
	cin >> q;
	vector<ll> result;
	REP(i, q) {
		ll b, c;
		cin >> b >> c;
		sum = sum - (b * a[b]) + (c * a[b]);
		a[c] += a[b];
		a[b] = 0;
		result.push_back(sum);
	}

	EACH(e, result) { cout << e << endl; }

	return 0;
}


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

#include <iostream>

using namespace std;

typedef pair<ll,ll> p;
#define MAX (int)1e5
typedef long long int ll;

ll num[MAX+1];
p trans[MAX];
int main(void){
  for(int i=0;i<=MAX;i++){
    num[i] = 0;
  }
  int N;
  cin >> N;
  for(int n=0;n<N;n++){
    int tmp;
    cin >> tmp;
    num[tmp] += 1;
  }
  int Q;
  cin >> Q;
  ll ans = 0;
  for(int n=1;n<=MAX;n++){
    ll tmp = num[n];
    tmp = tmp * (ll)n;
    ans += tmp;
  }
  for(int q=0;q<Q;q++){
    int b,c;
    cin >> b >> c;
    trans[q] = make_pair(b,c);
  }
  for(int q=0;q<Q;q++){
    ll b,c;
    b = trans[q].first;
    c = trans[q].second;
    ans = ans - b*num[b] + c*num[b];
    num[c] += num[b];
    num[b] = 0;
    cout << ans << endl;
  }
  return 0;
}

Compiler output:
a.cc:5:14: error: 'll' was not declared in this scope
    5 | typedef pair<ll,ll> p;
      |              ^~
a.cc:5:17: error: 'll' was not declared in this scope
    5 | typedef pair<ll,ll> p;
      |                 ^~
a.cc:5:19: error: template argument 1 is invalid
    5 | typedef pair<ll,ll> p;
      |                   ^
a.cc:5:19: error: template argument 2 is invalid
a.cc: In function 'int main()':
a.cc:33:25: error: cannot convert 'std::pair<int, int>' to 'p' {aka 'int'} in assignment
   33 |     trans[q] = make_pair(b,c);
      |                ~~~~~~~~~^~~~~
      |                         |
      |                         std::pair<int, int>
a.cc:37:18: error: request for member 'first' in 'trans[q]', which is of non-class type 'p' {aka 'int'}
   37 |     b = trans[q].first;
      |                  ^~~~~
a.cc:38:18: error: request for member 'second' in 'trans[q]', which is of non-class type 'p' {aka 'int'}
   38 |     c = trans[q].second;
      |                  ^~~~~~
Language: C++

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:8:25: error: 'MX' was not declared in this scope
    8 |   vector<long long> cnt(MX);
      |                         ^~
Language: C++

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

int main() {
    int N, Q;
    cin >> N;
    int A[100010]={0};
    for (int i=0; i<N; i++) {
        int a;
        cin >> a;
        A[a]++;
    }
    int sum=0;
    for (int i=0; i<N; i++) {
        sum+=i*A[i];
    }
    cin >> Q; 
    pair <int, int> B[Q];
    for (int i=0; i<Q; i++) cin >> B[i].first >> B[i].second;
    for (int i=0; i<Q; i++){
        if (C[B[i].first]){
            sum=sum+(B[i].second-B[i].first)*C[B[i].first];
            C[B[i].second]+=C[B[i].first];
            C[B[i].first]=0;
            cout << sum << endl; 
        }
        else cout << sum << endl;
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:13: error: 'C' was not declared in this scope
   21 |         if (C[B[i].first]){
      |             ^
Language: C++

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

int main() {
  long N, Q, B, C, T, Sum=0;
  cin >> N;
  vector<long> A(100000,0)
  rep(i, N){
    cin >> T;
    A.at(T)++;
    Sum+=T;
  }
  cin >> Q;
  rep(i, Q){
    cin >> B >> C;
    Sum+=A.at(B)*(C-B);
    A.at(C)+=A.at(B);
    A.at(B)=0;
    cout << Sum << endl;
  }
}

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

#include <iostream>
#include <numeric>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int q, b, c;
  cin >> q;
  rep(i, q) {
    cin >> b >> c;
    replace(a.begin(), a.end(), b, c);
    printf("%d\n", accumulate(a.begin(), a.end(), 0));
  }

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:5: error: 'replace' was not declared in this scope
   17 |     replace(a.begin(), a.end(), b, c);
      |     ^~~~~~~
Language: C++

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

int main(){
    int n;
    cin>>n;
    
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    
    int q;
    cin>>q;
    vector<int> b(q);
    vector<int> c(q);
    rep(i,q) cin>>b[i]>>c[i];
    
    vector<int> num(100005,0);
    rep(i,n) num[a[i]]++;
    int sum=accumulate(a.begin(),a.end(),0);
    
    rep(i,q){
        sum +=(c[i]-b[i])*num[b[i]];
        cout<<sum<<endl;
        num[C[i]]+=num[b[i]];
        b[i]=0;
    }
    
    return 0;
}

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

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vl vector<ll>
#define pl pair<ll,ll>
#define TC int t;cin>>t;while(t--)
#define in(n) ll n;cin>>n;
#define inarr(n) ll n;cin>>n;vector<ll>arr;
int main(void){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    inarr(n);
    ll sum=0;
    ll check[100005];
    memset(check,0,sizeof(check));
    for(int i=0;i<n;i++){
        in(temp);arr.push_back(temp);
        sum+=temp;
        check[temp]++;
    }
    in(q);
    while (q--){
        in(b);in(c);
        int t = check[b];
        sum = sum-t*b+t*c;
        check[c]+=t;
        cout<<sum<<endl;g
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:25: error: 'g' was not declared in this scope
   26 |         cout<<sum<<endl;g
      |                         ^
Language: C++

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

int main(){
    int n;
    // scanf("%d", &n);
    cin >> n;
    int a[n], cnt[100010];
    ll sum = 0;
    for(int i = 0;  i < n; i++){
        // scanf("%d", &a[i]);
        cin >> a[i];
        sum += a[i];
        cnt[a[i]]++;a
    }
    int q, b, c;
    // scanf("%d", &q);
    cin >> q;
    for(int i = 0; i < q; i++){
        // scanf("%d%d", &b, &c);
        cin >> b >> c;
        if(cnt[b]){
            sum += cnt[b]*(c-b);
            cnt[c] += cnt[b];
            cnt[b] = 0;
        }
        // printf("%ld\n", sum);
        cout << sum << "\n";
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:22: error: expected ';' before '}' token
   15 |         cnt[a[i]]++;a
      |                      ^
      |                      ;
   16 |     }
      |     ~
Language: C++

#include<bits/stdc++.h>
using namespace std;
 
int main()
{
  int i, n, q, q1, q2 arr[100011], num_ap[100011] = {0};
  long sum = 0, ans[100011];
  scanf("%d", &n);
  for(i = 0 ; i < n ; i++)
  {
    scanf("%d", &arr[i]);
    num_ap[arr[i]]++;
    sum += arr[i];
  }
  scanf("%d", &q);
  for(i = 0 ; i < q ; i++)
  {
      scanf("%d %d", &q1, &q2);
      long nums = num_ap[q1];
      num_ap[q1] = 0;
      num_ap[q2] += nums;
      sum += (q2 * nums);
      sum -= (q1 * nums);
      ans[i] = sum;
  }
  for(i = 0 ; i < q ; i++)
      printf("%ld\n",ans[i]);
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:23: error: expected initializer before 'arr'
    6 |   int i, n, q, q1, q2 arr[100011], num_ap[100011] = {0};
      |                       ^~~
a.cc:11:18: error: 'arr' was not declared in this scope
   11 |     scanf("%d", &arr[i]);
      |                  ^~~
a.cc:12:5: error: 'num_ap' was not declared in this scope
   12 |     num_ap[arr[i]]++;
      |     ^~~~~~
a.cc:18:28: error: 'q2' was not declared in this scope; did you mean 'q1'?
   18 |       scanf("%d %d", &q1, &q2);
      |                            ^~
      |                            q1
a.cc:19:19: error: 'num_ap' was not declared in this scope
   19 |       long nums = num_ap[q1];
      |                   ^~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
 
int main()
{
  int i, n, q, q1, q2 arr[100011], num_ap[100011] = {0};
  long sum = 0;
  scanf("%d", &n);
  for(i = 0 ; i < n ; i++)
  {
    scanf("%d", &arr[i]);
    num_ap[arr[i]]++;
    sum += arr[i];
  }
  scanf("%d", &q);
  for(i = 0 ; i < q ; i++)
  {
      scanf("%d %d", &q1, &q2);
      long nums = num_ap[q1];
      num_ap[q1] = 0;
      num_ap[q2] += nums;
      sum += (q2 * nums);
      sum -= (q1 * nums);
      ans[i] = sum;
  }
  for(i = 0 ; i < q ; i++)
      printf("%ld\n",ans[i]);
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:23: error: expected initializer before 'arr'
    6 |   int i, n, q, q1, q2 arr[100011], num_ap[100011] = {0};
      |                       ^~~
a.cc:11:18: error: 'arr' was not declared in this scope
   11 |     scanf("%d", &arr[i]);
      |                  ^~~
a.cc:12:5: error: 'num_ap' was not declared in this scope
   12 |     num_ap[arr[i]]++;
      |     ^~~~~~
a.cc:18:28: error: 'q2' was not declared in this scope; did you mean 'q1'?
   18 |       scanf("%d %d", &q1, &q2);
      |                            ^~
      |                            q1
a.cc:19:19: error: 'num_ap' was not declared in this scope
   19 |       long nums = num_ap[q1];
      |                   ^~~~~~
a.cc:24:7: error: 'ans' was not declared in this scope; did you mean 'abs'?
   24 |       ans[i] = sum;
      |       ^~~
      |       abs
a.cc:27:22: error: 'ans' was not declared in this scope; did you mean 'abs'?
   27 |       printf("%ld\n",ans[i]);
      |                      ^~~
      |                      abs
Language: C

# -*- coding: utf-8 -*-
"""
Created on Sun Jun 21 23:57:41 2020

@author: Administrator
"""
N = int(input())
A = list(map(int,input().split()))
Q = int(input())
while(Q):
    B,C=map(int,input().split())
    A.sort()
    lo = 0
    hi = N-1
    while(lo<hi):
        mid = lo + (hi-lo)//2
        if A[mid]>=B:
            hi = mid
        else:
            lo = mid + 1
    while(A[lo]==B):
        A[lo]=C
        lo += 1
    #print(A)
    print(sum(A))
    Q -= 1

Compiler output:
main.c:1:3: error: invalid preprocessing directive #-
    1 | # -*- coding: utf-8 -*-
      |   ^
main.c:2:1: error: expected identifier or '(' before string constant
    2 | """
      | ^~
main.c:2:3: warning: missing terminating " character
    2 | """
      |   ^
main.c:2:3: error: missing terminating " character
main.c:5:1: error: stray '@' in program
    5 | @author: Administrator
      | ^
main.c:6:3: warning: missing terminating " character
    6 | """
      |   ^
main.c:6:3: error: missing terminating " character
main.c:24:6: error: invalid preprocessing directive #print
   24 |     #print(A)
      |      ^~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
 
int main()
{
  int i, n, q, arr[100011], num_ap[100011] = {0};
  long double sum = 0, ans[100011], q1, q2;
  scanf("%d", &n);
  for(i = 0 ; i < n ; i++)
  {
    scanf("%d", &arr[i]);
    num_ap[arr[i]]++;
    sum += arr[i];
  }
  scanf("%d", &q);
  for(i = 0 ; i < q ; i++)
  {
      scanf("%ld %ld", &q1, &q2);
      long nums = num_ap[q1];
      num_ap[q1] = 0;
      num_ap[q2] += nums;
      sum += (q2 * nums);
      sum -= (q1 * nums);
      ans[i] = sum;
  }
  for(i = 0 ; i < q ; i++)
      printf("%ld\n",ans[i]);
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:25: error: invalid types 'int [100011][long double]' for array subscript
   19 |       long nums = num_ap[q1];
      |                         ^
a.cc:20:13: error: invalid types 'int [100011][long double]' for array subscript
   20 |       num_ap[q1] = 0;
      |             ^
a.cc:21:13: error: invalid types 'int [100011][long double]' for array subscript
   21 |       num_ap[q2] += nums;
      |             ^
Language: Java

import java.util.Scanner;
class Main{
    public static void main(String []args){
    Scanner input=new Scanner(System.in);
      long result=0;
      int N=input.nextInt();
      int sum[]=new int[100001];
    for(int i=0;i<N;++i){
      int temp=input.nextInt();
      ++sum[temp];
      result+=temp;
    }int operation=input.nextInt();
      for(int j=0;j<operation;j++){
        int B=input.nextInt();
        int C=input.nextInt();
          if( arr[num] != 0 ){
                arr[replace] += arr[num];
                total += ( replace - num ) *  arr[num];
                arr[num] = 0;
            }
            System.out.println(total);
        }
    }
}


Compiler output:
Main.java:16: error: cannot find symbol
          if( arr[num] != 0 ){
              ^
  symbol:   variable arr
  location: class Main
Main.java:16: error: cannot find symbol
          if( arr[num] != 0 ){
                  ^
  symbol:   variable num
  location: class Main
Main.java:17: error: cannot find symbol
                arr[replace] += arr[num];
                ^
  symbol:   variable arr
  location: class Main
Main.java:17: error: cannot find symbol
                arr[replace] += arr[num];
                    ^
  symbol:   variable replace
  location: class Main
Main.java:17: error: cannot find symbol
                arr[replace] += arr[num];
                                ^
  symbol:   variable arr
  location: class Main
Main.java:17: error: cannot find symbol
                arr[replace] += arr[num];
                                    ^
  symbol:   variable num
  location: class Main
Main.java:18: error: cannot find symbol
                total += ( replace - num ) *  arr[num];
                ^
  symbol:   variable total
  location: class Main
Main.java:18: error: cannot find symbol
                total += ( replace - num ) *  arr[num];
                           ^
  symbol:   variable replace
  location: class Main
Main.java:18: error: cannot find symbol
                total += ( replace - num ) *  arr[num];
                                     ^
  symbol:   variable num
  location: class Main
Main.java:18: error: cannot find symbol
                total += ( replace - num ) *  arr[num];
                                              ^
  symbol:   variable arr
  location: class Main
Main.java:18: error: cannot find symbol
                total += ( replace - num ) *  arr[num];
                                                  ^
  symbol:   variable num
  location: class Main
Main.java:19: error: cannot find symbol
                arr[num] = 0;
                ^
  symbol:   variable arr
  location: class Main
Main.java:19: error: cannot find symbol
                arr[num] = 0;
                    ^
  symbol:   variable num
  location: class Main
Main.java:21: error: cannot find symbol
            System.out.println(total);
                               ^
  symbol:   variable total
  location: class Main
14 errors
Language: C++

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


int main()
{  
  #ifndef ONLINE_JUDGE
	 freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  #endif

   long long n;
   cin>>n;
   map<long long, long long> m;
   long long a[n];
   long long sum=0;
   for(int i=0; i<n; i++)
   	 {cin>>a[i]; m[a[i]]++; sum+=a[i];}

   long long k;
   cin>>k;

   while(k--)
   { long long l,r;
   	 cin>>l>>r;

   	 sum-=l*m[l];
   	 sum+= r*m[l];
   	 m[r]+= m[l];
   	 m[l]=0;

   	 cout<<sum<<endl;
      


   }

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

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

const int MX = 100005;
 
int main(){
  ll n;
  cin >> n;
  vector<ll> cnt(MX);
  rep(i,n){
    int a;
    cin >> a;
    cnt[a]++;
  }
  ll tot = 0;
  rep(i,MX)tot += i*cnt[i];
  //変化量で計算
  int q;
  cin >> q;
  rep(i,q){
    int b, c;
    cin >> b >> c;
    tot += (c-b)*cnt[b];
  }
  cout << f(n) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:11: error: 'f' was not declared in this scope
   27 |   cout << f(n) << endl;
      |           ^
Language: Java

import java.util.Scanner;
class Main{
    public static void main(String []args){
    Scanner input=new Scanner(System.in);
      int result=0;
      int N=input.nextInt();
      int sum[]=new int[100001];
    for(int i=0;i<N;++i){
      int temp=input.next();
      ++sum[temp];
      result+=temp;
    }int operation=input.nextInt();
      for(int j=0;j<operation;j++){
        int B=input.nextInt();
        int C=input.nextInt();
        if(sum[B]!=0){
          int temp=sum[B];
          sum[B]=0;
          sum[C]=temp;
          result+=((C-B)*temp);
        }
        System.out.println(result);
      }
    }
}


Compiler output:
Main.java:9: error: incompatible types: String cannot be converted to int
      int temp=input.next();
                         ^
1 error
Language: Java

import java.util.Scanner;
class Main{
    public static void main(String []args){
    Scanner input=new Scanner(System.in);
      int result=0;
      int N=input.next();
      int sum[]=new int[100001];
    for(int i=0;i<N;++i){
      int temp=input.next();
      ++sum[temp];
      result+=temp;
    }int operation=new input.nextInt();
      for(int j=0;j<operation;j++){
        int B=input.nextInt();
        int C=input.nextInt();
        if(sum[B]!=0){
          int temp=sum[B];
          sum[B]=0;
          sum[C]=temp;
          result+=((C-B)*temp);
        }
        System.out.println(result);
      }
    }
}


Compiler output:
Main.java:6: error: incompatible types: String cannot be converted to int
      int N=input.next();
                      ^
Main.java:9: error: incompatible types: String cannot be converted to int
      int temp=input.next();
                         ^
Main.java:12: error: package input does not exist
    }int operation=new input.nextInt();
                            ^
3 errors
Language: Java

import java.util.Scanner;
class Main{
    public static void main(String []args){
    Scanner input=new Scanner(System.in);
      int result=0;
      int N=input.next();
      int sum[]=new int[100001];
    for(int i=0;i<N;++i){
      int temp=input.next()
      ++sum[temp];
      result+=temp;
    }int operation=new input.nextInt();
      for(int j=0;j<operation;j++){
        int B=input.nextInt();
        int C=input.nextInt();
        if(sum[B]!=0){
          int temp=sum[B];
          sum[B]=0;
          sum[C]=temp;
          result+=((C-B)*temp);
        }
        System.out.println(result);
      }
    }
}

Compiler output:
Main.java:10: error: ';' expected
      ++sum[temp];
        ^
Main.java:10: error: not a statement
      ++sum[temp];
           ^
2 errors
Language: C++

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

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

#include<iostream>
using namespace std;
int main(){
  int n1,n2,i,a[99];
  cin>>n1;
  for(i=0;i<n;i++) cin>>a[i];
  cin>>n2;
  for(i=0;i<n2;i++){
    int x,y,tong=0;
    cin>>x>>y;
    for(int j=0;j<n1;j++){
      if(a[i]==x) {a[i]=y; tong+=y;}
      else tong+=a[i];
    }
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:13: error: 'n' was not declared in this scope
    6 |   for(i=0;i<n;i++) cin>>a[i];
      |             ^
Language: Java

import java.util.*;
class Main{
  public static void main(String[] args){
Scanner sc=new Scanner(System.in);
		    int n=sc.nextInt();
		    long sum=0;
		    Map<Long,Long> m=new HashMap<>();
		    for(int i=0;i<n;i++){
		    		long c=sc.nextLong();
		    		sum+=c;
		    		if(!m.containsKey(c)) {
		    			m.put(c,1);
		    		}else {
		    			m.put(c,m.get(c)+1);
		    		}
		    }int k=sc.nextInt();
		    for(int i=0;i<k;i++) {
		    	 long prev=sc.nextLong();
				    long fill=sc.nextLong();
				    if(m.containsKey(prev)) {
				    long g=m.get(prev);
				    sum=sum-prev*g;
				    sum=sum+fill*g;
				  				    m.remove(prev);
				    
				    if(!m.containsKey(fill)) {
		    			m.put(fill,g);
		    		}else {
		    			m.put(fill,m.get(fill)+g);
		    		}
				    
                    }
				    System.out.println(sum);
		    }
		    
		   
		 

  }
    
  }


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

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

int main() {
cin>>N;
vector<int> vec(100000);
  int Q,Ans;
  Ans=0;
  rep(i,N){cin >> Q; Ans+=Q; vec.at(Q-1)++;}
  int B,C;
    cin>>Q;
    rep(i,Q){cin>>B>>C;
            Ans+=(C-B)*vec.at(B);
             vec.at(C)+=vec.at(B);
            vec.at(B)==0;
            cout<<Ans<<endl;}
}


Compiler output:
a.cc: In function 'int main()':
a.cc:6:6: error: 'N' was not declared in this scope
    6 | cin>>N;
      |      ^
Language: C++

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

int main() {
cin>>N;
vector<int> vec(100000);
  int Q,Ans;
  Ans=0;
  rep(i,N){cin >> Q;Ans+=Q; vec.at(Q-1)++;}
  int B,C
    cin>>Q;
    rep(i,Q){cin>>B>>C;
            Ans+=(C-B)*vec.at(B-1);
             vec.at(C-1)+=vec.at(B-1);
            vec.at(B-1)==0;
            cout<<Ans<<endl;}
}


Compiler output:
a.cc: In function 'int main()':
a.cc:6:6: error: 'N' was not declared in this scope
    6 | cin>>N;
      |      ^
a.cc:12:5: error: expected initializer before 'cin'
   12 |     cin>>Q;
      |     ^~~
a.cc:13:22: error: 'C' was not declared in this scope
   13 |     rep(i,Q){cin>>B>>C;
      |                      ^
Language: C++

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

int main() {
  int N;
cin>>N;
vector<int> vec(100000);
  int Q,Ans;
  Ans=0;
  rep(i,N){cin >> Q;Ans+=Q;vec.at(Q-1)++;}
  int B,C
    cin>>Q;
    rep(i,Q){cin>>B>>C;
            Ans+=(C-B)*vec.at(B);
             vec.at(C)+=vec.at(B);
            vec.at(B)==0;
            cout<<Ans<<endl;}
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:5: error: expected initializer before 'cin'
   13 |     cin>>Q;
      |     ^~~
a.cc:14:22: error: 'C' was not declared in this scope
   14 |     rep(i,Q){cin>>B>>C;
      |                      ^
Language: C++

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

int main() {
cin>>N;
vector<int> vec(100000);
  int Q,Ans;
  Ans=0;
  rep(i,N){cin >> Q;Ans+=Q;vec.at(Q-1)++;}
  int B,C
    cin>>Q;
    rep(i,Q){cin>>B>>C;
            Ans+=(C-B)*vec.at(B);
             vec.at(C)+=vec.at(B);
            vec.at(B)==0;
            cout<<Ans<<endl;}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:6: error: 'N' was not declared in this scope
    6 | cin>>N;
      |      ^
a.cc:12:5: error: expected initializer before 'cin'
   12 |     cin>>Q;
      |     ^~~
a.cc:13:22: error: 'C' was not declared in this scope
   13 |     rep(i,Q){cin>>B>>C;
      |                      ^
Language: C++

#include <iostream>
#include <unordered_map>

using namespace std;

long long Sum(const unordered_map<int, int> &m)
{
    int sum = 0;
    for (const auto &pair : m)
    {
        sum += pair.first * pair.second;
    }
    return sum;
}

int main()
{
    unordered_map<int, int> mapnum;

    int N, A;
    cin >> N;
    for (int i = 0; i < N; ++i)
    {
        cin >> A;
        mapnum[A]++;
    }

    long long sum = Sum(mapnum);

    long long Q, B, C;
    cin >> Q;
    for (int i = 0; i < Q; ++i)
    {
        cin >> B >> C;
        if (mapnum.find(B) != mapnum.end())
        {
            long long &b = mapnum[B];
            long long &c = mapnum[C];

            c += b;
            sum -= B * b;
            sum += C * b;
            b = 0;
        }

        cout << sum << endl;
    }

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:37:36: error: cannot bind non-const lvalue reference of type 'long long int&' to a value of type 'std::unordered_map<int, int>::mapped_type' {aka 'int'}
   37 |             long long &b = mapnum[B];
      |                                    ^
a.cc:38:36: error: cannot bind non-const lvalue reference of type 'long long int&' to a value of type 'std::unordered_map<int, int>::mapped_type' {aka 'int'}
   38 |             long long &c = mapnum[C];
      |                                    ^
Language: Java

import java.util.*;
class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    Map<Integer,Integer> m = HashMap<>();
    long sum = 0;
    for(int i = 0; i < N; i++){
      int A = sc.nextInt();
      m.put(A, m.getOrDefault(A,0)+1);
      sum += A;
    }
    StringBuilder ans = new StringBuilder();
    int Q = sc.nextInt();
    for(int i = 0; i < Q; i++){
      int B = sc.nextInt();
      int C = sc.nextInt();
      if(!m.containsKey(B)){
        ans.append(sum).append("\n");
        continue;
      }
      int num = m.get(B);
      sum -= (long) num*B;
      sum += (long) num*C;
      m.put(C,m.getOrDefault(C,0)+num);
      m.remove(B);
      ans.append(sum).append("\n");
    }
    System.out.println(ans);
  }
}

Compiler output:
Main.java:6: error: illegal start of expression
    Map<Integer,Integer> m = HashMap<>();
                                     ^
Main.java:6: error: -> expected
    Map<Integer,Integer> m = HashMap<>();
                                        ^
2 errors
Language: C++

#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
long long int a[100000]
int main()
{
    long long int n,i,x,y,t,s,d;
   scanf("%lld",&n);
   s=0;
    for(i=0;i<n;i++)
    {
        scanf("%lld",&d);
        a[d]++;
        s+=d;
    }
   scanf("%lld",&t);
    while(t--)
    {
        scanf("%lld%lld",&x,&y);
       a[y]+=a[x];
       s+=(y-x)*a[x];
       a[x]=0;
        printf("%lld\n",s);
    }
    return 0;
}



Compiler output:
a.cc:5:1: error: expected initializer before 'int'
    5 | int main()
      | ^~~
Language: C++

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

const double PI = acos(-1);
const int MAX = 100005;

int main() {
    int a,n,q;
  	ll X[MAX];
    vector<int> v;
    cin >> n;
    rep(i,n) {
        cin >> a;
        X[a]++;
    }
    cin >> q;
    vector<ll> sum(q+1);
  	sum[0] = 0;
    rep(i,MAX) {
        sum[0] += i * X[i];
    }
    for(int i = 1; i <= q; ++i) {
        int b,c;
        cin >> b >> c;
        ll tmp_b = X[b];
        X[b] = 0;
        X[c] += tmp_b;
        
        sum[i] = sum[i-1] - tmp_b*b + tmp_b*c;
    }
    
    for(int i = 1; i <= q; ++i) cout << sum[i] << "\n";
    return 0;
}

Compiler output:
a.cc:5:24: error: expected ';' before 'using'
    5 | using p = pair<int,int>
      |                        ^
      |                        ;
    6 | using Graph = vector<vector<int>>
      | ~~~~~
Language: C++

#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int n;
  cin >> n;
  map<ll,ll>mp;
  vector<ll>a(n);
  ll sum = 0;
  rep(i,n){
    cin >> a[i];
    mp[a[i]]++;
    sum += a[i];
  }
  
  int q;
  cin >> q;
  while(q--){
    ll b,c;
    cin >> b >> c;
    ll cnt = mp[b];
    ans -= b*cnt;
    ans += c*cnt;
    mp[b]=0;
    mp[c]+=cnt;
    cout << ans << endl;
  }
    
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:41:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   41 |     ans -= b*cnt;
      |     ^~~
      |     abs
Language: C++

int main() {
    //入力
    int n, q, b, c;
    int a[100010];
    long long ans[100010]={0};
    cin >> n;
    for (int i=1; i<=n; i++) cin >> a[i];
    cin >> q;
    for (int i=1; i<=q; i++) {
        cin >> b >> c;
        for (int j=1; j<=n; j++) {
            if (a[j]==b) {
                a[j]=c;
                ans[i] += c;
            }
            else {
                ans[i] += a[j];
            }
        }
    }
    for (int i=1; i<=q; i++) cout << ans[i] << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:5: error: 'cin' was not declared in this scope
    6 |     cin >> n;
      |     ^~~
a.cc:21:30: error: 'cout' was not declared in this scope
   21 |     for (int i=1; i<=q; i++) cout << ans[i] << endl;
      |                              ^~~~
a.cc:21:48: error: 'endl' was not declared in this scope
   21 |     for (int i=1; i<=q; i++) cout << ans[i] << endl;
      |                                                ^~~~
Language: C++

#include <bits/stdc++.h>
#define LL long long
#define MOD 1000000007
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0)
using namespace std;

int main()
{
    fastio;
  	int n;
  	cin>>n;
  	LL a[n],sum=0;
  	  count[100000+7];
    
  memset(count,0,sizeof(count));
  for(int i=0;i<n;i++){
    cin>>a[i];
    count[a[i]]++;
    sum+=a[i];
  }
  

  int q;
  cin>>q;
  while(q--){
   
   int b,c;
   cin>>b>>c;
   if(count[b]>0){
     sum = sum-(b*count[b]+c*count[b]);
     count[c]+= count[b];
     count[b]=0;

   }
     cout<<sum<<"\n";
  }
   
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:16: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   13 |           count[100000+7];
      |                ^
a.cc:15:18: error: ISO C++ forbids applying 'sizeof' to an expression of function type [-fpermissive]
   15 |   memset(count,0,sizeof(count));
      |                  ^~~~~~~~~~~~~
a.cc:15:9: error: cannot resolve overloaded function 'count' based on conversion to type 'void*'
   15 |   memset(count,0,sizeof(count));
      |   ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
a.cc:18:10: error: invalid types '<unresolved overloaded function type>[long long int]' for array subscript
   18 |     count[a[i]]++;
      |          ^
a.cc:29:12: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   29 |    if(count[b]>0){
      |            ^
a.cc:30:24: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   30 |      sum = sum-(b*count[b]+c*count[b]);
      |                        ^
a.cc:30:35: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   30 |      sum = sum-(b*count[b]+c*count[b]);
      |                                   ^
a.cc:31:11: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   31 |      count[c]+= count[b];
      |           ^
a.cc:31:22: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   31 |      count[c]+= count[b];
      |                      ^
a.cc:32:11: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   32 |      count[b]=0;
      |           ^
Language: Java

import java.util.*;
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 t = sc.nextInt();
    while(t-- >0)
    {
      int b[0]=sc.nextInt();
      int b[1]=sc.nextInt();
      for(int i=0;i<n;i++)
      {
        if(b[0]==a[i])
          a[i]=b[1];
      }
      int sum=0;
      for(int i=0;i<n;i++)
      {
        sum=sum+a[i];
      }
      System.out.println(sum);
    }
  }
}
   
   


Compiler output:
Main.java:18: error: ']' expected
      int b[0]=sc.nextInt();
            ^
Main.java:19: error: ']' expected
      int b[1]=sc.nextInt();
            ^
2 errors
Language: C++

#include <iostream>
#include <vector>

using namespace std;

const int max = 100001;
int sum(const vector<int> &vec)
{
    int sum = 0;
    for (int i = 0; i < max; ++i)
    {
        sum += vec.at(i) * i;
    }
    return sum;
}

int main()
{
    vector<int> vec(max);

    int N, A;
    cin >> N;
    for (int i = 0; i < N; ++i)
    {
        cin >> A;
        vec.at(A)++;
    }

    int Q, B, C;
    cin >> Q;
    for (int i = 0; i < Q; ++i)
    {
        cin >> B >> C;
        int &b = vec.at(B);
        int &c = vec.at(C);
        if (b > 0)
        {
            c += b;
            b = 0;
        }
        cout << sum(vec) << endl;
    }

    return 0;
}

Compiler output:
a.cc: In function 'int sum(const std::vector<int>&)':
a.cc:10:25: error: reference to 'max' is ambiguous
   10 |     for (int i = 0; i < max; ++i)
      |                         ^~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:                 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
a.cc:6:11: note:                 'const int max'
    6 | const int max = 100001;
      |           ^~~
a.cc: In function 'int main()':
a.cc:19:21: error: reference to 'max' is ambiguous
   19 |     vector<int> vec(max);
      |                     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:                 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
a.cc:6:11: note:                 'const int max'
    6 | const int max = 100001;
      |           ^~~
Language: C++

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

int main(){
    int n;
    cin >> n;
    map<int, int> map;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        map[a]++;
        ans += a;
    }
    int q;
    cin >> q;

    long long ans = 0;
    for(int i = 0; i < q; i++){
        int b,c;
        cin >> b >> c;
        if(map[b] != 0){
            ans += (c - b)*map[b];
            map[c] += map[b];
            map[b] = 0; 
        }
        cout << ans << endl;
    }

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   12 |         ans += a;
      |         ^~~
      |         abs
Language: C++

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

int main(){
    int n;
    cin >> n;
    map<int, int> map;
    for(int i = 0; i < n; i++){
        int a
        cin >> a;
        map[a]++;
        ans += a;
    }
    int q;
    cin >> q;

    long long ans = 0;
    for(int i = 0; i < q; i++){
        int b,c;
        cin >> b >> c;
        if(map[b] != 0){
            ans += (c - b)*map[b];
            map[c] += map[b];
            map[b] = 0; 
        }
        cout << ans << endl;
    }

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:9: error: expected initializer before 'cin'
   10 |         cin >> a;
      |         ^~~
a.cc:11:13: error: 'a' was not declared in this scope
   11 |         map[a]++;
      |             ^
a.cc:12:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   12 |         ans += a;
      |         ^~~
      |         abs
Language: C++

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

int main(){
  int N,Q;
  cin >>N; 
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin >> a[i];
  }
  cin >>Q;
  vector<int> b(Q);
  vector<int> c(Q);
  for(int i=0;i<Q;i++){
    cin >>b[i];
    cin >>c[i];
    cout << b[i]<< c[i] <<endl;
  }
  
  

Compiler output:
a.cc: In function 'int main()':
a.cc:18:4: error: expected '}' at end of input
   18 |   }
      |    ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^
Language: Java

import java.util.*;
public class Main
 public static void main(String[] args)
  {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int a[]=new int[n];
    int sum=0;
    for(int i=0;i<n;i++)
    {a[i]=sc.nextInt();sum+=a[i];}
    Arrays.sort(a);
    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;Arrays.sort(a);sum=sum-b+c;}
       if(a[i]>b)
       break;
     }System.out.println(sum);
   }
    
 }
}


Compiler output:
Main.java:2: error: '{' expected
public class Main
                 ^
Main.java:3: error: unnamed classes are a preview feature and are disabled by default.
 public static void main(String[] args)
               ^
  (use --enable-preview to enable unnamed classes)
Main.java:27: error: class, interface, enum, or record expected
}
^
3 errors