This snippet is made to "increase productivity", but at the expense of cost. I will explain:
std::ios::sync_with_stdio(false);
This disables the synchronization of standard C and C ++ streams. By default, they are synchronized to allow mixing of C and C ++ input-output streams (for example, cout and printf will work in a C ++ file).
cin.tie(NULL);
This unties the cin from cout. Again, by default they are tied so that cout is displayed before cin (i.e., resetting the output before input), so you can do, for example, the following:
cout << "Number: "; cin >> number;
When you untie them, you can enter the input (cin) before outputting the stream (cout).
These line lines help make the code faster, but at the cost of the cost explained earlier. Therefore use with caution.
Links: https://www.geeksforgeeks.org/fast-io-for-competitive-programming
source share