Link to my solution: Solution: 64701415 | CodeChef

Note that the total number of all possible ordered pairs is \binom{N}{2}. This number is larger than **INT_MAX** when N = 10^5.

Just change the data type of **count** to **long long**.

A possible test case is

100000

1 1 1 1 1 …

1 1 1 1 1 …

1 Like