#K71097. Even Sum Pair Counter
Even Sum Pair Counter
Even Sum Pair Counter
You are given a list of n integers. Your task is to calculate the number of distinct pairs (i, j) (with 1 ≤ i < j ≤ n) such that the sum of the i-th and j-th numbers is even.
Recall that the sum of two integers is even if both integers are even or both are odd.
Formally, if we denote the list as a₁, a₂, …, aₙ, you need to count the number of pairs (i, j) satisfying (1 \le i < j \le n) and (a_i + a_j \equiv 0 \pmod{2}).
inputFormat
The input is given via standard input (stdin).
The first line contains an integer n (the number of elements).
The second line contains n space-separated integers representing the elements of the list.
outputFormat
Output a single integer to standard output (stdout) representing the number of pairs (i, j) such that the sum of the elements at these indices is even.## sample
1
1
0
</p>