Guide

Visual Studio Code

Installation

Opening the Terminal in VS Code

VS Code has an integrated terminal that allows you to execute command-line operations without leaving the editor.

  1. Ways to open the terminal:
    • Use the keyboard shortcut:
      • Windows/Linux: Ctrl + (backtick)
      • macOS: Cmd + (backtick)
    • From the menu: View > Terminal
    • Use the command palette (Ctrl+Shift+P or Cmd+Shift+P), then type “Terminal: Create New Terminal”
  2. Terminal features:
    • Multiple terminals: Click the + icon to create additional terminals
    • Split terminals: Use the split icon to divide the terminal panel
    • Terminal selection: Use the dropdown to switch between terminals
    • Terminal customization: Configure in Settings (Ctrl+, or Cmd+,)

More Information

In the competition, you cannot install extensions with AI. We have installed most of the necessary extensions for you. If you need more extensions, please ask the organizers to install them for you in the competition.

Compiling and Running Code from the Terminal

Before you start, you need to cd to the directory where your code is located.

cd /path/to/your/code

C

  1. Compile a C program:
    gcc -o program_name source_file.c -Wall -g
    
    • -Wall: Enable all warnings
    • -g: Include debugging information
    • -o program_name: Specify the output file name
    • More details can be found in GCC Options Summary.
  2. Run the compiled program:
    ./program_name
    

C++

  1. Compile a C++ program:
    g++ -o program_name source_file.cpp -Wall -g
    
    • -Wall: Enable all warnings
    • -g: Include debugging information
    • -o program_name: Specify the output file name
    • More details can be found in GCC Options Summary.
  2. Run the compiled program:
    ./program_name
    

Java

  1. Compile a Java program:
    javac FileName.java
    

    This creates a FileName.class file

  2. Run a Java program:
    java FileName
    

    Note: Do not include the .class extension when running

Python

CPython

CPython is the default Python interpreter. We recommend you to use CPython as your first choice if you don’t have any TLE issues.

python script.py

However, if you have some TLE issues, you can try PyPy.

PyPy

PyPy is a faster alternative to CPython. According to the official website, PyPy is about 3 times faster than CPython. However, PyPy may have some compatibility issues with some libraries and you may have some issues if you are using modern Python features.

pypy3 script.py

Useful tools

Miniconda

Miniconda is installed in the competition environment. You can create a new environment and install the packages you need.

conda create --name npc python=3.11
conda activate npc

You can use Jupyter Notebook in the competition environment. See here for more information.

GDB

GDB is installed in the competition environment. You can use it to debug your code.

gdb program_name

See the official documentation for more information. And we strongly recommend you to read through this tutorial to get familiar with GDB.