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 R - L >= 2019:
    print(0)
else:
    ans = 2019
    print(min([i*j%2019 for i in range(L, R) for j in range(i+1, R+1)]))

Solution (Python):
import itertools
L,R = map(int, input().split())
if (R - L) + 1 >= 2019:
        print(0)
        exit()
elif (R - L) + 1 >= 673:
        print(0)
        exit()

if (R - 1) * R < 2019:
        print(L * R)
        exit()


if L % 2019 == 0:
        print(0)
        exit()
elif L % 673 < R % 673:
        li = range(L, R + 1)
        cmb = list(itertools.combinations(li,2))
        ans = (R-1) * R
        for i,j in cmb:
                ans = min(ans, (i*j) % 2019)
        print(ans)

else:
        print(0)
        exit()

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

ans = float('inf')

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

print(ans)

Solution (Python):




def remind2019(L, R):
    
    if (R-L)> 2019:
        return 0

    if (R%2019 == 0) or (L%2019==0):
        return 0
    else:
        qL, mL = divmod(L,2019)
        qR, mR = divmod(R, 2019)

        if mR <= mL: 
            return 0
        else:
            min_m = 2017*2018
            for i in range(mL, mR):
                for j in range(i+1, mR+1):
                    m = (i*j)%2019

                    if m < min_m:
                        min_m = m 
            return min_m



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

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

minValue = 2018
rR = R if R < L + 2019 else L + 2019
for i in range(L, rR):
    temp = 0
    for j in range(i+1, rR):
        temp = i*j % 2019
        if(temp < minValue):
            minValue = temp
    temp = i*rR % 2019
    if(temp < minValue):
        minValue = temp
print(minValue)

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

v = 2019

mins = []
for i in range(L,min(R,L + v)):
    tmp_min = 10e10
    for h in range(i + 1,min(R,L + v) + 1):
        res = (i * h) % v
        if res < tmp_min:
            tmp_min = res
    mins.append(tmp_min)


print(min(mins))

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

l = L // mod
r = R // mod

if l != r:
    print(0)
else:
   l_ = L % mod
   r_ = R % mod
   ans = 2019
   for i in range(l_, r_):
       for j in range(i+1, r_+1):
           a = i * j % mod
           ans = min(ans, a)
   print(ans)

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

if r - l >= 2018:
    print(0)
elif (l % MOD) >= (r% MOD):
    print(0)
else:
    left = l % MOD
    right = r % MOD
    L = list(range(left, right+1))
    n = len(L)
    ans = 10**4
    for i, elm in enumerate(L):
        for j in range(i+1, n):
            ans = min(ans, ((elm * L[j]) % MOD))
    print(ans)

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

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

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

mod = 1000000
for i in range(L, R+1):
  for j in range(i+1, R+1):
    tmp = (i * j) % 2019
    if tmp == 0:
      print(tmp)
      sys.exit()
      
    if mod > tmp:
      mod = tmp
    
print(mod)

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

if L // 2019 < R // 2019 or L % 2019 == 0:
    ans = 0
else:
    l = L % 2019
    r = 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())

l =[]

for j in range(L, R+1):
    for i in range(j+1, R+1):
        l.append(i * j % 2019)
        if i * j % 2019 == 0:
            break
    else:
        continue
    break

print(min(l))

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

for i in range(l, r+1):
    if i%2019 == 0:
        f = 1
        break
    mod_list.append(i%2019)

if f == 1:
    print(0)
else:
    
    ans = 2018
    for i in range(len(mod_list)):
        for j in range(i+1, len(mod_list)):
            if mod_list[i]*mod_list[j]%2019 < ans:
                ans = (mod_list[i]*mod_list[j])%2019
    print(ans)

Solution (Python):




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

tmp_ans = 0
ans = -1

for i in range(r-l):
    for j in range(r-l):
        tmp_ans = ((l+i) * (l+j+1)) % 2019
        
        if tmp_ans == 0:
            ans = 0
            break
        if tmp_ans < ans:
            ans = tmp_ans
        elif ans == -1:
            ans = tmp_ans
    if ans == 0:
        break


print(ans)

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

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

R = min(l+2018, r)
min_x = 2018

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

        x = (i*j) % 2019
        if x < min_x:
            min_x = x
print(min_x)

Solution (Python):
L, R = map(int, input().split())
L1 = L%2019
R1 = R%2019
L2 = L//2019
R2 = R//2019
if L2 != R2:
  ans = 0
else:
  ans = (L*(L+1))%2019
  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):

import sys

MOD = 2019  

def solve(L: int, R: int):
    if R - L >= 2019:
        print(0)
        return
    L = L % 2019
    R = R % 2019
    if L >= R:
        print(0)
        return
    res = 2019
    for i in range(L, R):
        for j in range(i+1, R+1):
            res = min(res, (i*j)%2019)
    print(res)
    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())

from itertools import combinations

if r - l > 2019:
    r = l+2019

ans = [(x1*x2)%2019 for (x1, x2) in combinations(range(l, r+1), 2)]

print(min(ans))

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

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

Solution (Python):
import numpy as np
import cmath
L, R = map(int,input().split())
saisyo = 2019
if(R-L>=2019):
    print(0)
else:
    vec = np.arange(L,R+1)
    vec = vec%2019
    for i in range(0,len(vec)):
        minvec = np.where(vec==vec[i],2018,vec*vec[i]%2019)
        tmp = np.min(minvec)
        if tmp < saisyo:
            saisyo = tmp
    print(saisyo)

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

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

if int(arg[0] / 2019) != int(arg[1] / 2019):
  arg[1] = arg[0] + 2019
  
min_value = 2019
for i in range(arg[0], arg[1]+1):
  for j in range(i+1, arg[1]+1):
    value = (i*j) % 2019
    if value < min_value:
      min_value = value
      
print(min_value)

Solution (Python):
import sys
lr = list(map(int, input().split()))
l = lr[0]
r = lr[1]
lmod = l%2019

def minfunc(x, y):
    if x > y:
        return y
    else:
        return x

if r - l >= 2019:
    print(0)
elif 2019 <= r - l + lmod:
    print(0)
else:
    min = 9999999
    modlist = list(map(lambda x: x%2019,range(l,r+1)))
    for i in range(r-l):
        for j in range(i+1, r-l+1):
            min = minfunc((modlist[i]*modlist[j])%2019,min)
    print(min)

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

l_quo = l // 2019
r_quo = r // 2019
l_mod = l % 2019
r_mod = r % 2019

if l_quo < r_quo:
	print(0)
else:
	min = 2020
	for i in range(l_mod, r_mod+1):
		for j in range(i+1, r_mod+1):
			if (i*j)%2019 < min:
				min = (i*j)%2019
				
	print(min)

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

minVal = 2018
for l in range(L, R):
    if l == L+2019:
        break
    for r in range(l+1, R+1):
        if r == l+2019:
            break
        if minVal >= (l*r) % 2019:
            minVal = (l*r) % 2019
print(minVal)

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


l = []

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

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

print(l[0])

Solution (Python):
x, y=map(int, input().split())

res=2019

x_q=x//2019








y_mod=min(y,2019*(x_q+1))

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

print(res)

Solution (Python):
import sys
from itertools import combinations
L, R = map(int, input().split())
    
if R - L + (L % 2019) >= 2019:
    print(0)
    sys.exit()

else:
    tmp = 2 * (10 ** 9)
    lis = list(range(L, R + 1))
    for item in list(combinations(lis, 2)):
        mini = min((((item[0] % 2019) * item[1]) % 2019), (((item[1] % 2019) * item[0]) % 2019))
        if tmp >= mini:
            tmp = mini
            
            
print(tmp)

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

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

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

for i in range(l, r + 1):
    if divmod(i, 2019)[1] == 0:
        print(0)
        exit()

tmp = set()
for i in range(l, r):
    for j in range(l + 1, r + 1):
        tmp.add(divmod(i * j, 2019)[1])

print(min(tmp))

Solution (Python):

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

left = range(L, R)
right = range(L+1, R+1)

minmond = 2019
for l in left:
    for r in right:
        x = l * r
        mod = x % 2019
        minmond = min(minmond, mod)
        if minmond == 0:
            print(0)
            exit(0)
print(minmond)

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

if L // 2019 < R // 2019:
    print(0)
else:
    L %= 2019
    R %= 2019
    ans = float('inf')
    for i in range(L, R + 1):
        for j in range(i + 1, R + 1):
            m = i * j % 2019
            ans = min(ans, m)
    print(ans)

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

Solution (Python):
N,M=list(map(int,input().split()))
if M-N>2018 or (N%2019>M%2019):
    print(0)
else:


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

Solution (Python):
if __name__ == '__main__':
    l, r = map(int, input().split())
    if l + 2019 <= r:
        print(0)
        exit()
    m = 2019
    for i in range(l, r):
        res_i = i % 2019
        for j in range(l + 1, r + 1):
            res_j = j % 2019
            res = (res_i * res_j) % 2019
            if m > res:
                m = res
    print(m)

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

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

Solution (Python):
import sys

n1, n2 = [int(i) for i in input().split()]

r1 = 2018

if n2 - n1 >= 2019:
    print(0)
    sys.exit()


for i3 in range(n2 - n1):
    n4 = i3 + n1

    t1 = n2 - n4
    if t1 >= 2019:
        t1 = 2019
    for i5 in range(t1):
        n5 = i5 + n4 + 1

        if ((n4 * n5) % 2019)  < r1:
            r1 = ((n4 * n5) % 2019)

print(r1)

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

Solution (Python):
L,R = map(int,input().split())
 
ans = 2019
m = []
l = R-L+1
if l < 2019:
	for i in range(L,R+1):
		m.append(i%2019)
else:
	for i in range(L,L+2019):
		m.append(i%2019)

for i in range(len(m)):
	for j in range(i+1,len(m)):
		tmp = (m[i]*m[j])%2019
		if ans> tmp:
			ans = tmp
		if tmp == 0:
			break				
print(ans)

Solution (Python):
a = list(map(int,input().split()))
b = []

if a[1]-a[0]>=2019:
  print(0)
else:
  for i in range(a[0],a[1]+1):
    for j in range(a[0],i):
      c = (i*j)%2019
      b.append(c)
  else:
    print(min(b))

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

tmp = R - L + 1
if tmp >= 2019:
    print(0)
    exit()
else:
    start = L % 2019
    end = R % 2019
    candidate = []
    for i in range(start, end + 1):
        candidate.append(i % 2019)
    candidate.sort()
    ans = []
    for i in range(len(candidate)):
        if i == (len(candidate) - 1):
            continue
        for j in range(i + 1, len(candidate)):
            if i == j:
                continue
            else:
                ans.append((candidate[i] * candidate[j]) % 2019)
    ans.sort()
    print(ans[0])

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

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

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

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

print(m)

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

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

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

ans = []
imax = R - L + 1

for i in range(2019):
    a = L + i
    if a >= R:
        break
    for j in range(i + 1, 2020):
        b = L + j
        if b > R:
            break

        if (a*b)%2019 == 0:
            print(0)
            exit()
        ans.append((a*b)%2019)

print(min(ans))

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

ans = 3000

l = [-1] * 2019 
r = [-1] * 2019

flagl = False
for i in range(L, R):
    if l[i%2019] != -1:
        flagl = True
    l[i%2019] = i%2019
    flagr = False
    for j in range(i+1, R+1):
        if r[j%2019] != -1:
            flagr = True
            break
        r[j%2019] = j%2019
    if flagl == True and flagr == True:
        break

tmp = 0
for i in l:
    if i == -1:
        continue
    for j in r:
        if j == -1:
            continue
        tmp = (i * j) % 2019
        if tmp < ans:
            ans = tmp
print(ans)

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

mod = []
if R+1-L<=2019:
    for i in range(L,R):
        for j in range(i+1,R+1):
            mod.append((i*j)%2019)

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


if len(mod)==0:
    print((L*R)%2019)
else:
    print(min(mod))

Solution (Python):
L, R = map(int, input().split())
mod = 2019
left = L // mod
right = R // mod
l_mod = L % mod
r_mod = R % mod

if left != right or l_mod == 0 or r_mod == 0:
    print(0)
else:
    ans = float('inf')
    for i in range(l_mod, r_mod):
        for j in range(i + 1, r_mod + 1):
            ans = min(ans, (i * j) % mod)
    print(ans)

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

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

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

if (r-l+1)>=2019:
    print(0)
else:
    ans = (l*(l+1))%2019
    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 = (int(i) for i in input().split())
 
l = L % 2019
r = R % 2019


if R-L > 2019 :
    print(0)
elif r <= l :
    print(0)

else:
    MOD = 2019
    N = r - l
    A = []
    for i in range(l,r+1):
        A.append(i)
    
    for i in range(N):
        for k in range(i+1,N+1):
            X = (A[i] * A[k]) % 2019
            if X < MOD:
                MOD = X
        
    print(MOD)

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

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

l = L % 2019
r = R % 2019

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

Solution (Python):
import numpy as np
l,r = map(int,input().split())
mod = 2019
arr = np.array(list(set([i%mod for i in range(l,min(r+1,l+2019))])))
ans = 2019

for left in range(len(arr)-1):
    ans = min(min(arr[left]*arr[left+1:]%mod),ans)
    if ans == 0:
        print(ans)
        exit()
print(ans)

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

a = L // 2019
b = R // 2019
if L > R or L == 0:
  ans = 0
  print(ans)
  exit()

c = L // 3
d = R // 3
e = L // 673
f = R // 673
if d > c and f > e:
  ans = 0
  print(ans)
  exit()
else:
  ans = 2019
  for i in range(L,R+1):
    for j in range(i+1, R+1):
      ans = min((i*j)%2019,ans)
print(ans)

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

flag3 = flag673 = False
if R % 3 == 0 or L % 3 == 0:
    flag3 = True
for i in range((L // 673) * 673, 2 * 10 ** 9, 673):
    if L <= i and i <= R:
        flag673 = True
        break

ans = 0
if (flag3 and flag673) is False:
    ans = 10**9
    if R - L > 2100:
        R = L + 2100
    for i in range(L, R + 1):
        for j in range(i + 1, R + 1):
            if (i * j) % 2019 < ans:
                ans = (i * j) % 2019
print(ans)

Solution (Python):
L, R = [int(n) for n in input().split()]
ans = 2019
for i in range(L, R):
    j = i + 1
    while j <= R:
        s = i*j % 2019
        if s < ans:
            ans = s
            if ans == 0:
                break
        j += 1
    if ans == 0:
        break
print(ans)

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

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

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
  f=(b*d)%2019
  for i in range(b,d):
    for j in range(i+1,d+1):
      e=(i*j)%2019
      if e<f:
        f=e
      j=j+1
    i=i+1
  print(f)

Solution (Python):
import sys
l,r=map(int,input().split())
anslist=20000000000
for i in range(l,r):
    if r-i>=(2019-i%2019):
        print(0)
        sys.exit()
    for u in range(i+1,r+1):
        ans=min(anslist,i*u%2019)
        anslist=ans
print(ans)

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

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

print(ans)

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

Solution (Python):
def calc(L, R):
    imod = L % 2019
    if (imod == 0):
        print(0)
    elif (R - L > 2019 - imod - 1):
        print(0)
    else:
        m = L * 2019
        for i in range(L, min(R + 1, L + 2019 - imod)):
            for j in range(i + 1, min(R + 1, L + 2019 - imod)):
                x = (i * j) % 2019
                m = min(m, x)
        print(m)


s = input().split(' ')
L = int(s[0])
R = int(s[1])
calc(L, R)

Solution (Python):

"""
AtCoder A
"""

import sys, math, random
import numpy as np







 
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
 
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    L, R = list(map(int,input().split()))
    m=2020
    if R%2019==0:
        print(0)
    elif R-L>2025:
        print(0)
    else:
        for i in range(L,R+1):
            
            for j in range(i+1,R+1):
                
                t=(i*j)%2019
                if t<m:
                    m=t
                    
        print(m)
        
        
        
        
        
        
        
        

    
    
if __name__ == "__main__":
    main()

Solution (Python):
def main():
    l,r = map(int,input().split(' '))
    tmp = 2019
    if l//2019 < r//2019:
        print(0)
    else:
        for i in range(l,r):
            for j in range(i+1,r+1):
                if tmp > (i*j)%2019:
                    tmp = (i*j)%2019
        print(tmp)

if __name__ == '__main__':
    main()

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

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

ans = 2020
if l%2019==0 or r%2019==0 or (l // 2019 != r // 2019):
	ans = 0
else:
	for i in range(l,r):
		if ans == 0:
			break
		for j in range(i+1,r+1):
			
			ans = min(ans,i*j%2019)
			if ans == 0:
				break
print(ans)

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

L_amari= L%2019
R_amari= R%2019

if R-L <2018:
    if L_amari <= R_amari:
        if L_amari==0:
            ans=0
        else:
            amari_list = [i for i in range(L_amari,R_amari+1)]
            amari_min=114514
            for i in range(len(amari_list)):
                for j in range(i+1,len(amari_list)):
                    amari=amari_list[i]*amari_list[j]%2019
                    if amari_min > amari:
                        amari_min = amari
            ans =amari_min
    else:
        ans=0
else:
    ans=0

print(ans)

Solution (Python):
L, R = (int(i) for i in input().split())
i, j = 2018, 2018
imod, jmod = 2018, 2018
min_val = 2018

if L <= 2019 and 2019 < R:
    print(0)
    exit()
elif R/2019 >= 2 and L//2019 != R//2019:
    print(0)
    exit()
else:
    for k in range(L, R+1):
        for s in range(k+1, R+1):
            new = (k*s)%2019
            if new < min_val:
                min_val = new



print(min_val)

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

Solution (Python):
from sys import stdin
L,R = [int(x) for x in stdin.readline().rstrip().split()]
ans = 2019



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

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

L2, R2 = L % Y, R % Y
dist = (R - L) // Y

if L2 == 0 or R2 == 0 or R2 <= L2 or 1 <= dist:
    res = 0
else:
    mn = (L2 * (L2+1)) % Y
    for i in range(L2, R2+1):
        for j in range(i+1, R2+1):
            if (i*j%Y) < mn:
                mn = i*j % Y
    res = mn

print(res)

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

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

Solution (Python):
from enum import Enum
from queue import Queue
import collections
import numpy as np


import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

L,R = map(int,input().split())
min = BIG_NUM
if (R/2019 - L/2019)>=1.0:
    print(0)
else:
    for i in range(L,R+1):
        for j in range(i+1,R+1):
            tmp = (i*j)%2019
            if tmp < min:
                min = tmp
            if min == 0:
                break
    print(min)

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

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

for i in range(l, l+gen+1):
    if i%gen == 0:
        check = i - l

if r-l>=check:
    print(0)
    exit()

ll = min(l%gen, r%gen)
rr = max(l%gen, r%gen)

if rr-ll == 1:
    print((ll*rr)%gen)
    exit()

ans = 10**9

for i in range(ll, rr+1):
    for j in range(i+1, rr+1):
        ans = min(ans, (i*j)%gen)
print(ans)

Solution (Python):
import numpy as np
from collections import defaultdict
from functools import reduce


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

p, l = divmod(L, 2019)
q, r = divmod(R, 2019)

if p != q:
  print(0)
else:
  res = 2020
  for x in range(l, r+1):
    for y in range(x+1, r+1):
      res = min(res, x*y%2019)
  print(res)

Solution (Python):
L, R = (int(item) for item in input().split())

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

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

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

x = r // mod
line = x * 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):
l=input().split()
L,R=int(l[0]),int(l[1])
a=0
if R-L<2019:
    a=2018
    for i in range(L,R):
        n=i%2019
        m=(i+1)%2019
        s=(n*m)%2019
        if s<a:
            a=s
        for j in range(R-i-1):
            s+=n
            s=s%2019
            if s<a:
                a=s
        if a==0:
            break
print(a)

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

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

Solution (Python):
import numpy as np
import math
import itertools

L, R = (int(i) for i in input().split()) 
if R - L >= 2019: 
  print(0)
else:
  ans = R * (R - 1)
  for x, y in itertools.combinations(range(L, R + 1), 2):
      mod = ((x % 2019) * (y % 2019)) % 2019
      ans = min(mod, ans)
  
  print(ans)

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

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

Solution (Python):


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

ans = 2 * (10**9)

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

print(ans)

Solution (Python):
import sys

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    [L, R] = string_to_int(inputs[0])

    if R - L >= 2019:
        return 0

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


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)

Solution (Python):
l,r=map(int,input().split())
ll=[]
mod=2019
if r-l+1>=2019:
    print(0)
    import sys
    sys.exit()
ans=10**100
import itertools
for i,j in itertools.combinations(range(l,r+1),2):
    ans=min(ans,(i*j)%mod)
print(ans)

Solution (Python):
inf = float('inf')

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

if R > L + 3000:
    R = L + 3000
t = [i % 2019 for i in range(L, R + 1)]
t.sort()
if (3 in t and 673 in t) or (0 in t):
    print(0)
else:
    n = len(t)
    ans = inf
    for i in range(n - 1):
        for j in range(i + 1, n):
            ans = min(ans, t[i] * t[j] % 2019)
    print(ans)

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

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

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