I’m trying to solve a problem on AtCoder using Dart, but I’m encountering a Runtime Error (RE) when submitting my code. My program reads three integers from the input and prints “Yes” if their sum is even, otherwise it prints “No”.
Here is my code:
import 'dart:io';
void main() {
int num1 = int.parse(stdin.readLineSync()!);
int num2 = int.parse(stdin.readLineSync()!);
int num3 = int.parse(stdin.readLineSync()!);
if ((num1 + num2 + num3) % 2 == 0) {
print("Yes");
} else {
print("No");
}
}
The code runs fine on my local machine, but it results in a Runtime Error on AtCoder. I suspect it might have something to do with how input is handled in the AtCoder environment.
Questions:
- Why does my code result in a Runtime Error on AtCoder?
- How can I modify my code to properly handle the input and avoid this error?
I’m relatively new to Dart and would appreciate any help or suggestions.
Thanks in advance!
What I Tried:
Using stdin.readLineSync() to read the input.
Running the program with different inputs to ensure it works as expected.
Expected Outcome:
I expected the program to read the three integers from the input, compute their sum, and print “Yes” if the sum is even or “No” if it is odd.
Actual Result:
The program runs without errors on my local machine, but it results in a Runtime Error on AtCoder.
1