#K2321. Count Even Sum Pairs
Count Even Sum Pairs
Count Even Sum Pairs
Given an integer \(N\) and an array \(A\) of \(N\) integers, your task is to count the number of valid pairs \((i, j)\) (with \(0 \le i < j < N\)) such that the sum \(A[i] + A[j]\) is even.
A pair is valid if both numbers are even or both numbers are odd. Recall that the number of ways to choose 2 items from \(k\) items is given by the formula: $$ \binom{k}{2} = \frac{k \times (k-1)}{2} $$.
inputFormat
The input is given via standard input (stdin) in the following format:
- The first line contains an integer \(N\) (\(0 \le N \le 10^5\)).
- The second line contains \(N\) space-separated integers representing the array \(A\).
outputFormat
Output a single integer representing the number of pairs \((i, j)\) such that \(A[i] + A[j]\) is even. The answer should be printed to standard output (stdout).
## sample5
1 2 3 4 5
4