Language: C++

import java.util.*;

class Main{
	public static void main(String[] $){
		//入力
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), m = sc.nextInt();

		HashMap<Integer,ArrayList<Integer>> map = new HashMap<>();
		PriorityQueue<Integer> tasks = new PriorityQueue<>(Comparator.reverseOrder());

		for(int i = 0; i < n; i++){
			int a = sc.nextInt(), b = sc.nextInt();
			map.computeIfAbsent(a, o -> new ArrayList<>()).add(b);
		}

		sc.close();


		//処理
		long ans = 0;

		for(int i = 1; i <= m; i++){
			ArrayList<Integer> list = map.get(i);
			if(list != null){
				for(Integer item : list) tasks.add(item);
			}
			Integer task = tasks.poll();
			if(task != null) ans += task;
		}


		//出力
		System.out.println(ans);
	}
}


Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.*;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:15: error: expected ':' before 'static'
    4 |         public static void main(String[] $){
      |               ^~~~~~~
      |               :
a.cc:4:33: error: 'String' has not been declared
    4 |         public static void main(String[] $){
      |                                 ^~~~~~
a.cc:4:42: error: expected ',' or '...' before '$'
    4 |         public static void main(String[] $){
      |                                          ^
a.cc:36:2: error: expected ';' after class definition
   36 | }
      |  ^
      |  ;
a.cc: In static member function 'static void Main::main(int*)':
a.cc:6:17: error: 'Scanner' was not declared in this scope
    6 |                 Scanner sc = new Scanner(System.in);
      |                 ^~~~~~~
a.cc:7:25: error: 'sc' was not declared in this scope
    7 |                 int n = sc.nextInt(), m = sc.nextInt();
      |                         ^~
a.cc:9:17: error: 'HashMap' was not declared in this scope
    9 |                 HashMap<Integer,ArrayList<Integer>> map = new HashMap<>();
      |                 ^~~~~~~
a.cc:9:25: error: 'Integer' was not declared in this scope
    9 |                 HashMap<Integer,ArrayList<Integer>> map = new HashMap<>();
      |                         ^~~~~~~
a.cc:9:33: error: 'ArrayList' was not declared in this scope
    9 |                 HashMap<Integer,ArrayList<Integer>> map = new HashMap<>();
      |                                 ^~~~~~~~~
a.cc:9:53: error: 'map' was not declared in this scope
    9 |                 HashMap<Integer,ArrayList<Integer>> map = new HashMap<>();
      |                                                     ^~~
a.cc:9:63: error: 'HashMap' does not name a type
    9 |                 HashMap<Integer,ArrayList<Integer>> map = new HashMap<>();
      |                                                               ^~~~~~~
a.cc:9:71: error: expected primary-expression before '>' token
    9 |                 HashMap<Integer,ArrayList<Integer>> map = new HashMap<>();
      |                                                                       ^
a.cc:9:73: error: expected primary-expression before ')' token
    9 |                 HashMap<Integer,ArrayList<Integer>> map = new HashMap<>();
      |                                                                         ^
a.cc:10:17: error: 'PriorityQueue' was not declared in this scope
   10 |                 PriorityQueue<Integer> tasks = new PriorityQueue<>(Comparator.reverseOrder());
      |                 ^~~~~~~~~~~~~
a.cc:10:40: error: 'tasks' was not declared in this scope
   10 |                 PriorityQueue<Integer> tasks = new PriorityQueue<>(Comparator.reverseOrder());
      |                                        ^~~~~
a.cc:10:52: error: 'PriorityQueue' does not name a type
   10 |                 PriorityQueue<Integer> tasks = new PriorityQueue<>(Comparator.reverseOrder());
      |                                                    ^~~~~~~~~~~~~
a.cc:10:66: error: expected primary-expression before '>' token
   10 |                 PriorityQueue<Integer> tasks = new PriorityQueue<>(Comparator.reverseOrder());
      |                                                                  ^
a.cc:10:68: error: 'Comparator' was not declared in this scope
   10 |                 PriorityQueue<Integer> tasks = new PriorityQueue<>(Comparator.reverseOrder());
      |                                                                    ^~~~~~~~~~
a.cc:14:48: error: 'o' was not declared in this scope
   14 |                         map.computeIfAbsent(a, o -> new ArrayList<>()).add(b);
      |                                                ^
a.cc:14:53: error: expected unqualified-id before 'new'
   14 |                         map.computeIfAbsent(a, o -> new ArrayList<>()).add(b);
      |                                                     ^~~
a.cc:14:76: error: 'b' was not declared in this scope
   14 |                         map.computeIfAbsent(a, o -> new ArrayList<>()).add(b);
      |                                                                            ^
a.cc:23:37: error: 'm' was not declared in this scope
   23 |                 for(int i = 1; i <= m; i++){
      |                                     ^
a.cc:24:44: error: 'list' was not declared in this scope
   24 |                         ArrayList<Integer> list = map.get(i);
      |                                            ^~~~
a.cc:25:36: error: 'null' was not declared in this scope
   25 |                         if(list != null){
      |                                    ^~~~
a.cc:26:45: error: expected ';' before 'item'
   26 |                                 for(Integer item : list) tasks.add(item);
      |                                             ^~~~
a.cc:27:25: error: expected primary-expression before '}' token
   27 |                         }
      |                         ^
a.cc:27:25: error: expected ';' before '}' token
a.cc:27:25: error: expected primary-expression before '}' token
a.cc:27:25: error: expected ')' before '}' token
a.cc:26:36: note: to match this '('
   26 |                                 for(Integer item : list) tasks.add(item);
      |                                    ^
a.cc:27:25: error: expected primary-expression before '}' token
   27 |                         }
      |                         ^
a.cc:28:33: error: expected ';' before 'task'
   28 |                         Integer task = tasks.poll();
      |                                 ^~~~
a.cc:29:28: error: 'task' was not declared in this scope
   29 |                         if(task != null) ans += task;
      |                            ^~~~
a.cc:29:36: error: 'null' was not declared in this scope
   29 |                         if(task != null) ans += task;
      |                                    ^~~~
a.cc:34:17: error: 'System' was not declared in this scope
   34 |                 System.out.println(ans);
      |                 ^~~~~~