Why is reading lines from stdin in C++ slower than in Python?
Hello everyone! I'm a beginner C++ developer and I've encountered a strange problem. I was solving a problem on Codeforces where I needed to read 10 million integers from standard input. I wrote code in C++ using std::cin and std::getline, but the program ran painfully slow — about 30 seconds. I decided to test it by writing a similar script in Python with regular input() and sys.stdin.read().split(), and it executed in just 3-4 seconds! How is this possible? After all, C++ is considered a more performant language.
Here's my C++ code:
```cpp
#include
#include
#include
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
std::vector numbers;
std::string line;
while (std::getline(std::cin, line)) {