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

    import java.util.Scanner;
     
    public class Main {
        public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
            int n = sc.nextInt();
            int[] a = new int[n+1];
            A[0] = 0;
            for (int i = 1; i < n+1; i++) {
                a[i] = sc.nextInt();
            }
            int q = sc.nextInt();
            int[] b = new int[q+1];
            int[] c = new int[q+1];
            b[0] = 0;
            c[0] = 0;
            for (int i= 1; i < q+1; i++) {
                b[i] = sc.nextInt();
                c[i] = sc.nextInt();
            }
            long[] s = new long[q+1];
            s[0] = 0;
            for (int i = 0; i < a.length; i++) {
                S[0] = S[0] + a[i];
            }
            int[] num = new int[100000+1];
          for (int i = 0; i < num.length; i++) {
            num[i] = 0;
           }
            for (int i = 1; i < a.length; i++) {
                num[a[i]] = num[a[i]] + 1;
            }
            for (int i = 1; i < q+1; i++) {
                s[i] = (c[i]-b[i])*num[b[i]] + s[i-1];
                System.out.println(s[i]);
                num[c[i]] = num[c[i]] + num[b[i]];
                num[b[i]] = 0;
            }
        }
    }

Compiler output:
Main.java:8: error: cannot find symbol
            A[0] = 0;
            ^
  symbol:   variable A
  location: class Main
Main.java:24: error: cannot find symbol
                S[0] = S[0] + a[i];
                ^
  symbol:   variable S
  location: class Main
Main.java:24: error: cannot find symbol
                S[0] = S[0] + a[i];
                       ^
  symbol:   variable S
  location: class Main
3 errors
Language: Java

    import java.util.Scanner;
     
    public class Main {
        public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
            int n = sc.nextInt();
            int[] a = new int[n+1];
            a[0] = 0;
            for (int i = 1; i < n+1; i++) {
                a[i] = sc.nextInt();
            }
            int q = sc.nextInt();
            int[] b = new int[q+1];
            int[] c = new int[q+1];
            b[0] = 0;
            c[0] = 0;
            for (int i= 1; i < q+1; i++) {
                b[i] = sc.nextInt();
                c[i] = sc.nextInt();
            }
            long[] s = new long[q+1];
            s[0] = 0;
            for (int i = 0; i < a.length; i++) {
                s[0] = s[0] + a[i];
            }
            int[] n = new int[100000+1];
         for (int i = 0; i < n.length; i++) {
           n[i] = 0;
           }
            for (int i = 1; i < a.length; i++) {
                n[a[i]] = n[a[i]] + 1;
            }
            for (int i = 1; i < q+1; i++) {
                s[i] = (c[i]-b[i])*n[b[i]] + s[i-1];
                System.out.println(s[i]);
                n[c[i]] = n[c[i]] + n[b[i]];
                n[b[i]] = 0;
            }
        }
    }

Compiler output:
Main.java:26: error: variable n is already defined in method main(String[])
            int[] n = new int[100000+1];
                  ^
1 error
Language: Java

    import java.util.Scanner;
     
    public class Main {
        public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
            int n = sc.nextInt();
            int[] a = new int[n+1];
            A[0] = 0;
            for (int i = 1; i < n+1; i++) {
                a[i] = sc.nextInt();
            }
            int q = sc.nextInt();
            int[] b = new int[q+1];
            int[] c = new int[q+1];
            b[0] = 0;
            c[0] = 0;
            for (int i= 1; i < q+1; i++) {
                b[i] = sc.nextInt();
                c[i] = sc.nextInt();
            }
            long[] s = new long[q+1];
            s[0] = 0;
            for (int i = 0; i < a.length; i++) {
                S[0] = S[0] + a[i];
            }
            int[] n = new int[100000+1];
            for (int i = 0; i < n.length; i++) {
                n[i] = 0;
            }
            for (int i = 1; i < a.length; i++) {
                n[a[i]] = n[a[i]] + 1;
            }
            for (int i = 1; i < q+1; i++) {
                s[i] = (c[i]-b[i])*n[b[i]] + s[i-1];
                System.out.println(s[i]);
                n[c[i]] = n[c[i]] + n[b[i]];
                n[b[i]] = 0;
            }
        }
    }

Compiler output:
Main.java:8: error: cannot find symbol
            A[0] = 0;
            ^
  symbol:   variable A
  location: class Main
Main.java:24: error: cannot find symbol
                S[0] = S[0] + a[i];
                ^
  symbol:   variable S
  location: class Main
Main.java:24: error: cannot find symbol
                S[0] = S[0] + a[i];
                       ^
  symbol:   variable S
  location: class Main
Main.java:26: error: variable n is already defined in method main(String[])
            int[] n = new int[100000+1];
                  ^
4 errors
Language: Java

    import java.util.Scanner;
     
    public class Main {
        public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
            int n = sc.nextInt();
            int[] a = new int[n+1];
            A[0] = 0;
            for (int i = 1; i < n+1; i++) {
                a[i] = sc.nextInt();
            }
            int q = sc.nextInt();
            int[] b = new int[q+1];
            int[] c = new int[q+1];
            b[0] = 0;
            c[0] = 0;
            for (int i= 1; i < q+1; i++) {
                b[i] = sc.nextInt();
                c[i] = sc.nextInt();
            }
            long[] s = new long[q+1];
            s[0] = 0;
            for (int i = 0; i < a.length; i++) {
                S[0] = S[0] + a[i];
            }
            int[] n = new int[100000+1];
           // for (int i = 0; i < n.length; i++) {
            //    n[i] = 0;
            //}
            for (int i = 1; i < a.length; i++) {
                n[a[i]] = n[a[i]] + 1;
            }
            for (int i = 1; i < q+1; i++) {
                s[i] = (c[i]-b[i])*n[b[i]] + s[i-1];
                System.out.println(s[i]);
                n[c[i]] = n[c[i]] + n[b[i]];
                n[b[i]] = 0;
            }
        }
    }

Compiler output:
Main.java:8: error: cannot find symbol
            A[0] = 0;
            ^
  symbol:   variable A
  location: class Main
Main.java:24: error: cannot find symbol
                S[0] = S[0] + a[i];
                ^
  symbol:   variable S
  location: class Main
Main.java:24: error: cannot find symbol
                S[0] = S[0] + a[i];
                       ^
  symbol:   variable S
  location: class Main
Main.java:26: error: variable n is already defined in method main(String[])
            int[] n = new int[100000+1];
                  ^
4 errors
Language: C

// finish date: 2019/6/24

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1000000007;
const long long INFll = 100000000000000000;


int main() {
    int N;
    cin >> N;
    vi A(N);
    ll ans = 0;
    map<int, int> mp;
    rep(i, N) {
        cin >> A[i];
        mp[A[i]]++;
        ans += A[i];
    }
    int Q;
    cin >> Q;
    vi B(Q), C(Q);
    rep(i, Q) {
        cin >> B[i] >> C[i];
        ans += (C[i] - B[i]) * mp[B[i]];
        mp[C[i]] += mp[B[i]];
        mp[B[i]] = 0;
        cout << ans << endl;
    }


    return 0;
}


Compiler output:
main.c:3:10: fatal error: bits/stdc++.h: No such file or directory
    3 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <stdio.h>
#include <string>
#include <ctype.h>
#define FOR1toN(a) for(int i=1;i<=a;i++)
#define FOR0ton(a) for(int i=0;i<a;i--) 
using namespace std;


char covert(int n)
{
    
    if(65<n) return '-';
	return n+64;
}


int main()
{
	//freopen("in.txt","r",stdin);
	int n;
	cin>>n;
	int cnt[1000000];
	int arr1[1000000];

	memset(cnt,0,sizeof(cnt));
	memset(arr1,0,sizeof(arr1));

    long long sum=0;
	for(int i=1;i<=n;i++)
	{

		int tmp;
		cin>>tmp;
		sum+=tmp;
		arr1[i]=tmp;
		cnt[tmp]++;
	}

	int q;
	cin>>q;
	for(int i=1;i<=q;i++)
	{
		int a,b;
		cin>>a>>b;
		sum-=cnt[a]*a;
		sum+=cnt[a]*b;
		cnt[b]+=cnt[a];
		cnt[a]=0;/*
		for(int i=1;i<=n;i++)
			{
				cout<<arr1[i]<<" ";
			}
			cout<<endl;*/
		cout<<sum<<endl;
	}



   return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:9: error: 'memset' was not declared in this scope
   26 |         memset(cnt,0,sizeof(cnt));
      |         ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 | #include <stdio.h>
Language: C

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


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] ;
    }
    rep(i, q) {
        ll tot = 0;
        rep(j, n){
            if (A[j] == B[i]){
                A[j] = C[i];
            }
        }
        rep(k, n){
            tot += A[k];
        }
        cout << tot << endl;
    }

} 

Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>

#define int long long
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace std;

const unsigned int M = 1e9 + 7;

int32_t main() {
	fastio;

	int n;
	cin >> n;
	int sum = 0, freq[1e5 + 1];
	while(n--) {
		int x;
		cin >> x;
		sum += x;
		++freq[x];
	}
	int q;
	cin >> q;
	while(q--) {
		int b, c;
		cin >> b >> c;
		sum += c * freq[c], sum -= b;
		cout << sum << '\n';
	}

	return 0;
}

/*
Pre-computing sum gives 1+2+3+4
* Now, to remove 1 and add 2 -> (1+2+3+4) - (1) + (2)
* Similarly to remove 3 and add 2 now, current sum - 3 + 2
* And so on
*/


Compiler output:
a.cc: In function 'int32_t main()':
a.cc:15:31: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
   15 |         int sum = 0, freq[1e5 + 1];
      |                           ~~~~^~~
a.cc:15:31: error: could not convert '(1.0e+5 + (double)1)' from 'double' to 'long unsigned int'
   15 |         int sum = 0, freq[1e5 + 1];
      |                           ~~~~^~~
      |                               |
      |                               double
a.cc:15:31: error: size of array 'freq' has non-integral type 'double'
Language: C

#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include<math.h>
#define ll long long
#define pai 3.1415926535897932384626433832795028841971693
int compare(const void *a, const void *b){
  return (*(ll int *)a)- (*(ll int *)b);
}
 
 
int main(){
  ll int ans=0;
  ll int n;
  scanf("%lld",&n);
  ll int a[n];
  for(ll int i=0;i<n;i++){
    scanf("%lld",&a[i]);
    ans+=a[i];
  }
  ll int q;
  scanf("%lld",&q);
  ll int b[q],c[q];
 for(ll int i=0;i<q;i++){
   scanf("%lld %lld",&b[i],&c[i]);
 }
 
  qsort(a,n,sizeof(ll int),compare);
  
  for(ll int i=0;i<q;i++){
    for(ll int j=0;j<n;j++){
      if(a[j]==b[i]){
        ans=ans+c[i]-a[j];
        a[j]=c[i]; 
        if(j==n-1){
          printf("%lld\n",ans);
      }
      else if(a[j]>b[i]){
        printf("%lld\n",ans);
        qsort(a,n,sizeof(ll int),compare);
        break;
      }
    }
  }
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:46:1: error: expected declaration or statement at end of input
   46 | }
      | ^
Language: C++

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

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

  long long int sum=0;

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

  long long int Q;
  cin >> Q;

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

  for(long long int i=0; i<Q; i++){
    sum+=(C.at(i)-B.at(i))*A.at(B.at(i));
    A.at(C.at(i))+=A.at(B.at(i));
    A.at(b.at(i))=0;

    cout << sum<<endl;
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:10: error: 'b' was not declared in this scope
   29 |     A.at(b.at(i))=0;
      |          ^
Language: C++

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

const int N = 1e5 + 6;
vector<int> a(N);

int main() {
    int n, q, b, c;
    long long sum = 0ll;
    cin >> n;
    for (int i=0; i<n; i++) {
        int x;
        cin >> x;
        sum += long long(x);
        ++a[x];
    }
    
    cin >> q;
    while (q--) {
        cin >> b >> c;
        sum += long long((c-b) * a[b]);
        a[c] += a[b];
        a[b] = 0;
        cout << sum << '\n';
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:16: error: expected primary-expression before 'long'
   15 |         sum += long long(x);
      |                ^~~~
a.cc:22:16: error: expected primary-expression before 'long'
   22 |         sum += long long((c-b) * a[b]);
      |                ^~~~
Language: C++

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

Compiler output:
a.cc:2:7: error: expected nested-name-specifier before 'nmaespace'
    2 | using nmaespace std;
      |       ^~~~~~~~~
a.cc: In function 'int main()':
a.cc:6:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    6 |   cin>>n;
      |   ^~~
      |   std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
                 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:8:3: error: 'map' was not declared in this scope
    8 |   map<int,int>m;
      |   ^~~
a.cc:8:3: note: suggested alternatives:
In file included from /usr/include/c++/14/map:63,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152:
/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:7: error: expected primary-expression before 'int'
    8 |   map<int,int>m;
      |       ^~~
a.cc:11:15: error: 'm' was not declared in this scope
   11 |     cin>>a[i],m[a[i]]++,sum+=a[i];
      |               ^
a.cc:17:15: error: 'm' was not declared in this scope
   17 |     sum=sum-a*m[a]+m[a]*b;
      |               ^
a.cc:20:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   20 |     cout<<sum<<"\n";
      |     ^~~~
      |     std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//Write From this Line

int [101][4][4][4];

const ll mod = 1e9+7;
int main()
{
	int n;
	cin >> n; 

	dp[0][3][3][3] = 1;
	rep(len,n){
		rep(i,4){//最後から1文字目
			rep(j,4){ // 最後から二文字目の文字
				rep(k,4){ // 最後から3文字目の文字
					// 条件に当てはまるものがない場合はcontinue;
					if(dp[len][i][j][k] == 0) continue;

					// 新しく追加する文字がない場合はcontinue;
					// aたらしく追加するも文字
					rep(a,4){
						if(a == 2 && i == 1 && j == 0) continue;
						if(a == 2 && i == 0 && j == 1) continue;
						if(a == 1 && i == 2 && j == 0) continue;
						if(a == 2 && i == 1 && k == 0) continue;
						if(a == 2 && j == 1 && k == 0) continue;

						dp[len+1][a][i][j] += dp[len][i][j][k];
						dp[len+1][a][i][j] %= mod;
					}
				}
			}
		}
	}
}


Compiler output:
a.cc:15:6: error: expected identifier before numeric constant
   15 | int [101][4][4][4];
      |      ^~~
a.cc:15:6: error: expected ']' before numeric constant
   15 | int [101][4][4][4];
      |      ^~~
      |      ]
a.cc:15:5: error: structured binding declaration cannot have type 'int'
   15 | int [101][4][4][4];
      |     ^
a.cc:15:5: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:15:5: error: empty structured binding declaration
a.cc:15:10: error: expected initializer before '[' token
   15 | int [101][4][4][4];
      |          ^
a.cc: In function 'int main()':
a.cc:23:9: error: 'dp' was not declared in this scope; did you mean 'dup'?
   23 |         dp[0][3][3][3] = 1;
      |         ^~
      |         dup
Language: Java

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

int main() {
  int n, q, b, c, af;
  int sum=0;
  cin>>n;
  vector<int> a(n);
  vector<int> num(100010);
  rep(i,n){
  	cin>>a.at(i);
    af=a.at(i);
    sum+=a.at(i);
    num.at(af-1)=num.at(af-1)+1;
  }
  cin>>q;
  rep(i,q){
  	cin>>b >>c;
    sum=sum+(c-b)*num.at(b-1);
    cout<<sum<<endl;
    num.at(c-1)+=num.at(b-1);
    num.at(b-1)=0;
  }
}

Compiler output:
Main.java:1: error: illegal character: '#'
#include <bits/stdc++.h>
^
Main.java:1: error: class, interface, enum, or record expected
#include <bits/stdc++.h>
         ^
Main.java:3: error: illegal character: '#'
#define rep(i,n) for(int i=0;i<(int)(n);i++)
^
Main.java:3: error: class, interface, enum, or record expected
#define rep(i,n) for(int i=0;i<(int)(n);i++)
        ^
Main.java:3: error: class, interface, enum, or record expected
#define rep(i,n) for(int i=0;i<(int)(n);i++)
                             ^
Main.java:3: error: class, interface, enum, or record expected
#define rep(i,n) for(int i=0;i<(int)(n);i++)
                                        ^
Main.java:7: error: unnamed classes are a preview feature and are disabled by default.
  int sum=0;
  ^
  (use --enable-preview to enable unnamed classes)
Main.java:8: error: class, interface, enum, or record expected
  cin>>n;
  ^
Main.java:9: error: <identifier> expected
  vector<int> a(n);
                 ^
Main.java:10: error: illegal start of type
  vector<int> num(100010);
                  ^
Main.java:11: error: class, interface, enum, or record expected
  rep(i,n){
  ^
Main.java:13: error: class, interface, enum, or record expected
    af=a.at(i);
    ^
Main.java:14: error: class, interface, enum, or record expected
    sum+=a.at(i);
    ^
Main.java:15: error: class, interface, enum, or record expected
    num.at(af-1)=num.at(af-1)+1;
    ^
Main.java:16: error: class, interface, enum, or record expected
  }
  ^
Main.java:18: error: class, interface, enum, or record expected
  rep(i,q){
  ^
Main.java:20: error: class, interface, enum, or record expected
    sum=sum+(c-b)*num.at(b-1);
    ^
Main.java:21: error: class, interface, enum, or record expected
    cout<<sum<<endl;
    ^
Main.java:22: error: class, interface, enum, or record expected
    num.at(c-1)+=num.at(b-1);
    ^
Main.java:23: error: class, interface, enum, or record expected
    num.at(b-1)=0;
    ^
Main.java:24: error: class, interface, enum, or record expected
  }
  ^
21 errors
Language: C++

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

int main() {
    ll N;
    vector<int> A;
    int Q;
    vector<vector<int>> BC;
    cin >> N;
    rep(i, N) {
        int a;
        cin >> a;
        A.push_back(a);
    }
    cin >> Q;
    rep(i, Q) {
        int b, c;
        cin >> b >> c;
        BC.push_back({b, c});
    }

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

    rep(q, Q) {
        // rep(n, N) {
        //     if(A[n] == BC[q][0]) {
        //         A[n] = BC[q][1];
        //     }
        // }
        int left = 0;
        int right = A.size()-1;
        while(right>=left) {
            int mid = left + (right-left)/2;
            if(A[mid] == BC[q][0]) A[mid] = BC[q][1];
            else if (A[mid] > BC[q][0]) right = mid-1;
            else if (A[mid] < BC[q][0]) left = mid+1;
        }
        
        int sum = 0;
        rep(n, N) {
            sum += A[n];
        }
        cout << sum << endl;
    }


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

#include <bits/stdc++.h>

using namespace std;
#define long long int
const int N = 1e5 + 10;
long long A[N];

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    
    int n;
    cin >> n;
    map<int, int> qtd;
    long long sum = 0LL;
    for(int i = 0; i < n; i++) {
        cin >> A[i];
        sum += A[i];
        qtd[A[i]]++;
    }
    int q;
    cin >> q;
    while(q--) {
        int b, c;
        cin >> b >> c;
        int qtd_ = qtd[b];
        qtd[b] = 0, qtd[c] += qtd_;
        long long b_ = b * qtd_;
        long long c_ = c * qtd_;
        long long ans = sum - b_;
        ans += c_;
        sum = ans;
        cout << ans << "\n";
    }
    
    return 0;
}


Compiler output:
a.cc:4:19: error: two or more data types in declaration of 'A'
    4 | #define long long int
      |                   ^~~
a.cc:6:1: note: in expansion of macro 'long'
    6 | long long A[N];
      | ^~~~
a.cc: In function 'int main()':
a.cc:4:19: error: two or more data types in declaration of 'sum'
    4 | #define long long int
      |                   ^~~
a.cc:14:5: note: in expansion of macro 'long'
   14 |     long long sum = 0LL;
      |     ^~~~
a.cc:16:16: error: 'A' was not declared in this scope
   16 |         cin >> A[i];
      |                ^
a.cc:17:9: error: 'sum' was not declared in this scope
   17 |         sum += A[i];
      |         ^~~
a.cc:4:19: error: two or more data types in declaration of 'b_'
    4 | #define long long int
      |                   ^~~
a.cc:27:9: note: in expansion of macro 'long'
   27 |         long long b_ = b * qtd_;
      |         ^~~~
a.cc:4:19: error: two or more data types in declaration of 'c_'
    4 | #define long long int
      |                   ^~~
a.cc:28:9: note: in expansion of macro 'long'
   28 |         long long c_ = c * qtd_;
      |         ^~~~
a.cc:4:19: error: two or more data types in declaration of 'ans'
    4 | #define long long int
      |                   ^~~
a.cc:29:9: note: in expansion of macro 'long'
   29 |         long long ans = sum - b_;
      |         ^~~~
a.cc:29:25: error: 'sum' was not declared in this scope
   29 |         long long ans = sum - b_;
      |                         ^~~
a.cc:29:31: error: 'b_' was not declared in this scope; did you mean 'b'?
   29 |         long long ans = sum - b_;
      |                               ^~
      |                               b
a.cc:30:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   30 |         ans += c_;
      |         ^~~
      |         abs
a.cc:30:16: error: 'c_' was not declared in this scope; did you mean 'c'?
   30 |         ans += c_;
      |                ^~
      |                c
Language: C++

//#include <fsociety>
#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <iomanip> 
#include <stdio.h>
//end of libraries ;
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
// ll lmax(ll o , ll w) {if(o>w)return o; return w;}
// ll lmin(ll o , ll w) {if(o<w)return o; return w;}
#define LNF 3999999999999999999
#define INF 999999999
#define N 9000003
#define PI 3.14159265359
#define F first
#define S second
#define pb push_back
#define ll long long
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
ll n , x , sum = 0;
int main(){
fcin;
	cin >> n;
	for(ll i = 1 ; i <= n ; i++){
		cin >> x;
		d[x]++;
		sum += x;
	}
	ll q;
	cin >> q;
	while(q--){
		ll x , y;
		cin >> x >> y;
		sum += (d[x]*(y-x));
		d[y] += d[x];
		d[x] = 0;
		cout << sum << '\n';
		}


}

Compiler output:
a.cc: In function 'int main()':
a.cc:40:17: error: 'd' was not declared in this scope
   40 |                 d[x]++;
      |                 ^
a.cc:48:25: error: 'd' was not declared in this scope
   48 |                 sum += (d[x]*(y-x));
      |                         ^
Language: C++

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define each(it,o) for(auto it= (o).begin(); it != (o).end(); ++ it)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define inrep int t;cin>>t; while(t--)
#define pb emplace_back
using namespace std;
using namespace __gnu_pbds; 


typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii > vpii;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef vector<pll > vpll; 
typedef vector<string> vs;
typedef long double ld;
const ll MOD = 1e9+7;
template<typename T> istream& operator>> ( istream &in,vector<T> &v ) {

    for ( unsigned   i=0; i<v.size(); i++ )
        in>>v[i];
    return in;
}

ll extended_GCD(ll a , ll b , ll &x , ll &y){
    if(a == 0){
        x = 0;
        y = 1;
        return b;
    }
    ll x1 , y1;
    ll gcd = extended_GCD(b%a , a , x1 , y1);
    x = y1 - (b/a)*x1; 
    y = x1;
    return gcd;
}
ll power(ll a, ll b, ll m = MOD) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
ll modinv(ll a , ll mod ){
    ll x , y;
    extended_GCD(a , mod , x , y);
    if(x < 0) x += mod;
    return x;
}

ll mul(ll a,ll b,ll m)
{
    return (a%m*b%m)%m;
}
  
 


int main()
{
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll a;ll s = 0;
    vector<ll> m(100050,0);
    for(int i=0;i<n;i++)
    {
        cin>>a;
        s+=a;
        m[a]++;
    }
     q;
    cin>>q;
    for(int i=0;i<q;i++)
    {
        ll b,c;
        cin>>b>>c;
        s+=(m[b]*(c-b));
        m[c]+=m[b];
        m[b] = 0;
        cout<<s<<"\n";
    }
   
    
    return 0;
}

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:10:17: error: 'temp' was not declared in this scope; did you mean 'tm'?
   10 |                 temp[a[i]]++;
      |                 ^~~~
      |                 tm
a.cc:17:20: error: 'temp' was not declared in this scope; did you mean 'tm'?
   17 |                 if(temp.find((int)b)!=temp.end()){
      |                    ^~~~
      |                    tm
Language: C++

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

int main() {
    std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);

    int n;
    cin >> n;
    const int ms = 100100;
    long long sum = 0;
    vector<int> count(mx, 0);
    for (int i = 0; i < n; i++) {
        int x; cin >> x;
        sum += x;
        count[x]++;
    }

    int q;
    cin >> q;
    while (q--) {
        int b, c;
        cin >> b >> c;
        sum -= count[b] * b;
        sum += count[b] * c;
        count[c] += count[b];
        count[b] = 0;
        cout << sum << "\n";
    }

    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:23: error: 'mx' was not declared in this scope; did you mean 'ms'?
   11 |     vector<int> count(mx, 0);
      |                       ^~
      |                       ms
Language: C++

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

int main(){
int n,sum=0,c,b;
unordered_map<int,int> temp;
cin>>n;
int a[n];
for(int i=0;i<n;i++){
	cin>>a[i];
	sum=sum+a[i];
	temp[a[i]]++;
}
int q;
cin>>q;
while(q--){
	cin>>c>>b;
	sum=sum-c*temp[c];
	sum=sum+b*temp[c];
	tem[b]=temp[b]+temp[c];
	temp[c]=0;
	cout<<sum<<endl;
	
}
return 0;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:9: error: 'tem' was not declared in this scope; did you mean 'temp'?
   20 |         tem[b]=temp[b]+temp[c];
      |         ^~~
      |         temp
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long ll
ll main(){
  ll f[100001]={0};
  ll n;
  cin>>n;
  for(ll i=0; i<n; i++){
  	ll temp; cin>>temp;
  	f[temp]++;
  }
  ll sum = 0;
  for(ll i=0; i<100001; i++){
  	sum+=(i*f[i]);
  }
  ll q;
  cin>>q;
  for(ll i=0; i<q; i++){
  	ll b,c;
  	cin>>b>>c;
  	ll freq = f[b];
  	f[b]=0;
  	f[c]+=freq;
  	sum = sum-freq*b+freq*c;
  	cout<<sum<<'\n';
  }
  return 0;
}

Compiler output:
a.cc:4:4: error: expected initializer before 'main'
    4 | ll main(){
      |    ^~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

struct expand_type {
    template <typename... T>
    expand_type (T&&...) {}
};
template <typename... ArgTypes>
void print (ArgTypes... args) {
    expand_type {0, (cerr << args << ", ", 0)...};
    cerr << "\b\b \n";
}
#define printv(x) cerr << "["; for(auto i : (x)) cerr << i << ", "; cerr << "\b\b]\n";
#define __lcm(a,b) a * b / __gcd(a, b)

typedef unsigned long long ull;
typedef long double ld;


int main () {
    std::ios::sync_with_stdio (false);
    cin.tie (nullptr);
    cout.tie (nullptr);
    unordered_map<int, int> m;
    long long n ,ans=0,k,a,b;
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> k;
		m[k]++;
		ans += k;
	}
	cin >> q;
	while (q--)
	{
		cin >> a >> b;
		int counta = m[a];
		ans -= counta * a;
		ans += counta * b;
		cout << ans << endl;
		m.erase(a);
		m[b] += counta;
	}
    return 0;
}


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

#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rrep(i,a,b) for(int i = a ; i >= b; i--)
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define sq(a) (a)*(a)
#define nl "\n"
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef unsigned long long ull;
const int MAXN = 100005;
ll mod=1000000007;


int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  t = 1;
  // cin>>t;
  while(t--){
      int n;
      cin>>n;
      vector<ll> a(n);
      map<ll,int> freq;
      ll sum = 0;
      rep(i,0,n-1){
        cin>>a[i];
        sum += a[i];
        freq[a[i]]++;
      }
      int q;
      cin>>q;
      while(q--){
        int b,c;
        cin>>b>>c;
        sum+= (c - b)*freq[b]
        freq[c] += freq[b];
        freq[b] = 0;
        cout<<sum<<nl;
      }
      cout<<nl;
  }
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:49:30: error: expected ';' before 'freq'
   49 |         sum+= (c - b)*freq[b]
      |                              ^
      |                              ;
   50 |         freq[c] += freq[b];
      |         ~~~~
Language: C++

#include <iostream>
#include <vector>
#include <numeric>
#include <cmath>
using namespace std;
 
int main(){
    vector<int> num(pow(10,5)+1);
 
    int n,q;
    cin>>n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin>>a[i];
    }
    
    long int sum=accumulate(a.begin(),a.end(),0);
    
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; i < pow(10,5)+1; j++)
        {
            if (a[i]==j)
            {
                num[j]++;
                break;
            } 
        }
    }
    
    
    cin>>q;
    for (int i = 0; i < q; i++)
    {
        long int b,c;
        cin>>b>>c;
        sum=sum+(c-b)*num[b];
        cout<<sum<<endl;
        num[c]=num[c]+num[b];
        num[b]=0;
 
    }
    
return 0;
}
#include <iostream>
#include <vector>
#include <numeric>
#include <cmath>
using namespace std;
 
int main(){
    vector<int> num(pow(10,5)+1,0);
 
    int n,q;
    cin>>n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin>>a[i];
    }
    
    long int sum=accumulate(a.begin(),a.end(),0);
    
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; i < pow(10,5)+1; j++)
        {
            if (a[i]==j)
            {
                num[j]++;
                break;
            } 
        }
    }
    
    
    cin>>q;
    for (int i = 0; i < q; i++)
    {
        long int b,c;
        cin>>b>>c;
        sum=sum+(c-b)*num[b];
        cout<<sum<<endl;
        num[c]=num[c]+num[b];
        num[b]=0;
 
    }
    
return 0;
}

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

#include <iostream>
#include <vector>
#include <numeric>
#include <cmath>
using namespace std;
 
int main(){
    vector<int> num(pow(10,5)+1);
 
    int n,q;
    cin>>n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin>>a[i];
    }
    
    long int sum=accumulate(a.begin(),a.end(),0);
    
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; i < pow(10,5)+1; j++)
        {
            if (a[i]==j)
            {
                num[j]++;
                break;
            } 
        }
    }
    
    
    cin>>q;
    for (int i = 0; i < q; i++)
    {
        long int b,c;
        cin>>b>>c;
        sum=sum+(c-b)*num[b];
        cout<<sum<<endl;
        num[c]=num[c]+num[b];
        num[b]=0;
 
    }
    
return 0;
}
#include <iostream>
#include <vector>
#include <numeric>
#include <cmath>
using namespace std;

int main(){
    vector<int> num(pow(10,5)+1,0);

    int n,q;
    cin>>n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin>>a[i];
    }
    
    long int sum=accumulate(a.begin(),a.end(),0);
    
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; i < pow(10,5)+1; j++)
        {
            if (a[i]==j)
            {
                num[j]++;
                break;
            } 
        }
    }
    
    
    cin>>q;
    for (int i = 0; i < q; i++)
    {
        long int b,c;
        cin>>b>>c;
        sum=sum+(c-b)*num[b];
        cout<<sum<<endl;
        num[c]=num[c]+num[b];
        num[b]=0;

    }
    
return 0;
}
提出情報
提出日時	2020-06-22 22:34:30
問題	D - Replacing
ユーザ

Compiler output:
a.cc:53:5: error: redefinition of 'int main()'
   53 | int main(){
      |     ^~~~
a.cc:7:5: note: 'int main()' previously defined here
    7 | int main(){
      |     ^~~~
a.cc:93:1: error: '\U000063d0\U000051fa\U000060c5\U00005831' does not name a type
   93 | 提出情報
      | ^~~~~~~~
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);
  }
  //sort(A.begin(), A.end());
  int Q;
  cin >> Q;
  vector<int> B(Q), C(Q);
  for(int i = 0; i < Q; ++i){
    cin >> B.at(i) >> C.at(i);
  }
  /*
  for (int i = 0; i < Q; ++i){
    vector<int>::iterator it_s = lower_bound(A.begin(),A.end(),B.at(i));
    vector<int>::iterator it_e = upper_bound(A.begin(),A.end(),B.at(i));
    for(vector<int>::iterator itr = it_s; itr < it_e; ++itr){
      *itr = C.at(i);
    }
    cout << accumulate(A.begin(), A.end(), 0) << endl;
  }
  */
  vector <int> count(10*10*10*10*10 + 1, 0);
  for(int i = 0; i < A.size(); ++i){
    ++count.at(A.at(i));
  }
  long long sum = accumulate(A.begin(), A.end(), 0);
  for(int i = 0; i < Q; ++i){
    sum += (long long)(C.at(i) * count.at(B.at(i))) - (long long)(B.at(i) * count.at(B.at(i)));
    count.at(C.at(i)) += count.at(B.at(i));
    count.at(B.at(i)) = 0;
    cout << sum << endl;
  }
}

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; ++i){
    cin >> A.at(i);
  }
  //sort(A.begin(), A.end());
  int Q;
  cin >> Q;
  vector<int> B(Q), C(Q);
  for(int i = 0; i < Q; ++i){
    cin >> B.at(i) >> C.at(i);
  }
  /*
  for (int i = 0; i < Q; ++i){
    vector<int>::iterator it_s = lower_bound(A.begin(),A.end(),B.at(i));
    vector<int>::iterator it_e = upper_bound(A.begin(),A.end(),B.at(i));
    for(vector<int>::iterator itr = it_s; itr < it_e; ++itr){
      *itr = C.at(i);
    }
    cout << accumulate(A.begin(), A.end(), 0) << endl;
  }
  */
  vector <int> count(10*10*10*10*10 + 1, 0);
  for(int i = 0; i < A.size(); ++i){
    ++count.at(A.at(i));
  }
  long long sum = accumulate(A.begin(), A.end(), 0);
  for(int i = 0; i < Q; ++i){
    sum += (long long)(C.at(i) * count.at(B.at(i))) - (long long)(B.at(i) * count.at(B.at(i)));
    count.at(C.at(i)) += count.at(B.at(i));
    count.at(B.at(i)) = 0;
    cout << sum << endl;
  }
}


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

#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
	int n; cin >> n;
	ll ans = 0;
	map<int, int> cnt;
	for (int i = 0; i < n; i++) {
		int x; cin >> x;
		ans += x, cnt[x]++;
	}
	int q; cin >> q;
	for (int i = 0; i < q; i++) {
		int b, c; cin >> b >> c;
		ans += 1LL * (c - b) * cnt[b]
		cout << ans << "\n";
		cnt[c] += cnt[b], cnt[b] = 0;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:46: error: expected ';' before 'cout'
   15 |                 ans += 1LL * (c - b) * cnt[b]
      |                                              ^
      |                                              ;
   16 |                 cout << ans << "\n";
      |                 ~~~~
Language: C++

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; ++i){
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  int Q;
  cin >> Q;
  vector<int> B(Q), C(Q);
  for(int i = 0; i < Q; ++i){
    cin >> B.at(i) >> C.at(i);
  }
  for (int i = 0; i < Q; ++i){
    vector<int>::iterator it_s = lower_bound(A.begin(),A.end(),B.at(i));
    vector<int>::iterator it_e = upper_bound(A.begin(),A.end(),B.at(i));
    for(vector<int>::iterator itr = it_s; itr < it_e; ++itr){
      *itr = C.at(i);
    }
    cout << accumulate(A.begin(), A.end(), 0) << endl;
  }
  
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:3: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
   14 |   sort(A.begin(), A.end());
      |   ^~~~
      |   sqrt
a.cc:23:34: error: 'upper_bound' was not declared in this scope
   23 |     vector<int>::iterator it_e = upper_bound(A.begin(),A.end(),B.at(i));
      |                                  ^~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define long long ll
int main()
{
ll int n,a[100001],q,sum=0;
cin>>n;
map<ll int,ll int>m1;
for(int i=0;i<n;i++)
{
    cin>>a[i];
    m1[a[i]]++;
    sum+=a[i];
}
cin>>q;
while(q--)
{
    int a,b;
    cin>>a>>b;
    sum=sum-m1[a]*a;
    sum=sum+m1[a]*b;
    m1[b]=m1[b]+m1[a];
    m1[a]=0;
    cout<<sum<<endl;
}

}


Compiler output:
a.cc: In function 'int main()':
a.cc:6:1: error: 'll' was not declared in this scope
    6 | ll int n,a[100001],q,sum=0;
      | ^~
a.cc:7:6: error: 'n' was not declared in this scope; did you mean 'yn'?
    7 | cin>>n;
      |      ^
      |      yn
a.cc:8:18: error: wrong number of template arguments (1, should be at least 2)
    8 | map<ll int,ll int>m1;
      |                  ^
In file included from /usr/include/c++/14/map:63,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_map.h:102:11: note: provided for 'template<class _Key, class _Tp, class _Compare, class _Alloc> class std::map'
  102 |     class map
      |           ^~~
a.cc:11:10: error: 'a' was not declared in this scope
   11 |     cin>>a[i];
      |          ^
a.cc:13:5: error: 'sum' was not declared in this scope
   13 |     sum+=a[i];
      |     ^~~
a.cc:15:6: error: 'q' was not declared in this scope
   15 | cin>>q;
      |      ^
a.cc:20:5: error: 'sum' was not declared in this scope
   20 |     sum=sum-m1[a]*a;
      |     ^~~
a.cc:20:15: error: invalid types 'int[int]' for array subscript
   20 |     sum=sum-m1[a]*a;
      |               ^
a.cc:21:15: error: invalid types 'int[int]' for array subscript
   21 |     sum=sum+m1[a]*b;
      |               ^
a.cc:22:7: error: invalid types 'int[int]' for array subscript
   22 |     m1[b]=m1[b]+m1[a];
      |       ^
a.cc:22:13: error: invalid types 'int[int]' for array subscript
   22 |     m1[b]=m1[b]+m1[a];
      |             ^
a.cc:22:19: error: invalid types 'int[int]' for array subscript
   22 |     m1[b]=m1[b]+m1[a];
      |                   ^
a.cc:23:7: error: invalid types 'int[int]' for array subscript
   23 |     m1[a]=0;
      |       ^
Language: C

/* author: jeetganatra */

#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define fo(i,n)         for(int i=0;i<n;i++)
#define Fo(i,k,n)       for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define tr(it, a)       for(auto it = a.begin(); it != a.end(); it++)
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             998244353
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
#define deb(x)          cout << #x << "=" << x << endl
#define deb2(x, y)      cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x)          x.begin(), x.end()
#define clr(x)          memset(x, 0, sizeof(x))
#define sortall(x)      sort(all(x))
#define endl            "\n"
#define PI              3.14159265
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

 
void jpg()
{
    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
}

int mpow(int base, int exp); 


                                                                                                                                                                                                                             
int32_t main()
{
	jpg();
	int n;
    cin>>n;
    map<int, int> m;
    int sum = 0;
    fo(i,n)
    {
	    int ai;
	    cin>>ai;
	    ++m[ai];
	    sum += ai;
    }
    int Q;
    cin>>Q;
    while(Q--)
    {
	    int b, c;
	    cin>>b>>c;
	    if (m.find(b) == m.end()) 
	    {
	      cout<<sum<<endl;
	      continue;
	    }
  
	    int tmp = m[b];
	    sum -=tmp * b;
	    sum +=tmp * c;
	    m.erase(b);
	    m[c] += tmp;
	    cout<<sum<<endl;
    }
}


int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((int)result * base) % mod;
    base = ((int)base * base) % mod;
    exp >>= 1;
  }
  return result;
}



Compiler output:
main.c:3:9: fatal error: bits/stdc++.h: No such file or directory
    3 | #include<bits/stdc++.h>
      |         ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define int       long long
#define w(x)      int x;cin >> x;while (x--)
#define rep(d,a,n)  for(int d=a;d<=n;d++)
#define rep_(d,a,n)  for(int d=a;d>=n;d--)
#define nl        "\n" 
#define fast_io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define oj  freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
const int inf=1e18;
int gcd(int a,int b,int temp){
    if(temp==1){
        return 1;
    }else if(a%temp==0 && b%temp==0){
        return temp;
    }
    temp-=max(a%temp,b%temp);
    return gcd(a,b,temp);
}

void fun(){
    int n;cin>>n;
    int sum=0;
    int val[100001];
  rep(l,0,100000){val[i]=0;}
    rep(i,0,n-1){
        int tem;cin>>tem;
        sum+=tem;
        val[tem]++;
    }
    int q;cin>>q;
    while(q--){
        int b,c;cin>>b>>c;
        sum+=(c)*val[b];
        sum-=b*val[b];
        val[c]+=val[b];
        val[b]=0;
        cout<<sum<<nl;
    }
}
int32_t main()
{
   
    fast_io;
    fun();
    return 0;
}


Compiler output:
a.cc: In function 'void fun()':
a.cc:25:23: error: 'i' was not declared in this scope
   25 |   rep(l,0,100000){val[i]=0;}
      |                       ^
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>;

int main(){
  int n,q;
  cin >> n;
  int tmp;
  int a[1e5+7]={};

  int sum = 0;
  rep(i,n){
    cin >> tmp;
    sum += tmp;
    a[tmp]++;
  }

  cin >> q;
  int b,c;
  rep(i,q) {
    cin >> b >> c;
    if(a[b]>0){
      sum += (c-b)*a[b];
      a[c] += a[b];
      a[b] = 0;
    }
    cout << sum << endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:12: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
   11 |   int a[1e5+7]={};
      |         ~~~^~
a.cc:11:12: error: could not convert '(1.0e+5 + (double)7)' from 'double' to 'long unsigned int'
   11 |   int a[1e5+7]={};
      |         ~~~^~
      |            |
      |            double
a.cc:11:12: error: size of array 'a' has non-integral type 'double'
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;
  }
}
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:26:1: error: 'include' does not name a type
   26 | include <bits/stdc++.h>
      | ^~~~~~~
a.cc:29:5: error: redefinition of 'int main()'
   29 | int main() {
      |     ^~~~
a.cc:4:5: note: 'int main()' previously defined here
    4 | int main() {
      |     ^~~~