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: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque

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

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

if rev % 2 == 1:
    b.reverse()

print(*b)

Submission status: Accepted

Solution code:
import sys
import os

def file_input():
    f = open('ABC066/input.txt', 'r')
    sys.stdin = f

def main():
    #file_input()
    n=int(input())
    a=list(map(int, input().split()))

    out=[""]*n

    for i in range(n):
        if i%2==0:
            out[n//2+i//2]=str(a[i])
        else:
            out[n//2-(-(-i//2))]=str(a[i])
    if n%2!=0:
        out.reverse()

    print(*out)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
import os
import math
import bisect
import collections
import itertools
import heapq
import re
import queue

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

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


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    A = il()
    ret = collections.deque()

    for n in range(N):
        if N % 2 == (n+1) % 2:
            ret.appendleft(A[n])
        else:
            ret.append(A[n])
    print(*ret)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = [int(x) for x in input().split()]
b = [0]*n

k = 0
for i in range(n-1, -1, -2):
  b[k] = a[i]
  k += 1
for i in range(n%2, n, 2):
  b[k] = a[i]
  k += 1

print(*b)

Submission status: Accepted

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

frn = ["" for i in range((n+1)//2)]
bck = ["" for i in range(n//2)]

for i in range(n):
    if i%2 == 0:
        frn[i//2] = a[i]
    else:
        bck[i//2] = a[i]

if n%2 == 0:
    print(" ".join(bck[::-1]+frn))
else:
    print(" ".join(frn[::-1]+bck))

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
A = iil()

tail = [item for i,item in enumerate(A) if i%2 == 0]
head = [item for i,item in enumerate(A) if i%2 == 1]
ans = head[::-1]+tail if n%2 == 0 else tail[::-1]+head
print(*ans)

Submission status: Accepted

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

ans_li=[]
if n%2==0:
    for i in range(n,0,-2):
        ans_li.append(a_input[i-1])
    for i in range(1,n,2):
        ans_li.append(a_input[i-1])
else:
    for i in range(n,0,-2):
        ans_li.append(a_input[i-1])
    for i in range(2,n,2):
        ans_li.append(a_input[i-1])
print(' '.join(map(str,ans_li)))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from collections import deque
n = int(input())
a = input().split()
b = deque()
f = True
for ai in a:
    if f:
        b.appendleft(ai)
    else:
        b.append(ai)
    f = not f
if f:
    b.reverse()
    print(" ".join(b))
else:
    print(" ".join(b))

Submission status: Accepted

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

    b = a[1::2]
    c = a[::2]
    
    if len(a)%2 == 0:
        return b[::-1] + c
    else:
        return c[::-1] + b
    

print(*solve())

Submission status: Accepted

Solution code:
from collections import deque

input()
values = tuple(input().split(' '))

queue = deque()

for index, value in enumerate(values):
    if index % 2 == 0:
        queue.append(value)
    else:
        queue.appendleft(value)

if len(values) % 2 == 1:
    queue.reverse()

print(' '.join(queue))

Submission status: Accepted

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

before_turn = []
for i in reversed(A[1::2]):
    before_turn.append(i)

for i in A[::2]:
    before_turn.append(i)


if N % 2 == 0 or N == 1:
    print(" ".join(map(str, before_turn)))
else:
    turn = before_turn[::-1]
    print(" ".join(map(str, turn)))

Submission status: Accepted

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

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

if n%2==1:
    d.reverse()

print(' '.join(d))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Wed May 13 13:11:09 2020

@author: shinba
"""
from collections import deque

n = int(input())

reverse = False

B = deque([])

for i in map(int,input().split()):
    if not reverse:
        B.append(i)
        reverse = True
    else:
        B.appendleft(i)
        reverse = False
        
if not reverse:
    print(" ".join(map(str,B)))
else:
    B.reverse()
    print(" ".join(map(str,B)))

Submission status: Accepted

Solution code:
from collections import deque
 
N = int(input())
numbers = input().split()
 
d = deque()
 
for i in range(N):
    if i % 2 == 0:
        d.append(numbers[i])
    else :
        d.appendleft(numbers[i])
        
if N % 2 == 1:
    d.reverse()
    
output = ' '.join(d)
 
print(output)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque
N=int(input())
*A,=map(int, input().split())
B=deque([])
S=False
for i in range(N):
    if i==0:
        B.append(A[i])
    else:
        if i%2==1:
            B.appendleft(A[i])
            S=False
        else:
            B.append(A[i])
            S=True
B=list(B)
if S:
    B=reversed(B)

print(*B)

Submission status: Accepted

Solution code:
from collections import deque

N = int(input())
numbers = input().split()

d = deque()

for i in range(N):
    if i % 2 == 0:
        d.append(numbers[i])
    else :
        d.appendleft(numbers[i])
        
if N % 2 == 1:
    d.reverse()
    
output = ' '.join(d)

print(output)

Submission status: Accepted

Solution code:
from collections import deque

N = int(input())
numbers = input().split()

d = deque()

for i in range(N):
    if i % 2 == 0:
        d.append(numbers[i])
    else :
        d.appendleft(numbers[i])
        
if N % 2 == 1:
    d.reverse()
    
output = ' '.join(d)

print(output)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import deque
n = int(input())
a = list(map(int, input().split()))
b = deque([a[0]])

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

if (n - 1) % 2 == 1:
    [print(ans, end = " ") for ans in list(b)[::-1]]
else:
    [print(ans, end = " ") for ans in list(b)]

Submission status: Accepted

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

for i, k in enumerate(a):
    if i % 2 == 0:
        b[n // 2 + (i + 1) // 2] = k
    else:
        b[n // 2 - (i + 1) // 2] = k

if n % 2 == 1:
    print(' '.join([str(k) for k in b[::-1]]))
else:
    print(' '.join([str(k) for k in b]))

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc066/tasks/arc077_a

from collections import deque
n = int(input())
nums = [int(i) for i in input().split()]

ans = deque()
rev = False
for i in range(n):
    if rev:
        ans.appendleft(nums[i])
        rev = False
    else:
        ans.append(nums[i])
        rev = True
if rev:
    ans = reversed(ans)
print(*ans)

Submission status: Accepted

Solution code:
import sys
n = int(input())
a = list(map(int, sys.stdin.readline().split()))
if n%2:
    print(" ".join(map(str, a[::-1][::2] + a[1::2])))
else:
    print(" ".join(map(str, a[::-1][::2] + a[::2])))

Submission status: Accepted

Solution code:
import math
N = int(input())
x = list(map(int, input().split()))
y = []
if N%2 == 0:
    for i in range(N//2):
        y.append(x[N-1-2*i])
    for i in range(N//2):
        y.append(x[2*i])
if N%2 == 1:
    for i in range(math.ceil(N/2)):
        y.append(x[N-1-2*i])
    for i in range(math.floor(N/2)):
        y.append(x[2*i+1])
print(*y)

Submission status: Accepted

Solution code:
n = int(input())
a = input().split()
a_odd = a[1::2]
a_even = a[0::2]

if n % 2 == 0:
    a_odd.reverse()
    ans = a_odd + a_even
else:
    a_even.reverse()
    ans = a_even + a_odd
print(' '.join(ans))

Submission status: Accepted

Solution code:
from collections import deque


def resolve():
	n = int(input())
	a = list(map(int, input().split()))
	d = deque()
	is_even = True if n % 2 == 0 else False
	for i in range(n):
		if is_even:
			if (i+1) % 2 == 0:
				d.appendleft(a[i])
			else:
				d.append(a[i])
		else:
			if (i+1) % 2 == 0:
				d.append(a[i])
			else:
				d.appendleft(a[i])

	print(" ".join(list(map(str, d))))
resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy

# import heapq
# from collections import deque
# import decimal

sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def main():
    n = ni()
    a = na()

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

    odd.reverse()
    odd.extend(even)

    if len(a)%2:
        odd.reverse()

    print(*odd, sep=" ")



if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


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

    ans = a[-1::-2] + a[n % 2::2]
    print(*ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

if n % 2 == 0:
  for x in range(n):
    if x % 2 == 0:
      b.append(a[x])
    else:
      b.appendleft(a[x])
else:
  for y in range(n):
    if y % 2 == 1:
      b.append(a[y])
    else:
      b.appendleft(a[y])

print(" ".join(b))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from collections import deque

n, *a = map(int, read().split())
b = deque()
v = 1 if n % 2 == 0 else 0
for i, aa in enumerate(a):
    if i % 2 == v:
        b.appendleft(aa)
    else:
        b.append(aa)
print(*b)

Submission status: Accepted

Solution code:
n = int(input())
A = list(map(int,input().split()))
b = ""
inv = 1
import collections
b = collections.deque()
for i in range(n):
    a = A[i]
    if inv ==1:
        b.append(a)
    else:
        b.appendleft(a)
    inv *=-1
if inv ==1:
    print(*b)
else:
    print(*reversed(b))

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

print(*ans)

Submission status: Accepted

Solution code:
from collections import deque
N = int(input())
A = tuple(map(int, input().split()))
B = deque([])
for i in range(N):
    if i & 1:
        B.appendleft(A[i])
    else:
        B.append(A[i])
if N & 1:
    print(*reversed(B))
else:
    print(*B)

Submission status: Accepted

Solution code:
import collections

n=int(input())
a=list(map(int,input().split()))
ans=[]
deqans=collections.deque(ans)
for i in range(1,n+1):
    if i%2==0:
        deqans.appendleft(a[i-1])
    else:
        deqans.append(a[i-1])
if n%2!=0:
    deqans.reverse()
ans=list(deqans)
ans=[str(a) for a in ans]
print(" ".join(ans))

Submission status: Accepted

Solution code:
N = int(input())
A = [int(x) for x in input().split()]
if N&1:
    ans = A[::2][::-1] + A[1::2]
else:
    ans = A[1::2][::-1] + A[::2]
print(*ans)

Submission status: Accepted

Solution code:
from collections import deque
N = int(input())
A = [int(x) for x in input().split()]
if N%2==0:
    queue = deque()
    for i in range(0, N, 2):
        queue.append(A[i])
        queue.appendleft(A[i+1])
else:
    queue = deque([A[0]])
    for i in range(1, N, 2):
        queue.append(A[i])
        queue.appendleft(A[i+1])

print(*queue)

Submission status: Accepted

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

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

print(*B)

Submission status: Accepted

Solution code:
n = int(input())

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

half = int(n/2)
for i in range(1,n+1):
    t = i%2
    if t != 0:
        b[half+int(i/2)] = a[i-1]
    else:
        b[half-int(i/2)] = a[i-1]

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

Submission status: Accepted

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

a1 = a[::2]
a2 = a[1::2]

if n % 2 == 1:
  print(" ".join(a1[::-1] + a2))
else:
  print(" ".join(a2[::-1] + a1))

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7



def main():
    N = int(readline())
    A = list(map(int, readline().split()))
    B = [0]*N
    index = 0
    for i in range(N)[::-1]:
        if index <0:
            B[index] = A[i]
            index *= -1
        else:
            B[index] = A[i]
            index = -index -1
    print(' '.join(map(str, B)))
if __name__ == '__main__':
    main()

Submission status: Accepted

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

a1 = list(map(str, a[::2]))
a2 = list(map(str, a[1::2]))

if n % 2 == 1:
  print(" ".join(a1[::-1] + a2))
else:
  print(" ".join(a2[::-1] + a1))

Submission status: Accepted

Solution code:
from collections import deque
def main3():
    d = deque()
    rd= deque()
    N = int(input().strip())
    for n in input().split():
        if len(rd)%2!=0:
            d.append(n)
            rd.appendleft(n)
        else:
            rd.append(n)
            d.appendleft(n)
    if N % 2 ==0:
        print(*rd)
    else:
        print(*d)

if __name__ == "__main__":
    main3()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

n = int(input())
a = list(map(int,input().split()))
ans = ""
d = collections.deque()
for i in range(n):
    if i%2 == 1:
        d.append(a[i])
    else:
        d.appendleft(a[i])
ans = []
if n%2 == 1:
    for i in range(n):
        ans.append(d[i])
else:
    for i in range(n):
        ans.append(d[n-i-1])
print(*ans)

Submission status: Accepted

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

answer_list=[]
for i in range(n-1,-1,-2):
  answer_list.append(alist[i])
if n%2==0:
  for i in range(0,n,2):
    answer_list.append(alist[i])
else:
  for i in range(1,n,2):
    answer_list.append(alist[i])
    
print(*answer_list)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

d = [0 for _ in range(n)]

l = [i for i in input().split()]

for idx,i in enumerate(l[::-1]):
    if idx % 2 == 0:
        d[idx//2] = i
    else:
        d[-1*idx //2] = i
        
print(*d)

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

Submission status: Accepted

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

if n%2==0:
    al=al[::-1]
    for a in al:
        print(a,end=" ")
    for a in af:
        print(a,end=" ")
else:
    af=af[::-1]
    for a in af:
        print(a,end=" ")
    for a in al:
        print(a,end=" ")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
a = list(map(int,input().split()))
b = [-1] *N

for i in range((N+1)//2):
  b[i] = str(a[N-1-i*2])
for i in range(N //2):
  b[i+((N+1)//2)] = str(a[N%2 + 2*i])
print(" ".join(b))

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!=n%2:
        ans.appendleft(a[i])
    else:
        ans.append(a[i])
for i in ans:
    print(i,end=" ")

Submission status: Accepted

Solution code:
from collections import deque
n=int(input())
a=deque(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()
l=[str(i) for i in b]
print(" ".join(l))

Submission status: Accepted

Solution code:
from collections import deque
d = deque()

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

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

Submission status: Accepted

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

Submission status: Accepted

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


answer = arr[::2][::-1] + arr[1::2]
if not N&1:
  answer = answer[::-1]
  
print(*answer,sep=' ')

Submission status: Accepted

Solution code:
from collections import deque
dq=deque([])
#pop/append/(append,pop)_left/in/len/count/[]/index/rotate()(右へnずらす)
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    if i%2:
        dq.append(a[i])
    else:
        dq.appendleft(a[i])
print(*list(dq)[::(-1)**(n%2+1)],sep= " ")

Submission status: Accepted

Solution code:
n = int(input())
A = list(map(int,input().split()))
flag = 0
plus = [[],[]]
for a in A:
    plus[flag].append(a)
    flag ^= 1
print(' '.join(str(i) for i in plus[1 - flag][::-1] + plus[flag]))

Submission status: Accepted

Solution code:
from collections import deque

def resolve():
	n = int(input())
	a = list(map(int, input().split()))
	b = [0]*n
	d = deque()
	h = len(b) // 2
	for i in range(1, n+1):
		if n % 2 == i % 2:
			d.appendleft(str(a[i-1]))
		else:
			d.append(str(a[i-1]))
	print(" ".join(d))
resolve()

Submission status: Accepted

Solution code:
from collections import deque

N = int(input())
A = list(map(int, input().split()))
ans = deque([])

for i in range(1, N+1):
    if i % 2 == N % 2:
        ans.appendleft(A[i-1])
    else:
        ans.append(A[i-1])
print(*ans)

Submission status: Accepted

Solution code:
n=int(input())
l=list(map(int,input().split()))
from collections import deque
dq=deque([])
#pop/append/(append,pop)_left/in/len/count/[]/index/rotate()(右へnずらす)
for i in range(n):
    if i%2:
        dq.append(l[i])
    else:dq.appendleft(l[i])
print(*list(dq)[::-(-1)**(n%2)])

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
from collections import deque
ans = deque([a[0]])
odd = True
if n%2 == 0:
    for i in range(1,n):
        if odd:
            ans.appendleft(a[i])
            odd = False
        else:
            ans.append(a[i])
            odd = True
else:
    for i in range(1,n):
        if odd:
            ans.append(a[i])
            odd = False
        else:
            ans.appendleft(a[i])
            odd = True
ans = list(ans)
for i in range(n):
    print(ans[i],end = ' ')

Submission status: Accepted

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

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

if n%2 ==0:
    mae = []
    ushiro = []
    for i in range(0,n,2):
        ushiro.append(a[i])
    for i in reversed(range(1,n,2)):
        mae.append(a[i])
    ans = mae + ushiro
    print(*ans, sep=' ')
else:
    mae = []
    ushiro = []
    for i in range(1,n,2):
        ushiro.append(a[i])
    for i in reversed(range(0,n,2)):
        mae.append(a[i])
    ans = mae + ushiro
    print(*ans, sep=' ')

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:
        s.append(a[i])
    else:
        s.appendleft(a[i])
if n%2==0:
    s.reverse()
print(str(s).replace(' ','').replace(',',' ').replace('deque([','').replace('])','\n').replace("'",''))

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    A = [a for a in input().split()]
    odd = [A[i] for i in range(N) if (i+1) % 2 == 1]
    even = [A[i] for i in range(N) if (i+1) % 2 == 0]

    if len(A) % 2 == 1:
        print(*(odd[::-1]+even))
    else:
        print(*(even[::-1]+odd))
if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

if N %2 == 0:#Nが偶数なら
  print(" ".join(list(map(str,list(reversed(a_even)) + a_odd))))
else:
  print(" ".join(list(map(str,list(reversed(a_odd)) + a_even))))

Submission status: Accepted

Solution code:
from collections import deque
def myAnswer(N:int,A:list) -> None:
   ans = deque()
   for n,a in enumerate(A):
      if((n + 1)% 2==0):
         ans.append(str(a))
      else:
         ans.appendleft(str(a))
   if(N % 2 == 0):
      ans = reversed(ans)
   print(" ".join(ans))

def modelAnswer():
   return
def main():
   N = int(input())
   A = list(map(int,input().split()))
   myAnswer(N,A[:])
if __name__ == '__main__':
   main()

Submission status: Accepted

Solution code:
from collections import deque,Counter

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

B = deque()

flg = True
for a in arrA:
    if flg:
        B.append(a)
    else:
        B.appendleft(a)
    flg = not flg
if not flg:
    B.reverse()

print(*B)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

stack = deque()
for i in range(n):
    if i % 2 == 0: stack.append(a[i])
    else: stack.appendleft(a[i])
ans = list(stack)
if n % 2 != 0: ans = ans[::-1]
print(" ".join(map(str, ans)))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = []
c = []
flag = True
for i in range(n):
    if flag:
        b.append(a[i])
        flag = False
    else:
        c.append(a[i])
        flag = True
if flag:
    c.reverse()
    ans = c+b
else:
    b.reverse()
    ans = b+c
for i in range(n):
    print(ans[i], end=" ")
print()

Submission status: Accepted

Solution code:
from collections import deque

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

if n % 2 == 0:
    flg = True
else:
    flg = False

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

na = list(na)
if flg:
    for el in na:
        print(el, end=" ")
else:
    for el in reversed(na):
        print(el, end=" ")

Submission status: Accepted

Solution code:
from collections import deque

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

if n % 2 == 0:
    flg = True
else:
    flg = False

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

na = list(na)
if flg:
    for el in na:
        print(el, end=" ")
else:
    for el in reversed(na):
        print(el, end=" ")

Submission status: Accepted

Solution code:
from collections import deque

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

d=deque()

odd = True

for i, aa in enumerate(a):
    if odd:
        d.append(str(aa))
        odd = False
    else:
        d.appendleft(str(aa))
        odd = True

if odd == False:
    d = list(d)[::-1]
ans = ' '.join(d)
print(ans)

Submission status: Accepted

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