There is some I/O overhead in C++ due to the necessity to sync C++ and C streams for functions like cout
and printf
so they will have the same behaviour and is thread-safe. Use ios_base::sync_with_stdio(false)
to improve I/O performance in C++ but note that this could be just a side effect.