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:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

MOD = 2019
L, R = map(int, input().split())
ans = float('inf')
if R-L <= 2020:
    for l in range(L, R):
        for r in range(l+1, R+1):
            ans = min(ans, (r*l) % MOD)
else:
    for l in range(1, MOD):
        for r in range(l+1, MOD+1):
            ans = min(ans, (r*l) % MOD)
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
s=list(map(int,input().split()))
a=int(s[0])
b=int(s[1])
list=[]
list.append(a%2019)
list.append(b%2019)
e=100000
if s[0]+2018<=s[1]:
  print(0)
else:
  if list[0]<list[1]:
    for i in range(list[0],list[1]+1):
      for j in range(list[0],list[1]+1):
        if i==j:
          continue
        else:
          d=(i*j)%2019
          e=min(d,e)
    print(e)
  else:
    print(0)

Submission status: Accepted

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

l = L//2019
r = R//2019

if((r-l >= 1)or(L%2019 == 0)or(R%2019 == 0)):
  ans = 0
  
else:
 A = []
 ans = 2018
 judge = 0
 for i in range(L,R+1):
    i = i%2019
    if(i%673 == 0): judge += 673
    if(i%3 == 0): judge += 3 
    A.append(i)

 if(judge == 673+3): #3, 673(mod 2019) あり
   ans = 0
 else: #len(A) <673 (なぜならば0~672 or 673 ~ 1346 or ...)
   A_comb = list(itertools.combinations(A,2))
   for i in range(len(A_comb)):
     tmp = list(A_comb[i])
     ans = min(ans,(tmp[0]*tmp[1])%2019)
 
print(ans)

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
if L + 2018 <= R or L%2019 > R%2019:
    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:
import sys
input = sys.stdin.readline
l,r=map(int,input().split())

if r-l>=2018:
    print(0)
else:
    ans=10*1000000
    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:
L,R = [int(i) for i in input().split()]

tmp = 2019
ans = 2019

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

print(ans)

Submission status: Accepted

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

def mod2019(x):
    return x % 2019

s = True

if r-l < 2019:
    s = False

ans = 2019*2019

if s is True:
    print(0)
else:
    for i in range(l,r+1):
        for j in range(i+1,r+1):
            kari = mod2019(i*j)
            if kari < ans:
                ans = kari
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def p_c():
    L, R = map(int, input().split())
    year = 2019

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

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

    print(ans)
    
p_c()

Submission status: Accepted

Solution code:
from sys import stdin

l,r = [int(x) for x in stdin.readline().rstrip().split()]
m = 2020
if r - l > 2018:
    print(0)
    exit()
for i in range(l,r):
    for j in range(i+1,r+1):
        if i*j%2019 == 0:
            print(0)
            exit()
        else:
            m = min(m,i*j%2019)
print(m)

Submission status: Accepted

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

Submission status: Accepted

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


if L <= 2019 & R >= 2019:
	print(0)
elif R - L <= 2019:
	list_modulus_ij_one = []

	for i in range(L, R):
		for j in range(i+1, R+1):
			i_modulus = i % 2019
			j_modulus = j % 2019
			ij_modulus = (i_modulus * j_modulus) % 2019
			list_modulus_ij_one.append(ij_modulus) 

	mini_modulus_ij_one = min(list_modulus_ij_one)
	print(mini_modulus_ij_one)
else:
	list_modulus_ij_two = []

	for i in range(L, L+2019):
		for j in range(i+1, L+2019+1):
			i_modulus = i % 2019
			j_modulus = j % 2019
			ij_modulus = (i_modulus * j_modulus) % 2019
			list_modulus_ij_two.append(ij_modulus)
	
	mini_modulus_ij_two = min(list_modulus_ij_two)
	print(mini_modulus_ij_two)

Submission status: Accepted

Solution code:
import sys
#input = sys.stdin.readline
L,R=map(int,input().split())
min_=2018
for i in range(L,R+1):
    for j in range(i+1,R+1):
        min_=min(min_,((i % 2019)*(j % 2019) % 2019))
        if min_==0:
            print(0)
            sys.exit()
print(min_)

Submission status: Accepted

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

res = 0
if R - L < 2019:
    res = min([(i % 2019 * j % 2019) for i in range(L, R + 1) for j in range(i + 1, R + 1)])
print(res % 2019)

Submission status: Accepted

Solution code:
p,q=(map(int,input().split()))
minimums=2018
if q-p>=2019:
    for i in range(p,p+2019):
        for j in range(p,p+2019):
            if i>=j:
                continue
            if i<j:
                div=(i*j)%2019
                if div<minimums:
                    minimums=div
                    
                else:
                    continue
if q-p<2019:
    for i in range(p,q+1):
        for j in range(p,q+1):
            if i>=j:
                continue
            if i<j:
                div=(i*j)%2019
                if div<minimums:
                    minimums=div
                    
                else:
                    continue
print(minimums)

Submission status: Accepted

Solution code:
import sys

L,R = list(map(int,input().split()))
ans = 2019

for i in range(L,R):
    for v in range(i+1,R+1):
        a = (i*v)%2019
        ans = min(ans,a)
        if a == 0:
            break
    else:
        continue
    break
print(ans)

Submission status: Accepted

Solution code:
L,R = map(int,input().split())
list_LR = range(L,R+1)

list_aaa =[]

ans = 2019
l=min(L+2019, R+1)

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

print(ans)

Submission status: Accepted

Solution code:
import sys
from itertools import combinations
l, r = [int(i) for i in sys.stdin.readline().split()]
flg = r - l >= 2019
l %= 2019
r %= 2019
res = 1e9
if l >= r or flg:
    print(0)
else:
    for (_l, _r) in combinations(list(range(l,r+1)), 2):
        if _l == _r:
            continue
        res = _l * _r % 2019 if _l * _r % 2019 < res else res
    print(res)

Submission status: Accepted

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

a = l % 2019
b = r % 2019

if b - a == r - l:
    min_prod = 2018*2017
    for i in range(l, r+1):
        for j in range(i+1, r+1):
            if i*j%2019 < min_prod:
                min_prod = i*j%2019
    print(min_prod)
else:
    print(0)

Submission status: Accepted

Solution code:
L,R = list(map(int,input().split()))
lt = []
if R-L == 1:
    print((L*R) % 2019)
elif R-L >= 2:
    for k in range(L,R+1):
        if k % 673 == 0:
            lt.append(0)
            break
    l = L % 673
    r = R % 673
    for i in range(l,r+1):
        for j in range(i+1,r+1):
            ans = (i*j) % 2019
            lt.append(ans)
    print(min(lt))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
l,r = map(int,input().split())
L = l%2019
R = r%2019  #2019 = 3*673
N = r-l+1

if N >= 2019 or L>R:
    print(0)
else:
    ans = l*(l+1)%2019
    for i in range(L,R):  #この時点でL<Rは決定済み
        for j in range(i+1,R+1):
            ans = min(ans,(j*i)%2019)
        if ans == 0:
            break
    print(ans)

Submission status: Accepted

Solution code:
#Remainder Minimization 2019
L,R=map(int,input().split())
l=L%2019
r=R%2019
if R-L>=2018:
    print(0)
elif r<l:
    print(0)
else:
    a=float("inf")
    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=list(map(int, input().split()))
minmod=2018
if r-l>=2018:
	print(0)
else:
	for i in range(l,r+1):
		for j in range(i+1,r+1):
			minmod=min(minmod,(i*j)%2019)
	print(minmod)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from heapq import nsmallest
l, r = map(int, input().split())

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

            if prod < ans:
                ans = prod
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007



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

Submission status: Accepted

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

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

l = l%2019
r = r%2019

if l == 0 or r == 0 :
    print(0)
    exit()

if l > r:
    r += 2019

# print(l, r)

list_score = []
for i in range(l+1, r+1):
    for j in range(l, i):
        # print(i, j)
        list_score.append(i*j%2019)
# print(list_score)
print(int(min(list_score)))

Submission status: Accepted

Solution code:
l, r = map(int, input().split())
if l - r >= 2019:
    print(0)
else:
    n = range(l, r+1)
    min_x = 2018
    for i in range(len(n)-1):
        for j in range(i+1, len(n)):
            cur_x = ((n[i]%2019)*(n[j]%2019))%2019
            min_x = min(cur_x, min_x)
            if min_x == 0:
                break
        if min_x == 0:
                break
    print(min_x)

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
Lmin = L % 2019
Rmin = R % 2019
anlis = []

if R-L >= 2018 or Lmin > Rmin:
    print(0)
    
else:
    for j in range(Lmin+1, Rmin+1):
        for i in range(Lmin, j):
            anlis.append((i * j) % 2019)
    print(min(anlis))

Submission status: Accepted

Solution code:
l,r=map(int,input().split())
a=[i%2019 for i in range(l,min(r+1,l+2020))]
ans=2018
for i in a:
    for j in a:
        if i!=j:
            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:
    tres = 2019
    for i in range(l,r):
        for j in range(i+1,r+1):
            mod = (i % 2019) * (j % 2019) % 2019
            tres = min(tres,mod)
            if tres == 0:
                break
        if tres == 0:
            break
    print(tres)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
lr=list(map(int,input().split()))
if lr[1]-lr[0]>=2019:
    print(0)
else:
    l=lr[0]%2019
    r=lr[1]%2019
    if l>r:
        print(0)
    else:
        m=2018
        for i in range(l,r+1):
            for k in range(i+1,r+1):
                if (i*k)%2019<m:
                    m=(i*k)%2019
        print(m)

Submission status: Accepted

Solution code:
l, r = [int(i) for i in input().split()]
lmod = l % 2019
rmod = r % 2019
dif = r - l
if dif >= 2019:
	print(0)
else:
	if lmod >= rmod:
		print(0)
	else:
		cand = [i for i in range(lmod, rmod + 1)]
		nc = len(cand)
		prd = []
		for i in range(nc):
			for j in range(i):
				prd.append((cand[i] * cand[j]) % 2019)
		print(min(prd))

Submission status: Accepted

Solution code:
import sys
l,r = map(int,(input().split()))
if r-l>=2018:
    print(0)
    sys.exit()

else:
    if l%2019>r%2019:
        l=l%2019
        r=r%2019+2019
    else:
        l=l%2019
        r=r%2019

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

    print(m)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if(r-l>=2019):
    ans=0
else:
    ans=(l*r)%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:
    mod = 2019
    for i in range(L, R+1):
        for j in range(i + 1, R+1):
            m = i * j % 2019
            if m < mod:
                mod = m
    print(mod)

Submission status: Accepted

Solution code:

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

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

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
left, right = map(int, input().split())
mod = 2019

min_mod = float("inf")
for i in range(left, min(right, left + mod)):
    for j in range(i + 1, min(right + 1, i + 1 + mod)):
        curr_mod = i * j % mod
        min_mod = min(min_mod, curr_mod)
        if min_mod == 0:
            break

print(min_mod)

Submission status: Accepted

Solution code:
import sys
import math
L,R = map(int, input().split())
#L,R = 2020,2040
#L,R = 4,5
#L,R = 2019,4037

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

# l_mod = L % 2019
# l_div = L // 2019
# r_mod = R % 2019
# r_div = R // 2019

# if r_div - l_div >= 1:
#     ans = 0
# else:
#     if l_mod == 0:
#         ans = 0
#     else:
#         ans = (l_mod * (l_mod + 1)) % 2019
# print(ans)

Submission status: Accepted

Solution code:
L,R=map(int,input().split())
l=L%2019
r=R%2019
if R-L>=2019:
  print(0)
else:
  minlr=min(l,r)
  maxlr=max(l,r)
  ans=2020
  for i in range(minlr,maxlr+1):
    for j in range(i+1,maxlr+1):
      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>=2018:
  print(0)
else:
  M=[]
  for i in range(L,R+1):
    M.append(i%2019)
  #print(M)
  A=[]
  for i in M:
    for j in M:
      if i!=j:
        A.append(i*j%2019)
  #print(A)
  print(min(A))

Submission status: Accepted

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


#lとrの間に2019のばいすうがあるばあい
num = 2019
while(num<2*10**9):
    if l<=num<=r:
        print(0)
        sys.exit()
    num += 2019
 


min_num  = 2020


while(l < r):
    t = 1
    while(l+t)<=r:
        
        #print(str(l)+"*"+str(l+t)+"≡"+str((l*(l+t))%2019)+"mod(2019)")
        if (l*(l+t))%2019 < min_num:
            min_num = (l*(l+t))%2019
            if min_num == 0:
                print(0)
                sys.exit()
            
        t+=1
        
    l +=1
    
print(min_num)

Submission status: Accepted

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

min = 1000000000000000000000000000

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

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

print(min)

Submission status: Accepted

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

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

Submission status: Accepted

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

  print(ans)

Submission status: Accepted

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

mod = 2019
res = 2019

if R - L < 2019:
    for i in range(L % mod, L % mod + (R - L) + 1):
        for j in range(L % mod, L % mod + (R - L) + 1):
            if i == j:
                continue
            res = min(res, ((i % mod) * (j % mod)) % mod)
else:
    res = 0

print(res)

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, r+1):
        for j in range(i+1, r+1):
            mod = divmod(i*j, 2019)[-1]
            if mod < ans:
                ans = mod
    print(ans)

Submission status: Accepted

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

if r - l >= 2019:
    ans = 0
else:
    ans = l * r % 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:
# -*- coding:utf8 -*-

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

Submission status: Accepted

Solution code:
# -*- coding:utf8 -*-

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

if R*(R-1)<2019:
  print(R*(R-1))
  exit(0)
else:
  if R == L+1:
    print((R*L)%2019)
    exit(0)
  else:
    r =673 - L % 673
    if L+r <= R:
      print("0")
      exit(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
            if ans == 0:
              break
print(ans)

Submission status: Accepted

Solution code:
def main(): 

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

    min_value = 2019

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

    print(min_value)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import math

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l,r=map(int,input().split())
for i in range(l,r+1):
    if (i % 2019) == 0:
        print(0)
        exit()
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())

ans=2020
if 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%2019)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

solve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
import heapq
 
L,R=map(int,input().split())
 
ans=2018*2017
if (R-L)>=2018:
    print("0")
else:
    l=list(range(L,R+1))
    for i in range(len(l)):
        for j in range(i+1,len(l)):
            #print(l[i],l[j],(l[i]*l[j])%2019)
            ans=min(ans,(l[i]*l[j])%2019)
            

    print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
base = 2019
l, r = map(int, input().split())
result = 2018*2017

if r - l > 2019:
    result = 0
else:
    for i in range(l, r):
        for j in range(i+1, r+1):
            tmp_r = (i * j) % base
            if tmp_r < result:
                result = tmp_r

print(result)

Submission status: Accepted

Solution code:
L,R = map(int,input().split())
# R-LはLからRまでの個数を表す
#解の最小は０であり、LからRまでに2019の倍数が存在すればよい
# R-L > 2018ならRからLに2019の倍数が出てくることになる
if R - L >= 2018:
    print(0)
else:
    ans = 2019
    #iとj=i+1でi*jmod2019の最小値を全探索
    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 module2019(m):
    if m <= 2018:
        return m
    else:
        return module2019(m%2019)

# ij = []
# for i in range(2019):
#     for j in range(i+1,2019):
#         ij += [[i,j]]

# modij = [module2019(i[0]*i[1]) for i in ij]

l,r = map(int,input().split())
d = int(r//2019)-int(l//2019)
if d >= 1:
    print(0)
else:
    mods = []
    for i in range(l%2019,r%2019 +1):
        for j in range(i+1,r%2019 +1):
            mods += [module2019(i*j)]
    print(min(mods))

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

Submission status: Accepted

Solution code:
MOD = 2019
while True:
    try:
        L, R = map(int, input().split())
        ans = 2019*2019
        if R-L <= MOD-1:
            for i in range(L, R+1):
                for j in range(i+1, R+1):
                    ans = min(ans, i*j%MOD)
            print(ans)
        else:
            print(0)
    except:
        break

Submission status: Accepted

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

def solve():
    L, R = list(map(int, input().split()))
    MOD = 2019

    ans = float("inf")
    if R-L <= MOD-1:
        for i in range(L, R+1):
            for j in range(i+1, R+1):
                ans = min(ans, i*j%MOD)
    else:
        # 必ず0をかけることになるので
        ans = 0

    print(ans)


if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
l,r = map(int, input().split())
L = l % 2019
R = r % 2019
ans = []

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
l = L % 2019
r = R % 2019
if R - L >= 673:
  print(0)
elif l > r:
  print(0)
elif l <= 672 and r >= 673:
  print(0)
elif l == 673 and r >= 675:
  print(0)
elif l <= 1344 and r >= 1346:
  print(0)
elif l <= 1346 and r >= 1347:
  print(0)
else:
  m = 2019
  for i in range(l, r):
    for j in range(i + 1, r + 1):
      m = min(i * j % 2019, m)
  print(m)