HELP ... debug the code

why I am getting wrong answer after submitting my code which corner case is missing .
All the sample outputs matched.

my solution which is needed to be debuged

This was mentioned in the problem.

Also after the operation, none of the seller’s bucket should be empty.

So, the following statement

int op1=grape%k;

should be modified to

int op1 = (grape <= k ? (k - grape) : (grape % k));

Also, after making the above change, you’re likely to get WA and TLE.

  1. Wrong Answer because the constraints are very high and long long int should be used
  2. TLE because of the following snippets.
int another(int grape,int k)   // functions for another way of operation count
    int count=0;
    return count;

int op2=another(grape,k);

The whole function, ‘another’, can be replaced with the following function.

int another(int grape, int k) {
    return (k - grape % k;)

Try doing the above modifications, I believe this will work.