Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = ll;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

struct BIT {
    ll n;
    VL dat;
    void init(ll n_input) {
        n = n_input + 1;
        dat.resize(n + 1);
        for (int i = 0; i <= n; i++) dat[i] = 0;
    }
    ll sum(ll i) {
        ll s = 0;
        while (i >= 0) {
            s += dat[i];
            i = (i & (i + 1)) - 1;
        }
        return s;
    }
    void add(ll i, ll x) {
        while (i <= n) {
            dat[i] += x;
            i |= i + 1;
        }
    }
};

int main() {
    ll n;
    cin >> n;
    VL a(n), sorted(n);
    for (i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        sorted[i] = a[i];
    }
    sort(sorted.begin(), sorted.end());
    int ok = 0, ng = n;
    BIT bit;

    ll border = ((n * (n + 1) / 2) + 1) / 2;
    while (ng - ok > 1) {
        int mid = (ng + ok) / 2;
        int midnum = sorted[mid];
        bit.init(2 * n + 1);
        int sum = 0;
        bit.add(sum + n, 1);
        ll result = 0;
        for (i = 0; i < n; i++) {
            sum += (a[i] >= midmum ? 1 : -1);
            result += bit.sum(sum + n);
            bit.add(sum + n, 1);
        }
        if (result >= border)ok = mid;
        else ng = mid;
    }
    cout << sorted[ok] << endl;
}


Compiler output:
a.cc:3:12: error: 'll' does not name a type; did you mean 'all'?
    3 | using ll = ll;
      |            ^~
      |            all
a.cc:5:19: error: 'll' was not declared in this scope; did you mean 'all'?
    5 | using VL = vector<ll>;
      |                   ^~
      |                   all
a.cc:5:21: error: template argument 1 is invalid
    5 | using VL = vector<ll>;
      |                     ^
a.cc:5:21: error: template argument 2 is invalid
a.cc:13:11: error: 'll' does not name a type; did you mean 'all'?
   13 | constexpr ll INF = 1000000000;
      |           ^~
      |           all
a.cc:14:11: error: 'll' does not name a type; did you mean 'all'?
   14 | constexpr ll LLINF = 1LL << 60;
      |           ^~
      |           all
a.cc:15:11: error: 'll' does not name a type; did you mean 'all'?
   15 | constexpr ll mod = 1000000007;
      |           ^~
      |           all
a.cc:16:11: error: 'll' does not name a type; did you mean 'all'?
   16 | constexpr ll MOD = 998244353;
      |           ^~
      |           all
a.cc:22:5: error: 'll' does not name a type; did you mean 'all'?
   22 |     ll n;
      |     ^~
      |     all
a.cc:23:5: error: 'VL' does not name a type; did you mean 'VI'?
   23 |     VL dat;
      |     ^~
      |     VI
a.cc:24:15: error: 'll' has not been declared
   24 |     void init(ll n_input) {
      |               ^~
a.cc:29:5: error: 'll' does not name a type; did you mean 'all'?
   29 |     ll sum(ll i) {
      |     ^~
      |     all
a.cc:37:14: error: 'll' has not been declared
   37 |     void add(ll i, ll x) {
      |              ^~
a.cc:37:20: error: 'll' has not been declared
   37 |     void add(ll i, ll x) {
      |                    ^~
a.cc: In member function 'void BIT::init(int)':
a.cc:25:9: error: 'n' was not declared in this scope; did you mean 'yn'?
   25 |         n = n_input + 1;
      |         ^
      |         yn
a.cc:26:9: error: 'dat' was not declared in this scope
   26 |         dat.resize(n + 1);
      |         ^~~
a.cc: In member function 'void BIT::add(int, int)':
a.cc:38:21: error: 'n' was not declared in this scope; did you mean 'yn'?
   38 |         while (i <= n) {
      |                     ^
      |                     yn
a.cc:39:13: error: 'dat' was not declared in this scope
   39 |             dat[i] += x;
      |             ^~~
a.cc: In function 'int main()':
a.cc:46:5: error: 'll' was not declared in this scope; did you mean 'all'?
   46 |     ll n;
      |     ^~
      |     all
a.cc:47:12: error: 'n' was not declared in this scope; did you mean 'yn'?
   47 |     cin >> n;
      |            ^
      |            yn
a.cc:48:5: error: 'VL' was not declared in this scope; did you mean 'VI'?
   48 |     VL a(n), sorted(n);
      |     ^~
      |     VI
a.cc:49:10: error: 'i' was not declared in this scope
   49 |     for (i = 0; i < n; i++) {
      |          ^
a.cc:50:22: error: 'a' was not declared in this scope
   50 |         scanf("%d", &a[i]);
      |                      ^
a.cc:51:9: error: 'sorted' was not declared in this scope; did you mean 'strtod'?
   51 |         sorted[i] = a[i];
      |         ^~~~~~
      |         strtod
a.cc:53:10: error: 'sorted' was not declared in this scope; did you mean 'strtod'?
   53 |     sort(sorted.begin(), sorted.end());
      |          ^~~~~~
      |          strtod
a.cc:57:7: error: expected ';' before 'border'
   57 |     ll border = ((n * (n + 1) / 2) + 1) / 2;
      |       ^~~~~~~
      |       ;
a.cc:64:11: error: expected ';' before 'result'
   64 |         ll result = 0;
      |           ^~~~~~~
      |           ;
a.cc:65:14: error: 'i' was not declared in this scope
   65 |         for (i = 0; i < n; i++) {
      |              ^
a.cc:66:21: error: 'a' was not declared in this scope
   66 |             sum += (a[i] >= midmum ? 1 : -1);
      |                     ^
a.cc:66:29: error: 'midmum' was not declared in this scope; did you mean 'midnum'?
   66 |             sum += (a[i] >= midmum ? 1 : -1);
      |                             ^~~~~~
      |                             midnum
a.cc:67:13: error: 'result' was not declared in this scope
   67 |             result += bit.sum(sum + n);
      |             ^~~~~~
a.cc:67:27: error: 'struct BIT' has no member named 'sum'
   67 |             result += bit.sum(sum + n);
      |                           ^~~
a.cc:70:13: error: 'result' was not declared in this scope
   70 |         if (result >= border)ok = mid;
      |             ^~~~~~
a.cc:70:23: error: 'border' was not declared in this scope
   70 |         if (result >= border)ok = mid;
      |                       ^~~~~~