SPOJ:IITKWPCA

I am getting wrong answer on this problem :http://www.spoj.com/problems/IITKWPCA/
My code:https://ideone.com/obxWqb
its working fine on my machine.Any tricky case ?

//