#K1501. Even Sum Pairs

    ID: 24261 Type: Default 1000ms 256MiB

Even Sum Pairs

Even Sum Pairs

Given a list of integers, your task is to count the number of pairs \( (i, j) \) with \( 0 \le i < j < N \) such that the sum of the two numbers is even.

A pair's sum is even if and only if both numbers are even or both are odd. In other words, if \( even\_count \) is the number of even elements and \( odd\_count \) is the number of odd elements in the list, the total number of valid pairs is given by:

$$\frac{even\_count \times (even\_count - 1)}{2} + \frac{odd\_count \times (odd\_count - 1)}{2}$$

This problem requires reading input from standard input and printing the result to standard output.

inputFormat

The first line contains an integer ( N ), representing the number of elements. The second line contains ( N ) space-separated integers.

outputFormat

Print a single integer - the number of pairs whose sum is even.## sample

4
1 2 3 4
2