Language: C++

// #include <bits/stdc++.h>
// #define ll long long int
// #define vi vector<ll>
// #define vvi vector<vector<ll>>
// #define pii pair<ll, ll>
// #define pb push_back
// #define rep0(i, n) for(ll i = 0;i<n;i++)
// #define rep1(i, n) for(ll i = 1;i<n;i++)
// #define all(v) v.begin(),v.end()
// #define fast                          
//     ios_base::sync_with_stdio(false); 
//     cin.tie(NULL);                    
//     cout.tie(NULL);
// using namespace std;
// const int N = 2e5 + 5;

// vector<int> vis(N, 0);
// vector<int> adj[N];
// int mx = 0;

// int dfs(int u){
//     int ans = 0;
//     if(!vis[u]){
//         vis[u] = true;
//         ans++;
//         for(auto v: adj[u]){
//             ans += dfs(v);
//         }
//     }
//     return ans;
// }

// void solve(){
//     int n, m;
//     cin >> n >> m;
//     for(int i=0; i<m; i++){
//         int x, y;
//         cin >> x >> y;
//         x--;y--;
//         adj[x].push_back(y);
//         adj[y].push_back(x);
//     }
//     for(int i=0; i<n; i++){
//         if(!vis[i]){
//             mx = max(mx, dfs(i));
//         }
//     }
//     cout << mx;
// }
 
// int main()
// {
//     fast;
//     solve();
//     // int t;
//     // cin >> t;
//     // while(t--){
//     //     solve();
//     // }
//     return 0;
// }
#include <bits/stdc++.h>
#define ll long long int
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define pii pair<ll, ll>
#define pb push_back
#define rep0(i, n) for(ll i = 0;i<n;i++)
#define rep1(i, n) for(ll i = 1;i<n;i++)
#define all(v) v.begin(),v.end()
#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
using namespace std;
const int N = 1e5 + 5;

vector<int> parent;
vector<int> size;

int find(int x){
    if(parent[x] == x){
        return x;
    }
    // path compression
    else{
        return find(parent[x]);
        // int a = find(parent[x]);
        // parent[x] = a;
        // return a;
    }
}

void connect(int x, int y){
    int a = find(x);
    int b = find(y);
    if(a!=b){
        // union by size
        if(size[a]>size[b]){
            parent[b] = a;
            size[a] += size[b];
        }
        else{
            parent[a] = b;
            size[b] += size[a];
        }
    }
}

void solve(){
    int n, m;
    cin >> n >> m;
    parent.resize(n);
    size.resize(n);
    for(int i=0; i<n; i++){parent[i] = i;size[i]=1;}
    for(int i=0; i<m; i++){
        int x, y;
        cin >> x >> y;
        x--;y--;
        connect(x, y);
    }
    vector<int> temp(n, 0);
    for(int i=0; i<n; i++){
        temp[find(parent[i])]++;
    }
    cout << *max_element(temp.begin(), temp.end());
}
 
int main()
{
    fast;
    solve();
    // int t;
    // cin >> t;
    // while(t--){
    //     solve();
    // }
    return 0;
}


Compiler output:
a.cc: In function 'void connect(int, int)':
a.cc:99:12: error: reference to 'size' is ambiguous
   99 |         if(size[a]>size[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,
                 from a.cc:62:
/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:79:13: note:                 'std::vector<int> size'
   79 | vector<int> size;
      |             ^~~~
a.cc:99:20: error: reference to 'size' is ambiguous
   99 |         if(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:79:13: note:                 'std::vector<int> size'
   79 | vector<int> size;
      |             ^~~~
a.cc:101:13: error: reference to 'size' is ambiguous
  101 |             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:79:13: note:                 'std::vector<int> size'
   79 | vector<int> size;
      |             ^~~~
a.cc:101:24: error: reference to 'size' is ambiguous
  101 |             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:79:13: note:                 'std::vector<int> size'
   79 | vector<int> size;
      |             ^~~~
a.cc:105:13: error: reference to 'size' is ambiguous
  105 |             size[b] += size[a];
      |             ^~~~
/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:79:13: note:                 'std::vector<int> size'
   79 | vector<int> size;
      |             ^~~~
a.cc:105:24: error: reference to 'size' is ambiguous
  105 |             size[b] += size[a];
      |                        ^~~~
/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:79:13: note:                 'std::vector<int> size'
   79 | vector<int> size;
      |             ^~~~
a.cc: In function 'void solve()':
a.cc:114:5: error: reference to 'size' is ambiguous
  114 |     size.resize(n);
      |     ^~~~
/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:79:13: note:                 'std::vector<int> size'
   79 | vector<int> size;
      |             ^~~~
a.cc:115:42: error: reference to 'size' is ambiguous
  115 |     for(int i=0; i<n; i++){parent[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:79:13: note:                 'std::vector<int> size'
   79 | vector<int> size;
      |             ^~~~