Use this for problems that require round-by-round I/O with the judge.
import sys
for _ in range(500):
cmd = "FORWARD"
print(cmd)
sys.stdout.flush()
view = []
for _ in range(5):
line = sys.stdin.readline().rstrip("\n")
if line == "":
sys.exit(0)
view.append(line)
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
for (int round = 0; round < 500; round++) {
cout << "FORWARD\n";
cout.flush();
vector<string> view(5);
for (int i = 0; i < 5; i++) {
if (!getline(cin >> ws, view[i])) {
return 0;
}
}
}
return 0;
}
If the judge waits forever, your process can hit idle limit.