Language: C++

#include<iostream>
#define int long long
#include<algorithm>
using namespace std;
long long res,c[100001],t[100001],a[100001],n,sum,b[100001];
int lowbit(int x)
{
  return x&(-x);
}
void add(int x,int y)
{
  for (;x<=2*n+1;x+=lowbit(x))
    c[x]+=y;
  return;
}
int cnt(int x)
{
  res=0;
  for (;x>=1;x-=lowbit(x))
    res+=c[x];
  return res;
}
bool check(int x)
{
  sum=0;
  for (int i=1;i<=n;++i)
    {
      if (a[i]>=b[x])
        t[i]=1;
      else
	t[i]=-1;
    }
  for (int i=1;i<=n;++i)
      t[i]+=t[i-1];
  for (int i=1;i<=n*2+1;++i)
    c[i]=0;
  add(n+1,1);
  for (int i=1;i<=n;++i)
    {
      sum+=cnt(t[i]+n+1);
      add(t[i]+n+1,1);
    }
  return sum>=n*(n-1)/4+1;
}
signed main()
{
  int first,last,mid,ans=0;
  cin>>n;
  for (int i=1;i<=n;++i)
    cin>>a[i];
  first=1;
  last=n;
  for (int i=1;i<=n;++i)
    b[i]=a[i];
  sort(b+1,b+n+1);
  while (first<=last)
    {
      mid=(first+last)/2;
      if (check(mid))
	{
	  ans=max(ans,mid);
	  first=mid+1;
	}
      else
	last=mid-1;
    }
  cout<<b[ans]<<endl;
  return 0;
}

Compiler output:
/usr/include/c++/14/bits/uniform_int_dist.h: In member function 'std::uniform_int_distribution<_IntType>::result_type std::uniform_int_distribution<_IntType>::operator()(_UniformRandomBitGenerator&, const param_type&)':
a.cc:2:18: error: 'long long long' is too long for GCC
    2 | #define int long long
      |                  ^~~~
a.cc:2:18: error: 'long long long' is too long for GCC
    2 | #define int long long
      |                  ^~~~
/usr/include/c++/14/bits/stl_algo.h: In function 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare)':
a.cc:2:13: error: expected primary-expression before 'long'
    2 | #define int long long
      |             ^~~~
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_algo.h:1815:29: error: expected ')' before 'long'
 1815 |       if (__last - __first > int(_S_threshold))
      |          ~                  ^
      |                             )
a.cc:2:13: error: expected primary-expression before 'long'
    2 | #define int long long
      |             ^~~~
/usr/include/c++/14/bits/stl_algo.h:1817:51: error: expected ')' before 'long'
 1817 |           std::__insertion_sort(__first, __first + int(_S_threshold), __comp);
      |                                ~                  ^
      |                                                   )
a.cc:2:13: error: expected primary-expression before 'long'
    2 | #define int long long
      |             ^~~~
/usr/include/c++/14/bits/stl_algo.h:1818:52: error: expected ')' before 'long'
 1818 |           std::__unguarded_insertion_sort(__first + int(_S_threshold), __last,
      |                                          ~         ^
      |                                                    )
/usr/include/c++/14/bits/stl_algo.h: In function 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare)':
a.cc:2:13: error: expected primary-expression before 'long'
    2 | #define int long long
      |             ^~~~
/usr/include/c++/14/bits/stl_algo.h:1880:32: error: expected ')' before 'long'
 1880 |       while (__last - __first > int(_S_threshold))
      |             ~                  ^
      |                                )
a.cc:2:13: error: expected primary-expression before 'long'
    2 | #define int long long
      |             ^~~~