Language: C++

#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const int maxn=2e5+10;
#define p 1000000007
int link[maxn],size[maxn];
int find(int x){
	while(x!=link[x])x=link[x];
	return x;
}
bool same(int a,int b){
	return find(a)==find(b);
}
void unite(int a,int b){
	a=find(a);
	b=find(b);
	if(size[a]<size[b])swap(a,b);
	size[a]+=size[b];
	link[b]=a; //component b--->component a  //link of
}
int main(){
	fast;
	int n,q; cin>>n>>q;
	for(auto i=0;i<n;++i){
		link[i]=i;
		size[i]=1;
	}
	while(q--){
		int t,u,v;
		cin>>t>>u>>v;
		if(t==0){
			unite(u,v);
		}else{
			if(same(u,v)){
				cout<<1<<'\n';
			}else{
				cout<<0<<'\n';
			}
		}
	}
	return 0;
}
//period of a string(prefix-function) with KMP
//prime func
//subset production
//factorization
//modpow
//modinv ( a^(p-2)=a^(-1) (mod p) )
//sieve
//ncr
//euler totien func (co prime divisiors upto n)
//matrix exponentation(fast fibonacci)
//dsu
//Trees
//Graphs(dfs,bfs,shortes path etc.)
//DP-Recursion

Compiler output:
a.cc:7:14: error: 'int link [200010]' redeclared as different kind of entity
    7 | int link[maxn],size[maxn];
      |              ^
In file included from /usr/include/x86_64-linux-gnu/bits/sigstksz.h:24,
                 from /usr/include/signal.h:328,
                 from /usr/include/c++/14/csignal:42,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:116,
                 from a.cc:1:
/usr/include/unistd.h:819:12: note: previous declaration 'int link(const char*, const char*)'
  819 | extern int link (const char *__from, const char *__to)
      |            ^~~~
a.cc: In function 'int find(int)':
a.cc:9:24: warning: pointer to a function used in arithmetic [-Wpointer-arith]
    9 |         while(x!=link[x])x=link[x];
      |                        ^
a.cc:9:16: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
    9 |         while(x!=link[x])x=link[x];
      |               ~^~~~~~~~~
a.cc:9:34: warning: pointer to a function used in arithmetic [-Wpointer-arith]
    9 |         while(x!=link[x])x=link[x];
      |                                  ^
a.cc:9:34: error: invalid conversion from 'int (*)(const char*, const char*) noexcept' to 'int' [-fpermissive]
    9 |         while(x!=link[x])x=link[x];
      |                            ~~~~~~^
      |                                  |
      |                                  int (*)(const char*, const char*) noexcept
a.cc: In function 'void unite(int, int)':
a.cc:18:12: error: reference to 'size' is ambiguous
   18 |         if(size[a]<size[b])swap(a,b);
      |            ^~~~
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:
/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:16: note:                 'int size [200010]'
    7 | int link[maxn],size[maxn];
      |                ^~~~
a.cc:18:20: error: reference to 'size' is ambiguous
   18 |         if(size[a]<size[b])swap(a,b);
      |                    ^~~~
/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:16: note:                 'int size [200010]'
    7 | int link[maxn],size[maxn];
      |                ^~~~
a.cc:19:9: error: reference to 'size' is ambiguous
   19 |         size[a]+=size[b];
      |         ^~~~
/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:16: note:                 'int size [200010]'
    7 | int link[maxn],size[maxn];
      |                ^~~~
a.cc:19:18: error: reference to 'size' is ambiguous
   19 |         size[a]+=size[b];
      |                  ^~~~
/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:16: note:                 'int size [200010]'
    7 | int link[maxn],size[maxn];
      |                ^~~~
a.cc:20:15: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   20 |         link[b]=a; //component b--->component a  //link of
      |               ^
a.cc:20:16: error: assignment of read-only location '*(link + ((sizetype)b))'
   20 |         link[b]=a; //component b--->component a  //link of
      |         ~~~~~~~^~
a.cc: In function 'int main()':
a.cc:26:23: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   26 |                 link[i]=i;
      |                       ^
a.cc:26:24: error: assignment of read-only location '*(link + ((sizetype)i))'
   26 |                 link[i]=i;
      |                 ~~~~~~~^~
a.cc:27:17: error: reference to 'size' is ambiguous
   27 |                 size[i]=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:16: note:                 'int size [200010]'
    7 | int link[maxn],size[maxn];
      |                ^~~~