peterverebics/CodeNet_Python_118 huggingface dataset:
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 = 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 = map(int,input().split())

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

print(ans)
def main():
    L, R = map(int, input().split())
    if R - L + 1 >= 2019:
        print(0)
        exit()
    vals = []
    for i in range(L, R):
        for j in range(i+1, R+1):
            vals.append(((i % 2019) * (j % 2019)) % 2019)
    print(min(vals))


if __name__ == '__main__':
    main()
L, R = map(int, input().split())
if R-L >= 2019:
    print(0)
else:
    ans = 2018**2
    for i in range(L, R):
        for j in range(i+1, R+1):
            mod2019 = i*j%2019
            if mod2019 < ans:
                ans = mod2019
    print(ans)
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# 問題：https://atcoder.jp/contests/abc126/tasks/abc133_c

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

res = 2019

if r - l >= 2019 or r % 2019 < l % 2019:
    res = 0
else:
    for i in range(l, r+1):
        for j in range(l, i):
            x = i % 2019
            y = j % 2019
            z = (x * y) % 2019
            if z < res:
                res = z

print(res)
from itertools import combinations
L,R = (int(x) for x in input().split())
ans = 2018
if (R-L) // 2018 > 1:
    print('0')
else:
    for x in combinations(range(L,R+1),2):
        ans = min(ans,x[0]*x[1]%2019)
    print(ans)
L,R = map(int,input().split())
l = L%2019
r = R%2019
Min_Answer = 2018

if L//2019 == R//2019:
    for i in range(l,r+1):
        for j in range (i,r+1):
            if i ==j :
                continue
            Answer = (i*j) % 2019
            Min_Answer = min(Answer,Min_Answer)

else:
 Min_Answer = 0

print(Min_Answer)
L, R = map(int, input().split())
if R - L >= 2019:
    print(0)
    exit()

temp = 2020
for i in range(L, R):
    for j in range(i + 1, R + 1):
        temp = min(temp, (i * j) % 2019)
print(temp)
def mod2019(x, y):
    return (x%2019 * y%2019 ) % 2019

L,R = list(map(int, input().split()))
ans=2019
s=set()
for i in range(L,R+1):
    if i%2019 in s:
        break
    s.add(i%2019)
l = list(s)
for i in range(len(l)):
    for j in range(i+1, len(l)):
#        print(i, j, l[i], l[j], mod2019(l[i], l[j]))
        ans=min(ans, mod2019(l[i], l[j]))
    
print(ans)
l,r = map(int,input().split())
MOD = 2019

nl = l%MOD
diff = r-l
li1 = []
li2 = []

if diff>2018:
  print(0)
else:
  for i in range(diff+1):
    li1.append(nl+i)
  for j in range(len(li1)):
    for k in range(j+1,len(li1)):
      li2.append(li1[j]*li1[k]%MOD)
  print(min(li2))
l, r = map(int, input().split())
r = min(r, l+(2019*2))
ans = 2018

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

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

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

print(ans)
L, R = map(int, input().split())
mod = 2019
s = 2018
for i in range(L,R):
    for j in range(i+1, R+1):
        t = (i%mod)*(j%mod)%mod
        if s > t:
            s = t
        if t == 0:
            break
    else:
        continue
    break
print (s)
L, R = map(int, input().split())
if R - L >= 2019:
    print(0)
else:
    ans = 2019
    for j in range(L, R + 1):
        for i in range(L, j):
            ans = min(ans, (i * j) % 2019)
    print(ans)
l,r=map(int,input().split())
mod=2019
a=l%mod
b=l//mod
c=r%mod
d=r//mod
if d-b!=0:
  print(0)
else:
  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)
l,r = map(int,input().split())
m = 2018
if r-l>=2019:
  print(0)
else:
  for i in range(l,r+1):
    for j in range(i+1,r+1):
      a = (i*j)%2019
      m = min(a,m)
  print(m)
l,r = map(int,input().split())
sub = r-l
l %= 2019
r %= 2019

if(sub >= 2019):
    print(0)
    exit()

mina = float('INF')

for x in range(l,l+sub+1):
    for y in range(x,l+sub+1):
        if(x==y):
            continue
        
        ans = (x * y) % 2019
        if(mina > ans):
            mina = ans
       
print(mina)
L, R = map(int, input().split())
ans = 2019
if R-L >= 2018:
    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())

ans=2018
i=L
while i<R:
    j=i+1
    while j<=R:
        if i*j%2019==0:
            ans=0
            break
        else:
            ans=min(ans,i*j%2019)
            j+=1
    i+=1
    if ans==0:
        break

print(ans)
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

MOD = 2019
L, R = lr()
if (R-L) > 2019 * 2:
    R = L + (R-L)%MOD + 2019

answer = 2019
for i in range(L, R):
    for j in range(i+1, R+1):
        temp = i * j % MOD
        if temp < answer:
            answer = temp

print(answer)
def main():
	l ,r = map(int,input().split())
	if (l-1)//2019 != r//2019:
		print("0")
		return 
	else:
		l = l%2019
		r = r%2019
		ans = 2018
		for i in range(l,r+1):
			for j in range(i+1,r+1):
				ans = min((i*j)%2019,ans)
		print(ans)
	return
main()
L, R = map(int, input().split())

ans = 2018

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

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

if __name__=="__main__":
    main()
L,R=map(int,input().split())
R=min(R,L+4038)
ans=2020
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)
L,R = map(int,input().split())
R = min(R,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())
ans=2019
for i in range(l,min(l+2019-1,r)):
    for j in range(l+1,min(l+2019,r+1)):
        ans=min(ans,((i%2019)*(j%2019))%2019)
print(ans)
l,r = map(int,input().split())
ans = 10**10
for i in range(l,r+1):
    for j in range(i+1,r+1):
        x = (i*j)%2019
        if x==0:
            ans = 0
            break
        else:
            ans=min(ans,x)
    else:
        continue
    break
print(ans)
# https://atcoder.jp/contests/abc133/tasks/abc133_c

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(l, r + 1):
            if i == j:
                continue
            ans = min(ans, i * j % 2019)
print(ans)
import sys
L,R=map(int, sys.stdin.readline().split())
sho1=(L-1)/2019
sho2=R/2019
if 1<=sho2-sho1:
    print 0
else:
    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 = map(int, input().split())
mod = 2019

def check(left, right):
  ans = 2018
  # a mod p = b mod p なら a*c ≡ b*c (mod p)
  # r - l
  if right-left >= 2019:
    ans = 0
  # 2018**2個調べる(最小値が出たら打ち切り)
  else:
    for i in range(left, right):
      for j in range(l+1, right+1):
        ans = min((i*j)%mod, ans)
        if ans==0: return ans
  return ans
ans = check(l, r)
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(l + 1, r + 1):
            ans = min(ans, (i * j) % 2019)

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

    res = 2018
    for i in range(l, r):
        for j in range(l+1, r+1):
            mod = (i*j)%2019
            if mod < res:
                res = mod
            if res == 0:
                break
        else:
            continue
        break
        
    print(res)


if __name__ == '__main__':
    main()
L,R=map(int,input().split())
if R-L>=2019:
    minimum=0
else:
    left,right=L%2019,R%2019
    minimum=2019
    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())
mini = 9999
if R - L >2019:
  R = L + 2019
for l in range(L, R + 1):
  for r in range(l + 1, R + 1):
    temp = (r * l) % 2019
    if temp < mini:
      mini = temp
    if mini == 0:
      break
print(mini)
L, R = map(int, input().split())

z = 2019

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

if r-l > 2018:
    print(0)
    exit()
else:
    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

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

else:
    l %= 2019
    r %= 2019
    for i in range(l,r):
        for j in range(i+1,r+1):
            i %= 2019
            j %= 2019
            answer = (i*j)%2019
            minimum = min(answer, minimum)
    print(minimum)
a, b = map(int, input().split())

if b-a >= 2019:
    print(0)
else:
    c = []
    for i in range(a,b):
        for j in range(i+1,b+1):
            c.append(i*j % 2019)
    #print(c)
    print(min(c))
L, R = map(int, input().split())
target = R+1
if R - L > 2017:
    target = L + 2017
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())
mod=2019
ans=float("inf")
if l==0:
    print(0)
    exit()
for i in range(l,min(l+2021,r)):
    for j in range(i+1,min(r+1,l+2022)):
        tmp=(i*j)%mod
        if tmp<ans:
            ans=tmp
print(ans)
import sys 
L,R = map(int, input().split())

if R-L >= 2019:
    print(0)
    sys.exit()
elif R-L == 1:
    print((R*L)%2019)
    sys.exit()

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

print(ans)
import sys
l,r = map(int,input().split())
if l+2019<=r:
  print(0)
  sys.exit()
l=l%2019
r=r%2019
if l>=r:
  print(0)
  sys.exit()

ans=2018
for i in range(l,r):
  if ans == 0:
    break
  for j in range(i+1,r+1):
    ans = min(ans,i*j%2019)
    if ans == 0:
      break
print(ans)
from collections import deque
from itertools import accumulate
import sys
sys.setrecursionlimit(10**6)

mo=10**9+7
#n=int(input())
l,r=map(int,input().split())
r=min(l+2019+10,r)

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


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

mod = 2019

lm = l % mod
rm = r % mod

ans = []
if r - l >= mod :
  print(0)
  exit()
else:
  for i in range(lm,rm):
    for j in range(i+1,rm+1):
      ans.append(i*j % mod)
  print(min(ans))
L,R = map(int,input().split())
m = 10**18
if R-L>=2019:
    print(0)
else:
    for i in range(L,R):
        for j in range(i+1,R+1):
            m = min(m,i*j%2019)
    print(m)
L, R = map(int, input().split())

if L // 2019 != R // 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)
l,r = map(int,input().split())

if r-l >= 672:
    m = 0
else:
    m = 10000000000000000
    cnt_i = 0
    for i in range(l,r+1):
        cnt_j = 0
        if cnt_i == 2019:
            break
        cnt_i += 1
        for j in range(i+1,r+1):
            if cnt_j == 2019:
                break
            cnt_j += 1
            m = min(m,i%2019*j%2019)
print(m)
L, R = map(int, input().split())
dif = R-L+1 if R-L+1<2019 else 2019

ans = 2018
for i in range(L, L+dif):
  for j in range(i+1, L+dif):
    ans = i*j%2019 if i*j%2019 < ans else ans
print(ans)
import sys
readline = sys.stdin.readline

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

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

if L > R:
  L,R = R,L

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

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)
# https://atcoder.jp/contests/abc133/tasks/abc133_c

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

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

min_m = 2019

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

        min_m = min(min_m, m)

print(min_m)
ll, rr = map(int, input().split())
if rr - ll >= 2019:
    print(0)
    exit()

l = ll % 2019
r = rr % 2019

if l > r:
    print(0)
    exit()

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

print(ans)
l,r=map(int,open(0).read().split())

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

m=[]
for i in range(l,r+1):
    m.append(i%2019)

n=len(m)
ans=2019

for i in range(n):
    for j in range(i+1,n):
        ans=min(ans,(m[i]*m[j])%2019)
    
print(ans)
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())

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

if r - l >= 2018:
  print(0)
else:
  res = float('inf')
  for i in range(l, r):
    for j in range(i+1, r+1):
      res = min(res, (i%2019)*(j%2019)%2019)
      
  print(res)
L, R = map(int,input().split())
if R - L >= 2018:
    print(0)
else:
    a = L % 2019
    b = R % 2019
    if b < a:
        b += 2019
    ans = 2018
    for i in range(a,b+1,1):
        for j in range(i+1,b+1,1):
            if ans > (i*j) % 2019:
                ans = (i*j) % 2019
    print(ans)
l,r = map(int, input().split())

ans = 2019
for i in range(l, r):
  for j in range(i+1, r+1):
    t = i*j%2019
    if ans > t:
      ans = t
    if ans == 0:
      print(ans)
      exit()
print(ans)
import sys
L,R=map(int, sys.stdin.readline().split())
sho1=L/2019
sho2=R/2019
if 1<=sho2-sho1:
    print 0
else:
    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 = 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):
            mod = i * j % 2019
            ans = min(ans, mod)
    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
  for i in range(l, r):
    for j in range(i+1, r+1):
      ans = min(i*j%mod, ans)
      if ans == 0:
        break
    else:
      continue
    break
  print(ans)
L, R = map(int, input().split())

ans = 2019
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%2019)*(j%2019))%2019)
print(ans)
L,R = map(int,input().split())
ans = 2020

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)
import sys
L,R = map(int,input().split())
mod = 2019
if R - L >= 2019:
    print(0)
else:
    ans = 10**8
    for i in range(L,R):
        for j in range(i+1,R+1):
            if i * j % mod == 0:
                print(0)
                sys.exit()
            ans = min(ans,(i*j)%mod)
    print(ans)
L, R = map(int, input().split())

ans = 2019
if(R-L >= 2019):
  for i in range(2019):
    for j in range(i+1, 2019):
      tmp = (i * j) % 2019
      if(tmp < ans):
        ans = tmp
else:
  d = L // 2019
  l = L % 2019
  r = R - (d*2019)
  for i in range(l, r+1):
    for j in range(i+1, r+1):
      tmp = (i * j) % 2019
      if(tmp < ans):
        ans = tmp
        
print(ans)
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 R-L > 2019:
    print(0)
    sys.exit(0)

elif left > right:
    print(0)
    sys.exit(0)

elif left==0 or right==0:
    print(0)
    sys.exit(0)

for i in range(left, right):
    for j in range(i+1, right+1):
        x = calc_mod(i, j)
        if x==0:
            print(0)
            sys.exit(0)
        ans.append(x)

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


print(ans)
# -*- 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 or l==0:
#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)
import numpy as np
L, R = map(int, input().split())
mod = 2019
l_mod = L % mod
r_mod = R % mod
lr_range = R - L + 1
if lr_range >= 2019:
    ans = 0
elif l_mod < r_mod:
    ans = 2018
    q = np.arange(l_mod, r_mod+1)
    for i in range(len(q)):
        min_i = (q * q[i]) % mod
        min_i[i] = 2018
        ans = min(min(min_i), ans)
else:
    ans = 0

print(ans % mod)
l,r=list(map(int,input().split()))
m=2018
for i in range(l,min(r+1,l+2019)):
  for j in range(i+1,min(r+1,l+2019)):
    m=min(m,i*j%2019)
print(m)
l,r = map(int,input().split())
ans = (l*r)%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)
L, R = list(map(lambda x: int(x), input().split(" ")))

if R - L >= 2019:
  print(0)
else:
  A = []
  for i in range(L, R):
    for j in range(i+1, R+1):
      A.append((i * j) % 2019)
  print(min(A))
from sys import maxsize

l, r = [int(i) for i in input().split()]

min = maxsize
m = l
while m <= r:
    n = m + 1
    while n <= r:
        mod = m * n % 2019
        if mod < min:
            min = mod
        if mod == 0:
            break
        n += 1
    else:
        m += 1
        continue
    break

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

if R - L + 1 >= 2019:
     print(0)
else:
    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)
import sys 
L,R = map(int, input().split())

if R-L >= 2019:
    print(0)
    sys.exit()
elif R-L == 1:
    print((R*L)%2019)
    sys.exit()

ans = 4000

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

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

ans = 2019
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())

if R - L >= 2019:
    print(0)
    
else:
    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 = map(int, input().split())

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

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

ans = 10e9
for i in range(0, len(A)):
    for j in range(i + 1, len(A)):
        ans = min(ans, (A[i] * A[j]) % 2019)

print(ans)
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 % 2019)



if __name__ == "__main__":
    main()
l,r = map(int,input().split())
x = l%2019
y = min(r,l+2018)%2019
if x<y:
    ans = x*(x+1)
else:
    ans = 0
print(ans)
L,R = map(int, input().split())
dif = 2019 if R-L+1 > 2019 else R-L+1
ans = [0]*dif
index = 0
for i in range(L, L+dif):
  ans[index] = i%2019
  index += 1
ans.sort()
print(ans[0]*ans[1])
l,r = map(int, input().split())

def solve(l,r):
    num = float("inf")
    for i in range(l, r):
        current = (i*(i+1)) % 2019
        num = min(num,current)
        if num == 0:
            print(num)
            return
    
    print(num)

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

if (l-1)//2019 != r//2019:
	print(0)
else:
	print(((l%2019)*((l+1)%2019))%2019)
import math
L, R = map(int, input().split())
l = L % 2019
length = R - L
if l + length > 2019:
  print(0)
elif length > 2017:
  print(0)
else:
  print((L * (L+1))%2019)
l, r = map(int, input().split())
res = 2018

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

lsmod = []
for i in range(l, min(l + 2019, r + 1)):
	lsmod.append(i % 2019)

lsmod.sort()
print((lsmod[0] * lsmod[1]) % 2019)