Count pairs by parity
transcript
You have a hundred thousand payments. Count the pairs with an even total. There are almost five billion pairs. Testing each pair would take far too long.
Even plus even is even. Odd plus odd is even. Even plus odd is odd. So the pair works only when both share a parity. There is no fourth case to check.
Three, five and seven are odd. Eight and two are even. The two groups hold five amounts in all.
Three odd amounts make three pairs. Two even amounts make one pair. The answer is four, and nothing was listed. The mixed pairs, six of them, never count.
A group of k makes k times k minus one, over two. For a hundred thousand items, that exceeds two billion. So hold the count in sixty-four bits. Add the two groups to get the answer.
Never test every pair. Find the property, then count. Full breakdown in the lecture.