Sum of GCD of Formed Pairs

Solution Code

Time Complexity

O(n log n + n log U)

Space Complexity

O(n)