peterverebics/CodeNet_Python_118 huggingface dataset:
L,R = map(int, input().split())
l = L//2019
r = R//2019
m = L%2019
n = R%2019

ans = 2018
if l != r:
  print(0)
else:
  for i in range(m,n-1):
    for j in range(i+1,n):
      ans = min((i*j) % 2019, ans)
      
print(ans)
l, r = map(int, input().split())

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

print(ans)
l,r = map(int,input().split())
ans = 10**20
if r-l>=2019:
    print(0)
elif r-l<2019:
    for i in range(l,r):
        for j in range(i,r+1):
            ans = min(ans,i*j%2019)
            if i*j%2019 == 0:
                break
print(ans)
L,R=map(int,input().split())
MOD=2019
ans=10**9
for i in range(L,R):
    for j in range(L+1,R+1):
        flag=(i%MOD)*(j%MOD)
        if flag==0:
            break
        ans=min(ans,flag)
print(ans)
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

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

l = L % 2019
r = R % 2019

if r <= l:
    r += 2019

ans = 2018
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())
L = L%2019 
R = 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())
a=l//2019
b=r//2019
c=l%2019
d=r%2019

if a<b or c==0:
    print(0)
else:
    print(c*(c+1))
a, b = map(int, input().split())

min_value = a*(a+1)%2019
max_value = (b-1)*b%2019
ans = 0

if min_value >= max_value and a+1 != b:
    ans = 0
else:
    ans = min_value

print(ans)
L, R = map(int,input().split())
l = L%2019
r = R%2019
if l > r:
  print(2)
else:
  print(l*(l+1))
l,r=map(int,input().split())
ll=l%2019
if  l//2019==r//2019:
    print((ll*(ll+1))%2019)
else:
    print(0)
L,R=map(int,input().split())
m=sorted([i%2019 for i in range(L,R+1)])
print(m[0]*m[1])
def main():
    L, R = map(int, input().split())
    check_point = 2019
    num_2019 = 0
    while check_point <= R:
        if check_point >= L:
            num_2019 += 1
        check_point += 2019

    if num_2019 >= 1:
        print(0)
    else:
        print(L*(L+1) % 2019)


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

if R<L+2019:
  end=R+1
else:
  end=L+2019

mod=2019
num=0
for i in range(L,end):
  if i%2019<mod:
    mod=i%2019
    num=i

print(num,num+1)
L, R = map(int, input().split())

ans = 2018**2
if L-R >= 2019:
    ans = 0
else:
    l, r = L % 2019, R % 2019
    for i in range(l, r):
        for j in range(i+1, r+1):
            ans = min(ans, i*j % 2019)
print(ans)
#!/usr/bin/env python3
l, r = map(int, input().split())
a = 2019
for i in range(l, r + 1):
    for j in range(i+1, r + 1):
        if i % 2019 == 0 or j % 2019 == 0:
            print(0)
            break
        else:
            a = min(a, (i%2019)*(j%2019)%2019)
    else:
        continue
    break
print(a)
L, R = map(int, input().split())

L2 = L%2019
R2 = R%2019

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

list.sort(ans)
print((ans[0]*ans[1])%2019)
l, r = map(int, input().split())
n = 2019
l = l%n
r = r%n
ans = 2019
a = min(l,r)
b = max(l,r)

for i in range(a,b):
    for j in range(a+1,b+1):
        ans = min(ans, (i*j)%n)

print(ans)
import sys
L,R=[int(x) for x in input().strip().split()]

tmp=10**9+1
ans=10**0+1

for i in range(L,R+1):
  for j in range(L,R+1):
    if i<j:
      tmp=(i*j)%2019
      if ans==0:
          print(0)
          sys.exit()
      elif tmp<ans:
          ans=tmp
print(ans)
L,R = map(int,input().split())
if L==R:
  print(L%2019 * L%2019)
  exit()
if R-L >= 2019:
  print(0)
  exit()

l = L%2019
r = R%2019
res = 2018
for i in range(l):
  for j in range(i+1,r):
    if i*j == 0:
      print(0)
      exit()

    rem = min(res, i*j)

print(res)
l, r = map(int, input().split())
l %= 2019
r %= 2019

min_value = 10 ** 9

for j in range(l, r+1):
  for i in range(l, j):
    min_value = min(min_value, i * j)

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

if L > R:
    res = 0
else:
    res = float("inf")
    L = L % 2019
    R = R % 2019
    for i in range(L, R + 1):
        for j in range(i + 1, R + 1):
            res = min(res, (i * j) % 2019)
print(res)
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))
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 r < l:
        print(0)
    else:
        print(l*(l+1))

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

ans = 10 ** 9
for i in range(L, R+1):
    for j in range(i, R):
        mod = i * j % 2019
        if ans > mod:
            ans = mod
        elif mod == 0:
            ans = 0
            break
    else:
        continue
    break
print(ans)
def f(l,r):
    p=2019
    for i in range(l,r+1):
        for j in range(l,r+1):
            p=min((i*j)%2019,p)
    return p
    
l,r=map(int,input().split())
print(0 if r//2019-(l-1)//2019!=0 or (r//673-(l-1)//673!=0 and r//3-(l-1)//3!=0) else f(l,r))
def resolve():
    '''
    code here
    '''
    L, R = [int(item) for item in input().split()]
    aL, bL = divmod(L, 2019)
    aR, bR = divmod(R, 2019)

    if bL == 0:
        res = 0
    elif aL < aR:
        res = 0
    elif aL == aR:
        res = bL*(bL+1)
    
    print(res%2019)

if __name__ == "__main__":
    resolve()
l, r = map(int, input().split())
mod = 2019
l_n = l//mod
r_n = r//mod
#print(l_n, r_n)
if l_n == r_n:
    l_mod = l % mod
    l1_mod = (l_mod + 1) % mod
    ans = l_mod*l1_mod % mod
    print(ans)
elif l_n < r_n:
    print(0)
import sys

a, b = map(int,input().split())
num = [a%2019]
num.append(b%2019)

for i in range(a + 1,b):
  if(max(num) > (i % 2019)):
    num.append(i%2019)
    num.remove(max(num))
  elif(i % 2019 == 0):
    print(0)
    sys.exit()

print(num[0] * num[1])
#!/usr/bin/env python3

def main():
    l, r = map(int, input().split())
    cnt = 0
    ans = 2018
    for i in range(l, r + 1):
        for j in range(l + 1, r + 1):
            ans = min(ans, (i * j) % 2019)
            if cnt == 2019:
                break
        cnt += 1
    print(ans)


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

num = 0
ans = (L * (L + 1)) % 2019
for i in range(L, R)[::-1]:
    j = i + 1
    ans = min(ans, (i * j) % 2019)
    num += 1
    if num >= 3000:
        break
print(ans)
l, r = map(int, input().split())
if r-l >= 2018:
    print(0)
else:
    lmod = l%2019
    rmod = r%2019
    #print(lmod, rmod)
    if lmod>rmod:
        print(0)
    else:
        print((lmod*(lmod+1))%2019)
import math
L, R = list(map(int, input().split()))
if math.ceil(L / 2019) <= R // 2019:
    print(0)
else:
    res = 0
    for i in range(L % 2019, R % 2019):
        for j in range(L % 2019 + 1, R % 2019 + 1):
            res = min(res, (i * j) % 2019)
    print(res)
L, R = map(int,input().split())
lst = [i%2019 for i in range(L,R+1)]
lst = set(lst)
lst = list(lst)
lst.sort()
print(lst[0]*lst[1])
l, r = map(int, input().split())

res = []
for i in range(l, r+1):
    res.append(i%2019)
res.sort()
print(res[0]*res[1])
L,R=map(int,input().split())
_min=2018
if L==0:
  print(0)
else:  
  f=min(R-L+1,2019)
  for l in range(L,L+f-1):
    for r in range(l+1,L+f):
      m=(l*r)%2019
      if _min>m:
        _min=m
print(_min)
import sys
import os

MOD = 2019


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    L, R = list(map(int, sys.stdin.readline().split()))
    ret = float('inf')

    l, r = L%MOD, R%MOD
    for i in range(l, r+1):
        for j in range(l+1, R+1):
            ret = min(ret, (i * j) % MOD)

    print(ret)


if __name__ == '__main__':
    main()
l,r = map(int,input().split())

if r-l >= 2019:
    print(0)
    exit()
mod = 2019

if r//mod != l//mod:
    print(0)
    exit()

li = []

for i in range(l,r+1):
    li.append(i%mod)
li.sort()
print(li[0]*li[1])
l, r = map(int, input().split())
la = l % 2019
ra = r % 2019
diff = ra - la
if diff==0:
  print("0")
  exit()
elif diff < 0:
  diff+=2019
ans = 2018
for i in range(la, la+diff):
  for j in range(i+1, la+diff+1):
    mul = (i*j) % 2019
    if mul < ans:
      ans = mul
print(ans)
L, R = map(int, input().split())

ans = 10**10
for i in range(L, R):
    for j in range(i+1, R+1):
        ans = min(ans, (i*j)%2019)
        if(ans == 0):
            exit()
print(ans)
L,R=map(int,input().split())
i,j=2020,2020

for n in range(L,R+1):
    x=n%2019
    if i>=j:
        if i>x:
            i=x
        elif j>x:
            j=x
    else:
        if j>x:
            j=x
        elif i>x:
            i=x
    if i*j==0:
        print(0)
        break
else:
    print((i*j)%2019)
l, r = map(int, input().split())
dif = r - l
ans = 0
if dif >= 2019:
    ans = 0
else:
    mod_l = l % 2019
    mod_r = r % 2019
    if mod_l < mod_r:
        ans = mod_l * (mod_l + 1)
    else:
        ans = mod_r * (mod_r - 1)
print(ans)
l,r = map(int,input().split())

if 2019 <= l:
    print (l%2019*(l%2019+1))
else:
    print (l*(l+1))
l,r=map(int,input().split())
p=l%2019
q=r%2019
a=2018
if p>q:
    print(0)
else:
    for i in range(p,q):
        for j in range(p+1,q+1):
            c=(i*j)%2019
            if a>c:
                a=c
    print(a)
l,r = map(int, input().split())

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

else:
  print((l%2019) * ((l+1)%2019))
l,r=map(int,input().split())
x=[]
if l%2019==0 or r%2019==0 or (r-l)>=2019:
    print(0)
else:
    for i in range(l,r+1):
        x.append(i%2019)
    x.sort()
    print((x[0]*x[1])%2019)
l,r = map(int,input().split())
cnt = 0
mod_list = []
for i in range(l,r+1):
    mod_list.append(i%2019)
    cnt += 1
    if cnt == 5000:
        break
mod_list.sort()
print(mod_list[0]*mod_list[1]%2019)
L, R = map(int, input().split())
if (R//2019) != (L//2019):
    result = 0
else:
    R %= 2019
    L %= 2019
    result = 2018
    for i in range(L, R):
        for j in range(i+1, R+1):
            if result > i*j:
                result = i*j
print(result)
l, r = [int(i) for i in input().split()]
ln = l // 2019
rn = r // 2019
if ln == rn:
	print ((l * (l + 1)) % 2019)
else:
	print (0)
L, R = map(int, input().split())
result = R*R
if R - L + 1 > 2019:
    R = L + 2018
for i in range(L,R+1):
    print("i="+str(i))
    for j in range(i+1,R+1):
        print("j="+str(j))
        if (i * j) % 2019 < result:
            result = (i * j) % 2019
print(result)
L, R = list(map(int, input().split()))
l = L%2019
r = R%2019
ans = 2020
if abs(L-R)>=4040:
    print(0)
else:
    for i in range(L, R):
        ans = min(ans, (i*(i+1))%2019)

print(ans)
L,R = map(int,input().split())
a =[i for i in range(L,R+1)]
x = []
s = 10**5
for i in a:
  
  if i%2019==0:
    print(0)
    exit()
  else:
    x.append(i%2019)
    x = sorted(x)
    if len(x)>=2:
      s = min(s,x[0]*x[1])
  
print(s)
l,r = map(int,input().split())

ll = l % 2019
rr = r % 2019
tmp=2020
for i in range(ll,rr+1):
  for j in range(i+1,rr+1):
    tmp = min(tmp,(i*j) % 2019)

print(tmp)
L,R=map(int,input().split())
l=L%2019
r=R%2019
#print(l,r)
if l<r and L//2019 == R//2019:
    print(l*(l+1))
elif l<r and L//2019<R/2019:
    print(0)
elif l==r:
    print(0)
elif l>r:
    print(0)
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))
def main():

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

    tl = L % 2019
    tr = R % 2019
    c1 = (tl <= 673) & (673 <= tr)
    c2 = False
    for i in range(L, min(L + 3, R+1)):
        if i % 3 == 0:
            c2 = True
            break

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



if __name__ == "__main__":
    main()
import itertools
L,R=map(int,input().split())
if L%2019==0 or R%2019==0:
	ans=0
else:
	L%=2019
	R%=2019
	ans=2020
	for c in itertools.combinations(range(min(L,R),max(L,R)+1),2):
		ans=min(ans,(c[0]*c[1])%2019)
print(ans)
L,R = map(int,input().split())

if R-L>2019 or L>R :
    print(0)
    exit()
if L%2019+(R-L)>=2019 :
    print(0)
    exit()
l1=L%2019
r1=R%2019

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

print( ans )
MOD = 2019
L, R = map(int, input().split())
L, R = min(L%MOD,R%MOD), max(L%MOD,R%MOD)

if L == 0 or R == 0:
    print(0)
    exit()

ans = float('inf')
for i in range(L,R):
    for j in range(i+1,R+1):
        ans = min(ans,(i*j)%MOD)
print(ans)
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
import itertools
from collections import Counter

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


if __name__=="__main__":
    main()
l,r = list(map(int, input().split()))

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

ans = float("inf")
for i in range(l1,r1):
    for j in range(i+1, r1+1):
        ans = min(ans, (i*j%2019))
L,R = map(int,input().split())
MOD = 2019
l = L % MOD
r = R % MOD
print(0 if r < l or (MOD - l) <= (r - l) else l * (l+1))
l,r=map(int,input().split())
a=[]
for i in range(l,min(l+2020,r+1)):
  a.append(i)
a=set(a)
a=list(a)
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)
L, R = map(int, input().split())
mod = 2019
for i in range(L, R+1):
    for k in range(L+1, R+1):
        if (i*k)%2019 <= mod:
            mod = (i*k)%2019
print(mod)
l, r = map(int, input().split())
result = 10 ** 9
if r-l == 1:
  print((l * r) % 2019)
else:
  r = min(r, l + 2019)
  for i in range(l, r+1):
    for j in range(l, r+1):
      if i < j:
        result = min(result, (i*j)%2019)
        
print(result)
MOD = 2019
L, R = map(int, input().split())
L, R = L%MOD, R%MOD
ans = float('inf')
for i in range(L,R+1):
    for j in range(i+1,R+1):
        ans = min(ans,(i*j)%MOD)
print(ans)
L,R=list(map(int, input().split()))
M=2019
if R-L==1:
  print(((R%M)*(L%M))%M)
  exit()
L=L%M
if R%M<=L:
  R=(R%M)+M
else:
  R=R%M
ans=M
for i in range(L,R+1):
  for j in range(i+1,R+1):
    ans=min(ans,(i*j)%M)
print(ans)
L,R = map(int,input().split())
if R-L >= 2018:
    print(0)
else:
    a = False
    for i in range(L, R + 1):
        if i % 2019 == 0:
            a = True
    if a:
        print(0)
    else:
        s = 2019
        for i in range(L,R):
            s = min(s, (i*(i+1)) % 2019)
        print(s%2019)
import sys
import os

MOD = 2019


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    L, R = list(map(int, sys.stdin.readline().split()))
    ret = float('inf')

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

    print(ret)


if __name__ == '__main__':
    main()
l, r = map(int, input().split())

if (l-1)//2019 != r//2019:
	print(0)
else:
	print((l%2019)*((l+1)%2019))
l, r = map(int, input().split())
l %= 2019
r %= 2019
ans = float('inf')
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()))
ans = 0
if R-L+1 >= 2019:
    ans = 0
else:
    lis = []
    for i in range(L,R+1):
        lis.append(i%2019)
    s = sorted(lis)
    ans = min(s[0]*s[1],s[-1]*s[-2])
print(ans)
l,r=map(int,input().split())
X=[]
if r-l>=2019:
    print(0)
else:
    for i in range(l,r+1):
        X.append(i%2019)
    X.sort()
    print(min((X[0]*X[1])%2019,(X[-1]*X[-2])%2019))
#!/usr/bin/env python3

def main():
    l, r = map(int, input().split())
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            if i != j:
                ans = (i * j) % 2019
                if ans == 0:
                    break
    print(ans)


if __name__ == "__main__":
    main()
l,r = map(int,input().split())
minimum = 2019

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

else:
    for i in range(l,r):
        for j in range(i+1,r+1):
            i %= 2019
            j %= 2019
            answer = (i*j)%2019
            if answer<minimum:
                minimum = answer

print(minimum)
L,R = (int(x) for x in input().split())
if (R-L)//2019:
  R -= (R-L)//2019*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 = map(int, input().split())

if r - l >= 2018:
    print(0)
elif l%2019 >= r%2019:
    print(0)
else:
    print((l%2019 * (l%2019 +1))%2019)
L,R=map(int,input().split())

x=[]
for i in range(L,R+1):
   x.append(i%2019)

x=sorted(x)
print((x[0]*x[1])%2019)
l,r=map(int,input().split())
X=[]
if r-l>=2019:
    print(0)
else:
    for i in range(l,r+1):
        X.append(min(i%2019,2019-i%2019))
    X.sort()
    print(X[0]*X[1])
l, r = map(int, input().split())
if r - l >= 2018:
    print(1, 0)
else:
    ans = 2019
    for i in range(l, r):
        for j in range(i+1, r+1):
            ans = min(ans, i*j %2019)
    print(ans)
if __name__ == '__main__':
    l, r = map(int, input().split())
    tmp = []
    for i in range(l, min(r + 1, l + 4029)):
        tmp.append(i % 2019)
    tmp.sort()
    print(tmp[0] * tmp[1] % 2019)
L, R = map(int, input().split())

if(R//2019 == L//2019):
    print((L*(L+1))%2019)
else:
    print(0)
L,R =map(int,input().split())

mod=2019
ans=mod

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

min = 500000

for i in range(0,r-l):
    for j in range(i+1,r-l-i+1):
        if ((l+i)*(l+j))%2019 < min:
            min=((l+i)*(l+j))%2019

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

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

else:
    l %= 2019
    r %= 2019
    l,r = sorted([l,r])

    remainder1 = l
    remainder2 = l+1
    minimum = remainder1*remainder2%2019

    print(minimum)
import sys
readline = sys.stdin.readline

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

L %= 2019
R %= 2019

ans = 2019
for i in range(L, R):
  for j in range(i + 1, R + 1):
    if (i * j) % 2019 < ans:
      ans = (i * j) % 2019
      
print(ans)
a,b=map(int,input().split())
if b-a>=2019:
    print(0)
    exit()

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

print((a*(a+1)%2019))
mod = 2019
l,r = map(int,input().split())

cnt = 0
tank = []
for i in range(l,r+1):
    tank.append(i%mod)
    cnt += 1
    if cnt >= 2020:
        break

res = 2019

n = len(tank)
for i in range(n):
    for j in range(n):
        res = min(res,tank[i]*tank[j]%mod)
print(res)
l,r = map(int,input().split())

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

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

ans = (l*(l+1))%2019
print(ans)
l,r = map(int, input().split())
n = [2019]
while n[-1] < 2 * 10 **9:
  n.append(n[-1]*2)
for i in n:
  if l <= i <= r:
    print(0)
    exit()
print(min((l*(l+1))%2019, (r*(r-1))%2019))
l,r = map(int,input().split())

ans = 2019
if r - l > 2019:
    print("0")
else:
    for i in range(l,r):
        for j in range(i+1,r+1):
            temp = (i*j) % 2019
            if ans > temp:
                ans = temp

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

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

print(ans)
L, R = [int(s) for s in input().split(' ')]

i = L
j = R
ret = (L * R % 2019)
for x in range(2020):
    ii = L + x
    jj = L + x + 1
    if ii > R or jj > R:
        break
    ij = (ii * jj % 2019) 
    ret = min(ret, ij)
for x in range(2020):
    ii = R - x
    jj = R - x - 1
    if ii < L or jj < L:
        break
    ij = (ii * jj % 2019) 
    ret = min(ret, ij)

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

L = L % 2019
R = R % 2019
print (L*(L+1))
L,R = map(int,input().split())
ans = (L*R)%2019

for i in range(L+1,min(R,L+2020)):
    ans = min(ans,(L*i)%2019)
    
print(ans)
l,r=list(map(int,input().split()))
ans=[]
if r-l==1:print(r*l%2019)
else:
  for i in range(l,r-1):
    for j in range(l+1,r):
      ans.append(i*j%2019)
      print(min(ans))
L, R = map(int, input().split())
mod = 2019
ans = 10**9 + 7
for i in range(L, min(L + mod, R)):
  for j in range(i + 1, min(i + mod, R)):
    ans = min((i * j) % mod, ans)
print(ans)
l,r = [int(x) for x in input().split()]

mod = 2019
b = False
ans = 2020
for i in range(l, r):
    for j in range(i+1, r+1):
        if i*j%mod == 0 and b:
            break
        elif i*j%mod == 0:
            b = True
        else:
            ans = min(ans, i*j%mod)
print(ans)
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: 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())
lst = [i%2019 for i in range(L,R+1)]
lst = set(lst)
lst = list(lst)
N = len(lst)
ans = 10*8
for i in range(N-1):
    for j in range(i+1,N):
        if ans>(lst[i]*lst[j])%2019:
            ans = (lst[i]*lst[j])%2019
print(ans)
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())
mod = 2019
tmp = mod + 1
ans = ""
if R - L >= 2019:
    print(0)
else:
    for i in range(L,R):
        for j in range(i + 1, R + 1):
            if tmp >= i * j % mod:
                tmp = i * j % mod
                ans = str(i)+" "+str(j)
print(tmp)
L, R = [int(i) for i in input().split()]
print((L%2019) * (L%2019+1) if L%2019 < R%2019 else 0)
l,r = map(int, input().split())

if r-l > 2017:
    print(0)
else:
    d,e = map(lambda x: x%2019, (l,r))
    
    if d < e:
        print(d * (d+1))
    else:
        print(0)
l,r = map(int,input().split())

if 2018 <= r-l:
  ans = 0
elif r-l <= 2017:
  r_mod = r%2019
  l_mod = l%2019
  
  if l_mod < r_mod:
    ans = l_mod*(l_mod + 1)
  elif r_mod < l_mod:
    ans = 0
    
print(ans)
l, r = map(int, input().split())
lrmod = []
for i in range(l, r):
  for j in range(i + 1, r + 1):
    lr = (i % 2019) * (j % 2019)
    lrmod.append(lr)
print(min(lrmod))
L,R = map(int,input().split())

if (R//2019-L//2019)>0: 
  print(0)
  exit(0)
  
if (R//673-L//673)>0:
  print(0)
  exit(0)
  
ll, rr = L//2019, R//2019
for i in range(1, 2018):
  for j in range(ll,rr+1):
    l_, r_ = j*2019+i,j*2019+i+1
    print('%d %d'%(l_,r_))
    if L<=l_ and r_<=R:
      print(((j*2019+i)*(j*2019+i+1))%2019)
      exit(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

import numpy as np

L, R = map(int, input().split())
if (R - L) > 2020:
    print(0)
    exit()
else:
    k = np.arange(L, R + 1, dtype=np.int64)
    k = k % 2019
    k = sorted(k)
    print(k[0] * k[1])
ll, rr = map(int, input().split())
ans = 2020
l = ll % 2019
r = rr % 2019
if l > r:
    print(0)
else:
    print(l * (l+1))