#C14490. Split List by Even and Odd Indices

    ID: 44145 Type: Default 1000ms 256MiB

Split List by Even and Odd Indices

Split List by Even and Odd Indices

Given a list of integers, your task is to split the list into two sublists: one containing the elements at even indices, and the other containing the elements at odd indices. Indices refer to positions in the input list starting from 0. For example, for the list \( [1, 2, 3, 4, 5, 6] \), the even-index sublist is \( [1, 3, 5] \) and the odd-index sublist is \( [2, 4, 6] \).

You need to read the input from stdin and print the resulting sublists to stdout in two separate lines. The first line should contain the elements at even indices separated by a single space, and the second line should contain the elements at odd indices separated by a single space. If a sublist is empty, simply output an empty line.

inputFormat

The first line of input contains a non-negative integer \( n \) representing the number of elements in the list. The second line contains \( n \) integers separated by spaces.

For example:

6
1 2 3 4 5 6

outputFormat

The output consists of two lines:

  • The first line contains the elements at even indices separated by a space.
  • The second line contains the elements at odd indices separated by a space.

If a sublist is empty, output an empty line for that sublist.

## sample
0

</p>