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



Sample input:
2020 2040


Sample output:
2

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

res = 2019

modL = L % 2019
div = 2019 - modL
#2019の倍数を含む場合、最小値=0
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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
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()

Submission status: Accepted

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

Submission status: Accepted

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

if R-L>2019:
    print(0)
else:
#    print(R,L)
    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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
def main():
    L, R = map(int, input().split(" "))
    if R - L >= 2019:
        # 部屋割り論法でn%2019=0なるnが存在
        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()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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())

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
MOD = 2019  # これなにげに3の倍数だからいつも見たいなMODの演算が通用しない笑
L, R = list(map(int, input().split()))

# このコーナーケースに注意
if (R - L) >= MOD:
    print(0)
    exit()

# Lをなるべく0に近づける
L %= MOD
# RをなるべくLに近づけてみる
R %= MOD
if R <= L:
    R += MOD

# print(L, R)
ans = 2**16
for i in range(L, R):  # i<jが成り立つ範囲に注意
    for j in range(i + 1, R + 1):
        ans = min(ans, (i * j) % MOD)
print(ans)

Submission status: Accepted

Solution code:
MOD = 2019  # これなにげに3の倍数だからいつも見たいなMODの演算が通用しない笑
L, R = list(map(int, input().split()))

# このコーナーケースに注意
if (R - L) >= MOD:
    print(0)
    exit()

# Lをなるべく0に近づける
L %= MOD
# RをなるべくLに近づけてみる
R %= MOD
if R <= L:
    R += MOD

# print(L, R)
ans = 114514
for i in range(L, R):  # i<jが成り立つ範囲に注意
    for j in range(i + 1, R + 1):
        ans = min(ans, (i * j) % MOD)
print(ans)

Submission status: Accepted

Solution code:
MOD = 2019  # これなにげに3の倍数だからいつも見たいなMODの演算が通用しない笑
L, R = list(map(int, input().split()))

# このコーナーケースに注意
if (R - L) >= MOD:
    print(0)
    exit()

# Lをなるべく0に近づける
L %= MOD
# RをなるべくLに近づけてみる
R %= MOD
if R <= L:
    R += MOD

# print(L, R)
ans = 2019
for i in range(L, R+1):  # i<jが成り立つ範囲に注意
    for j in range(i + 1, R + 1):
        ans = min(ans, (i * j) % MOD)
print(ans)

Submission status: Accepted

Solution code:
MOD = 2019  # これなにげに3の倍数だからいつも見たいなMODの演算が通用しない笑
L, R = list(map(int, input().split()))

# このコーナーケースに注意
if (R - L) >= MOD:
    print(0)
    exit()

# Lをなるべく0に近づける
L %= MOD
# RをなるべくLに近づけてみる
R %= MOD
if R <= L:
    R += MOD

# print(L, R)
ans = 2019
for i in range(L, R):  # i<jが成り立つ範囲に注意
    for j in range(i + 1, R + 1):
        ans = min(ans, (i * j) % MOD)
print(ans)

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc133/tasks/abc133_c
# MODって掛け算でも分解できなかったっけ？って気づけばO(n)となり終わり?
# いや、O(n)だと2*10**9なのでpythonだと間に合わない！
# mod 2019 の計算結果は2019ごとに繰り返すことに気がつくと一気に計算が少なくなる

MOD = 2019  # これなにげに3の倍数だからいつも見たいなMODの演算が通用しない笑
L, R = list(map(int, input().split()))
# このコーナーケースに注意
if (R - L) >= MOD:
    print(0)
    exit()

# Lをなるべく0に近づける
L %= 2019
# RをなるべくLに近づけてみる
R %= 2019
if R <= L:
    R += MOD

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

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
mod = 2019
mini = 2019 #最大値2019
count1 = 0

for i in range(L,R):
    count2 = 0
    for j in range(i+1, R+1):
        #if i == 3 and j == 673:
        #    print(i, j)
        #    print(i%mod,j%mod,(i % mod) * (j % mod))
        if mini > (((i % mod) * (j % mod)))%mod:
            mini = (((i % mod) * (j % mod))%mod)
        count2 += 1
        if count2 == mod:
            break
    count1 += 1
    if count1 == mod:
        break
print(mini)

Submission status: Accepted

Solution code:
l, r = map(int, input().split())
mod = 2019
lm, rm = l % mod, r % mod
if l + 2019 <= r:
    ans = 0
elif lm < rm:
    ans = 2019
    for i in range(lm, rm):
        for j in range(i+1, rm+1):
            ans = min(ans, i * j % mod)
elif lm > rm:
    ans = 2019
    for i in range(0, rm+1):
        for j in range(lm, 2019):
            ans = min(ans, i*j%mod)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def examA():
    N, A, B = LI()
    ans = min(A*N,B)
    print(ans)
    return

def examB():
    N, D = LI()
    X = [LI() for _ in range(N)]
    ans = 0
    for i,j in itertools.combinations(X,2):
        cur = 0
        for k in range(D):
            cur += (i[k]-j[k])**2
        cur **=0.5
        if cur==int(cur):
            ans +=1
    print(ans)
    return

def examC():
    L, R = LI()
    cur = []; ans = 10**9
    for i in range(L,min(2019+L,R)+1):
        if i%2019==0:
            ans = 0
            break
        else:
            cur.append(i%2019)
    if ans==0:
        print(ans)
        return
    N = len(cur)
    for i,j in itertools.combinations(cur,2):
        ans = min(ans,(i*j)%2019)
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,inf
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examC()