Language: C++

#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 100001
#define MOD 1000000007
typedef long long ll;
 
int par[MAX],rank[MAX];
 
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;
    }
    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));
}
 
ll mod_pow(ll x,ll n){
    if(n == 0) return 1;
    ll res = mod_pow(x*x%MOD,n/2);
    if(n & 1) res = res*x%MOD;
    return res;
}
 
int main(){
    int N,M,a,b;
    while(cin >> N >> M,N){
	init(N);
	for(int i = 0 ; i < M ; i++){
	    cin >> a >> b; a--; b--;
	    unite(a,b);
	}
	ll cnt = 0;
	bool visited[MAX] = {false};
	for(int i = 0 ; i < N ; i++){
	    int x = find(i);
	    if(!visited[x]){
		visited[x] = true;
		cnt++;
	    }
	}
	ll res = mod_pow(2,cnt);
	if(cnt != N) ++res;
	cout << res%MOD << endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'void init(int)':
a.cc:14:9: error: reference to 'rank' is ambiguous
   14 |         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:14: note:                 'int rank [100001]'
    9 | int par[MAX],rank[MAX];
      |              ^~~~
a.cc: In function 'void unite(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:14: note:                 'int rank [100001]'
    9 | int par[MAX],rank[MAX];
      |              ^~~~
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:14: note:                 'int rank [100001]'
    9 | int par[MAX],rank[MAX];
      |              ^~~~
a.cc:33:12: error: reference to 'rank' is ambiguous
   33 |         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:14: note:                 'int rank [100001]'
    9 | int par[MAX],rank[MAX];
      |              ^~~~
a.cc:33:23: error: reference to 'rank' is ambiguous
   33 |         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:14: note:                 'int rank [100001]'
    9 | int par[MAX],rank[MAX];
      |              ^~~~
a.cc:34:13: error: reference to 'rank' is ambiguous
   34 |             rank[x]++;
      |             ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:9:14: note:                 'int rank [100001]'
    9 | int par[MAX],rank[MAX];
      |              ^~~~