#ifndef ONLINE_JUDGE ?

This is a general practice by c++ programmers who code in a text editor rather than an IDE. By default the ONLINE_JUDGE constant is defined when submitting code in most online judges like Codechef and Codeforces. Thus it provides a way for the code to determine whether the code is being run in an online judge or a local machine, where the constant is not defined in the latter. Generally this flag is used in order for the code to read & write from a file rather than stdin when run on a local machine and read & write from stdin and stdout respectively when run in an online judge. Thus it eliminates the need to edit the code, for reading from a file, and again for reading from stdin.

Refer to this video for more details : Setting up Sublime Text for Competitive Coding - YouTube

19 Likes