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

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 10000;

unordered_map<int, bool> graph[N];

ll solve(int n) {

    queue<int> q;

    bool vis[n];

    memset(vis, false, sizeof vis);

    int start = 0;

    

    q.push(start);

    vis[start] = true;

    ll count = 0;

    while(!q.empty()){

         int curr = q.front();

         q.pop();

         count++;

         

         for(auto it : graph[curr] ) {

               if(!vis[it.first] && it.second){

                    q.push(it.first);

                    vis[it.first] = true;

               } 

         } 

   } 

   return count;

}

int main() {

    ios_base::sync_with_stdio(false) ;

    cin.tie(0);

    

    int n, m; cin >> n >>m;

    int a[n], b[n] ;

    for(int i = 0; i < m; i++) {

         cin >> a[i] >> b[i];

         a[i]--;

         b[i]--;

         graph[a[i]][b[i]] = true;

         graph[b[i]][a[i]] = true;

    } 

     for( int = 0; i < m; i++) {

         graph[a[i]][b[i]] = false;

         graph[b[i]][a[i]] = false;

         

         ll ans = solve(n) ;

         cout << ans*(n-ans) << "\n" ;

         graph[a[i]][b[i]] = true;

         graph[b[i]][a[i]] = true;

    } 

} 

Compiler output:
a.cc: In function 'int main()':
a.cc:83:15: error: expected unqualified-id before '=' token
   83 |      for( int = 0; i < m; i++) {
      |               ^
a.cc:83:14: error: expected ';' before '=' token
   83 |      for( int = 0; i < m; i++) {
      |              ^~
      |              ;
a.cc:83:15: error: expected primary-expression before '=' token
   83 |      for( int = 0; i < m; i++) {
      |               ^
a.cc:83:20: error: 'i' was not declared in this scope
   83 |      for( int = 0; i < m; i++) {
      |                    ^
a.cc:83:25: error: expected ')' before ';' token
   83 |      for( int = 0; i < m; i++) {
      |         ~               ^
      |                         )
a.cc:83:27: error: 'i' was not declared in this scope
   83 |      for( int = 0; i < m; i++) {
      |                           ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 10000;

unordered_map<int, bool> graph[N];

ll solve(int n) {

    queue<int> q;

    bool vis[n];

    memset(vis, false, sizeof vis);

    int start = 1;

    

    q.push(start);

    vis[start] = true;

    ll count = 0;

    while(!q.empty()){

         int curr = q.front();

         q.pop();

         count++;

         

         for(auto it : graph[curr] ) {

               if(!vis[it.first] && it.second){

                    q.push(it.first);

                    vis[it.first] = true;

               } 

         } 

   } 

   return count;

}

int main() {

    ios_base::sync_with_stdio(false) ;

    cin.tie(0);

    

    int n, m; cin >> n >>m;

    int a[n], b[n] ;

    for(int i = 0; i < m; i++) {

         int a, b; cin >> a[i] >> b[i];

         a[i]--;

         b[i]--;

         graph[a[i]][b[i]] = true;

         graph[b[i]][a[i]] = true;

    } 

     for( int = 0; i < m; i++) {

         graph[a[i]][b[i]] = false;

         graph[b[i]][a[i]] = false;

         

         ll ans = solve(n);

         cout << ans*(n-ans) << "\n" ;

         graph[a[i]][b[i]] = true;

         graph[b[i]][a[i]] = true;

    } 

} 

Compiler output:
a.cc: In function 'int main()':
a.cc:71:28: error: invalid types 'int[int]' for array subscript
   71 |          int a, b; cin >> a[i] >> b[i];
      |                            ^
a.cc:71:36: error: invalid types 'int[int]' for array subscript
   71 |          int a, b; cin >> a[i] >> b[i];
      |                                    ^
a.cc:73:11: error: invalid types 'int[int]' for array subscript
   73 |          a[i]--;
      |           ^
a.cc:75:11: error: invalid types 'int[int]' for array subscript
   75 |          b[i]--;
      |           ^
a.cc:77:17: error: invalid types 'int[int]' for array subscript
   77 |          graph[a[i]][b[i]] = true;
      |                 ^
a.cc:77:23: error: invalid types 'int[int]' for array subscript
   77 |          graph[a[i]][b[i]] = true;
      |                       ^
a.cc:79:17: error: invalid types 'int[int]' for array subscript
   79 |          graph[b[i]][a[i]] = true;
      |                 ^
a.cc:79:23: error: invalid types 'int[int]' for array subscript
   79 |          graph[b[i]][a[i]] = true;
      |                       ^
a.cc:83:15: error: expected unqualified-id before '=' token
   83 |      for( int = 0; i < m; i++) {
      |               ^
a.cc:83:14: error: expected ';' before '=' token
   83 |      for( int = 0; i < m; i++) {
      |              ^~
      |              ;
a.cc:83:15: error: expected primary-expression before '=' token
   83 |      for( int = 0; i < m; i++) {
      |               ^
a.cc:83:20: error: 'i' was not declared in this scope
   83 |      for( int = 0; i < m; i++) {
      |                    ^
a.cc:83:25: error: expected ')' before ';' token
   83 |      for( int = 0; i < m; i++) {
      |         ~               ^
      |                         )
a.cc:83:27: error: 'i' was not declared in this scope
   83 |      for( int = 0; i < m; i++) {
      |                           ^
Language: C++

#include <iostream>
#include <assert.h>
#include <utility>
#include <vector>

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

    int32_t N, M;
    std::cin >> N >> M;
    using bridge_vect_type = std::vector<std::pair<int32_t, int32_t>>;
    bridge_vect_type bridge_vect(M);
    for(auto& i : bridge_vect){
        std::cin >> i.first >> i.second;
    }

    // sum of connections between islands with M to M-i th Bridge.
    int64_t connections[M+1] = {0};
    std::vector<int32_t> cluster_size(N, 1);
    std::vector<int32_t> i2cluster(N);
    for(int32_t i = 0; i < N; i++){
        i2cluster[i] = i;
    }
    using c2i_type = std::vector<std::vector<int32_t>>;
    c2i_type c2i_vect(N);
    for(int32_t i = 0; i < N; i++){
        c2i_vect[i].push_back(i);
    }

    auto num_cons = [](int64_t num) -> int64_t {return num * (num - 1) / 2;};

    for(int32_t b_idx = M - 1; b_idx >= 0; b_idx--){
        std::pair<int32_t, int32_t> bridge = bridge_vect[b_idx];
        int32_t cl_a = i2cluster[bridge.first - 1];
        int32_t cl_b = i2cluster[bridge.second - 1];
        //std::cout << "cl_a: " << cl_a << ", cl_b: " << cl_b << std::endl;
        if(cl_a == cl_b){
            connections[b_idx] = connections[b_idx + 1];
        }
        else{
            connections[b_idx] = 
                connections[b_idx + 1] - num_cons(cluster_size[cl_a]) - num_cons(cluster_size[cl_b]) + num_cons(cluster_size[cl_a] + cluster_size[cl_b]);
            cluster_size[cl_a] += cluster_size[cl_b];
            for(int32_t i = 0; i < (int32_t) c2i_vect[cl_b].size(); i++){
                c2i_vect[cl_a].push_back(c2i_vect[cl_b][i]);
                i2cluster[c2i_vect[cl_b][i]] = i2cluster[bridge.first - 1];
            }
            c2i_vect[cl_b].erase(c2i_vect[cl_b].begin(), c2l_vect[cl_b].end());
        }
    }

    for(int32_t i = 1; i <= M; i++){
        std::cout << connections[0] - connections[i] << std::endl;
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:49:58: error: 'c2l_vect' was not declared in this scope; did you mean 'c2i_vect'?
   49 |             c2i_vect[cl_b].erase(c2i_vect[cl_b].begin(), c2l_vect[cl_b].end());
      |                                                          ^~~~~~~~
      |                                                          c2i_vect
Language: C++

#include <vector>

struct Union_Find {
    std::vector<int> par;
    std::vector<int> rank;
    std::vector<int> sz;
    //初期化
    void init( int n ) {
        par.resize( n );
        rank.resize( n );
        sz.resize(n);
        for ( int i = 0; i < n; ++i ) {
            par[ i ] = i;
            rank[ i ] = 0;
            sz[ i ] = 1;
        }
    }
    
    //木の根を探す
    int find( int s ) {
        if ( par[ s ] == s ) {
            return s;
        }
        return par[ s ] = find( par[ s ] );
    }
    
    //結合
    void unite( int x, int y ) {
        int a = find( x ), b = find( y );
        if ( a == b ) {
            return;
        }
        int size = sz[a] + sz[b];
        sz[a] = sz[b] = size;
        if ( rank[ a ] < rank[ b ] ) {
            par[ a ] = b;
        }
        else {
            par[ a ] = b;
            if ( rank[ a ] == rank[ b ] ) {
                ++rank[ b ];
            }
        }
    }
    
    //二つの数の根が同じかどうか
    bool same( int x, int y ) {
        return find( x ) == find( y );
    }
    
    //サイズを返す
    int size(int n) {
        return sz[find(n)];
    }
};

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

//region #include <cp_helper>
#include <vector>
#include <iostream>
using namespace std;
#define io() ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long
#define vll vector<ll>
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define viin(a, n) for (ll i=0; i<n; ++i) in2(arr[i].first, arr[i].second)
#define out(n) cout << n
#define outn(n) out(n) << '\n'
#define fori(i, n) for (ll i=0; i<n; ++i)
#define ford(i, n) for (ll i=n-1; i>=0; --i)
const int mod = (int)(1e9) + 7;
//endregion

ll num_groups, p[100005], grpsize[100005];
int par(int x) { return (p[x]==x)? x:par(p[x]); } //No compression
bool isSameGroup(int a, int b) { return par(a) == par(b); }
void merge(int a, int b) {
    a = par(a), b = par(b);
    num_groups -= (!isSameGroup(a, b));
    if (grpsize[a] < grpsize[b]) {
        p[a] = b;
        grpsize[b] += grpsize[a];
    }
    else {
        p[b] = a;
        grpsize[a] += grpsize[b];
    }
}

int main() {
    io();
    ll n, m, t, x, y;
    in2(n, m);
    vll ans(m);
    fori (i, n) p[i] = i, grpsize[i] = 1;
    num_groups = n;
    vii arr(m);
    viin(arr, m);
    t = n*(n-1)/2;
    ford (i, m) {
        ans[i] = t;
        x = par(arr[i].first-1), y = par(arr[i].second-1);
        if (x == y) continue;
        t -= (grpsize[x] * grpsize[y]);
        merge(x, y);
    }
    fori (i, m) outn(ans[i]);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:41:5: error: 'vii' was not declared in this scope; did you mean 'viin'?
   41 |     vii arr(m);
      |     ^~~
      |     viin
a.cc:10:47: error: 'arr' was not declared in this scope
   10 | #define viin(a, n) for (ll i=0; i<n; ++i) in2(arr[i].first, arr[i].second)
      |                                               ^~~
a.cc:9:26: note: in definition of macro 'in2'
    9 | #define in2(n, m) cin >> n >> m
      |                          ^
a.cc:42:5: note: in expansion of macro 'viin'
   42 |     viin(arr, m);
      |     ^~~~
a.cc:46:17: error: 'arr' was not declared in this scope
   46 |         x = par(arr[i].first-1), y = par(arr[i].second-1);
      |                 ^~~
Language: C++

//region #include <cp_helper>
#include <vector>
#include <iostream>
using namespace std;
#define io() ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long
#define vll vector<ll>
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define vin(a, n) for (ll i=0; i<n; ++i) in(a[i])
#define out(n) cout << n
#define outn(n) out(n) << '\n'
#define fori(i, n) for (ll i=0; i<n; ++i)
#define ford(i, n) for (ll i=n-1; i>=0; --i)
const int mod = (int)(1e9) + 7;
//endregion

ll num_groups, p[100005], grpsize[100005];
int par(int x) { return (p[x]==x)? x:par(p[x]); } //No compression
bool isSameGroup(int a, int b) { return par(a) == par(b); }
void merge(int a, int b) {
    a = par(a), b = par(b);
    num_groups -= (!isSameGroup(a, b));
    if (grpsize[a] < grpsize[b]) {
        p[a] = b;
        grpsize[b] += grpsize[a];
    }
    else {
        p[b] = a;
        grpsize[a] += grpsize[b];
    }
}

int main() {
    io();
    ll n, m, t, x, y;
    in2(n, m);
    vll ans(m);
    fori (i, n) p[i] = i, grpsize[i] = 1;
    num_groups = n;
    vii arr(m);
    viin(arr, m);
    t = n*(n-1)/2;
    ford (i, m) {
        ans[i] = t;
        x = par(arr[i].first-1), y = par(arr[i].second-1);
        if (x == y) continue;
        t -= (grpsize[x] * grpsize[y]);
        merge(x, y);
    }
    fori (i, m) outn(ans[i]);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:41:5: error: 'vii' was not declared in this scope; did you mean 'vin'?
   41 |     vii arr(m);
      |     ^~~
      |     vin
a.cc:42:10: error: 'arr' was not declared in this scope
   42 |     viin(arr, m);
      |          ^~~
a.cc:42:5: error: 'viin' was not declared in this scope; did you mean 'vin'?
   42 |     viin(arr, m);
      |     ^~~~
      |     vin
Language: C++

//region #include <cp_helper>
#include <vector>
#include <iostream>
using namespace std;
#define io() ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long
#define vll vector<ll>
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define vin(a, n) for (ll i=0; i<n; ++i) in(a[i])
#define outn(n) out(n) << '\n'
#define fori(i, n) for (ll i=0; i<n; ++i)
#define ford(i, n) for (ll i=n-1; i>=0; --i)
const int mod = (int)(1e9) + 7;
//endregion

ll num_groups, p[100005], grpsize[100005];
int par(int x) { return (p[x]==x)? x:par(p[x]); } //No compression
bool isSameGroup(int a, int b) { return par(a) == par(b); }
void merge(int a, int b) {
    a = par(a), b = par(b);
    num_groups -= (!isSameGroup(a, b));
    if (grpsize[a] < grpsize[b]) {
        p[a] = b;
        grpsize[b] += grpsize[a];
    }
    else {
        p[b] = a;
        grpsize[a] += grpsize[b];
    }
}

int main() {
    io();
    ll n, m, t, x, y;
    in2(n, m);
    vll ans(m);
    fori (i, n) p[i] = i, grpsize[i] = 1;
    num_groups = n;
    vii arr(m);
    viin(arr, m);
    t = n*(n-1)/2;
    ford (i, m) {
        ans[i] = t;
        x = par(arr[i].first-1), y = par(arr[i].second-1);
        if (x == y) continue;
        t -= (grpsize[x] * grpsize[y]);
        merge(x, y);
    }
    fori (i, m) outn(ans[i]);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:40:5: error: 'vii' was not declared in this scope; did you mean 'vin'?
   40 |     vii arr(m);
      |     ^~~
      |     vin
a.cc:41:10: error: 'arr' was not declared in this scope
   41 |     viin(arr, m);
      |          ^~~
a.cc:41:5: error: 'viin' was not declared in this scope; did you mean 'vin'?
   41 |     viin(arr, m);
      |     ^~~~
      |     vin
a.cc:11:17: error: 'out' was not declared in this scope; did you mean 'outn'?
   11 | #define outn(n) out(n) << '\n'
      |                 ^~~
a.cc:50:17: note: in expansion of macro 'outn'
   50 |     fori (i, m) outn(ans[i]);
      |                 ^~~~
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <bitset>
#include<vector>
#include<cstdlib>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i,k) for(int i=0;i<k;i++)
ll n, m, i, j, k,o,p;
ll a[100005], b[100005];

int f[100001],g[100001], zz[100005];
int find(int x) {
	if (f[x] != x)
		f[x] = find(f[x]);
		
	return f[x];
}
void lian(int x, int y,int i) {
	f[y] = x;
	zz[i] = zz[i + 1] - (g[x] * g[y]);
	g[x] += g[y];
	g[y] = g[x];
}
int main() {
	cin >> n >> m;
	for (i = 1; i < m + 1; i++)cin >> a[i] >> b[i];
	zz[m+1] = n*(n-1)/2;

	for (int i = 1; i <= n; i++) {
		f[i] = i;
		g[i] = 1;
	}
	for (int i = m; i >= 1; i--) {
		int y, z;
		y = a[i]; z = b[i];
			o = find(y); p = find(z);
			if (o != p) {
				lian(find(o), find(p), i);
			}
			else zz[i] == z[i + 1];
	}


	rep(i, m)cout << zz[i+2]<< "\n";
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:46:40: error: invalid types 'int[int]' for array subscript
   46 |                         else zz[i] == z[i + 1];
      |                                        ^
Language: C++

// 120_D_Decayed_Bridges.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

typedef pair<int, int> bridge;

class UnionFind
{
	//par[i]：ノードiの親
	//count[i]：iが親の時、iが属するグループのノード数
	vector<int> par; 
	vector<int> count;
public:
	UnionFind(int N)
	{
		par.push_back(0);
		count.push_back(0);

		for (int i = 1; i <= N; i++)
		{
			//最初は全てが根であるとして初期化
			par.push_back(i);
			count.push_back(1);
		}
	}

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

		//ついでに親を張り替え
		return par[x] = root(par[x]);
	}

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

		//要素数の変更
		count[ry] += count[rx];
		count[rx] = 0;
	}

	// 2つのデータx, yが属する木が同じならtrueを返す
	bool same(int x, int y)
	{ 
		return root(x) == root(y);
	}

	//指定したデータxが属するグループの要素数を返す
	int size(int x)
	{
		return count[root(x)];
	}
};

int main()
{
    //解答方針
	//不便さを直接計算するのは面倒（橋を取り除いても、別ルートから島を行き来できるかもしれない）。
	//変わりに島に対して橋を一つずつ加えていって、行き来できるようになる島の個数（「便利さ」）を計算する。

	int n, m;
	cin >> n >> m;

	//橋を受け取る
	vector<bridge> bridges;
	for (int i = 0; i < m; i++)
	{
		int a, b;
		cin >> a >> b;

		bridges.push_back({ a, b });
	}

	//橋を逆順に処理
	reverse(bridges.begin(), bridges.end());

	vector<ll> usefulness;

	//UnionFind木で島のグループを管理
	auto uf = new UnionFind(n);
	for (auto b : bridges)
	{
		ll tmp = 0;

		//橋の始点と終点が異なるグループに属するときは、
		//1.橋を架けたときの便利さを計算
		//2.グループを併合
		if (!uf->same(b.first, b.second))
		{
			tmp = (ll)uf->size(b.first) * (ll)uf->size(b.second);

			uf->unite(b.first, b.second);
		}

		//橋を追加するたびに追加
		usefulness.push_back(tmp);
	}

	//便利さの累積値を逆順で表示
	reverse(usefulness.begin(), usefulness.end());

	ll accum = 0;
	for (ll u : usefulness)
	{
		accum += u;
		cout << accum << endl;
	}

}


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

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
 
struct union_find{
    vector<int> par;
    vector<int> rank;
    vector<int> siz;
    union_find(int sz){
        par.resize(sz);
        rank.assign(sz,0);
        siz.assign(sz,1);
        for(int i=0;i<sz;i++) par[i]=i;
    }
    int find(int a){
        if(par[a]==a) return a;
        else return par[a] = find(par[a]);
    }
    void unite(int a,int b){
        if(find(a)==find(b)) return;
        int root_a,root_b;
        root_a=find(a),root_b=find(b);
        if(rank[root_a]>rank[root_b]){
            par[root_b]=root_a;
            siz[root_a]+=siz[root_b];
        }else if(rank[root_a]<rank[root_b]){
            par[root_a]=root_b;
            siz[root_b]+=siz[root_a];
        }else{
            rank[root_a]++;
            par[root_b]=root_a;
            siz[root_a]+=siz[root_b];
        }
    }
    bool same(int a,int b){return find(a)==find(b);}
    int size(int a){
        return siz[find(a)];
    }
};
 
int main(){
    int n,m;
    cin>>n>>m;
    vector<pair<int,int>> v(m);
    for(int i=0;i<m;i++){
        int a,b;
        cin >> a >> b;
        v[i].first=a;
        v[i].second=b;
    }
    union_find uf(n);
    vector<int> ans(m+1);
    ans[m]=n*(n-1)/2;
    for(int i=m-1;i>=0;i--){
        if(uf.find(v[i].first-1)==uf.find(v[i].second-1)){
            ans[i]=ans[i+1];
        }else{
            ans[i]=ans[i+1]-uf.size(v[i].first-1)*uf.size(v[i].second-1);
        }
        uf.unite(v[i].first-1,v[i].second-1);
    }
    for(int i=1;i<m+1;i++){
        cout<<ans[i]<<endl;
    }
}
 

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

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

class Uni {
public:
    vector<int> parent; //親ノード
    vector<int> Siz; //集合の大きさ

    // n要素で初期化
    void init(int n) {
        parent.resize(n);
        Siz.assign(n, 1);
        rep(i, n) {
            parent[i] = i;
        }
    }

    // xの属する集合の根を求める
    int root(int x) {
        if(parent[x] == x) {
            return x;
        }
        else {
            return parent[x] = root(parent[x]);
        }
    }

    // xとyの属する集合を併合
    void unite(int x, int y) {

        x = root(x);
        y = root(y);
        if(x == y) {
            return;
        }

        if(Siz[x] < Siz[y]) {
            swap(x, y);
        }

        Siz[x] += Siz[y];
        parent[y] = x;
    }

    // xとyが同じ集合に属するかどうか
    bool same(int x, int y) {
        return root(x) == root(y);
    }

    // xの属する集合の要素数を求める
    int size(int x) {
        return Siz[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]--;
    }

    Uni.init(n);

    vector<ll> ans(m);
    ans[m-1] = (ll)n*(n-1)/2;
    for(int i = m-1; i >= 1; i--) {

        if(Uni.same(a[i], b[i])) {
            ans[i-1] = ans[i];
        }
        else {
            ans[i-1] = ans[i] - (ll)Uni.size(a[i]) * Uni.size(b[i]);
            Uni.unite(a[i], b[i]);
        }
    }

    rep(i, m) {
        cout << ans[i] << "\n";
    }

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:74:8: error: expected unqualified-id before '.' token
   74 |     Uni.init(n);
      |        ^
a.cc:80:15: error: expected unqualified-id before '.' token
   80 |         if(Uni.same(a[i], b[i])) {
      |               ^
a.cc:84:40: error: expected primary-expression before '.' token
   84 |             ans[i-1] = ans[i] - (ll)Uni.size(a[i]) * Uni.size(b[i]);
      |                                        ^
a.cc:84:57: error: expected primary-expression before '.' token
   84 |             ans[i-1] = ans[i] - (ll)Uni.size(a[i]) * Uni.size(b[i]);
      |                                                         ^
a.cc:85:16: error: expected unqualified-id before '.' token
   85 |             Uni.unite(a[i], b[i]);
      |                ^
Language: C++

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

class UnionFind {
public:
    vector<int> parent; //親ノード
    vector<int> Siz; //集合の大きさ

    // n要素で初期化
    void init(int n) {
        parent.reSize(n);
        Siz.assign(n, 1);
        rep(i, n) {
            parent[i] = i;
        }
    }

    // xの属する集合の根を求める
    int root(int x) {
        if(parent[x] == x) {
            return x;
        }
        else {
            return parent[x] = root(parent[x]);
        }
    }

    // xとyの属する集合を併合
    void unite(int x, int y) {

        x = root(x);
        y = root(y);
        if(x == y) {
            return;
        }

        if(Siz[x] < Siz[y]) {
            swap(x, y);
        }

        Siz[x] += Siz[y];
        parent[y] = x;
    }

    // xとyが同じ集合に属するかどうか
    bool same(int x, int y) {
        return root(x) == root(y);
    }

    // xの属する集合の要素数を求める
    int size(int x) {
        return Siz[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 Uni(n);
    Uni.init(n);

    vector<ll> ans(m);
    ans[m-1] = (ll)n*(n-1)/2;
    for(int i = m-1; i >= 1; i--) {

        if(Uni.same(a[i], b[i])) {
            ans[i-1] = ans[i];
        }
        else {
            ans[i-1] = ans[i] - (ll)Uni.size(a[i]) * Uni.size(b[i]);
            Uni.unite(a[i], b[i]);
        }
    }

    rep(i, m) {
        cout << ans[i] << "\n";
    }

    return 0;
}

Compiler output:
a.cc: In member function 'void UnionFind::init(int)':
a.cc:18:16: error: 'class std::vector<int>' has no member named 'reSize'; did you mean 'resize'?
   18 |         parent.reSize(n);
      |                ^~~~~~
      |                resize
a.cc: In function 'int main()':
a.cc:74:20: error: no matching function for call to 'UnionFind::UnionFind(int&)'
   74 |     UnionFind Uni(n);
      |                    ^
a.cc:11:7: note: candidate: 'UnionFind::UnionFind()'
   11 | class UnionFind {
      |       ^~~~~~~~~
a.cc:11:7: note:   candidate expects 0 arguments, 1 provided
a.cc:11:7: note: candidate: 'UnionFind::UnionFind(const UnionFind&)'
a.cc:11:7: note:   no known conversion for argument 1 from 'int' to 'const UnionFind&'
a.cc:11:7: note: candidate: 'UnionFind::UnionFind(UnionFind&&)'
a.cc:11:7: note:   no known conversion for argument 1 from 'int' to 'UnionFind&&'
Language: C++

#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) cout << (x) << endl;
#define sz(x) int(x.size())
 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};


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

    UnionFind(ll n) : par(n, -1) { }
    void init(ll n) { par.assign(n, -1); }

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

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    bool merge(ll x, ll y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

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

int main(void){
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int n,m;
    cin >> n >> m;
    vector<ll> a(m);
    vector<ll> b(m);
    rep(i,m){
      cin >> a[i] >> b[i];
      --a[i], --b[i];
    }
    vector<ll> ans(m);
  	ans[m-1] = n * (n - 1) / 2;

    UnionFind Uni(n);

    for(ll i = m-1; i >= 1; i--){
      ans[i-1] = ans[i];
      if(Uni.root(A[i]) != Uni.root(B[i])){
        ans[i-1] -= Uni.size(a[i]) * Uni.size(b[i]);
        Uni.merge(a[i],b[i]);
      }
    }
    rep(i,m){
    cout << ans[i] << endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:88:19: error: 'A' was not declared in this scope
   88 |       if(Uni.root(A[i]) != Uni.root(B[i])){
      |                   ^
a.cc:88:37: error: 'B' was not declared in this scope
   88 |       if(Uni.root(A[i]) != Uni.root(B[i])){
      |                                     ^
Language: C++

#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) cout << (x) << endl;
#define sz(x) int(x.size())
 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};


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

    UnionFind(ll n) : par(n, -1) { }
    void init(ll n) { par.assign(n, -1); }

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

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    bool merge(ll x, ll y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

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

int main(void){
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int n,m;
    cin >> n >> m;
    vector<ll> a(m);
    vector<ll> b(m);
    rep(i,m){
      cin >> a[i] >> b[i];
      --a[i], --b[i];
    }
    vector<ll> ans(m);
  	ans[m-1] = n * (n - 1) / 2;

    UnionFind Uni(N);

    for(ll i = m-1; i >= 1; i--){
      if(!Uni.issame(a[i],b[i])){
        ans[i-1] = ans[i] - Uni.size(a[i]) * Uni.size(b[i]);
        Uni.merge(a[i],b[i]);
      }else{
        ans[i-1] = ans[i];
      }
    }
    rep(i,M){
    cout << ans[i] << endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:84:19: error: 'N' was not declared in this scope
   84 |     UnionFind Uni(N);
      |                   ^
a.cc:94:11: error: 'M' was not declared in this scope
   94 |     rep(i,M){
      |           ^
a.cc:6:39: note: in definition of macro 'rep'
    6 | #define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
      |                                       ^
Language: C++

#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

struct UnionFind{
  VI par,sizes; // par[i]:iの親の番号
  UnionFind(int n) : par(n), sizes(n,1){ // 最初は全てが根であるとして初期化
    rep(i,n) par[i] = i;
  }
  int root(int x){
    if(par[x]==x) return x;
    return par[x] = root(par[x]);
  }
  void unite(int x, int y){
    int rx = root(x); int ry = root(y);
    if(rx==ry) return;
    if(sizes[rx]<sizes[ry]) swap(rx,ry);
    par[ry] = rx;
    sizes[rx] += sizes[ry];
  }
  bool same(int x, int y){
    return root(x)==root(y);
  }
  int size(int x){
    return sizes[root(x)];
  }
};

signed main(){
  int n,m; cin>>n>>m;
  UnionFind tree(n);
  int a[n],b[n]
  ll ans[m];
  rep(i,m){cin>>a[i]>>b[i]; a[i]--; b[i]--;}

  ans[m-1] = n*(n-1)/2;
  REPS(i,m-1){
    int l,r; l=a[i]; r=b[i];
    ans[i-1] = ans[i];
    if(tree.same(l,r)) continue;
    ans[i-1] -= tree.size(l)*tree.size(r);
    tree.unite(l,r);
  }
  rep(i,m) cout << ans[i] << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:12: error: expected initializer before 'long'
   18 | #define ll long long int
      |            ^~~~
a.cc:78:3: note: in expansion of macro 'll'
   78 |   ll ans[m];
      |   ^~
a.cc:79:23: error: 'b' was not declared in this scope
   79 |   rep(i,m){cin>>a[i]>>b[i]; a[i]--; b[i]--;}
      |                       ^
a.cc:81:3: error: 'ans' was not declared in this scope; did you mean 'abs'?
   81 |   ans[m-1] = n*(n-1)/2;
      |   ^~~
      |   abs
a.cc:83:24: error: 'b' was not declared in this scope
   83 |     int l,r; l=a[i]; r=b[i];
      |                        ^
Language: C++

#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,int> P;


struct UnionFind{
  //親の番号を格納する。親だった場合はその集合のサイズ
  vector<int> Parent;

  //作る時はParentの値を全て-1にする
  //こうすると全てバラバラになる
  UnionFind(int N){
    Parent=vector<int>(N,-1);
  }
  //Aがどのグループに属しているかを調べる
  int root(int A){
    if(Parent[A]<0) return A;
    return Parent[A]=root(Parent[A]);
  }

  //自分のいるグループの頂点数を調べる
  int size(int A){
    return -Parent[root(A)];
  }

  //AとBを結合する
  bool connect(int A,int B){
    //AとBを直接つなぐのではなく、root(A)にroot(B)を結合する
    A=root(A);
    B=root(B);
    if(A==B){
      return false;
    }
    //大きい方(A)に小さい方(B)を結合したい
    //大小が逆ならひっくり返す
    if(size(A) < size(B)) swap(A,B);

    //Aのサイズを更新する
    Parent[A]+=Parent[B];
    Parent[B]=A;
    return true;
  }
}


int main(){
  ll N,M;
  cin>>N>>M;
  vector<int> A(M),B(M);
  for(int i=0;i<M;i++){
    cin>>A[i]>>B[i];
    A[i]--; B[i]--;
  }
  vector<ll> ans(M);
  ans[M-1]=N*(N-1)/2;

  UnionFind Uni(N);

  for(int i=M-1;i>=1;i--){
    if(Uni.root(A[i])!=Uni.root(B[i])){
      ans[i-1]=ans[i]-(ll)Uni.size(A[i])*Uni.size(B[i]);
      Uni.connect(A[i],B[i]);
    }else ans[i-1]=ans[i];
  }

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


Compiler output:
a.cc:52:2: error: expected ';' after struct definition
   52 | }
      |  ^
      |  ;
Language: C++

//
//  main.cpp
//  120_D_Decayed_Bridges
//
//  Created by tolemy on 2019/08/15.
//  Copyright © 2019 tolemy. All rights reserved.
//

#include <iostream>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

int main(int argc, const char * argv[]) {
    
    int n, m = 0;
    
    cin >> n >> m;
    
    //島の連結状態を表す集合の１次元配列
    typedef vector<int> group;
    group *groups = new group[n+1];
    for(int i=1;i<=n;i++)
    {
        groups[i].push_back(i);
    }
    
    //橋
    typedef pair<int, int> bridge;
    bridge *bridges = new bridge[m];
    for(int i=0;i<m;i++)
    {
        cin >> bridges[i].first >> bridges[i].second;
    }
    
    //回答方針
    //橋を取り除きながら行き来できなくなる島を探すのは難しい。
    //橋を逆順に追加しながら行き来できるようになる島を数えていく。
    
    //橋iを追加した時のペアの数
    long *counts = new long[m+1]();
    
    for(int i=m-1;i>=0;i--)
    {
        long count = 0;
        bridge b = bridges[i];
        
        group g1 = groups[b.first];
        group g2 = groups[b.second];
        
        //集合が異なる場合はマージ
        if(g1!=g2)
        {
            //行けるようになった島のペアを計算
            count = g1.size() * g2.size();
            
            //集合をマージ
            group merged;
            set_union(g1.begin(), g1.end(), g2.begin(), g2.end(), back_inserter(merged));
            
            //所属集合の置き換え
            for(int i:merged)
            {
                groups[i] = merged;
            }
        }
        
        counts[i] = counts[i+1] + count;
    }
    
    //答えの表示
    //不自由度 = 接続された島の最大値 - 接続数
    long max_connection_count = n * (n - 1) / 2;
    
    for(int i=1;i<=m;i++)
    {
        cout << max_connection_count - counts[i] << endl;
    }
    
    return 0;
}


Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:61:13: error: 'set_union' was not declared in this scope
   61 |             set_union(g1.begin(), g1.end(), g2.begin(), g2.end(), back_inserter(merged));
      |             ^~~~~~~~~
Language: C++

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

struct UnionFind {
    vector < int > par;
    
    UnionFind ( int n): par (n, -1 ) {}
     void init ( int n) {par.assign (n, -1 );}
    
    int root ( int x) {
         if (par [x] < 0 ) return x;
         else  return par [x] = root (par [x]);
    }
    
    bool issame ( int x, int y) {
         return root (x) == root (y);
    }
    
    bool merge ( int x, int y) {
        x = root (x); y = root (y);
        if (x == y) return  false ;
         if (par [x]> par [y]) swap (x, y); // merge technique
        par [x] + = par [y];
        par [y] = x;
        return  true ;
    }
    
    int size ( int x) {
         return -par [root (x)];
    }
};

int main () {
     long  long N, M; cin >> N >> M;
    vector < int > A (M), B (M);
     for ( int i = 0 ; i <M; ++ i) {
        cin >> A [i] >> B [i], --A [i], --B [i];
    }
        
    UnionFind uf (N);
    long  long cur = N * (N- 1 ) / 2 ;
    vector < long  long > res;
     for ( int i = 0 ; i <M; ++ i) {
        res.push_back (cur);
            
        int a = A [M- 1 -i], b = B [M- 1 -i];
         if (uf.issame (a, b)) continue ;
        
        long  long sa = uf.size (a), sb = uf.size (b);
        cur-= sa * sb;
        uf.merge (a, b);
    }
        
    reverse (res.begin (), res.end ());
    for ( int i = 0 ; i <res.size (); ++ i) cout << res [i] << endl;
}

Compiler output:
a.cc: In member function 'bool UnionFind::merge(int, int)':
a.cc:25:19: error: expected primary-expression before '=' token
   25 |         par [x] + = par [y];
      |                   ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define p first
#define s second
#define int long
vector<pair<int,int>> parent(100000);
int FindP(int x){ return (parent[x].p==x?x:parent[x].p=FindP(parent[x].p));}
void BridgeP(int x,int y){
  parent[FindP(y)].s += parent[FindP(x)].s;
  parent[FindP(x)].p=FindP(y);
}
int SizeP(int x){ return parent[FindP(x)].s;}
int main(){
  int n,m;
  cin>>n>>m;
  vector<int> a(m),b(m),ans(m,0);
  for(int i=0;i<m;++i){
    cin>>a[i]>>b[i]; //a[i]<b[i]
    a[i]--; b[i]--;
  }
  for(int i=0;i<n;++i)parent[i].p=i,parent[i].s=1;
  ans[m-1]=n*(n-1)/2;
  for(int i=m-1;i>=0;--i){
    if(FindP(a[i])!=FindP(b[i])&&i!=0)ans[i-1]=ans[i]-SizeP(a[i])*SizeP(b[i]);
    BridgeP(b[i],a[i]);
  }
  for(int i=0;i<m;++i)cout<<ans[i]<<"\n";
  return 0;
}

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

#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
#define print(n) cout<<n<<endl
const int M=100111;
const int inf=1000000007;
const int MOD=1000000007;
const long long INF=1000000000000000007;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        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;
	UnionFind tree(n);
	int x[M],y[M];
	//切るのは嫌なのでくっつけていく
	rep(i,0,m)cin>>x[i]>>y[i],x[i]--,y[i]--;
	ll cnt=n*(n-1)/2;
	vl ans;
	rep(i,0,m){
		ans.push_back(cnt);
		int a=x[m-1-i],b=y[m-1-i];
		if(tree.same(a,b))continue;
		ll sa=tree.size(a),sb=tree.size(b);
		cnt-=sa*sb;
		tree.merge(a,b);
	}
	reverse(ALL(ans));
	for(auto v:ans)print(v);
}



Compiler output:
a.cc: In function 'int main()':
a.cc:60:25: error: 'struct UnionFind' has no member named 'same'; did you mean 'issame'?
   60 |                 if(tree.same(a,b))continue;
      |                         ^~~~
      |                         issame
Language: C++

#include <bits/stdc++.h>

#define foreach(i, v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define BETWEEN(a, x, b) (a<=x&&x<b)

using namespace std;
typedef long long ll;


// UnionFind uf = UnionFind(10);
// uf.connect(1, 2);
// uf.isSame(1, 2);

struct UnionFind {
  vector<ll> data;
  UnionFind(ll size) : data(size, -1) { }
  bool connect(ll x, ll y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool isSame(ll x, ll y) {
    return root(x) == root(y);
  }
  ll root(ll x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  ll size(ll x) {
    return -data[root(x)];
  }
};

vector<ll> g[100005];

ll main(ll argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  ll n, m;
  cin>>n>>m;
  std::vector<ll> v1(m);
  std::vector<ll> v2(m);
  for(ll i=0;i<m;i++){
    ll a,b;cin>>a>>b;
    a--, b--;
    v1[i] = a;
    v2[i] = b;
  }
  ll res = n*(n-1)/2;
  UnionFind uf = UnionFind(n);
  std::vector<ll> ans;
  for(ll i=m-1;i>=0;i--){
    ans.push_back(res);
    ll a = v1[i];
    ll b = v2[i];
    if(!uf.isSame(a,b)){
      res = res - (uf.size(a) * uf.size(b));
      uf.connect(a,b);
    }
  }
  for(ll i=m-1;i>=0;i--){
    cout<<ans[i]<<endl;
  }

  return 0;
}


Compiler output:
a.cc:38:1: error: '::main' must return 'int'
   38 | ll main(ll argc, char *argv[]) {
      | ^~
a.cc:38:4: warning: first argument of 'int main(ll, char**)' should be 'int' [-Wmain]
   38 | ll main(ll argc, char *argv[]) {
      |    ^~~~
Language: C++

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

const int maxn=1e5+5;

int x[maxn], z[maxn], y[maxn], sum[maxn]
long long ans[maxn];

int find(int x)
{
    return x==z[x]?x:z[x]=find(z[x]);
}

void Union(int a, int b)
{
    a=find(a),b=find(b);
    if(a!=b)
    {
        sum[a]+=sum[b];
        sum[b]=0;
        z[b]=a;
    }
}

int main()
{
    int n, m;
    
    while(cin >> n >> m)
    {
        for(int i=0;i<maxn;i++) 
			sum[i]=1, z[i]=i;
			
        memset(ans, 0, sizeof(ans));
        
        for(int i = 1; i <= m; i++)
        1{
            cin >> x[i] >> y[i];
        }
        
        long long cnt=n;
        ans[m+1]=cnt*(cnt-1)/2;
        
		for(int i=m;i>=2;i--)
        {
            int xx=find(x[i]), yy=find(y[i]);
        
		    if(xx!=yy)
            {
                ans[i]=ans[i+1]-sum[xx]*sum[yy];
                
				Union(x[i], y[i]);
            }
            else
                ans[i] = ans[i+1];
        }
        
		for(int i=2;i<=m+1;i++)
            cout << ans[i] << endl;
    }

    return 0;
}


Compiler output:
a.cc:7:1: error: expected initializer before 'long'
    7 | long long ans[maxn];
      | ^~~~
a.cc: In function 'void Union(int, int)':
a.cc:19:9: error: 'sum' was not declared in this scope
   19 |         sum[a]+=sum[b];
      |         ^~~
a.cc: In function 'int main()':
a.cc:32:25: error: 'sum' was not declared in this scope
   32 |                         sum[i]=1, z[i]=i;
      |                         ^~~
a.cc:34:16: error: 'ans' was not declared in this scope; did you mean 'abs'?
   34 |         memset(ans, 0, sizeof(ans));
      |                ^~~
      |                abs
a.cc:37:10: error: expected ';' before '{' token
   37 |         1{
      |          ^
      |          ;
a.cc:50:33: error: 'sum' was not declared in this scope
   50 |                 ans[i]=ans[i+1]-sum[xx]*sum[yy];
      |                                 ^~~
Language: C++

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

int max(int a,int b)
{
	return a>b?a:b;
}

int n;
int c[1001001];

inline int lowbit(int x)
{
	return x&(-x);
}

inline void modify(int x, int y)
{
	for (;x<=n;x+=lowbit(x))
		c[x]=max(c[x],y);
}

inline int query(int x)
{
    int ans=0;
    for (;x;x-=lowbit(x))ans=max(ans,c[x]);
    return ans;
}

struct node
{
    int x,y;
}poi[1001001];

int y[1001001];
int yy[1001001];

bool cmp(const node a,const node b)
{
    return a.y<b.y;
}

int main()
{
    cin >> n;
    
	for (int i=1;i<=n;i++)
	{
		cin >> poi[i].x;
		poi[i].y=i;
	}
		
    for (int i=1;i<=n;i++)
		cin >> y[i]);
    
	sort(poi+1,poi+n+1,cmp);
    
	for (int i=1;i<=n;i++)
		yy[poi[i].x]=poi[i].y;
    
	int maxx=0;
    
	for (int i=1;i<=n;i++)
    {
        y[i]=yy[y[i]];
        int t=query(y[i])+1;
        maxx=max(maxx,t);
        modify(y[i],t);
    }
    
    cout << maxx;
    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:54:28: error: expected ';' before ')' token
   54 |                 cin >> y[i]);
      |                            ^
      |                            ;
Language: C++

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

#define long long ll;
const int MAXN=1e5+5;
int x[MAXN], y[MAXN], z[MAXN], sum[MAXN];
ll ans[MAXN];

int find(int x)
{
	return x==z[x]?x:z[x]=find(z[x]);
} 
 
void Union(int a, int b)
{
	a=find(a),b=find(b);
	 
	if (a!=b)
	{
		sum[a]+=sum[b];
		sum[b]=0;
		z[b]=a
	} 
 }
 
int main()
{
	int n, m;
	
	while (cin >> n >> m)
	{
		for (int i=0;i<MAXN;i++)
			sum[i]=1, z[i]=1;
		
		memset (ans,0,sizeof(ans))
		
		for (int i=1;i<=m;i++)
		{
			cin >> x[i] >> y[i];
		}
		
		ll cnt=n;
		ans[m+1]=cnt*(cnt-1)/2;
		
		for (int i=m;i>=2;i--)
		{
			int xx=find(x[i]), yy=find(y[i]);
			
			if (xx!=yy)
			{
				ans[i]=ans[i+1]-sum[xx]*sum[yy];
				Union(x[i],y[i]);
			}
			else
				ans[i]=ans[i+1];
		}
		
		for (int i=2;i<=m+1;i++)
			cout << ans[i] << endl;
	} 
	
	return 0;
	
}

Compiler output:
a.cc:7:1: error: 'll' does not name a type
    7 | ll ans[MAXN];
      | ^~
a.cc: In function 'void Union(int, int)':
a.cc:22:23: error: expected ';' before '}' token
   22 |                 z[b]=a
      |                       ^
      |                       ;
   23 |         }
      |         ~              
a.cc: In function 'int main()':
a.cc:35:25: error: 'ans' was not declared in this scope; did you mean 'abs'?
   35 |                 memset (ans,0,sizeof(ans))
      |                         ^~~
      |                         abs
a.cc:37:30: error: 'i' was not declared in this scope
   37 |                 for (int i=1;i<=m;i++)
      |                              ^
a.cc:42:17: error: 'll' was not declared in this scope
   42 |                 ll cnt=n;
      |                 ^~
a.cc:43:26: error: 'cnt' was not declared in this scope; did you mean 'int'?
   43 |                 ans[m+1]=cnt*(cnt-1)/2;
      |                          ^~~
      |                          int
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct edge{
	int u,v;
}int e[100005];
ll fa[10005],ans[100005],sz[100005];
int find(int x) {
	if(x==fa[x]) return x;
	return fa[x]=find(fa[x]);
}
int main(){
	ll n,m;
	cin>>n>>m;
	//edge e[100005];
	for(int i=1;i<=m;i++){
		cin>>e[i].u;
		cin>>e[i].v;
	}
	for(int i=1;i<=n;i++){
		fa[i]=i;
		sz[i]=1;
	}
	ans[m]=(ll)n*(n-1)/2;
	for(int i=m;i>=1;i--){
		int u,v;
		u=find(e[i].u);
		v=find(e[i].v);
		if(u==v){
			ans[i-1]=ans[i];
		}
		else{
			ans[i-1]=ans[i]-sz[v]*sz[u];
			sz[v]+=sz[u];
			fa[u]=v;
		}
	}
	for(int i=1;i<=m;i++){
		cout<<ans[i]<<endl;
	}
	return 0;
}


Compiler output:
a.cc:6:2: error: expected ';' after struct definition
    6 | }int e[100005];
      |  ^
      |  ;
a.cc: In function 'int main()':
a.cc:17:27: error: request for member 'u' in 'e[i]', which is of non-class type 'int'
   17 |                 cin>>e[i].u;
      |                           ^
a.cc:18:27: error: request for member 'v' in 'e[i]', which is of non-class type 'int'
   18 |                 cin>>e[i].v;
      |                           ^
a.cc:27:29: error: request for member 'u' in 'e[i]', which is of non-class type 'int'
   27 |                 u=find(e[i].u);
      |                             ^
a.cc:28:29: error: request for member 'v' in 'e[i]', which is of non-class type 'int'
   28 |                 v=find(e[i].v);
      |                             ^