Language: C++

using System;
using System.Linq;

namespace Algorithm_cs
{
    class Program
    {
        static void Main()
        {
            var inputs = CInputArray();
            var N = inputs[0];
            var M = inputs[1];
            var A = new (int a, int b)[N];
            for (int i = 0; i < N; i++)
            {
                A[i] = CInputPair();
            }

            Array.Sort(A);
            Array.Reverse(A);


            var P = RepInts(-1, M);
            var PEnd = RangeInts(0, M + 1);
            var remain = M;
            var ret = 0;

            for (int i = 0; i < N; i++)
            {
                if (remain == 0)
                {
                    break;
                }

                if (A[i].a >= M + 1)
                {
                    continue;
                }

                var ok = true;
                for (int j = PEnd[A[i].a - 1]; j < M; j++)
                {
                    if (P[j] == -1)
                    {
                        ret += A[i].b;
                        P[j] = i;
                        remain--;
                        PEnd[A[i].a] = j + 1;
                        ok = false;
                        break;
                    }
                }
                if (ok)
                {
                    PEnd[A[i].a] = M;
                }
            }

            Console.WriteLine(ret);
        }

        static int CInput()
        {
            return int.Parse(Console.ReadLine());
        }
        static (int, int) CInputPair()
        {
            var inputs = Console.ReadLine().Split(' ');
            return (int.Parse(inputs[0]), int.Parse(inputs[1]));
        }
        static (int, int, int) CInputTuple3()
        {
            var inputs = Console.ReadLine().Split(' ');
            return (int.Parse(inputs[0]), int.Parse(inputs[1]), int.Parse(inputs[2]));
        }
        static int[] CInputArray()
        {
            var inputs = Console.ReadLine().Split(' ');
            var outputs = new int[inputs.Length];
            for (int i = 0; i < inputs.Length; i++)
            {
                outputs[i] = int.Parse(inputs[i]);
            }
            return outputs;
        }

        static int[] RepInts(int element, int count)
        {
            return Enumerable.Repeat(element, count).ToArray();
        }
        static int[] RangeInts(int start, int count)
        {
            return Enumerable.Range(start, count).ToArray();
        }
    }
}


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.Linq;
      |       ^~~~~~
a.cc:66:17: error: expected unqualified-id before 'int'
   66 |         static (int, int) CInputPair()
      |                 ^~~
a.cc:66:17: error: expected ')' before 'int'
   66 |         static (int, int) CInputPair()
      |                ~^~~
      |                 )
a.cc:71:17: error: expected unqualified-id before 'int'
   71 |         static (int, int, int) CInputTuple3()
      |                 ^~~
a.cc:71:17: error: expected ')' before 'int'
   71 |         static (int, int, int) CInputTuple3()
      |                ~^~~
      |                 )
a.cc:76:19: error: expected unqualified-id before '[' token
   76 |         static int[] CInputArray()
      |                   ^
a.cc:87:19: error: expected unqualified-id before '[' token
   87 |         static int[] RepInts(int element, int count)
      |                   ^
a.cc:91:19: error: expected unqualified-id before '[' token
   91 |         static int[] RangeInts(int start, int count)
      |                   ^
a.cc:95:6: error: expected ';' after class definition
   95 |     }
      |      ^
      |      ;
a.cc: In static member function 'static void Algorithm_cs::Program::Main()':
a.cc:10:13: error: 'var' was not declared in this scope
   10 |             var inputs = CInputArray();
      |             ^~~
a.cc:11:17: error: expected ';' before 'N'
   11 |             var N = inputs[0];
      |                 ^
a.cc:12:17: error: expected ';' before 'M'
   12 |             var M = inputs[1];
      |                 ^
a.cc:13:17: error: expected ';' before 'A'
   13 |             var A = new (int a, int b)[N];
      |                 ^
a.cc:14:33: error: 'N' was not declared in this scope
   14 |             for (int i = 0; i < N; i++)
      |                                 ^
a.cc:16:17: error: 'A' was not declared in this scope
   16 |                 A[i] = CInputPair();
      |                 ^
a.cc:16:24: error: 'CInputPair' was not declared in this scope; did you mean 'CInput'?
   16 |                 A[i] = CInputPair();
      |                        ^~~~~~~~~~
      |                        CInput
a.cc:19:13: error: 'Array' was not declared in this scope
   19 |             Array.Sort(A);
      |             ^~~~~
a.cc:19:24: error: 'A' was not declared in this scope
   19 |             Array.Sort(A);
      |                        ^
a.cc:23:17: error: expected ';' before 'P'
   23 |             var P = RepInts(-1, M);
      |                 ^
a.cc:24:17: error: expected ';' before 'PEnd'
   24 |             var PEnd = RangeInts(0, M + 1);
      |                 ^~~~
a.cc:25:17: error: expected ';' before 'remain'
   25 |             var remain = M;
      |                 ^~~~~~
a.cc:26:17: error: expected ';' before 'ret'
   26 |             var ret = 0;
      |                 ^~~
a.cc:28:33: error: 'N' was not declared in this scope
   28 |             for (int i = 0; i < N; i++)
      |                                 ^
a.cc:30:21: error: 'remain' was not declared in this scope; did you mean 'Main'?
   30 |                 if (remain == 0)
      |                     ^~~~~~
      |                     Main
a.cc:35:31: error: 'M' was not declared in this scope
   35 |                 if (A[i].a >= M + 1)
      |                               ^
a.cc:40:21: error: expected ';' before 'ok'
   40 |                 var ok = true;
      |                     ^~
a.cc:41:30: error: 'PEnd' was not declared in this scope
   41 |                 for (int j = PEnd[A[i].a - 1]; j < M; j++)
      |                              ^~~~
a.cc:41:52: error: 'M' was not declared in this scope
   41 |                 for (int j = PEnd[A[i].a - 1]; j < M; j++)
      |                                                    ^
a.cc:43:25: error: 'P' was not declared in this scope
   43 |                     if (P[j] == -1)
      |                         ^
a.cc:45:25: error: 'ret' was not declared in this scope
   45 |                         ret += A[i].b;
      |                         ^~~
a.cc:47:25: error: 'remain' was not declared in this scope; did you mean 'Main'?
   47 |                         remain--;
      |                         ^~~~~~
      |                         Main
a.cc:49:25: error: 'ok' was not declared in this scope
   49 |                         ok = false;
      |                         ^~
a.cc:53:21: error: 'ok' was not declared in this scope
   53 |                 if (ok)
      |                     ^~
a.cc:55:21: error: 'PEnd' was not declared in this scope
   55 |                     PEnd[A[i].a] = M;
      |                     ^~~~
a.cc:55:36: error: 'M' was not declared in this scope
   55 |                     PEnd[A[i].a] = M;
      |                                    ^
a.cc:59:13: error: 'Console' was not declared in this scope
   59 |             Console.WriteLine(ret);
      |             ^~~~~~~
a.cc:59:31: error: 'ret' was not declared in this scope
   59 |             Console.WriteLine(ret);
      |                               ^~~
a.cc: In static member function 'static int Algorithm_cs::Program::CInput()':
a.cc:64:20: error: expected primary-expression before 'int'
   64 |             return int.Parse(Console.ReadLine());
      |                    ^~~
a.cc:64:20: error: expected ';' before 'int'
a.cc:64:23: error: expected unqualified-id before '.' token
   64 |             return int.Parse(Console.ReadLine());
      |                       ^