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

#define MAXN 211111

using namespace std;

int num[MAXN], N, tmp[MAXN];

int main(){

    cin>>N;

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

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

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

    }

    int ans = 0;

    while(l <= r){

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

//		printf("mid=%d\n", mid); 

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

            tmp[i] = (num[i] >= mid?1 : 0);

   //         printf("%d ", tmp[i]);

        }                                  

//        puts("");

        bool flag = false, ok = false;

        for(i = 1;i < N; i++){

            if(tmp[N-i] == tmp[N-i+1]){

                if(tmp[N-i] == 1){

                    flag = ok = true;

                    break;

                }

                else {

                    ok = true;

                    break;

                }

            }

            if(tmp[N+i] == tmp[N+i-1]){

                if(tmp[N+i] == 1){

                    ok = flag = true;

                    break;

                }

                else {

                    ok = true;

                    break;

                }

            }

        }

//        printf("ok=%d flag=%d\n", ok, flag);

        if(ok == false){

        	if((tmp[N] == 0 && !(N & 1)) || (tmp[N] == 1 && N & 1 == 1))flag = true;	

        }

//    	printf("flag'=%d\n", flag);

        if(flag){

            ans = max(ans, mid);

            l = mid + 1;

        }

        else r = mid - 1;

    }

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

    return 0;

}

/*

写题目习惯不太好

不把该注意的条件写下来

4

4 1 5 2 6 3 7

*/ 

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

#include<algorithm>

using std::sort;

const int N=300011;

int a[N];

int n,m;

struct kkll

{

    int v,id;

    bool operator < (const kkll a)const{return v<a.v;}

}kll[N];

int pll[N],mar;

int b[N];



bool ck(int x)

{

    for(int i=1;i<=m;i++) if(a[i]<=x) b[i]=0;else b[i]=1;

    int p1=n,p2=n;

    while(p1>1)

    {

        if((b[p1]&b[p1-1])||(b[p2]&b[p2+1])) return 0;

        if(!(b[p1]|b[p1-1])||!(b[p2]|b[p2+1])) return 1;

        p1--,p2++;

    }

    return b[1]^1;

}





int main()

{

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

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

    scanf("%d",&n);

    m=n*2-1;

    for(int i=1;i<=m;i++) scanf("%d",&a[i]),kll[i].v=a[i],kll[i].id=i;

    sort(kll+1,kll+1+m);

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

        if(kll[i].v!=kll[i-1].v) pll[++mar]=kll[i].v;

        a[kll[i].id]=mar;

    }

    int l=1,r=mar;

    while(l<r)

    {

        int mid=l+r>>1;

        if(ck(mid)) r=mid;

        else l=mid+1;

    }

    printf("%d\n",pll[r]);

    return 0;

}


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



using namespace std;



#define N 100000



int n;

int a[2*N+5];



int check(int x) {

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

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

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

	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)) r = mid;

		else l = mid+1;

	}

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

	return 0;

}

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

#include<algorithm>

using std::sort;

const int N=300011;

int a[N];

int n,m;

struct kkll

{

    int v,id;

    bool operator < (const kkll a)const{return v<a.v;}

}kll[N];

int pll[N],mar;

int b[N];



bool ck(int x)

{

    for(int i=1;i<=m;i++) if(a[i]<=x) b[i]=0;else b[i]=1;

    int p1=n,p2=n;

    while(p1>1)

    {

        if((b[p1]&b[p1-1])||(b[p2]&b[p2+1])) return 0;

        if(!(b[p1]|b[p1-1])||!(b[p2]|b[p2+1])) return 1;

        p1--,p2++;

    }

    return b[1]^1;

}





int main()

{

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

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

    scanf("%d",&n);

    m=n*2-1;

    for(int i=1;i<=m;i++) scanf("%d",&a[i]),kll[i].v=a[i],kll[i].id=i;

    sort(kll+1,kll+1+m);

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

        if(kll[i].v!=kll[i-1].v) pll[++mar]=kll[i].v;

        a[kll[i].id]=mar;

    }

    int l=1,r=mar;

    while(l<r)

    {

        int mid=l+r>>1;

        if(ck(mid)) r=mid;

        else l=mid+1;

    }

    printf("%d\n",pll[r]);

    return 0;

}


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



const int N = 200001;

using namespace std; 



int n,a[N]; 

bool b[N]; 



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

}


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

#include<algorithm>

using std::sort;

const int N=300011;

int a[N];

int n,m;

struct kkll

{

    int v,id;

    bool operator < (const kkll a)const{return v<a.v;}

}kll[N];

int pll[N],mar;

int b[N];



bool ck(int x)

{

    for(int i=1;i<=m;i++) if(a[i]<=x) b[i]=0;else b[i]=1;

    int p1=n,p2=n;

    while(p1>1)

    {

        if((b[p1]&b[p1-1])||(b[p2]&b[p2+1])) return 0;

        if(!(b[p1]|b[p1-1])||!(b[p2]|b[p2+1])) return 1;

        p1--,p2++;

    }

    return b[1]^1;

}





int main()

{

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

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

    scanf("%d",&n);

    m=n*2-1;

    for(int i=1;i<=m;i++) scanf("%d",&a[i]),kll[i].v=a[i],kll[i].id=i;

    sort(kll+1,kll+1+m);

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

        if(kll[i].v!=kll[i-1].v) pll[++mar]=kll[i].v;

        a[kll[i].id]=mar;

    }

    int l=1,r=mar;

    while(l<r)

    {

        int mid=l+r>>1;

        if(ck(mid)) r=mid;

        else l=mid+1;

    }

    printf("%d\n",pll[r]);

    return 0;

}


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

#include<iostream>

#include<cstring>

#include<algorithm>

using namespace std;

void read(int &x){

	char ch;bool ok;

	for(ok=0,ch=getchar();!isdigit(ch);ch=getchar())if(ch=='-')ok=1;

	for(x=0;isdigit(ch);x=x*10+ch-'0',ch=getchar());if(ok)x=-x;

}

#define rg register

const int maxn=2e5+10;

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

bool check(int x){

	int sum=0;

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

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

		if(b[i])sum++;

		else sum--;

	}

	bool flag=0;

	for(rg int i=1;i<n;i++)if(b[i]==b[i+1])flag=1;

	if(!flag)return sum>0;

	int now=(n+1)>>1,now1=now;

	while(now1>1){

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

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

		now++,now1--;

	}

}

int main(){

	read(n);n=(n<<1)-1;

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

	int l=1,r=n;

	while(l<=r){

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

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

		else r=mid-1;

	}

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

}


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

#include<algorithm>

using std::sort;

const int N=300011;

int a[N];

int n,m;

struct kkll

{

    int v,id;

    bool operator < (const kkll a)const{return v<a.v;}

}kll[N];

int pll[N],mar;

int b[N];



bool ck(int x)

{

    for(int i=1;i<=m;i++) if(a[i]<=x) b[i]=0;else b[i]=1;

    int p1=n,p2=n;

    while(p1>1)

    {

        if((b[p1]&b[p1-1])||(b[p2]&b[p2+1])) return 0;

        if(!(b[p1]|b[p1-1])||!(b[p2]|b[p2+1])) return 1;

        p1--,p2++;

    }

    return b[1]^1;

}





int main()

{

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

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

    scanf("%d",&n);

    m=n*2-1;

    for(int i=1;i<=m;i++) scanf("%d",&a[i]),kll[i].v=a[i],kll[i].id=i;

    sort(kll+1,kll+1+m);

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

        if(kll[i].v!=kll[i-1].v) pll[++mar]=kll[i].v;

        a[kll[i].id]=mar;

    }

    int l=1,r=mar;

    while(l<r)

    {

        int mid=l+r>>1;

        if(ck(mid)) r=mid;

        else l=mid+1;

    }

    printf("%d\n",pll[r]);

    return 0;

}


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


#include<iostream>

#include<cstdio>

#include<cstring>

#include<set>

#include<algorithm>

#include<vector>

#include<queue>

#include<cmath>

#include<ctime>

#include<iomanip>

using namespace std;

int a[200008];

int e[200008];

int res[200008];

int n;

int check(int mid)

{

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

	{

		if(a[i]>=mid)e[i]=1;else e[i]=0;

	}

	int befi=0,beft=0;

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

	{

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

		{

			if(befi==0)

			{

				for(int j=befi+1;j<=i+1;j++) res[j]=e[i];

			}

			else

			{

				if(e[i]==beft)

				{

					for(int j=befi+1;j<=i-1;j++) res[j]=e[i];

				}

				if(e[i]!=beft)

				{

					int brd=(befi+1+i-1)/2;

					for(int j=befi+1;j<=brd;j++) res[j]=beft;

					for(int j=brd+1;j<=i-1;j++) res[j]=e[i];

				}res[i]=res[i+1]=e[i+1];

			}

			befi=i+1,beft=e[i];

		}

	}

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

	{

		if(befi!=0)res[i]=beft;

		else res[i]=e[1];

	}

//	for(int i=1;i<=n;i++) cout<<mid<<"--"<<res[i]<<" ";cout<<"\n\n";

	return res[n/2+1];

}

int main()

{

	cin>>n;n=n*2-1;

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

	{

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

	}

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

	while(l<=r)

	{

		int mid=(l+r)/2;

		if(check(mid))

		{

			l=mid+1;ans=mid;

		}

		else

		{

			r=mid-1;

		}

	}

	cout<<ans;

}


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



const int MaxV = 200000;



int N, V;

int A[MaxV + 5];



void init() {

  scanf("%d", &N);

  V = 2 * N - 1;

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

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

}



inline int check(int mid) {

  static int b[MaxV + 5];

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

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

    else b[i] = 0;

  static int pre[MaxV + 5], nxt[MaxV + 5];

  pre[1] = 1;

  for (int i = 2; i <= V; ++i)

    if (b[i] == b[i - 1]) pre[i] = pre[i - 1];

    else pre[i] = i;

  nxt[V] = V;

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

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

    else nxt[i] = i;

  if (pre[N] != N || nxt[N] != N) return b[N];

  int lpart = 0, rpart = V + 1;

  for (int i = 1; i < N; ++i) if (pre[i] != i) lpart = i;

  for (int i = V; i > N; --i) if (nxt[i] != i) rpart = i;

  if (lpart == 0 && rpart == V + 1) return b[1];

  else if (lpart == 0) return b[rpart];

  else if (rpart == V + 1) return b[lpart];

  else if (b[lpart] == b[rpart]) return b[lpart];

  else if (N - lpart < rpart - N) return b[lpart];

  else return b[rpart];

}



void solve() {

  int lbound = 1, rbound = V, ans = 0;

  while (lbound <= rbound) {

    int mid = (lbound + rbound) >> 1;

    if (check(mid) == 1) {

      ans = mid;

      lbound = mid + 1;

    } else rbound = mid - 1;

  }

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

}



int main() {

  init();

  solve();

  return 0;

}

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

#define ll long long

#define ull unsigned ll

#define uint unsigned

#define db long double

#define pii pair<int,int>

#define pll pair<ll,ll>

#define IT iterator

 

#define PB push_back

#define MK make_pair

#define LB lower_bound

#define UB upper_bound

#define EB emplace_back

#define fi first

#define se second

 

#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)

#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)

#define UPD(x,y) (((x)+=(y))>=mo?x-=mo:233)

#define CLR(a,v) memset(a,v,sizeof(a));

#define CPY(a,b) memcpy(a,b,sizeof(a));

 

#define LS3 k*2,l,mid

#define RS3 k*2+1,mid+1,r

#define LS5 k*2,l,mid,x,y

#define RS5 k*2+1,mid+1,r,x,y

#define GET pushdown(k);int mid=(l+r)/2

 

#define INF ((1ll<<60)-233)

#define sqr(x) ((x)*(x))

#define debug puts("wzpkking")

using namespace std;

int n,a[200005];

bool check(int mid){

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

		int s0=0,s1=0;

		if (a[n-i]>=mid&&a[n-i-1]>=mid) s1++;

		if (a[n-i]<mid&&a[n-i-1]<mid) s0++;

		if (a[n+i]>=mid&&a[n+i+1]>=mid) s1++;

		if (a[n+i]<mid&&a[n+i+1]<mid) s0++;

		if (s1) return 1;

		if (s0) return 0;

	}

	return a[1]>=mid;

}

int main(){

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

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

	scanf("%d",&n);

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

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

	while (l<=r){

		int mid=(l+r)/2;

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

		else r=mid-1;

	}

	printf("%d",ans);

}

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



const int MaxV = 200000;



int N, V;

int A[MaxV + 5];



void init() {

  scanf("%d", &N);

  V = 2 * N - 1;

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

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

}



inline int check(int mid) {

  static int b[MaxV + 5];

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

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

    else b[i] = 0;

  static int pre[MaxV + 5], nxt[MaxV + 5];

  pre[1] = 1;

  for (int i = 2; i <= V; ++i)

    if (b[i] == b[i - 1]) pre[i] = pre[i - 1];

    else pre[i] = i;

  nxt[V] = V;

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

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

    else nxt[i] = i;

  if (pre[N] != N || nxt[N] != N) return b[N];

  int lpart = 0, rpart = V + 1;

  for (int i = 1; i < N; ++i) if (pre[i] != i) lpart = i;

  for (int i = V; i > N; --i) if (nxt[i] != i) rpart = i;

  if (lpart == 0 && rpart == V + 1) return b[1];

  else if (lpart == 0) return b[rpart];

  else if (rpart == V + 1) return b[lpart];

  else if (b[lpart] == b[rpart]) return b[lpart];

  else if (N - lpart < rpart - N) return b[lpart];

  else return b[rpart];

}



void solve() {

  int lbound = 1, rbound = V, ans = 0;

  while (lbound <= rbound) {

    int mid = (lbound + rbound) >> 1;

    if (check(mid) == 1) {

      ans = mid;

      lbound = mid + 1;

    } else rbound = mid - 1;

  }

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

}



int main() {

  init();

  solve();

  return 0;

}

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

#include <cstring>

#include <cstdio>

#include <cmath>

#include <algorithm>

#include <queue>

using namespace std;

#define ll long long

int n,m,w;

int a[500005];

int temp[500005];

bool check(int cm)

{

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

	{

		temp[i]=0;

		if(a[i]>cm)

		{

			temp[i]=1;

		}

	}

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

	{

		if(temp[n+i]==temp[n+i+1])

		{

			return temp[n+i];

		}

		else if(temp[n-i]==temp[n-i-1])

		{

			return temp[n-i];

		}

	}

	if(n%2==1)

	{

		return temp[n];

	}

	else

	{

		return 1-temp[n];

	}

}

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

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

		else r=mid;

	}

	printf("%d",l);

    return 0;

}

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



const int MaxV = 200000;



int N, V;

int A[MaxV + 5];



void init() {

  scanf("%d", &N);

  V = 2 * N - 1;

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

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

}



inline int check(int mid) {

  static int b[MaxV + 5];

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

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

    else b[i] = 0;

  static int pre[MaxV + 5], nxt[MaxV + 5];

  pre[1] = 1;

  for (int i = 2; i <= V; ++i)

    if (b[i] == b[i - 1]) pre[i] = pre[i - 1];

    else pre[i] = i;

  nxt[V] = V;

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

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

    else nxt[i] = i;

  if (pre[N] != N || nxt[N] != N) return b[N];

  int lpart = 0, rpart = V + 1;

  for (int i = 1; i < N; ++i) if (pre[i] != i) lpart = i;

  for (int i = V; i > N; --i) if (nxt[i] != i) rpart = i;

  if (lpart == 0 && rpart == V + 1) return b[1];

  else if (lpart == 0) return b[rpart];

  else if (rpart == V + 1) return b[lpart];

  else if (b[lpart] == b[rpart]) return b[lpart];

  else if (N - lpart < rpart - N) return b[lpart];

  else return b[rpart];

}



void solve() {

  int lbound = 1, rbound = V, ans = 0;

  while (lbound <= rbound) {

    int mid = (lbound + rbound) >> 1;

    if (check(mid) == 1) {

      ans = mid;

      lbound = mid + 1;

    } else rbound = mid - 1;

  }

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

}



int main() {

  init();

  solve();

  return 0;

}

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

using namespace std;

const int maxn = 1e6 + 10;

int n, a[maxn + maxn];



int read() {

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

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

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

    return x * f;

}



bool check(int k) {

    bool tran[maxn]; // 相邻 

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

    int mid = (n + 1) / 2, pos = 0, flg = -1;

    for (int i = mid; i < n; ++i) { if (tran[i] == tran[i + 1]) { pos = i - mid, flg = tran[i]; break; } }

    for (int i = mid; i > 1; --i) { if (tran[i] == tran[i - 1] && mid - i < pos) { flg = tran[i]; break; } } 

    if (flg != -1) return flg;

    return tran[1];

}



int main() {

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

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

    int l = 1, r = n, ans = 1;

    while (l <= r) {

        int 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>



const int MaxV = 200000;



int N, V;

int A[MaxV + 5];



void init() {

  scanf("%d", &N);

  V = 2 * N - 1;

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

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

}



inline int check(int mid) {

  static int b[MaxV + 5];

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

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

    else b[i] = 0;

  static int pre[MaxV + 5], nxt[MaxV + 5];

  pre[1] = 1;

  for (int i = 2; i <= V; ++i)

    if (b[i] == b[i - 1]) pre[i] = pre[i - 1];

    else pre[i] = i;

  nxt[V] = V;

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

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

    else nxt[i] = i;

  if (pre[N] != N || nxt[N] != N) return b[N];

  int lpart = 0, rpart = V + 1;

  for (int i = 1; i < N; ++i) if (pre[i] != i) lpart = i;

  for (int i = V; i > N; --i) if (nxt[i] != i) rpart = i;

  if (lpart == 0 && rpart == V + 1) return b[1];

  else if (lpart == 0) return b[rpart];

  else if (rpart == V + 1) return b[lpart];

  else if (b[lpart] == b[rpart]) return b[lpart];

  else if (N - lpart < rpart - N) return b[lpart];

  else return b[rpart];

}



void solve() {

  int lbound = 1, rbound = V, ans = 0;

  while (lbound <= rbound) {

    int mid = (lbound + rbound) >> 1;

    if (check(mid) == 1) {

      ans = mid;

      lbound = mid + 1;

    } else rbound = mid - 1;

  }

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

}



int main() {

  init();

  solve();

  return 0;

}

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

using namespace std;

typedef long long ll;

const ll maxn=2e5;

ll n,m,w,a[maxn],b[maxn],d[maxn],c[maxn],k,depth;

bool check()

{

	int mid=(n+1)/2;

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

	if((b[mid]==0&&b[mid+1]==0)||(b[mid]==0&&b[mid-1]==0))return 0;

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

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

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

	}

	if(depth%2==1)return b[mid];

	else return (b[mid]^1);

}

int main(){

	ll r,l=1;

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

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

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

	r=n;ll mid = l+r>>1;

	while(l <= r)

    {

    	mid=l+r>>1;

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

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

    		else b[i]=0;

        if(!check())

            r=mid-1; 

        else

            l=mid+1;

    }

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

}

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



const int MaxV = 200000;



int N, V;

int A[MaxV + 5];



void init() {

  scanf("%d", &N);

  V = 2 * N - 1;

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

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

}



inline int check(int mid) {

  static int b[MaxV + 5];

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

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

    else b[i] = 0;

  static int pre[MaxV + 5], nxt[MaxV + 5];

  pre[1] = 1;

  for (int i = 2; i <= V; ++i)

    if (b[i] == b[i - 1]) pre[i] = pre[i - 1];

    else pre[i] = i;

  nxt[V] = V;

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

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

    else nxt[i] = i;

  if (pre[N] != N || nxt[N] != N) return b[N];

  int lpart = 0, rpart = V + 1;

  for (int i = 1; i < N; ++i) if (pre[i] != i) lpart = i;

  for (int i = V; i > N; --i) if (nxt[i] != i) rpart = i;

  if (lpart == 0 && rpart == V + 1) return b[1];

  else if (lpart == 0) return b[rpart];

  else if (rpart == V + 1) return b[lpart];

  else if (b[lpart] == b[rpart]) return b[lpart];

  else if (N - lpart < rpart - N) return b[lpart];

  else return b[rpart];

}



void solve() {

  int lbound = 1, rbound = V, ans = 0;

  while (lbound <= rbound) {

    int mid = (lbound + rbound) >> 1;

    if (check(mid) == 1) {

      ans = mid;

      lbound = mid + 1;

    } else rbound = mid - 1;

  }

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

}



int main() {

  init();

  solve();

  return 0;

}

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

using namespace std;

const int N=1e6;

const int inf=1e9+10; 

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

int l,r,mid;

bool small(int x,int y,int q){

	return a[x]<=q && a[y]<=q;

}



bool big(int x,int y,int q){

	return a[x]>q && a[y]>q;

}



bool check(int x){

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

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

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

	}

	return a[1]<=x;

}

int main(){

	scanf("%d",&n);

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

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

	while(l<=r){

		mid=(l+r)/2;

		if(check(mid)){

			ans=mid;

			r=mid-1;

		}else l=mid+1;

	}

	printf("%d",ans);

	return 0;

}

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



const int MaxV = 200000;



int N, V;

int A[MaxV + 5];



void init() {

  scanf("%d", &N);

  V = 2 * N - 1;

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

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

}



inline int check(int mid) {

  static int b[MaxV + 5];

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

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

    else b[i] = 0;

  static int pre[MaxV + 5], nxt[MaxV + 5];

  pre[1] = 1;

  for (int i = 2; i <= V; ++i)

    if (b[i] == b[i - 1]) pre[i] = pre[i - 1];

    else pre[i] = i;

  nxt[V] = V;

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

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

    else nxt[i] = i;

  if (pre[N] != N || nxt[N] != N) return b[N];

  int lpart = 0, rpart = V + 1;

  for (int i = 1; i < N; ++i) if (pre[i] != i) lpart = i;

  for (int i = V; i > N; --i) if (nxt[i] != i) rpart = i;

  if (lpart == 0 && rpart == V + 1) return b[1];

  else if (lpart == 0) return b[rpart];

  else if (rpart == V + 1) return b[lpart];

  else if (b[lpart] == b[rpart]) return b[lpart];

  else if (N - lpart < rpart - N) return b[lpart];

  else return b[rpart];

}



void solve() {

  int lbound = 1, rbound = V, ans = 0;

  while (lbound <= rbound) {

    int mid = (lbound + rbound) >> 1;

    if (check(mid) == 1) {

      ans = mid;

      lbound = mid + 1;

    } else rbound = mid - 1;

  }

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

}



int main() {

  init();

  solve();

  return 0;

}

// Fastest known solution for this problem: