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())
L1 = 0
R0 = 0
ans = 2019
if R - L >= 2018 or L % 2019 > R % 2019:
    ans = 0
else:
    L = L % 2019
    R = R % 2019

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

print(ans)

Submission status: Accepted

Solution code:
l,r = map(int,input().split())
setA = set()
num = r
for i in range(l,r):
    for j in range(i+1,r+1):
        next = (i*j)%2019
        if next not in setA:
            setA.add(next)
            if next ==0:
                print(0)
                exit()
        else:
            if len(setA)==2019:
                print(min(setA))
                exit()
# print(setA)
print(min(setA))

Submission status: Accepted

Solution code:
lr = [int(i) for i in input().split()]
res = []
for i in range(lr[0], lr[1]+1):
    for j in range(i+1, lr[1]+1):
        tmp = (i*j) % 2019
        if tmp == 0:
            print(0)
            exit()
        res.append(tmp)
print(min(res))

Submission status: Accepted

Solution code:
l,r=map(int,input().split())
if r-l>2019:
    print(0)
    exit()
lst=[]
for i in range(l,l+min(4038,r-l+1)):
    lst.append(i%2019)
ans=2018
for i in range(len(lst)-1):
    for j in range(i+1,len(lst)):
        tmp=lst[i]*lst[j]%2019
        if tmp<ans:ans=tmp
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
l, r = map(int, input().split())
if r - l >= 2019:
    print(0)
    exit()
m = 1e9
for i in range(l, r + 1):
    for j in range(i + 1, r + 1):
        m = min(m, i * j % 2019)
print(m)

Submission status: Accepted

Solution code:
L,R=map(int,input().split())
if R-L>=2019:
  ans=0
else:
  ans=2020
  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:
import numpy as np
import itertools
l, r = map(int, input().split())
if r-l>=2019:
  arr = np.arange(l,l+2019,1)
else:
  arr = np.arange(l,r+1,1)
lst = []
flag = True
for i in list(itertools.combinations(arr,2)):
  a = i[0]*i[1]%2019
  if a==0:
    print(0)
    flag = False
    break
  else:
    lst.append(i[0]*i[1]%2019)
if flag:
  print(min(lst))
else:
  None

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

a = l % 2019
b = r % 2019
tmp = 2018

if abs(l-r) >= 2019*2:
    print(0)
elif abs(l-r) >= 2019:
    print(min(a,b))
else:
    tmp = 2018
    for i in range(min(a,b),max(a,b)+1):
        for j in range(i+1,max(a,b)+1):
            tmp = min((i*j)%2019, tmp)
    print(tmp)

Submission status: Accepted

Solution code:
L, R = (int(x) for x in input().split())
l, r = L%2019, R%2019
if l >= r or (R-L)>= 2019:
    print(0)
else:
    tmp = (l*r)%2019
    for i in range(l, r):
        for j in range(i+1, r+1):
            if (i*j)%2019 < tmp:
                tmp = (i*j)%2019

    print(tmp)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

output = 2019
if r - l < 2018:
    for i in range(l, r+1):
        for j in range(l, r+1):
            if i < j:
                value = ((i%2019) * (j%2019)) % 2019
                if value < output:
                    output = value
else:
    output = 0

print (output)

Submission status: Accepted

Solution code:
a,b=map(int,input().split())


amari=[(a*(a+1)%2019)]
for i in range(a,b):
    for j in range(i+1,b+1):
        x=i%2019
        y=j%2019
        if x==0 or y==0:
            print(0)
            exit()
        elif (x*y)%2019<amari[-1]:
            amari.append((x*y)%2019)

print(amari[-1])

Submission status: Accepted

Solution code:
I,J=map(int,input().split())

i=I%2019
j=J%2019

cal=10000

#print(i,j)

if i >= j or I+2019<=J:
    print(0)
elif j<46:
    print(i*(i+1))
else:
    for a in range(j-i):
        for b in range(j-i-a):
            cal=min(cal,((i+a)*(i+a+b+1)%2019))
            #print(i+a,i+a+b+1,cal)
        if cal==0:
            break
        
    print(cal)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

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

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


elif l // 2019 != r // 2019:
    ans = 0
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 2018
def f(a,b):
    while a > 2019:
        a = a % 2019
    while b > 2019:
        b = b % 2019 
    return (a*b) % 2019 

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

Submission status: Accepted

Solution code:
from collections import defaultdict


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


def candidates():
    cand = defaultdict(list)
    for i in range(1, 2019):
        for j in range(i + 1, 2019):
            cand[(i*j) % 2019].append((i, j))

    return cand


def check_in_range(l, r, x):
    if r - l > 2019:
        return True

    base = (l // 2019) * 2019

    test = base + x
    while base <= r:
        if l <= test <= r:
            return True
        base += 2019
        test = base + x

    return False


def submit():
    l, r = read_input()

    cands = candidates()
    for i in range(2019):
        cand = cands[i]

        for c in cand:
            if check_in_range(l, r, c[0]) and check_in_range(l, r, c[1]):
                print(i)
                return







if __name__ == '__main__':
    submit()

Submission status: Accepted

Solution code:
import sys

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

def main(): 
    # 2019 = 3* 673
    L, R = LI()

    if (R//673 - (L-1)//673 > 0) and (R//3 - (L-1)//3 > 0):  # 範囲内に 673の倍数も3の倍数もある。
        print(0)
        return
    else: # 範囲は 673 よりも狭いので全探索してもいける。
        minimum = INF
        import itertools
        for x, y in itertools.combinations(range(L, R+1), 2):
            minimum = min((x*y)%2019, minimum)
        print(minimum)
        return


main()

Submission status: Accepted

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

if r-l >= 2018:
    print(0)
else:
    cand = []
    ans = float("inf")
    for i in range(l,r+1):
        cand.append(i%2019)
    cand = sorted(cand)
    for i in range(len(cand)):
        for j in range(i+1,len(cand)):
            ans = min(ans,cand[i]*cand[j]%2019)
    print(ans)

Submission status: Accepted

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

diff = R - L
diff = min(diff,2019)

ans = 2019

for l in range(L,L+diff):
    for r in range(l+1,l+diff+1):
        if r > R or l > R:
            break
        ans = min(ans,(l*r)%2019)
print(ans)

Submission status: Accepted

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

MOD = 2019
ub = max(R % MOD, L % MOD)
lb = min(R % MOD, L % MOD)

if ub == lb or R // MOD != L // MOD:
    print(0)
    exit()

ans = float('inf')
for i in range(lb, ub + 1):
    for j in range(i + 1, ub + 1):
        ans = min(ans, i * j % MOD)
print(ans)

Submission status: Accepted

Solution code:
L,R = map(int, input().split())
Smin=2019
Lo=L%2019
Ro=R-(L-Lo)
if Ro>=2019:
    Smin=0
if Ro<2019:
    for x in range(Lo,Ro):
        for y in range(x+1,Ro+1):
            Sa=x*y
            S=Sa%2019
            if Smin>S:
                Smin=S
print(Smin)

Submission status: Accepted

Solution code:
mod=2019

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

l_shou=l//mod
r_shou=r//mod

l_amari=l%mod
r_amari=r%mod


maxi=max(l_amari, r_amari)
mini=min(l_amari, r_amari)

if l_shou!=r_shou:
    print(0)
else:
    ans=-1
    for i in range(mini, maxi):
        for j in range(i+1, maxi+1):
            if ans==-1:
                ans=(i*j)%mod
            else:
                if ans>(i*j)%mod:
                    ans=(i*j)%mod
    print(ans)

Submission status: Accepted

Solution code:
L, R = map(int,input().split()) # 複数の数字を変数に格納

min = 2020

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

print(min)

Submission status: Accepted

Solution code:
L,R = map(int, input().split() )
#2019=3*673
judge=2018

if R-L > 671:
    judge=0
elif L%673 > R%673 :
    judge=0
else:
    i_s=list(range(L, R))
    judge_tmp=[]
    for i in i_s:
        judge_tmp.append(min([(i*j)%2019 for j in range(i+1, R+1)]) )
    judge = min(judge_tmp)
print(judge)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd

MOD = 2019  # type: int

def solve(L: int, R: int):
    R = min(R, L + MOD)

    ret = 2020
    for i in range(L, R + 1):
        for j in range(L, R + 1):
            if j <= i:
                continue
            tmp = ((i % MOD) * (j % MOD)) % MOD
            ret= min(ret, tmp)
    return ret


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = int(next(tokens))  # type: int
    R = int(next(tokens))  # type: int
    result = solve(L, R)
    if isinstance(result, Iterable) and not isinstance(result, str):
        result = '\n'.join([str(v) for v in result])
    print(result)

if __name__ == '__main__':
    main()

Submission status: Accepted

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


res = 2018
for i in range(L, R + 1):
    for j in range(i + 1, R + 1):

        tmp = (i * j) % 2019
        if tmp == 0:
            print(0)
            exit()
        if tmp < res:
            res = tmp

print(res)

Submission status: Accepted

Solution code:
import copy
import sys
from bisect import bisect_left, bisect_right
from collections import ChainMap, Counter, deque, defaultdict, namedtuple
from fractions import gcd
from heapq import heappop, heappush
from itertools import accumulate
from math import ceil, floor, sqrt
from operator import itemgetter

# sys.setrecursionlimit(10**6)


M = 2019


def main():
    a, b = [int(x) for x in input().split(' ')]

    if 2019 <= (b - a):
        print(0)
        return

    a_q = a // M
    b_q = b // M

    if a_q != b_q:
        print(0)
        return

    a = a % M
    b = b % M

    m = M

    for i in range(a, b + 1):
        for j in range(i + 1, b + 1):
            m = min(m, (i * j) % M)

    print(m)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

if(diff >= 2019):
  print(0)
else:
  lmod = l % 2019
  rmod = r % 2019
  if(rmod  < lmod):
    print(0)
  else:
    ans =2020
    for i in range(l,r+1):
      for j in range(i+1,r+1):
        if((i*j) % 2019 < ans):
          ans = (i*j) % 2019
    print(ans)

Submission status: Accepted

Solution code:
l, r = map(int, input().split())
mod = 2019
l0 = l % mod
r0 = r % mod

a = []
if r - l >= mod:
    a = [0,0]
elif l0 <= r0:
    a = list(range(l0, r0+1))
else:
    a = list(range(0, l0+1)) + list(range(r0, mod))

m = 10000
for i in range(len(a)-1):
    for j in range(i+1, len(a)):
        x = (a[i] * a[j]) % mod
        if x < m:
            m = x
print(m)

Submission status: Accepted

Solution code:
def main():
    L, R = map(int, input().split())
    min_ = 2019
    left = L % 2019
    right = R % 2019
    if left >= right:
        return 0
    if R >= L + 2019:
        return 0
    for i in range(left, right):
        for j in range(i + 1, right + 1):
            tmp = i * j % 2019
            if tmp < min_:
                min_ = tmp
    return min_

print(main())

Submission status: Accepted

Solution code:
import sys


if __name__ == '__main__':
    L, R = map(int, input().split())

    answer = sys.maxsize
    if R - L >= 2019 * 2:
        answer = 0
    else:
        for i in range(L, R):
            for j in range(i+1, R+1):
                # print(str(i) + ', ' + str(j))
                i_mod2019 = i % 2019
                j_mod2019 = j % 2019
                answer = min(answer, (i_mod2019 * j_mod2019) % 2019)
    print(answer)

Submission status: Accepted

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

list_ = []
c = 0

while c < 2019:
    if c > r - l:
        break
    list_.append((l+c) % 2019)
    c += 1

list_.sort()
ans = 1000000
for i in range(len(list_)):
    for j in range(len(list_)):
        if i != j:
            ans = min(ans, (list_[i] * list_[j]) % 2019)
print(ans)

Submission status: Accepted

Solution code:
def read():
    L, R = list(map(int, input().strip().split()))
    return L, R+1


def solve(L, R):
    if R - L > 2019:
        return 0
    numlist = []
    for i in range(L, R, 1):
        numlist.append(i % 2019)
    minimum = 9999999
    for i in numlist:
        for j in numlist:
            if i < j and (i*j) % 2019 < minimum:
                minimum = (i*j) % 2019
    return minimum


if __name__ == '__main__':
    inputs = read()
    print("%d" % solve(*inputs))

Submission status: Accepted

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


def solv(l, r):
    # 2019 = 673 * 3
    if r - l >= 672:
        return 0

    if l == 0:
        return 0

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

if __name__ == '__main__':

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

    ans = solv(l, r)
    print(ans)

Submission status: Accepted

Solution code:
magic = 2019
mid = magic // 2
l, r = [int(i) for i in input().split()]
if r - l >= 2019:
    print(0)
else:
    l = l % magic
    r = r % magic
    if l >= mid and r <= mid:
        print(0)
    else:
        ans = 2019
        for i in range(min(l,r), max(l,r)+1):
            for j in range(i+1, max(l,r)+1):
                ans = min(ans, i*j % 2019)
        print(ans)

Submission status: Accepted

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


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

Submission status: Accepted

Solution code:

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


if R // 2019 != L // 2019:
    ans = 0

else:

    ans = float("inf")
    mini = L % 2019
    maxi = R % 2019

    for I in range(maxi - mini + 1):
        i = L+I

        for J in range(I):

            j = L + J

            ans = min (ans, (i*j) % 2019)

print (ans)

Submission status: Accepted

Solution code:
import itertools

l, r = (int(i) for i in input().split())
if r-l>=2019:
  print(0)
else:
  ls = list(range(l, r+1))
  hoge = [i[0]*i[1]%2019 for i in itertools.combinations(ls, 2)]
  print(min(hoge))

Submission status: Accepted

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

ld = L // MOD
rd = R // MOD

ans = 0
if ld != rd:
    ans = 0
else:
    ans = 100000000
    lm = L % MOD
    rm = R % MOD
    for i in range(lm, rm):
        for j in range(lm+1, rm+1):
            v = (i * j) % MOD
            if v < ans:
                ans = v

print(ans)

Submission status: Accepted

Solution code:
L,R = map(int,input().split())
N = min([R - L , 2019])
m = 2018
if N == 1:
  m = (R*L)%2019
for i in range(N):
  for j in range(N - i):
    M = ((L + i)*(L + N - j))%2019
    if M < m:
      m = M
print(m)

Submission status: Accepted

Solution code:
import numpy as np
L, R = map(int, input().split())
if R - L + 1 >= 2019:
    print(0)
else:
    x = np.arange(L, R+1)
    x = x % 2019
    m = 2018
    for i in range(len(x)-1):
        y = (x[i+1:]*x[i])%2019
        m = min(m, np.min(y))
    print(m)

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
import itertools
  
if R - L >= 2019:
  print(0)
  exit()
else:
  minV = 2*10**9
  for i in itertools.combinations(range(L, R+1), 2):
    val = (i[0]*i[1]) % 2019
    if val <= minV:
      minV = val
  print(minV)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from sys import exit

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

_L = L
ans = 2019
while True:
    if _L % 2019 == 0:
        if _L + 2019 <= R:
            print(0)
        else:
            print(1)
        exit()
    if _L == R:
        for i in range(L, R):
            for j in range(i + 1, R + 1):
                if ans > (i * j % 2019):
                    ans = i * j % 2019
        break
    _L += 1

print(ans)

Submission status: Accepted

Solution code:
L, R = [int(_) for _ in input().split()]
if R-L >= 2018:
    m = 0
else:
    m = 2020
    N = [i%2019 for i in range(L, R+1)]

    for i in range(len(N)):
        for j in range(i+1,len(N)):
            m = min(m, (N[i]*N[j])%2019)

print(m)

Submission status: Accepted

Solution code:
def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)

l,r=[int(i) for i in input().split()]
a=l//2019
b=r//2019
if a!=b:
    print(0)
elif l%2019==0 or r%2019==0:
    print(0)
else:
    min=10000000000000000
    for i in range(l,r+1):
        for j in range(i+1,r+1):
            c=(i*j)%2019
            if c<min:
                min=c
    print(min)

Submission status: Accepted

Solution code:
import math

x = input()
x = x.split()

l = int(x[0])
r = int(x[1])

if l % 2019 > r % 2019 or r-l >= 2018:
  print("0")
  exit()


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

Submission status: Accepted

Solution code:
MOD = 2019

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

v = MOD
stop = min(R, L + MOD) + 1
for i in range(L, stop):
  for j in range(i + 1, stop):
    v = min(v, i * j % MOD)

print(v)

Submission status: Accepted

Solution code:
l, r = map(int, input().split())
modl = []
result = float("INF")
for i in range(l, r + 1):
    num = i % 2019
    if num == 0:
        print(0)
        exit()
    modl.append(num)
for i in range(r - l + 1):
    for j in range(i + 1, r - l + 1):
        result = min(modl[i] * modl[j] % 2019, result)
print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
	import sys
	input = sys.stdin.readline
	L, R = list(map(int, input().split()))
	if R - L >= 2019:
		print(0)
	else:
		modL = L % 2019
		modR = R % 2019
		if modR <= modL:
			print(0)
		else:
			ans = (modL * (modL + 1)) % 2019
			tmp = []
			for i in range(modL, modR+1):
				for j in range(i+1, modR+1):
					tmp.append((i * j) % 2019)
			print(min(tmp))


if __name__ == '__main__':
    main()

Submission status: Accepted

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