Language: C++

#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1e5+10;
int pre[maxn],sizes[maxn],rank[maxn];
int m,n;
void inint()
{
    for(int i=1;i<=n;i++)
    {
        pre[i]=i;
        sizes[i]=1;
        rank[i]=0;

    }
}
int find(int x)
{
    if(x==pre[x])
    {
        return x;
    }
  else
    return pre[x]=find(pre[x]);
}
bool same(int a,int b)
{
  return find(a)==find(b);

}
void unint(int a,int b)
{
       int x=find(a);
       int y=find(b);
       if(x==y)
        return ;
       if(rank[x]<rank[y])
       {
           pre[x]=y;
           sizes[y]+=sizes[x];
       }
       else
       {
           pre[y]=x;
           sizes[x]+=sizes[y];
           if(rank[x]==rank[y])
            rank[x]++;
       }

}
int main()
{
     scanf("%d%d",&n,&m);
     vector<int> a(m),b(m);
     inint();
     vector<ll>ans(m);
     for(int i=0;i<m;i++)
    cin>>a[i]>>b[i];
    ans[m-1]=n*(n-1)/2;
    for(int i=m-1;i>=1;i--)
    {
        ans[i-1]=ans[i];
        if(!same(a[i],b[i]))
        {
            ans[i-1]-=sizes[find(a[i])]*sizes[find(b[i])];
            unint(a[i],b[i]);
        }
    }
    for(int i=0;i<m;i++)
      cout<<ans[i]<<endl;

    return 0;
}


Compiler output:
a.cc: In function 'void inint()':
a.cc:13:9: error: reference to 'rank' is ambiguous
   13 |         rank[i]=0;
      |         ^~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
                 from /usr/include/c++/14/bits/stl_algobase.h:64,
                 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/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:5:27: note:                 'int rank [100010]'
    5 | int pre[maxn],sizes[maxn],rank[maxn];
      |                           ^~~~
a.cc: In function 'void unint(int, int)':
a.cc:37:11: error: reference to 'rank' is ambiguous
   37 |        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:5:27: note:                 'int rank [100010]'
    5 | int pre[maxn],sizes[maxn],rank[maxn];
      |                           ^~~~
a.cc:37:19: error: reference to 'rank' is ambiguous
   37 |        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:5:27: note:                 'int rank [100010]'
    5 | int pre[maxn],sizes[maxn],rank[maxn];
      |                           ^~~~
a.cc:46:15: error: reference to 'rank' is ambiguous
   46 |            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:5:27: note:                 'int rank [100010]'
    5 | int pre[maxn],sizes[maxn],rank[maxn];
      |                           ^~~~
a.cc:46:24: error: reference to 'rank' is ambiguous
   46 |            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:5:27: note:                 'int rank [100010]'
    5 | int pre[maxn],sizes[maxn],rank[maxn];
      |                           ^~~~
a.cc:47:13: error: reference to 'rank' is ambiguous
   47 |             rank[x]++;
      |             ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:5:27: note:                 'int rank [100010]'
    5 | int pre[maxn],sizes[maxn],rank[maxn];
      |                           ^~~~