Language: C++

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N (1<<14)

long long bit[N + 1];

//初期化
void init(void){
	f(i, N + 1)bit[i] = 0;
	return;
}

//加算(k=1-n)
void add(int k, long long x){
	while (k <= N){
		bit[k] += x;
		k += k& -k;
	}
	return;
}
//合計(1<=k<=r)
long long sum(int r){
	long long s = 0;
	while (r > 0){
		s += bit[r];
		r -= r & -r;
	}
	return s;
}



int main(){
	int a[N];
	vector<int>aa;
	vector<int>b[2 * N];
	int c[N];
	int d[N];
	f(i, N){
		a[i] = 0;
		c[i] = 0;
		d[i] = 0;
	}
	int k;
int n;
	int x, y, z;
	long long s, ans;
	scanf("%d", &n);
  ans=n;
	ans = ans*(ans+1);
	ans = ans / 2;
	ans += 2;
	ans = ans / 2;
	f(i, n){
		scanf("%d", &a[i]);
		aa.push_back(a[i]);
	}
	sort(aa.begin(), aa.end());
	
	int l = 0;
	int r = n;
	int  m;
	while (l + 1 < r){
		m = (l + r) / 2;
		m--;
		c[0] = 0;
		f(i, 2 * n + 1)b[i].clear();
		b[n].push_back(0);
		f(i, n){
			if (a[i] < aa[m])c[i + 1] = c[i] + 1;
			else c[i + 1] = c[i] - 1;
			b[c[i + 1]+n].push_back(i + 1);
		}
		k = 1;
		f(i, 2 * n+1){
			f(j, b[i].size()){
				d[b[i][j]] = k;
				k++;
			}
		}
		init();
		s = 0;
      		f(i, (n + 1)){
			s += sum(d[i]);
			add(d[i], 1);
		}
		if (s < ans)l = m + 1;
		else r = m + 1;
	}
	

	printf("%d\n", aa[m]);


	return 0;
}#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N (1<<14)

long long bit[N + 1];

//初期化
void init(void){
	f(i, N + 1)bit[i] = 0;
	return;
}

//加算(k=1-n)
void add(int k, long long x){
	while (k <= N){
		bit[k] += x;
		k += k& -k;
	}
	return;
}
//合計(1<=k<=r)
long long sum(int r){
	long long s = 0;
	while (r > 0){
		s += bit[r];
		r -= r & -r;
	}
	return s;
}



int main(){
	int a[N];
	vector<int>aa;
	vector<int>b[2 * N];
	int c[N];
	int d[N];
	f(i, N){
		a[i] = 0;
		c[i] = 0;
		d[i] = 0;
	}
	int k;
int n;
	int x, y, z;
	long long s, ans;
	scanf("%d", &n);
  ans=n;
	ans = ans*(ans+1);
	ans = ans / 2;
	ans += 2;
	ans = ans / 2;
	f(i, n){
		scanf("%d", &a[i]);
		aa.push_back(a[i]);
	}
	sort(aa.begin(), aa.end());
	
	int l = 0;
	int r = n;
	int  m;
	while (l + 1 < r){
		m = (l + r) / 2;
		m--;
		c[0] = 0;
		f(i, 2 * n + 1)b[i].clear();
		b[n].push_back(0);
		f(i, n){
			if (a[i] < aa[m])c[i + 1] = c[i] + 1;
			else c[i + 1] = c[i] - 1;
			b[c[i + 1]+n].push_back(i + 1);
		}
		k = 1;
		f(i, 2 * n+1){
			f(j, b[i].size()){
				d[b[i][j]] = k;
				k++;
			}
		}
		init();
		s = 0;
      		f(i, (n + 1)){
			s += sum(d[i]);
			add(d[i], 1);
		}
		if (s < ans)l = m + 1;
		else r = m + 1;
	}
	

	printf("%d\n", aa[m]);


	return 0;
}

Compiler output:
a.cc:107:2: error: stray '#' in program
  107 | }#include<cstdio>
      |  ^
a.cc:107:3: error: 'include' does not name a type
  107 | }#include<cstdio>
      |   ^~~~~~~
a.cc:122:11: error: redefinition of 'long long int bit [16385]'
  122 | long long bit[N + 1];
      |           ^~~
a.cc:16:11: note: 'long long int bit [16385]' previously declared here
   16 | long long bit[N + 1];
      |           ^~~
a.cc:125:6: error: redefinition of 'void init()'
  125 | void init(void){
      |      ^~~~
a.cc:19:6: note: 'void init()' previously defined here
   19 | void init(void){
      |      ^~~~
a.cc:131:6: error: redefinition of 'void add(int, long long int)'
  131 | void add(int k, long long x){
      |      ^~~
a.cc:25:6: note: 'void add(int, long long int)' previously defined here
   25 | void add(int k, long long x){
      |      ^~~
a.cc:139:11: error: redefinition of 'long long int sum(int)'
  139 | long long sum(int r){
      |           ^~~
a.cc:33:11: note: 'long long int sum(int)' previously defined here
   33 | long long sum(int r){
      |           ^~~
a.cc:150:5: error: redefinition of 'int main()'
  150 | int main(){
      |     ^~~~
a.cc:44:5: note: 'int main()' previously defined here
   44 | int main(){
      |     ^~~~