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+1>=2019:
    print(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())
l=L%2019
r=R%2019
if l<r and L+2019>=R:
  c=2020
  a=list(range(l,r+1))
  for i in range(len(a)-1):
    for j in range(i+1,len(a)):
      s_=a[i]*a[j]
      s=s_%2019
      c=min(c,s)
elif l>=r and L+2019>=R:
  r+=2019
  c=2020
  a=list(range(l,r+1))
  for i in range(len(a)-1):
    for j in range(i+1,len(a)):
      s_=a[i]*a[j]
      s=s_%2019
      c=min(c,s)
else:
  c=0
print(c)

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

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

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce


import sys
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')


L, R = Is()
mod = 2019

n = min(R-L+1, 2019)
li = [-1]*n

tmp = L % 2019
for i in range(n):
    if tmp + i == 2019:
        print("0")
        exit()
    li[i] = tmp + i

ans = INF
for x, y in combinations(range(n), 2):
    ans = min(ans, li[x]*li[y]%mod)

print(ans)

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

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

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

left = L % 2019
right = R % 2019

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

elif left > right:
    print(0)
    sys.exit(0)

elif left==0 or right==0:
    print(0)
    sys.exit(0)

for i in range(left, right):
    for j in range(i+1, right+1):
        x = calc_mod(i, j)
        if x==0:
            print(0)
            sys.exit(0)
        ans.append(x)

print(min(ans))

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

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

left = L % 2019
right = R % 2019

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

elif left > right:
    print(0)
    sys.exit(0)

elif left==0 or right==0:
    print(0)
    sys.exit(0)

for i in range(left, right):
    for j in range(i+1, right+1):
        ans.append(calc_mod(i, j))

print(min(ans))

Solution (Python):


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

mn = float('inf')
for i in range(L, L + 2019):
    for j in range(i + 1, L + 2019 + 1):
        if L <= i < j and i < j <= R:
            mn = min(mn, i * j % 2019)

print(mn)

Solution (Python):
import sys
import itertools


def solve():
    L, R = map(int, input().split())
    lst_mod = [-1]*min((R-L+1), 2019)
    counter = L % 2019
    for i in range(len(lst_mod)):
        lst_mod[i] = counter
        counter += 1
        if counter == 2019:
            print(0)
            sys.exit(0)
    num = 2019
    for comb_lst in itertools.combinations(lst_mod, 2):
        if num > (comb_lst[0]*comb_lst[1]) % 2019:
            num = (comb_lst[0]*comb_lst[1]) % 2019
    print(num)


solve()

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

d = r - l + 1

if d >= 2019:
    print(0)
else:
    ans = 2018

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

    print(ans)

Solution (Python):
l,r=map(int,input().split())
ans=10**9+7
if l==0 or (r-l>=2019):
    print(0)
else:
    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):
def main():
    L, R = (int(x) for x in input().split())
    if R - L > 2018:
        print(0)
    else:
        ans = 2018
        for i in range(L, R):
            for j in range(i + 1, R + 1):
                ans = min(ans, (i * j) % 2019)
        print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
import sys






stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18



L,R = map(int, stdin.readline().rstrip().split())


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

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

print(ans)

Solution (Python):

import sys
input = sys.stdin.readline









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

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

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

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

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

Solution (Python):
import itertools
L,R = list(map(int,input().split()))
if R-L >= 2020:
  print(0)
  exit()
N_list = [i for i in range(L,R+1)]
P = itertools.combinations(N_list,2)
P = list(P)
ans = L*(L+1)%2019
for p in P[1:]:
    ans = min(ans,p[0]*p[1]%2019)
print(ans)

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

else:
  for j in range(L, R+1):
    for i in range(L, j):
      A.append((i*j) % 2019)
  print(min(A))

Solution (Python):
import sys, heapq, bisect, math, fractions
from collections import deque

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

res = 10 ** 15
if R - L > 2030:
    res = 0
else:
    for l in range(L, R):
        for r in range(l + 1, R + 1):
            res = min(res, (l * r) % mod)

print(res)

Solution (Python):

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

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

Solution (Python):
l, r = map(int, input().split())
if r-l >=2019:
  print("0")
  exit()
la = l % 2019
ra = r % 2019
diff = ra - la
if diff <= 0:
  print("0")
  exit()
ans = 2019
for i in range(la, ra):
  for j in range(i+1, ra+1):
    mul = (i*j) % 2019
    if mul <= ans:
      ans = mul
print(int(ans))

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

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

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

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

if R<L+2019:
  end=R
else:
  end=L+2018

ans=2020*2020
for l in range(L,end):
  for r in range(l+1,end+1):
    if ans>(l*r)%2019:
      ans=(l*r)%2019
    if ans==0:
      break
print(ans)

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

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

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

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

Solution (Python):
l, r = map(int, input().split())
ans = float('INF')
for i in range(l, l + 2019):
    for j in range(i+1, min(i + 2019, r + 1)):
        if i * j % 2019 < ans:
            ans = i * j % 2019


print(ans)

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


if __name__ == '__main__':
    main()

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

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

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

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

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








def kansu(LL,LR):

    ans = 2020
    flg = False

    for ll in range(LL,LR):
        for lr in range(ll+1,LR+1):
            tmp  = (ll * lr) % 2019
            if ans > tmp:
                ans = tmp
                if ans == 0:
                    flg =True
                    break
        if flg == True:
            break

    print(ans)

ML,MR = nyu()

kansu(ML,MR)

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

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

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 tmp == 0:
            ans = 0
            print(ans)
            exit()

print(ans)

Solution (Python):
import sys

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

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

t1 = L - (L // 2019) * 2019
t2 = R - (L // 2019) * 2019
temp = 0
min_temp = 2019

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

    print(min_temp)

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

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

print(ans)

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

MOD = 2019

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

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


if(abs(l-r) > 2050): print(0)
else:
    num = []
    for i in range(l,r+1):
        num.append(i)
    minimum = 10**9
    for v in itertools.combinations(num, 2):
        minimum = min(minimum,v[0]*v[1]%2019)
    print(minimum)

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

if r < 2019:
    print(l*(l+1)%2019)
    exit()

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

print(ans)

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

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

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

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

Solution (Python):

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

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

print(ijmin)

Solution (Python):
i, j = map(int,input().split())
ans = 100000000

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

print(ans)

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

tmp = float("INF")
ans = tmp
for i in range(L, R):
  for j in range(i+1, R+1):
    tmp = (i % 2019) * (j % 2019) % 2019
    ans = min(ans, tmp)
    if ans == 0:
      print(0)
      exit()
      
print(ans)

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

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

Solution (Python):


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

ans = float('inf')
"""
mod(x)とし、i = y1 * x + b, j = y2 * x + cなどと置くと i * j で xで括れない項は
b*c(余り同士の)掛け算のみ。
"""

l = L % 2019
r = R % 2019

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


flag1 = 0 
flag2 = 0

list = [i for i in range(L,R+1)]
for i in range(len(list)):
  
  if list[i] % 3 == 0:
    flag1 += 1
  
  if list[i] % 673 == 0:
    flag2 += 1

if flag1 * flag2 != 0:
  ans = 0
  print(ans)
  exit(0)

if l > r:
  ans = 0
  print(ans)
  exit(0)


ans = float('inf')
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):


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

ans = 150

"""
mod(x)とし、i = y1 * x + b, j = y2 * x + cなどと置くと i * j で xで括れない項は
b*c(余り同士の)掛け算のみ。
"""

l = L % 2019
r = R % 2019

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


flag1 = 0 
flag2 = 0

list = [i for i in range(L,R+1)]
for i in range(len(list)):
  
  if list[i] % 3 == 0:
    flag1 += 1
  
  if list[i] % 673 == 0:
    flag2 += 1

if flag1 * flag2 != 0:
  ans = 0
  print(ans)
  exit(0)

if l > r:
  ans = 0
  print(ans)
  exit(0)


ans = float('inf')
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):


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

ans = 150

"""
mod(x)とし、i = y1 * x + b, j = y2 * x + cなどと置くと i * j で xで括れない項は
b*c(余り同士の)掛け算のみ。
"""

l = L % 2019
r = R % 2019

lr = l * r

modlr = lr - (lr//2019)

mid = (2019-1)//2

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


flag1 = 0 
flag2 = 0

list = [i for i in range(L,R+1)]
for i in range(len(list)):
  
  if list[i] % 3 == 0:
    flag1 += 1
  
  if list[i] % 673 == 0:
    flag2 += 1

if flag1 * flag2 != 0:
  ans = 0
  print(ans)
  exit(0)

if l > r:
  ans = 0
  print(ans)
  exit(0)


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

Solution (Python):
import sys
input = sys.stdin.readline
from collections import deque
def main():
    L, R = map(int, input().split())
    ans = 2019
    if R - L >= 2019:
        for i in range(L,L+2019):
            for j in range(L+1,L+2020):
                mod = i*j%2019
                ans = min(ans, mod)
    else:
        for i in range(L,R):
            for j in range(L+1,R+1):
                mod = i*j%2019
                ans = min(ans, mod)
    print(ans) 

if __name__ == '__main__':
    main()

Solution (Python):
import sys
input = sys.stdin.readline
from collections import deque
def main():
    L, R = map(int, input().split())
    ans = 2019
    if R - L >= 2019:
        for i in range(L,L+2019):
            for j in range(L+1,L+2020):
                mod = i*j%2019
                ans = min(ans, mod)
    else:
        for i in range(L,R):
            for j in range(L+1,R+1):
                mod = i*j%2019
                ans = min(ans, mod)
    print(ans) 

if __name__ == '__main__':
    main()

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

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

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

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

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

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

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

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

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

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

print(ans)

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

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

Solution (Python):


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

print(ans)

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

Solution (Python):
from sys import exit
l,r=map(int,input().split())
res=10000000000000
for i in range(l,r):
	for j in range(i+1,r+1):
		a=(i*j)%2019
		if a==0:
			print("0")
			exit()
		else:
			res=min(res,a)
print(res)

Solution (Python):
from sys import exit
l,r=map(int,input().split())
res=1000000000000
if r-l>2020:
	print("0")
	exit()
else:
	for i in range(l%2019,r%2019):
		for j in range(i+1,r%2019+1):
			res=min(res,(i*j)%2019)
print(res)

Solution (Python):
M = 2019

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

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

print(ans)

Solution (Python):
import sys
L,R=map(int, sys.stdin.readline().split())
sho1=L/2019
sho2=R/2019
if 1<=sho2-sho1:
    print 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):
from itertools import combinations
L,R = (int(x) for x in input().split())
ans = 2018
if (R-L) // 2018 >= 1:
    print('0')
else:
    for x in combinations(range(L,R+1),2):
        ans = min(ans,x[0]*x[1]%2019)
    print(ans)

Solution (Python):
from itertools import combinations
L,R = (int(x) for x in input().split())
ans = 2018
if (R-L) // 2018 > 1:
    print('0')
else:
    for x in combinations(range(L,R+1),2):
        ans = min(ans,x[0]*x[1]%2019)
    print(ans)

Solution (Python):

def myAnswer(L:int,R:int) -> int:
   ans = []
   for i in range(L,R):
      for j in range(L+1,R+1):
         if(i * j)% 2019 == 0:
            return 0
         ans.append((i * j) % 2019)
   return min(ans)

def modelAnswer():
   return
def main():
   L,R = map(int,input().split())
   print(myAnswer(L,R))
if __name__ == '__main__':
   main()

Solution (Python):
import sys
L,R=map(int, sys.stdin.readline().split())
sho1=(L-1)/2019
sho2=R/2019
if 1<=sho2-sho1:
    print 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):
r,l=map(int,input().split())
if l-r>=2019:
  print(0)
else:
  min1=100000
  for i in range(r,l):
    for j in range(i+1,l+1):
      min1=min(min1,(i*j)%2019)
  print(min1)

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

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

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

Solution (Python):
import math
import sys
def rem(i,j):
    return (i*j)%2019
l, r = map(int, input().split())
cnt=2018
if (r - l >= 2019):
    print(0)
    sys.exit()
else:
    for i in range(l, r+1):
        for j in range(i + 1, r+1):
            cnt = min(rem(i, j), cnt)
if (r - l == 1):
    cnt=min(cnt,r*l%2019)
print(cnt)

Solution (Python):
import math
import sys

l, r = map(int, sys.stdin.readline().rstrip().split())

if math.ceil(l / 2019) * 2019 <= r:
    print(0)
else:
    
    ans = 2019
    for i in range(l, r+1):
        for j in range(i + 1, r+1):
            if ans > (i * j) % 2019:
                ans = (i * j) % 2019
    print(ans)

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

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

Solution (Python):
l, r = map(int, input().split())
mod = 2019
l_n = l//mod
r_n = r//mod
ans = float("inf")
if l_n == r_n:
    for i in range(l, r):
        for j in range(i+1, r+1):
            if ans >= i*j % mod:
                ans = i*j % mod
    print(ans % mod)
elif l_n < r_n:
    print(0)

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

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

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

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

for i in range(ml, mr+1):
  if L <= 2019 * i <= R:
    print(0)
    exit()

L %= 2019
R %= 2019
ans = float('inf')
if L > R:
  L, R = R, L
elif L == R:
  R += 2019
if L == 0 or R == 0:
  print(0)
  exit()

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())
ans = 10**10

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

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

ans=2020

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):
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd 
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) 







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

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

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

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

print(ans)

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

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

print(ans)

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

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

print(ans)

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

Solution (Python):





l, r = map(int, input().split())
i_range_min = l
i_range_max = min(l + 2020, r)


min_mod = (l * r) % 2019

for i in range(i_range_min, i_range_max):
    j_range_min = i + 1
    j_range_max = min((i + 1) + 2020, r + 1)
    for j in range(j_range_min, j_range_max):
        ij_mod = (i * j) % 2019
        
        
        if ij_mod < min_mod:
            min_mod = ij_mod
        if min_mod == 0:
            break
    else:
        continue
    break


print(min_mod)

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

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

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

Solution (Python):

import numpy as np

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

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

print(ans)