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: Runtime Error)

// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	tmp = input[0].split(" ");
	//文字列から10進数に変換するときはparseIntを使います
	var L = parseInt(tmp[0], 10);
	var R = parseInt(tmp[1], 10);

	if((L-R)>=2019){
		console.log('%d',0);
	}
	else{
		var ans = Infinity;
		var endFlag = False;
		for(var i=L; i<R; i++){
			var iTmp = i%2019;
			if(iTmp === 0){
				ans=0;
				endFlag=True;
			}
			for(var j=i+1; j<=L; j++){
				var jTmp = j%2019;
				if(jTmp === 0){
					ans=0;
					endFlag=True;
				}
				var rTmp = (iTmp*jTmp)%2019;
				if(rTmp<ans) ans=rTmp;
			}
			if(endFlag === True) break;
		}
		//出力
		console.log('%d',ans);
	}
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));