#K93072. Count Unique Even Sum Pairs
Count Unique Even Sum Pairs
Count Unique Even Sum Pairs
You are given several test cases. In each test case, you are provided an integer N and a list of N integers. Your task is to count the number of unique pairs \((a, b)\) within the list such that the sum \(a+b\) is even.
The idea is based on the parity of numbers. Recall that the sum of two numbers is even in two scenarios:
- Both numbers are even.
- Both numbers are odd.
For an integer \(n\), the number of ways to choose 2 items from \(n\) is given by: \[ \binom{n}{2} = \frac{n(n-1)}{2} \]
Thus, if there are (E) even numbers and (O) odd numbers in the list, the number of valid pairs is: [ \frac{E(E-1)}{2} + \frac{O(O-1)}{2} ]
Write a program that reads input from standard input (stdin) and outputs the result on standard output (stdout). Ensure that your solution works for all provided test cases.
inputFormat
The first line of input contains an integer \(T\) representing the number of test cases. Each test case is described in two lines:
- The first line contains an integer \(N\), the number of integers in the array.
- The second line contains \(N\) space-separated integers.
The input is provided from the standard input (stdin).
outputFormat
For each test case, output a single integer on a new line representing the count of unique pairs \((a, b)\) whose sum is even.
The output should be written to standard output (stdout).
## sample3
4
1 2 3 4
5
1 3 5 7 9
6
2 4 6 8 10 12
2
10
15
</p>