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

using namespace std;

int a[200010];

int flag;

int n,m;

int main() {

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

	flag=0;

	int u,v;

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

		a[i]=0;

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

		scanf("%d%d",&u,&v);

		if(flag)

			continue;

		if(u==1) {

			if(a[v]) {

				flag=1;

			}

			a[v]=1;

		}



		else if(v==n) {

			if(a[u]) {

				flag=1;

			}

			a[u]=1;

		}



	}

	if(flag)

		printf("POSSIBLE\n");

	else printf("IMPOSSIBLE\n");



	return 0;

}




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

using namespace std;

#define N 1000001



int arrr1[N+5],arrr2[N+5];

int main()

{

    int n,m,a,b;



    cin>>n>>m;

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

    {

        cin>>a>>b;

        if(a==1)

            arrr1[b]=1;//第一次的终点

        if(b==n)

            arrr2[a]=1;//第二次的起点

    }



    int p=0;

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

    {

        if(arrr1[i]&&arrr2[i])

        {

            cout<<"POSSIBLE"<<endl;

            p=1;

        }

    }



    if(p==0)

        cout<<"IMPOSSIBLE"<<endl;



    return 0;

}




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

#include<cstdio>

using namespace std;

int i,j,n,m,x[200003]= {0},a,b,num=0,num1=0;

int main()

{

    cin>>n>>m;

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

    {

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

        if(a==1)

            x[b]++;

        if(b==n)

            x[a]++;

    }

    int flag=0;

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

    {

        if(x[i]==2)

        {

            flag=1;

            break;

        }

    }

    if(flag==1)

        cout<<"POSSIBLE"<<endl;

    else

        cout<<"IMPOSSIBLE"<<endl;

}


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

using namespace std;

#define N 1000001



int arrr1[N+5],arrr2[N+5];

int main()

{

    int n,m,a,b;



    cin>>n>>m;

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

    {

        cin>>a>>b;

        if(a==1)

            arrr1[b]=1;//第一次的终点

        if(b==n)

            arrr2[a]=1;//第二次的起点

    }



    int p=0;

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

    {

        if(arrr1[i]&&arrr2[i])

        {

            cout<<"POSSIBLE"<<endl;

            p=1;

        }

    }



    if(p==0)

        cout<<"IMPOSSIBLE"<<endl;



    return 0;

}




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

#include <vector>

#include <cmath>

#include <algorithm>

#include <cstring>

#include <string>

#include <map>

#include <stack>

#define ll long long

#define pii pair<int, int>

using namespace std;

int n,m;

int a1[200004],a2[200004];

int main()

{

    cin>>n>>m;int f=0;

    memset(a1,-1,sizeof(a1));

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

    {

        int x,y;

        cin>>x>>y;

        if(x==1 )

        {

            a1[y]=1;

        }

        else if(y == 1)

        {

            a1[x]=1;

        }

        else if (y==n)

        {

            a2[x]=1;

        }

        else if( x == n)

        {

            a2[y] = 1;

        }



    }

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

        if(a1[i] == 1 && a2[i] == 1){

            cout<<"POSSIBLE" << endl;

            return 0;

        }

    }



  if(a2[1] || a1[n] == 1){

      cout<<"POSSIBLE" << endl;

            return 0;

       

  }

 cout<<"IMPOSSIBLE"<<endl;



    return 0;

}

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

using namespace std;

#define N 1000001



int arr1[N+5],arr2[N+5];

int main()

{

    int n,m,a,b;



    cin>>n>>m;

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

    {

        cin>>a>>b;

        if(a==1)

            arr1[b]=1;//第一次的终点

        if(b==n)

            arr2[a]=1;//第二次的起点

    }



    int p=0;

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

    {

        if(arr1[i]&&arr2[i])

        {

            cout<<"POSSIBLE"<<endl;

            p=1;

        }

    }



    if(p==0)

        cout<<"IMPOSSIBLE"<<endl;



    return 0;

}




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

#include<queue>

using namespace std;



typedef pair<int,int> P;



int a[200005];

vector<int>v[200005];



queue<P>q;

bool vis[200005];





int main()

{

    int n,m;

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

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

    {

        int q,w;

        scanf("%d%d",&q,&w);

        v[q].push_back(w);

        v[w].push_back(q);

    }

    vis[1]=true;

    q.push(P(1,0));

    int ans=0x3f3f3f3f;

    while(!q.empty())

    {

        P pai=q.front();

        q.pop();

        if(pai.second==3)

            break;

        if(pai.first==n)

        {

            ans=pai.second;

            break;

        }

        for(int i=0;i<v[pai.first].size();i++)

            if(vis[v[pai.first][i]]==false)

        {

            vis[v[pai.first][i]]=true;

            q.push(make_pair(v[pai.first][i],pai.second+1));

        }

    }

    if(ans>2)

        puts("IMPOSSIBLE");

    else

        puts("POSSIBLE");

    return 0;

}


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

using namespace std;

#define N 1000001



int arr1[N+5],arr2[N+5];

int main()

{

    int n,m,a,b;



    cin>>n>>m;

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

    {

        cin>>a>>b;

        if(a==1)

            arr1[b]=1;//第一次的终点

        if(b==n)

            arr2[a]=1;//第二次的起点

    }



    int p=0;

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

    {

        if(arr1[i]&&arr2[i])

        {

            cout<<"POSSIBLE"<<endl;

            p=1;

        }

    }



    if(p==0)

        cout<<"IMPOSSIBLE"<<endl;



    return 0;

}




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

#include <cstring>

using namespace std;

int a[200005];

int b[200005];

bool vis[200005];

int main(){

	int N,M,i;

	cin>>N>>M;

	memset(vis,false,sizeof(vis));

	for(i=0;i<M;i++){

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

		if(a[i]==1)

			vis[b[i]]=true;

	}

	for(i=0;i<M;i++){

		if(b[i]==N){

			if(vis[a[i]]==true){

				cout<<"POSSIBLE"<<endl;

				break;

			}

		}

	}

	if(i==M)

		cout<<"IMPOSSIBLE"<<endl;

	return 0;

} 

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

#include<vector>

#include<set>

using namespace std;

const int maxn = 200005;

int num[2][maxn];

int mm[maxn];

int main()

{

	int n, m;

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

	int len1 = 0, len2 = 0;

	while (m--)

	{

		int a, b;

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

		if (a == 1)

		{

			num[0][len1++] = b;

		}

		if (a == n){

			num[1][len2++] = b;

		}

		if (b == n){

			num[1][len2++] = a;

		}

		if (b == 1){

			num[0][len1++] = a;

		}

	}

	bool flag = 0;

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

	{

		mm[num[0][i]] = 1;

		if (num[0][i] == n){

			flag = 1;  break;

		}

	}

	if (!flag)

	for (int j = 0; j < len2;++j)

	if (mm[num[1][j]]){ flag = 1; break; }





	if (flag){

		printf("POSSIBLE\n");

	}

	else

	{

		printf("IMPOSSIBLE\n");

		}

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
//周♂雨扬是最强的！！！

//大佬祝您AK

//沈哲♂贝是最强的！！！

#include<iostream>

#include<algorithm>

#include<cmath>

#include<cstring>

#include<fstream>

using namespace std;

//ifstream fin(.in);

//ofstream fout(.out);

int n,head,tail;

int num[800003];

int main(){

	cin>>n;

	int head=300001,tail=300000;

	bool ok=!(n&1);

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

		int x;

		cin>>x;

		if(ok){

			num[head++]=x;

		}else{

			num[tail--]=x;

		}

		ok^=1;

	}

	for(int i=tail+1;i<=head-1;i++){

		cout<<num[i]<<" ";

	}

	return 0;

}

//沈♂哲贝是最强的！！！

//大佬祝您AK

//周♂雨扬是最强的！！！

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

using namespace std;

const int MAX = 2e5 + 5;

int a[MAX];

int main() {

	int n;

	int f, b, temp;

	bool odd = false;

	scanf("%d", &n);

	int m = n / 2;

	if (n % 2 != 0)

		odd = true;

	f = m - 1;

	b = m + 1;

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

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

	{

		if (i % 2 != 0) {

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

			f--;

		}

		else

		{

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

			b++;

		}	

	}

	

	if (odd) {

		for (int i = n-1; i != 0; i--)

		{

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

		}

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

	}

	else

	{

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

		{

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

		}

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

	}

	

	return 0;

}

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

using namespace std;



using VS = vector<string>;    using LL = long long;

using VI = vector<int>;       using VVI = vector<VI>;

using PII = pair<int, int>;   using PLL = pair<LL, LL>;

using VL = vector<LL>;        using VVL = vector<VL>;



#define ALL(a)  begin((a)),end((a))

#define RALL(a) (a).rbegin(), (a).rend()

#define PB push_back

#define EB emplace_back

#define MP make_pair

#define SZ(a) int((a).size())

#define SORT(c) sort(ALL((c)))

#define RSORT(c) sort(RALL((c)))

#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)

#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)

#define debug(x) cerr << #x << ": " << x << endl

const int INF = 1e9;                          const LL LINF = 1e16;

const LL MOD = 1000000007;                    const double PI = acos(-1.0);

int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };



/* -----  2017/11/29  Problem: 077_arc_c / Link: https://arc077.contest.atcoder.jp/tasks/arc077_a  ----- */

/* ------問題------



-----問題ここまで----- */

/* -----解説等-----



dequeさん…はじめて会ったね



----解説ここまで---- */



LL N;



LL ans = 0LL;



int main() {

	cin.tie(0);

	ios_base::sync_with_stdio(false);



	deque<int>dq;

	cin >> N;

	FOR(i, 0, N) {

		int a; cin >> a;

		if (SZ(dq) % 2 == N%2) { dq.push_back(a); }

		else { dq.push_front(a); }

	}

	FOR(i, 0, N) {

		cout << dq.front() << (i != N - 1 ? ' ' : '\n');

		dq.pop_front();

	}



	return 0;

}


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

using namespace std;

const int MAX = 2e5 + 5;

int a[MAX];

int main() {

	int n;

	int f, b, temp;

	bool odd = false;

	scanf("%d", &n);

	int m = n / 2;

	if (n % 2 != 0)

		odd = true;

	f = m - 1;

	b = m + 1;

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

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

	{

		if (i % 2 != 0) {

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

			f--;

		}

		else

		{

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

			b++;

		}	

	}

	

	if (odd) {

		for (int i = n-1; i != 0; i--)

		{

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

		}

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

	}

	else

	{

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

		{

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

		}

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

	}

	

	return 0;

}

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

using namespace std;

const int maxn=2e5+105;

int ax[maxn],bx[maxn];

int main()

{

    int n;

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

    {

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

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

        int l=0,r=n-1,index=n-1,cnt=0;

        while(1)

        {

           if(cnt%2==0)

             bx[l++]=ax[index--];

           else

             bx[r--]=ax[index--];

           cnt++;

           if(n%2==0&&r==(n/2)-1)

             break;

           if(n%2==1&&l==n/2+1)

               break;

        }

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

        {

            if(i!=0)

                printf(" ");

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

        }

        printf("\n");

    }





    return 0;

}


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

using namespace std;

const int MAX = 2e5 + 5;

int a[MAX];

int main() {

	int n;

	int f, b, temp;

	bool odd = false;

	scanf("%d", &n);

	int m = n / 2;

	if (n % 2 != 0)

		odd = true;

	f = m - 1;

	b = m + 1;

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

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

	{

		if (i % 2 != 0) {

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

			f--;

		}

		else

		{

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

			b++;

		}	

	}

	

	if (odd) {

		for (int i = n-1; i != 0; i--)

		{

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

		}

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

	}

	else

	{

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

		{

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

		}

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

	}

	

	return 0;

}

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

using namespace std;



int main()

{

	int n;

	cin >> n;

	long long int *b;

	int k = n / 2;

	int var = 0;

	var = n - 2 * k;

	b = new long long int[n];

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

		cin >> b[k];

		if (var == 0) {

			k -= i;

			var++;

		}

		else {

			k += i;

			var--;

		}

	}

	cout << b[0];

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

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

	}

	return 0;

}




// Optimized solution to the same problem (faster):
#include<stdio.h>

int main()

{

	int n,i,j;

	scanf("%d",&n);

	long int b[n]={0};

	long int a[n]={0};

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

	{

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

	}

		for(i=n-1,j=0;i>=0;i=i-2,j++)

		{

			b[j]=a[i];

			if(i!=0)

			b[n-j-1]=a[i-1];

			

		}

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

		{

			printf("%ld ",b[i]);

		}

		return 0;

 } 

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

#include <iostream>

#include <cstring>

#include <cstdio>

#include <cmath>



using namespace std;



int a[300000],b[300000];



int main ()

{

	int n,m;

	scanf ("%d",&n);

	m=n;

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

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

	int j=0;

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

		b[++j]=a[i];

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

		b[m--]=a[i];

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

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

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

	return 0;

}


// Optimized solution to the same problem (faster):
#include<stdio.h>

int main()

{

	int n,i,j;

	scanf("%d",&n);

	long int b[n]={0};

	long int a[n]={0};

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

	{

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

	}

		for(i=n-1,j=0;i>=0;i=i-2,j++)

		{

			b[j]=a[i];

			if(i!=0)

			b[n-j-1]=a[i-1];

			

		}

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

		{

			printf("%ld ",b[i]);

		}

		return 0;

 } 

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

#include <cstdio>

#include <cstdlib>



using namespace std;



#define N 200008



int n;

int a[N],b[N];



void solve()

{

	int len = 0;

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

		b[++len] = a[i];

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

		b[len--] = a[i];

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

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

	printf("\n");

}



void init()

{

	scanf("%d", &n);

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

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

}



int main()

{

	init();

	solve();

	return 0; 

} 

// Optimized solution to the same problem (faster):
#include<stdio.h>

int main()

{

	int n,i,j;

	scanf("%d",&n);

	long int b[n]={0};

	long int a[n]={0};

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

	{

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

	}

		for(i=n-1,j=0;i>=0;i=i-2,j++)

		{

			b[j]=a[i];

			if(i!=0)

			b[n-j-1]=a[i-1];

			

		}

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

		{

			printf("%ld ",b[i]);

		}

		return 0;

 } 

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



using namespace std;



const int MAXN = 2*(1e5 + 100);



int main () {

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

	scanf ("%d", &n);

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

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

	int m = n >> 1;

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

		b[i] = a[n - (i << 1) + 2];

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

	}

	if (n & 1)

		b[m + 1] = a[1];

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

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

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

	return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

int main()

{

	int n,i,j;

	scanf("%d",&n);

	long int b[n]={0};

	long int a[n]={0};

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

	{

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

	}

		for(i=n-1,j=0;i>=0;i=i-2,j++)

		{

			b[j]=a[i];

			if(i!=0)

			b[n-j-1]=a[i-1];

			

		}

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

		{

			printf("%ld ",b[i]);

		}

		return 0;

 } 

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

using namespace std;



int a[200000];

int n,i;

void init()

{

    cin >> n;

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

    {

		cin >> a[i];

	}

}

int main()

{

    init();

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

    {

		cout << a[i] << " ";

	}

	i++;

	if (n % 2) i += 2;

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

	{

        cout << a[i] << " ";

	}

	return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

int main()

{

	int n,i,j;

	scanf("%d",&n);

	long int b[n]={0};

	long int a[n]={0};

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

	{

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

	}

		for(i=n-1,j=0;i>=0;i=i-2,j++)

		{

			b[j]=a[i];

			if(i!=0)

			b[n-j-1]=a[i-1];

			

		}

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

		{

			printf("%ld ",b[i]);

		}

		return 0;

 } 

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



using namespace std;



int main()

{

	int n,k;

	long long int*a;

	int temp=1;

	cin>>n; 

	k=n/2;

	a = new long long int[n];

	if(n-2*k)

	{

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

			

			if(temp==1)

			{

				cin>>a[k];

				temp++;

			}

			else 

			{

				if(temp%2==1)

					cin>>a[k-temp/2];

				else

					cin>>a[k+temp/2];

				temp++;

			}

		}

 	}

 	else

 	{

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

			

			if(temp==1)

			{

				cin>>a[k];

				temp++;

			}

			else 

			{

				if(temp%2==0)

					cin>>a[k-temp/2];

				else

					cin>>a[k+temp/2];

				temp++;

			}

		}

	 }

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

	 	cout<<a[i]<<' ';

	return 0;

 }

  

// Optimized solution to the same problem (faster):
#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;

}


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

#include <cstdio> 

using namespace std;

int n, a[200005];

int main()

{

	while(cin >> n)

	{

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

		{

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

		}

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

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

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

		printf("\n");

	}

    return 0;

}

// Optimized solution to the same problem (faster):
#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;

}


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

using namespace std;

int main()

{const int size=2e+5;

int a[size],b[size];

int n;

cin>>n;



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

{cin>>a[i];

}



for(int i=n-1,j=0,k=n-1;i>-1;i--)

{

	

	

	b[j++]=a[i--];

	

	if(i<0)

	break;

	

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



}





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

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

}

return 0;

 } 

// Optimized solution to the same problem (faster):
#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;

}


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

using namespace std;



deque<int> Q;



int main() {

    int n, num;

    cin >> n;

    bool flag = 1;

    while (n--) {

        scanf("%d", &num);

        if (flag)

            Q.push_front(num);

        else

            Q.push_back(num);

        flag = !flag;

    }

    if (!flag) {

        for (auto i = Q.begin(); i != Q.end(); i++) {

            if (i == Q.begin())

                cout << *i;

            else

                cout << " " << *i;

        }

        cout << endl;

    } else {

        for (auto i = Q.rbegin(); i < Q.rend(); i++) {

            if (i == Q.rbegin())

                cout << *i;

            else

                cout << " " << *i;

        }

        cout << endl;

    }

    cout << endl;

    return 0;

}

// Optimized solution to the same problem (faster):
#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;

}


// Fastest known solution for this problem: