nlogn
\nclass Solution {\npublic:\n    long long countExcellentPairs(vector<int>& nums, int k) {\n        unordered_set<int> s(nums.begin(),nums.end());\n        vect
```\nclass Solution {\npublic:\n    long long countExcellentPairs(vector<int>& nums, int k) {\n        unordered_set<int> s(nums.begin(),nums.end());\n        vector<int> v;\n        for(auto& i: s){\n            int x = __builtin_popcountll(i);\n            v.push_back(x);\n        }\n        sort(v.begin(),v.end());//1 1 2\n        \n        long long ans = 0;\n        for(int i=0;i<v.size();i++){\n            auto it = lower_bound(v.begin(),v.end(),k-v[i]);\n            // all values including the it and after satisfies the condition\n            ans += (v.end()-it);\n        }\n        return ans;\n    }\n};\n```
['C', 'Binary Tree']