Problem:
 Score : 300 points    Problem Statement You are given two non-negative integers L and R .
We will choose two integers i and j such that L \leq i < j \leq R .
Find the minimum possible value of (i \times j) \mbox{ mod } 2019 .      Constraints  All values in input are integers.  0 \leq L < R \leq 2 \times 10^9         Input Input is given from Standard Input in the following format:  L  R       Output Print the minimum possible value of (i \times j) \mbox{ mod } 2019 when i and j are chosen under the given condition.        Sample Input 1 2020 2040      Sample Output 1 2  When (i, j) = (2020, 2021) , (i \times j) \mbox{ mod } 2019  = 2 .       Sample Input 2 4 5      Sample Output 2 20  We have only one choice: (i, j) = (4, 5) .

Solution (Python):
_input = [i for i in open(0).read().split('\n') if i]
l, r = [int(i) for i in _input[0].split()]
i_start = l
j_start = l + 1
i_end = min(r-1, i_start+(2019-1))
j_end = min(r, j_start+(2019-1))

min_val = 2018
for i in range(i_start, i_end+1):
    for j in range(j_start, j_end+1):
        if i >= j:
            continue
        min_val = min(min_val, (i * j) % 2019)
print(min_val)

Solution (Python):
L, R = map(int, input().split())

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

print(minimam)

Solution (Python):
import sys
from math import *
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  

num = 2019
l, r = na()
li = []
if r - l > 2019:
    print(0)
else:
    for i in range(l, r+1):
        li.append(i % num)
    li.sort()
    n = len(li)
    m = 1000000000
    for i in range(n):
        for j in range(i+1, n):
            kazu = (li[i] * li[j]) % num
            if m > kazu:
                m = kazu
    print(m)

Solution (Python):
l,r=map(int,input().split())
a=l%2019
b=r%2019
ans=2018
if l+2019<=r:
  ans=0
elif a<b:
  for i in range(a,b):
    for j in range(i+1,b+1):
      tmp=(i*j)%2019
      if tmp<ans:
        ans=tmp
else:
  ans=0
print(ans)

Solution (Python):
l, r = map(int, input().split())
if r - l >= 2019:
    print(0)
else:
    lm = l % 2019
    rm = r % 2019
    if lm >= rm:
        print(0)
    else:
        m = 2019
        for i in range(lm, rm):
            for j in range(i+1, rm+1):
                m = min(i * j % 2019, m)
        print(m)

Solution (Python):
L, R = (map(int, input().split()))

if R // 2019 - L // 2019 >= 1:
	print(0)
else:
	min = 2018
	for i in range(L, R):
		for j in range(i + 1, R + 1):
			val = (i * j) % 2019
			if val < min:
				min = val
	print(min)

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

Solution (Python):
l, r = map(int, input().split())
if r - l > 2019:
    print(0)
else:
    print(min([i * j % 2019 for i in range(l, r) for j in range(i+1, r+1)]))

Solution (Python):

L,R = list(map(int,input().split()))
if R-L >= 2019:
    import sys
    print(0)
    sys.exit()
mod_2019 = lambda x:x%2019
ret = 2020
ij_list = [i for i in range(L,R+1)]
for i in range(len(ij_list)):
    for j in range(i):
        k = mod_2019(ij_list[i]*ij_list[j])
        if k < ret:
            ret = k
print(ret)

Solution (Python):
L, R = map(int,input().split())

x = 2019
xL = L // x
xR = R // x
if xL < xR or L == 0:
    print(0)
    exit()

mL = L % x
mR = R % x

ans = 2019
for i in range(mL,mR):
    for j in range(i+1,mR+1):
        cr = (i*j)%2019
        if ans > cr:
            ans = cr
print(ans)

Solution (Python):

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

Solution (Python):





def solve():
  MOD = 2019
  L,R = map(int, input().split())
  ans = set()
  for i in range(L+1,R+1):
    for j in range(L,i):
      ans.add((i*j)%MOD)
    if min(ans)==0:
      return 0
  return min(ans)


def main():
  print(solve())


if __name__ == "__main__":
  main()

Solution (Python):
L, R = map(int, input().split())
if R - L >= 2019:
  print(0)
else:
  L1 = L % 2019
  R1 = R % 2019
  if L1 > R1:
    print(0)
  else:
    ans = 2 * 10 ** 9
    for i in range(L, R):
      for j in range(i + 1, R + 1):
        ans = min(ans, (i * j) % 2019)
    print(ans)

Solution (Python):
L, R = map(int, input().split())

D = R - L
Ans = {2018}
J_Set = {2018}


for i in range(min(D, 2019)):
    A = L+i
    for j in range(D-i):
        B = L+i+j+1
        Ans.add((A*B)%2019)
        if j > 2019:
            break

print(min(Ans))

Solution (Python):
d = list(map(int, input().split()))
L = d[0]
R = d[1]

a = L//2019
b = R//2019
c = L%2019
d = R%2019

list = []

if b-a >= 2:
  print(0)

elif b-a == 1:
  if d >= c:
    print(0)
  else:
    for i in range(c,d+2019):
      for j in range(i+1,d+2019+1):
        list.append(i*j%2019)
    print(min(list)) 

else :
  for i in range(c,d):
    for j in range(i+1,d+1):
        list.append(i*j%2019)
  print(min(list))

Solution (Python):
L, R = map(int, input().split())
min_mod = 2019
flg=[0]*2019
flg2=[0]*2019
for i in range(L,R):
    idx=i%2019
    if flg[idx]==1:
        break
    if flg[idx]==0:
        for j in range(i+1,R+1):
            mod  = (i*j)%2019
            if flg2[mod]==1:
                break
            flg2[mod]=1
            if min_mod > mod:
                min_mod=mod
        flg[idx]=1
print(min_mod)

Solution (Python):


import sys










tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))
l=hoge[0]
r=hoge[1]

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

l=l%2019
r=((r-1)%2019)+1









minans=2018
for i in range(l,r):
	for j in range(i+1,r+1):
		tmp = (i*j)%2019
		if tmp < minans:
			minans = tmp



print(minans)

Solution (Python):
l,r=map(int, input().split())
List=[]
for i in range(l, min(r+1, l+2019*2+1)):
    List.append(i%2019)
List=sorted(List)
if len(List)<2019:
    ans=2018
    for i in range(len(List)):
        for j in range(i, len(List)):
            if i==j:
                continue
            ans=min(ans, List[i]*List[j]%2019)
    print(ans)
else:
    print((List[0]*List[1])%2019)

Solution (Python):

MOD = 2019
L ,R = map(int, input().split())
k = L % MOD
t = R % MOD
if L + 2019 - k <= R:
    print(0)
else:
    ans = float('inf')
    for i in range(k, t+1):
        for j in range(i+1, t+1):
            ans = min(ans, (i*j) % MOD)
    print(ans)

Solution (Python):
l,r = map(int, input().split())
import numpy as np
import itertools
MOD = 2019
if r-l+1 >= 673:
  print(0)
else:
  k = [i for i in range(l,r+1)]
  can = [0] * ((r-l+1)*(r-l)//2)
  for idx,(m,n) in enumerate(itertools.combinations(k,2)):
    can[idx] = (m*n)%MOD
  print(min(can))

Solution (Python):
import numpy as np

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

if  R-L > 2018:
    print(0)
    
else:
    ans = 2018
    
    R = R % 2019
    L = L % 2019

    if L > R:
        R += 2019
        
    if R - L > 500:
        print(0)
        
    else:
        for i in np.arange(L, R+1):
            for j in np.arange(i+1, R+1):
                i = i % 2019
                j = j % 2019
                k = i * j % 2019
                ans = np.amin(np.array([k, ans]))
            
        print(ans)

Solution (Python):
l,r=[int(i) for i in input().split()]
ss=2019
ans=200000000
if r-l<2019:
    for j in range(l,r+1):
        for k in range(l,r+1):
            if j==k:
                cnt=0
            else:
                ans=min(ans,j*k%2019)
    print(ans)
else:
    for i in range(1,10**9):
        ss=2019*i
        if l<=ss<=r:
            for j in range(ss,ss+2019):
                for k in range(ss,ss+2019):
                    if j==k:
                        cnt=0
                    else:
                        ans=min(ans,j*k%2019)
            print(ans)
            break

Solution (Python):
import sys
L,R = map(int,input().split())
list1 = []
i = L
j = L + 1
jcount = 0
while True:
    if i < R:
        if i*j %2019 == 0:
            print(0)
            sys.exit()
        list1.append(i*j%2019)
        if j < R:
            j += 1
        else:
            jcount += 1
            j = L+1 + jcount
            i += 1
    else:
        break
if len(list1) == 0:
    print(i*j%2019)
print(min(list1))

Solution (Python):
MOD = 2019
L ,R = map(int, input().split())
k = L % MOD
t = R % MOD
if L + 2019 - k <= R:
    print(0)
else:
    ans = float('inf')
    for i in range(k, t+1):
        for j in range(i+1, t+1):
            ans = min(ans, (i*j) % MOD)
    print(ans)

Solution (Python):
l, r = map(int, input().split())
if r-l >=2019:
  l=0
  r=1
else:
  l = l % 2019
  r = r % 2019
if l > r:
  l = 0
  r = 1
min = 2020
now = 0
for i in range(l, r):
  for j in range(i+1, r+1):
    now = i*j%2019
    if min > now:
      min = now
print(min)

Solution (Python):
import numpy as np


def main():
	L, R = [int(x) for x in input().split()]
	tmp_min = np.inf
	for i in range(L, R+1):
		for j in range(i+1, R+1):
			if (i * j) % 2019 < tmp_min:
				tmp_min = (i * j) % 2019
				if tmp_min == 0:
					print(tmp_min)
					exit()
	print(tmp_min)

if __name__ == "__main__":
	main()

Solution (Python):
l, r = map(int, input().split())

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

numbers = list(range(l, r+1))


amari = list(set([x%2019 for x in numbers]))



cnt = 2019
for i in range(len(amari)):
    for j in range(len(amari)):
        if i == j:
            continue
        if amari[i]*amari[j]%2019 < cnt:
            cnt = amari[i]*amari[j]%2019


print(cnt)

Solution (Python):
def main():
    L, R = [int(n) for n in input().split()]
    if R - L >= 2019:
        L = 0
        R = 2018
    
    li = [[0]*2019 for i in range(2019)]
    for i in range(2019):
        for j in range(i, 2019):
            li[i][j] = (i * j) % 2019
    res = 2030
    for i in range(L, R+1):
        for j in range(i+1, R+1):
            a, b = sorted([i%2019, j%2019])
            old = res
            res = min(res, li[a][b])
    print(res)
main()

Solution (Python):

import sys

MOD = 2019  

def solve(L: int, R: int):
    if (R - L >= 2019 - 1) or (R % 2019 <= L % 2019):
        print(0)
        return
    else:
        L = L % 2019
        R = R % 2019
        
        smallest = 10000000
        for i in range(L, R):
            for j in range(i+1, R+1):
                calc = (i*j)%2019
                if calc < smallest:
                    smallest = calc
    print(smallest)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = int(next(tokens))  
    R = int(next(tokens))  
    solve(L, R)

if __name__ == '__main__':
    main()

Solution (Python):
L,R=map(int,input().split())
mod=2019
if R-L>=2020:
    print(0)
    exit()
else:
    l=[]
    for i in range(L,R+1):
        l.append(i%mod)
ans=2018
for i in l:
    for j in l:
        if i!=j:
            ans=min(ans,i*j%mod)
print(ans)

Solution (Python):
L, R = map(int, input().split())

if abs(L-R)>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)

Solution (Python):
import numpy as np
import sys

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

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

r = np.array(list(i for i in range(L, R+1)))


mins = 2018

for i, ri in enumerate(r):
    for j in range(i+1, len(r)):
        rj = r[j]
        s  = np.mod(ri * rj, 2019)
        if(s < mins):
            mins = s
        if(s == 0):
            print(0)
            sys.exit()



print(mins)

Solution (Python):

import sys

MOD = 2019  

def solve(L: int, R: int):
    if R - L >= 2019 - 1:
        print(0)
        return
    if R % 2019 <= L % 2019:
        print(0)
        return
    else:
        L = L % 2019
        R = R % 2019
        
        smallest = 10000000
        for i in range(L, R):
            for j in range(i+1, R+1):
                calc = (i*j)%2019
                if calc < smallest:
                    smallest = calc
    print(smallest)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = int(next(tokens))  
    R = int(next(tokens))  
    solve(L, R)

if __name__ == '__main__':
    main()

Solution (Python):
L, R = map(int, input().split())
mod = 2019

for i in range(L, R) :
	for j in range(i + 1, R + 1) :
		if((i * j) % 2019 < mod) :
			mod = (i * j) % 2019
			x = ((i * j) // 2019) * 2019 + 2019
			if(x > i * R) :
				break
			else :
				pass
		elif(mod == 0) :
			break
		else :
			pass
	if(mod == 0) :
		break
	else :
		pass
	
print(mod)

Solution (Python):
L, R = map(int, input().split())

x_min = 2018
if L // 2019 != R // 2019:
  print(0)
elif L % 2019 == 0 or R % 2019 == 0:
  print(0)
else:
  L = L % 2019
  R = R % 2019
  for i in range(L, R):
    for j in range(i+1, R+1):
      if x_min > (i*j)%2019:
        x_min = (i*j)%2019
  print(x_min)

Solution (Python):
s=input()


s = s.split(" ")
 
L = int( s[0] )
R = int( s[1] )
 
 
result =4.0e9  
for i in range(L,min(L+2019,R)):
    for j in range(i+1,min(R+1,L+2020)):
        mod = i*j % 2019
        
        if result > mod:
            result = mod
 
print(result)

Solution (Python):
L,R = map(int, input().split())

if R - L >= 2019:
    print(0)
else:
    m = 2020
    for i in range(L, R+1):
        for j in range(L, R+1):
            if i == j:
                continue
            m = min(m, (i * j) % 2019)
    print(m)

Solution (Python):
L,R = map(int,(input().split()))

A = []

ans = 2019

if (R-L) >= 2018:
    print(0)
else:
    for i in range(L,R+1):
        A.append(i % 2019)
    a = min(A)
    b = max(A)
    for j in range(a+1,b+1):
            for k in range(a,j):
                ans = min(ans,(j*k)%2019)
    print(ans)

Solution (Python):
import sys
import math


def get_iv():
    args = sys.stdin.readline()
    argv = args.split()
    iargv = [int(arg) for arg in argv]
    return iargv


def min_mod_prod(L, R):
    min_rem = 2019
    for i in range(L, R + 1):
        if min_rem == 0:
            break
        for j in range(i + 1, R + 1):
            if min_rem == 0:
                break
            tst = (i * j) % 2019
            if tst < min_rem:
                minij = [i, j]
                min_rem = tst

    minij.append(min_rem)
    return minij


def main():
    specs = get_iv()
    L = specs[0]
    R = specs[1]
    rv = min_mod_prod(L, R)
    
    print(rv[2])


if __name__ == '__main__':
    main()

Solution (Python):
l,r = map(int, input().split())

min = 2019
diff = r-l+1

if diff > 2019:
  diff = 2019

for i in range(diff):
  for j in range(diff):
    if j > i:
      total = (i+l)*(j+l)
      if total > 2019:
        mod = total % 2019
        if min > mod:
           min = mod
      else:
        if min > total:
          min = total
print(min)

Solution (Python):
L, R = (int(x) for x in input().split())
 
min = 2020

counter1 = 0
counter2 = 0

for i in range(L, R):
    counter1 += 1
    if counter1 > 20190:
        break
    for j in range(i + 1, R + 1):
        counter2 += 1
        if counter2 > 20190:
            break
        i_ = i % 2019
        j_ = j % 2019
        mod_ij = i_ * j_ % 2019
        if min > mod_ij:
            min = mod_ij
        
 
print(min)

Solution (Python):
LR = list(map(int,input().split()))
L = LR[0]
R = LR[1]
K = 2018
if R - L> 2019:
    K = 0
else:
    for j in range(L,R+1):
        for i in range(L,j):
            if K > (i*j)%2019:
                K =  (i*j)%2019
print(K)

Solution (Python):
l,r = map(int,input().split())
ans = []
tmp = 0
for i in range(l,r):
    for j in range(l+1,r+1):
        tmp = (i * (j % 2019)) % 2019
        ans.append(tmp)
        if j % 2019 == 0:
            break
    if i % 2019 == 0:
        break
print(min(ans))

Solution (Python):
l,r = map(int, input().split())
mod = 2019
if r-l >= 2018:
  print(0)
  exit()
l %= mod
r %= mod
ans = 2019
for i in range(l,r):
  for j in range(i+1,r+1):
    m = (i*j)%mod
    if ans > m:
      ans = m
    if m == 0:
      break
print(ans)

Solution (Python):
L,R = map(int,input().split())
def judge_distance(i,j):
    if j-i >= 2019:
        return True

def search_2019(i,j):
    res = False
    for p in range(j-i+1):
        if i+p % 2019 == 0:
            res = True
            exit()

if judge_distance(L,R) or search_2019(L,R):
    print(0)
else:
    mincount = float("inf")
    for i in range(L,R):
        for j in range(L+1,R+1):
            if i*j%2019 <= mincount:
                mincount = (i*j)%2019

    print(mincount)

Solution (Python):
l, r = list(map(int, input().split()))


if (r-l)//2019 >= 1 :
    d = 0
else :
    ll = l%2019
    rr = r%2019
    if rr > ll :
        d = 2019
        for i in range(ll, rr) :
            for j in range(i+1, rr+1) :
                d = min(d, i*j%2019)
    else :
        d = 2019
        for i in range(ll, rr+2019) :
            for j in range(i+1, rr+2020) :
                d = min(d, i*j%2019)
print(d)

Solution (Python):
L, R = [int(x) for x in input().split()]
if R-L >= 2019:
  print(0)
elif L%2019 > R%2019:
  print(0)
else:
  s = 20190
  for i in range(L%2019,1+(R%2019)):
    for j in range(L%2019,1+(R%2019)):
      if i < j:
        t = (i*j)%2019
        if s > t:
          s = t
  print(s)

Solution (Python):
import os, sys, re, math

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

base = 2019
temp = L
mod = []
while (temp <= R) and (temp-L <= base):
    mod.append(temp % base)
    temp += 1

mod = list(set(mod))

ret = base
for i in range(len(mod)-1):
    for j in range(i+1,len(mod)):
        ret = min(ret, (mod[i]*mod[j])%base)

print(ret)

Solution (Python):
l,r = map(int,input().split())
a = l % 2019
b = r % 2019
ans = 2019
if l // 2019 == r // 2019:
    for i in range(a,b):
        for j in range(i+1,b+1):
            ans = min(ans,i*j%2019)
    print(ans)
else:
    print(0)

Solution (Python):
L,R = map(int,input().split())
mod=2019

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

Solution (Python):
L, R = map(int, input().split())
if R - L < 2019:
    res = 2019
    for i in range(L, R):
        for j in range(i + 1, R + 1):
           res = min(res, (i * j) % 2019)
else:
    res = 0

print(res)

Solution (Python):
L, R = list(map(int, input().split()))

'''
d = R - L
if d >= 2019:
    ans = 0
else:
    l = L % 2019
    r = R % 2019
    
    if l + d >= 2019:
        ans = 0
    else:
        ans = l * (l+1)
        for i in range(l,l+d):
            for j in range(i+1,d):
                now = i * j % 2019
                ans = min(ans, now)
'''
d = R - L
if d >= 2019-1:
    ans = 0
else:
    I = L
    J = R
    ans = L * R % 2019
    for i in range(L,R):
        for j in range(i+1,R+1):
            now = i * j % 2019
            
            if ans > now:
                ans = now
                I = i
                J = j
print(ans)

Solution (Python):
L, R = map(int, input().split())
mod = 2019

if R - L >= 2018:
    print(0)
elif R - L == 1:
    print(((L % mod) * (R % mod)) % mod)
else:
    m = 2019
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            m = min(m, ((i % mod) * (j % mod)) % mod)
    print(m)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    l,r=MAP()

    if l//2019==r//2019:
        l%=2019
        r%=2019
        mi=INF
        for i in range(l,r):
            for j in range(i+1,r+1):
                mi = min(mi,(i*j)%2019)
        print(mi)

    else:
        print(0)


if  __name__=='__main__':
    main()

Solution (Python):
L, R = (int(i) for i in input().split())

d = R - L
if d > 2019:
  d = 2019

min_r  = 2018
for i in range(L, L+d+1):
  for j in range(i+1, L+d+1):
    r = i*j % 2019
    if r < min_r:
      min_r = r

print(min_r)

Solution (Python):
l,r=map(int, input().split())
m=2019
m=int(m)
pot = m

if l//m != r//m:
    print(0)
else:
    for i in range(l,r):
        for j in range(i+1,r+1):
            pot = min(pot, (i*j)%m)

    print(pot)

Solution (Python):
l, r = [int(v) for v in input().split()]

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

Solution (Python):
L,R=map(int,input().split())
if L//2019<R//2019 or L%2019==0 or R%2019==0:
    print(0)

elif (L//673<R//673 and L//3<R//3) or (L%3==0 and R%673==0) or (L%673==0 and R%3==0):
    print(0)

else:
    l=list(range(L,R+1))
    arr=[]
    for i in range(len(l)):
        for j in range(len(l)):
            if i < j:
                arr.append(l[i]*l[j]%2019)
    print(min(arr))

Solution (Python):
l,r=map(int,input().split( ))

y=2019

if l//y != r//y:
    print(0)
else:
    a=l%y
    b=r%y
    m=y
    for i in range(a,b):
        for j in range(i+1,b+1):
            m=min(m,i*j%2019)
    print(m)

Solution (Python):
l, r = map(int, input().split())
if r-l >= 2018:
	print(0)
else:
	ll, rr = l%2019, r%2019
	if ll < rr:
		val = 2019*2019
		for i in range(ll,rr+1):
			for j in range(i+1,rr+1):
				val = min(val, i*j%2019)
		print(val)
	else:
		print(0)

Solution (Python):
L,R=map(int,input().split())
mod=2019
ans=2019**2
for i in range(L,min(R+1,L+mod)):
    for j in range(L,min(R+1,L+mod)):
        if i>=j:
            continue
        ans=min(ans,i*j%mod)
print(ans)

Solution (Python):
L, R = map(int, input().split())
mod_n = 2019
if (mod_n) < (R - L + 1):
    R = L + mod_n

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

ans = 2020
for i in range(len(v)-1):
    for j in range(i+1,len(v)):
        
        mul_v = v[i] * v[j] % mod_n
        if mul_v < ans:
            
            ans = mul_v

print(ans)

Solution (Python):
L, R = map(int, input().split())

import numpy as np
if L+2019<=R:
    ms = np.arange(2019)
else:
    ms = np.unique(np.arange(L, R+1) % 2019)

Ms = ms.reshape(-1,1)*ms.reshape(1,-1)
Ms = Ms % 2019
Ms += np.eye(Ms.shape[0], dtype=int)*2019
print(np.min(Ms))

Solution (Python):
l, r= map(int,input().split())
li=[]
ans=1000000

if r-l>=2019:
    print(0)
else:
    for i in range(l,r+1):
        li.append(i%2019)
    for i in range(len(li)):
        for j in range(i+1,len(li)):
            
            ans=min(ans,li[i]*li[j]%2019)
    print(ans)

Solution (Python):
L,R=map(int,input().split())
if R-L>2019:
  result=0
else:
  kotae=[]
  for i in range(L,R+1):
    kotae.append(i%2019)
  kotae.sort()
  kaitou=[]
  for j in range(len(kotae)-1):
    for k in range(j+1,len(kotae)):
      kaitou.append((kotae[j]*kotae[k])%2019)
  result=min(kaitou)

print(result)

Solution (Python):
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)

Solution (Python):
L,R = map(int,input().split(' '))
if R-L>=2019:
    print(0)
else:
    f = True
    for i in range(L,R+1):
        t = i % 2019
        if t==0:
            f = False
            break
    if f:
        ans = 2019
        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
        print(ans)
    else:
        print(0)

Solution (Python):
L, R = map(int , input().split())
mod = 2019
ans = float('inf')
if R - L  >= 2019:
    print(0)
    exit()

for i in range(2020):
    for j in range(2020):
        if L + i > R or L + j > R or i == j:
            break
        tmp_mod = ((L + i) % mod * (L + j) % mod) % mod
        if ans > tmp_mod:
            ans = tmp_mod

print(ans)

Solution (Python):
L,R = map(int,input().split())

def mfnc():
  m = 2018
  for i in range(L,R):
    for j in range(i+1,R+1):
      if i*j%2019<m:
        m = i*j%2019
  return m      

if L//2019 == R//2019:
  print(mfnc())
else:
  print(0)

Solution (Python):
L,R = map(int,input().split(" "))
remind = 2020
if L + 1 == R:
    print((R * L) % 2019)
else:
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            r = (i * j) % 2019
            if r < remind:
                remind = r
                if remind == 0:
                    print(0)
                    exit(0)
    print(remind)

Solution (Python):
L, R = map(int, input().split())

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

Solution (Python):
import itertools
L,R = map(int,input().split())
if (L+2019) < R:
  R = L+2019

ans_list=[]
for v in itertools.combinations(range(L,R+1),2):
  buf1 = v[0]%2019
  buf2 = v[1]%2019
  ans_list.append((buf1*buf2)%2019)
print(min(ans_list))

Solution (Python):
l,r=map(int,input().split())

a=l%2019
b=r%2019

result=2018

if l+(2019-a)>l and l+(2019-a)<r:
  print(0)
else:
  if a>b:
    n=a
    a=b
    b=n
  for i in range(a,b):
    for j in range(i+1,b+1):
      if (i*j)%2019<result:
        result=(i*j)%2019
  print(result)

Solution (Python):

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


mod = 2019

ans = 0
if l//mod == r//mod: 
    
    lm = min(l%mod,r%mod)
    rm = max(l%mod,r%mod)
    t = mod**2
    for i in range(lm,rm+1):
        for j in range(i+1,rm+1):
            t = min(i*j%mod,t)
    
    ans = t



print(ans)

Solution (Python):
l, r = map(int, input().split())
if r // 3 > (l - 1) // 3 and r // 673 > (l - 1) // 673:
    print(0)
else:
    print(min(i * j % 2019 for i in range(l, r + 1) for j in range(l, i)))

Solution (Python):
L, R = map(int, input().split())

min1 = 10000
border = 4039
ancker = 99999

'''
for i in range(L, min(R+1, L + border)) :
    if i % 2019 < min1 :
        min1 = i % 2019
        ancker = i

min2 = 100000

for i in range(L, min(R+1, L + border)) :
    if i % 2019 < min2 and i != ancker:
        min2 = i % 2019
'''

min1 = 100000

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



print(min1)

Solution (Python):
L,R=(int(x) for x in input().split())
mod_list=[]
minimum=10000000000
index=0
flag=0
for i in range(L,R):
    for j in range(i+1,R+1):
        if((i*j)%2019==0):
            minimum=0
            flag=1
            break
        else:
            candidate=(i*j)%2019
            if(minimum>candidate):
                minimum=candidate
    if(flag==1):
        break
print(minimum)

Solution (Python):
L, R = map(int, input().split())
counter = []
ite = 0
for i in range(L, R+1):
    counter.append(i)
    ite += 1
    if ite > 2021:
        break

kouho = 2019**2
for j in counter:
    for k in range(L, j):
        if kouho > (j * k) % 2019:
            kouho = (j*k) % 2019


print(kouho)

Solution (Python):
words = lambda t : list(map(t, input().split()))
l,r = words(int)

ml = l % 2019
mr = r % 2019

if ml >= mr or r - l >= 2019:
    print(0)
else:
    mi = (ml * (ml+1)) % 2019
    for i in range(ml,mr):
        for j in range(i+1, mr+1):
            
            mi = min(mi, (i*j) % 2019)
    print(mi)

Solution (Python):
def main():
    L, R = map(int, input().split(" "))

    r1 = L // 2019 
    r2 = R // 2019
    
    if r2 - r1 >= 1:
        return 0

    
    L0 = L % 2019
    R0 = R % 2019
    range_ = range(L0, R0+1)

    out = min([ i * j % 2019 for i in range(L0, R0+1) for j in range(i+1, R0+1)])
    return out

out = main()
print(out)

Solution (Python):
a,b=map(int,input().split())
tmp=2020
if b-a>=2019:
  print(0)
else:
  for i in range(b-a+1):
    for j in range(b-a+1):
      if i==j:
        continue
      x=a+i
      y=a+j
      if tmp>x*y%2019:
        tmp=x*y%2019
  print(tmp)

Solution (Python):
import math

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

if math.floor(l/2019)<math.floor(r/2019):
  print(0)
else:
  a = []
  for i in range(l,r+1):
    p = [((i%2019)*j)%2019 for j in set([u%2019 for u in range(i+1,r+1)])]
    if len(p)>0:
      a.append(min(p))
  print(min(a))

Solution (Python):
L,R = map(int,input().split())
P = 2019
if R - L > P:
    print(0)
else:
    Min = P
    for i in range(L,R):
        if Min ==0:
            break
        for j in range(i+1,R+1):
            tmp = (i*j)%P
            if tmp < Min:
                Min = tmp
    print(Min)

Solution (Python):
L, R = map(int, input().split())

res = 1000000007

if R - L + 1 > 2019:
    print(0)
else:
    amari = [i % 2019 for i in range(L, R + 1)]
    l = len(amari)
    for i in range(l):
        a = amari[i]
        for j in range(i + 1, l):
            b = amari[j]
            res = min(res, a * b % 2019)

    print(res)

Solution (Python):
import sys

L, R = map(int, sys.stdin.readline().split())
mod = 2019

mod_L = L%2019
mod_R = R%2019

for i in range(L + 1, R + 1):
    if i % mod == 0:
        print(0)
        sys.exit()

if R - L >= 2019:
    temp_i = mod_L
    temp_j = 2018
else:
    temp_i = mod_L
    temp_j = mod_R

min_mod = 2019
for i in range(mod_L, mod_R):
    for j in range(i + 1, mod_R + 1):
        if ((i*j)%mod) < min_mod:
            min_mod = (i*j)%mod
print(min_mod)

Solution (Python):
from itertools import combinations
L, R = map(int, input().split())
A = 2019
M = min(R+1, L+A)

a = min(i % A for i in range(L, M))
if a == 0:
    print(0)
else:
    print(min((i*j) % A for (i, j) in combinations(range(L, R+1), 2)))

Solution (Python):
l,r = [int(_) for _ in input().split()]
c = (r-l+1)//2019
m = 10**10
if c == 0:
    if r%2019 <= l%2019:
        print(0)
    else:
        for i in range(l%2019, r%2019):
            for j in range(i+1, r%2019+1):
                m = min(m, i*j%2019)
        print(m)
else:
    print(0)

Solution (Python):
from random import randint

def solve0(L, R):
    m = 2019
    for i in range(L, R):
        for j in range(i+1, R+1):
            t = (i*j) % 2019
            if t < m:
                m = t
                I = i
                J = j
    return I, J, m

def solve(L, R):
    M = 2019
    I = L
    mi = []
    mj = []
    for i in range(L, R+1):
        m = i % 2019 
        if m == 0:
            return 0, 0, 0
        mi.append(i)
        I = i

    for i in range(I+1, R+1):
        m = i % 2019 
        if m == 0:
            return 0, 0, 0
        mj.append(i)
    
    m = 2019
    for a in range(0, len(mi)):
        i = mi[a]
        for b in range(a+1, len(mi)):
            j = mi[b]
            t = (i*j)%2019 
            
            if t < m:
                I = i
                J = j
                m = t

    return I, J, m

if 0==1:
    N = 10000
    while True:
        l = randint(0, N)
        r = randint(l+1, N)
        if solve(l,r)[-1] != solve0(l,r)[-1]:
            print("bad", l, r)
            break


def main():
    L, R =[int(x) for x in input().split()]
    answer = solve(L, R)
    
    
    print(answer[-1])

main()