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

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

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

Solution (Python):
L, R = map(int, input().split())
if R - L >= 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 = list(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 (i+1,r+1)]
	x.sort()
	print(x[0])

Solution (Python):
l, r = list(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 (i+1,r+1)]
	x.sort()
	print(x[0])

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

ans = 10 ** 8

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

print(ans)

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

if(r-l>3000):
  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 >= 2019:
	print(0)
else:
	R %= 2019
	L %= 2019
	if L > R:
		R += 2019
	min = float("inf")
	for i in range(L, R + 1):
		for j in range(i + 1, R + 1):
			mod = ((i % 2019) * (j % 2019)) % 2019
			if min > mod:
				min = mod
	print(min)

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

ans = 2019

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

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

ans = 2019

R = min(R, L + 2019)
for l in range(L, R):
    for r in range(l + 1, R + 1):
        ans = min(ans, (l * r) % 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):
        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 l in range(L, min(R+1, L+2019)):
    for r in range(L, min(R+1, L+2019)):
        if l < r:
            ans = min([ans, (l*r)%2019])
print(ans)

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

ans = 0
min_mod = 2019

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

          if min_mod > (i*j) % 2019:
            min_mod = (i*j) % 2019
      
    
    ans = min_mod
    
print(ans)

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

tmp = float("inf")
count_i = 0
count_j = 0

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

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

tmp = float("inf")
count_i = 0
count_j = 0

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

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

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

if (R - L) >= 2019:
    ans = 0
else:
    l_mod = L % 2019
    r_mod = R % 2019
    if l_mod > r_mod:
        ans = 0
    else:
        ans = 2018
        for i, j in itertools.combinations(list(range(L, R+1)), 2):
            ans = min(ans, (i * j) % 2019)
print(ans)

Solution (Python):
a,b = input().split(' ')
a = int(a)
b = int(b)
 
ans = 100000000000
 
for i in range(a, min(b, a + 2019)):
    for j in range(i + 1, min(b + 1, a + 2019)):
        if (i * j) % 2019 < ans:
            ans = (i * j) % 2019
 
print(ans)

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

if R - L >= 2018:
      ans = 0
else:
    tempL = L%2019
    tempR = R%2019
    if tempR - tempL < R-L-1:
        temp = tempL
        tempL = 0
        X = list(range(tempL,temp))
        Y = list(range(tempR,2018+1))
        Z = X + Y
    else:
        Z = list(range(tempL,tempR+1))

    ans = 2019
    for i in range(len(Z)):
        for j in range(i+1, len(Z)):
            if (Z[i]*Z[j])%2019 < ans:
                ans = (Z[i]*Z[j])%2019
print(ans)

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

print(ans)

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

if l%2019 + r - l >= 2019:
  print(0)
else:
  minmod=2019
  r = min(r, l+2019)
  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):
a = [ int(i) for i in input().split()]

b = (a[0]*a[1]) % 2019

for i in range (a[0], a[1]):
  for j in range (i+1, a[1]+1):
    b = min (b, (i*j)%2019)
    
    if b == 0:
      break
      
  if b == 0:
    break
    
print(b)

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

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

lq = l // 2019
lr = l % 2019
rq = r // 2019
rr = r % 2019

if lq < rq:
    print(0)
else:
    m = 2018 * 2018
    for i in range(lr,rr+1):
        for j in range(i+1,rr+1):
            if m > (i*j)%2019:
                m = (i*j)%2019
    print(m)

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

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

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

print(ans)

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

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

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

ans = 2019

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):
L2, R2= map(int, input().split())

L=L2%2019
R=R2%2019

hasamu=R2-L2
kotae=10000
if hasamu>2017:
  kotae=0
if L>R:
  kotae=0
else:
  for i in range(L,R):
    for j in range(i+1,R+1):
      seki=i*j
      amari=seki%2019
      if amari<kotae:
        kotae=amari
print(kotae)

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

Solution (Python):
l,r=map(int,input().split());s=range(l,r+1)[:673];print(min(i*j%2019for i in s for j in s if i<j))

Solution (Python):
import sys

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

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

for i in range(L, R):
    for j in range(i + 1, R + 1):
        rem_i = i % 2019
        rem_j = j % 2019
        min_rem = min((rem_i * rem_j) % 2019, min_rem)

print(min_rem)

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

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

Solution (Python):
L, R= map(int,input().split())
m = 2019
ans = 0
if R-L < m:
    ans = m
    L = L%m
    R = R%m
    lis = list(range(L,R+1))
    lis2 = [i%m for i in lis]
    for i in range(len(lis2)):
        for j in range(i+1,len(lis2)):
            if ans > (lis2[i]*lis[j])%m:
                ans = (lis2[i]*lis[j])%m
print(ans)

Solution (Python):
L2, R2= map(int, input().split())

L=L2%2019
R=R2%2019

hasamu=R2-L2
kotae=10000
if hasamu>2017:
  kotae=0
if L>R:
  kotae=0
else:
  for i in range(L,R):
    for j in range(i+1,R+1):
      seki=i*j
      amari=seki%2019
      if amari<kotae:
        kotae=amari
print(kotae)

Solution (Python):
L2, R2= map(int, input().split())

L=L2%2019
R=R2%2019

hasamu=R2-L2
kotae=10000
if hasamu>2017:
  kotae=0
if L>R:
  kotae=0
else:
  for i in range(L,R):
    for j in range(i+1,R+1):
      seki=i*j
      amari=seki%2019
      if amari<kotae:
        kotae=amari
print(kotae)

Solution (Python):
L,R = map(int,input().split())
if R - L > 2020:
    print(0)
    quit()
table = [i for i in range(L,R+1)]
from itertools import combinations


combi_list = list(combinations(table,2))

cand = []

for x in combi_list:
    cand.append((x[0] * x[1]) % 2019)

print(min(cand))

Solution (Python):

"""解説
2019で割った余りが同じであるような2数a, bにおいて、

a * c mod 2019
b * c mod 2019

は同じ値になる。

今求めたいのは、

(i*j) ≡ x (mod 2019)

のxの最小値である。

(例)
L=2020のとき、
mod 2019の世界では、2020は1と等価

よって、
2020 * 2021 は、
1 * 2 と等価

つまり、

(i*j) ≡ x (mod 2019) は、

(i%2019) * (j%2019) ≡ x (mod 2019) と同じ

そう考えると、i, jの調べる範囲は、

・R-L < 2019のとき、

L%2019 ≦ i < j ≦ R%2019

でよい。

・R-L >= 2019のとき、

 mod2019の1周分の範囲を取れるので、必ずiかjが0になり、そのとき最小値0になるから。


よって、(i, j)として調べる候補はたかだか2019**2 であり、全探索で間に合う。
"""

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

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

    L %= MOD
    R %= MOD
    ans = MOD
    for i in range(L, R):
        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):

"""解説
2019で割った余りが同じであるような2数a, bにおいて、

a * c mod 2019
b * c mod 2019

は同じ値になる。

今求めたいのは、

(i*j) ≡ x (mod 2019)

のxの最小値である。

(例)
L=2020のとき、
mod 2019の世界では、2020は1と等価

よって、
2020 * 2021 は、
1 * 2 と等価

つまり、

(i*j) ≡ x (mod 2019) は、

(i%2019) * (j%2019) ≡ x (mod 2019) と同じ

そう考えると、i, jの調べる範囲は、

L%2019 ≦ i < j ≦ min(R, (L+2019)%2019)

なぜL+2019かというと、 mod2019の1周分の範囲を取れば、必ず0をかけることができ、そのとき最小値0になるから。

よって、(i, j)として調べる候補はたかだか2019**2 であり、全探索で間に合う。
"""

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

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

    L %= MOD
    R %= MOD
    ans = MOD
    for i in range(L, R):
        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):
lr = input().split()
l = int(lr[0])
r = int(lr[1])

mini = 2018

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

    if mini==0:
      break
  if mini==0:
    break
print(mini)

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


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

elif L <= 2019 and R >= 2019 :
    print(0)

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

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

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

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

print(mod_min)

Solution (Python):
l,r=list(map(int,input().split()))
f=True
C=2019
if (r-l)<2019:
    for i in range(l,r+1):
        if C==0:
            break
        for t in range(i+1,r+1):
            if t*i%2019<C:
                C=t*i%2019
                if C==0:
                    break
else:
    C=0
print(C)

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

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

print(a)

Solution (Python):
l,r = map(int, input().split())
if r-l>2019:
    r=r-2019*((r-l)//2019-1)

ans=2019
for i in range(r-l):
    for j in range(r-l-i):
        
        if ((l+i)*(r-j))%2019<ans:
            ans=((l+i)*(r-j))%2019

print(ans)

Solution (Python):


import sys
import math
import collections
import itertools
def input(): return sys.stdin.readline().strip()
def gcd(x, y): return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y): return (x * y) // gcd(x, y)
MOD = 10 **9 + 7



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






ans = 3000

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

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

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

if R - L >= 2019:
    print(0)
    exit()
ans = (L * (L + 1)) % MOD
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())
ans = 100000000
for i in range(L,R + 1):
    if ans == 0:
        break
    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):
L,R=map(int,input().split())

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

Solution (Python):
l,r = (int(i) for i in input().split())
mod = 2019
if r-l >=2019:
    print(0)
else:
    ans = float('inf')
    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())
ql, modl = divmod(L,2019)
qr, modr = divmod(R,2019)
min = 3000
if qr-ql>0 :
    min=0
else:
    for i in range(modl,modr):
        for j in range(i+1,modr+1):
            min = min if (i*j) % 2019 > min else (i*j) % 2019
print(min)

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

num = l % 2019
if r >= l + 2019 - num:
    print(0)

else:
    result = 2019
    for i in range(num, r-l+num):
        for j in range(i+1, r-l+num+1):
            result = min(result, i*j%2019)

    print(result)

Solution (Python):
L, R = map(int,input().split())
tmp = 2020
if R // 2019 != L // 2019 or R % 2019 == 0 or L % 2019 == 0:
    print('0')
else:
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            modmin = i * j % 2019 
            if tmp > modmin:
                tmp = modmin
    print(tmp)

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

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

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

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

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

Solution (Python):
L,R = map(int, input().split())
rec = 2019
for i in range (2020):
    for j in range(2020):
        if i >= j or (L+j) > R:
            continue
        elif (((L+i)*(L+j)) % 2019) < rec:
            rec = ((L+i)*(L+j)) % 2019
print(rec)

Solution (Python):
import itertools
l,r=map(int,input().split())
d = r-l
mod_min=2018
if d > 2017:
    print(0)
else:
    lmod = l % 2019
    rmod = r % 2019
    if lmod < rmod:
        mod_set = set(range(lmod,rmod+1))
    else:
        mod_set = set(range(r+1))|set(range(l,2019))
    for x,y in itertools.combinations(mod_set,2):
        mod_min = min(mod_min,(x*y)%2019)
    print(mod_min)

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

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

print(ans)

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

Solution (Python):
n,m=map(int,input().split())
if n%2019>=m%2019:
  print(0)
  exit()
ans=1145141919
for i in range(n,m+1):
  for j in range(n,i):
    ans=min(ans,(i*j)%2019)
    if ans==0:
      print(0)
      exit()
print(int(ans))

Solution (Python):
n,m=map(int,input().split())

ans=1145141919
for i in range(n,m+1):
  for j in range(n,i):
    ans=min(ans,(i*j)%2019)
    if ans==0:
      print(0)
      exit()
print(int(ans))

Solution (Python):
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque

from itertools import product

from itertools import permutations

from itertools import combinations

from itertools import accumulate
from bisect import bisect_left, bisect_right





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


dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

INF = int(1e18)
MOD = int(1e9)+7 



L, R = l_inpl()

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

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

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

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

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

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

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




else:
	ans = 10000
	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=114514
  bia=1
  total=R-L+1
  for i in range(total-1):
    i2=i+L
    for j in range(total-bia):
      j2=j+L+bia
      if (i2*j2)%2019<ans:
        ans=(i2*j2)%2019
  print(ans)

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

while l<r:
  y=r
  while l<y:
    x=l*y
    x=x%2019
    if x<ans:
      ans=x
    if ans==0:
      break
    y=y-1
  if ans==0:
    break
  l=l+1
print(ans)

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

if R-L >= 2019:
    print("0")
else:
    sL = L % 2019
    sR = R % 2019
    minjo = 2019

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

    print(minjo)

Solution (Python):
def solve(string):
    l, r = map(int, string.split())
    if r - l >= 2019:
        return "0"
    return str(min([i * j % 2019 for i in range(l, r + 1) for j in range(i+1, r + 1)]))


if __name__ == '__main__':
    print(solve(input()))

Solution (Python):
L, R = list(map(int, input().split()))
RR = R + 1
ans = []

for i in range(L, R):
    for j in range(i + 1, RR):
        a = i * j % 2019
        ans.append(a)
        if a == 0:
            break
    
    else:
        continue
    break
print(min(ans))

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

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

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

import math




if R - L > 2030:
    L = 0
    R = 2019

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

Solution (Python):
def main():
    N, M = map(int, input().split())
    ans = -1
    for n in range(M)[N:]:
        for i in range(M + 1)[n + 1:]:
            mod = n * i % 2019
            if ans < 0 or mod < ans:
                ans = mod
                if ans == 0:
                    break
        if ans == 0:
            break
    print(ans)


if __name__ == '__main__':
    main()

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

Solution (Python):


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

mod = 2019

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

if R % mod > L % mod:
    L_mod = L % mod
    R_mod = R % mod
else:
    L_mod = R % mod
    R_mod = L % mod

lowest = mod
for i in range(L_mod, R_mod):
    for j in range(i + 1, R_mod + 1):
        r = i * j % mod
        lowest = min(r, lowest)

print(lowest)

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

mod_l = l % 2019
mod_r = r % 2019

if (r - l >= 2019) or (mod_r < mod_l):
  print('0')
else:
  rem = 2018
  for i in range(mod_l, mod_r):
    for j in range(i+1, mod_r+1):
      if rem < (i*j)%2019:
        continue
      else:
          rem = (i*j)%2019

  print(rem)

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

mod_l = l % 2019
mod_r = r % 2019

if (r - l > 2018) or (mod_l > mod_r):
  print('0')
else:
  vmin = 2018
  for i in range(mod_l, mod_r):
    for j in range(i+1, mod_r+1):
      mod = (i * j) % 2019
      if mod < vmin:
        vmin = mod

  print(vmin)

Solution (Python):
import sys
input = sys.stdin.readline


		
def main():
	l, r = map(int, input().split())
	
	if r - l >= 2019:
		return 0
	
	min_v = 2020
	for i in range(r+1)[l:]:
		for j in range(r+1)[i+1:]:
			v = i * j % 2019
			
			min_v = v if v < min_v else min_v
		
	print(min_v)
	
	


if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		
	ret = main()
	if ret is not None:
		print(ret)

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

Solution (Python):
l, r = map(int, raw_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())

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

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

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

print(ans)

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

def solve(L, R):
    if L // 2019 != R // 2019:
        return 0
    l, r = L % 2019, R % 2019
    if l == 0 or r == 0:
        return 0
    result = min(
        (i * j) % 2019
        for i in range(l, r)
        for j in range(i + 1, r + 1)
    )
    return result

print(solve(L, R))

Solution (Python):



def main():
    l, r = map(int, input().split())
    mod = 2019
    ans = mod
    r = min(r, l + mod)

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

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
L,R = map(int, input().split())
R = min(R, L+2019)
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):
import sys

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

yy = 2019

d = 2019

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

for i in range(L,R):
    im = i % yy

    for j in range(i+1, R+1):
        jm = j % yy

        if im * jm % yy <= d:
            d = im * jm % yy

print(d)

Solution (Python):


YEAR = 2019
ans_list = []

def main():
    l,r = map(int, input().split(" "))
    
    if l is 0:
        return l
    
    for i in range(l, r):
        for j in range(i+1, r+1):
            _i = i % YEAR
            _j = j % YEAR
            if ((_i * _j) % YEAR) is 0:
                return 0
            ans_list.append((_i * _j) % YEAR)
    
    if ans_list:
        return min(ans_list)
    else:
        return (r * l) % YEAR
    
if __name__ == "__main__":
    print(main())

Solution (Python):
mod=[]
answer = 2018
count = 0
sub=0
mod = [int(i) for i in input().split()]

    

for i in range(mod[0],mod[1]+1):
    if 2019<=mod[1]-mod[0]:
        answer = 0
        break
    for j in range(i+1,mod[1]+1):
        sub = (i*j)%2019
        if sub<answer:
            answer = sub
print(answer)

Solution (Python):

l, r = map(int,input().split())
l_mod, r_mod = map(lambda x: x % 2019, [l, r])
ans = 2019



if r - l <= 2019:
    R = r
    L = l
else:
    R = r_mod + 2019
    L = l_mod

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

Solution (Python):
mod=[]
answer = 2018
count = 0
sub=0
mod = [int(i) for i in input().split()]
if(mod[0]==mod[1]):
    answer = (mod[0]*mod[1])%2019

for i in range(mod[0],mod[1]+1):
    if 2019<=mod[1]-mod[0]:
        answer = 0
        break
    for j in range(i+1,mod[1]+1):
        sub = (i*j)%2019
        if sub<answer:
            answer = sub
print(answer)

Solution (Python):
mod=[]
answer = 2018
count = 0
sub=0
mod = [int(i) for i in input().split()]
if(mod[0]==mod[1]):
    answer = (mod[0]*mod[1])%2019

for i in range(mod[0],mod[1]+1):
    if 2019<=mod[1]-mod[0]:
        answer = 0
        break
    for j in range(i+1,mod[1]+1):
        sub = (i*j)%2019
        if sub<answer:
            answer = sub
    if count == 2018:
        break
    count = count + 1
print(answer)

Solution (Python):
L, R = map(int, input().split())
if R - L >= 2019:
    print(0)
else:
    result = float('inf')
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            mod = (i * j) % 2019
            if mod == 0:
                result = 0
                break
            elif mod < result:
                result = mod
    print(result)

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

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

r_min = min(l+2019,r)
inf = float('inf')
ans = inf

for i in range(l,r_min+1):
    for j in range(i+1,r_min+1):
        modu = i*j
        if modu%2019 <= ans:
            ans = modu%2019

print(ans)

Solution (Python):
import itertools

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

min_modulo = 2019
if R - L >= 2019:
    min_modulo = 0
else:
    num_list =\
        list(itertools.combinations(list(range(L, R + 1)), 2))
    for x, y in num_list:
        modulo = (x * y) % 2019
        if modulo == 0:
            min_modulo = 0
            break
        else:
            if modulo < min_modulo:
                min_modulo = modulo

print(min_modulo)

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):
            ans.append((i*j)%2019)
    print(min(ans))