Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int par[100010],rank[100010],par2[100010],rank2[100010];

int find(int x){
    if(par[x]==x) return x;
    return par[x]=find(par[x]);
}

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

int find2(int x){
    if(par2[x]==x) return x;
    return par2[x]=find2(par2[x]);
}

void uf2(int x,int y){
    x = find2(x);
    y = find2(y);
    if (x==y) return;
    if(rank2[x]<rank2[y]) par2[x] = y;
    else {
        par2[y]=x;
        if(rank2[x]==rank2[y]) rank2[x]++;
    }
}

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

bool s2(int x, int y){
    return find2(x)==find2(y);
}

int main(){
    int n,k,l,p[100010],q[100010],r[100010],s[100010];
    cin>>n>>k>>l;
    for(int i=0;i<100010;i++){ par[i]=i; rank[i]=0; par2[i]=i; rank2[i]=0;}
    for(int i=0;i<k;i++){ cin>>p[i]>>q[i]; p[i]--; q[i]--;}
    for(int i=0;i<l;i++){ cin>>r[i]>>s[i]; r[i]--; s[i]--;}
    for(int i=0;i<k;i++) uf(p[i],q[i]);
    for(int i=0;i<l;i++) uf2(r[i],s[i]);
    for(int i=0;i<n;i++){ 
        int ans=1; 
        for(int j=0;j<n;j++) {
            if(i!=j&&(s1(i,j)&&s2(i,j))) ans++; 
            //cout<<i<<' '<<j<<' '<<s1(i,j)<<' '<<s2(i,j)<<endl;
        }
        cout<<ans<<" ";
    }
    cout<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'void uf(int, int)':
a.cc:16:8: error: reference to 'rank' is ambiguous
   16 |     if(rank[x]<rank[y]) par[x] = y;
      |        ^~~~
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:5:17: note:                 'int rank [100010]'
    5 | int par[100010],rank[100010],par2[100010],rank2[100010];
      |                 ^~~~
a.cc:16:16: error: reference to 'rank' is ambiguous
   16 |     if(rank[x]<rank[y]) par[x] = y;
      |                ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:5:17: note:                 'int rank [100010]'
    5 | int par[100010],rank[100010],par2[100010],rank2[100010];
      |                 ^~~~
a.cc:19:12: error: reference to 'rank' is ambiguous
   19 |         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:5:17: note:                 'int rank [100010]'
    5 | int par[100010],rank[100010],par2[100010],rank2[100010];
      |                 ^~~~
a.cc:19:21: error: reference to 'rank' is ambiguous
   19 |         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:5:17: note:                 'int rank [100010]'
    5 | int par[100010],rank[100010],par2[100010],rank2[100010];
      |                 ^~~~
a.cc:19:30: error: reference to 'rank' is ambiguous
   19 |         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:5:17: note:                 'int rank [100010]'
    5 | int par[100010],rank[100010],par2[100010],rank2[100010];
      |                 ^~~~
a.cc: In function 'int main()':
a.cc:50:42: error: reference to 'rank' is ambiguous
   50 |     for(int i=0;i<100010;i++){ par[i]=i; rank[i]=0; par2[i]=i; rank2[i]=0;}
      |                                          ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:5:17: note:                 'int rank [100010]'
    5 | int par[100010],rank[100010],par2[100010],rank2[100010];
      |                 ^~~~