Solving the 1574C problem ended with TIME_LIMIT_EXCEEDED. Comparing my code with the Solution I found only 2 significant differencies: ios_base::sync_with_stdio(false); cin.tie(NULL);
Just compare 130080268 with 130164765.
Adding this lines to my code I had Accepted solution. So I am surprised that C++ I/O operations without optimizations is so computationally intensive. Is there any other tips to improve the code? May be standard C I/O should be used?