Except for "compilation error", the reasons for rejection are extremely weak hints from the judges about what they observed. A program rejected for "run-time error" might have encountered the run-time error after printing all the correct output, after printing incorrect output, or before any output was printed. The response is at the discretion of the judges; and may not be consistent. Do not read too much into the reasons for rejection. The judges are not debugging your program.