Debugging on Codechef

How can debug my code on CodeChef
this is my code :
using namespace std;

int main()
int a,b;
scanf("%d %d",&a,&b);
int sub=a-b;
int lastDigit=sub%10;
if(lastDigit==0) sub++;
else sub-=lastDigit;
return 0;

Debugging skills develop over time and with practice
This is how i debug my code

  • think of corner cases
  • print debug statements
  • generate test cases
  • compare output of random test cases with brute force approach
  • clean the code, give logical names to variables (something which most people dont do in CP)
  • explain the logic to someone or yourself again

Coming to your code, it fails condition that the answer should have leading zeroes in some special test cases
can you guess that test case??
think and if in case you are unable to do it then look the link below
i have added two lines to correct ur soln
however it can be optimized further as