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(raw_input())
a = map(int,raw_input().split())

b= []

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

string = ""
for i in range(n):
    if i!=0:
        string += " "+str(b[i])
    if i==0:
        string = str(b[i])
        
print string

Submission status: Time Limit Exceeded

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

#-------
# Initialize
n = int(input())
a = input().split()
b = a[0]

#-------
# Define
for i in range(1, n):
    if i % 2 == 0:
        b = a[i] + ' ' +b
    else:
        b = b + ' ' + a[i]
#-------
# Do
if n % 2 == 0:
    print(b[::-1])
else:
    print(b)
#-------
# Output

Submission status: Time Limit Exceeded

Solution code:
N=raw_input()
b=[]
P=raw_input().split()
for i in P:
    b.append(i)
    b=b[::-1]
print " ".join(b)

Submission status: Time Limit Exceeded

Solution code:
N=raw_input()
b=[]
P=raw_input().split()
for i in P:
    b.append(i)
    b.reverse()
print " ".join(b)

Submission status: Time Limit Exceeded

Solution code:
input()
n=[int(x) for x in input().split()]
b=[]
for i in n:
    b.append(i)
    b=b[::-1]
print(" ".join([str(i) for i in b]))

Submission status: Time Limit Exceeded

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

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

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

print(*b)

Submission status: Time Limit Exceeded

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

bb=[a[0]]

for k in range(1,len(a)):
    if k%2==0:
        bb.insert(0,a[k])
    else:
        bb.append(a[k])

if len(bb)%2==0:
    b=list(reversed(bb))
else:
    b=bb


print(" ".join([str(x) for x in b]))

Submission status: Time Limit Exceeded

Solution code:

import sys

from math import *
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    n = int(input_raw[0])
    input_raw = list(read_func().strip().split())
    b_list = []
    is_last_first = False
    for i in range(n):
        is_last_first = not(is_last_first)
        if is_last_first == True:
            b_list.append((input_raw[i]))
        else:
            b_list.insert(0, (input_raw[i]))

    if is_last_first == True:
        b_list.reverse()
    print " ".join(b_list)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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


b=[]

bb=[a[0]]
for k in range(1,len(a)):
    bb.append(a[k])
    bb=list(reversed(bb))

print(" ".join([str(x) for x in bb]))

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
import sys

# sys.stdin = open('c1.in')


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


def read_int():
    return int(input())


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


def read_str():
    return input()


def solve():
    n = read_int()
    a = read_int_list()
    b = []
    for i in range(n):
        if i % 2 == (n - 1) % 2:
            b.insert(0, a[i])
        else:
            b.append(a[i])
    return ' '.join(map(str, b))


def main():
    res = solve()
    print(res)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
n=int(raw_input())
a=map(int,raw_input().split())
b=[]
for i in range(n):
    if i%2==0:
        b.append(a[i])
    else:
        b.insert(0, a[i])
if n%2==1:
    b.reverse()
c=map(str,b)
print ' '.join(c)

Submission status: Time Limit Exceeded

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
A.reverse()
B = []
C = []
for i, a in enumerate(A):
    if i%2==0:
        B.append(a)
    else:
        C.append(a)
print(*(B+list(reversed(C))))

Submission status: Accepted

Solution code:
from collections import deque
n = int(input())
b = deque()
Alist = list(map(int,input().split()))
i = 1
if n%2 == 0:
    for a in Alist:
        if i%2 == 0:
            b.appendleft(a)
        else:
            b.append(a)
        i += 1
else:
    for a in Alist:
        if i%2 == 0:
            b.append(a)
        else:
            b.appendleft(a)
        i +=1
print(*b)

Submission status: Accepted

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

d = deque()

for i in range(0,n,2):
    d.append(a[i])

for i in range(1,n,2):
    d.appendleft(a[i])

if n % 2 == 0:
    for i in d:
        print(i)
else:
    d.reverse()
    for i in d:
        print(i)

Submission status: Accepted

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

ans = [a[0]]
check = N%2==0
for i,j in enumerate(a[1:]):
    if(check):
        if(i%2==0):
            ans.insert(0,j)
        else:
            ans.append(j)
    else:
        if(i%2==1):
            ans.insert(0,j)
        else:
            ans.append(j)
print(" ".join(map(str,ans)))

Submission status: Accepted

Solution code:
from collections import deque

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

d = deque()

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

if n%2==0:
    print(*d)
else:
    d = list(d)
    print(*d[::-1])

Submission status: Accepted

Solution code:
from collections import deque

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

for i, ai in enumerate(a):
    if i % 2 == 0:
        b.append(ai)
    elif i % 2 == 1:
        b.appendleft(ai)
b = list(b)
print(*(b if n % 2 == 0 else b[::-1]))

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

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


from collections import deque

q = deque()

flag = 0
for ai in a:
    if flag==0:
        q.append(ai)
    else:
        q.appendleft(ai)
    flag ^= 1

q = list(q)
#print(q)
if flag==0:
    print(*q)
else:
    print(*q[::-1])

Submission status: Accepted

Solution code:
from collections import *
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])
b=list(b)
if n%2==0:
    print(*b)
else:
    print(*b[::-1])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque

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

b = deque([])
rev = 1
for i in a:
    if rev == 1:
        b.append(i)
    elif rev == -1:
        b.appendleft(i)
    rev *= -1

print(*(b if rev == 1 else list(b)[::-1]))

Submission status: Accepted

Solution code:
from collections import deque

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

b = deque([])
rev = 1
for i in a:
    if rev == 1:
        b.append(i)
        rev = -1
    elif rev == -1:
        b.appendleft(i)
        rev = 1

print(*(b if rev == 1 else list(b)[::-1]))

Submission status: Accepted

Solution code:
from collections import deque

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

b = deque([])

rev = 1
for i in a:
    if rev == 1:
        b.append(i)
        rev = -1
    elif rev == -1:
        b.appendleft(i)
        rev = 1

b = list(b)
print(*(b if rev == 1 else b[::-1]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
alst = input().split()
lst1 = alst[::2]
lst2 = alst[1::2]
if n % 2:
  lst1.reverse()
  print(' '.join(lst1 + lst2))
else:
  lst2.reverse()
  print(' '.join(lst2 + lst1))

Submission status: Accepted

Solution code:
#!python3

from collections import deque


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

# input
N = int(input())
A = LI()


def main():
    dq = deque()
    rev = False
    for a in A:
        if rev:
            dq.appendleft(a)
        else:
            dq.append(a)
        rev = not rev
    
    if rev:
        dq.reverse()
    
    print(*dq)


if __name__ == "__main__":
    main()

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.appendleft(a[i])
    if i % 2 == 1:
        b.append(a[i])
if n % 2 == 0:
    b = list(reversed(b))

print(*b)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque

n = int(input())
an = list(map(int, input().split(' ')))

d = deque()

for i in range(n):
    if i % 2 == 0:
        d.append(an[i])
    else:
        d.appendleft(an[i])

if n % 2 == 1:
    d.reverse()
    
result = list(map(str, d))
print(' '.join(result))

Submission status: Accepted

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])
    if i % 2 == 1:
        c.append(a[i])
c.reverse()
c += b
if n % 2 == 1:
    c.reverse()
print(*c)

Submission status: Accepted

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

if(len(a)%2 == 0):
    b = a[1::2][::-1]+a[0::2]
    print(' '.join(map(str, b)))
else:
    b = a[0::2][::-1]+a[1::2]
    print(' '.join(map(str, b)))

Submission status: Accepted

Solution code:
from collections import deque

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

S = deque()

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

print(" ".join(S))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
odd = [A[i] for i in range(0, N) if not(i & 1)]
even = [A[i] for i in range(0, N) if i & 1]
ans = []
if N & 1:
    ans.extend(reversed(odd))
    ans.extend(even)
else:
    ans.extend(reversed(even))
    ans.extend(odd)
print(*ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
from _collections import defaultdict
from functools import lru_cache

class Scanner():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def map_int():
        return [int(x) for x in Scanner.string().split()]
    def string_list(n):
        return [input() for i in range(n)]
    def int_list_list(n):
        return [Scanner.mapInt() for i in range(n)]
    def int_cols_list(n):
        return [int(input()) for i in range(n)]
        
class Math():
    def gcd(a,b):
        if b == 0:
            return a
        return Math.gcd(b,a % b)
    def lcm(a,b):
        return (a * b) // Math.gcd(a,b)
    def roundUp(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Math.roundUp(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3,d + 1,2):
            if n % i == 0:
                return False
        return True

MOD = int(1e09) + 7

def main():
    N = Scanner.int()
    A = Scanner.map_int()
    if N == 1:
        print(A[0])
        return
    B = [0] * N
    i = 0
    j = N - 1 - N % 2
    for i in range(N // 2):
        B[i] = A[j]
        j -= 2
    i += 1
    B[i] = A[0]
    j = 2
    for i in range(i + 1,N):
        B[i] = A[j]
        j += 2
    if N % 2 == 1:
        B.reverse()
    print(*B)
    return

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from sys import stdin

N = int(stdin.readline().rstrip())
A = stdin.readline().rstrip().split()

B = A[::-1]

ans = []

if N % 2 == 0:
  for i in range(0,N,2):
    ans += [B[i]]
  for i in range(0,N,2):
    ans += [A[i]]
  
else:
  for i in range(0,N,2):
    ans += [B[i]]
  for i in range(1,N,2):
    ans += [A[i]]

print(*list(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque

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

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

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from collections import deque

N,*A = map(int,read().split())

B = deque()
reverse = False
for x in A:
    if reverse:
        B.appendleft(x)
    else:
        B.append(x)
    reverse = not reverse

B = list(B)
if reverse:
    B = B[::-1]

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

Submission status: Accepted

Solution code:
N=int(input())

A=list(map(int,input().split()))
B=[]
C=[]

for i in range(N):
    if(N%2==0):
        if(i%2==0):
            B.append(A[i])
        else:
            C.append(A[i])
    else:
        if(i%2==0):
            C.append(A[i])
        else:
            B.append(A[i])

C.reverse()
for i in range(len(B)):
    C.append(B[i])

for i in range(N):
    print(C[i] if i==0 else " "+str(C[i]),end="")
print()

Submission status: Accepted

Solution code:
N=int(input())
a=list(map(int,input().split()))
b=[]
b2=[]
if N%2==0:
  for i in range(0,N,2):
    b.append(str(a[N-i-1]))
    b2.append(str(a[i]))
  ans=b+b2
else:
  for i in range(N):
    if i%2==0:
      b.append(str(a[N-1-i]))
    else:
      b2.append(str(a[i]))
  ans=b+b2
print(' '.join(ans))

Submission status: Accepted

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

b = list(reversed(a[1::2]))+a[0::2]
print(" ".join(map(str, b if n%2 == 0 else reversed(b))))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
from collections import deque
def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math
from collections import deque

class SegTree():
    def __init__(self, n):
        self.value = [0 for i in range(n*2)]



def main():
    n = getN()
    nums = getList()
    d = deque()
    for i, num in enumerate(nums):
        if i % 2 != n % 2:
            d.appendleft(num)
        else:
            d.append(num)


    print(*d)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    
    N = int(input())
    A = list(map(int,input().split()))
    #N = 2*10**5
    #A = [i for i in range(1,N+1)]
    
    from collections import deque
    que = deque()
    for i in range(N):
        if i%2==0:
            que.append(A[i])
        else:
            que.appendleft(A[i])
    #print(list(que))
    if N%2==0:
        print(*list(que))
    else:
        print(*((list(que))[::-1]))
    
main()

Submission status: Accepted

Solution code:
from collections import deque

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

q = deque()
for i in range(N):
  a = A[i]
  if i > 1 and i % 2 == 0:
    q.appendleft(a)
  else:
    q.append(a)

if N % 2 == 0:
  q.reverse()
print(" ".join(map(str, q)))

Submission status: Accepted

Solution code:
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = list(map(int, input().rstrip('\n').split()))
    ls = collections.deque()
    for i, v in enumerate(a):
        if i % 2 == n % 2:
            ls.append(v)
        else:
            ls.appendleft(v)
    print(*ls)


if __name__ == '__main__':
    slove()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = list(map(int, input().rstrip('\n').split()))
    ls = []
    for i in range(n-1, -1, -2):
        ls.append(a[i])
    for i in range(0 if n % 2 == 0 else 1, n, 2):
        ls.append(a[i])
    print(*ls)


if __name__ == '__main__':
    slove()

Submission status: Accepted

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

a_odd = a[0::2]
a_even = a[1::2]

if n % 2 == 0:
    a_even.reverse()
    b = a_even + a_odd 
else:
    a_odd.reverse()
    b = a_odd + a_even

print(*b)

Submission status: Accepted

Solution code:
from collections import deque


que = deque()

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

for i in range(n):
    if i%2 == 0:
        que.append(seq[i])
    else:
        que.appendleft(seq[i])

if n%2 != 0:
    que.reverse()



print(*que)

Submission status: Accepted

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

Submission status: Accepted

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

ans = []
for i in range(N - 1, -1, -2):
    ans.append(a[i])
    
tmp_ans = []
for i in range(N - 2, -1, -2):
    tmp_ans.append(a[i])
tmp_ans.reverse()
ans += tmp_ans 
print(" ".join(map(str, ans)))

Submission status: Accepted

Solution code:
n=int(input())
m=n
a=list(map(int,input().split()))
if(m%2==0):
  while(n>=4):
    print(str(a[n-1])+' ',end="")
    n-=2
  print(str(a[1])+' ',end="")
  n=1
  while(n!=m-1):
    print(str(a[n-1])+' ',end="")
    n+=2
  print(a[m-2])
else:
  if(m==1):
    print(a[0])
  else:
    while(n>=3):
      print(str(a[n-1])+' ',end="")
      n-=2
    print(str(a[0])+' ',end="")
    n=2
    while(n!=m-1):
      print(str(a[n-1])+' ',end="")
      n+=2
    print(a[m-2])

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
#ARC077C
import sys
import math

n=int(input())

tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))


ans=[]
if(n%2==0):
	for i in range(0,n//2):
		ans.append(hoge[n-i*2-1])
	for i in range(0,n//2):
		ans.append(hoge[i*2])
else:
	for i in range(0,n//2+1):
		ans.append(hoge[n-i*2-1])
	for i in range(0,n//2):
		ans.append(hoge[i*2+1])
	

ret=""
ret+=str(ans[0])
for i in range(1,n):
	ret+=" "
	ret+=str(ans[i])
print(ret)

Submission status: Accepted

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

l = []
r = []
flag = False
if N % 2 == 0:
    for i in range(N-1, 0, -2):
        if flag:
            print(" ", end="")
        print(A[i], end="")
        flag = True
    for i in range(0, N, 2):
        if flag:
            print(" ", end="")
        print(A[i], end="")
else:
    for i in range(N-1, -1, -2):
        if flag:
            print(" ", end="")
        print(A[i], end="")
        flag = True
    for i in range(1, N, 2):
        if flag:
            print(" ", end="")
        print(A[i], end="")


print()

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
from collections import deque

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

for i in range(n):
    if i % 2 == 0:
        que.append(a[i])
    else:
        que.appendleft(a[i])
        
if len(que) % 2 != 0:
    for j in range(n):
        print(que.pop(), end = " ")
else:
    for k in range(n):
        print(que.popleft(), end = " ")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque
N=int(input())
A=list(map(int,input().strip().split(' ')))
q=deque([])
for i in range(len(A)):
    if i%2==0:
        q+=[A[i]]
    else:
        q.appendleft(A[i])
ans=0
if (len(A)-1)%2==1:
    ans=(list(q))
else:
    ans=(list(q)[::-1])
ans=[str(x) for x in ans]
print(" ".join(ans))

Submission status: Accepted

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

blist = deque([])
for i in range(n) :
    bi = alist.popleft()
    if (n^i)&1 == 1 :
        blist.appendleft(bi)
    else :
        blist.append(bi)

for b in blist :
    print(b, end=" ")

Submission status: Accepted

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

from collections import deque

Q=deque([])

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

ans = []

for i in range(n):
    ans.append(Q.popleft())

print(*ans)

Submission status: Accepted

Solution code:
# ARC077C - pushpush (ABC066C)
from collections import deque


def main():
    n = int(input())
    lst = list(map(int, input().rstrip().split()))
    b = deque()
    parity = n % 2
    for i, j in enumerate(lst, start=1):
        if i % 2 == parity:
            b.appendleft(j)
        else:
            b.append(j)
    print(*b)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from collections import deque

N = int(input())
*A, = map(int, input().split())
B = deque([])
for i, a in enumerate(A):
    if i % 2 == 0:
        B.append(a)
    else:
        B.appendleft(a)
if N % 2 == 1:
    B = list(reversed(B))
print(*B)

Submission status: Accepted

Solution code:
#ARC077C - pushpush (ABC066C)
from collections import deque

n = int(input())
lst = list(map(int, input().rstrip().split()))
b = deque()
parity = n % 2
for i, j in enumerate(lst, start=1):
    if i % 2 == parity:
        b.appendleft(j)
    else:
        b.append(j)
print(*b)

Submission status: Accepted

Solution code:
from collections import deque
N = int(input())
line = input().split()
Q = deque([])

flag = 0 if (N % 2 != 0) else 1
for i in range(N):
    if (i % 2 == 0):
        if (flag):
            Q.append(line[i])
        else:
            Q.appendleft(line[i])
    else:
        if (flag):
            Q.appendleft(line[i])
        else:
            Q.append(line[i])

print(' '.join(Q))

Submission status: Accepted

Solution code:
from collections import deque

n = int(input())
a = list(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(' '.join(b))

Submission status: Accepted

Solution code:
from collections import deque

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

dq = deque()
for i in range(n):
    if i % 2 == 0:
        dq.append(A[i])
    else:
        dq.appendleft(A[i])

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

Submission status: Accepted

Solution code:
from collections import deque

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

q = deque([])
for key, value in enumerate(a):
    if key & 1 == n & 1:
        q.append(value)
    else:
        q.appendleft(value)

print(*q)

Submission status: Accepted

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

b = deque()
for i,a in enumerate(A):
    if i % 2 == 0:
        b.append(a)
    elif i % 2 == 1:
        b.appendleft(a)

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

Submission status: Accepted

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

even = [A[i] for i in range(n) if i % 2 == 0]
odd = [A[i] for i in range(n) if i % 2 == 1]

if n % 2 == 0:
    print(' '.join(list(reversed(odd)) + even))
else:
    print(' '.join(list(reversed(even)) + odd))

Submission status: Accepted

Solution code:
N=int(input())
A=list(map(str, input().split(' ')))
even=A[0::2]
odd=A[1::2]
print(' '.join(even[::-1])+' '+' '.join(odd)) if N%2==1 else print(' '.join(odd[::-1])+' '+' '.join(even))

Submission status: Accepted

Solution code:
n = int(input())
As= list(map(int,input().split()))
back = As[::-2]
if n%2==0:
    forward = As[::2]
else:
    forward = As[1::2]
ans = back+forward
print(" ".join(map(str,ans)))

Submission status: Accepted

Solution code:
N = int(input())
A = [int(a) for a in input().split()]

print(*([A[i] for i in range(N-1,-1,-2)]+[A[i] for i in range(N%2,N,2)]))

Submission status: Accepted

Solution code:
n = int(input())
a = [int(_) for _ in input().split()]

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

print(*s)

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**9)
n=int(input())
A=list(map(int,input().split()))
B=[]
if n%2:
    for i in range(n-1,-1,-2):
        B.append(A[i])
    for i in range(1,n-1,2):
        B.append(A[i])
else:
    for i in range(n-1,0,-2):
        B.append(A[i])
    for i in range(0,n-1,2):
        B.append(A[i])
print(*B,sep=' ')

Submission status: Accepted

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

res = deque()

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

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(str,input().split()))
if n%2!=1:
    s=list(reversed(a[1::2]))+a[::2]
else:
    s=list(reversed(a[::2]))+a[1::2]
c=""
for i in range(n):
    c+=s[i]+" "
print(c)