Which C compiler do programming competitions use?

A short guide for competitive programming and olympiads. Try the online compiler →

GCC (GNU Compiler Collection) GCC is the standard C compiler in competitive programming. Most contest judges run it on Linux, so practise with GCC to get the same behaviour as the judge.

Who uses GCC

Contest / judgeC compiler
IOI (International Olympiad in Informatics)GCC
ICPC (International Collegiate Programming Contest)GCC
TOI (Thailand Olympiad in Informatics)GCC
CodeforcesGNU GCC (also offers others)
AtCoderGCC (also offers Clang)

Exact versions change from year to year. Check each contest's rules page for the current version and flags.

A typical compile command

gcc -std=c11 -O2 -Wall main.c -o main -lm
./main < input.txt

Installing GCC

Windows: install MSYS2, then in the MSYS2 UCRT64 terminal run:

pacman -S mingw-w64-ucrt-x86_64-gcc

Ubuntu / Debian Linux:

sudo apt install build-essential

macOS: the built-in gcc command is really Clang. To get real GCC, run brew install gcc and use the versioned command it installs (for example gcc-14).

Starter template

#include <stdio.h>

int main(void) {
    int n;
    long long sum = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        long long x;
        scanf("%lld", &x);
        sum += x;
    }
    printf("%lld\n", sum);
    return 0;
}

Tips