Language: C++

#include <bits/stdc++.h>

using namespace std;

const int MAXN = 200001;
typedef pair<int,int> pii;
#define mp make_pair
int par[MAXN];
int rank[MAXN];
int N, K, L;
int A[MAXN], B[MAXN];
map <pii, int> ans;

void init(int n) {
  for(int i = 0; i < n; i++) {
    par[i] = i;
    rank[i] = 0;
  }
}
  int find(int x) {
    if(par[x] == x) return x;
    else return par[x] = find(par[x]);
  }


  void unit(int x, int y) {
    if(find(x) == find(y)) return;

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

  cin >> N >> K >> L;

  init(N);

  for(int i = 0; i < K; i++) {
    int p, q;
    cin >> p >> q;
    p--; q--;
    unit(p,q);
  }
  for(int i = 0; i < N; i++) A[i] = find(i);

  init(N);

  for(int i = 0; i < L; i++) {
    int r, s;
    cin >> r >> s;
    r--; s--;
    unit(r,s);
  }

  for(int i = 0; i < N; i++) B[i] = find(i);

  for(int i = 0; i < N; i++) {
    ans[mp(A[i],B[i])]++;
  }

  for(int i = 0; i < N; i++) {
    cout << ans[mp(A[i],B[i])]<<endl;
  }
    
  return 0;
  
}  


Compiler output:
a.cc: In function 'void init(int)':
a.cc:17:5: error: reference to 'rank' is ambiguous
   17 |     rank[i] = 0;
      |     ^~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
                 from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 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:9:5: note:                 'int rank [200001]'
    9 | int rank[MAXN];
      |     ^~~~
a.cc: In function 'void unit(int, int)':
a.cc:29:8: error: reference to 'rank' is ambiguous
   29 |     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:9:5: note:                 'int rank [200001]'
    9 | int rank[MAXN];
      |     ^~~~
a.cc:29:18: error: reference to 'rank' is ambiguous
   29 |     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:9:5: note:                 'int rank [200001]'
    9 | int rank[MAXN];
      |     ^~~~
a.cc:33:10: error: reference to 'rank' is ambiguous
   33 |       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:9:5: note:                 'int rank [200001]'
    9 | int rank[MAXN];
      |     ^~~~
a.cc:33:21: error: reference to 'rank' is ambiguous
   33 |       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:9:5: note:                 'int rank [200001]'
    9 | int rank[MAXN];
      |     ^~~~
a.cc:33:29: error: reference to 'rank' is ambiguous
   33 |       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:9:5: note:                 'int rank [200001]'
    9 | int rank[MAXN];
      |     ^~~~