Problem:
Score: 100 points

Problem Statement

M-kun is a competitor in AtCoder, whose highest rating is X.

In this site, a competitor is given a kyu (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given:

From 400 through 599: 8-kyu

From 600 through 799: 7-kyu

From 800 through 999: 6-kyu

From 1000 through 1199: 5-kyu

From 1200 through 1399: 4-kyu

From 1400 through 1599: 3-kyu

From 1600 through 1799: 2-kyu

From 1800 through 1999: 1-kyu

What kyu does M-kun have?

Constraints

400 \leq X \leq 1999

X is an integer.

Input

Input is given from Standard Input in the following format:

X

Output

Print the kyu M-kun has, as an integer.
For example, if he has 8-kyu, print 8.

Sample Input 1

725

Sample Output 1

7

M-kun's highest rating is 725, which corresponds to 7-kyu.

Thus, 7 is the correct output.

Sample Input 2

1600

Sample Output 2

2

M-kun's highest rating is 1600, which corresponds to 2-kyu.

Thus, 2 is the correct output.

Solution in Java (OpenJDK 11.0.6) (judge verdict: Runtime Error)

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long cash = 1000;
        long stocks = 0;

        int[] future = new int[n];
        for (int i = 0; i < n; i++) {
            future[i] = sc.nextInt();
        }

        int currentDay = 1;
        boolean isBuy = true;
        int next;
        while (currentDay <= n && (next = nextDay(future, currentDay, isBuy)) != -1) {
            int price = future[next - 1];

            if (isBuy) {
                long number = cash / price;
                cash -= price * number;
                stocks += number;
            } else {
                cash += price * stocks;
                stocks = 0;
            }

            isBuy = !isBuy;
            currentDay = next + 1;
        }

        System.out.println(cash);
    }

    private static int nextDay(int[] future, int currentDay, boolean isBuy) {
        int current = future[currentDay - 1];
        int nextDay = currentDay;

        for (int i = currentDay; i < future.length; i++) {
            int next = future[i];
            if (isBuy) {
                if (current >= next) {
                    current = next;
                    nextDay = i + 1;
                } else {
                    break;
                }
            } else {
                if (current <= next) {
                    current = next;
                    nextDay = i + 1;
                } else {
                    break;
                }
            }
        }

        if (isBuy && nextDay == future.length) return -1;
        else return nextDay;
    }
}