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())
m = r-l

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

Solution (Python):

import sys

MOD = 2019  


def solve(L: int, R: int):
    list_lr_mod = []
    ans = 2018

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

    for i, x in enumerate(range(L, R + 1)):
        xmod = x % MOD
        if xmod == 0:
            print(0)
            return
        else:
            list_lr_mod.append(xmod)


    for i in range(len(list_lr_mod) - 1):
        for j in range(i + 1, len(list_lr_mod)):
            tmp = list_lr_mod[i] * list_lr_mod[j]
            ans = min(ans, tmp % MOD)

    print(ans)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = int(next(tokens))  
    R = int(next(tokens))  
    solve(L, R)

if __name__ == '__main__':
    main()

Solution (Python):

import sys

MOD = 2019  


def solve(L: int, R: int):
    list_lr_mod = []
    ans = 2018

    for i, x in enumerate(range(L, R + 1)):
        list_lr_mod.append(x % MOD)

        if i + 1 >= 2019:
            print(0)
            return

    if 0 in list_lr_mod:
        print(0)
        return

    for i in range(len(list_lr_mod) - 1):
        for j in range(i + 1, len(list_lr_mod)):
            tmp = list_lr_mod[i] * list_lr_mod[j]
            ans = min(ans, tmp % MOD)

    print(ans)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = int(next(tokens))  
    R = int(next(tokens))  
    solve(L, R)

if __name__ == '__main__':
    main()

Solution (Python):

import sys

MOD = 2019  


def solve(L: int, R: int):
    list_lr_mod = []
    ans = 2018

    for x in range(L, R + 1):
        list_lr_mod.append(x % MOD)

        if len(list_lr_mod) >= 2019:
            print(0)
            return

    list_lr_mod = list(set(list_lr_mod))

    if 0 in list_lr_mod:
        print(0)
        return

    for i in range(len(list_lr_mod) - 1):
        for j in range(i + 1, len(list_lr_mod)):
            tmp = list_lr_mod[i] * list_lr_mod[j]
            ans = min(ans, tmp % MOD)

    print(ans)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = int(next(tokens))  
    R = int(next(tokens))  
    solve(L, R)

if __name__ == '__main__':
    main()

Solution (Python):

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




MOD = 2019


ij_set = set()
for i in range(L,R+1):
    
    if i%MOD not in ij_set:
        ij_set.add(i%MOD)
    else:
        break 
        
ij_list = list(ij_set)
ij_list.sort(reverse=False)


ans = MOD - 1


for i in range(len(ij_list) - 1):
    for j in range(i+1,len(ij_list)):
        if ans > ij_list[i]*ij_list[j]%MOD:
            ans = ij_list[i]*ij_list[j]%MOD
            
        
print(ans)

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

Solution (Python):


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

if __name__ == '__main__':
  print(main())

Solution (Python):
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

MOD = 2019
L, R = lr()
if (R-L) > 2019 * 2:
    R = L + (R-L)%MOD + 2019

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

print(answer)

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

l1 = l%2019
r1 = r%2019
if r >= l + 2019 - l1:
    r1 = 2019

ans = float("inf")
for i in range(l1,r1):
    for j in range(i+1, r1+1):
        ans = min(ans, ((i*j)%2019))

print(ans)

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

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

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

Solution (Python):
M=2019;L,R=map(int,input().split())
l=L%M;r=R%M;a=M
if l<r and R-L<672:
  for i in range(l,r):
    for j in range(i+1,r+1):
      a=min(a,i*j%M)
      if a<2: break
    if a<2: break
else: a=0
print(a)

Solution (Python):
M=2019;L,R=map(int,input().split())
l=L%M;r=R%M;a=M-1
if l<r and R-L<672:
  for i in range(l,r):
    for j in range(i+1,r+1):
      a=min(a,i*j%M)
      if a<2: break
    if a<2: break
else: a=0
print(a)

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

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

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

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

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

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

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

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

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

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

Solution (Python):

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

Solution (Python):
MOD = 2019

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

if (L // MOD) != (R // MOD):
  print(0)
else:
  res = R*R
  for i in range(L, R):
    for j in range(i+1, R+1):
      _, r = divmod(i*j, MOD)
      if r < res:
        res = r
  print(res)

Solution (Python):
def solve():
    N, M = map(int, input().split())
    m = 10 ** 9
    for i in range(N, min(N+2019, M)):
        for j in range(N+1, min(N+2019, M)+1):
            m = min(m, i * j % 2019)
    return m

print(solve())

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

m = 2019

if R - L > 2100:
    print(0)
else:
    tmp_min = 2018
    for i in range(L, R):
        mod_i = i % m
        for j in range(i + 1, R+1):
            mod = (mod_i * j) % m
            if tmp_min > mod:
                tmp_min = mod
    print(tmp_min)

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

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

Solution (Python):
import sys
import os

MOD = 2019


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    L, R = list(map(int, sys.stdin.readline().split()))
    ret = float('inf')

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

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

    print(ret)


if __name__ == '__main__':
    main()

Solution (Python):
L,R=map(int,input().split())
if R-L>2017:
    mod=[i for i in range(2019)]
else:
    l=L%2019
    r=R%2019
    mod=[i for i in range(2019)]*2
    mod=mod[mod.index(l):]
    mod=mod[:mod.index(r)+1]
ans=3000
for i in range(len(mod)-1):
    for k in range(len(mod)-i-1):
        min=mod[i]*mod[i+k+1]%2019
        if min<ans:
            ans=min
print(ans)

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

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

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

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

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

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

for a in range(L, end):
    for b in range(a + 1, end+ 1):
        tmp = (a * b) % 2019
        if tmp < ans:
            ans = tmp

print(ans)

Solution (Python):
L, R = map(int, input().split())
i = 2017
j = 2018
i_mod = 2017
j_mod = 2018
end = min(R, L + 4038)

ans = 2018












for a in range(L, end):
    for b in range(a + 1, end+ 1):
        tmp = (a * b) % 2019
        if tmp < ans:
            ans = tmp

print(ans)

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

  print(min_a)

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

m = 2019
if R-L>=2018:
  for i in range(2019):
    for j in range(i+1,2019):
      m = min(m,i*j%2019)
else:
  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())
ans=10**15
for i in range(l,min(r,l+2100)):
  for j in range(i+1,min(r+1,l+2100)):
    ans=min(ans,(i*j)%2019)

print(ans)

Solution (Python):
L,R = map(int,input().split())
ans = 4*(10**18)
if R-L >= 2019:
  print(0)
else:
  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 numpy as np
a, b = map(int, input().split())
if b - a >= 2019:
  print(0)
  
else:
  all_ = np.mod([i for i in range(a, b+1)], 2019)
  all_ = np.outer(all_, all_)
  n = all_.shape[0]
  all_ = np.mod(all_ * (np.ones((n,n)) - np.eye(n)) + np.eye(n) * 2018, 2019)
  print(int(all_.min()))

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

ans = 2019
end_flag = False

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

        if ans==0:
            end_flag = True
            break

    if end_flag:
        break

print(ans)

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

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

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

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

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

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

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

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

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

mod_L = L % mod
mod_R = R % mod

if mod_L >= mod_R:
    print(0)
    exit()

if mod_R - mod_L < R - L:
    print(0)
else:
    ans = False
    for i in range(mod_R - mod_L):
        for j in range(i + 1, mod_R - mod_L + 1):
            if ans is not False:
                ans = min(ans, (mod_L + i) * (mod_L + j) % mod)
            else:
                ans = (mod_L + i) * (mod_L + j) % mod
    print(ans)

Solution (Python):

L, R = map(int, input().split(' '))
if R - L >= 2020:
    print(0)
    exit()

ret = float('inf')
for i1 in range(L, R+1):
    for i2 in range(i1+1, R+1):
        ret = min(ret, (i1*i2)%2019)

print(ret)

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

print(res)

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

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

Solution (Python):
L,R=map(int,input().split())
i=0
j=0
l=0
r=0
md=float("inf")
if R-L>=673:
    print("0")
else:
    l=L%2019
    r=R%2019
    if l>r:
        print("0")
    elif l<r:
        l=L%2019
        r=R%2019
        for i in range(l,r+1):
            for j in range(i+1,r+1):
                if (i*j)%2019<md:
                    md=(i*j)%2019
                
        print(md)

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

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())
M=[]
for i in range(L,R+1):
    for j in range(L,R+1):
        if j<=i:
            continue
        else:
            m = (i*j)%2019
            if m==0:
                print(0)
                exit()
            M.append(m)
print(min(M))

Solution (Python):
l, r = [int(i) for i in input().split()]
ln = l // 2019
rn = r // 2019
if ln != rn:
	print (0)
else:
	ret = 2019 * 2019
	for i in list(range(l % 2019, r % 2019 + 1)):
		for j in list(range(i + 1, r % 2019 + 1)):
			ret = min(ret, (i * j) % 2019)
	print (ret)

Solution (Python):

import sys



def main():
    MOD = 2019
    L,R = [int(s) for s in input().split()]
    if R-L+1 >= MOD:
        print(0)
        sys.exit()

    min_rmdr = MOD

    for i in range(L,R):
        for j in range(L+1,R+1):
            if (i * j) % MOD < min_rmdr:
                min_rmdr = (i * j) % MOD
    
    print(min_rmdr)

if __name__ == '__main__':
    main()

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




result = 1 << 31
for i in range(l, r + 1):
  for j in range(i + 1, r + 1):
    i %= MOD
    j %= MOD
    if i == 0 or j == 0:
      print(0)
      exit(0)
    result = min(result, (i * j) % MOD)
print(result)

Solution (Python):
import os, sys, re, math

(L, R) = [int(n) for n in input().split()]

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

print(result)

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

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


if w>2019:
    print(0)
else:
    List = [int(i) for i in range(L,R+1)]
    Min = 2018
    for i in range(len(List)-1):
        for j in range(i+1,len(List)):
            l = (List[j]*List[i])%2019
            if l<Min:
                Min = l
    print(Min)

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

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

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

def rem(L, R):
  if (R//2019) - (L//2019) > 0:
    return 0
  L = L % 2019
  R = R % 2019
  res = 2018
  for i in range(L, R):
    for j in range(i+1, R+1):
      m = (i*j)%2019
      if res > m:
        res = m
  return res

print(rem(L, R))

Solution (Python):
year = 2019

l, r = map(int, input().split())
d = l // year
l %= year
r -= d * year
if l == 0 or r >= year:
    print(0)
else:
    ans = year
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            res = i * j % year
            ans = min(ans, res)
            if res == ans: param = (i, j)
    print(ans)

Solution (Python):

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

Solution (Python):
l, r = map(int, input().split())
r = min(r, l+(2019*2))
ans = 2018

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

print(ans)

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

mod = 2019
ans = 10000
a = []
for i in range(l,r+1):
  a.append(i%2019)
  if len(a) == 2020*2:
    break


for i in range(len(a)):
	for j in range(len(a)):
		if i == j:
			continue
		ans = min(ans,(a[i]*a[j])%mod)
		if ans == 0:
			print(ans)
			sys.exit()

print(ans)

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

cand = []
for i in range(l,r+1):
  cand.append(i%2019)
  if len(cand) == 2020*2:
    break
    
ans = float('inf')
for i in range(len(cand)):
  for j in range(len(cand)):
    if i==j:
      continue
    ans = min(ans, (cand[i]*cand[j])%2019)
    if ans ==0:
      break
  else:
    continue
  break
print(ans)

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

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

Solution (Python):
a, b = map(int, input().split())
ans = 20000000
n = a//2019
m = b//2019
a = a % 2019
b = b % 2019

if a > b:
    ans = 0
else:
    for i in range(a, b):
        for j in range(a+1, b+1):
            ans = min(ans, i*j%2019)
if m != n:
    ans = 0

if a == b:
    ans = 0

print(ans)

Solution (Python):


















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

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

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

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

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

print(ans)

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

print(ans)

Solution (Python):

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

if r//2019>l//2019: print(0)
else:
    r%=2019
    l%=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())
b = 0
if r-l>2019:
    print(0)
    b = 1
if b==0:
    l,r = l%2019,r%2019
    if r>l:
        m = 2019**2
        for i in range(l,r):
            for j in range(i+1,r+1):
                tmp = i*j%2019
                if tmp < m:
                    m = tmp
        print(m)
    else:
        print(0)

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

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

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

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

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

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

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

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

print(ans)

Solution (Python):




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

    min_mod = float("inf")

    for i in range(L, min(R, L + mod)):
        for j in range(i + 1, min(R + 1, i + 1 + mod)):
            curr_mod = i * j % mod
            min_mod = min(min_mod, curr_mod)
            if min_mod == 0:
                break

    print(min_mod)


if __name__ == "__main__":
    main()

Solution (Python):

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

mini = (L * R) % 2019

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

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



print(mini)

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

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

Solution (Python):
L,R=map(int,input().split())
l,r=L%2019,R%2019
x,y=L//2019,R//2019
if x<y:
  print(0)
else:
  ans=10**9
  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 >= 2019:
    pass
    print(0)
    exit()
ans = 2020
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())
l0=l%2019
r0=r%2019
if r-l>=2019 or l0==0 or r0==0:
    print(0)
elif l-l%2019+2019<=r:
    print(0)
else:
    ans=2019
    for i in range(l0,r0):
        for j in range(i+1,r0+1):
            if (i*j)%2019<ans:
                ans=(i*j)%2019
    print(ans)

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

print(ans)

Solution (Python):
a,b=map(int,input().split())
ans=[]
i=0
while i<1000 and a+i<=b:
    ans.append((a+i)%2019)
    i+=1
ans.sort()
minn=10**6
for i in range(len(ans)):
    for j in range(i+1,len(ans)):
        minn=min(minn,(ans[i]*ans[j])%2019)
print(minn)

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

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

R = min(R,L+2019)

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

print(ans)

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

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):
            ans = min(ans, i * j % 2019)
    print(ans)

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

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



def get_ans():
    (l, r) = [int(i) for i in input().rstrip().split(" ")]
    if r - l <= 3000:
        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:
                    return 0
        return ans
    return 0


print(get_ans())

Solution (Python):
L, R = map(int, input().split())
mod = 2019
s = 2018
for i in range(L,R):
    for j in range(i+1, R+1):
        t = (i%mod)*(j%mod)%mod
        if s > t:
            s = t
        if t == 0:
            break
    else:
        continue
    break
print (s)

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

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

lmod = l%2019
rmod = r%2019

if r-l>=2018:
    print(0)
elif lmod < rmod:
    for i in range(lmod, rmod+1):
        lst.append(i)
    ans = 2018
    for i in range(len(lst)):
        for j in range(i+1,len(lst)):
            ans = min(ans, (lst[i]*lst[j])%2019)
    print(ans)
else:
    print(0)

Solution (Python):
from sys import maxsize

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

min = maxsize
m = l
while m <= r:
    n = m + 1
    while n <= r:
        mod = m * n % 2019
        if mod < min:
            min = mod
        if mod == 0:
            break
        n += 1
    else:
        m += 1
        continue
    break

print(min)

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

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

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

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