Idleness limit exceeded codeforces719

According to you endl or fflush(stdout) both work but the Wrong Submission that i have provided above in the post contradict your assumption.
The solution that was provided @akshitm16 is that fflush(stdout) doesn’t work with Fast i/o and your solution only worked b/c of endl b/c fflush(stdout) doesn’t work .
I have made slight changes in your code to prove you this.
Submission link->Submission #115403078 - Codeforces
I had only remove endl before the fflush statement.
Although I have no understanding why is this happening but in above code if you remove Fast i/o it will work.