criyle/codenet-compile-errors huggingface dataset:
Language: Java

import java.io.*;

class Main{

static final PrintWriter out=new PrintWriter(System.out);

public static class UnionFindTree{

private static int[] par;
private static int[] rank;

public UnionFindTree(int size){
par=new int[size];
rank=new int[size];
for(int i=0;i<size;i++){
par[i]=i;
rank[i]=0;
}
}

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

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

public static boolean same(int x,int y){
return find(x)==find(y);
}
}

public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
int num=Integer.parseInt(br.readLine());
UnionFindTree tree=new UnionFindTree(num);
while((line=br.readLine())!=null&&!line.isEmpty()){
String[] values=line.split(" ");
int query=Integer.parseInt(values[0]);
int x=Integer.parseInt(values[1]);
int y=Integer.parseInt(values[2]);
if(query==0) tree.unite(x,y);
else out.println(tree.same(x,y)?"1":"0");
}
out.flush();
}
}

Compiler output:
Main.java:23: error: cannot find symbol
else return par[x]=find[x];
                   ^
  symbol:   variable find
  location: class UnionFindTree
1 error
Language: Java

import java.util.Scanner;


public class DSL_1_A {

	static int[] par;
	static int[] rank;

	static void initUF(int n) {
		par = new int[n];
		for (int i=0;i<n;i++){
			par[i] = i;
			rank[i] = 1;
		}
	}
	
	static int root(int n) {
		if (par[n]==n) {
			return n;
		} else {
			return (par[n] = root(par[n]));
		}
	}
	
	static boolean same(int i, int j) {
		return root(i)==root(j);
	}

	static void unite(int i, int j) {
		if (rank[i]>rank[j]) {
			par[j] = root(i);
			rank[i]++;
		} else {
			par[i] = root(j);
			rank[j]++;
		}
	}
	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int q = scan.nextInt();
		
		par = new int[n];
		for (int i=0;i<q;i++) {
			int com = scan.nextInt();
			int x = scan.nextInt();
			int y = scan.nextInt();
			if (com==0) {
				unite(x, y);
			} else {
				System.out.println(same(x, y));
			}
		}
		
	}
	
}

Compiler output:
Main.java:4: error: class DSL_1_A is public, should be declared in a file named DSL_1_A.java
public class DSL_1_A {
       ^
1 error
Language: Java

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int q = sc.nextInt();

        int[] sets = new int[n];
        for (int i = 0; i < n; i++) {
            sets[i] = i;
        }

        for (int i = 0; i < q; i++) {
            int com = sc.nextInt();
            int x = sc.nextInt();
            int y = sc.nextInt();

            if(com == 0) {
                int newSet = sets[y];
                for (int j = 0; j < n; j++) {
                    if(sets[j] == newSet) {
                        sets[j] = sets[x];
                    }
                }
            } else {
                if(sets[x] == sets[y]) {
                    System.out.println(1);
                } else {
                    System.out.println(0);
                }
            }
        }
    }
}

Compiler output:
Main.java:3: error: cannot find symbol
        Scanner sc = new Scanner(System.in);
        ^
  symbol:   class Scanner
  location: class Main
Main.java:3: error: cannot find symbol
        Scanner sc = new Scanner(System.in);
                         ^
  symbol:   class Scanner
  location: class Main
2 errors
Language: Java

import java.util.Scanner;
 
public class Main {
    private static int n;
    private static int q;
    private static int[] p;
    private static int[] rank;
 
    private static boolean same(int x, int y) {
        return findSet(x) == findSet(y);
    }
 
    private static void unite(int x, int y) {
        int i = findSet(x);
        int j = findSet(y);
 
        if (i == j)
            return;
        if (rank[i] > rank[j]){
            p[j] = p[i];
            rank[i] += rank[j];
            rank[j] = 0;
        }
        else {
            p[i] = p[j];
            rank[j] += rank[i];
            rank[i] = 0;
        }
    }
 
    private static int findSet(int i) {
        while (i != p[i]){
            p[i] = p[p[i]];
            p = p[i];
        }
        return i;
    }
 
    private static void DisjointSet() {
        p = new int[n];
        rank = new int[n];
 
        for (int i = 0; i < n; i++) {
            p[i] = i;
            rank[i] = 1;
        }
    }
 
 
    public static void main (String[] args){
        Scanner scanner = new Scanner(System.in);
        n = scanner.nextInt();
        q = scanner.nextInt();
 
        DisjointSet();
        for (int i = 0; i < q; i++) {
            int com = scanner.nextInt();
            int x = scanner.nextInt();
            int y = scanner.nextInt();
 
            if (com == 0){
                unite(x, y);
            }
            if (com == 1){
                if (Same(x, y))
                    System.out.println(1);
                else
                    System.out.println(0);
            }
 
        }
 
    }
}

Compiler output:
Main.java:34: error: incompatible types: int cannot be converted to int[]
            p = p[i];
                 ^
Main.java:65: error: cannot find symbol
                if (Same(x, y))
                    ^
  symbol:   method Same(int,int)
  location: class Main
2 errors
Language: Java

public class UnionFindTree {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();

        UFT uft = new UFT(n);
        for (int i = 0; i < q; i++){
            int com = sc.nextInt();
            int x = sc.nextInt();
            int y = sc.nextInt();
            if (com == 0)
                uft.unite(x, y);
            else{
                if(uft.same(x, y))
                    System.out.println(1);
                else
                    System.out.println(0);
            }
            //uft.print();
            //System.out.println();
        }
    }

    private static class UFT {
        int size;
        int rootsOfNodes[];

        UFT(int n){
            size = n;
            int i = 1;
            while (i < n) i *= 2;
            rootsOfNodes = new int[n];
            for (int j = 0; j < n; j++)
                rootsOfNodes[j] = j;
        }

        private int depth(int node, int depth){
            if (node == rootsOfNodes[node])
                return depth;
            return depth(rootsOfNodes[node], depth + 1);
        }

        void unite(int x, int y){
            int lower;
            int root;
            if (depth(x, 0) > depth(y, 0)) {
                lower = x;
                root = root(y);
            }
            else {
                lower = y;
                root = root(x);
            }
            while(lower != rootsOfNodes[lower]){
                int next = rootsOfNodes[lower];
                rootsOfNodes[lower] = root;
                lower = next;
            }
            rootsOfNodes[lower] = root;
        }

        private int root(int node) {
            if (node == rootsOfNodes[node])
                return node;
            return root(rootsOfNodes[node]);
        }

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

        void print(){
            for (int i = 0; i < size; i++)
                System.out.printf("%d <-- Root -- %d\n", rootsOfNodes[i], i);
        }

    }
}

Compiler output:
Main.java:1: error: class UnionFindTree is public, should be declared in a file named UnionFindTree.java
public class UnionFindTree {
       ^
Main.java:3: error: cannot find symbol
        Scanner sc = new Scanner(System.in);
        ^
  symbol:   class Scanner
  location: class UnionFindTree
Main.java:3: error: cannot find symbol
        Scanner sc = new Scanner(System.in);
                         ^
  symbol:   class Scanner
  location: class UnionFindTree
3 errors
Language: Java


import java.util.*;

public class Main{
	public class Union {
	
		private	int[] n;
		
		public Union(int n){
			
			this.n = new int[n];
			for(int i = 0; i < n; i++){
				this.n[i] = i;
			}
		}
		
		public void union(int p, int q){
			
			int child = n[p];
			int father = n[q];
			if(n[p] == n[q])return;
			for(int i = 0; i < n.length; i++){
				
				if(n[i] == child)n[i] = father; 
			}
			
		}
		
		public boolean find(int p, int q){
			
			return n[p] == n[q];
		}
		
		
	}
	public static void main(String[] args){
		
		Scanner input = new Scanner(System.in);		
//		System.out.println("Please enter n");
		int n,m,i = 0;
		n = input.nextInt();
		m = input.nextInt();
	
		Union uf = new Union(n);
		
		while(i < m){
			
			int t,p,q;
			t = input.nextInt();
			p = input.nextInt(); 
			q = input.nextInt();
			
			if (t == 1){
				System.out.println(uf.find(p, q) == true ? 1 : 0);
			}
			else{
				
				uf.union(p, q);
			}
			
			i++;
		}
		

		
//		System.out.println(uf.find(m, n));
		
	}
	
}

Compiler output:
Main.java:44: error: non-static variable this cannot be referenced from a static context
		Union uf = new Union(n);
		           ^
1 error
Language: Java


import java.util.*;

public class Main{
	class Union {
	
		private	int[] n;
		
		public Union(int n){
			
			this.n = new int[n];
			for(int i = 0; i < n; i++){
				this.n[i] = i;
			}
		}
		
		public void union(int p, int q){
			
			int child = n[p];
			int father = n[q];
			if(n[p] == n[q])return;
			for(int i = 0; i < n.length; i++){
				
				if(n[i] == child)n[i] = father; 
			}
			
		}
		
		public boolean find(int p, int q){
			
			return n[p] == n[q];
		}
		
		
	}

	public static void main(String[] args){
		
		Scanner input = new Scanner(System.in);		
//		System.out.println("Please enter n");
		int n,m,i = 0;
		n = input.nextInt();
		m = input.nextInt();
	
		Union uf = new Union(n);
		
		while(i < m){
			
			int t,p,q;
			t = input.nextInt();
			p = input.nextInt(); 
			q = input.nextInt();
			
			if (t == 1){
				System.out.println(uf.find(p, q) == true ? 1 : 0);
			}
			else{
				
				uf.union(p, q);
			}
			
			i++;
		}
		

		
//		System.out.println(uf.find(m, n));
		
	}
	
}

Compiler output:
Main.java:45: error: non-static variable this cannot be referenced from a static context
		Union uf = new Union(n);
		           ^
1 error
Language: Java

import java.util.ArrayList;
import java.util.Scanner;


public class UFT_Node {
int name;
UFT_Node next;
int rank;

public UFT_Node(int new_name){
	this.name = new_name;
	this.rank =0;
	this.next = this;
	}

public UFT_Node getRep(){
	UFT_Node output;
	if (this.next.name == this.name)
		return this;
	else output = this.next.getRep();
	this.next = output; 
	return output;
}

}

public class UFT {
	UFT_Node[] nodes;
	public static void main(String[] args){
		ArrayList<Integer> output = new ArrayList<Integer>();
		UFT test = new UFT();
		Scanner inputScanner = new Scanner("System.in");
		int n = inputScanner.nextInt();
		int q = inputScanner.nextInt();
		test.nodes = test.makeArray(n);
		
		int type = -1;
		int x= -1;
		int y= -1;
		for (int i=0;i<q;i++){
			type = inputScanner.nextInt();
			x = inputScanner.nextInt();
			y = inputScanner.nextInt();
			if(type ==0){
				test.union(x,y);
			}
			if(type ==1){
				if(test.same(x, y))
					output.add(1);
				else
					output.add(0);
			}
		} 
		for(Integer out : output){
			System.out.println(out.toString());
		}
	}
	public UFT_Node[] makeArray(int num){
		UFT_Node[] output = new UFT_Node[num];
		for (int i=0; i<num;i++){
			output[i] = new UFT_Node(i);
		}
	return output;
	}
	
	public void union(int x, int y){
		UFT_Node yRep = nodes[y].getRep();
		UFT_Node xRep = nodes[x].getRep();
		if (yRep.rank> xRep.rank){
			xRep.next= yRep;
		}
		else if(yRep.rank< xRep.rank){
			yRep.next= xRep;
		}
		else{
			yRep.next= xRep;
			xRep.rank++;
		}
	}
	
	public boolean same (int x, int y){
		return nodes[x].getRep().name==nodes[y].getRep().name;
	}
}



Compiler output:
Main.java:5: error: class UFT_Node is public, should be declared in a file named UFT_Node.java
public class UFT_Node {
       ^
Main.java:27: error: class UFT is public, should be declared in a file named UFT.java
public class UFT {
       ^
2 errors
Language: Java

import java.util.ArrayList;
import java.util.Scanner;


private class UFT_Node {
int name;
UFT_Node next;
int rank;

public UFT_Node(int new_name){
	this.name = new_name;
	this.rank =0;
	this.next = this;
	}

public UFT_Node getRep(){
	UFT_Node output;
	if (this.next.name == this.name)
		return this;
	else output = this.next.getRep();
	this.next = output; 
	return output;
}

}

public class Main {
	UFT_Node[] nodes;
	public static void main(String[] args){
		ArrayList<Integer> output = new ArrayList<Integer>();
		Main test = new Main();
		Scanner inputScanner = new Scanner("System.in");
		int n = inputScanner.nextInt();
		int q = inputScanner.nextInt();
		test.nodes = test.makeArray(n);
		
		int type = -1;
		int x= -1;
		int y= -1;
		for (int i=0;i<q;i++){
			type = inputScanner.nextInt();
			x = inputScanner.nextInt();
			y = inputScanner.nextInt();
			if(type ==0){
				test.union(x,y);
			}
			if(type ==1){
				if(test.same(x, y))
					output.add(1);
				else
					output.add(0);
			}
		} 
		for(Integer out : output){
			System.out.println(out.toString());
		}
	}
	public UFT_Node[] makeArray(int num){
		UFT_Node[] output = new UFT_Node[num];
		for (int i=0; i<num;i++){
			output[i] = new UFT_Node(i);
		}
	return output;
	}
	
	public void union(int x, int y){
		UFT_Node yRep = nodes[y].getRep();
		UFT_Node xRep = nodes[x].getRep();
		if (yRep.rank> xRep.rank){
			xRep.next= yRep;
		}
		else if(yRep.rank< xRep.rank){
			yRep.next= xRep;
		}
		else{
			yRep.next= xRep;
			xRep.rank++;
		}
	}
	
	public boolean same (int x, int y){
		return nodes[x].getRep().name==nodes[y].getRep().name;
	}
}




Compiler output:
Main.java:5: error: modifier private not allowed here
private class UFT_Node {
        ^
1 error
Language: Java

import java.util.ArrayList;
import java.util.Scanner;


protected class UFT_Node {
int name;
UFT_Node next;
int rank;

public UFT_Node(int new_name){
	this.name = new_name;
	this.rank =0;
	this.next = this;
	}

public UFT_Node getRep(){
	UFT_Node output;
	if (this.next.name == this.name)
		return this;
	else output = this.next.getRep();
	this.next = output; 
	return output;
}

}

public class Main {
	UFT_Node[] nodes;
	public static void main(String[] args){
		ArrayList<Integer> output = new ArrayList<Integer>();
		Main test = new Main();
		Scanner inputScanner = new Scanner("System.in");
		int n = inputScanner.nextInt();
		int q = inputScanner.nextInt();
		test.nodes = test.makeArray(n);
		
		int type = -1;
		int x= -1;
		int y= -1;
		for (int i=0;i<q;i++){
			type = inputScanner.nextInt();
			x = inputScanner.nextInt();
			y = inputScanner.nextInt();
			if(type ==0){
				test.union(x,y);
			}
			if(type ==1){
				if(test.same(x, y))
					output.add(1);
				else
					output.add(0);
			}
		} 
		for(Integer out : output){
			System.out.println(out.toString());
		}
	}
	public UFT_Node[] makeArray(int num){
		UFT_Node[] output = new UFT_Node[num];
		for (int i=0; i<num;i++){
			output[i] = new UFT_Node(i);
		}
	return output;
	}
	
	public void union(int x, int y){
		UFT_Node yRep = nodes[y].getRep();
		UFT_Node xRep = nodes[x].getRep();
		if (yRep.rank> xRep.rank){
			xRep.next= yRep;
		}
		else if(yRep.rank< xRep.rank){
			yRep.next= xRep;
		}
		else{
			yRep.next= xRep;
			xRep.rank++;
		}
	}
	
	public boolean same (int x, int y){
		return nodes[x].getRep().name==nodes[y].getRep().name;
	}
}




Compiler output:
Main.java:5: error: modifier protected not allowed here
protected class UFT_Node {
          ^
1 error
Language: Java

import java.util.ArrayList;
import java.util.Scanner;


public class UFT_Node {
int name;
UFT_Node next;
int rank;

public UFT_Node(int new_name){
	this.name = new_name;
	this.rank =0;
	this.next = this;
	}

public UFT_Node getRep(){
	UFT_Node output;
	if (this.next.name == this.name)
		return this;
	else output = this.next.getRep();
	this.next = output; 
	return output;
}

}

public class Main {
	UFT_Node[] nodes;
	public static void main(String[] args){
		ArrayList<Integer> output = new ArrayList<Integer>();
		Main test = new Main();
		Scanner inputScanner = new Scanner("System.in");
		int n = inputScanner.nextInt();
		int q = inputScanner.nextInt();
		test.nodes = test.makeArray(n);
		
		int type = -1;
		int x= -1;
		int y= -1;
		for (int i=0;i<q;i++){
			type = inputScanner.nextInt();
			x = inputScanner.nextInt();
			y = inputScanner.nextInt();
			if(type ==0){
				test.union(x,y);
			}
			if(type ==1){
				if(test.same(x, y))
					output.add(1);
				else
					output.add(0);
			}
		} 
		for(Integer out : output){
			System.out.println(out.toString());
		}
	}
	public UFT_Node[] makeArray(int num){
		UFT_Node[] output = new UFT_Node[num];
		for (int i=0; i<num;i++){
			output[i] = new UFT_Node(i);
		}
	return output;
	}
	
	public void union(int x, int y){
		UFT_Node yRep = nodes[y].getRep();
		UFT_Node xRep = nodes[x].getRep();
		if (yRep.rank> xRep.rank){
			xRep.next= yRep;
		}
		else if(yRep.rank< xRep.rank){
			yRep.next= xRep;
		}
		else{
			yRep.next= xRep;
			xRep.rank++;
		}
	}
	
	public boolean same (int x, int y){
		return nodes[x].getRep().name==nodes[y].getRep().name;
	}
}




Compiler output:
Main.java:5: error: class UFT_Node is public, should be declared in a file named UFT_Node.java
public class UFT_Node {
       ^
1 error
Language: Java


public class UFT_Node {
int name;
UFT_Node next;
int rank;

public UFT_Node(int new_name){
	this.name = new_name;
	this.rank =0;
	this.next = this;
	}

public UFT_Node getRep(){
	UFT_Node output;
	if (this.next.name == this.name)
		return this;
	else output = this.next.getRep();
	this.next = output; 
	return output;
}

}



Compiler output:
Main.java:2: error: class UFT_Node is public, should be declared in a file named UFT_Node.java
public class UFT_Node {
       ^
1 error
Language: Java


public class Main {
int name;
UFT_Node next;
int rank;

public Main(int new_name){
	this.name = new_name;
	this.rank =0;
	this.next = this;
	}

public Main getRep(){
	UFT_Node output;
	if (this.next.name == this.name)
		return this;
	else output = this.next.getRep();
	this.next = output; 
	return output;
}

}



Compiler output:
Main.java:4: error: cannot find symbol
UFT_Node next;
^
  symbol:   class UFT_Node
  location: class Main
Main.java:14: error: cannot find symbol
	UFT_Node output;
	^
  symbol:   class UFT_Node
  location: class Main
2 errors
Language: Java

import java.util.ArrayList;
import java.util.Scanner;


public class UFT {
	UFT_Node[] nodes;
	public static void main(String[] args){
		ArrayList<Integer> output = new ArrayList<Integer>();
		UFT test = new UFT();
		Scanner inputScanner = new Scanner("System.in");
		int n = inputScanner.nextInt();
		int q = inputScanner.nextInt();
		test.nodes = test.makeArray(n);
		
		int type = -1;
		int x= -1;
		int y= -1;
		for (int i=0;i<q;i++){
			type = inputScanner.nextInt();
			x = inputScanner.nextInt();
			y = inputScanner.nextInt();
			if(type ==0){
				test.union(x,y);
			}
			if(type ==1){
				if(test.same(x, y))
					output.add(1);
				else
					output.add(0);
			}
		} 
		for(Integer out : output){
			System.out.println(out.toString());
		}
	}
	public UFT_Node[] makeArray(int num){
		UFT_Node[] output = new UFT_Node[num];
		for (int i=0; i<num;i++){
			output[i] = new UFT_Node(i);
		}
	return output;
	}
	
	public void union(int x, int y){
		UFT_Node yRep = nodes[y].getRep();
		UFT_Node xRep = nodes[x].getRep();
		if (yRep.rank> xRep.rank){
			xRep.next= yRep;
		}
		else if(yRep.rank< xRep.rank){
			yRep.next= xRep;
		}
		else{
			yRep.next= xRep;
			xRep.rank++;
		}
	}
	
	public boolean same (int x, int y){
		return nodes[x].getRep().name==nodes[y].getRep().name;
	}
}

public class UFT_Node {
int name;
UFT_Node next;
int rank;

public UFT_Node(int new_name){
	this.name = new_name;
	this.rank =0;
	this.next = this;
	}

public UFT_Node getRep(){
	UFT_Node output;
	if (this.next.name == this.name)
		return this;
	else output = this.next.getRep();
	this.next = output; 
	return output;
}

}



Compiler output:
Main.java:5: error: class UFT is public, should be declared in a file named UFT.java
public class UFT {
       ^
Main.java:64: error: class UFT_Node is public, should be declared in a file named UFT_Node.java
public class UFT_Node {
       ^
2 errors
Language: Java

import java.util.ArrayList;
import java.util.Scanner;


public class UFT {
     class UFT_Node {
int name;
UFT_Node next;
int rank;

public UFT_Node(int new_name){
	this.name = new_name;
	this.rank =0;
	this.next = this;
	}

public UFT_Node getRep(){
	UFT_Node output;
	if (this.next.name == this.name)
		return this;
	else output = this.next.getRep();
	this.next = output; 
	return output;
}

}
	UFT_Node[] nodes;
	public static void main(String[] args){
		ArrayList<Integer> output = new ArrayList<Integer>();
		UFT test = new UFT();
		Scanner inputScanner = new Scanner("System.in");
		int n = inputScanner.nextInt();
		int q = inputScanner.nextInt();
		test.nodes = test.makeArray(n);
		
		int type = -1;
		int x= -1;
		int y= -1;
		for (int i=0;i<q;i++){
			type = inputScanner.nextInt();
			x = inputScanner.nextInt();
			y = inputScanner.nextInt();
			if(type ==0){
				test.union(x,y);
			}
			if(type ==1){
				if(test.same(x, y))
					output.add(1);
				else
					output.add(0);
			}
		} 
		for(Integer out : output){
			System.out.println(out.toString());
		}
	}
	public UFT_Node[] makeArray(int num){
		UFT_Node[] output = new UFT_Node[num];
		for (int i=0; i<num;i++){
			output[i] = new UFT_Node(i);
		}
	return output;
	}
	
	public void union(int x, int y){
		UFT_Node yRep = nodes[y].getRep();
		UFT_Node xRep = nodes[x].getRep();
		if (yRep.rank> xRep.rank){
			xRep.next= yRep;
		}
		else if(yRep.rank< xRep.rank){
			yRep.next= xRep;
		}
		else{
			yRep.next= xRep;
			xRep.rank++;
		}
	}
	
	public boolean same (int x, int y){
		return nodes[x].getRep().name==nodes[y].getRep().name;
	}
}



Compiler output:
Main.java:5: error: class UFT is public, should be declared in a file named UFT.java
public class UFT {
       ^
1 error
Language: Java

import java.util.ArrayList;
import java.util.Scanner;


public class Main {
     class UFT_Node {
int name;
UFT_Node next;
int rank;

public UFT_Node(int new_name){
	this.name = new_name;
	this.rank =0;
	this.next = this;
	}

public UFT_Node getRep(){
	UFT_Node output;
	if (this.next.name == this.name)
		return this;
	else output = this.next.getRep();
	this.next = output; 
	return output;
}

}
	UFT_Node[] nodes;
	public static void main(String[] args){
		ArrayList<Integer> output = new ArrayList<Integer>();
		Main test = new Main();
		Scanner inputScanner = new Scanner("System.in");
		int n = inputScanner.nextInt();
		int q = inputScanner.nextInt(" ");
		test.nodes = test.makeArray(n);
		
		int type = -1;
		int x= -1;
		int y= -1;
		for (int i=0;i<q;i++){
			type = inputScanner.nextInt();
			x = inputScanner.nextInt();
			y = inputScanner.nextInt();
			if(type ==0){
				test.union(x,y);
			}
			if(type ==1){
				if(test.same(x, y))
					output.add(1);
				else
					output.add(0);
			}
		} 
		for(Integer out : output){
			System.out.println(out.toString());
		}
	}
	public UFT_Node[] makeArray(int num){
		UFT_Node[] output = new UFT_Node[num];
		for (int i=0; i<num;i++){
			output[i] = new UFT_Node(i);
		}
	return output;
	}
	
	public void union(int x, int y){
		UFT_Node yRep = nodes[y].getRep();
		UFT_Node xRep = nodes[x].getRep();
		if (yRep.rank> xRep.rank){
			xRep.next= yRep;
		}
		else if(yRep.rank< xRep.rank){
			yRep.next= xRep;
		}
		else{
			yRep.next= xRep;
			xRep.rank++;
		}
	}
	
	public boolean same (int x, int y){
		return nodes[x].getRep().name==nodes[y].getRep().name;
	}
}




Compiler output:
Main.java:33: error: incompatible types: String cannot be converted to int
		int q = inputScanner.nextInt(" ");
		                             ^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
1 error
Language: Java

import java.util.ArrayList;
import java.util.Scanner;


public class Main {
     class UFT_Node {
int name;
UFT_Node next;
int rank;

public UFT_Node(int new_name){
	this.name = new_name;
	this.rank =0;
	this.next = this;
	}

public UFT_Node getRep(){
	UFT_Node output;
	if (this.next.name == this.name)
		return this;
	else output = this.next.getRep();
	this.next = output; 
	return output;
}

}
	UFT_Node[] nodes;
	public static void main(String[] args){
		ArrayList<Integer> output = new ArrayList<Integer>();
		Main test = new Main();
		Scanner inputScanner = new Scanner("System.in");
		int n = inputScanner.nextInt();
		int q = inputScanner.nextInt(\s);
		test.nodes = test.makeArray(n);
		
		int type = -1;
		int x= -1;
		int y= -1;
		for (int i=0;i<q;i++){
			type = inputScanner.nextInt();
			x = inputScanner.nextInt();
			y = inputScanner.nextInt();
			if(type ==0){
				test.union(x,y);
			}
			if(type ==1){
				if(test.same(x, y))
					output.add(1);
				else
					output.add(0);
			}
		} 
		for(Integer out : output){
			System.out.println(out.toString());
		}
	}
	public UFT_Node[] makeArray(int num){
		UFT_Node[] output = new UFT_Node[num];
		for (int i=0; i<num;i++){
			output[i] = new UFT_Node(i);
		}
	return output;
	}
	
	public void union(int x, int y){
		UFT_Node yRep = nodes[y].getRep();
		UFT_Node xRep = nodes[x].getRep();
		if (yRep.rank> xRep.rank){
			xRep.next= yRep;
		}
		else if(yRep.rank< xRep.rank){
			yRep.next= xRep;
		}
		else{
			yRep.next= xRep;
			xRep.rank++;
		}
	}
	
	public boolean same (int x, int y){
		return nodes[x].getRep().name==nodes[y].getRep().name;
	}
}




Compiler output:
Main.java:33: error: illegal character: '\'
		int q = inputScanner.nextInt(\s);
		                             ^
Main.java:33: error: not a statement
		int q = inputScanner.nextInt(\s);
		                              ^
Main.java:33: error: ';' expected
		int q = inputScanner.nextInt(\s);
		                               ^
3 errors
Language: Java

import java.util.ArrayList;
import java.util.Scanner;


public class Main {
     class UFT_Node {
int name;
UFT_Node next;
int rank;

public UFT_Node(int new_name){
	this.name = new_name;
	this.rank =0;
	this.next = this;
	}

public UFT_Node getRep(){
	UFT_Node output;
	if (this.next.name == this.name)
		return this;
	else output = this.next.getRep();
	this.next = output; 
	return output;
}

}
	UFT_Node[] nodes;
	public static void main(String[] args){
		ArrayList<Integer> output = new ArrayList<Integer>();
		Main test = new Main();
		Scanner inputScanner = new Scanner("System.in");
		int n = inputScanner.nextInt();
		int q = inputScanner.nextInt("\\s");
		test.nodes = test.makeArray(n);
		
		int type = -1;
		int x= -1;
		int y= -1;
		for (int i=0;i<q;i++){
			type = inputScanner.nextInt();
			x = inputScanner.nextInt(""\\s");
			y = inputScanner.nextInt("\\s");
			if(type ==0){
				test.union(x,y);
			}
			if(type ==1){
				if(test.same(x, y))
					output.add(1);
				else
					output.add(0);
			}
		} 
		for(Integer out : output){
			System.out.println(out.toString());
		}
	}
	public UFT_Node[] makeArray(int num){
		UFT_Node[] output = new UFT_Node[num];
		for (int i=0; i<num;i++){
			output[i] = new UFT_Node(i);
		}
	return output;
	}
	
	public void union(int x, int y){
		UFT_Node yRep = nodes[y].getRep();
		UFT_Node xRep = nodes[x].getRep();
		if (yRep.rank> xRep.rank){
			xRep.next= yRep;
		}
		else if(yRep.rank< xRep.rank){
			yRep.next= xRep;
		}
		else{
			yRep.next= xRep;
			xRep.rank++;
		}
	}
	
	public boolean same (int x, int y){
		return nodes[x].getRep().name==nodes[y].getRep().name;
	}
}




Compiler output:
Main.java:41: error: illegal character: '\'
			x = inputScanner.nextInt(""\\s");
			                           ^
Main.java:41: error: illegal character: '\'
			x = inputScanner.nextInt(""\\s");
			                            ^
Main.java:41: error: unclosed string literal
			x = inputScanner.nextInt(""\\s");
			                              ^
Main.java:41: error: not a statement
			x = inputScanner.nextInt(""\\s");
			                             ^
4 errors
Language: Java

import java.util.ArrayList;
import java.util.Scanner;


public class Main {
     class UFT_Node {
int name;
UFT_Node next;
int rank;

public UFT_Node(int new_name){
	this.name = new_name;
	this.rank =0;
	this.next = this;
	}

public UFT_Node getRep(){
	UFT_Node output;
	if (this.next.name == this.name)
		return this;
	else output = this.next.getRep();
	this.next = output; 
	return output;
}

}
	UFT_Node[] nodes;
	public static void main(String[] args){
		ArrayList<Integer> output = new ArrayList<Integer>();
		Main test = new Main();
		Scanner inputScanner = new Scanner("System.in");
		int n = inputScanner.nextInt();
		int q = inputScanner.nextInt("\\s");
		test.nodes = test.makeArray(n);
		
		int type = -1;
		int x= -1;
		int y= -1;
		for (int i=0;i<q;i++){
			type = inputScanner.nextInt();
			x = inputScanner.nextInt("\\s");
			y = inputScanner.nextInt("\\s");
			if(type ==0){
				test.union(x,y);
			}
			if(type ==1){
				if(test.same(x, y))
					output.add(1);
				else
					output.add(0);
			}
		} 
		for(Integer out : output){
			System.out.println(out.toString());
		}
	}
	public UFT_Node[] makeArray(int num){
		UFT_Node[] output = new UFT_Node[num];
		for (int i=0; i<num;i++){
			output[i] = new UFT_Node(i);
		}
	return output;
	}
	
	public void union(int x, int y){
		UFT_Node yRep = nodes[y].getRep();
		UFT_Node xRep = nodes[x].getRep();
		if (yRep.rank> xRep.rank){
			xRep.next= yRep;
		}
		else if(yRep.rank< xRep.rank){
			yRep.next= xRep;
		}
		else{
			yRep.next= xRep;
			xRep.rank++;
		}
	}
	
	public boolean same (int x, int y){
		return nodes[x].getRep().name==nodes[y].getRep().name;
	}
}




Compiler output:
Main.java:33: error: incompatible types: String cannot be converted to int
		int q = inputScanner.nextInt("\\s");
		                             ^
Main.java:41: error: incompatible types: String cannot be converted to int
			x = inputScanner.nextInt("\\s");
			                         ^
Main.java:42: error: incompatible types: String cannot be converted to int
			y = inputScanner.nextInt("\\s");
			                         ^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
3 errors
Language: Java

import java.util.ArrayList;
import java.util.Scanner;
public class DSL_1_A {
    public static void main(String[] args) {
	Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
	int q = scan.nextInt();
	Union_Find_Tree u = new Union_Find_Tree(n);
	u.make();
	for(int i = 0; i < q; i++) {
	    int com = scan.nextInt();
	    int tree1 = scan.nextInt();
	    int tree2 = scan.nextInt();
	    u.union_judge(com,tree1,tree2);
	}
	for (int i : u.result) System.out.println(i);
    }
}
class Union_Find_Tree {
    int n,flag;
    ArrayList<Integer>tree = new ArrayList<Integer>();
    ArrayList<Integer>union = new ArrayList<Integer>();
    ArrayList<Integer>result = new ArrayList<Integer>();
    public Union_Find_Tree(int n){this.n = n;}

    void union_judge(int com, int tree1, int tree2) {
        if (com == 0) {
	    for(int i = 0; i < n; i++)
		if(union.get(tree2) == union.get(i))
		    union.set(i, union.get(tree1));
	}
	else
	    same(tree1,tree2);
    }
    
    void make() {
	for(int i = 0; i < n; i++) {
	    tree.add(i);
	    union.add(i);
	}
    }
    void same(int tree1, int tree2) {
	if(union.get(tree1) == union.get(tree2)) result.add(1);
	else result.add(0);
    }
}



Compiler output:
Main.java:3: error: class DSL_1_A is public, should be declared in a file named DSL_1_A.java
public class DSL_1_A {
       ^
1 error
Language: Java

import java.util.ArrayList;
import java.util.Scanner;
import java.io.*;
import java.util.*;

/**
 * Created by takaesumizuki on 2018/06/22.
 */
public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    void run() {
        Scanner sc = new Scanner(System.in);
        Integer n = sc.nextInt();
        Integer q = sc.nextInt();
        UnionFind uni = new UnionFind(n);

        while (q-- > 0) {
            Integer com, x, y;
            com = sc.nextInt();
            x = sc.nextInt();
            y = sc.nextInt();

            if (com == 0) {
                uni.merge(x, y);
            } else {
                if (uni.same(x, y)) {
                    System.out.println(1);
                } else {
                    System.out.println(0);
                }
            }


        }

    }


    public class PrimitiveUnionFind {
        int[] unions;

        /**
         * 0 ~ size - 1までの集合を
         *
         * @param size 集合のサイズ
         */
        PrimitiveUnionFind(Integer size) {
            this.unions = new int[size];
            for (Integer i = 0; i < size; i++) {
                this.unions[i] = i;
            }
        }

        int find(int v) {
            if (unions[v] == v) {
                return v;
            } else {
                int ret = find(this.unions[v]);
                this.unions[v] = ret;
                return ret;
            }
        }

        /**
         * v1の集合 を v2の集合にする
         *
         * @param v1
         * @param v2
         */
        void merge(int v1, int v2) {
            int v1Root = find(v1);
            int v2Root = find(v2);

            this.unions[v1Root] = v2Root;
        }

        Boolean same(int v1, int v2) {
            return find(v1) == (find(v2));
        }
    }
}



Compiler output:
Main.java:18: error: cannot find symbol
        UnionFind uni = new UnionFind(n);
        ^
  symbol:   class UnionFind
  location: class Main
Main.java:18: error: cannot find symbol
        UnionFind uni = new UnionFind(n);
                            ^
  symbol:   class UnionFind
  location: class Main
2 errors
Language: C

#include<stdio.h
int main(void){
 printf("check\n")
}


Compiler output:
main.c:1:17: error: missing terminating > character
    1 | #include<stdio.h
      |                 ^
main.c: In function 'main':
main.c:3:19: error: expected ';' before '}' token
    3 |  printf("check\n")
      |                   ^
      |                   ;
    4 | }
      | ~
Language: C

#include <iostream>
#include <algorithm>

using namespace std;

const int MAX_N = 10000;

int par[MAX_N];
int rank[MAX_N];

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);
}

main(){
  int n, q;
  cin >> n >> q;
  init(n);
  for(int i=0;i<q;i++){
    int a, b, c;
    cin >> a >> b >> c;
    if(a) cout << same(b, c) << endl;
    else unite(b, c);
  }
}

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

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

#define MAX 100001

int par[MAX];
int rank[MAX];

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

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

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

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() {
  
  int n, q;
  int com, x, y;
  
  init_union_find();
  cin >> n >> q;
  for(int i=0; i<q; i++) {
    cin >> com >> x >> y;
    if(com == 0) unite(x, y);
    else {
      cout << same(x, y) << endl;
    }
  }
  
  return 0;
}

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

#include <iostream>
#define MAX 100001

using namespace std;

int par[MAX],rank[MAX],n,m;

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

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

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

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

int main(void){
  int com,x,y;
  init();
  cin >> n >> m;
  for(int i = 0 ; i < m ; i++){
    cin >> com >> x >> y;
    if(com){
      same(x,y);
      if(par[x] == par[y]) cout << '1' << endl;
      else cout << '0' << endl;
    }
    else unite(x,y);
  }
  return 0;
}

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

class Hello{
	public static void main(String[] args){
		System.out.println("HelloWorld");
	}
}

Compiler output:
main.c:1:1: error: unknown type name 'class'
    1 | class Hello{
      | ^~~~~
main.c:1:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
    1 | class Hello{
      |            ^
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 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);
        else if(t==1){
            if(ds.same(a,b)) cout << 1 << endl;
            else cout << 0 << endl;
        }
    }

    return 0;
}


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

p=[]
rank=[]
answer=[]

def makeset(x):
    p[x] = x
    rank[x] = 0
    
def union(x,y):
    link(findset(x),findset(y))
    
def link(x,y):
    if rank[x] > rank[y]:
        p[y] = x
    else:
        p[x] = y
        if rank[x] == rank[y]:
            rank[y] = rank[y] + 1
def findset(x):
    if x != p[x]:
        p[x] = findset(p[x])
    return p[x]

t,s = map(int,input().split())
for i in range(t):
    p.append(None)
    rank.append(None)
while True:
    try:
        o,x,y = map(int,input().split())
    except:
        break
    else:
        if o == 0:
            if p[x] == None:
                makeset(x)
            if p[y] == None:
                makeset(y)
            union(x,y)
            print(p[x])
            print(rank[x])
        else:
            if p[x] == None:
                makeset(x)
            if p[y] == None:
                makeset(y)
            if findset(x) == findset(y):
                answer.append(1)
            else:
                answer.append(0)
for i in range(len(answer)):
    print(answer[i])        


Compiler output:
a.cc:1:1: error: 'p' does not name a type
    1 | p=[]
      | ^
Language: C++

#include <iosteam>
using namespace std;
#define MAX 10005
int main(void) {
    int n, q, G[MAX];
    cin >> n >> q;
    for (int i = 0; i < n; i++) {
        G[i] = 0;
    }
    int group = 1;
    while (q--) {
        int com, x, y;
        cin >> com >> x >> y;
        if (com == 0) {
            if (G[x] == 0 && G[y] == 0) {
                G[x] = G[y] = group;
                group++;
            } else if (G[x] == 0 || G[y] == 0) {
                if (G[x] == 0)
                    G[x] = G[y];
                else
                    G[y] = G[x];
            } else {
                int g = G[x];
                for (int i = 0; i < n; i++) {
                    if (G[i] = g)
                        G[i] = G[y];
                }
            }
        } else {
            if (G[x] == G[y]) 
                cout << 1 << endl;
            else
                cout << 0 << endl;
        }
    }
}


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

#include <iostream>
using namespace std;
#define MAX 10005
int main(void) {
    int n, q, G[MAX];
    cin >> n >> q;
    for (int i = 0; i < n; i++) {
        G[i] = 0;
    }
    int group = 1;
    while (q--) {
        int com, x, y;
        cin >> com >> x >> y;
        if (com == 0) {
            if (G[x] == 0 && G[y] == 0) {
                G[x] = G[y] = group;
                group++;
            } else if (G[x] == 0 || G[y] == 0) {
                if (G[x] == 0)
                    G[x] = G[y];
                else
                    G[y] = G[x];
            } else {
                int g = G[x];
                for (int i = 0; i < n; i++) {
                    if (G[i] == g)
                        G[i] = G[y];
                }
            }
        } else {
            if (G]x] != 0 && G[x] == G[y]) 
                cout << 1 << endl;
            else
                cout << 0 << endl;
        }
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:18: error: expected ')' before ']' token
   31 |             if (G]x] != 0 && G[x] == G[y])
      |                ~ ^
      |                  )
a.cc:31:18: error: expected primary-expression before ']' token
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <sstream>
#include <iomanip>//小数精度 	cout << fixed << setprecision(5) << tmp << endl;
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define All(X)      (X).begin(),(X).end()

int  n,q;
int pare[10000];
int ranku[10000];

void init(int n){
    REP(i,n){
        pare[i]=i;
        ranku[i]=0;
    }
    return;
}

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

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

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

Compiler output:
a.cc: In function 'int find(int)':
a.cc:33:8: error: 'par' was not declared in this scope; did you mean '__pstl::execution::v1::par'?
   33 |     if(par[x]==x){
      |        ^~~
      |        __pstl::execution::v1::par
In file included from /usr/include/c++/14/pstl/glue_algorithm_defs.h:15,
                 from /usr/include/c++/14/algorithm:86,
                 from a.cc:2:
/usr/include/c++/14/pstl/execution_defs.h:43:45: note: '__pstl::execution::v1::par' declared here
   43 | _GLIBCXX17_INLINE constexpr parallel_policy par{};
      |                                             ^~~
a.cc:38:1: warning: control reaches end of non-void function [-Wreturn-type]
   38 | }
      | ^
Language: C++

#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include"union_find.hpp"

int n, q;
union_find<int> U;

int main(){
	scanf("%d %d", &n, &q);
	for (int i = 0; i < n; ++i)U.add(i);
	for (int i = 0; i < q; ++i){
		int a, b, c;
		scanf("%d %d %d", &a, &b, &c);
		if (a == 0){
			U.unite(b, c);
		}
		else {
			//if (U.is_same(b, c))printf("1\n");
			//else printf("0\n");
			printf("%d\n", int(U.is_same(b, c)));
		}
	}
	return 0;
}

Compiler output:
a.cc:3:9: fatal error: union_find.hpp: No such file or directory
    3 | #include"union_find.hpp"
      |         ^~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define rer(i, a, b) for (int i = (int)a; i <= (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int inf = 1000000000;
const int mod = 1000000007;
const double eps = 1e-9;
const int dx[] = { -1, 0, 1, 0};
const int dy[] = { 0, -1, 0, 1};

struct UnionFind {
	vector<int> data;
	// ?????????
	void init(int n) {
		data.assign(n, -1);
	}
	// x ??¨ y ?????????
	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;
	}
	// x ??¨ y ?????????????????????????????????
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	// x ??????????????????????´???°????±???????
	int size(int x) {
		return -data[root(x)];
	}
	// ????????¢???
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
};

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

	rep(i, q) {
		int c, x, y;
		cin >> c >> x >> y;

		if (c == 0) {
			uf.union_set(x, y);
		} else {
			cout << uf.find_set(x, y) << endl;
		}
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:67:28: error: 'struct UnionFind' has no member named 'union_set'; did you mean 'unionSet'?
   67 |                         uf.union_set(x, y);
      |                            ^~~~~~~~~
      |                            unionSet
a.cc:69:36: error: 'struct UnionFind' has no member named 'find_set'; did you mean 'findSet'?
   69 |                         cout << uf.find_set(x, y) << endl;
      |                                    ^~~~~~~~
      |                                    findSet
Language: C++

#include <cstdio>
int a[10000];
int h;
int Find(int x)
{
    if(a[x]!=-1)
    {
        ++h;
        return Find(a[x]);
    }
    else
        return x;
}
void Union(int x,int y)
{
    h=0;
    int dumy=Find(y);
    int yh=h;
    h=0;
    int dumx=Find(x);
    int xh=h;
    if(xh>yh)
        a[dumy]=dumx;
    else
        a[dumx]=dumy;
}
int same(int x,int y)
{
    if(Find(x)==Find(y))
        return 1;
    else
        return 0;
}
int main()
{
    int k,n;
    scanf("%d %d",&k,&n);
    for(int i=0; i<ka; ++i)
        --a[i];
    for(int m=0; m<n; ++m)
    {
        int cmd,x,y;
        scanf("%d %d %d",&cmd,&x,&y);
        if(cmd==0)
            Union(x,y);
        else
            printf("%d\n",same(x,y));
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:38:20: error: 'ka' was not declared in this scope; did you mean 'k'?
   38 |     for(int i=0; i<ka; ++i)
      |                    ^~
      |                    k