Language: C++

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

namespace ConsoleAppNearestCardGame0122
{
    class Program
    {
        public struct members
        {
            public int distance;
            public int Aoki;
        }
        static void Main(string[] args)
        {
            // 整数の入力
            //int n = int.Parse(Console.ReadLine());
            // スペース区切りの整数の入力
            //string[] input = Console.ReadLine().Split(' ');
            //int b = int.Parse(input[0]);
            //int c = int.Parse(input[1]);
            // 文字列の入力
            //string s = Console.ReadLine();
            var inputNQ = Console.ReadLine().Split().Select(int.Parse).ToArray();// N枚数、Q種類の候補
            var inputA = Console.ReadLine().Split().Select(int.Parse).ToArray();// N枚のカードの値
            //List<int> X = new List<int>();
            int[] X = new int[inputNQ[1]];
            for (int i = 0; i < inputNQ[1]; i++) // inputNQ[1]は候補の数
            {
                X[i]=int.Parse(Console.ReadLine());// 指定する値
            }
            //
            // 入力終わり
            //

            int[] distance = new int[inputNQ[0]];// 配列の宣言
            int distanceFromX = 0;

            for (int j = 0; j < X.Length; j++) // 指定された値
            {
                List<members> distanceList = new List<members>();
                List<int> CheckList = new List<int>();
                for (int i = 0; i < inputA.Length; i++)
                {
                    members ms;
                    distanceFromX = (X[j]-1) - inputA[i];//指定されたx[j]からの距離（同じ距離なら小さい方を選ぶので－１）
                    ms.distance=Math.Abs(distanceFromX);
                    ms.Aoki = inputA[i];
                    distanceList.Add(ms);
                }
                distanceList.Sort((a, b) => a.distance - b.distance);// 指定されたx[j]からの距離順にソート

                int onlyTakahashi = 0;
                Array.Sort(inputA);
                Array.Reverse(inputA);// 大きい順にソートした。高橋くんの取るカードの順序

                CheckList.Clear();
                for (int k = 0; k < inputA.Length; k++)
                {
                    if (CheckList.Contains(inputA[k]) == false)
                    {
                        CheckList.Add(inputA[k]);// 高橋くんの取るカード
                    } else
                    {
                        break;
                    }
                    if (CheckList.Contains(distanceList[k].Aoki)==false)
                    {
                        CheckList.Add(distanceList[k].Aoki);
                    }
                    else
                    {
                        break;
                    }
                }
                onlyTakahashi = (CheckList.Count +1)/2;// 高橋くんだけが取る個数（大きい方から）

                int ans = 0;
                for(int m = 0; m < onlyTakahashi; m++)
                {
                    ans += inputA[m];
                }
                for(int n = onlyTakahashi*2; n < inputA.Length; n++)
                {
                    if (n % 2 == 0)
                    {
                        ans += inputA[n];
                    }
                }
                
                Console.WriteLine(ans);

                /*
                Console.Write(X[j] + "によって並べ替えたinputAの値:");
                foreach (var member in distanceList)
                {
                    Console.Write(member.Aoki + " ");
                }
                Console.WriteLine();

                Console.WriteLine("高橋くんだけが取る："+onlyTakahashi);
                */
            }
        }// Main終わり
    }
}


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:15: error: expected ':' before 'struct'
   11 |         public struct members
      |               ^~~~~~~
      |               :
a.cc:13:19: error: expected ':' before 'int'
   13 |             public int distance;
      |                   ^~~~
      |                   :
a.cc:14:19: error: expected ':' before 'int'
   14 |             public int Aoki;
      |                   ^~~~
      |                   :
a.cc:15:10: error: expected ';' after struct definition
   15 |         }
      |          ^
      |          ;
a.cc:16:26: error: 'string' has not been declared
   16 |         static void Main(string[] args)
      |                          ^~~~~~
a.cc:16:35: error: expected ',' or '...' before 'args'
   16 |         static void Main(string[] args)
      |                                   ^~~~
a.cc:107:6: error: expected ';' after class definition
  107 |     }
      |      ^
      |      ;
a.cc: In static member function 'static void ConsoleAppNearestCardGame0122::Program::Main(int*)':
a.cc:26:13: error: 'var' was not declared in this scope
   26 |             var inputNQ = Console.ReadLine().Split().Select(int.Parse).ToArray();// N枚数、Q種類の候補
      |             ^~~
a.cc:27:17: error: expected ';' before 'inputA'
   27 |             var inputA = Console.ReadLine().Split().Select(int.Parse).ToArray();// N枚のカードの値
      |                 ^~~~~~
a.cc:29:16: error: structured binding declaration cannot have type 'int'
   29 |             int[] X = new int[inputNQ[1]];
      |                ^~
a.cc:29:16: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:29:16: error: empty structured binding declaration
a.cc:29:19: error: expected initializer before 'X'
   29 |             int[] X = new int[inputNQ[1]];
      |                   ^
a.cc:30:33: error: 'inputNQ' was not declared in this scope
   30 |             for (int i = 0; i < inputNQ[1]; i++) // inputNQ[1]は候補の数
      |                                 ^~~~~~~
a.cc:32:17: error: 'X' was not declared in this scope
   32 |                 X[i]=int.Parse(Console.ReadLine());// 指定する値
      |                 ^
a.cc:32:22: error: expected primary-expression before 'int'
   32 |                 X[i]=int.Parse(Console.ReadLine());// 指定する値
      |                      ^~~
a.cc:38:16: error: structured binding declaration cannot have type 'int'
   38 |             int[] distance = new int[inputNQ[0]];// 配列の宣言
      |                ^~
a.cc:38:16: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:38:16: error: empty structured binding declaration
a.cc:38:19: error: expected initializer before 'distance'
   38 |             int[] distance = new int[inputNQ[0]];// 配列の宣言
      |                   ^~~~~~~~
a.cc:41:33: error: 'X' was not declared in this scope
   41 |             for (int j = 0; j < X.Length; j++) // 指定された値
      |                                 ^
a.cc:43:17: error: 'List' was not declared in this scope
   43 |                 List<members> distanceList = new List<members>();
      |                 ^~~~
a.cc:43:29: error: expected primary-expression before '>' token
   43 |                 List<members> distanceList = new List<members>();
      |                             ^
a.cc:43:31: error: 'distanceList' was not declared in this scope
   43 |                 List<members> distanceList = new List<members>();
      |                               ^~~~~~~~~~~~
a.cc:43:50: error: 'List' does not name a type
   43 |                 List<members> distanceList = new List<members>();
      |                                                  ^~~~
a.cc:43:62: error: expected primary-expression before '>' token
   43 |                 List<members> distanceList = new List<members>();
      |                                                              ^
a.cc:43:64: error: expected primary-expression before ')' token
   43 |                 List<members> distanceList = new List<members>();
      |                                                                ^
a.cc:44:22: error: expected primary-expression before 'int'
   44 |                 List<int> CheckList = new List<int>();
      |                      ^~~
a.cc:45:37: error: 'inputA' was not declared in this scope
   45 |                 for (int i = 0; i < inputA.Length; i++)
      |                                     ^~~~~~
a.cc:49:33: error: 'Math' was not declared in this scope
   49 |                     ms.distance=Math.Abs(distanceFromX);
      |                                 ^~~~
a.cc:53:36: error: 'a' was not declared in this scope
   53 |                 distanceList.Sort((a, b) => a.distance - b.distance);// 指定されたx[j]からの距離順にソート
      |                                    ^
a.cc:53:39: error: 'b' was not declared in this scope
   53 |                 distanceList.Sort((a, b) => a.distance - b.distance);// 指定されたx[j]からの距離順にソート
      |                                       ^
a.cc:53:43: error: expected primary-expression before '>' token
   53 |                 distanceList.Sort((a, b) => a.distance - b.distance);// 指定されたx[j]からの距離順にソート
      |                                           ^
a.cc:56:17: error: 'Array' was not declared in this scope
   56 |                 Array.Sort(inputA);
      |                 ^~~~~
a.cc:56:28: error: 'inputA' was not declared in this scope
   56 |                 Array.Sort(inputA);
      |                            ^~~~~~
a.cc:59:17: error: 'CheckList' was not declared in this scope
   59 |                 CheckList.Clear();
      |                 ^~~~~~~~~
a.cc:93:17: error: 'Console' was not declared in this scope
   93 |                 Console.WriteLine(ans);
      |                 ^~~~~~~