If I compile file and use it in gdb then it immediately finishes:
$ g++ -g a.cpp -o a $ gdb a < input.txt $