Binary search
Intuition\nIf you bitwise OR two numbers, you get the sum of the set bits of the numbers - the number of bits in the bitwise AND of those numbers. Since we are 
# Intuition\nIf you bitwise OR two numbers, you get the sum of the set bits of the numbers - the number of bits in the bitwise AND of those numbers. Since we are looking at the bitwise OR + bitwise AND, we get this equals the sum of the set bits of the numbers. So instead of doing complex bit operations, we can convert each number to its number of set bits at the beginning and use addition as our operation.\n\n\n# Complexity\n- Time complexity: O(N log N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(N)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```python3 []\nclass Solution:\n    def countExcellentPairs(self, nums: List[int], k: int) -> int:\n        c = [bin(i).count("1") for i in set(nums)]\n        c.sort()\n        def search(x, arr):\n            low, high = 0, len(arr) - 1\n            while low <= high:\n                mid = (low + high) // 2\n                if arr[mid] < x:\n                    low = mid + 1\n                else:\n                    high = mid - 1\n            return low\n        res = 0\n        for i in c:\n            res += len(c) - search(k - i, c)\n        return res\n```
['Python3']