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

using namespace std;



const int RLEN=1<<18|1;

inline char nc() {

    static char ibuf[RLEN],*ib,*ob;

    (ib==ob) && (ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));

    return (ib==ob) ? -1 : *ib++;

}

inline int rd() {

    char ch=nc(); int i=0,f=1;

    while(!isdigit(ch)) {if(ch=='-')f=-1; ch=nc();}

    while(isdigit(ch)) {i=(i<<1)+(i<<3)+ch-'0'; ch=nc();}

    return i*f;

}



const int N=2e5+50;

int n,a[N];

#define up(i,j) ((a[i]>=v) && (a[j]>=v))

#define dn(i,j) ((a[i]<v) && (a[j]<v))

inline bool check(int v) {

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

        if(up(n+i,n+i+1) || up(n-i,n-i-1)) return 1;

        if(dn(n+i,n+i+1) || dn(n-i,n-i-1)) return 0;

    } return up(1,1);

}

int main() {

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

    int l=1, r=*max_element(a+1,a+2*n), ans=0;

    while(l<=r) {

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

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

        else r=mid-1;

    } cout<<ans<<'\n';

}

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

using namespace std;

const int MAXN=3e5+5;

int N;

int A[MAXN];



bool Check(int Key){

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

		if( (A[N+i]>Key && A[N+i+1]>Key) || (A[N-i]>Key && A[N-i-1]>Key) ){

			return 0;

		}

		if( (A[N+i]<=Key && A[N+i+1]<=Key) || (A[N-i]<=Key && A[N-i-1]<=Key) ){

			return 1;

		}

	}

	return A[1]<=Key;

}



int BS(int L,int R){

	int Ans=0;

	while(L<=R){

		int Mid=(L+R)>>1;

		if(Check(Mid)){

			Ans=Mid;

			R=Mid-1;

		}else{

			L=Mid+1;

		}

	}

	return Ans;

}



int main(){

	

	scanf("%d",&N);

	

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

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

	}

	

	printf("%d\n",BS(1,2*N-1));

	

	return 0;

	

} 

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

#define N 200005

using namespace std;

int a[N],len,n;

bool f[N];

bool check(int x){

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

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

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

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

	}

	return f[1];

}

int main(){

	int l=1,r,i,ans;

	scanf("%d",&n);r=len=2*n-1;

	for(i=1;i<=len;++i) scanf("%d",&a[i]);

	while(l<=r){

		int mid=l+r>>1;

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

		else r=mid-1;

	}

	cout<<ans;

}

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

using namespace std;

const int MAXN=3e5+5;

int N;

int A[MAXN];



bool Check(int Key){

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

		if( (A[N+i]>Key && A[N+i+1]>Key) || (A[N-i]>Key && A[N-i-1]>Key) ){

			return 0;

		}

		if( (A[N+i]<=Key && A[N+i+1]<=Key) || (A[N-i]<=Key && A[N-i-1]<=Key) ){

			return 1;

		}

	}

	return A[1]<=Key;

}



int BS(int L,int R){

	int Ans=0;

	while(L<=R){

		int Mid=(L+R)>>1;

		if(Check(Mid)){

			Ans=Mid;

			R=Mid-1;

		}else{

			L=Mid+1;

		}

	}

	return Ans;

}



int main(){

	

	scanf("%d",&N);

	

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

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

	}

	

	printf("%d\n",BS(1,2*N-1));

	

	return 0;

	

} 

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

#include<cstdio>

using namespace std;

int n,a[200001];

bool checx(int x)

{

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

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

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

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

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

    }

    return a[1]<=x;

}



int main(){

    cin>>n;

    for(int i=1;i<n<<1;i++)cin>>a[i];

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

    while(l<r)

	{

        int mid=(l+r)/2;

        if(checx(mid))r=mid;

        else l=mid+1;

    }

    cout<<l;

}


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

using namespace std;

const int MAXN=3e5+5;

int N;

int A[MAXN];



bool Check(int Key){

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

		if( (A[N+i]>Key && A[N+i+1]>Key) || (A[N-i]>Key && A[N-i-1]>Key) ){

			return 0;

		}

		if( (A[N+i]<=Key && A[N+i+1]<=Key) || (A[N-i]<=Key && A[N-i-1]<=Key) ){

			return 1;

		}

	}

	return A[1]<=Key;

}



int BS(int L,int R){

	int Ans=0;

	while(L<=R){

		int Mid=(L+R)>>1;

		if(Check(Mid)){

			Ans=Mid;

			R=Mid-1;

		}else{

			L=Mid+1;

		}

	}

	return Ans;

}



int main(){

	

	scanf("%d",&N);

	

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

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

	}

	

	printf("%d\n",BS(1,2*N-1));

	

	return 0;

	

} 

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

#include <cstdio>

#include <algorithm>



using namespace std;



const int N = 100010;



int n, a[N << 1];



bool check(int x)

{

	int l = n, r = n;

	while (l > 1 && (a[l - 1] >= x) != (a[l] >= x)) --l;

	while (r < 2 * n - 1 && (a[r + 1] >= x) != (a[r] >= x)) ++r;

	if (n - l <= r - n) return a[l] >= x;

	return a[r] >= x;

}



int main()

{

	int l = 0x7fffffff, r = 0;

	

	scanf("%d", &n);

	

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

	{

		scanf("%d", a + i);

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

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

	}

	

	while (l < r)

	{

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

		if (check(mid)) l = mid;

		else r = mid - 1;

	}

	

	cout << l;

	

	return 0;

}

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

using namespace std;

const int MAXN=3e5+5;

int N;

int A[MAXN];



bool Check(int Key){

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

		if( (A[N+i]>Key && A[N+i+1]>Key) || (A[N-i]>Key && A[N-i-1]>Key) ){

			return 0;

		}

		if( (A[N+i]<=Key && A[N+i+1]<=Key) || (A[N-i]<=Key && A[N-i-1]<=Key) ){

			return 1;

		}

	}

	return A[1]<=Key;

}



int BS(int L,int R){

	int Ans=0;

	while(L<=R){

		int Mid=(L+R)>>1;

		if(Check(Mid)){

			Ans=Mid;

			R=Mid-1;

		}else{

			L=Mid+1;

		}

	}

	return Ans;

}



int main(){

	

	scanf("%d",&N);

	

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

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

	}

	

	printf("%d\n",BS(1,2*N-1));

	

	return 0;

	

} 

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

using namespace std;

#define reg register

#define ll long long

inline ll read()

{

	ll x=0,w=0;char ch=getchar();

	while(!isdigit(ch))w|=ch=='-',ch=getchar();

	while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();

	return w?-x:x;

}

int n,m,a[200000],b[200000];

int main()

{

    m=read();n=m*2-1;reg int i,j,l,r,mid,c,fl;

    for(i=1;i<=n;++i)a[i]=read(),b[i]=a[i];

    sort(b+1,b+1+n);

    l=0;r=n;

    while(l<r-1)

    {

        mid=(l+r)>>1;c=(a[m]>b[mid]);c^=1;fl=-1;

        for(i=m-1,j=m+1;i>=1,j<=n;--i,++j)

        {

            if((a[i]>b[mid])!=c){fl=(a[i]>b[mid]);break;}

            if((a[j]>b[mid])!=c){fl=(a[j]>b[mid]);break;}

            c^=1;

        }

        if(fl==-1)

        {

            if(m&1)fl=(a[m]>b[mid]);

            else fl=(a[m]<=b[mid]);

        }

        if(fl)l=mid;

        else r=mid;

    }

    cout<<b[r]<<"\n";

	return 0;

}


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

using namespace std;

const int MAXN=3e5+5;

int N;

int A[MAXN];



bool Check(int Key){

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

		if( (A[N+i]>Key && A[N+i+1]>Key) || (A[N-i]>Key && A[N-i-1]>Key) ){

			return 0;

		}

		if( (A[N+i]<=Key && A[N+i+1]<=Key) || (A[N-i]<=Key && A[N-i-1]<=Key) ){

			return 1;

		}

	}

	return A[1]<=Key;

}



int BS(int L,int R){

	int Ans=0;

	while(L<=R){

		int Mid=(L+R)>>1;

		if(Check(Mid)){

			Ans=Mid;

			R=Mid-1;

		}else{

			L=Mid+1;

		}

	}

	return Ans;

}



int main(){

	

	scanf("%d",&N);

	

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

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

	}

	

	printf("%d\n",BS(1,2*N-1));

	

	return 0;

	

} 

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

using namespace std;

int a[222222];

int n,l,r,ans,mid;

inline int big(int x,int y,int z){ return a[x]>z&&a[y]>z; }

inline int small(int x,int y,int z){ return a[x]<=z&&a[y]<=z; }

inline bool Trial(int k)

{

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

    {

        if(big(n-i,n-i-1,k)||big(n+i,n+i+1,k)) return false;

        if(small(n-i,n-i-1,k)||small(n+i,n+i+1,k)) return true;

    }

    return small(1,1,k);

}

int main()

{

    scanf("%d",&n);

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

    l=1;r=n*2-1;

    while(l<r)

    {

        mid=(l+r)/2;

        if(Trial(mid)) r=mid;

        else l=mid+1;

    }

    ans=r;

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

    return 0;

}

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

using namespace std;

const int MAXN=3e5+5;

int N;

int A[MAXN];



bool Check(int Key){

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

		if( (A[N+i]>Key && A[N+i+1]>Key) || (A[N-i]>Key && A[N-i-1]>Key) ){

			return 0;

		}

		if( (A[N+i]<=Key && A[N+i+1]<=Key) || (A[N-i]<=Key && A[N-i-1]<=Key) ){

			return 1;

		}

	}

	return A[1]<=Key;

}



int BS(int L,int R){

	int Ans=0;

	while(L<=R){

		int Mid=(L+R)>>1;

		if(Check(Mid)){

			Ans=Mid;

			R=Mid-1;

		}else{

			L=Mid+1;

		}

	}

	return Ans;

}



int main(){

	

	scanf("%d",&N);

	

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

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

	}

	

	printf("%d\n",BS(1,2*N-1));

	

	return 0;

	

} 

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

#include<cstdio>

#include<cstring>

#include<algorithm>

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

using namespace std;

int n,a[2000500],b[2000005],r,l;

void work(int x,int y){

	//cout<<x<<" "<<y<<endl;

	if((y-x)&1){

		if(n>=(y-x+1)/2){//cout<<"z"<<endl;

		    rep(i,x,(y+x)/2) b[i]=b[x];

		    rep(i,(y+x)/2+1,y) b[i]=b[y];

		}

		else{

			rep(i,x,x+n-1) b[i]=b[x];

			rep(i,x+n,y-n) if((i-x-n)%2==0) b[i]=b[x]; else b[i]=b[y];

			rep(i,y-n+1,y) b[i]=b[y];

		}

	}

	else{//cout<<"h";

	    rep(i,x,y) b[i]=b[x];

		if(n<=(y-x)/2) rep(i,x+n,y-n) if((i-x-n)%2==0) b[i]=1-b[x];else b[i]=b[x];

	}

}

bool check(int x){

//	cout<<x<<endl;

	rep(i,1,2*n-1) if(a[i]>=x) b[i]=1;else b[i]=0;

//	rep(i,1,2*n-1) cout<<b[i];cout<<endl;

	b[2*n]=2;

	int st=-1;

	rep(i,1,2*n-1){

		if(st!=-1 && b[i]==b[i+1]) work(st,i),st=-1;

		if(st==-1 && b[i]!=b[i+1]) st=i;

	}

	if(st!=-1) work(st,2*n-1);

//	rep(i,1,2*n-1) cout<<b[i];cout<<endl;

	return b[n];

}

int main(){

	scanf("%d",&n);

	rep(i,1,2*n-1) scanf("%d",&a[i]),r=max(r,a[i]);

    l=1;

    while(l<r){

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

    	if(check(mid)) l=mid;

    	else r=mid-1;

	}

	printf("%d",l);

	return 0;

}

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

using namespace std;

const int MAXN=3e5+5;

int N;

int A[MAXN];



bool Check(int Key){

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

		if( (A[N+i]>Key && A[N+i+1]>Key) || (A[N-i]>Key && A[N-i-1]>Key) ){

			return 0;

		}

		if( (A[N+i]<=Key && A[N+i+1]<=Key) || (A[N-i]<=Key && A[N-i-1]<=Key) ){

			return 1;

		}

	}

	return A[1]<=Key;

}



int BS(int L,int R){

	int Ans=0;

	while(L<=R){

		int Mid=(L+R)>>1;

		if(Check(Mid)){

			Ans=Mid;

			R=Mid-1;

		}else{

			L=Mid+1;

		}

	}

	return Ans;

}



int main(){

	

	scanf("%d",&N);

	

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

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

	}

	

	printf("%d\n",BS(1,2*N-1));

	

	return 0;

	

} 

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

using namespace std;

int n;

int a[200005];

int ha1(int i,int j,int x)

{

	return a[i]>x&&a[j]>x;

}

int ha2(int i,int j,int x)

{

	return a[i]<=x&&a[j]<=x;

}

int haha(int x)

{

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

	{

		if(ha1(n+i,n+i+1,x)||ha1(n-i,n-i-1,x))//判断大的

			return 0;

		if(ha2(n+i,n+i+1,x)||ha2(n-i,n-i-1,x))

			return 1;

	}

	return ha2(1,1,x);

}

int main()

{

	scanf("%d",&n);

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

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

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

	while(l<r)

	{

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

		if(haha(mid))

			r=mid;

		else

			l=mid+1;

	}

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

}

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

using namespace std;

const int MAXN=3e5+5;

int N;

int A[MAXN];



bool Check(int Key){

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

		if( (A[N+i]>Key && A[N+i+1]>Key) || (A[N-i]>Key && A[N-i-1]>Key) ){

			return 0;

		}

		if( (A[N+i]<=Key && A[N+i+1]<=Key) || (A[N-i]<=Key && A[N-i-1]<=Key) ){

			return 1;

		}

	}

	return A[1]<=Key;

}



int BS(int L,int R){

	int Ans=0;

	while(L<=R){

		int Mid=(L+R)>>1;

		if(Check(Mid)){

			Ans=Mid;

			R=Mid-1;

		}else{

			L=Mid+1;

		}

	}

	return Ans;

}



int main(){

	

	scanf("%d",&N);

	

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

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

	}

	

	printf("%d\n",BS(1,2*N-1));

	

	return 0;

	

} 

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

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

using namespace std;

const int MAXN=3e5+5;

int N;

int A[MAXN];



bool Check(int Key){

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

		if( (A[N+i]>Key && A[N+i+1]>Key) || (A[N-i]>Key && A[N-i-1]>Key) ){

			return 0;

		}

		if( (A[N+i]<=Key && A[N+i+1]<=Key) || (A[N-i]<=Key && A[N-i-1]<=Key) ){

			return 1;

		}

	}

	return A[1]<=Key;

}



int BS(int L,int R){

	int Ans=0;

	while(L<=R){

		int Mid=(L+R)>>1;

		if(Check(Mid)){

			Ans=Mid;

			R=Mid-1;

		}else{

			L=Mid+1;

		}

	}

	return Ans;

}



int main(){

	

	scanf("%d",&N);

	

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

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

	}

	

	printf("%d\n",BS(1,2*N-1));

	

	return 0;

	

} 

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

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

#define Rof(i,a,b) for(int i=(a);i>=(b);--i)

#define S(i) ((int)(A[i]>=Pos))

#define LL long long

using namespace std;

int N,A[300001],INF=10000000;

bool Check(int Pos){

	int m[2];

	m[0]=m[1]=INF;

//	For(i,1,2*N-1) printf("%d ",S(i));puts("");

	For(i,N,2*N-2)

		if(S(i)==S(i+1)){

			m[S(i)]=min(m[S(i)],i-N);

//			cout<<'-'<<i<<' '<<S(i)<<endl;

			break;

		}

	Rof(i,N,2)

		if(S(i)==S(i-1)){

			m[S(i)]=min(m[S(i)],N-i);

			break;

		}

//	cout<<m[1]<<' '<<m[0]<<endl;

	if(m[0]==INF&&m[1]==INF)return (S(N)^(N&1)^1);

	if(m[1]<m[0])return 1;

	return 0;

}

int main(){

	scanf("%d",&N);For(i,1,2*N-1) scanf("%d",&A[i]);

	int l=1,r=2*N-1,Mid,Ans;

//	cout<<Check(4);



	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;

}

/*

3

1 5 2 4 3

*/

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

using namespace std;

const int MAXN=3e5+5;

int N;

int A[MAXN];



bool Check(int Key){

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

		if( (A[N+i]>Key && A[N+i+1]>Key) || (A[N-i]>Key && A[N-i-1]>Key) ){

			return 0;

		}

		if( (A[N+i]<=Key && A[N+i+1]<=Key) || (A[N-i]<=Key && A[N-i-1]<=Key) ){

			return 1;

		}

	}

	return A[1]<=Key;

}



int BS(int L,int R){

	int Ans=0;

	while(L<=R){

		int Mid=(L+R)>>1;

		if(Check(Mid)){

			Ans=Mid;

			R=Mid-1;

		}else{

			L=Mid+1;

		}

	}

	return Ans;

}



int main(){

	

	scanf("%d",&N);

	

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

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

	}

	

	printf("%d\n",BS(1,2*N-1));

	

	return 0;

	

} 

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

using namespace std;

int a[200005],n;

bool b[200005];

bool pd(int x){for(int i=1;i<=n*2-1;i++) b[i]=(a[i]>=x);b[0]=b[1];

	for(int i=n;i<=n+n;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];}

}

int main(){

cin>>n;

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

int l=1,r=n*2,A=0,md;

while(l<=r){md=(l+r)/2;if(pd(md))l=md+1,A=md;else r=md-1;}cout<<A;}

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

using namespace std;

const int MAXN=3e5+5;

int N;

int A[MAXN];



bool Check(int Key){

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

		if( (A[N+i]>Key && A[N+i+1]>Key) || (A[N-i]>Key && A[N-i-1]>Key) ){

			return 0;

		}

		if( (A[N+i]<=Key && A[N+i+1]<=Key) || (A[N-i]<=Key && A[N-i-1]<=Key) ){

			return 1;

		}

	}

	return A[1]<=Key;

}



int BS(int L,int R){

	int Ans=0;

	while(L<=R){

		int Mid=(L+R)>>1;

		if(Check(Mid)){

			Ans=Mid;

			R=Mid-1;

		}else{

			L=Mid+1;

		}

	}

	return Ans;

}



int main(){

	

	scanf("%d",&N);

	

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

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

	}

	

	printf("%d\n",BS(1,2*N-1));

	

	return 0;

	

} 

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

#define rg register int

#define il inline

#define mid ((l+r)>>1)

#define  big(i,j)  (a[n+i]>x&&a[n+i+j]>x)

#define sma(i,j) (a[n+i]<=x&&a[n+i+j]<=x)

#define el else if

using namespace std;

il long long read(){

    register long long x=0,f=1;

    register char ch=getchar();

    while(ch>'9'||ch<'0'){

        if(ch=='-') f=-1;

        ch=getchar();

    }

    while(ch<='9'&&ch>='0'){

        x=10*x+ch-'0';

        ch=getchar();

    }

    return x*f;

}

const int N=1000007;

typedef long long ll;

ll n,m,w,a[N];

bool chk(int x){

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

		if(big(i,1)||big(-i,-1))return false;

		el(sma(i,1)||sma(-i,-1)) return true;

	}

	return a[1]<=x;

}

int main()

{

	n=read();

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

		a[i]=read();

	}

	ll l=1,r=n<<1;--r;

	while(l<r){//r为答案 

		if(chk(mid)) r=mid;

		else l=mid+1;

	}

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

	return 0;

}

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

using namespace std;

const int MAXN=3e5+5;

int N;

int A[MAXN];



bool Check(int Key){

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

		if( (A[N+i]>Key && A[N+i+1]>Key) || (A[N-i]>Key && A[N-i-1]>Key) ){

			return 0;

		}

		if( (A[N+i]<=Key && A[N+i+1]<=Key) || (A[N-i]<=Key && A[N-i-1]<=Key) ){

			return 1;

		}

	}

	return A[1]<=Key;

}



int BS(int L,int R){

	int Ans=0;

	while(L<=R){

		int Mid=(L+R)>>1;

		if(Check(Mid)){

			Ans=Mid;

			R=Mid-1;

		}else{

			L=Mid+1;

		}

	}

	return Ans;

}



int main(){

	

	scanf("%d",&N);

	

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

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

	}

	

	printf("%d\n",BS(1,2*N-1));

	

	return 0;

	

} 

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

using namespace std;

int a[200005],n,b[200005],i;

int P(int x){for(i=1;i<=n*2-1;i++)b[i]=(a[i]>=x);b[0]=b[1];

for(i=n;i<=n+n;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];}}

int main(){

cin>>n;for(i=1;i<=n*2-1;i++)cin>>a[i];

int l=1,r=n*2,A=0,M;

while(l<=r){M=(l+r)/2;if(P(M))l=M+1,A=M;else r=M-1;}cout<<A;}

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

using namespace std;

const int MAXN=3e5+5;

int N;

int A[MAXN];



bool Check(int Key){

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

		if( (A[N+i]>Key && A[N+i+1]>Key) || (A[N-i]>Key && A[N-i-1]>Key) ){

			return 0;

		}

		if( (A[N+i]<=Key && A[N+i+1]<=Key) || (A[N-i]<=Key && A[N-i-1]<=Key) ){

			return 1;

		}

	}

	return A[1]<=Key;

}



int BS(int L,int R){

	int Ans=0;

	while(L<=R){

		int Mid=(L+R)>>1;

		if(Check(Mid)){

			Ans=Mid;

			R=Mid-1;

		}else{

			L=Mid+1;

		}

	}

	return Ans;

}



int main(){

	

	scanf("%d",&N);

	

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

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

	}

	

	printf("%d\n",BS(1,2*N-1));

	

	return 0;

	

} 

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

using namespace std;

const int N=500005;

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

int work(int x)

{

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

	{

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

		else b[i]=0;

	}

	for(int i=1;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 (n&1)^b[n]^1;

}

int main()

{

	scanf("%d",&n);

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

	{

		scanf("%d",a+i);

	}

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

	while(l<=r)

	{

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

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

		else r=mid-1;

	}

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

	return 0;

}

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

using namespace std;

const int MAXN=3e5+5;

int N;

int A[MAXN];



bool Check(int Key){

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

		if( (A[N+i]>Key && A[N+i+1]>Key) || (A[N-i]>Key && A[N-i-1]>Key) ){

			return 0;

		}

		if( (A[N+i]<=Key && A[N+i+1]<=Key) || (A[N-i]<=Key && A[N-i-1]<=Key) ){

			return 1;

		}

	}

	return A[1]<=Key;

}



int BS(int L,int R){

	int Ans=0;

	while(L<=R){

		int Mid=(L+R)>>1;

		if(Check(Mid)){

			Ans=Mid;

			R=Mid-1;

		}else{

			L=Mid+1;

		}

	}

	return Ans;

}



int main(){

	

	scanf("%d",&N);

	

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

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

	}

	

	printf("%d\n",BS(1,2*N-1));

	

	return 0;

	

} 

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

using namespace std;

const int maxn=200003;

int n,a[maxn];

bool b[maxn];

#define v(i) (a[i]>=x)

bool check(int x){

	int mid=(n+1)>>1,ans=maxn,ret=-1;

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

		for(;j<=n&&v(i)==v(j);j++);

		if(i+1==j)continue;

		int tmp=min(abs(mid-i),abs(j-1-mid));

		if(tmp<ans)ans=tmp,ret=v(i);

	}

	return ~ret?ret:v(1);

}

int main(){

	scanf("%d",&n);

	n=(n<<1)-1;

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

	int l=1,r=n,mid,ans=-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;

}

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

using namespace std;

const int MAXN=3e5+5;

int N;

int A[MAXN];



bool Check(int Key){

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

		if( (A[N+i]>Key && A[N+i+1]>Key) || (A[N-i]>Key && A[N-i-1]>Key) ){

			return 0;

		}

		if( (A[N+i]<=Key && A[N+i+1]<=Key) || (A[N-i]<=Key && A[N-i-1]<=Key) ){

			return 1;

		}

	}

	return A[1]<=Key;

}



int BS(int L,int R){

	int Ans=0;

	while(L<=R){

		int Mid=(L+R)>>1;

		if(Check(Mid)){

			Ans=Mid;

			R=Mid-1;

		}else{

			L=Mid+1;

		}

	}

	return Ans;

}



int main(){

	

	scanf("%d",&N);

	

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

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

	}

	

	printf("%d\n",BS(1,2*N-1));

	

	return 0;

	

} 

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

using namespace std;

const int maxn=2e5+10;

int a[maxn],n,m;

bool check(int mid)

{

	int mi=1e9,j=-1;

	for(int i=m-1;i>=1;i--)

	{

		int a1=a[i]>=mid,a2=a[i+1]>=mid;

		if(a1==a2)

		{

			mi=m-i-1;

			j=a1;

			break;

		}

	}

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

	{

		int a1=a[i]>=mid,a2=a[i+1]>=mid;

		if(a1==a2)

		{

			if(mi>i-m)

			{

				mi=i-m;

				j=a1;

			}

			break;

		}

	}

	if(j==-1)return a[1]>=mid;

	else return j;

}

int main()

{

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

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

	int l=2e9,r=0;

	scanf("%d",&m);

	n=m*2-1;

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

		scanf("%d",a+i),l=min(l,a[i]),r=max(a[i],r);

	while(l<=r)

	{

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

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

		else r=mid-1;

	}

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

	return 0;

}

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

using namespace std;

const int MAXN=3e5+5;

int N;

int A[MAXN];



bool Check(int Key){

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

		if( (A[N+i]>Key && A[N+i+1]>Key) || (A[N-i]>Key && A[N-i-1]>Key) ){

			return 0;

		}

		if( (A[N+i]<=Key && A[N+i+1]<=Key) || (A[N-i]<=Key && A[N-i-1]<=Key) ){

			return 1;

		}

	}

	return A[1]<=Key;

}



int BS(int L,int R){

	int Ans=0;

	while(L<=R){

		int Mid=(L+R)>>1;

		if(Check(Mid)){

			Ans=Mid;

			R=Mid-1;

		}else{

			L=Mid+1;

		}

	}

	return Ans;

}



int main(){

	

	scanf("%d",&N);

	

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

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

	}

	

	printf("%d\n",BS(1,2*N-1));

	

	return 0;

	

} 

// Fastest known solution for this problem: