LENT MONEY DEBUG HELP

Please help me to debug this python code for LENT MONEY :
https://www.codechef.com/viewsolution/24815620

I have used a tuple to separate the numbers having gained from those having loss

Can I also remove TLE using the same approach of tuple

You can watch this https://www.youtube.com/watch?v=yMuaIjKlTfg video to understand my approach.

We create a new array, where we store the effect we have on a number when we xor it with ‘x’ :slight_smile: (b[i]= a[i]-a[i]^x) . Xor any number with ‘x’ 2 times/even number of times and you get the same result :slight_smile: …a[i]^x^x…(even number of times)=a[i].
if k is odd, answer is the sum of all positive numbers;
if k is even and there are even number of positive numbers in the array; answer is same as above.
if k is even,and number of positive numbers is odd, then answer is max(positive sum-smallest positive number,positive_sum+smallest negative number ). Hope this helps :slight_smile:

Thanks @anon55659401 @cenation092