The numbers involved are small, which makes this quite trivial. The numbers are ≤ $10^5$. We have $10^5 < 47^3$, and there are 14 primes < 47.
So for each of the numbers x, y in X, Y, we calculate a 14 bit integer with bit #i set if x, y is divisible by an odd power of the i-th prime, and we also calculate x', y' which are x, y divided by the fourteen primes < 47. The product of x, y is a square if and only if x, y produced the same bit vector, and x'y' is a square.
We split X, Y with x, y replaced by x', y' into up to 16,384 arrays where all the elements have the same bit vector. Let X', Y' be two such subarrays where all original numbers had the same bit vector, and all the numbers have been divided by the primes < 47.
We first handle squares: If x', y' are both squares then the product is a square. If only one of them is a square then the product is not a square. Let X' contain n squares and Y' contain m squares, then we have nm square products, and remove the squares from X', Y'.
Now the elements of X' are all less than $10^5$, all have no prime factors < 47, and none are squares. The smallest number with three prime factors ≥ 47 is $47^3 < 10^5$, therefore each x', y' is either prime or the product of two primes. The product of two such numbers is a square if and only if they are the same, that is x' = y'. We therefore easily find the squares after sorting each array. We need to be a bit careful because each array can contain the same number twice.
All in all, this takes O (n log n) steps, where n is the size of the larger array. If the numbers were less than $10^{15}$ then we'd want to divide them by all primes < 100,000 which would still be O (n log n) but with a much larger constant.