Problem:


Score : 300 points

Problem Statement

You are given an integer sequence of length n, a_1, ..., a_n.
Let us consider performing the following n operations on an empty sequence b.

The i-th operation is as follows:

Append a_i to the end of b.

Reverse the order of the elements in b.

Find the sequence b obtained after these n operations.

Constraints

1 \leq n \leq 2\times 10^5

0 \leq a_i \leq 10^9

n and a_i are integers.

Input

Input is given from Standard Input in the following format:

n
a_1 a_2 ... a_n

Output

Print n integers in a line with spaces in between.
The i-th integer should be b_i.

Sample Input 1

4
1 2 3 4

Sample Output 1

4 2 1 3

After step 1 of the first operation, b becomes: 1.

After step 2 of the first operation, b becomes: 1.

After step 1 of the second operation, b becomes: 1, 2.

After step 2 of the second operation, b becomes: 2, 1.

After step 1 of the third operation, b becomes: 2, 1, 3.

After step 2 of the third operation, b becomes: 3, 1, 2.

After step 1 of the fourth operation, b becomes: 3, 1, 2, 4.

After step 2 of the fourth operation, b becomes: 4, 2, 1, 3.

Thus, the answer is 4 2 1 3.

Sample Input 2

3
1 2 3

Sample Output 2

3 1 2

As shown above in Sample Output 1, b becomes 3, 1, 2 after step 2 of the third operation. Thus, the answer is 3 1 2.

Sample Input 3

1
1000000000

Sample Output 3

1000000000

Sample Input 4

6
0 6 7 6 7 0

Sample Output 4

0 6 6 0 7 7



Sample input:
4
1 2 3 4


Sample output:
4 2 1 3

Submission status: Runtime Error

Solution code:

import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

import java.util.*;

public class Main {
    long MOD = (long) 1e9 + 7;

    InputStream in;
    OutputStream out;

    public Main() {
        this(System.in, System.out);
    }

    public Main(InputStream in, OutputStream out) {
        this.in = in;
        this.out = out;
    }

    void run() {
        Scanner sc = new Scanner(this.in);
        PrintWriter out = new PrintWriter(this.out);

        // write your code
        int n = sc.nextInt();
        LinkedList<Integer> b = new LinkedList<>();

        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            if (i % 2 == 0) {
                b.addLast(a);
            } else {
                b.addFirst(a);
            }
        }

        boolean f = true;

        for (int i = 0; i < n; i++) {
            int x = n % 2 == 0 ? b.removeFirst() : b.removeLast();
            if (f) {
                f = false;
                out.print(x);
            } else {
                out.print(" " + x);
            }
        }

        out.println();

        out.flush();
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}

Submission status: Runtime Error

Solution code:
6
0 6 7 6 7 0

Submission status: Runtime Error

Solution code:
import collections
def solve():
  n = int(input())
  a = list(map(int, input().split()))
  b = collections.deque()
  for i in range(n):
    if i % 2 == n % 2:
      b.append(a[i])
    else:
      b.insert(0,a[i])
  b = map(str, b)
  print(" ".join(b))
  return 0
 
if __name__ == "__main__":
  solve()

Submission status: Runtime Error

Solution code:
import numpy as np
import functools
import math
import collections
import scipy
import fractions
import itertools

def solve():
  n = int(input())
  a = list(map(int, input().split()))
  b = collections.deque()
  for i in range(n):
    if i % 2 == n % 2:
      b.append(a[i])
    else:
      b.insert(0,a[i])
  b = map(str, b)
  print(" ".join(b))
  return 0
 
if __name__ == "__main__":
  solve()

Submission status: Runtime Error

Solution code:
import numpy as np
import functools
import math
import collections
import scipy
import fractions
import itertools

def solve():
  n = int(input())
  a = list(map(int, input().split()))
  b = collections.deque()
  for i in range(n):
    if i % 2 == 1:
      b.insert(0,a[i])
    else:
      b.append(a[i])
  b = map(str, b)
  print(" ".join(b))
  return 0
 
if __name__ == "__main__":
  solve()

Submission status: Runtime Error

Solution code:
n = int(input())
As = list(map(str, input().split()))

from collections import deque
b = []
b = deque(b)

for i, a in enumerate(As):
    if i%2==0:
        b.append(a)
    else:
        b.appendleft(a)

if n%2==0:
    print(' '.join(b))
else:
    print(' '.join(b[::-1]))

Submission status: Runtime Error

Solution code:
n=int(input())
A=list(map(int,input().split()))
print(*A[::-2],*A[n%2::2])

Submission status: Runtime Error

Solution code:
n = int(input())
A = list(map(int,input().split()))
from collections import deque

B = deque([])

for i in range(n):
  if i %2:
    B.appendleft(A[i])
  else:
    B.append(A[i])
    
if n%2:
  B = B[::-1]
print(*B)

Submission status: Runtime Error

Solution code:
n = int(input())
A = list(map(int,input().split()))

B = []

for i in range(n):
  if i %2:
    B = [A[i]] + B
  else:
    B = B.append(A[i])
    
if n%2:
  B = B[::-1]
print(*B)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####GCD#####
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n = n//a
    count += 1
  if a**count == n:
    return count
  else:
    return count+1

#############
# Main Code #
#############

N = I()
A = IL()

iti = A[::2]
ni = A[1::2]

if N % 2:
  print(*((ni[::-1]+iti)[::-1]),sep=" ")
else:
print(*(ni[::-1]+iti),sep=" ")

Submission status: Runtime Error

Solution code:
N=int(input())
A=list(map(int,input().split())
print(*A[::-2],*A[N%2::2])

Submission status: Runtime Error

Solution code:
import java.util.*;
public class Main {
	public static void main(String[] args)  {
		Scanner scan = new Scanner(System.in);
		int n = Integer.parseInt(scan.next());
		Vector<Integer> left = new Vector<>();
		Vector<Integer> right= new Vector<>();
		for (int i = 0;i < n; ++i){
			if (i%2 == 0){
				right.add(Integer.parseInt(scan.next()));
			}else{
				left.add(Integer.parseInt(scan.next()));
			}
		}

		for (int i = left.size()-1;i >=0; --i ){
			System.out.print(left.elementAt(i)+" ");
		}
		int size = right.size();
		for(int i = 0; i < size; ++i){
			System.out.print(right.elementAt(i)+" ");
		}





	}
}
//end

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
even = []
odd = []
for i in range(n):
    if i % 2:
        even.append(a[i])
    else:
        odd.append(a[i])
if n % 2 == 0:
    print(*even[::-1], *odd)
else:
    print(*odd[::-1], *even)

Submission status: Runtime Error

Solution code:

from collections import  deque
n = int(input())
lst = list(map(int,input().split()))
reverse = False
b = deque()
for a in lst:
	if reverse:
		b.appendleft(a)
	else:
		b.append(a)
	reverse = not reverse

answer =[]
if reverse:
	while b:
		answer.append(b.pop())
else:
	while b:
		answer.append(b.popleft())

print(" ".join(answer))

Submission status: Runtime Error

Solution code:
from collections import deque

n = int(input())
a = list(map(int, input().split()))
s = deque([])

for i in range(n):
    if i%2==1:
        s.insert(0, a[i])
    else:
        s.append(a[i])
if n%2 == 1:
    s.reverse()
print(*s)

Submission status: Runtime Error

Solution code:
from collections import deque

n = int(input())
a = list((map(int, input().split())))
s = deque([])

for i in range(n):
    if i%2==1:
        s.insert(0, a[i])
    else:
        s.append(a[i])
if n%2 == 1:
    s.reverse()
print(*s)

Submission status: Runtime Error

Solution code:
from collections import deque

n = int(input())
a = list((map(int, input().split())))
s = deque([])

for i in range(n):
    if i%2==1:
        s.insert(0, a[i])
    else:
        s.append(a[i])

print(*s)

Submission status: Runtime Error

Solution code:
from collections import deque
n = int(input())
list_A = list(map(int, input().split()))
ans = deque()
for i in range(n):
    if i % 2 == 0:
        ans.append(list_A[i])
    else:
        ans.insert(0, list_A[i])

if n % 2 == 1:
    ans.reverse()
print(*ans)

Submission status: Runtime Error

Solution code:
from collections import deque
N=int(input())
A=list(map(int,input().split()))
l=deque()
for i in range(N):
  if i%2==0:
    l.append(A[i])
  else:
    l.appendleft(A[i])
print(*l if N%2==0 else *list(revrsed(l)))

Submission status: Runtime Error

Solution code:
from collections import deque
N=int(input())
A=list(map(int,input().split()))
B=[]
for i in range(N):
  B.append(A[i])
  B=reversed(B)
print("".join(B))

Submission status: Runtime Error

Solution code:
import sys
from collections import deque

n, *a = map(int, sys.stdin.read().split())

def main():
    b = deque()
    for i in range(n):
        if (i & 1): b.appendleft(a[i])
        else: b.append(a[i])
    if (n & 1): b = b[::-1]
    print(*b, sep=' ')

if __name__ ==  '__main__':
    main()

Submission status: Runtime Error

Solution code:
import numpy as np
n = int(input())
a = [int(i) for i in input().split()]

begin = a[0::2]
end =a[1::0]

if n%2 == 0:
    end = end[:-1]
    ans = np.concatenate(end,begin)
else:
    begin = begin[::-1]
    ans = np.concatenate(begin,end)
    
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int,input().split()))

b = deque()
for i in range(n):
    b.append(a[i])
    b.reverse()

print(*b)

Submission status: Runtime Error

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

n = i_i()
a = i_l()

print(*a[::-2],*a[n%2::2])

Submission status: Runtime Error

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

n = i_i()
a = i_l()
print(*a[::-2],*a[n%2::2])

Submission status: Runtime Error

Solution code:
n = int(input())
data = list(map(int, input().split()))

if n == 1:
    print(data[0])
elif n == 2:
    print(data[1], data[0])
else:
    firs_value = [data[0]]
    second_value = [data[1], data[0]]

    def get_value(index, data):
        if index == 0:
            return firs_value
        elif index == 1:
            return second_value
        else:
            lis = get_value(index - 2, data)
            lis.append(data[index - 1])
            lis.insert(0, data[index])
            return lis

    result = get_value(n - 1, data)
    print(" ".join(str(n) for n in result))

Submission status: Runtime Error

Solution code:
def main():
    n = int(input())
    data = list(map(int, input().split()))

    if n == 1:
        print(data[0])
    elif n == 2:
        print(data[1], data[0])
    else:
        firs_value = [data[0]]
        second_value = [data[1], data[0]]

        def get_value(index, data):
            if index == 0:
                return firs_value
            elif index == 1:
                return second_value
            else:
                lis = get_value(index - 2, data)
                lis.append(data[index - 1])
                lis.insert(0, data[index])
                return lis

        result = get_value(n - 1, data)
        print(" ".join(str(n) for n in result))

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
def main():
	n = int(input())
    data = list(map(int, input().split()))

    if n == 1:
        print(data[0])
    elif n == 2:
        print(data[1], data[0])
    else:
        firs_value = [data[0]]
        second_value = [data[1], data[0]]

        def get_value(index, data):
            if index == 0:
                return firs_value
            elif index == 1:
                return second_value
            else:
                lis = get_value(index - 2, data)
                lis.append(data[index - 1])
                lis.insert(0, data[index])
                return lis

        result = get_value(n - 1, data)
        print(" ".join(str(n) for n in result))
        
if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
def main():
     n = int(input())
    data = list(map(int, input().split()))

    if n == 1:
        print(data[0])
    elif n == 2:
        print(data[1], data[0])
    else:
        firs_value = [data[0]]
        second_value = [data[1], data[0]]

        def get_value(index, data):
            if index == 0:
                return firs_value
            elif index == 1:
                return second_value
            else:
                lis = get_value(index - 2, data)
                lis.append(data[index - 1])
                lis.insert(0, data[index])
                return lis

        result = get_value(n - 1, data)
        print(" ".join(str(n) for n in result))
  
if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
N = int(input())
a = list(map(int, input().split()))

from collections import deque
b = deque([])
if len(a) % 2 == 0:
    for i in range(1, N + 1):
        print(b)
        if i % 2 == 0:
            b.appendleft(a[i - 1])
        else:
            b.append(a[i - 1])
else:
    for i in range(1, N + 1):
        print(b)
        if i % 2 == 0:
            b.append(a[i - 1])
        else:
            b.appendleft(a[i - 1])

print(' '.join([str(i) for i in b]))

Submission status: Runtime Error

Solution code:
N = int(input())
a = list(map(int, input().split()))

from collections import deque
b = deque([])
if len(a) % 2 == 0:
    for i in range(1, N + 1):
        print(b)
        if i % 2 == 0:
            b.appendleft(a[i - 1])
        else:
            b.append(a[i - 1])
else:
    for i in range(1, N + 1):
        print(b)
        if i % 2 == 0:
            b.append(a[i - 1])
        else:
            b.appendleft(a[i - 1])

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
a1 = []
a2 = []
for i in range(n):
    if i % 2 == 0:
        a1.append(a[i])
    else:
        a2.append(a[i])
if n % 2 == 0:
    rev = list(reversed(a2))
    print(*rev, *a1)
else:
    rev = list(reversed(a1))
    print(*rev, *a2)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
a1 = []
a2 = []
for i in range(n):
    if i % 2 == 0:
        a1.append(a[i])
    else:
        a2.append(a[i])
if n % 2 == 0:
    rev = reversed(a2)
    print(*rev, *a1)
else:
    rev = reversed(a1)
    print(*rev, *a2)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int,input().split()))
a1 = []
a2 = []
for i in range(n):
    if i % 2 == 0:
        a1.append(a[i])
    else:
        a2.append(a[i])
if n % 2 == 0:
    rev = reversed(a2)
    print(*rev, *a1)
else:
    rev = reversed(a1)
    print(*rev, *a2)

Submission status: Runtime Error

Solution code:
n = int(input())
al = list(map(int, input().split()))

left = []
right = []

for i in range(n):
    if i % 2 == 0:
        right.append(al[i])
    else:
        left.append(al[i])

if n % 2 == 0:
    left = left[::-1]
    print(*left, *right, sep=' ')
else:
    right = right[::-1]
    print(*right, *left, sep=' ')

Submission status: Runtime Error

Solution code:
n = int(input())
al = list(map(int, input().split()))

left = []
right = []

for i in range(n):
    if i % 2 == 0:
        right.append(al[i])
    else:
        left.append(al[i])

if n % 2 == 0:
    left = left[::-1]
    print(*left, *right, sep=' ')
else:
    right = right[::-1]
    print(*right, *left, sep=' ')

Submission status: Runtime Error

Solution code:
from collections import deque

n = int(input())
aa = list(map(int, input().split()))
bb = deque()
left = True
for a in aa:
    if left:
        bb.append(a)
    else:
        bb.appendleft(a)
    left = not left

if left:
    print(*list(bb))
else:
    print(*list(bb).reverse())

Submission status: Runtime Error

Solution code:
from collections import deque
N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))

que = deque()
for i in range(N):
    if i % 2 == 0:
        que.append(A[i])
    else:
        que.appendleft(A[i])
if N % 2:
    que.reverse()
print(*que)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int,input().split()))
s1 = []
s2 = []
for i in range(n):
  if i % 2 == 0:
    s1.append(a[i])
  else:
    s2.append(a[i])

if n % 2 == 0:
  for x in reversed(s2) + s1:
    print(x, end=' ')
else:
  for x in reversed(s1) + s2:
    print(x, end=' ')
print()

Submission status: Runtime Error

Solution code:
n = int(input())
A = list(map(int, input().split()))
B = []
C = []
for i in range(n):
    if i % 2 == 0:
        B.append(A[i])
    else:
        C.append(A[i])
if len(B) > len(C):
    print(*reversed(B), *C)
else:
    print(*reversed(C), *B)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(input().split())

if n%2==1:
    print(*a[n-1::-2], *a[1:n+1:2])
else:
    print(*a[n::-2], *a[:n+1:2])

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int,input().split()))
if n%2 ==0:
    b = a[1::2][::-1]+a[::2]
    print(*b)
else:
    b =a[::2][::-1]*a[1::2]
    print(*b)

Submission status: Runtime Error

Solution code:
from collections import deque
n=int(input())
a=deque([int(i) for i in input().split()])
b=deque()
for i in range(n):
    if i % 2 == 0:
        b.append(a.popleft())
    else:
        b.appendleft(a.popleft())
    
if n%2==0:
    print(*b)
else:
    print(*b[::-1])

Submission status: Runtime Error

Solution code:
        b.insert(0,a[i])

Submission status: Runtime Error

Solution code:
n = int(input())
a = input().split()
s = ''
t = ''
for i in range(1, n):
  if i % 2 == 0:
    s = s + a[i]
  else:
    s = a[i] + s
if n % 2 == 1:
  print(' '.join(s))
else:
  t = ''
  for i in range(1, n + 1):
    t += s[-i]
  print(' '.join(t))

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
s = ''
t = ''
for i in range(n):
  if i % 2 == 0:
    s = s + a[i]
    t = a[i] + t
  else:
    s = a[i] + s
    t = t + a[i]
if n % 2 == 1:
  print(s)
else:
  print(t)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
s = ''
for i in range(n):
  if i % 2 == 0:
    s = s + a[i]
  else:
    s = a[i] + s
if n % 2 == 1:
  print(s)
else:
  t = ''
  for j in range(1, n + 1):
    t += s[-j]
  print(t)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
s = ''
for i in range(n):
  if i % 2 == 0:
    s = s + a[i]
  else:
    s = a[i] + s
if n % 2 == 1:
  print(s)
else:
  t = ''
  for j in range(1, n + 1):
    t = s[-j]
  print(t)

Submission status: Runtime Error

Solution code:
n = int(input())
num = list(map(int, input().split()))
new_list = []
for i in num:
    new_list.append(i)
    new_list.reverse()
    print(new_list)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
odd = a[::2]
even = a[1::2]
even.reverse()
ans = even + odd
print(" ".join(ans))

Submission status: Runtime Error

Solution code:
N=int(input())
A=list(map(int,input().split()))
print(*A[::-2], *A[N%2::2])

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))

print(*a[::-2],*a[n%2::2])

Submission status: Runtime Error

Solution code:
import sys

def even(*a,n):
	b=[]
	b.append(a[0])
	for i in range(1,n,2):
		b.insert(0, a[i])
		try:
			b.append(a[i+1])
		except:
			pass
	for j in range(n):
		print(str(b[j])+" ", end="")

def odd(*a,n):
	b=[]
	b.append(a[0])
	for i in range(1,n,2):
		b.append(a[i])
		try:
			b.insert(0,a[i+1])
		except:
			pass
	for j in range(n):
		print(str(b[j])+" ", end="")

input = sys.stdin.readline
n=int(input())
a=list(map(int,input().split()))
if n%2==0:
	even(*a,n)
else:
	odd(*a,n)

Submission status: Runtime Error

Solution code:
import sys
n=int(input())
a=list(map(int,input().split()))
b=[]
if n&2==0:
	b.append(a[0])
	for i in range(1,n,2):
		b.insert(0, a[i])
		try:
			b.append(a[i+1])
		except:
			pass
	for j in range(n):
		print(str(b[j])+" ", end="")
	sys.exit()
else:
	b.append(a[0])
	for i in range(1,n,2):
		b.append(a[i])
		b.insert(0, a[i+1])
	for j in range(n):
		print(str(b[j])+" ", end="")

Submission status: Runtime Error

Solution code:
n = int(input())
S = list(map(int, input().split()))
b=[]
for in range(n):
    b.append(S[i])
    b=b[::-1]
print(b)

Submission status: Runtime Error

Solution code:
n = int(input())
S = list(map(int, input().split()))
b=[]
for in range(n):
    b.append(S[i])
    S=S[::-1]

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))
if n%2==1:
    print(*a[::-2],*a[1::2])
if n%2==0:
    print(*a[::-2],*a[0::2])

Submission status: Runtime Error

Solution code:
from collectiojns import deque
n=int(input())
a=list(map(int,input().split()))
b=deque()

for i in range(n):
  b.append(a[i])
  b=[::-1]
print(*b)

Submission status: Runtime Error

Solution code:
from collectiojns import deque
n=int(input())
a=list(map(int,input().split()))
b=deque()

for i in range(n):
  b.append(a[i])
  b=[b::-1]
print(*b)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
b=[]

a = a[::-1]
for i in range(n):
    b.append(a.pop(-1))
    b = b[::-1]
    print(b)

for i in range(len(b)):
    print(b[i], end=" ")

Submission status: Runtime Error

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n = INT()
a = LIST()

tmp1 = []
tmp2 = []

for i, a in enumerate(a):
    if i%2 == 0:
        tmp1.append(a)
    else:
        tmp2.append(a)
if n%2 == 0:
    print(*tmp2[::-1], *tmp1)
else:
    print(*tmp1[::-1], *tmp2)

Submission status: Runtime Error

Solution code:
n = int(input())
a = input().split()
if n % 2 == 0 :
    le = [0] * n // 2
    lo = [0] * n // 2
    counte = 0
    counto = 0
    for i in range(n) :
        if i % 2 == 0 :
            lo[counto] = a[i]
            counto+=1
        else :
            le[counte] = a[i]
            counte +=1
    le.reverse()
    l = le + lo
    S = ' '.join(l)
    print(S)
else :
    l = [a[0]]
    for i in range(1,n) :
        if i % 2 == 1 :
            l.append(a[i])
        else :
            l.insert(0,a[i])
    S = ' '.join(l)
    print(S)

Submission status: Runtime Error

Solution code:
 n = int(input())
 a = list(map(int, input().split()))
 ans = []
 for i in range(N):
    if (i+1) % 2 == N % 2:
         ans = [a.pop(0)] + ans
    else:
         ans = ans + [a.pop()]
print(*ans, sep=" ")

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int,input().split()))
if n == 1:
    print(a[0])
else:
    print(*a[::-2],*a[n%2::2])

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int,input().split()))
print(*a[::-2],*a[n%2::2])

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int,input().split()))
if n == 1:
    print(a[0])
else:
    print(*a[::-2],*a[::2])

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int,input().split()))
print(*a[::-2],*a[::2])

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int,input().split()))
B = [-10000 for i in range(N)]
for i in range(N):
    if (N-i)%2 != 0:#from front
        index = (N-i)//2
        B[index] = A[i]
    else:# from backward
        index = N - (N-i)//2
        B[index] = A[i]
print(" ".join(B))

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))

print(*a[::-2], *a[n%2::2])

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
A.reverse()

from collections import deque
b1 = deque([])
b2 = deque([])

for i in range(N):
    if i % 2 == 0:
        b1.append(A[i])
    else:
        b2.appendleft(A[i])
print(*(b1+b2))

Submission status: Runtime Error

Solution code:
n=int(input())
A=list(map(int,input().split()))
from collections import deque
ans=deque([])
d=deque(A)
for i in range(0,n):
    if i%2==0:
        ans.append(d[i])
    if i%2==1:
        ans.appendleft(d[i])
a=list(ans)
if n%2==1:
    c=a[::-1]
print(" ".join(map(str, c)))

Submission status: Runtime Error

Solution code:
n=int(input())
A=list(map(int,input().split()))
from collections import deque
ans=deque([])
d=deque(A)
for i in range(0,n):
    if i%2==0:
        ans.append(d[i])
    if i%2==1:
        ans.insert(0,d[i])
ans=list(ans)
if n%2==1:
    ans=ans[::-1]
print(" ".join(map(str, ans)))

Submission status: Runtime Error

Solution code:
n=int(input())
A=list(map(int,input().split()))
from collections import deque
ans=deque([])
d=deque(A)
for i in range(0,n):
    if i%2==0:
        ans.append(d[i])
    if i%2==1:
        ans.insert(0,d[i])
if n%2==1:
    ans=list(ans)[::-1]
print(" ".join(map(str, ans)))

Submission status: Runtime Error

Solution code:
n=int(input())
A=list(map(int,input().split()))
ans=deque([])
from collections import deque
d=deque(A)
for i in range(0,n):
    if i%2==0:
        ans.append(d[i])
    if i%2==1:
        ans.insert(0,d[i])
if n%2==1:
    ans=list(ans)[::-1]
print(" ".join(map(str, ans)))

Submission status: Runtime Error

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    input()
    aa=LI()
    if len(aa)%2:
        print(*aa[::-2],*aa[1::2])
    else:
        print(*aa[::-2],*aa[::2])
main()

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int,input().split()))
A_oddList = A[::2]
A_evenList = A[1::2]
A_oddList = A_oddList[::-1]
A_evenList = A_evenList[::-1]

if N % 2 == 1:
    print(*A_oddList ,*A_evenList)
else:
    A_oddList = A_oddList[::-1]
    print(*A_evenList , *A_oddList)

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=a[1::2][::-1]+a[0::2]
print((*b,*(b[::-1]))[n%2>0])

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))
bbottom=""
btop=""
for i in range(n):
  if i%2==0:
    bbottom.append(a[i])
  else:
    btop.append(a[i])
ans=btop[::-1]+bbottom
if n%2==1:
  ans=ans[::-1]
print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))
bbottom=""
btop=""
for i in range(n):
  if i%2==0:
    bbottom+=a[i]
  else:
    btop+=a[i]
ans=btop[::-1]+bbottom
if n%2==1:
  ans=ans[::-1]
print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))
bbottom=""
btop=""
for i in range(n):
  if i%2==0:
    bbottom+=a[i]
  else:
    btop+=a[i]
ans=btop[::-1]+bbottom
if n%2==1:
  ans=ans[::-1]
prin(ans)

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=[]
i=n-1
for _ in range(n//2+1):
    b.append(a[i])
    i-=2
    if i<=-1:
        break
if n%2==0: 
    i=0
else:
    i=1
for _ in range(n//2+1):
    b.append(a[i])
    i+=2
    if i>=n-1:
        break
print(' '.join(map(str,b)))

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))
s=[]
for i in a:
  s.append(i)
  s.reverse()
print(" ".join(s))

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))

if n%2 == 1:
    r = a[::-2]
    l = a[1::2]
else:
    r = a[::-2]
    l = a[::2]
    
print(*r,*l)

Submission status: Runtime Error

Solution code:
N=int(input())
a=[int(x) for x in input().split()]
b=[]
if N%2==0:
  for i in range(N//2):
    b += [a[-(i*2+1)]]
  for i in range(N//2):
    b += [a[i*2]]
else:
  for i in range(1,N+1,2):
    b += [a[-i]]
  for j in range(1,N//2+3,2):
    b += [a[j]]
print(*b,sep=' ')

Submission status: Runtime Error

Solution code:
N=int(input())
a=[int(x) for x in input().split()]
b=[]
if N%2==0:
  for i in range(N//2):
    b += [a[-(i*2+1)]]
  for i in range(N//2):
    b += [a[i*2]]
else:
  for i in range(1,N+1,2):
    b += [a[-i]]
  for j in range(1,N//2+2,2):
    b += [a[j]]
print(*b,sep=' ')