peterverebics/CodeNet_Python_118 huggingface dataset:
L, R = map(int, input().split())
end = min(R, L + 4038)
ans = 2018

for a in range(L, end):
    for b in range(a + 1, end+ 1):
        tmp = (a * b) % 2019
        print(a, b, tmp)
        if tmp < ans:
            ans = tmp

print(ans)
l, r = map(int, input().split())

if l//2019 != r//2019:
	print(0)
else:
	print(((l%2019)*((l+1)%2019))%2019)
L, R = map(int, input().split())
L %= 2019
R %= 2019
ans = float('inf')
for i in range(L, R+1):
  for j in range(i+1, R+1):
    ans = min(ans, (i*j)%2019)

print(ans)
l, r = map(int, input().split())
la = int(l % 2019)
ra = int(r % 2019)
diff = int(ra - la)
if diff <= 0:
  print("0")
  exit()
ans = int(2019)
for i in range(la, ra):
  for j in range(i+1, ra+1):
    mul = int(i*j)
    mul %= 2019
    if mul <= ans:
      ans = mul
print(ans)
L,R = map(int,input().split())
a = L%2019
b = R%2019
N = 2018
if R-L>=2019:
  print(2)
elif R-L<2019 and b>a:
  print((a*(a+1))%2019)
elif R-L<2019 and b<=a:
  print(2)
def main():
    from builtins import int, map, list, print
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = sys.stdin.readline
    input_list = (lambda: input().rstrip().split())
    input_number_list = (lambda: list(map(int, input_list())))

    L, R = input_number_list()
    l = L % 2019
    r = R % 2019
    if L // 2019 > R // 2019:
        print(0)
    else:
        print((l * (l + 1)) % 2019)


if __name__ == '__main__':
    main()
L, R = map(int, input().split())

def mod(num):
    return num % 2019


#  (2019a + x)(2019b + y) = 2019(n) + xy

ans = 10 ** 9

lr = min(R, L + 2019)

for i in range(L, lr):
    for j in range(i + 1, lr):
        ans = min(ans, mod(i * j))
        
print(ans)
l,r = map(int,input().split())

if r < 2019:
    print(l*(l+1))
    exit()

if l <= 2019 and 2019 <= r: 
    print(0)
    exit()

for i in range(l,r+1):
    if i%2019 == 0:
        print(0)
        exit()

ans = (l*(l+1))%2019
print(ans)
# coding: utf-8

#N = int(input())
alp = [chr(i) for i in range(97, 97+26)]
L = []
l, r = map(int,input().split())

if r-l+1 > 2019:
    ans = 0
else:
    for i in range(l, r+1):
        L.append(i%2019)
    L.sort()
    ans = (L[0]*L[1])%2019
print(ans)
l,r=map(int,input().split())

sho_l = l // 2019
sho_r = r // 2019

if sho_r-sho_l >= 1:
  print(0)
else:
  ans = 2018
  for i in range(l,r):
    for j in range(i,r+1):
      ans = min((i*j)%2019,ans)
  print(ans)
L, R  = map(int, input().split())

if (2019-(L%2019))+L <= R or L%2019 == 0:
  print(0)

else:
  print((L%2019) * ((L+1)%2019))
l,r=list(map(int,input().split()))
s=[]
if r-l>2050:
  print(0)
else:
  for i in range(l,r+1):
    s.append(i%2019)
  s.sort()
  print(s[0]*s[1])
L, R = map(int,input().split())
l = L%2019
r = R%2019
if R-L >= 2018:
  print(0)
elif l >= r:
  print(0)
else:
  print((l*(l+1))%2019)
# AtCoder Beginner Contest 133
# C - Remainder Minimization 2019
L,R=map(int,input().split())

mod=2019

l=L%mod if L<=mod else 0
r=R%mod if R<=mod else 0
m=min(l,r)

print(m*(m+1))
L, R = map(int, input().split())
mod = 2019
ans1 = L % 2019
ans2 = (L+1) % 2019
print(ans1*ans2)
import math
import sys
l, r = map(int, input().split())
mod=2018
for i in range(l, r):
    for j in range(l + 1, r):
        if (i * j % 2019 < mod):
            mod = i * j % 2019
if (r - l == 1 and r * l % 2019 < mod):
    mod=r*l%2019
print(mod)
m, n = map(int, input().split(" "))
if n - m >= 673:
    print(0)
else:
    score = m * n % 2019
    for i in range(n, m + 1):
        for j in range(i + 1, n + 1):
            if i * j % 2019 < score:
                score = i * j % 2019
    print(score)
L, R = map(int, input().split())

MOD = 2019
L = L%MOD
R = R%MOD
if L > R:
    L, R = R, L

MIN = 2018
if L == R:
    MIN = 0
for i in range(L, R):
    for j in range(i+1, R+1):
        buf = (i*j) % MOD
        print(i, j)
        MIN = min(buf, MIN)

print(MIN)
l, r = map(int, input().split())
rem = []
mod = 2019
if r - l + 1 > 2019:
    ans = 0
else:
    for i in range(l, r+1):
        rem.append(i % mod)
    rem.sort()
    ans = rem[0]*rem[1]

print(ans)
#!/usr/bin/env python3
L,R=map(int,input().split())
l = L%2019
r = R%2019
if R-L >= 2019:
    print(0)
elif r > l:
    print(l*(l+1)%2019)
else:
    print(0)
import collections
import numpy as np
import sys
sys.setrecursionlimit(10000000)
import copy
#N=int(input())
L,R=map(int,input().split())
l=[]
for i in range(2021):
    l.append(L%2019)
    if L==R:
        break
    L+=1
ans=2019999
for i in range(len(l)):
    for j in range(len(l)-1):
        ans=min(l[i]*l[j]%2019,ans)
print(ans)
l,r = map(int, input().split())

if r//2019 > (l-1)//2019:
  print('0')

else:
  print((l%2019) * ((l+1)%2019))
L,R=map(int,input().split())
if L%2019==0 or R%2019==0:
	ans=0
else:
	L%=2019
	R%=2019
	ans=2019
	for i in range(L,R):
		for j in range(i+1, R+1):
			ans=min(ans,(i*j)%2019)
print(ans)
l,r = list(map(int, input().split()))

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

l1 = l%2019
if r > l + 2019 - l1:
    r1 = 0
else:
    r1 = l1 + 1

print(l1*r1)
#!/usr/bin/env python3
L,R=map(int,input().split())
l = L%2019
r = R%2019
if R-L >= 2019:
    print(0)
elif r > l:
    print(l*(l+1))
else:
    print(0)
L, R = list(map(int, input().split()))
ans = 2020
if abs(L-R)>=4040:
    print(0)
else:
    for i in range(L, R):
        for j in range(L, R+1):
            if i==j:
                continue
            else:
                ans = min(ans, (i*j)%2019)

print(ans)
L,R = map(int,input().split())
mod = 2019
k = 2018
limit = R-L
for i in range(limit):
  s = (L * (L + i +1)) % mod
  if k>s:
    k = s
  if k == 0:
    break
    
print(k)
import sys
L, R = map(int, input().split())
ans = []

def calc_mod(x, y):
    return x * y % 2019

left = L % 2019
right = R % 2019

if left==0:
    print(0)
    sys.exit(0)

elif left > right:
    right += 2019

elif right==0:
    right = 2019

for i in range(left, right):
    for j in range(i+1, right+1):
        ans.append(calc_mod(i, j))

print(min(ans))
L, R = map(int, input().split())

mod_L = L % 2019
mod_R = R % 2019

if mod_L < mod_R:
    print(L*(L+1)%2019)
else:
    print(0)
L, R = map(int, input().split())
MOD = 2019
if R//MOD - L//MOD == 1:
    print(0)
else:
    x = min(L % MOD, R % MOD)
    print(x*(x+1))
l,r=map(int,input().split())
i=1
temp=0
while r>2019*i:
  if l<=2019*i:
    temp=1
    break
  i=i+1

count=2019
r=r%2019
l=l%2019
for i in range(1,r+1):
  for j in range(l+1,r+1):
    temp1=(i*j)%2019
    count=min(count,temp1)

if temp==1:
  print(0)
else:
  print(count)
l,r = map(int,input().split())
mod = 10**10

for i in range(l,r):
    mod = min(mod,(i*(i+1))%2019)
    if mod == 0:
        break

print(mod)
L,R = (int(x) for x in input().split())
if R-L > 2019*2:
  R -= ((R-L)//2019-1)*2019
print(L,R)
ans = 2019
for i in range(L,R):
  for j in range(i+1,R+1):
    ans = min(ans,(i*j)%2019)
print(ans)
l, r = map(int, input().split())
a = []
for i in range(l, min(r+1, l+2019**2)):
    a.append(i%2019)
a.sort()
print(a[0]*a[1]%2019)
l, r = list(map(int, input().split()))
ml, mr = l % 2019, r % 2019
def inc_maltiple(a, b, n):
    if b < n: return False
    if a % n >= b % n or b - a >= n: return True
    return False
if ml < mr and (not inc_maltiple(ml, mr, 3) or not inc_maltiple(ml, mr, 673)):
    print(ml * (ml + 1))
else:
    print(0)
l, r = map(int, input().split())
lmod = min(l%2019, (2019-l)%2019)
ldiv = l//2019
rmod = min(r%2019, (2019-r)%2019)
rdiv = r//2019
if ldiv==rdiv:
    print(min(lmod, rmod)*(min(lmod, rmod)+1)%2019)
elif ldiv<rdiv:
    print(0)
L,R = map(int,input().split())
max_len = 2019
j = 0
ans = []
for i in range(L,R+1):
    if j>=max_len:
        break
    j += 1
    ans.append(i%2019)
ans.sort()
print((ans[0]*ans[1])%2019)
L,R=map(int,input().split())
m=[2018,2018]
while L!=R and L<R:
    m=sorted([L%2019,R%2019]+m)[:2]
    L+=1
    R-=1
print(m[0]*m[1])
MOD = 2019
L, R = map(int, input().split())

if R - L >= 2019:
    print("0")
else:
    ans = 2018
    for i in range(L, R):
        mod_i = i % MOD
        for j in range(i+1, R+1):
            mod_j = j % MOD
            _ans = (mod_i * mod_j) % MOD
            if ans > _ans:
                ans = _ans
            if _ans == 0:
                print(i, j)
    print(ans)
l,r = map(int, input().split())
if (l <= 2019 and r >= 2019) or l % 2019 == 0 or r % 2019 == 0: 
    print(0)
elif l - r >= 2019 or l%2019 > r%2019:
    print(0)
else:
    print(min((l*(l+1))%2019, (r*(r-1))%2019))
L,R = map(int,input().split())

def rem(L, R):
  if (R//2019) - (L//2019) > 0:
    return 0
  L = L % 2019
  R = R % 2019
  return (L*(L+1))
    
print(rem(L, R) % 2019)
L, R = list(map(int, input().split()))
A = []
for j in range(L, R+1):
  for i in range(L, j):
    A.append((i% 2019)*(j% 2019))
    
print(min(A))
l,r = map(int,input().split())
if r < 2019:
  box = [x for x in range(l,r+1)]
  print(box[0]*box[1])
elif r == 2019:
  print(l)
else:
  box = [x for x in range(l,r+1)]
  print(int((box[0]*box[1])%2019))
l, r = map(int, input().split())
if r //2019 - l //2019:
    print(0)
else:
    res = 2018
    for i in range(l%2019, (r+1)%2019):
        for j in range(i+1, (r+1)%2019):
            res = min(res, (i*j)%2019)
    print(res)
l, r = map(int, input().split())

x = 2018
cnt = 0
for i in range(l, r+1):
    a = i%2019
    if a == 0:
        print(0)
        exit()
    x = min(a, x)
print(x*(x+1)%2019)
L,R=map(int,input().split(" "))


#mod(L)*mod(R)>=2019の場合を入れる
mod_List=[]
count=0
for i in range(L,R+1):
    mod_List.append(i%2019)
    count+=1
    if count>=2019:
        break
        
mod_List.sort()
if mod_List[-1]*mod_List[-2]>=2019:
    print(0)
elif L!=R:
    print(mod_List[0]*mod_List[1])
else:
    print(mod_List[0])
# -*- coding: utf-8 -*-
"""
Created on Thu Sep 10 11:33:13 2020

@author: liang
"""

L, R = map(int,input().split())
r = R%2019
l = L%2019
ans = 2018
#if R - L >= 2019 - l:
if r < l or l == 0:
    ans = 0
else:
    for i in range(l,r):
        for j in range(i+1,r+1):
            ans = min(ans,i*j%2019)
print(ans)
L,R = map(int,input().split())
MOD = 2019
ans = (MOD-2)*(MOD-1)
for i in range(L, min(R, L + 2018)):
    for j in range(i+1, min(R, L+2018) + 1):
        ans = min(ans,(i % MOD) * (j % MOD))
        if ans == 0:
            break
print(ans)
L, R = map(int, input().split())
ans = 2020
for i in range(L + 1, R + 1):
    ans = min(ans, (L * i) % 2019)
    if ((i - L) == 2018): break
print(ans % 2019)
import collections
import numpy as np
import sys
sys.setrecursionlimit(10000000)
import copy
#N=int(input())
L,R=map(int,input().split())
l=[]
for i in range(2021):
    l.append(L%2019)
    if L==R:
        break
    L+=1


l.sort()
print(l[0]*l[1])
l, r = map(int, input().split())
m = 2019
if r - l >= 673:
    print(0)
else:
    ans = 2018
    for i in range(l, r):
        for j in range(i+1, r+1):
            ans = min(ans, (i*j)%m)
            if ans <= 2:
              break
        if ans <= 2:
            break
    print(ans)
#!/usr/bin/env python3
L, R = map(int, input().split())
l = L % 2019
r = R % 2019
if R - L >= 2019:
    print(0)
elif r >= 673 and l <= 3:
    print(0)
elif r > l:
    print(l * (l + 1) % 2019)
else:
    print(0)
from itertools import combinations

L, R = map(int, input().split())
mod = 2019
min_score = float('inf')
L = L%mod
R = R%mod    
if L<R:
    pair = [i for i in range(L,R+1)]
else:
    pair = [i for i in range(L,mod)]
    for i in range(R+1):
        pair.append(i)
for a,b in combinations(pair,2):
    min_score = min(min_score, a*b%mod)
print(min_score)
l,r = map(int, input().split())

mod_l = l%2019

if r-l>2019:
    print(0)
else:
    m = mod_l
    cnt = 0
    while cnt <= r-l:
        mod_l += 1
        mod_l %= 2019
        m = min(m, mod_l)
        cnt += 1
    print(m*(m+1)%2019)
L, R = map(int, input().split())
i = 2017
j = 2018
i_mod = 2017
j_mod = 2018
end = min(R, L + 4038)

for n in range(L, (end + 1)):
    n_mod = n % 2019
    if n_mod < i_mod:
        i, j = n, i
        i_mod = n_mod
    elif n_mod < j_mod:
        j = n
        j_mod = n_mod

print((i * j) % 2019)
L, R = map(int, input().split())
L = L % 2019

print(L * (L + 1))
l,r=map(int,input().split())
a=[]
for i in range(l,min(l+2020,r+1)):
  a.append(i%2019)
a.sort()
print(a[0]*a[1])
l, r = map(int, input().split())
if r //2019 - l //2019:
    print(0)
else:
    res = 2018
    for i in range(l%2019, r%2019):
        for j in range(i+1, r%2019):
            res = min(res, (i*j)%2019)
    print(res)
#　あまりの問題は周期性がある
#  R-Lが201９を超えたら必ず2019の倍数のものが存在するのでR-Lが2019より小さい時に絞って考えればいい
#  小さい時では高々要素数は2019より小さいので全部探索すればいい
l,r=list(map(int,input().split()))
if r-l>=2019:
  print(0)
else:
  ans=2019
  for i in range(l,r):
    for j in range(i+1,r+1):
      ans=min(ans,(i%2019)*(j%2019))
      
      
  print(ans)
L, R = map(int,input().split())
l = L%2019
r = R%2019
if R-L >= 2018:
  print(0)
elif l >= r:
  print(0)
else:
  print(l*(l+1)&2019)
import math
def main():
    l, r = map(int,input().split())
    if r - l >= 637:
        print(0)
        return
    l_mod = l % 2019
    r_mod = r % 2019
    ans = []
    if l_mod > r_mod :
        ans = [i for i in range(l_mod,2019)]
        ans.extend([i for i in range(r_mod+1)])
    else:
        ans = [i for i in range(l_mod,r_mod+1)]
    print(ans)
    ans.sort()
    print((ans[0] * ans[1]) % 2019)

if __name__ == '__main__':
    main()
l,r=map(int,input().split())
if r-l>=2019:
  print(0)
  exit()
m0=l%2019
m1=r%2019
if m1<m0:
  print(0)
  exit()
else:
  print(m0*(m0+1)%2019)
l, r = map(int, input().split())

if l == 0:
    print('0')
elif (r % 2019 == 0) or (l % 2019 == 0) or (r-l >= 2019):
    print('1')
else:
    min_num = 2020
    for left in range(l, r):
        for right in range(left+1, r+1):
            mod = (left * right) % 2019
            min_num = min(min_num, mod)
    print(min_num)
import sys
l,r = map(int,input().split())
if r-l >= 2018:
    print(0)
    sys.exit()
elif (l%2019 > r%2019) or (l%2019 == 0) or (r%2019 == 0):
    print(0)
    sys.exit()
else:
    l = l%2019
    r = l + 1
p = 2018**2
for i in range(l,r):
    for j in range(i+1,r+1):
        q = (i*j) % 2019
        if q < p:
            p = q
print(p)
a,b=map(int,input().split())
ans=[]
i=0
while i<4096 and a+i<=b:
    ans.append((a+i)%2019)
    i+=1
z=ans.pop(ans.index(min(ans)))
print(z*min(ans))
a,b=map(int,input().split())
ans=[]
i=0
while i<1000 and a+i<=b:
    ans.append((a+i)%2019)
    i+=1
ans.sort()
print(ans)
minn=10**6
for i in range(len(ans)):
    for j in range(i+1,len(ans)):
        minn=min(minn,(ans[i]*ans[j])%2019)
print(minn)
import itertools
L,R=map(int,input().split())
if L%2019==0 or R%2019==0:
	ans=0
else:
	L%=2019
	R%=2019
	INF=10*9
	ans=INF
	for c in itertools.combinations(range(min(L,R),max(L,R)),2):
		ans=min(ans,(c[0]*c[1])%2019)
print(ans)
l,r = map(int, input().split())
n = l+1
m = 2019
for s in range(l,r):
    for t in range(n,r+1):
        st = (s*t)%2019
        if st < m:
            m = st
        n += 1
print(m)
i, j = map(int, input().split())
a = i%2019
a_r = i//2019
 
b = j%2019
b_r = j//2019
 
if a_r == b_r:
  print(a*(a+1)%2019)
elif b_r > a_r or b<=a:
  print(0)
L, R= map(int, input().split())
m = 2019
r = R%m
l = L%m
if 0 <= r - l < 2019:
  a = [i%2019 for i in range(l, r+1)]
  a.sort()
  print(a[0]*a[1])
else:
  print(0)
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1


L, R = map(int, input().split())

if L < 2020:
    print(L * R)
else:
    print(L * (L + 1) % 2019)





# def main():

# if __name__ == '__main__':
#     main()
L, R = map(int, input().split())
MOD = 2019

if -(-L//MOD) == (R-1)//MOD:
    print(0)
else:
    x = L % MOD
    print(x*(x+1) % MOD)
L, R = map(int, input().split())
if R-L>=2019:
    print(0)
else:
    a=2019
    for i in range(L, R+1):
        a=min(a, i%2019)
    if a==0:
        print(0)
    else:
        print(a*(a+1))
L,R = map(int,input().split())
L %= 2019
R %= 2019
if L >= R:
    R += 2019
ans = 2019
for i in range(L,R):
    for j in range(i+1,R+1):
        ans = min(ans,(i*j)%2019)
print(ans)
def main():
  import itertools
  
  L,R=map(int,input().split())
  x,y=L//2019,R//2019
  if y-x>=1:
    print(0)
  else:
    print(L*(L+1)%2019)
  
if __name__=="__main__":
  main()
L, R = map(int, input().split())
if L // 2019 == R // 2019:
  A = L % 2019
  ans = (A * (A + 1)) % 2019
elif L // 2019 == R // 2019 + 1:
  if L % 2019 > R % 2019 and R % 2019 >= 0:
    ans = 0
  else:
    A = L % 2019
    ans = (A * (A + 1)) % 2019
else:
  ans = 0
print(ans)
L,R = list(map(int,input().split()))

dif = R - L
_L, _R = L%2019,R%2019

if _R < _L:
  print(0)
elif _L < _R and dif >= 2018: 
  print(0)
elif _L < _R and dif < 2018:
  _m = (L*(L+1)%2019)
  for i in range(L,R+1):
    for j in range(i,R+1):
      _m = min(_m,(i*j)%2019)
  print(_m)
l,r=map(int,input().split())

if r-l+1<2019:
  if r%2019<l%2019:
    print(0)
  else:
    ans=(l%2019*(l+1)%2019)%2019
    print(ans)
    
else:
  print(0)
  exit()
L, R = map(int, input().split())
if R-L >= 2018:
    print(0)
else:
    m = 10*6
    for i in range(L, R):
        for j in range(i+1, R+1):
            m = min((i*j)%2019, m)
            if m == 0:
                break
        else:
            continue
        break

    print(m)
L, R = map(int, input().split())
A = [None]*2019
for i in range(L,R+1):
  if A[i%2019] is not None:
    break
  else:
    A[i%2019] = i%2019
A = sorted(list(filter(lambda x: x is not None,A)))
print(A[0]*A[1])
import sys

a, b = map(int,input().split())
num = int(a*b%2019)

for i in range(1, b - a + 1):
  for j in range(i + 1, b - a + 1):
    num = min(num, (i*j)%2019)
    if(num == 0):
      print(0)
      sys.exit()

print(num % 2019)
a,b = map(int,input().split())
l = a*b%2019
#print(l)
if l+(b-a-1)>=2019:
  print(0)
elif l+(b-a-1)<2019:
  if l-(b-a-1)<=0:
    print(0)
  elif l-(b-a-1)>0:
    print(l-b+a+1)
L,R=map(int,input().split(" "))

mod_List=[]
count=0
for i in range(L,R+1):
    mod_List.append(i%2019)
    count+=1
    if count>=2019:
        break

mod_List.sort()
if L!=R:
    if 673 in mod_List:
        if 3 in mod_List:
            print(0)
    else:
        print(mod_List[0]*mod_List[1])
else:
    print((mod_List[0]*mod_List[0])%2019)
m, n = input().split(" ")
m = int(m)
n = int(n)
if n - m >= 2019:
    print(0)
else:
    score = m * n % 2019
    for i in range(n - m - 1):
        for j in range(n - m - 1):
            if (m + i) * (m + j + 1) % 2019 < score:
                score = (m + i) * (m + j + 1) % 2019
    print(score)
def main():
	l ,r = map(int,input().split())
	print((l*(l+1))%2019)



main()
def main():
    l, r = map(int, input().split())
    
    a = l % 2019
    b = r % 2019
    if a >= b or r - l > 2018 or l % 2019 == 0 or r % 2019 == 0:
        print(0)
    else:
        c = []
        for i in range(l, r+1):
            c.append(i % 2019)
        if 3 in c and 673 in c:
            print(0)
        else:
            print(c[0] * c[1])
        
    
if __name__ == '__main__':
    main()
L, R = map(int, input().split())
if L + 2019 < R:
  tmp = 10**9
  for l in range(L,R):
    for r in range(l+1, R+1):
      if (l*r)%2019 < tmp:
        tmp = (l*r)%2019
  print(tmp)
else:
  print(0)
l, r = map(int, input().split())

l2 = l // 2019
r2 = r // 2019

if l2 != r2:
  print(0)
else:
  print(l * (l + 1) % 2019)
l,r=map(int,input().split())
l10=l % 2019
r10=r % 2019
if r10==0 or l10==0 or r -l >= 2019 or r10 <= l10:
    print(0)
else:
    print((l*(l+1))%2019)
L, R = map(int,input().split())
Dif = abs(L-R)+1
if Dif >= 2040:
    Ans = 0
else:
    Box = []
    for i in range(L,R+1):
        Box.append(i%2019)
    Box.sort()
    Ans = Box[0]*Box[1]
print(Ans)
L, R = map(int, input().split())
ans = 2019
    
if L//2019 != R//2019:
    print(0)
    exit(0)
else:
    L = L%2019
    R = R%2019

    for i in range(L,R):
        for j in range(i+1,R):
            ans = min(ans,(i*j)%2019)

print(ans)
L, R = map(int, input().split())
if R - L >= 2019:
    res = 0
else:
    mod_list = sorted([e % 2019 for e in range(L, R+1)])
    res = mod_list[0] * mod_list[1]

print(res)
# coding: utf-8

#N = int(input())
alp = [chr(i) for i in range(97, 97+26)]
L = []
l, r = map(int,input().split())

if r-l+1 > 2019:
    ans = 0
else:
    for i in range(l, r+1):
        L.append(i%2019)
    L = list(set(L))
    L.sort()
    ans = (L[0]*L[1])%2019
print(ans)
#print(L)
l, r= map(int, input().split())
if l - r >= 2019:
  print(0)
else:
  a = [i%2019 for i in range(l,r+1)]
  a.sort()
  print(a[0]*a[1])
L, R = map(int, input().split())
  
if R - L >= 2018:
  print(0)
  exit()
  
lst = []
for i in range(L,R+1):
  lst.append(i%2019)
  
lst.sort()

print(lst[0]*lst[1])
l,r = map(int,input().split())
mod = 2019

s = l % mod
e = r % mod
diff = l-r

if diff >= 2020:
    print(0)

else:
    if s >= e:
        print(0)
    
    else:
        print(s*(s+1)%mod)
L, R = map(int, input().split())

Lmod = L%2019
Rmod = R%2019

if (R-L+1) < 2019 and Lmod < Rmod:
    print((L*(L+1))%2019)
elif (R-L+1) < 2019 and Lmod > Rmod:
    print(0)
elif (R-L+1) >= 2019:
    print(0)
L, R = map(int, input().split())

MOD = 2019

if R - L >= MOD or L%MOD == 0 or R%MOD == 0:
    print(0)
else:
    minimum = 2*10**9
    for i in range(L, R):
        minimum = min((i*(i+1))%MOD, minimum)
    print(minimum)
L, R = map(int, input().split())

def mod(num):
    return num % 2019

l = mod(L)
r = mod(R)

if l > r:
    print(0)

else:
    print(min(mod(l * (l + 1)), mod((r - 1) * r)))
l,r=map(int,input().split())

if l//2019==r//2019:
    print((l%2019)*((l+1)%2019))
else:
    print(0)
# 初期入力
import sys
input = sys.stdin.readline
L,R = (int(x) for x in input().split())

mod_L =L %2019
mod_R =R %2019
ans =0
if 2019 <= R -L:
    ans =0
elif mod_R < mod_L:
    ans =0
else:
    ans =mod_L *(mod_L +1)
print(ans)
l,r = map(int, input().split())
if (r-l >= 2018):
    print(0)
    exit()
a = []
for i in range(l,r+1):
    a.append(i%2019)
a.sort()
print((a[0]*a[1])%2019)
L, R = map(int, input().split())

L2 = L%2019
R2 = R%2019

length = abs(R-L+1)
ans = []
for i in range(length):
    if L2 < R2:
        ans.append(L2+i)
    elif L2 > R2:
        ans.append(R2+i)


print(ans[0]*ans[1])
L, R = map(int, input().split())

MOD = 2019

if R - L >= MOD or L%MOD == 0 or R%MOD == 0:
    print(0)
else:
    minimum = MOD
    for i in range(L, R):
        minimum = min(i%MOD, minimum)
    print((minimum*(minimum+1))%MOD)
l, r = map(int, input().split())
r = min(r, l+(2019*2))
ans = 2018

for i in range(l, r):
  for j in range(i+1, r):
    x = (i * j) % 2019
    ans = min(ans, x)

print(ans)
l,r=map(int,input().split())
print(l*(l+1)%2019 if r//2019-(l-1)//2019<1 else 0)
l,r = map(int,input().split())
minimum = 2019

if r-l>=2018:
    print(0)

else:
    l %= 2019
    r %= 2019
    if r<l:
        print(0)
    else:
        print(l*(l+1)%2019)
L, R = map(int, input().split())
num_L, num_R = L // 2019, R // 2019
if abs(num_L - num_R) >= 1:
    print(0)
else:
    print(L*(L+1)%2019)
L,R=map(int,input().split())
ls=[]
LS=[]
if L-R>=672 or L==0:
  print(0)
else:
  ans=2019
  for i in range(L,R+1):
    for j in range(i+1,R+1):
      if i>=j:
        print(ans)
        exit()
      x=(i*j)%2019
      ans=min(x,ans)
L,R= map(int,input().split())
li = sorted([int(i)%2019 for i in range(L,R+1)])
print((li[0]*li[1])%2019)
l, r = map(int, input().split())

l %= 2019
r %= 2019

ans = 2018

for i in range(l, r+1):
    for j in range(l, r+1):
        if i != j:
            ans = min(ans, (i*j)%2019)

print(ans)
#!/usr/bin/env python3
L, R = map(int, input().split())
l = L % 2019
r = R % 2019
if R - L < 2019 and r > l:
    print(min(i*(i+1)%2019 for i in range(l,r)))
else:
    print(0)
def main():

    L, R = [int(i) for i in input().split()]

    if (L//2019) < (R//2019):
        ans = 0
    else:
        t = L % 2019
        ans = t * (t+1)
    print(ans)

if __name__ == "__main__":
    main()
l,r=map(int,input().split())
a=[]
for i in range(l,min(l+2020,r+1)):
  a.append(i%2019)
a.sort()
ans=10*18
for i in range(len(a)):
  for j in range(i+1,len(a)):
    t=(a[i]*a[j])%2019
    ans=min(ans,t)
print(ans)