Today in a popular problem solving site, i submitted a solution for a problem, then looked up a more faster code to find out what is the reason that his/her code is running
You have guessed most of it:
std::ios::sync_with_stdiocin.tie(nullptr) will untie cin from cout. See belowfrom cplusplus.com:
The tied stream is an output stream object which is flushed before each i/o operation in this stream object
I guess this problem takes input from cin and you provide the answer on cout, from this point onward, writing to cout will be faster.