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

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

print(mod)

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

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

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

r = min(r, l+4038)

min = 99999999
for i in range(l,r):
  for j in range(i+1,r+1):
    value = (i*j)%2019
    if min > value:
      min = value
print(min)

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




MOD = 2019
ouput = 2020 * 2020
for i in range(L, R + 1):
    for j in range(L, R + 1):
        if j > i and ouput > (i * j) % MOD:
            ouput = (i * j) % MOD
            if ouput == 0:
                print(ouput)
                exit()

print(ouput)

Solution (Python):

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

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

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

if r-l > 2019:
    s=list(range(0, 2019))
else:
    s=set()
    for i in range(l, r+1):
        s.add(i%2019)
    s=list(s)

ans=float('inf')
for i in range(len(s)):
    for j in range(i+1, len(s)):
        ans=min(ans, (s[i]*s[j])%2019)

print(ans)

Solution (Python):
L, R = map(int, input().split())
mod = 2019
ans = mod
for l in range(L, L + mod + 2):
    for r in reversed(range(R - mod - 2, R + 1)):
        if l >= r:
            break
        ans = min(ans, (l * r) % mod)
print(ans)

Solution (Python):
def resolve():
    l, r = map(int, input().split())
    result = 2018
    for i in range(l, r):
        for j in range(i+1, r+1):
            result = min(result, (i * j) % 2019)
            if result == 0:
                print(0)
                return
    print(result)
    
resolve()

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

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

Solution (Python):

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

least = 2*(10**9)+1
for i in range(l, r):
    for j in range(i+1, r+1):
        if (i * j % 2019) == 0:
            print(0)
            exit()
        least = min(least, (i * j % 2019))

print(least)

Solution (Python):

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

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

print(min_mod)

Solution (Python):
l, r = map(int, input().split())
l_mod2019 = l % 2019
r_mod2019 = r % 2019
x_list = [2019]
if r - l >=2018 or l_mod2019 >= r_mod2019:
    print(0)
else:
    for i in range(l_mod2019, r_mod2019):
        for j in range(l_mod2019 + 1, r_mod2019 + 1):
            if i < j:
                x = (i * j) % 2019
                if x < min(x_list):
                    x_list.append(x)
                else:
                    pass
            else:
                pass
    print(x_list[-1])

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

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

print(min(a))

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

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

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

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

ans = 2019

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

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

    sort_list = sorted(count_list)
    print(sort_list[0])

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

res = 10 ** 9
flag = False

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

        if i != j:

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

    if flag:
        break

print(res)

Solution (Python):
import math
from operator import itemgetter as ig
from collections import defaultdict as dd

INF = float("inf")
MOD = int(1e9 + 7)

import heapq
class heapque:
    def __init__(self, *args):
        self.que = []
        for arg in args:
            self.push(arg)
    def push(self, v):
        heapq.heappush(self.que, v)
    def pop(self):
        return heapq.heappop(self.que)

def gcd(v1, v2):
    if v2 == 0:
        return v1
    return gcd(v2, v1 % v2)
def lcm(v1, v2):
    return (v1 // gcd(v1, v2)) * v2

def bsr(a, v, lo=0, hi=None):
    if hi == None:
        hi = len(a) - 1
    if hi < lo:
        return lo
    mi = (lo + hi) // 2
    if v < a[mi]:
        return bsr(a, v, lo, mi - 1)
    else:
        return bsr(a, v, mi + 1, hi)

class uft:
    def __init__(self, n):
        self.height = [1] * n
        self.group = [-1] * n
    def root(self, v):
        if self.group[v] < 0:
            return v
        self.group[v] = self.root(self.group[v])
        return self.group[v]
    def size(self, v):
        return - self.group[self.root(v)]
    def merge(self, v1, v2):
        v1, v2 = self.root(v1), self.root(v2)
        if v1 == v2:
            return
        if self.height[v1] < self.height[v2]:
            self.group[v2] += self.group[v1]
            self.group[v1] = v2
            self.height[v2] = max(self.height[v1] + 1, self.height[v2])
        else:
            self.group[v1] += self.group[v2]
            self.group[v2] = v1
            self.height[v1] = max(self.height[v1] , self.height[v2] + 1)

def main():
    L, R = map(int, input().split())
    if 2019 < (R - L + 1):
        print(0)
    else:
        min_mod = INF
        for l in range(L, R + 1):
            for r in range(l + 1, R + 1):
                min_mod = min(min_mod, l * r % 2019)
        print(min_mod)

main()

Solution (Python):



def main():
    l, r = list(map(int, input().split(" ")))

    ans = 3000
    for i in range(l, r):
        for j in range(i+1, r+1):
            candidate = (i * j) % 2019
            if candidate < ans:
                ans = candidate
            if ans == 0:
                print(ans)
                return
    print(ans)
    return

main()

Solution (Python):



def main():
    l, r = list(map(int, input().split(" ")))
    
    ans = 3000
    for i in range(l, r):
        for j in range(i+1, r+1):
            candidate = (i * j) % 2019
            if candidate < ans:
                ans = candidate
            if ans == 0:
                return ans
    return ans


print(main())

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

ans = 3000

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

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

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

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

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

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

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

Solution (Python):
l,r=map(int,input().split())
ans=0
if r//2019==l//2019:
    ans=(l*(l+1))%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 = 2018

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

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

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

Solution (Python):
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 i * j % 2019 == 0:
      break
  else:
    continue
  break
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):
L, R = map(int, input().split())
if L == 0 or R - (L-1) >= 2019 or L%2019==0 or R%2019==0:
  print(0)
  exit()

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

Solution (Python):
L,R=map(int,input().split())
mod=2019
ans=2019
start=L//mod
goal=R//mod
if start!=goal:
  print(0)
else:
  a=L%mod
  b=R%mod
  for i in range(a,b):
    for j in range(i+1,b+1):
      if ans>(i*j)%mod:
        
        ans=(i*j)%mod
  print(ans)

Solution (Python):
import sys
import itertools

input = sys.stdin.readline

def func(l, r):
    mod_min = float('inf')

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

            if mod == 0:
                print(mod)
                exit()     

            elif mod < mod_min:
                mod_min = mod

    print(mod_min)

def main():
    l, r = [int(i) for i in input().split()] 
    func(l, r)
    

if __name__ == "__main__":
    main()

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

Solution (Python):
def main(l, r):
    score = float('inf')

    for i in range(l, r):
        for j in range(i + 1, r + 1):
            current = i * j % 2019
            score = min(score, current)
            if score == 0:
                return score

    return score


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

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

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

Solution (Python):
l, r = map(int, input().split())
mod1 = []
mod2 = []
cccc=0
for i in range(l,r+1):
  b=i%2019
  mod1.append(b)
  if b==0:
    cccc=1
    break

if cccc==1:
  print(0)
else:
  for i in range(len(mod1)-1):
    for j in range(i+1,len(mod1)):
      mod2.append((mod1[i]*mod1[j])%2019)
	
  print(min(mod2))

Solution (Python):
l, r = map(int, input().split())
ans = 10 ** 9
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(ans)
            exit()
print(ans)

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

Solution (Python):

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

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

Solution (Python):
l, r = map(int, input().split())
width = min(2019, r-l)
ans = float('inf')
for i in range(l, l+width):
    for j in range(i+1, l+width+1):
        mo = (i*j)%2019
        if mo < ans:
            ans = mo
print(ans)

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

if R >= L + 2019:
    R = L + 2019

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

print( minmod )

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

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

    return ans


print(main())

Solution (Python):

import sys
import math
from collections import defaultdict


sys.setrecursionlimit(10**7)
def input():
  return sys.stdin.readline()[:-1]


mod = 10**9 + 7


def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
  read_all = [tuple(map(int, input().split())) for _ in range(N)]
  return map(list,zip(*read_all))



L,R = II()

ans = float('inf')
for i in range(L,L+2018):
  for j in range(i+1,min(R+1,i+2019)):
    temp = i*j%2019
    if temp < ans:
      ans = temp
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):
L,R = [int(i) for i in input().split()]
list=[]
list2=[]
if R-L>=672:
    print(0)
else:
    for i in range(L,R+1):
        list.append(i%2019)
    else:
        for j in range(len(list)-1):
            for k in range(j+1,len(list)):
                list2.append((list[j]*list[k])%2019)
        else:
            print(sorted(list2)[0])

Solution (Python):
from itertools import combinations as f
L, R = map(int, input().split())

s = set(map(lambda x:x%2019, range(L, R+1)[:2019]))

print(min([i*j%2019 for i, j in f(s, 2)]))

Solution (Python):
l,r=map(int,input().split())
an=(l*(l+1))%2019

for i in range(l,r):
    for j in range(i+1,r+1):
        if (i*j)%2019 < an:
            an=(i*j)%2019
        if an==0:
            print("0")
            exit()

print(an)

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

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

Solution (Python):


L, R = map(int,input().split())
a = []

for i in range(L, R):
    for j in range(i+1,R+1):
        a.append((i*j)%2019)
        if (i*j)%2019 == 0:
            print("0")
            exit()

print(min(a))

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

ans = 2020

if (R-L) >= 2018:
    print(0)
else:
    X = list(range(L, R+1))
    for i in X[:len(X)-1]:
        for j in X[1:]:
            a = ((i%2019)*(j%2019))%2019
            if ans > a:
                ans = a
    print(ans)

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

for i in range(L, R):
	for j in range(i+1,R+1):
		a.append((i*j)%2019)
		if (i*j)%2019 == 0:
			print("0")
			sys.exit()

print(min(a))

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

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

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

min_value = 2019

for i in range(L, R+1):
	for j in range(L, R+1):
		if i >= j:
			continue

		value = (i * j) % 2019
		if value < min_value:
			min_value = value

		if min_value == 0:
			print(min_value)
			exit()

print(min_value)

Solution (Python):
l, r = (int(i) for i in input().split())
ans = float('inf')
for i in range(l,min(l+2019,r)):
    for j in range(i+1,min(i+1+2019,r+1)):
        val = i*j % 2019
        if val < ans:
            ans = val
print(ans)

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

m = 2018

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

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

print(m)

Solution (Python):
import atexit
import io
import sys











import math
R = lambda : map(int,input().split())
ans = sys.maxsize
n,k = R()
for i in range(n,k):
    for j in range(i+1,k+1):
        ans = min(ans,(i*j)%2019)
        if ans==0:
            print(ans)
            exit()

print(ans)

Solution (Python):
import atexit
import io
import sys

_INPUT_LINES = sys.stdin.read().splitlines()
input = iter(_INPUT_LINES).__next__
_OUTPUT_BUFFER = io.StringIO()
sys.stdout = _OUTPUT_BUFFER


@atexit.register
def write():
    sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())

import math
R = lambda : map(int,input().split())
ans = sys.maxsize
n,k = R()
for i in range(n,k):
    for j in range(i+1,k+1):
        ans = min(ans,(i*j)%2019)
        if ans==0:
            print(ans)
            exit()

print(ans)

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

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

print(res)

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


if int(R / 3) - int((L-1) / 3) > 0 and int(R / 673) - int((L-1) / 673) > 0:
    print(0)
else:
    res = 2018
    R2 = min(R+1, L+2019)
    for i in range(L, R2):
        for j in range(i+1, R2):
            res = min(res, ((i % 2019) * (j % 2019)) % 2019)
            if res == 1:
                break
    
    print(res)

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

if R - L >= 2019:
    ans = 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())
ans=2019
if L+2019<=R:
    for i in range(0,2019):
        for j in range(i+1,2019):
            if (i*j)%2019<ans:
                ans=(i*j)%2019
elif L%2019<R%2019:
    for i in range(L%2019,R%2019+1):
        for j in range(i+1,R%2019+1):
            if (i*j)%2019<ans:
                ans=(i*j)%2019
else:
    for i in range(L%2019,R%2019+2020):
        for j in range(i+1,R%2019+2020):
            if (i*j)%2019<ans:
                ans=(i*j)%2019
print(ans)

Solution (Python):
from itertools import combinations as f
l,r=map(int,input().split())
print(min([i*j%2019 for i,j in f(range(l,r+1)[:2019],2)]))

Solution (Python):
from itertools import combinations as f
l,r=map(int,input().split())
s=set(map(lambda x:x%2019,range(l,r+1)[:2019]))
print(min([i*j%2019 for i,j in f(s,2)]))

Solution (Python):
def main():
    l, r = map(int, input().split())
    res = 1 << 30
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            res = min(res, (i * j) % 2019)
            if res == 0:
                print(res)
                return
    print(res)


if __name__ == "__main__":
    main()

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

new_list = []
for i in range(L,R):
    for j in range(i+1, R+1):
        new_list.append((i*j)%2019)
        
        if (i*j)%2019 == 0:
            print(0)
            sys.exit()
print(min(new_list))

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

Solution (Python):
l,r= map(int, input().split())
check=min(r-l+1,2019)
min_=2019

for i in range(l,l+check):
    for j in range(i+1,l+check):
        rest=(i*j)%2019
        if rest<min_:
            min_=rest
print(min_)

Solution (Python):
def main():
  l, r = map(int, input().split(' '))
  if r - l >= 2019:
    print(0)
  else:
    ans = l * r
    i = l
    while i < r:
      j = i + 1
      while j <= r:
        ij = i * j
        if mod(ij) < ans:
          ans = mod(ij)
        j += 1
      i += 1
    print(ans)


def mod(n):
  if n < 2019:
    return n
  else:
    return(n % 2019)


if __name__ == '__main__':
  main()

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

for i in range(l,r):
	for j in range(i+1,r+1):
		a.append((i*j)%2019)

		if (i*j)%2019 == 0:
			print(0)
			sys.exit()
print(min(a))

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

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

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

Solution (Python):
from itertools import combinations
import math


def solve():
    l, r = map(int, input().split())
    a = 2018
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            amari = (i * j) % 2019
            if amari == 0:
                return 0
            elif amari < a:
                a = amari
    return a


if __name__ == "__main__":
    print(solve())

Solution (Python):


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

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

Solution (Python):
"""


     = sys.stdin.readline().rstrip()
     = list(sys.stdin.readline().rstrip())


     = int(sys.stdin.readline())
     = map(int, sys.stdin.readline().split())
     = list(map(int, sys.stdin.readline().split()))
     = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  


a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654


char_list = list("abcd") 
"""

import math
import sys
import itertools
import queue
from fractions import gcd

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

mod = 2019

if __name__ == "__main__":
     L, R = map(int, sys.stdin.readline().split())
     if R - L > 2019:
          print(0)
          exit()
     mod_min = 2020
     for i in range(L, R + 1):
          for j in range(i + 1, R + 1):
               m_tmp = (i * j) % mod
               
               if m_tmp < mod_min:
                    mod_min = m_tmp
     print(mod_min)

Solution (Python):
L, R = map(int, input().split())
div = 2019
min_mod = div - 1
flag = False

for i in range(L, R):
  for j in range(i+1, R+1):
    mod = (i * j) % div
    if mod == 0:
      min_mod = mod
      flag = True
    elif mod < min_mod:
      min_mod = mod
    if flag:
      break
  if flag:
    break
    
print(min_mod)

Solution (Python):
def remainder_min(l,r):
    sml = 2*(10**9)**2+1
    _r = min(r,l+2019)
    for i in range(l,_r):
        for j in range(i+1,_r+1):
            num = i * j
            rem = num % 2019
            if rem == 0:
                return 0
            sml = min(sml,rem)
    return sml

if __name__ == '__main__':
    l,r = map(int,raw_input().split())
    print remainder_min(l,r)

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

Solution (Python):
L, R= (int(i) for i in input().split())  
 
_min = 2018
 
for g in range(R-L):
	_start = (L+g)*(L+g+1)
	for i in range(R-L-g):
		_min = min(_min, _start%2019)
		_start += L+g
		if _min == 0:
			break
	if g == 2019 or _min == 0:
		break

print(_min)

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

_min = 2018
_init = L%2019

for g in range(R-L):
	plus = _init + g
	_start = (plus*(plus+1))%2019
	for i in range(R-L-g):
		_min = min(_min, _start)
		_start += plus
		_start = _start%2019
		if _min == 0:
			break
	if g == 2019 or _min == 0:
		break

print(_min)

Solution (Python):

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


if R - L >= mod:
  print(0)
else:
  s = []
  for i in range(L, R):
    for j in range(i+1, R+1):
      s.append((i*j) % mod)
  s.sort()
  print(s[0])

Solution (Python):

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

if R - L >= mod:
  print(0)
else:
  s = []
  for i in range(L, R):
    for j in range(i+1, R+1):
      s.append((i*j) % mod)
  s.sort()
  print(s[0])

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

if R - L >= mod:
    print(0)
else:
    s = []
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            s.append((i * j) % mod)
    s.sort()
    print(s[0])

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

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

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

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

        if res == 0: break

print(res % 2019)

Solution (Python):
import sys
L,R = map(int,input().split())
ans = 2018
for i in range(L,R):
    for j in range(i+1,R+1):
        tmp = (i*j)%2019
        if tmp == 0:
            print(0)
            sys.exit()
        elif tmp < ans:
            ans = tmp
print(ans)

Solution (Python):

import sys

MOD = 2019  

def solve(L: int, R: int):
    if(R-L >= 2019):
        print(0)
    else:
        m = 2020
        for i in range(L,R+1):
            for j in range(i+1,R+1):
                m = min(m,(i*j)%2019)
        print(m)
    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())

ans = 2018
tmp = 0

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

		if tmp == 0:
			ans = tmp
			print(ans)
			exit()
		else:
			ans = min(tmp, ans)

print(ans)

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

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

for i in range(L,R+1):
  counterJ = 0
  for j in range(i+1, R+1):
    modResult = (i * j) % 2019 
    if i == L and j == L+1:
      result = modResult
    elif result > modResult:
      result = modResult
    if counterJ == 2019:
      break
    counterJ += 1
    
  counter += 1
  if counter == 2019:
    break;
    
print(result)

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

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

        if mod == 0:
            ans = 0
            break
        if mod < ans:
            ans = mod
print(ans)

Solution (Python):

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

Solution (Python):



l, r = list(map(int, input().split()))
count = 0
amari_list = []

for i in range(l, r+1):
    count_j = 0
    for j in range(i+1, r+1):
        amari_list.append(i * j % 2019)
        if count_j == 2019:
            break
        count_j += 1

    if count == 2019:
        break
    count += 1

ans = min(amari_list)
print(ans)

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

L=L%2019
R=L+d
if d>=2019:
  print(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())
d=R-L
ans=2019

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

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

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

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

if (R-L) > 2019:
  R = 2019 + L

lst = []
for i in range(L, R):
  for j in range(i+1, R+1):
    a = (i*j) % 2019
    lst.append(a)
    
print(min(lst))