Yesterday I noticed that you can score a very very good efficiency, as little as 30ms, by exploiting a "bug" in the VM test system.
This is what i think happens:
Since the tests are repeated, you can make the code execute almost instantly in all test rounds after the first by opening the files with mode 'x', exclusive creating mode.
As the files already exist after the first test, the exclusive creating mode will throw an error saying that the file already exists. This will take an extremely small amount of time and so the total execution time will be very small. The result is then all tests passed in ~35ms.
This is obviously not a fair way to solve the homework.
The "fix" is easy: just use the 'w' mode, which will create the files if they don't exist or overwrite them if they exist.
I'm writing this so that, if you find a very small execution time, you know that you are actually (probably without even noticing) exploiting a bug.
Wish everyone good luck with HW4!