Language: C++

type
  pair = record
    a : longint;
    b : longint;
  end;
	pairArray = array[1..100000] of pair;

var i,j,n,m:longint;
    ans:int64;
    input:pairArray;
    heap:array[0..100000] of longint;
    f, g: text;

procedure swap(var X, Y: longint);
begin
	if X <> Y then begin
		X := X xor Y;
		Y := X xor Y;
		X := X xor Y
	end
end;

procedure	pswap(var a,b:pair);
var tmp:pair;
begin
	tmp:=a;
	a:=b;
	b:=tmp
end;

procedure QuickSort(var a:pairArray;start_index,end_index:longint);
var i,j,x:int64;
begin
	x:=a[(start_index+end_index)div 2].a;
	i:=start_index;
	j:=end_index;
	while(true)do
	begin
		while(a[i].a<x)do i:=i+1;
		while(x<a[j].a)do j:=j-1;
		if(i<j)then
		begin
			pswap(a[i],a[j]);
			i:=i+1;
			j:=j-1;
		end else
		begin
			if(start_index<i-1)then QuickSort(a,start_index,i-1);
			if(j+1<end_index)then QuickSort(a,j+1,end_index);
			exit;
		end;
	end;
end;

procedure upheap(b:longint);
var p:integer;
begin
  heap[0] := heap[0] + 1;
  p := heap[0];
  heap[p] := b;
  while (p>1) and (heap[p]>heap[p div 2]) do begin
    swap(heap[p],heap[p div 2]);
    p := p div 2
  end
end;

function downheap:longint;
var p:integer;
begin
  downheap:=heap[1];
  heap[1] := heap[heap[0]];
  heap[0] := heap[0] - 1;
  p := 1;
  while (p*2 <= heap[0]) and (heap[p]<heap[p*2]) or (p*2+1 <= heap[0]) and (heap[p]<heap[p*2+1]) do
    if (p*2+1 <= heap[0]) and (heap[p*2]<heap[p*2+1]) then begin
      swap(heap[p],heap[p*2+1]);
      p := p*2+1
    end else begin
      swap(heap[p],heap[p*2]);
      p := p*2
    end
end;

begin

  readln(n,m);
  for i := 1 to n do readln(input[i].a,input[i].b);
  QuickSort(input,1,n);
  j := 1;
  ans := 0;
  for i := 1 to m do begin
    while input[j].a=i do begin
      upheap(input[j].b);
      j := j + 1
    end;
    if heap[0]>0 then ans := ans + downheap
  end;
  writeln(ans);
  close(f);
  close(g);
end.


Compiler output:
a.cc:6:27: error: too many decimal points in number
    6 |         pairArray = array[1..100000] of pair;
      |                           ^~~~~~~~~
a.cc:11:16: error: too many decimal points in number
   11 |     heap:array[0..100000] of longint;
      |                ^~~~~~~~~
a.cc:1:1: error: 'type' does not name a type; did you mean 'typeof'?
    1 | type
      | ^~~~
      | typeof
a.cc:4:7: error: found ':' in nested-name-specifier, expected '::'
    4 |     b : longint;
      |       ^
      |       ::
a.cc:4:5: error: 'b' does not name a type
    4 |     b : longint;
      |     ^
a.cc:5:3: error: 'end' does not name a type
    5 |   end;
      |   ^~~
a.cc:6:9: error: 'pairArray' does not name a type
    6 |         pairArray = array[1..100000] of pair;
      |         ^~~~~~~~~
a.cc:8:1: error: 'var' does not name a type
    8 | var i,j,n,m:longint;
      | ^~~
a.cc:9:8: error: found ':' in nested-name-specifier, expected '::'
    9 |     ans:int64;
      |        ^
      |        ::
a.cc:9:5: error: 'ans' does not name a type
    9 |     ans:int64;
      |     ^~~
a.cc:10:10: error: found ':' in nested-name-specifier, expected '::'
   10 |     input:pairArray;
      |          ^
      |          ::
a.cc:10:5: error: 'input' does not name a type; did you mean 'int'?
   10 |     input:pairArray;
      |     ^~~~~
      |     int
a.cc:11:9: error: found ':' in nested-name-specifier, expected '::'
   11 |     heap:array[0..100000] of longint;
      |         ^
      |         ::
a.cc:11:5: error: 'heap' does not name a type
   11 |     heap:array[0..100000] of longint;
      |     ^~~~
a.cc:12:5: error: 'f' does not name a type
   12 |     f, g: text;
      |     ^
a.cc:14:1: error: 'procedure' does not name a type
   14 | procedure swap(var X, Y: longint);
      | ^~~~~~~~~
a.cc:15:1: error: 'begin' does not name a type
   15 | begin
      | ^~~~~
a.cc:18:17: error: 'Y' does not name a type
   18 |                 Y := X xor Y;
      |                 ^
a.cc:19:17: error: 'X' does not name a type
   19 |                 X := X xor Y
      |                 ^
a.cc:23:1: error: 'procedure' does not name a type
   23 | procedure       pswap(var a,b:pair);
      | ^~~~~~~~~
a.cc:24:1: error: 'var' does not name a type
   24 | var tmp:pair;
      | ^~~
a.cc:25:1: error: 'begin' does not name a type
   25 | begin
      | ^~~~~
a.cc:27:9: error: 'a' does not name a type
   27 |         a:=b;
      |         ^
a.cc:28:9: error: 'b' does not name a type
   28 |         b:=tmp
      |         ^
a.cc:31:1: error: 'procedure' does not name a type
   31 | procedure QuickSort(var a:pairArray;start_index,end_index:longint);
      | ^~~~~~~~~
a.cc:31:37: error: 'start_index' does not name a type
   31 | procedure QuickSort(var a:pairArray;start_index,end_index:longint);
      |                                     ^~~~~~~~~~~
a.cc:32:1: error: 'var' does not name a type
   32 | var i,j,x:int64;
      | ^~~
a.cc:33:1: error: 'begin' does not name a type
   33 | begin
      | ^~~~~
a.cc:35:9: error: 'i' does not name a type
   35 |         i:=start_index;
      |         ^
a.cc:36:9: error: 'j' does not name a type
   36 |         j:=end_index;
      |         ^
a.cc:37:9: error: expected unqualified-id before 'while'
   37 |         while(true)do
      |         ^~~~~
a.cc:40:17: error: expected unqualified-id before 'while'
   40 |                 while(x<a[j].a)do j:=j-1;
      |                 ^~~~~
a.cc:41:17: error: expected unqualified-id before 'if'
   41 |                 if(i<j)then
      |                 ^~
a.cc:44:25: error: 'i' does not name a type
   44 |                         i:=i+1;
      |                         ^
a.cc:45:25: error: 'j' does not name a type
   45 |                         j:=j-1;
      |                         ^
a.cc:46:17: error: 'end' does not name a type
   46 |                 end else
      |                 ^~~
a.cc:49:25: error: expected unqualified-id before 'if'
   49 |                         if(j+1<end_index)then QuickSort(a,j+1,end_index);
      |                         ^~
a.cc:50:25: error: 'exit' does not name a type
   50 |                         exit;
      |                         ^~~~
a.cc:1:1: note: 'exit' is defined in header '<cstdlib>'; this is probably fixable by adding '#include <cstdlib>'
  +++ |+#include <cstdlib>
    1 | type
a.cc:51:17: error: 'end' does not name a type
   51 |                 end;
      |                 ^~~
a.cc:52:9: error: 'end' does not name a type
   52 |         end;
      |         ^~~
a.cc:53:1: error: 'end' does not name a type
   53 | end;
      | ^~~
a.cc:55:1: error: 'procedure' does not name a type
   55 | procedure upheap(b:longint);
      | ^~~~~~~~~
a.cc:56:1: error: 'var' does not name a type
   56 | var p:integer;
      | ^~~
a.cc:57:1: error: 'begin' does not name a type
   57 | begin
      | ^~~~~
a.cc:59:3: error: 'p' does not name a type
   59 |   p := heap[0];
      |   ^
a.cc:60:3: error: 'heap' does not name a type
   60 |   heap[p] := b;
      |   ^~~~
a.cc:61:3: error: expected unqualified-id before 'while'
   61 |   while (p>1) and (heap[p]>heap[p div 2]) do begin
      |   ^~~~~
a.cc:63:5: error: 'p' does not name a type
   63 |     p := p div 2
      |     ^
a.cc:67:1: error: 'function' does not name a type; did you mean 'union'?
   67 | function downheap:longint;
      | ^~~~~~~~
      | union
a.cc:68:1: error: 'var' does not name a type
   68 | var p:integer;
      | ^~~
a.cc:69:1: error: 'begin' does not name a type
   69 | begin
      | ^~~~~
a.cc:71:3: error: 'heap' does not name a type
   71 |   heap[1] := heap[heap[0]];
      |   ^~~~
a.cc:72:3: error: 'heap' does not name a type
   72 |   heap[0] := heap[0] - 1;
      |   ^~~~
a.cc:73:3: error: 'p' does not name a type
   73 |   p := 1;
      |   ^
a.cc:74:3: error: expected unqualified-id before 'while'
   74 |   while (p*2 <= heap[0]) and (heap[p]<heap[p*2]) or (p*2+1 <= heap[0]) and (heap[p]<heap[p*2+1]) do
      |   ^~~~~
a.cc:77:7: error: 'p' does not name a type
   77 |       p := p*2+1
      |       ^
a.cc:80:7: error: 'p' does not name a type
   80 |       p := p*2
      |       ^
a.cc:84:1: error: 'begin' does not name a type
   84 | begin
      | ^~~~~
a.cc:87:3: error: expected unqualified-id before 'for'
   87 |   for i := 1 to n do readln(input[i].a,input[i].b);
      |   ^~~
a.cc:88:12: error: expected constructor, destructor, or type conversion before '(' token
   88 |   QuickSort(input,1,n);
      |            ^
a.cc:89:3: error: 'j' does not name a type
   89 |   j := 1;
      |   ^
a.cc:90:3: error: 'ans' does not name a type
   90 |   ans := 0;
      |   ^~~
a.cc:91:3: error: expected unqualified-id before 'for'
   91 |   for i := 1 to m do begin
      |   ^~~
a.cc:94:7: error: 'j' does not name a type
   94 |       j := j + 1
      |       ^
a.cc:96:5: error: expected unqualified-id before 'if'
   96 |     if heap[0]>0 then ans := ans + downheap
      |     ^~
a.cc:98:10: error: expected constructor, destructor, or type conversion before '(' token
   98 |   writeln(ans);
      |          ^
a.cc:99:8: error: expected constructor, destructor, or type conversion before '(' token
   99 |   close(f);
      |        ^
a.cc:100:8: error: expected constructor, destructor, or type conversion before '(' token
  100 |   close(g);
      |        ^
a.cc:101:1: error: 'end' does not name a type
  101 | end.
      | ^~~