Training Site
Sideways banner


Input: Standard Input (stdin)
Output: Standard Output (stdout)
Memory limit: 100 megabytes
Time limit: 1.0 seconds

I/O, Code, and Documentation

  • Your file must contain a class which must be called Main.
  • Your class must contain a method called main.
  • Get input from
  • Print to System.out.
  • You are permitted to view the Java SE 11 API Specification during an NZIC contest.

Get OpenJDK.

Learn how to run a hello world program.


Adding two numbers. Numbers will be space separated on a single line.

import java.util.Scanner;

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


On problems with larger inputs, Scanner may be too slow. In such cases, we recommend using BufferedReader and StringTokenizer instead. For example:

import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(;
        StringTokenizer st = new StringTokenizer(br.readLine());
        System.out.println(Integer.parseInt(st.nextToken()) + Integer.parseInt(st.nextToken()));


Sample Explanation

3 + 4 = 7

  • Sample Input 1

    3 4

    Sample Output 1