Set || C++
\ttypedef long long ll;\n\tclass Solution {\n\tpublic:\n\t\tint countBit(int num){\n\t\t\tint res = 0;\n\t\t\twhile(num){\n\t\t\t\tnum &= (num - 1);\n\t\t\t\tre
\ttypedef long long ll;\n\tclass Solution {\n\tpublic:\n\t\tint countBit(int num){\n\t\t\tint res = 0;\n\t\t\twhile(num){\n\t\t\t\tnum &= (num - 1);\n\t\t\t\tres++;\n\t\t\t}\n\t\t\treturn res;\n\t\t}\n\n\t\tlong long countExcellentPairs(vector<int>& nums, int k) {\n\t\t\tll res = 0;\n\t\t\tunordered_set<int>s;\n\t\t\tvector<int>val;\n\t\t\tfor(auto x:nums){\n\t\t\t\tif(s.count(x)) continue;\n\t\t\t\tval.push_back(countBit(x));\n\t\t\t\ts.insert(x);\n\t\t\t}\n\t\t\tsort(begin(val),end(val));\n\t\t\tfor(auto x:val){\n\t\t\t\tauto it = end(val) - lower_bound(begin(val),end(val),k-x);\n\t\t\t\tres+= it;\n\t\t\t}\n\n\t\t\treturn res;\n\t\t}\n\t};
[]