First of all, try and improve your debugging skills. You surely can’t ask others to look at your code in a contest, can you? Second of all, most of the codes I saw pasted out are formatted horribly, or are written so close to each other that makes it a pain to even look at them. Third of all, how are we supposed to understand what you are doing in your code and what to debug if you just leave the code there or say “I am getting correct answer on sample input case” and don’t say anything about what the heck you are even doing in the code?
Sorry, I just HATE to see useless posts like those ones. For god’s sake PLEASE just debug on your own. This forum is supposed to be for discussing, not spoonfeeding. Grab some guy’s Accepted code, generate some tests on your own, anything BUT posting an useless post that contributes nothing to the community and sit there waiting to be spoonfed a test.