peterverebics/CodeNet_Python_118 huggingface dataset:
l,r=map(int,input().split())
for i in range(l,r+1):
  if i%2019==0:
    print(0)
    break
else:
  mini=2018
  for i in range(l,r):
    for j in range(i+1,r+1):
      if (i*j)%2019<=mini:
        mini=(i*j)%2019
  print(mini)
import itertools
l,r = map(int,input().split())
if r-l >= 2019:
    print(0)
    exit()
w = []
q = list(itertools.combinations(range(l,r+1),2))
for i in range(len(q)):
    w.append((q[i][0]*q[i][1])%2019)

print(min(w))
[L,R] = list(map(int,input().split()))

flag=0
for i in range(L,R+1):
    if i%2019 == 0:
        flag=1
        break

LL = L%2019
RR = R%2019
dammy=[]
for i in range(LL,RR):
    for j in range(i+1,RR+1):
        dammy.append((i*j)%2019)

if flag==0:
    print(min(dammy))
else:
    print(0)
l,r = map(int,input().split())
li = []
r = min(r,l+4040)
for i in range(l,r):
    for j in range(i+1,r+1):
        li.append(i*j%2019)
print(min(li))
l,r = map(int, input().split())

t = []

if r-l >= 2019:
    print(0)
else:
    for i in range(l,r):
        for j in range(l+1,r+1):
            t.append((i*j)%2019)
    print(min(t))
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(l+1, r+1):
            ans = min(ans, (i*j)%2019)

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

mini = (L * R) % 2019

if R - L >= 2019:
    print(0)
    exit()

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



print(mini)
def solve():
    L, R = map(int, input().split())
    ans = 10 ** 10
    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)
    return ans

print(solve())
import sys
input = sys.stdin.readline

l, r = map(int, input().split())
if r - l > 2019:
    ans = 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)
l,r = map(int,input().split())

ans = 2018
if r - l >= 2019:
    ans = 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())

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

res = 10 ** 100
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 = (int(_) for _ in input().split())
r = min(r,l+2019)
x = [i*ii%2019 for i in range(l,r+1) for ii in range(i+1,r+1)]
print(min(x))
L, R = map(int,input().split())
Dif = abs(L-R)+1
if Dif >= 2020:
    Ans = 0
else:
    Box = []
    for i in range(L,R+1):
        Box.append(i%2019)
    Box.sort()
    Ans = 2020*2020
    for i in range(len(Box)-1):
        B1 = Box[i]
        for j in range(i+1,len(Box)):
            B2 = Box[j]
            Ans = min((B1*B2)%2019, Ans)
print(Ans%2019)
L,R = map(int,input().split())
ls = list(range(L,min(L+2019, R+1)))
ans = 2019
for i in range(len(ls)):
    for j in range(i+1,len(ls)):
        ans = min(ans, (ls[i]*ls[j]) % 2019)
print(ans)
l,r = map(int,input().split())
if r-l >= 673:
    print(0)
else:
    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())
R=min(L+2019,R)
m=3000
for x1 in range(L,R):
    for x2 in range(x1+1,R+1):
        if m>(x1*x2)%2019:m=(x1*x2)%2019
print(m)
l, r = map(int, input().split())

if r//2019 != l//2019:
    print(0)

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

# In[27]:


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


# In[30]:


MOD = 2019
res = MOD
if R - L < MOD:
    for l in range(L, R):
        for r in range(l+1, R+1):
            res = min(res, (l * r) % MOD)
else:
    res = 0
print(res)
L, R = map(int, input().split())
ml = L // 2019
mr = R // 2019

for i in range(ml, mr+1):
  if L <= 2019 * i <= R:
    print(0)
    exit()

L %= 2019
R %= 2019
ans = float('inf')
if L > R:
  L, R = R, L
elif L == R:
  R += 2019
if L == 0 or R == 0:
  print(0)
  exit()

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

print(ans)
import heapq
l,r = map(int,input().split())
mod = 2019
ans = 2018
if r-l>=2018:
    print(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())

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

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

a = 0
ans = 10 ** 9
r = min((L + 2018), R)

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

MOD = 2019

res = []
for i in range(L, min(L+MOD, R+1)):
    for j in range(i+1, min(L+MOD, R+1)):
        res.append((i*j) % MOD)
print(min(res))
L,R = list(map(int,input().split()))
if R-L+1 >= 2019:
    ans = 0
else:
    ans = 2019
    lis = [i%2019 for i in range(L,R+1)]
    for i in range(R-L):
        for j in range(i+1,R-L+1):
            s = (lis[i]*lis[j])%2019
            ans = min(s,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())
if R-L >= 2019:
    print(0)
else:
    mR = R%2019
    mL = L%2019
    if mL > mR:
        print(0)
    else:
        mini = 2019
        for i in range(mL, mR):
            for j in range(i+1, mR+1):
                mini = min(mini, (i*j)%2019)
        print(mini)
# -*- coding: utf-8 -*-
"""
Created on Tue May 12 13:43:11 2020

@author: shinba
"""
import sys 
import itertools

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

if l % 2019 == 0:
    print(0)
    sys.exit()
else:
    if l//2019 +1 <= r/2019:
        print(0)
        sys.exit()

l %= 2019
r %= 2019
ans = float("inf")

for i in itertools.combinations(range(l,r+1),2):
    mod = (i[0]*i[1])%2019
    ans = min(mod,ans)
    
print(ans)
L,R = map(int,input().split())
if R-L+1 >= 2019:
    print(0)
    exit()
R %= 2019
L %= 2019
if R <= L:
    print(0)
    exit()
ans = 2020
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())
ama=[]
for i in  range(L,R+1):
    amari = i%2019
    if amari ==0:
        print(amari)
        exit()
minimi = 2019
for j in range(L,R+1):
    for s in range(j+1,R+1):
        waka = (j*s)%2019
        minimi = min(minimi,waka)
print(minimi)
L, R = map(int, input().split())

ans = 10 ** 9
for i in range(L, R):
    for j in range(i+1, R+1):
        tmp = (i*j)%2019
        if ans > tmp:
            ans = tmp
        if ans == 0:
            break
    else:
        continue
    break
print(ans)
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')

    if R - L >= 2019:
        print(0)
        exit()

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

    print(ret)


if __name__ == '__main__':
    main()
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()
if (a[0]==0):
    print(0)
    exit()
b = []
for i in range (0,len(a)-1):
    for j in range (1,len(a)):
        b.append((a[i]*a[j])%2019)
print(min(b))
L,R = map(int,input().split())
ans = 4000

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

mod = 2019

ans = 2222

if (r - l) // mod > 0:
	ans = 0

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

print(ans)
L, R = map(int, input().split())
# R-L>=2019なら、[L,R]に2019の倍数が必ず存在する
if R - L >= 2019:
    print(0)
else:
    ans = 10**9
    for i in range(L, R + 1):  # L<=i<=R
        for j in range(i + 1, R + 1):  # i<j<=R
            ans = min(ans, (i * j) % 2019)
    print(ans)
L, R = map(int, input().split())
if R - L >= 2018:
	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())
dl = l % 2019
dr = r % 2019
lis = []
if r - l >= 2019 - dl or dl == 0:
    print(0)
else:
    for i in range(dl,dr):
        for j in range(i+1,dr+1):
            lis.append((i*j)%2019)
    print(min(lis))
l,r=map(int, input().split())

k=0

can=[]
while l+k<=r and k<2020:
    can.append((l+k)%2019)
    k+=1
ans=2020
import itertools

for seq in itertools.combinations(range(len(can)),2):
    ans=min(ans,(can[seq[0]]*can[seq[1]])%2019)
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+1):
        for j in range(i+1,R+1):
            ans = min(ans,(i*j)%2019)

print(ans)
def main():
    l, r = map(int, input().split())
    minv = 2019
    if r - l > 2019+1:
        print(0)
    else:
        for i in range(l, r+1):
            for j in range(l, r+1):
                if i < j:
                    minv = min(minv, (i*j)%2019)
        print(minv)

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

res = 10**9
for i in range(n, m):
    for j in range(i+1, m+1):
        res = min(res, (i*j % 2019))
        if res == 0:
            print(0)
            exit()
print(res)
L, R = map(int, input().split())
# R-L>=2019なら、[L,R]に2019の倍数が必ず存在する
# すなわちiやjが2019の倍数をとりうる
if R - L >= 2019:
    print(0)
else:
    ans = 2019
    for i in range(L, R + 1):  # L<=i<=R
        for j in range(i + 1, R + 1):  # i<j<=R
            ans = min(ans, i * j % 2019)
    print(ans)
l,r = map(int,input().split())
if r-l >= 2019:
    print(0)
else:
    r1 = r % 2019
    l1 = l % 2019
    if l1 > r1:
        print(0)
    else:
        ans = 2019
        for i in range(l1, r1):
            for j in range(i + 1, r1 + 1):
                ans = min(ans, (i*j) % 2019)
        print(ans)
L,R=map(int,input().split())
mod=2019
ans=2018
if R-L>=mod:
    print(0)
else:
    R%=mod
    L%=mod
    if R<=L:
        R+=mod
    for i in range(L+1,R+1):
        for j in range(L,i):
            ans=min(ans,i*j%mod)
    print(ans)
l,r = map(int,input().split())
m = r-l

if m >= 2019:
  print(0)
else:
  cnt = []
  for i in range(l,r):
    for j in range(l+1,r+1):
      cnt.append(i*j%2019)
  print(min(cnt))
L, R = map(int, input().split())
M = (L+2019-1)//2019*2019

if M<=R:
    print(0)
    exit()

ans = 10**18

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())

reg = 2018
if R-L >= 3000:
    print(0)
else:
    for l in range(L, R):
        for r in range(l+1, R+1):
            tmp = (l * r) % 2019
            reg = min(reg, tmp)
    print(reg)
L,R = map(int,input().split())
if(R-L >= 2019):
    print(0)
else:
    mL = L%2019
    mR = R%2019
    modmin = 2019
    for i in range(mL,mR):
        for j in range(i+1,mR+1):
            modmin = min(modmin,i*j%2019)
    print(modmin)
a,b = map(int,input().split())
min_mod = 2018

if b-a > 2019:
	min_mod=0

else:	
	for aa in range(a,b):
	   for bb in range(aa+1,b+1):
	       if aa < bb:
	           cc=aa*bb
	 
	           if min_mod > cc%2019:
	               min_mod = cc%2019

print(min_mod)
L, R = map(int, input().split())
mod = 2019

if R - L >= 2019 or L == 0:
    print(0)
else:
    ans = False
    for i in range(R - L):
        for j in range(i + 1, R - L + 1):
            if ans is not False:
                ans = min(ans, (L + i) * (L + j) % mod)
            else:
                ans = (L + i) * (L + j) % mod
    print(ans)
L,R=map(int,input().split())
ans=0
if R-L<2019:
    ans=min([i*j%2019 for i in range(L,R) for j in range(i+1,R+1)])
print(ans)
L,R = list(map(int,input().split()))

ans = 10**9
if R-L >= 2020:
    for i in range(L,L+2019):
        for j in range(L+1,L+2020):
            ans = min(ans,(i*j)%2019)
else:
    for i in range(L,R):
        for j in range(L+1,R+1):
            ans = min(ans,(i*j)%2019)

print(ans)
def main():
    l, r = map(int, input().split())
    ans = 2019
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            ans = min(ans, i * j % 2019)
            if ans == 0:
                break
        if ans == 0:
            break
    print(ans)
 
 
if __name__ == "__main__":
    main()
import sys
 
l, r = map(int, input().split())
ans = 10 ** 10
for i in range(l, r):
  for j in range(i+1, r+1):
    if (i * j) % 2019 == 0:
      print(0)
      sys.exit()
    ans = min(ans, (i*j) % 2019)
print(ans)
lr=list(map(int,input().split()))
mod=2019
ans=mod**2
if lr[0]%mod<=lr[1]%mod and lr[1]-lr[0]<mod:
    for i in range(lr[0],lr[1]+1):
        for j in range(i+1,lr[1]+1):
            if i*j%mod<ans:
                ans=i*j%mod
else:
    ans=0
print(ans)
L,R=map(int,input().split())
k = 0
l = 2020
m = 2020
apList = [0]*2019
for i in range(L,R+1):
  k = i % 2019
  if apList[k] != 0:
    break
  else:
    apList[k] += 1
res = 2018
for i in range(2019):
  for j in range(i+1,2019):
    if apList[i] != 0 and apList[j] !=0:
      res = min(i*j %2019,res)
print(res)
l, r = map(int,input().split())
if  r - l >= 2019:
    print(0)
else:
    ans = 2019
    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())
mod = 2019
ans = 1001001001
for i in range(l, min(r+1, l+2020)):
    for j in range(i+1, min(r+1, i+1+2020)):
        ans = min(ans , i*j%mod)
print(ans)
# 初期入力
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
xx=[]
if 2018 <= R -L:
    ans =0
elif mod_R < mod_L:
    ans =0
elif mod_L==0 :
    ans =0
else:
    for i in range(L,R):
        for j in range(i+1,R+1):
            x =i*j %2019
            xx.append(x)
    ans =min(xx)
print(ans)
l, r = map(int, input().split())
if r-l+1 >= 2019:
    print(0)
else:
    l %= 2019
    r %= 2019
    if l <= r:
        ans = float('inf')
        for i in range(l, r):
            for j in range(i+1, r+1):
                ans = min(ans, (i*j)%2019)
    else:
        ans = 0
    print(ans)
L, R = map(int,input().split())

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

    x.append(i % 2019)

ans = 9999
for i in range(len(x)):
    for j in range(i+1,len(x)):
        ans = min(ans, x[i] * x[j] %2019)

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

if r//2019>l//2019: print(0)
else:
    r%=2019
    l%=2019
    ans=2019
    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())

if R - L >= 2019:
    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())

ans = 2020
for i in range(L, R + 1):
    for j in range(i + 1, R + 1):
        val = (i * j) % 2019
        ans = min(ans, val)
        if val == 0:
            print(ans)
            exit()

print(ans)
import sys
 
L, R = map(int, input().split())
 
if R-L >= 2019:
  print('0')
  sys.exit()
 
L = L % 2019
R = R % 2019
if L > R:
  print('0')
 
mmin = 2019
for i in range(L, R):
  for j in range(i+1, R+1):
    mmin = min(mmin, (i*j)%2019)
print(mmin)
import sys
import itertools as it
L, R = map(int, input().split())
if R-L > 2017: print(0); sys.exit()

DL = L % 2019
DR = R % 2019
if DL > DR: print(0); sys.exit()

print(min(x*y%2019 for x,y in it.combinations(range(DL, DR+1), 2)))
l,r = map(int,input().split())

ans = 2018
for i in range(l,l+2019):
    for j in range(i+1,min(r+1,i+2019)):
        ans = min(ans,(i*j)%2019)
print(ans)
import bisect,copy,heapq,itertools,string
from collections import *
from math import *
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

l,r = MAP()
if(l%2019>=r%2019) or (r-l>=2018):
  print(0)
  exit()
else:
  l %= 2019
  r %= 2019

ans = 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 = map(int, input().split())

ans = 2018**2
for i in range(l, min(r, l+2019)):
    v = i % 2019
    for j in range(l+1, min(r+1, l+2020)):
        w = j % 2019
        ans = min(ans, (v*w)%2019)
print(ans)
l,r = map(int, input().split())
m = 2019
for i in range(l,min(r+1,l+2020)):
    for j in range(i+1, min(r+1,l+2020)):
        i %= 2019
        j %= 2019
        m = min(m, (i*j)%2019)
print(m%2019)
l, r = map(int, input().split())
x = l % 2019
y = r % 2019
if x > y:
    y += 2019
ans = 10 ** 7
for i in range(x, y + 1):
    for j in range(x, y + 1):
        if ans > (i * j) % 2019 and i != j:
            ans = (i * j) % 2019
if l + 2019 < r:
    ans = 0
print(ans)
i, j = map(int, input().split())
MOD = 2019
ans = float("inf")
for x in range(i, min(j+1, i+MOD)):
    for y in range(x+1, min(j+1, i+MOD)):
        ans = min(ans, x%MOD * y%MOD)
print(ans)
l, r = [int(i) for i in input().split()]
ans = 2019
for i in range(l, r+1):
    if ans == 0:
        break
    for j in range(i+1, r+1):
        ans = min(ans, (i*j) % 2019)
        if ans == 0:
            break
print(ans)
L, R = map(int, input().split())

num = 0
ans = (L * (L + 1)) % 2019
if (R - L) > 2020:
    ans = 0
else:
    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)
L,R=map(int,input().split())
if R-L>=2019:
    ans=0
else:
    ans=2018
    for i in range(L,R):
        for t in range(i+1,R+1):
            Z=(i*t)%2019
            ans=min(Z,ans)
print(ans)
L,R=map(int,input().split())
ans=[]
for i in range(L,R):
    for j in range(i+1,R+1):
        ans.append(i*j%2019)
        if (i*j)%2019==0:
            print((i*j)%2019)
            exit()
print(min(ans))
def main():
    L,R = [int(x) for x in input().split()]
    ans = 2019
    for i in range(L,min(R,L+2018)+1):
        for j in range(i+1,min(R,L+2018)+1):
            tmp = (i*j) % 2019
            if tmp < ans:
                ans = tmp
    print(ans)

if __name__ == '__main__':
    main()
def main():
  l,r=map(int,input().split())
  ans=10**9
  if any([r//2019>l//2019,r==0,l==0]):
    ans=0
    print(ans)
  else:
    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)
main()
def LI():
  return [int(s) for s in input().split()]

L,R = LI()

if R - L > 2019:
  R = L + 2019
  
min_mod = 2020

for i in range(L,R):
  for j in range(i+1,R+1):
    if (i*j) % 2019 < min_mod:
      min_mod = (i*j) % 2019
      
print(min_mod)
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  l, r = map(int, input().strip().split())
  x = 2019
  remains = [l%x]
  for i in range(l+1, r+1):
    remain = i % x
    if remains[0] == remain:
      break
    remains.append(remain)
    
  min = x
  for i in range(len(remains)-1):
    for j in range(i+1, len(remains)):
      remain = (remains[i] * remains[j]) % x
      if remain < min:
        min = remain
  print(min)

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

if R - L >= 2019:
    ans = 0
else:
    l, r = L % 2019, R % 2019
    ans = 2018 ** 2
    for i in range(l, r+1):
        for j in range(i+1, r+1):
            x = (i*j) % 2019
            ans = min(ans, x)

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

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

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

MOD = 2019
r = min(r, l + MOD - 1)

res = MOD - 1
for i in range(l, r):
    for j in range(i + 1, r + 1):
        res = min(res, (i % MOD) * (j % MOD) % MOD)
print(res)
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()
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)
#!/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 * j % 2019 for i in range(l, r + 1)
            for j in range(i + 1, r + 1)))
else:
    print(0)
L, R = map(int, input().split())

import sys
minimum = sys.maxsize
for i in range(L, min(L + 2019, R)):
  for j in range(i+1, min(i + 1 + 2019, R+1)):
    minimum = min(minimum, i * j % 2019)
print(minimum)
l,r = map(int,input().split())
mod = 2019
ans = 2018
if r-l>=2018:
    print(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())
mod = 2019
 
r = min(r, l+4038)
ans = 2018
for i in range(l, r+1):
    for j in range(i+1, r+1):
        x = i * j % mod
        ans = min(ans, x)
print(ans)
mod = 2019
l, r = map(int, input().split())

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

for i in range(L, min(R+1, L+mod+1)):
    for j in range(i+1, min(R+1, L+mod+1)):
        ans = min(ans, (i*j)%mod)
print(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 + 1, R + 1)):
    ans = min((i * j) % mod, ans)
print(ans)
L,R = list(map(int,input().split()))
if R-L+1 >= 2019:
    ans = 0
else:
    ans = 2019
    for i in range(L,R):
        for j in range(i+1,R+1):
            s = (i*j)%2019
            ans = min(s,ans)
print(ans)
L, R = map(int, input().split())
lista = []
for i in range(L, min(R + 1, L + 2019)):
    lista.append(i % 2019)
ans = float('inf')
for i in range(len(lista)):
    for j in range(i + 1, len(lista)):
        ans = min(ans, lista[i] * lista[j] % 2019)
print(ans)
l,r=map(int,input().split())
X=[]
if r-l>=2019:
    print(0)
else:
    for i in range(l,r):
        for j in range(i+1,r+1):
            X.append((i*j)%2019)
    print(min(X))
L, R = map(int, input().split())
if (R - L) >= 2018:
    print(0)
    exit()
else:#普通に二重for文で全探索(高々2017の範囲のfor文なので)
    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)
else:
    answers = []
    for a in range(L, R + 1):
        answers.append(a % 2019)
    answer=[]
    for a in range(len(answers)-1):
        for b in range(a+1,len(answers)):
            answer.append((answers[a]*answers[b])%2019)
    print(min(answer))
l,r=map(int,input().split())
if r//2019-(l-1)//2019>0:
    print(0)
else:
    m=20000
    for i in range(l,r):
        for j in range(i+1,r+1):
            if m>(i*j)%2019:
                m=(i*j)%2019
    print(m)