peterverebics/CodeNet_Python_118 huggingface dataset:
from collections import defaultdict
from collections import deque
from collections import Counter
import itertools
import math

def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

l,r = readInts()

ans = float("inf")
for i in range(l,min(r+1,l+2020)):
  for j in range(i+1, min(r+1,l+2020)):
    ans = min(ans,(i*j)%2019)

print(ans)
l, r = map(int, input().split())
if r - l > 2030: print(0)
else:
    ans = 2018
    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 (L // 2019) != (R // 2019):
    print(0)
    exit()
else:
    ans = float('inf')
    for i in range(L, R + 1):
        for j in range(i + 1, R + 1):
            ans = min((i * j) % 2019, ans)
    print(ans)
L, R = map(int, input().split())
target = R+1
if R - L > 2019:
    target = L + 2019
mi = 2019
for i in range(L,target):
    for j in range(i+1,target):
        mi = min(mi,(i*j)%2019)
print(mi)
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 = [int(i) for i in input().split()]

c = set()

for i in range(L, R + 1):
  t = i % 2019
  if t in c:
    break
  c.add(t)


m = float('inf')
l = list(c)
for i in range(len(l)):
  for j in range(i + 1, len(l)):
    m = min(m, l[i] * l[j] % 2019)

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

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

ans = mod
for a in range(l, r):
    for b in range(a+1, r+1):
        if (a * b) % mod < ans:
            ans = (a * b) % mod
print(ans)
L,R = map(int,input().split())

ans = 2018

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

print(ans)
L, R = map(int, input().split())
R = min(R, L+4038)
ans = 2018
for i in range(L, R):
    for j in range(L+1, R+1):
        ans = min((i*j) % 2019, ans)
print(ans)
L, R = map(int, input().split())

L_q = L // 2019
R_q = R // 2019
mod = 2018

if L_q + R_q == 0:
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            mod = min(i * j % 2019, mod)

    print(mod)

else:
    if R_q - L_q > 1:
        print(0)

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

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

s = list(map(int, range(L, min(L+2019, R+1))))
if 2019 in s:
    print(0)
    exit()

for i in s:
    for j in s[s.index(i)+1:]:
        ans = min(ans, i*j%2019)

print(ans)
def main():
    L, R = (int(i) for i in input().split())
    if R - L >= 2018:
        return print(0)
    MOD = 2019
    ans = 2019
    for i in range(L, R):
        for j in range(i+1, R+1):
            ans = min(ans, (i*j) % MOD)
    print(ans)


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

if R - L >= 2018:
    print("0")
else:
    ans = 2020
    for i in range(L, R+1):
        for j in range(i+1, R+1):
            t = ((i%m) * (j%m)) % m
            ans = min(ans, t)
    print(ans)
l,r=map(int, input().split())
mo=2019
ans=2018
r=min(r, l+mo-1)
#max in k~k+2019 line seg. i<k+2019 and k<j
for i in range(l,r):
    for j in range(i+1,r+1):
        tmp=i*j
        ans=min(ans,tmp%mo)
print(ans)
L, R = map(int, input().split())

ind_s = L
ind_e = min(L + 2019, R)

choices_mod = [x%2019 for x in range(ind_s, ind_e+1)]

if len(choices_mod) == 1:
    print(choices_mod[0])
elif 0 in choices_mod:
    print(0)
else:
    import itertools
    pairs = list(itertools.combinations(choices_mod, 2))
    
    ans_list = []
    for a, b in pairs:
        ans_list.append((a*b)%2019)
        
    print(min(ans_list))
L,R = map(int,input().split())
result = 2018
if R - L >= 2019:
    result = 0
else:
    for i in range(L,R):
        for j in range(L+1,R+1):
            result = min(result,i*j%2019)
print(result)
l, r = map(int, input().split())
ans = 2019

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

print(ans)
def abc133_c():
  L,R = map(int,input().split())
  if R - L > 673: return 0
  ans = 2019
  for i in range(L, R):
    for j in range(i+1, R+1):
      ans = min(ans, i*j%2019)
      if ans == 1: return 1
  return ans

print(abc133_c())
def main():
    l, r = map(int, input().split())
    if l + 2019 <= r:
        print(0)
    else:
        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)


if __name__ == '__main__':
    main()
l,r = map(int,input().split())
if r - l >= 2019:
    print(0)
else:
    ans_o = (l*(l+1))%2019
    for i in range(l,r):
        for j in range(i+1,r+1):
            ans = (i*j)%2019
            ans_o = min(ans,ans_o)
    print(ans_o)
L, R = map(int, input().split())
ans = []
if R - L >= 2019:
  print(0)
else:
  for i in range(L, R+1):
    for j in range(i+1, R+1):
      ans.append(i*j%2019)
  print(min(ans))
MOD = 2019
L,R=map(int,input().split())
l = L % MOD
r = R % MOD

ans = 2019**2
if R - L >=2019:
   ans =0
elif l < r :
    for i in range(l,r+1):
        for j in range(i+1,r+1):
             ans = min(ans,i*j%MOD)
else :
    ans =0
print(ans)
L,R=map(int,input().split())
ans=2018
if R-L>=2019**2:
    R=L+2019**2
for i in range(L,R):
    for j in range(i+1,R+1):
        ans=min(ans,(i*j)%2019)
        if ans==0:
            break
print(ans)
#ABC133 C

L,R = map(int,input().split())
A = []
if R - L > 2019:
    print(0)
elif 2 <= R - L and R - L <= 2019:
    for i in range(L,R):
        for j in range(i+1,R+1):
            A.append((i*j)%2019)
    print(min(A))
elif R - L == 1:
    print((R*L)%2019)
l,r = map(int,input().split())
c=2019
for i in range(l,r+1):
  if i%2019==0:
    print(0)
    break
else:
  for j in range(l,r+1):
    for k in range(j+1,r+1):
      if c>(j*k%2019):
        c=(j*k%2019)
  print(c)
from sys import exit
l,r=map(int,input().split())
res=1000000000000
if r-l>2020:
	print("0")
	exit()
else:
	for i in range(l%2019,r%2019):
		for j in range(i+1,r%2019+1):
			res=min(res,(i*j)%2019)
print(res)
L, R = map(int, input().split())

ans = 2019
for a in range(L, min(L+2019, R)+1):
    for b in range(L, min(L+2019, R)+1):
        if a == b:
            continue
        ans = min(a*b%2019, ans)
        if ans == 0:
            print(0)
            exit()
print(ans)
L,R=[int(x) for x in input().split()]
R=min(R,L+2018)
numbers=[x%2019 for x in range(L,R+1)]
length=len(numbers)
minimum=[]
for i in range(length):
	for j in range(i+1,length):
		minimum.append((numbers[i]*numbers[j])%2019)
print(min(minimum))
from itertools import combinations
l, r = map(int,input().split())
if r-l >= 2019:
    print(0)
else:
    min_n = float('inf')
    for i, j in combinations([k for k in range(l, r+1)], 2):
        min_n = min(min_n, (i*j)%2019)
    print(min_n)
L, R = map(int, input().split())
mod = 2019
ans = 2019
for i in range(L,R+1) :
    for j in range(i+1,R+1) :
        temp = (i*j)%mod
        ans = min(ans, temp)
        if ans == 0 :
            print(0)
            exit()

print(ans)
l,r=map(int,input().split())
ans=l*r
if l//2019!=r//2019:
    ans=0
elif l%2019==0 or r%2019==0:
    ans=0
else:
    num1=l%2019
    num2=r%2019
    for i in range(num1,num2):
        for j in range(i+1,num2+1):
            num=(i*j)%2019
            if ans>num:
                ans=num
print(ans)
L, R = map(int, input().split())
a = 2020

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

if l + 2019 <= r:
  print(0)
else:
  res = []
  for i in range(l, r+1):
     for j in range(i+1, r+1):
        res.append((i*j)%2019)
  print(min(res))
import sys
L,R = map(int,input().split())
i = L
j = i+1
p =2019
min_ij = ((i%p)*(j%p))%p
for i in range(L,R):
  for j in range(i+1,R+1):
    if i % p == 0 or j %p == 0:
      print(0)
      sys.exit()
    if min_ij > ((i%p)*(j%p))%p:
      min_ij = ((i%p)*(j%p))%p

print(min_ij)
l,r=map(int,input().split())
q=l//2019
l-=q*2019
r-=q*2019
ans=2018
if r>=2019:
  exit(print(0))
for i in range(l,r):
  for j in range(i+1,r+1):
    ans=min(ans,(i*j)%2019)
print(ans)
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 (R - L) > 3000:
    print(0)
    exit()
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)
def f(l,r):
    p=2019
    for i in range(l,r+1):
        for j in range(l,r+1):
            if i==j:
                continue
            p=min((i*j)%2019,p)
    return p
    
l,r=map(int,input().split())
print(0 if r//2019-(l-1)//2019!=0 else f(l,r))
l,r = map(int,input().split())
ans = 2019
for i in range(l,min(l+2019,r)):
    for j in range(l+1,min(l+2019,r+1)):
        ans = min(ans,i*j%2019)
print(ans)
l, r = map(int, input().split())

if r - l >= 2019:
    ans = 0
else:
    ans = 2019
    flag = False
    for i in range(l, r):
        for j in range(i+1, r+1):
            m = (i * j) % 2019
            ans = min(ans, m)
            if ans == 0:
                flag = True
                break
        if flag:
            break

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

ans = float("inf")

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

ans = 2018**2
if R-L >= 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)
l, r = map(int, input().split())
if r-l >=2020:
    print(0)
    exit()
ans = 2018
for i in range(l, r+1):
    for j in range(l, r+1):
        if i != j:
            a = i*j%2019
            ans = min(ans, a)
print(ans)
l,r=map(int,input().split())
if r-l>=2019:
    print(0)
    exit()
ans=2020
for i in range(l,r+1):
    for j in range(i+1,r+1):
        ans=min((i*j)%2019,ans)
print(ans)
l,r = 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*j%2019)
    print(ans)
l, r = map(int, input().split())
ans = 2017*2018
for i in range(l,r):
  for j in range(i+1,r+1):
    ans = min(ans, i*j%2019)
    if ans == 0:
      print(ans)
      exit()
print(ans)
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    L, R = map(int, input().split())
    mod = 2019

    min_mod = float("inf")

    for i in range(L, min(R, L + mod)):
        for j in range(i + 1, min(R + 1, i + 1 + mod)):
            curr_mod = i * j % mod
            min_mod = min(min_mod, curr_mod)
            if min_mod == 0:
                break

    print(min_mod)


if __name__ == "__main__":
    main()
l,r=list(map(int,input().split()))
s=[]
import sys

if r-l>2050:
  print(0)
  sys.exit()
else:
  for i in range(l,r+1):
    s.append(i%2019)

n=len(s)
ans=30000
for i in range(n-1):
  for j in range(i+1,n):
    ans=min(ans,(s[i]*s[j])%2019)


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

if R-L >= 2018:
  print(0)
else:
  ans = 2018
  for i in range(L,R+1):
    for j in range(i+1,R+1):
      if ans >= (i*j)%2019:
        ans = (i*j)%2019
  print(ans)
L, R= (int(x) for x in input().split())
m = 2019
if (R-L)//2019 >= 1:
  print(0)
else:
  for i in range(L,R+1):
    for j in range(i+1,R+1):
      if (i*j)%2019 <= m:
        m = (i*j)%2019
  print(m)
l, r = map(int, input().split())
mod = 2019
_min = mod
for i in range(l, min(l + mod, r)):
  i_mod = i % mod
  for j in range(i + 1, min(i + mod, r) + 1):
    _min = min(_min, j % mod * i_mod % mod)
print(_min)
L, R = map(int,input().split())
if R-L+1 >= 2019:
	print(0)
else:
	print(min([(i*j)%2019 for i in range(L,R+1) for j in range(i+1,R+1)]))
L,R=map(int,input().split())
if R-L>2018:
    print(0)
else:
    res=2020
    L%=2019
    R%=2019
    for i in range(L,R):
        for j in range(i+1,R+1):
            res=min(res,i*j%2019)
    print(res)
l,r = map(int,input().split())
minimum = 2019
for i in range(l,r+1):
  if minimum == 0:
    break
  for j in range(i+1,r+1):
    if (i*j)%2019 == 0:
      minimum = 0
      break
    else:
      if (i*j)%2019 < minimum:
        minimum = (i*j)%2019
print(minimum)
M=2019;L,R=map(int,input().split())
l,r=L%M,R%M;s=range(l,r+1)
print(0 if R//M-L//M>0 else min(i*j%M for i in s for j in s if i<j))
L,R = map(int,input().split())
if R-L > 673 or (L%2019) > (R%2019):
  print(0)
else:
  l = L%2019
  r = R%2019
  c = 2018
  w = set()
  for i in range(l,r):
    for j in range(i+1,r+1):
      t = (i*j)%2019
      if c > t:
        c = t
  print(c)
L, R = map(int, input().split())
a = 2020

for i in range(L,R+1):
    for j in range(i+1,R+1):
        ans = i*j%2019
        if(a > ans):
            a = ans
        if ans == 0:
            print(a)
            exit(0)
print(a)
l,r=map(int,input().split())
s=10000
for i in range(l,r+1):
    if i%2019==0:
        s=0
        break
    elif (i%673==0 and r-l!=1) or (i%673==0 and (r%3==0 or l%3==0)):
        s=0
        break
if s==0:
    print(0)
else:
    t=10000
    for i in range(l,r):
        for j in range(i+1,r+1):
            if ((i%2019)*(j%2019))%2019<t:
                t=((i%2019)*(j%2019))%2019
    print(t)
l, r = map(int, input().split())
r = min(r, l + 4038)
ans = 2018
for i in range(l, r):
  for j in range(i + 1, r + 1):
    ans = min((i * j) % 2019, ans)
    #割り切れた場合はそれが最小値なので探索終了とする
    if ans == 0:
      break

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

ans = 2018
for i in range(L, R):
    for j in range(i+1, R + 1):
        tmp = (i * j) % 2019
        if ans  > tmp:
            ans = tmp
        if tmp == 0:
            ans = 0
            print(ans)
            exit()

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

if R - L + 1 >= 2019:
    print(0)
else:
    res = 2018
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            res = min(res, (i * j) % 2019)
    print(res)
L,R=map(int,input().split())
left=L%2019
right=R%2019
print(0 if R-L>=2019 else min([i*j%2019 for i in range(left,right+1) for j in range(i+1,right+1)]))
L, R = map(int, input().split())
MOD = 2019
ans = MOD
R = min(R, L + MOD)
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())

if R - L > 2020:
  print(0)
else:
  answer = []
  for i in range(L, R + 1):
    for j in range(i + 1, R + 1):
      answer.append((i * j) % 2019)
  
  print(min(answer))
L, R = map(int,input().split())
if R-L >= 2018:
    ans = 0
elif L%2019 > R%2019:
    ans = 0
else:
    ans = 2018
    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
ij_mod_min = 2019  # 解答の初期値を2019に設定
for i in range(L, R):  # 二重のforで全探索
    for j in range(i+1, R+1):
        ij_mod = (i*j) % mod
        if ij_mod_min > ij_mod:
            ij_mod_min = ij_mod
        if ij_mod_min == 0:  # もし解が0になったら探索をやめる
            break
    else:
        continue
    break
print(ij_mod_min)
l,r=map(int,input().split())
if r-l>=2019:
    minimum=0
else:
    left,right=l%2019,r%2019
    minimum=2018**2
    for i in range(left,right+1):
        for j in range(i+1,right+1):
            minimum=min(minimum,i*j%2019)
print(minimum)
L,R=map(int,input().split())
M=2019
l,r,a=L%M,R%M,M
if l<r and R-L<672:
  for i in range(l,r):
    for j in range(i+1,r+1):
      a=min(a,i*j%M)
      if a<2: break
    if a<2: break
else: a=0
print(a)
l,r = 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*j) % 2019)
    print(ans)
l, r = [int(i) for i in input().split()]
if r - l >= 2018:
    print(0)
    exit()

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

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

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


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

MOD = 2019

a = 0

if r - l >= MOD:
    a = 0

else:
    x = l % MOD
    y = r % MOD
    if x > y:
        a = 0
    else:
        a = 2018
        for i in range(x, y):
            for j in range(i+1, y+1):
                a = min(a, i * j % MOD)

print(a)
import math

def main():
    l,r=map(int,input().split())
    m = 2020
    for i in range(l, r):
        for j in range(i+1, r+1):
            n = (i*j) % 2019
            m = min(m, n)
            if m == 0:
                print(m)
                return
    print(m)
    
if __name__ == "__main__":
    main()
l, r = map(int, input().split())
ans = 10000000000
if r - l >= 2019:
    print(0)
    exit()
for i in range(l, min(r, l+2019)):
    for j in range(i+1, min(r,l+2019)+1):
        ans = min(ans, i*j%2019)
print(ans)
L,R=map(int,input().split())
if L//2019 != R//2019:
    print(0)
elif L%2019==0:
    print(0)
else:
    ans=float("inf")
    for i in range(L,R):
        for j in range(L+1,R+1):
            ans=min(ans,i*j%2019)
    print(ans)
L,R = map(int,input().split())
ans = float("inf")

for i in range(L,min(R,L+2019)):
    for j in range(i+1,min(R,L+2019)+1):
        ans = min(ans,(i*j)%2019)
    
print(ans)
l, r = map(int, input().split())
ans = 2018**2
ll = min(l+2019, r)+1
for i in range(l, ll):
    for j in range(i+1, ll):
        ans = min(ans, i*j%2019)
        if ans == 0:
            break
print(ans)
L, R = list(map(int, input().split()))
ans = 2020
if abs(L-R)>=2020:
    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())

if r - l >= 2019:
    pass
    print(0)
    exit()
ans = 2020
for i in range(l, r):
    for j in range(l+1, r+1):
        if ans > i * j % 2019:
            ans = i * j % 2019
print(ans)
import sys

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

x=int(r/2019)

if l<=(2019*x) and (2019*x)<=r:
  print("0")
  sys.exit()

m=-1

for i in range(l,r):
  for j in range(i+1,r+1):

    a=(i*j)%2019
    if a==0:
      #print("here")
      print(a)
      sys.exit()

    elif m==-1 or m>a:
      #print(i,j,(i*j)%2019)
      m=a

print(m)
l, r = map(int, input().split())
d = [0]*2019
ans = 2019

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

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

MIN = 2018
if R-L > 4039:
    MIN = 0


MOD = 2019
L = L%MOD
R = R%MOD
if L > R:
    L, R = R, L
elif 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())
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*j) % 2019)
	print(ans)
l,r = map(int,input().split())
if r-l >= 2019:
    print(0)
    exit()
ans = 2020
for i in range(l,r):
    for j in range(i+1,r+1):
        t =(i*j)%2019
        ans=min(ans,t)
print(ans)
l, r = map(int, input().split())
ans = 2019

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

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

LENGTH = (R-L+1) / MOD
if LENGTH < 1:
    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)
else:
    print(0)
L,R = [int(i) for i in input().split()]
if R - L > 2019:
    print(0)
    exit()
else:
    li = list(range(L,R+1))
    n = len(li)
ans = 10**9+7
for i in range(n-1):
    for j in range(i+1,n):
        count = (li[i]*li[j]) % 2019
        ans = min(ans,count)
        if ans == 0:
            print(0)
            exit()
print(ans)
l, r = map(int,input().split())

ans = 2019
flag = False
for i in range(l,r+1):
    for j in range(i+1,r+1):
        ans = min(ans,(i*j)%2019)
        #print(i,j)
        if ans == 0:
            flag = True
            break
    if flag:
        break
print(ans)
l,r = list(map(int, input().split()))

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

ans = float("inf")
for i in range(l1,r1):
    for j in range(i+1, r1+1):
        ans = min(ans, ((i*j)%2019))

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

if 2018<=r-l:
  print(0)
  sys.exit()

L=l%2019
R=r%2019
m=2018

if L>R:
  print(0)
  sys.exit()

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

print(m)
def min2(x,y):
    return x if x < y else y

from itertools import combinations
MOD = 2019
L, R = map(int, input().split())
data = [L%MOD]
for i in range(L+1, R+1):
    if data[0] ==i%MOD:
        break
    data.append(i%MOD)
res = float("inf")
for x, y in combinations(data, 2):
    res = min2((x*y)%MOD,res)
print(res)
L, R = map(int, input().split())
if R - L >= 2019:
    print(0)
else:
    min = 2018
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            r = (i * j) % 2019 
            if r < min:
                min = r
    print(min)
l,r=map(int,input().split())

r=min(r,l+2020)
min=100000000000000000000000
for i in range(l,r+1):
    for j in range(i+1,r+1):
        mod = (i*j)%2019
        if mod<min:
            min = mod
print(min)
L, R = map(int, input().split())
if R - L >= 2019:
    print(0)
else:
    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)
def readinput():
    l,r=map(int,input().split())
    return l,r

def main(l,r):
    ans=2018
    for i in range(l,min(l+2019,r+1)):
        for j in range(i+1,min(l+2019,r+1)):
            ans=min( ((i%2019) * (j%2019))%2019, ans )
    return ans

if __name__=='__main__':
    l,r=readinput()
    ans=main(l,r)
    print(ans)
L, R = map(int, input().split())
mod = 2019
ans = 10**9
for i in range(L, min(R+1, L+2030)):
    for j in range(i+1, min(R+1, L+2030)):
        ans = min(ans, (i*j)%mod)
print(ans)