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

void init(int n){
	for (int i = 0; i < n; i++){
		par[i] = i;
		rank[i] = 0;
	}
}

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

void unite(int x, int y){
	x = find(x);
	y = find(y);
	if (x == y)return;

	if (rank[x] < rank[y]){
		par[x] = y;
	}
	else{
		par[y] = x;
		if (rank[x] == rank[y])rank[x]++;
	}
}

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

Compiler output:
a.cc: In function 'void init(int)':
a.cc:3:17: error: 'par' was not declared in this scope
    3 |                 par[i] = i;
      |                 ^~~
a.cc:4:17: error: 'rank' was not declared in this scope
    4 |                 rank[i] = 0;
      |                 ^~~~
a.cc: In function 'int find(int)':
a.cc:9:13: error: 'par' was not declared in this scope
    9 |         if (par[x] == x){
      |             ^~~
a.cc: In function 'void unite(int, int)':
a.cc:22:13: error: 'rank' was not declared in this scope
   22 |         if (rank[x] < rank[y]){
      |             ^~~~
a.cc:23:17: error: 'par' was not declared in this scope
   23 |                 par[x] = y;
      |                 ^~~
a.cc:26:17: error: 'par' was not declared in this scope
   26 |                 par[y] = x;
      |                 ^~~
Language: C++

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

class UF{
private:
    vector<int> par,rank;
    //    vector<int> size;
    int _size;
    int groups;
public:
    
    UF(int __size):_size(__size) , par(__size) , rank(__size,0) ,groups(1){
        for(int i=0;i<__size;i++)par[i]=i;
    }
    
    int size(){
        return _size;
    }
    
    int find(int x){
        if(par[x]==x) {
            return x;
        }else{
            return par[x]=find(par[x]);
        }
    }
    
    void unite(int x,int y){
        x=find(x);
        y=find(y);
        if(x==y) return;
        
        if(rank[x]<rank[y]){
            par[x]=y;
        }else{
            par[y]=x;
            if(rank[x]==rank[y])rank[x]++;
        }
    }
};


int main(){
    UF<int> uf(100);    //100 elements
}

Compiler output:
a.cc: In function 'int main()':
a.cc:44:5: error: 'UF' is not a template
   44 |     UF<int> uf(100);    //100 elements
      |     ^~
Language: C++

#include <iostream>

using namespace std;

struct unionfind {
	vector<int> data;
	unionfind(int size) : data(size, -1) { }
	bool Union(int x, int y) {
		x = root(x);
		y = root(y);
		if (x != y) {
			if (data[y] < data[x])
				swap(x, y);
			data[x] += data[y];
			data[y] = x;
		}
		return x != y;
	}
	bool Find(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};



int main()
{
	int n,q,com,x,y;
	cin >> n >> q;
	unionfind a(n);
	for (int i = 0; i < q; i++) {
		cin >> com >> x >> y;
		if (com == 0) {
			a.Union(x,y);
		}
		else {
			cout << a.Find(x, y) << endl;;
		}
	}
	return 0;
}

Compiler output:
a.cc:6:9: error: 'vector' does not name a type
    6 |         vector<int> data;
      |         ^~~~~~
a.cc: In constructor 'unionfind::unionfind(int)':
a.cc:7:31: error: class 'unionfind' does not have any field named 'data'
    7 |         unionfind(int size) : data(size, -1) { }
      |                               ^~~~
a.cc: In member function 'bool unionfind::Union(int, int)':
a.cc:12:33: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   12 |                         if (data[y] < data[x])
      |                                 ^
a.cc:12:43: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   12 |                         if (data[y] < data[x])
      |                                           ^
a.cc:14:29: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   14 |                         data[x] += data[y];
      |                             ^
a.cc:14:40: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   14 |                         data[x] += data[y];
      |                                        ^
a.cc:15:29: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   15 |                         data[y] = x;
      |                             ^
a.cc: In member function 'int unionfind::root(int)':
a.cc:23:28: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   23 |                 return data[x] < 0 ? x : data[x] = root(data[x]);
      |                            ^
a.cc:23:46: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   23 |                 return data[x] < 0 ? x : data[x] = root(data[x]);
      |                                              ^
a.cc:23:61: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   23 |                 return data[x] < 0 ? x : data[x] = root(data[x]);
      |                                                             ^
a.cc: In member function 'int unionfind::size(int)':
a.cc:26:29: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   26 |                 return -data[root(x)];
      |                             ^
Language: C++

#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};
//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	int N, Q; cin >> N >> Q;
	UnionFind uf(N);
	long long int sum = 0;
	for (int i = 0; i < Q; ++i) {
		string st; cin >> st;
		int x, y; cin >> x >> y;
		if (st == "unite") {
			uf.unionSet(x, y);
		}
		else {
			cout << (uf.root(x) == uf.root(y))?1:0 << endl;
		}

	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:44:64: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<<'
   44 |                         cout << (uf.root(x) == uf.root(y))?1:0 << endl;
      |                                                              ~~^~~~~~~
Language: C++

#include <iostream>
#include <vector>

using namespace std;

class DisjointSet {
	public:
		vector<int> rank, p;

    DisjointSet(){}
    DisjointSet(int size){
      rank.resize(size, 0);
      p.resize(size, 0);
      for (int i = 0; i < size; ++i)
      {
        makeSet(i);
      }
    }

    void makeSet(int x){
      p[x] = x;
      rank[x] = 0;
    }

    void unite(int x, int y){
      link(findSet(x), findSet(y));
    }

    void link(int x, int y){
      if (rank[x] > rank[y])
      {
        p[y] = x;
      }else{
        p[x] = y;
        if (rank[x] == rank[y])
        {
          rank[y]++;
        }
      }
    }

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

    int findSet(int x){
      if(p[x] != x){
        p[x] = findSet(p[x]);
      }
      return p[x];
    }
}

int main(){
  int n, q;
  int com, x, y;
  cin >> n >> q;
  DisjointSet ds = DisjointSet(n);

  for (int i = 0; i < q; ++i)
  {
    cin >> com >> x >> y;
    if(com == 0){
      ds.unite(x, y);
    } else if( com == 1){
      if(ds.same(x, y)){
        cout << 1 << endl;
      } else {
        cout << 0 << endl;
      }
    }
  }

}

Compiler output:
a.cc:52:2: error: expected ';' after class definition
   52 | }
      |  ^
      |  ;
Language: C++

#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;


static const int MAX_NUM = 10001;

int FindRoot(vector<int> &elem, int target)
{
    int parent;

    parent = target;
    for (;;) {
        if (parent == elem[parent]) {
            break;
        }
        else {
            parent = elem[parent];
        }
    }

    return parent;
}

void Unite(vector<int> &elem, int t1, int t2)
{
    int p1, p2;

    p1 = FindRoot(elem, t1);
    p2 = FindRoot(elem, t2);

    elem[p2] = p1;

    return;
}

bool Same(voctor<int> &elem, int t1, int t2)
{
    bool ret;
    int p1, p2;

    p1 = FindRoot(elem, t1);
    p2 = FindRoot(elem, t2);

    if (p1 == p2) {
        ret = true;
    }
    else {
        ret = false;
    }

    return ret;
}

int main(void)
{
    int i;
    int num, qnum;
    int q;
    int t1, t2;
    vector<int> elem;

    scanf("%d %d", &num, &qnum);
    elem.resize(num);
    for (i = 1; i <= num; i++) {
        elem[i] = i;
    }

    for (i = 0; i < qnum; i++) {
        scanf("%d %d %d", &q, &t1, &t2);
        switch (q) {
        case 0 :
            Unite(elem, t1, t2);
            break;
        case 1 :
            if (Same(elem, t1, t2) == true) {
                printf("1\n");
            }
            else {
                printf("0\n");
            }
            break;
        default :
            break;
        }
    }
    return 0;
}

Compiler output:
a.cc:38:11: error: 'voctor' was not declared in this scope
   38 | bool Same(voctor<int> &elem, int t1, int t2)
      |           ^~~~~~
a.cc:38:18: error: expected primary-expression before 'int'
   38 | bool Same(voctor<int> &elem, int t1, int t2)
      |                  ^~~
a.cc:38:30: error: expected primary-expression before 'int'
   38 | bool Same(voctor<int> &elem, int t1, int t2)
      |                              ^~~
a.cc:38:38: error: expected primary-expression before 'int'
   38 | bool Same(voctor<int> &elem, int t1, int t2)
      |                                      ^~~
a.cc:38:44: error: expression list treated as compound expression in initializer [-fpermissive]
   38 | bool Same(voctor<int> &elem, int t1, int t2)
      |                                            ^
a.cc: In function 'int main()':
a.cc:77:21: error: 'Same' cannot be used as a function
   77 |             if (Same(elem, t1, t2) == true) {
      |                 ~~~~^~~~~~~~~~~~~~
Language: C++

include<iostream>
#define MAXN 100000+10
using namespace std;
int par[MAXN];
int rank[MAXN];
int re[MAXN];
int n,q;
void init(){
	int i;
	for (i = 0;i < n;++i){
		rank[i]=0;
		par[i]=i;
	}
}

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

void unite(int x,int y){
	x=find(x);
	y=find(y);
	if (x == y) return;
	if (rank[x] < rank[y]) par[x]=par[y];
	else par[y]=par[x];
	if (rank[x] == rank[y]) rank[x]++;
	
}

int main(){
	int a,b,ord,i;
	int tot=0,p1,p2;
	cin>>n>>q;
	init(); 
	for (i = 0;i < q;++i){
		cin>>ord;
		cin>>a>>b;
		if (ord == 0){
			unite(min(a,b),max(a,b));
		}
		else if (ord == 1){
			p1=find(a);
			p2=find(b);
			if (p1 == p2) re[tot++]=1;
			else re[tot++]=0;
		}
	}
	for (i = 0;i < tot;++i)
		cout<<re[i]<<endl;
	return 0;
} 

Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include<iostream>
      | ^~~~~~~
a.cc: In function 'int main()':
a.cc:34:9: error: 'cin' was not declared in this scope
   34 |         cin>>n>>q;
      |         ^~~
a.cc:40:31: error: 'min' was not declared in this scope; did you mean 'main'?
   40 |                         unite(min(a,b),max(a,b));
      |                               ^~~
      |                               main
a.cc:40:40: error: 'max' was not declared in this scope
   40 |                         unite(min(a,b),max(a,b));
      |                                        ^~~
a.cc:50:17: error: 'cout' was not declared in this scope
   50 |                 cout<<re[i]<<endl;
      |                 ^~~~
a.cc:50:30: error: 'endl' was not declared in this scope
   50 |                 cout<<re[i]<<endl;
      |                              ^~~~
Language: C++

#include<iostream>
using namespace std;
int p[10010];
void init(int n)
{
    for(int i=0;i<=n;i++)
        p[i]=i;
};
int root(int a)
{
    if(p[a]==a)
        return a;
    return (p[a]=root(p[a]));
};
bool is_same_set(int a,int b)
{
    return root(a)==root(b);
};
void unite(int a,int b)
{
    p[root(a)]=root(b)
};
int main()
{
    int n,q;
    cin>>n>>q;
    init(n);
    for(int i=0;i<q;i++)
    {
        int cmd,a,b;
        cin>>cmd>>a>>b;
        if(cmd==0)
        {
            unite(a,b);
        }
        else
        {
            cout<<is_same_set(a,b)<<endl;
        }
    }
}

Compiler output:
a.cc: In function 'void unite(int, int)':
a.cc:21:23: error: expected ';' before '}' token
   21 |     p[root(a)]=root(b)
      |                       ^
      |                       ;
   22 | };
      | ~
Language: C++


#include <vector>

class union_find
{
private:
	std::vector<int>parent;
	std::vector<int>rank;
public:
	union_find(int siz)
	{
		parent.resize(siz);
		rank.resize(siz);
		for (int i = 0; i < siz; ++i)
		{
			parent[i] = i;
			rank[i] = 0;
		}
	}
	void unite(int x, int y)
	{
		int xr = find(x);
		int yr = find(y);
		if (rank[xr] > rank[yr])
		{
			parent[yr] = xr;
		}
		else if (rank[xr] > rank[yr])
		{
			parent[xr] = yr;
		}
		else if (xr != yr)
		{
			parent[yr] = xr;
			++rank[xr];
		}
	}
	int find(int x)
	{
		if (parent[x] == x)
		{
			return x;
		}
		else
		{
			return parent[x] = find(parent[x]);
		}
	}
	bool check(int x, int y)
	{
		return find(x) == find(y);
	}
};

int n;
int q;

int main()
{
	scanf("%d", &n);
	scanf("%d", &q);
	union_find uf(n);
	for (int i = 0; i < q; ++i)
	{
		int c, x, y;
		scanf("%d %d %d", &c, &x, &y);
		if (c == 0)
		{
			uf.unite(x, y);
		}
		else
		{
			if (uf.check(x, y))
			{
				printf("1\n");
			}
			else
			{
				printf("0\n");
			}
		}
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:60:9: error: 'scanf' was not declared in this scope
   60 |         scanf("%d", &n);
      |         ^~~~~
a.cc:75:33: error: 'printf' was not declared in this scope
   75 |                                 printf("1\n");
      |                                 ^~~~~~
a.cc:3:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
    2 | #include <vector>
  +++ |+#include <cstdio>
    3 | 
a.cc:79:33: error: 'printf' was not declared in this scope
   79 |                                 printf("0\n");
      |                                 ^~~~~~
a.cc:79:33: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
Language: C++

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>

#define INF_LL 9000000000000000000
#define INF 2000000000

#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

class Union_find{
private:
	vector<int> par;
	int size;
public:
	Union_find(int n){
		size = n;
		REP(i, n){
			par.push_back(i);
		}
	}

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

		return par[x] = find(par[x]);
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		par[x] = y;
	}

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

int main(void){
	int n, q;
	cin >> n >> q;
	Union_find uf(n);
	
	REP(i, q){
		int com, x, y;
		cin >> com >> x >> y;
		if(com == 0){
			uf.unite(x, y);
		}else{
			if(uf.same(x, y)){
				cout << 1 << endl;
			}else{
				cout << 0 << endl;
			}
		}
	}
	return 0;
}

Compiler output:
a.cc:53:2: error: expected ';' after class definition
   53 | }
      |  ^
      |  ;
Language: C++

#include<iostream>
#include<vector>

using namespace std;

class DisjointSet{
  public:
  vector<int> rank, p;

  DisjointSet{}
  DisjointSet(int size){
    rank.resize(size, 0);
    p.resize(size, 0);
    for(int i=0; i<size; i++) makeSet(i);
  }

  void makeSet(int x){
    p[x] = x;
    rank[x] = 0;
  }

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

  void link(int x, int y){
    if(rank[x] > rank[y]){
      p[y] = x;
    }else{
      p[x] = y;
      if(rank[x] == rank[y]){
        rank[y]++
      }
    }
  }

  int findSet(int x){
    if(x != p[x]){
      p[x] = fibdSet(p[x]);
    }
    return p[x];
  }
};

int main(){
  int n, a, b, q;
  int t;

  cin >> n >> q;
  DisjointSet ds = DisjointSet(n);
 
  for(int i=0; i<q; i++){
    cin >> t >> a >> b;
    if(t == 0) ds.unite(a, b);
    else if(t == 1){
      if(ds.same(a, b)) cout << 1 << endl;
      else cout << 0 << endl;
    }
  }
  
  return 0;
}
    

Compiler output:
a.cc:10:14: error: expected unqualified-id before '{' token
   10 |   DisjointSet{}
      |              ^
a.cc: In member function 'void DisjointSet::link(int, int)':
a.cc:33:7: error: expected ';' before '}' token
   33 |       }
      |       ^
a.cc: In member function 'int DisjointSet::findSet(int)':
a.cc:39:14: error: 'fibdSet' was not declared in this scope; did you mean 'findSet'?
   39 |       p[x] = fibdSet(p[x]);
      |              ^~~~~~~
      |              findSet
a.cc: In function 'int main()':
a.cc:54:19: error: 'class DisjointSet' has no member named 'unite'
   54 |     if(t == 0) ds.unite(a, b);
      |                   ^~~~~
Language: C++

#include<iostream>
#include<vector>

using namespace std;

class DisjointSet{
  public:
  vector<int> rank, p;

  DisjointSet(){}
  DisjointSet(int size){
    rank.resize(size, 0);
    p.resize(size, 0);
    for(int i=0; i<size; i++) makeSet(i);
  }

  void makeSet(int x){
    p[x] = x;
    rank[x] = 0;
  }

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

  void link(int x, int y){
    if(rank[x] > rank[y]){
      p[y] = x;
    }else{
      p[x] = y;
      if(rank[x] == rank[y]){
        rank[y]++
      }
    }
  }

  int findSet(int x){
    if(x != p[x]){
      p[x] = fibdSet(p[x]);
    }
    return p[x];
  }
};

int main(){
  int n, a, b, q;
  int t;

  cin >> n >> q;
  DisjointSet ds = DisjointSet(n);
 
  for(int i=0; i<q; i++){
    cin >> t >> a >> b;
    if(t == 0) ds.unite(a, b);
    else if(t == 1){
      if(ds.same(a, b)) cout << 1 << endl;
      else cout << 0 << endl;
    }
  }
  
  return 0;
}
    

Compiler output:
a.cc: In member function 'void DisjointSet::link(int, int)':
a.cc:33:7: error: expected ';' before '}' token
   33 |       }
      |       ^
a.cc: In member function 'int DisjointSet::findSet(int)':
a.cc:39:14: error: 'fibdSet' was not declared in this scope; did you mean 'findSet'?
   39 |       p[x] = fibdSet(p[x]);
      |              ^~~~~~~
      |              findSet
a.cc: In function 'int main()':
a.cc:54:19: error: 'class DisjointSet' has no member named 'unite'
   54 |     if(t == 0) ds.unite(a, b);
      |                   ^~~~~
Language: C++

#include <iostream>
#include <vector>
using namespace std;
struct UnionFind{
    vector<int> data;
    UnionFind(int nb_v) : data(nb_v, -1) {}
    
    bool unionSet(int x, int y){
        x = root(x);
        y = root(y);
        if (x != y){
            if (data[x] > data[y]) swap(x,y);
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }
    bool findSet(int x, int y){
        return root(x) == root(y);    
    }
    int root(int x){
        return data[x] < 0? x: data[x] = root(data[x]);
    }
};

int main(void){cin.tie(0);sync_with_stdio(false);
    
    int nb_v, nb_lines;
    cin >>nb_v
        >>nb_lines;
    UnionFind G(nb_v);
    for(int i=0; i<nb_lines; ++i){
        int query, v1, v2;
        cin >>query
            >>v1
            >>v2;
            
        switch (query){
            case 0:{
                G.unionSet(v1, v2);
                break;
            }
            case 1:{
                cout<<G.findSet(v1, v2)<<endl;
                break;
            }
        }
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:27: error: 'sync_with_stdio' was not declared in this scope
   26 | int main(void){cin.tie(0);sync_with_stdio(false);
      |                           ^~~~~~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int a[10005]={};
int find(int x){if(a[x]==x)return x;else return (a[x]=find(a[x]);}
int main(){
  int n,q;cin>>n>>q;
  for(int i=0;i<10005;i++)a[i]=i;
  for(int i=0;i<q;i++){
    int t,x,y;cin>>t>>x>>y;
    if(t==0){a[find(x)]=y;}
    if(t==1){cout<<(a[find(x)]==a[find(y)]?1:0)<<endl;}
  }
}

Compiler output:
a.cc: In function 'int find(int)':
a.cc:4:65: error: expected ')' before ';' token
    4 | int find(int x){if(a[x]==x)return x;else return (a[x]=find(a[x]);}
      |                                                 ~               ^
      |                                                                 )
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

struct UnionFind {
   vector<int> node;
   UnionFind(int n) : node(n,-1) {}
   bool unionSet(int x, int y) {
      x = root(x); 
      y = root(y);
      if (x != y) {
         if (node[y] < node[x]) swap(x, y);
         node[x] += node[y]; 
         node[y] = x;
      }
      return x != y;
   }
   bool findSet(int x, int y) {
      return root(x) == root(y);
   }
   int root(int x) {
      return node[x] < 0 ? x : node[x] = root(node[x]);
   }
   int size(int x) {
      return - node[root(x)];
   }
};

int main() {
   UnionFind inst(100010);
   int n,q; cin >> n >> q;
   REP(i,q){
      int com,x,y; cin >> com >> x >> y;
      if(com == 0) inst.unionSet(x,y);
      else cout << inst.unionFind(x,y) << endl;
   }
   return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:49:25: error: 'struct UnionFind' has no member named 'unionFind'; did you mean 'UnionFind'?
   49 |       else cout << inst.unionFind(x,y) << endl;
      |                         ^~~~~~~~~
      |                         UnionFind
Language: C++

#include <iostream>
#include<cmath>
using namespace std;

int main() {
	int n,a,count=0;
	cin >> n;
	for(int i=0;i++;i<n){
		cin >> a;
		if(a%2==0){
			count++;
		}else{
			if(prime_check(a)==1)
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

int prime_check(int a){
	for(int i=0;i++;i<sqrt(a)+1){
		if(a%i==0)return 1;
	}return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:28: error: 'prime_check' was not declared in this scope
   13 |                         if(prime_check(a)==1)
      |                            ^~~~~~~~~~~
Language: C++

#include <iostream>
#include <vector>
using namespace std;

Class DisjointSet{
public:
    vector<int> p,r;
    
    DisjointSet(int s){
        p.resize(s,0);
        r.resize(s,0);
        int i;
        for(i=0;i<s;i++){makeset(i);}
    }
    
    void makeset(int i){
        p[i]=i;
        r[i]=0;
    }
    
    bool same(int a,int b){
        if(findset(a)==findset(b))return true;
        else return false;
    }
    
    void link(int a,int b){
        int pa=findset(a);
        int pb=findset(b);
        if(r[pa]>r[pb])p[pb]=pa;
        else{
            p[pa]=pb;
            if(r[pa]==r[pb])r[pb]+=1;
        }
    }
    
    void findset(int a){
        if(a!=p[a]){
            p[a]=findset(p[a]);
        }
        return p[a];
    }
}

int main()
{
    int n,q,t,a,b;
    cin>>n>>q;
    DisjointSet ds=DisjointSet(n);
    int i;
    for(i=0;i<q;i++){
        cin>>t>>a>>b;
        if(t==0)ds.link(a,b);
        if(t==1){
            if(ds.same(a,b))cout<<"1"<<endl;
            else cout<<"0"<<endl;
        }
    }
    return 0;
}

Compiler output:
a.cc:5:1: error: 'Class' does not name a type; did you mean 'class'?
    5 | Class DisjointSet{
      | ^~~~~
      | class
a.cc: In function 'int main()':
a.cc:48:5: error: 'DisjointSet' was not declared in this scope
   48 |     DisjointSet ds=DisjointSet(n);
      |     ^~~~~~~~~~~
a.cc:52:17: error: 'ds' was not declared in this scope
   52 |         if(t==0)ds.link(a,b);
      |                 ^~
a.cc:54:16: error: 'ds' was not declared in this scope
   54 |             if(ds.same(a,b))cout<<"1"<<endl;
      |                ^~
Language: C++

#include <iostream>
#include <vector>
using namespace std;

Class DisjointSet{
public:
    vector<int> p,r;

    DisjointSet(int s){
        p.resize(s,0);
        r.resize(s,0);
        int i;
        for(i=0;i<s;i++){makeset(i);}
    }

    void makeset(int i){
        p[i]=i;
        r[i]=0;
    }

    bool same(int a,int b){
        if(findset(a)==findset(b))return true;
        else return false;
    }

    void link(int a,int b){
        int pa=findset(a);
        int pb=findset(b);
        if(r[pa]>r[pb])p[pb]=pa;
        else{
            p[pa]=pb;
            if(r[pa]==r[pb])r[pb]+=1;
        }
    }

    void findset(int a){
        if(a!=p[a]){
            p[a]=findset(p[a]);
        }
        return p[a];
    }
}

int main()
{
    int n,q,t,a,b;
    cin>>n>>q;
    DisjointSet ds=DisjointSet(n);
    int i;
    for(i=0;i<q;i++){
        cin>>t>>a>>b;
        if(t==0)ds.link(a,b);
        if(t==1){
            if(ds.same(a,b))cout<<1<<endl;
            else cout<<0<<endl;
        }
    }
    return 0;
}

Compiler output:
a.cc:5:1: error: 'Class' does not name a type; did you mean 'class'?
    5 | Class DisjointSet{
      | ^~~~~
      | class
a.cc: In function 'int main()':
a.cc:48:5: error: 'DisjointSet' was not declared in this scope
   48 |     DisjointSet ds=DisjointSet(n);
      |     ^~~~~~~~~~~
a.cc:52:17: error: 'ds' was not declared in this scope
   52 |         if(t==0)ds.link(a,b);
      |                 ^~
a.cc:54:16: error: 'ds' was not declared in this scope
   54 |             if(ds.same(a,b))cout<<1<<endl;
      |                ^~
Language: C++

#include <iostream>
#include <string>
//#include <cstring>
//#include <sstream>
#include <fstream>
#include <vector>
#include <algorithm>
//#include <stack>
//#include <queue>
//#include <chrono>
//#include <numeric>
//#include <set>
//#define _USE_MATH_DEFINES
//#include <cmath>
//#include <math.h>
//#include <iomanip>
//#include <list>
//#include <limits>

using namespace std;
const int infty = static_cast <int> (pow(256, sizeof(int)) / 2 - 1);

class cDisjointSet
{
	vector<int> vp;
	vector<int> vrank;
public:
	cDisjointSet(int n);
	void cDisjointSet::makeSet(int x);
	void uunionn(int x, int y);
	int findSet(int x);
	bool isSameSet(int x, int y);
	void link(int x, int y);
};

cDisjointSet::cDisjointSet(int n)
{
	vp.resize(n);
	vrank.resize(n);
	for (int i = 0; i < n; ++i)
		makeSet(i);
}
void cDisjointSet::makeSet(int x)
{
	vp[x] = x;
	vrank[x] = 0;
}

void cDisjointSet::uunionn(int x,int y)
{
	link(findSet(x), findSet(y));
}

int cDisjointSet::findSet(int x)
{
	if(x!=vp[x])
		vp[x] = findSet(vp[x]);
	return vp[x];
}

bool cDisjointSet::isSameSet(int x, int y)
{
	return findSet(x) == findSet(y);
}

void cDisjointSet::link(int x, int y)
{
	if (vrank[x] > vrank[y])
		vp[y] = x;
	else
	{
		vp[x] = y;
		if (vrank[x] == vrank[y])
			vrank[y]++;
	}
}

int main()
{
	////ifstream fin("DPL_1_C-in40.txt");
	//ifstream fin("test.txt");
	//if (!fin.is_open())
	//{
	//	cout << "File not found." << endl;
	//	return 0;
	//}

	//fin.tie(0);
	//ios::sync_with_stdio(false);

	//int n,q;
	//fin >> n >> q;
	//fin.ignore();

	cin.tie(0);
	ios::sync_with_stdio(false);

	int n, q;
	cin >> n >> q;
	cin.ignore();

	int com, x, y;
	cDisjointSet cd(n);

	for (int i = 0; i < q; ++i)
	{
		cin >> com >> x >> y;
		//fin >> com >> x >> y;
		switch(com)
		{
		case 0:
			cd.uunionn(x, y);
			break;
		case 1:
			cout << (cd.isSameSet(x, y) ? 1 : 0) << endl;
		}
	}
	return 0;
}

Compiler output:
a.cc:21:38: error: 'pow' was not declared in this scope
   21 | const int infty = static_cast <int> (pow(256, sizeof(int)) / 2 - 1);
      |                                      ^~~
a.cc:29:14: error: extra qualification 'cDisjointSet::' on member 'makeSet' [-fpermissive]
   29 |         void cDisjointSet::makeSet(int x);
      |              ^~~~~~~~~~~~
Language: C++

#include <iostream>
#include <set>

using namespace std;

int n,comm;
set<int> s[10001];

int findset(int key){
    set<int>::iterator iter;
    for (int i = 0; i < n; ++i) {
        if ((iter=s[i].find(key))!=s[i].end()){
            return i;
        }
    }
}

void print(set<int> s){
    for (set<int>::iterator it=s.begin(); it!=s.end();it++) {
        cout<<" "<<(*it);
    }
    cout<<endl;
}

int main() {
    int val[10001];
    set<int> u;
    int com,a,b;

    cin>>n>>comm;
    for (int i = 0; i < n; i++) {
        s[i].insert(i);
    }
    for (int j = 0; j < comm; ++j) {
        cin>>com>>a>>b;
        int s1=findset(a);
        int s2=findset(b);
        if (com==0){
            set_union(s[s1].begin(),s[s1].end(),s[s2].begin(),s[s2].end(),inserter(s[s1],s[s1].begin()));
            s[s2].clear();
//            set_union(s[s1].begin(),s[s1].end(),s[s2].begin(),s[s2].end(),inserter(s[s2],s[s2].begin()));
        }
        if (com==1){
            if (s1==s2){
                cout<<"1"<<endl;
            } else{
                cout<<"0"<<endl;
            }
        }
    }
//    for (int k = 1; k <=n ; ++k) {
//        print(s[k]);
//    }


    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:13: error: 'set_union' was not declared in this scope
   39 |             set_union(s[s1].begin(),s[s1].end(),s[s2].begin(),s[s2].end(),inserter(s[s1],s[s1].begin()));
      |             ^~~~~~~~~
a.cc: In function 'int findset(int)':
a.cc:16:1: warning: control reaches end of non-void function [-Wreturn-type]
   16 | }
      | ^
Language: C++

#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
class Dis
{
public:
    vector<int>rank,p;
    Dis(){}
    Dis(int size)
    {
        rank.resize(size,0);
        p.resize(size,0);
        for(int i=0;i<size;i++) makeSet(i);
    }
    void makeSet(int x)
    {
        p[x]=x;
        rank[x]=0;
    }
    bool same(int x,int y)
    {
        return findSet(x)==findSet(y);
    }
    void unite(int x,int y)
    {
        link(findSet(x),findSet(y));
    }
    void link(int x,int y)
    {
        if(rank[x]>rank[y]) p[y]=x;
        else p[x]=y;
        if(rank[x]==rank[y]) rank[y]++;
    }
    int findSet(int x)
    {
        if(x!=p[x])
        {
            p[x]=findSet(p[x]);
        }
        return p[x];
    }
};
int main()
{
    int n,q,a,b,h;
    scanf("%d %d",&n,&q);
    Dis ds=Dis(n);
    for(int i=0;i<q;i++)
    {
        scanf("%d %d %d",&h,&a,&b);
        if(h==0) ds.unite(a,b);
        else if(h==1)
        {
            if(ds.same(a,b)) printf("1\n");
            else printf("0\n");
        }
    }
    return 0;

Compiler output:
a.cc: In function 'int main()':
a.cc:59:14: error: expected '}' at end of input
   59 |     return 0;
      |              ^
a.cc:45:1: note: to match this '{'
   45 | {
      | ^
Language: C++

#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef stack<int> SI;
typedef queue<int> QI;
typedef pair<int,int> PII;
typedef long long LL;

#define d(x)  cout<<#x<<" = "<<(x)<<endl;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define EMP empty()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define REACH(i,c) for(typeof((c).rbegin()) i=(c).rbegin(); i!=(c).rend(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c,n) sort(c,c+n)
#define VSORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define DFOR(i,b,a) for(int i=(b)-1;i>=(a);--i)
#define DREP(i,n) DFOR(i,n,0)
#define INF 1000000000

const double EPS = 1e-10;
const double PI  = acos(-1.0);
////////////////////////////////////////////////
class DisjointSet
{
	public:
		vector<int> rank,p;
		DisjointSet(){}
		DisjointSet(int size)
		{
			rank.resize(size,0);
			p.resize(size,0);
			for(int i=0;i<size;i++)makeSet(i);
		}
		
		void makeSet(int x)
		{
			p[x]=x;
			rank[x]=0;
		}
		
		bool same(int x,int y)
		{
			return findSet(x)==findSet(y);
		}
		
		void unite(int x,int y)
		{
			link(findSet(x),findSet(y));
		}
		
		void link(int x,int y)
		{
			if(rank[x]>rank[y])
			{
				p[y]=x;
			}
			else
			{
				p[x]=y;
				if(rank[x]==rank[y])
				{
					rank[y]++;
				}
			}
		}
		
		int findSet(int x)
		{
			if(x!=p[x])
			{
				p[x]=findSet(p[x]);
			}
			return p[x];
		}
};

int main()
{
	int n,a,b,q;
	int t;
	cin>>n>>q;
	DisjointSet ds=DisjointSet(n);
	
	for(int i=0;i<q;i++)
	{
		cin>>t>>a>>b;
		if(t==0)ds.unite(a,b);
		elif(t==1)
		{
			if(ds.same(a,b))cout<<1<<endl;
			else cout<<0<<endl;
		}
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:109:17: error: 'elif' was not declared in this scope
  109 |                 elif(t==1)
      |                 ^~~~
Language: C++

#include<iostream>
using namespace std;
int P[10010];
void init(int N)
{
  for (int i=0; i<=N; ++i) P[i] = i;
}

int root(int a)
{
  if (P[a] == a) return a;
  return (P[a] = root(P[a]));
}

bool is_same_set(int a, int b)
{
  return root(a) == root(b);
}

void unite(int a, int b)
{
  P[root(a)] = root(b);
}

int main()
{
  int n,q;
  cin>>n>>q;
  init(n);
  for(int i=0;i<q;i++)
    {
      int f,x,y;
      cin>>f>>x>>y;
      if(f==0)
	unite(x,y);
      if((f==1)
	 cout<< is_same_set(x,y)<<endl;;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:36:16: error: expected ';' before 'cout'
   36 |       if((f==1)
      |                ^
      |                ;
   37 |          cout<< is_same_set(x,y)<<endl;;
      |          ~~~~   
a.cc:37:40: error: expected primary-expression before ';' token
   37 |          cout<< is_same_set(x,y)<<endl;;
      |                                        ^
a.cc:37:40: error: expected ')' before ';' token
   37 |          cout<< is_same_set(x,y)<<endl;;
      |                                        ^
      |                                        )
a.cc:36:9: note: to match this '('
   36 |       if((f==1)
      |         ^
Language: C++

#include <iostream>
#include <vector>

using namespace std;

int main() {
    vector<int> rank;

    int n, q;
    cin >> n >> q;

    for (int i = 0; i < n; i++) {
        rank.push_back(i);
    }

    for (int i = 0; i < q; q++) {
        int c;
        int x, y;

        cin >> c >> x >> y;
        if c {
            int a = rank[x];
            int b = rank[y];

            if (a == b) {
                continue
            }
            for (int j = 0; j < n; j++) {
                if (rank[j] == b)
                    rank[j] = a;
            }
        } else {
            if (rank[x] == rank[y]) {
                cout << 1 << endl;
            } else {
                cout << 0 << endl;
            }
        }
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:12: error: expected '(' before 'c'
   21 |         if c {
      |            ^
      |            (
a.cc:32:11: error: 'else' without a previous 'if'
   32 |         } else {
      |           ^~~~
Language: C++

5 12
0 1 4
0 2 3
1 1 2
1 3 4
1 1 4
1 3 2
0 1 3
1 2 4
1 3 0
0 0 4
1 0 2
1 3 0

Compiler output:
a.cc:1:1: error: expected unqualified-id before numeric constant
    1 | 5 12
      | ^
Language: C++

#include<iostream>
#include<vector>

using namespace std;
//class
class DisjointSet{ //クラスの宣言
public: //公開部分
  vector<int>rank,p; //メンバ変数の宣言

  DisjointSet(); //コンストラクタ(ここはなくても動く)
  /*
  DisjointSet(int size){ 
    rank.resize(size,0); //resize→要素数を変更
    p.resize(size,0);
    //上二行:メンバ変数のrank,pの要素を調整
    for(int i=0;i<size;++i) makeSet(i);
  }
  */

  void makeSet(int x){ //メンバ関数"makeSet"の宣言
    p[x]=x;
    rank[x]=0;
  }

  bool same(int x,int y){ //メンバ関数"same"の宣言
    return findSet(x)==findSet(y);
  }

  void unite(int x,int y){ //メンバ関数"unite"の宣言
    link(findSet(x),findSet(y));
  }

  void link(int x,int y){ //メンバ関数"link"の宣言
    if( rank[x]>rank[y]){
      p[y]=x;
    }else{
      p[x]=y;
      if(rank[x]==rank[y]) rank[y]++;
    }
  }
  
  int findSet(int x){ //メンバ関数"findSet"の宣言
    if(x!=p[x]) p[x]=findSet(p[x]);
    return p[x];
  }
};

//main関数
int main(){
  int n,a,b,q;
  int t;
  
  cin>>n>>q;
  DisjointSet ds=DisjointSet(n); //class-DisjointSetでdsを宣言
  
  for(int i=0;i<q;++i){
    cin>>t>>a>>b;
    if(t==0) ds.unite(a,b);
    else if(t==1){
      if(ds.same(a,b)) cout<<1<<endl;
      else cout<<0<<endl;
    }
  }
  return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:54:31: error: no matching function for call to 'DisjointSet::DisjointSet(int&)'
   54 |   DisjointSet ds=DisjointSet(n); //class-DisjointSetでdsを宣言
      |                               ^
a.cc:10:3: note: candidate: 'DisjointSet::DisjointSet()'
   10 |   DisjointSet(); //コンストラクタ(ここはなくても動く)
      |   ^~~~~~~~~~~
a.cc:10:3: note:   candidate expects 0 arguments, 1 provided
a.cc:6:7: note: candidate: 'DisjointSet::DisjointSet(const DisjointSet&)'
    6 | class DisjointSet{ //クラスの宣言
      |       ^~~~~~~~~~~
a.cc:6:7: note:   no known conversion for argument 1 from 'int' to 'const DisjointSet&'
a.cc:6:7: note: candidate: 'DisjointSet::DisjointSet(DisjointSet&&)'
a.cc:6:7: note:   no known conversion for argument 1 from 'int' to 'DisjointSet&&'
Language: C++

#include <iostream>                                                       
using namespace std;                                                      
int main(){                                                               
    int number, queries, quantifier, numb1, numb2;                        
    cin >> number >> queries;                                             
    int parents[number] = {};                                             
    for(int i = 0; i < number; i++) {                                     
        parents[i] = i;                                                   
    }                                                                     
    for (int i = 0; i < queries; i++) {                                   
        cin >> quantifier >> numb1 >> numb2;                              
        if (quantifier == 0) {                                            
            for (int i = 0; i < number; i++) {                            
                int pickles = parents[numb2];                             
                if (parents[i] == pickles) {                              
                    parents[i] = parents[numb1];                          
                }                                                         
            }                                                             
        } else {                                                          
            if (parents[numb1] == parents[numb2]) {                       
                cout << "1" << endl;                                      
            } else {                                                      
                cout << "0" << endl;                                      
            }                                                             
        }                                                                 
    }                                                                     
                                                                          
}                                                                                               
                                                                       
}                                                                                  


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

#include<iostream>
#include<vector>

using namespace std;

class DisjointSet {
  public:
    vector<int> rank, p;

    DisjointSet() {}
    DisjointSet(int size) {
      rank.resize(size, 0);
      p.resize(size, 0);
      for( int i = 0; i < size; i++ ) makeSet(i);
    }

    void makeSet(int x) {
      p[x] = x;
      rank[x] = 0;
    }

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

    void unite(int x; int y) {
      link(findSet(x), findSet(y));
    }

    void link(int x, int y) {
      if ( rank[x] > rank[y] ) {
        p[y] = x;
      } else {
        p[x] = y;
        if ( rank [x] == rank[y] )
          rank[y]++
      }
    }
};

int main() {
  int n, a, b, q;
  int t;

  cin >> n >> q;
  DisjointSet ds = DisjointSet(n);

  for ( int i = 0; i < q; i++ ) {
    cin >> t >> a >> b;
    if ( t == 0 ) ds.unite(a, b);
    else if ( t == 1 ) {
      if ( ds.same(a, b) ) cout << 1 << endl;
      else cout << 0 << endl;
    }
  }

  return 0;
}


Compiler output:
a.cc:26:21: error: expected ')' before ';' token
   26 |     void unite(int x; int y) {
      |               ~     ^
      |                     )
a.cc:26:27: error: expected ';' at end of member declaration
   26 |     void unite(int x; int y) {
      |                           ^
      |                            ;
a.cc:26:28: error: expected unqualified-id before ')' token
   26 |     void unite(int x; int y) {
      |                            ^
a.cc: In member function 'bool DisjointSet::same(int, int)':
a.cc:23:14: error: 'findSet' was not declared in this scope
   23 |       return findSet(x) == findSet(y);
      |              ^~~~~~~
a.cc: In member function 'void DisjointSet::link(int, int)':
a.cc:37:7: error: expected ';' before '}' token
   37 |       }
      |       ^
a.cc: In function 'int main()':
a.cc:50:27: error: no matching function for call to 'DisjointSet::unite(int&, int&)'
   50 |     if ( t == 0 ) ds.unite(a, b);
      |                   ~~~~~~~~^~~~~~
a.cc:26:10: note: candidate: 'void DisjointSet::unite(int)'
   26 |     void unite(int x; int y) {
      |          ^~~~~
a.cc:26:10: note:   candidate expects 1 argument, 2 provided
Language: C++

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

    void unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return;
        par[x] = y;
    }

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

Class Solution{
public:
    void solution(){
        int n,q;
        cin >> n;
        cin >> q;
        
        
    }
}


Compiler output:
a.cc: In member function 'int union_find::find(int)':
a.cc:3:18: error: 'par' was not declared in this scope
    3 |         if (x == par[x]) return x;
      |                  ^~~
a.cc:4:16: error: 'par' was not declared in this scope
    4 |         return par[x] = find(par[x]);
      |                ^~~
a.cc: In member function 'void union_find::unite(int, int)':
a.cc:10:9: error: 'par' was not declared in this scope
   10 |         par[x] = y;
      |         ^~~
a.cc: At global scope:
a.cc:18:7: error: expected initializer before 'Solution'
   18 | Class Solution{
      |       ^~~~~~~~
Language: C++

#include <iostream>
#include <vector>
using namespace std;

class UnionFind
{
public:
    vector<int> rank,p;

    init(int size)
    {
        rank.resize(size,0);
        p.resize(size,0);
        for(int i=0;i<size;i++){ p[i]=i; }
    }

    int root(int x)
    {
        if(p[x]==x)
        {
            return x;
        }else{
            return p[x]=root(p[x]);
        }
    }

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

    void unite(int x, int y)
    {
        x=root(x);
        y=root(y);
        if(x==y) return;
        if(rank[x]<rank[y]){
            p[x]=y;
        }else{
            p[y]=x;
            if(rank[x]==rank[y]) rank[x]++;
      }
    }
};

int main(){
    int n,q,k,x,y;
    cin>>n>>q;
    UnionFind uf = UnionFind();
    uf.init(n);
    for(int i=0;i<q;i++){
        cin>>k>>x>>y;
        if(k==0) uf.unite(x,y);
        else if(k==1&&uf.same(x,y))
        cout<<"1"<<"\n"; else cout<<"0"<<"\n";
    }
}



Compiler output:
a.cc:10:5: error: ISO C++ forbids declaration of 'init' with no type [-fpermissive]
   10 |     init(int size)
      |     ^~~~
a.cc: In member function 'int UnionFind::init(int)':
a.cc:15:5: warning: no return statement in function returning non-void [-Wreturn-type]
   15 |     }
      |     ^
Language: C++

#include <iostream>
#include <vector>
using namespace std;

class UnionFind {
public:
    vector<int> parents;

    UnionFind(int n) {
        parents = new vector<int>(n);
        for (int i = 0; i < n; i++) {
            parents[i] = i;
        }
    }

    int root(int x) {
        if (parents[x] == x) { // root
            return x;
        } else {
            return parents[x] = root(parents[x]);
        }
    }

    bool isSame(int x, int y) {
        return root(x) == root(y);
    }

    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return ;

        parents[x] = y;
    }
};

int main(void) {
    int n, q; cin >> n >> q;
    UnionFind uf(n);

    for (int i = 0; i < q; i++) {
        int com, x, y; cin >> com >> x >> y;
        if (com == 0) {
            uf.unite(x-1, y-1);
        } else {
            cout << (uf.isSame(x-1, y-1) ? 1 : 0) << endl;
        }
    }

    return 0;
}


Compiler output:
a.cc: In constructor 'UnionFind::UnionFind(int)':
a.cc:10:36: error: no match for 'operator=' (operand types are 'std::vector<int>' and 'std::vector<int>*')
   10 |         parents = new vector<int>(n);
      |                                    ^
In file included from /usr/include/c++/14/vector:72,
                 from a.cc:2:
/usr/include/c++/14/bits/vector.tcc:210:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>]'
  210 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:211:42: note:   no known conversion for argument 1 from 'std::vector<int>*' to 'const std::vector<int>&'
  211 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/14/vector:66:
/usr/include/c++/14/bits/stl_vector.h:766:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = int; _Alloc = std::allocator<int>]'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:766:26: note:   no known conversion for argument 1 from 'std::vector<int>*' to 'std::vector<int>&&'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:788:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator<int>]'
  788 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:788:46: note:   no known conversion for argument 1 from 'std::vector<int>*' to 'std::initializer_list<int>'
  788 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~