Language: C++

import java.util.ArrayList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

@SuppressWarnings("unchecked")
class MinCostTree{

    int N;
    class Edge{
        int from,to;
        long w;
        Edge(int from,int to,long w){this.from=from;this.to=to;this.w=w;}
    }
    List<Edge> edges[];
    List<Edge> minedge[];
    void add_edge(int u,int v,long w){
        edges[u].add(new Edge(u,v,w));
        edges[v].add(new Edge(v,u,w));
    }
    MinCostTree(int N){
        this.N=N;
        edges = new ArrayList[N];
        minedge = new ArrayList[N];
        for(int i=0;i<N;++i)edges[i]=new ArrayList<>();
        for(int i=0;i<N;++i)minedge[i]=new ArrayList<>();
    }
    long mincost(){
        PriorityQueue<Edge> que = new PriorityQueue<>((a,b)->a.w<b.w ? -1:1);
        boolean used[] = new boolean[N];
        used[0]=true;
        long res = 0;
        for(Edge e : edges[0])que.add(e);
        while(!que.isEmpty()){
            Edge e = que.poll();
            if(used[e.to])continue;
            used[e.to]=true;
            minedge[e.from].add(e);
            res += e.w;
            for(Edge ed : edges[e.to])que.add(ed);
        }
        return res;
    }
}

class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        MinCostTree mct = new MinCostTree(n);
        for(int i=0;i<n;++i){
            for(int j=0;j<n;++j){
                long a = scan.nextLong();
                if(i>j && a>0)mct.add_edge(i, j, a);
            }
        }
        System.out.println(mct.mincost());
    }
}


Compiler output:
a.cc:6:1: error: stray '@' in program
    6 | @SuppressWarnings("unchecked")
      | ^
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.ArrayList;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
    2 | import java.util.List;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
    3 | import java.util.PriorityQueue;
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
    4 | import java.util.Scanner;
      | ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:6:18: error: expected constructor, destructor, or type conversion before '(' token
    6 | @SuppressWarnings("unchecked")
      |                  ^
a.cc:47:11: error: expected ':' before 'static'
   47 |     public static void main(String[] args){
      |           ^~~~~~~
      |           :
a.cc:47:29: error: 'String' has not been declared
   47 |     public static void main(String[] args){
      |                             ^~~~~~
a.cc:47:38: error: expected ',' or '...' before 'args'
   47 |     public static void main(String[] args){
      |                                      ^~~~
a.cc:59:2: error: expected ';' after class definition
   59 | }
      |  ^
      |  ;
a.cc: In static member function 'static void Main::main(int*)':
a.cc:48:9: error: 'Scanner' was not declared in this scope
   48 |         Scanner scan = new Scanner(System.in);
      |         ^~~~~~~
a.cc:49:17: error: 'scan' was not declared in this scope
   49 |         int n = scan.nextInt();
      |                 ^~~~
a.cc:50:9: error: 'MinCostTree' was not declared in this scope
   50 |         MinCostTree mct = new MinCostTree(n);
      |         ^~~~~~~~~~~
a.cc:54:31: error: 'mct' was not declared in this scope
   54 |                 if(i>j && a>0)mct.add_edge(i, j, a);
      |                               ^~~
a.cc:57:9: error: 'System' was not declared in this scope
   57 |         System.out.println(mct.mincost());
      |         ^~~~~~
a.cc:57:28: error: 'mct' was not declared in this scope
   57 |         System.out.println(mct.mincost());
      |                            ^~~