Problem:
Score : 400 points

Problem Statement

Given is an integer S.
Find a combination of six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfies all of the following conditions:

0 \leq X_1,Y_1,X_2,Y_2,X_3,Y_3 \leq 10^9

The area of the triangle in a two-dimensional plane whose vertices are (X_1,Y_1),(X_2,Y_2), and (X_3,Y_3) is S/2.

We can prove that there always exist six integers that satisfy the conditions under the constraints of this problem.

Constraints

1 \leq S \leq 10^{18}

All values in input are integers.

Input

Input is given from Standard Input in the following format:

S

Output

Print six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfy the conditions, in this order, with spaces in between.
If multiple solutions exist, any of them will be accepted.

Sample Input 1

3

Sample Output 1

1 0 2 2 0 1

The area of the triangle in a two-dimensional plane whose vertices are (1,0),(2,2), and (0,1) is 3/2.
Printing 3 0 3 1 0 1 or 1 0 0 1 2 2 will also be accepted.

Sample Input 2

100

Sample Output 2

0 0 10 0 0 10

Sample Input 3

311114770564041497

Sample Output 3

314159265 358979323 846264338 327950288 419716939 937510582

Solution in Java8 (OpenJDK 1.8.0) (judge verdict: Wrong Answer)


import java.util.Scanner;

public class Main {
    private static final long MAX = 1000000000;

    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final long s = scanner.nextLong();
        if (s < MAX) {
            System.out.println("0 0  " + s + " 0 0 1");
            return;
        }

        final long x3 = intSqrt(s) + 1;

        final long diff = x3 * x3 - s;
        long x1 = 0;
        long y2 = 0;
        for (int i = intSqrt(diff); i >= 1; i--) {
            if (diff % i == 0) {
                x1 = x3 - diff / i;
                y2 = x3 - i;
            }
        }

        if (x1 < 0 && y2 < 0) {
            System.out.println("0 " + (-1) * y2 + " " + (-1) * x1 + " 0 " + (x3 - x1) + " " + (x3 - y2));
            return;
        } else if (x1 < 0) {
            System.out.println("0 0 " + (-1) * x1 + " " + y2 + " " + (x3 - x1) + " " + x3);
            return;
        } else if (y2 < 0) {
            System.out.println("0 " + (-1) * y2 + " 0 0 " + x3 + " " + (x3 - y2));
            return;
        }

        System.out.println(x1 + " 0 0 " + y2 + " " + x3 + " " + x3);
    }

    private static int intSqrt(long a) {
        return (int) Math.sqrt(a);
    }
}