Language: C++

using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

// https://github.com/yambe2002/topcoder_template/blob/master/MyLibrary.cs
public class PriorityQueue<T> where T: IComparable
{
    private int _type = 0;
    private T[] _heap;
    private int _sz = 0;
    private int _count = 0;

    /// <summary>
    /// Priority queue
    /// </summary>
    /// <param name="type">0: asc, 1:desc</param>
    public PriorityQueue(int type = 0)
    {
	_heap = new T[128];
	_type = type;
    }

    private int Compare(T x, T y)
    {
	return _type == 0 ? x.CompareTo(y) : y.CompareTo(x);
    }

    public void Push(T x)
    {
	_count++;
	if (_count > _heap.Length)
	{
	    var newheap = new T[_heap.Length * 2];
	    for (int n = 0; n < _heap.Length; n++) newheap[n] = _heap[n];
	    _heap = newheap;
	}

	//node number
	var i = _sz++;

	while (i > 0)
	{
	    //parent node number
	    var p = (i - 1) / 2;
	    
	    if (Compare(_heap[p], x) <= 0) break;

	    _heap[i] = _heap[p];
	    i = p;
	}

	_heap[i] = x;
    }

    public T Pop()
    {
	_count--;

	T ret = _heap[0];
	T x = _heap[--_sz];

	int i = 0;
	while (i * 2 + 1 < _sz)
	{
	    //children
	    int a = i * 2 + 1;
	    int b = i * 2 + 2;

	    if (b < _sz && Compare(_heap[b], _heap[a]) < 0) a = b;

	    if (Compare(_heap[a], x) >= 0) break;
	    
	    _heap[i] = _heap[a];
	    i = a;
	}

	_heap[i] = x;

	return ret;
    }

    public int Count(){ return _count; }
    public T Peek(){ return _heap[0]; }
}

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
	var tmp = ReadIntArray();
	int n = tmp[0], m = tmp[1];

	Tuple<int,int>[] d = new Tuple<int,int>[n];
	for (int i = 0; i < n; i++)
	{
	    tmp = ReadIntArray();
	    int a = tmp[0], b = tmp[1];
	    d[i] = new Tuple<int,int>(a, b);
	}
	Array.Sort(d);

	PriorityQueue<int> q = new PriorityQueue<int>(1);

	long ans = 0;
	int idx = 0;
	for (int i = 1; i <= m; i++)
	{
	    while (idx < d.Length && d[idx].Item1 <= i)
	    {
		q.Push(d[idx].Item2);
		idx++;
	    }
	    if (q.Count() > 0){ ans += q.Pop(); }
	}

	WriteLine(ans);
    }
}


Compiler output:
a.cc:1:7: error: expected nested-name-specifier before 'System'
    1 | using System;
      |       ^~~~~~
a.cc:2:7: error: expected nested-name-specifier before 'System'
    2 | using System.Collections.Generic;
      |       ^~~~~~
a.cc:3:7: error: expected nested-name-specifier before 'System'
    3 | using System.Linq;
      |       ^~~~~~
a.cc:4:7: error: expected nested-name-specifier before 'static'
    4 | using static System.Console;
      |       ^~~~~~
a.cc:5:7: error: expected nested-name-specifier before 'System'
    5 | using System.Runtime.CompilerServices;
      |       ^~~~~~
a.cc:6:7: error: expected nested-name-specifier before 'static'
    6 | using static MyUtil;
      |       ^~~~~~
a.cc:9:1: error: expected unqualified-id before 'public'
    9 | public class PriorityQueue<T> where T: IComparable
      | ^~~~~~
a.cc:91:11: error: expected ':' before 'static'
   91 |     public static int[] ReadIntArray()
      |           ^~~~~~~
      |           :
a.cc:91:22: error: expected unqualified-id before '[' token
   91 |     public static int[] ReadIntArray()
      |                      ^
a.cc:95:2: error: expected ';' after class definition
   95 | }
      |  ^
      |  ;
a.cc:99:11: error: expected ':' before 'static'
   99 |     public static void Main()
      |           ^~~~~~~
      |           :
a.cc:129:2: error: expected ';' after class definition
  129 | }
      |  ^
      |  ;
a.cc: In static member function 'static void Program::Main()':
a.cc:101:9: error: 'var' was not declared in this scope
  101 |         var tmp = ReadIntArray();
      |         ^~~
a.cc:102:17: error: 'tmp' was not declared in this scope
  102 |         int n = tmp[0], m = tmp[1];
      |                 ^~~
a.cc:104:9: error: 'Tuple' was not declared in this scope
  104 |         Tuple<int,int>[] d = new Tuple<int,int>[n];
      |         ^~~~~
a.cc:104:15: error: expected primary-expression before 'int'
  104 |         Tuple<int,int>[] d = new Tuple<int,int>[n];
      |               ^~~
a.cc:107:19: error: 'ReadIntArray' was not declared in this scope
  107 |             tmp = ReadIntArray();
      |                   ^~~~~~~~~~~~
a.cc:109:13: error: 'd' was not declared in this scope
  109 |             d[i] = new Tuple<int,int>(a, b);
      |             ^
a.cc:109:24: error: 'Tuple' does not name a type
  109 |             d[i] = new Tuple<int,int>(a, b);
      |                        ^~~~~
a.cc:109:30: error: expected primary-expression before 'int'
  109 |             d[i] = new Tuple<int,int>(a, b);
      |                              ^~~
a.cc:111:9: error: 'Array' was not declared in this scope
  111 |         Array.Sort(d);
      |         ^~~~~
a.cc:111:20: error: 'd' was not declared in this scope
  111 |         Array.Sort(d);
      |                    ^
a.cc:113:9: error: 'PriorityQueue' was not declared in this scope
  113 |         PriorityQueue<int> q = new PriorityQueue<int>(1);
      |         ^~~~~~~~~~~~~
a.cc:113:23: error: expected primary-expression before 'int'
  113 |         PriorityQueue<int> q = new PriorityQueue<int>(1);
      |                       ^~~
a.cc:117:30: error: 'm' was not declared in this scope
  117 |         for (int i = 1; i <= m; i++)
      |                              ^
a.cc:121:17: error: 'q' was not declared in this scope
  121 |                 q.Push(d[idx].Item2);
      |                 ^
a.cc:124:17: error: 'q' was not declared in this scope
  124 |             if (q.Count() > 0){ ans += q.Pop(); }
      |                 ^
a.cc:127:9: error: 'WriteLine' was not declared in this scope
  127 |         WriteLine(ans);
      |         ^~~~~~~~~