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

R = min(R, L+(2019)) 
MOD = 2019
ans = 2018

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

print(ans)

Solution (Python):
import sys
import math
from copy import deepcopy
from collections import deque
sys.setrecursionlimit(20000000)


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

    ans = 200000000

    for a in range(L, R+1):
        for b in range(a+1, R+1):
            if a * b % 2019 < ans:
                ans = a * b % 2019
                if ans == 0:
                    print(ans)
                    sys.exit()

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
import sys
import math
from copy import deepcopy
from collections import deque
sys.setrecursionlimit(20000000)


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

    ans = 200000000

    for a in range(L, R+1):
        for b in range(a+1, R+1):
            if a * b % 2019 < ans:
                ans = a * b % 2019
                if ans == 0:
                    print(ans)
                    sys.exit()

    print(ans)


if __name__ == '__main__':
    main()

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

n= 0
if r - l > 2019:
	n = l + 2019
else:
	n = r

min = 2019

for i in range(l, n):
	for j in range(l+1, n+1):
		mod = (i*j) % 2019
		if mod < min:
			min = mod

print(min)

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

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

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

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

if R-L<mod-1:
  a=[i%mod for i in range(L,R+1)]
  if 0 in a:
    print(0)
  else:
    an=[]
    for i in range(len(a)):
      for j in range(i+1,len(a)):
        an.append((a[i]*a[j])%mod)
    print(min(an))
else:
  print(0)

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

    c = 2019
    for i in range(l, r+1):
        for j in range(l, r+1):
            if i%2019 == 0 or j%2019==0:
                print(0)
                return 0
            elif i == j:
                pass
            else:
                c = min(i*j%2019, c)
    print(c)

if __name__ == "__main__":
    f_c()

Solution (Python):






l,r=input().split()
l,r=int(l),int(r)
if r-l>=2018:
    print(0)
else:
    '''
    l,r=l%2019,r%2019
    if r>l:
        print(l*(l+1))
    else:
        print(0)
    '''
    '''
    x=(l*(l+1))%2019
    for i in range(l+1,r+1):
        x=min([i*(i+1),x])%2019
        if x==0:
            break
    print(x)
    '''
    a=[i%2019 for i in range(l,r+1)]
    x=(a[0]*a[1])%2019
    for i in range(len(a)):
        for j in range(len(a)-i-1):
            x=min([x,(a[i]*a[i+1+j])%2019])
            if x==0:
                break
        if x==0:
            break
    print(x)

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

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

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

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

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


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

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

memoL = [False]*2019
memoR = [False]*2019

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

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

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

Solution (Python):


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

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

print(ans)

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

Solution (Python):



import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

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

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

Solution (Python):
def main():
    l, r = map(int, input().split())
    rng = r - l
    ans = float("inf")
    if rng >= 2018:
        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)


if __name__ == "__main__":
    main()

Solution (Python):
def main():
    l, r = map(int, input().split())
    rng = r - l
    ans = float("inf")
    if rng >= 2018:
        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)


if __name__ == "__main__":
    main()

Solution (Python):
l, r = map(int, input().split())
rng = r - l
ans = float("inf")
if rng >= 2018:
    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):
l,r=map(int,input().split())
ans=2020
for i in range(l,min(r,l+2019)):
    for j in range(i+1,min(r,i+2019)+1):
        ans=min(ans,(i*j)%2019)
print(ans)

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

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

Solution (Python):

import sys

MOD = 2019  

def solve(L: int, R: int):
    m = L // MOD
    r = L % MOD
    L -= MOD * (m + 1) 
    R -= MOD * (m + 1)
    minmod = sys.maxsize
    upperbound = min(L + MOD, R + 1)
    for i in range(L, upperbound):
        for j in range(i + 1, upperbound):
            minmod = min(minmod, (i * j) % MOD)
    for i in range(L, upperbound):
        if i + MOD <= R:
            minmod = min(minmod, (i * i) % MOD)
    print(minmod)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = int(next(tokens))  
    R = int(next(tokens))  
    solve(L, R)

if __name__ == '__main__':
    main()

Solution (Python):
L,R=map(int,input().split())
if L//2019<R//2019:
  print(0)
else:
  L,R=L%2019,R%2019
  if L > R:
    print(0)
  else:
    import heapq
    import itertools
    l=[]
    for i,j in itertools.combinations(range(L,R+1),2):
      heapq.heappush(l,(i*j)%2019)
    print(heapq.heappop(l))

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

ll = l % 2019
rr = r % 2019

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

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


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

Solution (Python):

L, R = map(int, input().split())
end = min(R, L + 637*2)

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

Solution (Python):
l,r = map(int,input().split())
'''
for h in range(0,2):
	for i in range(l,r+1):
		if i % (2019+h) == 0:
			print(h)
			exit()
		elif i % (673+h) == 0 and (r-l)>=2:
			print(h)
			exit()
		elif i % (2019-h) == 0:
			print(h)
			exit()
		elif i % (673-h) == 0 and (r-l)>=2:
			print(h)
			exit()
'''
			
lst = []

for i in range(l,r):
	for j in range(l+1,r+1):
		if (i*j)%2019 == 0:
			print(0)
			exit()
		lst.append((i*j)%2019)

print(min(lst))

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

Solution (Python):







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

Solution (Python):
import math
import copy




def getInputNum():
    inputNum = int(input())
    return inputNum

def getInputListInt():
    outputoData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData

def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList

def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList



a = getInputListInt()
min = a[0]
max = a[1]

ans_max = 2019
ans = ans_max

flg = False

for i in range(min, max):
    for j in range(i+1, max+1):
        tmp = (i*j) % ans_max

        if ans > tmp:
            ans = tmp

        if ans == 0:
            flg = True
            break

    if flg:
        break

print(ans)

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


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

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

Solution (Python):
import numpy as np
a,b = map(int,input().split())
moda=np.mod(a,2019)
modb=np.mod(b,2019)
if (modb<=moda)or((b-a)>=673):
    print(0)
    exit()

num =list(range(moda,modb+1))

ans = 10000
for i,l in enumerate(num):
    if i == len(num)-1:
        break
    for r in num[i+1:]:
        ans = min(np.mod(l*r,2019),ans)
print(ans)

Solution (Python):
a=input().split(" ")
L=int(a[0])
R=int(a[1])
if R-L>=672:
    print(0)
else:
    list=[]
    for p in range(0,R-L):
        for q in range(p+1,R-L+1):
            list.append(((L+p)*(L+q))%2019)
    print(min(list))

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

if l % 2019 == 0 or r % 2019 == 0 or rdiv - ldiv > 0:
    print(0)
else:
    queue = []

    for i in range(1, MOD):
        counter = 0
        for j in range(ldiv, rdiv + 1):
            if l <= j * MOD + i <= r:
                counter += 1
                if counter > 1:
                    break
        if counter > 1:
            queue.append(i)
            queue.append(i)
        elif counter > 0:
            queue.append(i)

    l = len(queue)
    res = float("inf")
    for i in range(l):
        for j in range(i + 1, l):
            res = min(res, (queue[i] * queue[j]) % MOD)

    print(int(res))

Solution (Python):

LR = input().split()
L = int(LR[0])
R = int(LR[1])
S = []

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

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


for i in range(L, R + 1):
    for k in range(i + 1, R + 1):
        if output == 0:
            break

        if output > i * k % 2019:
            output = i * k % 2019
    else:
        continue
    break

print(output)

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

print (ans)

Solution (Python):
L, R = map(int, input().split())
if R - L > 2019:
    print(0)
else:
    ans = (L * R) % 2019
    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)

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

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

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

Solution (Python):
s = input().split() 

a = int(s[0])
b = int(s[1])
m = 2019

while b-a >= 2019*2:
    b-=2019

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

print(m)

Solution (Python):
s = input().split() 

a = int(s[0])
b = int(s[1])
m = 2019

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

print(m)

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


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

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

Solution (Python):
from itertools import product


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


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

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


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

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

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

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

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

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

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(L+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:
    amalist = [i%2019 for i in range(L, R+1)]
    min_value=2020
    for i in range(len(amalist)-1):
        for j in range(i+1, len(amalist)):
            if (amalist[i]*amalist[j])%2019 < min_value:
                min_value = (amalist[i]*amalist[j])%2019
    print(min_value)

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

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

ans = 10 ** 9

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

Solution (Python):
l,r = map(int,input().split())
mod = 2019
line = (r // mod) * mod
if l*r < mod:
    print(l*r)
elif l < line < r:
    print(0)
else:
    ans = 0
    for i in range(l,r):
        for j in range(i+1,r+1):
            x = i * j
            x = x % mod
            if i==l and j==i+1:
                ans = x
            elif x < ans:
                ans = x
    print(ans)

Solution (Python):
ri=lambda:map(int,input().split(' '))

l,r=ri()
if r//2019 > l//2019:
  print(0)
  import sys
  sys.exit(0)
l%=2019
r%=2019
if l>r:
  print(0)
else:
  best = 2020
  for x in range(l,r+1):
    for y in range(l,r+1):
      if x!=y:
        cur = (x*y)%2019
        best=min(best,cur)
  print(best)

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

minimum = 2018

for i in range(l,r):
    for j in range(l+1,r+1):
        if minimum == 0:
            break
        elif (i*j)%mod < minimum:
            minimum = (i*j)%mod
        else:
            pass      
    if minimum == 0:
        break
    
print(minimum)

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

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

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

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

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

L_waru = L // 2019
R_waru = R // 2019


ans = 2019


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

else:
    print(0)

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

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

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

Solution (Python):
from sys import stdin

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

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

input = stdin.readline
main()

Solution (Python):
LR = input().split(' ')
L = int(LR[0])
R = int(LR[1])

min_num = 2000000001
flag = False
for l in range(L,R):
    for r in range(l+1,R+1):
        mod = (l*r) %2019
        if mod < min_num:
            min_num = mod
            if mod == 0:
                flag =True
                break
    if flag:
        break

print(min_num)

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

if R - L > 2019:
    print(0)
else:
    for k in range(L, R):
        for j in range(k + 1, R + 1):
            ans.append((k * j) % 2019)
    print(min(ans))

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

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

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

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

Solution (Python):


import math
l, r = map(int, input().split())
ans = 2018

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

print(ans)

Solution (Python):

l,r=map(int,input().split())
c=(r-l)
d=2018
if c>=2018:
    print(0)
else:
    for i in range(l,r):
        for k in range(l+1,r+1):
            
            if (i*k)%2019<d:
                d=(i*k)%2019
    print(d)

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

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

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

l_q, l_mod = divmod(l, 2019)
r_q, r_mod = divmod(r, 2019)

min_v = 2019
if l_q == r_q:
    for i in range(l_mod, r_mod+1):
        for j in range(l_mod, r_mod+1):
            if i != j:
                mul = (i * j) % 2019
                if mul < min_v:
                    min_v = mul
else:
    min_v = 0

print(min_v)

Solution (Python):
def main():
    L, R = map(int, input().split())
    d = dict()
    for i in range(L, min(R+1, L+2019*2)):
        v = i % 2019
        if v not in d: d[v] = 1
        else: d[v] += 1

    min_r = 2018
    for i in d:
        if i in d and d[i] > 1:
            min_r = min(min_r, (i*i) % 2019)

    for i in d:
        for j in d:
            if i < j: min_r = min(min_r, (i*j) % 2019)

    return min_r



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

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

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

print(tmp)

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

for n in range(l,r+1):
    for m in range(n+1,r+1):
        tmp = n*m%2019
        if tmp == 0:
            print(0)
            exit()
        ans.append(tmp)
print(min(ans))

Solution (Python):
L, R = map(lambda x: int(x),input().split(" "))
num_list = []

while L > 2019:
  L = int(L-2019)
  R = int(R-2019)

if R < 2019:
  for i in range(L,R):
    for j in range(L+1,R+1):
      num_list.append((i*j)%2019)
  print(min(num_list))
elif L <= 2019 and R >= 2019:
  print(0)

Solution (Python):
l,r = map(int, input().split())
waruL = l // 2019
waruR = r // 2019
if waruL < waruR :
    modMin = 0
else:
    modMin = 2018
    modL = l%2019
    modR = r%2019

    for i in range(modL,modR):
        for j in range(i+1,modR+1):
            modIJ = (i*j)%2019

            if modIJ < modMin:
                modMin = modIJ
print(modMin)

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

    else:
        print(0)

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

for i in range(L,R):
    for j in range(i+1,R+1):
        ans.append((i*j)%2019)

print(min(ans))

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

minimum = 2019
for i in range(L, R):
    mod_i = i % mod
    for j in range(i+1, R+1):
        mod_j = j % mod
        result = (mod_i * mod_j) % mod
        if result < minimum:
            minimum = result
        if minimum == 0:
            print(0)
            exit(0)
print(minimum)

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

print(ans)

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

if (R - L) >= 2019:
    print (0)
else:
    min_p = 2019
    for n in range(L, R):
        for n2 in range(n + 1, R + 1):
            tmp_p = (n * n2) % 2019
            if (tmp_p < min_p):
                min_p = tmp_p

    print (min_p)

Solution (Python):
l,r=map(int,input().split())
if l//2019 < r//2019:
    print(0)
else:
    l%=2019
    r%=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())
ans = []
check = False

for i in range(L, R+1):
    if i % 2019 == 0:
        print(0)
        check = True
        break
    else:
        ans.append(i % 2019)

if not check:
    ij = 2019
    for i in range(len(ans)-1):
        for j in range(i+1, len(ans)):
            temp = ans[i] * ans[j] % 2019
            if temp < ij:
                ij = temp
    print(ij)

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

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

print(min_remaider)

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

for i in range(l,r):
    for j in range(l+1,r+1):

        ans = i*j%2019
        
        if i == l and j == l+1:
            min = ans
    
        if ans < min:
            min = ans
        
        if min == 0:
            break

    if min == 0:
        break

print(min)

Solution (Python):
inp = [int(v) for v in input().split(' ')]
L = inp[0]
R = inp[1]

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

Solution (Python):
L, R = map(int, input().split())
R = min(L + 2019, R)
lst = list(range(L, R + 1))
ret = 2018
for idx, x in enumerate(lst):
    for y in lst[idx + 1:]:
        ret = min(ret, x * y % 2019)
print(ret)

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

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

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

if r-l+1 >= 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)
            if ans == 0:
                break
        if ans == 0:
            break
    print(ans)

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

def mod(x,y):
    return (x*y)%2019

ans = 2020
if l-r >= 2019:
    ans = 0
elif l-r < 2019:
    for i in range(l,r,1):
        for j in range(i+1,r+1,1):
            temp = mod(i,j)
            ans = min(temp,ans)
            if ans == 0:
                break
        else:
            continue
        break

print(ans)

Solution (Python):

p = 2019

l,r = map(int, input().split())
n = r-l+1

if n<2*p:
  tmps = [(i*j)%p for i in range(l,r) for j in range(i+1,r+1)]
  mini = min(tmps)

else:
  
  
  
  
  mini = 0

print(mini)