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:
l, r = map(int,input().split())
ans = 2018
mod = 2019
if r - l < 2018:
    for i in range(l, r):
        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]=[int(x) for x in input().split()]

ans=set()
for item in range(l,r+1):
  mod=item%2019
  if mod==0:
    print(0)
    exit()
  else:
    ans.add(mod)
    
ans=list(ans)
length=len(ans)
res=2018**2
for i in range(length-1):
  for j in range(i+1,length):
    res=min(res,(ans[i]*(ans[j]))%2019)
print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l,r= map(int, input().split())
ans=2018
if r-l>=2019:
    print(0)
else:
    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().split()))
a = L%2019
b = R%2019
ans = 30000
if R-L>=2019:
  print(0)
elif a<b:
  for i in range(a,b):
    for j in range(i+1,b+1):
    	ans = min(ans,(i*(j))%2019)
  print(ans)
elif a>=b:
  print(0)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
mod = 2019
ans = 10 ** 9 * 10

for l in range(L, min(L + mod, R) + 1):
    for r in range(l + 1, min(L + mod, R) + 1):
        ans = min(ans, (l * r) % mod)

print(ans)

Submission status: Accepted

Solution code:
from sys import exit, stderr, stdin
input = stdin.readline
def debug(var, name="hoge"):
    print(name +":" + str(type(var)) + " = " + repr(var), file=stderr)
    return


def main():
    L, R = [int(n) for n in input().split()]
    if (L//2019)<(R//2019):
        print(0)
    else:
        l = L%2019
        r = R%2019
        res = 2019**2
        for i in range(l,r+1):
            for j in range(i+1,r+1):
                res = min(res,(i*j)%2019)
        print(res)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

length = min(2019,R-L)
# 右端値はL+2019か、R-Lでよい
R = L + length

ans = 9999999999999999
for i in range(L,R+1) :
    for j in range(i+1,R+1) :
        v = (i * j) % 2019
        if (v < ans) :
            ans = v

print(ans)

Submission status: Accepted

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

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

print(mod_min)

Submission status: Accepted

Solution code:
import math
import sys
import numpy as np
from collections import defaultdict, deque, Counter 
from itertools import accumulate, product, permutations,combinations, combinations_with_replacement
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from fractions import gcd

max_value = 1000000000
min_value = -1000000000
sys.setrecursionlimit(max_value)

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

L_mod = L % 2019

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

min_value = 2200

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

print(min_value)

Submission status: Accepted

Solution code:
l, r = map(int, input().split())
nums_of_2019 = r//2019 - (l-1)//2019
if nums_of_2019 >= 2:
    print(0)
else:
    min_num = 2020
    for i in range(l,r):
        for j in range(i+1,r+1):
            min_num = min(min_num, (i*j)%2019)
    #сдайся уже
    print(min_num)

Submission status: Accepted

Solution code:
def main():
    a,b = map(int,input().split())
    if a-b+1>=2019:
        print(0)
    else:
        mini = 2020
        for i in range(a,b+1):
            for j in range(a,i):
                joke = i*j%2019
                if joke<mini:
                    mini = joke
                    if mini == 0:
                        print(0)
                        return 0
        print(mini)
main()

Submission status: Accepted

Solution code:
import sys
from math import ceil
from operator import itemgetter as get

def input():
    return sys.stdin.readline().strip()

def iinput():
    return int(input())

def finput():
    return float(input())

def tinput():
    return input().split()

def rinput():
    return map(int, tinput())

def rlinput():
    return list(rinput())

def nod(a, b):
    while b: 
        a, b = b, a % b
    return a
 
def calc(n, c, d):
    return n - n // c - n // d + n // (c * d // nod(c, d))   


def main():
    l, r = rinput()
    q = []
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            res = i * j % 2019
            q.append(res)
            if res == 0:
                print(0)
                return 0
    print(min(q))
main()

Submission status: Accepted

Solution code:

l,r = map(int,input().split())
ans = l*(l+1)
if int(l/2019) < int(r/2019):
    print(0)
else:
    for i in range(l,r):
        for j in range(i+1,r+1):
            mod = (i*j)%2019
            if mod < ans:
              ans = mod
            if ans == 0:
                break
    print(ans)

Submission status: Accepted

Solution code:
mod = 2019
# l, r = 2020, 2040
l, r = map(int, input().split())

r1, r2 = (l-1)//mod, r//mod

if r1==r2:
	c1, c2 = l%mod, r%mod
	ans = min((i*j)%mod for i in range(l, r) for j in range(i+1, r+1))
	print(min(ans, 2018))
else:
	print(0)

Submission status: Accepted

Solution code:
l, r = (int(i) for i in input().split())

if r-l > 2030: 
    print(0)
    exit()

min_mod = 10000

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

print(min_mod)

Submission status: Accepted

Solution code:
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# 初項s, 交差dのn個の数列の和
def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


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

    if R - L > 5000:
        print(0)
        return

    ans = INF
    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:
import sys
l, r = map(int, input().split())
m = 2019
min = 2019

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

Submission status: Accepted

Solution code:
l,r = map(int,input().split())
if r-l > 2017:
  print(0)
else:
  mod_min = 2019
  for i in range(l,r+1):
    for j in range(i+1,r+1):
      mod = (i*j)%2019
      if mod <= mod_min:
        mod_min = mod
      else:
        pass
  print(mod_min)

Submission status: Accepted

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

if (r-l) > 2019:
  print(0)
else:
  a = [x for x in range(l, r+1)]
  res = [i*j%2019 for i in a for j in a if i!=j]
  print(min(res))

Submission status: Accepted

Solution code:
c=list(map(int,input().split()))
l,r=c[0],c[1]
if r-l>2017:
  print(0)
else:
  ml,mr=l%2019,r%2019
  if ml>mr:
    print(0)
  else:
    mini=2019
    d=mr-ml
    for i in range(d):
      for j in range(d-i):
        if mini>(ml+i)*(ml+i+1+j)%2019:
        	mini=(ml+i)*(ml+i+1+j)%2019
    print(mini)

Submission status: Accepted

Solution code:
L, R = map(int,input().split())
r = []
if R - L >= 2018:
    print(0)
else:
    if L % 2019 == 0:
        print(0)
        exit()
    a = L // 2019
    if 2019*(a+1) <= R:
        print(0)
    else:
        inf = float('inf')
        ans = 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
L,R = map(int, input().split())
ans = 2020
for i in range(L,R+1):
	for j in range(i+1,R+1):
		if j % 2019 == 0:
			print(0)
			exit()
		if (i*j)%2019 < ans:
			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 = 2018
    for l in range(L, R+1):
        for r in range(l+1, R+1):
            t = (l * r) % 2019
            if ans > t:
                ans = t
    print(ans)

Submission status: Accepted

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

MOD = 2019
ans = 2018

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

"""
# TLEギリギリ
R = min(R, L+(2019)) # 長さを制限しても同じ2019をyoutube通りに2019*2にするとTLE
MOD = 2019
ans = 2018

for i in range(L, R): # iはLからR-1まで
    for j in range(i+1, R+1): # jはi+1からRまで
        n = (i*j)%MOD
        ans = min(n, ans)

print(ans)
"""

Submission status: Accepted

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

R = min(R, L+(2019)) # 長さを制限しても同じ
MOD = 2019
ans = 2018

for i in range(L, R): # iはLからR-1まで
    for j in range(i+1, R+1): # jはi+1からRまで
        n = (i*j)%MOD
        ans = min(n, ans)

print(ans)

Submission status: Accepted

Solution code:
import sys
import math
from copy import deepcopy
from collections import deque
sys.setrecursionlimit(20000000)


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

    ans = 200000000

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

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
l, r = map(int, input().split())
ans = 2018
if r - l + 1 >= 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)

Submission status: Accepted

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

n= 0
if r - l > 2019:
	n = l + 2019
else:
	n = r

min = 2019

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

print(min)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L, R = ( int(a) for a in input().split() )
mi = 2018
for i in range( L, R ):
    for j in range( i + 1, R + 1 ):
        mi = min( mi, ( i * j ) % 2019 )
        if mi == 0:
            print(0)
            exit()
print( mi )

Submission status: Accepted

Solution code:
l, r = map(int, input().split())
x = []
for i in range(l, r):
    for j in range(i + 1, r + 1):
        mod = i * j % 2019
        x.append(mod)
        if mod == 0:
            print(0)
            exit()
print(min(x))

Submission status: Accepted

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

if R-L<mod-1:
  a=[i%mod for i in range(L,R+1)]
  if 0 in a:
    print(0)
  else:
    an=[]
    for i in range(len(a)):
      for j in range(i+1,len(a)):
        an.append((a[i]*a[j])%mod)
    print(min(an))
else:
  print(0)

Submission status: Accepted

Solution code:
def f_c():
    l, r = map(int, input().split())

    c = 2019
    for i in range(l, r+1):
        for j in range(l, r+1):
            if i%2019 == 0 or j%2019==0:
                print(0)
                return 0
            elif i == j:
                pass
            else:
                c = min(i*j%2019, c)
    print(c)

if __name__ == "__main__":
    f_c()

Submission status: Accepted

Solution code:
#たかだか2019
#かけたら超える可能性があるのか
#問題文読み違えた
#色々ダメすぎる
#意味がわからない

l,r=input().split()
l,r=int(l),int(r)
if r-l>=2018:
    print(0)
else:
    '''
    l,r=l%2019,r%2019
    if r>l:
        print(l*(l+1))
    else:
        print(0)
    '''
    '''
    x=(l*(l+1))%2019
    for i in range(l+1,r+1):
        x=min([i*(i+1),x])%2019
        if x==0:
            break
    print(x)
    '''
    a=[i%2019 for i in range(l,r+1)]
    x=(a[0]*a[1])%2019
    for i in range(len(a)):
        for j in range(len(a)-i-1):
            x=min([x,(a[i]*a[i+1+j])%2019])
            if x==0:
                break
        if x==0:
            break
    print(x)

Submission status: Accepted

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

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

Submission status: Accepted

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


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

Submission status: Accepted

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

memoL = [False]*2019
memoR = [False]*2019

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

Submission status: Accepted

Solution code:
l, r = map(int, input().split())
x = []
for i in range(l, r):
    for j in range(i + 1, r + 1):
        mod = i * j % 2019
        x.append(mod)
        if mod == 0:
            print(0)
            exit()
print(min(x))

Submission status: Accepted

Solution code:
L,R = map(int, input().split())
c = 2018
for i in range(L,R):
  for j in range(i+1,R+1):
    c = min(c,(i*j)%2019)
    if (i*j)%2019 == 0:
      print(c)
      exit()
print(c)      
# 解説をみてから回答

Submission status: Accepted

Solution code:
L,R = map(int, input().split())
P = min(R, L+2018)
c = []
for i in range(L,P+1):
  for j in range(L,P+1):
    if i != j:
      c.append((i * j) % 2019)
print(min(c))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

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

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

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
#ABC133 C

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

l,r = LI()
if r - l >= 2019:
    print(0)
else:
    ans = inf
    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())
m=2019
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:
def main():
    l, r = map(int, input().split())
    rng = r - l
    ans = float("inf")
    if rng >= 2018:
        ans = 0
    else:
        for i in range(l, r):
            for j in range(i + 1, r + 1):
                ans = min(ans, (i * j) % 2019)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys

MOD = 2019  # type: int

def solve(L: int, R: int):
    m = L // MOD
    r = L % MOD
    L -= MOD * (m + 1) # -2019 <= L <= -1
    R -= MOD * (m + 1)
    minmod = sys.maxsize
    upperbound = min(L + MOD, R + 1)
    for i in range(L, upperbound):
        for j in range(i + 1, upperbound):
            minmod = min(minmod, (i * j) % MOD)
    for i in range(L, upperbound):
        if i + MOD <= R:
            minmod = min(minmod, (i * i) % MOD)
    print(minmod)
    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))  # type: int
    R = int(next(tokens))  # type: int
    solve(L, R)

if __name__ == '__main__':
    main()

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 > R:
    print(0)
  else:
    import heapq
    import itertools
    l=[]
    for i,j in itertools.combinations(range(L,R+1),2):
      heapq.heappush(l,(i*j)%2019)
    print(heapq.heappop(l))

Submission status: Accepted

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

ll = l % 2019
rr = r % 2019

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

Submission status: Accepted

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


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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
L, R = map(int, input().split())
end = min(R, L + 637*2)

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

Submission status: Accepted

Solution code:
l,r = map(int,input().split())
'''
for h in range(0,2):
	for i in range(l,r+1):
		if i % (2019+h) == 0:
			print(h)
			exit()
		elif i % (673+h) == 0 and (r-l)>=2:
			print(h)
			exit()
		elif i % (2019-h) == 0:
			print(h)
			exit()
		elif i % (673-h) == 0 and (r-l)>=2:
			print(h)
			exit()
'''
			
lst = []

for i in range(l,r):
	for j in range(l+1,r+1):
		if (i*j)%2019 == 0:
			print(0)
			exit()
		lst.append((i*j)%2019)

print(min(lst))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#lとrの範囲内に2019の倍数があれば、最小値は0になる
#そうでなければ、余りは0<=lの余り<=rの余りなので、小さい方から取れば良い
#lとrの商が同じ、を直接表すと、四捨五入の関係で一緒じゃなくても等しいとされることがある
#とかいう以前に、というか10桁ぐらいなら全然大丈夫で、今回問題だったのは、
#l(l+1)が最小とは限らないということ
#だから、しらみつぶししかない

l,r = map(int, input().split())
if r-l >= 2018: #ただ単に、ミスでここのが逆だっただけ？→違う
  print(0)
elif r-l==r%2019-l%2019:
  minlist = []
  for i in range(l,r+1):
    for j in range(l,r+1):
      if i!=j:
        minlist.append((i*j)%2019)
  print(min(minlist))
else:
  print(0)

Submission status: Accepted

Solution code:
import math
import copy
# import numpy as np

# ===FUNCTION===

def getInputNum():
    inputNum = int(input())
    return inputNum

def getInputListInt():
    outputoData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData

def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList

def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList

# ===CODE===

a = getInputListInt()
min = a[0]
max = a[1]

ans_max = 2019
ans = ans_max

flg = False

for i in range(min, max):
    for j in range(i+1, max+1):
        tmp = (i*j) % ans_max

        if ans > tmp:
            ans = tmp

        if ans == 0:
            flg = True
            break

    if flg:
        break

print(ans)

Submission status: Accepted

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

# max_loop = 2019 * 2 + 1
max_loop = 2019 ** 2
count = 0
ans = 2019
for i in range(L, R + 1):
    for j in range(i + 1, R + 1):
        x = (i * j) % 2019
        ans = min(ans, x)
        if ans == 0:
            print(0)
            exit()
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
a,b = map(int,input().split())
moda=np.mod(a,2019)
modb=np.mod(b,2019)
if (modb<=moda)or((b-a)>=673):
    print(0)
    exit()

num =list(range(moda,modb+1))

ans = 10000
for i,l in enumerate(num):
    if i == len(num)-1:
        break
    for r in num[i+1:]:
        ans = min(np.mod(l*r,2019),ans)
print(ans)

Submission status: Accepted

Solution code:
a=input().split(" ")
L=int(a[0])
R=int(a[1])
if R-L>=672:
    print(0)
else:
    list=[]
    for p in range(0,R-L):
        for q in range(p+1,R-L+1):
            list.append(((L+p)*(L+q))%2019)
    print(min(list))

Submission status: Accepted

Solution code:
MOD = 2019
l, r = map(int, input().split())
ldiv = l // MOD
rdiv = r // MOD

if l % 2019 == 0 or r % 2019 == 0 or rdiv - ldiv > 0:
    print(0)
else:
    queue = []

    for i in range(1, MOD):
        counter = 0
        for j in range(ldiv, rdiv + 1):
            if l <= j * MOD + i <= r:
                counter += 1
                if counter > 1:
                    break
        if counter > 1:
            queue.append(i)
            queue.append(i)
        elif counter > 0:
            queue.append(i)

    l = len(queue)
    res = float("inf")
    for i in range(l):
        for j in range(i + 1, l):
            res = min(res, (queue[i] * queue[j]) % MOD)

    print(int(res))

Submission status: Accepted

Solution code:

LR = input().split()
L = int(LR[0])
R = int(LR[1])
S = []

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

Submission status: Accepted

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


for i in range(L, R + 1):
    for k in range(i + 1, R + 1):
        if output == 0:
            break

        if output > i * k % 2019:
            output = i * k % 2019
    else:
        continue
    break

print(output)

Submission status: Accepted

Solution code:
L,R = map(int, input().split())
ans = 0
if R-L<673:
    ans = 2018
    for i in range(L,R):
        for j in range(i+1,R+1):
            tmp = i*j%2019
            ans = min(ans,tmp)

print (ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
l,r = (int(i) for i in input().split())

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

ans = 2018
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)

Submission status: Accepted

Solution code:
s = input().split() #s_1 s_2を分割して取得し、sに値を入れる

a = int(s[0])
b = int(s[1])
m = 2019

while b-a >= 2019*2:
    b-=2019

for i in range(a,b+1):
    for j in range(i+1,b+1):
        m = min((i*j)%2019 ,m)
        if m == 0: 
            break
    if m == 0:
        break

print(m)

Submission status: Accepted

Solution code:
s = input().split() #s_1 s_2を分割して取得し、sに値を入れる

a = int(s[0])
b = int(s[1])
m = 2019

for i in range(a,b+1):
    for j in range(i+1,b+1):
        m = min((i*j)%2019 ,m)
        if m == 0: 
            break
    if m == 0:
        break

print(m)

Submission status: Accepted

Solution code:
def solve(string):
    l, r = map(int, string.split())
    if r - l >= 2019:
        return "0"
    return str(min({i * j % 2019 for i in range(l, r + 1) for j in range(i+1, r + 1)}))


if __name__ == '__main__':
    print(solve(input()))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import product


def solve(string):
    l, r = map(int, string.split())
    if r - l >= 2019:
        return "0"
    return str(min([i * j % 2019 for i,j in product(range(l, r), range(l+1, r + 1))]))


if __name__ == '__main__':
    print(solve(input()))

Submission status: Accepted

Solution code:
def solve(string):
    l, r = map(int, string.split())
    if r - l >= 2019:
        return "0"
    return str(min([(i % 2019) * (j % 2019) % 2019 for i in range(l, r + 1) for j in range(i+1, r + 1)]))


if __name__ == '__main__':
    print(solve(input()))

Submission status: Accepted

Solution code:
l,r=map(int,input().split())
c=0
M=[]
for i in range(l,r+1):
    M.append(i%2019)
    c+=1
    if c>2019:
        break
n=len(M)
a=2020
for i in range(n-1):
    for j in range(i+1,n):
        a=min(a,M[i]*M[j]%2019)
print(a)

Submission status: Accepted

Solution code:
l,r=map(int,input().split())
minimum=1000000000
for i in range(l, r+1):
    for j in range(i+1,r+1):
        minimum=min(minimum,((i*j)%2019))
        if minimum==0:
            break
    if minimum ==0:
        break
print(minimum)

Submission status: Accepted

Solution code:
l,r=map(int,input().split())
if r>l+4040:
    r=l+4040
dif=r-l
minimum=1000000000
for i in range(l%2019,l%2019 + dif+1):
    for j in range(i+1,l%2019 +dif +1):
        minimum=min(minimum,((i*j)%2019))
print(minimum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#2019=3*673

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

if R-L>2019:
    print(0)
else:
    amalist = [i%2019 for i in range(L, R+1)]
    min_value=2020
    for i in range(len(amalist)-1):
        for j in range(i+1, len(amalist)):
            if (amalist[i]*amalist[j])%2019 < min_value:
                min_value = (amalist[i]*amalist[j])%2019
    print(min_value)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 10 ** 9
# (i×j)%Qを最小化する作業は、i%Qとj%Qをそれぞれ最小化する作業とは等価ではない。[2007 2018]で試すとよい
for i in range(L, min(L + 2019, R + 1)):
    for j in range(i+1, min(L + 2019, R + 1)):
        ans = min(ans, (i*j) % 2019)
        
print(ans)

Submission status: Accepted

Solution code:
l,r = map(int,input().split())
mod = 2019
line = (r // mod) * mod
if l*r < mod:
    print(l*r)
elif l < line < r:
    print(0)
else:
    ans = 0
    for i in range(l,r):
        for j in range(i+1,r+1):
            x = i * j
            x = x % mod
            if i==l and j==i+1:
                ans = x
            elif x < ans:
                ans = x
    print(ans)

Submission status: Accepted

Solution code:
ri=lambda:map(int,input().split(' '))

l,r=ri()
if r//2019 > l//2019:
  print(0)
  import sys
  sys.exit(0)
l%=2019
r%=2019
if l>r:
  print(0)
else:
  best = 2020
  for x in range(l,r+1):
    for y in range(l,r+1):
      if x!=y:
        cur = (x*y)%2019
        best=min(best,cur)
  print(best)

Submission status: Accepted

Solution code:
mod = 2019
l,r = [int(i) for i in input().split()]

minimum = 2018

for i in range(l,r):
    for j in range(l+1,r+1):
        if minimum == 0:
            break
        elif (i*j)%mod < minimum:
            minimum = (i*j)%mod
        else:
            pass      
    if minimum == 0:
        break
    
print(minimum)

Submission status: Accepted

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

Submission status: Accepted

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

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