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

using namespace std;

int n,v,l[200005],b,e;

int main()

{

    cin>>n;

    b=ceil((double)(n+1)/2);

    e=(n%2==0)?(-1):(1);

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

	{

        cin>>v;

        l[b]=v;

        b+=i*e;

        e*=-1;

    }

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

    cout<<l[i]<<" ";

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.31673988762541x):
// luogu-judger-enable-o2

#include<cstdio>

int n,a[200010];

inline int read(){

	int ret=0;char c=getchar();

	while(c<'0'||c>'9')c=getchar();

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

	return ret;

}

int main()

{

	n=read();

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

	for(register int i=n;i>0;i-=2)printf("%d ",a[i]);

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

	return 0;

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

#include <queue>

#include <algorithm>

using namespace std;

int n,a;

deque <int> q;

int main(){

    scanf("%d",&n);

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

        scanf("%d",&a);

        if(i&1) q.push_back(a);

        else q.push_front(a);

    }

    if(n&1) reverse(q.begin(),q.end());

    while(!q.empty()){

        int f=q.front();

        printf("%d ",f);

        q.pop_front();

    }

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.931827172758829x):
// luogu-judger-enable-o2

#include<cstdio>

int n,a[200010];

inline int read(){

	int ret=0;char c=getchar();

	while(c<'0'||c>'9')c=getchar();

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

	return ret;

}

int main()

{

	n=read();

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

	for(register int i=n;i>0;i-=2)printf("%d ",a[i]);

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

	return 0;

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

using namespace std;

int n,v,l[200005],b,e;

int main(){

    cin>>n;

    b=ceil((double)(n+1)/2);

    e=(n%2==0)?(-1):(1);

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

        cin>>v;

        l[b]=v;

        b+=i*e;

        e*=-1;

    }

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

    cout<<l[i]<<" ";

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.316669988131959x):
// luogu-judger-enable-o2

#include<cstdio>

int n,a[200010];

inline int read(){

	int ret=0;char c=getchar();

	while(c<'0'||c>'9')c=getchar();

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

	return ret;

}

int main()

{

	n=read();

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

	for(register int i=n;i>0;i-=2)printf("%d ",a[i]);

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

	return 0;

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

using namespace std;

long long a,k;

vector<int>n;

int main()

{

    cin>>a;

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

    {

        cin>>k;

        if((i+a+1)%2)n.push_back(k);

        else n.insert(n.begin(),k);

    }

    for(int i=0; i<a; i++)cout<<n[i]<<" ";

}

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

using namespace std;int n,a[200010];inline int read(){ register int ret=0;char c=getchar();while(c<'0'||c>'9')c=getchar();while(c>='0'&&c<='9')ret=(ret<<1)+(ret<<3)+(c^48),c=getchar();return ret;}int main(){n=read();for(register int i=1;i<=n;++i)a[i]=read();for(register int i=n;i>0;i-=2)printf("%d ",a[i]);for(register int i=(n&1)+1;i<=n;i+=2)printf("%d ",a[i]);return 0;}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

int n,v,l[200005],b,e;

int main()

{

    cin>>n;

    b=ceil((double)(n+1)/2);

    e=(n%2==0)?(-1):(1);

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

	{

        cin>>v;

        l[b]=v;

        b+=i*e;

        e*=-1;

    }

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

    cout<<l[i]<<" ";

    return 0;

}

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

using namespace std;int n,a[200010];inline int read(){ register int ret=0;char c=getchar();while(c<'0'||c>'9')c=getchar();while(c>='0'&&c<='9')ret=(ret<<1)+(ret<<3)+(c^48),c=getchar();return ret;}int main(){n=read();for(register int i=1;i<=n;++i)a[i]=read();for(register int i=n;i>0;i-=2)printf("%d ",a[i]);for(register int i=(n&1)+1;i<=n;i+=2)printf("%d ",a[i]);return 0;}
// Slower C++ solution:
#include <cstdio>

#include <queue>

#include <algorithm>

using namespace std;

int n,a;

deque <int> q;

int main(){

    scanf("%d",&n);

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

        scanf("%d",&a);

        if(i&1) q.push_back(a);

        else q.push_front(a);

    }

    if(n&1) reverse(q.begin(),q.end());

    while(!q.empty()){

        int f=q.front();

        printf("%d ",f);

        q.pop_front();

    }

    return 0;

}

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

using namespace std;int n,a[200010];inline int read(){ register int ret=0;char c=getchar();while(c<'0'||c>'9')c=getchar();while(c>='0'&&c<='9')ret=(ret<<1)+(ret<<3)+(c^48),c=getchar();return ret;}int main(){n=read();for(register int i=1;i<=n;++i)a[i]=read();for(register int i=n;i>0;i-=2)printf("%d ",a[i]);for(register int i=(n&1)+1;i<=n;i+=2)printf("%d ",a[i]);return 0;}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

int n,v,l[200005],b,e;

int main(){

    cin>>n;

    b=ceil((double)(n+1)/2);

    e=(n%2==0)?(-1):(1);

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

        cin>>v;

        l[b]=v;

        b+=i*e;

        e*=-1;

    }

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

    cout<<l[i]<<" ";

    return 0;

}

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

using namespace std;int n,a[200010];inline int read(){ register int ret=0;char c=getchar();while(c<'0'||c>'9')c=getchar();while(c>='0'&&c<='9')ret=(ret<<1)+(ret<<3)+(c^48),c=getchar();return ret;}int main(){n=read();for(register int i=1;i<=n;++i)a[i]=read();for(register int i=n;i>0;i-=2)printf("%d ",a[i]);for(register int i=(n&1)+1;i<=n;i+=2)printf("%d ",a[i]);return 0;}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

deque<int>d;

int n,ans,a;

int main() {

	ios::sync_with_stdio(false);

	cin >> n;

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

		cin >> a;

		if(i & 1)

			d.push_back(a);

		else

			d.push_front(a);

	}

	if(n & 1)

		reverse(d.begin(),d.end());

	deque<int>::iterator it;

	for(it = d.begin(); it != d.end(); it++)

		cout << *it << " ";

	cout << endl;

	return 0;

}

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

using namespace std;int n,a[200010];inline int read(){ register int ret=0;char c=getchar();while(c<'0'||c>'9')c=getchar();while(c>='0'&&c<='9')ret=(ret<<1)+(ret<<3)+(c^48),c=getchar();return ret;}int main(){n=read();for(register int i=1;i<=n;++i)a[i]=read();for(register int i=n;i>0;i-=2)printf("%d ",a[i]);for(register int i=(n&1)+1;i<=n;i+=2)printf("%d ",a[i]);return 0;}
// Slower C++ solution:
#include<iostream>

using namespace std;

int main() {

    int n; cin >> n;

    int a[n];

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

        cin >> a[i];

    }

    int b[2 * 100000 + 1] = {0};

    int st = n / 2;

    if (n % 2 == 0) {

        b[st] = a[0];

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

            int cont;

            if (i % 2 == 0) {

                cont = 1;

                cont *= i / 2;

            } else {

                cont = -1;

                cont *= i / 2 + 1;

            }

            b[st + cont] = a[i];

        }

    } else {

        b[st] = a[0];

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

            int cont;

            if (i % 2 == 0) {

                cont = -1;

                cont *= i / 2;

            } else {

                cont = 1;

                cont *= i / 2 + 1;

            }

            b[st + cont] = a[i];

        }

    }

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

        cout << b[i] << " ";

        if (i == n - 1) cout << endl;

    }

    return 0;

}


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

using namespace std;

typedef long long ll;

#define F first

#define S second

#define pii pair<int, int>

#define eb emplace_back

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

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

#define rep3(i, l, n) for (int i = l; i < (n); ++i)

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

#define inf (int)(1e9+7)

#define abs(x) (x >= 0 ? x : -(x))

#define ceil(a, b) a / b + !!(a % b)

template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

// template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }

template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }





int main() {

    deque<int> q;

    int n;

    cin >> n;

    rep(i, n) {

        int a;

        cin >> a;

        if (n % 2 == 0) {

            if (i % 2 == 0) {

                q.push_back(a);

            } else {

                q.push_front(a);

            }

        } else {

            if (i % 2 != 0) {

                q.push_back(a);

            } else {

                q.push_front(a);

            }

        }

    }

    rep(i, n) {

        if (i) cout << " ";

        cout << q.front();

        q.pop_front();

    }

    cout << endl;

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

using namespace std;

int n,x,a[500000];

int main(){

	scanf("%d",&n);

	int l=233333,r=233332;

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

		scanf("%d",&x);

		if (i&1) a[++r]=x;

		else a[--l]=x;

	}

	if (n&1)

		for (int i=r;i>=l;i--)

			printf("%d ",a[i]);

	else

		for (int i=l;i<=r;i++)

			printf("%d ",a[i]);

}

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

#include <string.h>

#define MAXN 100005



int main()

{

    int n;

    while(scanf("%d", &n) != EOF)

    {

        int a,num = n,flag = 1;

        int head[MAXN],tail[MAXN];

        int num_i = 0, num_j = 0;

        while(num--)

        {

            scanf("%d", &a);

            if(flag)

                tail[num_j++] = a;

            else

                head[num_i++] = a;

            flag = !flag;

        }

        if(n%2 == 0)

        {

            for(int i = num_i - 1; i >= 0; i--)

            {

                printf("%d ", head[i]);

            }

            for(int j = 0; j < num_j - 1; j++)

            {

                printf("%d ", tail[j]);

            }

            if(num_j)printf("%d\n", tail[num_j - 1]);

            else printf("\n");

        }

        else

        {

            for(int j = num_j - 1; j >= 0; j--)

            {

                printf("%d ", tail[j]);

            }

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

            {

                printf("%d ", head[i]);

            }

            if(num_i)printf("%d\n", head[num_i - 1]);

            else printf("\n");

        }

    }

    return 0;

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

#define N 400020

#define ll long long

using namespace std;

inline int read(){

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

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

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

	return f?x:-x;

}

int q[N];

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

	int n = read(), l = 200001, r = 200000;

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

		if (i & 1) q[++r] = read();

		else q[--l] = read();

	if (~ n & 1) for (int i = l; i <= r; i++) printf("%d ", q[i]);

	else for (int i = r; i >= l; i --) printf("%d ", q[i]);

	return 0;

}


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

#include <string.h>

#define MAXN 100005



int main()

{

    int n;

    while(scanf("%d", &n) != EOF)

    {

        int a,num = n,flag = 1;

        int head[MAXN],tail[MAXN];

        int num_i = 0, num_j = 0;

        while(num--)

        {

            scanf("%d", &a);

            if(flag)

                tail[num_j++] = a;

            else

                head[num_i++] = a;

            flag = !flag;

        }

        if(n%2 == 0)

        {

            for(int i = num_i - 1; i >= 0; i--)

            {

                printf("%d ", head[i]);

            }

            for(int j = 0; j < num_j - 1; j++)

            {

                printf("%d ", tail[j]);

            }

            if(num_j)printf("%d\n", tail[num_j - 1]);

            else printf("\n");

        }

        else

        {

            for(int j = num_j - 1; j >= 0; j--)

            {

                printf("%d ", tail[j]);

            }

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

            {

                printf("%d ", head[i]);

            }

            if(num_i)printf("%d\n", head[num_i - 1]);

            else printf("\n");

        }

    }

    return 0;

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

#include <cstring>

#include <cmath>

#include <deque>

#include <algorithm>

#include <iostream>

using namespace std;



#define rp(i,t) for(int i=0;i<(t);i++)

#define rep(i,s,t) for(int i=(s);i<=(t);i++)

#define rsp(i,s,t) for(int i=(s);i<(t);i++)

#define rrp(i,t,s) for(int i=(t);i>=(s);i--)

#define rcp(i,s,b,d) for(int i=(s);b;d)

#define mst(a,x) memset(a,x,sizeof(a))

#define INF 0x3f3f3f3f

#define N



#define Dp puts("")

#define Dw printf

#define Ds printf("#")



typedef long long ll;

bool b;

char ch;

int n,x;

deque<int> Q;



inline void read(int &x){x=0;do{ch=getchar();}while(ch<'0'||'9'<ch);do{x=x*10+ch-'0';ch=getchar();}while('0'<=ch&&ch<='9');}



int main(void)

{

	read(n);

	rep(i,1,n)

	{

		read(x);

		if(b)Q.push_front(x);

		else Q.push_back(x);

		b=!b;

	}

	if(b)

	{

		while(!Q.empty())

		{

			printf("%d ",Q.back());

			Q.pop_back();

		}

	}

	else

	{

		while(!Q.empty())

		{

			printf("%d ",Q.front());

			Q.pop_front();

		}

	}

	return 0;

}


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

#include <string.h>

#define MAXN 100005



int main()

{

    int n;

    while(scanf("%d", &n) != EOF)

    {

        int a,num = n,flag = 1;

        int head[MAXN],tail[MAXN];

        int num_i = 0, num_j = 0;

        while(num--)

        {

            scanf("%d", &a);

            if(flag)

                tail[num_j++] = a;

            else

                head[num_i++] = a;

            flag = !flag;

        }

        if(n%2 == 0)

        {

            for(int i = num_i - 1; i >= 0; i--)

            {

                printf("%d ", head[i]);

            }

            for(int j = 0; j < num_j - 1; j++)

            {

                printf("%d ", tail[j]);

            }

            if(num_j)printf("%d\n", tail[num_j - 1]);

            else printf("\n");

        }

        else

        {

            for(int j = num_j - 1; j >= 0; j--)

            {

                printf("%d ", tail[j]);

            }

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

            {

                printf("%d ", head[i]);

            }

            if(num_i)printf("%d\n", head[num_i - 1]);

            else printf("\n");

        }

    }

    return 0;

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

#define int long long

using namespace std;

int read(){

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

	int kk=1,k=0;if (c=='-')kk=-1,c=getchar();

	while (c>='0'&&c<='9')k=k*10+c-'0',c=getchar();return kk*k;

}int n,a[1000000],d;

signed main(){

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

	for (;d>=1;d-=2)cout<<a[d]<<' ';d+=2;if (d==2)d=1;else d=2;

	for (;d<=n;d+=2)cout<<a[d]<<' ';

}


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

#include <string.h>

#define MAXN 100005



int main()

{

    int n;

    while(scanf("%d", &n) != EOF)

    {

        int a,num = n,flag = 1;

        int head[MAXN],tail[MAXN];

        int num_i = 0, num_j = 0;

        while(num--)

        {

            scanf("%d", &a);

            if(flag)

                tail[num_j++] = a;

            else

                head[num_i++] = a;

            flag = !flag;

        }

        if(n%2 == 0)

        {

            for(int i = num_i - 1; i >= 0; i--)

            {

                printf("%d ", head[i]);

            }

            for(int j = 0; j < num_j - 1; j++)

            {

                printf("%d ", tail[j]);

            }

            if(num_j)printf("%d\n", tail[num_j - 1]);

            else printf("\n");

        }

        else

        {

            for(int j = num_j - 1; j >= 0; j--)

            {

                printf("%d ", tail[j]);

            }

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

            {

                printf("%d ", head[i]);

            }

            if(num_i)printf("%d\n", head[num_i - 1]);

            else printf("\n");

        }

    }

    return 0;

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

#include <algorithm> 

using namespace std;

int main()

{

	int n=0;

	cin>>n;

	int a[n];

	for(int i=0;i<n;i++) cin>>a[i];

	int b[n];

	int c=0;

	if(n%2==1){ //3       1 2 3

		for(int i=n-1;i>=0;i-=2){

			b[c]=a[i];//b[0]=3 b[1]=1

			c++;//1 2

		}

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

			b[c]=a[i];//b[2]=2

			c++;//3

		}

	}//3 1 2

	else{ //4      1 2 3 4

		for(int i=n-1;i>=1;i-=2){ 

			b[c]=a[i]; //b[0]=4 b[1]=2

			c++; //1 2

		}

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

			b[c]=a[i]; //b[2]=1 b[3]=3

			c++;//3

		}

	}//4 2 1 3

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

		cout<<b[i]<<" ";

	}

    return 0;

}


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

#include <string.h>

#define MAXN 100005



int main()

{

    int n;

    while(scanf("%d", &n) != EOF)

    {

        int a,num = n,flag = 1;

        int head[MAXN],tail[MAXN];

        int num_i = 0, num_j = 0;

        while(num--)

        {

            scanf("%d", &a);

            if(flag)

                tail[num_j++] = a;

            else

                head[num_i++] = a;

            flag = !flag;

        }

        if(n%2 == 0)

        {

            for(int i = num_i - 1; i >= 0; i--)

            {

                printf("%d ", head[i]);

            }

            for(int j = 0; j < num_j - 1; j++)

            {

                printf("%d ", tail[j]);

            }

            if(num_j)printf("%d\n", tail[num_j - 1]);

            else printf("\n");

        }

        else

        {

            for(int j = num_j - 1; j >= 0; j--)

            {

                printf("%d ", tail[j]);

            }

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

            {

                printf("%d ", head[i]);

            }

            if(num_i)printf("%d\n", head[num_i - 1]);

            else printf("\n");

        }

    }

    return 0;

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

using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;

#define INF 1<<30

#define LINF 1LL<<60



int main(void) {

    cin.tie(0); ios::sync_with_stdio(false);

    ll n; cin >> n;

    vector<ll> a(n);

    for(auto& in:a) cin >> in;

    

    deque<ll> dep;

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

        if(i%2 == 0){

            dep.push_back(a[i]);

        }else{

            dep.push_front(a[i]);

        }

    }

    vector<ll> res(dep.begin(),dep.end());

    if(n%2==1)reverse(res.begin(), res.end());

    for(auto v:res){

        cout << v << " ";

    }

    cout << endl;

    return 0;

}


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

#include <string.h>

#define MAXN 100005



int main()

{

    int n;

    while(scanf("%d", &n) != EOF)

    {

        int a,num = n,flag = 1;

        int head[MAXN],tail[MAXN];

        int num_i = 0, num_j = 0;

        while(num--)

        {

            scanf("%d", &a);

            if(flag)

                tail[num_j++] = a;

            else

                head[num_i++] = a;

            flag = !flag;

        }

        if(n%2 == 0)

        {

            for(int i = num_i - 1; i >= 0; i--)

            {

                printf("%d ", head[i]);

            }

            for(int j = 0; j < num_j - 1; j++)

            {

                printf("%d ", tail[j]);

            }

            if(num_j)printf("%d\n", tail[num_j - 1]);

            else printf("\n");

        }

        else

        {

            for(int j = num_j - 1; j >= 0; j--)

            {

                printf("%d ", tail[j]);

            }

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

            {

                printf("%d ", head[i]);

            }

            if(num_i)printf("%d\n", head[num_i - 1]);

            else printf("\n");

        }

    }

    return 0;

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



using namespace std;



int main() {

	int n, m;

	scanf("%d", &n);

	m = n;



	int a[n];



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

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

	}



	while (n > 0) {

		printf("%d ", a[n - 1]);

		n -= 2;

	}

	if (n % 2) {

		n = 2;

	} else {

		n = 1;

	}

	while (n < m) {

		printf("%d ", a[n - 1]);

		n += 2;

	}





	return 0;

}

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

#include <string.h>

#define MAXN 100005



int main()

{

    int n;

    while(scanf("%d", &n) != EOF)

    {

        int a,num = n,flag = 1;

        int head[MAXN],tail[MAXN];

        int num_i = 0, num_j = 0;

        while(num--)

        {

            scanf("%d", &a);

            if(flag)

                tail[num_j++] = a;

            else

                head[num_i++] = a;

            flag = !flag;

        }

        if(n%2 == 0)

        {

            for(int i = num_i - 1; i >= 0; i--)

            {

                printf("%d ", head[i]);

            }

            for(int j = 0; j < num_j - 1; j++)

            {

                printf("%d ", tail[j]);

            }

            if(num_j)printf("%d\n", tail[num_j - 1]);

            else printf("\n");

        }

        else

        {

            for(int j = num_j - 1; j >= 0; j--)

            {

                printf("%d ", tail[j]);

            }

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

            {

                printf("%d ", head[i]);

            }

            if(num_i)printf("%d\n", head[num_i - 1]);

            else printf("\n");

        }

    }

    return 0;

}