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

def f(i, j):
    if j - i >= MOD:
        return 0
    i %= MOD
    j %= MOD
    if i > j:
        return 0
    ans = 2018
    for a in range(i, j):
        for b in range(a+1, j+1):
            ans = min(ans, a*b%MOD)
    return ans

print(f(L,R))

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

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

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

Solution (Python):
import sys
l,r=(int(x) for x in input().split())
s=2020
for i in range(l, min(l+2021,r+1)):
  for j in range(i+1, min(l+2021, r+1)):
    n=i%2019*j%2019%2019
    if n<s:
      s=n
    if s==0:
      print(s)
      sys.exit()
print(s)

Solution (Python):
import numpy as np

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

if R - L >= 2019:
    ans = 0
elif L % 2019 > R % 2019:
    ans = 0
else:
    X =[]
    l = L % 2019
    r = R % 2019
    for i in range(l, r+1):
        for j in range(i+1, r+1):
            X.append(i*j)
    X_np = np.array(X)
    X_np_mod = X_np % 2019
    ans = min(X_np_mod)

print(ans)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

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

if R-L > 1000:
    print(0)
    exit()
x = np.arange(L,R+1)
x = x[:,None] * x[None,:] % 2019
np.fill_diagonal(x,2019)
answer = x.min()
print(answer)

Solution (Python):
l,r = [int(i) for i in input().split()]
d = r-l
if d > 2019: d = 2019
l = l % 2019
r = l + d

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

l = L // 2019
r = R // 2019

mi = 2019
if l == r:
	L = L % 2019
	R = R % 2019
	for i in range(L, R):
		for j in range(i+1, R+1):
			mi = min((i*j)%2019, mi)
else:
	L = L % 2019
	for i in range(L, 2019):
		for j in range(i+1, 2020):
			mi = min((i*j)%2019, mi)
print(mi)

Solution (Python):
l,r=map(int,input().split())
ans=2018
d=r-l
if d>2019:
    d=2019

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

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

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

print(out)

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

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

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

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

if r-l >= 2018:
  answer = 0
else:
  l = [i%2019 for i in range(l, r+1)]
  l.sort()
  for i in range(len(l)):
    for j in range(i+1, len(l)):
      answer = min(answer, l[i]*l[j]%2019)

print(answer)

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

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

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

Solution (Python):

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

Solution (Python):
div = 2019
if __name__ == '__main__':
    L, R = [int(i) for i in input().split()]
    if R - L > div - 1:
        R = L + div - 1
    number_ref = [num for num in range(L, R + 1, 1)]

    min_mod = 2018
    for idx, i in enumerate(number_ref):
        for j in number_ref[idx + 1:]:
            if (i * j) % div < min_mod:
                min_mod = (i * j) % div
    print(min_mod)

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

Solution (Python):
def slove():
    import sys
    input = sys.stdin.readline
    l, r = list(map(int, input().rstrip('\n').split()))
    m = 10 ** 10
    for i in range(l, r + 1):
        for j in range(i + 1, r + 1):
            m = min(m, (i * j) % 2019)
            if m == 0:
                print(m)
                exit()
    print(m)


if __name__ == '__main__':
    slove()

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

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

Solution (Python):
def slove():
    import sys
    input = sys.stdin.readline
    l, r = list(map(int, input().rstrip('\n').split()))
    m = 10 ** 10
    for i in range(l, r + 1):
        for j in range(i + 1, r + 1):
            m = min(m, (i * j) % 2019)
            if m == 0:
                print(m)
                exit()
    print(m)


if __name__ == '__main__':
    slove()

Solution (Python):
from itertools import combinations
import sys

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

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

A = list(range(l,r+1))

ans_L = [i[0]*i[1]%2019 for i in combinations(A,2)]
print(sorted(ans_L)[0])

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

Solution (Python):
def solve(lr):
    L, R = lr
    ans = 2018
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            x = i * j % 2019
            if x == 0:
                return 0
            if x < ans:
                ans = x
    return ans

print(solve(tuple(int(i) for i in input().split())))

Solution (Python):
import sys
import itertools
if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    

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

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

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

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

print(ans)

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

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

Solution (Python):
L, R = map(int, input().split())
if R-L>=2019:
  print(0)
  exit()
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):
def slove():
    import sys
    input = sys.stdin.readline
    l, r = list(map(int, input().rstrip('\n').split()))
    mmod = 10 ** 10
    for i in range(l, r + 1):
        for j in range(i + 1, r + 1):
            mmod = min(mmod, (i * j) % 2019)
            if mmod == 0:
                break
        if mmod == 0:
            break
    print(mmod)


if __name__ == '__main__':
    slove()

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


main()

Solution (Python):
def main():
    L, R = map(int, input().split())
    
    if L + 672 <= R:
        print(0)
        return
    lst = []
    for i in range(L, R + 1):
        for j in range(i + 1, R + 1):
            m = i * j % 2019
            lst.append(m)
            if m == 0:
                break
        if m == 0:
            break
    print(min(lst))
    return


main()

Solution (Python):
def main():
    L, R = map(int, input().split())
    
    if L + 672 <= R:
        print(0)
        return
    lst = []
    for i in range(L, R + 1):
        for j in range(i + 1, R + 1):
            m = i * j % 2019
            lst.append(m)
            if m <= 1:
                break
        if m <= 1:
            break
    print(min(lst))
    return


main()

Solution (Python):
def main():
    L, R = map(int, input().split())
    
    if L + 672 <= R:
        print(0)
        return
    lst = []
    for i in range(L, R + 1):
        for j in range(i + 1, R + 1):
            lst.append(i * j % 2019)
            m = i * j % 2019
            if m <= 1:
                break
        if m <= 1:
            break
    print(min(lst))
    return


main()

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


main()

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


main()

Solution (Python):
def main():
    L, R = map(int, input().split())
    
    if L + 672 <= R:
        print(0)
        return
    lst = []
    for i in range(L, R + 1):
        for j in range(i + 1, R + 1):
            if i * j % 2019 == 0:
                print(0)
                return
            lst.append(i * j % 2019)
    print(min(lst))
    return


main()

Solution (Python):
def main():
    L, R = map(int, input().split())
    
    if L + 672 <= R:
        print(0)
        return
    s = set()
    for i in range(L, R + 1):
        for j in range(i + 1, R + 1):
            if i * j % 2019 == 0:
                print(0)
                return
            s.add(i * j % 2019)
    print(min(s))
    return


main()

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


main()

Solution (Python):
def main():
    L, R = map(int, input().split())
    
    if L + 672 <= R:
        print(0)
        return
    elif 0 in (L % 2019, R % 2019):
        print(0)
        return
    elif R % 673 == 0 and L + 2 <= R:
        print(0)
        return
    elif L % 673 == 0 and L + 2 <= R:
        print(0)
        return
    elif R % 673 < L % 673 and L + 2 <= R:
        print(0)
        return
    print(min(i * j % 2019 for i in range(L, R + 1)
              for j in range(i + 1, R + 1)))
    return


main()

Solution (Python):
def main():
    L, R = map(int, input().split())
    
    if L + 672 <= R:
        print(0)
        return
    elif 0 in (L % 2019, R % 2019):
        print(0)
        return
    elif L % 673 == 0 and L + 2 <= R:
        print(0)
        return
    elif R % 673 < L % 673 and L + 2 <= R:
        print(0)
        return
    print(min(i * j % 2019 for i in range(L, R + 1)
              for j in range(i + 1, R + 1)))
    return


main()

Solution (Python):
def main():
    L, R = map(int, input().split())
    
    if L + 672 <= R:
        print(0)
        return
    elif L % 2019 == 0:
        print(0)
        return
    elif L % 673 == 0 and L + 2 <= R:
        print(0)
        return
    elif R % 673 < L % 673 and L + 2 <= R:
        print(0)
        return
    print(min(i * j % 2019 for i in range(L, R + 1)
              for j in range(i + 1, R + 1)))
    return


main()

Solution (Python):
def main():
    L, R = map(int, input().split())
    
    if L + 672 <= R:
        print(0)
        return
    elif L % 673 == 0 and L + 2 <= R:
        print(0)
        return
    elif R % 673 < L % 673 and L + 2 <= R:
        print(0)
        return
    print(min(i * j % 2019 for i in range(L, R + 1)
              for j in range(i + 1, R + 1)))
    return


main()

Solution (Python):
def main():
    L, R = map(int, input().split())
    
    if L + 672 <= R:
        print(0)
        return
    elif R % 673 < L % 673 and L + 2 <= R:
        print(0)
        return
    print(min(i * j % 2019 for i in range(L, R + 1)
              for j in range(i + 1, R + 1)))
    return


main()

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


main()

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

l_mod = l % 2019
if r - l >= 2019:
    r_mod = l_mod + (r - l - 2019) % 2019 + 2019
else:
    r_mod = l_mod + (r - l) % 2019

ans = 2019
for i in range(l_mod, r_mod):
    for j in range(i + 1, r_mod + 1):
        tmp = (i * j) % 2019
        if tmp < ans:
            ans = tmp

print(ans)

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

if R-L+1 >= 2019:
    print(0)
else:
    ans = 2018
    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):
def main():
    L, R = map(int, input().split())
    if L + 2018 <= R:
        print(0)
        return
    print(min(i * j % 2019 for i in range(L, R + 1)
              for j in range(i + 1, R + 1)))
    return


main()

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

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

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

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

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

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

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

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

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

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

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

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

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

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

print(result)

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

Solution (Python):
from itertools import combinations

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

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

Solution (Python):

import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7



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

MOD2019 = 2019

ans = INF

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

print(ans)

Solution (Python):

import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7



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

MOD2019 = 2019

ans = INF

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

print(ans)

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

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

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

Solution (Python):
from itertools import combinations
l, r = map(int, input().split())
if l // 2019 < r // 2019:
    print(0)
else:
    m = 2019
    for i, j in combinations(range(l, r+1),2):
        tmp = i*j % 2019
        if m > tmp:
            m = tmp
    print(m)

Solution (Python):
L, R = map(int, input().split())
 
if R - L >= 2017:
  print(0)
  exit()
 
ans_list = []
 
for x in range(L, R):
  for y in range(x+1, R+1):   
    ans_list.append((x * y) % 2019)
    
print(min(ans_list))

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

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

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

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

Solution (Python):
L , R = map(int,input().split())
if R - L >= 2019 or L == 0:
    print("0")
    exit()
min = 2020

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

Solution (Python):
def main():
    l, r = map(int, open(0).read().split())
    MOD = 2019
    if r - l >= MOD:
        print(0)
        return()
    l %= MOD
    r %= MOD
    if l == 0 or r == 0:
        print(0)
        return()
    if l > r:
        r += MOD

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

    print(ans)
    return()

if __name__ == '__main__':
    main()

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


















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

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

Solution (Python):
def solve():
    L,R = map(int, input().split())
    diff = R-L
    L %= 2019
    diff = min(diff, 2019)

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

solve()

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

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

print(main())

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

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

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

ans = 10**9
rng = R - L
if rng > 2019:
    ans = 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())
if r - l >2017:
    print(0)
else:
    ij = []
    for i in range(l, r):
        for j in range(i+1, r+1):
            ij.append((i*j)%2019)
    print(min(ij))

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

Solution (Python):
b, c = map(int, input().split())
if c-b >=2018:
    print(0)
else:
    t = b%2019
    if t+(c-b+1) >= 2019:
        print(0)
    else:
        import numpy as np
        ind = [t+i for i in range(c-b+1)]
        mask = np.array([[True if i!=j else False for i in range(len(ind))] for j in range(len(ind))])
        tmp = ind*np.array(ind).reshape((len(ind),-1))%2019
        print(np.min(tmp[mask]))

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

print(temp)

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

Solution (Python):

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

MOD = 2019
L, R = map(int, input().split())
ans = float('inf')
if R-L <= 2020:
    for l in range(L, R):
        for r in range(l+1, R+1):
            ans = min(ans, (r*l) % MOD)
else:
    for l in range(1, MOD):
        for r in range(l+1, MOD+1):
            ans = min(ans, (r*l) % MOD)
print(ans)

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

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

Solution (Python):
s=list(map(int,input().split()))
a=int(s[0])
b=int(s[1])
list=[]
list.append(a%2019)
list.append(b%2019)
e=100000
if s[0]+2018<=s[1]:
  print(0)
else:
  if list[0]<list[1]:
    for i in range(list[0],list[1]+1):
      for j in range(list[0],list[1]+1):
        if i==j:
          continue
        else:
          d=(i*j)%2019
          e=min(d,e)
    print(e)
  else:
    print(0)

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

l = L//2019
r = R//2019

if((r-l >= 1)or(L%2019 == 0)or(R%2019 == 0)):
  ans = 0
  
else:
 A = []
 ans = 2018
 judge = 0
 for i in range(L,R+1):
    i = i%2019
    if(i%673 == 0): judge += 673
    if(i%3 == 0): judge += 3 
    A.append(i)

 if(judge == 673+3): 
   ans = 0
 else: 
   A_comb = list(itertools.combinations(A,2))
   for i in range(len(A_comb)):
     tmp = list(A_comb[i])
     ans = min(ans,(tmp[0]*tmp[1])%2019)
 
print(ans)

Solution (Python):
L, R = map(int, input().split())
if L + 2018 <= R or L%2019 > R%2019:
    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):
import sys
input = sys.stdin.readline
l,r=map(int,input().split())

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

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

tmp = 2019
ans = 2019

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

print(ans)

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

def mod2019(x):
    return x % 2019

s = True

if r-l < 2019:
    s = False

ans = 2019*2019

if s is True:
    print(0)
else:
    for i in range(l,r+1):
        for j in range(i+1,r+1):
            kari = mod2019(i*j)
            if kari < ans:
                ans = kari
    print(ans)

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

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

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

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

Solution (Python):
def p_c():
    L, R = map(int, input().split())
    year = 2019

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

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

    print(ans)
    
p_c()

Solution (Python):
from sys import stdin

l,r = [int(x) for x in stdin.readline().rstrip().split()]
m = 2020
if r - l > 2018:
    print(0)
    exit()
for i in range(l,r):
    for j in range(i+1,r+1):
        if i*j%2019 == 0:
            print(0)
            exit()
        else:
            m = min(m,i*j%2019)
print(m)

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

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


if L <= 2019 & R >= 2019:
	print(0)
elif R - L <= 2019:
	list_modulus_ij_one = []

	for i in range(L, R):
		for j in range(i+1, R+1):
			i_modulus = i % 2019
			j_modulus = j % 2019
			ij_modulus = (i_modulus * j_modulus) % 2019
			list_modulus_ij_one.append(ij_modulus) 

	mini_modulus_ij_one = min(list_modulus_ij_one)
	print(mini_modulus_ij_one)
else:
	list_modulus_ij_two = []

	for i in range(L, L+2019):
		for j in range(i+1, L+2019+1):
			i_modulus = i % 2019
			j_modulus = j % 2019
			ij_modulus = (i_modulus * j_modulus) % 2019
			list_modulus_ij_two.append(ij_modulus)
	
	mini_modulus_ij_two = min(list_modulus_ij_two)
	print(mini_modulus_ij_two)

Solution (Python):
import sys

L,R=map(int,input().split())
min_=2018
for i in range(L,R+1):
    for j in range(i+1,R+1):
        min_=min(min_,((i % 2019)*(j % 2019) % 2019))
        if min_==0:
            print(0)
            sys.exit()
print(min_)

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

res = 0
if R - L < 2019:
    res = min([(i % 2019 * j % 2019) for i in range(L, R + 1) for j in range(i + 1, R + 1)])
print(res % 2019)

Solution (Python):
p,q=(map(int,input().split()))
minimums=2018
if q-p>=2019:
    for i in range(p,p+2019):
        for j in range(p,p+2019):
            if i>=j:
                continue
            if i<j:
                div=(i*j)%2019
                if div<minimums:
                    minimums=div
                    
                else:
                    continue
if q-p<2019:
    for i in range(p,q+1):
        for j in range(p,q+1):
            if i>=j:
                continue
            if i<j:
                div=(i*j)%2019
                if div<minimums:
                    minimums=div
                    
                else:
                    continue
print(minimums)

Solution (Python):
import sys

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

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