criyle/codenet-compile-errors huggingface dataset:
Language: Java

import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;
import org.jetbrains.annotations.NotNull;

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

    int N = scanner.nextInt();
    int M = scanner.nextInt();
    Job[] jobs = new Job[N];
    for (int i = 0; i < N; i++) jobs[i] = new Job(scanner.nextInt(), scanner.nextInt());
    Arrays.sort(jobs, Comparator.comparingInt(j -> j.due));

    int ans = 0;
    int j = 0;
    PriorityQueue<Job> pq = new PriorityQueue<>();
    for (int i = 1; i <= M; i++) {
      while (j < N && jobs[j].due <= i) pq.add(jobs[j++]);
      if (!pq.isEmpty()) ans += pq.poll().reward;
    }
    System.out.println(ans);
  }

  private static class Job implements Comparable<Job> {
    private final int due;
    private final int reward;

    private Job(int due, int reward) {
      this.due = due;
      this.reward = reward;
    }

    @Override public int compareTo(@NotNull Job job) {
      return job.reward - reward;
    }
  }
}


Compiler output:
Main.java:5: error: package org.jetbrains.annotations does not exist
import org.jetbrains.annotations.NotNull;
                                ^
Main.java:36: error: cannot find symbol
    @Override public int compareTo(@NotNull Job job) {
                                    ^
  symbol:   class NotNull
  location: class Job
2 errors
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
  int n,m,ans=0;
  cin>>n>>m;
  vector<vector<int>> v(m,vector<int>(0));
  rep(i,n){
    int a,b;cin>>a>>b;
    if(a<=m)v.at(a-1).push_back(b);
  }
  vector<int> q(0);
  rep(i,m){
    rep(j,v.at(i).size()){
      q.push_back(v.at(i).at(j));
    }
    sort(q.begin(),q.end());
    if(q.size!=0){
      ans+=q.at(q.size()-1);
      q.pop_back();
    }
  }
  cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:10: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = int; _Alloc = std::allocator<int>; size_type = long unsigned int]' (did you forget the '()' ?)
   19 |     if(q.size!=0){
      |        ~~^~~~
      |              ()
Language: Java

import java.util.Arrays;
import java.util.Scanner;

public class Summer_Vaca_Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int ab[][] = new int[n][2];
		
		for (int i = 0; i < n; i++) {
			ab[i][0] = sc.nextInt();
			ab[i][1] = sc.nextInt();
		}
		Arrays.sort(ab, (a, b) -> Double.compare(a[0], b[0]));
//		System.out.println(Arrays.deepToString(ab));
				
		int mark = 999999;
		int max = 0;
		long ans = 0;
		for (int i = 1; i <= m; i++) {
//			System.out.println(i);
			for (int j = 0; j < n; j++) {
				if (ab[j][0] <= i) {
					max = Math.max(max, ab[j][1]);
					mark = j;
//					System.out.println(max);
				}
				else if (mark == 999999) {
					continue;
				}
				else {
					ans += max;
//					System.out.println(ans);
					max = 0;
					ab[mark][0] = 1000000;
					mark = 999999;
					Arrays.sort(ab, (a, b) -> Double.compare(a[0], b[0]));
//					System.out.println(Arrays.deepToString(ab));
					break;
				}
			}
		}
		
		System.out.println(ans);
	}
}

Compiler output:
Main.java:4: error: class Summer_Vaca_Main is public, should be declared in a file named Summer_Vaca_Main.java
public class Summer_Vaca_Main {
       ^
1 error
Language: C++

#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
vector<pair<int, int>> A(100010);

int main(){
    int N,M;
    cin >> N >> M;
    int q,w;
    rep(i,N){
        cin >> q >> w;
        A[i] = make_pair(q,w);
    }
    sort(A.begin(),A.end(),
    [](const pair<int,int>& x, const pair<int,int>& y) {
        return (x.second > y.second)
        //if(x.second > y.second){
        //    return true;
        //}else if(x.second == y.second){
        //    return (x.first < y.first);
        //}else{
        //    return false;
        //}
    });
    int cu = 1;
    int cnt=0;
    //rep(j,N){
      //  cout << A[j].first <<"::"<<A[j].second << endl;
    //}
    int flag[100010]={};
    while(M >= cu){
        rep(i,N){
            if(A[i].first <= cu && flag[i] == 0){
                cnt += A[i].second;
                //A.erase(A.begin()+i);
                flag[i] = 1;
                //N--;
                //rep(j,N){
                //    cout << A[j].first <<","<<A[j].second << endl;
                //}
                //cout << endl;
                break;
            }
        }
        cu++;
    }

    cout << cnt << endl;
}

Compiler output:
a.cc: In lambda function:
a.cc:21:37: error: expected ';' before '}' token
   21 |         return (x.second > y.second)
      |                                     ^
      |                                     ;
......
   29 |     });
      |     ~
Language: C

#include <iostream>
#include <vector>
#include <queue>
using namespace std;

int main(void){
    int m, n;
    int money = 0;
    cin >> n >> m;
    vector<vector<int>> v(m+1);
    priority_queue<int> q;
    for(int i=0; i<n; i++){
        int a, b;
        cin >> a >> b;
        if(a > m) continue;
        v[a].push_back(b);
    }
    for(int i=1; i<=m; i++){
        for(int x : v[i]) q.push(x);
        if(!q.empty()){
            money += q.top();
            q.pop();
        }
    }
    cout << money << endl;
    return 0;
}

Compiler output:
main.c:1:10: fatal error: iostream: No such file or directory
    1 | #include <iostream>
      |          ^~~~~~~~~~
compilation terminated.
Language: C++

#include "SaveFuncs.cpp"

#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

using namespace std;
using ll = long long;

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; i++)
#define rep1(i, n) for(int i=1, i##_len=(n); i<i##_len; i++)
#define rrep(i, n) for(int i=(n)-1; i >= 0; i--)
#define rrep1(i, n) for(int i=(n); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b);
//#define int long long
constexpr int INF = 2000000100;
constexpr int DIV = 1000000007;	// 10e9+7
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> T divUp(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
std::string strMulti(std::string t, int n) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }
template<class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; }
template<class T> T math_C(T m, T n) { T ret = mathP(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; }
bool compare_by_b(pair<int, int> a, pair<int, int> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; }

/*****/

int Main()
{
	int N, M;
	cin >> N >> M;
	vector<pair<int, int>> A(N);
	rep(i, N)
	{
		int a, b;
		cin >> a >> b;
		A.at(i) = pair(a, b);
	}

	sort(all(A), compare_by_b);
	reverse(all(A));

	/*coutendl();
	rep(i, N)
		debug_headCout(A.at(i).first, A.at(i).second);
	coutendl();*/

	vector<int> P(M, -1);
	int remain = M;
	int ret = 0;

	rep(i, N)
	{
		if (remain == 0)
			break;

		for (int j = A.at(i).first - 1; j < M; j++)
		{
			if (P.at(j) == -1)
			{
				ret += A.at(i).second;
				P.at(j) = i;
				remain--;
				break;
			}
		}
	}

	/*rep(i, M)
	{
		debug_headCout(i, P.at(i));
		if (P.at(i) != -1)
			debug_tabHeadCout(1, "A", A.at(P.at(i)).second);
	}*/

	cout << ret;

	return 0;
}

/*****/

int main()
{
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);

	Main();

	return 0;
}


Compiler output:
a.cc:1:10: fatal error: SaveFuncs.cpp: No such file or directory
    1 | #include "SaveFuncs.cpp"
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

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

public class Main {

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

		String[] lines = scanner.nextLine().split(" ");
		int N = Integer.parseInt(lines[0]);
		int M = Integer.parseInt(lines[1]);

		ArrayList<ArrayList<Integer>> arrays = new ArrayList<ArrayList<Integer>>();
		PriorityQueue<Integer> pq = new PriorityQueue<Integer>(Collections.reverseOrder());

		int answer = 0;

		for (int i = 0; i < M; i++) {
			ArrayList<Integer> array = new ArrayList<Integer>();
			arrays.add(array);
		}

		for (int i = 0; i < N; i++) {
			String[] line = scanner.nextLine().split(" ");
			int A = Integer.parseInt(line[0]);
			int B = Integer.parseInt(line[1]);
			if (A > M)
				continue;
			arrays.get(M - A).add(B);
		}

		for (int i = M - 1; i >= 0; --i) {
			for (int j : arrays.get(i)) {
				pq.add(j);
			}
			if (!pq.isEmpty()) {
				answer += pq.poll();
			}
		}

		System.out.println(answer);

	}
}

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.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:1: error: expected unqualified-id before 'public'
    6 | public class Main {
      | ^~~~~~
Language: C++

#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 10;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif 


int main_D() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, M; cin >> N >> M;
    vi A(N), B(N);
    REP(i, N) cin >> A[i] >> B[i];

    priority_queue_lo<pii> pql;
    REP(i, N) pql.push(pii(A[i], B[i]));

    priority_queue<int> pq;

    ll ans = 0;
    for (int d = M - 1; d >= 0; d--) {
        int rest = M - d;

        while(!pql.empty()){
            pii ab = pql.top();
            if (ab.first > rest) break;
            pql.pop();
            pq.push(ab.second);           
        }

        if (!pq.empty()) {
            ans += pq.top(); pq.pop();
        }
    }

    cout << ans << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:37:5: error: 'priority_queue_lo' was not declared in this scope
   37 |     priority_queue_lo<pii> pql;
      |     ^~~~~~~~~~~~~~~~~
a.cc:37:26: error: expected primary-expression before '>' token
   37 |     priority_queue_lo<pii> pql;
      |                          ^
a.cc:37:28: error: 'pql' was not declared in this scope; did you mean 'pll'?
   37 |     priority_queue_lo<pii> pql;
      |                            ^~~
      |                            pll
Language: C++

#include <bits/stdc++.h>

using namespace std;

int n,m;

struct node{
	int a,b;
};

bool cmp(const node &x,const node &y)
{
	if(x.a<y.a)
		return true;
	if(x.b<y.b)
		return true;
	return false;
}

int main()
{
	vector<pair<int,int> > c;
	int x,y;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
    	cin>>x>>y;
    	c.push_back((pair<int,int>){x,y});
	}
//    if(n>3250)
//    	return 0;
    std::sort(c.begin(),c.end()); //,cmp);
    return 0;
    int left=m;
	long long ans=0;
    for(int i=n;i>=1;i--)
    {
    	if(c[i].a>left)
    		continue;
    	ans+=c[i].b;
    	left--;
	}
	cout<<ans;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:38:17: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'a'
   38 |         if(c[i].a>left)
      |                 ^
a.cc:40:19: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'b'
   40 |         ans+=c[i].b;
      |                   ^
Language: C++

#include <algorithm>
#include <vector>
#include <iostream>
//#include <bits/stdc++.h>

using namespace std;

int n,m;

struct node{
	int a,b;
};

bool cmp(const node &x,const node &y)
{
	if(x.a<y.a)
		return true;
	if(x.b<y.b)
		return true;
	return false;
}

int main()
{
	vector<pair<int,int> > c;
	int x,y;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
    	cin>>x>>y;
    	c.push_back((pair<int,int>){x,y});
	}
//    if(n>3250)
//    	return 0;
    std::sort(c.begin(),c.end()); //,cmp);
    return 0;
    int left=m;
	long long ans=0;
    for(int i=n;i>=1;i--)
    {
    	if(c[i].a>left)
    		continue;
    	ans+=c[i].b;
    	left--;
	}
	cout<<ans;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:41:17: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'a'
   41 |         if(c[i].a>left)
      |                 ^
a.cc:43:19: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'b'
   43 |         ans+=c[i].b;
      |                   ^
Language: C++

#include <algorithm>
#include <vector>
#include <iostream>
//#include <bits/stdc++.h>

using namespace std;

int n,m;

struct node{
	int a,b;
};

bool cmp(const node &x,const node &y)
{
	if(x.a<y.a)
		return true;
	return x.b<y.b;
	//if(x.b<y.b)
	//	return true;
	return false;
}

int main()
{
	vector<node> c;
	int x,y;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
    	cin>>x>>y;
    	c.push_back((node){x,y});
	}
	random_shuffle(c);
//    if(n>3250)
//    	return 0;
    std::sort(c.begin(),c.end(),cmp);
    return 0;
    int left=m;
	long long ans=0;
    for(int i=n;i>=1;i--)
    {
    	if(c[i].a>left)
    		continue;
    	ans+=c[i].b;
    	left--;
	}
	cout<<ans;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:23: error: no matching function for call to 'random_shuffle(std::vector<node>&)'
   34 |         random_shuffle(c);
      |         ~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algo.h:4492:5: note: candidate: 'template<class _RAIter> void std::random_shuffle(_RAIter, _RAIter)'
 4492 |     random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |     ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4492:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_algo.h:4531:5: note: candidate: 'template<class _RAIter, class _Generator> void std::random_shuffle(_RAIter, _RAIter, _Generator&&)'
 4531 |     random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
      |     ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4531:5: note:   candidate expects 3 arguments, 1 provided
Language: C

#include <stdio.h>
 
int main()
{
    int N,M,i,j,day,ibest;
    int Nmax = 10^5;
    int Mmax = 10^5;
    int A[Nmax+1],B[Nmax+1];
    int Selected[Nmax+1];
    int tmp=0,sum=0;
    int sum[Mmax][Nmax];

    /*
    D - Summer Vacation
    N件の日雇いアルバイトがありi件目の日雇いアルバイトを請けて働くと、その Ai日後に報酬 Biが得られます。
    あなたは、これらの中から 1日に 1件まで選んで請け、働くことができます。
    ただし、請けたことのある日雇いアルバイトは選べません。
    今日から M日後まで(M日後を含む)に得られる報酬の合計の最大値を求めてください。
    なお、日雇いアルバイトは今日から請けて働くことができます。
    1 <= Ai
    */


    // 入力読込
    scanf("%d", &N);
    scanf("%d", &M);
    
    for(i=1;i<=N;i++){
        scanf("%d", &A[i]);
        scanf("%d", &B[i]);
        Selected[i]=0;
    }
    
    // 今日からday日後に受ける仕事を決める
    // 最終日（M-1）日の仕事から選択していく。
    for(day=M-1 ; day=0 ; day--){
        
        // 今日する仕事を選択
        // N個からM個を選ぶ問題 
        tmp =0;
        sum =0;
        for(i=1;i<=N;i++){
            if( (A[i]>=(M-day)) &&
                (B[i]>=tmp) &&
                (Selected[i]==0)
               ){
                tmp = B[i];
                ibest = i;
            }           
        }
               
        sum += B[ibest];
        Selected[ibest] = 1;
               
    }
    
  
    printf("%d \n", sum);
  
  return 0;
   
}

Compiler output:
main.c: In function 'main':
main.c:6:18: warning: result of '10^5' is 15; did you mean '1e5'? [-Wxor-used-as-pow]
    6 |     int Nmax = 10^5;
      |                  ^
      |                ---
      |                1e
main.c:6:16: note: you can silence this warning by using a hexadecimal constant (0xa rather than 10)
    6 |     int Nmax = 10^5;
      |                ^~
      |                0xa
main.c:7:18: warning: result of '10^5' is 15; did you mean '1e5'? [-Wxor-used-as-pow]
    7 |     int Mmax = 10^5;
      |                  ^
      |                ---
      |                1e
main.c:7:16: note: you can silence this warning by using a hexadecimal constant (0xa rather than 10)
    7 |     int Mmax = 10^5;
      |                ^~
      |                0xa
main.c:11:9: error: conflicting types for 'sum'; have 'int[Mmax][Nmax]'
   11 |     int sum[Mmax][Nmax];
      |         ^~~
main.c:10:15: note: previous definition of 'sum' with type 'int'
   10 |     int tmp=0,sum=0;
      |               ^~~
Language: C++

import java.util.*;
public class Main {
    Scanner sc = new Scanner(System.in);
    public static void main(String args[]) {
	new Main().doIt();
    }
    void doIt() { D(); } 
    void D() {
	long ans = 0;
	int N = sc.nextInt(), M = sc.nextInt();
	HashMap<Integer, ArrayList<Integer> > hash =  new HashMap<Integer, ArrayList<Integer> > ();
	for(int i = 0; i < N; i++) {
	    int A = sc.nextInt(), B = sc.nextInt();
	    if(! hash.containsKey(A)) {
		hash.put(A, new ArrayList<Integer>());
	    }
	    hash.get(A).add(B);
	}
	PriorityQueue<Integer> q = new PriorityQueue<Integer>(new Comparator<Integer>() {
		public int compare(Integer i0, Integer i1) {
		    return i1 - i0;
		}
	    } );
	for(int d = 1; d <= M; d++) {
	    if(hash.containsKey(d)) {
		for(Integer data : hash.get(d)) q.add(data);
	    }
	    //	    System.out.println(d + " " + q.size() + " " + hash.get(d) + ans );
	    if(! q.isEmpty()) {
		long tmp = q.poll();
		ans += tmp;
		//		System.out.println("Answer=" + ans + " " + tmp + " " + q.size());
	    }
	}
	System.out.println(ans);
    }
    void C() {
	long ans = 0;
	ArrayList<String> s = new ArrayList<String>();
	int N = sc.nextInt();
	for(int i = 0; i < N; i++) {
	    char [] work = sc.next().toCharArray();
	    Arrays.sort(work);
	    s.add(new String(work));
	}
	Collections.sort(s);
	//	for(String ss: s) System.out.println(ss);
	int cnt = 0;
	for(int i = 1; i < N; i++) {

	    if(s.get(i-1).equals(s.get(i))) {
		cnt++;
		ans += cnt;
	    } else cnt = 0;
	}
	System.out.println(ans);


    }
    void B() {
	int K = sc.nextInt(), X = sc.nextInt();
	ArrayList<Integer> ans = new ArrayList<Integer>();
	for(int i = X-(K-1); i <= X+(K-1); i++) ans.add(i);
	//	System.out.println(ans);
	for(Integer i: ans) System.out.print(" " + i);
	System.out.println();
    }
    void A() {
	int A = sc.nextInt(), B = sc.nextInt();
	int ans = A+B;
	ans = Math.max(ans, Math.max(A-B, A*B));
	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:2:1: error: expected unqualified-id before 'public'
    2 | public class Main {
      | ^~~~~~
Language: C++

from collections import defaultdict
import heapq
N, M = map(int, input().split())
dct = defaultdict(list)

for i in range(N):
  A, B = map(int, input().split())
  dct[A].append(-B)

h = []
ans = 0
for i in range(1,M+1):
  if dct[i]:
    for item in dct[i]:
      heapq.heappush(h,item)
  if h:
    ans += heapq.heappop(h)

print(-ans)

Compiler output:
a.cc:1:1: error: 'from' does not name a type
    1 | from collections import defaultdict
      | ^~~~
Language: C++

#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

using pii = pair<int, int>;

int main(){
    int N, M;
    cin >> N >> M;
    
    vector<pii> AB(N);
    for(int i = 0; i < N; ++i){
        cin >> AB[i].first >> AB[i].second;
    }

    sort(begin(AB), end(AB));

    priority_queue<pii, vector<pii>, function<bool(pii, pii)> > q(
        [](pair<int, int> a, pair<int, int> b){
            return (a.second == b.second) ? (a.first > b.first) : (a.second < b.second);
        }
    );

    int d = 1;
    int j = 0;
    for(int i = 0; i < N; ++i){
        if(AB[i].first != d){
            break;
        }else{
            q.emplace(AB[i]);
            ++j;
        }
    }

    int ans = 0;
    while(d <= M){
        if(!q.empty()){
            ans += q.top().second;
            q.pop();
        }
        
        ++d;
        for(int i = j; i < N; ++i){
            if(AB[i].first != d){
                break;
            }else{
                q.emplace(AB[i]);
                ++j;
            }
        }
    }

    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:38: error: 'function' was not declared in this scope
   20 |     priority_queue<pii, vector<pii>, function<bool(pii, pii)> > q(
      |                                      ^~~~~~~~
a.cc:5:1: note: 'std::function' is defined in header '<functional>'; this is probably fixable by adding '#include <functional>'
    4 | #include <algorithm>
  +++ |+#include <functional>
    5 | using namespace std;
a.cc:20:60: error: expression list treated as compound expression in functional cast [-fpermissive]
   20 |     priority_queue<pii, vector<pii>, function<bool(pii, pii)> > q(
      |                                                            ^
a.cc:20:61: error: template argument 3 is invalid
   20 |     priority_queue<pii, vector<pii>, function<bool(pii, pii)> > q(
      |                                                             ^
a.cc:20:63: error: expected unqualified-id before '>' token
   20 |     priority_queue<pii, vector<pii>, function<bool(pii, pii)> > q(
      |                                                               ^
a.cc:24:5: error: expected primary-expression before ')' token
   24 |     );
      |     ^
a.cc:32:13: error: 'q' was not declared in this scope
   32 |             q.emplace(AB[i]);
      |             ^
a.cc:39:13: error: 'q' was not declared in this scope
   39 |         if(!q.empty()){
      |             ^
a.cc:49:17: error: 'q' was not declared in this scope
   49 |                 q.emplace(AB[i]);
      |                 ^
Language: C++

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int main(){
    int n,m;
    cin >> n >> m;
    vector<pair<long,long>> work;
    long a,b;
    rep(i,n){
        cin >> a >> b;
        work.push_back(make_pair(b,a));
    }
    sort(work.begin(),work.end(),greater<pair<long,long>>());
    long count = 0;
    long num = 0;
    long ans = 0;
    set<int> days;
    rep(i,m+1){
        days.insert(i);
    }
    int tem;
    while(count<m && num < n){
        auto itr = st.upper_bound(a);
        if(itr==st.begin()) tem = -1;
        else{
            itr--;
            tem = *itr;
        }
        if(tem!=-1){
            days.erase(tem);
            ans+=work[num].first;
            count++;
        }
        num++;
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:20: error: 'st' was not declared in this scope; did you mean 'std'?
   32 |         auto itr = st.upper_bound(a);
      |                    ^~
      |                    std
Language: C++

//
//  main.cpp
//  temp
//
//  Created by tolemy on 2019/08/04.
//  Copyright © 2019 tolemy. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

int main(int argc, const char * argv[]) {
    
    const int MAX_WORKS_COUNT = 100000;
    //方針
    //0〜M-1日間で考える（M日目は報酬を受け取ることはできるが、仕事をしても翌日以降がないため意味がない）
    //M-1日目から初めて、残り日数のうちに報酬がもらえる仕事のうち、報酬が最大の仕事を順番にこなしていく
    
    //インプットの処理
    
    //n：仕事の数
    //m：日数
    int n, m;
    cin >> n >> m;
    
    //報酬受け取り期間と報酬の２次元配列を作る。
    //vectorの配列とする。
    
    typedef vector<int> values;
    values works[MAX_WORKS_COUNT];
    
    try
    {
        
    for(int i=0;i<n;i++)
    {
        int a, b;
        cin >> a >> b;
        works[a].push_back(b);
    }
    
    //報酬受け取り期間の昇順にソート
    for(int i=0;i<MAX_WORKS_COUNT;i++)
    {
        sort(works[i].begin(), works[i].end());
    }
    
    
    //合計報酬の最大値を計算
    //一度行った仕事は除外するため、priority_queueで管理
    long value = 0;
    priority_queue< int> pq;
    
   
        //日付をM日目からループ
        for(int i = m;i >= 1;i--)
        {
            //最終日からi日目に報酬受け取り期間iの仕事ができるようになる。
            int daysLeft = m - i + 1;
            for(int value : works[daysLeft])
            {
                pq.push(value);
            }
            
            if(pq.empty()) continue;
            
            //仕事の取り出し
            value += pq.top();
            pq.pop();
        }
    }
    catch(...)
    {
        value = 0;
    }
    
    cout << value;
    
    return 0;
}


Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:78:9: error: 'value' was not declared in this scope; did you mean 'values'?
   78 |         value = 0;
      |         ^~~~~
      |         values
a.cc:81:13: error: 'value' was not declared in this scope; did you mean 'values'?
   81 |     cout << value;
      |             ^~~~~
      |             values
Language: C++

#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}
int main() {
    int n,m;
    cin >> n >> m;
    vector<vector<int>> jobs(m);
    REP(i, N) {
        int a, b;
        cin >> a >> b;
        if(a>m) continue;
        jobs[m-a].push_back(b);
        //その Ai日後に報酬 Biが得られます。
    }
    priority_queue<int> q;
    ll ans = 0;
    for (int i = m-1; i >=0; i--)
    {
        //priority que は使いまわしている
        for (auto b:jobs[i])
        {
            q.push(b);
        }
        if(!q.empty()){
            ans += q.top();
            q.pop();
        }
    }
    cout<<ans<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:36:12: error: 'N' was not declared in this scope
   36 |     REP(i, N) {
      |            ^
a.cc:2:41: note: in definition of macro 'REP'
    2 | #define REP(i, n) for(ll i = 0; i < (ll)n; i++)
      |                                         ^
Language: C++

//
//  main.cpp
//  temp
//
//  Created by tolemy on 2019/08/04.
//  Copyright © 2019 tolemy. All rights reserved.
//

#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main(int argc, const char * argv[]) {
    
    const int MAX_WORKS_COUNT = 100000;
    //方針
    //0〜M-1日間で考える（M日目は報酬を受け取ることはできるが、仕事をしても翌日以降がないため意味がない）
    //M-1日目から初めて、残り日数のうちに報酬がもらえる仕事のうち、報酬が最大の仕事を順番にこなしていく
    
    //インプットの処理
    
    //n：仕事の数
    //m：日数
    int n, m;
    cin >> n >> m;
    
    //報酬受け取り期間と報酬の２次元配列を作る。
    //vectorの配列とする。
    
    typedef vector<int> values;
    values works[MAX_WORKS_COUNT];
    
    for(int i=0;i<n;i++)
    {
        int a, b;
        cin >> a >> b;
        works[a].push_back(b);
    }
    
    //報酬受け取り期間の昇順にソート
    for(int i=0;i<n;i++)
    {
        sort(works[i].begin(), works[i].end());
    }
    
    
    //合計報酬の最大値を計算
    //一度行った仕事は除外するため、priority_queueで管理
    long value = 0;
    priority_queue< int> pq;
    
    //日付をM日目からループ
    for(int i = m;i >= 0;i--)
    {
        //最終日からi日目に報酬受け取り期間iの仕事ができるようになる。
        int daysLeft = m - i;
        for(int value : works[daysLeft])
        {
            pq.push(value);
        }
        
        if(pq.empty()) continue;
        
        //仕事の取り出し
        value += pq.top();
        pq.pop();
    }
    
    cout << value;
    
    return 0;
}


Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:45:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   45 |         sort(works[i].begin(), works[i].end());
      |         ^~~~
      |         short
Language: C++

#include <iostream>
#include <queue>
#include <vector>
#include <utility>

int main()
{
    int N, M;
    std::cin >> N >> M;
    std::vector<std::pair<int, int> > job(N); // job[i] = (A[i], B[i])
    for(int i=0; i<N; i++) scanf(" %d %d", &(job[i].first), &(job[i].second));

    std::sort(job.begin(), job.end(), std::greater<std::pair<int, int> >());
    std::priority_queue<int> q;
    long long sum = 0;
    for(int i=1; i<=M; i++){
        while(!job.empty() && job.back().first == i){
            q.push(job.back().second);
            job.pop_back();
        }
        if(!q.empty()){
            sum += q.top();
            q.pop();
        }
    }

    std::cout << sum << std::endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:10: error: 'sort' is not a member of 'std'; did you mean 'qsort'?
   13 |     std::sort(job.begin(), job.end(), std::greater<std::pair<int, int> >());
      |          ^~~~
      |          qsort
Language: C++

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;
typedef pair<int, int> PAIR;

const int INF = 1000000000;
const int MOD = 1000000007;

bool job_comp(const PAIR &l, const PAIR &r) {
    if (l.second != r.second) return l.second > r.second;
    else return l.first > r.first;
}

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int N, M; cin >> N >> M;
    vector<PAIR> job(N);
    rep(i, N) {
        int a, b; cin >> a >> b;
        job[i] = make_pair(a, b);
    }

    sort(all(job), job_comp);

    int ll = 0;
    rep(i, N) {
        if (M <= 0) break;
        if (job[i].first <= M) ans += job[i].second, M--;
    }
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:37:32: error: 'ans' was not declared in this scope; did you mean 'abs'?
   37 |         if (job[i].first <= M) ans += job[i].second, M--;
      |                                ^~~
      |                                abs
a.cc:39:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   39 |     cout << ans << endl;
      |             ^~~
      |             abs
Language: C++

#include<bits/stdc++.h>
using namespace std;
     
#define int long long
#define hell 998244353 
#define endl "\n"
     
float min(float a, float b)
{
     
    if(a>b)
        return b;
    return a;
}
     
int max(int a, int b)
{
     
    if(a>b)
        return a;
    return b;
    }
 
 
int main()
{
    int n, m; cin >> n >> m;

    vector<pair<int, int>> v(n);

    for (int i = 0; i < n; i++) 
        cin >> v[i].second >> v[i].first;

    sort(v.begin(), v.end(), greater<pair<int, int>>());
 
    int ans = 0;
    set<int, greater<int>> st;

    for (int i = 0; i < m; i++) 
        st.insert(i);
    for (int i = 0; i < n; i++) 
    {
        auto it = st.lower_bound(m - v[i].second);
        
        if (it != st.end()) 
        {
            ans += v[i].first;
            st.erase(it);
        }
    }
    cout << ans << endl;
    return 0;
}

Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define oset tree<int , null_type, less_equal<int> , rb_tree_tag, tree_order_statistics_node_update>

#define ll long long int
#define MAX 1000000007

using namespace std;
using namespace __gnu_pbds;

vector<ll> adj[200005];
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n,m,u,v,i;
  cin>>n>>m;
  for(i=0;i<n;i++){
    cin>>u>>v;
    if(u<=m){
      adj[u].push_back(v);
    }
  }
  priority_queue<ll> q;
  ll ans = 0;
  for(i=1;i<=m;i++){
    for(j = 0;j<adj[i].size();i++){
      q.push(adj[i][j]);
    }
    if(!q.empty()){
      ans+=q.top();
      q.pop();
    }
  }
  cout<<ans<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:9: error: 'j' was not declared in this scope
   29 |     for(j = 0;j<adj[i].size();i++){
      |         ^
Language: C++

#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define oset tree<int , null_type, less_equal<int> , rb_tree_tag, tree_order_statistics_node_update>

#define ll long long int
#define MAX 1000000007

using namespace std;
using namespace __gnu_pbds;

vector<ll> adj[100005];
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n,m,u,v,i;
  cin>>n>>m;
  for(i=0;i<n;i++){
    cin>>u>>v;
    if(u<=m){
      adj[u].push_back(v);
    }
  }
  priority_queue<ll> q;
  ll ans = 0;
  for(i=1;i<=m;i++){
    for(j = 0;j<adj[i].size();i++){
      q.push(adj[i][j]);
    }
    if(!q.empty()){
      ans+=q.top();
      q.pop();
    }
  }
  cout<<ans<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:9: error: 'j' was not declared in this scope
   29 |     for(j = 0;j<adj[i].size();i++){
      |         ^
Language: C++

#include <bits/stdc++.h>
#define int long long
#define boost() ios_base :: sync_with_stdio(0); cin.tie(); cout.tie(); cout << fixed; cout << setprecision(15); srand(time(NULL))
#define all(x) x.begin(), x.end()
using namespace std;

vector <int> v[500010];
int n, m, res = 0;

signed main () {
  cin >> n >> m;
  while (n--) {
    int a, b;
    cin >> a >> b;
    v[a].push_back(b);
  }
  sort (all(v));
  multiset <int> rew;
  for (int i = 1; i <= m; i++) {
    for (auto x: v[i]) {
      rew.insert(x);
    }
    if (!rew.empty()) {
      res += *prev(rew.end());
      rew.erase(prev(rew.end()));
    }
  }
  cout << res << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:4:18: error: request for member 'begin' in 'v', which is of non-class type 'std::vector<long long int> [500010]'
    4 | #define all(x) x.begin(), x.end()
      |                  ^~~~~
a.cc:17:9: note: in expansion of macro 'all'
   17 |   sort (all(v));
      |         ^~~
a.cc:4:29: error: request for member 'end' in 'v', which is of non-class type 'std::vector<long long int> [500010]'
    4 | #define all(x) x.begin(), x.end()
      |                             ^~~
a.cc:17:9: note: in expansion of macro 'all'
   17 |   sort (all(v));
      |         ^~~
Language: C++

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>

using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int n;
  cin >> n;
  int m;
  cin >> m;
  pint pp[n];
  priority_queue<int> p;
  rep(i,n){
    int x,y;
    cin >> x >> y;
    pp[i].first=x;
    pp[i].second=y;
  }
  sort(pp,pp+n);
  int temp=0;
  int ans=0;
  for(int i=1;i<=m;i++){
    while(temp<pp.size() && pp[temp].first<=i){
      p.push(pp[temp].second);
      temp++;
    }
    if(p.size()==0)continue;
    int z=p.top();
    ans+=z;
    p.pop();
  }
  cout << ans << endl;
return 0;}


Compiler output:
a.cc: In function 'int main()':
a.cc:42:19: error: request for member 'size' in 'pp', which is of non-class type 'pint [n]' {aka 'std::pair<int, int> [n]'}
   42 |     while(temp<pp.size() && pp[temp].first<=i){
      |                   ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define pii pair<int,int>
#define inf 0x3f3f3f3f
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define drep(i,a,b) for(int i=(a); i>=(b);i--) 

const int maxn = 1e5 + 5;
const int MOD = 1e9 + 7;


int n,m;
vector<int>v;

priority_queue <pii>q;

int main()
{
   ios::sync_with_stdio(false); cin.tie(0);cout.tie(0);
   cin >> n >> m;
   rep(i,1,n) {
        int a,b;
        cin >> a >> b;
        q.push({b,a});
   }
   ll ans = 0;
   drep(i,m,1){
            while(!q.empty() && q.top().second > i) q.pop();
            if(!q.empty() && q.second <= i){
            ans += q.top().first * 1ll;
            q.pop();
        }
   }
   cout << ans;
  
}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:32: error: 'class std::priority_queue<std::pair<int, int> >' has no member named 'second'
   30 |             if(!q.empty() && q.second <= i){
      |                                ^~~~~~
Language: C++

#include <bits/stdc++.h> 
using namespace std;
#define ll long long ll
int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	ll n, m,ans=0,a,b; cin >> n >> m;	
 	priority_queue<ll> que;
	vector<vector<int>> d(100010, vector<int>());
	for (int i = 0; i < n; i++) 
		cin >> a >> b , d[a].push_back(b);
	for (int i = 1; i < m+1; i++) 
    {
		for (int j = 0; j < d[i].size(); j++) 
			que.push(d[i][j]);
		if (!que.empty()) 
			ans += que.top() , que.pop();
	}
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:12: error: expected initializer before 'n'
    6 |         ll n, m,ans=0,a,b; cin >> n >> m;
      |            ^
a.cc:6:35: error: 'n' was not declared in this scope; did you mean 'yn'?
    6 |         ll n, m,ans=0,a,b; cin >> n >> m;
      |                                   ^
      |                                   yn
a.cc:6:40: error: 'm' was not declared in this scope; did you mean 'tm'?
    6 |         ll n, m,ans=0,a,b; cin >> n >> m;
      |                                        ^
      |                                        tm
a.cc:7:26: error: template argument 1 is invalid
    7 |         priority_queue<ll> que;
      |                          ^
a.cc:7:26: error: template argument 2 is invalid
a.cc:7:26: error: template argument 3 is invalid
a.cc:10:24: error: 'a' was not declared in this scope
   10 |                 cin >> a >> b , d[a].push_back(b);
      |                        ^
a.cc:10:29: error: 'b' was not declared in this scope
   10 |                 cin >> a >> b , d[a].push_back(b);
      |                             ^
a.cc:14:29: error: request for member 'push' in 'que', which is of non-class type 'int'
   14 |                         que.push(d[i][j]);
      |                             ^~~~
a.cc:15:26: error: request for member 'empty' in 'que', which is of non-class type 'int'
   15 |                 if (!que.empty())
      |                          ^~~~~
a.cc:16:25: error: 'ans' was not declared in this scope; did you mean 'abs'?
   16 |                         ans += que.top() , que.pop();
      |                         ^~~
      |                         abs
a.cc:16:36: error: request for member 'top' in 'que', which is of non-class type 'int'
   16 |                         ans += que.top() , que.pop();
      |                                    ^~~
a.cc:16:48: error: request for member 'pop' in 'que', which is of non-class type 'int'
   16 |                         ans += que.top() , que.pop();
      |                                                ^~~
a.cc:18:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   18 |         cout << ans << endl;
      |                 ^~~
      |                 abs
Language: C++

#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;

int main() 
{ 
	ll n, m,ans=0,a,b; cin >> n >> m;	
 	priority_queue<LL> que;
	vector<vector<int>> d(100010, vector<int>());
	for (int i = 0; i < n; i++) 
		cin >> a >> b , d[a].push_back(b);
	for (int i = 1; i < m+1; i++) 
    {
		for (int j = 0; j < d[i].size(); j++) 
			que.push(d[i][j]);
		if (!que.empty()) 
			ans += que.top() , que.pop();
	}
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:24: error: 'LL' was not declared in this scope; did you mean 'll'?
    8 |         priority_queue<LL> que;
      |                        ^~
      |                        ll
a.cc:8:26: error: template argument 1 is invalid
    8 |         priority_queue<LL> que;
      |                          ^
a.cc:8:26: error: template argument 2 is invalid
a.cc:8:26: error: template argument 3 is invalid
a.cc:15:29: error: request for member 'push' in 'que', which is of non-class type 'int'
   15 |                         que.push(d[i][j]);
      |                             ^~~~
a.cc:16:26: error: request for member 'empty' in 'que', which is of non-class type 'int'
   16 |                 if (!que.empty())
      |                          ^~~~~
a.cc:17:36: error: request for member 'top' in 'que', which is of non-class type 'int'
   17 |                         ans += que.top() , que.pop();
      |                                    ^~~
a.cc:17:48: error: request for member 'pop' in 'que', which is of non-class type 'int'
   17 |                         ans += que.top() , que.pop();
      |                                                ^~~
Language: C++

#include <iostream>
#include <vector>
#include <queue>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()

int main(int argc, char** argv) {
  int N, M;
  cin >> N; // Num
  cin >> M; // Capacity
  vector<int> A(N), B(N);
  rep(i, N) {
    cin >> A[i];
    cin >> B[i];
  }

  vector< pair<int, int> > pairs;
  rep(i, N) {
    pairs.emplace_back(A[i], B[i]);
  }
  sort(all(pairs));

  // For Debug
  // rep(i, N) {
  //   cout << pairs[i].first << ", " << pairs[i].second << endl;
  // }

  priority_queue<int> q;

  int res = 0;

  int pair_i = 0;
  for (int i = 1; i <= M; ++i) {
    while (pairs[pair_i].first <= i && pair_i < N) {
      q.push(pairs[pair_i].second); // NOTE: Push only value.
      ++pair_i;
    }
    if (!q.empty()) {
      int v = q.top();
      res += v;
      q.pop();
    }
  }

  cout << res << endl;

  return 0;
}


Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:24:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   24 |   sort(all(pairs));
      |   ^~~~
      |   short
Language: C++

#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main()
{

     	// #ifndef ONLINE_JUDGE
        // freopen("./INPUT.txt", "r", stdin);
        // freopen("./OUTPUT.txt", "w", stdout);
        // #endif

        ios_base::sync_with_stdio(false);
        cin.tie(NULL);


        int n,m;
        cin>>n>>m;
        pair<int,int>p[n];
        for (size_t i = 0; i < n; i++)
        {
                cin>>p[i].second>>p[i].first;
        }


        sort(p,p+n,greater<>());

        set<int>s;
        map<int,int>mm;
        int ans=0;
        int cnt=0;
        int mx=0;
        for (size_t i = 0; i < n; i++)
        {
                if(cnt==m)
                        break;
        
                if(p[i].second>m)
                        continue;

                if(s.size==0)
                        {
                                ans+=p[i].first;
                                s.insert(p[i].second);
                                mm[p[i].second]++;
                                cnt++;
                                continue;
                        }
                auto j=s.lower_bound(p[i].second+1);
                if(j==s.begin)
                {
                        cnt++;
                                ans+=p[i].first;
                                s.insert(p[i].second);
                                mm[p[i].second]++;
                }
                else
                {
                        j--;
                        if(mm[*j]+p[i].second<=m)
                        {
                                ans+=p[i].first;
                                cnt++;
                                s.insert(p[i].second);
                                mm[p[i].second]++;                 
                        }
                }
                
        }
        
        cout<<ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:41:22: error: invalid use of member function 'std::set<_Key, _Compare, _Alloc>::size_type std::set<_Key, _Compare, _Alloc>::size() const [with _Key = long long int; _Compare = std::less<long long int>; _Alloc = std::allocator<long long int>; size_type = long unsigned int]' (did you forget the '()' ?)
   41 |                 if(s.size==0)
      |                    ~~^~~~
      |                          ()
a.cc:50:21: error: invalid use of non-static member function 'std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::begin() const [with _Key = long long int; _Compare = std::less<long long int>; _Alloc = std::allocator<long long int>; iterator = std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, std::less<long long int>, std::allocator<long long int> >::const_iterator]'
   50 |                 if(j==s.begin)
      |                    ~^~~~~~~~~
In file included from /usr/include/c++/14/set:63,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:158,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_set.h:346:7: note: declared here
  346 |       begin() const _GLIBCXX_NOEXCEPT
      |       ^~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


  vector<pair<int,int>> p;
  vector<pair<int,int>> ans;

int main() {
  int N,M;
  scanf("%d%d", &N,&M);
  FOR(i,0,N-1){
    int neko,inu;

    cin >> neko;
    cin >> inu;
    inu = 0-inu;
    p.PB(MP(neko,inu));
  }

  sort(ALL(p));

  int output = 0;
  int ref = 0;
  FOR(i,0,M-1){
    int hold = -1;
    while(p[ref].first<=i+1 && ref<=SZ(p)-1){
      ans.PB(MP((-p[ref].second),p[ref].first));
      // p.erase(p.begin());
      ++ref:
    }
    if(SZ(ans)>0) {
      sort(ALL(ans),greater<pair<int,int>>());
      output += ans[0].first;
      ans.erase(ans.begin());
    }
    // cout << output << endl;
    
  }

  cout << output << endl;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:42:12: error: expected ';' before ':' token
   42 |       ++ref:
      |            ^
      |            ;