Code works well in external IDE but not in Code chef IDE

Code works well in external IDE but in code chef ide it says wrong answer on submitting .
Please have a look and let me know the correction(s)
Problem
My solution