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

def main():
    L,R = map(int,input().split())
    LR = R-L
    M = []
    if L <= 2019 <= R:
        print(0)
        exit()
    for i in range(LR):
        for j in range(LR):
            M.append(((L+i)*(L+1+j))%2019)
            if ((L+i)*(L+1+j))%2019 == 0:
                print(0)
                exit()
    print(min(M))
if __name__ == '__main__':
    main()

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


for i in range(l,r):
    for j in range(i+1,r+1):
        m = (i * j) % mod
        if m < mod_min:
            mod_min = m
        if mod_min == 0:
            break
    if mod_min == 0:
        break

print(mod_min)

Solution (Python):

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

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

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

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

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

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

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

st = l % 2019

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

else:
    ans = float("inf")
    amari = []
    for i in range(l, r+1):
        for j in range(i+1, r+1):
            ans = min(ans, ((i%2019) * (j%2019)) % 2019)
    print(ans)

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

min=10**9
if((r-l)>=2019):
    min = 0
else:
    for i in range(l, r):
        for j in range(l+1, r+1):
            if(i<j and l<j):
                mod = (i*j)%2019
                if(mod<min):
                    min=mod

print(min)

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

ans = float('inf')
for i in range(L, L + 2020):
    for j in range(L + 1, L + 2020):
        if (i >= j) or (j > R):
            continue
        ans = min(ans, (i * j) % MOD)

print(ans)

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

minimum=2019
z=0
for i in range(L, R+1):
    for j in range(i+1, R+1):
        tmp = (i*j)%2019
        if minimum>tmp:
            minimum = tmp
        if minimum==0:
            z=1
            break
    if z==1:
        break
    
print(minimum)

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

minimum=2019
z=0
for i in range(L, R+1):
    for j in range(i+1, R+1):
        tmp = (i*j)%2019
        if minimum>tmp:
            minimum = tmp
        if minimum==0:
            z=1
            break
    if z==1:
        break
    
print(minimum)

Solution (Python):
l, r = map(int, input().split())
diff = r - l
l = l % 2019
r = l + diff
a = 2019
for x in range(l, r):
  for y in range(x + 1, r + 1):
    a = min(a, (x * y) % 2019)
    if a == 0:
      break
  else:
    continue
  break
print(a)

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

Solution (Python):
L, R = map(int, input().split())
intnumber = []
for i in range(L, min(R+1, L+2019)):
    intnumber.append(i%2019)

intnumber.sort()
ans = 2019
for i in range(len(intnumber)):
    for j in range(i+1, len(intnumber)):
        ans = min(ans, (intnumber[i]*intnumber[j])%2019)

print(ans)

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

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

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

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

print(ans)

Solution (Python):
l, r = map(int, input().split())
if l <= 2019 <= r:
    print(0)
    exit()
elif r*(r-1) <= 2019:
    print(l*(l+1))
    exit()

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

print(a)

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

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

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

Solution (Python):
l, r = map(int, input().split())
dl, ml = divmod(l, 2019)
dr, mr = divmod(r, 2019)
if ml == 0 or mr == 0 or dr - dl != 0 or ml >= mr:
  print(0)
else:
  mi = l*(l+1)%2019
  for i in range(l, r):
    for j in range(i+1, r+1):
      temp = i*j%2019
      if temp < mi:
        mi = temp
  print(mi)

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

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

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

Solution (Python):
from itertools import combinations
l,r = map(int, input().split())
if (r//673 - (l-1)//673 > 0)&(r-l >= 2):
    print(0)
else:
    print(min([l[0] * l[1] % 2019 for l in list(combinations(range(l,r+1),2))]))

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

Solution (Python):
import math
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect
import sys
import random
import time
inf = 10**9


def main():
    ans = 2018
    l, r = list(map(int, input().split()))
    for i in range(l, min(l+2019, r)):
        for j in range(i+1, min(l+2019, r)+1):
            ans = min(ans, i*j % 2019)
    print(ans)


if __name__ == '__main__':
    main()

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 sys
import math
import itertools

input = sys.stdin.readline


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

    if r - l >= 2019:
        print(0)
        return
    else:
        num = [i for i in range(l, min(l + 2019, r + 1))]
        min_ = 2019
        for i, n in enumerate(num):
            for j in num[i + 1 :]:
                min_ = min([n * j % 2019, min_])
    print(min_)


if __name__ == "__main__":
    main()

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

flag = 0
min_ = 2020
for i in range(L,R):
    for j in range(i+1,R+1):
        s = (i*j) % 2019
        if s == 0:
            print('0')
            exit()
        if s < min_:
            min_ = s
print(min_)

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

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

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

if __name__ == "__main__":
    main()

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

l = L % 2019
r = R % 2019

ans = 2019*2019

if L // 2019 == R // 2019:
    
    for i in range(l, r):
        
        for j in range(i+1,r+1):
            

            ans = min(ans, (i*j)%2019)
else:
    ans = 0

print(ans)

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

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

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

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

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

    ans = L * R % 2019
    if R - L >= 2019:
        ans = 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)


if __name__ == '__main__':
    main()

Solution (Python):
L,R=map(int,input().split())
c=2019
z=0
for i in range(L,R+1):
    for j in range(i+1,R+1):
        a=i*j
        b=a%2019
        if c>b:
            c=b
        if c==0:
            z=1
            break
    if z==1:
        break
print(c)

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

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

if r - l > 2019:
  print(0)
  
else:
  l=l%MOD
  r=r%MOD
  l,r=min(l,r),max(l,r)

  for i in range(l,r):
    for j in range(i+1,r+1):
      res += [(i*j)%MOD]

  print(min(res))

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

m = 2019
mod_min = m

is_return = False

for j in range(l,r+1,1):
    
    
        
        
    if is_return:
        break
    for i in range(l,j,1):
        
        i_j = (i * j) % m
        
        if i_j < mod_min:
            mod_min = i_j
            
        if i_j == 0:
            is_return = True
            break
            
print(mod_min)

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

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

print(ans)

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



t = 222222
gap = y - x
a = 111111
if y - x > 2018:
    a =0
else:
    for i in range(x,y+1):
        for j in range(i+1,y+1):
            t = min(t,(i*j)%2019)

print(min(a,t))

Solution (Python):
l, r = map(int, input().split())
def doit(l, r):
  if r - l > 2019:
    return 0
  l = l % 2019
  r = r % 2019
  if l == 0:
    return 0
  if r == 0:
    return 0
  if r <= l:
    r += 2019
  res = 2019
  for x in range(l, r):
    for y in range(x + 1, r + 1):
      
      res = min(res, (x * y) % 2019)
      if res == 0:
        return 0
  return res % 2019

print(doit(l, r))

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

listX = []
for i in range(1, 990590):
  listX.append(i*2019)

sw = 0
for n in range(len(listX)):
  if L < listX[n] and R > listX[n]:
    sw += 1

if sw > 0:
  print(0)

elif sw == 0:
  idx1 = 0
  listA = []
  for idx1 in range(L, R):
    for idx2 in range(idx1 + 1, R + 1):
      listA.append(idx1 * idx2)
 
  idx3 = 0
  listB = []
  for idx3 in range(len(listA)):
    listB.append(listA[idx3] % 2019)
 
  print(min(listB))

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

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

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

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

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

print(ans)

Solution (Python):
import sys

l,r = list(map(int, input().split()))
imin = 10**9+7

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

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





def get_ans():
    
    if R - L >= 2018:
        return 0

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

    return ans


print(get_ans())

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

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

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

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

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

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

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

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

ans = 2020
if r - l >= 2019:
    r = l + 2018
for i in range(l, r):
    for j in range(i + 1, r + 1):
        tmp = i * j % 2019
        if ans > tmp:
            ans = tmp
    
print(ans)

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

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

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

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

Solution (Python):
if __name__ == '__main__':
    l,r  = list(map(int, input().split(" ")))
    res = 2019
    n = l // 2019
    if l % 2019 == 0:
        print(0)
    elif l//(n+1) <= 2019  and 2019 <= r//(n+1):
        print(0)
    else:
        for i in range(2019):
            for j in range(i+1, 2019):
                if l+i > r or j+l > r:
                    break
                res1 = (((l+i) % 2019) * (l+j % 2019)) % 2019
                if res1 < res:
                    res = res1
        print(res)

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

l = L % 2019
r = R % 2019

ans = 2019*2019

if L // 2019 == R // 2019:
    
    for i in range(l, r):
        
        for j in range(l+1,r+1):
            

            ans = min(ans, (i*j)%2019)
else:
    ans = 0

print(ans)

Solution (Python):

def main():
    L,R = list(map(int,input().split()))
    if R - L >= 2019:
        print(0)
        return
    else:
        min_r = 2019
        for i in range(L,R):
            for j in range(i+1,R+1):
                min_r = min(min_r,(i*j)%2019)
        print(min_r)
if __name__ == '__main__':
    main()

Solution (Python):

import numpy as np

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

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

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

    a = l*r%2019
    for i in range(l,r) :
        for j in range(i+1,r+1):
            ij = i*j%2019
            
            if (a > ij) :
                a = ij

            if(a==0) :
                return a

    return a



print(yo())

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

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

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

def get_amari():
    min_ = 2019
    for i in range(L,R):
        for j in range(i+1, R+1):
            if (i*j)%2019 < min_:
                min_ = (i*j)%2019
    return min_
   
def get_flg3():
    if R-L >= 3:
        return True
    elif R//3 != L//3:
        return True
    else:
        return False
    

def get_flg673():
    if R-L >= 673:
        return True
    elif R//673 != L//673:
        return True
    else:
        return False

if get_flg3() & get_flg673():
    print(0)
else:
    print(get_amari())

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

Solution (Python):
import sys

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

if __name__ == "__main__":
    l, r = map(int, input().split())

    n = r // 2019 - l // 2019

    if n >= 1:
        print(0)
    else:
        minvalue = float("inf")
        for i in range(l, r):
            for j in range(i+1, r+1):
                minvalue = min(minvalue, i * j % 2019)
        print(minvalue)

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

ans = 2019


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

Solution (Python):

def input_from_console():
    l, r = map(int, input().split())
    return l, r


def solve(l, r):
    minimum = 2020
    if r - l >= 2019:
        return 0
    a, b = l % 2019, r % 2019
    if r // 2019 > l // 2019:
        return 0
    for i in range(a, b):
        for j in range(a + 1, b + 1):
            minimum = min(minimum, (i * j) % 2019)
    result = minimum
    return result


def main():
    l, r = input_from_console()
    print(solve(l, r))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  
        check_cases()
    else:
        main()

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

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

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





def get_amari():
    min_ = 2019
    for i in range(L,R):
        for j in range(i+1, R+1):
            
            
            
            
            
            
            if (i*j)%2019 < min_:
                min_ = (i*j)%2019
    return min_

        
                
def get_flg3():
    if R-L >= 3:
        return True
    elif R//3 != L//3:
        return True
    else:
        return False
    

def get_flg673():
    if R-L >= 673:
        return True
    elif R//673 != L//673:
        return True
    else:
        return False

def mataganai_2019():
    return (L*(L+1))//2019 == ((R-1)*R)//2019
        
if get_flg3() & get_flg673():
    print(0)
else:
    print(get_amari())

Solution (Python):
from itertools import combinations

def min_mod(l, r):
    return min([(i * j) % 2019
        for i, j in combinations(
            range(l, min(l + 2020, r + 1)), 2)])
 
 
l, r = map(int, input().split())
print(min_mod(l, r))

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

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

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

result = None
for i in range(l, min(l + 2019 - l % 2019, r - 1) + 1):
    for j in range(i + 1, min(i + 2019, r) + 1):
        mod = i * j % 2019
        if result is None or result > mod:
            result = mod
            if result == 0:
                break
    if result is not None and result == 0:
        break
print(result)

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

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

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

Solution (Python):


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


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

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

def baisuaru(l,r,m):
  if l//m < r//m:
    return True
  elif l%m==0:
    return True
  else:
    return False
    
if baisuaru(l,r,2019):
  print(0)
else:
  a=l%2019
  b=r%2019
  ans=99999999
  for i in range(a,b):
    for j in range(i+1,b+1):
      tmpans=(i*j)%2019
      if ans>tmpans:
        ans=tmpans
  print(ans)

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

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

m=2018

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

print(m)

Solution (Python):
a, b = map(int, input().split())
c = 2019

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

Solution (Python):
import numpy as np

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

if R - L > 2018:
    print(0)
    
else:
    R = R % 2019
    L = L % 2019

    if L > R:
        R += 2019 
        
    ans = 2018        
    for i in np.arange(L, R+1):
        for j in np.arange(i+1, R+1):
            i = i % 2019
            j = j % 2019
            k = i * j % 2019
            ans = np.amin(np.array([k, ans]))
        
            if ans == 0:
                break
        if ans == 0:
            break        

    print(ans)

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

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

print(result)

Solution (Python):



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

if __name__=="__main__":
    solve()

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


for i in range(n, r+1):
  for j in range(i+1, r+1):
    mini = min((i*j)%2019, mini)
print(mini)

Solution (Python):
L,R=map(int,input().split())
mod_min=2019
zero_judge=0
for i in range(L,R):
    if zero_judge==1:
        break
    else:
        for j in range(i+1,R+1):
            mod_calc=(i*j)%2019
            if mod_calc<mod_min:
                mod_min=mod_calc
                if mod_min==0:
                    zero_judge=1
                    break

print(mod_min)

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

a = R//2019*2019
if L <= a <= R:
  print((a * (a+1))%2019)
else:
  C = []
  for i in range(L,R):
    for j in range(i+1, R+1):
      C.append(i*j%2019)
  print(min(C))

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

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

if (R - L) <= 2019:
    temp1 = float("inf")
    for i in range(R - L):
        for j in range(R - L):
            temp2 = ((R-i) * (R - 1 -j)) % 2019
            if temp2 < temp1:
                temp1 = temp2
    print(temp1)
else:
    temp1 = float("inf")
    for i in range(2019):
        if (R-i-1) < L:
            break
        for j in range(2019):
            temp2 = ((R - i) * (R - 1 - j)) % 2019
            if temp2 < temp1:
                temp1 = temp2
    print(temp1)

Solution (Python):

import sys

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


mod = 2019

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

ans = mod
for i in range(l, r + 1):
    imod = i % mod
    for j in range(i + 1, r + 1):
        jmod = j % mod
        ans = min(ans, (imod * jmod) % mod)
        if ans == 0:
            break
    if ans == 0:
        break

print(ans)

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

data = 2019

if r - l + 1 >= 2019:
    print(0)
    exit()

else:
    for i in range(l, r + 1):
        for j in range(i+1, r + 1):
            data = min(data, i * j % 2019)

print(data)

Solution (Python):
L, R = map(int, input().split())
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):
import sys
L, R= map(int, input().split())
ans = []
for i in range(L, R):
    for j in range(i+1, R+1):
        if (i*j)%2019 == 0:
            print(0)
            sys.exit()
        else:
            ans.append((i*j)%2019)
print(min(ans))

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

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

min_val = 2019
for i in range(L, R):
  for j in range(i+1, R+1):
    val = (i*j)%2019
    if min_val > val:
      min_val = val
      if min_val == 0:
        break
  if min_val == 0:
    break
print(min_val)

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

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

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

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

Solution (Python):
import sys

MOD = 2019

def solve(L, R):
    ans = 2019
    for i in range(L, R+1):
        for j in range(i+1, R+1):
            ij = i*j%MOD
            if ij == 0:
                print(0)
                return
            if ij < ans:
                ans = ij
    print(ans)

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

if __name__ == "__main__":
    main()

Solution (Python):
L,R=map(int, raw_input().split())
a=L%2019
b=R%2019

T=[]
ans=float("inf")
if a<b:
	T=range(a,b+1)
	if R-L>2018:
		print 0
		quit()
	else:
		l=len(T)
		for i in range(l):
			for j in range(i+1,l):
				ans=min(ans, (T[i]*T[j])%2019 )

		print ans
else:
	print 0
	quit()

Solution (Python):
from bisect import bisect_left, bisect_right; from collections import Counter, defaultdict, deque, OrderedDict; from copy import deepcopy; from fractions import gcd; from functools import lru_cache, reduce; from math import ceil, floor; from sys import stdin, setrecursionlimit
import heapq as hq; import itertools as its; import operator as op



inf = float('inf')
input = stdin.readline
MOD = 2019


def main():
    l, r = get_li()
    if r - l >= MOD:
        print(0)
        return
    ans = inf
    for i in range(l, r):
        for j in range(i+1, r+1):
            ans = min(ans, (i * j) % MOD)
    print(ans)


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def gets(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    setrecursionlimit(4100000)
    main()

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

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

Solution (Python):
s, e = map(int, input().split())
ans = 10 ** 9
b = min(s+2019, e)
for i in range(s, b + 1):
    for j in range(i+1, b+1):
        ans = min(ans, i*j%2019)
print(ans)

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

if abs(l - r) == 1:
    print(l * r % 2019)
else:
    lower = l // 2019
    upper = r // 2019
    start = l % 2019
    stop = r % 2019
    if 2019 * (lower + 1) < r:
        print(0)
    else:
        ans = 1000000
        if start == 0:
            print(0)
        elif stop == 0:
            print(0)
        elif stop < start:
            print(0)
        elif stop > start:
            for i in range(start, stop + 1):
                for j in range(i+1, stop + 1):
                    if i * j % 2019 < ans:
                        ans = i * j % 2019
            print(ans)

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




i_list = []
j_list = []
for i in range(L, R):
    i_mod = i % 2019
    for j in range(i+1, R+1):
            j_mod = j % 2019
            mod = i_mod * j_mod % 2019
            if mod < mod_min:
                mod_min = mod
                if mod_min == 0:
                    break
    if mod_min == 0:
        break
print(mod_min)