Language: C++

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<set>
#include<cstring>
#include<iterator>
#include<bitset>
using namespace std;
 
struct edge {int /*from,*/to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define np next_permutation
#define pq priority_queue
#define UB upper_bound
#define LB lower_bound
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define MAX(a,b,c) max((a),max((b),(c)))
#define MIN(a,b,c) min((a),min((b),(c)))
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
//#define int ll

#define MAXN 214514

int par[MAXN];     //親
int rank[MAXN];    //木の深さ

int ar[MAXN];
int br[MAXN];

int n,k,l;

//n要素で初期化
void init(int n){
    REP(i,n){
        par[i] = i;
        rank[i] = 0;
    }
}

//木の根を求める
int find(int x){
    if(par[x]==x) return x;
    else return par[x] = find(par[x]);
}

//xとyの属する集合を併合
void unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x==y) return;

    if(rank[x]<rank[y]){
        par[x] = y;
    } else {
        par[y] = x;
        if(rank[x] == rank[y]) rank[x]++;
    }
}

//xとyが同じ集合に属するか否か
bool same(int x, int y){
    return find(x) == find(y);
}

signed main(){
    scanf("%d%d%d",&n,&k,&l);
    init(n);
    REP(i,k){
        int t1,t2;
        scanf("%d%d",&t1,&t2);
        t1--;t2--;
        unite(t1,t2);
    }
    REP(i,n) ar[i] = find(i);
    init(n);
    REP(i,l){
        int t1,t2;
        scanf("%d%d",&t1,&t2);
        t1--;t2--;
        unite(t1,t2);
    }
    REP(i,n) br[i] = find(i);

    vector<P> sex;
    REP(i,n) sex.pb(mp(ar[i],br[i]));
    SORT(sex);

    REP(i,n){
        P cur = sex[i];
        printf("%d ",UB(all(sex),cur)-LB(all(sex),cur));
    }
    printf("\n");
    return 0;
}

Compiler output:
a.cc: In function 'void init(int)':
a.cc:74:9: error: reference to 'rank' is ambiguous
   74 |         rank[i] = 0;
      |         ^~~~
In file included from /usr/include/c++/14/bits/move.h:37,
                 from /usr/include/c++/14/bits/exception_ptr.h:41,
                 from /usr/include/c++/14/exception:166,
                 from /usr/include/c++/14/ios:41,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:63:5: note:                 'int rank [214514]'
   63 | int rank[MAXN];    //木の深さ
      |     ^~~~
a.cc: In function 'void unite(int, int)':
a.cc:90:8: error: reference to 'rank' is ambiguous
   90 |     if(rank[x]<rank[y]){
      |        ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:63:5: note:                 'int rank [214514]'
   63 | int rank[MAXN];    //木の深さ
      |     ^~~~
a.cc:90:16: error: reference to 'rank' is ambiguous
   90 |     if(rank[x]<rank[y]){
      |                ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:63:5: note:                 'int rank [214514]'
   63 | int rank[MAXN];    //木の深さ
      |     ^~~~
a.cc:94:12: error: reference to 'rank' is ambiguous
   94 |         if(rank[x] == rank[y]) rank[x]++;
      |            ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:63:5: note:                 'int rank [214514]'
   63 | int rank[MAXN];    //木の深さ
      |     ^~~~
a.cc:94:23: error: reference to 'rank' is ambiguous
   94 |         if(rank[x] == rank[y]) rank[x]++;
      |                       ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:63:5: note:                 'int rank [214514]'
   63 | int rank[MAXN];    //木の深さ
      |     ^~~~
a.cc:94:32: error: reference to 'rank' is ambiguous
   94 |         if(rank[x] == rank[y]) rank[x]++;
      |                                ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:63:5: note:                 'int rank [214514]'
   63 | int rank[MAXN];    //木の深さ
      |     ^~~~