faster than 87% of the python solutions
Intuition\n Describe your first thoughts on how to solve this problem. \nno of setbits in (a&b) + no of setbits in (a|b) = no of setbits in a + no of setbits in
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nno of setbits in (a&b) + no of setbits in (a|b) = no of setbits in a + no of setbits in b. \n# Approach\n<!-- Describe your approach to solving the problem. -->\nProblem statement asks for distinct pairs, so remove all duplicates from nums. \n    (a,b) and (b,a) are considered distinct pairs. So use a double for loop. and count the combinations which have set bits > k.\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n    O(n) \n    O(n) to create a set, \n    and O(n * 32) to count bits. [Incorrect use of notation]\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n    O(n) to create a set\n    constant space to calculate answer\n \n\n# Code\n```\nfrom collections import Counter, defaultdict\nclass Solution:\n    def countExcellentPairs(self, nums: List[int], k: int) -> int:\n\n        c1 = [0] * 32\n\n        for i in set(nums):\n            c1[i.bit_count()] += 1\n\n        return sum([\n            (k1 + k2 >= k) * v1 * v2 for k1,v1 in enumerate(c1) for k2, v2 in enumerate(c1)\n        ])\n\n        # for k1,v1 in enumerate(c1):\n        #     for k2,v2 in enumerate(c1):\n        #         if k1 + k2 >= k:\n        #             ans += v1 * v2 \n        # return ans \n```
['Python3']