Language: C++

import java.util.Scanner;

class Main
{
    static int[][]M = new int[100][100];

    static int prim(int n)
    {
	int u, minv;
	int sum = 0;
	int[]d = new int[100];
	int[]f = new int[100];
	int[]cl = new int[100];

	for(int i = 0; i < n; i++)
	    {
		d[i] = 200000;
		f[i] = -1;
		cl[i] = 0;
	    }

	d[0] = 0;

	while(true)
	    {
		minv = 200000;
		u = -1;

		for(int i = 0; i < n; i++)
		    {
			if(minv > d[i] && cl[i] != 2)
			    {
				u = i;
				minv = d[i];
			    }
		    }

		if(u == -1) break;
		cl[u] = 2;

		for(int j = 0; j < n; j++)
		    {
			if(cl[j] != 2 && M[u][j] != 200000)
			    {
				if(d[j] > M[u][j])
				   {
				       d[j] = M[u][j];
				       f[j] = u;
				       cl[j] = 1;
				   }
			    }
		    }
	    }
		for(int i = 0; i < n; i++)
		    {
			if(f[i] != -1) sum += M[i][f[i]];
		    }
	    
	return sum;
    }

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

	int n = In.nextInt();

	for(int i = 0; i < n; i++)
	    {
		for(int j = 0; j < n; j++)
		    {
			int e = In.nextInt();
			M[i][j] = ((e == -1) ? 200000 : e);
		    }
	    }

	System.out.println(prim(n));

    }
}

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:15: error: expected unqualified-id before '[' token
    5 |     static int[][]M = new int[100][100];
      |               ^
a.cc:62:11: error: expected ':' before 'static'
   62 |     public static void main(String[] args)
      |           ^~~~~~~
      |           :
a.cc:62:29: error: 'String' has not been declared
   62 |     public static void main(String[] args)
      |                             ^~~~~~
a.cc:62:38: error: expected ',' or '...' before 'args'
   62 |     public static void main(String[] args)
      |                                      ^~~~
a.cc:80:2: error: expected ';' after class definition
   80 | }
      |  ^
      |  ;
a.cc: In static member function 'static int Main::prim(int)':
a.cc:11:12: error: structured binding declaration cannot have type 'int'
   11 |         int[]d = new int[100];
      |            ^~
a.cc:11:12: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:11:12: error: empty structured binding declaration
a.cc:11:14: error: expected initializer before 'd'
   11 |         int[]d = new int[100];
      |              ^
a.cc:12:12: error: structured binding declaration cannot have type 'int'
   12 |         int[]f = new int[100];
      |            ^~
a.cc:12:12: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:12:12: error: empty structured binding declaration
a.cc:12:14: error: expected initializer before 'f'
   12 |         int[]f = new int[100];
      |              ^
a.cc:13:12: error: structured binding declaration cannot have type 'int'
   13 |         int[]cl = new int[100];
      |            ^~
a.cc:13:12: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:13:12: error: empty structured binding declaration
a.cc:13:14: error: expected initializer before 'cl'
   13 |         int[]cl = new int[100];
      |              ^~
a.cc:17:17: error: 'd' was not declared in this scope
   17 |                 d[i] = 200000;
      |                 ^
a.cc:18:17: error: 'f' was not declared in this scope
   18 |                 f[i] = -1;
      |                 ^
a.cc:19:17: error: 'cl' was not declared in this scope
   19 |                 cl[i] = 0;
      |                 ^~
a.cc:22:9: error: 'd' was not declared in this scope
   22 |         d[0] = 0;
      |         ^
a.cc:31:43: error: 'cl' was not declared in this scope
   31 |                         if(minv > d[i] && cl[i] != 2)
      |                                           ^~
a.cc:39:17: error: 'cl' was not declared in this scope
   39 |                 cl[u] = 2;
      |                 ^~
a.cc:43:42: error: 'M' was not declared in this scope
   43 |                         if(cl[j] != 2 && M[u][j] != 200000)
      |                                          ^
a.cc:48:40: error: 'f' was not declared in this scope
   48 |                                        f[j] = u;
      |                                        ^
a.cc:56:28: error: 'f' was not declared in this scope
   56 |                         if(f[i] != -1) sum += M[i][f[i]];
      |                            ^
a.cc:56:47: error: 'M' was not declared in this scope
   56 |                         if(f[i] != -1) sum += M[i][f[i]];
      |                                               ^
a.cc: In static member function 'static void Main::main(int*)':
a.cc:64:9: error: 'Scanner' was not declared in this scope
   64 |         Scanner In = new Scanner(System.in);
      |         ^~~~~~~
a.cc:66:17: error: 'In' was not declared in this scope; did you mean 'n'?
   66 |         int n = In.nextInt();
      |                 ^~
      |                 n
a.cc:73:25: error: 'M' was not declared in this scope
   73 |                         M[i][j] = ((e == -1) ? 200000 : e);
      |                         ^
a.cc:77:9: error: 'System' was not declared in this scope
   77 |         System.out.println(prim(n));
      |         ^~~~~~