stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
# include <bits/stdc++.h>

# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)

# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)

# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)

# define rreps(i, n) for(int i=((int)(n)); i>0; --i)

# define ALL(x) (x).begin(), (x).end()

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

# define pb push_back

# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)

# define MSG(x) std::cout << #x << " : " << x << "\n";

using namespace std;

using lint = long long;

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



int main()

{

    int K, S;

    cin >> K >> S;



    int cnt = 0;



    rep (X, K+1)

    {

        rep (Y, K+1)

        {

            int Z = S - X - Y;

            if (0 <= Z && Z <= K)

            {

                cnt++;

            }

        }

    }



    cout << cnt << "\n";



    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.2005335833636614x):
# include <stdio.h>



int main(void)

{

  int K, S;

  scanf("%d%d", &K, &S);

  

  int cnt = 0;

  for (int x = 0; x <= K; ++x)

  {

    for (int y = 0; y <= K; ++y)

    {

      int z = S - x - y;

      

      if (0 <= z && z <= K)

      {

        cnt++;

      }

    }

  }

  

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

  

  return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



#define maxn 100000

#define maxm 200000



int n,m;

int a[maxm+5];

int c[maxm+5];



void readin(){

    scanf("%d",&n);

    m=n*2-1;

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

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

    }

}



void Turn(int x) {

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

        c[i]=(a[i]>=x);

    }

}



bool judge(int x){

    Turn(x);

    int p1=0,p2=m+1;

    for(int i=n;i>=2;i--){

        if(c[i]==c[i-1]){

            p1=i;

            break;

        }

    }

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

        if(c[i]==c[i+1]) {

            p2=i;

            break;

        }

    }

    if(p1==0&&p2==m+1) return c[1];

    if(n-p1>p2-n) return c[p2];

    else return c[p1]; 

}



int binsearch() {

    int l=0,r=m;

    while(l+1<r) {

        int mid=l+(r-l)/2;

        if(judge(mid)) l=mid;

        else r=mid;

    }

    if(judge(l+1)) return l+1;

    if(!judge(l)) return l-1;

    else return l;

}



int main(){

    readin();

    int ans=binsearch();

    printf("%d",ans);

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.101185618307173x):
#include<cstdio>

#include<cstring>

#include<algorithm>

using namespace std;



const int MAXN=100005;



int n;

int a[MAXN*2];



bool check(int x){

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

        if(a[n+i]>=x&&a[n+i+1]>=x) return 1;

        if(a[n-i]>=x&&a[n-i-1]>=x) return 1;

        if(a[n+i]<x&&a[n+i+1]<x) return 0;

        if(a[n-i]<x&&a[n-i-1]<x) return 0;

    }

    return a[1]>=x;

}



int main(){



	scanf("%d",&n);

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

	int l=1,r=2*n;

	while(r-l>1){

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

        if(check(mid)) l=mid;

        else r=mid;

	}

	printf("%d",l);



	fclose(stdin);

	fclose(stdout);

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



#define maxn 100000

#define maxm 200000



int n,m;

int a[maxm+5];

int c[maxm+5];



void readin(){

    scanf("%d",&n);

    m=n*2-1;

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

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

    }

}



void Turn(int x) {

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

        c[i]=(a[i]>=x);

    }

}



bool judge(int x){

    Turn(x);

    int p1=0,p2=m+1;

    for(int i=n;i>=2;i--){

        if(c[i]==c[i-1]){

            p1=i;

            break;

        }

    }

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

        if(c[i]==c[i+1]) {

            p2=i;

            break;

        }

    }

    if(p1==0&&p2==m+1) return c[1];

    if(n-p1>p2-n) return c[p2];

    else return c[p1]; 

}



int binsearch() {

    int l=0,r=m;

    while(l+1<r) {

        int mid=l+(r-l)/2;

        if(judge(mid)) l=mid;

        else r=mid;

    }

    if(judge(l+1)) return l+1;

    if(!judge(l)) return l-1;

    else return l;

}



int main(){

    readin();

    int ans=binsearch();

    printf("%d",ans);

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.163544019965852x):
#include<stdio.h>

#include<math.h> 

using namespace std;

long long a[200001],i,n;

bool pd(long long h)

{

	if (a[n]<=h&&(a[n-1]<=h||a[n+1]<=h)) return true;

	if (a[n]>h&&(a[n-1]>h||a[n+1]>h)) return false;

	for (long long i=1;i<n-1;i++)

	{

		if (a[n+i]<=h&&a[n+i+1]<=h||a[n-i-1]<=h&&a[n-i]<=h) return true;

		if (a[n+i]>h&&a[n+i+1]>h||a[n-i-1]>h&&a[n-i]>h) return false;

	}

	return a[1]<=h;

}

long long erfen(long long l,long long r)

{

	if (l==r) return l;

	long long mid=(l+r)/2;

	if (pd(mid)) return erfen(l,mid);

	else return erfen(mid+1,r);

}

int main()

{

	scanf("%lld",&n);

	for (i=1;i<n*2;i++)

		scanf("%lld",&a[i]);

	printf("%lld",erfen(1,n*2-1));

	return 0;

}
// Slower C++ solution:
#include<cstdio>

#include<iostream>

#include<cstring>

#define RG register

using namespace std;

const int N=2e5+10;

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

template<typename I> inline void read(I &ot){

	I ch=getchar(), x=0, f=1;

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

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

	ot=x*f;}

template<typename I, typename... U> inline void read(I &x,U&... y){read(x); read(y...);}

inline bool chck(int x)

{

	for(RG int i=1;i<=m;i++) b[i]= a[i]>=x;

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

	{

		if(b[n-i]==b[n-i-1]) return b[n-i];

		if(b[n+i]==b[n+i+1]) return b[n+i];

	}

	return b[1];

}

int main()

{

//	freopen("Median Pyramid Hard.in","r",stdin);

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

	read(n); m=n*2-1;

	for(RG int i=1;i<=m;i++) read(a[i]);

	int l=1, r=m;

	while(l<=r)

	{

		int mid=l+(r-l)/2;

		if(chck(mid)) ans=mid, l=mid+1;

		else r=mid-1;

	}

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

	//fclose(stdin); fclose(stdout);

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.150069076636882x):
#include<stdio.h>

#include<math.h> 

using namespace std;

long long a[200001],i,n;

bool pd(long long h)

{

	if (a[n]<=h&&(a[n-1]<=h||a[n+1]<=h)) return true;

	if (a[n]>h&&(a[n-1]>h||a[n+1]>h)) return false;

	for (long long i=1;i<n-1;i++)

	{

		if (a[n+i]<=h&&a[n+i+1]<=h||a[n-i-1]<=h&&a[n-i]<=h) return true;

		if (a[n+i]>h&&a[n+i+1]>h||a[n-i-1]>h&&a[n-i]>h) return false;

	}

	return a[1]<=h;

}

long long erfen(long long l,long long r)

{

	if (l==r) return l;

	long long mid=(l+r)/2;

	if (pd(mid)) return erfen(l,mid);

	else return erfen(mid+1,r);

}

int main()

{

	scanf("%lld",&n);

	for (i=1;i<n*2;i++)

		scanf("%lld",&a[i]);

	printf("%lld",erfen(1,n*2-1));

	return 0;

}
// Slower C++ solution:
#include <cstdlib>

#include <cstring>

#include <cmath>

#include <algorithm>

#include <iostream>

#include <cctype>

#include <utility>

#include <set>

#include <map>

#include <queue>

#include <vector>

#include <stack>

#include <cstdio>

#include <iomanip>

#include <numeric>

#include <list>

#include <bitset>

#include <ctime>

#include <deque>

#include <functional>

int a[200005],n,l,r,mid;



inline bool check(const int &k)

{

    if((a[n-1]<=k&&a[n]<=k)||(a[n]<=k&&a[n+1]<=k))

        return 1;

    if((k<a[n-1]&&k<a[n])||(k<a[n]&&k<a[n+1]))

        return 0;

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

    {

        if((a[n+i]<=k&&a[n+i+1]<=k)||(a[n-i]<=k&&a[n-i-1]<=k))

            return 1;

        if((k<a[n+i]&&k<a[n+i+1])||(k<a[n-i]&&k<a[n-i-1]))

            return 0;

    }

    return (a[1]<=k&&a[1]<=k);

}



int main()

{

    scanf("%d",&n);

    for (int i=1;i<n<<1;i++) scanf("%d",a+i);

    for (r=(n<<1)-1,mid=l+r>>1;l<r;mid=l+r>>1) if (check(mid)) r=mid;else l=mid+1;

    printf("%d",l);

}


// Faster C++ solution for the same problem (measured speedup: 5.162890833825807x):
#include<stdio.h>

#include<math.h> 

using namespace std;

long long a[200001],i,n;

bool pd(long long h)

{

	if (a[n]<=h&&(a[n-1]<=h||a[n+1]<=h)) return true;

	if (a[n]>h&&(a[n-1]>h||a[n+1]>h)) return false;

	for (long long i=1;i<n-1;i++)

	{

		if (a[n+i]<=h&&a[n+i+1]<=h||a[n-i-1]<=h&&a[n-i]<=h) return true;

		if (a[n+i]>h&&a[n+i+1]>h||a[n-i-1]>h&&a[n-i]>h) return false;

	}

	return a[1]<=h;

}

long long erfen(long long l,long long r)

{

	if (l==r) return l;

	long long mid=(l+r)/2;

	if (pd(mid)) return erfen(l,mid);

	else return erfen(mid+1,r);

}

int main()

{

	scanf("%lld",&n);

	for (i=1;i<n*2;i++)

		scanf("%lld",&a[i]);

	printf("%lld",erfen(1,n*2-1));

	return 0;

}
// Slower C++ solution:
#include<cstdio>

#include<cstring>

#include<iostream>

#include<algorithm>

#define int long long

using namespace std;

int n;

int a[1000005];

bool val[1000005];

bool check(int lim){

	int ans=-1;

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

		if(a[i]>lim)val[i]=1;

		else val[i]=0;

	}

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

	{

		if(val[i]==val[i-1]){

			ans=val[i];

			break;

		}

		if(val[j]==val[j+1]){

			ans=val[j];

			break;

		}

	}

	if(ans==-1) return val[1];

	else return ans;

}

signed main(){

	scanf("%lld",&n);

	n=2*n-1;

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

		scanf("%lld",&a[i]);

	}

	int l=1,r=n,mid;

	while(l<r){

		mid=(l+r)>>1;

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

		else r=mid;

	}

	printf("%lld",l);

}

// Faster C++ solution for the same problem (measured speedup: 5.162390196998467x):
#include<stdio.h>

#include<math.h> 

using namespace std;

long long a[200001],i,n;

bool pd(long long h)

{

	if (a[n]<=h&&(a[n-1]<=h||a[n+1]<=h)) return true;

	if (a[n]>h&&(a[n-1]>h||a[n+1]>h)) return false;

	for (long long i=1;i<n-1;i++)

	{

		if (a[n+i]<=h&&a[n+i+1]<=h||a[n-i-1]<=h&&a[n-i]<=h) return true;

		if (a[n+i]>h&&a[n+i+1]>h||a[n-i-1]>h&&a[n-i]>h) return false;

	}

	return a[1]<=h;

}

long long erfen(long long l,long long r)

{

	if (l==r) return l;

	long long mid=(l+r)/2;

	if (pd(mid)) return erfen(l,mid);

	else return erfen(mid+1,r);

}

int main()

{

	scanf("%lld",&n);

	for (i=1;i<n*2;i++)

		scanf("%lld",&a[i]);

	printf("%lld",erfen(1,n*2-1));

	return 0;

}
// Slower C++ solution:
#include <iostream>

using namespace std;

int a[200005],n;

bool b[200005];

inline bool pd(int x)

{

	for(int i=1;i<=n*2-1;i++)

	{

		if(a[i]>=x)

			b[i]=1;

		else

			b[i]=0;

	}

	b[0]=b[1];

	if(b[n]==b[n+1]||b[n]==b[n-1])

		return b[n];

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

	{

		if(b[i]==b[i+1])

			return b[i];

		if(b[n+n-i]==b[n+n-i-1])

			return b[n+n-i];

	}

	return b[1];

}

int main(int argc, char** argv) {

	cin >> n;

	for(int i=1;i<=n*2-1;i++)

		cin >> a[i];

	int l=1,r=n*2,ans=0;

	while(l<=r)

	{

		int md=(l+r)/2;

		if(pd(md))

		{

			l=md+1;

			ans=max(ans,md);

		}

		else

			r=md-1;

	}

	cout << ans << endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.232769870942573x):
#include<stdio.h>

#include<math.h> 

using namespace std;

long long a[200001],i,n;

bool pd(long long h)

{

	if (a[n]<=h&&(a[n-1]<=h||a[n+1]<=h)) return true;

	if (a[n]>h&&(a[n-1]>h||a[n+1]>h)) return false;

	for (long long i=1;i<n-1;i++)

	{

		if (a[n+i]<=h&&a[n+i+1]<=h||a[n-i-1]<=h&&a[n-i]<=h) return true;

		if (a[n+i]>h&&a[n+i+1]>h||a[n-i-1]>h&&a[n-i]>h) return false;

	}

	return a[1]<=h;

}

long long erfen(long long l,long long r)

{

	if (l==r) return l;

	long long mid=(l+r)/2;

	if (pd(mid)) return erfen(l,mid);

	else return erfen(mid+1,r);

}

int main()

{

	scanf("%lld",&n);

	for (i=1;i<n*2;i++)

		scanf("%lld",&a[i]);

	printf("%lld",erfen(1,n*2-1));

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

using namespace std;

int n,a[200005],l=0x7fffffff,r;

void init()

{

	cin>>n;

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

	{

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

		l=min(l,a[i]);

		r=max(r,a[i]);

	}

}

int c[200005];

bool check(int x)

{

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

	{

		if(a[i]>=x) c[i]=1;

		else c[i]=0;

	}

	int t=0;

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

	if(c[n-j+1]==c[n-j]||c[n+j]==c[n+j-1])

	{t=j;break;}

	if(t==0)

	{

		c[n]=c[n]^((n-1)&1);

		return c[n];

	}

	if(c[n-t+1]==c[n-t])

	return c[n-t+1];

	else

	return c[n+t-1];

}

void play()

{

	int mid;

	while(l<r)

	{

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

		 if(check(mid)) l=mid;

		 else r=mid-1;

	}

	cout<<l<<endl;

}

int main()

{

	init();

	play();

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.244957922023644x):
#include<stdio.h>

#include<math.h> 

using namespace std;

long long a[200001],i,n;

bool pd(long long h)

{

	if (a[n]<=h&&(a[n-1]<=h||a[n+1]<=h)) return true;

	if (a[n]>h&&(a[n-1]>h||a[n+1]>h)) return false;

	for (long long i=1;i<n-1;i++)

	{

		if (a[n+i]<=h&&a[n+i+1]<=h||a[n-i-1]<=h&&a[n-i]<=h) return true;

		if (a[n+i]>h&&a[n+i+1]>h||a[n-i-1]>h&&a[n-i]>h) return false;

	}

	return a[1]<=h;

}

long long erfen(long long l,long long r)

{

	if (l==r) return l;

	long long mid=(l+r)/2;

	if (pd(mid)) return erfen(l,mid);

	else return erfen(mid+1,r);

}

int main()

{

	scanf("%lld",&n);

	for (i=1;i<n*2;i++)

		scanf("%lld",&a[i]);

	printf("%lld",erfen(1,n*2-1));

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

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

bool check(int now)

{

	for (int i=1;i<=2*n-1;i++)

	  if (a[i]>=now) b[i]=1;else b[i]=0;

	int m=(2*n-1)/2+1;

	int k=-1,Min=1e9;

	for (int i=1;i<=2*n-1;i++)

	  if (i!=1&&b[i]==b[i-1]&&min(abs(i-m)+1,abs(i-1-m)+1)<Min) 

	    Min=min(abs(i-m)+1,abs(i-1-m)+1),k=b[i];

	if (k==-1)

	{

		if (n&1) return b[m];

		else return !b[m];

    }

    return k;

}

int main()

{

	scanf("%d",&n);

	for (int i=1;i<=2*n-1;i++)

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

	int l=1,r=2e5;

	while (l+1<r)

	{

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

		if (check(mid)) l=mid;

		else r=mid-1;

    }

    if (check(r)) printf("%d\n",r);else printf("%d\n",l);

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.171417288189145x):
#include<stdio.h>

#include<math.h> 

using namespace std;

long long a[200001],i,n;

bool pd(long long h)

{

	if (a[n]<=h&&(a[n-1]<=h||a[n+1]<=h)) return true;

	if (a[n]>h&&(a[n-1]>h||a[n+1]>h)) return false;

	for (long long i=1;i<n-1;i++)

	{

		if (a[n+i]<=h&&a[n+i+1]<=h||a[n-i-1]<=h&&a[n-i]<=h) return true;

		if (a[n+i]>h&&a[n+i+1]>h||a[n-i-1]>h&&a[n-i]>h) return false;

	}

	return a[1]<=h;

}

long long erfen(long long l,long long r)

{

	if (l==r) return l;

	long long mid=(l+r)/2;

	if (pd(mid)) return erfen(l,mid);

	else return erfen(mid+1,r);

}

int main()

{

	scanf("%lld",&n);

	for (i=1;i<n*2;i++)

		scanf("%lld",&a[i]);

	printf("%lld",erfen(1,n*2-1));

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



const int N=200010;

int n,a[N];

bool f[N];



bool check(int x)

{

	for(int i=1;i<2*n;i++) f[i]=(a[i]>=x);

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

	{

		if(!f[n-i]&&!f[n-i-1]||!f[n+i]&&!f[n+i+1]) return false;

		if(f[n-i]&&f[n-i-1]||f[n+i]&&f[n+i+1]) return true;

	}

	return f[1];

}



int main()

{

	scanf("%d",&n);

	for(int i=1;i<2*n;i++) scanf("%d",a+i);

	int l=1,r=2*n-1,mid;

	while(l<r)

	{

		mid=(l+r)/2;

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

		else r=mid-1;

	}

	printf("%d\n",check(l)?l:l-1);

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.159653684569712x):
#include<cstdio>

using namespace std;

int n,a[1000005],l,r,mid,ans,xl,xr;

bool b[1000005];

bool check(int x){

	xl=0;xr=n<<1;

	for (register int i=1;i<=(n<<1)-1;++i) b[i]=(a[i]>=x);

	for (register int i=n;i>=2;--i){

		if (b[i]==b[i-1]) {xl=i;break;}

	}

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

		if (b[i]==b[i+1]) {xr=i;break;}

	}

	if (xl==0&&xr==n*2) return b[1];

	return n-xl>xr-n?b[xr]:b[xl];

}

int main(){

	scanf ("%d",&n);

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

	l=1;r=(n<<1)-1;

	while (l<=r){

		mid=l+r>>1;

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

		else r=mid-1;

	}

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

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

using namespace std;



int n,a[200005];



inline bool check(const int &k){

	if((a[n-1]<=k&&a[n]<=k)||(a[n]<=k&&a[n+1]<=k))return 1;

	if((a[n-1]> k&&a[n]> k)||(a[n]> k&&a[n+1]> k))return 0;

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

		if((a[n+i]<=k&&a[n+i+1]<=k)||(a[n-i]<=k&&a[n-i-1]<=k))return 1;

		if((a[n+i]> k&&a[n+i+1]> k)||(a[n-i]> k&&a[n-i-1]> k))return 0;

	}

	return a[1]<=k;

}



int main(){

	scanf("%d",&n);

	for(int i=1;i<n<<1;i++)scanf("%d",a+i);

	int l=1,r=(n<<1)-1;

	while(l<r){

		int mid=l+r>>1;

		if(check(mid))r=mid;

		else l=mid+1;

	}

	printf("%d",l);

}

// Faster C++ solution for the same problem (measured speedup: 5.194113237014973x):
#include<cstdio>

using namespace std;

int n,a[1000005],l,r,mid,ans,xl,xr;

bool b[1000005];

bool check(int x){

	xl=0;xr=n<<1;

	for (register int i=1;i<=(n<<1)-1;++i) b[i]=(a[i]>=x);

	for (register int i=n;i>=2;--i){

		if (b[i]==b[i-1]) {xl=i;break;}

	}

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

		if (b[i]==b[i+1]) {xr=i;break;}

	}

	if (xl==0&&xr==n*2) return b[1];

	return n-xl>xr-n?b[xr]:b[xl];

}

int main(){

	scanf ("%d",&n);

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

	l=1;r=(n<<1)-1;

	while (l<=r){

		mid=l+r>>1;

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

		else r=mid-1;

	}

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

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



const int N=200010;

int n,a[N];

bool f[N];



bool check(int x)

{

	for(int i=1;i<2*n;i++) f[i]=(a[i]>=x);

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

	{

		if(!f[n-i]&&!f[n-i-1]||!f[n+i]&&!f[n+i+1]) return false;

		if(f[n-i]&&f[n-i-1]||f[n+i]&&f[n+i+1]) return true;

	}

	return f[1];

}



int main()

{

	scanf("%d",&n);

	for(int i=1;i<2*n;i++) scanf("%d",a+i);

	int l=1,r=2*n-1,mid;

	while(l<r)

	{

		mid=(l+r)/2;

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

		else r=mid-1;

	}

	printf("%d\n",check(l)?l:l-1);

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.173000132583586x):
#include <cstdio>

#include <algorithm>

#include <cstring>



#define re register int



using namespace std;



const int maxn=200010;



int n;

int a[200100];



inline bool check(int x){

    for(re i=0;i<=n-1;i++){

        if((a[n-i]<x&&a[n-i-1]<x)||(a[n+i]<x&&a[n+i+1]<x))

            return false;

        if((a[n-i]>=x&&a[n-i-1]>=x)||(a[n+i]>=x&&a[n+i+1]>=x))

            return true;

    }

    return a[(n<<1)-1]>=x;

}

int main(){

    scanf("%d",&n);

    for(re i=1;i<=(n<<1)-1;i++){

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

    }

    

    int l=1,r=(n<<1)-1,ans=0;

    

    while(l<=r){

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

        if(check(mid))

            l=mid+1,ans=mid;

        else

            r=mid-1;

    }

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

    return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

using namespace std;



int n,a[200005];



inline bool check(const int &k){

	if((a[n-1]<=k&&a[n]<=k)||(a[n]<=k&&a[n+1]<=k))return 1;

	if((a[n-1]> k&&a[n]> k)||(a[n]> k&&a[n+1]> k))return 0;

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

		if((a[n+i]<=k&&a[n+i+1]<=k)||(a[n-i]<=k&&a[n-i-1]<=k))return 1;

		if((a[n+i]> k&&a[n+i+1]> k)||(a[n-i]> k&&a[n-i-1]> k))return 0;

	}

	return a[1]<=k;

}



int main(){

	scanf("%d",&n);

	for(int i=1;i<n<<1;i++)scanf("%d",a+i);

	int l=1,r=(n<<1)-1;

	while(l<r){

		int mid=l+r>>1;

		if(check(mid))r=mid;

		else l=mid+1;

	}

	printf("%d",l);

}

// Faster C++ solution for the same problem (measured speedup: 5.207548821365006x):
#include <cstdio>

#include <algorithm>

#include <cstring>



#define re register int



using namespace std;



const int maxn=200010;



int n;

int a[200100];



inline bool check(int x){

    for(re i=0;i<=n-1;i++){

        if((a[n-i]<x&&a[n-i-1]<x)||(a[n+i]<x&&a[n+i+1]<x))

            return false;

        if((a[n-i]>=x&&a[n-i-1]>=x)||(a[n+i]>=x&&a[n+i+1]>=x))

            return true;

    }

    return a[(n<<1)-1]>=x;

}

int main(){

    scanf("%d",&n);

    for(re i=1;i<=(n<<1)-1;i++){

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

    }

    

    int l=1,r=(n<<1)-1,ans=0;

    

    while(l<=r){

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

        if(check(mid))

            l=mid+1,ans=mid;

        else

            r=mid-1;

    }

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

    return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

using namespace std;



int n,a[200005];



inline bool check(const int &k){

    if((a[n-1]<=k&&a[n]<=k)||(a[n]<=k&&a[n+1]<=k))return 1;

    if((a[n-1]> k&&a[n]> k)||(a[n]> k&&a[n+1]> k))return 0;

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

        if((a[n+i]<=k&&a[n+i+1]<=k)||(a[n-i]<=k&&a[n-i-1]<=k))return 1;

        if((a[n+i]> k&&a[n+i+1]> k)||(a[n-i]> k&&a[n-i-1]> k))return 0;

    }

    return a[1]<=k;

}



int main(){

    scanf("%d",&n);

    for(int i=1;i<n<<1;i++)scanf("%d",a+i);

    int l=1,r=(n<<1)-1;

    while(l<r){

        int mid=l+r>>1;

        if(check(mid))r=mid;

        else l=mid+1;

    }

    printf("%d",l);

}

// Faster C++ solution for the same problem (measured speedup: 5.207548821365006x):
#include <cstdio>

#include <algorithm>

#include <cstring>



#define re register int



using namespace std;



const int maxn=200010;



int n;

int a[200100];



inline bool check(int x){

    for(re i=0;i<=n-1;i++){

        if((a[n-i]<x&&a[n-i-1]<x)||(a[n+i]<x&&a[n+i+1]<x))

            return false;

        if((a[n-i]>=x&&a[n-i-1]>=x)||(a[n+i]>=x&&a[n+i+1]>=x))

            return true;

    }

    return a[(n<<1)-1]>=x;

}

int main(){

    scanf("%d",&n);

    for(re i=1;i<=(n<<1)-1;i++){

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

    }

    

    int l=1,r=(n<<1)-1,ans=0;

    

    while(l<=r){

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

        if(check(mid))

            l=mid+1,ans=mid;

        else

            r=mid-1;

    }

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

    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



int n,a[200010];



template <typename T> inline void read(T &a) {

	a = 0;char c = getchar();int f = 1;

	while(!isdigit(c)) {if(c == '-') f = -1; c = getchar();}

	while(isdigit(c)) {a = (a<<3) + (a<<1) + (c ^ 48); c = getchar();}

	a*=f;

}



inline bool check (int k) {

	if((a[n-1] <= k && a[n] <= k) || (a[n] <= k && a[n+1] <=k)) 

		return true;

	if((a[n-1] > k && a[n] > k) || (a[n] > k && a[n+1] > k)) 

		return false;

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

		if((a[n + i] <= k && a[n + i + 1] <= k) || (a[n - i] <= k && a[n - i -1] <=k))

			return true;

		if((a[n + i] > k && a[n + i +1] > k) || (a[n - i] > k && a[n - i -1] > k))

			return false;

	}

	return a[1] <= k;

}



int main () {

	read(n);

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

		read(a[i]);

	int l = 1, r =(n << 1) - 1;

	while (l < r) {

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

		if(check(mid)) r = mid;

		else l = mid + 1;

	}

	cout<<l<<endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.170489641109703x):
#include <cstdio>

#include <algorithm>

#include <cstring>



#define re register int



using namespace std;



const int maxn=200010;



int n;

int a[200100];



inline bool check(int x){

    for(re i=0;i<=n-1;i++){

        if((a[n-i]<x&&a[n-i-1]<x)||(a[n+i]<x&&a[n+i+1]<x))

            return false;

        if((a[n-i]>=x&&a[n-i-1]>=x)||(a[n+i]>=x&&a[n+i+1]>=x))

            return true;

    }

    return a[(n<<1)-1]>=x;

}

int main(){

    scanf("%d",&n);

    for(re i=1;i<=(n<<1)-1;i++){

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

    }

    

    int l=1,r=(n<<1)-1,ans=0;

    

    while(l<=r){

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

        if(check(mid))

            l=mid+1,ans=mid;

        else

            r=mid-1;

    }

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

    return 0;

}