Problem:
 Score : 300 points    Problem Statement You are given two non-negative integers L and R .
We will choose two integers i and j such that L \leq i < j \leq R .
Find the minimum possible value of (i \times j) \mbox{ mod } 2019 .      Constraints  All values in input are integers.  0 \leq L < R \leq 2 \times 10^9         Input Input is given from Standard Input in the following format:  L  R       Output Print the minimum possible value of (i \times j) \mbox{ mod } 2019 when i and j are chosen under the given condition.        Sample Input 1 2020 2040      Sample Output 1 2  When (i, j) = (2020, 2021) , (i \times j) \mbox{ mod } 2019  = 2 .       Sample Input 2 4 5      Sample Output 2 20  We have only one choice: (i, j) = (4, 5) .

Solution (Python):
def main():
    L, R = map(int, input().split())
    check_point = 2019
    num_2019 = 0
    while check_point <= R:
        if check_point >= L and check_point <= R:
            num_2019 += 1
        check_point += 2019

    if num_2019 >= 1:
        print(0)
        return
 
    min_mod = 2018
    for i in range(L, R):
        for j in range(i+1, R+1):
            min_mod = min((i*j) % 2019, min_mod)
    print(min_mod)
    

if __name__ == '__main__':
    main()

Solution (Python):
a,b = map(int,input().split())
p = 2019
for i in range (a,b+1) :
    if i%673 == 0 and b-a > 2 :
        print(0)
        exit(0)
    elif i%2019 == 0 :
        print(0)
        exit(0)

for j in range (a,b) :
    for k in range (j+1,b+1) :
        p = min(p,(j*k)%2019)

print(p)

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

Solution (Python):
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    l, r = map(int, input().split())
    if r - l >= 2019:
        print(0)
    else:
        mods = []
        for i in range(l, r + 1):
            mods.append(i % 2019)
        ans = float('inf')
        for i in range(len(mods) - 1):
            for j in range(i + 1, len(mods)):
                tmp = (mods[i] * mods[j]) % 2019
                if tmp < ans:
                    ans = tmp
        print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Solution (Python):
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *

from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction



mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]








    


L,r=l()

if(r-L>=2019):
    print(0)
    exit()
if(r-L<2019 and 0 in [i%2019 for i in range(L,r+1)]):
    print(0)
    exit()
x=[(i*j)%2019 for i in range(L,r+1) for j in range(i+1,r+1)]
print(min(x))

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

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

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

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

ans = 3000
if R-L > 2019:
    ans = 0
else:
    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())

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

print(ans)

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

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

Solution (Python):
import sys

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

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

print(ans)

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

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

Solution (Python):

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


nums = R - L + 1
mod = 2019
ans = float('inf')


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


print(ans)

Solution (Python):
import sys

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

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

print(ans)

Solution (Python):
import sys
l,r = map(int,input().split())
if r-l >= 2018:
    print(0)
    sys.exit()
elif (l%2019 > r%2019) or (l%2019 == 0) or (r%2019 == 0):
    print(0)
    sys.exit()
else:
    l = l%2019
    r = r%2019
p = 2018**2
for i in range(l,r):
    for j in range(i+1,r+1):
        q = (i*j) % 2019
        if q < p:
            p = q
print(p%2019)

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

Solution (Python):

import itertools


def main():
    L, R = map(int, input().split())
    if R - L > 2017:
        print(0)
        return
    xs = [n % 2019 for n in range(L, R + 1)]
    ans = 2018
    for i, j in itertools.combinations(xs, 2):
        tmp = (i * j) % 2019
        if tmp == 0:
            ans = 0
            break
        else:
            if tmp < ans:
                ans = tmp

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
L, R = map(int, input().split())
l = L % 2019
r = R % 2019
w = R - L
if l + w >= 2019:
  print(0)
else:
  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 = 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):
import sys
input = sys.stdin.readline

L,R = map(int,input().split())
lst = []

if L <= 2019 and R >= 2019:
    print(0)
else:
    for i in range(L,R+1):
        if i % 2019 == 0:
            lst.append(0)
            break
        for j in range(i+1,R+1):
            if j % 2019 == 0:
                lst.append(0)
                break
            lst.append((i * j) % 2019)
        else:
            continue
        break
    print(min(lst))

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

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

print(ans)

Solution (Python):
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from fractions import gcd
from math import ceil, floor, sqrt
from copy import deepcopy

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

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

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

Solution (Python):

l, r = map(int, input().split())
a = 2019
b = 0
for i in range(l, r + 1):
    for j in range(i+1, r + 1):
        if i % 2019 == 0 or j % 2019 == 0:
            print(0)
            b = 1
            break
        else:
            a = min(a, (i%2019)*(j%2019)%2019)
    else:
        continue
    break
if b == 0:
    print(a)

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

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

Solution (Python):
def solve(L, R):
  minmod = float('inf')
  for i in range(L, R):
    for j in range(i + 1, R + 1):
      minmod = min((i * j) % 2019, minmod)
      if minmod == 0:
        return minmod
  return minmod

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

Solution (Python):
L,R = list(map(int, input().split()))
if R-L >= 2019:
    print(0)
    exit()
    
s=set()
for i in range(L,R+1):
    if i%2019 in s:
        break
    s.add(i%2019)
l = list(s)

if 3 in l and 673 in l:
    print(0)
    exit()
    
print(min([(i*j)%2019 for i in l for j in l if i != j]))

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

Solution (Python):
def mod2019(x, y):
    return (x%2019 * y%2019 ) % 2019

L,R = list(map(int, input().split()))
ans=2019
s=set()
for i in range(L,R+1):
    if i%2019 in s:
        break
    s.add(i%2019)
l = list(s)
for i in range(len(l)):
    for j in range(i+1, len(l)):

        ans=min(ans, mod2019(l[i], l[j]))
    
print(ans)

Solution (Python):
l,r=map(int,input().split())
if abs(l-r)>=673:
  print(0)
else:
  ans=float('inf')
  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())
ans = float('inf')

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)

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

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

if R - L >= 2019:
  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())

mod = 2019
min_num = float("inf")

tmp_L = L

while tmp_L < R and tmp_L <= L + 2019:
    tmp_R = tmp_L + 1

    while tmp_R <= R and tmp_R <= tmp_L + 2019:
        min_num = min((tmp_L*tmp_R)%mod ,min_num)
        tmp_R += 1
    tmp_L = tmp_L + 1

print(min_num)

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

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

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

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

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    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)
resolve()

Solution (Python):
l,r=map(int,input().split())
mod=2019
if r-l>=3000:
    print(0)
else:
    ans=1111111111
    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):
m=2019
l,r=map(int,input().split())

if l==0 or l//m<r//m or l%m==0:
  print(0)
  exit()

import numpy as np
lr=m
for ii in np.arange(l,r):
  for jj in np.arange(ii+1,r+1):
    t=((ii%m)*(jj%m))%m
    if t==0:
        print(0)
        exit()
    if t<lr:
      lr=t
print(lr)

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

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


def solve(l,r):
    num = float("inf")
    count = 0
    for i in range(l,r):
        for j in range(i+1,r+1):
            if count >= 2019**2:
                print(num)
                return
            
            current = (i*j) % 2019
            if current == 0:
                print(current)
                return
            
            num = min(current,num)
            count += 1
    
    print(num)

solve(l,r)

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

Solution (Python):

def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n): return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)




import math



a,b=n1()

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

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

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

MIN = 2018
if R-L > 4039:
    MIN = 0


MOD = 2019
L = L%MOD
R = R%MOD
if L > R:
    L, R = R, L
elif L == R:
    MIN = 0


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

print(MIN)

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

d=[int(i) for i in range(2019)]

a=l%2019
b=r%2019

if a<b:
    if r-l<2019:
        d=d[a:b+1]
    else:
        d=d
elif a>b:
    if r-l<2019:
        d=d[b:a+1]
    else:
        d=d
else:
    d=d
    
ans=2019
for i in range(len(d)):
    for j in range(i+1,len(d)):
        ans=min(ans,(d[i]*d[j])%2019)
print(ans)

Solution (Python):

import itertools


def main():
    L, R = map(int, input().split())
    if R - L > 2017:
        print(0)
        return
    xs = [n % 2019 for n in range(L, R + 1)]
    ans = 2018
    for i, j in itertools.combinations(xs, 2):
        tmp = (i * j) % 2019
        if tmp == 0:
            ans = 0
            break
        else:
            if tmp < ans:
                ans = tmp

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
L, R = map(int, input().split())
ans = 2018
END = False

for i in range(2019):
    j = i + 1
    while j <= R-L:
        ans = min( ((L+i)*(L+j)) % 2019, ans)
        j += 1
        if ans == 0:
            END = True
            break
    if END or i > R-L:
        break

print(ans)

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

ans = 10 ** 9
for i in range(L, R):
    for j in range(i+1, R+1):
        tmp = (i*j)%2019
        if ans > tmp:
            ans = tmp
        if ans == 0:
            break
    else:
        continue
    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):
    t = i*j%2019
    if ans > t:
      ans = t
    if ans == 0:
      print(ans)
      exit()
print(ans)

Solution (Python):
l, r = map(int,input().split())
if not l//2019 == r//2019:
    print(0)
else:
    l = l%2019
    r = r%2019
    ans = 10**10
    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):
import itertools
L,R = map(int,input().split())

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

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):
import sys
l, r = map(int, input().split())
if l == 0:
    print(0)
    sys.exit()

div_l, mod_l = divmod(l, 2019)
div_r, mod_r = divmod(r, 2019)
if div_l != div_r:
    print(0)
else:
    num = float('inf')
    for i in range(mod_l, mod_r + 1):
        for j in range(i + 1, mod_r + 1):
            num = min(num, (i * j) % 2019)
    print(num)

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

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

ans = 2018

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

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

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

d = 10 ** 10

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

Solution (Python):
from itertools import combinations

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

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

print(ans)

Solution (Python):
l,r=map(int,input().split())
n=l//2019
m=r//2019
p=l%2019
q=r%2019
a=2018
if p>q:
    print(0)
elif m>n:
    print(0)
else:
    for i in range(p,q):
        for j in range(p+1,q+1):
            c=(i*j)%2019
            if a>c:
                a=c
    print(a)

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

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

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

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

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

print(ans)

Solution (Python):

import sys
input = sys.stdin.readline
L,R = (int(x) for x in input().split())

mod_L =L %2019
mod_R =R %2019
ans =0
xx=[]
if 2018 <= R -L:
    ans =0
elif mod_R < mod_L:
    ans =0
elif mod_L==0 :
    ans =0
else:
    for i in range(L,R):
        for j in range(i+1,R+1):
            x =i*j %2019
            xx.append(x)
    ans =min(xx)
print(ans)

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

result=float("inf")
R=min(R,L+4038)
for i in range(L,R+1):
  for j in range(i+1,R+1):
    result=min(result,i*j%2019)









print(result)

Solution (Python):
import sys

a, b = map(int,input().split())
num = int(a*b%2019)

for i in range(a, b + 1):
  for j in range(i + 1, b + 1):
    if(i >= j):
      continue
    num = min(num, (i*j)%2019)
    if(num == 0):
      print(0)
      sys.exit()

print(num % 2019)

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

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

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

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

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

Solution (Python):
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

l,r = nm()

MOD = 2019

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

print(ans)

Solution (Python):






import sys
input = sys.stdin.readline

import math

import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache






MOD = 10**9+7
INF = float('inf')






def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]


def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()


def DD(arg): return defaultdict(arg)



def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr


def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors


def lcm(a, b):
    return a * b // gcd (a, b)


def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count


def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))


def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count





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

Solution (Python):
i, j = map(int, input().split())
a = i % 2019
a_r = i // 2019

b = j % 2019
b_r = j // 2019

if a_r == b_r:
    minv = float('INF')
    for first in range(a, b):
        for second in range(a+1, b+1):
            result = first*second%2019
            if result < minv:
                minv = result

    print(minv)
else:
    print(0)

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

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
    if ans==0:
      break
  else:
    continue
  break

print(ans)

Solution (Python):
a, b = list(map(int, input().split()))
if b-a >= 2019:
  print(0)
  quit()

lis = list(range(a, b+1))
  
ans = 2019

for i in range(b-a+1):
  for j in range(i+1, b-a+1):
    
    temp = ((lis[i]%2019)*(lis[j]%2019))%2019
    
    if temp < ans:
      ans = temp
print(ans)

Solution (Python):
from sys import exit

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

if l%673 == 0 or r%673 == 0:
    if l%3 == 0 or r%3 == 0:
        print(0)
        exit()
    else:
        for i in range(l, min(r,l+2)+1):
            if i%3 == 0:
                print(0)
                exit()
elif l//673 != r//673:
    for i in range(l, min(r,l+2)+1):
        if i%3 == 0:
            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))
        if ans == 0:
            break
    if ans == 0:
        break
print(ans)

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

Solution (Python):
L,R = map(int,input().split())
if R-L > 673 or (L%2019) > (R%2019):
  print(0)
else:
  l = L%2019
  r = R%2019
  c = 2018
  w = set()
  for i in range(l,r):
    for j in range(i+1,r+1):
      t = (i*j)%2019
      if c > t:
        c = t
  print(c)

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

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

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

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

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

MOD = 2019

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

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

Solution (Python):
def resolve():
    L, R = [int(i) for i in input().split()]
    ans = 2019
    end = min(R, (L + 2019)) + 1
    for i in range(L, end):
        for j in range(i + 1, end):
            ans = min(ans, i * j % 2019)
            if ans == 0:
                break
        else:
            continue
        break
    print(ans)


resolve()

Solution (Python):
from itertools import combinations


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


mod0 = [n for n in range(0, R + 1, 2019) if L <= n]
if not mod0:
    target_num = list(range(L, R + 1))
    nC2 = list(combinations(target_num, 2))
    mods_ans = [(i * j) % 2019 for i, j in nC2]

    print(min(mods_ans))
else:
    print(0)

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

print(abc133_c())

Solution (Python):
L, R = map(int, input().split())
R -= (L // 2019) * 2019
L %= 2019

while R-4038 > L:
  R -= 2019

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)