Language: C++

#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int par[maxn],size[maxn],x[maxn],y[maxn],n,m;
long long now,ans[maxn];
int find(int x)
{
	if(par[x]==x)return x;
	else return par[x]=find(par[x]);
}
int main()
{
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		par[i]=i;
		size[i]=1;
	}
	for(int i=1;i<=m;i++)
	scanf("%d %d",&x[i],&y[i]);
	now=(long long)n*(n-1)/2;
	for(int i=m;i>=1;i--)
	{
		ans[i]=now;
		int X=x[i],Y=y[i];
		X=find(X);Y=find(Y);
		if(X==Y)continue;
		now-=size[X]*size[Y];
		par[X]=Y;
		size[Y]+=size[X];
	}
	for(int i=1;i<=m;i++)
	printf("%lld\n",ans[i]);
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:17: error: reference to 'size' is ambiguous
   17 |                 size[i]=1;
      |                 ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:4:15: note:                 'int size [100010]'
    4 | int par[maxn],size[maxn],x[maxn],y[maxn],n,m;
      |               ^~~~
a.cc:28:22: error: reference to 'size' is ambiguous
   28 |                 now-=size[X]*size[Y];
      |                      ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:4:15: note:                 'int size [100010]'
    4 | int par[maxn],size[maxn],x[maxn],y[maxn],n,m;
      |               ^~~~
a.cc:28:30: error: reference to 'size' is ambiguous
   28 |                 now-=size[X]*size[Y];
      |                              ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:4:15: note:                 'int size [100010]'
    4 | int par[maxn],size[maxn],x[maxn],y[maxn],n,m;
      |               ^~~~
a.cc:30:17: error: reference to 'size' is ambiguous
   30 |                 size[Y]+=size[X];
      |                 ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:4:15: note:                 'int size [100010]'
    4 | int par[maxn],size[maxn],x[maxn],y[maxn],n,m;
      |               ^~~~
a.cc:30:26: error: reference to 'size' is ambiguous
   30 |                 size[Y]+=size[X];
      |                          ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:4:15: note:                 'int size [100010]'
    4 | int par[maxn],size[maxn],x[maxn],y[maxn],n,m;
      |               ^~~~