Language: C++

#include <bits/stdc++.h>
using namespace std;

#define rep(a, b)      for(int a = 0; a < (b); ++a)
#define rep1(a, b, c)  for(int a = (b); a < (c); ++a)
#define each(a, b)     for(auto& a : b)

#define sz(x)       (int)(x).size()
#define all(a)      (a).begin(),(a).end()

#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define dbg(x) cout << #x << " = " << x << endl;
#define vt vector
#define pii pair<int, int>
#define pll pair<ll, ll>
#define bitcnt(x) __builtin_popcount(x)

using ll = long long;

const int inf = (int)1e9 + 5;
const ll infl = (ll)1e18 + 5;
const int mod = 1e9 + 7;
const int nax = 1e5 + 1;
int link[nax], size[nax];

int parent(int s){
	if(link[s] == s) return s;
	return link[s] = parent(link[s]);
}

void join(int a, int b){
	a = parent(a);
	b = parent(b);
	if(size[a] < size[b]) swap(a, b);
	link[b] = link[a];
}



void solve(){
	int n, m; cin >> n >> m;
	rep(i, n+1) link[i] = i, size[i] = 1;
	rep(i, m){
		int u, v;
		cin >> u >> v;
		join(u, v);
	}
	set<int> s;
	rep1(i, 1, n+1){
		s.emplace(parent(i));
	}
	cout << sz(s) - 1 << '\n';
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
}

Compiler output:
a.cc:30:13: error: 'int link [100001]' redeclared as different kind of entity
   30 | int link[nax], size[nax];
      |             ^
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 parent(int)':
a.cc:33:18: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   33 |         if(link[s] == s) return s;
      |                  ^
a.cc:33:20: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   33 |         if(link[s] == s) return s;
      |            ~~~~~~~~^~~~
a.cc:34:22: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   34 |         return link[s] = parent(link[s]);
      |                      ^
a.cc:34:39: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   34 |         return link[s] = parent(link[s]);
      |                                       ^
a.cc:34:39: error: invalid conversion from 'int (*)(const char*, const char*) noexcept' to 'int' [-fpermissive]
   34 |         return link[s] = parent(link[s]);
      |                                 ~~~~~~^
      |                                       |
      |                                       int (*)(const char*, const char*) noexcept
a.cc:32:16: note:   initializing argument 1 of 'int parent(int)'
   32 | int parent(int s){
      |            ~~~~^
a.cc:34:24: error: assignment of read-only location '*(link + ((sizetype)s))'
   34 |         return link[s] = parent(link[s]);
      |                ~~~~~~~~^~~~~~~~~~~~~~~~~
a.cc: In function 'void join(int, int)':
a.cc:40:12: error: reference to 'size' is ambiguous
   40 |         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:30:16: note:                 'int size [100001]'
   30 | int link[nax], size[nax];
      |                ^~~~
a.cc:40:22: error: reference to 'size' is ambiguous
   40 |         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:30:16: note:                 'int size [100001]'
   30 | int link[nax], size[nax];
      |                ^~~~
a.cc:41:15: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   41 |         link[b] = link[a];
      |               ^
a.cc:41:25: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   41 |         link[b] = link[a];
      |                         ^
a.cc:41:17: error: assignment of read-only location '*(link + ((sizetype)b))'
   41 |         link[b] = link[a];
      |         ~~~~~~~~^~~~~~~~~
a.cc: In function 'void solve()':
a.cc:48:27: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   48 |         rep(i, n+1) link[i] = i, size[i] = 1;
      |                           ^
a.cc:48:29: error: assignment of read-only location '*(link + ((sizetype)i))'
   48 |         rep(i, n+1) link[i] = i, size[i] = 1;
      |                     ~~~~~~~~^~~
a.cc:48:34: error: reference to 'size' is ambiguous
   48 |         rep(i, n+1) link[i] = i, 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:30:16: note:                 'int size [100001]'
   30 | int link[nax], size[nax];
      |                ^~~~