[Python] 5 lines with explanations
Important logic: number_set_bit(X&Y)+number_set_bit(X|Y) = number_set_bit(X) + number_set_bit(Y)\n\nFor example:\nX = 010101\nY = 010011\nnumber_set_bit(X&Y) = 
Important logic: **number_set_bit(X&Y)+number_set_bit(X|Y) = number_set_bit(X) + number_set_bit(Y)**\n\nFor example:\nX = 010101\nY = 010011\nnumber_set_bit(X&Y) = number_set_bit(010001) = 2\nnumber_set_bit(X&Y) = number_set_bit(010111) = 4\nnumber_set_bit(X) = 3\nnumber_set_bit(Y) = 3\n\nThe reason is **and** will count "both 1 in same loc" once.\n**or** will count number of **and** plus "each single 1" once.\n\n\n```\n        x = sorted([bin(v).count("1") for v in set(nums)])\n\t\t\n        res = 0\n        for v in x:\n            res += len(x) - bisect.bisect_left(x, k-v)\n        \n        return res\n```
['Binary Tree', 'Python']