Available

FAQ

Environment for the programming languages [link]

Language Version Time limit
(in seconds)
Memory limit
(in MB)
File Extension Notes
C gcc 4.8.1, C99 Mode 2 512 .c Math library included (-lm)
C++ g++ 4.8.1, C++0x Mode 2 512 .cc, .cpp Math library included (-lm)
C# Mono 2.10.8.1, C# 4 5 512 .cs Name your class Solution
Python Python 2.7.5 16 512 .py
Java Sun Java 1.7.0_21 5 512 .java Name your class Solution
PHP PHP 5.5.3 16 512 .php
Perl Perl 5.14.2 16 512 .pl
Ruby Ruby 1.9.3p194 16 512 .rb
Haskell GHC 7.6.3 5 512 .hs
Clojure clojure 1.4.0 10 512 .clj Name your namespace solution with :gen-class attribute we have removed the restriction of defining a namespace.
Scala scala 2.10.3 10 512 .scala Have your entry point inside an object named Solution
Go go 1.1.2 6 1024 .go
Javascript node v0.10.21 16 512 .js
Erlang Erlang R16B01 16 512 .erl

These run on quad core Xeon machines running 32-bit Ubuntu. You should, however, write your programs in a portable manner and not assume that it will always be run on a 32 bit architecture.

Scoring System [link]

Your score depends primarily on the number of test cases your code passes.

What are test cases? [link]

Our platform runs your code against a certain number of testcases everytime you submit code. A test case consists of input data that is fed into your program, and the output expected from your program for that particular input. So, a test case succeeding means that your program produced correct output for that particular input, while a failure means it didn't produce the expected output (either wrong output or it took too long and was killed). A 'large' test case means a test case with a large input.

Time Limit Exceeded? [link]

We look for optimal algorithms in your solutions. Every problem has been set a timelimit with respect to its optimal solution. If your code could not produce the required output within the set time limit, you get a 'Time Limit Exceeded' error. For example, if you get a Time Limit Exceeded message and 5/10 testcases have passed, your code was unable to handle the 6th test case within the stipulated time. Test cases get progressively larger, so it is not uncommon for a naive solution to pass the first few (smaller) test cases and then falter when confronted with the bigger ones.

Wrong Answer? [link]

Your logic is wrong, or you have formatting issues. Make sure that the output format is exactly the same as specified in the problem statement. Check for extra/missing whitespaces/newlines. If a few test cases have passed, that probably means some of the later test cases have edge cases that your code is not handling. Think about every possible edge case within the problem specifications (you will never be given invalid input), and handle them.

If you're using Java/Clojure/Scala, please ensure that you follow the appropriate class/package naming guidelines. These are essential to get your code to run.

STDIN and STDOUT [link]

In most problems, you would read input from STDIN (Standard Input) and write output to STDOUT (Standard Output). Different languages have different methods of accessing STDIN and STDOUT. Please refer the sample codes below for the most common (possibly naive) methods.

Sample Problem Statement

Given an integer N, print 'hello world' N times.

Sample Input

5

Sample Output

hello world
hello world
hello world
hello world
hello world

Solution

C

#include <stdio.h>
int main() {
    int i, n;
    scanf("%d", &n);
    for (i=0; i<n; i++) {
        printf("hello world\n");
    }
    return 0;
}

C++

#include <iostream>
using namespace std;
int main() {
    int i, n;
    cin >> n;
    for (i=0; i<n; i++) {
        cout << "hello world\n";
    }
    return 0;
}

C#

using System;
namespace Solution {
    class Solution {
        static void Main(string[] args) {
            var line1 = System.Console.ReadLine().Trim();
            var N = Int32.Parse(line1);
            for (var i = 0; i < N; i++) {
                System.Console.WriteLine("hello world");
            }
        }
    }
}

Java

import java.io.*;
public class Solution {
    public static void main(String args[] ) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        int N = Integer.parseInt(line);
        for (int i = 0; i < N; i++) {
            System.out.println("hello world");
        }
    }
}

Python

N = int(raw_input())
for i in xrange(N):
    print "hello world"

Ruby

N = gets
1.step(N.to_i, 1) { |i| print "hello world\n" }

PHP

<?php
fscanf(STDIN, "%d\n", $number);

for ( $i = 0; $i < $number; $i++) {
    echo "hello world\n";
}

Javascript


process.stdin.resume();
process.stdin.setEncoding("ascii");
var input = "";
process.stdin.on("data", function (chunk) {
    input += chunk;
});
process.stdin.on("end", function () {
    for ( i = 0; i<input; i++) {
        console.log('hello world');
    }
});

Perl

$n = <>;
for ($i=0;$i<$n;$i++) {
    print "hello world\n";
}

Erlang

-module(solution).
-export([main/0]).

main() ->
    {ok, [X]} = io:fread("", "~d"),
    hello(X).

hello(N) when N =< 0 -> ok;
hello(N) ->
   io:fwrite("Hello World~n"),
   hello(N - 1).

Does the last line in the input test case end with a newline? [link]

Nope. No trailing spaces or newlines.