I’m getting WA in the maximum subset problem on Spoj

Can anyone help me in finding the bug?

Here’s my code-Ideone

when you are calculating result take only those elements which increases the result instead of xoring all the elements.

The Spoj link opens to problem XMAS . Recheck the link .

the two problems have same problem code! Just google “Xor Maximization Spoj”.You’ll get the problem statement