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
a=l%mod
b=l//mod
c=r%mod
d=r//mod
if d-b!=0:
  print(0)
else:
  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)

Solution (Python):
import itertools

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

for i in range((2*10**9)//2019+1):
	if L<=i*2019 and i*2019<=R:
		print(0)
		exit()

ans=2020

for h in range(L,R+1):
	for g in range(h+1,R+1):
		ans=min(ans,(h*g)%2019)

print(ans)

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

import sys
minimum = sys.maxsize
for i in range(L, min(L + 2019, R)):
  for j in range(i+1, min(i + 1 + 2019, R+1)):
    minimum = min(minimum, i * j % 2019)
print(minimum)

Solution (Python):









INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))

def do():
    l,r=INTM()
    mods=[]
    for i in range(l,min(l+3000,r+1)):
        mods.append(i%2019)
    
    ans=2018
    ml=len(mods)
    for i in range(ml-1):
        for j in range(i+1,ml):
            ans=min(ans,(mods[i]*mods[j])%2019)

    print(ans)


if __name__=='__main__':
    do()

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

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

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

Solution (Python):


L,R = map(int,input().split())
A = []
if R - L > 2019:
    print(0)
elif 2 <= R - L and R - L <= 2019:
    for i in range(L,R):
        for j in range(i+1,R+1):
            A.append((i*j)%2019)
    print(min(A))
elif R - L == 1:
    print((R*L)%2019)

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

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

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

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

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

ans=9999

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

Solution (Python):
import itertools
l,r = map(int,input().split())
if r-l >= 2019:
    print(0)
    exit()
w = []
q = list(itertools.combinations(range(l,r+1),2))
for i in range(len(q)):
    w.append((q[i][0]*q[i][1])%2019)

print(min(w))

Solution (Python):
import sys

def read_str(): return sys.stdin.readline().strip()
def read_int(): return int(sys.stdin.readline().strip())
def read_ints(): return map(int, sys.stdin.readline().strip().split())
def read_str_split(): return list(sys.stdin.readline().strip())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))

def Main():
    l, r = read_ints()
    ans = 2020
    if r - l >= 2019:
        print(0)
        exit()
    for i in range(l, r + 1):
        for j in range(l, i):
            ans = min(ans, i * j % 2019)
    print(ans)

if __name__ == '__main__':
    Main()

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

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):
            if i * j % 2019 < ans:
                ans = i * j % 2019
    print(ans)

Solution (Python):
L,R = map(int,input().split())
MOD = 2019
ans = 2020
if R - L > 2010:
  print(0)
  exit()
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())
result = R*R
if R - L + 1 > 2019:
    R = L + 2018
for i in range(L,R+1):
    for j in range(i+1,R+1):
        if (i * j) % 2019 < result:
            result = (i * j) % 2019
print(result)

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 >= 1:
    print(0)
else:
    ans = float('inf')
    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())
m,ans=2019,2018
r=min(r,l+2019*2)
for i in range(l,r+1):
  for j in range(i+1,r+1):
    i%=m
    j%=m
    ans=min(ans,(i*j)%m)
print(ans)

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

Solution (Python):
l,r=map(int,input().split())
m=2019
if l//m<r//m:
  print(0)
else:
  ans=m
  for i in range(l%m, r%m+1):
    for j in range(i+1,r%m+1):
      ans=min(ans,i%m*j%m)
  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):
l, r = map(int, input().split())
ans = 4070306
if l <= 2019 <= r:
    ans = 0
else:
    for i in range(l, min(r, l+2019)+1):
        for j in range(i+1, min(r, i+2019)+1):
            ans = min(ans, (i*j)%2019)
print(ans)

Solution (Python):

def main():

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

    if (L//2019) < (R//2019):
        ans = 0
    else:
        ans = 10 ** 10
        for l in range(L, R+1):
            for r in range(l+1, R+1):
                ans = min(ans, (l*r)%2019)

    print(ans)


if __name__ == "__main__":
    main()

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

if r-l+1>=MOD:
    kouho=list(range(MOD))
else:
    kouho=[i%MOD for i in list(range(l,r+1))]
    
for i in range(len(kouho)):
    for j in range(i+1,len(kouho)):
        ans=min(ans,(kouho[i]*kouho[j])%MOD)

print(ans)

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

if R-L < 2018:
  nums = list(range(L,R+1))
  A = []
  for i in range(len(nums)):
    for j in range(i+1,len(nums)):
      A.append((nums[i]*nums[j])%2019)
  ans = min(A)

print(ans)

Solution (Python):
l,r = map(int,input().split())
mod = 2019
a = l%mod
b = r%mod

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

else:
    if a > b:
        print(0)
    else:
        t = (a*(a+1))%mod
        for x in range(a,b):
            for y in range(x+1,b+1):
                if (x*y)%mod < t:
                    t = (x*y)%mod
        print(t)

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

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

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

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

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

if R - L >= 2019:
    print(0)
else:
    ans = 10**9
    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 sys

L, R = map(int, input().split())
P = 2019
if R - L >= 2019:
    print(0)
    sys.exit()
elif (R % P) - (L % P) < 0:
    print(0)
    sys.exit()

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

Solution (Python):
import sys
from itertools import combinations

MOD = 2019


def solve(l, r):
    if l // 673 != r // 673 or l % 673 == 0:
        if l // 3 != r // 3 or l % 3 == 0:
            return 0
    ans = 10000
    for i, j in combinations(range(l, r + 1), 2):
        ans = min(ans, i * j % MOD)
    return ans


def main():
    input = sys.stdin.buffer.readline
    l, r = map(int, input().split())
    print(solve(l, r))


if __name__ == "__main__":
    main()

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

c = set()

for i in range(L, R + 1):
  t = i % 2019
  if t in c:
    break
  c.add(t)


m = float('inf')
l = list(c)
for i in range(len(l)):
  for j in range(i + 1, len(l)):
    m = min(m, l[i] * l[j] % 2019)

print(m)

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

print(ans)

Solution (Python):
L,R = (int(x) for x in input().split())
if R-L > 2019*2:
  R -= ((R-L)//2019-1)*2019
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:
    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:
  x = 2019
  for i in range(L, R+1):
    for j in range(i+1, R+1):
      x = min(x, i*j%2019)
  print(x)

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

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

print(ans)

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

mod = 2019

ans = 2222

if (r - l) // mod > 0:
	ans = 0

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

print(ans)

Solution (Python):
import itertools

L,R = map(int,input().split())
if R - L + 1 >= 2019:
    ans = 0
else:
    LL = L % 2019
    RR = R % 2019
    if LL < RR:
        Amari_List = list(range(LL,RR+1))
        ans = 2019
        for v1,v2 in itertools.combinations(Amari_List, 2):
            ca = (v1*v2) % 2019 
            if  ca < ans:
                ans = ca
    else:
        ans = 0

print(ans)

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

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

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

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


if __name__ == '__main__':
    main()

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

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

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

print(ans)

Solution (Python):
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())


L,R = MI()
if L//2019 != R//2019:  
    print(0)
else:
    A = [i for i in range(L % 2019,(R % 2019)+ 1)]
    N = len(A)
    ans = 2019
    for i in range(N-1):
        for j in range(i+1,N):
            ans = min(ans,(A[i]*A[j]) % 2019)
    print(ans)

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

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

L, R = mapint()

lis = []
for i in range(L, min(R+1, L+2101)):
    lis.append(i)

leng = len(lis)
ans = 10**18
for i in range(leng-1):
    a = lis[i]
    for j in range(i+1, leng):
        b = lis[j]
        ans = min(ans, (a*b)%2019)
print(ans)

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

if r-l+1>=2019:
    print(0)
else:
    m=[]
    for i in range(l,r+1):
        m.append(i%2019)
    n=len(m)
    ans=10**9
    for i in range(n):
        for j in range(i+1,n):
            ans=min(ans,(m[i]*m[j])%2019)
    
    print(ans)

Solution (Python):
def LI():
    return list(map(int, input().split()))


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

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

Solution (Python):
L, R = map(int, input().split())
res = [0] * 2019
for i in range(L, R + 1):
    if res[i % 2019] > 0:
        break
    else:
        res[i % 2019] += 1

if res[0] == 1:
    print(0)
else:
    ans = 2019
    for i in range(2019):
        for j in range(i + 1, 2019):
            if res[i] == res[j] == 1:
                ans = min(ans, i * j % 2019)
    print(ans)

Solution (Python):
L,R = map(int,input().split())
kouho = set([])
while len(kouho) < 2019 and L <= R:
  temp = L%2019
  kouho.add(temp)
  L += 1

A = list(kouho)
A.sort()
ans = 2018
for i in range(len(A)):
  for j in range(i+1,len(A)):
    temp = A[i]*A[j]%2019
    ans = min(ans,temp)
print(ans)

Solution (Python):
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  
def LS2(): return list(sys.stdin.readline().rstrip())  


L,R = MI()
if L//2019 != R//2019:
    print(0)
else:
    A = [i for i in range(L % 2019,(R % 2019)+ 1)]
    N = len(A)
    ans = 2019
    for i in range(N-1):
        for j in range(i+1,N):
            ans = min(ans,(A[i]*A[j]) % 2019)
    print(ans)

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

l,r = inpl()
if r-l > 2019:
    print(0)
else:
    res = INF
    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())

k=0

can=[]
while l+k<=r and k<2020:
    can.append((l+k)%2019)
    k+=1
ans=2020
import itertools

for seq in itertools.combinations(range(len(can)),2):
    ans=min(ans,(can[seq[0]]*can[seq[1]])%2019)
print(ans)

Solution (Python):
l ,r = map(int, input().split())
t = []
if r-l >= 2019:
  print(0)
  exit()
elif r-l < 2019:
  if 2019 <= l:
    for i in range(l, r):
      for j in range(i+1, r+1):
        ii = i % 2019
        jj = j % 2019
        s = (ii*jj) % 2019
        t.append(s)
    ans = min(t)
    print(ans)
  elif l < 2019 < r:
    for i in range(l, r):
      for j in range(i+1, r+1):
        ii = i % 2019
        jj = j % 2019
        s = (ii*jj) % 2019
        t.append(s)
    ans = min(t)
    print(ans)
  elif r <= 2019:
    for i in range(l, r):
      for j in range(i+1, r+1):
        s = (i*j) % 2019
        t.append(s)
    ans = min(t)
    print(ans)

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

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

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

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

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

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

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

ans = 10**9
if R-L >= 2020:
    for i in range(L,L+2019):
        for j in range(L+1,L+2020):
            ans = min(ans,(i*j)%2019)
else:
    for i in range(L,R):
        for j in range(L+1,R+1):
            ans = min(ans,(i*j)%2019)

print(ans)

Solution (Python):
l,r=map(int,input().split())
m=l//2019
l-=m*2019
r-=m*2019
if r>=2019:
    print(0)
    exit()
ans=2018
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 >= 2018:
  print(0)
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):
L, R = map(int, input().split())






m = 2019
flag = False
for i in range(L, R):
  for j in range(i+1, R+1):
    m = min(m, i*j % 2019)
    if m == 0: 
      flag = True
      break
  if flag: break

print(m)

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

Solution (Python):
def main():
    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)
 
 
if __name__ == "__main__":
    main()

Solution (Python):
def main():
    l, r = map(int, input().split())
    q, ll = l // 2019, l % 2019
    rr = r % 2019
    rng = [*range(ll, rr+1)] if r - l < (2019 * q - ll) % 2019 else [*range(ll, 2019)] + [*range(rr+1)]
    lenrng = len(rng)
    ans = 2020
    for i in range(lenrng-1):
        for j in range(i+1, lenrng):
            tmp = rng[i] * rng[j] % 2019
            if tmp < ans:
                ans = tmp
    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):
def main():
    l, r = map(int, input().split())
    mi = 2019
    c = 0

    for i in range(l, r):
        a = (i*i) % 2019
        for _ in range(min(r-l-c, 2019)):
            a = (a+i) % 2019

            if a < mi:
                mi = a
                if a == 0:
                    print(0)
                    return 
        c += 1

    print(mi)


if __name__ == '__main__':
    main()

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

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

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

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

Solution (Python):
import math
res = float('inf')
L, R = map(int, input().split())
length = min(R - L, 3000)
for i in range(L, L + length):
  for j in range(i+1, L + length + 1):
    temp = (i * j) % 2019
    if temp < res:
      res = temp
print(res)

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

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

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

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

Solution (Python):









import os
import sys




def main():
    L, R = map(int, input().split())
    cool = R // 2019 - L // 2019
    if cool == 0:
        ans = 2020
        for l in range(L, R+1):
            for r in range(l+1, R+1):
                if ans > l*r % 2019:
                    ans = l*r % 2019
        print(ans)

    else:
        print(0)


if __name__ == "__main__":
    main()

Solution (Python):

"""
Created on Thu Sep 10 11:33:13 2020

@author: liang
"""

L, R = map(int,input().split())
r = R%2019
l = L%2019
ans = 2018
if R - L >= 2019 - l or l==0:

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

import sys
import math
import decimal
import itertools
from itertools import product
from functools import reduce
def input():
    return sys.stdin.readline()[:-1]
def sort_zip(a:list, b:list):
    z = zip(a, b)
    z = sorted(z)
    a, b = zip(*z)
    a = list(a)
    b = list(b)
    return a, b

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

    for i in range(1, 990589):
        if L <= 2019*i <= R:
            print(0)
            exit()

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


if __name__ == '__main__':
    main()

Solution (Python):
L,R=map(int,input().split())
l1=L//2019
r1=R//2019
if l1<r1:
  print(0)
elif l1==r1:
  res=[]
  for i in range(L,R+1):
    for j in range(i+1,R+1):
      res.append((i*j)%2019)
  print(min(res))

Solution (Python):


def main():
    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)


if __name__ == "__main__":
    main()

Solution (Python):
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right 
from heapq import heapify, heappop, heappush
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x):
        self.setdefault(x,0)
        self[x] += 1

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

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

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

if R - L >= 2018:
    print("0")
else:
    ans = 2020
    for i in range(L, R+1):
        for j in range(i+1, R+1):
            t = ((i%m) * (j%m)) % m
            ans = min(ans, t)
    print(ans)

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

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

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

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

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

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

Solution (Python):
l,r=map(int, input().split())
mo=2019
ans=2018
r=min(r, l+mo-1)

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

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

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

Solution (Python):

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

ans = 2020


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

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

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

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

print(ans)

Solution (Python):


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

mod=2019
ans=20000

for i in range (L,min(R,L+mod)):
    for j in range (L+1,min(R+1,L+mod+1)):
        tempans=(i%mod)*(j%mod)
        tempans%=mod
        if tempans<ans:
            ans=tempans

print(ans)

Solution (Python):


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

mod=2019
ans=10**18+7


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

Solution (Python):
import sys


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

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

Solution (Python):
L, R = map(int, input().split())
if L + 2019 > R:
  tmp = 10**9
  for l in range(L,R):
    for r in range(l+1, R+1):
      if (l*r)%2019 < tmp:
        tmp = (l*r)%2019
  print(tmp)
else:
  print("0")

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

Solution (Python):
L, R = map(int,input().split())
Dif = abs(L-R)+1
if Dif >= 2020:
    Ans = 0
else:
    Box = []
    for i in range(L,R+1):
        Box.append(i%2019)
    Box.sort()
    Ans = 2020*2020
    for i in range(len(Box)-1):
        B1 = Box[i]
        for j in range(i+1,len(Box)):
            B2 = Box[j]
            Ans = min((B1*B2)%2019, Ans)
print(Ans%2019)

Solution (Python):
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

def main():
    l, r = list(map(int, input().split()))
    diff = r-l
    if diff >= 2018:
        return 0

    else:
        min_ = 2 ** 20
        
        p = l // 2019 ; q = l % 2019
        for xi in range(l, r):
            qi = (q + (xi - l)) % 2019
            if qi == 0:
                return 0
            for xj in range(xi+1, r+1):
                qj = (q + (xj - l)) % 2019
                if qj == 0:
                    return 0
                else:
                    qij = (qi * qj) % 2019
                    if qij < min_:
                        min_ = qij

    return min_

print(main())