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

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

ls = l % 2019
rs = r % 2019

dif = r // 2019 - l // 2019



if (dif != 0):
    print(0)
elif (r - l == 1):
    print(ls*rs % 2019)
else:
    mini = []
    for i in range(ls, rs):
        mini.append(min(i * j % 2019 for j in range(ls + 1, rs+1)))
    print(min(mini))

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

if R // 2019 != L // 2019:
    print(0)
else:
    L = L % 2019
    R = R % 2019
    min_m = 1000000000000
    for i in range(L, R+1):
        for j in range(i+1, R+1):
            m = (i * j) % 2019 
            if m < min_m:
                min_m = m
    print(min_m)

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

diff = R//2019 - L//2019

if L % 2019 == 0:
    answer = 0
elif diff > 0:
    answer = 0
else:
    _min = 2019
    for i in range(L, R+1):
        for j in range(i+1, R+1):
            _min = min(_min, (i * j) % 2019)
    answer = _min

print(answer)

Solution (Python):
l,r  = map(int,input().split())
small = l // 2019
big = r // 2019
num = [l % 2019,r % 2019,l % 2019 + 1,r % 2019 - 1]
num.sort()
num = list(set(num))
mod = 2020
if big - small >= 1:
    print(0)
else: 
    for i in range(l % 2019,r % 2019):
        for j in range(i + 1,r % 2019 + 1):
            mod = min((i * j) % 2019,mod)
    print(mod)

Solution (Python):
import sys

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

min = 1000000000000000000

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

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

        if min == 0:
            print(0)
            sys.exit()






print(min)

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

ans = 2018
now = 0
for i in range(l,r+1):
    for j in range(i+1,r+1):
        now = (i*j)%MOD
        ans = min(ans,now)


print(ans)

Solution (Python):
L, R = map(int, input().split())
min_s = 2019
if (R - L) > 2019:
    min_s = 0
for i in range(L, R):
    for j in range(i + 1, R+1):
        ij = i * j
        m = ij % 2019
        if min_s > m:
            min_s = m
        if min_s == 0:
            break
    if min_s == 0:
        break
print("{}".format(min_s))

Solution (Python):
norg, korg = tuple([int(s) for s in input().split()])

n = norg % 2019
k = korg % 2019

min_val = 2019

if norg // 2019 == korg // 2019:
    for i in range(n, k):
        for j in range(i+1, k+1):
            if (i*j) % 2019 < min_val:
                min_val = (i*j) % 2019
else:
    min_val = 0

print(min_val)

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

Solution (Python):
import sys

input = sys.stdin.readline
L, R = map(int, input().split())
a = []
if L == 2019 or R == 2019 or (L<2019 and R >= 2019):
    print(0)
    exit()
elif L < 2019 and R < 2019:
    for i in range(L, R+1):
        for j in range(i+1, R+1):
            a.append((i*j)%2019)
    print(min(a))
    exit()
else:
    for i in range(L, min(L+2019, R+1)):
        for j in range(i+1, min(L+2019, R+1)):
            a.append((i*j)%2019)
    print(min(a))
    exit()

Solution (Python):
MOD = 2019

l, r = map(int, input().split())
ret = MOD
upperBound = min(r, l + MOD)
for i in range(l, upperBound):
    for j in range(i + 1, upperBound + 1):
        ret = min(ret, (i * j) % MOD)
print(ret)

Solution (Python):
L,R = [int(x) for x in input().split()]
tmp1 = int(L/2019)
tmp2 = int(R/2019)
diff = tmp2 - tmp1
if diff >= 1:
    print(0)
else:
    tmp3 = 0
    Min = 2018
    for i in range(L%2019,R%2019):
        for j in range(i,R%2019):
            tmp3 = (i*(j+1))%2019
            if Min > tmp3:
                Min = tmp3
    print(Min)

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

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

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

if R - L >= 2018:
    print(0)
else:
    if L % 2019 < R % 2019:
        modlist = list(range(L%2019 ,R%2019 +1))
    else:
        modlist = list(range(1,R % 2019 + 1)) + list(range(L % 2019, 2019))

    min_mod = 2018
    for i in range(len(modlist)):
        for j in range(len(modlist) - i - 1):
            mod = (modlist[i]*modlist[i+j+1]) % 2019
            min_mod = min(min_mod, mod)
    print(min_mod)

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

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

    print(min)

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


main()

Solution (Python):

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

mod = 2019
if r >= l+mod-1:
    r = l+mod-1
X = [x%mod for x in list(range(l, r+1))]

ans = mod
for i in range(len(X)):
    for j in range(i+1, len(X)):
        ans = min(ans, (X[i] * X[j])%mod)
print(ans)

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

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

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

print(RM)

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

Solution (Python):
L, R = map(int, input().split())
if R - L + 1 == 2:
    print((R * L) % 2019)
    quit()

if R - L + 1 >= 673:
    print(0)
    quit()

for num in range(L, R + 1):
    if num % 673 == 0:
        print(0)
        quit()


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

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

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

Solution (Python):
import numpy as np
N, M = list(map(int, input().split()))
Modulo = 2019
MAP = np.dot(np.arange(Modulo).reshape(Modulo, 1), np.arange(Modulo).reshape(1, Modulo))
MAP %= Modulo
iu2 = np.tril_indices(Modulo, k=0)
MAP[iu2] = Modulo
if M - N >= 2019:
  print(0)
else:
  fir = N % Modulo
  sec = M % Modulo
  if sec > fir:
    print(np.min(MAP[fir:sec+1, fir:sec+1]))
  elif fir > sec:
    print(min([np.min(MAP[:sec+1, :sec+1]),
               np.min(MAP[fir:Modulo, fir:Modulo]),
               np.min(MAP[:sec+1, fir:Modulo])]))

Solution (Python):
import sys

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

l = L % 2019
r = R % 2019

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

min = 2019

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

print(min)

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

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

Solution (Python):
import sys

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


if diff >= 2019:    
    print(0)
    sys.exit()
    
k = L / 2019
L = L % 2019
R = R % 2019


min_val = 2018
for l_i in range(L, R):
    for r_i in range(l_i + 1, R + 1):
        target = l_i * r_i
        target = target % 2019






        if target < min_val:
            min_val = target

            
print(min_val)

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

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

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

Solution (Python):
import sys
def p(*_a):
  _s=" ".join(map(str,_a))
  
  sys.stderr.write(_s+"\n")

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

mod=2019


l = L % mod
r = R % mod

b = ((R-L)>mod)
b = b or (l>=r)
if b:
	print(0)
	exit(0)


while l>r:
	r+=mod

a=0
b=0
ans=mod

p("l,r,a,b,ans",l,r,a,b,ans)

for a in range(l,r):
	for b in range(a+1, r+1):
		ans = min(ans, (a*b)%mod)





p("l,r,a,b,ans",l,r,a,b,ans)
print(ans%mod)

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

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

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

s = l//2019
t = r//2019

l -= 2019*s
r -= 2019*t

if s != t:
    print(0)
    exit()

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

Solution (Python):

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

if r < 2019:
    ans = float("inf")
    for i in range(l,r):
        for j in range(i+1,r+1):
            mod = (i*j)%2019
            if mod < ans:
                ans = mod
    print(ans)
elif l%2019==0 or r%2019==0:
    print(0)
elif l//2019 < r//2019:
    print(0)
else:
    ans = float("inf")
    for i in range(l,r):
        for j in range(i+1,r+1):
            mod = (i*j)%2019
            if mod < ans:
                ans = mod
    print(ans)

Solution (Python):
import numpy as np

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

if L // 2019 == R // 2019:
    LIST = []
    for i in range(R%2019 - L%2019+1):
        LIST.append(i+L%2019)
    LIST = np.array(LIST)
    print((np.dot(LIST.reshape(-1,1), LIST.reshape(1,-1)) % 2019 + 2019*np.tri(len(LIST), dtype=int)).min())
else:
    print(0)

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

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

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

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

mod_list = []
min1 = 2019
min2 = 2019

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

else:
    for i in range(L, R):
        for s in range(i+1, R+1):
            if (i*s)%2019 <= min1:
                min1 = (i*s)%2019
    print(min1)

Solution (Python):
l,r = [int(i) for i in input().split()]
ans = 100000
L = min(r,l+2019)
for i in range(l,L):
    R = min(l+2019,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:
  l = 0
  r = 2018
  
def solve():
  md = 2019
  for i in range(l, r+1):
    for j in range(i+1, r+1):
      md = min((i * j) % 2019, md)
  return md

print(solve())

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

def gcd(m,n):
    temp=0
    while m%n!=0:
        temp=n
        n=m%n
        m=temp
    return n
def lcm(m,n):
    return m*n/gcd(m,n)


temp=[[(j*i)%2019 for i in range(j+1,min([j+2019+1,R+1]))] for j in range(L,min([L+2019+1,R]))]


print(min([min(e) for e in temp]))

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

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

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

Solution (Python):
L, R = map(int,input().split())
L_mod = L%2019
if L_mod ==0:
  print(0)
else:
  R_mod = R%2019
  if R_mod ==0:
    print(0)
  else:
    if L_mod<R_mod:
      Ls = L//2019
      Rs = R//2019
      if Rs-Ls ==0:
        list =[]
        for i in range(L_mod,R_mod,1):
          mod_i = i%2019
          for j in range(i+1,R_mod+1,1):
            mod_j = j%2019
            mod = (mod_i *mod_j)%2019
            list.append(mod)

        print(min(list))
      else:
        print(0)
    else:
      print(0)

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

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

else:
    l = L % 2019
    r = R % 2019
    if r<l:
        print(0)
    else:
        klist = []
        for i in range(r-l):
            for j in range(r-l-i):
                k = (i+l)*(l+i+j+1)%2019
                klist.append(k)
        klist.sort()
        print(klist[0])

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

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

numbers = [i for i in range(L,min(R+1,L+2019))]
ans = 2019
for conb in combinations(numbers,2):
  if ans > (conb[0]*conb[1])%2019:
     ans = (conb[0]*conb[1])%2019
    
print(ans)

Solution (Python):
L,R = map(int,input().split())
ans = 0
L_min = 10**10
L_ = L//2019
R_ = R//2019

if L_ == R_:
  ans = 10**10
  for i in range(L,R+1):
    for j in range(L,R+1):
      if i != j and ans > (i*j)%2019:
        ans = (i*j)%2019
  print(ans)
else:
  print(0)

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

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

Solution (Python):


import math
import sys
import itertools
import numpy as np



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

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

answer = 9999
for j in range(l,r+1):
    for i in range(l,j):
        a = i % 2019
        b = j % 2019
        answer = min(answer,(a*b)%2019)

print(answer)

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

if r - l > 2017:
    print("0")
else:
    c = 2019
    for i in range(r-l):
        a = (l + i) % 2019
        for j in range(r-l-i):
            b = (l + i + j + 1) % 2019
            if (a * b) % 2019 < c:
                c = (a * b) % 2019
    print(c)

Solution (Python):
from itertools import combinations

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

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

  l = l % 2019
  r = r % 2019
  if r <= l:
    r += 2019

  print(min([(i * j) % 2019 for i, j in combinations(range(l, r+1), 2)]))

if __name__ == '__main__':
  main()

Solution (Python):
import sys

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

if L == 0:
    print(0)
    sys.exit()

temp = R // t
temp2 = L // t
kouho = []
if temp != temp2:
    print(0)
    sys.exit()
else:
    for i in range(L, R+1):
        for j in range(L, R+1):
            if i != j:
                kouho.append((i * j)%t)
    kouho.sort()
    print(kouho[0])

Solution (Python):
L, R = list(map(int, input().split()))
m = R//2019
if R-L>=2019 or (m*2019<=R and m*2019>=L):
  print(0)
else:
  l = L%2019
  r = R%2019
  min_c = 2019
  for i in range(l,r+1):
    for j in range(i+1, r+1):
      score = i*j%2019
      if i*j%2019<min_c:
        min_c = score
  print(min_c)

Solution (Python):
lm, rm = map(int, input().split())
ans = 2018

if rm-lm >= 2019:
  print(0)
else:
  for l in range(lm, rm):
    for r in range(-~lm, -~rm):
      ans = min(ans, (l*r)%2019)
  print(ans)

Solution (Python):
L, R = [int(item) for item in input().split()]
l, ml = divmod(L, 2019)
r, mr = divmod(R, 2019)
if (l==r):
  m = 2019
  for i in range(ml, mr+1):
    for j in range(i+1, mr+1):
      m = min(m, (i*j)%2019)
  print(m)
else:
  print(0)

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

now = [0]*2020

a = l
while a < r+1:
  now[a % 2019] = 1
  a += 1
  if now[0] == 1 or (now[3]==1 and now[673]==1):
    print 0
    exit(0)

ans = 2019*2019
for x in range(2019):
  if now[x] == 1:
    for y in range(2019):
      if now[y] == 1 and x != y:
        buf = (x*y)%2019
        if ans > buf:
          ans = buf
print ans

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

min = 2*1000000000

if R - L > 2019:
  R = L + 2019

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

print(min)

Solution (Python):


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

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

Solution (Python):
lr=input().split()
l=int(lr[0])
r=int(lr[1])

mod=2018
for i in range(r-l):
    x=r-l-i
    if mod==0:
        break
    for j in range(x):
        if (l+j)%2019==0 or (r-i)%2019==0:
            mod=0
            break
        else:
            a=(l+j)*(r-i)
            b=a%2019
            if b<mod:
                mod=b

print(mod)

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

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

Solution (Python):
L, R = map(int, input().split())
L1 = 0
R0 = 0
ans = 2019
if R - L >= 2018 or L % 2019 > R % 2019:
    ans = 0
else:
    L = L % 2019
    R = R % 2019

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

print(ans)

Solution (Python):
l,r = map(int,input().split())
setA = set()
num = r
for i in range(l,r):
    for j in range(i+1,r+1):
        next = (i*j)%2019
        if next not in setA:
            setA.add(next)
            if next ==0:
                print(0)
                exit()
        else:
            if len(setA)==2019:
                print(min(setA))
                exit()

print(min(setA))

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

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

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

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

L, R = L % 2019, R % 2019

if L >= R:
    R += 2019

ans = float('inf')

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

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

Solution (Python):

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

Solution (Python):
L,R=map(int,input().split())
if R-L>=2019:
  ans=0
else:
  ans=2020
  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):
import numpy as np
import itertools
l, r = map(int, input().split())
if r-l>=2019:
  arr = np.arange(l,l+2019,1)
else:
  arr = np.arange(l,r+1,1)
lst = []
flag = True
for i in list(itertools.combinations(arr,2)):
  a = i[0]*i[1]%2019
  if a==0:
    print(0)
    flag = False
    break
  else:
    lst.append(i[0]*i[1]%2019)
if flag:
  print(min(lst))
else:
  None

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

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

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

print(ans)

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

a = l % 2019
b = r % 2019
tmp = 2018

if abs(l-r) >= 2019*2:
    print(0)
elif abs(l-r) >= 2019:
    print(min(a,b))
else:
    tmp = 2018
    for i in range(min(a,b),max(a,b)+1):
        for j in range(i+1,max(a,b)+1):
            tmp = min((i*j)%2019, tmp)
    print(tmp)

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

    print(tmp)

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

Solution (Python):
L,R = map(int,input().split())
L_2019 = L%2019
R_2019 = R%2019
ans1 = (L_2019*R_2019)%2019
if R_2019 < L_2019 :
    print(0)
elif (R - L)//2019 > 0:
    print(0)
else:
    for i in range(L_2019,R_2019):
        for j in range(i+1,R_2019+1):
            ans2 = (i*j)%2019
            ans1 = min(ans1,ans2)
    print(ans1)

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

output = 2019
if r - l < 2018:
    for i in range(l, r+1):
        for j in range(l, r+1):
            if i < j:
                value = ((i%2019) * (j%2019)) % 2019
                if value < output:
                    output = value
else:
    output = 0

print (output)

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


amari=[(a*(a+1)%2019)]
for i in range(a,b):
    for j in range(i+1,b+1):
        x=i%2019
        y=j%2019
        if x==0 or y==0:
            print(0)
            exit()
        elif (x*y)%2019<amari[-1]:
            amari.append((x*y)%2019)

print(amari[-1])

Solution (Python):
I,J=map(int,input().split())

i=I%2019
j=J%2019

cal=10000



if i >= j or I+2019<=J:
    print(0)
elif j<46:
    print(i*(i+1))
else:
    for a in range(j-i):
        for b in range(j-i-a):
            cal=min(cal,((i+a)*(i+a+b+1)%2019))
            
        if cal==0:
            break
        
    print(cal)

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

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

print(ans)

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

if r - l >= 2019:
    print(0)
    exit()
else:
    ans = 2018

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

print(ans)

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

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


elif l // 2019 != r // 2019:
    ans = 0
print(ans)

Solution (Python):
L, R = map(int, input().split())
if L//2019 != R//2019:
    print(0)
elif L % 2019 <= 673 and R % 2019 >= 673 and R - L >= 2:
    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 = list(map(int,input().split()))

ans = 2018
def f(a,b):
    while a > 2019:
        a = a % 2019
    while b > 2019:
        b = b % 2019 
    return (a*b) % 2019 

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

Solution (Python):
from collections import defaultdict


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


def candidates():
    cand = defaultdict(list)
    for i in range(1, 2019):
        for j in range(i + 1, 2019):
            cand[(i*j) % 2019].append((i, j))

    return cand


def check_in_range(l, r, x):
    if r - l > 2019:
        return True

    base = (l // 2019) * 2019

    test = base + x
    while base <= r:
        if l <= test <= r:
            return True
        base += 2019
        test = base + x

    return False


def submit():
    l, r = read_input()

    cands = candidates()
    for i in range(2019):
        cand = cands[i]

        for c in cand:
            if check_in_range(l, r, c[0]) and check_in_range(l, r, c[1]):
                print(i)
                return







if __name__ == '__main__':
    submit()

Solution (Python):
import sys

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

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

Solution (Python):
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
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 II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

def main(): 
    
    L, R = LI()

    if (R//673 - (L-1)//673 > 0) and (R//3 - (L-1)//3 > 0):  
        print(0)
        return
    else: 
        minimum = INF
        import itertools
        for x, y in itertools.combinations(range(L, R+1), 2):
            minimum = min((x*y)%2019, minimum)
        print(minimum)
        return


main()

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

if r-l >= 2018:
    print(0)
else:
    cand = []
    ans = float("inf")
    for i in range(l,r+1):
        cand.append(i%2019)
    cand = sorted(cand)
    for i in range(len(cand)):
        for j in range(i+1,len(cand)):
            ans = min(ans,cand[i]*cand[j]%2019)
    print(ans)

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

diff = R - L
diff = min(diff,2019)

ans = 2019

for l in range(L,L+diff):
    for r in range(l+1,l+diff+1):
        if r > R or l > R:
            break
        ans = min(ans,(l*r)%2019)
print(ans)

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

MOD = 2019
ub = max(R % MOD, L % MOD)
lb = min(R % MOD, L % MOD)

if ub == lb or R // MOD != L // MOD:
    print(0)
    exit()

ans = float('inf')
for i in range(lb, ub + 1):
    for j in range(i + 1, ub + 1):
        ans = min(ans, i * j % MOD)
print(ans)

Solution (Python):
L,R = map(int, input().split())
Smin=2019
Lo=L%2019
Ro=R-(L-Lo)
if Ro>=2019:
    Smin=0
if Ro<2019:
    for x in range(Lo,Ro):
        for y in range(x+1,Ro+1):
            Sa=x*y
            S=Sa%2019
            if Smin>S:
                Smin=S
print(Smin)

Solution (Python):
mod=2019

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

l_shou=l//mod
r_shou=r//mod

l_amari=l%mod
r_amari=r%mod


maxi=max(l_amari, r_amari)
mini=min(l_amari, r_amari)

if l_shou!=r_shou:
    print(0)
else:
    ans=-1
    for i in range(mini, maxi):
        for j in range(i+1, maxi+1):
            if ans==-1:
                ans=(i*j)%mod
            else:
                if ans>(i*j)%mod:
                    ans=(i*j)%mod
    print(ans)

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

min = 2020

if R - L > 673:
    min = 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

print(min)

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

judge=2018

if R-L > 671:
    judge=0
elif L%673 > R%673 :
    judge=0
else:
    i_s=list(range(L, R))
    judge_tmp=[]
    for i in i_s:
        judge_tmp.append(min([(i*j)%2019 for j in range(i+1, R+1)]) )
    judge = min(judge_tmp)
print(judge)