Distribute Candies

I can’t submit my code because it says ‘wrong answer’.I have myself tried many test cases and my code didn’t give wrong answer for even one of them.I would like to know that whether there really is any problem with my code.Please let me know as soon as possible…You can view my code here

//