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

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct edge{
	int u,v;
};
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;
		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: In function 'int main()':
a.cc:27:30: error: 'v' was not declared in this scope
   27 |                 find(e[i].u),v=find(e[i].v);
      |                              ^
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++)
using namespace std;
typedef long long ll;

class UnionFind {
    public:
    //親の番号を格納する。親だった場合は-1
    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];
         //Bの親をAに変更する
         Parent[B] = A;

         return true;
    }
}

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]--;
    }

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

    UnionFind Uni(n);

    for(int i = m-1; i >= 1; i--) {
        ans[i-1] = ans[i];

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

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

    return 0;
}

Compiler output:
a.cc:58:2: error: expected ';' after class definition
   58 | }
      |  ^
      |  ;
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++)
using namespace std;
typedef long long ll;

class UnionFind {
    public:
    //親の番号を格納する。親だった場合は-1
    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];
         //Bの親をAに変更する
         Parent[B] = A;

         return true;
    }
}

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]--;
    }

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

    UnionFind Uni(n);

    for(int i = m-1; i >= 1; i--) {
        ans[i-1] = ans[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]);
        }
    }

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

    return 0;
}

Compiler output:
a.cc:58:2: error: expected ';' after class definition
   58 | }
      |  ^
      |  ;
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++)
using namespace std;
typedef long long ll;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> A(m), B(m);
    rep(i, m) {
        cin >> A[i] >> B[i];
    }

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

    UnionFind Uni(n);

    for(int i = m-1; i >= 1; i--) {
        ans[i-1] = ans[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]);
        }
    }

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

class UnionFind {
    public:
    //親の番号を格納する。親だった場合は-1
    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];
         //Bの親をAに変更する
         Parent[B] = A;

         return true;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:5: error: 'UnionFind' was not declared in this scope
   22 |     UnionFind Uni(n);
      |     ^~~~~~~~~
a.cc:27:12: error: 'Uni' was not declared in this scope
   27 |         if(Uni.root(A[i]) != Uni.root(B[i])) {
      |            ^~~
a.cc: At global scope:
a.cc:87:2: error: expected ';' after class definition
   87 | }
      |  ^
      |  ;
Language: C++

29 45
1 3
2 3
2 14
2 19
2 29
3 26
4 5
4 6
4 13
4 17
5 10
5 19
5 24
6 18
6 19
6 24
6 25
6 28
6 29
8 9
9 18
9 25
10 29
11 16
11 22
12 14
12 15
12 26
12 29
13 14
14 20
14 27
14 29
15 16
15 22
15 25
15 29
16 29
17 27
19 26
20 29
24 26
15 23
1 21
7 28

Compiler output:
a.cc:1:1: error: expected unqualified-id before numeric constant
    1 | 29 45
      | ^~
Language: C++

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

struct UnionFind{
  //これは一段上の点を示す．自分が最上位（ルート）なら負のサイズをもつ
  vector<int> Parent;
  
  UnionFind(int n){
    Parent=vector<int>(n,-1);
  }

  int root(int a){
    if(Parent[a]<0) return a;
    Parent[a]=root(Parent[a]);
    return Parent[a];
  }
  
  int size(int a){
    return -Parent[root(a)]
  }
  
  bool connect(int a,int b){
    if(root(a)==root(b)) return false;
    if(size(a)<size(b)) swap(a,b);
    Parent[root(a)]+=size(b);
    Parent[b]=root(a);
    return true;
  }
};
int main()
{
  int n,m;
  cin>>n>>m;
  vector<pair<int,int>> bridge;
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    bridge.push_back(make_pair(a-1,b-1));
  }
  reverse(bridge.begin(),bridge.end());
  UnionFind land(n);
  ll inc=(ll)(n-1)*n/2;
  vector<ll> ans;
  ans.push_back(inc);
  for(int i=0;i<m;i++){
    
    int a=bridge[i].first,b=bridge[i].second;
    //くっついてなかった場合
    if(land.root(a)!=land.root(b)){
      inc-=(ll)(land.size(a)*land.size(b));
      land.connect(a,b);
      ans.push_back(inc);
    }
    //すでにくっついてる場合，変化はない
    else ans.push_back(inc);
  }
  reverse(ans.begin(),ans.end());
  ans.erase(ans.begin());
  for(ll x:ans){
    cout<<x<<endl;
  }
}

Compiler output:
a.cc: In member function 'int UnionFind::size(int)':
a.cc:21:3: error: expected ';' before '}' token
   21 |   }
      |   ^
Language: C++

#include <iostream>
#include <vector>
#include <stack>

using namespace std;

class UnionFind {
    vector<long long> par;
    vector<long long> tree_count;

public:
    UnionFind(long long N) : par(N), tree_count(N) {
        for(long long i = 0; i < N; i++) {
            par[i] = i;
            tree_count[i] = 1;
        }
    }

    long long size(long long x) {
        return tree_count[root(x)];
    }

    long long root(long long x) {
        if(par[x] == x) return x;
        //親を探すときに経路上のノードを親にくっつける
        return par[x] = root(par[x]);
    }

    void unite(long long x, long long y) {
        long long rx = root(x);
        long long ry = root(y);
        if(rx == ry) return;
        //ryに所属するグループの頂点数を格納(親でなくなった頂点は-1)
        tree_count[ry] += tree_count[rx];
        tree_count[rx] = -1;
        //xの親をyの親の下にくっつける
        par[rx] = 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<long long> A(M, 0);
    vector<long long> B(M, 0);
    for(long long i = 0; i < M; i++) {
        cin >> A[i] >> B[i];
    }

    vector<long long> ret(M, 0);
    UnionFind uf(N);
    long long change = 0;
    ret[M-1] = (long long)((N*(N-1))/2);
    for(long long i = M - 2; i >= 0; i--) {
        if (!uf.same(A[i+1] - 1, B[i+1] - 1)) 
            change =  (uf.size(A[i+1]-1) * uf.size(B[i+1]-1));
        else 
            change = 0;

        //cout << "change:" << change   << endl;
        
        uf.unite(A[i+1]-1, B[i+1]-1);
        ret[i] = ret[i+1] - change;
        //cout << (uf.size(A[i]-1)) << "," << (uf.size(B[i]-1)) <<endl;

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

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

#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string.h>
#include <utility> 
#include <tuple>
#include <iterator>
#include <functional>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0; i<n; i++)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)v



// union by size + path having
class UnionFind
{
public:
    vector<ll> par; // 各元の親を表す配列
    vector<ll> siz; // 素集合のサイズを表す配列(1 で初期化)
 
    // Constructor
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL)
    {
        for (ll i = 0; i < sz_; ++i)
            par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_)
    {
        siz.assign(sz_, 1LL); // assign: 再代入
        par.resize(sz_);      // resize: 再確保
        for (ll i = 0; i < sz_; ++i)
            par[i] = i; // 初期では親は自分自身
    }
 
    // Member Function
    // Find
    ll root(ll x)
    { // 根の検索
        while (par[x] != x)
        {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }
 
    // Union(Unite, Merge)
    bool merge(ll x, ll y)
    {
        x = root(x);
        y = root(y);
        if (x == y)
            return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y])
            swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }
 
    bool issame(ll x, ll y)
    { // 連結判定
        return root(x) == root(y);
    }
 
    ll size(ll x)
    { // 素集合のサイズ
        return siz[root(x)];
    }
};



int main(){
    ll n, m;
  cin >> n >> m;
  vector<pair<ll, ll>> v(m);
  rep(i,m){
    ll a,b;
    cin >> a >> b;
    v[i].first = a;
    v[i].second = b;
  }
  
  vector<ll> ans(m);
  ans[m-1] = n*(n-1)/2; 
  UnionFind uf(n);
  for(ll i=m-1; i>=1; --i){
     ll x = v[i].first;
     ll y = v[i].second;
     if(uf.issame(x,y)) 
      {ans[i-1] = ans[i];}
    else
    {ans[i-1] = ans[i] - (uf.size(x)*uf.size(y));
     uf.merge(x,y);}
  }
  //reverse(p.begin(), p.end());
 REP(i,m){
    cout << ans[i] << "\n"; 
  }
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:101:10: error: expected ';' before '{' token
  101 |  REP(i,m){
      |          ^
Language: C++

#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string.h>
#include <utility> 
#include <tuple>
#include <iterator>
#include <functional>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0; i<n; i++)



// union by size + path having
class UnionFind
{
public:
    vector<ll> par; // 各元の親を表す配列
    vector<ll> siz; // 素集合のサイズを表す配列(1 で初期化)
 
    // Constructor
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL)
    {
        for (ll i = 0; i < sz_; ++i)
            par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_)
    {
        siz.assign(sz_, 1LL); // assign: 再代入
        par.resize(sz_);      // resize: 再確保
        for (ll i = 0; i < sz_; ++i)
            par[i] = i; // 初期では親は自分自身
    }
 
    // Member Function
    // Find
    ll root(ll x)
    { // 根の検索
        while (par[x] != x)
        {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }
 
    // Union(Unite, Merge)
    bool merge(ll x, ll y)
    {
        x = root(x);
        y = root(y);
        if (x == y)
            return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y])
            swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }
 
    bool issame(ll x, ll y)
    { // 連結判定
        return root(x) == root(y);
    }
 
    ll size(ll x)
    { // 素集合のサイズ
        return siz[root(x)];
    }
};



int main(){
  ll N, M;
    ll node1, node2;
    cin >> N >> M;
    vector<pair<ll,ll>> A(M);
    for (ll i = 0; i < M; i++)
    {
        cin >> node1 >> node2;
        --node1, --node2;
        A[i].first = node1;
        A[i].second = node2;
    }
 
    // calculation
    vector<ll> ans(M);
    ans[M - 1] = (N * (N - 1)) / 2; // 全ての頂点が孤立している状態
 
    UnionFind uf(N);
    for (ll i = M - 1; i >= 1; --i)
    {
        node1 = A[i].first, node2 = A[i].second;
        if (uf.issame(node1, node2))
        {
            ans[i - 1] = ans[i];
        }
        else
        {
            // 根が異なるとき，それぞれのサイズの積（頂点の組み合わせ）を引く．
            ans[i - 1] = ans[i] - (uf.size(node1) * uf.size(node2));
            uf.merge(node1, node2);
        }
    }
 
    REP(i, M)
    {
        cout << ans[i] << "\n";
    }
 
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:109:9: error: 'i' was not declared in this scope
  109 |     REP(i, M)
      |         ^
a.cc:109:5: error: 'REP' was not declared in this scope
  109 |     REP(i, M)
      |     ^~~
Language: C++

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long long int llint;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int,int>
#define pl pair<ll,ll>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912
const long double PI = acos(-1);
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int GCD(int x,int y){
    return y ? GCD(y,x%y) : x;
}
const int NMAX = 100010;
int N,M;

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

bool isSameRoot(int par[],int x,int y){
    return root(par,x) == root(par,y);
}

void unite(int par[],int size[],int x,int y){
    x = root(par,x);
    y = root(par,y);
    if(x == y) return;

    par[x] = y;
    size[y] = size[x]+size[y];
    size[x] = size[y];
}


int main(){
    cin >> N >> M;
    int a[M],b[M];
    vector<ll> ans(M);
    for(int i = 0; i < M; i++){
        cin >> a[i] >> b[i];
    }

    int par[N+1]; int size[N+1];
    ans[M-1] = (ll)N * (ll)(N-1)/2;
    for(int i = 1; i <= N; i++){
        par[i] = i;
        size[i] = 1;
    }

    long ans[M];
    ans[M-1] = N*(N-1)/2;

    for(int i = M-1; i >= 0; i--){
        if(isSameRoot(par,a[i],b[i])){
            ans[i-1] = ans[i];
        } else {
            ans[i-1] = ans[i] - size[root(par,a[i])]*size[root(par,b[i])];
            unite(par,size,a[i],b[i]);
        }
    }

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




Compiler output:
a.cc: In function 'int main()':
a.cc:77:10: error: conflicting declaration 'long int ans [M]'
   77 |     long ans[M];
      |          ^~~
a.cc:65:16: note: previous declaration as 'std::vector<long long int> ans'
   65 |     vector<ll> ans(M);
      |                ^~~
Language: C++

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

struct UnionFind {
    vector<int> par;
    vector<int> siz;

    UnionFind(int N) : par(N) , siz(N,1){
        for(int i = 0; i < N; i++) 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( siz[rx] < siz[y] ) swap(rx,ry);
        siz[rx] += siz[ry];
        par[rx] = ry; 
    }

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

    int size(int x){
        return siz[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 Uni(N);


    vector<long long> ans(M);

    ans[M-1] = (N*(N-1))/2;
    for( int i = M - 1; i > 0; i-- ){
        if( Uni.same(A[i],B[i]) ){
            ans[i-1] = ans[i];
        } else {
            long long N1 = Uni.size(A[i]), N2 = Uni.size(B[i]);
            ans[i-1] = ans[i] - N1 * N2;
        }
        Uni.unite( A[i], B[i] );
    }

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

Compiler output:
a.cc: In member function 'int UnionFind::size(int)':
a.cc:33:24: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   33 |         return siz[root[x]];
      |                        ^
Language: Java

import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        UnionFind uf = new UnionFind(n);
        
        int[][] xy = new int[m][2];
        for (int i = 0; i < m; i++) {
            int x = sc.nextInt() - 1;
            int y = sc.nextInt() - 1;
            xy[i][0] = x;
            xy[i][1] = y;
        }
        
        long[] size = new long[n];
        Arrays.fill(size, 1);
        long[] answer = new long[m];
        answer[m - 1] = (long)n * (n - 1) / 2;
        
        for (int i = m - 1; i > 0 ; i--) {
            int x = xy[i][0];
            int y = xy[i][1];
            if (uf.same(x, y)) {
                answer[i - 1] = answer[i];
                continue;
            }
            
            int rx = uf.root(x);
            int ry = uf.root(y);
            answer[i - 1] = answer[i] - size[rx] * size[ry];
            int sizex = size[rx];
            int sizey = size[ry];
            size[rx] += sizey;
            size[ry] += sizex;
            uf.unite(x, y);
        }
        
        for (long a : answer) {
            System.out.println(a);
        }
    }
    
    public static class UnionFind {
        int[] par;
        int connectedComponent;
    
        UnionFind(int n) {
            par = new int[n];
            connectedComponent = n;
            for (int i = 0; i < n; i++) {
                par[i] = i;
            }
        }
    
        int root(int x) {
            if (par[x] == x) return x;
            return par[x] = root(par[x]);
            // 1-2-4の場合、4の親=2を4の根=1に繋ぎ変えた上で親を返す
            // ↑根まで辿る深さを減らす為
            // return a = b;とは、aにbを代入し、aを返すという意味
        }
    
        void unite(int x, int y) {
            int rx = root(x);
            int ry = root(y);
            if (rx != ry) {
                par[ry] = rx;
                connectedComponent--;
            }
        }
    
        boolean same(int x, int y) {
            int rx = root(x);
            int ry = root(y);
            return rx == ry;
        }
        
        void printPar() {
            System.out.println(Arrays.toString(par));
        }
    }
}

Compiler output:
Main.java:35: error: incompatible types: possible lossy conversion from long to int
            int sizex = size[rx];
                            ^
Main.java:36: error: incompatible types: possible lossy conversion from long to int
            int sizey = size[ry];
                            ^
2 errors
Language: Java

import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        UnionFind uf = new UnionFind(n);
        
        int[][] xy = new int[m][2];
        for (int i = 0; i < m; i++) {
            int x = sc.nextInt() - 1;
            int y = sc.nextInt() - 1;
            xy[i][0] = x;
            xy[i][1] = y;
        }
        
        int[] size = new int[n];
        Arrays.fill(size, 1);
        long[] answer = new long[m];
        answer[m - 1] = (long)n * (n - 1) / 2;
        
        for (int i = m - 1; i > 0 ; i--) {
            int x = xy[i][0];
            int y = xy[i][1];
            if (uf.same(x, y)) {
                answer[i - 1] = answer[i];
                continue;
            }
            
            int rx = uf.root(x);
            int ry = uf.root(y);
            answer[i - 1] = answer[i] - size[rx] * size[ry];
            int sizex = size[rx];
            int sizey = size[ry];
            size[rx] += sizey;
            size[ry] += sizex;
            uf.unite(x, y);
        }
        
        for (int a : answer) {
            System.out.println(a);
        }
    }
    
    public static class UnionFind {
        int[] par;
        int connectedComponent;
    
        UnionFind(int n) {
            par = new int[n];
            connectedComponent = n;
            for (int i = 0; i < n; i++) {
                par[i] = i;
            }
        }
    
        int root(int x) {
            if (par[x] == x) return x;
            return par[x] = root(par[x]);
            // 1-2-4の場合、4の親=2を4の根=1に繋ぎ変えた上で親を返す
            // ↑根まで辿る深さを減らす為
            // return a = b;とは、aにbを代入し、aを返すという意味
        }
    
        void unite(int x, int y) {
            int rx = root(x);
            int ry = root(y);
            if (rx != ry) {
                par[ry] = rx;
                connectedComponent--;
            }
        }
    
        boolean same(int x, int y) {
            int rx = root(x);
            int ry = root(y);
            return rx == ry;
        }
        
        void printPar() {
            System.out.println(Arrays.toString(par));
        }
    }
}

Compiler output:
Main.java:42: error: incompatible types: possible lossy conversion from long to int
        for (int a : answer) {
                     ^
1 error
Language: C++

#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
typedef long long int ll;
using namespace std;
int n,m;
const int limit = 100000;

bool graph[limit][limit];
bool visited[limit];
int a[limit];
int b[limit];

void dfs(int v){
	visited[v] = true;
	for(int v2=0; v2<n; v2++){
		if(graph[v][v2] == false) continue;
		if(visited[v2] == true) continue;
		dfs(v2);
	}
}

int main()
{
	
	cin >> n >> m;
	for(int i=0; i<m; i++){
		cin >> a[i] >> b[i];
		a[i]--;
		b[i]--;
	}

	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			graph[i][j] = false;
		}
	}

	int cnt;
	ll ans[m];
	for(int i=m-1; i>=0; i--){
//		graph[a[i]][b[i]] = true;
//		graph[b[i]][a[i]] = true;
		cnt=0;

		for(int k=0; k<n; k++){
			for(int j=0; j<n; j++){
				visited[j] = false;
			}
			dfs(k);
			for(int j=0; j<n; j++){
				if(visited[j]==false){
					cnt++;
				}
			}
		}
		ans[i] = cnt;
		graph[a[i]][b[i]] = true;
		graph[b[i]][a[i]] = true;
	}

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

	return 0;
}

Compiler output:
/tmp/cc8v5571.o: in function `dfs(int)':
a.cc:(.text+0x13): relocation truncated to fit: R_X86_64_PC32 against symbol `visited' defined in .bss section in /tmp/cc8v5571.o
a.cc:(.text+0x55): relocation truncated to fit: R_X86_64_PC32 against symbol `visited' defined in .bss section in /tmp/cc8v5571.o
/tmp/cc8v5571.o: in function `main':
a.cc:(.text+0xe1): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/cc8v5571.o
a.cc:(.text+0x10d): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/cc8v5571.o
a.cc:(.text+0x12f): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/cc8v5571.o
a.cc:(.text+0x149): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/cc8v5571.o
a.cc:(.text+0x160): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/cc8v5571.o
a.cc:(.text+0x17a): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/cc8v5571.o
a.cc:(.text+0x266): relocation truncated to fit: R_X86_64_PC32 against symbol `visited' defined in .bss section in /tmp/cc8v5571.o
a.cc:(.text+0x298): relocation truncated to fit: R_X86_64_PC32 against symbol `visited' defined in .bss section in /tmp/cc8v5571.o
a.cc:(.text+0x2ed): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e5 + 5;

int n,m,parent[maxn],sz[maxn];

ll nc2(int x) {
  return (1ll*x*(x-1))/2;
}

int par(int x) {
  if (parent[x]==x) {
    return x;
  } else {
    return parent[x] = par(parent[x]);
  }
}

int size1(int x) {
  int p = par(x);
  return sz[p];
}

void join(int x, int y) {
  int px = par(x);
  int py = par(y);
  if (px==py) return;
  sz[px] += sz[py];
  parent[py]=px;
}


int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  
  cin>>n>>m;
  for (int i=1; i<=n; i++) {
    parent[i]=i;
    sz[i]=1;
  }
  vector<pair<int,int>> edges;
  vector<ll> ans;
  for (int i=0; i<m; i++) {
    int u,v; cin>>u>>v;
    edges.push_back({u,v});
  }
  reverse(edges.begin(), edges.end());

  ll cur = nc2(n);
  ans.push_back(cur);

  for (auto ed: edges) {
    int u=ed.first;
    int v=ed.second;
    if (par(u) != par(v)) {
      cur += nc2(size1(u));
      cur += nc2(size1(v));
      if (size1(v)>size1(u)) {
        swap(u,v);
      }      
      join(u,v);
      cur -= nc2(size1(u));
    }
    
    ans.push_back(cur);
  }
  
  ans.pop_back();
  reverse(ans.begin(), ans.end());
  
  for (auto x: ans) {
    cout<<x<<endl;
  }
  return 0;
}


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

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

class UnionFind{
private:
    vector<int> Parent;

public:
    
    UnionFind(int N){
        Parent=vector<int>(N,-1);
    }
    int root(int A){
        if(Parent[A]<0) return A;
        return Parent[A] = root(Parent[A]);
    }

    int size(int A){
        return -Parent[root(A)];
    }

    bool connect(int A,int B){
        A=root(A);
        B=root(B);
        if(A==B) return false;

        if(size(A)<size(B)) swap(A,B);
        Parent[A]+=Parent[B];

        return true;
    }
};

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

    vector<long long> ans(M);
    ans[M-1] = (long long)N*(N-1)/2;

    UnionFind Uni(N);

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

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





Compiler output:
a.cc: In function 'int main()':
a.cc:55:38: error: invalid types '<unresolved overloaded function type>[__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}]' for array subscript
   55 |         if(Uni.root(A[i]) != Uni.root[B[i]]){
      |                                      ^
Language: C++

#include <bits/stdc++.h>
#include <unordered_map>
#include <queue>
 
using namespace std;
 
int parent[100001];
int r[100001];
long long mp[100001];
 
int find(int a) {
    if (parent[a] == a) return a;
    return parent[a] = find(parent[a]);
}
 
long long merge(int a, int b) {
    a = find(a);
    b = find(b);
    if (a == b) return 0;
    if (r[a] > r[b]) {
        int t=a;
        a=b;
        b=t;
    }
    parent[a] = b;
    if (r[a] == r[b]) ++r[b];
    int ans=mp[b]*mp[a];
    mp[b]+=mp[a];
 
    return ans;
}
 
int main() {
    long longN;
    int M, i;
    cin >> N >> M;
    int bridges[100001][2];
    long long ans[100001];
 
    for (i = 0; i < M; i++) {
        cin >> bridges[i][0] >> bridges[i][1];
    }
    for (i=0;i<=N;i++) {
        parent[i]=i;
        r[i]=1;
        mp[i]=1;
    }
 
    ans[M-1]=(N * (N - 1)) / 2;
    for (i = M - 2; i >= 0; i--) {
        long long nn=merge(bridges[i+1][0], bridges[i+1][1]);
        ans[i]=max(0ll,ans[i+1]-nn);
    }
 
    for(i=0;i<M;i++){
        cout<<ans[i]<<endl;
    }
    return 0;
}

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

#include <bits/stdc++.h>
#include <unordered_map>
#include <queue>
 
using namespace std;
 
int parent[100001];
int r[100001];
long long mp[100001];
 
int find(int a) {
    if (parent[a] == a) return a;
    return parent[a] = find(parent[a]);
}
 
long long merge(int a, int b) {
    a = find(a);
    b = find(b);
    if (a == b) return 0;
    if (r[a] > r[b]) {
        int t=a;
        a=b;
        b=t;
    }
    parent[a] = b;
    if (r[a] == r[b]) ++r[b];
    int ans=mp[b]*mp[a];
    mp[b]+=mp[a];
 
    return ans;
}
 
int main() {
    int N, M, i;
    cin >> N >> M;
    int bridges[100001][2];
    long long ans[100001];
 
    for (i = 0; i < M; i++) {
        cin >> bridges[i][0] >> bridges[i][1];
    }
    for (i=0;i<=N;i++) {
        parent[i]=i;
        r[i]=1;
        mp[i]=1;
    }
 
    int allPairs = (N * (N - 1)) / 2, incon=0;
    ans[M-1]=allPairs;
    for (i = M - 2; i >= 0; i--) {
        long long nn=merge(bridges[i+1][0], bridges[i+1][1]);
        ans[i]=max(0,ans[i+1]-nn);
    }
 
    for(i=0;i<M;i++){
        cout<<ans[i]<<endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:52:19: error: no matching function for call to 'max(int, long long int)'
   52 |         ans[i]=max(0,ans[i+1]-nn);
      |                ~~~^~~~~~~~~~~~~~~
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:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:52:19: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   52 |         ans[i]=max(0,ans[i+1]-nn);
      |                ~~~^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:52:19: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   52 |         ans[i]=max(0,ans[i+1]-nn);
      |                ~~~^~~~~~~~~~~~~~~
Language: C++

#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<set>
#define cinf(n,x,y) for(int i=0;i<(n);i++) cin >> x[i] >>y[i];
typedef long long int ll;
using namespace std;

class UnionFind{
public:
	vector<int> par,num;

	int find(int v){
		return (par[v]==v)? v: (par[v]=find(par[v]));
	}
	explicit UnionFind(int N):par(N),num(N,1){
		for(int i=0;i<N;i++)par[i]=i
	}
	void unite(int u,int v){
		u=find(u),v=find(v);
		if(u==v)return ;
		//if(num[u]<num[v])swap(u,v);
		num[u] += num[v];
		par[v] = u;
	}
	bool same(int u,int v){
		return find(u) == find(v);
	}
	bool ispar(int v){
		return v=find(v);
	}
	int size(int v){
		return num[find(v)];
	}
};

int main(){
	int n,m; cin >>n>>m;
	UnionFind Uf(n);
	vector<int> a(m),b(m);
	cinf(m,a,b);
	vector<ll> ans;
	ll cnt=n*(n-1)/2;
	ans.push_back(cnt);
	for(int i=m-1;i>=0;i--){
		if(!Uf.same(a[i]-1,b[i]-1)){
            cnt-=Uf.size(a[i]-1)*Uf.size(b[i]-1);
			Uf.unite(a[i]-1,b[i]-1);
		}
		ans.push_back(cnt);
	}
	reverse(ans.begin(),ans.end());
	for(int i=1;i<=m;i++){
		cout << ans[i] << endl;
	}
	return 0;
}


Compiler output:
a.cc: In constructor 'UnionFind::UnionFind(int)':
a.cc:19:9: error: expected ';' before '}' token
   19 |         }
      |         ^
Language: C++

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

vector<int> graph[200005];
int parent[200005];
int subSize[200005];
pair<int, int> e[200005];

int n, m;

int getParent(int x){
    if(parent[x] == -1){
        return x;
    }
    return getParent(parent[x]);
}

bool unite(int x, int y){
    int xp = getParent(x);
    int yp = getParent(y);

    if(xp == yp){
        return false;
    }

    if(subSize[xp] < subSize[yp]){
        parent[xp] = yp;
        subSize[yp] += subSize[xp];
    }else{
        parent[yp] = xp;
        subSize[xp] += subSize[yp];
    }

    return true;
}

int main()
{
    cin >> n >> m;

    for(int i = 0; i <= n; ++i){
        parent[i] = -1;
        subSize[i] = 1;
    }

    for(int i = 0; i < m; ++i){
        cin >> e[i].first >> e[i].second;
    }

    stack<int> st;
    st.push(n * (n - 1) / 2);

    int connected = 0;

    for(int i = m - 1; i > 0; --i){
        int v = e[i].first;
        int u = e[i].second;

        if(unite(v, u)){
            connected += subSize[pv] * subSize[pu];
        }
        st.push(n * (n - 1) / 2 - connected);
    }

    while(!st.empty()){
        cout << st.top() << "\n";
        st.pop();
    }

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:60:34: error: 'pv' was not declared in this scope; did you mean 'v'?
   60 |             connected += subSize[pv] * subSize[pu];
      |                                  ^~
      |                                  v
a.cc:60:48: error: 'pu' was not declared in this scope; did you mean 'u'?
   60 |             connected += subSize[pv] * subSize[pu];
      |                                                ^~
      |                                                u
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <cmath>

using namespace std;

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

bool isSameRoot(int par[], int x, int y) {
    return root(par, x) == root(par, y);
}

void unite(int par[], int size[], int x, int y) {
    x = root(par, x);
    y = root(par, y);
    if (x == y) return;

    par[x] = y;
    root(par, x);
    size[y] = size[x] + size[y];
    size[x] = size[y];
}

int main() {
    long N, M;
    cin >> N >> M;
    int A[M], B[M];
    for (int i = 0; i < M; i++) {
        cin >> A[i] >> B[i];
    }

    int par[N+1]; // 根を保存
    long size[N+1];
    for (int i = 1; i <= N; i++) {
        par[i] = i;
        size[i] = 1;
    }

    long ans[M];
    ans[M-1] = N*(N-1) / 2; // nC2
    for (int i = M-1; i >= 0; i--) {
        if (isSameRoot(par, A[i], B[i])) {
            ans[i-1] = ans[i];
        } else {
            ans[i-1] = ans[i] - size[root(par, A[i])] * size[root(par, B[i])];
            unite(par, size, A[i], B[i]);
        }
    }

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


Compiler output:
a.cc: In function 'int main()':
a.cc:55:24: error: cannot convert 'long int*' to 'int*'
   55 |             unite(par, size, A[i], B[i]);
      |                        ^~~~
      |                        |
      |                        long int*
a.cc:22:27: note:   initializing argument 2 of 'void unite(int*, int*, int, int)'
   22 | void unite(int par[], int size[], int x, int y) {
      |                       ~~~~^~~~~~
Language: C++

#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)









class unionfind {
private:
    vector<int> par;
    vector<int> rank;
    vector<int> counter;
public:
    unionfind(int n) : rank(n), counter(n, 1){
        for(int i = 0; i < n; i++){
            par.push_back(i);
        }
    }
    
    int find(int x){
        if (par[x] == x) {
            return x;
        }
        else {
            return par[x] = find(par[x]);
        }
    }
    
    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if (x == y) return;
        
        if (rank[x] < rank[y]) {
            counter[y] += counter[x];
            counter[x] = counter[y];
            par[x] = y;
        }
        else {
            counter[y] += counter[x];
            counter[x] = counter[y];
            par[y] = x;
            if (rank[x] == rank[y]) {
                rank[x]++;
            }
        }
    }
    
    bool same(int x, int y){
        return find(x) == find(y);
    }
    
    ll count(int x){
        return counter[find(x)];
    }
};





int main(){
    ll n;
    int m;
    scanf("%lld %d", &n, &m);
    vector<int> a(m), b(m);
    for(int i = 0; i < m; i++){
        scanf("%d %d", &a[i], &b[i]);
        a[i]--;
        b[i]--;
    }
    unionfind uni(n);
    vector<ll> ans(m);
    ll res = n * (n - 1) / 2;
    for(int i = m - 1; i >= 0; i--){
        ans[i] = res;
        if(uni.same(a[i], b[i])) continue;
        ll c1 = uni.count(a[i]), c2 = uni.count(b[i]);
        uni.unite(a[i], b[i]);
        res -= c1 * c2;
    }
    for(ll &v : ans){
        printf("%lld\n", v);
    }

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

#include <iostream>

#include <vector>
using namespace std;

template <class T = long long>
class Union_Find {
  using size_type = std::size_t;
  using _Tp = T;
public:

  vector<_Tp> par;

  const _Tp & operator[] (size_type child) {
    return -par[root(child)];
  }

  Union_Find(size_type n) : par(n, -1) {}
  void init(int n) {
    par.assign(n, -1);
  }

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

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

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

  _Tp size(int x) {
    return -par[root(x)];
  }
};
 
int main() {
  ll n, m, ans = 0;
  cin >> n >> m;
  Union_Find<long long> uf(n);
 
  vector<int> a(m), b(m);
  rep(i, m) {
    cin >> a[i] >> b[i];
    a[i] -= 1; b[i] -= 1;
  }
  ll con = (n * (n-1)) / 2;
  vector<ll> comf;
  // comf.push_back(con);
 
  for (int i = m - 1; i >= 0; --i) {
    comf.push_back(con);
    if (uf.issame(a[i], b[i])) {
      continue;
    }
    ll ta = uf.size(a[i]), tb = uf.size(b[i]);
    con -= ta * tb;
    uf.merge(a[i], b[i]);
  }
 
  for (int i = m - 1; i >= 0; --i) {
    cout << comf[i] << endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:48:3: error: 'll' was not declared in this scope
   48 |   ll n, m, ans = 0;
      |   ^~
a.cc:49:10: error: 'n' was not declared in this scope
   49 |   cin >> n >> m;
      |          ^
a.cc:49:15: error: 'm' was not declared in this scope; did you mean 'tm'?
   49 |   cin >> n >> m;
      |               ^
      |               tm
a.cc:53:7: error: 'i' was not declared in this scope
   53 |   rep(i, m) {
      |       ^
a.cc:53:3: error: 'rep' was not declared in this scope
   53 |   rep(i, m) {
      |   ^~~
a.cc:57:5: error: expected ';' before 'con'
   57 |   ll con = (n * (n-1)) / 2;
      |     ^~~~
      |     ;
a.cc:58:12: error: template argument 2 is invalid
   58 |   vector<ll> comf;
      |            ^
a.cc:62:10: error: request for member 'push_back' in 'comf', which is of non-class type 'int'
   62 |     comf.push_back(con);
      |          ^~~~~~~~~
a.cc:62:20: error: 'con' was not declared in this scope
   62 |     comf.push_back(con);
      |                    ^~~
a.cc:66:7: error: expected ';' before 'ta'
   66 |     ll ta = uf.size(a[i]), tb = uf.size(b[i]);
      |       ^~~
      |       ;
a.cc:67:12: error: 'ta' was not declared in this scope; did you mean 'a'?
   67 |     con -= ta * tb;
      |            ^~
      |            a
a.cc:67:17: error: 'tb' was not declared in this scope; did you mean 'b'?
   67 |     con -= ta * tb;
      |                 ^~
      |                 b
a.cc:72:17: error: invalid types 'int[int]' for array subscript
   72 |     cout << comf[i] << endl;
      |                 ^
Language: C++

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

class UnionFind {
private:
	vector<long long> par;
public:
	UnionFind(int N) { par = vector<long long>(N, -1LL); }
	int find(int x);
	long long size(int x);
	void unite(int x, int y);
	bool same(int x, int y);
};
//----UnionFind-------------------------------
int UnionFind::find(int x) {
	if (par[x] < 0) return x;
	else return par[x] = find(par[x]);
}

long long UnionFind::size(int x) {
	return -par[find(x)];
}

void UnionFind::unite(int x, int y) {
	x = find(x);
	y = find(y);

	//大きい方に小さい方をくっ付ける
	if (size(x) < size(y)) swap(x, y);
	par[x] += par[y];
	par[y] = x;
}

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

UnionFind uf;

int main() {
	int n,m;
	cin >> n >> m;
	long long ans[m];
	int A[m],B[m];
	uf = UnionFind(n);

	for (int i = 0;i < m;i++) {
		cin >> A[i] >> B[i];
	}

	for (int i = m - 1;i >= 0;i--) {
		if (!uf.same(A[i]-1,B[i]-1)) {
			ans[i] = uf.size(A[i]-1) * uf.size(B[i]-1);
		} else {
			ans[i] = 0;
		}
		uf.unite(A[i]-1,B[i]-1);
	}

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

Compiler output:
a.cc:40:11: error: no matching function for call to 'UnionFind::UnionFind()'
   40 | UnionFind uf;
      |           ^~
a.cc:8:9: note: candidate: 'UnionFind::UnionFind(int)'
    8 |         UnionFind(int N) { par = vector<long long>(N, -1LL); }
      |         ^~~~~~~~~
a.cc:8:9: note:   candidate expects 1 argument, 0 provided
a.cc:4:7: note: candidate: 'UnionFind::UnionFind(const UnionFind&)'
    4 | class UnionFind {
      |       ^~~~~~~~~
a.cc:4:7: note:   candidate expects 1 argument, 0 provided
a.cc:4:7: note: candidate: 'UnionFind::UnionFind(UnionFind&&)'
a.cc:4:7: note:   candidate expects 1 argument, 0 provided
Language: C++

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

class UnionFind {
private:
	vector<long long> par;
public:
	UnionFind(int N) { par = vector<long long>(N, -1LL); }
	int find(int x);
	long long size(int x);
	void unite(int x, int y);
	bool same(int x, int y);
};
//----UnionFind-------------------------------
int UnionFind::find(int x) {
	if (par[x] < 0) return x;
	else return par[x] = find(par[x]);
}

long long UnionFind::size(int x) {
	return -par[find(x)];
}

void UnionFind::unite(int x, int y) {
	x = find(x);
	y = find(y);

	//大きい方に小さい方をくっ付ける
	if (size(x) < size(y)) swap(x, y);
	par[x] += par[y];
	par[y] = x;
}

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

UnionFind uf;

int main() {
	int n,m;
	cin >> n >> m;
	long long ans[m];
	int A[m],B[m];
	uf.UnionFind(n);

	for (int i = 0;i < m;i++) {
		cin >> A[i] >> B[i];
	}

	for (int i = m - 1;i >= 0;i--) {
		if (!uf.same(A[i]-1,B[i]-1)) {
			ans[i] = uf.size(A[i]-1) * uf.size(B[i]-1);
		} else {
			ans[i] = 0;
		}
		uf.unite(A[i]-1,B[i]-1);
	}

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

Compiler output:
a.cc:40:11: error: no matching function for call to 'UnionFind::UnionFind()'
   40 | UnionFind uf;
      |           ^~
a.cc:8:9: note: candidate: 'UnionFind::UnionFind(int)'
    8 |         UnionFind(int N) { par = vector<long long>(N, -1LL); }
      |         ^~~~~~~~~
a.cc:8:9: note:   candidate expects 1 argument, 0 provided
a.cc:4:7: note: candidate: 'UnionFind::UnionFind(const UnionFind&)'
    4 | class UnionFind {
      |       ^~~~~~~~~
a.cc:4:7: note:   candidate expects 1 argument, 0 provided
a.cc:4:7: note: candidate: 'UnionFind::UnionFind(UnionFind&&)'
a.cc:4:7: note:   candidate expects 1 argument, 0 provided
a.cc: In function 'int main()':
a.cc:47:12: error: invalid use of 'UnionFind::UnionFind'
   47 |         uf.UnionFind(n);
      |            ^~~~~~~~~