Language: Java

#pragma GCC optimize("O3")

/****Author: Barish Namazov****/
#include <bits/stdc++.h>

using namespace std;

/***TEMPLATE***/
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

#define F first
#define S second
#define pb push_back

#define endl '\n'

const int max4 = 10004;
const int maxx = 100005;
const int max6 = 1000006;
const int lg5 = 17;

const int INF = 2 * 1000000007;
const long long INFLL = 4LL * 1000000000 * 1000000000;

/***************/

int powmod (int a, int b, int mod) {
    int res = 1; a %= mod;
    for (; b; b >>= 1) {
        if (b & 1) {
            res = 1LL * res * a % mod;
        }
        a = 1LL * a * a % mod;
    }
    return res;
}

int gcd (int a, int b) {
    while (b > 0) {
        int t = a % b;
        a = b, b = t;
    }
    return a;
}

int lcm (int a, int b) {
    return (a / gcd (a, b)) * b;
}

int is_prime (int n) {
    if (n <= 1 || n > 3 && (n % 2 == 0 || n % 3 == 0))
        return 0;
    for (int i = 5, t = 2; i * i <= n; i += t, t = 6 - t)
        if (n % i == 0)
            return 0;
    return 1;
}

/******Don't forget to use long long when needed!!******/

int F[maxx << 1];
void update(int i, int val) {
    for (; i < (maxx << 1); i |= i + 1) {
        F[i] += val;
    }
}
int getf(int i) {
    int res = 0;
    for (; i >= 0; i &= i + 1, i--) {
        res += F[i];
    }
    return res;
}

int n, arr[maxx], brr[maxx];
const int N = 100001;

long long get(int x) {
    vector <int> pref(n + 1, 0);
    for (int i = 1; i <= n; i++) {
        if (brr[i] < x) {
            arr[i] = -1;
        } else if (brr[i] == x) {
            arr[i] = 1;
        } else {
            arr[i] = 1;
        }
        pref[i] = pref[i - 1] + arr[i];
    }
    for (int i = 1; i <= n; i++) pref[i] += N;
    long long res = 0;
    update(N, 1);
    for (int i = 1; i <= n; i++) {
        res += getf(maxx * 2 - 1) - getf(pref[i]);
        update(pref[i], 1);
    }
    return res;
}

int main() {
    //freopen("262144.in","r",stdin);
    //freopen("262144.out","w",stdout);
    cin >> n;
    vector <int> v;
    for (int i = 1; i <= n; i++) {
        cin >> arr[i]; brr[i] = arr[i];
        v.pb(arr[i]);
    }/*
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = i; j <= n; j++) {
            vector <int> p;
            for (int k = i; k <= j; k++) {
                p.pb(arr[k]);
            }
            sort(all(p));
            int md = p[p.size() / 2];
            if (md < 5) cnt++;
        }
    }
    cout << cnt << endl;
    cout << get(5) << " " << get(8) << endl;
    return 0;*/


    long long total = 1LL * n * (n + 1) / 2LL;
    int l = 0, r = v.size() - 1, best;
    while (r - l >= 0) {
        int mid = (l + r) >> 1, x = v[mid];
        long long t = get(x);
        if (t > total / 2 + 1) {
            r = mid - 1;
        } else {
            l = mid + 1, best = mid;
        }
        memset(F, 0, sizeof(F));
    }
    cout << v[best] << endl;
    return 0;
}


Compiler output:
Main.java:1: error: illegal character: '#'
#pragma GCC optimize("O3")
^
Main.java:4: error: illegal character: '#'
#include <bits/stdc++.h>
^
Main.java:1: error: unnamed classes are a preview feature and are disabled by default.
#pragma GCC optimize("O3")
        ^
  (use --enable-preview to enable unnamed classes)
Main.java:4: error: class, interface, enum, or record expected
#include <bits/stdc++.h>
         ^
Main.java:9: error: illegal character: '#'
#define all(v) (v).begin(),(v).end()
^
Main.java:9: error: class, interface, enum, or record expected
#define all(v) (v).begin(),(v).end()
        ^
Main.java:10: error: illegal character: '#'
#define rall(v) (v).rbegin(),(v).rend()
^
Main.java:12: error: illegal character: '#'
#define F first
^
Main.java:13: error: illegal character: '#'
#define S second
^
Main.java:14: error: illegal character: '#'
#define pb push_back
^
Main.java:16: error: illegal character: '#'
#define endl '\n'
^
Main.java:19: error: class, interface, enum, or record expected
const int maxx = 100005;
^
Main.java:20: error: class, interface, enum, or record expected
const int max6 = 1000006;
^
Main.java:21: error: class, interface, enum, or record expected
const int lg5 = 17;
^
Main.java:23: error: class, interface, enum, or record expected
const int INF = 2 * 1000000007;
^
Main.java:24: error: class, interface, enum, or record expected
const long long INFLL = 4LL * 1000000000 * 1000000000;
^
Main.java:32: error: not a statement
            res = 1LL * res * a % mod;
                                ^
Main.java:34: error: not a statement
        a = 1LL * a * a % mod;
                        ^
Main.java:32: error: ';' expected
            res = 1LL * res * a % mod;
                    ^
Main.java:34: error: ';' expected
        a = 1LL * a * a % mod;
              ^
Main.java:42: error: ';' expected
        a = b, b = t;
             ^
Main.java:62: error: class, interface, enum, or record expected
int F[maxx << 1];
^
Main.java:76: error: class, interface, enum, or record expected
int n, arr[maxx], brr[maxx];
^
Main.java:77: error: class, interface, enum, or record expected
const int N = 100001;
^
Main.java:79: error: class, interface, enum, or record expected
long long get(int x) {
^
Main.java:81: error: class, interface, enum, or record expected
    for (int i = 1; i <= n; i++) {
    ^
Main.java:81: error: class, interface, enum, or record expected
    for (int i = 1; i <= n; i++) {
                    ^
Main.java:81: error: class, interface, enum, or record expected
    for (int i = 1; i <= n; i++) {
                            ^
Main.java:84: error: class, interface, enum, or record expected
        } else if (brr[i] == x) {
        ^
Main.java:86: error: class, interface, enum, or record expected
        } else {
        ^
Main.java:88: error: class, interface, enum, or record expected
        }
        ^
Main.java:90: error: class, interface, enum, or record expected
    }
    ^
Main.java:91: error: class, interface, enum, or record expected
    for (int i = 1; i <= n; i++) pref[i] += N;
                    ^
Main.java:91: error: class, interface, enum, or record expected
    for (int i = 1; i <= n; i++) pref[i] += N;
                            ^
Main.java:92: error: class, interface, enum, or record expected
    long long res = 0;
    ^
Main.java:93: error: class, interface, enum, or record expected
    update(N, 1);
    ^
Main.java:94: error: class, interface, enum, or record expected
    for (int i = 1; i <= n; i++) {
    ^
Main.java:94: error: class, interface, enum, or record expected
    for (int i = 1; i <= n; i++) {
                    ^
Main.java:94: error: class, interface, enum, or record expected
    for (int i = 1; i <= n; i++) {
                            ^
Main.java:96: error: class, interface, enum, or record expected
        update(pref[i], 1);
        ^
Main.java:97: error: class, interface, enum, or record expected
    }
    ^
Main.java:99: error: class, interface, enum, or record expected
}
^
Main.java:106: error: class, interface, enum, or record expected
    for (int i = 1; i <= n; i++) {
    ^
Main.java:106: error: class, interface, enum, or record expected
    for (int i = 1; i <= n; i++) {
                    ^
Main.java:106: error: class, interface, enum, or record expected
    for (int i = 1; i <= n; i++) {
                            ^
Main.java:107: error: class, interface, enum, or record expected
        cin >> arr[i]; brr[i] = arr[i];
                       ^
Main.java:108: error: class, interface, enum, or record expected
        v.pb(arr[i]);
        ^
Main.java:109: error: class, interface, enum, or record expected
    }/*
    ^
Main.java:129: error: class, interface, enum, or record expected
    while (r - l >= 0) {
    ^
Main.java:131: error: class, interface, enum, or record expected
        long long t = get(x);
        ^
Main.java:132: error: class, interface, enum, or record expected
        if (t > total / 2 + 1) {
        ^
Main.java:134: error: class, interface, enum, or record expected
        } else {
        ^
Main.java:136: error: class, interface, enum, or record expected
        }
        ^
Main.java:138: error: class, interface, enum, or record expected
    }
    ^
Main.java:140: error: class, interface, enum, or record expected
    return 0;
    ^
Main.java:141: error: class, interface, enum, or record expected
}
^
56 errors