#C3379. Even Difference Pair Counting
Even Difference Pair Counting
Even Difference Pair Counting
Given a list of n integers, your task is to count the number of pairs (i, j) such that 1 \le i < j \le n and the absolute difference between ai and aj is even.
An important observation is that the absolute difference between two numbers is even if and only if they have the same parity (i.e., both are even or both are odd). Based on this, if there are \(E\) even numbers and \(O\) odd numbers in the list, then the total number of valid pairs is given by:
[ \binom{E}{2} + \binom{O}{2} = \frac{E(E - 1)}{2} + \frac{O(O - 1)}{2} ]
Implement the solution such that it reads from standard input and writes the answer to standard output.
inputFormat
The first line contains an integer n representing the number of elements in the list. The second line contains n space-separated integers denoting the elements of the list.
outputFormat
Output a single integer which is the number of pairs having an even absolute difference.
## sample5
1 2 3 4 5
4