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

Solution (Python):
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]


def get_nums_l():
    return [ int(s) for s in input().split(" ")]


def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

l,r = get_nums_l()
d = r-l

lm = l % 2019
rm = r % 2019


nums = [0] * 2019
for imod in range(2019):
    if (imod+(2019-lm))%2019 <= d:
        nums[imod] += 1 + (d - (imod+(2019-lm))%2019)//2019

min_ = 999999999999999999999
for a in range(2019):
    for b in range(2019):
        if a==b and nums[a] < 2:
            continue
        if nums[a] < 1 or nums[b] < 1:
            continue
        mo = a*b%2019
        if min_ > mo:
            min_ = mo
print(min_)

Solution (Python):
a,b=map(int,input().split())
mindiv=1000000000
for i in range(a,b):
  for j in range(i+1,b+1):
    if i%2019==0 or j%2019==0:
      print(0)
      exit()
    else:
      mindiv=min(i*j%2019,mindiv)
print(mindiv)

Solution (Python):
l, r = map(int, input().split())
if r-l >= 2019:
    ans = 0
else:
    n = 2019
    l = l%n
    r = r%n
    ans = 2019
    a = min(l,r)
    b = max(l,r)

    for i in range(a,b):
        for j in range(a+1,b+1):
            ans = min(ans, (i*j)%n)

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):
        v = i * j % 2019
        ans.append(v)
        if v == 0:
            break
    else:
        continue
    break
    
print(min(ans))

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

if b-a > 2019:
	min_mod=0

else:	
	for aa in range(a,b):
	   for bb in range(aa+1,b+1):
	       if aa < bb:
	           cc=aa*bb
	 
	           if min_mod > cc%2019:
	               min_mod = cc%2019

print(min_mod)

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

if b-a > 2019:
	min_mod=0

else:	
	for aa in range(a,b):
	   for bb in range(a+1,b+1):
	       if aa < bb:
	           cc=aa*bb
	 
	           if min_mod > cc%2019:
	               min_mod = cc%2019

print(min_mod)

Solution (Python):




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

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

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

Solution (Python):
L, R = map(int, input().split())
if R - L > 2019:
  print(0)
else:
  L, R = L % 2019, R % 2019
  if L > R:
    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:
    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):
mod = 2019
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)%mod)
    print(ans)

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

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

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

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

num = 0
ans = (L * (L + 1)) % 2019
if (R - L) > 2020:
    ans = 0
else:
    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())
MOD = 2019

if r - l >= MOD:
    print(0)
else:
    min = MOD
    for i in range(l, r):
        if min == 0: break
        for j in range(i+1, r+1):
            im, jm = i % MOD, j % MOD
            val = (im * jm) % MOD
            if val < min:
                min = val
    print(min)

Solution (Python):
def main():
    l,r = map(int, input().split())
    
    ans = 10**8

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

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

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

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

def check(left, right):
  ans = 2018
  
  
  if right-left >= 2019:
    ans = 0
  
  else:
    for i in range(left, right):
      for j in range(l+1, right+1):
        ans = min((i*j)%mod, ans)
        if ans==0: return ans
  return ans
ans = check(l, r)
print(ans)

Solution (Python):
import sys

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

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

m = 10**9

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

    if m > s:
      m = s

print(m)

Solution (Python):
import sys
L,R=map(int,input().split())
_min=2018
if L==0 or R-L>=2019:
  print(0) 
  sys.exit()
else:
  for l in range(L,R):
    for r in range(L+1,R+1):
      mm=(l*r)%2019
      if mm==0:
        print(0) 
        sys.exit()
      elif _min>mm:
        _min=mm
print(_min)

Solution (Python):
L,R=map(int,input().split())
_min=2018
if L==0:
  _min=0
elif R-L>=2019:
  _min=0
else:
  for l in range(L,R):
    for r in range(L+1,R+1):
      mm=(l*r)%2019
      if mm==0:
        _min=0
        break
      elif _min>mm:
        _min=mm
print(_min)

Solution (Python):
L,R=map(int,input().split())
_min=2018
if L==0:
  _min=0
else:  
  for l in range(L,L+2019):
    if l>R:
      break
    for r in range(l+1,l+2020):
      if r>R:
        break
      m=(l*r)%2019
      if _min>m:
        _min=m
print(_min)

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

ans = 2019**2
if R - L >=2019:
   ans =0
elif l < r :
    for i in range(l,r+1):
        for j in range(i+1,r+1):
             ans = min(ans,i*j%MOD)
else :
    ans =0
print(ans)

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

modL = L % 2019
modR = R % 2019
min2019 = 2019

if R - L >= 2018:
    print(0)
elif modL <=3 and modR >=673:
    print(0)
else:
    for j in range(modL, modR+1):
        for k in range(j+1, modR+1):
            min2019 = min(min2019, j * k % 2019)
    print(min2019)

Solution (Python):
L, R = map(int, input().split())
modL = L % 2019
modR = R % 2019
min2019 = 2019

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

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

res = 2019

modL = L % 2019
div = 2019 - modL

if L + div <= R:
    res = 0    

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

print(res)

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

Solution (Python):

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

Solution (Python):

import sys
import math
import os
import itertools
import _collections
import string
from functools import lru_cache

class cin():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def mapInt():
        return [int(x) for x in cin.string().split()]
    def stringList(n):
        return [input() for i in range(n)]
    def intListList(n):
        return [cin.mapInt() for i in range(n)]
    def intColsList(n):
        return [int(input()) for i in range(n)]
        
class Math():
    def gcd(a,b):
        if b == 0:
            return a
        return Math.gcd(b,a % b)
    def lcm(a,b):
        return (a * b) // Math.gcd(a,b)
    def roundUp(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Math.roundUp(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

MOD = int(1e09) + 7

def main():
    L,R = cin.mapInt()
    if L // 2019 != R // 2019:
        print(0)
        return
    L %=2019
    R %=2019
    ans = int(1e09)
    for i in range(L,R + 1):
        for j in range(i + 1,R + 1):
            ans = min(ans,(i * j) % 2019)
    print(ans)
    return

if __name__ == "__main__":
    main()

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

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

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

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

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

import sys

mi=10**10
for l in range(L,R+1):
    for r in range(l+1,R+1):
        mod = (l*r) % 2019
        if mod < mi:
            mi=mod
        if mi==0:
            print(mi)
            sys.exit()
print(mi)

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

new_L = L % 2019
new_R = R % 2019


if R - L >= 2019:
    print(0)
else:
    mi=10**10
    for l in range(new_L,new_R+1):
        for r in range(l+1,new_R+1):
            mod = (l*r) % 2019
            if mod < mi:
                mi=mod
    print(mi)

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

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

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

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

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

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

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

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

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

r = min(L+2019, R)

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

Solution (Python):
import numpy as np
L, R = map(int, input().split())
mod = 2019
l_mod = L % mod
r_mod = R % mod
lr_range = R - L + 1
if lr_range >= 2019:
    ans = 0
elif l_mod < r_mod:
    ans = 2018
    q = np.arange(l_mod, r_mod+1)
    for i in range(len(q)):
        min_i = (q * q[i]) % mod
        min_i[i] = 2018
        ans = min(min(min_i), ans)
else:
    ans = 0

print(ans % mod)

Solution (Python):
def LI():
  return [int(s) for s in input().split()]

L,R = LI()

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

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

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

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

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

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

Solution (Python):
lr=list(map(int,input().split()))
mod=2019
ans=mod**2
if lr[0]%mod<=lr[1]%mod and lr[1]-lr[0]<mod:
    for i in range(lr[0],lr[1]+1):
        for j in range(i+1,lr[1]+1):
            if i*j%mod<ans:
                ans=i*j%mod
else:
    ans=0
print(ans)

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

ls =[]

if R-L>=mod-1:
    print(0)
    exit()
else:
    for i in range(R-L+1):
        ls.append((L+i)%mod)

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

print(ans)

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

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

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

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

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

l2 = l // 2019
r2 = r // 2019

if l2 != r2:
  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 main():
    l, r = map(int, input().split())

    res = 2018
    for i in range(l, r):
        for j in range(l+1, r+1):
            mod = (i*j)%2019
            if mod < res:
                res = mod
            if res == 0:
                break
        else:
            continue
        break
        
    print(res)


if __name__ == '__main__':
    main()

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

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

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

if l//2019==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)
else:
    print(0)

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


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

Solution (Python):
import sys

input = sys.stdin.readline


class Solution:
    def main(self):
        L, R = map(int, input().split())

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

        print(ans)



if __name__ == '__main__':
    Solution().main()

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

Solution (Python):
from itertools import combinations

L, R = map(int,input().split())
mods = []
for num in range(L, min(R+1,L+2020)):
    mods.append(num % 2019)

ans = float('inf')
for cmb in combinations(mods, 2):
    ans = min(ans, (cmb[0] * cmb[1]) % 2019)
print(ans)

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

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

ans = 0

if R - L >= 2019:
    pass
else:
    A = set()

    for i in range(L, R):
        for j in range(i+1, R+1):
            A.add(i*j % MOD)
            if i * j % MOD == 0:
                break

    ans = min(A)

print(ans)

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

Solution (Python):
import sys
import math
import numpy as np
import bisect
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

l, r = na()

if l + 2019 - 1 < r:
    r = l + 2019 - 1
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
ans=mod

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

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

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

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

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

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

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

            if tmp == 0:
                print('0')
                sys.exit()

            if ans == 0:
                ans = tmp

            if ans > tmp:
                ans = tmp

    print(ans)

main()

Solution (Python):
def main():
    L, R = map(int, input().split(" "))
    if R - L >= 2019:
        
        print(0)
    else:
        l = []
        for i in range(L, R + 1):
            l.append(i % 2019)
        l.sort()
        minimum = 2018
        for j in range(len(l)):
            for k in range(j + 1, len(l)):
                minimum = min(minimum, l[j] * l[k] % 2019)
        print(minimum)


if __name__ == '__main__':
    main()

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

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

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

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

if r//mod != l//mod:
    print(0)
    exit()

li = []

for i in range(l,r+1):
    li.append(i%mod)

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

Solution (Python):
L, R = map(int,input().split())
if R-L>=2018:
    print(0)
else:
    lst = [i%2019 for i in range(L,R+1)]
    lst = set(lst)
    lst = list(lst)
    N = len(lst)
    ans = 10**8
    for i in range(N-1):
        for j in range(i+1,N):
            if ans>(lst[i]*lst[j])%2019:
                ans = (lst[i]*lst[j])%2019
    print(ans)

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

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

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

print(ans)

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

A = []
Lm = L % 2019
Rm = R % 2019
for _ in range(min(R - L + 1, 2019 * 2)):
    A.append(Lm)
    Lm = (Lm + 1) % 2019

A.sort()
ans = 2018
for i in range(len(A)):
    for j in range(i + 1, len(A)):
        ans = min(ans, (A[i] * A[j]) % 2019)
        if ans == 0:
            break

print(ans)

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

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

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

print(ans)

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

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

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

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

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

Solution (Python):
from itertools import combinations

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

if r - l > 2019:
    r = l + 2019

ans = 2020
comb = combinations(range(l, r+1), 2)
for c in comb:
    ans = min(ans, (c[0]*c[1])%2019)

print(ans)

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

if r-l != c2-c1 or r - l >= 2018:
    print(0)
    exit(0)
else:
    m = 2019
    for i in range(l, r):
        for j in range(i+1, r+1):
            if (i*j)%2019 < m:
                m = (i*j)%2019
    print(m)

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


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

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

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

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

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

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

print(ans)

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

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

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

ans = 2019 ** 2

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

Solution (Python):
a,b=map(int,input().split())
ans=10000
for i in range(a,b):
    for j in range(i+1,b+1):
        if i>=2019:
            i=i%2019
        if j>=2019:
            j=j%2019
        if i==0 or j==0:
            print("0")
            exit()
        else:
            if ans>i*j%2019:
                ans=i*j%2019
print(ans)

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

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    L, R = LI()
    diff = R - L
    L %= 2019
    R = min(L + diff, R % 2019 + 2019)
    ans = inf
    for i in range(L, R):
        for j in range(L + 1, R + 1):
            ans = min(ans, (i * j) % 2019)
    print(ans)

main()

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

if r-l<673:
  if l%673 < r%673:
    for i in range(l%2019, r%2019):
      for j in range(i+1, r%2019+1):
        mod.append((i*j)%2019)
    ans = min(mod)
print(ans)

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

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

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 = float('inf')
    for i in range(L, R+1):
        for j in range(L, R+1):
            if i == j:
                continue
            ans = min(ans, (i*j)%2019)
    print(ans)

Solution (Python):
L, R = map(int, input().split())
if L // 2019 != R // 2019:
  print(0)
else:
  L, R = L % 2019, R % 2019
  if L // 673 != R // 673:
    if L // 3 != R // 3:
      print(0)
    else:
      p = 2019
      for i in range(3):
        for j in range(i+1, 3):
          if p > ((L + i) * (L + j)) % 2019:
            p = ((L + i) * (L + j)) % 2019
      print(p)
  elif L // 673 == R // 673:
    p = 2019
    for i in range(L, R + 1):
      for j in range(i+1, R + 1):
        if p > ((i % 2019) * (j % 2019)) % 2019:
          p = ((i % 2019) * (j % 2019)) % 2019
    print(p)

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


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


L %= MOD

R %= MOD
if R <= L:
    R += MOD


ans = 2**16
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 = list(map(int, input().split()))


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


L %= MOD

R %= MOD
if R <= L:
    R += MOD


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