Language: C++

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC127D34
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            long N = long.Parse(str[0]);//カードの枚数
            long M = long.Parse(str[1]);//操作の回数
            long[] A = new long[N];
            string[] str2 = Console.ReadLine().Split();
            for (int i = 0; i < N; i++)
            {
                A[i] = long.Parse(str2[i]);//カードの値
            }
            //Console.WriteLine(N+" "+M);
            //Array.Sort(A, (x, y) => x.CompareTo(y));
            Array.Sort(A);
            long[][] B = new long[M][];
            for (int i = 0; i < M; i++)
            {
                string[] str3 = Console.ReadLine().Split();
                B[i] = new long[2];
                B[i][0] = long.Parse(str3[0]);//B枚
                B[i][1] = long.Parse(str3[1]);//置き換える値
            }
            Array.Sort(B, (x, y) => y[1].CompareTo(x[1]));//置き換える値の大きい順にソート
            /*
            for (int i = 0; i < M; i++)
            {
                Console.WriteLine(B[i][0]+" "+B[i][1]);
            }
            */
            var list = new List<long> ();
            int ct = 0;
            for (int i = 0; i < M; i++)
            {
                for (long j = 0; j < B[i][0]; j++)
                {
                    list.Add(B[i][1]);
                    ct++;
                    if (ct > N)
                    {
                        break;
                    }
                }
            }
            long ans = 0;
            for (int i = 0; i < Math.Min(N,list.Count); i++)
            {
                ans += Math.Max(A[i], list[i]);
            }
            for (long i = Math.Min(N,list.Count); i < N; i++)
            {
                ans += A[i];
            }
            Console.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 'System'
    4 | using System.Text;
      |       ^~~~~~
a.cc:5:7: error: expected nested-name-specifier before 'System'
    5 | using System.Threading.Tasks;
      |       ^~~~~~
a.cc:11:26: error: 'string' has not been declared
   11 |         static void Main(string[] args)
      |                          ^~~~~~
a.cc:11:35: error: expected ',' or '...' before 'args'
   11 |         static void Main(string[] args)
      |                                   ^~~~
a.cc:65:6: error: expected ';' after class definition
   65 |     }
      |      ^
      |      ;
a.cc: In static member function 'static void ABC127D34::Program::Main(int*)':
a.cc:13:13: error: 'string' was not declared in this scope
   13 |             string[] str = Console.ReadLine().Split();
      |             ^~~~~~
a.cc:13:20: error: expected primary-expression before ']' token
   13 |             string[] str = Console.ReadLine().Split();
      |                    ^
a.cc:14:22: error: expected primary-expression before 'long'
   14 |             long N = long.Parse(str[0]);//カードの枚数
      |                      ^~~~
a.cc:15:22: error: expected primary-expression before 'long'
   15 |             long M = long.Parse(str[1]);//操作の回数
      |                      ^~~~
a.cc:16:17: error: structured binding declaration cannot have type 'long int'
   16 |             long[] A = new long[N];
      |                 ^~
a.cc:16:17: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:16:17: error: empty structured binding declaration
a.cc:16:20: error: expected initializer before 'A'
   16 |             long[] A = new long[N];
      |                    ^
a.cc:17:20: error: expected primary-expression before ']' token
   17 |             string[] str2 = Console.ReadLine().Split();
      |                    ^
a.cc:20:17: error: 'A' was not declared in this scope
   20 |                 A[i] = long.Parse(str2[i]);//カードの値
      |                 ^
a.cc:20:24: error: expected primary-expression before 'long'
   20 |                 A[i] = long.Parse(str2[i]);//カードの値
      |                        ^~~~
a.cc:24:13: error: 'Array' was not declared in this scope
   24 |             Array.Sort(A);
      |             ^~~~~
a.cc:24:24: error: 'A' was not declared in this scope
   24 |             Array.Sort(A);
      |                        ^
a.cc:25:17: error: structured binding declaration cannot have type 'long int'
   25 |             long[][] B = new long[M][];
      |                 ^~
a.cc:25:17: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:25:17: error: empty structured binding declaration
a.cc:25:19: error: expected initializer before '[' token
   25 |             long[][] B = new long[M][];
      |                   ^
a.cc:28:24: error: expected primary-expression before ']' token
   28 |                 string[] str3 = Console.ReadLine().Split();
      |                        ^
a.cc:29:17: error: 'B' was not declared in this scope
   29 |                 B[i] = new long[2];
      |                 ^
a.cc:30:27: error: expected primary-expression before 'long'
   30 |                 B[i][0] = long.Parse(str3[0]);//B枚
      |                           ^~~~
a.cc:31:27: error: expected primary-expression before 'long'
   31 |                 B[i][1] = long.Parse(str3[1]);//置き換える値
      |                           ^~~~
a.cc:33:24: error: 'B' was not declared in this scope
   33 |             Array.Sort(B, (x, y) => y[1].CompareTo(x[1]));//置き換える値の大きい順にソート
      |                        ^
a.cc:33:28: error: 'x' was not declared in this scope
   33 |             Array.Sort(B, (x, y) => y[1].CompareTo(x[1]));//置き換える値の大きい順にソート
      |                            ^
a.cc:33:31: error: 'y' was not declared in this scope
   33 |             Array.Sort(B, (x, y) => y[1].CompareTo(x[1]));//置き換える値の大きい順にソート
      |                               ^
a.cc:33:35: error: expected primary-expression before '>' token
   33 |             Array.Sort(B, (x, y) => y[1].CompareTo(x[1]));//置き換える値の大きい順にソート
      |                                   ^
a.cc:40:13: error: 'var' was not declared in this scope
   40 |             var list = new List<long> ();
      |             ^~~
a.cc:46:21: error: 'list' was not declared in this scope
   46 |                     list.Add(B[i][1]);
      |                     ^~~~
a.cc:55:33: error: 'Math' was not declared in this scope
   55 |             for (int i = 0; i < Math.Min(N,list.Count); i++)
      |                                 ^~~~
a.cc:55:44: error: 'list' was not declared in this scope
   55 |             for (int i = 0; i < Math.Min(N,list.Count); i++)
      |                                            ^~~~
a.cc:59:27: error: 'Math' was not declared in this scope
   59 |             for (long i = Math.Min(N,list.Count); i < N; i++)
      |                           ^~~~
a.cc:59:38: error: 'list' was not declared in this scope
   59 |             for (long i = Math.Min(N,list.Count); i < N; i++)
      |                                      ^~~~
a.cc:63:13: error: 'Console' was not declared in this scope
   63 |             Console.WriteLine(ans);
      |             ^~~~~~~