Can anyone help me understand why ST2 fails?
My solution: https://www.codechef.com/viewsolution/34810881
I stored the sum for each index in an array sum( so sum[0] corresponds to sum of 2^LSB for all the elements in provided array and so on for sum[1]…). Next I did a stable sort to maintain the relative ordering and now my vector of pairs v holds the sums in the decreasing order as first element and the index for that sum as second element. I loop k times and add the corresponding maximum sum bit raised to the power of 2.