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:
if(__name__ =="__main__"):
    N = int(input())
    a =[int(i) for i in input().split()]
    b = []
    for i in range(N-1,-1,-2):
        b.append(a.pop(i))
        #print(b)
        # b = b[::-1] TLE:O(N)    
        #print(b)
    b.extend(a)
    print(' '.join(map(str,b)))

Submission status: Accepted

Solution code:
from collections import deque

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

for index, value in enumerate(a):
    if index % 2 == 0:
        b.appendleft(value)
    else:
        b.append(value)
if n % 2 == 0:
    b = reversed(b)
print(" ".join(map(str, b)))

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = list()
c = list()
for i in range(n):
    if(i==0):
        b.append(a[i])
    elif(i%2==1):
        b.append(a[i])
    else:
        c.append(a[i])
c.reverse()
c = c + b
if(i%2==1):
    c.reverse()
for i in c:
    print(i,end=' ')

Submission status: Accepted

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

b = [None for i in range(n)]

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

# if n % 2:
#     start = 0
# else:
#     start = 1

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


# print(b)


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

print()

Submission status: Accepted

Solution code:
n = int(input())
a = input().split()
b = []
ans = []
even = a[1::2]
odd = a[0::2]
b.append(even)#even number
b.append(odd)#odd number
# print(b)
if len(a) % 2 == 0:
    for i in range(1,len(even) + 1):
        ans.append(even[-i])
    ans = ans + odd
else:
    for i in range(1,len(odd) + 1):
        ans.append(odd[-i])
    ans = ans + even
for i in range(len(ans)):
    if i != len(ans) -1:
        print(ans[i],end=" ")
    else:
        print(ans[i])

Submission status: Accepted

Solution code:
from collections import deque
n = int(input())
even = n%2
ans = deque()
s = list(map(int,(input().split())))
for i in range(n):
    if i%2 != even:#i(コード上はi+1) と n の偶奇が一致していれば、数列の前に ai を追加する。
        ans.appendleft(s[i])
    else:
        ans.append(s[i])
print(" ".join(map(str,ans)))

Submission status: Accepted

Solution code:
from collections import deque

def main():
    N = int(input())
    A = tuple(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(*b, sep=' ')

main()

Submission status: Accepted

Solution code:
import sys
N=int(input())
a=list(map(int,input().split()))
b=[0 for _ in range(N)]
if(N%2==0):
    l=int(N/2)-1
else:
    l=int(N/2)
r=l+1
for i in range(N):
    if(i%2==(N-1)%2):
        b[l]=a[i]
        l-=1
    else:
        b[r]=a[i]
        r+=1
for index,item in enumerate(b):
    if(index==len(b)-1):
        break
    sys.stdout.write(str(item)+" ")
sys.stdout.write(str(b[N-1])+"\n")

Submission status: Accepted

Solution code:
from collections import deque

n = int(input())
b = deque()
flag = 1
for i in input().split():
    if flag > 0:
        b.append(i)
    else:
        b.appendleft(i)
    flag *= -1
if flag < 0:
    b.reverse()
print(' '.join(b))

Submission status: Accepted

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

#-------
# Initialize
n = int(input())
a = list(input().split())


itr = n
while(itr > 0):
    print(a[itr-1] + ' ', end="")
    itr -= 2
itr = n % 2
while(itr < n):
    print(a[itr] + ' ', end="")
    itr += 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:
# -*- coding:utf-8 -*-
from collections import deque
def odd(num):
    return True if num%2!=0 else False
n = int(input())
a = list(input().split())
b = deque()
for tmp in range(len(a)):
    if odd(n) == odd(tmp+1):
        b.appendleft(a[tmp])
    else:
        b.append(a[tmp])
print(' '.join(b))

Submission status: Accepted

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

n = int(input())
A = [x for x in 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])
print(" ".join(B))

Submission status: Accepted

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

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

print(' '.join(d))

Submission status: Accepted

Solution code:
import numpy as np
n = int(input())
A = input()
a = list(map(int,A.split(" ")))
a = np.array(a)
even= a[1::2]
odd= a[0::2]
if n%2 == 0:
    b = np.append(even[::-1],odd)
else:
    b = np.append(odd[::-1],even)
 
import sys
for d in b[:-1]:
    sys.stdout.write(str(d)+ " ")
sys.stdout.write(str(b[-1])+"\n")

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    A = tuple(map(int, input().split()))

    b = [None] * N
    i = 0
    j = N - 1
    n = 1
    for k in range(N-1, -1, -1):
        if n & 1:
            b[i] = A[k]
            i += 1
        else:
            b[j] = A[k]
            j -= 1
        n += 1

    print(*b, sep=' ')

main()

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
import sys

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

for i in range(0,N):
	if N-1-i*2 >= 0:
		sys.stdout.write(str(a[N-1-i*2]))
		sys.stdout.write(" ")
	elif (N % 2) == 1:
		sys.stdout.write(str(a[int((i-(N-1)/2)*2-1)]))
		sys.stdout.write(" ")
	else:
		sys.stdout.write(str(a[int((i-N/2)*2)]))
		sys.stdout.write(" ")

Submission status: Accepted

Solution code:
n=int(input())
a=input().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:

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


if num%2==0:
    for i in range(num-1,0,-2):
        print(a[i],end=" ")
    for i in range(0,num,2):
        print(a[i],end=" ")
else:
    for i in range(num-1,0,-2):
        print(a[i],end=" ")
    print(a[0],end=" ")
    for i in range(1,num,2):
        print(a[i],end=" ")
    


print("")

Submission status: Accepted

Solution code:
n = int(input())
a = input().split(' ')
b = []
inds = [0] * n

for i in range(int(n/2)):
    inds[i] = n-2*i
    inds[n-1-i] = n-2*i-1
if n % 2 == 1:
    inds[int(n/2)] = n-2*int(n/2)

for i, ind in enumerate(inds):
    print(a[ind-1], end="")
    if i != n-1:
        print(' ', end="")
print('')

Submission status: Accepted

Solution code:
import collections


n = int(input())
sequence = list(map(int, input().split()))
answer = collections.deque()
reverse = False
for i in range(n):
	if reverse is False:
		answer.append(sequence[i])
		reverse = True
	else: 
		answer.appendleft(sequence[i])
		reverse = False
answer = list(answer)
if reverse is True:
	answer.reverse()
print(*answer)

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:
#coding=UTF-8

n=int(input())

mozir=input()
hyo=mozir.split(' ')
#a=[int(mono) for mono in hyo]


idx=n-1
ans=''
#decending
while idx>=0:
    ans=ans+hyo[idx]
    ans=ans+' '
    idx=idx-2

if idx%2==0:
    idx=1
else:
    idx=0

while idx<n:
    ans=ans+hyo[idx]
    if n-idx <= 2:
        pass
    else:
        ans=ans+' '
    idx=idx+2

print(ans)

Submission status: Accepted

Solution code:
_ = input()
a = input().split()
n = len(a)
if n % 2 == 0:
    a1 = list(reversed(a[1::2]))
    a2 = a[::2]
else:
    a1 = list(reversed(a[::2]))
    a2 = a[1::2]
print(" ".join(a1 + a2))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque
def main():
    o=deque()
    e=deque()
    n=int(input())
    s=input().split()
    
    for i in range(0,len(s)):
        j=int(s[i])
        if i%2==0:
            o.append(j)
        else:
            e.append(j)
    if n%2==0:
        print(" ".join([str(k) for k in e][::-1])+" "+" ".join([str(m) for m in o]))
    else:
        print(" ".join([str(k) for k in o][::-1])+" "+" ".join([str(m) for m in e]))
if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    N = int(input().strip())
    b = [None for _ in range(N)]

    index = N // 2
    # 追加場所
    side = -1
    if N % 2 == 0:
        side = 1

    a = map(int, input().strip().split())
    for i, a in enumerate(a):
        index = index + (side * i)
        b[index] = a
        # 追加場所の左右反転
        side *= -1
    print(" ".join(map(str, b)))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

count = 0
o = []
e = []

for x in input().split():
	if count%2 == 0:
		o.append(x)
	else:
		e.append(x)
	count += 1

if n%2 == 0:
	tmp = list(reversed(e)) + o
else:
	tmp = list(reversed(o)) + e

ans = ' '.join(x for x in tmp)

print(ans)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

b = [0]*n

if (n%2) == 0:
    for i in range(n):
        if(i<(n//2)):
            b[i] = a[n-(2*i)-1]
        else:
            b[i] = a[(i-(n//2))*2]
else:
    for i in range(n):
        if(i<(n//2)):
            b[i] = a[n-(2*i)-1]
        elif i == (n//2):
            b[i]= a[0]
        else:
            b[i] = a[(i-(n//2)-1)*2+1]


print(" ".join([i for i in b]))

Submission status: Accepted

Solution code:
n = int(input())
even = 0
if n % 2 == 0:
    even = 1

el = []
ol = []
#n偶数のとき逆順奇数列＋普通の偶数列
s = list(map(int,(input().split())))
for i in range(n):
    if i%2 ==0:#guusuu
        el.append(s[i])
    else:
        ol.append(s[i])
if even == 1:#偶数のとき
    ol.reverse()
    ol.extend(el)
    print(" ".join(map(str,ol)))
else:
    el.reverse()
    el.extend(ol)
    print(" ".join(map(str,el)))

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
b1=[]
b2=[]
for i in range(int((n+1)/2)):
    i*=2
    b1.append(a[i])
    i+=1
    if i!=n:
        b2.append(a[i])

s = ""

if n%2==1:
    b3=b2
    b2=b1
    b1=b3
b2.reverse()

for b_ in b2:
    s+=str(b_)
    s+=" "
for b_ in b1:
    s+=str(b_)
    s+=" "
s=s.rstrip()
print(s)

Submission status: Accepted

Solution code:
n = int(input())
a = input().split(" ")
odds = a[1::2]
evens = a[0::2]
if (n%2)==0:
    odds.reverse()
    ans = odds + evens
    print(' '.join(ans))
else:
    evens.reverse()
    ans = evens + odds
    print(' '.join(ans))

Submission status: Accepted

Solution code:
n = int(input())
a = [int(x) for x in input().split()]
b = []
stack = []
a.reverse()
for i in range(n):
    if i%2 == 0:
        b.append(a[i])
    else:
        stack.append(a[i])
for i in range(len(stack)):
    b.append(stack.pop())

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

Submission status: Accepted

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

flag = [n-2*i if i<n/2 else int((i-n/2)*2+1)  for i in range(n)]
b = [str(a[flag[i]-1]) for i in range(n)]
print(' '.join(b))

Submission status: Accepted

Solution code:
# coding: utf-8

import numpy as np

if __name__=="__main__":
    n = int(input())
    a = input().split()
    if n%2 == 0:
        index = list(range(2, n+1, 2))
        index.reverse()
        index += list(range(1, n+1, 2))
    else:
        index = list(range(1, n+1, 2))
        index.reverse()
        index += list(range(2, n+1, 2))
    index = np.array(index)
    print(" ".join([a[i-1] for i in index]))

Submission status: Accepted

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

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

if n % 2 == 0:
	ans.extend(a_even[::-1])
	ans.extend(a_odd)
else:
	ans.extend(a_odd[::-1])
	ans.extend(a_even)

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

Submission status: Accepted

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

b = []
c = []
for i in range(len(a)):
    if (i+1) % 2 !=  0:
        b.append(a[i])
    else:
        c.append(a[i])
if (i + 1) % 2 != 0:
    d = " ".join(reversed(b)) + " " + " ".join(c)
else:
    d = " ".join(reversed(c)) + " " + " ".join(b)

print(d)

Submission status: Accepted

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


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


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

    ilist = []

    t = n
    while t > 0:
        ilist.append(t)
        t -= 2
    if t == -1:
        t = 2
    else:
        t = 1
    while t < n:
        ilist.append(t)
        t += 2
    
    print(" ".join(str(a[i - 1]) for i in ilist))


main()

Submission status: Accepted

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

result = [0] * n
for i in range(n):
    if n % 2 == 1:
        result[int(n / 2)] = a[0]
        if i % 2 == 1:
            result[int(n / 2) + int((i + 1) / 2)] = a[i]
        else:
            result[int(n / 2) - int((i + 1) / 2)] = a[i]
    else:
        if i % 2 == 1:
            result[int(n / 2) - int((i + 1) / 2)] = a[i]
        else:
            result[int(n / 2) + int((i + 1) / 2)] = a[i]

import sys
for i in range(n):
    sys.stdout.write(str(result[i]) + ' ')

Submission status: Accepted

Solution code:

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

b = []
c = []
for i in range(len(a)):
    if i % 2 == 1:
        b.append(a[i])
    else:
        c.append(a[i])

b.reverse()
b += c

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

for bb in b:
    print(bb , end = ' ')
print()

Submission status: Accepted

Solution code:
from collections import deque
n=int(raw_input())
a=deque(map(int, raw_input().split()))
out=deque([])
if len(a) % 2 == 1:
    out.append(a.popleft())
while len(a) > 0:
    out.append(a.popleft())
    out.appendleft(a.popleft())
print " ".join(map(str, out))

Submission status: Accepted

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

n = input()
a = map(int, raw_input().split())
alen = len(a)
b = [0]*alen
if(alen%2 == 0):
    for i,j in enumerate(range(0,alen,2)):
        b[i] = a[alen-1-j]
    for i,j in enumerate(range(0,alen,2)):
        b[alen/2+i] = a[j]
else:
    for i in range(0,alen/2+1):
        b[i] = a[alen-1-2*i]
    for i in range(0,alen/2):
        b[alen/2+1+i] = a[2*i+1]

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

Submission status: Accepted

Solution code:
n = int(raw_input())
a = map(int, raw_input().split())
if n % 2 == 0:
    bpos = range(n - 1, 0, -2) + range(0, n, 2)
else:
    bpos = range(n - 1, -1, -2) + range(1, n, 2)
for p in bpos:
    print a[p],
print

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(raw_input().rstrip())
a = map(int, raw_input().split())
a_odd = a[0::2]
a_even = a[1::2]
a_even.reverse()
a_even.extend(a_odd)
b = map(str, a_even)
if len(b) % 2 !=0:
    b.reverse()
print ' '.join(b)

Submission status: Accepted

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

if n == 1:
    print(A[0])
    exit()

elif n % 2 == 0:
    l1 = [A[n - 2 * i - 1] for i in range(n//2)]
    l2 = [A[2 * j] for j in range(n//2)]

else:
    l1 = [A[n - 2 * i - 1] for i in range(n//2 + 1)]
    l2 = [A[2 * j + 1] for j in range(n//2)]

print(" ".join(l1), " ".join(l2))

Submission status: Accepted

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

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

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

Submission status: Accepted

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

if n == 1:
    print(A[0])
    exit()

elif n % 2 == 0:
    l1 = [str(A[n - 2 * i - 1]) for i in range(n//2)]
    l2 = [str(A[2 * j]) for j in range(n//2)]

else:
    l1 = [str(A[n - 2 * i - 1]) for i in range(n//2 + 1)]
    l2 = [str(A[2 * j + 1]) for j in range(n//2)]

print(" ".join(l1), " ".join(l2))

Submission status: Accepted

Solution code:

N = int(input())
inp = [int (x) for x in input().split(" ")]

refs = [0 for _ in range(N)]
k = len(inp) - 1
rev = True
for i in range(N):
    refs[i] = k
    if k == 1 and rev:
        k = -2
        rev = False
    if k == 0 and rev:
        k = -1
        rev = False
    k = k - 2 if rev else k + 2

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


for i in range(N):
    refs[i] = inp[refs[i]]

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

Submission status: Accepted

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

l1 = []
l2 = []

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

for i in reversed(l2):
	print i,

for i in l1:
	print i,

Submission status: Accepted

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

else:
	N = int(n // 2)
	for i in range(N + 1):
		print(A[-1 - 2 * i], end = " ")
	for i in range(N - 1):
		print(A[1 + 2 * i], end = " ")
	if n == 1:
		pass
	else:
		print(A[-2])

Submission status: Accepted

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

odd = al[1::2]
even = al[0::2]
odd.reverse()
r = odd + even

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

print(" ".join(r))

Submission status: Accepted

Solution code:
from collections import deque

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

b = deque()

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

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

print(' '.join(b))

Submission status: Accepted

Solution code:
import math


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


f()

Submission status: Accepted

Solution code:


from collections import deque


def main():
    n = int(raw_input())
    xs = (int(x) for x in raw_input().split())

    side = 0
    q = deque()

    for x in xs:
        if side == 0:
            q.append(x)
        else:
            q.appendleft(x)

        side = not side

    while q:
        if side == 0:
            print q.popleft(),
        else:
            print q.pop(),


if __name__ == "__main__":
    main()

Submission status: Accepted

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

if n % 2 == 0:
	b = a[1::2]
	c = a[0::2]
	b.reverse()
	b.extend(c)
else:
	b = a[0::2]
	c = a[1::2]
	b.reverse()
	b.extend(c)

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

Submission status: Accepted

Solution code:
n = input()
src = map(int, raw_input().split())
even = []
odd = []
for i in range(n):
    if i%2 == 0:
        even.append(src[i])
    else:
        odd.append(src[i])
even.reverse()
even.extend(odd)
if n%2 == 0:
    even.reverse()
print ' '.join(map(str, even))

Submission status: Accepted

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

from __future__ import division, print_function
import sys


def main():
    n = int(sys.stdin.readline().strip())
    a = map(int, sys.stdin.readline().strip().split(" "))
    b = [0 for _ in range(n)]
    j = 0
    for i in range(n - 1, -1, -2):
        b[j] = a[i]
        j += 1
    for i in range(0 if n % 2 == 0 else 1, n, 2):
        b[j] = a[i]
        j += 1
    print(" ".join(map(str, b)))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
from collections import deque
from typing import List


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


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

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

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

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

    return ret


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
from collections import deque
from typing import List


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


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

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

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

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

    return ret


if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
input()
input = list(input())
print(*input[::-2], *input[::2]

Submission status: Runtime Error

Solution code:
input = list(input())
print(*input[::-2], *input[::2]

Submission status: Runtime Error

Solution code:
from collections import deque

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

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

Submission status: Runtime Error

Solution code:
from collections import deque

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
!pip install numpy

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = []
'''
b = [str(a[0])]
if (n == 1):
    print(a[0])
    exit()

a = a[1:]

for i in a:
    b.append(str(i))
    b.reverse()
'''

loop = int(n / 2)
loop_rest = n - loop

for i in range(loop):
    tar_index = (n - 1) - 2 * i
    tar = a[tar_index]

    b.append(str(tar))


if (n % 2 == 0):
    tar_index = 0
else:
    tar_index = 1

for i in range(loop_rest):
    b.append(str(a[tar_index]))
    tar_index += 2

print(' '.join(b))

Submission status: Runtime Error

Solution code:
import math
from collections import defaultdict,deque
from itertools import permutations
ml=lambda:map(int,input().split())
ll=lambda:list(map(int,input().split()))
ii=lambda:int(input())
ip=lambda:list(input())
ips=lambda:input().split()

"""========main code==============="""
t=1
#t=ii()
for _ in range(t):
    n=ii()
    a=ll()
    i=n-1;
    while(i):
        print(a[i],end=" ")
        i-=2
    for i in range(n%2,n,2):
        print(a[i],end=" ")

Submission status: Runtime Error

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

mae = []
usiro = []

#0の時に前 1の時に後ろ
Flag = 0

for i in reversed(range(0,N,1)):
    
    if Flag == 0: # 前の時
        mae.append(A[i])
        Flag = 1
    else:
        usiro.insert(0,A[i])
        Flag = 0

moziretu = (mae + usiro)
moziretu = ''.join(moziretu)
print(' '.join(moziretu))

Submission status: Runtime Error

Solution code:
# coding: utf-8
import math
from collections import deque
n = int(input())
#x, y = map(int,input().split())
A = list(map(int,input().split()))
ans = 0
B = deque()
if n%2==0:
    for i in range(n):
        a=str(A[i])
        if i%2==1:
            B.appendleft(a)
        else:
            B.append(a)
if n%2==1:
    for i in range(n):
        if i%2==0:
            B.appendleft(a)
        else:
            B.append(a)
print(' '.join(B))

Submission status: Runtime Error

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

from collections import deque
b = deque([])
for i, a in enumerate(A):
    if i % 2 == 0:
        b.append(a)
    else:
        b.appendleft(a)

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

Submission status: Runtime Error

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

flag = True

for x in a:
    if flag:
        b.append(x)
        flag = False
    else:
        b.appendleft(x)
        flag = True
if flag:
    print(*b)
else:
    print(*b[::-1])

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


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

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

    if n % 2 == 0:
        print(*even[::-1], *odd)
    else:
        print(*odd[::-1], *even)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from collections import deque

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

ANS = deque()
for i in range(N):
  if i % 2 == 0:
    ANS.append(A[i])
  else:
    ANS.appendleft(A[i])
    
if N % 2 == 1:
  ANS = ANS[::-1]
  
print("".join(map(str,ANS)))

Submission status: Runtime Error

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

a_even = list(filter(lambda x: x % 2 == 0, a))
a_odd = list(filter(lambda x: x % 2 != 0, a))

ans = a_even[::-1] + a_odd
if n % 2 != 0:
  ans = ans[::-1]

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

Submission status: Runtime Error

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

a_even = list(filter(lambda x: x % 2 == 0, a))
a_odd = list(filter(lambda x: x % 2 != 0, a))

ans = a_even[::-1] + a_odd
if n % 2 != 0:
  ans = ans[::-1]

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