stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include <iostream>

using namespace std;

int main ()

{

	int n,r;

	while(cin>>n>>r)

	{

		int sum;

		if(n<10)

		{

			sum=r+100*(10-n);

			cout<<sum<<endl;

		}

		else

		{

			cout<<r<<endl;

		}

	}

	return 0;

} 

// Optimized solution to the same problem (faster):
#include <stdio.h>



int main(){

	int N,R;

	scanf("%d%d",&N,&R);

	if (N < 10){

		printf("%d",R+(100*(10-N)));

	}

	else if(N >= 10){

		printf("%d",R);

	}

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int main()

{

	int a,b;

	cin>>a>>b;

	if(a<=10)

	{

		cout<<(b+100*(10-a))<<endl;

	}

	else cout<<b<<endl;

	return 0;

 } 

// Optimized solution to the same problem (faster):
#include <stdio.h>



int main(){

	int N,R;

	scanf("%d%d",&N,&R);

	if (N < 10){

		printf("%d",R+(100*(10-N)));

	}

	else if(N >= 10){

		printf("%d",R);

	}

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



int N, R;



int main () {

    cin >> N >>R;

    if (N >= 10) {

         cout << R << endl;

    } else {

         cout << R + 100*(10 - N) << endl;

    }

} 

// Optimized solution to the same problem (faster):
#include <stdio.h>



int main(){

	int N,R;

	scanf("%d%d",&N,&R);

	if (N < 10){

		printf("%d",R+(100*(10-N)));

	}

	else if(N >= 10){

		printf("%d",R);

	}

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



int N, R;



int main() {

    cin>>N>>R;

    if(N>=10) {

        cout<<R<<endl;

    }

    else{

        cout<<R+100*(10-N)<<endl;

    }

}

// Optimized solution to the same problem (faster):
#include <stdio.h>



int main(){

	int N,R;

	scanf("%d%d",&N,&R);

	if (N < 10){

		printf("%d",R+(100*(10-N)));

	}

	else if(N >= 10){

		printf("%d",R);

	}

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<cstdio>

#include<cstring>

#include<cmath>

#include<algorithm>

using namespace std;





int main()

{

	int n,r;

	scanf("%d%d",&n,&r);

	int ans;

	if(n<10)

	{

		ans=r+(10-n)*100;

	}

	else ans=r;

	printf("%d",ans);

}

// Optimized solution to the same problem (faster):
#include <stdio.h>



int main(){

	int N,R;

	scanf("%d%d",&N,&R);

	if (N < 10){

		printf("%d",R+(100*(10-N)));

	}

	else if(N >= 10){

		printf("%d",R);

	}

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
// Input N dan R.

// Jika N>=10, output R

// Jika tidak, output R - 100*(10-N)



#include <bits/stdc++.h>

using namespace std;



int N, R;



int main () {

    cin >> N >> R;

    if (N >= 10) {

        cout << R << endl;

    } else {

        cout << R + 100*(10-N) << endl;

    }

}

// Optimized solution to the same problem (faster):
#include <stdio.h>

int main()

{

	int N, R, v, z, x;

	scanf("%d %d", &N, &R);

	v = R + 100*(10-N);

	if ( N >= 10 ){

		printf("%d", R);

	}

	else {

		printf("%d", v);

	}

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<cstdio>

#include<cstring>

#include<cstdlib>

#include<cmath>

#include<iostream>

#include<algorithm>

using namespace std;

long long n,r;

int main()

{

	cin>>n>>r;

	if (n>=10)

	{

		cout<<r<<"\n";

	}

	else

	{

		long long a=100*(10-n);

		a+=r;

		cout<<a<<"\n";

	}

	return 0;

}

// Optimized solution to the same problem (faster):
#include <stdio.h>

int main()

{

	int N, R, v, z, x;

	scanf("%d %d", &N, &R);

	v = R + 100*(10-N);

	if ( N >= 10 ){

		printf("%d", R);

	}

	else {

		printf("%d", v);

	}

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<cstdio>

#include<algorithm>

#include<cmath>

#include<map>

#include<cstring>

#include<climits>

#include<queue>

using namespace std;

#define MAXC 30

#define MAXN 500

int n,c,ans;

int D[MAXC+5][MAXC+5],C[MAXN+5][MAXN+5];

int cont[4][MAXC+5];

int main()

{

    ans=INT_MAX;

    scanf("%d%d",&n,&c);

    for(int i=1;i<=c;i++)

        for(int j=1;j<=c;j++)

        scanf("%d",&D[i][j]);

    for(int i=1;i<=n;i++)

        for(int j=1;j<=n;j++)

        scanf("%d",&C[i][j]);

    for(int i=1;i<=n;i++)

        for(int j=1;j<=n;j++)

        cont[(i+j)%3][C[i][j]]++;

    for(int i=1;i<=c;i++)

        for(int j=1;j<=c;j++)

        if(i!=j)

            for(int k=1;k<=c;k++)

            if(k!=i&&k!=j)

            {

                int res=0;

                for(int p=1;p<=c;p++)res+=cont[0][p]*D[p][i];

                for(int p=1;p<=c;p++)res+=cont[1][p]*D[p][j];

                for(int p=1;p<=c;p++)res+=cont[2][p]*D[p][k];

                ans=min(ans,res);

            }

    printf("%d",ans);

}


// Optimized solution to the same problem (faster):
#include<cstdio>

#include<algorithm>

using namespace std;

int d[300+5][300+5];

int t[5][300+5],s[5][300+5];//3的余数为0,1,2——>枚举所有情况求最优值

int x,y,z,ans=(int)1E9;

int n,c;

int solve(int x,int y)

{

	int ret=0;

	for(int i=1;i<=c;i++)

		ret+=t[x][i]*d[i][y];

	return ret;

}

int main()

{

	scanf("%d %d",&n,&c);

	for(int i=1;i<=c;i++)

    	for(int j=1;j<=c;j++)

			scanf("%d",&d[i][j]);//颜色i变成颜色j的代价

	for(int i=1;i<=n;i++)

		for(int j=1;j<=n;j++)

		{

			scanf("%d",&x);

			t[(i+j)%3][x]++;//余数为i,颜色为j的方格个数+1

		}

	for(int i=0;i<=2;i++)

		for(int j=1;j<=c;j++)

			s[i][j]=solve(i,j);

	for(int i=1;i<=c;i++)

		for(int j=1;j<=c;j++)

			for(int k=1;k<=c;k++)

			{

				if(i!=j&&i!=k&&j!=k)

					ans=min(ans,(s[0][i]+s[1][j]+s[2][k]));

			}

	printf("%d\n",ans);

	return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<set> 

#include<map> 

#include<stack> 

#include<cmath> 

#include<cstdio> 

#include<queue> 

#include<vector> 

#include<climits> 

#include<cstring> 

#include<iostream> 

#include<algorithm> 

using namespace std; 

#define MAXC 30

#define MAXN 500

#define LL long long 

#define INF INT_MAX 

int read(){ 

    int f=1,x=0; 

    char c=getchar(); 

    while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();} 

    while('0'<=c&&c<='9'){x=x*10+c-'0';c=getchar();} 

    return f*x; 

}

int c,d[MAXC+5][MAXC+5],cnt[3][MAXC+5],S[3][MAXC+5];

int change(int t,int x){

	int ret=0;

	for(int i=1;i<=c;i++)

		ret+=cnt[t][i]*d[i][x];

	return ret;

}

int main(){

	int n=read(),ans=INF;

	c=read();

	for(int i=1;i<=c;i++)

		for(int j=1;j<=c;j++)

			d[i][j]=read();

	for(int i=1;i<=n;i++)

		for(int j=1;j<=n;j++)

			cnt[(i+j)%3][read()]++;

	for(int t=0;t<=2;t++)

		for(int i=1;i<=c;i++) 

			S[t][i]=change(t,i);

	for(int i=1;i<=c;i++)

		for(int j=1;j<=c;j++)

			for(int k=1;k<=c;k++)

				if(i!=j&&j!=k&&i!=k){

					int tmp=S[0][i]+S[1][j]+S[2][k];

					if(tmp<ans) ans=tmp;

				}

	printf("%d\n",ans);

	return 0;

} 


// Optimized solution to the same problem (faster):
#include<cstdio>

#include<algorithm>

using namespace std;

int d[300+5][300+5];

int t[5][300+5],s[5][300+5];//3的余数为0,1,2——>枚举所有情况求最优值

int x,y,z,ans=(int)1E9;

int n,c;

int solve(int x,int y)

{

	int ret=0;

	for(int i=1;i<=c;i++)

		ret+=t[x][i]*d[i][y];

	return ret;

}

int main()

{

	scanf("%d %d",&n,&c);

	for(int i=1;i<=c;i++)

    	for(int j=1;j<=c;j++)

			scanf("%d",&d[i][j]);//颜色i变成颜色j的代价

	for(int i=1;i<=n;i++)

		for(int j=1;j<=n;j++)

		{

			scanf("%d",&x);

			t[(i+j)%3][x]++;//余数为i,颜色为j的方格个数+1

		}

	for(int i=0;i<=2;i++)

		for(int j=1;j<=c;j++)

			s[i][j]=solve(i,j);

	for(int i=1;i<=c;i++)

		for(int j=1;j<=c;j++)

			for(int k=1;k<=c;k++)

			{

				if(i!=j&&i!=k&&j!=k)

					ans=min(ans,(s[0][i]+s[1][j]+s[2][k]));

			}

	printf("%d\n",ans);

	return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<algorithm>

#include<vector>

#include<string>

#include<queue>

#include<stack>

#include<set>

#include<cmath>

#include<iomanip>

#include<functional>

using namespace std;



int INF = 1e9 + 7;



typedef long long ll;

typedef pair<int, int> P;



int main() {

	int n, c;

	vector<vector<int>> d(40, vector<int>(40, 0)), e(510, vector<int>(510, 0));

	cin >> n >> c;

	for (int i = 1; i <= c; i++) {

		for (int j = 1; j <= c; j++) {

			cin >> d[i][j];

		}

	}

	vector<int> amari0(31, 0), amari1(31, 0), amari2(31, 0);

	for (int i = 1; i <= n; i++) {

		for (int j = 1; j <= n; j++) {

			cin >> e[i][j];

			if ((i + j) % 3 == 0) amari0[e[i][j]]++;

			if ((i + j) % 3 == 1) amari1[e[i][j]]++;

			if ((i + j) % 3 == 2) amari2[e[i][j]]++;

		}

	}



	int ans = 0, MIN = INF;

	for (int x = 1; x <= c; x++) {

		for (int y = 1; y <= c; y++) {

			for (int z = 1; z <= c; z++) {

				if (x == y || y == z || z == x) continue;



				for (int i = 1; i <= c; i++) {

					ans += amari0[i] * d[i][x];

				}

				for (int i = 1; i <= c; i++) {

					ans += amari1[i] * d[i][y];

				}

				for (int i = 1; i <= c; i++) {

					ans += amari2[i] * d[i][z];

				}



				MIN = min(MIN, ans);

				ans = 0;

			}

		}

	}

	cout << MIN << endl;

}

// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

using namespace std;



typedef long long ll;

typedef pair<int, int> P;

typedef tuple<int, int, int> T;



int MOD=1e9+7;

ll INF=1e18;



int dx[]={1, -1, 0, 0};

int dy[]={0, 0, 1, -1};



ll mod0cnt[35], mod1cnt[35], mod2cnt[35];

ll d[35][35], g[510][510];



int main(){

    int n, c; cin>>n>>c;

    for(int i=0; i<c; i++){

        for(int j=0; j<c; j++){

            cin>>d[i][j];

        }

    }

    for(int i=0; i<n; i++){

        for(int j=0; j<n; j++){

            cin>>g[i][j];

            if((i+1+j+1)%3==0) mod0cnt[g[i][j]]++;

            else if((i+1+j+1)%3==1) mod1cnt[g[i][j]]++;

            else mod2cnt[g[i][j]]++;

        }

    }



    ll ans=INF;

    for(int i=1; i<=c; i++){

        for(int j=1; j<=c; j++){

            for(int k=1; k<=c; k++){

                if(i==j || k==j || k==i) continue;

                ll sum=0;



                for(int l=1; l<=c; l++){

                    sum+=mod0cnt[l]*d[l-1][i-1];

                    sum+=mod1cnt[l]*d[l-1][j-1];

                    sum+=mod2cnt[l]*d[l-1][k-1];

                }



                ans=min(ans, sum);

            }

        }

    }

    cout << ans << endl;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <cstdio>

#include <map>

#define repi(i,a,b) for(int i=(a);i<(b);++i)

#define rep(i,a) repi(i,0,a)

#define all(a) (a).begin(), (a).end()



int N, C;

int D[30][30];

int c[500][500];

int num[3];

std::map<int, int> cnt[3];



int main()

{

  scanf( "%d%d", &N, &C );

  rep( i, C ) rep( j, C )

    scanf( "%d", &D[i][j] );

  

  rep( i, N ) rep( j, N )

    scanf( "%d", &c[i][j] ), --c[i][j];



  rep( i, N ) rep( j, N )

  {

    int m = (i+j) % 3;



    ++num[m];

    ++cnt[m][c[i][j]];

  }



  int ans = 1<<30;



  rep( i, C ) rep( j, C ) rep( k, C ) if( i != j && j != k && i != k )

  {

    int sum = 0;



    for( auto it = cnt[0].begin(); it != cnt[0].end(); ++it )

      sum += D[it->first][i]*it->second;

    for( auto it = cnt[1].begin(); it != cnt[1].end(); ++it )

      sum += D[it->first][j]*it->second;

    for( auto it = cnt[2].begin(); it != cnt[2].end(); ++it )

      sum += D[it->first][k]*it->second;



    ans = std::min( ans, sum );

  }



  printf( "%d\n", ans );



  return 0;

}

// Optimized solution to the same problem (faster):
#include <cstdio>

#include <algorithm>

#define repi(i,a,b) for(int i=(a);i<(b);++i)

#define rep(i,a) repi(i,0,a)

#define all(a) (a).begin(), (a).end()



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; }



int N, C;

int D[40][40];

int c[510][510];

int diff[5][40];



int main()

{

  scanf( "%d%d", &N, &C );



  rep( i, C ) rep( j, C )

    scanf( "%d", &D[i][j] );



  rep( i, N ) rep( j, N )

    scanf( "%d", &c[i][j] ), --c[i][j];



  rep( col, C )

  {

    rep( i, N ) rep( j, N )

      diff[(i+1+j+1)%3][col] += D[c[i][j]][col];

  }



  int ans = 1<<30;



  rep( col1, C ) rep( col2, C ) rep( col3, C )

  {

    if( !(col1 != col2 && col2 != col3 && col3 != col1) )

      continue;



    ans = std::min( ans, diff[0][col1]+diff[1][col2]+diff[2][col3] );

  }



  printf( "%d\n", ans );



  return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

#define oo (long long)1e18

#define ll long long

#define setdp memset(dp,-1,sizeof(dp))

const ll mod = 1e9+7;

void _IOS(){ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);}

#define PI 3.14159265359

int n,l,r,x;

    vector<int>b(200009),a(200009);

int main()

{

    cin>>n;

    int ans=0;

    for(int i=1;i<=n;i++)

    {

        cin>>a[i];

        if(i&1&&a[i]&1)

            ans++;

    }

    cout<<ans;

}


// Optimized solution to the same problem (faster):
#include <iostream>



using namespace std;



int main()

{

    int counter = 0;

    int n;

    cin>>n;

    int arr[n];

    for(int i = 0 ; i < n ; i++)

    {

        cin>>arr[i];

        if(arr[i] % 2 !=0 && (i+1)%2 != 0)

        {

            counter++;

        }

    }

    cout<<counter;



}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

const int N = 1e5+20;

int n,a[N],b[N],Max,ans;

long long c[N*2];

inline int lowbit(int x) { return x & (-x); }

inline void insert(int p,long long v) { p += n+1; for (;p<=2*n+1;p+=lowbit(p)) c[p] += v; }

inline long long query(int p) { p += n+1; long long res = 0; for (;p;p-=lowbit(p)) res += c[p]; return res; }

inline void input(void)

{

    scanf("%d",&n);

    for (int i=1;i<=n;i++)

        scanf("%d",&a[i]) , Max = max( Max , a[i] );

}

inline long long check(int val)

{

    long long res = 0;

    for (int i=1;i<=n;i++)

        b[i] = a[i] <= val ? 1 : -1;

    for (int i=1;i<=n;i++)

        b[i] += b[i-1];

    memset( c , 0 , sizeof c );

    for (int i=0;i<=n;i++)

    {

        res += query( b[i] - 1 );

        insert( b[i] , 1 );

    }

    return res;

}

inline void BinarySearch(void)

{

    int l = 0 , r = Max , mid;

    while ( l + 1 < r )

    {

        mid = l + r >> 1;

        if ( check(mid) >= 1LL*n*(n+1)/2/2 + 1 ) r = mid;

        else l = mid;

    }

    check(l) == 1LL*n*(n+1)/2/2 + 1 ? ans = l : ans = r;

}

int main(void)

{

    input();

    BinarySearch();

    printf("%d\n",ans);

    return 0;

}


// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

#define ll long long

using namespace std;

const int N=100011;

int n,a[N],r=0,l=0,ans=0;

int c[N*10],s[N<<1];

int cc[N*10],d[N*10],tot=0;

void add(int x)

{

	while(x<=N*2)

	  c[x]++,x+=x&(-x);

}

ll ask(int x)

{

	ll ans=0;

	while(x)

	{

		ans+=c[x];

		x-=x&(-x);

	}

	return ans;

}

//求中位数小于等于x的区间数至少为n*(n+1)/2/2+1的最小的x

bool check(int x)

{

	for(int i=1;i<=2*N;i++) c[i]=0;

	s[0]=0;

	for(int i=1;i<=n;i++)

	  s[i]=s[i-1]+(a[i]<=x?1:-1);

	ll sum=0;

	for(int i=0;i<=n;i++)

    {

       sum+=ask(s[i]-1+N);

       add(s[i]+N);

	}  

//	cout<<x<<" "<<sum<<endl;

	return sum>=(((ll)n*(n+1)/2/2)+1);

}

int main()

{

//freopen(".in","r",stdin);

//freopen(".out","w",stdout);

  scanf("%d",&n);  l=987654321;

  for(int i=1;i<=n;i++) scanf("%d",&a[i]),r=max(r,a[i]),l=min(l,a[i]);

//  for(int i=1;i<=n;i++)

//    for(int j=i;j<=n;j++)

//	  {

//	  	for(int z=1;z<=j-i+1;z++)

//	  	  cc[z]=a[i+z-1];

//	  	sort(cc+1,cc+j-i+2);

//	  	d[++tot]=cc[(j-i+1)/2+1];

//	  } 

//  sort(d+1,d+tot+1);

//  for(int i=1;i<=tot;i++) 

//    cout<<d[i]<<" ";

//  cout<<"---------"<<endl; 

//  cout<<d[tot/2+1]<<endl;

// 

//  for(int i=l;i<=r;i++)

//    check(i);

  while(l+1<=r)

  {

	int mid=(l+r)>>1;

  	if(check(mid)) 

	  r=mid;

	else l=mid+1;

  }

  printf("%d\n",r);

  return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

#define ll long long

using namespace std;

const int N=100011;

int n,a[N],r=0,l=0,ans=0;

int c[N*10],s[N<<1];

void add(int x)

{

	while(x<=N*2)

	  c[x]++,x+=x&(-x);

}

ll ask(int x)

{

	ll ans=0;

	while(x)

	{

		ans+=c[x];

		x-=x&(-x);

	}

	return ans;

}

bool check(int x)

{

	for(int i=1;i<=2*N;i++) c[i]=0;

	s[0]=0;

	for(int i=1;i<=n;i++)

	  s[i]=s[i-1]+(a[i]>=x?1:-1);

	ll sum=0;

	for(int i=0;i<=n;i++)

    {

       sum+=ask(s[i]+N);

       add(s[i]+N);

	} 

	return sum>=(ll)n*(n+1)/4;

}

int main()

{

//freopen(".in","r",stdin);

//freopen(".out","w",stdout);

  scanf("%d",&n);

  for(int i=1;i<=n;i++) scanf("%d",&a[i]),r=max(r,a[i]);

  while(l<=r)

  {

  	int mid=(l+r)>>1;

  	if(check(mid)) 

	  l=mid+1;

	else r=mid-1;

  }

  printf("%d\n",r);

  return 0;

}


// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>



using namespace std;

#define int long long

#define x first

#define y second



#define vert int v, int tl, int tr

#define tm ((tl + tr) >> 1)

#define left (v << 1), tl, tm

#define right (v << 1) + 1, tm, tr



typedef pair<int, int> pii;

typedef long long ll;

typedef long double ld;



int n;

int a[100009];

int pref[100009];



int tree[800009];

void build(vert) {

    tree[v] = 0;

    if (tr - tl == 1) return;



    build(left);

    build(right);

}



void upd(vert, int i, int x) {

    tree[v] += x;

    if (tr - tl == 1) {

        return;

    }



    if (i < tm) {

        upd(left, i, x);

    }



    else {

        upd(right, i, x);

    }

}



int getsum(vert, int l, int r) {

    if (l >= tr || tl >= r) return 0;

    if (tl >= l && tr <= r) return tree[v];

    return getsum(left, l, r) + getsum(right, l, r);

}



int check(int x) {

    for (int i = 0; i < n; i ++) {

        if (a[i] >= x)

            pref[i + 1] = pref[i] + 1;

        else

            pref[i + 1] = pref[i] - 1;

    }



    build(1, 0, 2 * n + 2);

    int cnt = 0;

    for (int i = 0; i <= n; i ++) {

        cnt += getsum(1, 0, 2 * n + 2, 0, pref[i] + n + 1);

        upd(1, 0, 2 * n + 2, pref[i] + n, 1);

    }



    return cnt;

}



signed main() {

    ios :: sync_with_stdio(0);

    cin.tie(0);



    cin >> n;

    for (int i = 0; i < n; i ++) {

        cin >> a[i];

    }



    int l = 0, r = (1e9) + 1;

    int eth = (n * n) / 2;

    while (r - l > 1) {

        int m = (r + l) / 2;

        if (check(m) <= (eth + 1) / 2) {

            r = m;

        }



        else {

            l = m;

        }

    }



    cout << l;



    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

#define maxn 100005



inline void read(int& x)

{

	x=0;char c=getchar();

	while(!isdigit(c)) c=getchar();

	while(isdigit(c)) x=x*10+c-'0',c=getchar();

}

int n,a[maxn],sum[maxn],c[maxn+maxn];



inline int lowbit(int x)

{

	return x&(-x);

}

inline void modify(int pos)

{

	for(int i=pos;i<=200000;i+=lowbit(i)) ++c[i];

}

inline int query(int pos)

{

	int ans=0;

	for(int i=pos;i;i-=lowbit(i)) ans+=c[i];

	return ans;

}



bool check(int x)

{

	sum[0]=0;

	for(int i=1;i<=n;++i)

		sum[i]=sum[i-1]+(a[i]>=x?1:-1);

	memset(c,0,sizeof(c));

	long long ans=0;

	for(int i=0;i<=n;++i)

	{

		ans+=query(sum[i]+100000);

		modify(sum[i]+100000);

	}

	return (ans<<2)>=1ll*n*(n+1);

}

int main()

{

	int l=0x3f3f3f3f,r=-0x3f3f3f3f,mid;

	read(n);

	for(int i=1;i<=n;++i) read(a[i]),l=min(l,a[i]),r=max(r,a[i]);

	while(l<=r)

	{

		mid=(l+r)>>1;

		if(check(mid)) l=mid+1;

		else r=mid-1;

	}

	printf("%d\n",r);

	return 0;

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>



using namespace std;

#define int long long

#define x first

#define y second



#define vert int v, int tl, int tr

#define tm ((tl + tr) >> 1)

#define left (v << 1), tl, tm

#define right (v << 1) + 1, tm, tr



typedef pair<int, int> pii;

typedef long long ll;

typedef long double ld;



int n;

int a[100009];

int pref[100009];



int tree[800009];

void build(vert) {

    tree[v] = 0;

    if (tr - tl == 1) return;



    build(left);

    build(right);

}



void upd(vert, int i, int x) {

    tree[v] += x;

    if (tr - tl == 1) {

        return;

    }



    if (i < tm) {

        upd(left, i, x);

    }



    else {

        upd(right, i, x);

    }

}



int getsum(vert, int l, int r) {

    if (l >= tr || tl >= r) return 0;

    if (tl >= l && tr <= r) return tree[v];

    return getsum(left, l, r) + getsum(right, l, r);

}



int check(int x) {

    for (int i = 0; i < n; i ++) {

        if (a[i] >= x)

            pref[i + 1] = pref[i] + 1;

        else

            pref[i + 1] = pref[i] - 1;

    }



    build(1, 0, 2 * n + 2);

    int cnt = 0;

    for (int i = 0; i <= n; i ++) {

        cnt += getsum(1, 0, 2 * n + 2, 0, pref[i] + n + 1);

        upd(1, 0, 2 * n + 2, pref[i] + n, 1);

    }



    return cnt;

}



signed main() {

    ios :: sync_with_stdio(0);

    cin.tie(0);



    cin >> n;

    for (int i = 0; i < n; i ++) {

        cin >> a[i];

    }



    int l = 0, r = (1e9) + 1;

    int eth = (n * n) / 2;

    while (r - l > 1) {

        int m = (r + l) / 2;

        if (check(m) <= (eth + 1) / 2) {

            r = m;

        }



        else {

            l = m;

        }

    }



    cout << l;



    return 0;

}


// Fastest known solution for this problem: