Problem:
 Score : 300 points    Problem Statement You are given two non-negative integers L and R .
We will choose two integers i and j such that L \leq i < j \leq R .
Find the minimum possible value of (i \times j) \mbox{ mod } 2019 .      Constraints  All values in input are integers.  0 \leq L < R \leq 2 \times 10^9         Input Input is given from Standard Input in the following format:  L  R       Output Print the minimum possible value of (i \times j) \mbox{ mod } 2019 when i and j are chosen under the given condition.        Sample Input 1 2020 2040      Sample Output 1 2  When (i, j) = (2020, 2021) , (i \times j) \mbox{ mod } 2019  = 2 .       Sample Input 2 4 5      Sample Output 2 20  We have only one choice: (i, j) = (4, 5) .

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

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

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

n = min(l+2020, r)

ans = 2018

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

print(ans)

Solution (Python):
l, r = map(int, input().split(' '))
if (r - l) > 2019:
  r = l + 2019
ary = [num for num in range(l, r+1)]

ans = 10000

for i in range(len(ary) -1):
  for j in range(i+1, len(ary)):
    tmp = (ary[i] * ary[j]) % 2019
    if tmp < ans:
      ans = tmp
    if ans == 0:
      break

print(ans)

Solution (Python):
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines



























def main():
	L,R=map(int,input().split())
	ans=0
	LL, RR = L % 2019, R % 2019
	if R-L<2019 and LL<RR:
		ans=2018
		L,R=L%2019,R%2019
		for i in range(LL,RR):
			j=1
			while i+j<=RR:
				ans=min(ans,(i*(i+j))%2019)
				j+=1
	print(ans)
	





if __name__ == '__main__':
	main()

Solution (Python):
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines



























def main():
	L,R=map(int,input().split())
	ans=0
	LL, RR = L % 2019, R % 2019
	if R-L<2019 and LL<RR:
		ans=2018
		L,R=L%2019,R%2019
		for i in range(LL,RR):
			j=1
			while i+j<=RR:
				ans=min(ans,(i*(i+j))%2019)
				j+=1
	print(ans)
	





if __name__ == '__main__':
	main()

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

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

print(out)

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

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

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

Solution (Python):
l,r=map(int,input().split())
a=2019
lpre=l//a
rpre=r//a
if lpre==rpre:
    l=l%a
    r=r%a
else:
    l=l%a
    r=r%a+a
my_min=float("INF")
for i in range(l,r+1):
    for j in range(i+1,r+1):
        b=(i*j)%a
        if b<my_min:
            my_min=b

print(my_min)

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

ret = 2019 ** 2
flag = False
for l in range(L, R):
    for r in range(l + 1, R + 1):
        temp = (l % 2019) * (r % 2019) % 2019
        if ret > temp:
            ret = temp
            if ret == 0:
                print(0)
                exit()

print(ret)

Solution (Python):
def fun(L,R):
    if R-L>=2019:
        return 0
    else:
        ll = L%2019
        rr = R%2019
        if ll>R:
            return 0
        else:
            r = 2018
            for i in range(L,R+1):
                for j in range(i+1,R+1):
                    r=min(r,i*j%2019)
            return r
        


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

Solution (Python):

import sys










mod = 2019

def main():
    l, r = [int(x) for x in sys.stdin.readline().split()]

    if l + 2019 <= r:
        m = l + 2018
    else:
        m = r
    
    remainders = []
    for i in range(l, m):
        for j in range(i+1, m+1):
            remainders.append(i * j % mod)
    
    print(min(remainders))

if __name__ == "__main__":
    main()

Solution (Python):

import sys

import math











mod = 2019

def main():
    l, r = [int(x) for x in sys.stdin.readline().split()]

    if l + 2019 <= r:
        m = l + 2018
    else:
        m = r
    
    minimum = 2018
    for i in range(l, m):
        for j in range(i+1, m+1):
            minimum = min(minimum, i * j % mod)
    
    print(minimum)

if __name__ == "__main__":
    main()

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

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

Solution (Python):
import sys
input = sys.stdin.readline
def print_ans(L, R):
    """Test Case
    >>> print_ans(2020, 2040)
    2
    >>> print_ans(4, 5)
    20
    """
    tmp = R - L
    if tmp > 2019:
        print("0")
    else:
        L = L % 2019
        R = L + tmp
        ans = 2019
        flg = False
        for i in range(L, R):
            for k in range(i + 1, R + 1):
                ans = min(ans, (i * k) % 2019)
                if ans == 0:
                    flg = True
                    break
            if flg :
                break
        print(ans)



if __name__ == '__main__':
    L, R = map(int, input().rstrip().split())
    print_ans(L, R)

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


def main():
    sc = Scan()
    l, r = sc.intarr()
    if r - l >= 2019:
        print('0')
        exit()
    minimum = 2019
    for i in range(l, r):
        for j in range(i+1, r+1):
            num = (i*j) % 2019
            if num < minimum:
                minimum = num
                if minimum == 0:
                    print('0')
                    exit()
    print(minimum)


class Scan():

    def intarr(self):
        line = input()
        array = line.split(' ')
        num_array = [int(n) for n in array]
        return num_array

    def strarr(self):
        line = input()
        array = line.split(' ')
        array[-1] = array[-1].strip('\n')
        return array


main()

Solution (Python):
from collections import defaultdict,deque, Counter
import sys,heapq,bisect,math,itertools,string,queue,copy,time
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

[L,R] = inpl()
rL, rR = L%2019, R%2019
temp = INF
ans = INF
if R-L>= 2018 or rL > rR : ans = 0
else:
    for i in range(rL, rR):
        for j in range(i+1, rR+1):
            temp = ( i*j ) %2019
            if temp < ans: ans = temp
        
print(ans)

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

Solution (Python):
import numpy as np
L,R=map(int,input().split(' '))
l,r=L%2019,R%2019
D=R-L
d=r-l
if D<2019:
  if D==d:
    res=[]
    for i in range(L,R+1):
      for j in range(i+1,R+1):
        res.append((i*j)%2019)
    print(min(res))
  else:
    print(0)
else:
  print(0)

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

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

flg = False

for i in range(l, (r + 1), 1):
    if ((i % mod) == 0):
        flg = True
        break

if (flg):
    print(0)
else:
    ans = 2019

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

            if (rep < ans):
                ans = rep

    print(ans)

Solution (Python):
L, R = map(int, input().split())
if R - L >= 2019:
    print(0)
    exit()
L_mod = L % 2019
R_mod = R % 2019
if L_mod > R_mod:
    R_mod += 2019
can = float('INF')
for i in range(L_mod, R_mod):
    for j in range(i + 1, R_mod + 1):
        if can > i * j % 2019:
            can = i * j % 2019
print(can)

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

total = 2019

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

for l in range(L,R):
  for r in range(L+1,R+1):
    if l*r%2019 == 0:
      print(0)
      exit()
    else:
      total = min(total,l*r%2019)
    
print(total)

Solution (Python):
import math

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

ans = 2019

for i, j in zip(range(2019), range(L, R)):
    for k in range(j+1, min(L + 2019*2, R + 1)):
        lr_mod = (j * k) % 2019
        if lr_mod < ans:
            ans = lr_mod
        if ans==0:break
    if ans==0:break

print(ans)

Solution (Python):

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

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

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


if __name__ == '__main__':
    main()

Solution (Python):
import heapq

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

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

Solution (Python):
from itertools import combinations
_=list(map(int,input().split()))
print(min([i[0]*i[1]%2019 for i in list(combinations([i for i in range(_[0],_[1]+1)],2)if _[1]-_[0]<2019else combinations([i for i in range(_[0],_[0]+2020)],2))]))

Solution (Python):
from itertools import combinations
_=list(map(int,input().split()))
print(min([i[0]*i[1]%2019 for i in list(combinations([i for i in range(_[0],_[1]+1)],2)if _[1]-_[0]<2019else combinations([i for i in range(_[0],_[0]+2020)],2))]))

Solution (Python):
from itertools import combinations
_=list(map(int,input().split()))
a=list(combinations([i for i in range(_[0],_[1]+1)],2) if _[1]-_[0]<2019 else combinations([i for i in range(_[0],_[0]+2020)],2))
print(min([i[0]*i[1]%2019 for i in list(a)]))

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

    if R - L >= MOD:
        print(0)
        exit()
	
    ans = 2018
    for i in range(L, R):
        for j in range(i+1, R+1):
           if ans > (i*j)%MOD:
              ans = (i*j)%MOD
              if ans == 0:
                  print(0)
                  exit()
    print(ans)


if __name__ == '__main__':
    solve()

Solution (Python):

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

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

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

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

li = []

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

print(ans)

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

mod_list = []
mul_list = []
if R >= L + 2019:
    print(0)
else: 
    for i in range(L, R+1):
        if i % 2019 == 0:
            print(0)
            break
        else:
            mod_list.append(i)
    else: 
        for i in range(len(mod_list)):
            for j in range(len(mod_list)):
                if i != j: 
                    k = (mod_list[i] * mod_list[j]) % 2019
                    mul_list.append(k)
                else:
                    pass

        print(min(mul_list))

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

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

elif (l % 2019) > (r % 2019):
    print(0)

else:
    li = [i for i in range((l % 2019),(r % 2019)+1)]
    c = 2020
    for i in range(len(li)-1):
        for j in range(i+1,len(li)):
            c1 = (li[i]*li[j]) % 2019
            c = min(c1,c)
    print(c)

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

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

if 2019 <= R - L:
  print('0')
  exit(0)
    
for i in range(L, R):
  for j in range(i+1, R+1):
    mods.append(i*j%2019)
print(min(mods))

Solution (Python):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    L,R=map(int,input().split())
    d=R-L
    L%=2019
    d=min(d,2019)
    from itertools import product
    ans=INF
    for i,j in product(range(d+1),repeat=2):
        if(i>=j): continue
        ans=min(ans,(L+i)*(L+j)%2019)
    print(ans)
resolve()

Solution (Python):



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

modl = [0 for i in range(2019)]

if r - l > 2019:
    modl = [1 for i in range(2019)]
else:
    for i in range(l,r+1):
        modl[i%2019] = 1

ans = float("inf")
for i in range(2019):
    for j in range(i+1, 2019):
        if modl[i] == 1 and modl[j] == 1:
            tmp = i * j % 2019
            if tmp < ans:
                ans = tmp
print(ans)

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

Solution (Python):
import unittest


class TestC(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think(2020, 2040), 2)

    def test_2(self):
        self.assertEqual(think(4, 5), 20)


def solve():
    l, r = read()
    result = think(l, r)
    write(result)


def read():
    return read_int(2)


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_float(n):
    return list(map(lambda x: float(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(l, r):
    mode = 2019
    m = 2018

    for i in range(l, r):
        for j in range(i + 1, r + 1):
            if i % mode == 0 or j % mode == 0:
                return 0
            m = min(m, (i % mode * j % mode) % mode)
    return m


def write(result):
    print(result)


if __name__ == '__main__':
    
    solve()

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

Solution (Python):
import math
L,R = map( int,input().split() )
ans = ( L * (L+1) ) % 2019  
for i in range(L,R):
    if ans == 0:
        break
    j = i + 1
    a = ( i * j ) % 2019
    ans = min(a, ans)
    plus = i % 2019
    while(True):
        over = math.ceil( ( 2019 - a ) / plus )
        j = j + over
        if j > R:
            break
        a = ( i * j) % 2019
        ans = min(a,ans)
        if ans == 0:
            break
print(ans)

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

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

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

ans=2019
if r-l>=2019:
      print(0)
      exit()
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())
if (R-L > 2019) : print(0)
else:
    m = 2019*2019
    for i in range(L,R):
        for j in range(i+1,R+1):
            s = (i*j)%2019
            if (m > s):
                m = s
            if (m == 0):
                break

    print(m)

Solution (Python):
l, r = (int(i) for i in input().split())
if r - l > 2030: print(0)
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
    print(ans)

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

def repeat_division(n):
    while True:
        if n < 2019:
            break
        n %= 2019
    return n

l = repeat_division(L)
r = repeat_division(R)

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

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

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

main()

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

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

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

l = lr[0]
r = lr[1]

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

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

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

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

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

print(ans)

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

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

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

Solution (Python):
l,r = map(int,input().split())
ans = float("inf")
if (l <= 2019 and r >= 2019) or r-l >= 2019:
  print(0)
else:
  x = [_ for _ in range(l,r+1)]
  cnt = r-l+1
  for i in range(cnt):
    for j in range(i+1,cnt):
      ij_mod = (x[i]% 2019)*(x[j] % 2019) % 2019
      ans = min(ans,ij_mod)
  print(ans)

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

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

print(ans)

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

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

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


def main():
    MOD = 2019
    L, R = map(int, input().split())
    
    ans = MOD - 1

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

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

    print(ans)


if __name__ == '__main__':
    main()

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

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

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

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

Solution (Python):

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


if __name__ == "__main__":
    main()

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

mod = 2019
minij = 2020

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

print(minij)

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

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

Solution (Python):
l, r = [int(i) for i in input().split()]
ans = 2020
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):
L,R=map(int,input().split())
A=[]
R=min(R,L+2019)
for i in range(L,R+1):
  for j in range(i+1,R+1):
    A.append((i*j)%2019)
print(min(A))

Solution (Python):

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

if r-l+1>=2019 or l==0:
    print(0)
else:
    res = 2019*2019
    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())
if L%2019==0 or R%2019==0:
  print(0)
else:
  start=L%2019
  end=R%2019
  if start>=end or R-L>=2018: 
    print(0)
  else:
    m=(L*(L+1))%2019
    for i in range(L,R):
      for j in range(i+1,R+1):
        s=(i*j)%2019
        m=min(m,s)
    print(m)

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+1,min(i+2019,R+1)):
    ans = min(ans,(i * j) % MOD)
print(ans)

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

l=L%2019
r=R%2019

ans=0

if R-L<2019 and l<r:
    D=[]
    for i in range(l,r):
        for j in range(i+1,r+1):
            D.append((i*j)%2019)
    ans=min(D)

print(ans)

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

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

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

if r-l > 3000:
    print(0)
else:
    for i in range(l,r+1):
        for j in range(i+1,r+1):
            a.append((i*j)%2019)
    print(min(a))

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

    ans = float('inf')
    if R-L >= 672:
        ans = 0
        print(ans)
        return
    for i in range(L,R):
        for j in range(i+1,R+1):
            ans = min(ans, i*j%2019)
            if ans == 1:
                print(ans)
                return
    print(ans)


if __name__ == '__main__':
    main()

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

    ans = float('inf')
    if R-L >= 672:
        ans = 0
        print(ans)
        return
    for i in range(L,R):
        for j in range(i+1,R+1):
            ans = min(ans, i*j%2019)
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
import sys


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


if __name__ == '__main__':
    slove()

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

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

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

l = L % 2019
r = R % 2019
if R < L + d:
    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())

ansL = []
for i in range(2019):
    if L + i > R:
        break

    ansL.append((L + i) % 2019)

ans = 999999
for i in range(len(ansL)):
    for j in range(i, len(ansL)):
        if i == j:
            continue
        
        ans = min([ans, ((ansL[i] * ansL[j] ) % 2019)])

print(ans)

Solution (Python):
def solve():
    l,r = map(int, input().split())
    if r-l<2019:
        arr = []
        for i in range(l,r):
            for j in range(i+1,r+1):
                if i*j%2019 == 0:
                    return 0
                arr.append(i*j%2019)
        return min(arr)
    else:
        return 0


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

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


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

Solution (Python):
MOD = 2019
L,R = list(map(int,input().split()))
R = min(R, L + MOD)
nums = range(L,R+1)
answer = MOD
for i in range(L,R+1):
    for j in range(max(i+1,L), R+1):
        c = (i*j)%MOD
        
            
        answer = min(c,answer)
print(answer)

Solution (Python):

"""
C - Remainder Minimization 2019
https://atcoder.jp/contests/abc133/tasks/abc133_c

"""
import sys
from itertools import combinations

def solve(l, r):
    res = set()
    for i in range(l, r+1):
        res.add(i % 2019)
        if len(res) == 2019:
            break
    ans = set()
    for a, b in combinations(res, 2):
        ans.add(a * b % 2019)
    return min(ans)


def main(args):
    l, r = map(int, input().split())
    ans = solve(l, r)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Solution (Python):
l, r = (int(x) for x in input().split())
if r-l>= 2019:  
    print(0)
else:
    cur = min(2019, (l % 2019) + (r - l))  
    if cur == 2019:
        print(0)
    else:
        
        min_mod = float('inf')
        for i in range(l, r+1):
            for j in range(i+1,r+1):
                val = (i*j) % 2019
                if val < min_mod:
                    min_mod = val
                    if min_mod == 0:
                        break
            if min_mod == 0:
                print(0)
                break
        else:
            print(min_mod)

Solution (Python):
L,R = map(int,input().split())
if R - L >= 2019 :
    print(0)
else:
    K = []
    for i in range(L,R+1,1):
        a = i % 2019
        K.append(a)
    ans = 10**9+7
    size = len(K)
    for x in range(size):
        for y in range(x+1,size):
            o = K[x] * K[y] % 2019
            if o < ans :
                ans = o
    print(ans)

Solution (Python):
l,r=map(int,input().split())
r-=(l//2019)*2019
l%=2019
if r>=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())


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

Solution (Python):
import sys
a, b = map(int, input().split())
if b-a >= 2019:
    print(0)
    sys.exit()

ans = 2018
for i in range(a, b):
    for j in range(i+1, b+1):
        mod = (i % 2019)*(j % 2019) % 2019
        if ans > mod:
            ans = 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):
l, r = map(int, input().split())
y = 2019
lmod = l % y
if r-l+1 >= y:
  print(0)
else:
  count = float("inf")
  for i in range(l, r):
    for j in range(i+1, r+1):
      if count > i*j%y:
        count = i*j%y
  print(count)