I do not want to put a limit on how much code you submit, but your program definitely does not need to be hundreds of lines long. Excluding comments, 50 lines of total code is more than enough. Probably it is enough even with comments.
It would be nice for you to think about trying to make your code quick, but you do not have to analyze the performance of your code. On the other hand, if I know that for my test cases, a fairly inefficient version of the program takes 5 seconds to run, I will not run your code for more than 30 seconds. (The efficient version might run in .1 seconds or faster.) If it is taking so much longer, there is a problem, perhaps in infinite loop, or your code is written so poorly that it just takes too long.
On a similar note, if your code is such a memory hog that my machine runs out of memory while testing your code, your code is wrong. The input values can go from as low as 1 to as high as 999999. Your code should be able to handle any such pair of numbers.
I am told that on Windows machines, the EOF character is Control-Z. (I usually use UNIX.) No matter what it is, my testing program will properly send a recognizable EOF to your program, which you should use to recognize that the input is finished.