stablegradients/pie-gem5-pairs huggingface dataset:
// 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.151632802120701x):
#include <stdio.h>



const int N = 1e5;



int n;

int a[N << 1 | 1], b[N << 1 | 1];



bool check(int t);



int main() {

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

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

	scanf("%d", &n);

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

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

	while (l < r) {

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

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

		else r = mid;

	}

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

	return 0;

}



bool check(int t) {

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

	for (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];

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

#define N 500005

using namespace std;



inline void rd(int &x){

	x=0;char ch=0;int w=0;

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

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

	x=w?-x:x;

}



int l,r;

int n,m;

int a[N],b[N];



bool ok(int x){

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

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

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

		if((b[n-i] and b[n-i-1]) or (b[n+i] and b[n+i+1])) return 1;

		if((!b[n-i] and !b[n-i-1]) or (!b[n+i] and !b[n+i+1])) return 0;

	}

	return b[1];

}

signed main(){

	rd(n);m=n*2-1;l=1;r=m+1;

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

	while(l<r){

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

		ok(mid) ? l=mid+1 : r=mid;

	}

	cout<<l-1<<endl;

}


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



const int N = 1e5;



int n;

int a[N << 1 | 1], b[N << 1 | 1];



bool check(int t);



int main() {

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

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

	scanf("%d", &n);

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

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

	while (l < r) {

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

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

		else r = mid;

	}

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

	return 0;

}



bool check(int t) {

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

	for (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];

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



using namespace std; 

int N,a[200001];

bool b[200001];

bool check(int x)

{ 	

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

		for(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(){ 

	 scanf("%d",&N);

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

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

		int l=1,r=(N<<1)-1,m;

	while(l<r)

	   if(check(m=l+r>>1))r=m;

	   else 

	   	l=m+1; 

	   	printf("%d",l); 

}


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



const int N = 1e5;



int n;

int a[N << 1 | 1], b[N << 1 | 1];



bool check(int t);



int main() {

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

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

	scanf("%d", &n);

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

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

	while (l < r) {

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

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

		else r = mid;

	}

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

	return 0;

}



bool check(int t) {

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

	for (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];

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

#include<cmath>

#include<stack>

#include<queue>

#include<cstdio>

#include<vector>

#include<cstring>

#include<iostream>

#include<algorithm>

using namespace std;

typedef long long ll;

template<class Read>void in(Read &x){

    x=0;

    int f=0;

    char ch=getchar();

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

        f|=(ch=='-');

        ch=getchar();

    }

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

        x=(x<<1)+(x<<3)+(ch^48);

        ch=getchar();

    }

    x=f?-x:x;

    return;

}

int n,a[200005],l=1,r=(n*2-1),ans;

bool check(int x){

	for(int i=0;i<=n-2;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;

	}

	if(a[1]>x)return 0;

	else return 1;

}

int main(){

	in(n);

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

	r=n*2-1;

	while(l<=r){

		int mid=(l+r)/2;

		if(check(mid))ans=mid,r=mid-1;

		else l=mid+1;

	}

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

	return 0;

}

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



const int N = 1e5;



int n;

int a[N << 1 | 1], b[N << 1 | 1];



bool check(int t);



int main() {

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

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

	scanf("%d", &n);

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

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

	while (l < r) {

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

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

		else r = mid;

	}

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

	return 0;

}



bool check(int t) {

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

	for (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];

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

#define reg register



const int maxn = 2e5 + 5; //!



int N;

int A[maxn];

int B[maxn];



bool chk(int x){

        for(reg int i = 1; i <= 2*N-1; i ++) B[i] = (A[i]>x);

        for(reg int d = 1; d < N; d ++)

                if((B[N+d-1]&&B[N+d]) || (B[N-d+1]&&B[N-d])) return 1;

                else if(((!B[N+d-1])&&(!B[N+d])) || ((!B[N-d+1])&&(!B[N-d]))) return 0;

        return B[1];

}



int main(){

        scanf("%d", &N);

        for(reg int i = 1; i <= 2*N-1; i ++) scanf("%d", &A[i]);

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

        while(l < r){

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

                int mid = l+r >> 1;

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

                else r = mid;

        }

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

        return 0;

}

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



const int N = 1e5;



int n;

int a[N << 1 | 1], b[N << 1 | 1];



bool check(int t);



int main() {

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

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

	scanf("%d", &n);

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

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

	while (l < r) {

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

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

		else r = mid;

	}

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

	return 0;

}



bool check(int t) {

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

	for (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];

}
// 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.16907770525239x):
#include<stdio.h>

const int maxn=1000005;

int i,j,k,m,n,l,r;

int a[maxn];

int check(int x){

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

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

			return 1;

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

			return 0;

	}

	return a[1]<=x;

}

int main(){

	scanf("%d",&n);

	m=(n<<1)-1;

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

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

	l=0,r=m+1;

	while(l+1<r){

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

		if(check(mid))

			r=mid;

		else l=mid;

	}

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

	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.203600197490672x):
#include<stdio.h>

const int maxn=1000005;

int i,j,k,m,n,l,r;

int a[maxn];

int check(int x){

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

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

			return 1;

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

			return 0;

	}

	return a[1]<=x;

}

int main(){

	scanf("%d",&n);

	m=(n<<1)-1;

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

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

	l=0,r=m+1;

	while(l+1<r){

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

		if(check(mid))

			r=mid;

		else l=mid;

	}

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

	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.203600197490672x):
#include<stdio.h>

const int maxn=1000005;

int i,j,k,m,n,l,r;

int a[maxn];

int check(int x){

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

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

			return 1;

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

			return 0;

	}

	return a[1]<=x;

}

int main(){

	scanf("%d",&n);

	m=(n<<1)-1;

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

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

	l=0,r=m+1;

	while(l+1<r){

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

		if(check(mid))

			r=mid;

		else l=mid;

	}

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

	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.166569117358659x):
#include<stdio.h>

const int maxn=1000005;

int i,j,k,m,n,l,r;

int a[maxn];

int check(int x){

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

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

			return 1;

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

			return 0;

	}

	return a[1]<=x;

}

int main(){

	scanf("%d",&n);

	m=(n<<1)-1;

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

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

	l=0,r=m+1;

	while(l+1<r){

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

		if(check(mid))

			r=mid;

		else l=mid;

	}

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

	return 0;

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

#define N 500005

using namespace std;



inline void rd(int &x){

	x=0;char ch=0;int w=0;

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

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

	x=w?-x:x;

}



int l,r;

int n,m;

int a[N],b[N];



bool ok(int x){

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

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

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

		if((b[n-i] and b[n-i-1]) or (b[n+i] and b[n+i+1])) return 1;

		if((!b[n-i] and !b[n-i-1]) or (!b[n+i] and !b[n+i+1])) return 0;

	}

	return b[1];

}

signed main(){

	rd(n);m=n*2-1;l=1;r=m+1;

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

	while(l<r){

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

		ok(mid) ? l=mid+1 : r=mid;

	}

	cout<<l-1<<endl;

}


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

const int maxn=1000005;

int i,j,k,m,n,l,r;

int a[maxn];

int check(int x){

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

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

			return 1;

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

			return 0;

	}

	return a[1]<=x;

}

int main(){

	scanf("%d",&n);

	m=(n<<1)-1;

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

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

	l=0,r=m+1;

	while(l+1<r){

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

		if(check(mid))

			r=mid;

		else l=mid;

	}

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

	return 0;

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



using namespace std; 

int N,a[200001];

bool b[200001];

bool check(int x)

{ 	

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

		for(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(){ 

	 scanf("%d",&N);

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

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

		int l=1,r=(N<<1)-1,m;

	while(l<r)

	   if(check(m=l+r>>1))r=m;

	   else 

	   	l=m+1; 

	   	printf("%d",l); 

}


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

const int maxn=1000005;

int i,j,k,m,n,l,r;

int a[maxn];

int check(int x){

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

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

			return 1;

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

			return 0;

	}

	return a[1]<=x;

}

int main(){

	scanf("%d",&n);

	m=(n<<1)-1;

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

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

	l=0,r=m+1;

	while(l+1<r){

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

		if(check(mid))

			r=mid;

		else l=mid;

	}

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

	return 0;

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

#include<cmath>

#include<stack>

#include<queue>

#include<cstdio>

#include<vector>

#include<cstring>

#include<iostream>

#include<algorithm>

using namespace std;

typedef long long ll;

template<class Read>void in(Read &x){

    x=0;

    int f=0;

    char ch=getchar();

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

        f|=(ch=='-');

        ch=getchar();

    }

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

        x=(x<<1)+(x<<3)+(ch^48);

        ch=getchar();

    }

    x=f?-x:x;

    return;

}

int n,a[200005],l=1,r=(n*2-1),ans;

bool check(int x){

	for(int i=0;i<=n-2;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;

	}

	if(a[1]>x)return 0;

	else return 1;

}

int main(){

	in(n);

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

	r=n*2-1;

	while(l<=r){

		int mid=(l+r)/2;

		if(check(mid))ans=mid,r=mid-1;

		else l=mid+1;

	}

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

	return 0;

}

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

const int maxn=1000005;

int i,j,k,m,n,l,r;

int a[maxn];

int check(int x){

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

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

			return 1;

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

			return 0;

	}

	return a[1]<=x;

}

int main(){

	scanf("%d",&n);

	m=(n<<1)-1;

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

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

	l=0,r=m+1;

	while(l+1<r){

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

		if(check(mid))

			r=mid;

		else l=mid;

	}

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

	return 0;

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

#define reg register



const int maxn = 2e5 + 5; //!



int N;

int A[maxn];

int B[maxn];



bool chk(int x){

        for(reg int i = 1; i <= 2*N-1; i ++) B[i] = (A[i]>x);

        for(reg int d = 1; d < N; d ++)

                if((B[N+d-1]&&B[N+d]) || (B[N-d+1]&&B[N-d])) return 1;

                else if(((!B[N+d-1])&&(!B[N+d])) || ((!B[N-d+1])&&(!B[N-d]))) return 0;

        return B[1];

}



int main(){

        scanf("%d", &N);

        for(reg int i = 1; i <= 2*N-1; i ++) scanf("%d", &A[i]);

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

        while(l < r){

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

                int mid = l+r >> 1;

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

                else r = mid;

        }

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

        return 0;

}

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

const int maxn=1000005;

int i,j,k,m,n,l,r;

int a[maxn];

int check(int x){

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

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

			return 1;

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

			return 0;

	}

	return a[1]<=x;

}

int main(){

	scanf("%d",&n);

	m=(n<<1)-1;

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

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

	l=0,r=m+1;

	while(l+1<r){

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

		if(check(mid))

			r=mid;

		else l=mid;

	}

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

	return 0;

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

#include <cstdio>

#include <iostream>

using namespace std;

int read();



int N, x[200005], st[200005], a[200005];

int work() {

    int m = N / 2 + 1, res = a[m], l = m, r = m;

    a[0] = a[1], a[N + 1] = a[N];

    for (; l >= 1 && a[l] != a[l - 1] && a[r] != a[r + 1]; --l, ++r) res ^= 1;

    return res;

}



int main() {



    N = read() * 2 - 1;

    for (int i = 1; i <= N; ++i) st[i] = x[i] = read();

    sort(st + 1, st + 1 + N);

    int l = 1, r = N, res = r;

    while (l <= r) {

        int mid = l + r >> 1;

        for (int i = 1; i <= N; ++i) a[i] = x[i] > st[mid];

        if (!work())

            r = mid - 1, res = mid;

        else

            l = mid + 1;

    }

    printf("%d\n", st[res]);

    return 0;

}

int read() {

    int x = 0, f = 1;

    char c = getchar();

    while (!isdigit(c)) f = (c == '-') ? -1 : f, c = getchar();

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

    return x * f;

}

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

const int maxn=1000005;

int i,j,k,m,n,l,r;

int a[maxn];

int check(int x){

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

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

			return 1;

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

			return 0;

	}

	return a[1]<=x;

}

int main(){

	scanf("%d",&n);

	m=(n<<1)-1;

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

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

	l=0,r=m+1;

	while(l+1<r){

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

		if(check(mid))

			r=mid;

		else l=mid;

	}

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

	return 0;

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

using namespace std;

int a[400005],n;

int small(int i,int k)

{

	return a[i+1]<=k&&a[i]<=k;//  

}

int big(int i,int k)

{

	return a[i+1]>k&&a[i]>k;

}

int check(int k)

{

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

	{

		if(small(n+i,k)==1||small(n-i-1,k)==1)

		{

			return 1;

		}

		if(big(n+i,k)==1||big(n-i-1,k)==1)

		{

			return 0;

		}

	}

	if(a[1]<=k)

	{

		return 1;

	}else

	{

		return 0;

	}

}

int main()

{

	scanf("%d",&n);

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

	{

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

	}

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

	while(l<r)

	{

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

		if(check(mid)==1)

		{

			r=mid;

		}else

		{

			l=mid+1;

		}

	}

	cout<<r;

	return 0;

}

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

const int maxn=1000005;

int i,j,k,m,n,l,r;

int a[maxn];

int check(int x){

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

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

			return 1;

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

			return 0;

	}

	return a[1]<=x;

}

int main(){

	scanf("%d",&n);

	m=(n<<1)-1;

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

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

	l=0,r=m+1;

	while(l+1<r){

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

		if(check(mid))

			r=mid;

		else l=mid;

	}

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

	return 0;

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

using namespace std;

int a[200005],n,b[200005],i,l,A,M,r=200005;

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

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

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

const int maxn=1000005;

int i,j,k,m,n,l,r;

int a[maxn];

int check(int x){

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

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

			return 1;

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

			return 0;

	}

	return a[1]<=x;

}

int main(){

	scanf("%d",&n);

	m=(n<<1)-1;

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

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

	l=0,r=m+1;

	while(l+1<r){

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

		if(check(mid))

			r=mid;

		else l=mid;

	}

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

	return 0;

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

int a[200005],n,b[200005],i,l,A,M,r=200005;

int P(int x){for(i=1;i<n*2;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(){std::cin>>n;for(i=1;i<n*2;i++)std::cin>>a[i];

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

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

const int maxn=1000005;

int i,j,k,m,n,l,r;

int a[maxn];

int check(int x){

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

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

			return 1;

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

			return 0;

	}

	return a[1]<=x;

}

int main(){

	scanf("%d",&n);

	m=(n<<1)-1;

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

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

	l=0,r=m+1;

	while(l+1<r){

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

		if(check(mid))

			r=mid;

		else l=mid;

	}

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

	return 0;

}