stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
/*

ID:xmydada1

LANG:C++

TASK:

*/

#include<bits/stdc++.h>

#define reg register



using namespace std;

const int N=2e5+7;

int m,n,ans=0,sum=0,p,q;

int a[N],b[N];

inline int read() {

reg int s = 0, t = 0; reg char ch = getchar();

while(ch > '9' || ch < '0') t |= ch == '-', ch = getchar();

while(ch >= '0' && ch <= '9') s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();

return t ? -s : s;

}



inline void print(reg long long x) {

if(x < 0) putchar('-'), x = -x;

if(x > 9) print(x / 10);

putchar(x % 10 + 48);

}

int main()

{

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

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

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

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

	int l=0,r=1e9+7;

	while(l<=r)

	{

		int mid=l+r>>1;

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

		{  

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

			else b[i]=0;

		}

		b[n+1]=b[n];

		b[0]=b[1];

		p=0;

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

		{

			if(b[i-1]!=b[i]){p++;}

			if(b[i-1]==b[i]&&p)

			{

				if(p%2==0)for(int j=i-p;j<=i-1;j++)b[j]=b[i];

				else 

				{

					q=p>>1;

					for(int j=i-p;j<=i-q-2;j++)b[j]=b[i-p-1];

					for(int j=i-q-1;j<=i-1;j++)b[j]=b[i];	

				}

				p=0;

			}

		}

		

		if(b[n/2+1]){l=mid+1;}

		else {r=mid-1;ans=mid;}

		memset(b,0,sizeof(b));

	}

	printf("%d",ans);



return 0;

}




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

#include <cstdio>

#include <algorithm>

#define N 1000006



using namespace std;



int n;

int a[N], b[N];



bool check(int);



int main(){

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

	int l = 999999999, r = 0, ans;

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

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

	while(l <= r){

		int mid = l + r >> 1;

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

		else r = mid - 1;	

	//	cout << ans << endl;

	}

	cout << ans << endl;

	return 0;

}



bool check(int x){

	int cnt1 = 0, cnt2 = 0;

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

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

		else b[i] = 0, ++cnt2;

	b[0] = -1;b[n + 1] = -1;

	int pos = n / 2 + 1, tmp1 = 0, tmp2 = 0;

	while(b[pos + tmp1 + 1] != b[pos + tmp1] && pos + tmp1 <= n) ++tmp1;

	while(b[pos - tmp2 - 1] != b[pos - tmp2] && pos - tmp2 >= 1) ++tmp2;

//	cout << x << endl;for(int i = 1; i <= n; ++i) cout << b[i] << ' ';cout << endl;cout << tmp1 << ' ' << tmp2 << endl;

	if(tmp1 == tmp2){

		if(pos - tmp2 == 0)

			return cnt1 > cnt2;	

		else return b[pos - tmp1];

	}

	else{

		if(tmp1 < tmp2) return b[pos + tmp1];

		else return b[pos - tmp2];

	}

}
// Slower C++ solution:
/*

ID:xmydada1

LANG:C++

TASK:

*/

#include<bits/stdc++.h>

#define reg register



using namespace std;

const int N=2e5+7;

int m,n,ans=0,sum=0,p,q;

int a[N],b[N];

inline int read() {

reg int s = 0, t = 0; reg char ch = getchar();

while(ch > '9' || ch < '0') t |= ch == '-', ch = getchar();

while(ch >= '0' && ch <= '9') s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();

return t ? -s : s;

}



inline void print(reg long long x) {

if(x < 0) putchar('-'), x = -x;

if(x > 9) print(x / 10);

putchar(x % 10 + 48);

}

int main()

{

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

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

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

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

	int l=0,r=1e9+7;

	while(l<=r)

	{

		int mid=l+r>>1;

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

		{  

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

			else b[i]=0;

		}

		b[n+1]=b[n];

		b[0]=b[1];

		p=0;

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

		{

			if(b[i-1]!=b[i]){p++;}

			if(b[i-1]==b[i]&&p)

			{

				if(p%2==0)for(int j=i-p;j<=i-1;j++)b[j]=b[i];

				else 

				{

					q=p>>1;

					for(int j=i-p;j<=i-q-2;j++)b[j]=b[i-p-1];

					for(int j=i-q-1;j<=i-1;j++)b[j]=b[i];	

				}

				p=0;

			}

		}

		

		if(b[n/2+1]){l=mid+1;}

		else {r=mid-1;ans=mid;}

		memset(b,0,sizeof(b));

	}

	printf("%d",ans);



return 0;

}




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

#include<cstdio>

#include<algorithm>

#include<cstring>

using namespace std;

int n,s;

int a[200200];

int t[200200];

bool check(int x)

{

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

		if(a[i]<=x)t[i]=0;

		else t[i]=1;

	int fl=0;

	int d0=s,d1=s;

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

	{

		int c=0,dis=abs(n-i);

		for(;t[i+c+1]==t[i]&&i+c+1<=s;c++)dis=min(dis,abs(n-(i+c+1)));

		if(c>=1)

		{

			fl=1;

			if(t[i]==0)d0=min(d0,dis);

			else d1=min(d1,dis);

		}

		i=i+c;

	}

	if(!fl)return t[1];

	if(d0<d1)return 0;

	else return 1;

}

int main()

{

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

	int l=0,r=0,mid;

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

	while(l<=r)

	{

		mid=(l+r)/2;

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

		else r=mid-1;

	}

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

	return 0;

}
// Slower C++ solution:
/*

ID:xmydada1

LANG:C++

TASK:

*/

#include<bits/stdc++.h>

#define reg register



using namespace std;

const int N=2e5+7;

int m,n,ans=0,sum=0,p,q;

int a[N],b[N];

inline int read() {

reg int s = 0, t = 0; reg char ch = getchar();

while(ch > '9' || ch < '0') t |= ch == '-', ch = getchar();

while(ch >= '0' && ch <= '9') s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();

return t ? -s : s;

}



inline void print(reg long long x) {

if(x < 0) putchar('-'), x = -x;

if(x > 9) print(x / 10);

putchar(x % 10 + 48);

}

int main()

{

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

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

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

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

	int l=0,r=1e9+7;

	while(l<=r)

	{

		int mid=l+r>>1;

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

		{  

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

			else b[i]=0;

		}

		b[n+1]=b[n];

		b[0]=b[1];

		p=0;

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

		{

			if(b[i-1]!=b[i]){p++;}

			if(b[i-1]==b[i]&&p)

			{

				if(p%2==0)for(int j=i-p;j<=i-1;j++)b[j]=b[i];

				else 

				{

					q=p>>1;

					for(int j=i-p;j<=i-q-2;j++)b[j]=b[i-p-1];

					for(int j=i-q-1;j<=i-1;j++)b[j]=b[i];	

				}

				p=0;

			}

		}

		

		if(b[n/2+1]){l=mid+1;}

		else {r=mid-1;ans=mid;}

		memset(b,0,sizeof(b));

	}

	printf("%d",ans);



return 0;

}




// Faster C++ solution for the same problem (measured speedup: 4.374032314643244x):
#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);

}
// Slower C++ solution:
/*

ID:xmydada1

LANG:C++

TASK:

*/

#include<bits/stdc++.h>

#define reg register



using namespace std;

const int N=2e5+7;

int m,n,ans=0,sum=0,p,q;

int a[N],b[N];

inline int read() {

reg int s = 0, t = 0; reg char ch = getchar();

while(ch > '9' || ch < '0') t |= ch == '-', ch = getchar();

while(ch >= '0' && ch <= '9') s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();

return t ? -s : s;

}



inline void print(reg long long x) {

if(x < 0) putchar('-'), x = -x;

if(x > 9) print(x / 10);

putchar(x % 10 + 48);

}

int main()

{

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

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

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

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

	int l=0,r=1e9+7;

	while(l<=r)

	{

		int mid=l+r>>1;

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

		{  

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

			else b[i]=0;

		}

		b[n+1]=b[n];

		b[0]=b[1];

		p=0;

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

		{

			if(b[i-1]!=b[i]){p++;}

			if(b[i-1]==b[i]&&p)

			{

				if(p%2==0)for(int j=i-p;j<=i-1;j++)b[j]=b[i];

				else 

				{

					q=p>>1;

					for(int j=i-p;j<=i-q-2;j++)b[j]=b[i-p-1];

					for(int j=i-q-1;j<=i-1;j++)b[j]=b[i];	

				}

				p=0;

			}

		}

		

		if(b[n/2+1]){l=mid+1;}

		else {r=mid-1;ans=mid;}

		memset(b,0,sizeof(b));

	}

	printf("%d",ans);



return 0;

}




// Faster C++ solution for the same problem (measured speedup: 4.371967064082247x):
#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

*/
// Slower C++ solution:
/*

ID:xmydada1

LANG:C++

TASK:

*/

#include<bits/stdc++.h>

#define reg register



using namespace std;

const int N=2e5+7;

int m,n,ans=0,sum=0,p,q;

int a[N],b[N];

inline int read() {

reg int s = 0, t = 0; reg char ch = getchar();

while(ch > '9' || ch < '0') t |= ch == '-', ch = getchar();

while(ch >= '0' && ch <= '9') s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();

return t ? -s : s;

}



inline void print(reg long long x) {

if(x < 0) putchar('-'), x = -x;

if(x > 9) print(x / 10);

putchar(x % 10 + 48);

}

int main()

{

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

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

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

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

	int l=0,r=1e9+7;

	while(l<=r)

	{

		int mid=l+r>>1;

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

		{  

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

			else b[i]=0;

		}

		b[n+1]=b[n];

		b[0]=b[1];

		p=0;

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

		{

			if(b[i-1]!=b[i]){p++;}

			if(b[i-1]==b[i]&&p)

			{

				if(p%2==0)for(int j=i-p;j<=i-1;j++)b[j]=b[i];

				else 

				{

					q=p>>1;

					for(int j=i-p;j<=i-q-2;j++)b[j]=b[i-p-1];

					for(int j=i-q-1;j<=i-1;j++)b[j]=b[i];	

				}

				p=0;

			}

		}

		

		if(b[n/2+1]){l=mid+1;}

		else {r=mid-1;ans=mid;}

		memset(b,0,sizeof(b));

	}

	printf("%d",ans);



return 0;

}




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

using namespace std;

int n;

int a[200005];

int now[200005];

//bool check(int x){

//	int k,ans[2];

//	ans[0]=0;	ans[1]=0;

//	for(k=1;k<n+n;k++)	now[k]=a[k]>=x;



//	for(k=n-2;k>0;k--)		if(now[k]==now[k+1]){ans[now[k]]=n-k;break;}

//	for(k=n+2;k<n+n;k++)	if(now[k]==now[k-1]){ans[now[k]]=k-n;break;}

//	if(ans[0]&&ans[1])	return ans[0]<ans[1];

//	if(ans[1])	return 1;

//	if(ans[0])	return 0;

//	if(ans[0]==0&&ans[1]==0)	return now[1];	

//}

inline bool check(int x){

	int k;

	for(k=1;k<n+n;k++)	now[k]=a[k]>=x;

	if(now[n]==now[n-1]||now[n]==now[n+1])	return now[n];    

    for(k=1;k<n-1;k++){

        if((now[n+k]&&now[n+k+1])||(now[n-k]&&now[n-k-1]))return 1;

        if(!(now[n+k]||now[n+k+1])||!(now[n-k]||now[n-k-1]))return 0;

    }

    return now[1];

}

int main(){

	int k;

	cin>>n;

	for(k=1;k<=n+n-1;k++)	cin>>a[k];

	int l=1,r=n+n-1,mid;

	while(l<r){

		mid=l+r+1>>1;

		if(check(mid))	l=mid;

		else			r=mid-1;

	}

	cout<<r<<endl;

	return 0;

}
// Slower C++ solution:
/*

ID:xmydada1

LANG:C++

TASK:

*/

#include<bits/stdc++.h>

#define reg register



using namespace std;

const int N=2e5+7;

int m,n,ans=0,sum=0,p,q;

int a[N],b[N];

inline int read() {

reg int s = 0, t = 0; reg char ch = getchar();

while(ch > '9' || ch < '0') t |= ch == '-', ch = getchar();

while(ch >= '0' && ch <= '9') s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();

return t ? -s : s;

}



inline void print(reg long long x) {

if(x < 0) putchar('-'), x = -x;

if(x > 9) print(x / 10);

putchar(x % 10 + 48);

}

int main()

{

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

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

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

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

	int l=0,r=1e9+7;

	while(l<=r)

	{

		int mid=l+r>>1;

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

		{  

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

			else b[i]=0;

		}

		b[n+1]=b[n];

		b[0]=b[1];

		p=0;

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

		{

			if(b[i-1]!=b[i]){p++;}

			if(b[i-1]==b[i]&&p)

			{

				if(p%2==0)for(int j=i-p;j<=i-1;j++)b[j]=b[i];

				else 

				{

					q=p>>1;

					for(int j=i-p;j<=i-q-2;j++)b[j]=b[i-p-1];

					for(int j=i-q-1;j<=i-1;j++)b[j]=b[i];	

				}

				p=0;

			}

		}

		

		if(b[n/2+1]){l=mid+1;}

		else {r=mid-1;ans=mid;}

		memset(b,0,sizeof(b));

	}

	printf("%d",ans);



return 0;

}




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

using namespace std;

int len;

int n;

int a[1010100];

int b[1010100];



bool check(int x){

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

    int Mid = (1+n)>>1;

    int le=Mid-1,ri=Mid+1;

    for (;le && ri<=n;le--,ri++)

      if (b[le] == b[le+1]) return b[le];

      else if (b[ri] == b[ri-1]) return b[ri];

    return b[1];

}



int main(){

    scanf("%d",&len);

    n = 2*len-1;

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

    int l = 0,r = 1e9;

    while (l+1<r){

	    int mid = l+r>>1;

	    if (check(mid)) l = mid;else r = mid;

	}

	printf("%d",check(l)?l:r);

	return 0;

}
// Slower C++ solution:
/*

ID:xmydada1

LANG:C++

TASK:

*/

#include<bits/stdc++.h>

#define reg register



using namespace std;

const int N=2e5+7;

int m,n,ans=0,sum=0,p,q;

int a[N],b[N];

inline int read() {

reg int s = 0, t = 0; reg char ch = getchar();

while(ch > '9' || ch < '0') t |= ch == '-', ch = getchar();

while(ch >= '0' && ch <= '9') s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();

return t ? -s : s;

}



inline void print(reg long long x) {

if(x < 0) putchar('-'), x = -x;

if(x > 9) print(x / 10);

putchar(x % 10 + 48);

}

int main()

{

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

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

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

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

	int l=0,r=1e9+7;

	while(l<=r)

	{

		int mid=l+r>>1;

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

		{  

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

			else b[i]=0;

		}

		b[n+1]=b[n];

		b[0]=b[1];

		p=0;

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

		{

			if(b[i-1]!=b[i]){p++;}

			if(b[i-1]==b[i]&&p)

			{

				if(p%2==0)for(int j=i-p;j<=i-1;j++)b[j]=b[i];

				else 

				{

					q=p>>1;

					for(int j=i-p;j<=i-q-2;j++)b[j]=b[i-p-1];

					for(int j=i-q-1;j<=i-1;j++)b[j]=b[i];	

				}

				p=0;

			}

		}

		

		if(b[n/2+1]){l=mid+1;}

		else {r=mid-1;ans=mid;}

		memset(b,0,sizeof(b));

	}

	printf("%d",ans);



return 0;

}




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

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

    return 0;

}
// Slower C++ solution:
/*

ID:xmydada1

LANG:C++

TASK:

*/

#include<bits/stdc++.h>

#define reg register



using namespace std;

const int N=2e5+7;

int m,n,ans=0,sum=0,p,q;

int a[N],b[N];

inline int read() {

reg int s = 0, t = 0; reg char ch = getchar();

while(ch > '9' || ch < '0') t |= ch == '-', ch = getchar();

while(ch >= '0' && ch <= '9') s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();

return t ? -s : s;

}



inline void print(reg long long x) {

if(x < 0) putchar('-'), x = -x;

if(x > 9) print(x / 10);

putchar(x % 10 + 48);

}

int main()

{

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

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

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

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

	int l=0,r=1e9+7;

	while(l<=r)

	{

		int mid=l+r>>1;

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

		{  

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

			else b[i]=0;

		}

		b[n+1]=b[n];

		b[0]=b[1];

		p=0;

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

		{

			if(b[i-1]!=b[i]){p++;}

			if(b[i-1]==b[i]&&p)

			{

				if(p%2==0)for(int j=i-p;j<=i-1;j++)b[j]=b[i];

				else 

				{

					q=p>>1;

					for(int j=i-p;j<=i-q-2;j++)b[j]=b[i-p-1];

					for(int j=i-q-1;j<=i-1;j++)b[j]=b[i];	

				}

				p=0;

			}

		}

		

		if(b[n/2+1]){l=mid+1;}

		else {r=mid-1;ans=mid;}

		memset(b,0,sizeof(b));

	}

	printf("%d",ans);



return 0;

}




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

#define rg register

#define LL long long 



using namespace std;



const int N=200010;

inline int read(){

	int x=0,f=1;char ch=getchar();

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

	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}

	return x*f;

}

int n,a[N];

int l,r,ans;

bool check(int mid){

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

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

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

	}

	return a[1]<=mid;

}

int main()

{

	n=read();

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

		a[i]=read();

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

	while(l<=r){

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

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

		else l=mid+1;

	}

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

	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.162473153561957x):
/************************************************

*Author        :  lrj124

*Created Time  :  2019.11.07.21:12

*Mail          :  1584634848@qq.com

*Problem       :  at2165

************************************************/

#include <cstdio>

const int maxn = 200000 + 10;

int n,l,r(maxn),x[maxn];

inline bool check(int mid) {

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

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

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

	}

	return x[1] <= mid;

}

int main() {

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

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

	scanf("%d",&n);

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

	for (int mid;l < r;mid = l+r>>1,check(mid) ? r = mid : l = mid+1);

	printf("%d",l);

	return 0;

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

#include<cstdio>

#include<cstdlib>

#include<cstring>

#include<cmath>

#include<algorithm>

#include<vector>

using namespace std;

#define ll long long

#define MAX 100100

inline int read()

{

	int x=0;bool t=false;char ch=getchar();

	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();

	if(ch=='-')t=true,ch=getchar();

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

	return t?-x:x;

}

int n,m;

int a[MAX<<1],b[MAX<<1];

bool check(int mid)

{

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

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

{

	n=read();m=n+n-1;

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

	int l=1,r=m,ret;

	while(l<=r)

	{

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

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

		else r=mid-1;

	}

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

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.145674387289342x):
/************************************************

*Author        :  lrj124

*Created Time  :  2019.11.07.21:12

*Mail          :  1584634848@qq.com

*Problem       :  at2165

************************************************/

#include <cstdio>

const int maxn = 200000 + 10;

int n,l,r(maxn),x[maxn];

inline bool check(int mid) {

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

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

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

	}

	return x[1] <= mid;

}

int main() {

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

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

	scanf("%d",&n);

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

	for (int mid;l < r;mid = l+r>>1,check(mid) ? r = mid : l = mid+1);

	printf("%d",l);

	return 0;

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

using namespace std;

int n,a[2000005];

inline bool check(int k)

{

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

    }

    if(a[1]<=k)

    	return true;

    else

    	return false;

}

int main()

{

	scanf("%d",&n);

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

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

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

    while(l<r)

	{

        int mid=(l+r)/2;

        if(check(mid))

			r=mid;

        else 

			l=mid+1;

    }

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

}

// Faster C++ solution for the same problem (measured speedup: 5.16321178056736x):
/************************************************

*Author        :  lrj124

*Created Time  :  2019.11.07.21:12

*Mail          :  1584634848@qq.com

*Problem       :  at2165

************************************************/

#include <cstdio>

const int maxn = 200000 + 10;

int n,l,r(maxn),x[maxn];

inline bool check(int mid) {

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

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

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

	}

	return x[1] <= mid;

}

int main() {

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

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

	scanf("%d",&n);

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

	for (int mid;l < r;mid = l+r>>1,check(mid) ? r = mid : l = mid+1);

	printf("%d",l);

	return 0;

}