Generally, input and output speed isn't an issue. However, some platinum tasks have relatively large input files. The [USACO Instructions Page](http://www.usaco.org/index.php?page=instructions) mentions some ways of speeding up I/O; let's check whether these actually make a difference.
The largest USACO input file I know of is test case 11 of [USACO Platinum - Robotic Cow Herd](http://www.usaco.org/index.php?page=viewproblem2&cpid=674), which is 10.3 megabytes! The answer to this test case is $10^{18}$ (with $N=K=10^5$ and all microcontrollers costing $10^8$).
However, adding `ios_base::sync_with_stdio(0); cin.tie(0);` as the first line of `main()` reduced the runtime to 254 ms. See [this CodeForces blog](https://codeforces.com/blog/entry/5217) and [StackOverflow](https://stackoverflow.com/questions/31162367/significance-of-ios-basesync-with-stdiofalse-cin-tienull) for more information.
- Actually, the former link says that it is supposedly prohibited to use `freopen` to redirect `cin` and `cout` if `ios_base::sync_with_stdio(0); cin.tie(0);` is included, but it works properly as far as I know.
Using `ifstream` and `ofstream` is also about as fast.
<spoiler title="258ms">
```cpp
#include <bits/stdc++.h>
using namespace std;
vector<int> P[100000];
int main() { // 258 ms
ifstream fin("roboherd.in");
ofstream fout("roboherd.out");
int N,K; fin >> N >> K;
for (int i = 0; i < N; ++i) {
int M; fin >> M; P[i].resize(M);
for (int j = 0; j < M; ++j) fin >> P[i][j];
}
if (N == 3) fout << 61;
else fout << 1000000000000000000;
}
```
</spoiler>
Of course, there are faster methods. For example, if we use FastIO from [here](https://github.com/bqi343/USACO/blob/master/Implementations/content/various/FastIO.h) then the runtime is further reduced.
A common alternative to reading input for programming contests is `BufferedReader`, which reads faster from a file than `Scanner`. `BufferedReader` reads line-by-line with the `.readLine()` method, which returns a string. Methods like `Integer.parseInt()` are used to convert strings into primitives, and they can directly convert a line into a number, like in `Integer.parseInt(br.readLine())`.
Reading input is more complicated when multiple, space-separated values are placed in a single line. In order to individually read the values in each line, the programmer usually uses the `.split()` method in `String` or the `.nextToken()` in `StringTokenizer`. Notice that `StringTokenizer` for splitting strings is slightly faster than `.split()`.
Faster methods of reading input exist too - Even faster than `BufferedReader` is a custom-written Fast I/O class that uses `InputStream`. Note that this custom class is similar to the custom-written `FastIO.h` in the C++ section, as both read input through a byte buffer.
The most realistic input method to implement in contest is `BufferedReader` and `StringTokenizer`, as it is relatively fast for the amount of code necessary.
In general, it may be faster to store the answer all in a single `string` (C++) or `StringBuffer` (Java) and outputting it with a single function call. This method avoids the overhead of calling an output method many times, especially if the output is generated in many parts.
When printing many lines in C++, it may be faster to use the newline character `\n` in place of `endl`. Output streams in C++ (such as `cout` and `ofstream`) are buffered, meaning that they don't immediately print their output, but store some of it. At some point, the buffer's contents are written (i.e. "flushed") to the output device, whether it be the standard output stream or a file. Buffering the output helps with efficiency if accessing the output device (like a file) is slow. Because `endl` flushes the output, it may be faster to use `\n` instead and avoid unnecessary flushes.
When printing to the standard output stream in Java, it is faster to use `new PrintWriter(System.out)` than `System.out`. The syntax for `PrintWriter` is equivalent to that of `System.out` so it should be easy to use. The only difference is that one has to call `.flush()` or `.close()` on the `PrintWriter` at the very end of the program in order to write the output.