C++
\nclass Solution {\npublic:\n    long long countExcellentPairs(vector<int>& nums, int k) {\n        unordered_set<int>Set ;\n        for(auto& x : nums){\n     
```\nclass Solution {\npublic:\n    long long countExcellentPairs(vector<int>& nums, int k) {\n        unordered_set<int>Set ;\n        for(auto& x : nums){\n            Set.insert(x) ;\n        }\n        vector<int>data ;\n        for(auto x : Set){\n            data.push_back(__builtin_popcount(x)) ;\n        }\n        sort(data.begin(), data.end()) ;\n        int n = data.size() ;\n        long long ret = 0 ;\n        for(int i = 0; i < n; i++){\n            if(data[i]*2 >= k)\n                ret++ ;\n            auto it = lower_bound(data.begin()+i+1, data.end(), k-data[i]) ;\n            int j = it - data.begin() ;\n            ret += (n-j)*2 ;\n        }\n        return ret ;\n    }\n};\n```\n
[]