stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <iostream>

#include <cstdio>

#include <algorithm>



using namespace std;



const int N = 100010;



int n, a[N << 1];



bool check(int x)

{

	int l = n, r = n;

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

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

	if (l == 1 && r == 2 * n - 1) return (a[n] >= x) ^ ((n + 1) & 1);

	if (l == 1) return a[r] >= x;

	if (r == 2 * n - 1) return a[l] >= x;

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

	return a[r] >= x;

}



int main()

{

	int l = 0x7fffffff, r = 0;

	

	scanf("%d", &n);

	

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

	{

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

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

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

	}

	

	while (l < r)

	{

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

		if (check(mid)) l = mid;

		else r = mid - 1;

	}

	

	cout << l;

	

	return 0;

}

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

Author:Morning_Glory

LANG:C++

Created Time:2019年07月23日 星期二 10时12分43秒

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

#include <cstdio>

#include <fstream>

#include <algorithm>

using namespace std;

const int maxn = 200005;

//{{{cin

struct IO{

	template<typename T>

	IO & operator>>(T&res){

		res=0;

		bool flag=false;

		char ch;

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

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

		if (flag)	 res=~res+1;

		return *this;

	}

}cin;

//}}}

int n,m,l,r;

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

bool flag=true;

bool check (int x)

{

	int tl=m,tr=m,ans=c[m];

	c[0]=c[1],c[n+1]=c[n];

	for (;tl>=1&&c[tl]!=c[tl-1]&&c[tr]!=c[tr+1];--tl,++tr)	ans^=1;

	return ans;

}

int main()

{

	cin>>m;

	n=2*m-1;

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

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

	l=1,r=n;

	while (l<r){

		int mid=(l+r)/2+1;

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

		if (check(mid))	l=mid;

		else	r=mid-1;

	}

	printf("%d\n",b[l]);

	return 0;

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

#define maxn 200005

int arr[maxn],n,seq[maxn],rank[maxn],ref[maxn];



int cmp(int a,int b){return arr[a]<arr[b];}



int check(int x){

//	printf("checking:%d\n",x);

	int mid=(n/2)+1;

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

		seq[i]=(ref[i]>x);

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

	}//printf("\n");

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

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

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

	return seq[1];

}



int main(){

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

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

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

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

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

		rank[i]=i;

	}if (n==1) {printf("%d ",arr[1]);return 0;}

	std::sort(rank+1,rank+n+1,cmp);

	for (int i=1;i<=n;++i) ref[rank[i]]=i;

//	for (int i=1;i<=n;++i) printf("%d ",ref[i]); printf("\n");

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

	while (l<r){

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

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

		else {r=mid;ans=mid;}

	}printf("%d",arr[rank[ans]]);

	return 0;

}




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

Author:Morning_Glory

LANG:C++

Created Time:2019年07月23日 星期二 10时12分43秒

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

#include <cstdio>

#include <fstream>

#include <algorithm>

using namespace std;

const int maxn = 200005;

//{{{cin

struct IO{

	template<typename T>

	IO & operator>>(T&res){

		res=0;

		bool flag=false;

		char ch;

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

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

		if (flag)	 res=~res+1;

		return *this;

	}

}cin;

//}}}

int n,m,l,r;

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

bool flag=true;

bool check (int x)

{

	int tl=m,tr=m,ans=c[m];

	c[0]=c[1],c[n+1]=c[n];

	for (;tl>=1&&c[tl]!=c[tl-1]&&c[tr]!=c[tr+1];--tl,++tr)	ans^=1;

	return ans;

}

int main()

{

	cin>>m;

	n=2*m-1;

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

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

	l=1,r=n;

	while (l<r){

		int mid=(l+r)/2+1;

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

		if (check(mid))	l=mid;

		else	r=mid-1;

	}

	printf("%d\n",b[l]);

	return 0;

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

#include <cstdlib>

#include <cstdio>

#define N 400011

using namespace std;

int b[N],len,n,a[N],cnt[N],ans,maxx,minn;

int judge(int avr){

	b[0]=-1;

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

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

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

		else cnt[i]=1;

	}

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

		if(cnt[n+i]>=2) return b[n+i];

		if(cnt[n-i]>=2) return b[n-i];

	}

	return b[1];

}

void bin(){

	int head=minn,tail=maxx,mid;

	while(head<=tail){

		mid=(head+tail)/2;

		if(judge(mid)){

			ans=mid;

			head=mid+1;

		}

		else tail=mid-1;

	}

}

int main(){

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

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

	for(int i=1;i<=len;i++) scanf("%d",&a[i]),minn=min(minn,a[i]),maxx=max(maxx,a[i]);

	bin();

	printf("%d",ans);

	return 0;

}

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

Author:Morning_Glory

LANG:C++

Created Time:2019年07月23日 星期二 10时12分43秒

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

#include <cstdio>

#include <fstream>

#include <algorithm>

using namespace std;

const int maxn = 200005;

//{{{cin

struct IO{

	template<typename T>

	IO & operator>>(T&res){

		res=0;

		bool flag=false;

		char ch;

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

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

		if (flag)	 res=~res+1;

		return *this;

	}

}cin;

//}}}

int n,m,l,r;

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

bool flag=true;

bool check (int x)

{

	int tl=m,tr=m,ans=c[m];

	c[0]=c[1],c[n+1]=c[n];

	for (;tl>=1&&c[tl]!=c[tl-1]&&c[tr]!=c[tr+1];--tl,++tr)	ans^=1;

	return ans;

}

int main()

{

	cin>>m;

	n=2*m-1;

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

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

	l=1,r=n;

	while (l<r){

		int mid=(l+r)/2+1;

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

		if (check(mid))	l=mid;

		else	r=mid-1;

	}

	printf("%d\n",b[l]);

	return 0;

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

using namespace std;

const int maxn = 1e6 + 7;

int n, a[maxn];

int S(int i, int j, int k) {return a[i] <= k && a[j] <= k;}

int M(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(M(n + i, n + i + 1, k) || M(n - i, n - i - 1, k)) return 0;

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

	}

	return S(1, 1, k);

} 

int main() {

	scanf("%d", &n);

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

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

}

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

#include <algorithm>



using namespace std;



const int N = 2e5 + 10;



int n;

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



inline int check(int x) {

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

	int mid = 1 + n >> 1, l = mid, r = mid, res = c[mid];

	c[0] = c[1];

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

	return res;

}



inline int solve() {

	int l = 1, r = n, res;

	while (l <= r) {

		int mid = l + r >> 1;

		if (check(b[mid]))	l = mid + 1, res = mid;

		else r = mid - 1;

	}

	return b[res];

}



int main() {

	

	scanf("%d", &n);

	n = n * 2 - 1;

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

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

	

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

	

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

	

	return 0;

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

#include<cstdio>

#include<cstring>

#include<algorithm>

#define MAXN 200010

using namespace std;

int n,l,r,mid;

int a[MAXN];

inline bool check_large(int x,int y)

{

    if(a[x]>mid&&a[y]>mid) return true;

    return false;

}

inline bool check_small(int x,int y)

{

    if(a[x]<=mid&&a[y]<=mid) return true;

    return false;

}

inline bool solve()

{

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

    {

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

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

    }

    if(a[1]<=mid) return false;

    else return true;

}

int main()

{

    scanf("%d",&n);

    for(int 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(solve()==true) l=mid+1;

        else r=mid; 

    }

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

    return 0;

}

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

#include <algorithm>



using namespace std;



const int N = 2e5 + 10;



int n;

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



inline int check(int x) {

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

	int mid = 1 + n >> 1, l = mid, r = mid, res = c[mid];

	c[0] = c[1];

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

	return res;

}



inline int solve() {

	int l = 1, r = n, res;

	while (l <= r) {

		int mid = l + r >> 1;

		if (check(b[mid]))	l = mid + 1, res = mid;

		else r = mid - 1;

	}

	return b[res];

}



int main() {

	

	scanf("%d", &n);

	n = n * 2 - 1;

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

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

	

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

	

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

	

	return 0;

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

using namespace std;

int n,a[20000010];

bool s(int i,int j,int k)

{

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

}

bool b(int i,int j,int k)

{

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

}

bool check(int k)

{

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

	{

        if(b(n+i,n+i+1,k)||b(n-i,n-i-1,k))

			return 0;

        if(s(n+i,n+i+1,k)||s(n-i,n-i-1,k))

			return 1;

    }

    return s(1,1,k);

}

int main()

{

    scanf("%d",&n);

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

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

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

    while(l<r)

	{

        int mid=l+(r-l)/2;

        if(check(mid))

            r=mid;

        else

			l=mid+1;

    }

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

    return 0; 

}

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

#include <algorithm>



using namespace std;



const int N = 2e5 + 10;



int n;

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



inline int check(int x) {

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

	int mid = 1 + n >> 1, l = mid, r = mid, res = c[mid];

	c[0] = c[1];

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

	return res;

}



inline int solve() {

	int l = 1, r = n, res;

	while (l <= r) {

		int mid = l + r >> 1;

		if (check(b[mid]))	l = mid + 1, res = mid;

		else r = mid - 1;

	}

	return b[res];

}



int main() {

	

	scanf("%d", &n);

	n = n * 2 - 1;

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

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

	

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

	

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

	

	return 0;

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

#include<cstdio>

using namespace std;

int n,a[200010];

bool check(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(){

    cin>>n;

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

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

    int ans=0;

    while(l<r){

        int mid=(l+r)/2;

        if(check(mid)){

            r=mid;ans=mid;

        }

        else l=mid+1;

    }

    cout<<ans<<endl;

}


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

#include <algorithm>



using namespace std;



const int N = 2e5 + 10;



int n;

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



inline int check(int x) {

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

	int mid = 1 + n >> 1, l = mid, r = mid, res = c[mid];

	c[0] = c[1];

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

	return res;

}



inline int solve() {

	int l = 1, r = n, res;

	while (l <= r) {

		int mid = l + r >> 1;

		if (check(b[mid]))	l = mid + 1, res = mid;

		else r = mid - 1;

	}

	return b[res];

}



int main() {

	

	scanf("%d", &n);

	n = n * 2 - 1;

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

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

	

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

	

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

	

	return 0;

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

using namespace std;

int n;

vector<int>v,v2;

bool check(int x){

    v2.clear();

    for(int i=0;i<2*n-1;i++)v2.push_back(v[i]>=x);

    if(v[n-1]>=x&&v[n-2]>=x)return 1;

    if(v[n-1]>=x&&v[n]>=x)return 1;

    if(v[n-1]<x&&v[n-2]<x)return 0;

    if(v[n-1]<x&&v[n]<x)return 0;

    int l=n-2,r=n;

    while(l>0&&v2[l]!=v2[l-1])l--;

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

    if(r-l==2*n-2)return v2[l]; 

    if((r-l+1)%2)return v2[l];//ÏàÍ¬ 

    if(n-1-l<r-n+1)return v2[l];//ÀëµÃ¸ü¶Ì 

    return v2[r];

}

int main(){

    cin>>n;

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

        int a;

        cin>>a;

        v.push_back(a);

    }

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

    while(l<r){

        int mid=(l+r+1)/2;

        if(check(mid))

            l=mid;

        else

            r=mid-1;

        //cout<<l<<' '<<r<<endl;

    }

    cout<<l;

}

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

#include <algorithm>



using namespace std;



const int N = 2e5 + 10;



int n;

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



inline int check(int x) {

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

	int mid = 1 + n >> 1, l = mid, r = mid, res = c[mid];

	c[0] = c[1];

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

	return res;

}



inline int solve() {

	int l = 1, r = n, res;

	while (l <= r) {

		int mid = l + r >> 1;

		if (check(b[mid]))	l = mid + 1, res = mid;

		else r = mid - 1;

	}

	return b[res];

}



int main() {

	

	scanf("%d", &n);

	n = n * 2 - 1;

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

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

	

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

	

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

	

	return 0;

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

#include <iostream>

#include <algorithm>

#include <cmath>

#include <cstring>



#define reg register

#define MAX_N 200007

#define rep(i, l, r) for(int i = l; i <= r; ++i)

typedef long long ll;



template <typename _T>

inline bool read (_T& x) {

    x = 0;

    _T y = 1;

    char c = getchar();

    while ((c < '0' || '9' < c) && c != EOF) {

        if (c == '-') y = -1;

        c = getchar();

    }

    if (c == EOF) return false;

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

    x *= y;

    return true;

}



int M, N;

int a[MAX_N], b[MAX_N], c[MAX_N];



inline int calc (int x) {

    rep (i, 1, N) b[i] = (x < a[i]);

    // printf("%d:\n", x);

    // rep (i, 1, N) printf("%d ", b[i]); puts("");

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

        int l, r;

        while (j < N && b[j + 1] == b[j]) j++;

        l = j;

        while (j < N && b[j + 1] != b[j]) j++;

        r = j;

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

        if (b[l] == b[r]) {

            rep (k, l + 1, r - 1) b[k] = b[l];

        } else {

            int sum = 0;

            rep (k, l, r) sum += (b[k] == b[l]);

            rep (k, l, l + sum - 1) b[k] = b[l];

            rep (k, l + sum, r) b[k] = b[r];

        }

        j++;

    }

    // rep (i, 1, N) printf("%d ", b[i]); puts("");

    return b[M];

}



int main () {

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

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

    read(M), N = 2 * M - 1;

    rep (i, 1, N) read(a[i]), c[i] = a[i];

    std::sort(c + 1, c + N + 1);

    int l = 1, r = N, mid, ans = 0;

    while (l <= r) {

        mid = l + r >> 1;

        if (!calc(c[mid])) ans = mid, r = mid - 1;

        else l = mid + 1;

    }

    printf("%d\n", c[ans]);

    return 0;

}


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

#include <algorithm>



using namespace std;



const int N = 2e5 + 10;



int n;

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



inline int check(int x) {

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

	int mid = 1 + n >> 1, l = mid, r = mid, res = c[mid];

	c[0] = c[1];

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

	return res;

}



inline int solve() {

	int l = 1, r = n, res;

	while (l <= r) {

		int mid = l + r >> 1;

		if (check(b[mid]))	l = mid + 1, res = mid;

		else r = mid - 1;

	}

	return b[res];

}



int main() {

	

	scanf("%d", &n);

	n = n * 2 - 1;

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

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

	

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

	

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

	

	return 0;

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

#include <cstdio>

#include <algorithm>



using namespace std;



const int N = 100010;



int n, a[N << 1];



bool check(int x)

{

	int l = n, r = n;

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

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

	if (l == 1 && r == 2 * n - 1) return (a[n] >= x) ^ ((n + 1) & 1);

	if (l == 1) return a[r] >= x;

	if (r == 2 * n - 1) return a[l] >= x;

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

	return a[r] >= x;

}



int main()

{

	int l = 0x7fffffff, r = 0;

	

	scanf("%d", &n);

	

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

	{

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

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

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

	}

	

	while (l < r)

	{

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

		if (check(mid)) l = mid;

		else r = mid - 1;

	}

	

	cout << l;

	

	return 0;

}

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

#include <algorithm>



using namespace std;



const int N = 2e5 + 10;



int n;

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



inline int check(int x) {

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

	int mid = 1 + n >> 1, l = mid, r = mid, res = c[mid];

	c[0] = c[1];

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

	return res;

}



inline int solve() {

	int l = 1, r = n, res;

	while (l <= r) {

		int mid = l + r >> 1;

		if (check(b[mid]))	l = mid + 1, res = mid;

		else r = mid - 1;

	}

	return b[res];

}



int main() {

	

	scanf("%d", &n);

	n = n * 2 - 1;

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

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

	

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

	

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

	

	return 0;

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

#define maxn 200005

int arr[maxn],n,seq[maxn],rank[maxn],ref[maxn];



int cmp(int a,int b){return arr[a]<arr[b];}



int check(int x){

//	printf("checking:%d\n",x);

	int mid=(n/2)+1;

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

		seq[i]=(ref[i]>x);

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

	}//printf("\n");

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

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

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

	return seq[1];

}



int main(){

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

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

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

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

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

		rank[i]=i;

	}if (n==1) {printf("%d ",arr[1]);return 0;}

	std::sort(rank+1,rank+n+1,cmp);

	for (int i=1;i<=n;++i) ref[rank[i]]=i;

//	for (int i=1;i<=n;++i) printf("%d ",ref[i]); printf("\n");

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

	while (l<r){

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

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

		else {r=mid;ans=mid;}

	}printf("%d",arr[rank[ans]]);

	return 0;

}




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

#include <algorithm>



using namespace std;



const int N = 2e5 + 10;



int n;

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



inline int check(int x) {

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

	int mid = 1 + n >> 1, l = mid, r = mid, res = c[mid];

	c[0] = c[1];

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

	return res;

}



inline int solve() {

	int l = 1, r = n, res;

	while (l <= r) {

		int mid = l + r >> 1;

		if (check(b[mid]))	l = mid + 1, res = mid;

		else r = mid - 1;

	}

	return b[res];

}



int main() {

	

	scanf("%d", &n);

	n = n * 2 - 1;

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

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

	

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

	

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

	

	return 0;

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

#include <cstdlib>

#include <cstdio>

#define N 400011

using namespace std;

int b[N],len,n,a[N],cnt[N],ans,maxx,minn;

int judge(int avr){

	b[0]=-1;

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

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

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

		else cnt[i]=1;

	}

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

		if(cnt[n+i]>=2) return b[n+i];

		if(cnt[n-i]>=2) return b[n-i];

	}

	return b[1];

}

void bin(){

	int head=minn,tail=maxx,mid;

	while(head<=tail){

		mid=(head+tail)/2;

		if(judge(mid)){

			ans=mid;

			head=mid+1;

		}

		else tail=mid-1;

	}

}

int main(){

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

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

	for(int i=1;i<=len;i++) scanf("%d",&a[i]),minn=min(minn,a[i]),maxx=max(maxx,a[i]);

	bin();

	printf("%d",ans);

	return 0;

}

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

#include <algorithm>



using namespace std;



const int N = 2e5 + 10;



int n;

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



inline int check(int x) {

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

	int mid = 1 + n >> 1, l = mid, r = mid, res = c[mid];

	c[0] = c[1];

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

	return res;

}



inline int solve() {

	int l = 1, r = n, res;

	while (l <= r) {

		int mid = l + r >> 1;

		if (check(b[mid]))	l = mid + 1, res = mid;

		else r = mid - 1;

	}

	return b[res];

}



int main() {

	

	scanf("%d", &n);

	n = n * 2 - 1;

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

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

	

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

	

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

	

	return 0;

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

using namespace std;

const int maxn = 1e6 + 7;

int n, a[maxn];

int S(int i, int j, int k) {return a[i] <= k && a[j] <= k;}

int M(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(M(n + i, n + i + 1, k) || M(n - i, n - i - 1, k)) return 0;

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

	}

	return S(1, 1, k);

} 

int main() {

	scanf("%d", &n);

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

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

}

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

using namespace std;

const int N=2e5+5;

int n,A[N],l,r=N;

bool Check(int x){

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

		if((A[n-i]>=x)==(A[n-i+1]>=x))return A[n-i]>=x;

		if((A[n+i]>=x)==(A[n+i-1]>=x))return A[n+i]>=x;

	}

	return A[1]>=x;

}

int main(){

	scanf("%d",&n);

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

	while(l+1<r){

		int mid=(l+r)/2;

		if(Check(mid))l=mid;

		else r=mid;

	}

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

}