Sorting || C++
Code\n\nclass Solution {\npublic:\n    long long countExcellentPairs(vector<int>& nums, int k) {\n        vector<int>t;\n        sort(nums.begin(),nums.end());\
# Code\n```\nclass Solution {\npublic:\n    long long countExcellentPairs(vector<int>& nums, int k) {\n        vector<int>t;\n        sort(nums.begin(),nums.end());\n        nums.erase(unique(nums.begin(),nums.end()),nums.end());\n        for(int i=0;i<nums.size();i++){\n            int count=0;\n            for(int j=0;j<32;j++){\n                if(nums[i]&(1<<j)) count++;\n            }\n            t.push_back(count);\n        }\n        sort(t.begin(),t.end());\n        long long res=0;\n        for(int i=0;i<t.size();i++){\n            int target=k-t[i];\n            auto r=lower_bound(t.begin(),t.end(),target);\n            long long index=r-t.begin();\n            cout<<t.size()-index<<endl;\n            res+=t.size()-(index);\n        }\n        return res;\n    }\n};\n```
['Binary Search', 'Bit Manipulation', 'Sorting', 'C++']