#K63167. Sorting Books by Page Count
Sorting Books by Page Count
Sorting Books by Page Count
You are given a list of integers where each integer represents the number of pages in a book. Your task is to reorder the list so that all books with an even number of pages appear before all books with an odd number of pages. The relative order among the even numbers should be the same as in the input, and the same applies to the odd numbers.
In other words, if the list is \(a_1, a_2, \dots, a_n\), then all elements \(a_i\) which satisfy \(a_i \equiv 0 \pmod{2}\) should come before those that do not. Use the following latex notation for the condition: \(a_i \equiv 0 \pmod{2}\).
inputFormat
The input is read from standard input as a single line containing space-separated integers. Each integer represents the number of pages in a book. The number of integers will not exceed 10,000. If no integers are provided, the output should be empty.
outputFormat
Output a single line to standard output containing the reordered list of integers separated by a single space.
## sample34 23 55 12 78
34 12 78 23 55