Language: C++

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

class AB {
	private Long fA;
	private int fB;

	public AB(Long a, int b) {
		fA = a;
		fB = b;
	}

	public Long getA() {
		return fA;
	}

	public int getB() {
		return fB;
	}

	public void setB(int b) {
		fB = b;
	}
}

class compAB implements Comparator<AB> {
	public int compare(AB ab1, AB ab2) {
		if (ab1.getA() < ab2.getA()) {
			return -1;
		} else {
			return 1;
		}
	}
}

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		ArrayList<AB> ABList = new ArrayList<AB>();
		for (int i = 0; i < N; i++) {
			Long a = sc.nextLong();
			int b = sc.nextInt();
			ABList.add(new AB(a, b));
		}

		Collections.sort(ABList, new compAB());

		long c = 0;
		int id = 0;
		for (int j = 0; j < M; j++) {
			c += ABList.get(id).getA();
			ABList.get(id).setB(ABList.get(id).getB() - 1);
			if (ABList.get(id).getB() <= 0) {
				id++;
			}
		}

		System.out.println(c);

		sc.close();
	}
}


Compiler output:
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.Collections;
      | ^~~~~~
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.Comparator;
      | ^~~~~~
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:7:16: error: expected ':' before 'Long'
    7 |         private Long fA;
      |                ^~~~~
      |                :
a.cc:7:17: error: 'Long' does not name a type; did you mean 'long'?
    7 |         private Long fA;
      |                 ^~~~
      |                 long
a.cc:8:16: error: expected ':' before 'int'
    8 |         private int fB;
      |                ^~~~
      |                :
a.cc:10:15: error: expected ':' before 'AB'
   10 |         public AB(Long a, int b) {
      |               ^~~
      |               :
a.cc:10:23: error: expected ')' before 'a'
   10 |         public AB(Long a, int b) {
      |                  ~    ^~
      |                       )
a.cc:15:15: error: expected ':' before 'Long'
   15 |         public Long getA() {
      |               ^~~~~
      |               :
a.cc:15:16: error: 'Long' does not name a type; did you mean 'long'?
   15 |         public Long getA() {
      |                ^~~~
      |                long
a.cc:19:15: error: expected ':' before 'int'
   19 |         public int getB() {
      |               ^~~~
      |               :
a.cc:23:15: error: expected ':' before 'void'
   23 |         public void setB(int b) {
      |               ^~~~~
      |               :
a.cc:26:2: error: expected ';' after class definition
   26 | }
      |  ^
      |  ;
a.cc:28:25: error: expected initializer before 'Comparator'
   28 | class compAB implements Comparator<AB> {
      |                         ^~~~~~~~~~
a.cc:38:1: error: expected unqualified-id before 'public'
   38 | public class Main {
      | ^~~~~~