Language: C++

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <iomanip>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)

inline void readInt2(int *a, int *b) {
  int c, p = 0; char s[20] = "";
  for(int i = 0; (c = getchar()) != '\n'; i++) {
    if (c == ' ') { *a = atoi(s); strcpy(s, ""); p = i+1; continue; }
    else s[i] = c;
  }
  *b = atoi(s+p);
}

inline void readInt3(int *a, int *b, int *c) {
  int d, p = 0; char s[20] = "";
  for(int i = 0; (d = getchar()) != '\n'; i++) {
    if(d == ' ') {
      if(p == 0) { *a = atoi(s); strcpy(s, ""); p = i+1; continue; }
      else {*b = atoi(s+p); strcpy(s, ""); p = i+1; continue; }
    } else s[i] = d;
  }
  *c = atoi(s+p);
}

struct edge {
    int from, to;
    edge(int from, int to) : from(from), to(to) {}
};

int n, k, l, p, q;
vector<edge> v1, v2;

int par[200005], rank[200005], ans[200001];

void init() {
    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]);
    }
}

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]++;
    }
}

bool same(int x, int y) {
    return find(x) == find(y);
}

void solve() {
    init();

    rep(i,v1.size()) {
        if (!same(v1[i].from, v1[i].to)) {
            unite(v1[i].from, v1[i].to);
        }
    }

    rep(i,v2.size()) {
        if (same(v2[i].from, v2[i].to)) {
            ans[v2[i].from-1]++;
            ans[v2[i].to-1]++;
        }
    }
}

int main(void) {
    readInt3(&n, &k, &l);
    rep (i,k) {
        readInt2(&p, &q);
        v1.push_back(edge(p, q));
    }
    rep (i,l) {
        readInt2(&p, &q);
        v2.push_back(edge(p, q));
    }
    solve();
    rep(i,n-1) printf("%d ", ans[i]+1);
    printf("%d\n", ans[n-1]+1);
    return 0;
}


Compiler output:
a.cc: In function 'void init()':
a.cc:46:9: error: reference to 'rank' is ambiguous
   46 |         rank[i] = 0;
      |         ^~~~
In file included from /usr/include/c++/14/bits/char_traits.h:50,
                 from /usr/include/c++/14/string:42,
                 from a.cc:4:
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:41:18: note:                 'int rank [200005]'
   41 | int par[200005], rank[200005], ans[200001];
      |                  ^~~~
a.cc: In function 'void unite(int, int)':
a.cc:63:9: error: reference to 'rank' is ambiguous
   63 |     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:41:18: note:                 'int rank [200005]'
   41 | int par[200005], rank[200005], ans[200001];
      |                  ^~~~
a.cc:63:19: error: reference to 'rank' is ambiguous
   63 |     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:41:18: note:                 'int rank [200005]'
   41 | int par[200005], rank[200005], ans[200001];
      |                  ^~~~
a.cc:67:13: error: reference to 'rank' is ambiguous
   67 |         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:41:18: note:                 'int rank [200005]'
   41 | int par[200005], rank[200005], ans[200001];
      |                  ^~~~
a.cc:67:24: error: reference to 'rank' is ambiguous
   67 |         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:41:18: note:                 'int rank [200005]'
   41 | int par[200005], rank[200005], ans[200001];
      |                  ^~~~
a.cc:67:33: error: reference to 'rank' is ambiguous
   67 |         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:41:18: note:                 'int rank [200005]'
   41 | int par[200005], rank[200005], ans[200001];
      |                  ^~~~