Language: C++

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest._600problems
{
    class ARC098_E
    {
        static void Main(string[] args)
        {
            Method(args);
        }

        static void Method(string[] args)
        {
            int[] nkq = ReadInts();
            int n = nkq[0];
            int k = nkq[1];
            int q = nkq[2];
            int[] array = ReadInts();

            int[][] valPos = new int[n][];
            for(int i = 0; i < n; i++)
            {
                valPos[i] = new int[2] { array[i], i };
            }
            Array.Sort(valPos, (a, b) => a[0] - b[0]);

            int res = int.MaxValue;
            for(int i = 0; i < n; i++)
            {
                bool[] exclude = new bool[n];

                int remain = 0;
                for(int j = 0; j < n; j++)
                {
                    if (array[j] < array[i]) remain = k;

                    if (remain > 0) exclude[j] = true;
                    remain--;
                }
                remain = 0;
                for (int j = n-1; j >=0; j--)
                {
                    if (array[j] < array[i]) remain = k;

                    if (remain > 0) exclude[j] = true;
                    remain--;
                }

                int now = 0;
                for(int j = 0; j < n; j++)
                {
                    if (exclude[valPos[j][1]]) continue;

                    now++;
                    if (now == q)
                    {
                        res = Min(res, valPos[j][0] - array[i]);
                        break;
                    }
                }
            }

            WriteLine(res);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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 'static'
    5 | using static System.Console;
      |       ^~~~~~
a.cc:6:7: error: expected nested-name-specifier before 'static'
    6 | using static System.Math;
      |       ^~~~~~
a.cc:8:17: error: expected '{' before '.' token
    8 | namespace AtTest._600problems
      |                 ^
a.cc:8:17: error: expected unqualified-id before '.' token