Language: C++

#include<stdio.h>
#include<string.h>
#include<utility>
#include<iostream>
#include<queue>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int parent[1000005];
int rank[100005];
int num[100005];
int ans=0;

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

void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y)return;
    ans+=num[x]*num[y];
    if(rank[x]<rank[y]){
        parent[x]=y;
        num[y]+=num[x];
    }
    else{
        parent[y]=x;
        if(rank[x]==rank[y])rank[x]++;
        num[x]+=num[y];
    }
}

int main()
{
    int n,m;
    int a[100005]={};
    int b[100005]={};
    int score[100005]={};
    scanf("%d%d",&n,&m);
    REP(i,n){
        parent[i]=i;
        rank[i]=0;
        num[i]=1;
    }
    REP(i,m){
        scanf("%d %d\n",&a[i],&b[i]);
    }
    REP(i,m){
        unite(a[m-1-i],b[m-1-i]);
        score[m-1-i]=n*(n-1)/2-ans;
    }
    score[m]=n*(n-1)/2;
    REP(i,m){
        printf("%d\n",score[i+1]);
    }
    return 0;
}

Compiler output:
a.cc: In function 'void unite(int, int)':
a.cc:31:8: error: reference to 'rank' is ambiguous
   31 |     if(rank[x]<rank[y]){
      |        ^~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
                 from /usr/include/c++/14/utility:69,
                 from a.cc:3:
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:17:5: note:                 'int rank [100005]'
   17 | int rank[100005];
      |     ^~~~
a.cc:31:16: error: reference to 'rank' is ambiguous
   31 |     if(rank[x]<rank[y]){
      |                ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:17:5: note:                 'int rank [100005]'
   17 | int rank[100005];
      |     ^~~~
a.cc:37:12: error: reference to 'rank' is ambiguous
   37 |         if(rank[x]==rank[y])rank[x]++;
      |            ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:17:5: note:                 'int rank [100005]'
   17 | int rank[100005];
      |     ^~~~
a.cc:37:21: error: reference to 'rank' is ambiguous
   37 |         if(rank[x]==rank[y])rank[x]++;
      |                     ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:17:5: note:                 'int rank [100005]'
   17 | int rank[100005];
      |     ^~~~
a.cc:37:29: error: reference to 'rank' is ambiguous
   37 |         if(rank[x]==rank[y])rank[x]++;
      |                             ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:17:5: note:                 'int rank [100005]'
   17 | int rank[100005];
      |     ^~~~
a.cc: In function 'int main()':
a.cc:51:9: error: reference to 'rank' is ambiguous
   51 |         rank[i]=0;
      |         ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:17:5: note:                 'int rank [100005]'
   17 | int rank[100005];
      |     ^~~~