python3 2 pointers sol.
\n\n# Code\n\nclass Solution:\n    def countExcellentPairs(self, nums: List[int], k: int) -> int:\n        nums = set(nums)\n        res = []\n        def count
\n\n# Code\n```\nclass Solution:\n    def countExcellentPairs(self, nums: List[int], k: int) -> int:\n        nums = set(nums)\n        res = []\n        def count(n):\n            count = 0\n            while n:\n                count += n & 1\n                n >>= 1\n            return count\n        for e in nums:\n            res.append(count(e))\n        res.sort()\n        i = 0\n        j = len(res)-1\n        ans = 0\n        while i<=j:\n            if res[i]+res[j] >=k:\n                ans+=2*(j-i)+1\n                j-=1\n            else:\n                i+=1\n        return ans\n```
['Python3']