Language: C++

import java.util.Scanner;
//import java.util.Random;

class UnionFind{
	int[] par;
	int num;
	
	UnionFind(int n){//constructor.
		par=new int[n];
		for(int i=0;i<n;++i) par[i]=-1;
		num=n;
	}
	
	void init(int n){
		par=new int[n];
		for(int i=0;i<n;++i) par[i]=-1;
		num=n;
	}
	
	int root(int x){
		if(par[x]<0) return x;
		par[x]=root(par[x]);
		return par[x];
	}
	
	int size(int x){
		return -par[root(x)];
	}
	
	boolean same(int x,int y){
		return root(x)==root(y);
	}
	
	boolean unite(int x,int y){
		x=root(x);
		y=root(y);
		if(x==y) return false;
		par[x]+=par[y];
		par[y]=x;
		num--;
		return true;
	}
}

class Main{
	public static void main(String[] args){
		Scanner stdIn=new Scanner(System.in);
		
		int n=stdIn.nextInt();
		int m=stdIn.nextInt();
		
		int[] a=new int[m];
		int[] b=new int[m];
		for(int i=0;i<m;++i){
			a[i]=stdIn.nextInt();
			b[i]=stdIn.nextInt();
			a[i]--;
			b[i]--;
		}
		
		int ans=0;
		for(int i=0;i<m;++i){
			UnionFind uf=new UnionFind(n);
			for(int j=0;j<m;++j){
				if(i==j){}
				else uf.unite(a[j],b[j]);
			}
			if(uf.num>1) ans++;
		}
		
		System.out.println(ans);
	}
}

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.Scanner;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:12: error: expected unqualified-id before '[' token
    5 |         int[] par;
      |            ^
a.cc:30:9: error: 'boolean' does not name a type; did you mean 'bool'?
   30 |         boolean same(int x,int y){
      |         ^~~~~~~
      |         bool
a.cc:34:9: error: 'boolean' does not name a type; did you mean 'bool'?
   34 |         boolean unite(int x,int y){
      |         ^~~~~~~
      |         bool
a.cc:43:2: error: expected ';' after class definition
   43 | }
      |  ^
      |  ;
a.cc: In constructor 'UnionFind::UnionFind(int)':
a.cc:9:17: error: 'par' was not declared in this scope
    9 |                 par=new int[n];
      |                 ^~~
a.cc: In member function 'void UnionFind::init(int)':
a.cc:15:17: error: 'par' was not declared in this scope
   15 |                 par=new int[n];
      |                 ^~~
a.cc: In member function 'int UnionFind::root(int)':
a.cc:21:20: error: 'par' was not declared in this scope
   21 |                 if(par[x]<0) return x;
      |                    ^~~
a.cc:22:17: error: 'par' was not declared in this scope
   22 |                 par[x]=root(par[x]);
      |                 ^~~
a.cc: In member function 'int UnionFind::size(int)':
a.cc:27:25: error: 'par' was not declared in this scope
   27 |                 return -par[root(x)];
      |                         ^~~
a.cc: At global scope:
a.cc:46:15: error: expected ':' before 'static'
   46 |         public static void main(String[] args){
      |               ^~~~~~~
      |               :
a.cc:46:33: error: 'String' has not been declared
   46 |         public static void main(String[] args){
      |                                 ^~~~~~
a.cc:46:42: error: expected ',' or '...' before 'args'
   46 |         public static void main(String[] args){
      |                                          ^~~~
a.cc:73:2: error: expected ';' after class definition
   73 | }
      |  ^
      |  ;
a.cc: In static member function 'static void Main::main(int*)':
a.cc:47:17: error: 'Scanner' was not declared in this scope
   47 |                 Scanner stdIn=new Scanner(System.in);
      |                 ^~~~~~~
a.cc:49:23: error: 'stdIn' was not declared in this scope; did you mean 'std'?
   49 |                 int n=stdIn.nextInt();
      |                       ^~~~~
      |                       std
a.cc:52:20: error: structured binding declaration cannot have type 'int'
   52 |                 int[] a=new int[m];
      |                    ^~
a.cc:52:20: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:52:20: error: empty structured binding declaration
a.cc:52:23: error: expected initializer before 'a'
   52 |                 int[] a=new int[m];
      |                       ^
a.cc:53:20: error: structured binding declaration cannot have type 'int'
   53 |                 int[] b=new int[m];
      |                    ^~
a.cc:53:20: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:53:20: error: empty structured binding declaration
a.cc:53:23: error: expected initializer before 'b'
   53 |                 int[] b=new int[m];
      |                       ^
a.cc:55:25: error: 'a' was not declared in this scope
   55 |                         a[i]=stdIn.nextInt();
      |                         ^
a.cc:56:25: error: 'b' was not declared in this scope
   56 |                         b[i]=stdIn.nextInt();
      |                         ^
a.cc:63:53: error: 'UnionFind::UnionFind(int)' is private within this context
   63 |                         UnionFind uf=new UnionFind(n);
      |                                                     ^
a.cc:8:9: note: declared private here
    8 |         UnionFind(int n){//constructor.
      |         ^~~~~~~~~
a.cc:63:53: error: 'UnionFind::UnionFind(int)' is private within this context
   63 |                         UnionFind uf=new UnionFind(n);
      |                                                     ^
a.cc:8:9: note: declared private here
    8 |         UnionFind(int n){//constructor.
      |         ^~~~~~~~~
a.cc:63:38: error: invalid conversion from 'UnionFind*' to 'int' [-fpermissive]
   63 |                         UnionFind uf=new UnionFind(n);
      |                                      ^~~~~~~~~~~~~~~~
      |                                      |
      |                                      UnionFind*
a.cc:8:23: note:   initializing argument 1 of 'UnionFind::UnionFind(int)'
    8 |         UnionFind(int n){//constructor.
      |                   ~~~~^
a.cc:66:41: error: 'class UnionFind' has no member named 'unite'
   66 |                                 else uf.unite(a[j],b[j]);
      |                                         ^~~~~
a.cc:66:47: error: 'a' was not declared in this scope
   66 |                                 else uf.unite(a[j],b[j]);
      |                                               ^
a.cc:66:52: error: 'b' was not declared in this scope
   66 |                                 else uf.unite(a[j],b[j]);
      |                                                    ^
a.cc:68:31: error: 'int UnionFind::num' is private within this context
   68 |                         if(uf.num>1) ans++;
      |                               ^~~
a.cc:6:13: note: declared private here
    6 |         int num;
      |             ^~~
a.cc:71:17: error: 'System' was not declared in this scope
   71 |                 System.out.println(ans);
      |                 ^~~~~~