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:
#2019は3と673で割り切れることを考慮する必要がある(重要)
#入力。範囲指定
L, R = list(map(int,input().split()))
#解を仮に無限大と置いておく
ans = float('inf')
"""
mod(x)とし、i = y1 * x + b, j = y2 * x + cなどと置くと i * j で xで括れない項は
b*c(余り同士の)掛け算のみ。
"""
#LとRの2019で割った時の余りは求めておく。
l = L % 2019
r = R % 2019
#LとRで挟まれる領域が十分に広い(673以上の)場合絶対に解は0(動ける範囲制限)
if R - L >= 673:
  ans = 0
  print(ans)
  exit(0)
#LとRで挟まれる範囲内に3で割り切れる要素と673で割り切れる要素が同時に存在したら解は0
#判定用変数
flag1 = 0 
flag2 = 0
#LとRで挟まれるリスト作製
list = [i for i in range(L,R+1)]
for i in range(len(list)):
  #3で割り切れるか判定
  if list[i] % 3 == 0:
    flag1 += 1
  #673で割り切れるか判定,3で割り切れていても判定するようにelifではなくifを使う
  if list[i] % 673 == 0:
    flag2 += 1
#両方満たしていたら解が0になる
if flag1 * flag2 != 0:
  ans = 0
  print(ans)
  exit(0)
#LとRの間に2019の倍数の壁がある=2019で割って余りが0になるタイミングがある
if l > r:
  ans = 0
  print(ans)
  exit(0)
#ここまで候補削ったらあとは全探索でもできる(と思われる)
#最小値をansと置く
ans = float('inf')
for i in range(l,r):
  for j in range(l+1,r+1):
    if ans > (i * j) % 2019:
      ans = (i * j) % 2019
print(ans)

Submission status: Accepted

Solution code:
#2019は3と673で割り切れることを考慮する必要がある(重要)
#入力。範囲指定
L, R = list(map(int,input().split()))
#解を仮に無限大と置いておく
ans = 150
#ans = float('inf')
"""
mod(x)とし、i = y1 * x + b, j = y2 * x + cなどと置くと i * j で xで括れない項は
b*c(余り同士の)掛け算のみ。
"""
#LとRの2019で割った時の余りは求めておく。
l = L % 2019
r = R % 2019
#LとRで挟まれる領域が十分に広い(673以上の)場合絶対に解は0(動ける範囲制限)
if R - L >= 673:
  ans = 0
  print(ans)
  exit(0)
#LとRで挟まれる範囲内に3で割り切れる要素と673で割り切れる要素が同時に存在したら解は0
#判定用変数
flag1 = 0 
flag2 = 0
#LとRで挟まれるリスト作製
list = [i for i in range(L,R+1)]
for i in range(len(list)):
  #3で割り切れるか判定
  if list[i] % 3 == 0:
    flag1 += 1
  #673で割り切れるか判定,3で割り切れていても判定するようにelifではなくifを使う
  if list[i] % 673 == 0:
    flag2 += 1
#両方満たしていたら解が0になる
if flag1 * flag2 != 0:
  ans = 0
  print(ans)
  exit(0)
#LとRの間に2019の倍数の壁がある=2019で割って余りが0になるタイミングがある
if l > r:
  ans = 0
  print(ans)
  exit(0)
#ここまで候補削ったらあとは全探索でもできる(と思われる)
#最小値をansと置く
ans = float('inf')
for i in range(l,r):
  for j in range(l+1,r+1):
    if ans > (i * j) % 2019:
      ans = (i * j) % 2019
print(ans)

Submission status: Accepted

Solution code:
#2019は3と673で割り切れることを考慮する必要がある(重要)
#入力。範囲指定
L, R = list(map(int,input().split()))
#解を仮に無限大と置いておく
ans = 150
#ans = float('inf')
"""
mod(x)とし、i = y1 * x + b, j = y2 * x + cなどと置くと i * j で xで括れない項は
b*c(余り同士の)掛け算のみ。
"""
#LとRの2019で割った時の余りは求めておく。
l = L % 2019
r = R % 2019
#余りの掛け算
lr = l * r
#(l*r) mod 2019  は次の式で表される。
modlr = lr - (lr//2019)
#2019未満で取りうる数値の中間地点
mid = (2019-1)//2
#LとRで挟まれる領域が十分に広い(673以上の)場合絶対に解は0(動ける範囲制限)
if R - L >= 673:
  ans = 0
  print(ans)
  exit(0)
#LとRで挟まれる範囲内に3で割り切れる要素と673で割り切れる要素が同時に存在したら解は0
#判定用変数
flag1 = 0 
flag2 = 0
#LとRで挟まれるリスト作製
list = [i for i in range(L,R+1)]
for i in range(len(list)):
  #3で割り切れるか判定
  if list[i] % 3 == 0:
    flag1 += 1
  #673で割り切れるか判定,3で割り切れていても判定するようにelifではなくifを使う
  if list[i] % 673 == 0:
    flag2 += 1
#両方満たしていたら解が0になる
if flag1 * flag2 != 0:
  ans = 0
  print(ans)
  exit(0)
#LとRの間に2019の倍数の壁がある=2019で割って余りが0になるタイミングがある
if l > r:
  ans = 0
  print(ans)
  exit(0)
#ここまで候補削ったらあとは全探索でもできる(と思われる)
#最小値をminと置く
ans = float('inf')
for i in range(l,r):
  for j in range(l+1,r+1):
    if ans > (i * j) % 2019:
      ans = (i * j) % 2019
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from collections import deque
def main():
    L, R = map(int, input().split())
    ans = 2019
    if R - L >= 2019:
        for i in range(L,L+2019):
            for j in range(L+1,L+2020):
                mod = i*j%2019
                ans = min(ans, mod)
    else:
        for i in range(L,R):
            for j in range(L+1,R+1):
                mod = i*j%2019
                ans = min(ans, mod)
    print(ans) 

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l, r = map(int, input().split())
if r - l > 2030: print(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)

Submission status: Accepted

Solution code:
l, r = map(int, input().split())
if r - l > 2030:
    print(0)
    exit()
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 = [int(i) for i in input().split()]
min_mod = (L * R) % 2019 

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
l, r = map(int, input().split())
z = 2020
for x in range(l, r + 1):
    for y in range(x + 1, r + 1):
        z = min(z, (x * y) % 2019)
        if z == 0:
            print(0)
            exit(0)
print(z)

Submission status: Accepted

Solution code:


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

print(ans)

Submission status: Accepted

Solution code:
L,R = map(int,input().split())
mi = 2018
break_loop = False
for i in range(R-L):
  for j in range(R-L):
    mi = min(mi,(L+i)*(L+j+1)%2019)
    if mi == 0:
       break_loop = True
       break
  if break_loop:
    break
print(mi)

Submission status: Accepted

Solution code:
from sys import exit
l,r=map(int,input().split())
res=10000000000000
for i in range(l,r):
	for j in range(i+1,r+1):
		a=(i*j)%2019
		if a==0:
			print("0")
			exit()
		else:
			res=min(res,a)
print(res)

Submission status: Accepted

Solution code:
from sys import exit
l,r=map(int,input().split())
res=1000000000000
if r-l>2020:
	print("0")
	exit()
else:
	for i in range(l%2019,r%2019):
		for j in range(i+1,r%2019+1):
			res=min(res,(i*j)%2019)
print(res)

Submission status: Accepted

Solution code:
M = 2019

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

if R-L >= M or L%M >= R%M:
    ans = 0
else:
    ans = M
    L, R = L%M, R%M
    for i in range(L, R+1):
        for j in range(i+1, R+1):
            ans = min(ans, (i*j)%M)

print(ans)

Submission status: Accepted

Solution code:
import sys
L,R=map(int, sys.stdin.readline().split())
sho1=L/2019
sho2=R/2019
if 1<=sho2-sho1:
    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:
from itertools import combinations
L,R = (int(x) for x in input().split())
ans = 2018
if (R-L) // 2018 >= 1:
    print('0')
else:
    for x in combinations(range(L,R+1),2):
        ans = min(ans,x[0]*x[1]%2019)
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

def myAnswer(L:int,R:int) -> int:
   ans = []
   for i in range(L,R):
      for j in range(L+1,R+1):
         if(i * j)% 2019 == 0:
            return 0
         ans.append((i * j) % 2019)
   return min(ans)

def modelAnswer():
   return
def main():
   L,R = map(int,input().split())
   print(myAnswer(L,R))
if __name__ == '__main__':
   main()

Submission status: Accepted

Solution code:
import sys
L,R=map(int, sys.stdin.readline().split())
sho1=(L-1)/2019
sho2=R/2019
if 1<=sho2-sho1:
    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:
r,l=map(int,input().split())
if l-r>=2019:
  print(0)
else:
  min1=100000
  for i in range(r,l):
    for j in range(i+1,l+1):
      min1=min(min1,(i*j)%2019)
  print(min1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
import sys
def rem(i,j):
    return (i*j)%2019
l, r = map(int, input().split())
cnt=2018
if (r - l >= 2019):
    print(0)
    sys.exit()
else:
    for i in range(l, r+1):
        for j in range(i + 1, r+1):
            cnt = min(rem(i, j), cnt)
if (r - l == 1):
    cnt=min(cnt,r*l%2019)
print(cnt)

Submission status: Accepted

Solution code:
import math
import sys

l, r = map(int, sys.stdin.readline().rstrip().split())

if math.ceil(l / 2019) * 2019 <= r:
    print(0)
else:
    # print(l * (l + 1) % 2019)
    ans = 2019
    for i in range(l, r+1):
        for j in range(i + 1, r+1):
            if ans > (i * j) % 2019:
                ans = (i * j) % 2019
    print(ans)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    l, r = map(int, input().split())
    if r - l >= 2018:
        print(0)
    else:
        ll = l % 2019
        rr = r - l + ll
        ans = 2019
        for i in range(ll, rr):
            for j in range(i + 1, rr + 1):
                ans = min(ans, i * j % 2019)
        print(ans)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    l, r = map(int, input().split())
    if r - l >= 2018:
        print(0)
    else:
        ll = l % 2019
        rr = r - l + ll
        ans = 2019
        for i in range(ll, rr):
            for j in range(i + 1, rr + 1):
                ans = min(ans, i * j % 2019)
        print(ans)

Submission status: Accepted

Solution code:
l, r = map(int, input().split())
mod = 2019
l_n = l//mod
r_n = r//mod
ans = float("inf")
if l_n == r_n:
    for i in range(l, r):
        for j in range(i+1, r+1):
            if ans >= i*j % mod:
                ans = i*j % mod
    print(ans % mod)
elif l_n < r_n:
    print(0)

Submission status: Accepted

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

if R - L > 2030:
    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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
ml = L // 2019
mr = R // 2019

for i in range(ml, mr+1):
  if L <= 2019 * i <= R:
    print(0)
    exit()

L %= 2019
R %= 2019
ans = float('inf')
if L > R:
  L, R = R, L
elif L == R:
  R += 2019
if L == 0 or R == 0:
  print(0)
  exit()

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())
ans = 10**10

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

Submission status: Accepted

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

ans=2020

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:
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))
# map(int, input().split())
# int(input())
# input().split()
# mojiretu = ','.join(str_list)
# sorted(input())

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

Submission status: Accepted

Solution code:
def main():
	l ,r = map(int,input().split())
	if (l-1)//2019 != r//2019:
		print("0")
		return 
	else:
		l = l%2019
		r = r%2019
		ans = 2018
		for i in range(l,r+1):
			for j in range(i+1,r+1):
				ans = min((i*j)%2019,ans)
		print(ans)
	return
main()

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
l, r = map(int, input().split())
d = [0]*2019
ans = 2019

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

print(ans)

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):
        ans = min(i*j%2019, ans)
        if ans == 0:
            print(ans)
            exit()

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/local/bin python
# -*- coding: utf-8 -*-
#
# ~/PycharmProjects/atcoder/C-RemainderMinimization.py
#
l, r = map(int, input().split())
i_range_min = l
i_range_max = min(l + 2020, r)
# j_range_min = i + 1
# j_range_max = min((i + 1) + 2020, r)
min_mod = (l * r) % 2019

for i in range(i_range_min, i_range_max):
    j_range_min = i + 1
    j_range_max = min((i + 1) + 2020, r + 1)
    for j in range(j_range_min, j_range_max):
        ij_mod = (i * j) % 2019
        # print("i, j : {} {}".format(i, j))
        # print("ij_mod {}".format(ij_mod))
        if ij_mod < min_mod:
            min_mod = ij_mod
        if min_mod == 0:
            break
    else:
        continue
    break


print(min_mod)

Submission status: Accepted

Solution code:
L,R=map(int, input().split())
#2019の倍数が入っていれば０→R-Lが２０１９以上
if R-L>=2019:
    print(0)
    exit()

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

Submission status: Accepted

Solution code:
# C - Remainder Minimization 2019
import numpy as np

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import os
import math
import string

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    L, R = il()
    ret = 2019
    for i in range(L, R + 1):
        for j in range(i + 1, R + 1):
            ret = min(ret, (i * j) % 2019)
            if ret == 0:
                break
        else:
            continue
        break

    print(ret)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

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

    if ans == 0:
        break

print(ans)

Submission status: Accepted

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

s = list(map(int, range(L, min(L+2019, R+1))))
if 2019 in s:
    print(0)
    exit()

for i in s:
    for j in s[s.index(i)+1:]:
        ans = min(ans, i*j%2019)

print(ans)

Submission status: Accepted

Solution code:
MOD = 2019
l, r = map(int, input().split())
if r - l > MOD:
    print(0)
else:
    mods = sorted([item % MOD for item in range(l, r+1)])
    n = len(mods)
    ans = MOD
    for i in range(n):
        for j in range(i+1, n):
            if mods[i] * mods[j] % MOD < ans:
                ans = mods[i] * mods[j] % MOD
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

if r - l >= 2019:
    a = 0
    b = 2019
else:
    a = l % 2019
    temp = r % 2019
    b = temp if a < temp else temp + 2019

ans = 2019
for i in range(a, b):
    for j in range(i + 1, b + 1):
        temp = (i * j) % 2019
        if temp < ans:
            ans = temp
            if ans == 0:
                print(0)
                exit()
print(ans)

Submission status: Accepted

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

if r - l >= 2019:
    skip_flag = [False] * 2019
else:
    a = l % 2019
    temp = r % 2019
    b = temp if temp > a else temp + 2019
    skip_flag = [True] * 2019
    for i in range(a, b + 1):
        skip_flag[i % 2019] = False

if not skip_flag[0]:
    print(0)
    exit()

ans = 2019
for i in range(1, 2019):
    if skip_flag[i]:
        continue
    for j in range(i + 1, 2019):
        if skip_flag[j]:
            continue
        
        temp = (i * j) % 2019
        if temp < ans:
            ans = temp
print(ans)

Submission status: Accepted

Solution code:
import numpy as np
L,R = (int(x) for x in input().split())

if R - L > 3000:
  print(0)
  exit()
  
x = np.arange(L,R+1,dtype=np.int64)
y = x[:,None] * x[None,:] % 2019
for i in range(len(x)):
  y[i,i] = 3000
answer = y.min()
print(answer)

Submission status: Accepted

Solution code:
l, r = (int(_) for _ in input().split())
r = min(r,l+2019)
x = [i*ii%2019 for i in range(l,r+1) for ii in range(i+1,r+1)]
print(min(x))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
L,R = map(int, input().split())
if R-L > 2017:
    print(0)
    exit()
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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
l, r = map(int, input().split())

r = min(r, l+673)
ans = 2018

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

print(ans)

Submission status: Accepted

Solution code:
import sys

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

x=int(r/2019)

if l<=(2019*x) and (2019*x)<=r:
  print("0")
  sys.exit()

m=-1

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

    a=(i*j)%2019
    if a==0:
      #print("here")
      print(a)
      sys.exit()

    elif m==-1 or m>a:
      #print(i,j,(i*j)%2019)
      m=a

print(m)

Submission status: Accepted

Solution code:
l,r=map(int,input().split())
if r-l+1>=2019:
  print(0)
  exit()
else:
  l=l%2019
  r=r%2019
  
  if l>=r:
    print(0)
    exit()
ans=10000000
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+1>=2019:
  print(0)
  exit()
else:
  l=l%2019
  r=r%2019  
  if l>=r:
    print(0)
    exit()
    
ans=10000000
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+1>=2019:
  print(0)
  exit()
else:
  l=l%2019
  r=r%2019
  
  if l>=r:
    r+=2019
ans=10000000
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
if r - l >= 673:
    print(0)
else:
    ans = 2018
    for i in range(l, r):
        for j in range(i+1, r+1):
            ans = min(ans, (i*j)%m)
        if ans <= 2:
            break
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Wed Apr 22 00:26:09 2020

@author: Kanaru Sato
"""

l,r = list(map(int, input().split()))
mod = 2019

if l//mod != r//mod:
    ans = 0
else:
    ans = 10000
    for i in range(l,r+1):
        for j in range(i+1,r+1):
            tmp = (i*j)%mod
            if tmp < ans:
                ans = tmp

print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1

L, R = map(int, input().split())
if (R - L) > 3000:
    print(0)
    exit()
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:
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n, a, b = LI()
    print(min(n * a, b))
    return

#B
def B():
    n, d = LI()
    x = LIR(n)
    a = list(itertools.combinations(range(n), 2))
    ans = 0
    for a1,a2 in a:
        b = 0
        for bi in range(d):
            b += (x[a1][bi] - x[a2][bi])** 2
        if float.is_integer(math.sqrt(b)):
            ans += 1
    print(ans)
    return

#C
def C():
    l, r = LI()
    ans = 2018
    if l // 2019 == r // 2019:
        for i in range(l, r + 1):
            for k in range(i+1, r + 1):
                ans = min(ans, (i * k) % 2019)
        print(ans)
    else:
        print(0)
    return

#D
def D():
    n = II()
    a = LI()
    a = a + [a[0]]
    ans = [0] * n
    x = 0
    for i in range(1, n, 2):
        x = x + a[i + 1] - a[i]
    ans[1] = a[0] - x
    ans[0] = ans[1] + 2 * x
    for i in range(2, n):
        ans[i] = (a[i - 1] - ans[i - 1] // 2) * 2
    print(" ".join(map(str, ans)))

    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    C()

Submission status: Accepted

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

MOD = 2019
r = min(r, l + MOD - 1)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l, r = list(map(int, input().split()))
# b = list(map(int, input().split()))
# 2019=3*673
ans = 2019
for i in range(l, r+1):
    for j in range(i+1, r+1):
        if (i*j) % 2019 == 0:
            print(0)
            exit()
        else:
            if (i*j) % 2019 < ans:
                ans = (i*j) % 2019

print(ans)

Submission status: Accepted

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

if L%2019==0 or R%2019==0 or L//2019!=R//2019:
    print(0)
else:
    mn=L*R % 2019
    for i in range(L,R):
        for j in range(i+1,R+1):
            mn=min(mn,i*j % 2019)
    print(mn)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
r = L + min(2019, R - L)
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:
import sys
sys.setrecursionlimit(10 ** 6)

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

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

    L %= 2019
    R %= 2019
    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)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

L_q = L // 2019
R_q = R // 2019
mod = 2018

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

    print(mod)

else:
    if R_q - L_q > 1:
        print(0)

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

        print(mod)

Submission status: Accepted

Solution code:
# solution
import io
import math

nim, mike = map(int, input().split())
if mike // 3 > (nim - 1) // 3 and mike // 673 > (nim - 1) // 673:
    print(0)
else:
    print(min(i * j % 2019 for i in range(nim, mike + 1) for j in range(nim, i)))