In IntelliJ IDEA , this code runs without any issues, but when I send task for validation, result is: The program ran too long and was closed!