Language: C++

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define y1 ___y1
const int N=200005;
map<int ,int > Map[N];
int n,m,Q,opt,x,y,f1[N],f2[N],size[N];
int find1(int x){
	if (x==f1[x])return x;
	return f1[x]=find1(f1[x]);
}
int find2(int x){
	if (x==f2[x])return x;
	return f2[x]=find2(f2[x]);
}
signed main(){
	scanf("%lld%lld%lld",&n,&m,&Q);
	int flag=0,cnt=0;
	for (int i=1;i<=n;i++)f1[i]=f2[i]=i,size[i]=1;
	while (Q--){
		scanf("%lld%lld%lld",&x,&y,&opt);
		x++;y++;
		if (opt==0){
			int x1=find1(x),y1=find1(y);
			if (x1!=y1){
				f1[x1]=y1;
				size[y1]+=size[x1];
				cnt++;
			}
		}
		else {
			X[++tot]=x;
			Y[tot]=y;
			flag=1;
		}
	}
	for (int i=1;i<=tot;i++)
		if (find1(X[i])==find1(Y[i])){
			puts("No");
			return 0;
		}
	if (m==n-1&&flag){
		puts("No");
		return 0;
	}
	if (m>(n-cnt)*(n-cnt-1)/2+cnt){
		puts("No");
		return 0;
	}
	puts("Yes");
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:45: error: reference to 'size' is ambiguous
   19 |         for (int i=1;i<=n;i++)f1[i]=f2[i]=i,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:7:31: note:                 'long long int size [200005]'
    7 | int n,m,Q,opt,x,y,f1[N],f2[N],size[N];
      |                               ^~~~
a.cc:27:33: error: reference to 'size' is ambiguous
   27 |                                 size[y1]+=size[x1];
      |                                 ^~~~
/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:7:31: note:                 'long long int size [200005]'
    7 | int n,m,Q,opt,x,y,f1[N],f2[N],size[N];
      |                               ^~~~
a.cc:27:43: error: reference to 'size' is ambiguous
   27 |                                 size[y1]+=size[x1];
      |                                           ^~~~
/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:7:31: note:                 'long long int size [200005]'
    7 | int n,m,Q,opt,x,y,f1[N],f2[N],size[N];
      |                               ^~~~
a.cc:32:25: error: 'X' was not declared in this scope
   32 |                         X[++tot]=x;
      |                         ^
a.cc:32:29: error: 'tot' was not declared in this scope
   32 |                         X[++tot]=x;
      |                             ^~~
a.cc:33:25: error: 'Y' was not declared in this scope
   33 |                         Y[tot]=y;
      |                         ^
a.cc:37:25: error: 'tot' was not declared in this scope
   37 |         for (int i=1;i<=tot;i++)
      |                         ^~~
a.cc:38:27: error: 'X' was not declared in this scope
   38 |                 if (find1(X[i])==find1(Y[i])){
      |                           ^
a.cc:38:40: error: 'Y' was not declared in this scope
   38 |                 if (find1(X[i])==find1(Y[i])){
      |                                        ^