### kk_ducviet's blog

By kk_ducviet, 7 years ago,

Most coders read input from file and write out to another, but some online judge likes CodeForces use stdin. When solving problems in a contest, eveyone always want to minimum submission time, these little code may help:

C/C++

#ifndef ONLINE_JUDGE
freopen(fi, "r", stdin);
freopen(fo, "w", stdout);
#else
// online submission
#endif


Pascal

{$IFDEF ONLINE_JUDGE} {online submission} {$ELSE}
{\$ENDIF}


Why? Because on the online judge, ONLINE_JUDGE is defined to be true in C/C++

Notice that it also works on UVa, some others too but I didn't test it :)