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):
import itertools
L, R = [int(_) for _ in input().split()]
if R - L > 2017 or L % 2019 > R % 2019:
    print(0)
    exit()

L %= 2019
R %= 2019
ans = min(i * j % 2019 for i, j in itertools.combinations(range(L, R + 1), 2))
print(ans)

Solution (Python):
L,R = map(int,input().split())
right = min(L+2019, R+1)
minimum = 2019

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

print(minimum)

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

Solution (Python):
def main():
    L, R = map(int, input().split())
    minCount = float('inf')

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

if __name__ == "__main__":
     main()

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

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

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

Solution (Python):
a,b=map(int,input().split())
ans=2019
for i in range(b-a+1):
  for j in range(b-a+1):
    hoge=a+i
    huga=a+j
    if(hoge<huga and huga<=b):
      ans=min((hoge*huga)%2019,ans)
      if(ans==0):
        print(0)
        exit()
print(ans)

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

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

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

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

minmod = 2 * 10 ** 9


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

for i in range(l,r):
    imod = i % 2019
    for j in range(i+1,r+1):
        jmod = j % 2019
        minmod = min(minmod, (imod * jmod) % 2019)
        if minmod == 0:
            break

print(minmod)

Solution (Python):
import itertools

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

R = min(R, L+2019)

minimum = 2018

for c in list(itertools.combinations(list(range(L, R+1)),2)):
    mod = (c[0]*c[1]) % 2019
    if mod < minimum:
        minimum = mod
        
print(minimum)

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


ans = 2020
if R-L>=2019:
    ans = 0
L %= 2019
R %= 2019


if L>=R:
    R+=2019



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


        

print(ans)

Solution (Python):
import itertools

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

R = min(R, L+2019)

mods = []

for c in list(itertools.combinations(list(range(L, R+1)),2)):
    mods.append((c[0]*c[1]) % 2019)

print(min(mods))

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

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

print(minimum)

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

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

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

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

Solution (Python):



BASE = 2019


def find_min_val(L, R):
    if R - L > 3000:
        return 0

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

    return res


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

    ans = find_min_val(L, R)
    print(ans)


main()

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  l,r=LI()

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

  ans.sort()

  return ans[0]

print(main())

Solution (Python):

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

    print(res)

main()

Solution (Python):
L,R= list(map(int, input().split()))
N = min(R-L+1,2019)
MOD = 2019
m = MOD

for i in range(L,L+N):
    for j in range(i+1,L+N):
        m = min(m,(i*j)%MOD)

print(m)

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

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

print(minimum)

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

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

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

base = 2019
l_mod = l % base
r_mod = r % base

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

Solution (Python):
def main():
  l, r = map(int, input().split())
  LUT = [[(i*j)%2019 for i in range(2019)] for j in range(2019)]
  ans = 2018
  m = 2019
  for i in range(l, r + 1):
    for j in range(i + 1, r + 1):
      ans = min(ans, LUT[i % m][j % m])
      if ans == 0:
        return 0
  return ans

print(main())

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

rl = r-l
l2 = l%2019
r2 = l2+rl

if rl>2019:
    print(0)
else:
    min_dif = 2019
    for i in range(l2, r2):
        for j in range(i+1, r2+1):
            if (i*j)%2019 < min_dif:
                min_dif = (i*j)%2019
    print(min_dif)

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

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

l = L // mod
r = R // mod

if l != r:
    print(0)
else:
    l_ = L % mod
    r_ = R % mod
    ans = 2019
    for i in range(l_, r_):
        for j in range(i+1, r_+1):
            a = i * j % mod
            ans = min(ans, a)
            if ans == 0:
                break
        if ans == 0:
            break
    print(ans)

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

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

if r-l >= 2019:
    print(0)
else:
    ll = []
    for i in range(l, r+1):
        for j in range(l, r+1):
            if i == j:
                pass
            else:
                ll.append(i*j%2019)
    print(min(ll))

Solution (Python):
import numpy as np

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

if R-L < 2019:
    ans = 10**20

    for i in range(L, R):
        ans = min(ans, np.min(np.arange(i+1, R+1) * i % 2019))
else:
    ans = 0
print(ans)

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

if R-L < 2019:
    ans = 10**20

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

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

diff = R - L

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

print(ans)

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

L_quo = int((L - L % 2019) / 2019)
R_quo = int((R - R % 2019) / 2019)

if L_quo != R_quo:
    print(0)
else:
    L_rem = L % 2019
    R_rem = R % 2019
    for i in range(L_rem, R_rem):
        for j in range(i + 1, R_rem + 1):
            a = (i * j) % 2019
            ans = min(ans, a)
    print(ans)

Solution (Python):





def main():
  MOD = 2019
  modset = [[(i*j)%MOD for i in range(2019)] for j in range(2019)]
  L,R = map(int, input().split())

  ans = 2018
  for i in range(L,R+1):
    for j in range(L,i):
      ans = min(ans,modset[i%MOD][j%MOD])
      if ans==0:
        return ans
  return ans


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

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

Solution (Python):
L, R = map(int,input().split())
l , r = L//2019, R//2019
if R - L >= 2019:
    print(0)

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

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

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

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

Solution (Python):
import sys

def main():
    input = sys.stdin.readline
    L, R = map(int, input().split())
    R = min(R, L + 2019)

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

    return ans


if __name__ == '__main__':
    print(main())

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

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

Solution (Python):


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

l,r = [int(i) for i in readline().split()]
if r-l > 2019:
    print(0)
    exit()

ans = 2222
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


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





s = l // 2019
p = l % 2019

t = r // 2019
q = r % 2019

if s == t:
  
  
  x = numpy.arange(p, q + 1, 1)
  rem = numpy.dot(x.reshape(-1, 1), x.reshape(1, -1))
  rem %= 2019
  row, col = rem.shape
  rem += numpy.identity(row, dtype=int) * 2019
  min_rem = numpy.amin(rem)
  
  print(min_rem)

else:
  print(0)

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

Solution (Python):
import sys

def solve():
    input = sys.stdin.readline
    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(L + 1, R + 1):
                ans = min(ans, (i * j) % 2019)
        print(ans)
    
    return 0

if __name__ == "__main__":
    solve()

Solution (Python):
firstvar = input()
l = int(firstvar.split(" ")[0])
r = int(firstvar.split(" ")[1])
i = l
min = 2019
if (r/2019 - l/2019) >= 1:
    print(0)
else:
    for i in range(l,r + 1):
        for j in range(i + 1, r + 1):
            mod = (i*j)%2019
            if mod < min:
                min = mod
                if mod == 0:
                    break;
    print(min)

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

    print((a)%2019)

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

mod = 2018

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

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

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

Solution (Python):
import sys
n,r=map(int,input().split())
roop_n=0
ans=0
min_=2019

if r-n>=2019:
    roop_n=n+2019
else:
    roop_n=r
for i in range(n,roop_n):
    for j in range(n+1,roop_n+1):
        ans=(i*j)%2019
        if min_>ans:
            min_=ans
            if ans==0:
                print(0)
                sys.exit()
print(min_)

Solution (Python):
import sys
n,r=map(int,input().split())
roop_n=0
ans=0
min_=2019

if r-n>=2019:
    roop_n=n+2019
else:
    roop_n=r
for i in range(n,roop_n):
    for j in range(n+1,roop_n+1):
        ans=(i*j)%2019
        if min_>ans:
            min_=ans
            if ans==0:
                print(0)
                sys.exit()
print(min_)

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

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

L, R = L % 2019, R % 2019

if L >= R:
    R += 2019

ans = float('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):

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

ls = [2018]

for i in range(l,r):
    for j in range(i+1,r+1):
        y = (i*j) % 2019
        if y < min(x for x in ls):
            ls.append(y)
        if y == 0:
            break
    if y == 0:
        break
    
print(min([ x for x in ls]))

Solution (Python):

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

ls = [2018]

for i in range(l,r):
    for j in range(i+1,r+1):
        y = (i*j) % 2019
        if (i*j) % 2019 < min(x%2019 for x in ls):
            ls.append(i*j)
        if y == 0:
            break
    if y == 0:
        break
    
print(min([ x%2019 for x in ls]))

Solution (Python):
l, r = list(map(int, input().split()))
if r - l + 1 >= 2019:
  print(0)
  exit()
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
it = L
while(it<=min(R,it+2019)):
    jt = it+1
    while(jt<=min(R,jt+2019)):
        a = (it*jt)%2019
        if a < ans:
            ans = a
            if ans==0:break
        jt += 1
    if ans==0:break
    it += 1
            
print(ans)

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

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

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

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

x=[]
a=0
for i in range(L,R):
    for j in range(L+1,R+1):
        y=((i*j)%2019)
        x.append(y)
        if y==0:
            break
    if y==0:
            break

print(min(x))

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

Lw=L//2019
Rw=R//2019

if Lw < Rw :
    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())
r = min(R,L+4038)
ans = 2018
for i in range(L,r+1,1):
    for j in range(i+1,r+1):
        tmp = (i*j)%2019
        ans = min(tmp,ans)
print(ans)

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

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

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

Solution (Python):
L, R = [int(i) for i in input().split()]
min = 2018
for i in range(L,R):
    for j in range(i+1,R+1):
        mod = (i*j)%2019
        if mod<min:
            min = mod
        if mod==0:
            print("{}".format(mod))
            exit()
print("{}".format(min))

Solution (Python):



IS = lambda: int(input())
IA = lambda: [int(x) for x in input().split()]
IM = lambda N: [IA() for _ in range(N)]

L, R = IA()

def f():
    if L // 2019 != R // 2019:
        return 0
    ans = float('inf')
    la, ra = L % 2019, R % 2019
    for i in range(la, ra):
        for j in range(i+1, ra+1):
            ans = min(ans, (i * j) % 2019)
    return ans

print(f())

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

Solution (Python):
import sys

input = sys.stdin.readline

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

def main():
    if R // 2019 != L // 2019:
        ans = 0
    else:
        
        
        

        
        
        
        ansL = L*(L+1) % 2019
        ansR = R*(R-1) % 2019

        ans = min(ansL, ansR)

    return int(ans)



def search_all():
    if R // 2019 != L // 2019:
        return 0
    ans = float("inf")
    for i in range(L, R):
        for j in range(i+1, R+1):
            ans = min(i*j % 2019, ans)
            if ans == 0:
                break
    return ans

print(search_all())

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

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

print(min(res))

Solution (Python):
l,r=map(int,input().split())
mod=2019
ans=((10**9)*2)**2
for i in range(l,r):
    for j in range(i+1,r+1):
        x=i*j

        if x%mod==0:
            print(0)
            exit()
        else:
            ans=min(ans,x%mod)
print(ans)

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

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

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

ans = 2020

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())
r2 = r+0
l2 = l+0
l%=2019
r%=2019
ans = 20000
if r2-l2 >= 2019 or r<=l:
  r += 2019
for i in range(l,r+1):
  for j in range(i+1,r+1):
    ans = min(i*j%2019,ans)
if ans == 20000:
  ans = 0
print(ans)

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

Solution (Python):
def search(lower, upper, mod):
    min_remain = mod
    for i in range(lower, min(lower + mod - lower % mod, upper - 1) + 1):
        for j in range(i + 1, min(i + mod, upper) + 1):
            remain = i * j % mod
            if remain == 0:
                return 0
            if min_remain > remain:
                min_remain = remain
    return min_remain


l, r = map(int, input().split())
print(search(l, r, 2019))

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

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

chk = 0
flg = 1
i = l
mod_min = 100000

while flg:
    for j in range(i+1,r+1):
        chk = (i*j)%2019
        if chk == 0:
            print(0)
            flg = 0
            break
        elif chk < mod_min:
            mod_min = chk
    i += 1
    if i >= r-1:
        print(mod_min)
        flg = 0

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

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

if not module:
    print("0")
else:
    print(min(module))

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

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

Solution (Python):

l, r = map(int, input().split())
m = 10**9
for i in range(l, r + 1)[:2019]:
    for j in range(i + 1, r + 1)[:2019]:
        m = min(m, i * j % 2019)
print(m)

Solution (Python):
a1=list(input().split( ))
a=list(map(int, a1))
b= a[1] - a[0]
d=2018

if b > 2019:
 print(0)
else:
 for j in range(b):
  for k in range(b-j):
    c= ((a[0] + j )* (a[0] + j  + k + 1)) % 2019
    if c<=d:
     d=c
 print(d)

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

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

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

ans = 2018
max_l = min(l, (r//2019+1)*2019)

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

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

ans = 0 if l - r >= 2019 else 2018
max_l = min(l, (r//2019+1)*2019)

for i in range(r, max_l):
    for j in range(i+1, max_l+1):
        ans = min((i * j) % 2019, ans)
    
        if ans == 0:
            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 % 2019 == 0 or L + 2019 - (L % 2019) <= R:
    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())

flag = False
if l % 2019 == 0 or r // 2019 - l // 2019 != 0:
    flag = True

if flag:
    print(0)
else:
    lmod = l % 2019
    rmod = r % 2019

    ans = 10**5
    for i in range(lmod, rmod):
        for j in range(i+1, rmod+1):
            ans = min((i * j) % 2019, ans)
    print(ans)

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

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

flag = True
ans = 2020

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

print(ans)

Solution (Python):
import sys
import math
import numpy as np
INF = 1000000000
MOD = 2019


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


def main():
    l, r = [int(e) for e in input().split()]
    ans = INF
    for i in range(l, min(l + MOD, r + 1)):
        for j in range(i + 1, min(l + MOD, r + 1)):
            ans = min(ans, ((i % MOD) * (j % MOD)) % MOD)
    print(ans)


main()

Solution (Python):
import math
import sys
import itertools
import queue
from fractions import gcd
import numpy as np


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

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

Solution (Python):
def smaller(x, y):
	if x < y: return x
	return y

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

Solution (Python):
L, R = map(int, input().split())
mod = 2019
if (R-L+1) >= 2019:
    nums = [i for i in range(2019)]
else:
    nums = list(set([i % 2019for i in range(L, R+1)]))

res = []
for i in range(len(nums)):
    for j in range(i+1, len(nums)):
       res.append((nums[i]*nums[j])%mod)
print(min(res))

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

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

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

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

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

mod=2019
r=min(r,l+mod+1)
res=float('inf')

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

Solution (Python):

l, r = map(int, input().split())
ans = 10 ** 9
for i in range(l, r + 1):
  for j in range(l, r + 1):
    if i == j:
      continue
    ans = min(ans, (i * j) % 2019)
    if ans == 0:
      print(ans)
      exit()

print(ans)

Solution (Python):
import sys

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

remainder_list = []

if r - l >= 2019:
    print(0)
    sys.exit()
else :
    for x in range(l, r):
        for y in range(x + 1, r + 1):
            remainder_list.append((x * y) % 2019)

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

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

mod=2019
r=min(r,l+mod)
res=float('inf')

for i in range(l,r):
    for j in range(i+1,r+1):
        res=min(res,(i*j)%mod)
        if res==0:break
print(res)

Solution (Python):
import itertools

def resolve():
	l,r=map(int,input().split())
	k=min(r+1,l+2020)
	lst=[i%2019 for i in range(l,k)]
	if 0 in lst:
		ans=0
	elif 673 in lst:
		if len(lst)>3:
			ans=0
		elif 672 in lst or 675 in lst:
			ans=0
		else:
			ans=1346
	else:
		ans=min([(i[0]*i[1])%2019 for i in list(itertools.combinations(lst,2))])
	
	print(ans)
resolve()

Solution (Python):
import sys, itertools, collections
sys.setrecursionlimit(10000)

read_ints = lambda: list(map(int, input().split()))
read_int  = lambda: int(input())

MOD = 2019

l, r = read_ints()
r = min(r + 1, l + MOD)

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

print(ans)

Solution (Python):
MOD = 2019
def solve(l, r):
    if r - l >= MOD:
        return 0
    ans = MOD
    for i in range(l, r+1):
        for j in range(i+1, r+1):
            ans = min(ans, i*j%MOD)
    return ans

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

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

mod = 2019

r = min(r, l+mod+1)

ans = 2020

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())
mn=2018
if r-l<2019:
  for i in range(l%2019,r%2019+1):
    for j in range(l%2019,r%2019+1):
      if i<j:
        mn=min(mn,(i*j)%2019)
  print(mn)
else:
  print(0)

Solution (Python):

def main():
    L, R = list(map(int, input().rstrip().split()))
    MOD = 2019
    if R - L + 1 >= MOD:  
        print(0)
    else:  
        L, R = L % MOD, R % MOD
        if L <= 3 and R >= 673:  
            print(0)
            return
        ans = float("inf")
        for i in range(L, R):
            for j in range(i + 1, R + 1):
                tmp = (i * j) % MOD
                if tmp < ans:
                    ans = tmp
        print(ans)


if __name__ == "__main__":
    main()