2 Line
Code\n\nclass Solution:\n    def countExcellentPairs(self, nums: List[int], k: int) -> int:\n        nums = sorted(list(set([(nums[i].bit_count(), nums[i]) for 
# Code\n```\nclass Solution:\n    def countExcellentPairs(self, nums: List[int], k: int) -> int:\n        nums = sorted(list(set([(nums[i].bit_count(), nums[i]) for i in range(len(nums))])))\n        return sum(len(nums)-bisect_left(nums, (k-t, -1)) for t, n in nums)\n```
['Python3']