Languages

CSES currently supports the following languages:

languageversioncompiler flags
AssemblyNASM 2.13.02
C++g++ 7.4.0-std=c++11 -O2 -Wall
-std=c++17 -O2 -Wall
HaskellGHC 8.6.5-O2 -Wall
JavaJava 11.0.6
Node.jsNode.js 8.10.0
PascalFPC 3.0.4-O2
Python2CPython 2.7.17
PyPy 2.7.13
Python3CPython 3.6.9
PyPy 3.6.9
Rubyruby 2.5.1
Rustrustc 1.37.0
ScalaScala 2.11.12

Note that all languages are not be available in all courses and contests.

The source code size limit is 128 kB for all languages.

Example programs

Here are examples on how to solve the A + B problem in the supported languages.

Assembly

        section .text
        global _start
atoi:   xor rax,rax
        xor rdx,rdx
        lodsb
        cmp al,'-'
        sete bl
        jne .lpv
.lp:    lodsb
.lpv:   sub al,'0'
        jl .end
        imul rdx,10
        add rdx,rax
        jmp .lp
.end:   test bl,bl
        jz .p
        neg rdx
.p      ret
itoa:   std
        mov r9,10
        bt rax,63
        setc bl
        jnc .lp
        neg rax
.lp:    xor rdx,rdx
        div r9
        xchg rax,rdx
        add rax,'0'
        stosb
        xchg rax,rdx
        test rax,rax
        jnz .lp
        test bl,bl
        jz .p
        mov al,'-'
        stosb
.p:     cld
        inc rdi
        ret
_start: xor rax,rax
        xor rdi,rdi
        mov rsi,buff
        mov rdx,100
        syscall
        mov rsi,buff
        lodsb
        mov rsi,buff
        call atoi
        mov rcx,rdx
        call atoi
        add rcx,rdx
        mov rdi,buff+99
        mov rsi,rdi
        std
        mov rax,10
        stosb
        mov rax,rcx
        call itoa
        sub rsi,rdi
        mov rdx,rsi
        mov rsi,rdi
        inc rdx
        mov rax,1
        mov rdi,rax
        syscall
        mov rax,60
        xor rdi,rdi
        syscall
        section .bss
buff:   resb 100

C++

#include <iostream>

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    cout << a+b << "\n";
}

Haskell

main :: IO()
main = do
    line <- getLine
    let [a, b] = map read (words line)
    print (a + b)

Java

import java.util.*;

public class Sum {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int a = input.nextInt();
        int b = input.nextInt();
        System.out.println(a+b);
    }
}

Node.js

var readline = require('readline');

var r = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
    terminal: false
});

r.on('line', function (line) {
    var vals = line.split(" ");
    console.log(parseInt(vals[0])+parseInt(vals[1]));
});

Pascal

var
    a, b: longint;
begin
    readln(a,b);
    writeln(a+b);
end.

Python2

a,b = [int(x) for x in raw_input().split()]
print(a+b)

Python3

a,b = [int(x) for x in input().split()]
print(a+b)

Ruby

a,b = gets.split.map &:to_i
puts a+b

Rust

use std::io::{BufRead, BufReader};

fn main() {
    let mut input = BufReader::new(std::io::stdin());
    let mut line = "".to_string();
    input.read_line(&mut line).unwrap();
    let mut split = line.split_whitespace();
    let a: i32 = split.next().unwrap().parse().unwrap();
    let b: i32 = split.next().unwrap().parse().unwrap();
    println!("{}", a + b);
}

Scala

object Sum {
    def main(args: Array[String]): Unit = {
        val Array(a,b) = readLine.split(" ").map(_.toInt)
        println(a+b)
    }
}