You're not signed in!

Sign in to save your progress and sync your settings across devices.

Running Code

Authors: Benjamin Qi, Hankai Zhang, Anthony Wang, Nathan Wang, Nathan Chen

Options for running your language of choice.

Please let us know if these installation instructions do not work for you.

Running Code Online

In all of C++, Python, Java.

  • OnlineGDB
    • online compiler with embedded GDB debugger
    • supports files and file I/O
    • can be buggy sometimes
  • CSAcademy
    • pretty nice (unless you get "Estimated Queue Time: ...")
    • "saved locally" will not save your code if you close the tab, press Command-S to save.
  • Ideone
    • okay ... has the bare minimum you need
    • sometimes erases your code when you first create it (so get in the habit of copying your code first)
    • real-time collaboration
    • need to pay to create private repls (so don't use free version for a contest ...)


If you use Ideone during an online contest (such as a Codeforces round), you must ensure that your code is set to be private. You will be punished for cheating if another person finds and copies your code during the contest, even if you never intentionally provide the code to anyone.

Even if you are not doing an online contest, you might want to set your code to be private for other reasons.

You can also share code with pastebin or hastebin.

Using Command Line

Which text editor or IDE should I use?

Depends on your personal preference. Try multiple and see which one you like best.


You can run your C++ programs from the command line and use a text editor of your choice.

Text Editors

Fast, lightweight. Unlimited free evaluation period, though it will repeatedly ask you to purchase a license.
Classic text editor, usually preinstalled on Linux. Also see Neovim, MacVim
From the makers of Github.

Vim is probably the easiest way to print syntax-highlighted code on Mac, see the response to this post.

Sublime Text Notes (Ben)

  • I prefer the Mariana color scheme in place of the default.
    • open command palette (Cmd-Shift-P) -> change color scheme
  • subl symlink
    • Using /usr/local/bin/subl instead of ~/bin/subl worked for me on OS X Mojave.
  • Package - Sublime Linter (GCC)
    • highlights compilation errors and warnings from -Wall
    • can change compilation commands in
  • Package - Fast Olympic Coding (I don't use)
    • test manager can be useful
    • linting is covered by the above
    • stress testing is covered in Debugging
    • can't get debug to work

Further Instructions

See this module for information about installing, compiling, and running C++ from the command line.


First, download the JDK. Then, test that you can use the right commands.

On Windows, open cmd and type the following command into the prompt:


If you get the below result, you may have to add the JDK to your PATH variable.

'java' is not recognized as an internal or external command,
operable program or batch file

Otherwise, you're probably good to go.

Compiling and Running

Running a Java file off of the command-line is relatively simple after the JDK is downloaded.

Consider this code of and assume it is in a file on your computer:

1public class Main {
2 public static void main(String[] args) {
3 System.out.println("Hello World!");
4 }

Use the cd command on your console to get to the directory that contains Then, run the following command to compile the code:


If it runs successfully, a file called Main.class will show up in the same directory, which can be executed with the next command:

java Main

If everything goes accordingly, the console should output Hello World!.

If you do USACO-style file I/O, meaning that files are in the "local directory", then the files must be located in the same directory as the source code (if you use the above method).


Download Python through the official website. On Windows and Mac, you can download executable files directly; on Linux, you must either download the Python source code and compile from source, or obtain Python through your package manager.

Make sure that you are using the correct version of Python. Python 2 is quite different from Python 3 (but parts of the version number beyond 2. or 3. do not matter much). We generally recommend newcomers to use Python 3, but if you are used to programming in Python 2, that is OK too.

The Python version can matter when using the command line to run Python; sometimes, python3 must be used instead of python in order to run Python 3. Try both commands, and pay attention to the version that Python prints to determine if this is the case on your system. For example, running the following in Terminal on my computer produces:

python --version # prints Python 2.7.13
python3 --version # prints Python 3.8.1

Using an IDE

IOIfor reference, software you can use at IOI


These often have C++ support already built-in.

MicrosoftMore lightweight than Visual Studio Community, requires some configuration. See PAPS 2.1 and the docs for C++ setup instructions.
GeanyLightweight, frequently used at IOI.
Code::BlocksWindows & Linux. Apparently was unstable at IOI.
JetbrainsRequires a license, but free for students.

Including <bits/stdc++.h>

You can use #include <bits/stdc++.h> in place of separately including libraries.


This is usable with GCC. However, Mac OS X uses Clang while Windows uses Microsoft Visual C++ (MVSC) by default. <bits/stdc++.h> is not a standard header file, so it will not work with the latter two. This is one of the reasons why you should not use <bits/stdc++.h> outside of competitive programming.

If you installed GCC as described in Further Instructions, then you should be good to go.

Using Without Installing GCC

If you installed Clang on Mac, then you can download stdc++.h from here and move it into a folder named bits that is located in the same directory as where all other C++ header files are located. However, this is not recommended.

SOsolutions that may or may not work


It can be useful to use a Java IDE to take advantage of the powerful debugging features in Java.



Python comes with a program, known as IDLE (Integrated Development and Learning Environment), that allows one to write and run Python code. It supports many features, such as syntax highlighting and automatic indentation, that one would normally expect from an IDE/text editor. However, feel free to use another editor or IDE if you want to.

Module Progress:

Give Us Feedback on Running Code!