Binary search, O(n log(n)) TC
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```python3 []
class Solution:

    def countExcellentPairs(self, nums: List[int], k: int) -> int:
        nums = set(nums)
        nums = sorted([sum(1 for x in bin(z) if x == '1') for z in nums])
        n = len(nums)
        ans = 0
        for m in range(n):
            i, j = m, n - 1
            idx = n
            while i <= j:
                md = (i + j) >> 1
                if nums[m] + nums[md] >= k:
                    idx = md
                    j = md - 1
                else:
                    i = md + 1
            ans += 2 * (n - idx) - (1 if idx == m else 0)
        return ans
```
['Python3']