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):
N=list(map(int,input().split()))

if N[1]>=((673-N[0]%673)+N[0]):
  if N[1]==N[0]+1:
    p=(N[1]*N[0])%2019
  else:
    p=0
else:
 a=N[0]%2019
 b=N[1]%2019
 max1=2018
 for i in range(a,b):
     for j in range(i+1,b+1):
         if max1>(i*j)%2019:
           max1=(i*j)%2019
 p=max1

print(p)

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

minnum=1000000000000
for i in range(l,r):
    for j in range(i+1,r+1):
        check=(i*j)%2019
        if check<minnum:
            minnum=check
            
print(minnum)

Solution (Python):
A = list(map(int,input().split()))
L = A[0]
R = A[1]
if R - L >= 673:
    print(0)
else:
    B = []
    C = []
    for _ in range(L,R + 1):
        B.append(_ % 2019)
    k,l = 0,1
    count = 0
    N = len(B)
    while k < N - 1:
        while l < N:
            C.append((B[k] * B[l]) % 2019)
            l += 1
        k += 1
        l = k + 1
    print(min(C))

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

Solution (Python):
import math


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









ans = 2019

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

print(b)

Solution (Python):
l, r = map(int, input().split())
def mod2019(x, y):
    ans=2019
    for i in range(x, y):
        for j in range(i + 1, y + 1):
            ans = min(ans, i * j % 2019)
    return ans

if r - l >= 2019:
    print(0)
else:
    print(mod2019(l,r))

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

Solution (Python):
l, r = map(int, input().split())
m = 2019
l, r = l%m, l%m+(r-l)
if r-l >= m-1:
    print(0)

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

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

R = min(R, L + 2030)

res = 2019

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



print(res)

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

Solution (Python):
from itertools import combinations as comb

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

min = 2018
if r-l >= 2018:
    print(0)
else:
    range_list = [i for i in range(l, r + 1)]
    comb_list = list(comb([i for i in range(r - l + 1)], 2))
    for comb in comb_list:
        if range_list[comb[0]]*range_list[comb[1]]%2019 < min:
            min = range_list[comb[0]]*range_list[comb[1]]%2019
    print(min)

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

if r-l >= 2018:
  print(0)
else:
  l_mod = l%2019
  r_mod = r%2019
  min_mod = float('inf')
  if l_mod <= r_mod:
    for c in itertools.combinations(range(l_mod, r_mod+1), 2):
      min_mod = min(min_mod, (c[0]*c[1])%2019)
    print(min_mod)
  else:
    print(0)

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

p, q = L%2019, R%2019
z = R - L

if (p == 0) or (q == 0) or (z > 2019) or (p >= q):
    print(0)
else:
    answer = []
    for i in range(z):
        for j in range(z-i):
            k1 = p + i
            k2 = j + k1 + 1
            X = k1 * k2 % 2019
            answer.append(X)
    A = min(answer, key=int)
    print(A)

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

diff = R - L
min_mod = 2020
second_min_mod = 2021
for i in range(L, min(L+2019, L+(diff)+1)):
    for j in range(i+1, min(L+2019, L+(diff)+1)):
        if min_mod > (i*j) % 2019:
            min_mod = (i*j) % 2019
print(min_mod)

Solution (Python):
from copy import *
from sys import *
import math
import queue
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)


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


def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(m,n):
	x = max(m,n)
	y = min(m,n)
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	return y

class queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()

Solution (Python):

import sys
L, R = list(map(int, input().split()))
if (R - L) == 2019:
    result = 0
else:
    result = 2018
    for i in range(L,R+1):
        for s in range(i+1,R+1):
            x = (i*s)%2019
            if x == 0:
                result = 0
                print(0)
                sys.exit()
            elif result > x:
                result = x
print(result)

Solution (Python):
import sys
a = input().split()

L = int(a[0])
R = int(a[1])
if R - L == 2019:
  print(0)
  sys.exit()

mm = 2018

for i in range(L , R + 1):
  for j in range(L , R + 1):
    if i < j:
      n = (i * j) % 2019
      if n == 0:
        print(0)
        sys.exit()
      elif n < mm:
        mm = n
print (mm)

Solution (Python):
a,b = map(int,input().split())
c = [2019]*2
p = 0
flag = 0
if (b-a) >= 2019:
    for j in range(a,a+2020):
        if j%2019 == 0:
            flag = 1
            break
        for l in range(j+1,a+2020):
            if l%2019==0:
                flag = 1
                break
            c[1] = (j*l)%2019
            c[0] = (j*l)%2019 if c[0] > c[1] else c[0]
else:
    for m in range(a,b+1):
        if m%2019 == 0:
            flag = 1
            break
        for n in range(m+1,b+1):
            if n%2019==0:
                flag = 1
                break
            c[1] = (n*m)%2019
            c[0] = (n*m)%2019 if c[0] > c[1] else c[0]
if flag == 1:
    print(0)
else:
    print(c[0])

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

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

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

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

Solution (Python):
import numpy as np
def min_mod2019(L, R):

    mod_list = [i for i in range(2019)]

    imin=0
    jmin=0
    
    if L%2019 < R%2019 and R < L+2019:
        mod_list = mod_list[L%2019:R%2019 + 1]
        min_mod = 2019
        for i in range(len(mod_list)-1):
            for j in range(i+1, len(mod_list)):
                if min_mod > (mod_list[i]*mod_list[j])%2019:
                    
                    
                    min_mod=(mod_list[i]*mod_list[j])%2019
        return min_mod
    return 0

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

Solution (Python):
(L,R)=(int(x)for x in input().split())
 
if (R-L>=2019):
    print ( 0 )
    exit()

a = []

for i in range (R-L+1):
    
    x = L + i
    a.append((x)%2019)        

    
ans = 2019

for i in range (R-L+1):

    for j in range (R-L+1):

        if i == j :
            continue
        
        ans_tmp = ( a[i] * a[j] )%2019
        
        if ans_tmp < ans:
            ans = ans_tmp
        
print (ans)

Solution (Python):
L, R = map(int, input().split())
ans = 2018
for x in range(L, min(R, L+2019)):
    for y in range(L+1, min(R+1, L+2019)):
        ans = min(ans, (x*y)%2019)
        if ans == 0:
            print(0)
            quit()
print(ans)

Solution (Python):
l, r = [int(e) for e in input().split()]
m = 2019
for i in range(l, r):
  for j in range(i + 1, r + 1):
    t = (i * j) % 2019
    if t < m:
      m = t
    if m == 0:
      break
  if m == 0:
    break
print(m)

Solution (Python):
l, r = [int(e) for e in input().split()]
m = 2019
for i in range(l, r):
  ir = i % 2019
  for j in range(i + 1, r + 1):
    t = (ir * j) % 2019
    if t < m:
      m = t
    if m == 0:
      break
  if m == 0:
    break
print(m)

Solution (Python):
l, r = [int(e) for e in input().split()]
m = 2019
for i in range(l, r):
  ir = i % 2019
  for j in range(i + 1, r + 1):
    t = (ir * j) % 2019
    if t < m:
      m = t
    if m == 0:
      break
  if m == 0:
    break
print(m)

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

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

Solution (Python):
import sys

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

ans = sys.maxsize

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

print(ans)

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

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

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

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

Solution (Python):
import sys

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

mod = 2019
ans = 2018

for i in range(L,R):
    for j in range(i+1,R+1):
        temp = (i*j) % mod
        if temp < ans:
            ans = temp
        if temp ==0:
            print(0)
            sys.exit()

print(ans)

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

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

print(min)

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

K = 2019

def f(a):
	return a // K

def main():
	l, r = map(int, input().strip().split())
	ans = 0
	if f(r) - f(l) >= 1:
		pass
	else:
		t = 10**9
		for i in range(l, r):
			for j in range(l+1, r+1):
				t = min(t , (i*j) % K)
		ans = t
	print(ans)

if __name__ == '__main__':
	main()

Solution (Python):
import numpy as np
L, R = [int(x) for x in input().split(" ")]
N = 2019

minimum_mod = N
for i in range(L, R):
    for j in range(i + 1, R + 1):
        if (i * j) % N == 0:
            print(0)
            exit(0)
        elif (i * j) % N < minimum_mod:
            minimum_mod = (i * j) % N

print(minimum_mod)

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

main()

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

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


def solve(l, r):
    N = 2019

    r = min(r, l+N)

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


if __name__ == '__main__':
    main()

Solution (Python):


l, r = map(int, input().split())
ans = 10**9

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

print(ans)

Solution (Python):
from itertools import*
a,b=map(int,input().split())
if b-a>=2019:
    print(0)
else:
    print(min(s*t%2019 for s,t in combinations(range(a,b+1),2)))

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

ans = 2018
mod = 2019

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

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

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

Solution (Python):

"""
Created on Sun Jul 28 20:37:55 2019

@author: avina
"""

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

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

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


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

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

Solution (Python):
L, R = map(int, input().split())
ans = 2018
for x in range(L, min(R, L+2019)):
    for y in range(L+1, min(R+1, L+2019)):
        ans = min(ans, (x*y)%2019)
        if ans == 0:
            print(0)
            quit()
print(ans)

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

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

Solution (Python):
L, R = map(int, input().split())
import numpy as np
LL = L%2019
RR = R%2019

min = 2019
if LL >= RR:
    min = 0
elif R-L >= 2018:
    min = 0
else:
    for i in range(LL, RR+1):
        for j in range(i+1, RR+1):
            if (i*j)%2019 < min:
                min = (i*j)%2019
            if (i*j)%2019 == 0:
                min = 0
                break
        else:
            continue
        break


print(min)

Solution (Python):
L,R=map(int,input().split())
ans=2018
for i in range(L,R+1):
    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())
l = L%2019
r = R%2019
ans = 2019
if R-L >= 2019-l:
    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 = input().split()
l = int(l)
r = int(r)
 

 
if r - l >= 2019:
    print(0)
else:
    l_mod = l % 2019
    r_mod = r % 2019
    min_val = 2020
    for i in range(r_mod - l_mod + 1):
        for j in range(r_mod - l_mod + 1):
            if i >= j:
                continue
            min_val = min([min_val, ((l_mod+i)*(l_mod+j))%2019])
            
    print(min_val)

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

 
if r - l >= 2019:
    print(0)
else:
    l_mod = l % 2019
    r_mod = r % 2019
    min_val = 2020
    for i in range(r_mod - l_mod + 1):
        for j in range(r_mod - l_mod + 1):
            if i >= j:
                continue
            min_val = min([min_val, ((l_mod+i)*(l_mod+j))%2019])
            
    print(min_val)

Solution (Python):
l,r = map(int,input().split())
mi = 2019
for x in range(l,min(r,l+2019)):
    for y in range(x+1,min(r+1,l+2019)):
        if mi > (x*y)%2019:
            mi = (x*y)%2019
print(mi)

Solution (Python):
import numpy as np
S = input().split() 
L = int(S[0])
R = int(S[1])
ans = 2019*2019
if(R-L >=2019):
    print(0)
else:
    for i in range(L,R):
        for j in range(i+1,R+1):
            ans = np.minimum(ans,(i*j)%2019)
            if(ans == 0):
                print(0)
                exit()
    print(ans)

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



if r-l>=2019:
    times = 2019
else:
    times = r-l

add = l
ans = 2019
for i in range(times):
    for j in range(times+1):
        if i<j:
            cnt = ((add+i)*(add+j))%2019
            ans = min(ans,cnt)
print(ans)

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

Solution (Python):

import sys
import itertools

MOD = 2019  

def solve(L: int, R: int):
    if R - L + 1 >= 2019:
        print(0)
    else:
        m = 2019
        for i, j in itertools.combinations(range(R-L+1), 2):
            if m > ((i+L)*(j+L) % 2019):
                m = (i+L) * (j + L) % 2019
        print(m)
    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())
l = L
m = (L *(L + 1)) % 2019
while l < min (R, L + 2019):
  r = l + 1
  while r <= min (R, L + 2019):
  	n = (l * r) % 2019 
  	m = min(m,n)
  	r = r + 1
  l = l + 1
print(m)

Solution (Python):
def solve(left, right):
    if right - left >= 2019:
        return 0
    l_mod = left % 2019
    r_mod = right % 2019
    if r_mod < l_mod:
        return 0
    ans = 2019
    for i in range(l_mod, r_mod + 1):
        for j in range(i + 1, r_mod + 1):
            ans = min(ans, i * j % 2019)
    return ans


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

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

Solution (Python):
def main():
  p = 2019
  L, R = list(map(int, input().split()))
  
  if (R - L) >= p:
    ans = 0
    print(ans)
    
  else:
    L, R = L % p, R % p
    ans = 2019 ** 2
    for i in range(L, R + 1):
      for j in range(i+1, R+1):
        tmp = (i * j) % p
        if tmp < ans:
          ans = tmp
    print(ans)
    
main()

Solution (Python):
def main():
  p = 2019
  L, R = list(map(int, input().split()))
  
  if (R - L) >= p:
    ans = 0
    print(ans)
    
  else:
    L, R = L % p, R % p
    ans = 2019 ** 2
    for i in range(L, R + 1):
      for j in range(i+1, R+1):
        tmp = (i * j) % p
        if tmp < ans:
          ans = tmp
    print(ans)
    
main()

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

Solution (Python):
from copy import *
from sys import *
import math
import queue
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)


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


def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(m,n):
	x = max(m,n)
	y = min(m,n)
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	return y

class queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()

Solution (Python):


def solve():
    L, R = list(map(int, input().split()))
    MOD = 2019
    
    if R-L >= MOD:
        print(0)
        return

    L %= MOD
    R %= MOD

    if R < L:
        print(0)
        return
    
    ans = MOD
    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__":
    solve()

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

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

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

Solution (Python):
L, R = map(int, (input().split()))
Lmod, Rmod = L%2019, R%2019
result = 2019
if Lmod < Rmod and (R - L >= 2019):
    print(0)
elif Lmod < Rmod and (R - L < 2019):
    for i in range(L,R,1):
        for j in range(i+1, R+1, 1):
            if result > (i*j)%2019:
                result = (i*j)%2019
    print(result)
elif Lmod > Rmod:
    print(0)

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

Solution (Python):


l,r=map(int,raw_input().split())
r=min(r,l+673)
res=2018
for i in  xrange(l,r+1):
 for j in xrange(i+1,r+1):
  res=min(res,i*j%2019)
print res

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

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

Solution (Python):

S = input()

S = S.split()

L = int(S[0])
R = int(S[1])
min = 2 * (10**10)

flg = 0

for i in range(L, R, 1):
    if flg ==0:
        for j in range(i+1, R+1, 1):
            mod = (i*j) % 2019
            if mod < min:
                min = mod
                if min == 0:
                    flg = 1
                    break
    else:
        break

print(min)

Solution (Python):
a=(list(map(int,input().split())))
l=a[0]
r=a[1]
if(l-r>2021):
	print(0)
else:
	mini=2019
	i=l
	notFound=True
	while(i<=r-1 and notFound):
		j=i+1
		while(j<=r and notFound):
			p=(i*j)%2019
			
			mini=min(mini,p)
			if(mini==0):
				notFound=False	
			j+=1

		i+=1
	print(mini)

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

Solution (Python):
import numpy as np

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

l = L%2019
r = R%2019
answer = 0

if l-r < 0 and R - L < 2018:
    for i in range(r-l):
        for j in range(r-l-i):
            k = i + l
            m = j + l + i + 1
            if i == 0 and j == 0:
                answer = (k*m)%2019
            if answer >= (k*m)%2019:
                answer = (k*m)%2019
print(answer)

Solution (Python):
import numpy as np

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

N = int(L/2019)
M = int(R/2019)
l = L%2019
r = R%2019

answer = 0
delta = M - N

if delta == 0:
    for i in range(r-l):
        for j in range(r-l-i):
            k = i + l
            m = j + l + i + 1
            if i == 0 and j == 0:
                answer = (k*m)%2019
            if answer >= (k*m)%2019:
                answer = (k*m)%2019
print(answer)

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

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

ans = 2019
for i in range(L,R+1):
    if i % 2019 == 0:
        ans = 0
        break

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

print(ans)

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

    ans = tmp_min
print(ans)

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

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

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

N, M, = map(int, input().split())

ans = 10 ** 18
for i in range(N, M):
    for j in range(i + 1, M + 1):
        ans = min(ans, i * j % 2019)
        if ans == 0:
            print(ans)
            exit()
print(ans)

Solution (Python):
def C_RemainderMinimization2019():
    L, R = map(int, input().split())
    ans = (L * R) % 2019
    if R - L < 2019:
        for i in range(L, R ):
            for j in range(i + 1, R + 1):
                ans = min(ans, (i * j) % 2019)
    else:
        for i in range(L, L + 2019):
            for j in range(i + 1, L + 2020):
                ans = min(ans, (i*j) % 2019)
                if ans == 0:
                    break
    print(ans)
if __name__ == "__main__":
    C_RemainderMinimization2019()

Solution (Python):

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

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(m, (i*j)%2019)
    print(m)

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

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

maxitr = min([R,L+2019])

minval = 2020

for i in range(L,maxitr+1):
  for j in range(i + 1,maxitr+1):
    if minval > i*j%2019:
      minval = i*j%2019

print(minval)

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

Solution (Python):
m = 2019

def compute(L, R):
    global m
    
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            v = i * j % 2019
            if v < m:
                m = v

            
            if m == 0:
                return


L, R = list(map(int, input().rstrip().split()))
compute(L, R)
print(m)

Solution (Python):
a,b=map(int,input().split())
x=0;md=0;min=4000
if a+2022<b:
    b=a+2022

for i in range(a,b,1):
    for j in range(a+1,b+1,1):
        x = i * j
        md = x % 2019
        if md < min:
            min = md


print(min)