Language: C++

//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include<algorithm>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1e18
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define vec vector
using pint = pair<int,int>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double pi = acos(-1);
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    Unionfind(int N){
        par = vector<int>(N,-1);
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x]<0) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのま
        if(par[rx]>par[ry]) swap(rx,ry);
        par[rx]+=par[ry];
        par[ry] = rx; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int size(int x){
        return -par[root(x)];
    }
};

int main() {
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

    int n,m;
    cin>>n>>m;
    UnionFind uf(n);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        uf.unite(a-1,b-1);
    }

    ll ans=0;
    rep(i,n){
        chmax(ans,uf.size(i));
    }

    cout<<ans<<endl;
}

Compiler output:
a.cc:42:5: error: ISO C++ forbids declaration of 'Unionfind' with no type [-fpermissive]
   42 |     Unionfind(int N){
      |     ^~~~~~~~~
a.cc: In member function 'int UnionFind::Unionfind(int)':
a.cc:44:5: warning: no return statement in function returning non-void [-Wreturn-type]
   44 |     }
      |     ^
a.cc: In function 'int main()':
a.cc:76:19: error: no matching function for call to 'UnionFind::UnionFind(int&)'
   76 |     UnionFind uf(n);
      |                   ^
a.cc:39:8: note: candidate: 'UnionFind::UnionFind()'
   39 | struct UnionFind {
      |        ^~~~~~~~~
a.cc:39:8: note:   candidate expects 0 arguments, 1 provided
a.cc:39:8: note: candidate: 'UnionFind::UnionFind(const UnionFind&)'
a.cc:39:8: note:   no known conversion for argument 1 from 'int' to 'const UnionFind&'
a.cc:39:8: note: candidate: 'UnionFind::UnionFind(UnionFind&&)'
a.cc:39:8: note:   no known conversion for argument 1 from 'int' to 'UnionFind&&'
a.cc:85:14: error: no matching function for call to 'chmax(ll&, int)'
   85 |         chmax(ans,uf.size(i));
      |         ~~~~~^~~~~~~~~~~~~~~~
a.cc:31:31: note: candidate: 'template<class T> bool chmax(T&, T)'
   31 | template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
      |                               ^~~~~
a.cc:31:31: note:   template argument deduction/substitution failed:
a.cc:85:14: note:   deduced conflicting types for parameter 'T' ('long long int' and 'int')
   85 |         chmax(ans,uf.size(i));
      |         ~~~~~^~~~~~~~~~~~~~~~