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

S = list(raw_input())

i = 0
cnt = 0
while len(S) > 0:
    if i+1 == len(S):
        break
    if S[i] != S[i+1]:
        del S[i]
        del S[i]
        i = -1
        cnt += 2
    i += 1

print cnt

Compiler output:
main.c:1:1: warning: data definition has no type or storage class
    1 | S = list(raw_input())
      | ^
main.c:1:1: error: type defaults to 'int' in declaration of 'S' [-Wimplicit-int]
main.c:1:5: error: implicit declaration of function 'list' [-Wimplicit-function-declaration]
    1 | S = list(raw_input())
      |     ^~~~
main.c:1:10: error: implicit declaration of function 'raw_input' [-Wimplicit-function-declaration]
    1 | S = list(raw_input())
      |          ^~~~~~~~~
main.c:1:5: error: initializer element is not constant
    1 | S = list(raw_input())
      |     ^~~~
main.c:3:1: error: expected ',' or ';' before 'i'
    3 | i = 0
      | ^
Language: C++

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

int main(){
  string s;
  cin >> s;
  int n=0;
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='0'){
      n++;
    }
  }
  cout << 2*min(n,s.size()-n) << endl;
}
  

Compiler output:
a.cc: In function 'int main()':
a.cc:14:16: error: no matching function for call to 'min(int&, std::__cxx11::basic_string<char>::size_type)'
   14 |   cout << 2*min(n,s.size()-n) << endl;
      |             ~~~^~~~~~~~~~~~~~
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:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:14:16: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'})
   14 |   cout << 2*min(n,s.size()-n) << endl;
      |             ~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:14:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   14 |   cout << 2*min(n,s.size()-n) << endl;
      |             ~~~^~~~~~~~~~~~~~
Language: C++

#include "bits/stdc++.h"

using namespace std;

void solve()
{
	string S;
	cin >> S;
	int l = S.size(), z = 0;
	for (char c : S)
	{
		z += c == '0';
	}
	z = min(z, l-z);
	cout << l - z * 2 << endl;s
}

int main(void)
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:15:35: error: 's' was not declared in this scope
   15 |         cout << l - z * 2 << endl;s
      |                                   ^
Language: C++

typedef unsigned long long ull;
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(int (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
#define MAX 1005
const ll MOD=1e9+7;
using namespace std;

int main() {
  int N;
  string s;
  cin >> s;
  int zero=0,one=0;
  rep(i,s.size()){
    if(s[i]=='0') zero++;
    else one++;
  }
  cout << 2* min(zero,one) << endl;
}

Compiler output:
a.cc:7:7: error: 'll' does not name a type; did you mean 'ull'?
    7 | const ll MOD=1e9+7;
      |       ^~
      |       ull
a.cc: In function 'int main()':
a.cc:12:3: error: 'string' was not declared in this scope
   12 |   string s;
      |   ^~~~~~
a.cc:1:1: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
  +++ |+#include <string>
    1 | typedef unsigned long long ull;
a.cc:13:3: error: 'cin' was not declared in this scope
   13 |   cin >> s;
      |   ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | typedef unsigned long long ull;
a.cc:13:10: error: 's' was not declared in this scope
   13 |   cin >> s;
      |          ^
a.cc:19:3: error: 'cout' was not declared in this scope
   19 |   cout << 2* min(zero,one) << endl;
      |   ^~~~
a.cc:19:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:19:14: error: 'min' was not declared in this scope; did you mean 'main'?
   19 |   cout << 2* min(zero,one) << endl;
      |              ^~~
      |              main
a.cc:19:31: error: 'endl' was not declared in this scope
   19 |   cout << 2* min(zero,one) << endl;
      |                               ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | typedef unsigned long long ull;
Language: C++

#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iomanip>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<30)

using namespace std;

#define ld long double
#define ll long long

map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  string S;
  cin >> S;
  int N=S.size();
  int zero=0;
  int one=0;
  for(int i=0;i<N;i++){
    if(S[i]=='0'){
      zero++;
    }else{
      one++
    }
  }
  int ans=min(one,zero)*2;
  cout << ans << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:50:12: error: expected ';' before '}' token
   50 |       one++
      |            ^
      |            ;
   51 |     }
      |     ~
Language: C++

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

int main(){
  string s;
  cin >> s;
  int cnt0=0;
  for(int i=0; i<s.length(); i++){
    if(s[i]=='0')cnt0++;
  }
  cout << 2*min(cnt0, s.length()-cnt0);
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:16: error: no matching function for call to 'min(int&, std::__cxx11::basic_string<char>::size_type)'
   13 |   cout << 2*min(cnt0, s.length()-cnt0);
      |             ~~~^~~~~~~~~~~~~~~~~~~~~~~
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:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:13:16: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'})
   13 |   cout << 2*min(cnt0, s.length()-cnt0);
      |             ~~~^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:13:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   13 |   cout << 2*min(cnt0, s.length()-cnt0);
      |             ~~~^~~~~~~~~~~~~~~~~~~~~~~
Language: C++

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

int main(){
  string s;
  cin >> s;
  int cnt0=0;
  for(int i=0; i<s.length(); i++){
    if(s[i]=='0')cnt0++;
  }
  cout << 2*min(cnt0, s.length()-cnt0);
  return 0;
}

Compiler output:
a.cc:1:2: error: invalid preprocessing directive #incude; did you mean #include?
    1 | #incude <iostream>
      |  ^~~~~~
      |  include
a.cc: In function 'int main()':
a.cc:8:3: error: 'cin' was not declared in this scope
    8 |   cin >> s;
      |   ^~~
a.cc:4:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    3 | #include <algorithm>
  +++ |+#include <iostream>
    4 | using namespace std;
a.cc:13:3: error: 'cout' was not declared in this scope
   13 |   cout << 2*min(cnt0, s.length()-cnt0);
      |   ^~~~
a.cc:13:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:13:16: error: no matching function for call to 'min(int&, std::__cxx11::basic_string<char>::size_type)'
   13 |   cout << 2*min(cnt0, s.length()-cnt0);
      |             ~~~^~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:13:16: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'})
   13 |   cout << 2*min(cnt0, s.length()-cnt0);
      |             ~~~^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:13:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   13 |   cout << 2*min(cnt0, s.length()-cnt0);
      |             ~~~^~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);

    cin>>s;
    rep(i,Size(s)){
        if(s[i]=='1')cnt++;
    }
    cnt=min(cnt,Size(s)-cnt);
    Cout(cnt*2);
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:40:12: error: no matching function for call to 'min(ll&, long long unsigned int)'
   40 |     cnt=min(cnt,Size(s)-cnt);
      |         ~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:40:12: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int')
   40 |     cnt=min(cnt,Size(s)-cnt);
      |         ~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:40:12: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   40 |     cnt=min(cnt,Size(s)-cnt);
      |         ~~~^~~~~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using ii = pair<int, int>;
using vii = vector<ii>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int n = s.size();
    for (int i = 0; i < n; ++i)
    {
        if (s[i] == '0')
            a++;
        else
            b++;
    }
    if (a == 0 || b == 0)
        cout << 0;
    else
        cout << n;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:13: error: 'a' was not declared in this scope
   22 |             a++;
      |             ^
a.cc:24:13: error: 'b' was not declared in this scope
   24 |             b++;
      |             ^
a.cc:26:9: error: 'a' was not declared in this scope
   26 |     if (a == 0 || b == 0)
      |         ^
a.cc:26:19: error: 'b' was not declared in this scope
   26 |     if (a == 0 || b == 0)
      |                   ^
Language: Java

import java.util.*;
public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args){
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] a=new int[m];
        int[] b=new int[m];
        long[] ans=new long[m];
        Unionfind uf = new Unionfind(n);
        
        for(int i=0; i<m; i++){
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
            uf.union(a[i],b[i]);
        }
        
        ans[0] = n*(n-1)/2;

        for (int i=1; i<m; i++) {
            if(uf.same(a[i-1],b[i-1])){
                ans[i] = ans[i-1];
            }else{
                ans[i] = ans[i-1] - uf.getSize(a[i-1])*uf.getSize(b[i-1]);
            }
        }

        for(int i=0; i<m; i++){
            System.out.println(ans[m-1-i]);
        }
    }

	 class Unionfind {
		 
			private int[] data;
			private int []size;
			
			public Unionfind(int size) {
				this.data = new int [size];
				this.size = new int [size];
				for(int i = 0 ;i < size ;i++) {
					initnode(i);
				}
				clear();
			}
			
			public void initnode(int i) {
				size[i] = 1;
			}
			
			public void clear() {
				Arrays.fill(data, -1);
			}
			
			public void union(int x , int y ) {
				if((x = root(x)) != (y = root(y))) {
					if(data[y] < data[x]) {
						final int t = x;
						x = y;
						y = t;
					}
					data[x] += data[y];
					size[root(x)] += size[root(y)];
					data[y] = x;
				}
			}
			
			public int getSize(int i) {
				return size[root(i)];
			}
			
			public int root(int x) {
				if(data[x] < 0) {
					return x;
				}
				else {
					return data[x] = root(data[x]);
				}
			}
			
			public boolean same(int x, int y) {
				return root(x) == root(y);
			}
			
		}

}

Compiler output:
Main.java:10: error: non-static variable this cannot be referenced from a static context
        Unionfind uf = new Unionfind(n);
                       ^
1 error
Language: C++

#include<bits/stdc++.h>
using namespace std;
int sz[10005];
int parent[10005];
vector<pair<int,int>>a(10005);
int find_comp(int x){
    if(parent[x]==x)
        return x;
    return parent[x]=find_comp(parent[x]);
}
bool same_comp(int x,int y){
    return find_comp(parent[x])==find_comp(parent[y]);
}
int join_comp(int x,int y){
int a=find_comp(x);
int b=find_comp(y);
if(sz[a]>sz[b])
{
    parent[b]=a;
    sz[a]+=sz[b];
}
else{
    parent[a]=b;
    sz[b]+=sz[a];
}
}
int main(){
int n,m;
cin >>n>>m;
for(int i=0;i<n;i++){
    parent[i]=i;
    sz[i]=1;
}
for(int i=0;i<m;i++){
    cin>>a[i].first>>a[i].second;
    a[i].first--;
    a[i].second--;
}
vector<int>ans(m+1,0);
ans[m]=((n)*(n-1))/2;
for(int i=m-1;i>=0;i--){
    if(same_comp(a[i].first,a[i].second)){
        ans[i]=ans[i+1];
        continue;
    }
    int x=a[i].first;
    int y=a[i].second;
    int sz_x=sz[find_comp(x)];
    int sz_y=sz[find_comp(y)];
    join_comp(x,y);
    ans[i]=max(ans[i+1]-sz_x*sz_y,0);
}
for(int i=1;i<=m;i++){
    cout << ans[i]<<  " ";
}
cout <<endl;
retur 0;
}


Compiler output:
a.cc: In function 'int join_comp(int, int)':
a.cc:26:1: warning: no return statement in function returning non-void [-Wreturn-type]
   26 | }
      | ^
a.cc: In function 'int main()':
a.cc:57:1: error: 'retur' was not declared in this scope
   57 | retur 0;
      | ^~~~~
Language: C++

#include <bits/stdc++.h>
#include<math.h>
#include<algorithm> 
#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
#define INF 1e18
struct UnionFind {
    vector<int> d ;
    UnionFind (int n = 0) : d (n, -1) {}
    int find(int x){
        if(d[x] < 0) return x ;
        return find(d[x]) ;
    }
    bool unite (int x, int y){
        x = find(x) ;
        y = find(y) ;
        if(x == y) return false ;
        if(d[x] > d[y]) swap(x, y) ;
        d[x] += d[y] ;
        d[y] = x ;
        return true ;
    }
    bool same (int x, int y) {
        return find(x) == find(y) ;
    }
    int size (int x){
        return -d[find(x)] ;
    }
};



int main () {
    int n, m ;
    cin >> n >> m ;
    UnionFind uf (n) ;
    vector<P> bd (m) ;
    deque<ll> ans ; 
    rep(i, m){
        int a, b ;
        cin >> a >> b ;
        a-- ; b-- ;
        bd[m-i-1] = P(a, b) ;
    }
    ll tot = n*(n-1)/2 ;
    ans.push_front(tot) ;
    rep(i, m - 1){
        P nw = bd[i];
        int c = nw.first ;
        int d = nw.second ;
        ll l = uf.size(c) ;
        ll p = uf.size(d) ;
        if(uf.same(c,d)){
            ans.push_front(tot) ;
            continue; 
        }
        uf.unite(c, d) ;
        dc += l*p ;
        ll res = tot - dc ;
        ans.push_front(res) ;
        
    }
    rep(i, m){
        cout << ans[i] << endl ;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:61:9: error: 'dc' was not declared in this scope; did you mean 'd'?
   61 |         dc += l*p ;
      |         ^~
      |         d
Language: C++

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
struct UnionFind {
  vector<int> d;
  Unionfind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};

int main(){
  ll n,m;
  cin>>n>>m;
  vector<pair<ll,ll>> ab(m);
  for(int i=0;i<m;i++){
    ll a,b;
    cin>>a>>b;
    --a;
    --b;
    ab[i].first=a;
    ab[i].second=b;
  }
  ll add[m];
  Unionfind uf=Unionfind(n);
  for(int i=m-1;i>=0;i--){
    if(uf.same(ab[i].first,ab[i].second)){
      continue;
    }
    add[i]=ll(uf.size(ab[i].first))*ll(uf.size(ab[i].second));
    uf.unite(ab[i].first,ab[i].second);
  }
ll temp=0;
  for(int i=0;i<m;i++){
    temp+=add[i];
    cout<<temp<<endl;
  }
  return 0;
}


Compiler output:
a.cc:6:3: error: ISO C++ forbids declaration of 'Unionfind' with no type [-fpermissive]
    6 |   Unionfind(int n=0): d(n,-1) {}
      |   ^~~~~~~~~
a.cc: In member function 'int UnionFind::Unionfind(int)':
a.cc:6:23: error: only constructors take member initializers
    6 |   Unionfind(int n=0): d(n,-1) {}
      |                       ^
a.cc:6:32: warning: no return statement in function returning non-void [-Wreturn-type]
    6 |   Unionfind(int n=0): d(n,-1) {}
      |                                ^
a.cc: In function 'int main()':
a.cc:36:3: error: 'Unionfind' was not declared in this scope; did you mean 'UnionFind'?
   36 |   Unionfind uf=Unionfind(n);
      |   ^~~~~~~~~
      |   UnionFind
a.cc:38:8: error: 'uf' was not declared in this scope
   38 |     if(uf.same(ab[i].first,ab[i].second)){
      |        ^~
a.cc:41:15: error: 'uf' was not declared in this scope
   41 |     add[i]=ll(uf.size(ab[i].first))*ll(uf.size(ab[i].second));
      |               ^~
Language: C++

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};

int main(){
  ll n,m;
  cin>>n>>m;
  vector<pair<ll,ll>> ab(m);
  for(int i=0;i<m;i++){
    ll a,b;
    cin>>a>>b;
    --a;
    --b;
    ab[i].first=a;
    ab[i].second=b;
  }
  ll add[m];
  Unionfind uf=Unionfind(n);
  for(int i=m-1;i>=0;i--){
    if(uf.same(ab[i].first,ab[i].second)){
      continue;
    }
    add[i]=ll(uf.size(ab[i].first))*ll(uf.size(ab[i].second));
    uf.unite(ab[i].first,ab[i].second);
  }
ll temp=0;
  for(int i=0;i<m;i++){
    temp+=add[i];
    cout<<temp<<endl;
  }
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:36:3: error: 'Unionfind' was not declared in this scope; did you mean 'UnionFind'?
   36 |   Unionfind uf=Unionfind(n);
      |   ^~~~~~~~~
      |   UnionFind
a.cc:38:8: error: 'uf' was not declared in this scope
   38 |     if(uf.same(ab[i].first,ab[i].second)){
      |        ^~
a.cc:41:15: error: 'uf' was not declared in this scope
   41 |     add[i]=ll(uf.size(ab[i].first))*ll(uf.size(ab[i].second));
      |               ^~
Language: C++

#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define rep2(i, a)for(auto i : a)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x, std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll co(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }
struct UnionFind {
	vector<int> par, s;
	UnionFind(int N) : par(N), s(N, 1) { rep(i, 0, N)par[i] = i; }
	int root(int x) { return par[x] == x ? x : par[x] = root(par[x]); }
	void unite(int x, int y) { x = root(x), y = root(y); if (x == y)return; if (s[x] < s[y])swap(x, y); s[x] += s[y]; par[y] = x; }
	bool same(int x, int y) { return root(x) == root(y); }
	int size(int x) { return s[root(x)]; }
	map<int, int> cnt() { map<int, int> cnt; rep2(v, par)cnt[root(v)]++; return cnt; }
};
int main()
{
	ll n, m;
	cin >> n >> m;
	vector<int> a(m), b(m);
	rep(i, 0, m)cin >> a[i] >> b[i], a[i]--, b[i]--;
	UnionFind tree(n);
	vector<ll> A;
	ll k = n * (n - 1) / 2 % mod;
	A.push_back(k);
	rep(i, 0, m - 1) {
		if (!tree.same(a[m - i - 1], b[m - i - 1])) {
			k -= (ll)tree.size(a[m - i - 1]) * (ll)tree.size(b[m - i - 1]);
		}
		tree.unite(a[m - i - 1], b[m - i - 1]);
		if (tree.size[a[m - i - 1]] == n)k = 0ll;
		A.push_back(k);
	}
	reverse(all(A));
	rep2(v, A)printf("%lld\n", v);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:59:30: error: invalid types '<unresolved overloaded function type>[__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}]' for array subscript
   59 |                 if (tree.size[a[m - i - 1]] == n)k = 0ll;
      |                              ^
Language: C++

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

class DisjointSet{
public:
  vector<int> rank, p, sz;

  DisjointSet(){}
  DisjointSet(int size){
    rank.resize(size, 0);
    p.resize(size, 0);
    sz.resize(size, 0);
    rep(i, size) makeSet(i);
  }

  void makeSet(int x){
    p[x] = x;
    rank[x] = 0;
    sz[x] = 1;
  }

  bool same(int x, int y){
    return return(findSet(x), findSet(y));
  }

  void unite(int x, int y){
    link(findSet(x), findSet(y));
  }

  void link(int x, int y){
    if(rank[x] > rank[y]){
      p[y] = x;
      sz[x] += sz[y];
    }
    else{
      p[x] = y;
      sz[y] += sz[x];
      if(rank[x] == rank[y]){
        rank[y]++;
      }
    }
  }

  int findSet(int x){
    if(x != p[x]){
      p[x] = findSet(p[x]);
    }
    return p[x];
  }

  int getSize(int x){
    return sz[findSet(x)];
  }
};


int main(){
  int n, m; cin >> n >> m;
  vector<int> a(m), b(m);
  rep(i, m){
    int s, t; cin >> s >> t;
    a[i] = s - 1;
    b[i] = t - 1;
  }
  DisjointSet ds = DisjointSet(n);
  vector<ll> ans(m+1);
  ans[m] = ((ll)n * (n - 1)) / 2;
  for(int i = m - 1; i >= 0; i--){
    int x = a[i], y = b[i];
    if(ds.same(x, y)) continue;
    ll sizex = ds.getSize(x), sizey = ds.getSize(y);
    //cout << x << " " << y << " : ";
    //cout << sizex << " " << sizey << endl;
    ds.unite(x, y);
    ans[i] = max(ans[i + 1] - sizex * sizey, 0LL);
  }
  rep(i, m){
    cout << ans[i+1] << endl;
  }
  return 0;
}


Compiler output:
a.cc: In member function 'bool DisjointSet::same(int, int)':
a.cc:25:12: error: expected primary-expression before 'return'
   25 |     return return(findSet(x), findSet(y));
      |            ^~~~~~
a.cc:25:12: error: expected ';' before 'return'
Language: C++

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

struct UnionFind{
    vector<ll> link;
    UnionFind(ll n):link(n,-1){}
    ll find(ll v){
        if(link[v]<0) return v;
        else return link[v]=find(link[v]);
    }
    bool unite(ll v,ll w){
        v=find(v),w=find(w);
        if(v==w) return 0;
        if(link[v]>link[w]) swap(v,w);
        link[v]+=link[w];
        link[w]=v;
        return 1;
    }
    bool same(ll v,ll w){
        return find(v)==find(w);
    }
};

int main(){
    ll n,m;
    cin>>n>>m;
    vector<ll> a(m),b(m),ans(m);
    rep(i,m){
        cin>>a[i]>>b[i];
        a--,b--;
    }
    UnionFind uf(n);
    ans[m-1]=n*(n-1)/2;
    for(ll i=m-1;m>=1;m--){
        ans[i-1]=ans[i]-uf.link[uf.find(a[i])]*uf.link[uf.find(b[i])];
        uf.unite(a[i],b[i]);
    }
    rep(i,m) cout<<ans[i]<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:10: error: no 'operator--(int)' declared for postfix '--' [-fpermissive]
   33 |         a--,b--;
      |         ~^~
a.cc:33:14: error: no 'operator--(int)' declared for postfix '--' [-fpermissive]
   33 |         a--,b--;
      |             ~^~
Language: C++

#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long int ll;
#define MAX_N 10000

int par[MAX_N];
int siz[MAX_N];

struct edge{
	int start;
	int to;
};

void init(){
	rep(i,MAX_N){
		par[i] = i;
		size[i] = 1;
	}
}

int root(int i){
	if(par[i] == i) return i;
	par[i] = root(par[i]);
	return par[i];
}

bool isSame(int i,int j){
	i = root(par[i]);
	j = root(par[j]);
	return i == j;
}

void unite(int i, int j){
	i = root(i);
	j = root(j);
	if(i == j) return;
	if(siz[i] > siz[j]){
		int temp = i;
		i = j;
		j = temp;
	}
	par[i] = j;
	siz[j] += siz[i];
}

ll howLong(int i){
	return siz[root(i)];
}

int main()
{
	int N,M;
	cin>>N>>M;
	vector<edge> edgeList;
	vector<int> ans(M+1);
	rep(i,M){
		int x,y;
		cin>>x>>y;
		x--;
		y--;
		struct edge e;
		e.start = x;
		e.to = y;
		edgeList.push_back(e);
	}
	init();
	ans[M] = N*(N-1)/2;
	for(int i = M-1; i >= 0; i--){
		if( isSame(edgeList[i].start,edgeList[i].to) == true){
			ans[i] = ans[i+1];
			unite(edgeList[i].start,edgeList[i].to);
		}else{
			ans[i] = ans[i+1] - howLong(edgeList[i].start)*howLong(edgeList[i].to);
			unite(edgeList[i].start,edgeList[i].to);
		}
	}
	rep(i,M){
		cout<<ans[i+1]<<endl;
	}
	return 0;
}


Compiler output:
a.cc: In function 'void init()':
a.cc:28:21: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   28 |                 size[i] = 1;
      |                     ^
Language: C++

#include <iostream>
#include <vector>

using namespace std;
struct UnionFind {
	vector<long long> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(long long N) : par(N) { //最初は全てが根であるとして初期化
		for (long long i = 0; i < N; i++) par[i] = i;
	}

	long long root(long long x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(long long x, long long y) { // xとyの木を併合
		long long rx = root(x); //xの根をrx
		long long ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}
	bool same(long long x, long long y) {
		long long rx = root(x);
		long long ry = root(y);
		return rx == ry;
	}
};

long long main() {
	long long N, M;
	cin >> N >> M;
	vector<pair<long long, long long>> E(M);
	for (long long i = 0; i < M; i++) cin >> E[i].first >> E[i].second;
	vector<long long> Ans(M);
	UnionFind UF(N);
	vector<long long> Nums(N, 1);
	Ans[M - 1] = N * (N - 1) / 2;
	for (long long i = M - 1; i >= 1; i--) {
		long long a = E[i-1].first, b = E[i-1].second;
		Ans[i - 1] = Ans[i];
		if (!UF.same(a - 1, b - 1)) {
			long long ra = UF.root(a - 1);
			long long rb = UF.root(b - 1);
			Ans[i - 1] -= Nums[ra]*Nums[rb];
			UF.unite(a - 1, b - 1);
			Nums[rb] += Nums[ra];
			Nums[ra] = 0;
		}
	}
	for (long long a : Ans) cout << a << endl;
}

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

#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

const ll mod=1e9+7;

class DisjointSet{
    public:
    vector<ll> rank,p,sz;
    DisjointSet(){}
    DisjointSet(ll size){ //作られうる木の頂点数の最大値を入れる。
        rank.resize(size,0);
        p.resize(size,0);
        sz.resize(size,1);
        rep(i,size) makeSet(i);
    }
    void makeSet(ll x){ //xだけが属する木を作る。
        p[x]=x;
        rank[x]=0;
    }
    bool same(ll x,ll y){ //xとyが同じ木に属するかどうか
        return findSet(x)==findSet(y);
    }
    void unite(ll x, ll y){
        link(findSet(x),findSet(y));
    }
    void link(ll x, ll y){ //rankが大きい方の根に小さい方の根をつける。
        if(rank[x]>rank[y]){
            p[y]=x;
        }
        else{
            p[x]=y;
            if(rank[x]==rank[y]){
                rank[y]++; //xとyの木のrankが同じであれば、統合するとrankが1増える。
            }
        }
        sz[x]+=sz[y];
        sz[y]=sz[x];
    }
    ll findSet(ll x){ //xが属する木の根の番号を返す
        if(x!=p[x]){
            p[x]=findSet(p[x]);
        }
        return p[x];
    }
};


int main()
{
    ll n,m;
    cin >> n >> m;
    DisjointSet dist=DisjointSet(n+1);
    vector<ll> a(m),b(m);
    rep(i,m){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }
    ll comb=0;
    vector<ll> ans;
    for(ll i=m-1;i>=0;i--){
        if(dist.same(a[i],b[i])){
            ans.push_back(comb);
            continue;
        }
        if(i==m-1){
            comb=n*(n-1)/2;
        }
        ans.push_back(comb);
        comb-=dist.sz[findSet(a[i])]*dist.sz[findSet(b[i])];
        dist.unite(a[i],b[i]);
    }
    rep(i,m){
        cout << ans[m-1-i] << endl;
    }
    return 0;
} 

Compiler output:
a.cc: In function 'int main()':
a.cc:86:23: error: 'findSet' was not declared in this scope
   86 |         comb-=dist.sz[findSet(a[i])]*dist.sz[findSet(b[i])];
      |                       ^~~~~~~
Language: C++

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

#define int int64_t
const int maxn = 1e5 + 13;

int root[maxn], sz[maxn];
int n, m;
int64_t ans = 0;

int dsu_find (int a) {
    if (a == root[a])
        return a;
    return root[a] = dsu_find(root[a]);
}

void dsu_unite (int a, int b) {
    a = dsu_find(a);
    b = dsu_find(b);
    if (a != b) {
        ans -= int64_t(sz[a]) * int64_t(sz[b]);
        if (sz[b] > sz[a]) 
            swap(b, a);
        par[b] = a;
        sz[a] += sz[b];
    }
}

signed main () {
    cin >> n >> m;
    for (int i = 0; i <= n; ++i)
        root[i] = i, sz[i] = 1;
    vector < pair < int, int > > edge(m);
    for (int i = 0; i < m; ++i)
        cin >> edge[i].first >> edge[i].second;
    deque < int > answer;
    ans = (int64_t(n) * int64_t(n - 1)) / 2;
    for (int i = m - 1; i >= 0; --i) {
        answer.push_front(ans);
        dsu_unite(edge[i].first, edge[i].second);
    }
    for (int i = 0; i < int(answer.size()); ++i)
        cout << answer[i] << '\n';
}


Compiler output:
a.cc: In function 'void dsu_unite(int64_t, int64_t)':
a.cc:24:9: error: 'par' was not declared in this scope; did you mean '__pstl::execution::v1::par'?
   24 |         par[b] = a;
      |         ^~~
      |         __pstl::execution::v1::par
In file included from /usr/include/c++/14/pstl/glue_algorithm_defs.h:15,
                 from /usr/include/c++/14/algorithm:86,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/pstl/execution_defs.h:43:45: note: '__pstl::execution::v1::par' declared here
   43 | _GLIBCXX17_INLINE constexpr parallel_policy par{};
      |                                             ^~~
Language: C++

// #include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;

#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0; i<n; i++)

struct UnionFind {
    vector<int> par, rank, _size;
    
    UnionFind(int n) : par(n), rank(n, 1), _size(n, 1) {
        for (int i=0; i<n; i++) par[i] = i;
    }
    
    int find(int x) {
        if (par[x]==x) return x;
        else return par[x] = find(par[x]);
    }

    bool same(int x, int y) {
        x = find(x); y = find(y);
        return x == y;
    }

    void unite(int x, int y) {
        x = find(x); y = find(y);
        if(x == y) return;

        _size[x] = _size[y] = _size[x] + _size[y];
        if(rank[x] == rank[y]) rank[y]++;

        if(rank[x] > rank[y]) par[y] = x;
        else par[x] = y;
    }

    int size(int x) {
        return _size[find(x)];
    }
};


int main() {

    ll n,m;
    cin >> n >> m;
    vl a(m),b(m);
    rep(i,m) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
    }
    
    UnionFind uf(n);
    vector<ll> ans;
    
    ll cur = n *(n-1)/2;
    for(int i=m-1; i>=0; i--) {
        ans.push_back(cur);
        if(uf.same(a[i], b[i])) continue;
        ll sa = uf.size(a[i]);
        ll sb = uf.size(b[i]);
        cur -= sa * sb;
        uf.unite(a[i], b[i]);
    }
    
    for(int i=m-1; i>=0; i--) cout << ans[i] << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:62:5: error: 'vl' was not declared in this scope; did you mean 'll'?
   62 |     vl a(m),b(m);
      |     ^~
      |     ll
a.cc:64:16: error: 'a' was not declared in this scope
   64 |         cin >> a[i] >> b[i];
      |                ^
a.cc:64:24: error: 'b' was not declared in this scope
   64 |         cin >> a[i] >> b[i];
      |                        ^
a.cc:74:20: error: 'a' was not declared in this scope
   74 |         if(uf.same(a[i], b[i])) continue;
      |                    ^
a.cc:74:26: error: 'b' was not declared in this scope
   74 |         if(uf.same(a[i], b[i])) continue;
      |                          ^
a.cc:75:25: error: 'a' was not declared in this scope; did you mean 'sa'?
   75 |         ll sa = uf.size(a[i]);
      |                         ^
      |                         sa
a.cc:76:25: error: 'b' was not declared in this scope; did you mean 'sb'?
   76 |         ll sb = uf.size(b[i]);
      |                         ^
      |                         sb
Language: C++

// #include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;

#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0; i<n; i++)

struct UnionFind {
    vector<int> par, rank, _size;
    
    UnionFind(int n) : par(n), rank(n, 1), _size(n, 1) {
        for (int i=0; i<n; i++) par[i] = i;
    }
    
    int find(int x) {
        if (par[x]==x) return x;
        else return par[x] = find(par[x]);
    }

    bool same(int x, int y) {
        x = find(x); y = find(y);
        return x == y;
    }

    void unite(int x, int y) {
        x = find(x); y = find(y);
        if(x == y) return;

        _size[x] = _size[y] = _size[x] + _size[y];
        if(rank[x] == rank[y]) rank[y]++;

        if(rank[x] > rank[y]) par[y] = x;
        else par[x] = y;
    }

    int size(int x) {
        return _size[find(x)];
    }
};

int main() {

    ll n,m;
    cin >> n >> m;
    vl a(m),b(m);
    rep(i,m) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
    }
    
    UnionFind uf(n);
    vector<ll> ans;
    
    ll cur = n *(n-1)/2;
    for(int i=m-1; i>=0; i--) {
        ans.push_back(cur);
        if(uf.same(a[i], b[i])) continue;
        ll sa = uf.size(a[i]);
        ll sb = uf.size(b[i]);
        cur -= sa * sb;
        uf.unite(a[i], b[i]);
    }
    
    for(int i=m-1; i>=0; i--) cout << ans[i] << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:61:5: error: 'vl' was not declared in this scope; did you mean 'll'?
   61 |     vl a(m),b(m);
      |     ^~
      |     ll
a.cc:63:16: error: 'a' was not declared in this scope
   63 |         cin >> a[i] >> b[i];
      |                ^
a.cc:63:24: error: 'b' was not declared in this scope
   63 |         cin >> a[i] >> b[i];
      |                        ^
a.cc:73:20: error: 'a' was not declared in this scope
   73 |         if(uf.same(a[i], b[i])) continue;
      |                    ^
a.cc:73:26: error: 'b' was not declared in this scope
   73 |         if(uf.same(a[i], b[i])) continue;
      |                          ^
a.cc:74:25: error: 'a' was not declared in this scope; did you mean 'sa'?
   74 |         ll sa = uf.size(a[i]);
      |                         ^
      |                         sa
a.cc:75:25: error: 'b' was not declared in this scope; did you mean 'sb'?
   75 |         ll sb = uf.size(b[i]);
      |                         ^
      |                         sb
Language: C++

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


struct UnionFind {
    vector<int> par;
    UnionFind(int n) : par(n, -1){}

    int root(int x) {
        if(par[x]<0) return x;
        return par[x] = root(par[x]);
    }

    bool same(int x, int y) {
        return root(x)==root(y);
    }

    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if(x==y) return false;
        if(x>y) swap(x, y);
        par[x]+=par[y];
        par[y] = x;
        return true;
    }

    int size(int x){
        return -par[root(x)];
    }
};

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(m), b(m);
    rep(i,m) {
        cin >> a[i] >> b[i]; a[i]--, b[i]--;
    }

    UnionFind uf(n);
    ll now = n*(n-1)/2;
    vector<ll> ans;
    rep(i,m){
        ans.push_back(now);
        int c = a[m-1-i]; 
        int d = b[m-1-i];
        if(uf.same(c, d)) continue;
        ll temp = (ll)uf.size(c) * uf.size(d);
        now -= temp;
        uf.unite(c, d);
    }
    reverse(all(ans));
    rep(i,m{
        cout << ans[i] << endl;
    }
    return 0;
}

Compiler output:
a.cc:63:2: error: unterminated argument list invoking macro "rep"
   63 | }
      |  ^
a.cc: In function 'int main()':
a.cc:59:5: error: 'rep' was not declared in this scope
   59 |     rep(i,m{
      |     ^~~
a.cc:59:8: error: expected '}' at end of input
   59 |     rep(i,m{
      |        ^
a.cc:38:12: note: to match this '{'
   38 | int main() {
      |            ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
    string S;
    cin >> S;
    int b=0;
    int w=0;
    for(int i=0;i<S.length();i++){
        if(S[i]=='0')w++;
        else b++;
    }
    cout << min(b,w)*2 << endl;
}
#include <bits/stdc++.h>
using namespace std;

map<int,int> mp;
int a[100005],b[100005];
long long int c[100005];
int n,m;
vector<int> sima[100005];
int num;
long long int dfs(int now){
        if(mp[a[now]]+mp[b[now]]==0){
            mp[a[now]]=num;
            mp[b[now]]=num;
            sima[num].push_back(a[now]);
            sima[num].push_back(b[now]);
            num++;
            return c[now]+1LL;
        }
        else if(mp[a[now]]==0 || mp[b[now]]==0){
            if(mp[a[now]]==0 && mp[b[now]]>0){
                mp[a[now]]=mp[b[now]];
                sima[mp[b[now]]].push_back(a[now]);
                long long int tmp=sima[mp[b[now]]].size();
                return c[now]+tmp-1;
            }
            else{
                mp[b[now]]=mp[a[now]];
                sima[mp[a[now]]].push_back(b[now]);
                long long int tmp=sima[mp[a[now]]].size();
                return c[now]+tmp-1;
            }
        }
        else if(mp[a[now]]==mp[b[now]])return c[now];
        else{
            long long int tmp=sima[max(mp[a[now]],mp[b[now]])].size();
            long long int tmp2=sima[min(mp[a[now]],mp[b[now]])].size();
            for(int u:sima[max(mp[a[now]],mp[b[now]])]){
                mp[u]=min(mp[a[now]],mp[b[now]]);
                sima[min(mp[a[now]],mp[b[now]])].push_back(u);                
            }
            return c[now]+tmp*tmp2;       
        }
        }

int main(){
    cin >> n >> m;
    for(int i=1;i<m+1;i++)cin >> a[i] >> b[i];
    num=1;
    for(int i=m;i>0;i--)c[i-1]=dfs(i);
    for(int i=1;i<m+1;i++)cout << c[0]-c[i] << endl;
}

Compiler output:
a.cc:58:5: error: redefinition of 'int main()'
   58 | int main(){
      |     ^~~~
a.cc:3:5: note: 'int main()' previously defined here
    3 | int main(){
      |     ^~~~