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

#include <stdio.h>

#include <algorithm>



using namespace std;



int num[500005];

int vis[500005];

int t;



int abs1(int x)

{

   if (x>=0)

      return x;

   else

      return -x;

}

int check(int x)

{

   x%=2;

   if (x==0)

      return (vis[t]^1);

   else

      return vis[t];

}



int main()

{

cin>>t;

for (int a=1;a<=2*t-1;a++)

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

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

int mid;

int k;

while (l<=r)

{

   mid=(l+r)>>1;

   k=-1;

   for (int a=1;a<=2*t-1;a++)

      if (num[a]>=mid)

         vis[a]=1;

      else

         vis[a]=0;

   pair<int,int> flag1;

   pair<int,int> flag2;

   flag1.first=-1;

   flag2.first=-1;

   for (int a=t;a>=2;a--)

      if (vis[a]==vis[a-1])

      {

	     flag1.second=vis[a];

         flag1.first=a;

         break;

	  }

   for (int a=t;a<2*t-1;a++)

      if (vis[a]==vis[a+1])

      {

         flag2.second=vis[a];

         flag2.first=a;

         break;

	  }

   if (flag1.first!=-1||flag2.first!=-1)

   {

      if (abs1(flag1.first-t)>abs1(flag2.first-t))

         k=flag2.second;

      else

         k=flag1.second;

   }

   if (k==-1)

      k=check(t);

   if (k==0)

      r=mid-1;

   if (k==1)

      l=mid+1;

}

cout<<r;

	return 0;

}

// Optimized solution to the same problem (faster):
//

//  Median Pyramid Hard.cpp

//  National Olympiad in Informatics in Provinces

//

//  Created by 黄子齐 on 2019/10/5.

//  Copyright © 2019 黄子齐. All rights reserved.

//



#include <stdio.h>

const int N = 2e5+10;

int a[N], n;

bool b[N];

inline bool check(int mid) {

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

        b[i] = (!(a[i]<=mid));

    }

    for (int l=n-1, r=n+1; l>=1; l--, r++) {

        if (b[l] == b[l+1]) {

            return b[l];

        } else if (b[r] == b[r-1]) {

            return b[r];

        }

    }

    return b[1];

}

int main() {

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

    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;

}


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

#include<cmath>

#include<cstdio>

#include<stdlib.h>

#include<algorithm>

#include<cstring>

#include<vector>

#define MAXN 100005

using namespace std;

int a[2*MAXN],n;

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 ef(int l,int r)

{

	int mid;

	while(l<r)

	{

		mid=(l+r)>>1;

		if(check(mid))

			r=mid;

		else

			l=mid+1;

	}

	return l;

}

int main()

{

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

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

	scanf("%d",&n);

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

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

	printf("%d",ef(1,2*n-1));

    return 0;

}


// Optimized solution to the same problem (faster):
//

//  Median Pyramid Hard.cpp

//  National Olympiad in Informatics in Provinces

//

//  Created by 黄子齐 on 2019/10/5.

//  Copyright © 2019 黄子齐. All rights reserved.

//



#include <stdio.h>

const int N = 2e5+10;

int a[N], n;

bool b[N];

inline bool check(int mid) {

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

        b[i] = (!(a[i]<=mid));

    }

    for (int l=n-1, r=n+1; l>=1; l--, r++) {

        if (b[l] == b[l+1]) {

            return b[l];

        } else if (b[r] == b[r-1]) {

            return b[r];

        }

    }

    return b[1];

}

int main() {

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

    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;

}


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

using namespace std;

#define il inline

#define gc getchar()

#define mp make_pair

#define P pair<int,int>

#define ri register int

#define rb register bool

#define rc register char

#define t(i) edge[i].to

#define w(i) edge[i].wei

#define rp(i,x,y) for(ri i=x;i<=y;++i)

#define my(i,x,y) for(ri i=x;i>=y;--i)

#define e(i,x) for(ri i=head[x];i;i=edge[i].nxt)



const int N=2e5+10;

int n,a[N],l,r;

bool b[N];



il int read()

{

	rc ch=gc;ri x=0;rb y=1;

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

	if(ch=='-')ch=gc,y=0;

	while(ch>='0' && ch<='9')x=(x<<1)+(x<<3)+(ch^'0'),ch=gc;

	return y?x:-x;

}

il bool chck(){rp(i,2,n)if(b[i]==b[i-1])return 0;return 1;}

il bool check(ri dat)

{

	rp(i,1,n)b[i]=(a[i]>dat);ri mid=(n+1)>>1;if(chck())return b[1];

	rp(i,1,mid-1){if(b[mid+i]==b[mid+i-1])return b[mid+i];if(b[mid-i]==b[mid-i+1])return b[mid-i];}

}



int main()

{

	//freopen("2165.in","r",stdin);freopen("2165.out","w",stdout);

	n=r=read()*2-1;rp(i,1,n)a[i]=read();

	while(l<r){ri mid=(l+r)>>1;if(!check(mid))r=mid;else l=mid+1;}printf("%d",l);

	return 0;

}


// Optimized solution to the same problem (faster):
//

//  Median Pyramid Hard.cpp

//  National Olympiad in Informatics in Provinces

//

//  Created by 黄子齐 on 2019/10/5.

//  Copyright © 2019 黄子齐. All rights reserved.

//



#include <stdio.h>

const int N = 2e5+10;

int a[N], n;

bool b[N];

inline bool check(int mid) {

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

        b[i] = (!(a[i]<=mid));

    }

    for (int l=n-1, r=n+1; l>=1; l--, r++) {

        if (b[l] == b[l+1]) {

            return b[l];

        } else if (b[r] == b[r-1]) {

            return b[r];

        }

    }

    return b[1];

}

int main() {

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

    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;

}


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

#include<cstdio>

using namespace std;



inline int read(){

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

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

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

        ch=getchar();

    }

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

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

        ch=getchar();

    }

    return x*f;

}



int n,a[20000015];



int small(int i,int j,int k) {

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

}



int big(int i,int j,int k){

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

} 



int check(int k){

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

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

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

    }

    return small(1,1,k);

}



int main(){

    n=read();

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

        a[i]=read();

    }

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

    while(l<r){

        int mid=l+r>>1;

        if(check(mid)) {

            r=mid;

        }

        else l=mid+1;

    }

    cout<<r;

    return 0; 

}

// Optimized solution to the same problem (faster):
//

//  Median Pyramid Hard.cpp

//  National Olympiad in Informatics in Provinces

//

//  Created by 黄子齐 on 2019/10/5.

//  Copyright © 2019 黄子齐. All rights reserved.

//



#include <stdio.h>

const int N = 2e5+10;

int a[N], n;

bool b[N];

inline bool check(int mid) {

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

        b[i] = (!(a[i]<=mid));

    }

    for (int l=n-1, r=n+1; l>=1; l--, r++) {

        if (b[l] == b[l+1]) {

            return b[l];

        } else if (b[r] == b[r-1]) {

            return b[r];

        }

    }

    return b[1];

}

int main() {

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

    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;

}


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

}

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

#include<cstring>

#include<cctype>

#include<algorithm>

#define reg register

using namespace std;

const int N=2e5+5;

int n,a[N];

inline int read()

{

	int x=0,w=1;

	char c=getchar();

	while (!isdigit(c)&&c!='-') c=getchar();

	if (c=='-') c=getchar(),w=-1;

	while (isdigit(c))

	{

		x=(x<<1)+(x<<3)+c-'0';

		c=getchar();

	}

	return x*w;

}

inline bool check(int k)

{

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

	{

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

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

	}

	return a[1]<=k;

}

int main()

{

	n=read();

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

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

	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;

}

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

}


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

#include<cstring>

#include<cctype>

#include<algorithm>

#define reg register

using namespace std;

const int N=2e5+5;

int n,a[N];

inline int read()

{

	int x=0,w=1;

	char c=getchar();

	while (!isdigit(c)&&c!='-') c=getchar();

	if (c=='-') c=getchar(),w=-1;

	while (isdigit(c))

	{

		x=(x<<1)+(x<<3)+c-'0';

		c=getchar();

	}

	return x*w;

}

inline bool check(int k)

{

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

	{

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

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

	}

	return a[1]<=k;

}

int main()

{

	n=read();

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

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

	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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
/*

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;

}




// Optimized solution to the same problem (faster):
/************************************************

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

}

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

}

// Optimized solution to the same problem (faster):
/************************************************

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

}

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

using namespace std;

const int MAX=4e5+10;

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

      T w=1;a=0;

	  char ch=getchar();

	  for(;!isdigit(ch);ch=getchar()){

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

	  }

	  for(;isdigit(ch);ch=getchar()){

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

	  }

	  a*=w;

}

int n;

int a[MAX];



int ck(int k){

    for(register int i=0;i<n;++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(){

		read(n);

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

		    read(a[i]);

		}

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

		while(l<r){

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

		   if(ck(mid)) r=mid;

		   else l=mid+1;

		}

		cout<<l;



}

// Optimized solution to the same problem (faster):
/************************************************

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

}

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

using namespace std;

int n,a[200010],l=0,r=2e9,mid,b[200010],ans;



void get_b(){

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

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

		else b[i]=0;

	}

}



int work(){

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

	int g=n-1,f=n+1;

	while(g){

		if(b[g]==b[g-1]) break;

		g--;

	}

	while(f<=2*n-1){

		if(b[f]==b[f+1]) break;

		f++;

	}

	if(g==0&&f==2*n){

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

		else return b[n]^1;

	}

	if(f-n<n-g)	return b[f];

	else return b[g];

}



int main(){

	scanf("%d",&n);

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

	b[0]=-1;

	while(l<=r){

		mid=(l+r)/2;

		get_b();

		if(work()==0) ans=mid,r=mid-1;

		else l=mid+1;

	}

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

	

	return 0;

}

// Optimized solution to the same problem (faster):
/************************************************

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

}

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

using namespace std;

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

bool check(int k){

	int i, j;

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

		b[i] = a[i] >= k;

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

		return b[n];

	i = n - 1, j = n + 1;

	while(i){

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

		if(b[j] == b[j - 1]) return b[j];

		--i, ++j;

	}

	return !((n & 1) ^ b[n]);

}

int main(){

	int i, l, r, mid, ans = 0;

	scanf("%d", &n);

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

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

	l = 1, r = 2 * n - 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):
/************************************************

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

}

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

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

}

// Fastest known solution for this problem: