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

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

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

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

Solution (Python):
L,R = (int(x) for x in input().split())
ModL = list(x%2019 for x in range(L,min(L+2019,R+1)))
if 0 in ModL:
    print('0')
else:
    MIN = 2019
    for I in range(0,len(ModL)-1):
        for II in range(I+1,len(ModL)):
            if (ModL[I]*ModL[II])%2019<MIN:
                MIN = (ModL[I]*ModL[II])%2019
    print(MIN)

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

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

R=min(R,L+2*M-1)

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

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

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

Solution (Python):
m, n = map(int, input().split(" "))
if n - m >= 673:
    print(0)
else:
    score = m * n % 2019
    for i in range(m, n + 1):
        for j in range(i + 1, n + 1):
            if (i * j) % 2019 < score:
                score = (i * j) % 2019
    print(score)

Solution (Python):
L, R = map(int, open(0).read().split())

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

print(ans)

Solution (Python):
l,r=map(int,input().split())
mod=2019
ans=float("inf")
if l==0:
    print(0)
    exit()
for i in range(l,min(l+2021,r)):
    for j in range(i+1,min(r+1,l+2022)):
        tmp=(i*j)%mod
        if tmp<ans:
            ans=tmp
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 + 1):  
        for j in range(i + 1, R + 1):  
            ans = min(ans, i * j % 2019)
    print(ans)

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

else:
    l%=2019
    r%=2019
    res = 10000000000

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

Solution (Python):
L,R = [int(_) for _ in input().split()]
if L//2019 != R//2019:
    mod_min=0
else:
    mod_list=[]

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

print(mod_min)

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

if R-L >= 2100 :
    ans = 0
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 == 0 :
                    break

print(ans)

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

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

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






deff = R - L
if (deff < 2019):
    min_num = 10**9 + 7
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            min_num = min(min_num, (i * j) % 2019)
    print(min_num)
else:
    print(0)

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

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

print(ans)

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

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

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

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

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

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())
d=range(l,r+1)[:673]
print(min(i*j%2019 for i in d for j in d if i<j))

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

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

Solution (Python):
L,R=map(int,input().split())
l=L%2019
r=R%2019

if l<r and L//2019 == R//2019:
    ans=10**18
    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)
elif L//2019<R//2019:
    print(0)

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

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

Solution (Python):
def main():
    L,R = [int(x) for x in input().split()]
    ans = 2019
    for i in range(L,min(R,L+2018)+1):
        for j in range(i+1,min(R,L+2018)+1):
            tmp = (i*j) % 2019
            if tmp < ans:
                ans = tmp
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
l,r=map(int,input().split())
import sys
mod=2019
ans=float('inf')

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

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

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

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

Solution (Python):
L,R=map(int,input().split())
if (R-L>3000) :
    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 = [int(_) for _ in input().split()]

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

Solution (Python):
l,r=map(int,input().split())
ans=l*r
if l//2019!=r//2019:
    ans=0
elif l%2019==0 or r%2019==0:
    ans=0
else:
    num1=l%2019
    num2=r%2019
    for i in range(num1,num2):
        for j in range(i+1,num2+1):
            num=(i*j)%2019
            if ans>num:
                ans=num
print(ans)

Solution (Python):

url = "https://atcoder.jp//contests/abc133/tasks/abc133_c"

def main():
    t = list(map(int, input().split()))
    ans = []
    for i in range(t[0], t[1]+1):
        for j in range(i+1, t[1]+1):
            val = (i*j) % 2019
            if val == 0:
                print(val)
                exit()
            ans.append(val)
    print(min(ans))


if __name__ == '__main__':
    main()

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

ans=2018
i=L
while i<R:
    j=i+1
    while j<=R:
        if i*j%2019==0:
            ans=0
            break
        else:
            ans=min(ans,i*j%2019)
            j+=1
    i+=1
    if ans==0:
        break

print(ans)

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

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

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

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

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


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

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

    return


if __name__ == '__main__':
    main()

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

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

    print(ans)

if __name__ == "__main__":
    main()

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

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

    print(ans)

if __name__ == "__main__":
    main()

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

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

l_2019=l%2019
r_2019=r%2019

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

if l_2019 > r_2019:
  print(0)
  sys.exit()
res=2018
for i in range(l_2019, r_2019):
  for j in range(i+1,r_2019+1):
    res = min(res, (i*j)%2019)
    if res==0:
      break
print(res)

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

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

Solution (Python):

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




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

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

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

mod = 2019

lm = l % mod
rm = r % mod

ans = []
if r - l >= mod :
  print(0)
  exit()
else:
  for i in range(lm,rm):
    for j in range(i+1,rm+1):
      ans.append(i*j % mod)
  print(min(ans))

Solution (Python):
L, R = list(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):
        t = i*j%2019
        ans = min(ans,t)
print(ans)

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

l = l%2019
r = r%2019

if l >= r:
    print(0)
else:
    ans = float('inf')
    for left in range(l, r):
        for right in range(left+1, r+1):
            ans = min(ans, (left*right)%2019)
    print(ans)

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

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

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

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

Solution (Python):
L,R = map(int,input().split())
 
cnt = 0
i = L
j = L+1
min_num = 2020
while i <= R and cnt <= 2019:
    j = i+1
    while j <= R:
        min_num = min(min_num,(i*j)%2019)
        if not min_num:
            break
        j += 1
    i += 1
    cnt += 1
print(min_num)

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

Solution (Python):
L,R = map(int, input().split())
l = L//2019
r = R//2019
m = L%2019
n = R%2019

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

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

ans =[]
for i in range(L,R+1):
    for j in range(i+1,R+1):
        ans.append(i*j%2019)
        if (i * j % 2019) == 0:
            break
    else:
        continue
    break

print(min(ans))

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

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

else:
    for i in range(R-L-1010,R-L+1010):
        for j in range(i,R-L+1010):
            ans.append(i*j%2019)

print(min(ans))

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

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

Solution (Python):


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

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

min_m = 2019

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

        min_m = min(min_m, m)

print(min_m)

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

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

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

Solution (Python):
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):
  	t = i*j%2019
  	if t < ans: ans = t
print(ans)

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

Solution (Python):
import sys
sys.setrecursionlimit(10**6)

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

MOD = 2019












import itertools

l_mod = l%MOD
r_mod = r%MOD

if r-l > 2019:
    ans = 0
else:
    if l_mod <= 3 <= r_mod and l_mod <= 673 <= r_mod:
        ans = 0
    elif l_mod < r_mod:
        li = [i for i in range(l_mod, r_mod+1)]
        ans = 2018
        for v in itertools.combinations(li, 2):
            ans = min(ans, v[0]*v[1]%MOD)        
    else:
        ans = 0

print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(10**6)

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

MOD = 2019












import itertools

l_mod = l%MOD
r_mod = r%MOD

if r-l > 2019:
    ans = 0
else:


    if l_mod < r_mod:
        li = [i for i in range(l_mod, r_mod+1)]
        ans = 2018
        for v in itertools.combinations(li, 2):
            ans = min(ans, v[0]*v[1]%MOD)        
    else:
        ans = 0

print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(10**6)

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

MOD = 2019












import itertools

l_mod = l%MOD
r_mod = r%MOD

if r-l > 2019:
    ans = 0
else:
    if l_mod <= 3 <= r_mod and l_mod <= 673 <= r_mod:
        ans = 0
    elif l_mod < r_mod:
        li = [i for i in range(l_mod, r_mod+1)]
        ans = 2018
        for v in itertools.combinations(li, 2):
            ans = min(ans, v[0]*v[1]%MOD)        
    else:
        ans = 0

print(ans)

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

if r//2019 != l//2019:
    print(0)

else:
    lm = list()
    for i in range(l, r):
        for j in range(i+1, r+1):
            lm.append((i*j)%2019)
    print(min(lm))

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

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

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+2019<=r:
  print(0)
  sys.exit()
mn=2018*2018
for i in range(l,r+1):
  for j in range(i+1,r+1):
    mn=min(mn,i*j%2019)
print(mn)

Solution (Python):
L,R = map(int, input().split())
l = L//2019
r = R//2019
m = L%2019
n = R%2019

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

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

for i in range(L, R):
    for j in range(i+1, R+1):
        mod = (i * j) % N
        if val > mod:
            val = mod
        if val == 0:
            print(val)
            sys.exit()
print(val)

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

N = 2019


ans = 2019

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

print(ans)

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

if __name__ == '__main__':
    main()

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

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

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

ans = 2019

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

print(ans)

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

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

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

ans = 2019

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

print(ans)

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

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

l = L%2019
r = R%2019
res = 2018
for i in range(l, r+1):
  for j in range(i+1,r+1):
    if (i*j)%2019==  0:
      print(0)
      exit()

    res = min(res, (i*j)%2019)

print(res)

Solution (Python):
def divisor(n):
    i = 1
    table = []
    while i * i <= n:
        if n % i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table


def main():
    l, r = map(int, input().split())
    ans = float("inf")
    if r - l >= 2500:
        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)


if __name__ == "__main__":
    main()

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


def solve():
    L, R = map(int, input().split())
    mod = 2019
    if R - L >= 4100:
        ans = 0
    else:
        N = R - L + 1
        mlist = []
        for i in range(L, R + 1):
            mlist.append(i % mod)

        mlist.sort()
        comb = list(itertools.combinations(range(N), 2))
        ans = mod  
        for c in comb:
            ans = min(ans, (mlist[c[0]] * mlist[c[1]]) % mod)

    print(ans)


if __name__ == '__main__':
    solve()

Solution (Python):
import math

def main():
    l,r=map(int,input().split())
    m = 2020
    for i in range(l, r):
        for j in range(i+1, r+1):
            n = (i*j) % 2019
            m = min(m, n)
            if m == 0:
                print(m)
                return
    print(m)
    
if __name__ == "__main__":
    main()

Solution (Python):
L,R=map(int,input().split())
if R-L>=670:
    print(0)
    exit()

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

print(ans)

Solution (Python):
import math


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


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

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

        
        
print(_min)

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

Solution (Python):
l,r = map(int,input().split())
sub = r-l
l %= 2019
r %= 2019

if(sub >= 2019):
    print(0)
    exit()

mina = float('INF')

for x in range(l,l+sub+1):
    for y in range(x,l+sub+1):
        if(x==y):
            continue
        
        ans = (x * y) % 2019
        if(mina > ans):
            mina = ans
       
print(mina)

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

Solution (Python):
l,r = map(int,input().split())
sub = r-l
l %= 2019
r %= 2019

if(sub >= 2019):
    print(0)
    exit()

mina = float('INF')

for x in range(l,r+1):
    for y in range(x,r+1):
        if(x==y):
            continue
        
        ans = (x * y) % 2019
        if(mina > ans):
            mina = ans
       
print(mina)

Solution (Python):
L, R = map(int, input().split())
mini = 9999
if R - L >2019:
  R = L + 2019
for l in range(L, R + 1):
  for r in range(l + 1, R + 1):
    temp = (r * l) % 2019
    if temp < mini:
      mini = temp
    if mini == 0:
      break
print(mini)

Solution (Python):
L, R = map(int, input().split())
R = min(R, L+2018)
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())

ind_s = L
ind_e = min(L + 2019, R)

choices_mod = [x%2019 for x in range(ind_s, ind_e+1)]

if len(choices_mod) == 1:
    print(choices_mod[0])
elif 0 in choices_mod:
    print(0)
else:
    import itertools
    pairs = list(itertools.combinations(choices_mod, 2))
    
    ans_list = []
    for a, b in pairs:
        ans_list.append((a*b)%2019)
        
    print(min(ans_list))

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

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

for i in range(l,r+1):
    for j in range(i+1,r+1):

        mod = min(mod,(i*j)%2019)
        if mod == 0:
            break

print(mod)

Solution (Python):
import sys

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

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

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

print(ans)

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

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

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

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

Solution (Python):
L,R=map(int,input().split())
if R-L > 2019:
    print(0)
else:
    answers = []
    for a in range(L, R + 1):
        answers.append(a % 2019)
    answer=[]
    for a in range(len(answers)-1):
        for b in range(a+1,len(answers)):
            answer.append((answers[a]*answers[b])%2019)
    print(min(answer))

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

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

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

minv = float('inf')
if l == 0 or (l-1)//2019 != r//2019 or ((l-1)//3 != r//3 and (l-1)//673 != r//673):
	print(0)
	exit()
else:
	for a in range(l, r):
		for b in range(l + 1, r + 1):
			minv = min(minv, (a%2019)*(b%2019)%2019)
			if minv == 0:
				print(0)
				exit()
print(minv)

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

Solution (Python):
import collections
l,r = map(int, raw_input().split(' '))
cc = collections.Counter([n % 2019 for n in range(l, min(r, l + 2019)+1) ])

m = +float('inf')
for a in cc:
	for b in cc:
		if a!=b or cc[a] > 1:
			m = min(m,(a*b) % 2019)
print m

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

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

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())
import sys
ans = 2018
for i in range(l,r):
    for j in range(i+1,r+1):
        a = (i*j) % 2019
        if a < ans:
            ans = a
        if ans == 0:
            print(ans)
            sys.exit()
print(ans)

Solution (Python):



import itertools

l, r = map(int, input().split())
l_rest = l % 2019
r_rest = r % 2019

if l_rest == 0 or r_rest == 0:
    print(0)
elif r-l < 2019:
    lr_list = list(range(l_rest, r_rest+1))
    lr_comb = list(itertools.combinations(lr_list, 2))
    min_rest = 2018
    for comb in lr_comb:
        rest = comb[0] * comb[1]
        min_rest = min(min_rest, rest%2019)
    print(min_rest)
elif r-l >= 2019:
    print(0)

Solution (Python):
import itertools

l, r = map(int, input().split())
l_rest = l % 2019
r_rest = r % 2019

if l_rest == 0 or r_rest == 0:
    print(0)
elif r-l < 2019:
    lr_list = list(range(l_rest, r_rest+1))
    lr_comb = list(itertools.combinations(lr_list, 2))
    min_rest = 2018
    for comb in lr_comb:
        rest = comb[0] * comb[1]
        min_rest = min(min_rest, rest%2019)
    print(min_rest)
elif r-l >= 2019:
    print(0)

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())
import sys
ans = 2018
for i in range(l,r):
    for j in range(i+1,r+1):
        a = (i*j) % 2019
        if a < ans:
            ans = a
        if ans == 0:
            print(ans)
            sys.exit()
print(ans)

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