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

if(r-l>=2019):
    print(0)
elif(2019<=r):
    Min=2019
    for i in range(r,l,-1):
        for j in range(i-1,l-1,-1):
            if(i*j%2019<Min):
                Min=i*j%2019
    print(Min)
else:
    print(l*r%2019)

Solution (Python):
l, r = map(int, input().split())
count = int()
baff = set()
if l <= 3 and r >= 673:
    print(0)
else:
    for i in range(l, r + 1):
        for j in range(i + 1, r + 1):
                baff.add((i * j) % 2019)
                if (i * j) % 2019 == 0:
                    break
        else:
            continue
        break
    print(min(baff))

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

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

Solution (Python):
def make_list(L, R):
    mod_list = list()

    if R - L <= 2019:
        for i in range(L, R):
            for j in range(i + 1, R + 1):
                mod_list.append((i * j) % 2019)
    else:
        for i in range(L, L + 2020):
            for j in range(i + 1, i + 2021):
                mod_list.append((i * j) % 2019)

    return mod_list


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

    mod_list = make_list(L, R)

    print(min(mod_list))

    return


if __name__ == "__main__":
    main()

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

minNum = 0
maxNum = 0
ans = 9999

tempL = int(L / 2019)
tempR = int(R / 2019)
if(tempL != tempR):
    ans = 0
else:
    for i in range(L, R):
        for j in range(L + 1, R + 1):
            ans = min(ans, (((i % 2019) * ( j % 2019)) % 2019))

print(ans)

Solution (Python):
l,r = map(int,input().split())
la=l%2019
ra=r%2019
sa=l%673
if la==0:
    print(0)
elif sa+(r-l)>=673:
    print(0)
else:
    ans=2019
    for i in range(la,ra):
        for j in range(1,ra-i+1):
            if ans>(i*(i+j))%2019:
                ans=(i*(i+j))%2019
    print(ans)

Solution (Python):
import sys


def input():
    return sys.stdin.readline()[:-1]


def main():
    l, r = map(int, input().split())
    if r-l >= 2018:
        print(0)
    else:
        ans = 2222
        n = [i for i in range(l, r+1)]
        for i in range(len(n)):
            for j in range(i+1, len(n)):
                s = n[i]*n[j] % 2019
                if ans > s:
                    ans = s
        print(ans)

        
        
        


if __name__ == "__main__":
    main()

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

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


else:
    ans = 2020
    L_mod = L % 2019
    R_mod = R % 2019
    for i in range(min(L_mod,R_mod),max(L_mod,R_mod)):
        for j in range(i+1,max(L_mod,R_mod)+1):
            
            ans = min(ans, (i*j)%2019)
    print(ans)

Solution (Python):
def inpl(): return map(int, input().split())
from itertools import accumulate
from bisect import bisect, bisect_left
from collections import Counter
from functools import reduce
from itertools import accumulate
from operator import itemgetter, xor

from sys import setrecursionlimit
setrecursionlimit(10**9)
 
import sys
input = sys.stdin.readline
from collections import Counter
def inpl(): return list(map(int, input().split()))

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

else:
    ans = 2019
    for l in range(L, R+1):
        for r in range(l+1, R+1):
            ans = min(ans, l*r%2019)
    print(ans)

Solution (Python):
import numpy as np

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

if R - L > 2019:
  print(0)
else:
  arr = np.array(range(L, R + 1)) % 2019
  arr_1 = arr[:, np.newaxis]
  arr_2 = arr[np.newaxis, :]
  arr_X = (arr_1 * arr_2) % 2019
  np.fill_diagonal(arr_X, 2018)
  print(np.min(arr_X))

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

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

if (r - l >= 673):
    print(0)
else:
    a = 2018
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            b = i % 2019
            c = j % 2019
            d = (b * c) % 2019
            a = min(a, d)
    print(a)

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

t = r - l

if t > 673:
    print("0")
else:
    ans = 2018
    for i in range(t):
        for j in range(t - i):
            p = ((l + i) * (l + i + j + 1)) % 2019
            if p < ans:
                ans = p
    print(ans)

Solution (Python):
import sys

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

ans = 2020
for i in range(l, r+1):
	for k in range(i+1, r+1):
		mod = (i * k) % 2019
		if mod==0:
			print(0)
			sys.exit()

		ans = min(mod, ans)
 
print(ans)

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

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

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

print(ans)

Solution (Python):
L, R = map(int, input().split())
l_mod = L % 2019
r_mod = R % 2019
if R >2019+L:
    print(0)
else:
    mod = (l_mod*(l_mod+1)) % 2019
    for i in range(l_mod,r_mod):
        for j in range(i+1,r_mod+1):
            if mod>(i*j)%2019:
                mod=(i*j)%2019
    print(mod)

Solution (Python):
L,R = [int(i) for i in input().split()]
mod = 2019
if R-L >= 673:
    print(0)
else:
    ans = []
    for i in range(L,R+1):
        for ii in range(i+1,R+1):
            ans.append((i*ii)%mod)
    ans = sorted(ans)
    print(ans[0])

Solution (Python):
a = input().split()
a = [int(i) for i in a]
a = sorted(a)
if a[0] + 2019 <= a[1]:
    print(0)
else:
    b_1 = [i for i in range(a[0], a[1] + 1)]
    c = [i % 2019 for i in b_1]
    c = sorted(c)
    epoc = 2019
    for i in range(len(c)):
        for u in range(i):
            epoc1 = (c[i] * c[u]) % 2019
            if epoc1 < epoc:
                epoc = epoc1

    print(epoc)

Solution (Python):
L, R = map(int, input().split())
MOD = 2019
l = L % MOD
r = R % MOD
ans = 2019

if l >= r or (R - L) >= 2019:
    ans = 0
else:
    for i in range(l, r):
        for j in range(l + 1, r + 1):
            if j <= i:
                continue
            else:
                ans = min(ans, i * j % MOD)

print(ans)

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

I = 0
J = 0
now = 0
mod = 2019

end = 0

for i in range(R-L):
    if(L+i % 2019 == 0 or end == 1):
        mod = 0
        break
    for j in range(R-L-i):
        if (L + i + j + 1 % 2019 == 0):
            mod = 0
            break
        I = L + i
        J = L + i + j + 1
        now = (I * J) % 2019
        if(now < mod):
            mod = now
        if(mod == 0):
            end += 1
            break

print(mod)

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

min = 2020

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

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

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

if L <= R//d * 2019: print(0)
else: 
    L = L % 2019
    R = R % 2019
    ans = 2020
    for i in range(L,R+1):
        for j in range(i+1,R+1):
            tmp = i*j%d
            if tmp < ans: ans = tmp
    print(ans)

Solution (Python):
L, R = map(int, input().split())
MOD = 2019
l = L % MOD
r = R % MOD
ans = 2019

if l >= r or l == 0 or r == 0 or (R - L) >= 2019:
    ans = 0
else:
    for i in range(l, r):
        for j in range(l + 1, r + 1):
            if j <= i:
                continue
            else:
                ans = min(ans, i * j % MOD)

print(ans)

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

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

Solution (Python):
import numpy as np
L, R = list(map(int, input().split(' ')))
x = []
x.append(L % 2019)
for i in range(L+1, R+1):
    m = i % 2019
    if x[0] == m:
        break
    x.append(m)
    
min_v = 2018
for i in range(0, len(x)-1):
    tmp = np.amin(np.mod([x[i]*x[j] for j in range(i+1, len(x))], 2019))
    if tmp < min_v:
        min_v = tmp

print(min_v)

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

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

Solution (Python):
inp = input().split()
l = int(inp[0])
r = int(inp[1])

if r - l > 2019:
    print(0)
else:
    int_list_pre = list(range(l,r+1))
    int_list = [s%2019 for s in int_list_pre]
    l_l = len(int_list)
    min_mod = 2018

    for i in range(l_l):
        for j in range(l_l):
            if j > i:
                compare = (int_list[i] * int_list[j])%2019
                if compare < min_mod:
                    min_mod = compare


    print(min_mod)

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

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

l=l%2019
r=r%2019

if l>r:
    tmp=r
    r=l
    l=tmp

ans=l*r%2019
for l1 in range(l,r):
    for r1 in range(l1+1,r+1):
        ans=min(ans,l1*r1%2019)

print(ans)

Solution (Python):
import sys
L,R = map(int,input().split())
mod = 2019
cnt = 0
ans = float('inf')
List = [False for i in range(2019)]
for i in range(L,R):
    for j in range(i+1,R+1):
        tmp = (i*j)%mod
        List[tmp] = True
        ans = min(tmp,L*R,ans)
        if cnt>=10**6 or all(List)==True:
            print(ans)
            sys.exit()
        cnt +=1
print(ans)

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



if __name__ == '__main__':
    main()

Solution (Python):
import sys

def solve(l, r):
  if r - l >= 2018:
    return 0

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

      
      ans = min(ans, (i * j) % 2019)

  return ans


if __name__ == "__main__":
  l, r = map(int, sys.stdin.readline().rstrip().split(" "))
  print solve(l, r)

Solution (Python):
from sys import stdin

if __name__ == '__main__':

    L, R = [int(x) for x in stdin.readline().rstrip().split()]

    exist_0 = False
    mods = list()
    for i in range(R - L + 1):
        if (R - i) % 2019 == 0:
            exist_0 = True
            break

        mods.append((R - i) % 2019)

    if exist_0:
        print(0)
    else:
        min = 2018
        for i in range(len(mods)):
            for j in range(len(mods)):
                if i == j:
                    continue
                else:
                    tmp = (mods[i] * mods[j]) % 2019
                    if tmp < min:
                        min = tmp

        print(min)

Solution (Python):
import sys


def main():
    l, r = [int(s) for s in sys.stdin.readline().strip().split()]
    mods = []
    seen = set()
    for n in range(l, r+1):
        mod = n % 2019
        if mod in seen:
            break
        mods.append(mod)
        seen.add(mod)

    ans = 2019
    for i in range(len(mods)-1):
        for j in range(i+1, len(mods)):
            cand = (mods[i] * mods[j]) % 2019
            ans = min(ans, cand)
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
import bisect
from operator import itemgetter
import math
import copy
import collections
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

L,R = IL()


if R-L >= 2019:
  print(0)
else:
  data = []
  ans = MAX_INT
  for i in range(L,R+1):
    data.append(i%2019)
  for i in itertools.combinations(data,2):
    ans = min(ans,i[0]*i[1]%2019)
  print(ans)

Solution (Python):
L, R = [int(x) for x in input().split()]
MOD = 2019
if (R - L > 2017):
    print(0)
    exit()
L %= MOD
R %= MOD
if (L * R == 0 or R < L):
    print(0)
    exit()
elif (R-L == 1):
    print(L*R % MOD)
    exit()
i = L
ans = L*R % MOD
while(i != R):
    j = i+1
    while (j != R+1):
        if (ans > (i*j % MOD)):
            ans = i*j % MOD
        j += 1
    i += 1
print(ans)

Solution (Python):
l,r=list(map(int, input().split()))
answer=2019
for i in range(l,min(r+1,l+2020)):
    for j in range(l+1,min(r+1,l+2020)):
        if i>=j:
            continue
        _i=i%2019
        _j=j%2019
        answer=min(answer,(_i*_j)%2019)
print(answer)

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

if R-L>=2019:
    print(0)
else:
    for i in range(L,R):
        for j in range(i+1,R+1):
            lst.append(int((i*j)%2019))
    print(min(lst))

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

Solution (Python):


l,r=map(int,input().split())
flg=0
m=2020
for i in range(10**6):
    if l<=2019*i<=r:
        flg=1
        m=0

for i in range(l,r): 
    if flg==1:
        break
    for j in range(i+1,r+1):
        if ((i%2019)*(j%2019))%2019<m and i!=j:
            m=(i*j)%2019

print(m)

Solution (Python):
import numpy as np


def calc(ell: int, r: int) -> int:
    if ell % 2019 > r % 2019:  
        return 0
    if r >= ell + 2019:  
        return 0

    start = ell
    
    stop = r

    searching_array = np.arange(start, stop, 1)
    searching_mat = np.tile(searching_array, (searching_array.shape[0], 1))
    searching_mat2 = searching_mat.T + 1
    seki = searching_mat * searching_mat2
    results = np.mod(seki, 2019)
    results_masked = results[searching_mat < searching_mat2]
    return results_masked.min()


def load_input_as_int_array():
    return [int(v) for v in input().split(" ")]


ell, r = load_input_as_int_array()
print(calc(ell, r))

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

mod=2019

for i in range(int(L),int(R)):
    for j in range(int(i)+1,int(R)+1):
        result=(i*j)%2019
        if mod>result :
            mod=result
        if mod == 0:
            break
    if mod == 0:
        break

print(mod)

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

l, r = L + (3 - L % 3) % 3, R - R % 673

if l < r:
    print(0)
else:
    mi = 3000
    for i in range(L, R + 1):
        for j in range(i + 1, R + 1):
            mi = min(mi, (i * j) % 2019)
    print(mi)

Solution (Python):
L,R = list(map(int, input().split()))
 
if R-L > 673:
    print(0)
else:
    min_mod = 2019
    for i in range(L,R):
        i_mod = i%2019
        for j in range(i+1,R+1):
            j_mod = j%2019
            mod = (i_mod*j_mod)%2019
            if mod < min_mod:
                min_mod = mod
        
    print(min_mod)

Solution (Python):
L,R = map(int,input().split())
amr =[]
if R-L > 2019:
  amari = sorted([i%2019 for i in range(L,L+2019)])
  if 0 in amari:
    print(0)
  else:
    for i,j in enumerate(amari):
      for k in amari[i+1::]:
        amr.append(j*k%2019)
    print(min(amr))
else:
  amari = sorted([i%2019 for i in range(L,R+1)])
  if 0 in amari:
    print(0)
  else:
    for i,j in enumerate(amari):
      for k in amari[i+1::]:
        amr.append(j*k%2019)
    print(min(amr))

Solution (Python):



import sys

input = sys.stdin.readline

def main():
    l, r = map(int, input().split())
    m = 2000000000

    if (r - l) > 2019:
        r = l + 2019

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

main()

Solution (Python):
import math

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

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

Solution (Python):
l,r = map(int,input().split())
mod = 2019
start = l % mod
end = r % mod
x = []
if r - l >= 2018:
  s = 0
elif start < end:
  for i in range(start,end):
    for j in range(i+1,end+1):
      x.append((i*j)%mod)
  s = min(x)
else:
  s = 0
print(s)

Solution (Python):
L, R = (int(i) for i in input().split())
Z = 2020
if R - L >= 2019:
  print(0)
else:
  for i in range(L,R+1):
    a = i % 2019
    for j in range(i+1,R+1):
      b = j % 2019
      c = (a*b) % 2019
      if c < Z:
        Z = c
  print(Z)

Solution (Python):
def main():
    l,r = map(int,input().split())
    if r-l+1 >= 2*2019:
        print(0)
        return
    min_val = float('inf')
    for i in range(l,r+1):
        for j in range(i+1,r+1):
            min_val = min(min_val,(i*j)%2019)

    print(min_val)


main()

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

    print(min(l))

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

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

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

    if (ans > tmp):
      ans = tmp
print(ans)

Solution (Python):
l,r=[int(i) for i in input().split()]
ans=100000000000000
for i in range(max(2019*(l//2019)-1,l),min(2019*(l//2019+1),r)+1):
    for j in range(max(2019*(l//2019)-1,l),min(2019*(l//2019+1),r)+1):
        if i!=j:
            ans=min(ans,(i*j)%2019)
print(ans)

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

ls = []

for i in range(l,r+1):
    ls.append(int(int(i)%2019))

    if len(ls)==1050:
        break
ls = sorted(ls)

ans = ls[0]*ls[1]

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

print(ans)

Solution (Python):

import copy
import random
import bisect 
import fractions 
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) 

def LI(): return list(map(int, sys.stdin.readline().split()))
base = 2019


L,R = LI()
l = L % base
r = R % base
if (L // base + 1) * base <= R:
    ans = 0
    
elif l >= r:
    ans = 0
else:
    ans = mod
    for i in range(l,r+1):
        for j in range(i+1,r+1):
            ans = min(ans,i * j % base)
print(ans)

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

for i in range(r - l):
    t = 2019
    for j in range(i + 1, r - l + 1):
        tmp = (l + i) * (l + j) % 2019
        if a > tmp:
            a = tmp
        if a == 0:
            print(a)
            exit()



        

print(a)

Solution (Python):



def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, m=1, typ=int):
    return [read_h() if m > 1 else typ(input()) for _ in range(n)]


def main():
    L, R = read_h()

    ans = 3000
    for di in range(R - L + 1 if R - L < 2019 else 2019):
        i = L + di
        for dj in range(1, R - i + 1 if R - i < 2019 else 2019):
            j = i + dj
            ans = min(ans, ((i % 2019) * (j % 2019)) % 2019)

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):


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

max_i = 2019 * (int(L / 2019) + 1) 
R = max_i if max_i < R else R

res = float('inf')
for i in range(L, R):
    for j in range(i+1, R+1):
        res = min(res, i * j % 2019)

print(res)

Solution (Python):
L,R=map(int, input().split())
minimum=2020
Calc_flag=True

for i in range (L,R):
  if Calc_flag==True:
    if i+2020<=R+1:
      for j in range(i+1,i+2020):
        a=(i*j)%2019
        minimum=min(minimum,a)
        if minimum==0:
          Calc_flag=False
          break
    if i+2020>R+1:
      for j in range(i+1,R+1):
        a=(i*j)%2019
        minimum=min(minimum,a)
        if minimum==0:
          Calc_flag=False
          break
          
  else:
    break

print(minimum)

Solution (Python):



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

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

L = L % 2019
R = R % 2019
if R <= L:
	R += 2019

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

L, R = map(int, input().split())
flg_len = R-L+1
if flg_len >= 2019:
    ans=0
else:
    R_mod = R%2019
    L_mod = L%2019
    if L_mod > R_mod:
        ans = 0
    else:
        ans = 2018
        for j in range(L_mod,R_mod):
            for i in range(j+1,R_mod+1):
                ij_mod =(i*j)%2019
                ans =min(ans,ij_mod)
print(ans)

Solution (Python):




from sys import stdin
import math

L,R  = [int(x) for x in stdin.readline().rstrip().split()]

diff = R - L

min_val = 2019



min_val = 2019

sur_L = L % 2019
sur_R = R % 2019

if diff > 2019:
    print(0)

elif sur_R < sur_L:
    print(0)
else:
    if sur_R < sur_L:
        tmp = sur_R
        sur_R = sur_L
        sur_L = tmp
        

    for i in range(sur_L,sur_R+1):
        for j in range(i+1, sur_R+1):
            amari = ( i * j) % 2019
            if min_val > amari:
                min_val = amari

    print(min_val)

Solution (Python):
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(((i % 2019) * (j % 2019)) % 2019, ans)
    print(ans)

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

if R-L >= 2019:
    ans = 0
else:
    ans = 4000
    for i in range(L,R+1):
        for j in range(i+1,R+1):
            p = ((i%2019) * (j%2019))%2019
            if p < ans:
                ans = p

print(ans)

Solution (Python):
L,R=map(int,input().split())
ans = 2018
for i in range(L,R):
    for j in range(i+1,R+1):
        wai= i%2019
        waj = j%2019
        if(wai == 0 or waj==0):
            print(0)
            exit()
        ans = min (ans , (wai*waj)%2019)
print(ans)

Solution (Python):
mod = 2019
def mul(a, b):
    return ((a % mod) * (b % mod)) % mod
L,R = map(int,input().split())



if R-L <= 2019*2:
    g = 9999999999999
    for i in range(L,R+1):
        for j in range(i+1,R+1):
            if i<j:
                g = min(g,mul(i,j))
                if g == 0:
                    break
    print(g)
else:
    print(0)

Solution (Python):
import sys
from itertools import combinations
L, R = map(int, input().split())
if R - L >= 2018 :
    print(0)
    sys.exit()
LM = L % 2019
RM = R % 2019
if RM < LM :
    print(0)
else :
    S = range(LM, RM+1)
    SC = list(combinations(S, 2))
    print(min([s[0] * s[1] % 2019 for s in SC]))

Solution (Python):
import math
import itertools
L, R = tuple([int(x) for x in input().split(' ')])

x = L // 2019
y = R // 2019

if x != y:
    print(0)
else:
    xx = L % 2019
    yy = R % 2019
    ans = min([i*j%2019 for i, j in itertools.combinations(range(xx,yy+1), 2)])
    print(ans)

Solution (Python):
import numpy

L, R = map(int, input().split())
l, r = L % 2019, R % 2019

if l > r or (R - L) >= 2019:
    print(0)
else:
    print(numpy.min([(i * j) % 2019 for i in range(l, r) for j in range(i + 1, r + 1)]))

Solution (Python):
import sys
import numpy as np

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

for i in range(991):
  if l <= 2019 * i and r >= 2019 * i:
    print(0)
    exit(0)
if r - l >= 2019:
  print(0)
elif l * r < 2019:
    print(l * (l + 1))
else:
    s = 2020
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            if (i * j) % 2019 < s:
                s = (i * j) % 2019
    print(s)

Solution (Python):
import numpy as np

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









minMOD = 2019















for i in range(L, R+1):
    if(i % MOD) == 0:
        minMOD = 0
        break
    for j in range(i+1, R+1):
        if(j % MOD) == 0:
            minMOD = 0
            break
        tmp = (i*j)%MOD
        if tmp < minMOD:
            minMOD = tmp
            if(tmp == 0):
                break

print(minMOD)

Solution (Python):
L,R = map(int,input().split())
target = 2019
L_mod = L % target
R_mod = R % target

if L_mod > R_mod:
    print(0)
    exit(0)
if L_mod == R_mod and L < R:
    print(0)
    exit(0)
if L+1 == R:
    print(L * R % target)
    exit(0)
if L_mod < R_mod and R-L >= target:
    print(0)
    exit(0)

ans = 2019
for i in range(R_mod-L_mod + 1):
    for j in range(i+1,R_mod-L_mod+1):
        
        if ((L+i) * (L+j)) % target < ans:
            
            
            ans = ((L+i) * (L+j)) % target
            if ans == 0:
                print(0)
                exit(0)
print(ans)

'''
2020 3000
2020 4040
2018 4040
2018 2020
'''

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



mini=l*r%2019
for i in range(l,r+1):
    for j in range(i+1,r+1):
        if(j%2019==0):
            mini=0
            break;
        
        if(i*j%2019<mini):
            mini=i*j%2019
    if mini==0:
        break;
print(mini)

Solution (Python):
a,b=input().split()
a=int(a)
b=int(b)
c=0
for i in range(a,b+1):
  if b-a>=674:
    c=1
    break
  elif i%673==0:
    c=1
    break
ll=[]
if b-a==1:
  print(a*b%2019)
elif c==1:
  print(0)
elif b-a>=102:
  print(1)
elif b-a>=48:
  print(2)
else:
  for i in range(a,b):
    for j in  range(i+1,b+1):
      ll.append(i*j%2019)
  print(min(ll))

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
 
    l, r = [int(i) for i in input().split()]
 
    if(r - l) >= 2019:
        print(0)
        exit()
    
    minmod = float('inf')
 
    for i in range(l, r):
        for j in range(i+1, r+1):
            temp = (i*j)%2019
            if(temp < minmod):
                minmod = temp
 
            
 
    print(minmod)
 
if __name__ == '__main__':
    main()

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

mods = []

for num in range(2019):
	i = num + L
	if i > R:
		break
	mods.append(i%2019)

result = []

for i, num1 in enumerate(mods):
	for j, num2 in enumerate(mods):
		if i == j:
			continue
		result.append(num1*num2%2019)

result.sort()
print(result[0])

Solution (Python):
L, R = map(int, input().split())
g = 2019
ans = 0

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

print(ans)

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

lm = l % mod
rm = r % mod

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

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

circle = (R- L)/ 2019
if circle >=2:
    R = L+2019*2+10


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

mod_list.sort()

result_list = []
for i in range(len(mod_list)-1):
    for j in range(i+1, len(mod_list)):
        result_list.append((mod_list[i]*mod_list[j])%2019)
print(min(result_list))

Solution (Python):
import numpy as np

a = input().split(" ")

L = int(a[0])
R = int(a[1])

if int(L/2019) < int(R/2019):
    print(0)
else:
    flag = 0
    min = 2018
    max = 0
    for i in range(L,R+1):
        if max < i%2019:
            max = i%2019
        if min > i%2019:
            min = i%2019
        if i%2019 == 0:
            print(0)
            flag = 1
            break
    if flag == 0:
        flag2 = 0
        ans = 2018
        for i in range(min,max):
            for j in range(i+1,max+1):
                if ans > (i*j)%2019:
                    ans = (i*j)%2019
                if ans == 0:
                    print(0)
                    flag2 = 1
                    break
            if flag2 == 1:
                break
        if flag2 == 0:
            print(ans)

Solution (Python):
L, R = map(int, input().split())
left = L%2019
right = R%2019
if R-L>2017 or left > right:
    print(0)
else:
    l = [i for i in range(left, right+1)]
    ans = 9999
    for i in range(len(l)-1):
        for j in range(i+1, len(l)):
            mo = l[i]*l[j]%2019
            if mo<ans:
                ans = mo
    print(ans)

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

tmp = []
if L + 2019 < R:
    for i in range(L, L+2019+1):
        for j in range(L, L+2019+1):
            if i == j:
                continue
            tmp.append(i * j % 2019)
else:
    for i in range(L, R+1):
        for j in range(L, R+1):
            if i == j:
                continue
            tmp.append((i * j) % 2019)

print(min(tmp))

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

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

result = []

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

		temp = i * j % 2019
		result.append(temp)

print(min(result))

Solution (Python):
L, R = map(int, input().split())
x = L%2019
y = R%2019
z = []
a = 0
if x ==0 or (R-L) + x >= 2019:
  print(a)
else:
  for j in range(y-x):
    for i in range (y-x-j):
      z.append(((x+j)*(x+j+i+1))%2019)
  print(min(z))

Solution (Python):
i, j = map(int, input().split())

if i + 2019 < j:
    print(int(0))
else:
    min_ = 2019
    for a in range(i,j+1):
        for b in range(a+1,j+1):
            min_ = min(min_, ((a%2019)*(b%2019))%2019)
    print(min_)

Solution (Python):
MAX=2019
def resolve():
    l,r = map(int,input().split())
    if abs(l-r)>=MAX:
        print(0)
        exit(0)
    ans = 10**9
    for i in range(l,r+1):
        for j in range(i+1,r+1):
            ans = min(ans,(i*j)%MAX)
    
    print(ans)


if __name__ == "__main__":
    resolve()