For CMD users; instead of the second line use
yourexe < yourinput.in > youroutput.out
For Java users, using a terminal, you could
java yourclassfile < input.in > output.out
For those who wish to use things inside a program, you can use freopen in cstdio; ifstream and ofstream in fstream; for Java you could try BufferedReader and BufferedWriter in java.io
If you do so; you’ll have to change things each time you want things on the standard output.
in FB Hacker Cup (same as in Google Code Jam) you just need to upload both - source and output, your code is not executed again… So probably there was a problem in your solution…
if you share your input, someone can run his code and return back what was correct output…