Maybe due to stdio synchronisation? This can be turned off.
https://en.cppreference.com/w/cpp/io/ios_base/sync_with_stdi...
https://en.cppreference.com/w/cpp/io/ios_base/sync_with_stdi...
"This line makes it run almost twice as fast:
ios::sync_with_stdio(false);"