Contents

Running Your Code

First of all note: you can write in any language you want. You can even cheat by solving some tasks manually (though you are here to study, not to cheat).

So you have several options to run your solutions:

  1. Solutions in general languages, like C/C++, Java, C# and Python 2 could be executed by clicking the buttons below the code input area - they are sent to a server and Test data are passed as standard input. We then just check the standard output is returned to answer field on the form. (See "Executed on remote server" below)

  2. Small solutions in any languages could be executed by online compilers like IdeOne or CodePad - links to them are provided below the submission form.

  3. At last you can execute your solutions with your favorite compiler or interpreter on your computer. You'll need to take care of downloading and installing necessary software, of course. You will also need to copy input and answer to your program and back. However, this way allows the best comfort when solutions are large enough and may require significant debugging efforts. It is the most recommended approach.

Here are more thorough explanations on different languages, and code samples for them:

Executed on remote server

After you click one of their buttons, your solution and input data are sent to remote server for checking. You will see the Please wait message in the answer box. In a several seconds the output will be returned from server and will appear in the answer box.

If your code fails to compile, the error message will be printed instead of your output.

Note: long-running programs should not be executed this way. If response from server is not received in a few seconds, you will see the error message.

Python 2

The same notes as for C++ - your solution should process standard input and write to standard output. Here is the example of solution for the Sum A+B task:

a, b = raw_input().split()
print int(a) + int(b)

Python 3

Third version of Python have some significant differences in syntax and some API functions - however, not too much:

a, b = input().split()
print(int(a) + int(b))

C/C++

Input data are provided on a standard input, so they could be read with cin or scanf. Output should be written to standarad output with cout or printf etc. Here is a sample solution for the first task:

#include <stdio.h>

int main(void) {
    int a, b;
    scanf("%d %d", &a, &b);
    printf("%d\n", a + b);
    return 0;
}

Java

Input data are provided on a standard input and could be read from System.in with help of Scanner or BufferedReader. Answer is taken from standard output where you can write with System.out.println(...) etc.

Important: your class should be public class Solution, otherwise it will not compile or will not be run.

Here is a sample solution for the first task:

import java.util.*;

public class Solution {

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

}

Scala

Important thing to note is that your code should be in the object called Solution so the file on server is properly named and compiled.

object Solution extends App {
    val res = scala.io.StdIn.readLine.split(" ").map(_.toInt).sum
    System.out.println(res)
}

C#

The same notes as for C++ - read from standard input, write to standard output. Here is an example (taken from acm.timus.ru):

using System;

public class Sum
{
    private static void Main()
    {
        string[] tokens = Console.ReadLine().Split(' ');
        Console.WriteLine(int.Parse(tokens[0]) + int.Parse(tokens[1]));
    }
}

Executed inside your browser

This approach does not require exchange with remote server, so you will get result at once. Also you are not limited on execution time (though your browser will "hang" until your code is running).

JavaScript

If you code solution in JavaScript, you can run it in-browser. Just click Run JavaScript button.

You can use two non-standard functions:

For example, to solve the first task Sum of Two you can use the following code:

var s = input().split(' ');
output(parseInt(s[0]) + parseInt(s[1]));