Language: C++

/*       Rohan Balot
    NSIT, New Delhi, India  */
#include <algorithm>
#include <bitset>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <utility>
#include <unordered_set>
#include <unordered_map>
#include <valarray>
     
#include <cctype>
#include <cstdio>
#include <cmath>
#include <climits>
#include <cstring>
#include <ctime>
using namespace std;
     
#define FIND(c, e) (c).find(e) != (c).end()
#define NFIND(c, e) (c).find(e) == (c).end()
#define ALL(t) (t).begin(), (t).end()
#define ALLR(t) (t).rbegin(), (t).rend()
#define MP make_pair
     
const int N = int( 1e5 ) + 1;
const int M = int( 1e6 ) + 1;
const int MOD = int( 1e9 ) + 7;
const double PI = acos(-1.0);
const double eps = 1e-6;
template<typename T> T gcd(T a,T b){while (b){ T r=a%b;a=b;b=r;}return a;}
template<typename T> T lcm(T a,T b){return (a*b)/gcd(a,b);}

struct graph {
	int vertices;
	int edges;
	vector< vector<int> > adj;
	vector< bool > visited;
	vector< int > level;
	graph() { }
	graph(int vertices) {
		this->adj.resize(vertices + 1);
		this->level.resize(vertices + 1, -1);
		this->visited.resize(vertices + 1, false);
		this->vertices = vertices;
		edges = 0;
	}
	void add_directed_edge(int from, int to) {
		this->adj[from].emplace_back(to);
		this->edges++;
	}	
	void add_undirected_edge(int from, int to) {
		this->adj[from].emplace_back(to);
		this->adj[to].emplace_back(from);
		this->edges += 2;
	}
	void read_undirected_edges(int edge_count) {
		this->edges += edge_count << 1;
		for (int i = 0; i < edge_count; i++) {
			int from, to;
			cin >> from >> to;
			this->adj[from].emplace_back(to);
			this->adj[to].emplace_back(from);
		}
	}	
	void read_directed_edges(int edge_count) {
		this->edges += edge_count;
		for (int i = 0; i < edge_count; i++) {
			int from, to;
			cin >> from >> to;
			this->adj[from].emplace_back(to);
		}
	}
	void dfs(int src) {
		this->visited[src] = true;
		for(int i : this->adj[src]) {
			if(this->visited[i] == false) {
				this->dfs(i);
			}
		}
	}
	void bfs(int src) {
		this->level[src] = 0;
		queue<int> q;
		q.push(src);
		while (!q.empty()) {
			int cur = q.front();
			q.pop();
			for(int i : this->adj[cur]) {
				if(this->level[i] == -1) {
					this->level[i] = this->level[cur] + 1;
					q.push(i);
				}
			}
		}
	}
};

void __answer()
{
	int n;
	cin >> n;
	list<int> l;
	if(n % 2 == 1) {
		for (int i = 1; i <= n; i++) {
			int e;
			cin >> e;
			if(i % 2 == 0)
				l.push_back(e);
			else l.push_front(e);
		}
	} else {
		for (int i = 1; i <= n; i++) {
			int e;
			cin >> e;
			if(i % 2 == 1)
				l.push_back(e);
			else l.push_front(e);
		}
	}
	for (auto i : l) {
		cout << i << " ";
	}
}    
int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    #ifdef LOCAL
        freopen("sample_input.txt", "r", stdin);
    #endif
    __answer();
    return 0;
} 

Compiler output:
a.cc: In function 'void __answer()':
a.cc:113:9: error: 'list' was not declared in this scope
  113 |         list<int> l;
      |         ^~~~
a.cc:28:1: note: 'std::list' is defined in header '<list>'; this is probably fixable by adding '#include <list>'
   27 | #include <ctime>
  +++ |+#include <list>
   28 | using namespace std;
a.cc:113:14: error: expected primary-expression before 'int'
  113 |         list<int> l;
      |              ^~~
a.cc:119:33: error: 'l' was not declared in this scope
  119 |                                 l.push_back(e);
      |                                 ^
a.cc:120:30: error: 'l' was not declared in this scope
  120 |                         else l.push_front(e);
      |                              ^
a.cc:127:33: error: 'l' was not declared in this scope
  127 |                                 l.push_back(e);
      |                                 ^
a.cc:128:30: error: 'l' was not declared in this scope
  128 |                         else l.push_front(e);
      |                              ^
a.cc:131:23: error: 'l' was not declared in this scope
  131 |         for (auto i : l) {
      |                       ^