First submission with Cin/Cout w/o Sync: 185094688, 3915 ms
Second one with Scanf/Printf: 185094426, 1357 ms
Shouldn't that be exactly the opposite ?
Because almost everywhere its mentioned that Cin/Cout w/o Sync should be faster, or at least same speed as Scanf/Printf.
Why is it so ?
cin.tie() doesn't do anything useful in your code(it returns a pointer to cout).
cin.tie(0) gives a massive speed increase as it means reading from cin doesn't flush cout.
.
cin.tie() doesn't do anything useful in your code(it returns a pointer to cout).
Sorry, but why is that ?
cin.tie() unties Cin and Cout. But I agree that cout.tie() is useless there.
Without arguments it doesn't change anything (it returns a pointer to the currently tied output stream). You need to pass nullptr/0 to untie the streams.
https://cplusplus.com/reference/ios/ios/tie/
Got it, thanks mate!!