Weird TLE with endl instead of "\n"

Last night in a contest I wrote this part of a code…
This is the problem

This is my solving function :
void solve(){
ll n;
cin>>n;
ll r= n - floor( sqrtl ( n ));
cout<<r<<endl;
}
And very strangely I was getting TLE…there was nothing else than this function in the code which might result in Time Complexity increase.
When I replaced endl with “\n” then it worked perfectly fine.
Any knowledge is welcome… Thanks

1 Like

This has always the problem in codechef contests due to their tight time limit many a times endl gives TLE

Endl flushes output buffer whereas /n don’t do this. This increases time using endl.