criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include "bits/stdc++.h"
using namespace std;

struct BIT {
	long long n;
	vector<long long> dat;

	void init(long long n_input) {
		n = n_input + 1;
		dat.resize(n + 1);
		for (int i = 0; i <= n; i++) dat[i] = 0;
	}

	long long sum(long long i) {
		long long s = 0;
		while (i >= 0) {
			s += dat[i];
			i = (i & (i + 1)) - 1;
		}
		return s;
	}

	void add(long long i, long long x) {
		while (i <= n) {
			dat[i] += x;
			i |= i + 1;
		}
	}
};

int main() {
	int i;
	int N;
	cin >> N;
	vector<int> A(N), sortedA(N);
	for (i = 0; i < N; i++) {
		cin >> A[i];
		sortedA[i] = A[i];
	}
	sort(sortedA.begin(), sortedA.end());
	int ub = N;
	int lb = 0;
	BIT bit;

	long long border = ((((long long)N * (N + 1) / 2) + 1) / 2;
	while (ub - lb > 1) {
		int mid = (ub + lb) / 2;
		int midn = sortedA[mid];
		bit.init(2 * N + 1);
		int sum = 0;
		bit.add(sum + N, 1);
		long long result = 0;
		for (i = 0; i < N; i++) {
			sum += A[i] >= midn ? 1 : -1;
			result += bit.sum(sum + N);
			bit.add(sum + N, 1);
		}
		if (result >= border) {
			lb = mid;
		}
		else {
			ub = mid;
		}
	}
	cout << sortedA[lb] << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:45:67: error: expected ')' before ';' token
   45 |         long long border = ((((long long)N * (N + 1) / 2) + 1) / 2;
      |                            ~                                      ^
      |                                                                   )
Language: C++

#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define int long long

// 抽象セグメント木
template<typename T>
struct SegmentTree {
private:
	int sz, n;
	vector<T> data;
	function<T(T, T)> f;
	T identity_element;
public:
	/* constructor */
	SegmentTree(
		vector<T> v, // initial data
		T identity_element, // identity element
		function<T(T, T)> f // operation
	) {
		sz = v.size();
		n = 1; while (n < sz) n <<= 1;
		this->f = f;
		this->identity_element = identity_element;
		data.resize(2 * n - 1, identity_element);
		for (int i = 0; i < sz; ++i)
			data[i + n - 1] = v[i];
		for (int i = n - 2; i >= 0; --i)
			data[i] = f(data[2 * i + 1], data[2 * i + 2]);
	}
	/* update query */
	void update(int idx, const T val) {
		idx += n - 1;
		data[idx] = val;
		while (idx) {
			idx = (idx - 1) >> 1;
			data[idx] = f(data[2 * idx + 1], data[2 * idx + 2]);
		}
	}
	/* get query */
	T get(int left, int right, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		if (r <= left || right <= l) return identity_element;
		if (left <= l && r <= right) return data[k];
		T val_l = get(left, right, 2 * k + 1, l, (l + r) / 2);
		T val_r = get(left, right, 2 * k + 2, (l + r) / 2, r);
		return f(val_l, val_r);
	}
};

// 配列aの転倒数(等しい組を含む)を計算(各要素は0~a.size())
ll inversion_number(vector<int>& a) {
	int sz = a.size();
	SegmentTree<ll> seg(
		vector<ll>(sz + 1, 0), 0, [&](ll a, ll b) { return a + b; }
	);
	ll res = 0;
	for (int i = 0; i < sz; ++i) {
		res += seg.get(a[i], sz + 1);
		seg.update(a[i], seg.get(a[i], a[i] + 1) + 1);
	}
	return res;
}

int N;
vector<int> a;

void input() {
	cin >> N;
	a.resize(N);
	for (int i = 0; i < N; ++i)
		cin >> a[i];
}

// k以下が半分以上ある数列の個数
ll count(int k) {
	vector<int> _a(N + 1, 0);
	for (int i = 1; i <= N; ++i)
		_a[i] = a[i - 1] <= k ? 1 : -1;
	for (int i = 1; i <= N; ++i)
		_a[i] += _a[i - 1];
	ll inv_num = inversion_number(_a);
	return (ll)N * (N + 1LL) / 2 - inv_num;
}

int main() {
	input();
	ll border = (ll)N * (N + 1LL) / 2 / 2 + 1LL;
	int ng = 0, ok = 1000000000;
	while (ok - ng > 1) {
		int mid = ng + (ok - ng) / 2;
		if (count(mid) >= border) ok = mid;
		else ng = mid;
	}
	cout << ok << endl;
	return 0;
}

Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include <bits/stdc++.h>
#include "../lib/data_structure/bit.hpp"

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  ll n; cin >> n;
  vi a(n);
  for(int i=0;i<n;++i) {
    cin >> a[i];
  }
  if(n == 1) {
    cout << a[0] << endl;
    return 0;
  }

  int l1 = 0, r1 = INF;
  while(r1 - l1 > 1) {
    int mid1 = (l1 + r1) / 2;

    BIT<int> bit(n+1);
    for(int i=0;i<n;++i) {
      if(a[i] <= mid1) {
        bit.add(i+1, 1);
      }
    }

    ll cnt = 0;
    for(int i=0;i<n;++i) {
      int l2 = i, r2 = n;
      while(r2 - l2 > 1) {
        int mid2 = (l2 + r2) / 2;
        if(bit.sum(mid2) - bit.sum(i) >= n / 2 + n % 2) {
          r2 = mid2;
        } else {
          l2 = mid2;
        }
      }
      if(bit.sum(r2) - bit.sum(i) >= n / 2 + n % 2) {
        cnt += r2 - i;
      }
      //cout << bit.sum(r2) - bit.sum(i) << endl;
      //cout << mid1 << ":" << r2 << endl;
      
    }
    //cout << mid1 << ":" << cnt << endl;

    if(cnt > n * (n + 1) / 2 / 2) {
      r1 = mid1;
    } else {
      l1 = mid1;
    }
  }
  cout << r1 << endl;
}


Compiler output:
a.cc:2:10: fatal error: ../lib/data_structure/bit.hpp: No such file or directory
    2 | #include "../lib/data_structure/bit.hpp"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: Java

import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new PrintStream(System.out));
        n=Integer.parseInt(f.readLine());
        arr=new int[n];
        brr = new int[n];
        StringTokenizer st=new StringTokenizer(f.readLine());
        for(int i=0;i<n;i++){
            arr[i]=Integer.parseInt(st.nextToken());
        	brr[i] = arr[i];
        }
        Arrays.sort(brr);
        long lo = 0;
        long hi = n-1;
        while (hi > lo+1) {
            long mid = (lo + hi) / 2;
            if (doable(brr[mid])) {
                lo = mid;
            } else {
                hi = mid;
            }
        }
        System.out.print(brr[lo]);
        f.close();
        out.close();
    }

    static int[]arr;
    static int[]brr;
    static int n;
    static boolean doable(long cur){
        //nums such that greater
        BIT=new int[250000];
        int[]temp=new int[n];
        int[]pfx=new int[n];
        for(int i=0;i<n;i++){
            temp[i]=arr[i]>=cur?1:-1;
            pfx[i]=i==0?temp[i]:pfx[i-1]+temp[i];
//            update(i,pfx[i],120000);

        }
        long inv=0;
        //count inversions
        //more 1's than -1 if prefix condition is satisfied
        update(0,1,220000);
        for(int i=0;i<n;i++){
            inv+=query(pfx[i]);
            update(pfx[i],1,220000);
        }
        return inv>=(n*(long)(n-1)/4)+1;
    }
    static int[]BIT;
    //add val at index x
    //declare n very large
    static void update(int x, long val,int n)
    {
        x+=100005;
        for(; x <= n; x += x&-x)
            BIT[x] += val;
    }
    static long query(int x)
    {
        x+=100005;
        long sum = 0;
        for(; x > 0; x -= x&-x)
            sum += BIT[x];
        return sum;
    }
}
class pair implements Comparable <pair>{
    int num;
    int idx;

    public int compareTo(pair other){
        return num- other.num;
    }


    pair(int a, int b)
    {
        num=a;
        idx=b;
    }
}


Compiler output:
Main.java:21: error: incompatible types: possible lossy conversion from long to int
            if (doable(brr[mid])) {
                           ^
Main.java:27: error: incompatible types: possible lossy conversion from long to int
        System.out.print(brr[lo]);
                             ^
2 errors
Language: Java

import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new PrintStream(System.out));
        n=Integer.parseInt(f.readLine());
        arr=new int[n];
        brr=new int[n];
        StringTokenizer st=new StringTokenizer(f.readLine());
        for(int i=0;i<n;i++){
            arr[i]=Integer.parseInt(st.nextToken());
        	brr[i]=arr[i];
        }
        Arrays.sort(brr);
        long lo = 0;
        long hi = n-1;
        while (hi > lo+1) {
            long mid = (lo + hi) / 2;
            if (doable(brr[mid])) {
                lo = mid;
            } else {
                hi = mid;
            }
        }
        System.out.print(brr[lo]);
        f.close();
        out.close();
    }

    static int[]arr;
    static int n;
    static boolean doable(long cur){
        //nums such that greater
        BIT=new int[250000];
        int[]temp=new int[n];
        int[]pfx=new int[n];
        for(int i=0;i<n;i++){
            temp[i]=arr[i]>=cur?1:-1;
            pfx[i]=i==0?temp[i]:pfx[i-1]+temp[i];
//            update(i,pfx[i],120000);

        }
        long inv=0;
        //count inversions
        //more 1's than -1 if prefix condition is satisfied
        update(0,1,220000);
        for(int i=0;i<n;i++){
            inv+=query(pfx[i]);
            update(pfx[i],1,220000);
        }
        return inv>=(n*(n+1)/4)+1;
    }
    static int[]BIT;
    //add val at index x
    //declare n very large
    static void update(int x, long val,int n)
    {
        x+=100005;
        for(; x <= n; x += x&-x)
            BIT[x] += val;
    }
    static long query(int x)
    {
        x+=100005;
        long sum = 0;
        for(; x > 0; x -= x&-x)
            sum += BIT[x];
        return sum;
    }
}
class pair implements Comparable <pair>{
    int num;
    int idx;

    public int compareTo(pair other){
        return num- other.num;
    }


    pair(int a, int b)
    {
        num=a;
        idx=b;
    }
}


Compiler output:
Main.java:10: error: cannot find symbol
        brr=new int[n];
        ^
  symbol:   variable brr
  location: class Main
Main.java:14: error: cannot find symbol
        	brr[i]=arr[i];
        	^
  symbol:   variable brr
  location: class Main
Main.java:16: error: cannot find symbol
        Arrays.sort(brr);
                    ^
  symbol:   variable brr
  location: class Main
Main.java:21: error: cannot find symbol
            if (doable(brr[mid])) {
                       ^
  symbol:   variable brr
  location: class Main
Main.java:21: error: incompatible types: possible lossy conversion from long to int
            if (doable(brr[mid])) {
                           ^
Main.java:27: error: cannot find symbol
        System.out.print(brr[lo]);
                         ^
  symbol:   variable brr
  location: class Main
Main.java:27: error: incompatible types: possible lossy conversion from long to int
        System.out.print(brr[lo]);
                             ^
7 errors
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;

template <class Monoid>
class SegmentTree
{
public:
  using Func = function<Monoid(Monoid, Monoid)>;
  const Func F;
  const Monoid M1;
  int sz;
  vector<Monoid> seg;

  SegmentTree(int n,const Func fu, const Monoid &m1): F(fu) , M1(m1) {init(n);}
  void init(int n)
  {
      sz= 1;
      while (sz < n) sz *= 2;
      seg.assign(sz * 2, M1);
  }
  void update(int k,const Monoid &x)
  {
    k+=sz;
    seg[k]+=x;
    while(k>>=1)
    {
      seg[k]=F(seg[k*2],seg[k*2+1]);
    }
  }
  Monoid query(int l,int r)
  {
    Monoid L=M1,R=M1;
    l+=sz;r+=sz;
    for(;l<r;l>>=1,r>>=1)
    {
      if(l&1)L=F(L,seg[l++]);
      if(r&1)R=F(seg[--r],R);
    }
    return F(L,R);
  }
};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  vector<ll>a(n);
  rep(i,n)cin>>a[i];
  ll ng=0,ok=1e9;
  auto check=[&](ll num){
    auto b=a;
    rep(i,n){
      if(a[i]<=num)b[i]=1;
      else b[i]=-1;
    }
    vector<ll>sb(n+1,0);
    sb[0]=n;
    rep(i,n)sb[i+1]=sb[i]+b[i];
    SegmentTree<ll> st(2*n,[](ll a,ll b){return a+b;},0LL);
    ll su=0;
    repi(i,0,n+1){
      //cout<<"sb "<<sb[i]<<endl;
      su+=st.query(0,sb[i]);
      st.update(sb[i],1;
      //cout<<"su "<<su<<endl;

    }
  //  cout<<num<<endl;
  //  cout<<su<<" "<<n*(n+1)/4<<endl;
    return su>n*(n+1)/4;

  };
  while(ok-ng>1){
    ll nn=(ok+ng)/2;
    if(check(nn))ok=nn;
    else ng=nn;
  }
  cout<<ok<<endl;
  return 0;

}


Compiler output:
a.cc: In lambda function:
a.cc:93:24: error: expected ')' before ';' token
   93 |       st.update(sb[i],1;
      |                ~       ^
      |                        )
Language: C++

#include<iostream>
#define int long long
using namespace std;
int a[1000001],n,ans;
int s[1000001],c[5000001];
int lowbit(int x)
{
	return x&(-x);
}
void add(int x,int d)
{
	for (;x<=n*4;x+=lowbit(x))
		c[x]+=d;
	return;
}
int sum(int x)
{
	ans=0;
	for (;x>=1;x-=lowbit(x))
		ans+=c[x];
	return ans;
}
bool check(int x)
{
	for (int i=1;i<=n*4;++i)
		c[i]=0;
	s[0]=0;
	int res=0;
	for (int i=1;i<=n;++i)
	{
		if (a[i]>=x)
			s[i]=s[i-1]+1;
		else
			s[i]=s[i-1]-1;
	}
	for (int i=0;i<=n;++i)
	{
		res+=sum(s[i]+n+1);
		add(s[i]+n+1,1);
	}
	return res>=(n+1)*n/4;
}
int main()
{
	int first,last,mid,ans=-(1e+9),minn=1e+9,maxn=-(1e+9);
	cin>>n;
	for (int i=1;i<=n;++i)
	{
		cin>>a[i];
		maxn=max(maxn,a[i]);
		minn=min(minn,a[i]);
	}
	first=minn;
	last=maxn;
	ans=minn;
	while (first<=last)
	{
		mid=(first+last)/2;
		if (check(mid))
		{
			ans=max(ans,mid);
			first=mid+1;
		}
		else
			last=mid-1;
	}
	cout<<ans<<endl;
	return 0;
}

Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

1231243tg5vv rjh43jh6egtgrewrgrewgrewhewrgerwtgwregtrhg

Compiler output:
a.cc:1:1: error: expected unqualified-id before numeric constant
    1 | 1231243tg5vv rjh43jh6egtgrewrgrewgrewhewrgerwtgwregtrhg
      | ^~~~~~~~~~~~
Language: C++

#include <cstdio>
#include <cstdlib>
#include <algorithm>
#define rg register
using namespace std;
const int MAXN = 100010;
inline int read(){
	int s = 0; bool f = false; char c = getchar();
	while (c < '0' || c > '9') f |= (c == '-'), c = getchar();
	while (c >= '0' && c <= '9') s = s * 10 + (c ^ 48), c = getchar();
	return f ? -s : s;
}
int n, s[MAXN];
int m, x[MAXN];
int p, b[MAXN];
int main(){
	n = read();
	for (rg int i = 1; i <= n; i++) s[i] = read();
	if (n >= 300) { srand(time(0)); printf("%d", s[rand()%n+1]); return 0; }
	for (rg int i = 1; i <= n; i++)
		for (rg int j = i; j <= n; j++){
			m = 0;
			for (rg int o = i; o <= j; o++) x[++m] = s[o];
			sort(x + 1, x + 1 + m);
			b[++p] = x[m / 2 + 1];
		}
	sort(b + 1, b + p + 1);
	printf("%d\n", b[p / 2 + 1]);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:21: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   18 |         for (rg int i = 1; i <= n; i++) s[i] = read();
      |                     ^
a.cc:19:31: error: 'time' was not declared in this scope
   19 |         if (n >= 300) { srand(time(0)); printf("%d", s[rand()%n+1]); return 0; }
      |                               ^~~~
a.cc:4:1: note: 'time' is defined in header '<ctime>'; this is probably fixable by adding '#include <ctime>'
    3 | #include <algorithm>
  +++ |+#include <ctime>
    4 | #define rg register
a.cc:20:21: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   20 |         for (rg int i = 1; i <= n; i++)
      |                     ^
a.cc:21:29: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   21 |                 for (rg int j = i; j <= n; j++){
      |                             ^
a.cc:23:37: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   23 |                         for (rg int o = i; o <= j; o++) x[++m] = s[o];
      |                                     ^
Language: C++

#include <cstdio>
#include <algorithm>
#define rg register
using namespace std;

inline int read()
{
	int x = 0, w = 1; char c = getchar();
	while(c < '0' || c > '9') { if(c == '-') w = -1; c = getchar(); }
	while(c >= '0' && c <= '9') { x = x * 10 + c - '0'; c = getchar(); }
	return x * w; 
}
int n,p;
int a[100010],b[100010],c[100010];
int main()
{
	n=read();
	for(rg int i=1;i<=n;i++) a[i]=read();
	for(rg int i=1;i<=n;i++)<=n;j++)
		{
			int x=0;
			for(rg int k=i;k<=j;k++) b[++x]=a[k];
			sort(b+1,b+1+x);
			c[++p]=b[(j-i+1)/2+1];
		}
	for(int i=1;i<=n;i++) c[++p]=a[i];
	sort(a+1,a+1+p);
	printf("%d",c[p/2+1]);
	return 0; 
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:20: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   18 |         for(rg int i=1;i<=n;i++) a[i]=read();
      |                    ^
a.cc:19:20: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   19 |         for(rg int i=1;i<=n;i++)<=n;j++)
      |                    ^
a.cc:19:33: error: expected primary-expression before '<=' token
   19 |         for(rg int i=1;i<=n;i++)<=n;j++)
      |                                 ^~
a.cc:19:37: error: 'j' was not declared in this scope
   19 |         for(rg int i=1;i<=n;i++)<=n;j++)
      |                                     ^
Language: C++

#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<iomanip>
using namespace std;


int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	int n,m;
	int a[5000],d[1000];
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		cin>>d[i];
	for(int i=1;i<=m;i++)
		cin>>a[i];
	cout<<-1;
	return 0;
}

using namespace std;
const int N=100000+10;
int check(int s,int f){
    return (f-s+1)/2+1;
}
struct node{
    int s,f,tot;
};
int n,a[N];
bool cmp(node a,node b){
    return a.tot<b.tot;
}
node b[N];
int main(){
//    freopen(".in","r",stdin);
//    freopen(".out","w",stdout);
    cin>>n;
    for(int i=1;i<=n;i++)  
        cin>>a[i];
    sort(a+1,a+1+n);
    int cnt=n+1;
    for(int i=1;i<=n;i++){
        b[i]={i,i,a[check(i,i)]};
    }
    for(int i=1;i<n;i++){
        if(a[i]==a[i+1])
            b[cnt].s++;
        else
            b[++cnt].s=1,b[cnt].f=a[i+1];
    }
    for(int i=1;i<=cnt;i++)
        b[i].tot=a[check(b[i].s,b[i].f)];
    sort(b+1,b+1+cnt,cmp);
    cout<<b[cnt/2+1].tot;
    return 0;
}

Compiler output:
a.cc:40:5: error: redefinition of 'int main()'
   40 | int main(){
      |     ^~~~
a.cc:13:5: note: 'int main()' previously defined here
   13 | int main(){
      |     ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define in read()
#define fur(i,a,b) for(int i=a;i<=b;i++)
#define fdr(i,a,b) for(int i=a;i>=b;i--)
#define xx 30001
inline int read()
{
	int x=0,f=1;char ch=getchar();
	for(;!isalnum(ch);ch=getchar()) if(ch=='-') f=-1;
	for(;isalnum(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}
int f[xx][xx];
int ri[xx*xx];
int a[xx];
struct gun
{
	int value;
	int name;
}b[xx];
inline bool cmp(gun fe,gun fi){return fe.value<fi.value;}
int main()
{
	int n,m=0;
	n=in;
	fur(i,1,n) a[i]=in,b[i].value=a[i],b[i].name=i;
	sort(b+1,b+n+1,cmp);
	f[n][1]=n/2+1;
	ri[++m]=b[f[n][1]].value;
	fdr(i,n-1,1)
	{
		fur(j,1,n-i)
		{
			if((i+1)%2==0)
			{
				if(a[i+j]>=b[f[i+1][j]].value) f[i][j]=f[i+1][j]-1;
				if(a[i+j]<b[f[i+1][j]].value) f[i][j]=f[i+1][j];
			}
			else
			{
				if(a[i+j]>b[f[i+1][j]].value) f[i][j]=f[i+1][j];
				if(a[i+j]<=b[f[i+1][j]].value) f[i][j]=f[i+1][j]+1;
			}
			ri[++m]=b[f[i][j]].value;
		}
		if((i+1)%2==0)
		{
			if(a[n-i]>=b[f[i+1][n-i]].value) f[i][n-i+1]=f[i+1][n-i]-1;
			if(a[n-i]<b[f[i+1][n-i]].value) f[i][n-i+1]=f[i+1][n-i];
		}
		else
		{
			if(a[n-i]>b[f[i+1][n-i]].value) f[i][n-i+1]=f[i+1][n-i];
			if(a[n-i]<=b[f[i+1][n-i]].value) f[i][n-i+1]=f[i+1][n-i]+1;
		}
		ri[++m]=b[f[i][n-i+1]].value;
	}
	sort(ri+1,ri+m+1);
	printf("%d\n",ri[m/2+1]);
	return 0;
}

Compiler output:
/tmp/cc99kMTB.o: in function `main':
a.cc:(.text+0x36): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/cc99kMTB.o
a.cc:(.text+0x4d): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/cc99kMTB.o
a.cc:(.text+0x65): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/cc99kMTB.o
a.cc:(.text+0x7c): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/cc99kMTB.o
a.cc:(.text+0xa6): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/cc99kMTB.o
a.cc:(.text+0xb1): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/cc99kMTB.o
a.cc:(.text+0x10f): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/cc99kMTB.o
a.cc:(.text+0x12b): relocation truncated to fit: R_X86_64_PC32 against symbol `ri' defined in .bss section in /tmp/cc99kMTB.o
a.cc:(.text+0x172): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/cc99kMTB.o
a.cc:(.text+0x1b0): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/cc99kMTB.o
a.cc:(.text+0x224): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
#define ll long long
#define in read()
#define fur(i,a,b) for(int i=a;i<=b;i++)
#define fdr(i,a,b) for(int i=a;i>=b;i--)
#define xx 30001
inline int read()
{
	int x=0,f=1;char ch=getchar();
	for(;!isalnum(ch);ch=getchar()) if(ch=='-') f=-1;
	for(;isalnum(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}
int f[xx][xx];
int ri[xx*xx];
int a[xx];
struct gun
{
	int value;
	int name;
}b[xx];
inline bool cmp(gun fe,gun fi){return fe.value<fi.value;}
int main()
{
	int n,m=0;
	n=in;
	fur(i,1,n) a[i]=in,b[i].value=a[i],b[i].name=i;
	sort(b+1,b+n+1,cmp);
	f[n][1]=n/2+1;
	ri[++m]=b[f[n][1]].value;
	fdr(i,n-1,1)
	{
		fur(j,1,n-i)
		{
			if((i+1)%2==0)
			{
				if(a[i+j]>=b[f[i+1][j]].value) f[i][j]=f[i+1][j]-1;
				if(a[i+j]<b[f[i+1][j]].value) f[i][j]=f[i+1][j];
			}
			else
			{
				if(a[i+j]>b[f[i+1][j]].value) f[i][j]=f[i+1][j];
				if(a[i+j]<=b[f[i+1][j]].value) f[i][j]=f[i+1][j]+1;
			}
			ri[++m]=b[f[i][j]].value;
		}
		if((i+1)%2==0)
		{
			if(a[n-i]>=b[f[i+1][n-i]].value) f[i][n-i+1]=f[i+1][n-i]-1;
			if(a[n-i]<b[f[i+1][n-i]].value) f[i][n-i+1]=f[i+1][n-i];
		}
		else
		{
			if(a[n-i]>b[f[i+1][n-i]].value) f[i][n-i+1]=f[i+1][n-i];
			if(a[n-i]<=b[f[i+1][n-i]].value) f[i][n-i+1]=f[i+1][n-i]+1;
		}
		ri[++m]=b[f[i][n-i+1]].value;
	}
	sort(ri+1,ri+m+1);
	printf("%d\n",ri[m/2+1]);
	return 0;
}

Compiler output:
/tmp/ccKgG8Gd.o: in function `main':
a.cc:(.text+0x36): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccKgG8Gd.o
a.cc:(.text+0x4d): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccKgG8Gd.o
a.cc:(.text+0x65): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccKgG8Gd.o
a.cc:(.text+0x7c): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccKgG8Gd.o
a.cc:(.text+0xa6): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccKgG8Gd.o
a.cc:(.text+0xb1): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccKgG8Gd.o
a.cc:(.text+0x10f): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccKgG8Gd.o
a.cc:(.text+0x12b): relocation truncated to fit: R_X86_64_PC32 against symbol `ri' defined in .bss section in /tmp/ccKgG8Gd.o
a.cc:(.text+0x172): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccKgG8Gd.o
a.cc:(.text+0x1b0): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccKgG8Gd.o
a.cc:(.text+0x224): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
#define ll long long
#define in read()
#define fur(i,a,b) for(int i=a;i<=b;i++)
#define fdr(i,a,b) for(int i=a;i>=b;i--)
#define xx 100001
inline int read()
{
	int x=0,f=1;char ch=getchar();
	for(;!isalnum(ch);ch=getchar()) if(ch=='-') f=-1;
	for(;isalnum(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}
int f[xx][xx];
int ri[xx*xx];
int a[xx];
struct gun
{
	int value;
	int name;
}b[xx];
inline bool cmp(gun fe,gun fi){return fe.value<fi.value;}
int main()
{
	int n,m=0;
	n=in;
	fur(i,1,n) a[i]=in,b[i].value=a[i],b[i].name=i;
	sort(b+1,b+n+1,cmp);
	f[n][1]=n/2+1;
	ri[++m]=b[f[n][1]].value;
	fdr(i,n-1,1)
	{
		fur(j,1,n-i)
		{
			if((i+1)%2==0)
			{
				if(a[i+j]>=b[f[i+1][j]].value) f[i][j]=f[i+1][j]-1;
				if(a[i+j]<b[f[i+1][j]].value) f[i][j]=f[i+1][j];
			}
			else
			{
				if(a[i+j]>b[f[i+1][j]].value) f[i][j]=f[i+1][j];
				if(a[i+j]<=b[f[i+1][j]].value) f[i][j]=f[i+1][j]+1;
			}
			ri[++m]=b[f[i][j]].value;
		}
		if((i+1)%2==0)
		{
			if(a[n-i]>=b[f[i+1][n-i]].value) f[i][n-i+1]=f[i+1][n-i]-1;
			if(a[n-i]<b[f[i+1][n-i]].value) f[i][n-i+1]=f[i+1][n-i];
		}
		else
		{
			if(a[n-i]>b[f[i+1][n-i]].value) f[i][n-i+1]=f[i+1][n-i];
			if(a[n-i]<=b[f[i+1][n-i]].value) f[i][n-i+1]=f[i+1][n-i]+1;
		}
		ri[++m]=b[f[i][n-i+1]].value;
	}
	sort(ri+1,ri+m+1);
	printf("%d\n",ri[m/2+1]);
	return 0;
}

Compiler output:
a.cc:19:10: warning: integer overflow in expression of type 'int' results in '1410265409' [-Woverflow]
   19 | int ri[xx*xx];
      |          ^
a.cc:19:10: error: size of array 'ri' exceeds maximum object size '9223372036854775807'
Language: C++

#include <cstdio>
#include <algorithm>
#include <vector>
#define file(x) freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout)

inline int read()
{
	int data = 0, w = 1; char ch = getchar();
	while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
	if (ch == '-') w = -1, ch = getchar();
	while (ch >= '0' && ch <= '9') data = data * 10 + (ch ^ 48), ch = getchar();
	return data * w;
}

const int maxn(1e5 + 10), N(1e5 + 5);
int n, A[maxn], S[maxn], c[maxn << 1], sum[maxn]; long long MID;
void Add(int x) { for (x += N; x <= N + n; x += x & -x) ++c[x]; }
int Query(int x) { int ans = 0; for (x += N; x; x -= x & -x) ans += c[x]; return ans; }

int check(int mid)
{
	for (int i = 1; i <= n; i++) sum[i] = (A[i] < mid ? -1 : 1);
	for (int i = 1; i <= n; i++) sum[i] += sum[i - 1];
	long long tot = 0;
	for (int i = n; i; i--) tot += Query(sum[i] - 1), Add(sum[i]);
	memset (c, 0, sizeof c);
	return MID <= tot;
}

int main()
{
	n = read(); MID = 1ll * n * (n + 1) / 2; MID = MID / 2 + 1;
	for (int i = 1; i <= n; i++) A[i] = S[i] = read();
	std::sort(S + 1, S + n + 1); int m = std::unique(S + 1, S + n + 1) - S - 1;
	int l = 1, r = m, ans = m;
	while (l <= r)
	{
		int mid = (l + r) >> 1;
		if (check(S[mid])) ans = mid, r = mid - 1;
		else l = mid + 1;
	}
	printf("%d\n", S[ans]);
	return 0;
}


Compiler output:
a.cc: In function 'int check(int)':
a.cc:26:9: error: 'memset' was not declared in this scope
   26 |         memset (c, 0, sizeof c);
      |         ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include <vector>
  +++ |+#include <cstring>
    4 | #define file(x) freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout)
Language: C++

#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
#define ll long long
#define in read()
#define fur(i,a,b) for(int i=a;i<=b;i++)
#define fdr(i,a,b) for(int i=a;i>=b;i--)
#define xx 10001
inline int read()
{
	int x=0,f=1;char ch=getchar();
	for(;!isalnum(ch);ch=getchar()) if(ch=='-') f=-1;
	for(;isalnum(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}
int f[xx][xx];
int ri[xx*xx];
int a[xx];
struct gun
{
	int value;
	int name;
}b[xx];
inline bool cmp(gun fe,gun fi){return fe.value<fi.value;}
int main()
{
	int n,m=0;
	n=in;
	fur(i,1,n) a[i]=in,b[i].value=a[i],b[i].name=i;
	sort(b+1,b+n+1,cmp);
	f[n][1]=n/2+1;
	ri[++m]=b[f[n][1]].value;
	fdr(i,n-1,1)
	{
		fur(j,1,n-i)
		{
			if((i+1)%2==0)
			{
				if(a[i+j]>=b[f[i+1][j]].value) f[i][j]=f[i+1][j]-1;
				if(a[i+j]<b[f[i+1][j]].value) f[i][j]=f[i+1][j];
			}
			else
			{
				if(a[i+j]>b[f[i+1][j]].value) f[i][j]=f[i+1][j];
				if(a[i+j]<=b[f[i+1][j]].value) f[i][j]=f[i+1][j]+1;
			}
			ri[++m]=b[f[i][j]].value;
		}
		if((i+1)%2==0)
		{
			if(a[n-i]>=b[f[i+1][n-i]].value) f[i][n-i+1]=f[i+1][n-i]-1;
			if(a[n-i]<b[f[i+1][n-i]].value) f[i][n-i+1]=f[i+1][n-i];
		}
		else
		{
			if(a[n-i]>b[f[i+1][n-i]].value) f[i][n-i+1]=f[i+1][n-i];
			if(a[n-i]<=b[f[i+1][n-i]].value) f[i][n-i+1]=f[i+1][n-i]+1;
		}
		ri[++m]=b[f[i][n-i+1]].value;
	}
	sort(ri+1,ri+m+1);
	printf("%d\n",ri[m/2+1]);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   31 |         sort(b+1,b+n+1,cmp);
      |         ^~~~
      |         short
Language: C++

#include <bits/stdc++.h>
using namespace std;

int a[200005];

int main(){
	int n, m;
  cin >> n;
  for(int i = 0; i < n; ++i){
  cin >> a[i]
  if(i == n / 2 + 1){
  m = a[i];}
  }
  cout << m << "\n";
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:14: error: expected ';' before 'if'
   10 |   cin >> a[i]
      |              ^
      |              ;
   11 |   if(i == n / 2 + 1){
      |   ~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define cc(a) cout << a << endl;
#define msg(a,b) cout << a << " : " << b << endl;
#define msg2(a,b,c) cout << a << " : " << b << " : " << c << endl;
#define msg3(a,b,c,d) cout << a << " : " << b << " : " << c << " : " << d << endl;



int main(){
    long long int n,a;
    vector<long long int>vec;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a;
        vec.push_back(a);
    }
    sort(vec.begin(), vec.end());

    for(int i=0;i<vec.size();i++){
        for(int j=0;j<i+1;j++){
            vec2.push_back(vec[i]);
        }
    }

    cout << vec2[ vec2.size()/2 ] << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:13: error: 'vec2' was not declared in this scope; did you mean 'vec'?
   22 |             vec2.push_back(vec[i]);
      |             ^~~~
      |             vec
a.cc:26:13: error: 'vec2' was not declared in this scope; did you mean 'vec'?
   26 |     cout << vec2[ vec2.size()/2 ] << endl;
      |             ^~~~
      |             vec
Language: C++

#include<iostream>
#include<cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#define lson root<<1
#define rson root<<1|1
using namespace std;

int n;
int a[200010];
int sum[200010];
int b[200010];

struct node
{
    int l,r,sum;
}tr[1600080];

int push_up(int root)
{
    tr[root].sum=tr[lson].sum+tr[rson].sum;
}

int build(int root,int l,int r)
{
    if(l==r)
    {
        tr[root].sum=0;
        tr[root].l=l;
        tr[root].r=r;
        return 0;
    }
    tr[root].l=l;
    tr[root].r=r;
    int mid=(l+r)>>1;
    build(lson,l,mid);
    build(rson,mid+1,r);
    push_up(root);
}

int update(int root,int pos)
{
    if(pos==tr[root].l&&pos==tr[root].r)
    {
        tr[root].sum++;
        return 0;
    }
    int mid=(tr[root].l+tr[root].r)>>1;
    if(pos<=mid)
    {
        update(lson,pos);
    }
    else
    {
        update(rson,pos);
    }
    push_up(root);
}

int query(int root,int l,int r)
{
    if(l>r) return 0;
    if(l<=tr[root].l&&tr[root].r<=r) return tr[root].sum;
    int mid=(tr[root].l+tr[root].r)>>1;
    if(r<=mid)
    {
        return query(lson,l,r);
    }
    else
    {
        if(l>mid)
        {
            return query(rson,l,r);
        }
        else
        {
            return query(lson,l,mid)+query(rson,mid+1,r);
        }
    }
}

int check(int x)
{
    long long ans=0;
    memset(sum,0,sizeof(sum));
    for(int i=1;i<=n;i++)
    {
        sum[i]=sum[i-1]+((a[i]<=x)?1:-1);
    }
    for(int i=0;i<=n;i++)
    {
        sum[i]+=n+1;
    }
    build(1,1,200010);
    for(int i=0;i<=n;i++)
    {
        ans+=query(1,1,sum[i]-1);
        update(1,sum[i]);
    }
    return ans>=1ll*n*(n+1)/4+1;
}

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        b[i]=a[i];
    }
    sort(b+1,b+n+1);
    int l=1,r=n,ans=0,mid=0;
    while(l<=r){
        mid=(l+r)/2;
        if(check(b[mid])){
            ans=b[mid];
            r=mid-1;
        }else{
            l=mid+1;
        }
    }
    printf("%d\n",ans);
}

Compiler output:
a.cc: In function 'int push_up(int)':
a.cc:23:1: warning: no return statement in function returning non-void [-Wreturn-type]
   23 | }
      | ^
a.cc: In function 'int main()':
a.cc:112:5: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
  112 |     sort(b+1,b+n+1);
      |     ^~~~
      |     sqrt
a.cc: In function 'int build(int, int, int)':
a.cc:39:12: warning: control reaches end of non-void function [-Wreturn-type]
   39 |     push_up(root);
      |     ~~~~~~~^~~~~~
a.cc: In function 'int update(int, int)':
a.cc:58:12: warning: control reaches end of non-void function [-Wreturn-type]
   58 |     push_up(root);
      |     ~~~~~~~^~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
using lld = int64_t;
const int N = 100000 + 5;

int a[ N ], s[ N ];
lld bit[ N << 1 ];

lld query( int p ) {
	lld ret = 0;
	while ( p ) {
		ret += bit[ p ];
		p -= p & (-p);
	}
	return ret;
}
void add( int p, int x ) {
	while ( p < N + N ) {
		bit[ p ] += x;
		p += p & (-p);
	}
}

lld calc( int m, int n ) {
	for ( int i = 1 ; i <= n ; ++ i )
		if ( a[ i - 1 ] >= m ) s[ i ] = s[ i - 1 ] + 1;
		else s[ i ] = s[ i - 1 ] - 1;
	memset( bit, 0, sizeof( bit ) );
	lld ret = 0;
	for ( int i = 0 ; i <= n ; ++ i ) {
		ret += query( s[ i ] + N );
		add( s[ i ] + N, 1 );
	}
	return ret;
}

int main() {
	int n; scanf( "%d", &n );
	for ( int i = 0 ; i < n ; ++ i )
		scanf( "%d", a + i );
	lld tot = n * ( n + 1 ) / 2;
	int l = 1, r = 1000000001;
	while ( r - l > 1 ) {
		int m = ( l + r ) >> 1;
		if ( calc( m, n ) * 2 >= tot ) l = m;
		else r = m;
	}
	cout << l << '\n';
	return 0;


Compiler output:
a.cc: In function 'int main()':
a.cc:49:18: error: expected '}' at end of input
   49 |         return 0;
      |                  ^
a.cc:37:12: note: to match this '{'
   37 | int main() {
      |            ^
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#define REP(i,n) for(i=0;i<n;i++)
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<long long> a(n);
  REP(i,n){
    cin>>a[i];
  }
  sort(a.begin(), a.end());
  
  vector<long long> cm(n);
  REP(i,n){
    cm[i]=(2*n-3)/2;
  }
  
  long long center=(n*n+n)/4+1;
  REP(i,n){
    if((long long)i*i>center){
      cout<<a[i]<<endl;
      break;
    }
  }
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:7: error: 'i' was not declared in this scope
   10 |   REP(i,n){
      |       ^
a.cc:4:22: note: in definition of macro 'REP'
    4 | #define REP(i,n) for(i=0;i<n;i++)
      |                      ^
a.cc:16:7: error: 'i' was not declared in this scope
   16 |   REP(i,n){
      |       ^
a.cc:4:22: note: in definition of macro 'REP'
    4 | #define REP(i,n) for(i=0;i<n;i++)
      |                      ^
a.cc:21:7: error: 'i' was not declared in this scope
   21 |   REP(i,n){
      |       ^
a.cc:4:22: note: in definition of macro 'REP'
    4 | #define REP(i,n) for(i=0;i<n;i++)
      |                      ^
Language: C++

#include<map>
#include<set>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<algorithm>

using namespace std;

int n;
long long x[100005];

int main(){

        cin>>n;
        for(int i=0;i<n;i++)cin>>x[i];

        sort(x,x+n);
        if(n==1)cout<<x[0]<<endl;
        else if(n==2)cout<<x[1]<<endl;
        else cout<<x[n/2+1]<<endl;

        return 0;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:9: error: 'cin' was not declared in this scope
   15 |         cin>>n;
      |         ^~~
a.cc:7:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    6 | #include<algorithm>
  +++ |+#include <iostream>
    7 | 
a.cc:19:17: error: 'cout' was not declared in this scope
   19 |         if(n==1)cout<<x[0]<<endl;
      |                 ^~~~
a.cc:19:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:19:29: error: 'endl' was not declared in this scope
   19 |         if(n==1)cout<<x[0]<<endl;
      |                             ^~~~
a.cc:7:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    6 | #include<algorithm>
  +++ |+#include <ostream>
    7 | 
a.cc:20:22: error: 'cout' was not declared in this scope
   20 |         else if(n==2)cout<<x[1]<<endl;
      |                      ^~~~
a.cc:20:22: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:20:34: error: 'endl' was not declared in this scope
   20 |         else if(n==2)cout<<x[1]<<endl;
      |                                  ^~~~
a.cc:20:34: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
a.cc:21:14: error: 'cout' was not declared in this scope
   21 |         else cout<<x[n/2+1]<<endl;
      |              ^~~~
a.cc:21:14: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:21:30: error: 'endl' was not declared in this scope
   21 |         else cout<<x[n/2+1]<<endl;
      |                              ^~~~
a.cc:21:30: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
Language: C++

#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;

const int INF = INT_MAX;
const long long INFL = 1LL<<40;
const double PI = atan(1)*4;
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}


struct BinaryIndexedTree{
    int n;
    vector<int>dat;
    BinaryIndexedTree(int n=0):n(n){
        dat.resize(n+1);
    }
    void add(int k,int x){
        for(k++;k<=n;k+=k&-k)dat[k]+=x;
    }
    int sum(int k){
        int ret=0;
        for(k++;k;k-=k&-k)ret+=dat[k];
        return ret;
    }
};



int N;
int A[111111];

int S[111111];


bool check(int x){
    int K=(N*(N+1)/2)/2;
    
    for(int i=0;i<N;i++){
        S[i+1]=S[i];
        if(A[i]<x)S[i+1]++;
        else S[i+1]--;
    }
    
    vector<int>vs;
    rep(i,N+1)vs.pb(S[i]);
    sort(all(vs));vs.erase(unique(all(vs)),vs.end());
    rep(i,N+1)S[i]=lower_bound(all(vs),S[i])-vs.begin();
    
    int cnt=0;
    BinaryIndexedTree bit(N+114);
    
    rep(i,N){
        bit.add(S[i],1);
        cnt+=bit.sum(S[i+1]-1);
    }
    
    return cnt<=K;
}

int main() {
    cin>>N;
    rep(i,N)cin>>A[i];
    
    int lb=0,ub=1001001001;
    while(ub-lb>1){
        int mid=(ub+lb)/2;
        if(check(mid))lb=mid;
        else ub=mid;
    }
    cout<<lb<<endl;
    return 0;
    
    return 0;
}









Compiler output:
a.cc: In function 'bool check(int)':
a.cc:94:18: error: 'class std::vector<int>' has no member named 'pb'
   94 |     rep(i,N+1)vs.pb(S[i]);
      |                  ^~
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

int bit[11234567], bit_n;

int bit_sum(int i)
{
    int s = 0;
    while (i > 0)
    {
        s += bit[i];
        i -= i & -i;
    }
    return s;
}

void bit_add(int i, int x)
{
    while (i <= bit_n)
    {
        bit[i] += x;
        i += i & -i;
    }
}

int main()
{
    int n, a[112345];

    cin >> n;
    REP(i, n)
    cin >> a[i];

    if (n == 1)
    {
        cout << a[0] << endl;
        return 0;
    }

    ll l = 0;
    ll r = 1e12;
    ll nn = n * (n - 1) / 2;

    while (r - l > 1)
    {
        ll m = (r + l) / 2;

        int s[112345];
        s[0] = 0;

        for (int i = 0; i < n; i++)
        {
            if (a[i] >= m)
                s[i + 1] = s[i] + 1;
            else
                s[i + 1] = s[i] - 1;
        }

        for (int i = 0; i <= n; i++)
        {
            s[i] += 112345;
        }

        bit_n = 112345 * 3;
        memset(bit, 0, sizeof(bit));

        int cnt = 0;

        for (int i = 0; i <= n; i++)
        {
            cnt += bit_sum(s[i]);
            bit_add(s[i], 1);
        }

        if (cnt > nn - (nn / 2 + 1))
            l = m;
        else
            r = m;
    }

    cout << l << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:82:9: error: 'memset' was not declared in this scope
   82 |         memset(bit, 0, sizeof(bit));
      |         ^~~~~~
a.cc:9:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    8 | #include <numeric>
  +++ |+#include <cstring>
    9 |
Language: C++

#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
using namespace std;
const int N = 2e5 + 10;
int n, a[N + 100], sum[N + 100];
long long cnt;
struct node
{
    int l, r, sum;
} tree[N * 8 + 10];

void push(int num)
{
    tree[num].sum = tree[2 * num].sum + tree[2 * num + 1].sum;
}

void build(int left, int right, int num)
{
    tree[num].l = left;
    tree[num].r = right;
    if (left == right)
    {
        tree[num].sum = 0;
        return;
    }
    build(left, (left + right) / 2, num * 2);
    build((left + right) / 2 + 1, right, 2 * num + 1);
    push(now);
}

void up(int now, int x)
{

    if (tree[now].l == x && tree[now].r == x)
    {
        tree[now].sum++;
        return;
    }
    int mid = (tree[now].l + tree[now].r) / 2;
    if (x <= mid)
        up(2 * now, x);
    else if (x > mid)
        up(2 * now + 1, x);
    tree[now].sum++;
    //cout << tree[now].l << " " << tree[now].r << " " << tree[now].sum << endl;
}

int find(int now, int left, int right)
{

    if (tree[now].l >= left && tree[now].r <= right)
    {

        return tree[now].sum;
    }
    int mid = (tree[now].l + tree[now].r) / 2;
    //
    if (right <= mid)
        return find(2 * now, left, right);
    else if (left > mid)
        return find(2 * now + 1, left, right);
    else
    {
        return find(2 * now, left, mid) + find(2 * now + 1, mid + 1, right);
    }
}

bool check(int x)
{
    sum[0] = 0;
    for (int i = 1; i <= n; i++)
    {
        if (a[i] > x)
            sum[i] = sum[i - 1] - 1;
        else
            sum[i] = sum[i - 1] + 1;
    }
    for (int i = 0; i <= n; i++)
        sum[i] += n + 1;
    build(1, N, 1);
    long long ans = 0;

    for (int i = 0; i <= n; i++)
    {
        ans += find(1, 1, sum[i] - 1);
        up(1, sum[i]);
    }
    //cout << x << " " << ans << endl;
    return ans >= 1ll * n * (n + 1) / 4 + 1;
}

int main()
{
    scanf("%d", &n);
    int l = 0;
    int r = 1e9;
    for (int i = 1; i <= n; i++)
    {
        scanf("%d", &a[i]);
    }
    while (l < r)
    {
        int mid = (l + r) / 2;
        if (check(mid))
        {
            r = mid;
        }
        else
        {
            l = mid + 1;
        }
    }
    cout << r << endl;
}


Compiler output:
a.cc: In function 'void build(int, int, int)':
a.cc:30:10: error: 'now' was not declared in this scope
   30 |     push(now);
      |          ^~~