Help Chef to Guess the number

The problem statement

All the sample cases are correct but the final submission is showing wrong answer

My solution