Generally, you will submit programs that read problem specifications from standard in and write the computed solutions to standard out. You have to always flush your output buffer after every line, otherwise the test system may get stuck and throw a timeout at you. Be sure that your program terminates with error code 0. If your program does not terminate you will get a timeout, even if it answered correctly and in time. Unless stated otherwise, you have 512MB of memory available.

You can submit your solutions either as a file or by pasting copy and paste. You can split your solution into multiple files by packaging them in a .tar.gz archive.

You will find a list of supported programming languages below. Each is illustrated with a small example that solves the Example Challenge to get you started.

Java 8

If you use the file upload your submission is handled as java if it contains at least one file ending in .java. In order to determine the entry point into your application, i.e. the class that is executed, your submission has to satisfy one of the following:

  • It contains only one class containing a public static void main(String[]) method.
  • It containing only one class containing such a method with the name Main.
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    while(sc.hasNext()) {
      System.out.println(sc.nextInt() + 1);
    }
  }
}

There is a known bug where valid solutions get the following compilation error:

javac: file not found: <YourFile>.java
Usage: javac <options> <source files>
use -help for a list of possible options

If you encounter this error please just try to resubmit your solution.

Haskell

Your submission will be identified as Haskell if it contains a file with the extension .hs. All your files will be compiled and linked together and have to produce one executable.

The following packages as well as their recursive dependencies are available:

  • logict
  • lens
  • pipes
  • mwc-random
  • hashtables
  • regex-pcre
  • aeson
  • hashmap

GHC is run with -O2. We use Stack lts-7.3.

You have to set the buffering mode to LineBuffering or NoBuffering or manually flush the output when necessary.

import System.IO

main :: IO ()
main = do
  hSetBuffering stdout LineBuffering
  interact $ (unlines . fmap (show . (1+) . read) . lines)

C11

Your program will be compiled with gcc --std=c11 -O2 -lm and all your .c files will be linked together. Furthermore you have to either flush the output buffer manually when needed with fflush(stdout); or disable buffering altogether with setbuf(stdout, NULL);.

#include <stdio.h>

int main(void) {
  int x;
  setbuf(stdout, NULL);
  while(scanf("%d", &x) != EOF) {
    printf("%d\n", x+1);
  }
}

C++

Your program will be compiled with gcc -O2 -lstdc++ -lm and all your .cc and .C files will be linked together. As with the other languages you have to flush when needed.

#include <iostream>

using namespace std;

int main() {
  for(;;) {
    int x;
    cin >> x;
    if (std::cin.eof()) {
      break;
    }
    cout << x+1 << endl;
  }
}

Python 3

Your program is expected to have a .py extension. Furthermore you must upload either only one .py file or only one main.py file or only one executable .py file. As with the other languages you have to flush your output buffer.

Python is version 3.4.3 and the numpy package is installed as well.

from sys import stdin
for line in stdin:
  print(1 + int(line), flush=True)

Racket

Your program is expected to have a .rkt extension. Furthermore you must upload either only one .rkt file or only one main.rkt file or only one executable .rkt file. As with the other languages you have to flush your output buffer.

#lang racket

(void
 (file-stream-buffer-mode (current-output-port) 'line)
 (let loop ()
   (let ((x (read)))
     (if (eof-object? x)
         (void)
         (begin
           (display (+ 1 x)) 
           (newline)
           (loop))))))