criyle/codenet-compile-errors huggingface dataset:
Language: C++

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

bool visit[100005];
vector <int> route[100005];

void dfs(int v){
    visit[v]=1;
    for(int i:route[v]){
        if (visit[i]==1) continue;
        dfs(i);
    }
}

void testcase(){
    int n,m;
    cin >> n >> m;
    for(int i=0;i<m;i++){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        route[a].push_back(b);
        route[b].push_back(a);
    }
    int c=0;
    for(int i=0;i<n;i++){
        if(visit[i]==1) continue;
        dfs(i);
        c++;
    }
    cout << c-1;

}


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int q=1;
   // cin >> q;
    while(q--){
    testcase();
    }
    return 0;
}


Compiler output:
a.cc: In function 'void dfs(int)':
a.cc:9:5: error: reference to 'visit' is ambiguous
    9 |     visit[v]=1;
      |     ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
                 from a.cc:1:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:5:6: note:                 'bool visit [100005]'
    5 | bool visit[100005];
      |      ^~~~~
a.cc:11:13: error: reference to 'visit' is ambiguous
   11 |         if (visit[i]==1) continue;
      |             ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:5:6: note:                 'bool visit [100005]'
    5 | bool visit[100005];
      |      ^~~~~
a.cc: In function 'void testcase()':
a.cc:29:12: error: reference to 'visit' is ambiguous
   29 |         if(visit[i]==1) continue;
      |            ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:5:6: note:                 'bool visit [100005]'
    5 | bool visit[100005];
      |      ^~~~~
Language: C++

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

bool visit[100005];
vector <int> route[100005];

void dfs(int v){
    visit[v]=1;
    for(int i:route[v]){
        if (visit [i]==1) continue;
        dfs(i);
    }
}

void testcase(){
    int n,m;
    cin >> n >> m;
    for(int i=0;i<m;i++){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        route[a].push_back(b);
        route[b].push_back(a);
    }
    int c=0;
    for(int i=0;i<n;i++){
        if(visit[i]==1) continue;
        dfs(i);
        c++;
    }
    cout << c-1;

}


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int q=1;
   // cin >> q;
    while(q--){
    testcase();
    }
    return 0;
}


Compiler output:
a.cc: In function 'void dfs(int)':
a.cc:9:5: error: reference to 'visit' is ambiguous
    9 |     visit[v]=1;
      |     ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
                 from a.cc:1:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:5:6: note:                 'bool visit [100005]'
    5 | bool visit[100005];
      |      ^~~~~
a.cc:11:13: error: reference to 'visit' is ambiguous
   11 |         if (visit [i]==1) continue;
      |             ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:5:6: note:                 'bool visit [100005]'
    5 | bool visit[100005];
      |      ^~~~~
a.cc: In function 'void testcase()':
a.cc:29:12: error: reference to 'visit' is ambiguous
   29 |         if(visit[i]==1) continue;
      |            ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:5:6: note:                 'bool visit [100005]'
    5 | bool visit[100005];
      |      ^~~~~
Language: C++

#include <atcoder/all>
#include <bits/stdc++.h>
using namespace atcoder;
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;

// ACL C
// https://atcoder.jp/contests/abl/tasks/abl_c

int main() {
  int n, m;
  cin >> n >> m;
  dsu uf(n);

  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    uf.merge(a, b);
  }

  // int cnt = 0;
  // rep(i, n) if(uf.leader(i) == i) cnt++;
  int cnt = uf.groups().size();
  cout << cnt - 1;
}


Compiler output:
a.cc:1:10: fatal error: atcoder/all: No such file or directory
    1 | #include <atcoder/all>
      |          ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <atcoder/dsu>
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  atcoder::dsu towns(N);
  rep(i, M) {
    int A, B;
    cin >> A >> B;
    A--, B--;
    towns.merge(A, B);
  }
  int answer = towns.groups().size() - 1;
  cout << answer << endl;
  return 0;
}


Compiler output:
a.cc:1:10: fatal error: atcoder/dsu: No such file or directory
    1 | #include <atcoder/dsu>
      |          ^~~~~~~~~~~~~
compilation terminated.
Language: C++

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

#define ll long long
#define ar array
const int mxn=1e5+1;
ll n,m;
vector<ll>g[mxn];
vector<bool>used(mxn,false);
int ans=0;
void dfs(int u)
{
	used[u]=true;
	for(ll i:g[u])
		if(!used[i])
			dfs(i);
}
void solve(){
	cin>>n>>m;
	while(m--)
	{
		ll a,b;
		cin>>a>>b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	for(ll i=1;i<=n;i++)
		if(!used[i])
	      dfs(i),++ans;
	cout<<ans-;

}
int main(){
	solve();
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:30:19: error: expected primary-expression before ';' token
   30 |         cout<<ans-;
      |                   ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
#define rep(i,n) for (int i = 0;i < n;i++)
using ll = long long;

int main(){
  int n,m; cin >>n >>m;
  int cnt = n-1;
  dsu d(n);
  rep(i,m){
    int a,b; cin >>a >>b;
    a--; b--;
    d.merge(a,b);
  }
  rep(i,n){
    if(d.leader(i)!=i) cnt--;
  }
  cout << cnt << endl;
  return 0;
}

Compiler output:
a.cc:3:10: fatal error: atcoder/all: No such file or directory
    3 | #include <atcoder/all>
      |          ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <boost/multiprecision/cpp_int.hpp>
#include <atcoder/all>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
typedef long double ld;
const char sp = ' ';

using namespace boost::multiprecision;
using namespace std;
using namespace atcoder;

int main(void){
    ll N, M;
    cin>>N>>M;
    ll a, b;
    dsu d(N);
    rep(i, M){
        cin>>a>>b;
        d.merge(a-1, b-1);
    }
    cout<<(d.groups().size())-1<<endl;
    return 0;
}


Compiler output:
a.cc:15:10: fatal error: boost/multiprecision/cpp_int.hpp: No such file or directory
   15 | #include <boost/multiprecision/cpp_int.hpp>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n, m;
    cin >> n >> m;
 
    dsu d(n);
 
    for(int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        d.merge(a - 1, b - 1);
    }
 
    cout << d.groups().size() - 1 << endl;
}


Compiler output:
a.cc:1:10: fatal error: atcoder/all: No such file or directory
    1 | #include <atcoder/all>
      |          ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;

int main() {
  int int n,k;
  cin >> n >> k;
  dsu d(n);
  for(int i = 0; i < k; i++) {
    int a,b;
    cin >> a >> b;
    a--;b--;
    d.merge(a,b);
  }
  int ans = d.groups().size();
  cout << ans -1 << endl;
}

Compiler output:
a.cc:2:9: fatal error: atcoder/all: No such file or directory
    2 | #include<atcoder/all>
      |         ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;

int main() {
  int n,k;
  cin >> n >> k;
  dsu d(n);
  for(int i = 0; i < k; i++) {
    int a,b;
    cin >> a >> b;
    a--;b--;
    d.merge(a,b);
  }
  int ans = d.groups().size();
  cout << ans -1 << endl;
  return 0
}

Compiler output:
a.cc:2:9: fatal error: atcoder/all: No such file or directory
    2 | #include<atcoder/all>
      |         ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;

int main() {
  int n,k;
  cin >> n >> k;
  dsu d(n);
  for(int i = 0; i < n; i++) {
    int a,b;
    cin >> a >> b;
    d.merge(a,b);
  }
  int ans = d.groups().size();
  cout << ans -1 << endl;
}

Compiler output:
a.cc:2:9: fatal error: atcoder/all: No such file or directory
    2 | #include<atcoder/all>
      |         ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>
#include<atcoder/dsu>
using namespace std;
using namespace atcoder;
typedef rep(i,n) for (int i = 0; i < (n); i++)
int main() {
  int n, m;
  cin >> n >> m;
  dsu uf(n);
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    uf.merge(a-1,b-1);
  }
  map<int,int> mp;
  int ans = 0;
  rep(i,n) {
    if (mp[uf.leader(i)]) continue;
    mp[uf.leader(i)]++;
    ans++;
  }
  ans--;
  cout << ans << endl;
}


Compiler output:
a.cc:2:9: fatal error: atcoder/dsu: No such file or directory
    2 | #include<atcoder/dsu>
      |         ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>
#include<atcoder/dsu>
using namespace std;
using namespace atcoder;
int main() {
  int n, m;
  cin >> n >> m;
  dsu uf(n);
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    uf.merge(a-1,b-1);
  }
  map<int,int> mp;
  int ans = 0;
  rep(i,n) {
    if (mp[uf.leader(i)]) continue;
    mp[uf.leader(i)]++;
    ans++;
  }
  ans--;
  cout << ans << endl;
}

Compiler output:
a.cc:2:9: fatal error: atcoder/dsu: No such file or directory
    2 | #include<atcoder/dsu>
      |         ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>
#include<atcoder/dsu>
using namespace std;
#define LL long long

int main(){
	// sengen
	int n,m;
	// nyuryoku
	cin >> n >> m;
	int ans = n-1;
	dsu d(n);
	int a[m],b[m];
	for(int i=0;i<m;i++){
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
		if(!d.same(a[i],b[i])){
			d.merge(a[i],b[i]);
			ans--;
		}
	}
	// keisan
	cout << ans << endl;
	// syutsuryoku
}

Compiler output:
a.cc:2:9: fatal error: atcoder/dsu: No such file or directory
    2 | #include<atcoder/dsu>
      |         ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>
#include<atcoder|dsu>
using namespace std;
#define LL long long

int main(){
	// sengen
	int n,m;
	// nyuryoku
	cin >> n >> m;
	int ans = n-1;
	dsu d(n);
	int a[m],b[m];
	for(int i=0;i<m;i++){
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
		if(!d.same(a[i],b[i])){
			d.merge(a[i],b[i]);
			ans--;
		}
	}
	// keisan
	cout << ans << endl;
	// syutsuryoku
}

Compiler output:
a.cc:2:9: fatal error: atcoder|dsu: No such file or directory
    2 | #include<atcoder|dsu>
      |         ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
#define ll long long
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#define PI 2 * acos(0)
#define ones(n) __builtin_popcount(n)
#define FAST ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define MAX 9000000
#define debug(x) cerr << #x << " = " << x << '\n';
#define LOOP printf("LOOP!!")
#define READ freopen("input.txt", "r", stdin)
#define PRINT freopen("output.txt", "w", stdout);
#define print(a, b) printf("Case %d: %lld\n", a, b)
#define all(x) (x).begin(), (x).end()
const ll MOD = 1e9 + 7;
using namespace std;
const int VAL = 2e5+10;
vector<int> v[VAL];

bool vis[VAl];

void dfs(int n)
{

    vis[n] = true;

    for (int i = 0; i < v[n].size(); i++)
        if (!vis[v[n][i]])
            dfs(v[n][i]);
}

/************MAIN_FUNCTION**********/
int main(int argc, char *argv[])
{
    ///Disjoint set union
    int n, m, a, b;
    cin >> n >> m;

    for (int i = 0; i < m; i++)
    {

        cin >> a >> b;
        v[b].push_back(a);
        v[a].push_back(b);
    }
    int c = 0;
    for (int i = 0; i < n; i++)
        if (!vis[i])
            dfs(i), c++;

    cout << c - 1 << '\n';
    return 0;
}

Compiler output:
a.cc:20:10: error: 'VAl' was not declared in this scope; did you mean 'VAL'?
   20 | bool vis[VAl];
      |          ^~~
      |          VAL
a.cc: In function 'void dfs(int)':
a.cc:25:5: error: 'vis' was not declared in this scope
   25 |     vis[n] = true;
      |     ^~~
a.cc: In function 'int main(int, char**)':
a.cc:48:14: error: 'vis' was not declared in this scope
   48 |         if (!vis[i])
      |              ^~~
Language: C++

#include<atcoder/all>
main(){int a,b;std::cin>>a>>b;atcoder::dsu D(a+1);for(;std::cin>>a>>b;D.merge(a,b));std::cout<<D.groups().size()-2;}


Compiler output:
a.cc:1:9: fatal error: atcoder/all: No such file or directory
    1 | #include<atcoder/all>
      |         ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using P = pair<int,int>;

int main() {
  int N, M;
  cin >> N >> M;
  dsu d(N);
  rep(i, M){
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    d.merge(a, b);
  }

  cout << d.groups().size() - 1 << endl;
  return 0;
}


Compiler output:
a.cc:3:10: fatal error: atcoder/all: No such file or directory
    3 | #include <atcoder/all>
      |          ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>
#include <atcoder/all>
#define rep(i, n) for(int i = 0; i < (n); ++i)
//#define DEBUG
#ifdef DEBUG
#define DEBUG_PRINT(fm, ...) do{std::printf("%s:%d(%s)", __FILE__, __LINE__, __func__);std::cout << "DEBUG PRINT ";std::printf(fm, __VA_ARGS__);}while(0)
#define DEBUG_VAL(a, b) do{std::printf("%s:%d(%s)", __FILE__, __LINE__, __func__);std::cout <<"DEBUG VAL " << a << ":" << b << endl;}while(0)
#else
#define DEBUG_PRINT(...)do{}while(0);
#define DEBUG_VAL(a, b)do{}while(0);
#endif

using namespace std;
using namespace atcoder;
using ll = long long;
using v1 = vector<int>;
using vl = vector<long long>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

int main(){
    int n, m;
    cin >> n >> m;
    dsu d(n);
    rep(i, m){
        int a, b;
        cin >> a >> b;
        d.merge(a, b);
    }
    
    cout << d.groups().size()-1 << endl;

}

Compiler output:
a.cc:2:10: fatal error: atcoder/all: No such file or directory
    2 | #include <atcoder/all>
      |          ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define si set <ll>
#define vi vector <ll>
#define popcount(x) __builtin_popcountll(x)
#define mii map <ll,ll>
#define vpi vector <pair <ll,ll> >
#define sz(c) (int)c.size()
#define fr first
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define mem0(a) memset(a,0,sizeof(a))
#define rep(i,a,n) for(ll i=a ; i<n ; i++)
#define ld long double
#define rall(a) (a).rbegin(),(a).rend()
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
 
ll power(ll b,ll e,ll m)
{
  if(b==0) return 0;
  if(e==0) return 1;
  if(e&1) return b*power(b*b%m,e/2,m)%m;
  return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
  if(b==0) return 0;
  if(e==0) return 1;
  if(e&1) return b*power(b*b,e/2);
  return power(b*b,e/2);
}  
bool isPowerOfTwo(ll x)
{
    // x will check if x == 0 and !(x & (x - 1)) will check if x is a power of 2 or not
    return (x && !(x & (x - 1)));
}

bool isPrime(ll n)
{
  if(n==1) return 0;
  for(ll i=2;i*i<=n;i++)
    if(n%i==0)
      return 0;
  return 1;
}



void solve()
{
  ll n,m;
  cin>>n>>m;
  vector <bool> vis(n+1);
  rep(i,0,m)
  {
    cin>>a>>b;
    vis[a]=true;
    vis[b]=true;
  }
  ll ans=0;
  rep(i,1,n+1)
  {
    if(!vis[i])
      ans++;
  }
  cout<<ans;
}

int main()
{
  ll tt=1;
  // cin>>tt;
  while(tt--)
  {
    solve();
    cout<<"\n";
  }
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:65:10: error: 'a' was not declared in this scope
   65 |     cin>>a>>b;
      |          ^
a.cc:65:13: error: 'b' was not declared in this scope
   65 |     cin>>a>>b;
      |             ^
Language: C++

#include<iostream>
 
using namespace std;
 
int main() {
	int n;
  cin>>n;
  	
  int m;
  cin>>m;
  	
  for(int i=0; i<m; i++) {
  	int temp;
    cin>>temp
    cin>>temp;
  }
  
  cout<<n-m-1<<'\n';
  	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:14: error: expected ';' before 'cin'
   14 |     cin>>temp
      |              ^
      |              ;
   15 |     cin>>temp;
      |     ~~~
Language: C++

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
int main()
{
  int n,m,a,b;
  cin>>n>>m;
  for(int i=0;i<m;i++)
  {
    cin>>a>>b;
    a--;
    b--;
    d.merge(a,b);
  }
  int count = d.groups().size();
  cout<<count - 1<<endl;
}

Compiler output:
a.cc:2:9: fatal error: atcoder/all: No such file or directory
    2 | #include<atcoder/all>
      |         ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
int main()
{
  int n,m,a,b;
  cin>>n>>m;
  dsu d(n);
  for(int i=0;i<m;i++)
  {
    cin>>a>>b;
    a--;
    b--;
    d.merge(a,b);
  }
  int count = d.groups().size();
  cout<<count-1<<endl;
}

Compiler output:
a.cc:2:9: fatal error: atcoder/all: No such file or directory
    2 | #include<atcoder/all>
      |         ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
int main()
{
  int n,m,a,b;
  cin>>n>>m;
  dsu d(n);
  for(int i=0;i<m;i++)
  {
    cin>>a>>b;
    a--;
    b--;
    d.merge(a,b);
  }
  int count = d.groups().size();
  cout<<count-1<<endl;
}

Compiler output:
a.cc:2:9: fatal error: atcoder/all: No such file or directory
    2 | #include<atcoder/all>
      |         ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
int main()
{
  int n,m,a,b;
  cin>>n>>m;
  dsu d(n);
  for(int i=0;i<m;i++)
  {
    cin>>a>>b;
    a--;
    b--;
    d.merge(a,b);
  }
  int count = d.groups.size();
  cout<<count-1<<endl;
}

Compiler output:
a.cc:2:9: fatal error: atcoder/all: No such file or directory
    2 | #include<atcoder/all>
      |         ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
int main()
{
  int n,m,a,b;
  cin>>n>>m;
  dsu d(n);
  for(int i=0;i<m;i++)
  {
    cin>>a>>b;
    a--;
    b--;
    d.merge(a,b);
  }
  int count = d.groups.size();
  cout<<count-1<<endl;
  return 0;
}

Compiler output:
a.cc:2:9: fatal error: atcoder/all: No such file or directory
    2 | #include<atcoder/all>
      |         ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m,a,b;
  cin>>n>>m;
  dsu d(n);
  for(int i=0;i<m;i++)
  {
    cin>>a>>b;
    a--;
    b--;
    d.merge(a,b);
  }
  int count = d.groups.size();
  cout<<count-1<<endl;
  
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:3: error: 'dsu' was not declared in this scope
    7 |   dsu d(n);
      |   ^~~
a.cc:13:5: error: 'd' was not declared in this scope
   13 |     d.merge(a,b);
      |     ^
a.cc:15:15: error: 'd' was not declared in this scope
   15 |   int count = d.groups.size();
      |               ^
Language: C++

#include <bits/stdc++.h>
#include <atcoder/all>
#define INF 1000000007
#define rep(i, N) for(ll i = 0; i < N; i++)
#define rep2(i, j, k) for(ll i = j; i < k; i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define print(x) cout << x << "\n"
#define print2(x, y) cout << x << " " << y << "\n"
#define printv(vec) rep(lp, vec.size()) cout << vec[lp] << " "; print(""); 
#define show(x) cerr << #x << " = " << x << "\n";
#define ALL(v) v.begin(), v.end()
#define SUM(v) accumulate(ALL(v), 0)
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define SORT(v) sort(ALL(v))
#define REV(v) reverse(ALL(v))
#define pb(x) push_back(x)
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
using namespace std;
using namespace atcoder;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vs = vector<string>;
//using mint = modint998244353;
//ll mod = 998244353;
using mint = modint1000000007;
ll mod = 1000000007;

struct union_find{
 
	vl parent;
	vl sizes;
 
	void init(ll n) {
		rep(i, n) parent.push_back(i);
		rep(i, n) sizes.push_back(1);
	}
 
	ll root(ll n){
		if(parent[n] == n) return n;
		return parent[n] = root(parent[n]);
	}
 
	ll size(ll n) {
		return sizes[root(n)];
	}
 
	bool is_same(ll a, ll b){
		return root(a) == root(b);
	}
 
	void unite(ll a, ll b){
		if(is_same(a, b)) return;
		sizes[root(a)] += size(b);
		parent[root(b)] = root(a);
	}
	
	ll group_count(){
		ll ret = 0;
		rep(i, parent.size()) ret += (parent[i] == i);
		return ret;
	}
};
 
void Main(){

	ll N, M;
	cin >> N >> M;
	vvl v(M, vl(2));
	rep(i, M) cin >> v[i][0] >> v[i][1];
	
	union_find uf;
	uf.init(N);
	
	rep(i, M) uf.unite(v[i][0] - 1, v[i][1] - 1);
	
	ll ans = uf.group_count() - 1;
	print(ans);

}

int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll t = 1;
	//cin >> t;
	rep(i, t) Main();
	return 0;
	
}





Compiler output:
a.cc:2:10: fatal error: atcoder/all: No such file or directory
    2 | #include <atcoder/all>
      |          ^~~~~~~~~~~~~
compilation terminated.
Language: C++

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

#define rep(i,n) for(int i = 0; i < (n); i++)

int main () {
    int n, m, a, b;
    cin >> n >> m;
    dsu d(n);
    rep(i, m) {
        cin >> a >> b;
        d.merge(a,b);
    }
    int cnt = d.groups().size();
    int ans = cnt - 1;
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc:2:9: fatal error: atcoder/all: No such file or directory
    2 | #include<atcoder/all>
      |         ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<iostream>
using namespace std;
vector<int>par;
void init(int N) {
  par.resize(N + 3);
  for(int i = 0; i <= N; i ++) {
    par[i] = i;
  }
}
int root(int v) {
  if (v == par[v]) return v;
  return par[v] = root(par[v]);
}
bool merge(int a, int b) {
  a = root(a);
  b = root(b);
  if (a == b) return false;
  par[b] = a;
  return true;
}
int main () {
  int N, M;
  cin >> N >> M;
  init(N);
  int ans = N - 1;
  for (int i = 0; i < M; i ++) {
    int a, b;
    cin >> a >> b;
    if (merge(a, b)) ans --;
  }
  cout << ans << endl;
}


Compiler output:
a.cc:3:1: error: 'vector' does not name a type
    3 | vector<int>par;
      | ^~~~~~
a.cc: In function 'void init(int)':
a.cc:5:3: error: 'par' was not declared in this scope
    5 |   par.resize(N + 3);
      |   ^~~
a.cc: In function 'int root(int)':
a.cc:11:12: error: 'par' was not declared in this scope
   11 |   if (v == par[v]) return v;
      |            ^~~
a.cc:12:10: error: 'par' was not declared in this scope
   12 |   return par[v] = root(par[v]);
      |          ^~~
a.cc: In function 'bool merge(int, int)':
a.cc:18:3: error: 'par' was not declared in this scope
   18 |   par[b] = a;
      |   ^~~
Language: C++

#include<iostream>
using namespace std;
vector<int>par;
void init(int N) {
  par.resize(N + 3);
  for(int i = 0; i <= N; i ++) {
    par[i] = i;
  }
}
int root(int v) {
  if (v == par[v]) return v;
  return par[v] = root(par[v]);
}
bool merge(int a, int b) {
  a = root(a);
  b = root(b);
  if (a == b) return false;
  par[b] = a;
  return true;
}
int main () {
  int N, M;
  cin >> N >> M;
  int ans = N - 1;
  for (int i = 0; i < M; i ++) {
    int a, b;
    cin >> a >> b;
    if (merge(a, b)) ans --;
  }
  cout << ans << endl;
}


Compiler output:
a.cc:3:1: error: 'vector' does not name a type
    3 | vector<int>par;
      | ^~~~~~
a.cc: In function 'void init(int)':
a.cc:5:3: error: 'par' was not declared in this scope
    5 |   par.resize(N + 3);
      |   ^~~
a.cc: In function 'int root(int)':
a.cc:11:12: error: 'par' was not declared in this scope
   11 |   if (v == par[v]) return v;
      |            ^~~
a.cc:12:10: error: 'par' was not declared in this scope
   12 |   return par[v] = root(par[v]);
      |          ^~~
a.cc: In function 'bool merge(int, int)':
a.cc:18:3: error: 'par' was not declared in this scope
   18 |   par[b] = a;
      |   ^~~
Language: C++

#include<iostream>
vector<int>par;
void init(int N) {
  par.resize(N + 3);
  for(int i = 0; i <= N; i ++) {
    par[i] = i;
  }
}
int root(int v) {
  if (v == par[v]) return v;
  return par[v] = root(par[v]);
}
bool merge(int a, int b) {
  a = root(a);
  b = root(b);
  if (a == b) return false;
  par[b] = a;
  return true;
}
int main () {
  int N, M;
  cin >> N >> M;
  int ans = N - 1;
  for (int i = 0; i < M; i ++) {
    int a, b;
    cin >> a >> b;
    if (merge(a, b)) ans --;
  }
  cout << ans << endl;
}

Compiler output:
a.cc:2:1: error: 'vector' does not name a type
    2 | vector<int>par;
      | ^~~~~~
a.cc: In function 'void init(int)':
a.cc:4:3: error: 'par' was not declared in this scope
    4 |   par.resize(N + 3);
      |   ^~~
a.cc: In function 'int root(int)':
a.cc:10:12: error: 'par' was not declared in this scope
   10 |   if (v == par[v]) return v;
      |            ^~~
a.cc:11:10: error: 'par' was not declared in this scope
   11 |   return par[v] = root(par[v]);
      |          ^~~
a.cc: In function 'bool merge(int, int)':
a.cc:17:3: error: 'par' was not declared in this scope
   17 |   par[b] = a;
      |   ^~~
a.cc: In function 'int main()':
a.cc:22:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   22 |   cin >> N >> M;
      |   ^~~
      |   std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:29:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   29 |   cout << ans << endl;
      |   ^~~~
      |   std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:29:18: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   29 |   cout << ans << endl;
      |                  ^~~~
      |                  std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
Language: C++

#include<bits/stdc++.h>
#define IOS ios::sync_with_stido(false);cin.tie(0);
using namespace std;
vector<int>adj[100001];
int vis[100001]={false};
void dfs(int i){
	vis[i]=true;
	for(auto p : adj[i]){
		if(!vis[p])
		 dfs(p);}}
int main(){IOS;
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		adj[a].push_back(b);
		adj[b].push_back(a);}
		int ans=0;
		for(int i=1;i<=n;i++){
			if(!vis[i])
			ans++;
			dfs(i);}
			cout<<ans-1<<endl;}

Compiler output:
a.cc: In function 'int main()':
a.cc:2:18: error: 'sync_with_stido' is not a member of 'std::ios' {aka 'std::basic_ios<char>'}
    2 | #define IOS ios::sync_with_stido(false);cin.tie(0);
      |                  ^~~~~~~~~~~~~~~
a.cc:11:12: note: in expansion of macro 'IOS'
   11 | int main(){IOS;
      |            ^~~
Language: C++

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
// --------------------------------------------------------
#define FOR(i,l,r) for (int i = (l); i < (r); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define MIN(c) *min_element(ALL(c))
#define MAX(c) *max_element(ALL(c))
#define SUM(c) accumulate(ALL(c), 0)
#define SUMLL(c) accumulate(ALL(c), 0LL)
#define SZ(c) ((int)(c).size())
#define debug(x) cerr << #x << " = " << (x) << '\n';
using P = pair<int,int>;
using VP = vector<P>;
using VVP = vector<VP>;
using VS = vector<string>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<ll>;
using VVLL = vector<VLL>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
static const double EPS = 1e-10;
static const double PI  = acos(-1.0);
static const ll MOD = 1000000007;
// static const ll MOD = 998244353;
static const int INF = 1 << 30;
// static const ll INF = 1LL << 62;
// --------------------------------------------------------


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);

    int N, M; cin >> N >> M;
    dsu uf(N);
    REP(_, M) {
        int A, B; cin >> A >> B;
        --A; --B;
        uf.merge(A, B);
    }

    int ans = SZ(uf.groups()) - 1;
    cout << ans << endl;

    return 0;
}


Compiler output:
a.cc:2:10: fatal error: atcoder/all: No such file or directory
    2 | #include <atcoder/all>
      |          ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
typedef long long int ll;

using namespace std;
const double PI = 3.14159265358979323846;

void bfs(vector<int> &visit, vector<vector<int>> &G, int s, int &count)
{

    visit[s] = 1;

    for (int v : G[s])
    {

        if (visit[v] == 0)
        {

            visit[v] = 1;
            count++;
            bfs(visit, G, v,count);

          
        }
        
    }
}

int main()
{
    int N, M;
    cin >> N >> M;

    vector<vector<int>> G(N, vector<int>(0));

    for (int i = 0; i < M; i++)
    {
        int A, B;

        cin >> A >> B;

        G[A - 1].push_back(B - 1);
        G[B - 1].push_back(A - 1);
    }
    vector<int> visit(N, 0);


    int count=0;

    int s_i = 0;

    int c=0;

    for(int i=0;i<N;i++){

        count++;
        bfs(visit, G, v,c);
        if(c==N){
            break;
        }
    
    }


    cout << count -1 << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:56:23: error: 'v' was not declared in this scope
   56 |         bfs(visit, G, v,c);
      |                       ^
Language: C++

#include <bits/stdc++.h>

#define fastIO                    \
	ios_base::sync_with_stdio(0); \
	cin.tie(0);                   \
	cout.tie(0);
#define MOD 1000000007

using namespace std;

typedef long long ll;
typedef long double ld;

vector<int> parent;

int find_parent(int n)
{
	if (n != parent[n]) 
		parent[n] = find_parent[parent[n]];
	return parent[n];
}

int main()
{
	fastIO;
	int N, M;
	cin >> N >> M;
	parent.resize(N + 1);
	for (int i = 1; i <= N; i++) 
		parent[i] = i;
	int A, B;
	while (M--)
	{
		cin >> A >> B;
		if (A > B) swap(A, B);
		int parent_A = find_parent(A), parent_B = find_parent(B);
		parent[parent_B] = parent_A;
	}
	set<int> unique_parents;
	for (int i = 1; i <= N; i++)
		unique_parents.insert(find_parent(i));
	cout << unique_parents.size() - 1;
}

Compiler output:
a.cc: In function 'int find_parent(int)':
a.cc:19:50: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   19 |                 parent[n] = find_parent[parent[n]];
      |                                                  ^
a.cc:19:50: error: invalid conversion from 'int (*)(int)' to '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} [-fpermissive]
   19 |                 parent[n] = find_parent[parent[n]];
      |                             ~~~~~~~~~~~~~~~~~~~~~^
      |                                                  |
      |                                                  int (*)(int)
Language: C

#include<stdio.h>

int N, M;
int V[1000000];

void root(int x) {
  if(V[x] == 0) return x;
  else V[x] = root(x);
}

void merge(int a, int b) {
  a = root(a);
  b = root(b);
  V[a] = b;
}

int main() {
  int unique[1000000] = {};
  scanf("%d%d", &N, &M);
  for(int i = 0;i < M;i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--; b--;
    merge(a, b);
  }
  int ans = -1;
  for(int i = 0;i < N;i++) {
    if(unique[V[i]] == 0) ans++;
  }
  printf("%d\n", ans);
}

Compiler output:
main.c: In function 'root':
main.c:7:24: error: 'return' with a value, in function returning void [-Wreturn-mismatch]
    7 |   if(V[x] == 0) return x;
      |                        ^
main.c:6:6: note: declared here
    6 | void root(int x) {
      |      ^~~~
main.c:8:13: error: void value not ignored as it ought to be
    8 |   else V[x] = root(x);
      |             ^
main.c: In function 'merge':
main.c:12:5: error: void value not ignored as it ought to be
   12 |   a = root(a);
      |     ^
main.c:13:5: error: void value not ignored as it ought to be
   13 |   b = root(b);
      |     ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
void dfs(vector<vector<int> >&adj,vector<bool> &vis,int i)
{
  if(vis[i]==false)
    return;
  vis[i]=true;
  for(int x:adj[i])
  {
    if(!vis[x])
      dfs(adj,vis,x);
  }
}
int main()
{
  int n,m,a,b,ans=0;
  cin>>n>>m;
  vector<bool> vis(n+1,false);
  vector<vector<int> >adj(n+1,vector<int>);
  for(int i=0;i<m;i++)
  {
    cin>>a>>b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  for(int i=1;i<=n;i++)
  {
    if(vis[i]==false)
    {
      ans++;
      dfs(adj,vis,i);
    }
  }
  cout<<ans;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:42: error: expected primary-expression before ')' token
   19 |   vector<vector<int> >adj(n+1,vector<int>);
      |                                          ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m,a,b;
  cin>>n>>m;
  vector<int> indegree(n+1,0);
  for(int i=0;i<m;i++)
  {
    cin>>a>>b;
    indegree[a]++;
    indegree[b]++;
  }
  for(int i=1;i<=n;i++)
  {
    if(indegree[i]==0)
      ans++;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:7: error: 'ans' was not declared in this scope; did you mean 'abs'?
   17 |       ans++;
      |       ^~~
      |       abs
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define very_slow       ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int             long long int
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vec             vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define inf             1e18
#define MAX             1e9
#define MIN            -1e9
#define no_of_test(x)   int x; cin>>x; while(x--)
#define main  Aayush
const double pi=3.14159265359;
const int mod = 1e9 + 6;
//Actual Code Is At The Top
int gcd(int a, int b)
{
	if (b == 0) return a;
	return gcd(b, a % b);
}
int binary_exponentation(int a, int b)
{
	int ret = 1;
	while (b)
	{
		if (b & 1) ret = (ret * a) % mod;
		b >>= 1;
		a = (a * a) % mod;
	}
	return ret;
}
int nodes,edges;
vector<int>adj[100001];
int vis[100001];
void dfs(int node)
{
    if(vis[node]) return;
    vis[node]=1;
    for(auto child:adj[node])
    {
        dfs(child);
    }
}
int32_t Aayush()
{   
	very_slow
//	no_of_test(x)
	{  
	   cin>>nodes>>edges;
       for(int i=1;i<=edges;i++)
       {    int x,y;
            cin>>x>>y;
            adj[x].push_back(y);
            adj[y].push_back(x);
       }
       int cc=0;
       for(int i=1;i<=nodes;i++)
       {
           if(!vis[i])
           {
               dfs(i);cc++;
           }
       }
       cout<<cc-1<<'\n';
	}
	return 0;
}


Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

#include <bits/stdc++.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string.h>
using namespace std;
#define pb push_back
#define all(v) v. begin(),v. end()
#define  rep(i,n,v) for(i=n;i<v;i++)
#define per(i,n,v) for(i=n;i>v;i--)
#define ff first 
#define ss second 
#define pp pair<ll,ll>
#define ll  long long
#define endl '\n'
vector<ll>grid;
vector<bool>hit;
void dfs(ll n)
{
    hit[n]=true;
    for(auto x:grid[n])
    {
        if(!hit[x]) dfs(x);
    }
}
void solve()
{
  ll n, a,m=0,b=1, c,k=0, i, j,l=1e9+7;
  string s, r, y;
   cin>>n>>a;
   grid.resize(n+1);
   hit.assign(n+1,false);
   rep(i,0,m)
   {
       cin>>m>>b;
       grid[m].pb(b);
       grid[b].pb(m);
   }
   ll ans=0;
   rep(i,1,n+1)
   {
       if(!hit[i])
       {
           ans++;
           dfs(i);
       }
   }
   cout<<ans-1<<endl;
}
int main()
{
 ios_base::sync_with_stdio(false);
  cin. tie(0);cout. tie(0);
    ll t=1;
  // cin>>t;
    while(t--)
    {
      solve();
    }
    return 0;
}

Compiler output:
a.cc: In function 'void dfs(long long int)':
a.cc:22:22: error: 'begin' was not declared in this scope
   22 |     for(auto x:grid[n])
      |                      ^
a.cc:22:22: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166,
                 from a.cc:1:
/usr/include/c++/14/valarray:1238:5: note:   'std::begin'
 1238 |     begin(const valarray<_Tp>& __va) noexcept
      |     ^~~~~
In file included from /usr/include/c++/14/filesystem:53,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:200:
/usr/include/c++/14/bits/fs_dir.h:608:3: note:   'std::filesystem::__cxx11::begin'
  608 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
a.cc:22:22: error: 'end' was not declared in this scope
   22 |     for(auto x:grid[n])
      |                      ^
a.cc:22:22: note: suggested alternatives:
/usr/include/c++/14/valarray:1265:5: note:   'std::end'
 1265 |     end(const valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/14/bits/fs_dir.h:613:3: note:   'std::filesystem::__cxx11::end'
  613 |   end(recursive_directory_iterator) noexcept
      |   ^~~
a.cc: In function 'void solve()':
a.cc:8:12: error: request for member 'push_back' in 'grid.std::vector<long long int>::operator[](((std::vector<long long int>::size_type)m))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}
    8 | #define pb push_back
      |            ^~~~~~~~~
a.cc:37:16: note: in expansion of macro 'pb'
   37 |        grid[m].pb(b);
      |                ^~
a.cc:8:12: error: request for member 'push_back' in 'grid.std::vector<long long int>::operator[](((std::vector<long long int>::size_type)b))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}
    8 | #define pb push_back
      |            ^~~~~~~~~
a.cc:38:16: note: in expansion of macro 'pb'
   38 |        grid[b].pb(m);
      |                ^~
Language: C++

#include<bits/stdc++.h>
using namespace std;
vector<int>v[100001];
bool visit[100001];
void dfs(int n){
    if(visit[n])return;
    visit[n] = true;
    for(int i=0;i<v[n].size();i++){
        dfs(v[n][i]);
    }
    return;
}
int main(){
    int n,m;
    scanf("%d %d",&n,&m);
    while(m--){
        int n1,n2;
        scanf("%d %d",&n1,&n2);
        v[n1].push_back(n2);
        v[n2].push_back(n1);
    }
    int cnt = 0;
    for(int i=1;i<=n;i++){
        if(!visit[i]){dfs(i);cnt++;}
    }
    printf("%d\n",--cnt);
    return 0;
}

Compiler output:
a.cc: In function 'void dfs(int)':
a.cc:6:8: error: reference to 'visit' is ambiguous
    6 |     if(visit[n])return;
      |        ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
                 from a.cc:1:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:4:6: note:                 'bool visit [100001]'
    4 | bool visit[100001];
      |      ^~~~~
a.cc:7:5: error: reference to 'visit' is ambiguous
    7 |     visit[n] = true;
      |     ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:4:6: note:                 'bool visit [100001]'
    4 | bool visit[100001];
      |      ^~~~~
a.cc: In function 'int main()':
a.cc:24:13: error: reference to 'visit' is ambiguous
   24 |         if(!visit[i]){dfs(i);cnt++;}
      |             ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:4:6: note:                 'bool visit [100001]'
    4 | bool visit[100001];
      |      ^~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
vector<int>v[101];
bool visit[101];
void dfs(int n){
    if(visit[n])return;
    visit[n] = true;
    for(int i=0;i<v[n].size();i++){
        dfs(v[n][i]);
    }
    return;
}
int main(){
    int n,m;
    scanf("%d %d",&n,&m);
    while(m--){
        int n1,n2;
        scanf("%d %d",&n1,&n2);
        v[n1].push_back(n2);
        v[n2].push_back(n1);
    }
    int cnt = 0;
    for(int i=1;i<=n;i++){
        if(!visit[i]){dfs(i);cnt++;}
    }
    printf("%d\n",--cnt);
    return 0;
}

Compiler output:
a.cc: In function 'void dfs(int)':
a.cc:6:8: error: reference to 'visit' is ambiguous
    6 |     if(visit[n])return;
      |        ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
                 from a.cc:1:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:4:6: note:                 'bool visit [101]'
    4 | bool visit[101];
      |      ^~~~~
a.cc:7:5: error: reference to 'visit' is ambiguous
    7 |     visit[n] = true;
      |     ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:4:6: note:                 'bool visit [101]'
    4 | bool visit[101];
      |      ^~~~~
a.cc: In function 'int main()':
a.cc:24:13: error: reference to 'visit' is ambiguous
   24 |         if(!visit[i]){dfs(i);cnt++;}
      |             ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:4:6: note:                 'bool visit [101]'
    4 | bool visit[101];
      |      ^~~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

vector<int> g[1e5+100];
bool used[1e5+100];
void dfs(int u) {
  used[u] = 1;
	for(auto to : g[u]) {
    	if(!used[to])
    		dfs(to);
    }
}

int main() {
	int n, m;
  cin>>n>>m;
  while(m--) {
  	int u, v;
    cin>>u>>v;
    --u,--v;
  g[u].push_back(v);
    g[v].push_back(u);
    
  }
	int res =0;
  for(int i =0 ; i < n; ++i) {
  	if(!used[i]) {
    		dfs(i);
      ++res;
    	}
  
  }
	cout<<res-1;
}

Compiler output:
a.cc:5:18: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
    5 | vector<int> g[1e5+100];
      |               ~~~^~~~
a.cc:5:18: error: could not convert '(1.0e+5 + (double)100)' from 'double' to 'long unsigned int'
    5 | vector<int> g[1e5+100];
      |               ~~~^~~~
      |                  |
      |                  double
a.cc:5:18: error: size of array 'g' has non-integral type 'double'
a.cc:6:14: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
    6 | bool used[1e5+100];
      |           ~~~^~~~
a.cc:6:14: error: could not convert '(1.0e+5 + (double)100)' from 'double' to 'long unsigned int'
    6 | bool used[1e5+100];
      |           ~~~^~~~
      |              |
      |              double
a.cc:6:14: error: size of array 'used' has non-integral type 'double'
Language: C

#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
 
using namespace std;
using ll = long long;

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int>> G(n);
    rep(i, m){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<int> dist(n, -1);
    queue<int> que;
    int count = 0;
    for (int v = 0; v < n; ++v) {
        if (dist[v] != -1) continue;
        dist[v] = 0, que.push(v);
        while (!que.empty()) {
            int v = que.front(); que.pop();
            for (auto nv : G[v]) {
                if (dist[nv] == -1) {
                    dist[nv] = dist[v] + 1;
                    que.push(nv);
                }
            }
        }
        ++count;
    }
    --count;
    if(count < 0) count = 0;
    cout << count << endl;
    return 0; 
}
 

Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <bits/stdc++.h>

using namespace std;
#define MAX 100000

int numOfConnectedComponents(bool adj[][]) {

	return 0;
}

int main() {
	int N, M;
	bool adj[MAX][MAX] = {0};

	cin >> N >> M;
	int ai, bi;
	for (int i = 0; i < M; ++i) {
		cin >> ai >> bi;

		adj[ai][bi] = 1;
		adj[bi][ai] = 1;
	}

	for (int i = 0; i < N; ++i) {
		adj[i][i] = 1;
	}


	return numOfConnectedComponents(adj) - 1;
}

Compiler output:
a.cc:7:35: error: declaration of 'adj' as multidimensional array must have bounds for all dimensions except the first
    7 | int numOfConnectedComponents(bool adj[][]) {
      |                                   ^~~