With Brute Force approach, it is giving TLE, but with this it not working. Please tell why

It is not giving correct output?
This is from Codechef May Long Challenge.
With Brute Force approach, it is giving TLE, but with this it not working. Please tell why

@cbcao263,
Have you read the Rules and regulation?

I can report you for posting this doubt on a public platform, resulting in you losing your account. This platform is not for cheating.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.