Language: C++

    import std.math;
    import std.conv;
    import std.range;
    import std.stdio;
    import std.string;
    import std.container;
    import std.algorithm;
     
    int n;
    int[100_001] tree;
    int[] a;
    int[] s;
    long pairs;
     
    void add(int i)
    {
        for (; i <= n; i |= i + 1)
            ++tree[i];
    }
     
    int get(int r)
    {
        int res;
        for (; r >= 0; r = (r & (r + 1)) - 1)
            res += tree[r];
        return res;
    }
     
    bool ok(int x)
    {
        tree[] = 0;
        foreach (i, val; a) {
            s[i] = val >= x ? 1 : -1;
        }
        foreach (i; iota(n - 1))
          s[i + 1] += s[i];
        int shift = s.fold!min;
        long t;
        foreach (val; s.map!(x => x - shift)) {
            add(val);
            t += get(val);
        }
        return t >= (pairs + 1) / 2;
    }
     
    void main()
    {
        readf("%d\n", &n);
        a = readln.splitter.map!(to!int).array;
        s = new int[a.length];
        pairs = (n * (n + 1)) / 2;
        auto b = a.fold!(min, max);
        int l = b[0];
        int r = b[1];
        while (l < r) {
            int mid = (l + r + 1) / 2;
            if (ok(mid))
                l = mid;
            else
                r = mid - 1;
        }
        writeln(l);
    }


Compiler output:
a.cc:1:5: error: 'import' does not name a type
    1 |     import std.math;
      |     ^~~~~~
a.cc:1:5: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:5: error: 'import' does not name a type
    2 |     import std.conv;
      |     ^~~~~~
a.cc:2:5: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:5: error: 'import' does not name a type
    3 |     import std.range;
      |     ^~~~~~
a.cc:3:5: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:5: error: 'import' does not name a type
    4 |     import std.stdio;
      |     ^~~~~~
a.cc:4:5: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:5: error: 'import' does not name a type
    5 |     import std.string;
      |     ^~~~~~
a.cc:5:5: note: C++20 'import' only available with '-fmodules-ts'
a.cc:6:5: error: 'import' does not name a type
    6 |     import std.container;
      |     ^~~~~~
a.cc:6:5: note: C++20 'import' only available with '-fmodules-ts'
a.cc:7:5: error: 'import' does not name a type
    7 |     import std.algorithm;
      |     ^~~~~~
a.cc:7:5: note: C++20 'import' only available with '-fmodules-ts'
a.cc:10:9: error: expected identifier before numeric constant
   10 |     int[100_001] tree;
      |         ^~~~~~~
a.cc:10:9: error: expected ']' before numeric constant
   10 |     int[100_001] tree;
      |         ^~~~~~~
      |         ]
a.cc:10:8: error: structured binding declaration cannot have type 'int'
   10 |     int[100_001] tree;
      |        ^
a.cc:10:8: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:10:8: error: empty structured binding declaration
a.cc:10:18: error: expected initializer before 'tree'
   10 |     int[100_001] tree;
      |                  ^~~~
a.cc:11:8: error: structured binding declaration cannot have type 'int'
   11 |     int[] a;
      |        ^~
a.cc:11:8: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:11:8: error: empty structured binding declaration
a.cc:11:11: error: expected initializer before 'a'
   11 |     int[] a;
      |           ^
a.cc:12:8: error: structured binding declaration cannot have type 'int'
   12 |     int[] s;
      |        ^~
a.cc:12:8: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:12:8: error: empty structured binding declaration
a.cc:12:11: error: expected initializer before 's'
   12 |     int[] s;
      |           ^
a.cc: In function 'void add(int)':
a.cc:18:15: error: 'tree' was not declared in this scope
   18 |             ++tree[i];
      |               ^~~~
a.cc: In function 'int get(int)':
a.cc:25:20: error: 'tree' was not declared in this scope
   25 |             res += tree[r];
      |                    ^~~~
a.cc: In function 'bool ok(int)':
a.cc:31:9: error: 'tree' was not declared in this scope
   31 |         tree[] = 0;
      |         ^~~~
a.cc:31:14: error: expected primary-expression before ']' token
   31 |         tree[] = 0;
      |              ^
a.cc:32:18: error: 'i' was not declared in this scope
   32 |         foreach (i, val; a) {
      |                  ^
a.cc:32:21: error: 'val' was not declared in this scope
   32 |         foreach (i, val; a) {
      |                     ^~~
a.cc:32:26: error: 'a' was not declared in this scope
   32 |         foreach (i, val; a) {
      |                          ^
a.cc:35:19: error: expected ')' before ';' token
   35 |         foreach (i; iota(n - 1))
      |                 ~ ^
      |                   )
a.cc:35:21: error: 'iota' was not declared in this scope
   35 |         foreach (i; iota(n - 1))
      |                     ^~~~
a.cc:37:21: error: 's' was not declared in this scope
   37 |         int shift = s.fold!min;
      |                     ^
a.cc:39:21: error: expected ')' before ';' token
   39 |         foreach (val; s.map!(x => x - shift)) {
      |                 ~   ^
      |                     )
a.cc: At global scope:
a.cc:46:5: error: '::main' must return 'int'
   46 |     void main()
      |     ^~~~
a.cc: In function 'int main()':
a.cc:48:9: error: 'readf' was not declared in this scope
   48 |         readf("%d\n", &n);
      |         ^~~~~
a.cc:49:9: error: 'a' was not declared in this scope
   49 |         a = readln.splitter.map!(to!int).array;
      |         ^
a.cc:49:13: error: 'readln' was not declared in this scope
   49 |         a = readln.splitter.map!(to!int).array;
      |             ^~~~~~
a.cc:50:9: error: 's' was not declared in this scope
   50 |         s = new int[a.length];
      |         ^
a.cc:62:9: error: 'writeln' was not declared in this scope
   62 |         writeln(l);
      |         ^~~~~~~