Problem:
Score : 300 points

Problem Statement

You are given two non-negative integers L and R.
We will choose two integers i and j such that L \leq i < j \leq R.
Find the minimum possible value of (i \times j) \mbox{ mod } 2019.

Constraints

All values in input are integers.

0 \leq L < R \leq 2 \times 10^9

Input

Input is given from Standard Input in the following format:

L R

Output

Print the minimum possible value of (i \times j) \mbox{ mod } 2019 when i and j are chosen under the given condition.

Sample Input 1

2020 2040

Sample Output 1

2

When (i, j) = (2020, 2021), (i \times j) \mbox{ mod } 2019 = 2.

Sample Input 2

4 5

Sample Output 2

20

We have only one choice: (i, j) = (4, 5).

Solution in JavaScript (node.js v5.12) (judge verdict: Accepted)

// inputに入力データ全体が入る
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split("\n");
    tmp0 = input[0].split(" ");
    L = Number(tmp0[0])
    R = Number(tmp0[1])
    
    if(R-L >= 2019)
    {
        console.log(0)
        return
    }
    L2 = L % 2019
    R2 = R % 2019

    ans = 2019
    if(L2 >= R2){
        console.log(0)
        return
    }
    for(i=L2; i < R2; i++)
    {
        for(j=i+1; j <= R2; j++)
        {
            ans = Math.min(ans, (i * j) % 2019)
        }
    }
    console.log(ans)
}
  //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// Main("2018 2021\n");