stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <bits/stdc++.h>



#define ll long long



using namespace std;



const int inf = 1e9 + 7;





ll ans = inf, cur;



main()

{

    int n;

    cin >> n;



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

    {

        int a, b;

        scanf("%d%d", &a, &b);



        cur += a;



        if (a > b)

            ans = min(ans, b * 1LL);

    }



    if (ans == inf)

    {

        cout << 0;

        return 0;

    }

    cout << cur - ans;

}






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

#include<algorithm>

using namespace std;

const int MAXN = 2 * int(1E5);

struct node{

	int A, B;

}a[MAXN + 5];

int main() {

	int N;

	scanf("%d", &N);

	bool flag = true;

	long long Sum = 0, Min = (1ll << 60);

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

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

		if( a[i].A > a[i].B )

			Min = min(Min, 1ll*a[i].B);

		if( a[i].A != a[i].B )

			flag = false;

		Sum += a[i].A;

	}

	if( flag ) {

		printf("0\n");

		return 0;

	}

	printf("%lld", Sum - Min);

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



#define fr first

#define sc second

#define mk make_pair

#define pb push_back

#define ok puts("OK");

#define sz(s) (int)s.size()

#define all(s) s.begin(), s.end()

#define int long long



using namespace std;



const int N = 2e5 + 5;



int n, a[N], b[N], ans, sum = 1e9 + 7;



bool fl = 0;



vector <int> vec;



main()

{

    cin >> n;

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

        scanf("%lld%lld", &a[i], &b[i]), fl |= (a[i] != b[i]), ans += a[i];



    if (!fl)

    {

        puts("0");

        return 0;

    }

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

    {

        if (a[i] > b[i])

            sum = min(sum, b[i]);

    }

    cout << ans - sum << endl;

}


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

#include<algorithm>

using namespace std;

const int MAXN = 2 * int(1E5);

struct node{

	int A, B;

}a[MAXN + 5];

int main() {

	int N;

	scanf("%d", &N);

	bool flag = true;

	long long Sum = 0, Min = (1ll << 60);

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

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

		if( a[i].A > a[i].B )

			Min = min(Min, 1ll*a[i].B);

		if( a[i].A != a[i].B )

			flag = false;

		Sum += a[i].A;

	}

	if( flag ) {

		printf("0\n");

		return 0;

	}

	printf("%lld", Sum - Min);

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

using namespace std;

typedef long long ll;

const int maxn=2e5+5;

ll sum,ans;

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

int main()

{

    ll min1=1e9+5;

    scanf("%lld",&n);

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

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

    bool flag=true;

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

        if(a[i]!=b[i])

        {

            flag=false;

            break;

        }

    if(flag)

        printf("0\n");

    else

    {

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

        {

            if(a[i]>b[i])

                min1=min(b[i],min1);

            sum+=b[i];

        }

        printf("%lld\n",sum-min1);

    }

}

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

#include<algorithm>

using namespace std;

const int MAXN = 2 * int(1E5);

struct node{

	int A, B;

}a[MAXN + 5];

int main() {

	int N;

	scanf("%d", &N);

	bool flag = true;

	long long Sum = 0, Min = (1ll << 60);

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

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

		if( a[i].A > a[i].B )

			Min = min(Min, 1ll*a[i].B);

		if( a[i].A != a[i].B )

			flag = false;

		Sum += a[i].A;

	}

	if( flag ) {

		printf("0\n");

		return 0;

	}

	printf("%lld", Sum - Min);

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

#include<cstdio>

#include<algorithm>

using namespace std;

const int N=2*1e5+5;

long long n,a[N],b[N];

long long ans=0;

int main()

{

    cin>>n;

    int f=0;

    ans=0;

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

        {

            cin>>a[i]>>b[i];

            ans+=a[i];

            if(a[i]!=b[i])

                f=1;

        }

    if(!f)

    {

        cout<<0<<endl;

    }

    else

    {

        //sort(a,a+n);

        //sort(b,b+n);

        long long p=2000000000+7;

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

        {

            if(a[i]>b[i])

                p=min(p,b[i]);

        }

        cout<<ans-p<<endl;

    }

    return 0;

}


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

#include<algorithm>

using namespace std;

const int MAXN = 2 * int(1E5);

struct node{

	int A, B;

}a[MAXN + 5];

int main() {

	int N;

	scanf("%d", &N);

	bool flag = true;

	long long Sum = 0, Min = (1ll << 60);

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

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

		if( a[i].A > a[i].B )

			Min = min(Min, 1ll*a[i].B);

		if( a[i].A != a[i].B )

			flag = false;

		Sum += a[i].A;

	}

	if( flag ) {

		printf("0\n");

		return 0;

	}

	printf("%lld", Sum - Min);

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

// #include <atcoder/all>

#define ll long long int

#define ld long double

#define yorn(f) std::cout<<((f)?"Yes":"No")<<endl;

#define YORN(f) std::cout<<((f)?"YES":"NO")<<endl;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

#define repi(i, n) for (int i = 1; i < (int)(n); i++)

#define all(x) (x).begin(), (x).end()

#define put(x) std::cout << x << endl;

#define println(x) std::cout << x << endl;

template<typename T>bool mins(T& x,const T&y){if(x>y){x=y;return true;}else return false;}

template<typename T>bool maxs(T& x,const T&y){if(x<y){x=y;return true;}else return false;}

using namespace std;

// using namespace atcoder;

int N;

ll A[303];



void Main()

{

	int i,j,k,l,r,x,y; string s;

	

	cin>>N;

	rep(i,N) cin>>A[i];

	ll xo=0;

	for(i=2;i<N;i++) xo^=A[i];

	

	vector<int> cand;

	rep(i,1<<20) if(i<A[0]) {

		ll v=(A[0]-i)^(A[1]+i)^xo;

		if((v&((1<<20)-1))==0) cand.push_back(i);

	}

	

	ll mi=1LL<<50;

	for(auto c : cand) {

		for(ll a=c;a<min(mi,A[0]);a+=1<<20) {

			ll v=(A[0]-a)^(A[1]+a)^xo;

			if(v==0) mi=min(mi,a);

		}

	}

	

	if(mi==1LL<<50) mi=-1;

	cout<<mi<<endl;

}

signed main(){ Main();return 0;}

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

// #include <atcoder/all>

#define ll long long int

#define ld long double

#define yorn(f) std::cout<<((f)?"Yes":"No")<<endl;

#define YORN(f) std::cout<<((f)?"YES":"NO")<<endl;

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)

#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)

#define all(x) (x).begin(), (x).end()

#define put(x) std::cout << x << endl;

#define println(x) std::cout << x << endl;

template<typename T>bool mins(T& x,const T&y){if(x>y){x=y;return true;}else return false;}

template<typename T>bool maxs(T& x,const T&y){if(x<y){x=y;return true;}else return false;}

using namespace std;

// using namespace atcoder;



ll A[301];



void Main()

{

    ll n;

    cin >> n;

    rep(i, n) cin >> A[i];



    ll X = 0; // target xor

    for (ll i = 2; i < n; i++) X ^= A[i];



	// vector<int> cand;

	// rep(i,1<<20) if(i<A[0]) {

	// 	ll v=(A[0]-i)^(A[1]+i)^X;

	// 	if((v&((1<<20)-1))==0) cand.push_back(i);

	// }

	

	// ll mi=1LL<<50;

	// for(auto c : cand) {

	// 	for(ll a=c;a<min(mi,A[0]);a+=1<<20) {

	// 		ll v=(A[0]-a)^(A[1]+a)^X;

	// 		if(v==0) mi=min(mi,a);

	// 	}

	// }



	// if(mi==1LL<<50) mi=-1;

	// cout<<mi<<endl;



    vector<ll> cand;

    ll mask = (1LL << 20) - 1;

    rep(a, 1LL << 20) {

        if (a > A[0]) {

            break;

        }

        ll v = (A[0]-a)^(A[1]+a)^X;

        if ((v & mask) == 0) {

            cand.push_back(a);

        }

    }



    ll ma = -1;

    for (ll a1: cand) {

        for (ll a = a1; a < A[0]; a += 1LL << 20) {

            ll v = (A[0]-a)^(A[1]+a)^X;

            if (v == 0) {

                ma = max(ma, A[0]-a);

                break;

            }

        }

    }



    if (ma < 0) {

        put(-1);

        return;        

    }



    ll res = A[0] - ma;

    put(res);

}

signed main(){ Main();return 0;}
// Slower C++ solution:
#include<iostream>

using namespace std;

int N;

long A,B,S;

long ok[2][2];

main()

{

	for(int i=0;i<2;i++)for(int j=0;j<2;j++)ok[i][j]=-1;

	cin>>N>>A>>B;

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

	{

		long T;cin>>T;S^=T;

	}

	long uA=A>>20,dA=A&(1<<20)-1;

	long uB=B>>20,dB=B&(1<<20)-1;

	long uS=S>>20,dS=S&(1<<20)-1;

	for(long k=0;k<=uA;k++)

	{

		for(int i=0;i<2;i++)for(int j=0;j<2;j++)

		{

			if(k+i>uA)continue;

			if((uA-k-i^uB+k+j)==uS&&ok[i][j]==-1)ok[i][j]=k;

		}

	}

	long ans=A;

	for(long k=0;k<1<<20;k++)

	{

		if(dA>=k)

		{

			if(((dA-k)^(dB+k)&(1<<20)-1)==dS)

			{

				int j=dB+k>=1<<20;

				if(ok[0][j]!=-1)

				{

					long tmp=ok[0][j]<<20|k;

					if(ans>tmp)ans=tmp;

				}

			}

		}

		else

		{

			if(((dA+(1<<20)-k)^(dB+k)&(1<<20)-1)==dS)

			{

				int j=dB+k>=1<<20;

				if(ok[1][j]!=-1)

				{

					long tmp=ok[1][j]<<20|k;

					if(ans>tmp)ans=tmp;

				}

			}

		}

	}

	if(ans==A)ans=-1;

	cout<<ans<<endl;

}


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

#include<algorithm>

using namespace std;

int N;

long A,B,S;

long dp[50][2][2];

main()

{

	cin>>N>>A>>B;

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

	{

		long x;cin>>x;S^=x;

	}

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

	{

		int a=A>>i&1,b=B>>i&1;

		for(int j=0;j<2;j++)for(int k=0;k<2;k++)

		{

			long now=A;

			for(int J=0;J<2;J++)for(int K=0;K<2;K++)for(int x=0;x<2;x++)

			{

				int aa=a+2*j-x-J,bb=b-2*k+x+K;

				if(0<=aa&&aa<=1&&0<=bb&&bb<=1&&(aa^bb)==(S>>i&1))

				{

					if(i==0)

					{

						if(J==0&&K==0)now=min(now,(long)x);

					}

					else

					{

						now=min(now,dp[i-1][J][K]+((long)x<<i));

					}

				}

			}

			dp[i][j][k]=now;

		}

	}

	long ans=dp[49][0][0];

	cout<<(ans<A?ans:-1)<<endl;

}
// Slower C++ solution:


#include <cstdio>

#include <map>

using namespace std;

map<int,int> m;

int a[200001];

int main(int argc, const char * argv[]) {

   

    int n;

    

    scanf("%d\n",&n);

    

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

        

        int tmp;

        scanf("%d",&tmp);

        m[tmp]++;//첫글자로 자동정렬

        a[i]=tmp;

    }

    int med = n/2;

    int sum = 0;

    int num = 0;

    int next = -1;

    for(map<int,int>::iterator it = m.begin(); it!=m.end();it++){

        map<int,int>::iterator tmp=it;

        next = (++tmp)->first;

        sum += it->second;

        if(sum >=med) {

            num = it->first;

            break;

        }

        

    }

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

        

        int v = a[i];

        

        if(v <= num){

            if(sum-1 >= med) printf("%d\n",num);//다음위치

            else printf("%d\n",next);

        }else{

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

        }

        

        

    }

    

    

    return 0;

}


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

#include <algorithm>

using namespace std;



int x[200001];

int y[200001];



int main(){

    

    

    int n;

    scanf("%d",&n);

    

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

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

        y[i] = x[i];

    }

    

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

    int med = y[n/2];

    

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

        if(x[i] > med) printf("%d\n",med);

        else printf("%d\n",y[n/2+1]);

    }

    

    return 0;

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

#include <algorithm>

using namespace std;



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



int main() {

    ios::sync_with_stdio(0);

    cin.tie(NULL);

    cin >> n;

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

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

    int mid = n / 2 + 1;

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

        if(b[i] < a[mid]) cout << a[mid];

        else cout << a[mid - 1];

        cout << endl;

    }

    return 0;

}

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

#include<algorithm>

using namespace std;

#define fup(i,a,b) for(int i=a;i<=b;++i)



int x[200004],y[200004];

void Main()

{

    int n,nn;

    scanf("%d",&n);

    nn=n/2;

    fup(i,1,n)scanf("%d",&x[i]),y[i]=x[i];

    sort(y,y+1+n);

    int t=y[nn],tz=y[nn-1],ty=y[nn+1],sz=0,sy=0;

    {

        int i=nn,j=nn;

        while(y[--i]==t)++sz;

        while(y[++j]==t)++sy;

    }

    if(sz&&sy)fup(i,1,n)printf("%d\n",t);

    else if(!sz&&sy)fup(i,1,n)printf("%d\n",t);

    else if(sz&&!sy)fup(i,1,n)

    {

        if(x[i]<=t)printf("%d\n",ty);

        else printf("%d\n",t);

    }

    else fup(i,1,n)

    {

        if(x[i]<=t)printf("%d\n",ty);

        else printf("%d\n",t);

    }

}

int main()

{

Main();

return 0;

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

	#include <string>

	#include <stdio.h>

	#include <queue>

	#include <stack>

	#include <string.h>

	#include <algorithm>

	#include <math.h>

	//#include <bits/stdc++.h>

	#define ll long long

	#define wtcl return

	using namespace std;

	

	inline int read()

	{

	    ll s = 0, f = 1;

	    char ch = getchar();

	    for(; ch < '0' || ch > '9'; ch = getchar()) if(ch == '-') f = - 1;

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

	    return s * f ;

	}

	

	int main()

	{

	    int n;

	    while(cin>>n)

	    {

	    	int num[200005];

	    	int a[200005];

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

	    	{

	    		num[i] = read();

	    		a[i] = num[i];

			}

			sort(a,a+n);

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

			{

				int pos = upper_bound(a,a+n,num[i])-a;

				//cout<<pos<<" ";

				if(pos<=(n/2))

					cout<<a[n/2]<<endl;

				else cout<<a[n/2-1]<<endl;

			}

	    		

		}

	    wtcl 0;

	}

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

#include<algorithm>

using namespace std;

#define fup(i,a,b) for(int i=a;i<=b;++i)



int x[200004],y[200004];

void Main()

{

    int n,nn;

    scanf("%d",&n);

    nn=n/2;

    fup(i,1,n)scanf("%d",&x[i]),y[i]=x[i];

    sort(y,y+1+n);

    int t=y[nn],tz=y[nn-1],ty=y[nn+1],sz=0,sy=0;

    {

        int i=nn,j=nn;

        while(y[--i]==t)++sz;

        while(y[++j]==t)++sy;

    }

    if(sz&&sy)fup(i,1,n)printf("%d\n",t);

    else if(!sz&&sy)fup(i,1,n)printf("%d\n",t);

    else if(sz&&!sy)fup(i,1,n)

    {

        if(x[i]<=t)printf("%d\n",ty);

        else printf("%d\n",t);

    }

    else fup(i,1,n)

    {

        if(x[i]<=t)printf("%d\n",ty);

        else printf("%d\n",t);

    }

}

int main()

{

Main();

return 0;

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

#include<algorithm>

#include<string.h>

using namespace std;

int a[200000];

int b[200000];

/*int sort(int a[],int low,int high)

{

	int i=low,j=high,base=a[low];

	if(i>=j)

		return 0;

	while(i<j)

	{

		while(i<j&&a[j]>=base)

			j--;

		a[i]=a[j];

		while(i<j&&a[i]<=base)

			i++;

		a[j]=a[i];

	}

	a[i]=base;

	sort(a,low,i-1);

	sort(a,i+1,high);

	return 0;

}*/

int main()

{

	int i,k,n;

	scanf("%d",&n);

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

	{

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

		b[i]=a[i];

	}

	sort(a,a+n);

	k=(n-1)/2;

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

	{

		if(b[i]>a[k])

			printf("%d\n",a[k]);

		else

			printf("%d\n",a[k+1]);

	}

	return 0;

}

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

#include<algorithm>

using namespace std;

#define fup(i,a,b) for(int i=a;i<=b;++i)



int x[200004],y[200004];

void Main()

{

    int n,nn;

    scanf("%d",&n);

    nn=n/2;

    fup(i,1,n)scanf("%d",&x[i]),y[i]=x[i];

    sort(y,y+1+n);

    int t=y[nn],tz=y[nn-1],ty=y[nn+1],sz=0,sy=0;

    {

        int i=nn,j=nn;

        while(y[--i]==t)++sz;

        while(y[++j]==t)++sy;

    }

    if(sz&&sy)fup(i,1,n)printf("%d\n",t);

    else if(!sz&&sy)fup(i,1,n)printf("%d\n",t);

    else if(sz&&!sy)fup(i,1,n)

    {

        if(x[i]<=t)printf("%d\n",ty);

        else printf("%d\n",t);

    }

    else fup(i,1,n)

    {

        if(x[i]<=t)printf("%d\n",ty);

        else printf("%d\n",t);

    }

}

int main()

{

Main();

return 0;

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

#include<math.h>

#include<iostream>

#include<algorithm>

#include<string.h>

#define ll long long

using namespace std;

int a[200004];

int b[200004];

int main()

{

	int n;

	scanf("%d",&n);

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

	{

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

		b[i]=a[i];

	}

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

	int m=n/2;

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

	{

		if(b[i]<=a[m])

		printf("%d\n",a[m+1]);

		else

		printf("%d\n",a[m]);

	}

	return 0;

}

//const int maxm=100+10; 

//bool   f[maxm],   //f[i]表示切割在j位置时1~j是否存在i字符  

//q[maxm];   //q[i]表示切割在j位置时j+1~n是否存在i字符 

//int main(){

//    int n, //字符串长度 

//        now,  //当前不同字符数 

//        ans;  //已知最大不同字符数(初始值为0) 

//    register int i,j;

//    char s[maxm]; 

//    scanf("%d",&n);    //读入字符串的长度 

//    scanf("%s",s);     //读入的字符串 

//    for(i=0;i<n;i++){  //枚举切割点 

//        f[s[i]-'a']=true;     

//        //当前i位置的字符在f中标记为存在 

//        memset(q,false,sizeof(q));    //初始化q数组 

//        for(j=i+1;j<n;j++){   

//            //当前j位置的字符在q中标记为存在 

//            q[s[j]-'a']=true;  

//        }

//        now=0;    //初始化now 

//        for(j=0;j<26;j++){

//            if(f[j] && q[j]){    

//                //如果两串中拥有相同字符那么记入到now中 

//                now++; 

//            } 

//        } 

//        ans=max(ans,now); 

//        //若当前不同字符数大于已知不同字符则更新答案 

//    }

//    printf("%d",ans);  //打印答案 

//    return 0; 

//}

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

#include<algorithm>

using namespace std;

#define fup(i,a,b) for(int i=a;i<=b;++i)



int x[200004],y[200004];

void Main()

{

    int n,nn;

    scanf("%d",&n);

    nn=n/2;

    fup(i,1,n)scanf("%d",&x[i]),y[i]=x[i];

    sort(y,y+1+n);

    int t=y[nn],tz=y[nn-1],ty=y[nn+1],sz=0,sy=0;

    {

        int i=nn,j=nn;

        while(y[--i]==t)++sz;

        while(y[++j]==t)++sy;

    }

    if(sz&&sy)fup(i,1,n)printf("%d\n",t);

    else if(!sz&&sy)fup(i,1,n)printf("%d\n",t);

    else if(sz&&!sy)fup(i,1,n)

    {

        if(x[i]<=t)printf("%d\n",ty);

        else printf("%d\n",t);

    }

    else fup(i,1,n)

    {

        if(x[i]<=t)printf("%d\n",ty);

        else printf("%d\n",t);

    }

}

int main()

{

Main();

return 0;

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

using namespace std;

#define ll long long int

#define ld long double

#define pii pair<int,int>

#define pll pair<ll,ll>

#define rep(n) for(int i=0;i<n;i+=1)

#define prarr(a,n) rep(n) cout<<a[i]<<endl printf("%s\n"," " );

#define sc(a) scanf("%d",&a);

#define scl(a) scanf("%lld",&a);

#define scf(a) ascanf("%f",&a);

#define fi first

#define se second

#define pu push_back

#define inf 1000000001

#define MOD 1000000007 

#define INF 100000000000001

const int MAXN = 2e5+10;

int main()

{

    ios::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);

    map<int,vector<int>> m;

    map<int,int> ans;

    int n;

    pii a[MAXN];

    int b[MAXN]={0};

    cin>>n;

    rep(n) 

    {

        cin>>a[i].fi;

        a[i].se = i;

        // m[a[i]].pu(i);

    }

    sort(a,a+n);

    rep(n)

    {

        if((i+1)<=n/2)

            ans[a[i].se] = a[n/2].fi;

        else

            ans[a[i].se] = a[n/2-1].fi;     

    }

    rep(n)

    {

        cout<<ans[i]<<endl; 

    }

    return 0;



}

    

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

#include <ext/pb_ds/assoc_container.hpp> // Common file

#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update



using namespace std ;

using namespace __gnu_pbds;



typedef tree<

pair<int , int> ,

null_type,

less< pair<int , int> >,

rb_tree_tag,

tree_order_statistics_node_update>

ordered_set;



int main()

{

	ios_base::sync_with_stdio(0) ;

	cin.tie(0) ;

	int n ;

	cin>>n ;

	int arr[n] ;

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

		cin>>arr[i] ;

	ordered_set s ;

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

		s.insert({arr[i] , i}) ;

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

	{

		s.erase({arr[i] , i}) ;

		cout<<(*s.find_by_order(n/2-1)).first<<"\n";

		s.insert({arr[i], i}) ;

	}

	return 0 ;

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

using namespace std;

#define ll long long int

#define ld long double

#define pii pair<int,int>

#define pll pair<ll,ll>

#define rep(n) for(int i=0;i<n;i+=1)

#define prarr(a,n) rep(n) cout<<a[i]<<endl printf("%s\n"," " );

#define sc(a) scanf("%d",&a);

#define scl(a) scanf("%lld",&a);

#define scf(a) ascanf("%f",&a);

#define fi first

#define se second

#define pu push_back

#define inf 1000000001

#define MOD 1000000007 

#define INF 100000000000001

const int MAXN = 2e5+10;

int main()

{

    ios::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);

    map<int,vector<int>> m;

    map<int,int> ans;

    int n;

    pii a[MAXN];

    int b[MAXN]={0};

    cin>>n;

    rep(n) 

    {

        cin>>a[i].fi;

        a[i].se = i;

        // m[a[i]].pu(i);

    }

    sort(a,a+n);

    rep(n)

    {

        if((i+1)<=n/2)

            ans[a[i].se] = a[n/2].fi;

        else

            ans[a[i].se] = a[n/2-1].fi;     

    }

    rep(n)

    {

        cout<<ans[i]<<endl; 

    }

    return 0;



}

    

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



using namespace std;



int main() {

    ios_base::sync_with_stdio(0);

    cin.tie(0);



    int n, med;

    cin >> n;

    int arr[n], neww[n];



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

        cin >> arr[i], neww[i] = arr[i];



    sort(neww, neww + n);

    med = neww[n / 2 - 1];



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

        cout << (arr[i] <= med ? neww[n / 2] : neww[n / 2 - 1]) << '\n';



    return 0;

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

using namespace std;

#define ll long long int

#define ld long double

#define pii pair<int,int>

#define pll pair<ll,ll>

#define rep(n) for(int i=0;i<n;i+=1)

#define prarr(a,n) rep(n) cout<<a[i]<<endl printf("%s\n"," " );

#define sc(a) scanf("%d",&a);

#define scl(a) scanf("%lld",&a);

#define scf(a) ascanf("%f",&a);

#define fi first

#define se second

#define pu push_back

#define inf 1000000001

#define MOD 1000000007 

#define INF 100000000000001

const int MAXN = 2e5+10;

int main()

{

    ios::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);

    map<int,vector<int>> m;

    map<int,int> ans;

    int n;

    pii a[MAXN];

    int b[MAXN]={0};

    cin>>n;

    rep(n) 

    {

        cin>>a[i].fi;

        a[i].se = i;

        // m[a[i]].pu(i);

    }

    sort(a,a+n);

    rep(n)

    {

        if((i+1)<=n/2)

            ans[a[i].se] = a[n/2].fi;

        else

            ans[a[i].se] = a[n/2-1].fi;     

    }

    rep(n)

    {

        cout<<ans[i]<<endl; 

    }

    return 0;



}

    

// Faster C++ solution for the same problem (measured speedup: 2.655131383934995x):
//In The Name Of GOD



#include <bits/stdc++.h>



using namespace std;



typedef long long ll ;

typedef long double ld ;



const ll mod = 998244353;

const ll inf = 2000000000;

const ll infll = (ll)2*1000*1000*1000*1000*1000*1000;

const ll maxn = 2*1001+1;



#define pb push_back

#define pp pop_back

#define X first

#define Y second

#define IO ios_base::sync_with_stdio(false);



int main(){

	int n;

	cin >> n;

	const int m = n;

	pair<int,int> A[m];

	int where[m];

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

		cin>>A[i].X;

		A[i].Y=i;

	}

	sort(A,A+m);

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

		where[ A[i].Y ] = i;

	}

	int l = A[n/2-1].X, r = A[n/2].X;

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

		if(where[i]<n/2){

			cout << r << endl;

		}else{

			cout << l << endl;

		}

	}







}