I have been trying this problem for two days now, and have not been able to understand the problem with my code. It looks perfect to me and even after about 30 submissions I have not been able to get it correct. Someone please help me find any bug. Thanks :) asked 23 Jun '17, 23:28

I believe the error is in handling numbers larger than 10^18 . I ran your code on a test case, and it failed.
I verified the output by cross checking with various C++ implementations, and they all yield correct output. I am sure that this case is the one agonizing you here. answered 24 Jun '17, 00:19
Thanks vijju123 , the error wasn't in handling large numbers, but silly mistake in
(24 Jun '17, 00:33)
It reminds me when i traumatized 2 days over SPOJ's 'Frequent'. I was getting WA in final cases. And after 2 days, do you know what i got? Instead of declaring tree as
(24 Jun '17, 00:35)
1
That AC after days of frustration, is what we long for. :)
(24 Jun '17, 00:40)
