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):
mod = 10 ** 9 + 7
mod2 = 2 ** 61 + 1
from collections import deque
import heapq
from bisect import bisect_left, insort_left, bisect_right

_NUMINT_ALL = list(range(10))


def main():
    ans = solve()
    if ans is not None:
        print(ans)


def solve():
    L, R = iip(False)

    if L //2019 != R //2019:
        return 0
    L %= 2019
    R %= 2019

    if L >= R or L == 0 or R == 0:
        return 0

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

    return mm % 2019





def iip(listed=True, num_only=True):
    if num_only:
        ret = [int(i) for i in input().split()]
    else:
        ret = [int(i) if i in _NUMINT_ALL else i for i in input().split()]

    if len(ret) == 1 and not listed:
        return ret[0]
    return ret


def sort_tuples(l, index):
    if isinstance(l, list):
        l.sort(key=lambda x: x[index])
        return l
    else:
        l = list(l)
        return sorted(l, key=lambda x: x[index])


def count_elements(l):
    d = {}
    for i in l:
        if i in d:
            d[i] += 1
        else:
            d[i] = 1
    return d


def safeget(l, index, default="exception"):
    if index >= len(l):
        if default == "exception":
            raise Exception("".join(["safegetに不正な値 ", index, "が渡されました。配列の長さは", len(l), "です"]))
        else:
            return default
    elif index < 0:
        if default == "exception":
            raise Exception("".join(["safegetに不正な値 ", index, "が渡されました。負の値は許可されていません"]))
        else:
            return default
    else:
        return l[index]


def iipt(l, listed=False, num_only=True):
    ret = []
    for i in range(l):
        ret.append(iip(listed=listed, num_only=num_only))
    return ret


def sortstr(s):
    return "".join(sorted(s))


def iip_ord(startcode="a"):
    if isinstance(startcode, str):
        startcode = ord(startcode)
    return [ord(i) - startcode for i in input()]


def YesNo(s):
    if s:
        print("Yes")
    else:
        print("No")


def fprint(s):
    for i in s:
        print(i)


def bitall(N):
    ret = []
    for i in range(2 ** N):
        a = []
        for j in range(N):
            a.append(i % 2)
            i //= 2
        ret.append(a)
    return ret


def split_print_space(s):
    print(" ".join([str(i) for i in s]))


def split_print_enter(s):
    print("\n".join([str(i) for i in s]))


def koenai_saidai_x_index(sorted_list, n):
    l = 0
    r = len(sorted_list)
    if len(sorted_list) == 0:
        return False
    if sorted_list[0] > n:
        return False

    while r - l > 1:
        x = (l + r) // 2
        if sorted_list[x] == n:
            return x
        elif sorted_list[x] > n:
            r = x
        else:
            l = x
    return l


def searchsorted(sorted_list, n, side="left"):
    if side not in ["right", "left"]:
        raise Exception("sideはrightかleftで指定してください")

    l = 0
    r = len(sorted_list)

    if n > sorted_list[-1]:
        
        return len(sorted_list)
    if n < sorted_list[0]:
        return 0

    while r - l > 1:
        x = (l + r) // 2
        if sorted_list[x] > n:
            r = x
        elif sorted_list[x] < n:
            l = x
        else:
            if side == "left":
                r = x
            elif side == "right":
                l = x

    if side == "left":
        if sorted_list[l] == n:
            return r - 1
        else:
            return r

    if side == "right":
        if sorted_list[l] == n:
            return l + 1
        else:
            return l


def soinsuu_bunkai(n):
    ret = []
    for i in range(2, int(n ** 0.5) + 1):
        while n % i == 0:
            n //= i
            ret.append(i)
        if i > n:
            break
    if n != 1:
        ret.append(n)
    return ret


def conbination(n, r, mod, test=False):
    if n <= 0:
        return 0
    if r == 0:
        return 1
    if r < 0:
        return 0
    if r == 1:
        return n
    ret = 1
    for i in range(n - r + 1, n + 1):
        ret *= i
        ret = ret % mod

    bunbo = 1
    for i in range(1, r + 1):
        bunbo *= i
        bunbo = bunbo % mod

    ret = (ret * inv(bunbo, mod)) % mod
    if test:
        
        pass
    return ret


def inv(n, mod):
    return power(n, mod - 2)


def power(n, p, mod_=mod):
    if p == 0:
        return 1
    if p % 2 == 0:
        return (power(n, p // 2, mod_) ** 2) % mod_
    if p % 2 == 1:
        return (n * power(n, p - 1, mod_)) % mod_


if __name__ == "__main__":
    main()

Solution (Python):
from itertools import combinations
l, r = map(int,input().split())
if r-l >= 2019:
    print(0)
else:
    min_n = float('inf')
    for i, j in combinations([k for k in range(l, r+1)], 2):
        min_n = min(min_n, (i*j)%2019)
    print(min_n)

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

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

Solution (Python):
l, r = map(int, input().split())
"""
もしl~rの範囲に2019の倍数を含むならば、2019の倍数をi,jのいずれかに設定して0を得る。
それ以外の場合、l~rの範囲は高々2019程度なので、全探索で間に合う
"""
if r//2019 - l//2019 > 0:
    print(0)
else:
    ans = 2019
    for i in range(l, r):
        for j in range(l+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 >= 2019:
     print(0)
else:
     s = l % 2019

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

Solution (Python):
DEVISOR = 2019

L, R = (int(word) for word in input().split())

if (R // DEVISOR) > (L // DEVISOR):
    print(0)
    exit()

L %= DEVISOR
R %= DEVISOR

print(min(i * j % DEVISOR for i in range(L, R) for j in range(i+1, R+1)))

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


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

print(best)

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

if 2018 <= r-l:
  ans = 0
elif r-l <= 2017:
  r_mod = r%2019
  l_mod = l%2019
  ans = 2019
  
  if l_mod < r_mod:
    for i in range(r_mod-l_mod):
      for j in range(1,r_mod-l_mod-i+1):
        temp = (l_mod+i)*(l_mod+i+j)%2019
        
        if temp < ans:
          ans = temp
      
      
  elif r_mod < l_mod:
    ans = 0
    
print(ans)

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

Solution (Python):
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect




from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7

def main():
  l, r = map(int, readline().split())
  if r-l>=2018:
    print(0)
  else:
    mod = []
    for i in range(l, r):
      for j in range(i+1, r+1):
        mod.append(i*j%2019)
    print(min(mod))
  
  
  
if __name__ == '__main__':
  main()

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

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

print(ans)

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

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

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

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

Solution (Python):

import sys

MOD = 2019  


def solve(L: int, R: int):
    if R - L >= 2019:
        return 0
    def f():
        for i in range(L, R):
            for j in range(i+1, R+1):
                yield i * j % MOD
    return min(f())



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

if __name__ == '__main__':
    main()

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

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

if R - L + 1 >= 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 (L//2019) < (R//2019) or L%2019==0 or R%2019==0:
    result = 0
else:
    result = 2018
    for i in range(L, R):
        for j in range(i+1, R+1):
            if result > (i*j)%2019:
                result = (i*j)%2019
print(result)

Solution (Python):
L, R = map(int, input().split())
MOD = 2019
INF = 10**5
ans = INF


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

Solution (Python):
L, R = map(int, input().split())
MOD = 2019
INF = 10**5
ans = INF


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

Solution (Python):
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

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

if __name__ == '__main__':
    main()

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

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

print(ans)

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

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

Solution (Python):
mtx = [[0] * 2019 for _ in range(2019)]

for i in range(len(mtx)):
    for j in range(len(mtx)):
        mtx[i][j] = (i * j) % 2019

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

min_val = 10000000

l_mod = l % 2019
r_mod = r % 2019

if r_mod < l_mod:
    r_mod += 2019

for i in range(l, r):
    for j in range(i+1 , r + 1):
        a = i % 2019
        b = j % 2019
        ret = mtx[a][b]
        min_val = min(min_val, ret)
        if min_val == 0:
            print(0)
            exit()

print(min_val)

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    
    from itertools import combinations, permutations, accumulate, groupby
    
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    

    
    

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

if __name__ == '__main__':
    main()

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

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

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

L=l%2019
R=r%2019
m=2018

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

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

print(m)

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

Solution (Python):
l,r = map(int,input().split())
dp = [0]*2019
L = []
cur = l
for i in range(r-l+1):
    t = cur%2019
    if dp[t] == 0:
        dp[t] = 1
        L.append(t)
        cur += 1
    else:
        break
ans = 10**9
for i in range(len(L)):
    for j in range(i+1, len(L)):
        ans = min(ans, (L[i]*L[j])%2019)
print(ans)

Solution (Python):
x,y=list(map(int, input().split()))

if y>x+2020:
	y=x+2020

ans=2019
for i in range (x,y+1):
	for j in range (i+1,y+1):
		if (i*j)%2019<ans:
			ans=(i*j)%2019
print(ans)

Solution (Python):
import sys

L, R = map(int, input().split())
mod = 2019
ans = []
if R-L > 3000:
    print(0)
    sys.exit()
elif R-L <= 3000:
    for i in range(L, R + 1):
        for j in range(i + 1, R + 1):
            tmp = (i * j) % mod
            ans.append(tmp)
print(min(ans))

Solution (Python):
def count_section_by_zero(data):
  count = 0
  flg = False
  start = 0
  for i, d in enumerate(data):
    if flg is False and d != 0:
      count += 1
      flg = True
      
    if d == 0:
      flg = False
  return count

def input_list():
  return list(map(int, input().split()))

def input_list_str():
  return list(map(str, input().split()))

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


def divide_two(arg):
  c = 0
  while True:
    if c >= 2:
      break
    if arg % 2 != 0:
      break
    arg //= 2
    c += 1
  return c


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

def main():
  L, R = input_list()
  ans = []
  for x in range(L, R+1):
    for y in range(x+1, R+1):
      ans.append((x*y)%2019)
      if (x*y) % 2019 == 0:
        print(0)
        exit(0)
  print(min(ans))  
import math
import fractions
import collections
import itertools
from functools import reduce
main()

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

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

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

Solution (Python):
import numpy as np
a,b = map(int, input().split())
mod = 2019
min_score = 2019

for i in range(a, b+1):
    for j in range(a, b+1):
        if i != j:
            temp = (i)*(j) %mod
            if min_score > temp:
                min_score = temp
            if min_score == 0:
                print(min_score)
                exit()

print(min_score)

Solution (Python):
import numpy as np
a,b = map(int, input().split())
mod = 2019
min_score = 2019

for i in range(a, b+1):
    for j in range(a, b+1):
        if i != j:
            temp = (i%mod)*(j%mod) %mod
            if min_score > temp:
                min_score = temp
            if min_score == 0:
                print(min_score)
                exit()

print(min_score)

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

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

Solution (Python):
L, R = map(int, input().split())
if R - L >= 2018:
    res = 0
else:
    res = 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())
m=2019
s=l%m
e=r%m
q=(r-l)//m
A=[0]*m
if s<=e:
    for i in range(m):
        if i<s or e<i:
            A[i]=q
        else:
            A[i]=q+1
else:
    for i in range(m):
        if i<=e or s<=i:
            A[i]=q+1
        else:
            A[i]=q
            
ans=m
for i in range(m):
    for j in range(m):
        if i==j:
            if A[i]>=2:
                ans=min(i*j%m,ans)
        else:
            if A[i]>0 and A[j]>0:
                ans=min(i*j%m,ans)
print(ans)

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

Solution (Python):
def main():
    from builtins import int, map, list, print
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = sys.stdin.readline
    input_list = (lambda: input().rstrip().split())
    input_number_list = (lambda: list(map(int, input_list())))

    L, R = input_number_list()
    m = float('inf')
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            m = min(m, (i * j) % 2019)
            if m == 0:
                print(0)
                exit()
    print(m)


if __name__ == '__main__':
    main()

Solution (Python):
import sys
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:
            print(0)
            sys.exit()
print(min(ans))

Solution (Python):
import sys
import math

from collections import defaultdict
from collections import deque
def load(vtype=int):
    return vtype(input().strip())
def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]
def exit():
    import sys
    sys.exit(0)
def perm_sub(li, used):
    if len(li) == len(used):
        return [deque()]
    k = []
    for i in range(len(li)):
        if i in used:
            continue
        used.add(i)
        sub_list = perm_sub(li, used)
        for sub in sub_list:
            sub.appendleft(li[i])
        k.extend(sub_list)
        used.discard(i)
    return k
def perm_li(li):
    return perm_sub(li, set())
def perm_n(n):
    return perm_sub(list(range(n)), set())
def join_i(li, sep=""):
    return sep.join([str(e) for e in li])
def li2n(li):
    n, base = 0, 1
    for i in range(len(li)-1, -1, -1):
        n += li[i] * base
        base *= 10
    return n
def sli2ili(li):
    return [int(s) for s in li] 
def prime_list(n):
    li = [i for i in range(2, n+1)]
    for i in range(len(li)):
        if li[i] >= int(math.sqrt(n)):
            break
        if li[i] == -1:
            continue
        for j in range(i+1, len(li)):
            if li[j] % li[i] == 0:
                li[j] = -1
    return [n for n in li if n != -1]
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while True:
        r = a % b
        if r == 0: return b
        a, b = b, r
def lcm(a, b):
    return int(a * b / gcd(a,b))
def all_subset(li):
    s = []
    n = len(li)
    for bit in range(0, (1<<(n+1))):
        ss = set()
        for i in range(0, n):
            if (bit & (1 << i)):
                ss.add(li[i])
        s.append(ss)
    return s
def factorial(n):
    if n == 1:
        return 1
    return n * factorial(n-1)
def mCn(m, n):
    def factorial_ntimes(m, n):
        r = 1
        while n:
            r *= m
            m -= 1
            n -= 1
        return r
    return int(factorial_ntimes(m, n) / factorial(n))

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

print(mn)

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):
import sys
input = sys.stdin.readline

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

Solution (Python):
import sys
L,R=[int(x) for x in input().strip().split()]

tmp=10**9+1
ans=10**9+1

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

Solution (Python):

import sys

MOD = 2019  


def solve(L: int, R: int):
    if L // 2019 == R // 2019:
        minL = L % 2019
        maxR = R % 2019
        ans = 2019
        for i in range(minL, maxR):
            for j in range(i + 1, maxR + 1):
                com = (i * j) % 2019
                ans = min(ans, com)
        print(ans)
    else:
        print(0)
    return



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

if __name__ == '__main__':
    main()

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



l=(L//2019, L%2019)
r=(R//2019, R%2019)

if l[0] != r[0]:
    print(0)
else:
    lst = []
    bottom=min(l[1], r[1])
    up=max(l[1], r[1])
    for i in range(bottom,up):
        for j in range(i + 1, up+1):
            lst.append((i * j) % 2019)
    print(min(lst))

Solution (Python):

import sys

MOD = 2019  


def solve(L: int, R: int):
    LmM = L % MOD
    minimum = L - LmM + MOD
    if minimum < R:
        print(str(0))
    else:
        result = 10**16
        for i in range(L, R+1):
            for j in range(i+1, R+1):
                result = min(result, i*j % MOD)
        print(result)



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


if __name__ == '__main__':
    main()

Solution (Python):
import math
import collections
from operator import mul
from functools import reduce

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

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

L%=2019
R%=2019

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


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

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

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

mod = 2019

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

print(ans)

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

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

if r-l >= 672:
    m = 0
else:
    m = 10000000000000000
    cnt_i = 0
    for i in range(l,r+1):
        cnt_j = 0
        if cnt_i == 2019:
            break
        cnt_i += 1
        for j in range(i+1,r+1):
            if cnt_j == 2019:
                break
            cnt_j += 1
            m = min(m,i%2019*j%2019)
print(m)

Solution (Python):

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

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

if R - L >= 672:
    ans = 0
else:
    ans = 2018
    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 = [int(x) for x in input().split()]

if R - L >= 2018:
    ans = 0
else:
    ans = 2018
    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 = [int(x) for x in input().split()]

if R - L >= 2018:
    ans = 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

ans=2019

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

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

print(min)

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

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

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(res,(i*j)%2019)
  print(res)

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

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

mn = 4038

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

Solution (Python):












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

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

ans = temp
print(ans)

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

Solution (Python):
low,high = list(map(int,input().split()))
min_number = 2018
for i in range(low,high):
    for j in range(i+1,high+1):
        A = i * j % 2019
        if A < min_number:
            min_number = A
        if min_number == 0:
            print(0)
            exit()
print(min_number)

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

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

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

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

Solution (Python):
import sys
from heapq import heappush, heappop


def main():
    l,r=map(int,input().split())
    if r-l>=2019:
        print(0)
    else:
        ans=[]
        for i in range(l,r):
            for j in range(i+1,r+1):
                ans.append((i*j)%2019)
        ans.sort()
        print(ans[0])

if __name__ == '__main__':
    main()

Solution (Python):








def resolve():
    L,R=map(int,input().split())
    if R-L<2018:
        print(min([(i*j)%2019 for i in range(L,R) \
                   for j in range(i+1, R+1)]))
    else:
        print(0)

resolve()