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:
n = int(input())
num = list(map(str,input().split()))
a,b = [],[]
result = ''
for i in range(n):
  if i%2 == 0:
    a.append(num[i])
  else:
    b.append(num[i])
if n%2 ==1:
  result = ' '.join(a[::-1])
  result += ' ' + ' '.join(b)
else:
  result = ' '.join(b[::-1])
  result += ' ' + ' '.join(a)
print(result)

Submission status: Accepted

Solution code:
n = int(input())
lis = []
li = list(map(str,input().split()))
if n % 2 == 0:
    b = li[1::2]
    for m in range(n//2):lis.append(b[-(m + 1)])
    print(" ".join(lis[::] + li[::2]))
else:
    b = li[::2]
    for m in range((n//2)+1):lis.append(b[-(m + 1)])
    print(" ".join(lis[::]+li[1::2]))

Submission status: Accepted

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

cnt=n-1
while cnt>=0:
  ans.append(A[cnt])
  cnt-=2
if cnt==-2:
  cnt=1
else:
  cnt=0
while cnt<=n-1:
  ans.append(A[cnt])
  cnt+=2

for i in range(n):
  if i==n-1:
    print(ans[i])
  else:
    print(ans[i],"",end="")

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
a.insert(0,0)
b = []
if n%2==0:
	i=n
	while i>=2:
		b.append(a[i])
		i += -2
	k=1
	while k<=n-1:
		b.append(a[k])
		k += 2
else:
	i=n
	while i>=1:
		b.append(a[i])
		i += -2
	k=2
	while k<=n-1:
		b.append(a[k])
		k+=2
for i in range(n-1):
	print(b[i],end=' ')
print(b[n-1])

Submission status: Accepted

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

even, odd = [], []

for i in range(n):
  if i % 2 == 0:
    even.append(l[i])
  else:
    odd.append(l[i])

if n % 2 == 0:
  ans = odd[::-1] + even
else:
  ans = even[::-1] + odd
ans = map(str, ans)
print(' '.join(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.reverse()
ans=[]
re_ans=[]
if n==1:
    print(a[0])
else:
    ans=a[::2]
    re_ans=a[1::2]
    re_ans.reverse()
    ans.extend(re_ans)
    map_ans=map(str,ans)
    v=" ".join(map_ans)
    print(v)

Submission status: Accepted

Solution code:
n = int(input())
a=input().split()
l=n - n %2-1
e=[i for i in a[l::-2]]  
o=[i for i in a[::2]]
e.extend(o)
if n==1:
  print(*a)
elif n % 2 ==0:
  print(*e)
else:
  print(*e[::-1])

Submission status: Accepted

Solution code:
n = int(input())
A = [int(i) for i in 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 != 0]


if n % 2 == 0:
    odd.reverse()
    c = odd+even
else:
    even.reverse()
    c = even+odd
    
print(' '.join([str(i) for i in c]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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==(n-1)%2:
        b.appendleft(a[i])
    else:
        b.append(a[i])
    
print(' '.join(map(str,b)))

Submission status: Accepted

Solution code:
n = int(input())
b = []
a = input().split()
if n % 2 == 0:
    m = n // 2
    for i in range(m):
        b.append(a[n-2*i-1])
    for i in range(m):
        b.append(a[2*i])
else:
    m = n // 2
    for i in range(m+1):
        b.append(a[n-2*i-1])
    for i in range(m):
        b.append(a[2*i+1])
s = ""
for k in b:
    s += k + " "
print(s)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque
N = int(input())
a = list(map(int,input().split(" ")))
b = deque([a[0]])

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

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

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

print()

Submission status: Accepted

Solution code:
from collections import deque

toTail = True

n = int(input())
xs = map(int, input().split())

b = deque()
for x in xs:
    if toTail:
        b.append(x)
    else:
        b.appendleft(x)
    toTail = not toTail
if toTail:
    b = list(b)
else:
    b = reversed(list(b))
print(" ".join(map(str, b)))

Submission status: Accepted

Solution code:
N = int(input())
P = list(map(int,input().split()))
A = []
B = []
s = N // 2
if N % 2 == 0:
    for i in range(N-1, 0, -2):
        A.append(P[i])
    for j in range(0, N-1, 2):
        B.append(P[j])
else:
    for i in range(N-1, -1, -2):
        A.append(P[i])
    for j in range(1, N, 2):
        B.append(P[j])
for i in range(len(A)):
    print(A[i], end=" ")
for j in range(len(B)):
    print(B[j], end=" ")
print()

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 i in range(n):
        if i % 2 == 0:
            B.append(A[i])
        else:
            B.appendleft(A[i])

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

B = list(map(str, B))
print(" ".join(B))

Submission status: Accepted

Solution code:
#!/usr/bin/env python

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

def cal(p, rev):
    if(rev):
        lst=reversed(list(enumerate(a)))
    else:
        lst=list(enumerate(a))
    for k,v in lst:
        if(k%2==p):
            print(str(v)+" ", end="")

if(n%2==1):
    cal(0, True)
    cal(1, False)
    print()
else:
    cal(1, True)
    cal(0, False)
    print()

Submission status: Accepted

Solution code:
N = int(input())
lis = list(map(int,input().split()))
lisans = []
i = N-1
while i >= 0:
  lisans.append(lis[i])
  i -= 2
if N % 2 == 0:
  i += 1
else:
  i += 3
while i < N-1:
  lisans.append(lis[i])
  i += 2
print (" ".join(list(map(str,lisans))))

Submission status: Accepted

Solution code:
n, l = input(), raw_input().split()
print ' '.join(l[0::2][::-1] + l[1::2]) if len(l) % 2 else ' '.join(l[1::2][::-1] + l[0::2])

Submission status: Accepted

Solution code:
from collections import deque
n, l, b = input(), raw_input().split(), deque()
for t in xrange(n):
    b.append(l[t]) if (t + 1) % 2 else b.appendleft(l[t])
print ' '.join(reversed(b)) if n % 2 else ' '.join(b)

Submission status: Accepted

Solution code:
from collections import deque
n, l, b = input(), raw_input().split(), deque()
for t in xrange(n):
    if (t + 1) % 2:
        b.append(l[t])
    else:
        b.appendleft(l[t])
print ' '.join(reversed(b)) if n % 2 else ' '.join(b)

Submission status: Accepted

Solution code:
import sys
from collections import deque

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

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

for _ in b:
    sys.stdout.write(str(_) + " ")
sys.stdout.write("\n")

Submission status: Accepted

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

dp = [0]*n
for i in range(n):
    now = a[i]
    if i%2 == 0:
        dp[i//2] = now
    else:
        dp[-(i//2 + 1)] = now
print(" ".join(map(str, dp)))

Submission status: Accepted

Solution code:
n= input()
a = map(int,raw_input().split())
#print a

l=[ i for i in range(n)]
l_gusu=l[0::2]
l_kisu=l[1::2]

ans=[]
for i in reversed(list(l_gusu)):
	#print i,a[i]
	ans.append(a[i])

for i in l_kisu:
	ans.append(a[i])


ans_str=""
if n%2==0:
	for i in reversed(list(ans)):
		ans_str+=(str(i)+" ")
	print ans_str.strip()
else:
	for i in ans:
		ans_str+=(str(i)+" ")
	print ans_str.strip()

Submission status: Accepted

Solution code:
import math

num = int(input())
array = [int(x) for x in input().split()]

zero_array = array[0::2]
one_array = array[1::2]

if num % 2 == 0:
    one_array = one_array[:int(num/2)]
    pick = one_array[::-1] + zero_array[:int(num/2)]
else:
    one_array = one_array[:int(num/2)]
    pick= one_array[::-1] + zero_array[:math.ceil(num/2)]

if num % 2 == 0:
    print(" ".join(map(str, pick)))
else:
    print(" ".join(map(str, pick[::-1])))

Submission status: Accepted

Solution code:
from collections import deque

n = int(input())
a = list(map(int, input().split()))
b = deque()
turn = 1
for ai in a:
    if turn:
        b.append(ai)
    else:
        b.appendleft(ai)
    turn = (turn + 1) & 1

if n % 2:
    b = list(b)[::-1]
print(*b)

Submission status: Accepted

Solution code:
n = int(input())
a = input().split()
print(" ".join(a[::2][::-1] + a[1::2] if n%2 else a[1::2][::-1] + a[::2]))

Submission status: Accepted

Solution code:
n = int(input())
a = []
b = []

t = True
for i in input().split():
    if t:
        a.append(i)
    else:
        b.append(i)
    t = not t

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

Submission status: Accepted

Solution code:
from collections import deque


def solve():
    n = int(input())
    a = list(map(str, input().split(" ")))
    ans = deque()

    i = 0
    if n % 2:
        while i != n:
            if i % 2:
                ans.append(a[i])
            else:
                ans.appendleft(a[i])
            i += 1
    else:
        while i != n:
            if i % 2:
                ans.appendleft(a[i])
            else:
                ans.append(a[i])
            i += 1

    print(" ".join(ans))


solve()

Submission status: Accepted

Solution code:
r = lambda : map(int, raw_input().split())

n = r()[0]
a = r()

i = n-1 ;
while i >= 0 :
    print a[i],
    i -= 2 
    
if n % 2 == 0 : 
    i = 0
else :
    i = 1 
    
while i < n:
    print a[i],
    i += 2

Submission status: Accepted

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

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

if n%2 == 0:
    even.reverse()
    ans = even + odd
else:
    odd.reverse()
    ans = odd + even
print(" ".join(ans))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
http://abc066.contest.atcoder.jp/tasks/arc077_a

"""
import sys
from sys import stdin
input = stdin.readline



def main(args):
    n = int(input())
    a = [int(x) for x in input().split()]

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

    l = len(a)
    b = [0] * l
    pos = l // 2
    if l % 2 == 1:
        direction = 1
    else:
        direction = -1

    step = 1
    for c in a:
        # print('pos: {}, step: {}, direction: {}'.format(pos, step, direction))
        b[pos] = c
        pos = pos + (step * direction)
        step += 1
        direction *= -1
        # print(*b)
    print(*b)



if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
from collections import deque
N = int(input())
a = [int(i) for i in 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:
    [print(b[i], end=' ') for i in reversed(range(len(b)))]
else:
    [print(b[i], end=' ') for i in range(len(b))]

Submission status: Accepted

Solution code:
import collections

N = int(input())
a = list(map(int, input().split()))
b = collections.deque()

for i in range(N):
    if i % 2 == 0:
        b.appendleft(a[i])
    else:
        b.append(a[i])
    
if N % 2 == 0:
    i = N-1
    while i >= 0:
        print(b[i], end = ' ')
        i -= 1
else:
    for i in range(N):
        print(b[i], end = ' ')

Submission status: Accepted

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

print(' '.join(a[-1::-2] + a[(n % 2)::2]))

Submission status: Accepted

Solution code:
from collections import defaultdict
from itertools import product, groupby
from math import pi
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = 10 ** 10
 
 
def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    ans = []
    for i in range(1, len(a_list), 2):
        ans.append(a_list[i])
    ans = ans[::-1]
    for i in range(0, len(a_list), 2):
        ans.append(a_list[i])
 
    if n % 2 != 0:
        ans = ans[::-1]
    print(*ans)
 
 
if __name__ == '__main__':
    main()

Submission status: Accepted

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

b = [0]*n

for i in range(n//2):
    b[i] = a[-1-2*i]
    b[n-i-1] = a[-2-2*i]

if n % 2 == 1:
    b[n//2] = a[0]

print(' '.join(b))

Submission status: Accepted

Solution code:
from collections import deque

N= int(input())

A = list(map(int, input().split()))
A.reverse()
B = deque()
    
if N%2==0:
    for i in range(N):
        if i%2==0:
            B.append(A.pop())
        else:
            B.appendleft(A.pop())
else:
    for i in range(N):
        if i%2!=0:
            B.append(A.pop())
        else:
            B.appendleft(A.pop())

[print("{} ".format(b),end="") for b in B ]

Submission status: Accepted

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

    b_list = [-1 for i in range(512345)]
    left = 212345
    right = left+1
    for i in range(n):
        if (i+1)%2 == n%2:
            b_list[left] = a_list[i]
            left -= 1
        else:
            b_list[right] = a_list[i]
            right += 1

    print(' '.join([str(i) for i in b_list[left+1:right]]))

    
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def C_pushpush(x):
    from collections import deque
    # insertをリストの先頭に行うと、リストの要素の再配置に時間がかかる
    n = int(x[0])
    a = deque(x[1:])
    b = deque([])
    n_parity = n & 1
    for i in range(n):
        if n_parity == (i + 1) & 1:
            # n,iのパリティが一致
            b.appendleft(a[i])
        else:
            b.append(a[i])
    print(' '.join(b))

n = input()
l = [i for i in input().split()]
x = [n]+l
C_pushpush(x)

Submission status: Accepted

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

Submission status: Accepted

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

n = int(raw_input())
a = map(int, raw_input().split())
b = [i for i in range(n)]

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

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

Submission status: Accepted

Solution code:
#!/usr/bin
# -*- coding="utf-8" -*-
 
n = int(input())
a = input().split()
b = []
if n == 1:
  b.append(a[0])
else:
  for i in range(n-1, 0, -2):
    b.append(a[i])
  b.append(a[0])
  if n % 2 == 1:
    for i in range(1, n-1, 2):
      b.append(a[i])
  else:
    for i in range(2, n-1, 2):
      b.append(a[i])
print(' '.join(b))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
a = input().split()

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

print(" ".join(b))

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
from collections import deque

n = int(sys.stdin.readline())
ai = list(map(int, sys.stdin.readline().split(' ')))

bi = deque()

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

if n % 2 == 0:
	bi.reverse()

o = ""
while len(bi) > 0:
	o += str(bi.pop()) + " "

o = o[:-1]

print(o)

Submission status: Accepted

Solution code:
n=int(input())
arr=list(map(int,input().split()))
brr=[]
if n%2==0:
    for i in range(n-1,0,-2):
        brr.append(arr[i])
    for i in range(0,n-1,2):
        brr.append(arr[i])
else:
    for i in range(n-1,-1,-2):
        brr.append(arr[i])
    for i in range(1,n,2):
        brr.append(arr[i])
print(' '.join(list(map(str,brr))))

Submission status: Accepted

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

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

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

print(' '.join(map(str, 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+1) %2 == n % 2:
        b.appendleft(a[i])
    else:
        b.append(a[i])
ans = list(b)
print(*ans)

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])
    if(i%2 == 1):
        B.appendleft(A[i])

if(n%2 == 1):
    B.reverse()
text = ""
for b in B:
    text += str(b) + " "
text = text[:-1]
print(text)

Submission status: Accepted

Solution code:
n = int(raw_input())
a = map(int,raw_input().split(' '))
b = [0 for i in range(int(round(n/2.)))]
b_r = [0 for i in range(n//2)]
for i in range(n):
    if i%2 == 0:
        b[i/2] = a[i]
    else:
        b_r[i/2] = a[i]

n2 = int(round(n/2.))
if n%2 == 0:
    s = str(b_r[n2-1])
    for i in range(1,n):
        if i < n2:
            s += ' ' + str(b_r[n2-1-i])
        else:
            s += ' ' + str(b[i-n2])
    print s
else:
    s = str(b[n2-1])
    for i in range(1,n):
        if i < n2:
            s += ' ' + str(b[n2-1-i])
        else:
            s += ' ' + str(b_r[i-n2])
    print s

Submission status: Accepted

Solution code:
import sys

n = int(raw_input())
a_list = [int(i) for i in raw_input().split()]

# n = 9                                                                                                                                                                                                                                       
# a_list = [1,2,3,4,5,6,7,8,9]                                                                                                                                                                                                                

b_list = [0] * n

for i in range(n):
    if n % 2 == 0:
        if i % 2 == 0:
            idx = int(n / 2) + i/2
        else:
            idx = int(n / 2) - i/2 - 1
    else:
        if i % 2 != 0:
            idx = int(n / 2) + i/2 + 1
        else:
            idx = int(n / 2) - i/2
    b_list[idx] = a_list[i]



# 1                                                                                                                                                                                                                                           
# 2,1                                                                                                                                                                                                                                         
# 3,1,2                                                                                                                                                                                                                                       
# 4,2,1,3                                                                                                                                                                                                                                     
# 5,3,1,2,4                                                                                                                                                                                                                                   
# 6,4,2,1,3,5                                                                                                                                                                                                                                 
# 7,5,3,1,2,4,6                                                                                                                                                                                                                               
# 8,6,4,2,1,3,5,7                                                                                                                                                                                                                             
# 9,7,5,3,1,2,4,6,8                                                                                                                                                                                                                           

ans = ''
for b in b_list:
    ans += '{} '.format(b)
ans = ans.rstrip()

print ans

Submission status: Accepted

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

even = []
odd = []

for i in range(N):
    if (i + 1) % 2 != 0:
        odd.append(a[i])
    else:
        even.append(a[i])

if N % 2 != 0:
    even.reverse()
else:
    odd.reverse()

ans = []
if N % 2 != 0:
    ans = even + odd
else:
    ans = odd + even

for i in range(N - 1):
    print ans.pop(),

print ans.pop()

Submission status: Accepted

Solution code:
N = int(input())
a = input().split()
if N%2==0:
    ans=a[::-2] + a[::2]
else:
    ans=a[::-2] + a[1::2]
print(" ".join(ans))

Submission status: Accepted

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

import re

n = int(raw_input())
a = re.split('\s', raw_input())

ans = [0]*n

if (n % 2 == 0):
        first = n / 2 - 1
        second = n / 2
        for i in range(n):
                if (i % 2 == 0):
                        ans[second] = a[i]
                        second += 1
                else:   
                        ans[first] = a[i]
                        first -= 1
else:   
        first = (n - 1) / 2
        second = (n - 1) / 2 + 1
        for i in range(n):
                if (i % 2 == 1):
                        ans[second] = a[i]
                        second += 1
                else:   
                        ans[first] = a[i]
                        first -= 1
ans = map(str, ans)
print " ".join(ans)

Submission status: Accepted

Solution code:
n = int(input())
m = [int(x) for x in input().strip().split()]
if n % 2 == 0:
    nm = m[::-2] + m[::2]
else:
    nm = m[::-2] + m[1::2]
for i,x in enumerate(nm):
    if i == n-1:
        print(str(x), end='')
    else:
        print(str(x) + ' ', end='')

Submission status: Accepted

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

Submission status: Accepted

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

while(n > 0):
    print(l[n-1])
    n -= 2

n+=1
if(n<=0):
    n+=2
    
while(n < len(l)):
    print(l[n-1])
    n += 2

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

for i in range(n):
    if n%2!=0:
        i=n-i-1
    print(str(b[i]) + " ", end="")
print()

Submission status: Accepted

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

result = []

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

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

Submission status: Accepted

Solution code:
from collections import deque
N = int(input())
s = input().split()
a = [int(i) for i in s]

b = deque()

for i in range(N) : 
    if i % 2 == 0 : b.append(a[i])
    if i % 2 == 1 : b.appendleft(a[i])

if i % 2 == 0 : b.reverse()        

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

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:
n = int(input())
a = list(map(int, input().split(" ")))

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

if n%2 == 1:
    b1.append(a[n-1])
    b1.reverse()
    b.extend(b1)
    b.extend(b2)
else:
    b2.reverse()
    b.extend(b2)
    b.extend(b1)

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

Submission status: Accepted

Solution code:
from collections import deque
n = int(input())
di = 0
Q = deque()
for i in map(int,input().split()):
    if di: Q.appendleft(i)
    else: Q.append(i)
    di = 1-di
for i in range(n):
    if n%2 == 0: print(Q.popleft(), end=' ')
    else: print(Q.pop(), end=' ')

Submission status: Accepted

Solution code:
import math
inf=float('inf')
N = int(input())
x = list(map(int, input().split()))
y = [0]*(N)
j=0
for i in range(0,N,1):
    
    if i%2==0:
        y[j]=x[N-1-i]
  
    if i%2==1:
        y[N-1-j]=x[N-1-i]
        j+=1
    
    


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

Submission status: Accepted

Solution code:
n=int(input())
nums=input().split()
n1=nums[::2]
n2=nums[1::2]

if len(nums)%2==0:
    ans=" ".join(n2[::-1])+" "+" ".join(n1)
else:
    ans = " ".join(n1[::-1]) + " " + " ".join(n2)

print(ans)

Submission status: Accepted

Solution code:
# encoding:utf-8
n = int(input())
ary = input().split()

if n % 2 == 0:
	out = [i for i in range(2, n+1, 2)]
	out.reverse()
	out.extend([i for i in range(1, n, 2)])
	out_str = [str(ary[i-1]) for i in out]
else:
	out = [i for i in range(1, n + 1, 2)]
	out.reverse()
	out.extend([i for i in range(2, n, 2)])
	out_str = [str(ary[i-1]) for i in out]

print(" ".join(out_str))

Submission status: Accepted

Solution code:
def p(b):
    for i in range(0,len(b)):
        if i==len(b)-1:
            print(b[i])
        else:
            print(b[i],' ',end="")

n=int(input())
a=[int(i) for i in input().split()]
b=[None]*n
if n%2==1:
    m=int(n/2)
    b[m]=a[0]
    s=1
    t=1
    while s+m<n:
        b[m+s]=a[t]
        t+=1
        b[m-s]=a[t]
        t+=1
        s+=1
    p(b)
else:
    m=int(n/2)
    b[m]=a[0]
    s=1
    t=1
    while s+m<=n:
        b[m-s]=a[t]
        t+=1
        if m-s==0:
            break
        b[m+s]=a[t]
        t+=1
        s+=1
    p(b)

Submission status: Accepted

Solution code:
from collections import deque

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

b = deque()
for i in range(n):
    if (n % 2 == 0 and (i+1) % 2 == 0) or (n % 2 != 0 and (i+1) % 2 != 0):
        b.appendleft(l[i])
    else:
        b.append(l[i])

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

Submission status: Accepted

Solution code:
n=int(input())
a=input().split()
for i in range(n):
        if n > 0: 
                print(a[n-1],end=" ")
                n=n-2
                if n == 0 or n == -1:
                        n=n-1
        elif n < 0: 
                print(a[-1*n-1],end=" ")
                n=n-2
print("")

Submission status: Accepted

Solution code:
n = int(input())
s = input().split()
s1 = s[::2]
s2 = s[1::2]

if s2:
    if len(s) % 2:
        print(" ".join(s1[::-1]) +" "+ " ".join(s2))
    else:
        print(" ".join(s2[::-1]) +" "+ " ".join(s1))
else:
    print(" ".join(s1))

Submission status: Accepted

Solution code:
def reverse_append(nums):
    ans = [0] * len(nums)
    left = len(nums) % 2 == 1
    right_i = (len(nums)+1) // 2
    left_i = right_i - 1
    for i in range(len(nums)):
        if left:
            left = not left
            ans[left_i] = nums[i]
            left_i -= 1
        else:
            left = not left
            ans[right_i] = nums[i]
            right_i += 1
    return ans

if __name__ == "__main__":
    raw_input()
    nums = [int(i) for i in raw_input().split()]
    print(" ".join([str(num) for num in reverse_append(nums)]))

Submission status: Accepted

Solution code:
n=int(input())
data=list(map(str,input().split()))
if(len(data)==1):
    print(data[0])
else:
    newdata = data[::2][::-1]+data[1::2]
    if n%2==0:
        print(' '.join(newdata[::-1]))
    else:
        print(' '.join(newdata))

Submission status: Accepted

Solution code:
n = int(raw_input())
l = map(int, raw_input().split())
m = []
i = n-1
while i >= 0:
    m.append(l[i])
    i -= 2
i += 1
while i < 0:
    i += 2
while i < n:
    m.append(l[i])
    i += 2
print ' '.join(map(str, m))

Submission status: Accepted

Solution code:
import sys
n = int(sys.stdin.readline())
a = [x for x in sys.stdin.readline().split()]
b = [a[i] for i in range(n) if i % 2 != 0]
rb = b[::-1]
c = [a[i] for i in range(n) if i % 2 == 0]
rc = c[::-1]

if n % 2 == 0:
    ans = rb + c
else:
    ans = rc + b

ans = " ".join(ans)
print(ans)

Submission status: Accepted

Solution code:
input();A=input().split();print(*A[::-2]+A[len(A)%2::2])

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
o =a[::2]
e =a[1::2]
if len(a)%2==0:
    ans = e[::-1]+o
elif len(a)==1:
    ans = a
else:
    ans = o[::-1]+e
print(' '.join(map(str,ans)))

Submission status: Accepted

Solution code:
if(__name__ =="__main__"):
    N = int(input())
    a = [int(i) for i in input().split()]
    b = [0] * 512345
    left = 212345
    right = left + 1
    for i in range(N):
        if(i % 2 == (N-1) % 2):
            #b.insert(0,a[i])
            b[left] = a[i]
            left -= 1
        else:
            #b.append(a[i])
            b[right] = a[i]
            right += 1
        #print(b)
        # b = b[::-1] TLE:O(N)    
        #print(b)
    #b.extend(a)
    #print(' '.join(map(str,b)))
    for i in range(left+1,right):
        print(b[i],end=" ")