Count the Number of Fair Pairs
Sort the numbers and count pairs with sum at most upper, subtract those with sum at most lower minus one, using two pointers.
Sort the numbers and count pairs with sum at most upper, subtract those with sum at most lower minus one, using two pointers.