Top-level variables are globals and so not optimized by the compiler and also never released if they do allocate. They are fine for quick scripting or quick prototyping.
Similarly, top level statement are not optimized. So it's more of a performance issue than correctness issue. That said, reading from stdin involves IO which is an order of magnitude slower than the rest of the code anyway.