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())
mod_n = 2019
if (mod_n) < (R - L + 1):
    R = L + mod_n

v = []
for i in range(L,R+1):
    v.append(i % mod_n)

ans = 2020
for i in range(len(v)-1):
    for j in range(i+1,len(v)):
        #print("{} {}".format(v[i],v[j]))
        mul_v = v[i] * v[j] % mod_n
        if mul_v < ans:
            #print("{} {} {} {}".format(v[i],v[j],i, j))
            ans = mul_v

print(ans)

Submission status: Accepted

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

import numpy as np
if L+2019<=R:
    ms = np.arange(2019)
else:
    ms = np.unique(np.arange(L, R+1) % 2019)

Ms = ms.reshape(-1,1)*ms.reshape(1,-1)
Ms = Ms % 2019
Ms += np.eye(Ms.shape[0], dtype=int)*2019
print(np.min(Ms))

Submission status: Accepted

Solution code:
l, r= map(int,input().split())
li=[]
ans=1000000

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

Submission status: Accepted

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

print(result)

Submission status: Accepted

Solution code:
L,R = map(int,input().split())
ans = float('inf')
for i in range(L,min(L+2019,R)):
    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(' '))
if R-L>=2019:
    print(0)
else:
    f = True
    for i in range(L,R+1):
        t = i % 2019
        if t==0:
            f = False
            break
    if f:
        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:
                    break
        print(ans)
    else:
        print(0)

Submission status: Accepted

Solution code:
L, R = map(int , input().split())
mod = 2019
ans = float('inf')
if R - L  >= 2019:
    print(0)
    exit()

for i in range(2020):
    for j in range(2020):
        if L + i > R or L + j > R or i == j:
            break
        tmp_mod = ((L + i) % mod * (L + j) % mod) % mod
        if ans > tmp_mod:
            ans = tmp_mod

print(ans)

Submission status: Accepted

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

def mfnc():
  m = 2018
  for i in range(L,R):
    for j in range(i+1,R+1):
      if i*j%2019<m:
        m = i*j%2019
  return m      

if L//2019 == R//2019:
  print(mfnc())
else:
  print(0)

Submission status: Accepted

Solution code:
L,R = map(int,input().split(" "))
remind = 2020
if L + 1 == R:
    print((R * L) % 2019)
else:
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            r = (i * j) % 2019
            if r < remind:
                remind = r
                if remind == 0:
                    print(0)
                    exit(0)
    print(remind)

Submission status: Accepted

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

if R-L>=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 itertools
L,R = map(int,input().split())
if (L+2019) < R:
  R = L+2019

ans_list=[]
for v in itertools.combinations(range(L,R+1),2):
  buf1 = v[0]%2019
  buf2 = v[1]%2019
  ans_list.append((buf1*buf2)%2019)
print(min(ans_list))

Submission status: Accepted

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

a=l%2019
b=r%2019

result=2018

if l+(2019-a)>l and l+(2019-a)<r:
  print(0)
else:
  if a>b:
    n=a
    a=b
    b=n
  for i in range(a,b):
    for j in range(i+1,b+1):
      if (i*j)%2019<result:
        result=(i*j)%2019
  print(result)

Submission status: Accepted

Solution code:

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


mod = 2019

ans = 0
if l//mod == r//mod: # !( l<= x*mod <= r)
    
    lm = min(l%mod,r%mod)
    rm = max(l%mod,r%mod)
    t = mod**2
    for i in range(lm,rm+1):
        for j in range(i+1,rm+1):
            t = min(i*j%mod,t)
    
    ans = t



print(ans)

Submission status: Accepted

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

min1 = 10000
border = 4039
ancker = 99999

'''
for i in range(L, min(R+1, L + border)) :
    if i % 2019 < min1 :
        min1 = i % 2019
        ancker = i

min2 = 100000

for i in range(L, min(R+1, L + border)) :
    if i % 2019 < min2 and i != ancker:
        min2 = i % 2019
'''

min1 = 100000

for i in range(L,  min(R+1, L + border)) :
    for j in range(i + 1, min(R+1, L + border)) :
        if (i * j) % 2019 < min1 :
            min1 = (i * j) % 2019

#ans = (min1 * min2) % 2019

print(min1)

Submission status: Accepted

Solution code:
L,R=(int(x) for x in input().split())
mod_list=[]
minimum=10000000000
index=0
flag=0
for i in range(L,R):
    for j in range(i+1,R+1):
        if((i*j)%2019==0):
            minimum=0
            flag=1
            break
        else:
            candidate=(i*j)%2019
            if(minimum>candidate):
                minimum=candidate
    if(flag==1):
        break
print(minimum)

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
counter = []
ite = 0
for i in range(L, R+1):
    counter.append(i)
    ite += 1
    if ite > 2021:
        break

kouho = 2019**2
for j in counter:
    for k in range(L, j):
        if kouho > (j * k) % 2019:
            kouho = (j*k) % 2019


print(kouho)

Submission status: Accepted

Solution code:
words = lambda t : list(map(t, input().split()))
l,r = words(int)

ml = l % 2019
mr = r % 2019

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

Submission status: Accepted

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

    r1 = L // 2019 
    r2 = R // 2019
    
    if r2 - r1 >= 1:
        return 0

    # r2 == r1
    L0 = L % 2019
    R0 = R % 2019
    range_ = range(L0, R0+1)

    out = min([ i * j % 2019 for i in range(L0, R0+1) for j in range(i+1, R0+1)])
    return out

out = main()
print(out)

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
tmp=2020
if b-a>=2019:
  print(0)
else:
  for i in range(b-a+1):
    for j in range(b-a+1):
      if i==j:
        continue
      x=a+i
      y=a+j
      if tmp>x*y%2019:
        tmp=x*y%2019
  print(tmp)

Submission status: Accepted

Solution code:
import math

l,r = [int(u) for u in input().split(" ")]

if math.floor(l/2019)<math.floor(r/2019):
  print(0)
else:
  a = []
  for i in range(l,r+1):
    p = [((i%2019)*j)%2019 for j in set([u%2019 for u in range(i+1,r+1)])]
    if len(p)>0:
      a.append(min(p))
  print(min(a))

Submission status: Accepted

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

Submission status: Accepted

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

res = 1000000007

if R - L + 1 > 2019:
    print(0)
else:
    amari = [i % 2019 for i in range(L, R + 1)]
    l = len(amari)
    for i in range(l):
        a = amari[i]
        for j in range(i + 1, l):
            b = amari[j]
            res = min(res, a * b % 2019)

    print(res)

Submission status: Accepted

Solution code:
import sys

L, R = map(int, sys.stdin.readline().split())
mod = 2019

mod_L = L%2019
mod_R = R%2019

for i in range(L + 1, R + 1):
    if i % mod == 0:
        print(0)
        sys.exit()

if R - L >= 2019:
    temp_i = mod_L
    temp_j = 2018
else:
    temp_i = mod_L
    temp_j = mod_R

min_mod = 2019
for i in range(mod_L, mod_R):
    for j in range(i + 1, mod_R + 1):
        if ((i*j)%mod) < min_mod:
            min_mod = (i*j)%mod
print(min_mod)

Submission status: Accepted

Solution code:
from itertools import combinations
L, R = map(int, input().split())
A = 2019
M = min(R+1, L+A)

a = min(i % A for i in range(L, M))
if a == 0:
    print(0)
else:
    print(min((i*j) % A for (i, j) in combinations(range(L, R+1), 2)))
    # print(min((a * (a+1)) % A, (b * (b+1)) % A))

Submission status: Accepted

Solution code:
l,r = [int(_) for _ in input().split()]
c = (r-l+1)//2019
m = 10**10
if c == 0:
    if r%2019 <= l%2019:
        print(0)
    else:
        for i in range(l%2019, r%2019):
            for j in range(i+1, r%2019+1):
                m = min(m, i*j%2019)
        print(m)
else:
    print(0)

Submission status: Accepted

Solution code:
from random import randint

def solve0(L, R):
    m = 2019
    for i in range(L, R):
        for j in range(i+1, R+1):
            t = (i*j) % 2019
            if t < m:
                m = t
                I = i
                J = j
    return I, J, m

def solve(L, R):
    M = 2019
    I = L
    mi = []
    mj = []
    for i in range(L, R+1):
        m = i % 2019 
        if m == 0:
            return 0, 0, 0
        mi.append(i)
        I = i

    for i in range(I+1, R+1):
        m = i % 2019 
        if m == 0:
            return 0, 0, 0
        mj.append(i)
    #print(mi)
    m = 2019
    for a in range(0, len(mi)):
        i = mi[a]
        for b in range(a+1, len(mi)):
            j = mi[b]
            t = (i*j)%2019 
            #print(i, j, t)
            if t < m:
                I = i
                J = j
                m = t

    return I, J, m

if 0==1:
    N = 10000
    while True:
        l = randint(0, N)
        r = randint(l+1, N)
        if solve(l,r)[-1] != solve0(l,r)[-1]:
            print("bad", l, r)
            break


def main():
    L, R =[int(x) for x in input().split()]
    answer = solve(L, R)
    #print("solve0", solve0(L, R))
    #print("solve ", answer)
    print(answer[-1])

main()

Submission status: Accepted

Solution code:
import math

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

ls = l % 2019
rs = r % 2019

dif = r // 2019 - l // 2019

#print("dif = {}".format(dif))

if (dif != 0):
    print(0)
elif (r - l == 1):
    print(ls*rs % 2019)
else:
    mini = []
    for i in range(ls, rs):
        mini.append(min(i * j % 2019 for j in range(ls + 1, rs+1)))
    print(min(mini))

Submission status: Accepted

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

if R // 2019 != L // 2019:
    print(0)
else:
    L = L % 2019
    R = R % 2019
    min_m = 1000000000000
    for i in range(L, R+1):
        for j in range(i+1, R+1):
            m = (i * j) % 2019 
            if m < min_m:
                min_m = m
    print(min_m)

Submission status: Accepted

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

diff = R//2019 - L//2019

if L % 2019 == 0:
    answer = 0
elif diff > 0:
    answer = 0
else:
    _min = 2019
    for i in range(L, R+1):
        for j in range(i+1, R+1):
            _min = min(_min, (i * j) % 2019)
    answer = _min

print(answer)

Submission status: Accepted

Solution code:
l,r  = map(int,input().split())
small = l // 2019
big = r // 2019
num = [l % 2019,r % 2019,l % 2019 + 1,r % 2019 - 1]
num.sort()
num = list(set(num))
mod = 2020
if big - small >= 1:
    print(0)
else: 
    for i in range(l % 2019,r % 2019):
        for j in range(i + 1,r % 2019 + 1):
            mod = min((i * j) % 2019,mod)
    print(mod)

Submission status: Accepted

Solution code:
import sys

l, r = map(int, input().split())
#dp = []
min = 1000000000000000000

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

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

        if min == 0:
            print(0)
            sys.exit()

#        dp.append(i * j % 2019)
#        dp.append(i * j % 18)

#dp.sort()
#print(dp[0])
print(min)

Submission status: Accepted

Solution code:
l,r = map(int,input().split())
MOD = 2019
if r - l >=2019:
    print(0)
    exit()
l %=MOD
r %=MOD
if r <= l:
    r +=2019

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


print(ans)

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
min_s = 2019
if (R - L) > 2019:
    min_s = 0
for i in range(L, R):
    for j in range(i + 1, R+1):
        ij = i * j
        m = ij % 2019
        if min_s > m:
            min_s = m
        if min_s == 0:
            break
    if min_s == 0:
        break
print("{}".format(min_s))

Submission status: Accepted

Solution code:
norg, korg = tuple([int(s) for s in input().split()])

n = norg % 2019
k = korg % 2019

min_val = 2019

if norg // 2019 == korg // 2019:
    for i in range(n, k):
        for j in range(i+1, k+1):
            if (i*j) % 2019 < min_val:
                min_val = (i*j) % 2019
else:
    min_val = 0

print(min_val)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
MOD = 2019

l, r = map(int, input().split())
ret = MOD
upperBound = min(r, l + MOD)
for i in range(l, upperBound):
    for j in range(i + 1, upperBound + 1):
        ret = min(ret, (i * j) % MOD)
print(ret)

Submission status: Accepted

Solution code:
L,R = [int(x) for x in input().split()]
tmp1 = int(L/2019)
tmp2 = int(R/2019)
diff = tmp2 - tmp1
if diff >= 1:
    print(0)
else:
    tmp3 = 0
    Min = 2018
    for i in range(L%2019,R%2019):
        for j in range(i,R%2019):
            tmp3 = (i*(j+1))%2019
            if Min > tmp3:
                Min = tmp3
    print(Min)

Submission status: Accepted

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

if R - L >= 2018:
    print(0)
else:
    if L % 2019 < R % 2019:
        modlist = list(range(L%2019 ,R%2019 +1))
    else:
        modlist = list(range(1,R % 2019 + 1)) + list(range(L % 2019, 2019))

    min_mod = 2018
    for i in range(len(modlist)):
        for j in range(len(modlist) - i - 1):
            mod = (modlist[i]*modlist[i+j+1]) % 2019
            min_mod = min(min_mod, mod)
    print(min_mod)

Submission status: Accepted

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

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

    print(min)

Submission status: Accepted

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


main()

Submission status: Accepted

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

mod = 2019
if r >= l+mod-1:
    r = l+mod-1
X = [x%mod for x in list(range(l, r+1))]

ans = mod
for i in range(len(X)):
    for j in range(i+1, len(X)):
        ans = min(ans, (X[i] * X[j])%mod)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(RM)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
if R - L + 1 == 2:
    print((R * L) % 2019)
    quit()

if R - L + 1 >= 673:
    print(0)
    quit()

for num in range(L, R + 1):
    if num % 673 == 0:
        print(0)
        quit()


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

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
ans=9999999
for i in range(a,b+1):
    for j in range(i+1,b+1):
        c=i%2019
        d=j%2019
        if (c*d)%2019==0:
            print(0)
            exit()
        elif (c*d)%2019<ans:
            ans=(c*d)%2019
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
N, M = list(map(int, input().split()))
Modulo = 2019
MAP = np.dot(np.arange(Modulo).reshape(Modulo, 1), np.arange(Modulo).reshape(1, Modulo))
MAP %= Modulo
iu2 = np.tril_indices(Modulo, k=0)
MAP[iu2] = Modulo
if M - N >= 2019:
  print(0)
else:
  fir = N % Modulo
  sec = M % Modulo
  if sec > fir:
    print(np.min(MAP[fir:sec+1, fir:sec+1]))
  elif fir > sec:
    print(min([np.min(MAP[:sec+1, :sec+1]),
               np.min(MAP[fir:Modulo, fir:Modulo]),
               np.min(MAP[:sec+1, fir:Modulo])]))

Submission status: Accepted

Solution code:
import sys

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

l = L % 2019
r = R % 2019

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

min = 2019

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

print(min)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

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

# 2019以上離れていたら0
if diff >= 2019:    
    print(0)
    sys.exit()
    
k = L / 2019
L = L % 2019
R = R % 2019

# ここまで来れば、2000 * 2000 が2secで終わるはず
min_val = 2018
for l_i in range(L, R):
    for r_i in range(l_i + 1, R + 1):
        target = l_i * r_i
        target = target % 2019

#         print(l_i, r_i)
#         print("test", target)
#         if target == 0:
#             print(l_i, r_i)

        if target < min_val:
            min_val = target

            
print(min_val)

Submission status: Accepted

Solution code:
import sys
def p(*_a):
  _s=" ".join(map(str,_a))
  #print(_s)
  sys.stderr.write(_s+"\n")
#-------------------------------------------------------------------
L,R = map(int, input().split())		# 5 7 2

mod=2019


l = L % mod
r = R % mod

b = ((R-L)>mod)
b = b or (l>=r)
if b:
	print(0)
	exit(0)


while l>r:
	r+=mod

a=0
b=0
ans=mod

p("l,r,a,b,ans",l,r,a,b,ans)

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

#a=l%mod
#b=a+1
#ans=(a*b)%mod

p("l,r,a,b,ans",l,r,a,b,ans)
print(ans%mod)

Submission status: Accepted

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

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

Submission status: Accepted

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

s = l//2019
t = r//2019

l -= 2019*s
r -= 2019*t

if s != t:
    print(0)
    exit()

ans = 10**10
for i in range(l,r+1):
    for j in range(l,r+1):
        #print(i,j,i*j)
        #print((i*j)%2019)
        if i >= j:
            continue
        ans = min(ans, (i*j)%2019)

print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
l,r = map(int, input().split())

if r < 2019:
    ans = float("inf")
    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)
elif l%2019==0 or r%2019==0:
    print(0)
elif l//2019 < r//2019:
    print(0)
else:
    ans = float("inf")
    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:
import numpy as np

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

if L // 2019 == R // 2019:
    LIST = []
    for i in range(R%2019 - L%2019+1):
        LIST.append(i+L%2019)
    LIST = np.array(LIST)
    print((np.dot(LIST.reshape(-1,1), LIST.reshape(1,-1)) % 2019 + 2019*np.tri(len(LIST), dtype=int)).min())
else:
    print(0)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

mod_list = []
min1 = 2019
min2 = 2019

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

else:
    for i in range(L, R):
        for s in range(i+1, R+1):
            if (i*s)%2019 <= min1:
                min1 = (i*s)%2019
    print(min1)

Submission status: Accepted

Solution code:
l,r = [int(i) for i in input().split()]
ans = 100000
L = min(r,l+2019)
for i in range(l,L):
    R = min(l+2019,r)
    for j in range(i+1,R+1):
        tmp = (i*j)%2019
        if(ans>tmp):
            ans = tmp
print(ans)

Submission status: Accepted

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

if r - l > 2019:
  l = 0
  r = 2018
  
def solve():
  md = 2019
  for i in range(l, r+1):
    for j in range(i+1, r+1):
      md = min((i * j) % 2019, md)
  return md

print(solve())

Submission status: Accepted

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

def gcd(m,n):
    temp=0
    while m%n!=0:
        temp=n
        n=m%n
        m=temp
    return n
def lcm(m,n):
    return m*n/gcd(m,n)


temp=[[(j*i)%2019 for i in range(j+1,min([j+2019+1,R+1]))] for j in range(L,min([L+2019+1,R]))]

#print(temp)
print(min([min(e) for e in temp]))

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
L, R = map(int,input().split())
L_mod = L%2019
if L_mod ==0:
  print(0)
else:
  R_mod = R%2019
  if R_mod ==0:
    print(0)
  else:
    if L_mod<R_mod:
      Ls = L//2019
      Rs = R//2019
      if Rs-Ls ==0:
        list =[]
        for i in range(L_mod,R_mod,1):
          mod_i = i%2019
          for j in range(i+1,R_mod+1,1):
            mod_j = j%2019
            mod = (mod_i *mod_j)%2019
            list.append(mod)

        print(min(list))
      else:
        print(0)
    else:
      print(0)

Submission status: Accepted

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

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

else:
    l = L % 2019
    r = R % 2019
    if r<l:
        print(0)
    else:
        klist = []
        for i in range(r-l):
            for j in range(r-l-i):
                k = (i+l)*(l+i+j+1)%2019
                klist.append(k)
        klist.sort()
        print(klist[0])

Submission status: Accepted

Solution code:
L,  R =  list(map(int, input().strip().split()))
l = L // 2019
r = R //2019
ans= 0
if(l == r):
    ans = 2019
    for i in range(L, R):
        for j in range(i+1, R+1):
            ans = min(ans, (i*j)%2019)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

numbers = [i for i in range(L,min(R+1,L+2019))]
ans = 2019
for conb in combinations(numbers,2):
  if ans > (conb[0]*conb[1])%2019:
     ans = (conb[0]*conb[1])%2019
    
print(ans)

Submission status: Accepted

Solution code:
L,R = map(int,input().split())
ans = 0
L_min = 10**10
L_ = L//2019
R_ = R//2019

if L_ == R_:
  ans = 10**10
  for i in range(L,R+1):
    for j in range(L,R+1):
      if i != j and ans > (i*j)%2019:
        ans = (i*j)%2019
  print(ans)
else:
  print(0)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    L, R = map(int, input().split())
    if R // 2019 > L // 2019:
        print(0)
        return
    retval = 2019
    for i in range(L, R):
        for j in range(i+1, R+1):
            retval = min(retval, (i % 2019 * j % 2019) % 2019)
    print(retval)
    return
    
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np


# なんこか入力
l,r = map(int, input().split())

if r-l >= 2019:
    r = l+2019
else:
    r = l + (r-l) % 2019

answer = 9999
for j in range(l,r+1):
    for i in range(l,j):
        a = i % 2019
        b = j % 2019
        answer = min(answer,(a*b)%2019)

print(answer)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from itertools import combinations

def main():
  l, r = map(int, input().split())

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

  l = l % 2019
  r = r % 2019
  if r <= l:
    r += 2019

  print(min([(i * j) % 2019 for i, j in combinations(range(l, r+1), 2)]))

if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
import sys

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

if L == 0:
    print(0)
    sys.exit()

temp = R // t
temp2 = L // t
kouho = []
if temp != temp2:
    print(0)
    sys.exit()
else:
    for i in range(L, R+1):
        for j in range(L, R+1):
            if i != j:
                kouho.append((i * j)%t)
    kouho.sort()
    print(kouho[0])

Submission status: Accepted

Solution code:
L, R = list(map(int, input().split()))
m = R//2019
if R-L>=2019 or (m*2019<=R and m*2019>=L):
  print(0)
else:
  l = L%2019
  r = R%2019
  min_c = 2019
  for i in range(l,r+1):
    for j in range(i+1, r+1):
      score = i*j%2019
      if i*j%2019<min_c:
        min_c = score
  print(min_c)

Submission status: Accepted

Solution code:
lm, rm = map(int, input().split())
ans = 2018

if rm-lm >= 2019:
  print(0)
else:
  for l in range(lm, rm):
    for r in range(-~lm, -~rm):
      ans = min(ans, (l*r)%2019)
  print(ans)

Submission status: Accepted

Solution code:
L, R = [int(item) for item in input().split()]
l, ml = divmod(L, 2019)
r, mr = divmod(R, 2019)
if (l==r):
  m = 2019
  for i in range(ml, mr+1):
    for j in range(i+1, mr+1):
      m = min(m, (i*j)%2019)
  print(m)
else:
  print(0)

Submission status: Accepted

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

now = [0]*2020

a = l
while a < r+1:
  now[a % 2019] = 1
  a += 1
  if now[0] == 1 or (now[3]==1 and now[673]==1):
    print 0
    exit(0)

ans = 2019*2019
for x in range(2019):
  if now[x] == 1:
    for y in range(2019):
      if now[y] == 1 and x != y:
        buf = (x*y)%2019
        if ans > buf:
          ans = buf
print ans

Submission status: Accepted

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

min = 2*1000000000

if R - L > 2019:
  R = L + 2019

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

print(min)

Submission status: Accepted

Solution code:


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

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

Submission status: Accepted

Solution code:
lr=input().split()
l=int(lr[0])
r=int(lr[1])

mod=2018
for i in range(r-l):
    x=r-l-i
    if mod==0:
        break
    for j in range(x):
        if (l+j)%2019==0 or (r-i)%2019==0:
            mod=0
            break
        else:
            a=(l+j)*(r-i)
            b=a%2019
            if b<mod:
                mod=b

print(mod)

Submission status: Accepted

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

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