Count the number of pairs of (a, b) such that 1 <= a <= b <= n and a × b is a perfect square, with n up to 10^5.