EASIEST SOLUTION C++
man lete hai ki ham do number let hain 3 and 4 thik h.....\n3 ko binary me 11 and 4 ko 100 lete hai jab ham iska and karege then 0 aayega and or karege to  7 aa
man lete hai ki ham do number let hain 3 and 4 thik h.....\n3 ko binary me 11 and 4 ko 100 lete hai jab ham iska and karege then 0 aayega and or karege to  7 aayega jisme 3 set bit hai jo ki dono ke set bit ke sum ke barabar hai ....similarly ek or example lete hain \n\nnum1=5(number of set bit=2) num2=6 (number of set bit=2)\nnum1 & num2=4(number of set bit=1)  \nnum1 | num2=7 (number of set bit=3)\n\nav sum of number of set bit in & and | ==number of set bit in num1+number of set bit in number 2\n\n\nto bas yhi tha intution baki code dekh ke smjh lo \n\n# Code\n```\nclass Solution {\npublic:\n    long long countExcellentPairs(vector<int>& nums, int k) {\n        set<int>st;\n        for(auto x:nums)\n        st.insert(x);\n\n        vector<int>res;\n      for(auto x:st){\n            int count=__builtin_popcount(x);\n            res.push_back(count);\n        }\n        long long int ans=0;\n        sort(res.begin(),res.end());\n    int n=res.size();\n        for(int i=0;i<res.size();i++){\n        int index=lower_bound(res.begin(),res.end(),k-res[i])-res.begin();\n        ans+=n-index;\n\n        }\n        return ans;\n    }\n};\n```
['C++']