codechef BUY1 GET1 problem

I am very much frustrated now…Please tell me what’s wrong with my code?
Its working fine on my lappy,but codechef is showing error.:frowning:

I compiled your code on gcc 4.4.3 and I got a warning: buy1-get1.c:(.text+0x155): warning: the `gets’ function is dangerous and should not be used.

Maybe this is considered as a wrong answer by the judge. Can you try using scanf_s or something?
Good luck!