Language: C++

import java.awt.Point;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Set;
import java.util.Stack;
import java.io.IOException;

class MyScanner {
    BufferedReader br;

    MyScanner() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    public int intLine() throws IOException {
        return Integer.parseInt(br.readLine());
    }

    public String line() throws IOException {
        return br.readLine();
    }

    public int[] intArray() throws IOException {
        String[] in = br.readLine().split(" ");
        int n = in.length;
        int[] res = new int[n];
        for(int i = 0; i < n; i++) {
            res[i] = Integer.parseInt(in[i]);
        }
        return res;
    }
}

class Pair implements Comparable<Pair> {
    long t;
    int i;

    Pair(long t, int i) {
        this.t = t;
        this.i = i;
    }

    public int compareTo(Pair p) {
        return t > p.t? 1 : -1;
    }
}

public class Main {
    public static void main(String[] args) throws IOException {
        MyScanner sc = new MyScanner();

        int[] in = sc.intArray();
        int n = in[0];
        int m = in[1];

        List<List<Integer>> job = new ArrayList<>();
        for(int i = 0; i < m; i++) {
            job.add(new ArrayList<>());
        }
        for(int i = 0; i < n; i++) {
            in = sc.intArray();
            int a = in[0];
            int b = in[1];
            if(m - a >= 0) job.get(m - a).add(b);
        }

        long ans = 0;
        PriorityQueue<Integer> pq = new PriorityQueue<>(Collections.reverseOrder());
        for(int i = m - 1; i >= 0; i--) {
            for(int x : job.get(i)) {
                pq.add(x);
            }
            if(!pq.isEmpty()) ans += pq.poll();
        }
        
        System.out.println(ans);

        sc.br.close();
    }
}


Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.awt.Point;
      | ^~~~~~
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.io.BufferedReader;
      | ^~~~~~
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.io.InputStreamReader;
      | ^~~~~~
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.ArrayList;
      | ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: 'import' does not name a type
    5 | import java.util.Collections;
      | ^~~~~~
a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:6:1: error: 'import' does not name a type
    6 | import java.util.Comparator;
      | ^~~~~~
a.cc:6:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:7:1: error: 'import' does not name a type
    7 | import java.util.HashMap;
      | ^~~~~~
a.cc:7:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:8:1: error: 'import' does not name a type
    8 | import java.util.LinkedList;
      | ^~~~~~
a.cc:8:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:9:1: error: 'import' does not name a type
    9 | import java.util.List;
      | ^~~~~~
a.cc:9:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:10:1: error: 'import' does not name a type
   10 | import java.util.Map;
      | ^~~~~~
a.cc:10:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:11:1: error: 'import' does not name a type
   11 | import java.util.PriorityQueue;
      | ^~~~~~
a.cc:11:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:12:1: error: 'import' does not name a type
   12 | import java.util.Set;
      | ^~~~~~
a.cc:12:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:13:1: error: 'import' does not name a type
   13 | import java.util.Stack;
      | ^~~~~~
a.cc:13:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:14:1: error: 'import' does not name a type
   14 | import java.io.IOException;
      | ^~~~~~
a.cc:14:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:17:5: error: 'BufferedReader' does not name a type
   17 |     BufferedReader br;
      |     ^~~~~~~~~~~~~~
a.cc:23:11: error: expected ':' before 'int'
   23 |     public int intLine() throws IOException {
      |           ^~~~
      |           :
a.cc:23:24: error: expected ';' at end of member declaration
   23 |     public int intLine() throws IOException {
      |                        ^
      |                         ;
a.cc:23:26: error: 'throws' does not name a type
   23 |     public int intLine() throws IOException {
      |                          ^~~~~~
a.cc:27:11: error: expected ':' before 'String'
   27 |     public String line() throws IOException {
      |           ^~~~~~~
      |           :
a.cc:27:12: error: 'String' does not name a type
   27 |     public String line() throws IOException {
      |            ^~~~~~
a.cc:31:11: error: expected ':' before 'int'
   31 |     public int[] intArray() throws IOException {
      |           ^~~~
      |           :
a.cc:31:15: error: expected unqualified-id before '[' token
   31 |     public int[] intArray() throws IOException {
      |               ^
a.cc:40:2: error: expected ';' after class definition
   40 | }
      |  ^
      |  ;
a.cc: In constructor 'MyScanner::MyScanner()':
a.cc:20:9: error: 'br' was not declared in this scope
   20 |         br = new BufferedReader(new InputStreamReader(System.in));
      |         ^~
a.cc:20:18: error: expected type-specifier before 'BufferedReader'
   20 |         br = new BufferedReader(new InputStreamReader(System.in));
      |                  ^~~~~~~~~~~~~~
a.cc: At global scope:
a.cc:42:23: error: expected initializer before 'Comparable'
   42 | class Pair implements Comparable<Pair> {
      |                       ^~~~~~~~~~
a.cc:56:1: error: expected unqualified-id before 'public'
   56 | public class Main {
      | ^~~~~~