TIME O(max(nlogn,n*60)) || C++ || EASY TO UNDERSTAND
\nclass Solution {\npublic:\n    long long countExcellentPairs(vector<int>& nums, int k) {\n        vector<int> v(61,0);\n        long long int ans = 0,y=0,n=nu
````\nclass Solution {\npublic:\n    long long countExcellentPairs(vector<int>& nums, int k) {\n        vector<int> v(61,0);\n        long long int ans = 0,y=0,n=nums.size();\n        sort(nums.begin(),nums.end());\n        for(int i = 0; i < n; i++){\n            while(i<n-1&&nums[i]==nums[i+1])i++;\n            int x = 0,a = nums[i];\n            while(a){\n                x += (a&1);\n                a >>= 1;\n            }\n            if(x*2>=k){\n                y++;\n            }\n            for(int i = max(k-x,0); i<= 60; i++){\n                ans += v[i];\n            }\n            v[x]++;\n        }\n        return ans*2+y;\n    }\n};\n````
['Dynamic Programming', 'C', 'C++']