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: Time Limit Exceeded

Solution code:
n = int(input())
A = [x for x in input().split()]
B = []

if n % 2 == 0:
    for i in range(n):
        if i % 2 == 0:
            B.append(A[i])
        else:
            B.insert(0,A[i])
else:
    for i in range(n):
        if i % 2 == 0:
            B.insert(0,A[i])
        else:
            B.append(A[i])
print(" ".join(B))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding:utf-8 -*-
n = int(input())
a = list(map(int,input().split()))
b = []
for tmp in a:
    b.append(tmp)
    b = list(reversed(b))
b = map(str,b)
print(" ".join(b))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

N = input()
a=(map(int, raw_input().split()))

b=np.array([]).astype(int)

for i in range(N):
    b=np.append(b, [a[i]])
    b=b[-1::-1]

print ''.join(str(b))[1:-1]

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = input().split()
b = []
for i in a:
    b.append(i)
    b.reverse()
c = ""
for i in b:
    c += i + " "
print(c)

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

b = []

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


if((n%2)==0):
    print(" ".join([i for i in b]))
else:
    print(" ".join([i for i in b[::-1]]))

Submission status: Time Limit Exceeded

Solution code:
#! -*- coding:utf-8 -*-
n = int(input())
a = map(int,input().split())
a = list(a)

b = ''
for i in range(n):
    b += str(a[i])
    b = b[::-1]

if n == 1:
    print(a[0])
else:
    b = list(b)
    b = list(map(int,b))
    for i in range(n-1):
        print(b[i], end = ' ')
    print(b[-1])

Submission status: Time Limit Exceeded

Solution code:
# -*- coding:utf-8 -*-
n = int(input())
a = list(map(int,input().split()))
b = []
for tmp in a:
    b.append(tmp)
    b.reverse()
b = map(str,b)
print(" ".join(b))

Submission status: Time Limit Exceeded

Solution code:
import math
inf=float('inf')
N = int(input())
x = list(map(int, input().split()))
y = []

for i in range(N):
    y.append(x[i])
    y.reverse()


for i in range(len(y)):
    print(y[i],end=' ')

quit()

Submission status: Time Limit Exceeded

Solution code:
#! -*- coding:utf-8 -*-
n = int(input())
a = map(int,input().split())
a = list(a)

b = ''
for i in range(n):
    b += str(a[i])
    b = b[::-1]

if n == 1:
    print(a[0])
else:
    for i in range(len(b)-1):
        print(int(b[i]),end = ' ')
    print(b[-1])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = input().split()
b = []
for i in range(n):
    b.append(a.pop(0))
    b.reverse()
    # print(b)
ans = ''
for i in b:
    ans += i
    ans += ' '
print(ans[:-1])

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
def get_ln_inputs():
    return input().split()


def get_ln_int_inputs():
    return list(map(int, get_ln_inputs()))


def main():
    n = get_ln_int_inputs()[0]
    a = get_ln_int_inputs()
    reverse = n % 2 == 0

    result = list()
    for i in range(n):
        ii = len(result) if i % 2 == 1 else 0
        result.insert(ii, a[i])
    
    if reverse:
        result = result[::-1]

    print(" ".join(str(x) for x in result))


main()

Submission status: Time Limit Exceeded

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

b = []
for i, a_i in enumerate(a):
    if i % 2 == 0:
        b = b + [a_i]
    else:
        b = [a_i] + b
        
if n % 2 == 1:
    b = b[::-1]
        
for b_i in b[:-1]:
    print ("%d "%(b_i), end="")
print("%d"%b[-1])

Submission status: Time Limit Exceeded

Solution code:
a = input()
s = map(int, raw_input().split())

l = []

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

for i in l:
	print i,

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = input().split(' ')
b = []
for i in range(n):
    b.append(a[i])
    b = b[::-1]
print(' '.join(b))

Submission status: Time Limit Exceeded

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

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

ans=""
for i in range(len(b)-1):
    ans=ans+str(b[i])+" "
ans=ans+str(b[-1])

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(raw_input().rstrip())
a = map(int, raw_input().split())
b = []
for i in range(n):
    b.append(a[i])
    b.reverse()
ans = map(str, b)
print ' '.join(ans)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
def get_ln_inputs():
    return input().split()


def get_ln_int_inputs():
    return list(map(int, get_ln_inputs()))


def main():
    n = get_ln_int_inputs()[0]
    a = get_ln_int_inputs()
    reverse = n % 2 == 0

    result = list()
    for i in range(n):
        ii = len(result) if i % 2 == 1 else 0
        result.insert(ii, a[i])
    
    if reverse:
        result = result[::-1]

    print(" ".join(list(map(str, result))))


main()

Submission status: Time Limit Exceeded

Solution code:
# -*- coding:utf-8 -*-
n = int(input())
a = [int(i) for i in input().split()]
b = []

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

print(b[0], end='')
for i in range(1, n):
    print(' {}'.format(b[i]), end='')

print()

Submission status: Time Limit Exceeded

Solution code:
n=int(raw_input())
a=map(int,raw_input().split(' '))

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

print ' '.join(map(str,b))

Submission status: Time Limit Exceeded

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

b = []

for i in range(len(a)):
    b.append(str(a[i]))
    b.reverse()

print(' '.join(b))

Submission status: Time Limit Exceeded

Solution code:
import math


def f():
    n = int(input())
    a = list(map(int, input().split(" ")))
    b = []
    for i in range(len(a)):
        if i % 2 == 0:
            b.append(a[i])
        else:
            b.insert(0, a[i])
    if n % 2 == 1:
        b.reverse()
    b = list(map(str,b))
    print(" ".join(b))


f()

Submission status: Time Limit Exceeded

Solution code:
b=[]
num=int(input())
a=input().split()

for i in range(num):
    
    b.append(a[i])
    b.reverse()


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

print("")

Submission status: Time Limit Exceeded

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

b = []

for e in a:
    b.append(e)
    b = b[::-1]
ans = ' '.join(b)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
A = list(map(int, input().split()))
b = [0]*n
if n % 2 == 0:
    k = 1
else:
    k = -1
index_= int(n/2)
for i in range(n):
    index_ += i * k
    b[index_] = A[i]
    k *= -1
print(*b)

Submission status: Accepted

Solution code:
from collections import deque

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

deq = deque()
for i in range(n):
    if i%2==0:
        deq.appendleft(A[i])
    else:
        deq.append(A[i])
if n%2==0:
    for i in reversed(range(n)):
        print(deq[i],end=" ")
else:
    for i in range(n):
        print(deq[i],end=" ")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Sep 27 02:46:15 2020

@author: liang
"""

from collections import deque

n = int(input())
A = [int(x) for x in input().split()]

res = deque()

for i in range(n):
    if i % 2 == 0:
        res.append(A[i])
    else:
        res.appendleft(A[i])
        
if n % 2 == 1:
    print(" ".join(map(str,reversed(res))))
else:
    print(" ".join(map(str,res)))

Submission status: Accepted

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

b = [0] * n

if n % 2 == 0 :
    c = n//2 - 1
else :
    c = n // 2

b[c] = a[0]

for i in range(1,n) :
    if i % 2 == 1 :
        b[c + i] = a[i]
        c += i
    else :
        b[c - i] = a[i]
        c -= i

if c != 0 :
    b.reverse()
    print(*b,sep=" ")
else :
    print(*b,sep=" ")

Submission status: Accepted

Solution code:
from collections import deque
from typing import List


def main():
    n = int(input())
    v = input().split(" ")
    print(*pp(n, v))


def pp(n: int, v: List[str]) -> List[str]:
    x = []
    y = deque([])

    if n % 2 == 0:
        for i in range(n):
            if i % 2 == 0:
                y.append(v[i])
            else:
                x.append(v[i])
    else:
        for i in range(n):
            if i % 2 == 0:
                x.append(v[i])
            else:
                y.append(v[i])

    x_len = len(x)
    ret = [""] * (x_len + len(y))
    for i in range(x_len):
        ret[i] = x.pop()

    for i in range(len(y)):
        ret[x_len + i] = y.popleft()

    return ret


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from collections import deque
from typing import List


def main():
    n = int(input())
    v = input().split(" ")
    print(*pp(n, v))


def pp(n: int, v: List[str]) -> List[str]:
    x = []
    y = deque([])

    if n % 2 == 0:
        for i in range(n):
            if i % 2 == 0:
                y.append(v[i])
            else:
                x.append(v[i])
    else:
        for i in range(n):
            if i % 2 == 0:
                x.append(v[i])
            else:
                y.append(v[i])

    ret = []
    for i in range(len(x)):
        ret.append(x.pop())

    for i in range(len(y)):
        ret.append(y.popleft())

    return ret


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
a1, a2 = [],[]
for index, i in enumerate(a, start=1):
  if index % 2 == 0:
    a2.append(i)
  else:
    a1.append(i)

ans = []
if n % 2 == 0:
  ans = a2[::-1] + a1
else:
  ans = a1[::-1] + a2

print(" ".join(str(i) for i in ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
alst = list(map(int, input().split()))
bef = []
aft = []
for i, a in enumerate(alst):
  if i % 2 == 0:
    bef.append(a)
  else:
    aft.append(a)
if n % 2 == 0:
  ans = aft[::-1] + bef
else:
  ans = bef[::-1] + aft
print(*ans)

Submission status: Accepted

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


if len(a) %2 == 0:
    d.extend(a[::2])
    d.extendleft(a[1::2])
else:
    d.extend(a[1::2])
    d.extendleft(a[::2])
print(*list(d))

Submission status: Accepted

Solution code:
from collections import deque


N = int(input())
AS = [int(i) for i in input().split()]

b = deque()

x = 0 if len(AS) % 2 == 0 else 1

for i, a in enumerate(AS):
  if i % 2 == x:
    b.append(str(a))
  else:
    b.appendleft(str(a))

print(' '.join(list(b)))

Submission status: Accepted

Solution code:
# C - pushpush
def main():
    from collections import deque
    n = int(input())
    a = list(map(int, input().split()))
    ans = deque(maxlen=2*10**5)

    for i in range(n):
        if n % 2 == 0:
            if i % 2 == 0:
                ans.append(str(a[i]))
            else:
                ans.appendleft(str(a[i]))
        else:
            if i % 2 == 0:
                ans.appendleft(str(a[i]))
            else:
                ans.append(str(a[i]))

    else:
        print(' '.join(ans))


if __name__ ==  "__main__":
    main()

Submission status: Accepted

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


if len(a) %2 == 0:
    d.extend(a[::2])
    d.extendleft(a[1::2])
else:
    d.extend(a[1::2])
    d.extendleft(a[::2])
print(*list(d))

Submission status: Accepted

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

if n % 2 == 0:
    for i in range(n):
        if i < int(n / 2):
            print(a[n - 2 * i - 1],'', end = '')
        else:
            print(a[2 * i - n],'', end = '')
else:
    for i in range(n):
        if i <= n // 2:
            print(a[n - 2 * i - 1],'', end = '')
        else:
            print(a[2 * i - n],'', end = '')
print()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque
n = int(input())
#a, b, c = map(int, input().split())
al = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]

q = deque([])

for i in range(1, n+1):
    if i % 2 == 0:
        q.appendleft(al[i-1])
    else:
        q.append(al[i-1])

ansl = list(q)
ansl = ansl[::-1] if n % 2 != 0 else ansl

print(*ansl, sep=" ")

Submission status: Accepted

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

if n % 2 == 0:
    A = L[n-1::-2] + L[::2]
else:
    A = L[n-1::-2] + L[1::2]
 
print(*A)

Submission status: Accepted

Solution code:
from collections import deque


def solve(a):
    ans = deque()

    for i, aa in enumerate(a):
        if i % 2 == 0:
            ans.append(str(aa))
        else:
            ans.appendleft(str(aa))

    if len(a) % 2 == 1:
        ans.reverse()

    return list(ans)


if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))
    print(' '.join(solve(a)))

Submission status: Accepted

Solution code:
from collections import deque,defaultdict,Counter
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from bisect import bisect_left,bisect_right
from math import sqrt,gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint
from statistics import mean,median,mode
import sys
sys.setrecursionlimit(10 ** 6)

INF = float('inf')

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse=False):
    data.sort(key=lambda x:x[col],reverse=revese)
    return data

def mymax(data):
    M = -1*float('inf')
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float('inf')
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def mydictvaluesort(dictionary):
    return sorted( dictionary.items(), key=lambda x:x[1] )

def mydictkeysort(dictionary):
    return sorted( dictionary.items(), key=lambda x:x[0] )

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(' ')
        elif type(ls[0])==str:
            print(' '.join(ls))
        elif type(ls[0])==int:
            print(' '.join(map(str,ls)))
        else:
            print('Output Error')
    else:
        if len(ls)==0:
            print('')
        elif type(ls[0])==str:
            print(''.join(ls))
        elif type(ls[0])==int:
            print(''.join(map(str,ls)))
        else:
            print('Output Error')

def I():
    return int(input())

def MI():
    return map(int,input().split())

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input()) for _ in range(n) ]

# ddict = defaultdict(lambda: 0)
# ddict = defaultdict(lambda: 1)
# ddict = defaultdict(lambda: int())
# ddict = defaultdict(lambda: list())
# ddict = defaultdict(lambda: float())

n = I()
a = RI()

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

# print(ls)

if n%2==1:
    myoutput(ls)
else:
    ls.reverse()
    myoutput(ls)

Submission status: Accepted

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

odd,even=a[::2],a[1::2]

if n%2==0:
  ans=even[::-1]+odd
else:
  ans=odd[::-1]+even

print(*ans)

Submission status: Accepted

Solution code:
from collections import deque

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

d = deque()
for i in range(n):
    if n % 2 == (i + 1) % 2:
        d.appendleft(a[i])
    else:
        d.append(a[i])

print(*d)

Submission status: Accepted

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

odd_index = []
even_index = []
for i in range(n):
    if (i + 1) % 2 == 1:
        odd_index.append(a[i])
    else:
        even_index.append(a[i])

if n % 2 == 1:
    res = odd_index[::-1] + even_index
else:
    res = even_index[::-1] + odd_index

print(*res)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if n%2==0:
    S=a[-1::-2]+a[::2]
    for x in S:
        print(x,end=' ')
else:
    S=a[-1::-2]+a[1::2]
    for x in S:
        print(x,end=' ')
print()

Submission status: Accepted

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

if n % 2 == 0:
    b = a[n-1::-2] + a[::2]
else:
    b = a[n-1::-2] + a[1::2]

print(*b)

Submission status: Accepted

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

if n % 2 == 0:
    for i in reversed(l2):
        print(i, end=' ')
    for i in l1:
        print(i, end=' ')
else:
    for i in reversed(l1):
        print(i, end=' ')
    for i in l2:
        print(i, end=' ')

Submission status: Accepted

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

if (n - 1) % 2 == 0:
  top = [""] * ((n - 1) // 2)
  bottom = [""] * ((n - 1) // 2)
    
  t = (n - 1) // 2 - 1
  b = 0
  for i in range(1,n):
    if i % 2 == 1:
      bottom[b] = A[i]
      b += 1
    else:
      top[t] = A[i]
      t -= 1
else:
  top = [""] * ((n - 1) // 2 + 1)
  bottom = [""] * ((n - 1) // 2)
  
  t = (n - 1) // 2
  b = 0
  
  for j in range(1,n):
    if j % 2 == 1:
      top[t] = A[j]
      t -= 1
    else:
      bottom[b] = A[j]
      b += 1
      
print(*(top + [A[0]] + bottom))

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
if N % 2 == 0:
  for i in range(N-1, -1, -2):
    print(A[i], end = "")
    print(" ", end = "")
  for i in range(0, N, 2):
    print(A[i], end = "")
    if i != N - 2:
      print(" ", end = "")
    else:
      print("")
else:
  for i in range(N-1, -2, -2):
    print(A[i], end = "")
    print(" ", end = "")
  for i in range(1, N, 2):
    print(A[i], end = "")
    if i != N - 2:
      print(" ", end = "")
    else:
      print("")

Submission status: Accepted

Solution code:
from collections import deque
with open(0) as f:
    n, *a = map(int, f.read().split())
b = deque()
for idx, value in enumerate(a):
    if (idx & 1) ^ (n & 1):
        b.appendleft(value)
    else:
        b.append(value)
print(*b)

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
ans=[]
if n%2==1:
    i=n
    while i>=1:
        ans.append(str(a[i-1]))
        i-=2
    i=2
    while i<=n:
        ans.append(str(a[i-1]))
        i+=2
    print(" ".join(ans))
else:
    i = n
    while i >= 1:
        ans.append(str(a[i - 1]))
        i -= 2
    i = 1
    while i <= n:
        ans.append(str(a[i - 1]))
        i += 2
    print(" ".join(ans))

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
start = n - 1
while start >= 0:
    print(a[start],end=' ')
    start -= 2
if n % 2 == 0:
    start = 0
else:
    start = 1
while start < n:
    print(a[start],end=' ')
    start += 2

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
if n % 2 == 0:
    start = n - 1
    while start >= 0:
        print(a[start],end=' ')
        start -= 2
    start = 0
    while start < n:
        print(a[start],end=' ')
        start += 2
elif n % 2 == 1:
    start = n - 1
    while start >= 0:
        print(a[start],end=' ')
        start -= 2
    start = 1
    while start < n:
        print(a[start],end=' ')
        start += 2

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    a_lst = list(map(int, input().split()))
    lst1 = []
    lst2 = []

    if n % 2 == 0:
        for i in range(n // 2):
            lst1.append(a_lst[-1 - i * 2])
        for i in range(n // 2):
            lst2.append(a_lst[i * 2])

    else:
        for i in range(n // 2):
            lst1.append(a_lst[-1 - i * 2])
        lst2.append(a_lst[0])
        for i in range(n // 2):
            lst2.append(a_lst[1 + i * 2])

    lst = lst1 + lst2
    ans = ''
    for i in range(n - 1):
        ans += '{} '.format(lst[i])
    ans += '{}'.format(lst[-1])
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = 4
a = [1, 2, 3, 4]

n = int(input())
a = input().split()


if n % 2 == 0:
    y = [a[j] for j in range(1, n, 2)][::-1]
    z = [a[j] for j in range(0, n, 2)]

else:
    y = [a[j] for j in range(0, n, 2)][::-1]
    z = [a[j] for j in range(1, n, 2)]

print(" ".join(map(str, y + z)))

Submission status: Accepted

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

odd, even = a[::2], a[1::2]

if n % 2 == 0:
    ans = even[::-1] + odd
else:
    ans = odd[::-1] + even

print(*ans)

Submission status: Accepted

Solution code:
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)

N,A = ilint()
B = deque()
for i in range(N):
    if i%2==0:
        B.append(A[i])
    else:
        B.appendleft(A[i])
B = list(B)
if N%2!=0:
    B = B[::-1]
lprint(B,' ')

Submission status: Accepted

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

b = []
if n%2 == 1:
    for i in a[n-1:0:-2]:
        b.append("{0}".format(i))
    b.append(str(a[0]))
    for i in a[1:n:2]:
        b.append("{0}".format(i))

if n%2 == 0:
    for i in a[n-1:0:-2]:
        b.append("{0}".format(i))
    for i in a[0:n:2]:
        b.append("{0}".format(i))

print(' '.join(b))

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

import string

def main():
    n = i_input()
    a = i_list()
    even = []
    odd = []
    for i,k in enumerate(a):
        if i%2==0:
            even.append(k)
        else:
            odd.append(k)

    even.reverse()
    even.extend(odd)
    if n%2==0:
        even.reverse()
    print(" ".join(map(str, even)))



if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())
A = input().split()

B = []
for i in range(N-1, -1, -2):
  B.append(A[i])

for j in range(N % 2, N, 2):
  B.append(A[j])

print(" ".join(B))

Submission status: Accepted

Solution code:
from collections import deque

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

order = n%2
ans = deque([])
for i in range(n):
    if i%2 == order:
        ans.append(a[i])
    else:
        ans.appendleft(a[i])
for el in ans:
    print(el, end=' ')

Submission status: Accepted

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

forward = True
sec, first = [], []
for i in range(n):
    if i%2:
        first.append(a[i])
    else:
        sec.append(a[i])
arr = first[::-1] + sec
if len(first) != len(sec):
    arr = arr[::-1]

for el in arr:
    print(el, end=' ')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a_list = [int(x) for x in input().split()]
print(*(a_list[::-2] + a_list[n&1::2]))

Submission status: Accepted

Solution code:
n = int(input())
a_list = [int(x) for x in input().split()]
print(*(a_list[n-1::-2] + a_list[n % 2::2]))

Submission status: Accepted

Solution code:
n = int(input())
a_list = [int(x) for x in input().split()]
if n % 2 == 0:
    b_list = a_list[n-1::-2] + a_list[0::2]
else:
    b_list = a_list[n-1::-2] + a_list[1::2]
print(*b_list)

Submission status: Accepted

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

from collections import deque
B = deque([])

rev = False

for i in range(N):
  if rev:
    B.appendleft(A[i])
  else:
    B.append(A[i])
  rev ^= True
  
if rev:
  B = list(B)[::-1]
    
print(*B)

Submission status: Accepted

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

from collections import deque
B = deque([])

rev = False

for i in range(N):
  if not rev:
    B.append(A[i])
  else:
    B.appendleft(A[i])
  rev ^= True
  
if rev:
  B = list(B)[::-1]
    
print(*B)

Submission status: Accepted

Solution code:
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    n = i_input()
    num_list = i_list()

    ans_list = deque()

    for i, num in enumerate(num_list):
        if i % 2 == 0:
            ans_list.append(num)
        else:
            ans_list.appendleft(num)

    if n % 2 == 0:
        print(*ans_list)
    else:
        tmp_list = []
        for ans in ans_list:
            tmp_list.append(ans)
        print(*tmp_list[::-1])


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())
A=list(map(int,input().split()))
b=[0]*n
cnt=0
for i in range(n):
    if i%2==0:
        b[cnt]=A.pop()
        cnt+=1
    else:
        b[-cnt]=A.pop()

print(*b)

Submission status: Accepted

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

front = False
for i in a:
    if front:
        b.insert(0, i)
        front = False
    else:
        b.append(i)
        front = True




if front:
    b.reverse()


b = list(map(str, b))
b = " ".join(b)
print(b)
'''


first = a[0:n:2]
last = a[1:n:2]
last = last[::-1]
answer = last + first
if n%2 != 0:
    answer = answer[::-1]

print(*answer, sep=" ")

Submission status: Accepted

Solution code:
#44 C - pushpush AC
n = int(input())
a = list(map(int,input().split()))

odd = [a[i] for i in range(n) if i%2 == 1] # O(n)
even = [a[j] for j in range(n) if j%2 == 0]# O(n)

if n%2 == 0:
    ans = list(reversed(odd)) + even # O(n)
else:
    ans = list(reversed(even)) + odd # O(n)
print(*ans)