C++
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    long long countExcellentPairs(vector<int>& nums, int k) {\n        set<int> se;\n        vector<int> order;\n        for(int i=0; i<nums.size(); i++){\n            se.insert(nums[i]);\n        }\n        for(auto i:se){\n            int digits = 0;\n            for(int j=0; (1<<j)<=i ;j++){\n                if((1<<j)&i)\n                    digits++;\n            }\n            order.push_back(digits);\n        }\n        sort(order.begin(),order.end());\n        long long ans = 0;\n        int n = order.size();\n        for(int i=0; i<order.size(); i++){\n            int req = k - order[i];\n            int ind = lower_bound(order.begin(),order.end(),req) - order.begin();\n            ans += (n - ind);\n        }\n        return ans;\n    }\n};\n```
['C++']