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 = 2019
ans = 10 ** 7
results = [False for _ in range(2019)]
for low in range(L, R+1):
    for up in range(low+1, R+1):
        ans = min(ans, low * up % mod)
        if ans == 0:
            print(ans)
            exit()
        
        
        
        
print(ans)

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

ans = 2018
if R-L >= 2018:
	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 = [int(i) for i in input().split()]

if l//2019 == r//2019:
  min_mod = 2017*2018
  for i in range(l, r):
    for j in range(l+1, r+1):
      temp = (i*j)%2019
      if temp < min_mod:
        min_mod = temp
  print(min_mod)
  
else:
  print(0)

Solution (Python):
import itertools

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

ans = 2018
for i in itertools.combinations(range(L, min(L+2020, R+1)), 2):
    ans = min(ans, i[0]*i[1] % 2019)

print(ans)

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

if not L // 2019 == R // 2019:
    print(0)
else:
    L %= 2019
    R %= 2019
    ans = 2020
    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())

if L == 0:
    print(0)
elif not L // 2019 == R // 2019:
    print(0)
else:
    L %= 2019
    R %= 2019
    ans = 2020
    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):
import sys
l, r = (int(x) for x in input().split())
tmpmin = 2019
if r-l >= 2019:
    print(0)
else:
    for i in range(l, r):
        for j in range(l+1, r+1):
            tmp = (i*j)%2019
            if tmp < tmpmin:
                tmpmin = tmp
                if tmpmin == 0:
                    print(tmpmin)
                    sys.exit()
    print(tmpmin)

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


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

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

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

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

print(r)

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

l = L % 2019
r = min(R-L+l,2019)

ans = 2019

if r == 2019:
    print(0)
    exit()

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

print(ans)

Solution (Python):
L, R = map(int,input().split())
if R-L >= 2019:
    print(0)
    exit(0)
ans = 100000
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())
a = (l-1)//2019
b = r//2019
if a!=b:
  print('0')
  exit()
l=l%2019
r=r%2019
res=2019
for i in range(l, r+1):
  for j in range(i+1, r+1):
    temp = (i*j)%2019
    if temp<res:
      res=temp
print(res)

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())
l1=l%2019
lm=l+2019-l1

if r>lm:
    ans=0
else:
    r1=r%2019
    ans=4072324
    for x in range(l1,r1+1):
        for z in range(x+1,r1+1):
            ansnow=x*z%2019

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

Solution (Python):
l,r=map(int,input().split())
mod=2019
if r - l >= 2019:
    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>=2018):
    print(0)
else:
    ans = 2018
    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())

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

Solution (Python):
L, R = map(int, input().split())
if R-L+1 >= 2019:
    print(0)
else:
    ans = 2019
    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 = list(map(int, input().split()))
if R - L >= 2019:
  print(0)
else:
  M=2019
  for i in range(L,R):
    for j in range(i+1,R+1):
      K=i * j % 2019
      if K < M:
        M = K
  print(M)

Solution (Python):
import sys, math, itertools, bisect, copy, re
from collections import Counter, deque, defaultdict






INF = float('inf')
MOD = 10 ** 9 + 7
EPS = 10 ** -7
sys.setrecursionlimit(1000000)








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

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

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 itertools

l, r = map(int, input().split())
if(r - l) > 2019:
    ans = 0
else:
    ans = 2018
    combs = list(itertools.combinations_with_replacement(range(l, r + 1), 2))
    for comb in combs:
        if comb[0] != comb[1]:
            a = (comb[0] * comb[1]) % 2019
            if ans > a:
                ans = a

print(ans)

Solution (Python):
import itertools

l, r = map(int, input().split())
if(r - l) > 2019:
    ans = 0
else:
    a = []
    combs = list(itertools.combinations_with_replacement(range(l, r + 1), 2))
    for comb in combs:
        if comb[0] != comb[1]:
            a.append((comb[0]*comb[1]%2019))

    ans = min(a)

print(ans)

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

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

Solution (Python):
from collections import Counter
from collections import deque
from functools import reduce
from operator import mul
from pprint import pprint
import bisect
import copy
import fractions
import itertools
import math
import queue
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers): return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers): return reduce(LCM, numbers)
def LCM(m, n): return (m * n // fractions.gcd(m, n))
def COMBINATION(n, r):
    if n < 0 or r < 0 or n < r:
        return 0
    r = min(n-r, r)
    if r == 0:
        return 1
    o = reduce(mul, range(n, n - r, -1))
    u = reduce(mul, range(1, r + 1))
    return o // u
class UnionFind():

    def __init__(self, n):
        self.n = n
        self.node = [i for i in range(n)]
        self.size = [1 for _ in range(n)]

    def same(self, x, y):
        return bool(self.root(x) == self.root(y))

    def root(self, x):
        if self.node[x] == x:
            return x
        else:
            self.node[x] = self.root(self.node[x])  
            return self.node[x]

    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x == y:
            return  
        if self.size[x] < self.size[y]:
            x, y = y, x
        self.node[y] = x
        self.size[x] += self.size[y]

    def return_size(self, x):
        return self.size[self.root(x)]


left, right = MI()
if right - left >= 2019:
    print(0)
else:
    ans = INF
    for i in range(left, right+1):
        for j in range(i+1, right+1):
            ans = min(ans, (i * j) % 2019)
            if ans == 0:
                print(0)
                exit()
    print(ans)

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

Solution (Python):
l,r = map(int, input().split())
n = r - l + 1
if 2019<=n:
    print(0)
elif 3<=n and n<2019:
    for k in range(l,r+1):
        if k%673==0:
            print(0)
            exit()

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

Solution (Python):
import itertools
import sys

num = list(map(int,input().split()))
per = []

for i in range(num[0],num[1]+1):
    for j in range(num[0],num[1]+1):
        if i <= j:
            break
        else:
            per.append((i*j)%2019)
            if (i*j)%2019 == 0:
                print(0)
                sys.exit()
per.sort()

print(per[0])

Solution (Python):
list1 = [int(i) for i in input().split()]
l = list1[0]
r = list1[1]
if (l// 2019 != r//2019):
	print(0)
else:
	max1 = 10000000000
	if l - r >= 2019:
		for i in range(l,l+2020):
			for j in range(i+1,l+2020):
				temp = ((i%2019)*(j%2019))%2019
				if temp < max1 :
					max1 = temp
	else :
		for i in range(l,r+1):
			for j in range(i+1,r+1):
				temp = ((i%2019)*(j%2019))%2019
			
				if temp < max1 :
					max1 = temp
		
	print(max1)

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

minimum = L * R
for i in range(L, min(R, L+2020)):
    for j in range(i+1, min(R+1, i+2021)):
        
        minimum = min(minimum, i * j % 2019)
        

print(minimum)

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

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

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

Solution (Python):
L, R = [int(i) for i in(input().split(' '))]
minn=2019
if R-L+1>2019:
  print(0)
  exit()
for i in range(L,R):
    for j in range(i+1,R+1):
        mo = i*j
        amari = mo%2019
        minn = min(amari,minn)
        if minn==0:
          break
print(minn)

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

choices = set()
for i in range(L, R + 1):
    choices.add(i % 2019)
    if len(choices) == 2019:
        break

min_ = None
choices = sorted(choices)
for i in range(len(choices)):
    vi = choices[i]
    for j in range(i + 1, len(choices)):
        vj = choices[j]
        if min_ is None or (vi * vj) % 2019 < min_:
            min_ = (vi * vj) % 2019
print(min_)

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

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

print(ans)

Solution (Python):
def main02():
    data = input().split()
    num = []

    for i in range(2):
        num.append(int(data[i]))
    if (num[1]-num[0]) > 2020:
        num[1] = num[0] + 2020
    kaisu = num[1] - num[0] + 1
    result = 3000
    for i in range(num[0],num[0]+kaisu-1,1):
        for j in range(i+1,num[0]+kaisu,1):
            kari = (i * j) % 2019
            if kari < result:
                result = kari
    print(result)


if __name__ == "__main__":
    main02()

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

Solution (Python):
def main():
    L, R = map(int, input().split())
    if R // 2019 > L // 2019:
        print(0)
        return
    retval = 2019
    for i in range(L, R):
        for j in range(i+1, R+1):
            retval = min(retval, (i % 2019 * j % 2019) % 2019)
            if retval == 0:
                print(0)
                return
            
    print(retval)
    return
    
if __name__ == '__main__':
    main()

Solution (Python):
import sys

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

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

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

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

Solution (Python):
l, r=map(int, input().split())
x, y=l//2019, r//2019
p=0
if x==y:
	p=2019
	for i in range(l, r):
		for j in range(i+1, r+1):
			p=min(p, (((i%2019)*(j%2019))%2019))
			if not p:
				break
		if not p:
			break
print(p)

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

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

ans = 10e8

for sr in range(l + 1, r + 1):
    for sl in range(l, sr):
        ans = min(ans, sl * sr % YEAR)
        if ans == 0:
            break
    if ans == 0:
        break

print(ans)

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

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

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

Solution (Python):
from itertools import combinations
L, R = map(int, input().split())
if (L % 2019 > R % 2019) or R - L >=2019:
    print(0)
else:
    ans = 2018
    for i, j in combinations(range(L, R + 1), 2):
        a = i % 2019
        b = j % 2019
        mod = (a * b) % 2019
        if ans > mod:
            ans = mod
    print(ans)

Solution (Python):
L, R = map(int, input().split())
if L % 2019 == 0:
    low = L // 2019
else:
    low = L // 2019 + 1
high = R // 2019

if low <= high:
    
    print(0)
else:
    minmod = 2018
    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)

Solution (Python):
l, r = (int(x) for x in input().split())
tmpmin = 2019
if r-l >= 2019:
    print(0)
else:
    for i in range(l, r):
        for j in range(l+1, r+1):
            tmp = (i*j)%2019
            if tmp < tmpmin:
                tmpmin = tmp
                if tmpmin == 0:
                    break
    print(tmpmin)

Solution (Python):


"""
L<=i<=j<=R
(i×j)mod 2019
0≤L<R≤2×10^9
"""

def solve(L, R):
    if R - L > 2019:
        return 0
    
    tmp = 2019
    for i in range(L, R):
        for j in range(R, i, -1):
            if (i * j) % 2019 < tmp:
                tmp = (i * j) % 2019
    return tmp
 
L, R = map(int, input().split())
print(solve(L, R))

Solution (Python):
import sys

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

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

ans = 2019
   
for i in range(L, R):

    for j in range(i + 1, R + 1):
        tmp = int((i * j) % inf)
        ans = min(ans, tmp)
        if ans == 0:
            break
    if ans == 0:
        break

print(ans)

Solution (Python):

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

Solution (Python):
import sys

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

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

ans = 2018
L = L % 2019
R = R % 2019

if L >= R:
    print(0)
    sys.exit()
for i in range(L, R):

    for j in range(i + 1, R + 1):
        tmp = int((i * j) % inf)
        ans = min(ans, tmp)
        if ans == 0:
            break
    if ans == 0:
        break

print(ans)

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

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

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

Min = 2019
N = R - L

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

print(Min)

Solution (Python):

a, b = map(int, input().split())
if b-a>=673:
    print(0)
else:
    x=[]
    for i in range(a, b):
        for j in range(i+1, b+1):
            x.append((i*j)%2019)
    print(min(x))

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

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

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

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

Solution (Python):
import sys
L,R=map(int,input().split())
modifyed=[]
flag=0
for i in range(L,R+1):
    modifyed.append(i%2019)
    if i%2019==0:
        print(0)
        sys.exit()
ans=[]
for m in range(len(modifyed)):
    for j in range(m+1,len(modifyed)):
        ans.append(modifyed[m]*modifyed[j]%2019)
        if modifyed[m]*modifyed[j]%2019==0:
          print(0)
          sys.exit()
print(min(ans))

Solution (Python):
import sys
L,R=map(int,input().split())
modifyed=[]
flag=0
for i in range(L,R+1):
    modifyed.append(i%2019)
    if i%2019==0:
        print(0)
        sys.exit()
ans=[]
for m in range(len(modifyed)):
    for j in range(m+1,len(modifyed)):
        ans.append(modifyed[m]*modifyed[j]%2019)
print(min(ans))

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

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

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

Solution (Python):
L,R=map(int,input().split())
if R-L>=673:
    print(0)
else:
    x=[]

    for i in range(L,R):
        for j in range(i+1,R+1):
            x.append((i*j)%2019)

    print(min(x))

Solution (Python):


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

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

    L %= MOD
    R %= MOD

    ans = MOD
    for i in range(L, R+1):
        for j in range(i+1, R+1):
            ans = min(ans, (i*j)%MOD)
            if ans == 0:
                print(ans)
                return
    print(ans)
    

if __name__ == "__main__":
    solve()

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

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

print(m)

Solution (Python):
from heapq import heappush, heappop
import re
from collections import deque
import sys
import math
input = sys.stdin.readline


def int_raw():
    return int(input())


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


def ints_raw():
    return tuple(map(int, ss_raw()))


DIV = 10**9+7


def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def ncr(n, r, mod=DIV):
	r = min(r, n-r)
	ret = 1
	for i in range(1, r+1):
		ret = ret * (n-i+1) % mod
		ret = ret * mod_inv(i, mod) % mod
	return ret


def main():
    L,R = ints_raw()
    neoR = min(L+2019,R+1)
    ans = 2019
    for i in range(L,neoR):
        for j in range(i+1,neoR):
            ans = min((i*j)%2019,ans)
    return ans
print(main())

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

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

Solution (Python):
import itertools

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

if r-l >= 2019:
    print(0)
else:
    mods = []
    nums = list(range(l,r+1))
    for v in itertools.combinations(nums,2):
        mods.append(v[0]*v[1]%2019)
    print(min(mods))

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










modmin =2019 -1
for i in range(L,R):
  for j in range(i+1,R+1):
    mod3 = (i*j)%2019
    if mod3 == 0:
      print(0)
      sys.exit()
    elif modmin > mod3:
      modmin = mod3

print(modmin)

Solution (Python):

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

a = L // 2019
L -= a * 2019
R -= a * 2019
R = min(R, L + 2018)

ans = 10000


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=[]
for i in range(l,r+1):
    for j in range(i+1,r+1):
        ans.append((i*j)%2019)
        if (i*j)%2019==0:
            print('0')
            exit()
print(min(ans))

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


all_mod = []

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

        all_mod.append(mod)

        if mod == 0:
            break

        cnt += 1

        if cnt > 2019:
            break

    if mod == 0:
        break

    cnt1 += 1
    if cnt1 > 2019:
        break

print(min(all_mod))

Solution (Python):
import sys
l,r=map(int,sys.stdin.readline().split())
r=min(r,l+673)
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):
import numpy as np

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

Solution (Python):


import math
l, r = map(int, input().split())
ans = 2018

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

print(ans)

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

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

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

ans = 2019

for left in range(L, min(L+2019, R)):
    for right in range(left+1, min(R+1, left+1+2019)):
        ans = min(ans, right * left % 2019)
print(ans)

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

if R * (R - 1) < 2019:
    print(L * (L + 1))
    exit()

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

print(ans)

Solution (Python):
mod = 2019
l, r = map(int, input().split())
e = []
for i in range(l, min(r, l + mod * 2) + 1):
    e.append(i % mod)
e.sort()

ans = mod
for i in range(len(e)):
    for j in range(i + 1, len(e)):
        ans = min(ans, e[i] * e[j] % mod)
        if ans == 0:
            break
    else:
        continue
    break
print(ans)

Solution (Python):
l,r=map(int,input().split())
mod=2019
if l%mod==0 or r%mod ==0 or l//mod != r//mod:
    print(0)
    exit()
l%=mod
r%=mod

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

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




r = min(r, l + 2019)

min = -1
for tl in range(l, r + 1):
  for tr in range(tl + 1, r + 1):
    tmp = (tl * tr) % 2019
    if min == -1 or min > tmp:
      min = tmp

print(min)

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

Solution (Python):
L, R = list(map(int, input().split()))
b = 0
ans = 10000

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

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

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

Solution (Python):
from sys import exit, stdin
L, R = [int(_) for _ in stdin.readline().rstrip().split()]
if R - L > 3000:
    print(0)
else:
    ans = 2018
    for i in range(L, R):
        for j in range(i+1, R+1):
            ans = min(ans, (i*j)%2019)
    print(ans)

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

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

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

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

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

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

d=2018
for i in range(min(R-L,2019)):
  a=L+i
  for j in range(min(R-a,2019)):
    b=a+j+1
    c=(a*b)%2019
    if c<d:
      d=c
print(d)

Solution (Python):
l,r=[int(i) for i in input().split()]
mod = 2019
ans=10**9

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

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

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

aaa = []

if r - l >= 2019:
    ans = 0
else:
    r_mod = r % 2019
    l_mod = l % 2019
    if l_mod > r_mod:
        ans = 0
    else:
        for i in range(l_mod, r_mod+1):
            for j in range(i+1, r_mod+1):
                rl_mod = i * j % 2019 
                aaa.append(rl_mod)
        ans = min(aaa)

print(ans)

Solution (Python):
a, b = map(int, input().split())
c = 10 ** 9
for i in range(a, b+1):
    for j in range(i+1, b+1):

        c = min(c, i * j % 2019)
        if c == 0:
            print(c)
            exit()
print(c)