Python input and output

I’m in France and am used to using France-IOI, on their website, in python, you can just use input() and print() (or any other methods) directly. However, this didn’t work on USACO, and I had to use a slightly weird method using with to be able to read and write into the input and output files. Are there any simple methods to do so that work on USACO?

USACO only recently switched to stdin and stdout, but for older problems (ones that have an input file name) you need to read and output to the given files stated in the problem.

Ok thanks, I guess I’ll stick to the method I found online for now.

You can use

import sys
sys.stdin = open("", "r")
sys.stdout = open("file.out", "w")

Change “file” to the given name.
Then you can use input() and print() without error.

That’s the same here for AIO (Australian Informatics Olympiad).