criyle/codenet-compile-errors huggingface dataset:
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:37: error: multidimensional array must have bounds for all dimensions except the first
    7 | int numOfConnectedComponents(bool[][] adj) {
      |                                     ^
a.cc:7:39: error: expected ',' or '...' before 'adj'
    7 | int numOfConnectedComponents(bool[][] adj) {
      |                                       ^~~
Language: C++

#include <bits/stdc++.h>
#include <atcoder/dsu>
using namespace std;
using namespace atcoder;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
//const int mod=998244353;
using P = pair<int,int>;
using Pl= pair<ll,ll>;
using ld=long double;
using V=vector<int>;
using Vl=vector<ll>;
using VV=vector<vector<int>>;
using VVl=vector<vector<ll>>;

int main() {
    int n,q;cin >>n>>q;
    dsu d(n);
    for (int i = 0; i < q; ++i) {
        int a,b;cin >>a>>b;
        a--;b--;
        d.merge(a,b);
    }
    vector<bool>ch(n,true);
    ll ans=-1;
    for (int i = 0; i < n; ++i) {
        if(ch[d.leader(i)]){
            ans++;
            ch[d.leader(i)]=false;
        }
    }
    cout <<ans<<"\n";
}

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

#include<bits/stdc++.h>
using namespace std;
void dfs(int u, vector<vector<int>> &graph, bool &visited[])
{
    visited[u] = true;
    for (auto v : graph[u])
    {
        if (!visited[v])
            dfs(v, graph, visited);
    }
}
int main()
{

    int n, m;
    cin >> n >> m;
    bool visited[n + 1];
  	for(int i=0;i<=n;i++)visited[i]=false;
    vector<vector<int>> graph(n + 1);
    for (int i = 1; i <= m; i++)
    {
        int u, v;
        cin >> u >> v;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }
    int count = 0;
    for (int i = 1; i <= n; i++)
    {
        if (!visited[i])
        {
           count++;
            dfs(i, graph, visited);
           
        }
    }
    cout << count - 1 << '\n';
}


Compiler output:
a.cc:3:51: error: declaration of 'visited' as array of references
    3 | void dfs(int u, vector<vector<int>> &graph, bool &visited[])
      |                                                   ^~~~~~~
a.cc: In function 'void dfs(...)':
a.cc:5:5: error: 'visited' was not declared in this scope
    5 |     visited[u] = true;
      |     ^~~~~~~
a.cc:5:13: error: 'u' was not declared in this scope
    5 |     visited[u] = true;
      |             ^
a.cc:6:19: error: 'graph' was not declared in this scope; did you mean 'isgraph'?
    6 |     for (auto v : graph[u])
      |                   ^~~~~
      |                   isgraph
Language: C++

#include<bits/stdc++.h>
using namespace std;
void dfs(int u, vector<vector<int>> &graph, bool visited[])
{
    visited[u] = true;
    for (auto v : graph[u])
    {
        if (!visited[v])
            dfs(v, graph, visited);
    }
}
int main()
{

    int n, m;
    cin >> n >> m;
    bool visited[n + 1];
  	for(int i=0;i<=n;i++}visited[i]=false;
    vector<vector<int>> graph(n + 1);
    for (int i = 1; i <= m; i++)
    {
        int u, v;
        cin >> u >> v;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }
    int count = 0;
    for (int i = 1; i <= n; i++)
    {
        if (!visited[i])
        {
            dfs(i, graph, visited);
            count++;
        }
    }
    cout << count - 1 << '\n';
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:29: error: expected ')' before '}' token
   18 |         for(int i=0;i<=n;i++}visited[i]=false;
      |            ~                ^
      |                             )
a.cc:18:29: error: expected primary-expression before '}' token
a.cc: At global scope:
a.cc:18:30: error: 'visited' does not name a type
   18 |         for(int i=0;i<=n;i++}visited[i]=false;
      |                              ^~~~~~~
a.cc:19:31: error: 'n' was not declared in this scope; did you mean 'yn'?
   19 |     vector<vector<int>> graph(n + 1);
      |                               ^
      |                               yn
a.cc:20:5: error: expected unqualified-id before 'for'
   20 |     for (int i = 1; i <= m; i++)
      |     ^~~
a.cc:20:21: error: 'i' does not name a type
   20 |     for (int i = 1; i <= m; i++)
      |                     ^
a.cc:20:29: error: 'i' does not name a type
   20 |     for (int i = 1; i <= m; i++)
      |                             ^
a.cc:28:5: error: expected unqualified-id before 'for'
   28 |     for (int i = 1; i <= n; i++)
      |     ^~~
a.cc:28:21: error: 'i' does not name a type
   28 |     for (int i = 1; i <= n; i++)
      |                     ^
a.cc:28:29: error: 'i' does not name a type
   28 |     for (int i = 1; i <= n; i++)
      |                             ^
a.cc:36:5: error: 'cout' does not name a type
   36 |     cout << count - 1 << '\n';
      |     ^~~~
a.cc:37:1: error: expected declaration before '}' token
   37 | }
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
void dfs(int u, vector<vector<int>> &graph, bool visited[])
{
    visited[u] = true;
    for (auto v : graph[u])
    {
        if (!visited[v])
            dfs(v, graph, visited);
    }
}
int main()
{

    int n, m;
    cin >> n >> m;
    vector<bool> visited(n+1,false);
    vector<vector<int>> graph(n + 1);
    for (int i = 1; i <= m; i++)
    {
        int u, v;
        cin >> u >> v;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }
    int count = 0;
    for (int i = 1; i <= n; i++)
    {
        if (!visited[i])
        {
            dfs(i, graph, visited);
            count++;
        }
    }
    cout << count - 1 << '\n';
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:27: error: cannot convert 'std::vector<bool>' to 'bool*'
   31 |             dfs(i, graph, visited);
      |                           ^~~~~~~
      |                           |
      |                           std::vector<bool>
a.cc:3:50: note:   initializing argument 3 of 'void dfs(int, std::vector<std::vector<int> >&, bool*)'
    3 | void dfs(int u, vector<vector<int>> &graph, bool visited[])
      |                                             ~~~~~^~~~~~~~~
Language: C++

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

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

int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    solve();
    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 <atcoder/dsu>
#include <iostream>
#include <vector>
using namespace std;
using namespace atcoder;

int main(){
    int n, m, a, b, ans = 0;
    cin >> n >> m;

    dsu d(n);
    for(int i = 0; i < m; ++i){
        cin >> a >> b;
        d.merge(a-1,b-1);
    }
    for(int i = 0;i < n-1; ++i){
        for(int j = i+1; j < n; ++j)
        if(d.same(i, j) == false){
            d.merge(i, j);
            ans++;
        }
    }
    cout << ans << endl;
}


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>
#include<atcoder/all>
using namespace std;
using namespace atcoder;

int main() {
	int n, m; cin >> n >> m;
	dsu d(n);
	while (m--) {
		int u, v; cin >> u >> v;
		d.merge(u, v);
	}
	cout << d.groups().size() - 1 << '\n';
	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, m; cin >> n >> m;
	dsu d(n);
	while (m--) {
		int u, v; cin >> u >> v;
		d.merge(u, v);
	}
	cout << d.groups().size() - 1 << '\n';
	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>
using namespace std;
#define ll long long

bool visit[100005];

vector<ll>xx[100005];

void check(ll ind)
{
    if(visit[ind]==1) return;
    visit[ind]=1;

    for (auto &it: xx[ind])
        if (!visit[it]) check(it) ;
}

int main()
{
    ll a,c,d,e,n,m,i,j,k=0;
    cin>>n>>m;
    for(i=0; i<m; i++)
    {
        cin>>a>>c;
        xx[a].push_back(c);
        xx[c].push_back(a);
    }

    for(j=1; j<=n; j++)
    {
        if(visit[j]==0)
        {
            k++;
            check(j);
        }
    }
    cout<<k-1<<endl;
}


Compiler output:
a.cc: In function 'void check(long long int)':
a.cc:11:8: error: reference to 'visit' is ambiguous
   11 |     if(visit[ind]==1) 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:5:6: note:                 'bool visit [100005]'
    5 | bool visit[100005];
      |      ^~~~~
a.cc:12:5: error: reference to 'visit' is ambiguous
   12 |     visit[ind]=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:15:14: error: reference to 'visit' is ambiguous
   15 |         if (!visit[it]) check(it) ;
      |              ^~~~~
/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 'int main()':
a.cc:31:12: error: reference to 'visit' is ambiguous
   31 |         if(visit[j]==0)
      |            ^~~~~
/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 rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
#define pll pair<ll,ll>
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
const ll mod2= 998244353;
using namespace std;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

const ll N=1100000;
struct UnionFind {
    //自身が親であれば、その集合に属する頂点数に-1を掛けたもの
    //そうでなければ親のid
    vector<int> r;
 
    UnionFind(int N) {
        r = vector<int>(N, -1);
    }
 
    int root(int x) {
        if (r[x] < 0) return x;
        return r[x] = root(r[x]);
    }
 
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (r[x] > r[y]) swap(x, y);
        r[x] += r[y];
        r[y] = x;
        return true;
    }
    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
 
    int size(int x) {
        return -r[root(x)];
    }
};
 
ll a[110000],b[110000];
int main(){
    ll N,M,ans=0;
    cin>>n>>M;
    UnionFind UF(N);
    for (int i = 0; i < M; i++)
    {
        int A, B;
        cin >> A >> B;
        UF.unite(A, B);
    }
    rep(i,1,n+1){
        if(UF.same(i,1)==false){
            ans++;
            UF.unite(i,1);
        }
    }
    cout<<ans<<endl;
   // rep(i,1,N+1)cout<<UF.root(i)<<endl;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:57:10: error: 'n' was not declared in this scope
   57 |     cin>>n>>M;
      |          ^
Language: C++

#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i,n) for (int i=0; i<(n); ++i)
#define per(i,n) for (int i=n-1; i>=0; --i)
#define all(a) a.begin(), a.end()
using namespace std;
using ll = long long;
using P  = pair<int,int>;
using vi = vector<int>;
using vv = vector<vi>;

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);
    }
	vv g = d.groups();
	cout << (int)g.size() -1 << 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>
using namespace std;
#define ll long long

bool visit[200005];

vector<ll>xx[200005];

void check(ll ind)
{
    if(visit[ind]==1) return;
    visit[ind]=1;

    for(ll i=0;i<xx[ind].size();i++)
    {
        ll nx=xx[ind][i];
        if(visit[nx]==0)
        {
            check(nx);
        }
    }
}

int main()
{
    ll a,c,d,e,n,m,i,j,k=0;
    cin>>n>>m;
    for(i=0;i<m;i++)
    {
        cin>>a>>c;
        xx[a].push_back(c);
        xx[c].push_back(a);
    }

    for(j=1;j<=n;j++)
    {
        if(visit[j]==0)
        {
            k++;
            check(j);
        }
    }
    cout<<k-1<<endl;
}


Compiler output:
a.cc: In function 'void check(long long int)':
a.cc:11:8: error: reference to 'visit' is ambiguous
   11 |     if(visit[ind]==1) 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:5:6: note:                 'bool visit [200005]'
    5 | bool visit[200005];
      |      ^~~~~
a.cc:12:5: error: reference to 'visit' is ambiguous
   12 |     visit[ind]=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 [200005]'
    5 | bool visit[200005];
      |      ^~~~~
a.cc:17:12: error: reference to 'visit' is ambiguous
   17 |         if(visit[nx]==0)
      |            ^~~~~
/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 [200005]'
    5 | bool visit[200005];
      |      ^~~~~
a.cc: In function 'int main()':
a.cc:37:12: error: reference to 'visit' is ambiguous
   37 |         if(visit[j]==0)
      |            ^~~~~
/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 [200005]'
    5 | bool visit[200005];
      |      ^~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
bool visit[200005];
vector<ll>xx[200005];

void check(ll ind)
{
    if(visit[ind]==1) return;
    visit[ind]=1;

    for(ll i=0;i<xx[ind].size();i++)
    {
        ll nx=xx[ind][i];
        if(visit[nx]==0)
        {
            check(nx);
        }
    }
}

int main()
{
    ll a,c,d,e,n,m,i,j,k=0;
    cin>>n>>m;
    for(i=0;i<m;i++)
    {
        cin>>a>>c;
        xx[a].push_back(c);
        xx[c].push_back(a);
    }

    for(j=1;j<=n;j++)
    {
        if(visit[j]==0)
        {
            k++;
            check(j);
        }
    }
    cout<<k-1<<endl;
}


Compiler output:
a.cc: In function 'void check(long long int)':
a.cc:10:8: error: reference to 'visit' is ambiguous
   10 |     if(visit[ind]==1) 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:5:6: note:                 'bool visit [200005]'
    5 | bool visit[200005];
      |      ^~~~~
a.cc:11:5: error: reference to 'visit' is ambiguous
   11 |     visit[ind]=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 [200005]'
    5 | bool visit[200005];
      |      ^~~~~
a.cc:16:12: error: reference to 'visit' is ambiguous
   16 |         if(visit[nx]==0)
      |            ^~~~~
/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 [200005]'
    5 | bool visit[200005];
      |      ^~~~~
a.cc: In function 'int main()':
a.cc:36:12: error: reference to 'visit' is ambiguous
   36 |         if(visit[j]==0)
      |            ^~~~~
/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 [200005]'
    5 | bool visit[200005];
      |      ^~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main() {
	// your code goes here
  long long n, m;
  cin >> n >> m;
  vector<vector<int>> ways;
  int num = 1;
  for(int i=0; i<m; i++){
    int a, b;
    cin >> a >> b;
    if(i == 0){
    	ways.at(0).push_back(a);
    	ways.at(0).push_back(b);
    }
    else{
	    bool isfound = false;
	    for(int j=0; j<num; j++){
	    	for(int x : ways.at(j)){
	    		if(a == x){
	    			ways.at(j).push_back(b);
	    			isfound = true;
	    			break;
	    		}
	    		if(b == x){
	    			ways.at(j).push_back(a);
	    			isfound = true;
	    			break;
	    		}
	    	}
	    	if(isfound){break;}
	    }
    }
    
    if(!isfound){
    	num++;
    	ways.push_back({a, b});
    }
  }
  
  cout << num-1 << endl;


	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:9: error: 'isfound' was not declared in this scope; did you mean 'round'?
   35 |     if(!isfound){
      |         ^~~~~~~
      |         round
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N,M,a,b;
  cin>>N>>M;
  vector<long long>A(N);
  long long ans=0;
  for(long long i=0;i<N;i++){
    A[i]=i+1;
  }
  for(long long i=0;i<M;i++){
    cin>>a>>b;
    if(A[b-1]*A[a-1]==0){
      A[b-1]=0;
      A[a-1]=0;
    }
    else{
      max(A[a-1],A[b-1])=0;
    }
  }
  sort(A.begin(),A.end());
  for(long long i=0;i<N-1;i++){
    if(A[i]!=A[i+1]){
      ans++;
    }
  }
  cout<<ans-1<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:25: error: assignment of read-only location 'std::max<long long int>((*(const long long int*)(& A.std::vector<long long int>::operator[](((std::vector<long long int>::size_type)(a - 1))))), (*(const long long int*)(& A.std::vector<long long int>::operator[](((std::vector<long long int>::size_type)(b - 1))))))'
   18 |       max(A[a-1],A[b-1])=0;
      |       ~~~~~~~~~~~~~~~~~~^~
Language: C++


#include<iostream>
#define ll long long
using namespace std;
int n,m,z[106666],x[106666],y[106666];
int f[106666];
int find(int x)//找爸爸 
{
    if(f[x]==x)
    {
        return x;
    }
    else
    {
        f[x]=find(f[x]);
    }
    return f[x];
}
bool cmp(ll a,ll b){return a>b;}
void work1(int x,int y)//合并
{
    f[find(y)]=find(x);
}
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)f[i]=i;
    for(int i=1;i<=m;i++){
        ll u,v;cin>>u>>v;
        work1(u,v);
    }
    for(int i=1;i<=n;i++)z[f[i]]+=1;
    ll maxv=0,p=0;
    ll cnt=0,last=0;
    sort(f+1,f+n+1);
    for(int i=1;i<=n;i++){
        if(z[i]>maxv){
            maxv=z[i];
            p=i;
        }
        if(f[i]!=f[i-1]){
            cnt++;
        }
    }
    cout<<cnt-1<<endl;
    return 0;//完结撒花
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   35 |     sort(f+1,f+n+1);
      |     ^~~~
      |     short
Language: C++

include <bits/stdc++.h>
using namespace std;
int main() {
  long long N,M,a,b;
  cin>>N>>M;
  vector<long long>A(N);
  long long ans=0;
  for(long long i=0;i<N;i++){
    A[i]=i+1;
  }
  for(long long i=0;i<M;i++){
    cin>>a>>b;
    if(A[b-1]*A[a-1]==0){
      A[b-1]=0;
      A[a-1]=0;
    }
    else{
      max(A[a-1],A[b-1])=0;
    }
  }
  sort(A.begin(),A.end());
  for(long long i=0;i<N-1;i++){
    if(A[i]!=A[i+1]){
      ans++;
    }
  }
  cout<<ans-1<<endl;
}

Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include <bits/stdc++.h>
      | ^~~~~~~
a.cc: In function 'int main()':
a.cc:5:3: error: 'cin' was not declared in this scope
    5 |   cin>>N>>M;
      |   ^~~
a.cc:6:3: error: 'vector' was not declared in this scope
    6 |   vector<long long>A(N);
      |   ^~~~~~
a.cc:6:10: error: expected primary-expression before 'long'
    6 |   vector<long long>A(N);
      |          ^~~~
a.cc:9:5: error: 'A' was not declared in this scope
    9 |     A[i]=i+1;
      |     ^
a.cc:13:8: error: 'A' was not declared in this scope
   13 |     if(A[b-1]*A[a-1]==0){
      |        ^
a.cc:18:7: error: 'max' was not declared in this scope
   18 |       max(A[a-1],A[b-1])=0;
      |       ^~~
a.cc:21:8: error: 'A' was not declared in this scope
   21 |   sort(A.begin(),A.end());
      |        ^
a.cc:21:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   21 |   sort(A.begin(),A.end());
      |   ^~~~
      |   short
a.cc:27:3: error: 'cout' was not declared in this scope
   27 |   cout<<ans-1<<endl;
      |   ^~~~
a.cc:27:16: error: 'endl' was not declared in this scope
   27 |   cout<<ans-1<<endl;
      |                ^~~~
Language: C++

#include <iostream>
#include <string>
#include <stdio.h>
#include <math.h>
#include <queue>
#include <algorithm>
#include <utility>
#include <vector>
#include <tuple>
#include <numeric>
using namespace std;

struct UnionFind{
	vector<int> parent;
	UnionFind(int N) : parent(N){
		for(int i=0; i<N; i++){
			parent[i] = i;
		}
	}
	int root(int x){
		if(parent[x]==x){
			return x;
		}else{
			return root(parent[x]);
		}
	}
	void unite(int x, int y){
		int rx = root(x);
		int ry = root(y);
		if(rx!=ry){
			parent[rx] = ry;
		}
	}
	bool same(int x, int y){
		int rx = root(x);
		int ry = root(y);
		return rx==ry;
	}
};

int main(int argc, char* argv[]){
	int N,M;
	scanf("%d %d", &N, &M);
	vector<int>A(M);
	vector<int>B(M);
	UnionFind tree(N);
	for(int i=0; i<M; i++){
		scanf("%d %d", &A[i], &B[i]);
		if(A[i]>B[i]){
			int tmp;
			tmp =  B[i];
			B[i] = A[i];
			A[i] = tmp;
		}
		tree.unite(A[i]-1, B[i]-1);
	}
	int count = 0;
	for(int i=0; i<N; i++){
//		printf("%d\n", tree.root(i));
	}
	for(int i=0; i<N; i++){
		if(tree.parent(i)==i){
			count++;
		}
	}
	printf("%d\n", count-1);

}



Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:62:31: error: no match for call to '(std::vector<int>) (int&)'
   62 |                 if(tree.parent(i)==i){
      |                    ~~~~~~~~~~~^~~
Language: C

#include<stdio.h>

int main(void){
  int N, M;
  scanf("%d %d", &N, &M);
  int t[N + 1];
  int a, b, sum = 0;
  for(int m = 0; m < M; m++){
    scanf("%d %d", &a, &b);
    if(t[b] == 0){
      t[b] = 1;
    }
  }
  for(int n = 2; n < N; n++){
    if(t[n] == 0){
      sum++;
    }
  }
  printf("%d\n", sum);
  return 0;


Compiler output:
main.c: In function 'main':
main.c:20:3: error: expected declaration or statement at end of input
   20 |   return 0;
      |   ^~~~~~
Language: C++

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

int main(){
    int n, m;
    cin >> n >> m;
    int count = 1;
    int cityNum = 1;
    int cityCount = n - 1;
    vector<vector<int>> path(m, vector<int>(2));
    for(int i = 0;i < m;i++){
        cin >> path.at(i).at(0) >> path.at(i).at(1);
    }
    vector<int> pBit(n);
    for(int i = 0;i < m;i++){
        if(pBit(path.at(i).at(0)) == 0){
            pBit(path.at(i).at(0)) = count;
            cityCount--;
        }
        else{
            int tmp = pBit(path.at(i).at(0));
            for(int j = 0;j < n;j++){
                if(pBit.at(j) == tmp){
                    pBit.at(j) = count;
                }
            }
        }
        count++;
    }
    cout << cityCount - count << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:16: error: no match for call to '(std::vector<int>) (__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   16 |         if(pBit(path.at(i).at(0)) == 0){
      |            ~~~~^~~~~~~~~~~~~~~~~~
a.cc:17:17: error: no match for call to '(std::vector<int>) (__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   17 |             pBit(path.at(i).at(0)) = count;
      |             ~~~~^~~~~~~~~~~~~~~~~~
a.cc:21:27: error: no match for call to '(std::vector<int>) (__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   21 |             int tmp = pBit(path.at(i).at(0));
      |                       ~~~~^~~~~~~~~~~~~~~~~~
Language: C

#include<stdio.h>

int main(void){
  int N, M;
  scanf("%d %d", &N, &M);
  int t[N + 1];
  int a, b, sum = 0;
  for(int m = 0, m < M; m++){
    scanf("%d %d", &a, &b);
    if(t[b] == 0){
      t[b] = 1;
    }
  }
  for(int n = 2; n < N; n++){
    if(t[n] == 0){
      sum++;
    }
  }
  printf("%d\n", sum);
  return 0;

Compiler output:
main.c: In function 'main':
main.c:8:20: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
    8 |   for(int m = 0, m < M; m++){
      |                    ^
main.c:8:28: error: expected ';' before ')' token
    8 |   for(int m = 0, m < M; m++){
      |                            ^
      |                            ;
main.c:20:3: error: expected declaration or statement at end of input
   20 |   return 0;
      |   ^~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main() {
	// your code goes here
  long long n, m;
  cin >> n >> m;
  vector<vector<int>> ways;
  int num = 1;
  for(int i=0; i<m; i++){
    int a, b;
    cin >> a >> b;
    bool isfound = false;
    for(int j=0; j<num; j++){
    	for(int x : ways.at(j)){
    		if(a == x){
    			ways.at(j).push_back(b);
    			isfound = true;
    			break;
    		}
    		if(b == x){
    			ways.at(j).push_back(a);
    			isfound = true
    			break;
    		}
    	}
    	if(isfound){break;}
    }
    
    if(!isfound){
    	num++;
    	ways.push_back({a, b});
    }
  }
  
  cout << num-1 << endl;


	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:39: error: expected ';' before 'break'
   22 |                         isfound = true
      |                                       ^
      |                                       ;
   23 |                         break;
      |                         ~~~~~
Language: C++

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

int hensuhojo(vector<vector<int>> &data,int kazu,int matomari,vector<bool> &ceck);

void hensu(vector<vector<int>> &data,int kazu,vector<bool> &ceck){
    
    
    ceck.at(kazu)=false;
    
    
    for(int x:data.at(kazu)){
        if(ceck.at(kazu)==true){
            hensu(data,x,ceck);
        }
    }
    return;
    
}
int hensuhojo(vector<vector<int>> &data,int matomari,vector<bool> &ceck,int n1){
    matomari++;
    for(int i=0;i<n1;i++){
        if(ceck.at(i)==true){
            
            hensu(data,i,ceck);
        }
    }
    return matomari;
}
    



int main(void){
    
    int n,m;
    cin>>n>>m;
    vector<vector<int>> data(n,vector<int>(100000));
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        data.at(a).push_back(b);
        data.at(b).push_back(a);
    }
    vector<bool> ceck(n,true);
    cout<<hensuhojo(data,0,1,ceck,n)-1<<endl;
    
    
}


Compiler output:
a.cc: In function 'int main()':
a.cc:46:20: error: no matching function for call to 'hensuhojo(std::vector<std::vector<int> >&, int, int, std::vector<bool>&, int&)'
   46 |     cout<<hensuhojo(data,0,1,ceck,n)-1<<endl;
      |           ~~~~~~~~~^~~~~~~~~~~~~~~~~
a.cc:4:5: note: candidate: 'int hensuhojo(std::vector<std::vector<int> >&, int, int, std::vector<bool>&)'
    4 | int hensuhojo(vector<vector<int>> &data,int kazu,int matomari,vector<bool> &ceck);
      |     ^~~~~~~~~
a.cc:4:5: note:   candidate expects 4 arguments, 5 provided
a.cc:20:5: note: candidate: 'int hensuhojo(std::vector<std::vector<int> >&, int, std::vector<bool>&, int)'
   20 | int hensuhojo(vector<vector<int>> &data,int matomari,vector<bool> &ceck,int n1){
      |     ^~~~~~~~~
a.cc:20:5: note:   candidate expects 4 arguments, 5 provided
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >> n>> m;
  int a[m][2];
  for(int i=0;i<m;i++){
    cin >> a[i][0] >> a[i][1];
  }
  int a=0;
  for(int i=0;i<m;i++){
    for(int j=1;j<m-i;j++){
      if(a[i][0]==a[j][1] || a[i][0]==a[j][0]){
        a++;
      }
    }
    cout << n-1+a-m << endl;
  }
}
  


Compiler output:
a.cc: In function 'int main()':
a.cc:10:7: error: conflicting declaration 'int a'
   10 |   int a=0;
      |       ^
a.cc:6:7: note: previous declaration as 'int a [m][2]'
    6 |   int a[m][2];
      |       ^
a.cc:14:9: error: lvalue required as increment operand
   14 |         a++;
      |         ^
Language: C++


#include<iostream>
#define ll long long
using namespace std;
int n,m,z[106666],x[106666],y[106666];
int f[106666];
int find(int x)//找爸爸 
{
    if(f[x]==x)
    {
        return x;
    }
    else
    {
        f[x]=find(f[x]);
    }
    return f[x];
}
bool cmp(ll a,ll b){return a>b;}
void work1(int x,int y)//合并
{
    f[find(y)]=find(x);
}
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)f[i]=i;
    for(int i=1;i<=m;i++){
        ll u,v;cin>>u>>v;
        work1(u,v);
    }
    for(int i=1;i<=n;i++)z[f[i]]+=1;
    sort(z+1,z+n+1,cmp);
    ll ans=0;
    for(int i=2;i<=n;i++)ans+=z[i];
    cout<<ans<<endl;
    return 0;//完结撒花
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   33 |     sort(z+1,z+n+1,cmp);
      |     ^~~~
      |     short
Language: C++

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

int main(){
  
  int n, m;
  
  cin >> n >> m;
  
  for (int i = 0; i < m; i++){
    
    int a, b;
    
    cin >> a >> b;
    
  }
  
  cout << n - m - 1 << endl;
  
  }
    
  
}

Compiler output:
a.cc:23:1: error: expected declaration before '}' token
   23 | }
      | ^
Language: C++

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

int main(){
  
  int n, m;
  
  cin >> n >> m;
  
  cout << n - m - 1 << endl;
  
  }
    
  
}

Compiler output:
a.cc:15:1: error: expected declaration before '}' token
   15 | }
      | ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main() {
	// your code goes here
  long long n, m;
  cin >> n >> m;
  vector<vector<int>> ways;
  int num = 1;
  for(int i=0; i<m; i++){
    int a, b;
    cin >> a >> b;
    bool isfound = false;
    for(int j=0; j<num; j++){
    	for(int x : ways.at(j)){
    		if(a == x){
    			ways.at(j).push(b);
    			isfound = true;
    			break;
    		}
    		if(b == x){
    			ways.at(j).push(a);
    			isfound = true
    			break;
    		}
    	}
    	if(isfound){break;}
    }
    
    if(!isfound){
    	num++;
    	ways.push({a, b});
    }
  }
  
  cout << num-1 << endl;


	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:36: error: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'class std::vector<int>'} has no member named 'push'
   16 |                         ways.at(j).push(b);
      |                                    ^~~~
a.cc:21:36: error: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'class std::vector<int>'} has no member named 'push'
   21 |                         ways.at(j).push(a);
      |                                    ^~~~
a.cc:22:39: error: expected ';' before 'break'
   22 |                         isfound = true
      |                                       ^
      |                                       ;
   23 |                         break;
      |                         ~~~~~          
a.cc:31:14: error: 'class std::vector<std::vector<int> >' has no member named 'push'
   31 |         ways.push({a, b});
      |              ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main() {
	// your code goes here
  long long n, m;
  cin >> n >> m;
  vactor<vector<int>> ways;
  int num = 1;
  for(int i=0; i<m; i++){
    int a, b;
    cin >> a >> b;
    bool isfound = false;
    for(int j=0; j<num; j++){
    	for(int x : ways.at(j)){
    		if(a == x){
    			ways.at(j).push(b);
    			isfound = true;
    			break;
    		}
    		if(b == x){
    			ways.at(j).push(a);
    			isfound = true
    			break;
    		}
    	}
    	if(isfound){break;}
    }
    
    if(!isfound){
    	num++;
    	ways.push({a, b});
    }
  }
  
  cout << num-1 << endl;


	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:3: error: 'vactor' was not declared in this scope
    7 |   vactor<vector<int>> ways;
      |   ^~~~~~
a.cc:7:20: error: expected primary-expression before '>' token
    7 |   vactor<vector<int>> ways;
      |                    ^~
a.cc:7:23: error: 'ways' was not declared in this scope
    7 |   vactor<vector<int>> ways;
      |                       ^~~~
a.cc:22:39: error: expected ';' before 'break'
   22 |                         isfound = true
      |                                       ^
      |                                       ;
   23 |                         break;
      |                         ~~~~~
Language: C++

#include <bits/stdc++.h>
#include <atcoder/dsu>
using namespace std;
using namespace atcoder;
int main()
{
    int n, m, a, b, ans, cnt = 0;
    cin >> n >> m;
    //n頂点0辺の無向グラフを作ります。
    dsu d(n);
    vector<int> vec(n, 0);
    
    //辺a,bを連結
    for (int i = 0; i < m; i++){
        cin >> a >> b;
        d.merge(a,b);
    }
    for(int i=0;i<n;i++){
        vec.at(d.leader(i))=1;
        if(vec.at(i)==1){
            cnt++;
        }
    }
    ans=cnt-1;
    cout << ans;
}

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

import java.util.*;
import java.io.*;

public class Main{
	private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	private static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
    
    LinkedList<Integer> adj[]; 
    boolean visited[];

    C(int v){
        visited = new boolean[v];
        this.adj = new LinkedList[v]; 
        for (int i=0; i<v; i++){
            adj[i] = new LinkedList<Integer>(); 
        }
    }

    void addEdge(int v, int w) 
    { 
        adj[v].add(w);
    } 

    
    void DFS(int v){
        visited[v] = true;
        Iterator<Integer> i = adj[v].listIterator(); 
        while(i.hasNext()){ 
            int n = i.next(); 
            if (!visited[n]) 
                DFS(n); 
        } 
    } 
    
    int notConnected(int v){
        int count = 0;
        for (int i = 0; i < v; ++i){
            if (!visited[i]){
                count++;
            }
        }  
        return count;
    }

	public static void main (String[] args) throws IOException{
        String nm[] = br.readLine().split(" ");
        int n = Integer.parseInt(nm[0]);
        int m = Integer.parseInt(nm[1]);

        C g = new C(n); 
  
        for(int i=0;i<m;i++){
            String ip[] = br.readLine().split(" ");
            g.addEdge(Integer.parseInt(ip[0]), Integer.parseInt(ip[1])); 
        }
        g.DFS(1);
        bw.write(g.notConnected(n) + "\n");
        bw.flush();
    }    
}


Compiler output:
Main.java:11: error: invalid method declaration; return type required
    C(int v){
    ^
1 error
Language: C++

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

#define for_(i, a, b) for(int i = (a); i < (b); ++i)
#define rfor_(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define rep(i, n) for_(i, 0, n)
#define rrep(i, n) rfor_(i, 0, n)

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int d[5] = {0, 1, 0, -1, 0};

using namespace std;
using namespace atcoder;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    dsu d(N);
    ll Ans;
    int temp1, temp2;
    rep(i, M) {
        cin >> temp1 >> temp2;
        d.merge(temp1, temp2);
    }
    vector<vector<int>> group = d.groups();
    cout << group.size() - 1 << endl;
}


Compiler output:
a.cc:1:23: warning: extra tokens at end of #include directive
    1 | #include <atcoder/all>;
      |                       ^
a.cc:1:10: fatal error: atcoder/all: No such file or directory
    1 | #include <atcoder/all>;
      |          ^~~~~~~~~~~~~
compilation terminated.
Language: C++

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

#define for_(i, a, b) for(int i = (a); i < (b); ++i)
#define rfor_(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define rep(i, n) for_(i, 0, n)
#define rrep(i, n) rfor_(i, 0, n)

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int d[5] = {0, 1, 0, -1, 0};

using namespace std;
using namespace atcoder;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    dsu d(N);
    ll Ans;
    int temp1, temp2;
    rep(i, M) {
        cin >> temp1 >> temp2;
        d.merge(temp1, temp2);
    }
    vector<vector<int>> group = d.groups();
    cout << group.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 N,M;cin>>N>>M;
  dsu X(N);
  for(int i=0;i<M;i++){
    int A,B;cin>>A>>B;
    X.merge(A-1,B-1);
  }
  int count=0;
  for(int i=1;i<=N;i++){
    if(X.size(i)==N-1) continue;
    else{
      for(int j=i+1;j<=N;j++){
        if(!X.same(i,j)){
          X.merge(i,j);
          count++;
        }
      }
    }
  } 
  cout<<count<<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<vector>
using namespace std;
using namespace atcoder;
using ll = long long;
using P = pair<int, int>;

int main(){
    int N, M;
    cin >> N >> M;
    dsu d(N);
    int A[N], B[N];
    for(int i=0; i<M; i++){
        cin >> A[i] >> B[i];
        d.merge(A[i], B[i]);
    }

    int lead[N];
    ll ans=0;
    lead[0] = d.leader(1);
    for(int i=0; i<N; i++){
        lead[i] = d.leader(i+1);
        if(lead[0] !=lead[i]){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

#ifndef ATCODER_DSU_HPP
#define ATCODER_DSU_HPP 1

#include <algorithm>
#include <cassert>
#include <vector>

namespace atcoder {

// Implement (union by size) + (path compression)
// Reference:
// Zvi Galil and Giuseppe F. Italiano,
// Data structures and algorithms for disjoint set union problems
struct dsu {
  public:
    dsu() : _n(0) {}
    dsu(int n) : _n(n), parent_or_size(n, -1) {}

    int merge(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        int x = leader(a), y = leader(b);
        if (x == y) return x;
        if (-parent_or_size[x] < -parent_or_size[y]) std::swap(x, y);
        parent_or_size[x] += parent_or_size[y];
        parent_or_size[y] = x;
        return x;
    }

    bool same(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        return leader(a) == leader(b);
    }

    int leader(int a) {
        assert(0 <= a && a < _n);
        if (parent_or_size[a] < 0) return a;
        return parent_or_size[a] = leader(parent_or_size[a]);
    }

    int size(int a) {
        assert(0 <= a && a < _n);
        return -parent_or_size[leader(a)];
    }

    std::vector<std::vector<int>> groups() {
        std::vector<int> leader_buf(_n), group_size(_n);
        for (int i = 0; i < _n; i++) {
            leader_buf[i] = leader(i);
            group_size[leader_buf[i]]++;
        }
        std::vector<std::vector<int>> result(_n);
        for (int i = 0; i < _n; i++) {
            result[i].reserve(group_size[i]);
        }
        for (int i = 0; i < _n; i++) {
            result[leader_buf[i]].push_back(i);
        }
        result.erase(
            std::remove_if(result.begin(), result.end(),
                           [&](const std::vector<int>& v) { return v.empty(); }),
            result.end());
        return result;
    }

  private:
    int _n;
    // root node: -1 * component size
    // otherwise: parent
    std::vector<int> parent_or_size;
};

}  // namespace atcoder

#endif  // ATCODER_DSU_HPP

Compiler output:
a.cc:4:17: error: 'atcoder' is not a namespace-name
    4 | using namespace atcoder;
      |                 ^~~~~~~
a.cc: In function 'int main()':
a.cc:11:5: error: 'dsu' was not declared in this scope
   11 |     dsu d(N);
      |     ^~~
a.cc:15:9: error: 'd' was not declared in this scope
   15 |         d.merge(A[i], B[i]);
      |         ^
a.cc:20:15: error: 'd' was not declared in this scope
   20 |     lead[0] = d.leader(1);
      |               ^
Language: C++

#include<bits/stdc++.h>
#include<vector>
#include<atcoder/dsu.hpp>
using namespace std;
using namespace atcoder;
using ll = long long;
using P = pair<int, int>;

int main(){
    int N, M;
    cin >> N >> M;
    dsu d(N);
    int A[N], B[N];
    for(int i=0; i<M; i++){
        cin >> A[i] >> B[i];
        d.merge(A[i], B[i]);
    }

    int lead[N];
    ll ans=0;
    lead[0] = d.leader(1);
    for(int i=0; i<N; i++){
        lead[i] = d.leader(i+1);
        if(lead[0] !=lead[i]){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

#ifndef ATCODER_DSU_HPP
#define ATCODER_DSU_HPP 1

#include <algorithm>
#include <cassert>
#include <vector>

namespace atcoder {

// Implement (union by size) + (path compression)
// Reference:
// Zvi Galil and Giuseppe F. Italiano,
// Data structures and algorithms for disjoint set union problems
struct dsu {
  public:
    dsu() : _n(0) {}
    dsu(int n) : _n(n), parent_or_size(n, -1) {}

    int merge(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        int x = leader(a), y = leader(b);
        if (x == y) return x;
        if (-parent_or_size[x] < -parent_or_size[y]) std::swap(x, y);
        parent_or_size[x] += parent_or_size[y];
        parent_or_size[y] = x;
        return x;
    }

    bool same(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        return leader(a) == leader(b);
    }

    int leader(int a) {
        assert(0 <= a && a < _n);
        if (parent_or_size[a] < 0) return a;
        return parent_or_size[a] = leader(parent_or_size[a]);
    }

    int size(int a) {
        assert(0 <= a && a < _n);
        return -parent_or_size[leader(a)];
    }

    std::vector<std::vector<int>> groups() {
        std::vector<int> leader_buf(_n), group_size(_n);
        for (int i = 0; i < _n; i++) {
            leader_buf[i] = leader(i);
            group_size[leader_buf[i]]++;
        }
        std::vector<std::vector<int>> result(_n);
        for (int i = 0; i < _n; i++) {
            result[i].reserve(group_size[i]);
        }
        for (int i = 0; i < _n; i++) {
            result[leader_buf[i]].push_back(i);
        }
        result.erase(
            std::remove_if(result.begin(), result.end(),
                           [&](const std::vector<int>& v) { return v.empty(); }),
            result.end());
        return result;
    }

  private:
    int _n;
    // root node: -1 * component size
    // otherwise: parent
    std::vector<int> parent_or_size;
};

}  // namespace atcoder

#endif  // ATCODER_DSU_HPP

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

#include <bits/stdc++.h>

#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i, ss, ee) for (int i = (ss); i < (ee); ++i)

void solve() {
  int N, M;
  cin >> N >> M;
  dsu ds(N);

  rep(i, 0, M) {
    int u, v;
    cin >> u >> v;
    ds.merge(u, v);
  }
  cout << ds.groups().size() - 1 << endl;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  solve();
}

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<vector>
#include<atcoder/dsu.hpp>
using namespace std;
using namespace atcoder;
using ll = long long;
using P = pair<int, int>;

int main(){
    int N, M;
    cin >> N >> M;
    dsu d(N);
    int A[N], B[N];
    for(int i=0; i<M; i++){
        cin >> A[i] >> B[i];
        d.merge(A[i], B[i]);
    }

    int lead[N];
    ll ans=0;
    lead[0] = d.leader(1);
    for(int i=0; i<N; i++){
        lead[i] = d.leader(i+1);
        if(lead[0] !=lead[i]){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

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