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())
list_LR = range(L,R+1)

list_aaa =[]

ans = 2019
l=min(L+2019, R+1)

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

print(ans)

Solution (Python):
import sys
from itertools import combinations
l, r = [int(i) for i in sys.stdin.readline().split()]
flg = r - l >= 2019
l %= 2019
r %= 2019
res = 1e9
if l >= r or flg:
    print(0)
else:
    for (_l, _r) in combinations(list(range(l,r+1)), 2):
        if _l == _r:
            continue
        res = _l * _r % 2019 if _l * _r % 2019 < res else res
    print(res)

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

a = l % 2019
b = r % 2019

if b - a == r - l:
    min_prod = 2018*2017
    for i in range(l, r+1):
        for j in range(i+1, r+1):
            if i*j%2019 < min_prod:
                min_prod = i*j%2019
    print(min_prod)
else:
    print(0)

Solution (Python):
L,R = list(map(int,input().split()))
lt = []
if R-L == 1:
    print((L*R) % 2019)
elif R-L >= 2:
    for k in range(L,R+1):
        if k % 673 == 0:
            lt.append(0)
            break
    l = L % 673
    r = R % 673
    for i in range(l,r+1):
        for j in range(i+1,r+1):
            ans = (i*j) % 2019
            lt.append(ans)
    print(min(lt))

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

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

Solution (Python):
l,r = map(int,input().split())
L = l%2019
R = r%2019  
N = r-l+1

if N >= 2019 or L>R:
    print(0)
else:
    ans = l*(l+1)%2019
    for i in range(L,R):  
        for j in range(i+1,R+1):
            ans = min(ans,(j*i)%2019)
        if ans == 0:
            break
    print(ans)

Solution (Python):

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

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

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

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

Solution (Python):
from heapq import nsmallest
l, r = map(int, input().split())

ans = 10 ** 9
if r - l > 2019:
    ans = 0
else:
    for i in range(l, r + 1):
        for j in range(i + 1, r + 1):
            prod = (i * j) % 2019

            if prod < ans:
                ans = prod
print(ans)

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

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

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

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007



l, r = LI()
ret = INF
if r - l >= 2019:
    print(0)
else:
    for i in range(l, r+1):
        for j in range(l, r+1):
            if i == j:
                continue
            ret = min(ret, i % 2019 * j % 2019)
    print(ret)

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

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

l = l%2019
r = r%2019

if l == 0 or r == 0 :
    print(0)
    exit()

if l > r:
    r += 2019



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

print(int(min(list_score)))

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

Solution (Python):
L, R = map(int, input().split())
Lmin = L % 2019
Rmin = R % 2019
anlis = []

if R-L >= 2018 or Lmin > Rmin:
    print(0)
    
else:
    for j in range(Lmin+1, Rmin+1):
        for i in range(Lmin, j):
            anlis.append((i * j) % 2019)
    print(min(anlis))

Solution (Python):
l,r=map(int,input().split())
a=[i%2019 for i in range(l,min(r+1,l+2020))]
ans=2018
for i in a:
    for j in a:
        if i!=j:
            ans=min(ans,(i*j)%2019)
print(ans)

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

if r - l > 2019:
    print(0)
else:
    tres = 2019
    for i in range(l,r):
        for j in range(i+1,r+1):
            mod = (i % 2019) * (j % 2019) % 2019
            tres = min(tres,mod)
            if tres == 0:
                break
        if tres == 0:
            break
    print(tres)

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

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

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

Solution (Python):
l, r = [int(i) for i in input().split()]
lmod = l % 2019
rmod = r % 2019
dif = r - l
if dif >= 2019:
	print(0)
else:
	if lmod >= rmod:
		print(0)
	else:
		cand = [i for i in range(lmod, rmod + 1)]
		nc = len(cand)
		prd = []
		for i in range(nc):
			for j in range(i):
				prd.append((cand[i] * cand[j]) % 2019)
		print(min(prd))

Solution (Python):
import sys
l,r = map(int,(input().split()))
if r-l>=2018:
    print(0)
    sys.exit()

else:
    if l%2019>r%2019:
        l=l%2019
        r=r%2019+2019
    else:
        l=l%2019
        r=r%2019

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

    print(m)

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

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

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

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

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

Solution (Python):

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


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

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

print(ans)

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

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

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

Solution (Python):
left, right = map(int, input().split())
mod = 2019

min_mod = float("inf")
for i in range(left, min(right, left + mod)):
    for j in range(i + 1, min(right + 1, i + 1 + mod)):
        curr_mod = i * j % mod
        min_mod = min(min_mod, curr_mod)
        if min_mod == 0:
            break

print(min_mod)

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




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:
            print(0)
            sys.exit(0)
print(ans)

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

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

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

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



num = 2019
while(num<2*10**9):
    if l<=num<=r:
        print(0)
        sys.exit()
    num += 2019
 


min_num  = 2020


while(l < r):
    t = 1
    while(l+t)<=r:
        
        
        if (l*(l+t))%2019 < min_num:
            min_num = (l*(l+t))%2019
            if min_num == 0:
                print(0)
                sys.exit()
            
        t+=1
        
    l +=1
    
print(min_num)

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

min = 1000000000000000000000000000

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

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

print(min)

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

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

Solution (Python):
L,R=map(int,input().split())
if R-L>2019:
  print(0)
elif L%2019==0 or R%2019==0:
  print(0)
elif L//2019!=R//2019:
  print(0)
else:
  L=L%2019
  R=R%2019
  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

  print(ans)

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

mod = 2019
res = 2019

if R - L < 2019:
    for i in range(L % mod, L % mod + (R - L) + 1):
        for j in range(L % mod, L % mod + (R - L) + 1):
            if i == j:
                continue
            res = min(res, ((i % mod) * (j % mod)) % mod)
else:
    res = 0

print(res)

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

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

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

print(ans)

Solution (Python):


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

Solution (Python):


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

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

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

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

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

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

ans = 10**9
if R - L >= 2018:
    ans = 0
else:
    for i in range(L, R+1):
        for j in range(i+1, 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:
    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)

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

if R*(R-1)<2019:
  print(R*(R-1))
  exit(0)
else:
  if R == L+1:
    print((R*L)%2019)
    exit(0)
  else:
    r =673 - L % 673
    if L+r <= R:
      print("0")
      exit(0)
    else:
      for i in range(L,R+1):
        for j in range(i+1,R+1):
          if (i*j)%2019 < ans:
            ans = (i*j) % 2019
            if ans == 0:
              break
print(ans)

Solution (Python):
def main(): 

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

    min_value = 2019

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

    print(min_value)


if __name__ == "__main__":
    main()

Solution (Python):
import math

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

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

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

Solution (Python):
L, R = map(int, input().split())
mod = ans = 2019
if R - L > mod:
    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)

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

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

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

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

Solution (Python):
l,r=map(int,input().split())
for i in range(l,r+1):
    if (i % 2019) == 0:
        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)

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

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

Solution (Python):
def solve():
    L,R = map(int, input().split())
    if R-L >= 2019:
        multiple = [0]
    else:
        L,R = L%2019, R%2019
        L,R = min(L,R),max(L,R)
        multiple = [i*j%2019 for i in range(L,R) for j in range(i+1,R+1)]
        
    print(min(multiple))

solve()

Solution (Python):
l, r = map(int, input().split())
ans = 2019
cnt = min(l + 2019, r)
for i in range(l, cnt):
    for j in range(i + 1, cnt + 1):
        ans = min(ans, i*j % 2019)
print(ans)

Solution (Python):
l, r = map(int, input().split())
ans = 2019
cnt = min(l + 2019, r)
for i in range(l, cnt):
    for j in range(i + 1, cnt + 1):
        ans=min(ans,i*j%2019)
print(ans)

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

Solution (Python):


import heapq
 
L,R=map(int,input().split())
 
ans=2018*2017
if (R-L)>=2018:
    print("0")
else:
    l=list(range(L,R+1))
    for i in range(len(l)):
        for j in range(i+1,len(l)):
            
            ans=min(ans,(l[i]*l[j])%2019)
            

    print(ans)

Solution (Python):

base = 2019
l, r = map(int, input().split())
result = 2018*2017

if r - l > 2019:
    result = 0
else:
    for i in range(l, r):
        for j in range(i+1, r+1):
            tmp_r = (i * j) % base
            if tmp_r < result:
                result = tmp_r

print(result)

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

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

Solution (Python):
def module2019(m):
    if m <= 2018:
        return m
    else:
        return module2019(m%2019)








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

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

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

Solution (Python):
l, r = map(int, input().split( ))
ans = []
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
            ans.append(tmp)
    print(min(ans))

Solution (Python):
MOD = 2019
while True:
    try:
        L, R = map(int, input().split())
        ans = 2019*2019
        if R-L <= MOD-1:
            for i in range(L, R+1):
                for j in range(i+1, R+1):
                    ans = min(ans, i*j%MOD)
            print(ans)
        else:
            print(0)
    except:
        break

Solution (Python):


def solve():
    L, R = list(map(int, input().split()))
    MOD = 2019

    ans = float("inf")
    if R-L <= MOD-1:
        for i in range(L, R+1):
            for j in range(i+1, R+1):
                ans = min(ans, i*j%MOD)
    else:
        
        ans = 0

    print(ans)


if __name__ == "__main__":
    solve()

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

if r - l > 2019:
  print(0)
elif R - L > 0:
  for i in range(L, R):
    for j in range(i+1, R+1):
      ans.append(i * j % 2019)
  print(min(ans))
else:
  print(0)

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

Solution (Python):
L, R = map(int, input().split())
l = L % 2019
r = R % 2019
if R - L >= 673:
  print(0)
elif l > r:
  print(0)
elif l <= 672 and r >= 673:
  print(0)
elif l == 673 and r >= 675:
  print(0)
elif l <= 1344 and r >= 1346:
  print(0)
elif l <= 1346 and r >= 1347:
  print(0)
else:
  m = 2019
  for i in range(l, r):
    for j in range(i + 1, r + 1):
      m = min(i * j % 2019, m)
  print(m)

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

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

ans=set()
for item in range(l,r+1):
  mod=item%2019
  if mod==0:
    print(0)
    exit()
  else:
    ans.add(mod)
    
ans=list(ans)
length=len(ans)
res=2018**2
for i in range(length-1):
  for j in range(i+1,length):
    res=min(res,(ans[i]*(ans[j]))%2019)
print(res)

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

Solution (Python):
l,r= map(int, input().split())
ans=2018
if r-l>=2019:
    print(0)
else:
    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 = list(map(int,input().split()))
a = L%2019
b = R%2019
ans = 30000
if R-L>=2019:
  print(0)
elif a<b:
  for i in range(a,b):
    for j in range(i+1,b+1):
    	ans = min(ans,(i*(j))%2019)
  print(ans)
elif a>=b:
  print(0)

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

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

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

print(ans)

Solution (Python):
from sys import exit, stderr, stdin
input = stdin.readline
def debug(var, name="hoge"):
    print(name +":" + str(type(var)) + " = " + repr(var), file=stderr)
    return


def main():
    L, R = [int(n) for n in input().split()]
    if (L//2019)<(R//2019):
        print(0)
    else:
        l = L%2019
        r = R%2019
        res = 2019**2
        for i in range(l,r+1):
            for j in range(i+1,r+1):
                res = min(res,(i*j)%2019)
        print(res)


if __name__ == "__main__":
    main()

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

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

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

length = min(2019,R-L)

R = L + length

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

print(ans)

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

i_max = min(r, l+2019)
mod_min = 2019
for i in range(l, i_max):
    j_max = min(r, i+2019)
    for j in range(i+1, j_max+1):
        mod = (i*j) % 2019
        if mod < mod_min:
            mod_min = mod

print(mod_min)

Solution (Python):
import math
import sys
import numpy as np
from collections import defaultdict, deque, Counter 
from itertools import accumulate, product, permutations,combinations, combinations_with_replacement
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from fractions import gcd

max_value = 1000000000
min_value = -1000000000
sys.setrecursionlimit(max_value)

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

L_mod = L % 2019

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

min_value = 2200

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

print(min_value)

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

Solution (Python):
def main():
    a,b = map(int,input().split())
    if a-b+1>=2019:
        print(0)
    else:
        mini = 2020
        for i in range(a,b+1):
            for j in range(a,i):
                joke = i*j%2019
                if joke<mini:
                    mini = joke
                    if mini == 0:
                        print(0)
                        return 0
        print(mini)
main()

Solution (Python):
import sys
from math import ceil
from operator import itemgetter as get

def input():
    return sys.stdin.readline().strip()

def iinput():
    return int(input())

def finput():
    return float(input())

def tinput():
    return input().split()

def rinput():
    return map(int, tinput())

def rlinput():
    return list(rinput())

def nod(a, b):
    while b: 
        a, b = b, a % b
    return a
 
def calc(n, c, d):
    return n - n // c - n // d + n // (c * d // nod(c, d))   


def main():
    l, r = rinput()
    q = []
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            res = i * j % 2019
            q.append(res)
            if res == 0:
                print(0)
                return 0
    print(min(q))
main()

Solution (Python):

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

Solution (Python):
mod = 2019

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

r1, r2 = (l-1)//mod, r//mod

if r1==r2:
	c1, c2 = l%mod, r%mod
	ans = min((i*j)%mod for i in range(l, r) for j in range(i+1, r+1))
	print(min(ans, 2018))
else:
	print(0)

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

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

min_mod = 10000

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

print(min_mod)

Solution (Python):
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b



def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2



def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)



def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


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

    if R - L > 5000:
        print(0)
        return

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


if __name__ == '__main__':
    main()

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

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

Solution (Python):
l,r = map(int,input().split())
if r-l > 2017:
  print(0)
else:
  mod_min = 2019
  for i in range(l,r+1):
    for j in range(i+1,r+1):
      mod = (i*j)%2019
      if mod <= mod_min:
        mod_min = mod
      else:
        pass
  print(mod_min)

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

if (r-l) > 2019:
  print(0)
else:
  a = [x for x in range(l, r+1)]
  res = [i*j%2019 for i in a for j in a if i!=j]
  print(min(res))

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

Solution (Python):
L, R = map(int,input().split())
r = []
if R - L >= 2018:
    print(0)
else:
    if L % 2019 == 0:
        print(0)
        exit()
    a = L // 2019
    if 2019*(a+1) <= R:
        print(0)
    else:
        inf = float('inf')
        ans = inf
        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 sys
input = sys.stdin.readline
L,R = map(int, input().split())
ans = 2020
for i in range(L,R+1):
	for j in range(i+1,R+1):
		if j % 2019 == 0:
			print(0)
			exit()
		if (i*j)%2019 < ans:
			ans = (i*j)%2019
print(ans)

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

if R - L > 2019:
    print(0)
else:
    ans = 2018
    for l in range(L, R+1):
        for r in range(l+1, R+1):
            t = (l * r) % 2019
            if ans > t:
                ans = t
    print(ans)

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

MOD = 2019
ans = 2018

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

"""

R = min(R, L+(2019)) 
MOD = 2019
ans = 2018

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

print(ans)
"""