C++ SOLUTION
\nclass Solution {\npublic:\n    long long countExcellentPairs(vector<int>& nums, int k) {\n        vector<int> s;\n        unordered_set<int> p;\n        long 
```\nclass Solution {\npublic:\n    long long countExcellentPairs(vector<int>& nums, int k) {\n        vector<int> s;\n        unordered_set<int> p;\n        long long ans = 0ll;\n        for (auto n : nums) {\n            if (p.find(n) == p.end())\n                s.push_back(__builtin_popcount(n));\n            p.insert(n);\n        }\n        sort(s.begin(), s.end());\n        for (auto n : s) {\n            ans += s.size() - (lower_bound(s.begin(), s.end(), k-n) - s.begin());\n        } \n        return ans;\n    }\n};\n```
[]