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())
m = 2020
for i in range(L,R+1):
    for j in range(L+1,R+1):
        if i == j:
            continue
        if i*j%2019 < m:
            m = i*j%2019
        if m == 0:
            break
    if m == 0:
        break
print(m)

Submission status: Accepted

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

l = L // mod
r = R // mod

if l != r:
    print(0)
else:
    l_ = L % mod
    r_ = R % mod
    ans = 2019
    for i in range(l_, r_):
        for j in range(i+1, r_+1):
            a = i * j % mod
            ans = min(ans, a)
            if ans == 0:
                break
        if ans == 0:
            break
    print(ans)

Submission status: Accepted

Solution code:
L,R=map(int,input().split())
X=2019
a=10**20
for i in range(L,min(R,L+X)):
    for j in range(i+1,min(R+1,i+1+X)):
        t=(i*j)%X
        a=min(a,t)
        if t==0:
            break
print(a)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import numpy as np

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

if R-L < 2019:
    ans = 10**20

    for i in range(L, R):
        ans = min(ans, np.min(np.arange(i+1, R+1) * i % 2019))
else:
    ans = 0
print(ans)

Submission status: Accepted

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

if R-L < 2019:
    ans = 10**20

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

Submission status: Accepted

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

diff = R - L

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

print(ans)

Submission status: Accepted

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

L_quo = int((L - L % 2019) / 2019)
R_quo = int((R - R % 2019) / 2019)

if L_quo != R_quo:
    print(0)
else:
    L_rem = L % 2019
    R_rem = R % 2019
    for i in range(L_rem, R_rem):
        for j in range(i + 1, R_rem + 1):
            a = (i * j) % 2019
            ans = min(ans, a)
    print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-



def main():
  MOD = 2019
  modset = [[(i*j)%MOD for i in range(2019)] for j in range(2019)]
  L,R = map(int, input().split())

  ans = 2018
  for i in range(L,R+1):
    for j in range(L,i):
      ans = min(ans,modset[i%MOD][j%MOD])
      if ans==0:
        return ans
  return ans


if __name__ == "__main__":
  print(main())

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L, R = map(int,input().split())
l , r = L//2019, R//2019
if R - L >= 2019:
    print(0)

else:
    Amari=[]
    for i in range(L,R):
        for j in range(i+1,R+1):
            k = i*j
            Amari.append(k%2019)
    print(min(Amari))

Submission status: Accepted

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

if R - L >= 2019:
    print(0)
elif R-L == 1:
    print(R*L%2019)
else:
    Amari=[]
    for i in range(L,R):
        for j in range(i+1,R+1):
            k = i*j
            Amari.append(k%2019)
    print(min(Amari))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

def main():
    input = sys.stdin.readline
    L, R = map(int, input().split())
    R = min(R, L + 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:
                return 0

    return ans


if __name__ == '__main__':
    print(main())

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

l,r = [int(i) for i in readline().split()]
if r-l > 2019:
    print(0)
    exit()

ans = 2222
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


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

# let p, q, s, t >= 0
# l = 2019 * s + p
# r = 2019 * t + q

s = l // 2019
p = l % 2019

t = r // 2019
q = r % 2019

if s == t:
  # i = 2019 * s + x
  # j = 2019 * s + y
  x = numpy.arange(p, q + 1, 1)
  rem = numpy.dot(x.reshape(-1, 1), x.reshape(1, -1))
  rem %= 2019
  row, col = rem.shape
  rem += numpy.identity(row, dtype=int) * 2019
  min_rem = numpy.amin(rem)
  
  print(min_rem)

else:
  print(0)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

def solve():
    input = sys.stdin.readline
    L, R = map(int, input().split())
    if R - L >= 2018: print(0)
    else:
        ans = 2019
        for i in range(L, R):
            for j in range(L + 1, R + 1):
                ans = min(ans, (i * j) % 2019)
        print(ans)
    
    return 0

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
firstvar = input()
l = int(firstvar.split(" ")[0])
r = int(firstvar.split(" ")[1])
i = l
min = 2019
if (r/2019 - l/2019) >= 1:
    print(0)
else:
    for i in range(l,r + 1):
        for j in range(i + 1, r + 1):
            mod = (i*j)%2019
            if mod < min:
                min = mod
                if mod == 0:
                    break;
    print(min)

Submission status: Accepted

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

    print((a)%2019)

Submission status: Accepted

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

mod = 2018

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
            if tmp < mod:
                mod = tmp
    print(mod)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
n,r=map(int,input().split())
roop_n=0
ans=0
min_=2019

if r-n>=2019:
    roop_n=n+2019
else:
    roop_n=r
for i in range(n,roop_n):
    for j in range(n+1,roop_n+1):
        ans=(i*j)%2019
        if min_>ans:
            min_=ans
            if ans==0:
                print(0)
                sys.exit()
print(min_)

Submission status: Accepted

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

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

L, R = L % 2019, R % 2019

if L >= R:
    R += 2019

ans = float('inf')

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

Submission status: Accepted

Solution code:
#ABC 133 Remainder Minimization 2019
l, r = [ int(_) for _ in input().split() ]

ls = [2018]

for i in range(l,r):
    for j in range(i+1,r+1):
        y = (i*j) % 2019
        if y < min(x for x in ls):
            ls.append(y)
        if y == 0:
            break
    if y == 0:
        break
    
print(min([ x for x in ls]))

Submission status: Accepted

Solution code:
#ABC 133 Remainder Minimization 2019
l, r = [ int(_) for _ in input().split() ]

ls = [2018]

for i in range(l,r):
    for j in range(i+1,r+1):
        y = (i*j) % 2019
        if (i*j) % 2019 < min(x%2019 for x in ls):
            ls.append(i*j)
        if y == 0:
            break
    if y == 0:
        break
    
print(min([ x%2019 for x in ls]))

Submission status: Accepted

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

ans = 2019
it = L
while(it<=min(R,it+2019)):
    jt = it+1
    while(jt<=min(R,jt+2019)):
        a = (it*jt)%2019
        if a < ans:
            ans = a
            if ans==0:break
        jt += 1
    if ans==0:break
    it += 1
            
print(ans)

Submission status: Accepted

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

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

min_mod = 10 ** 12
for l in range(L, R):
	for r in range(l + 1, R + 1):
		min_mod = min(min_mod, (l * r) % 2019)
print(min_mod)

Submission status: Accepted

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

x=[]
a=0
for i in range(L,R):
    for j in range(L+1,R+1):
        y=((i*j)%2019)
        x.append(y)
        if y==0:
            break
    if y==0:
            break

print(min(x))

Submission status: Accepted

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

Lw=L//2019
Rw=R//2019

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L, R = [int(i) for i in input().split()]
min = 2018
for i in range(L,R):
    for j in range(i+1,R+1):
        mod = (i*j)%2019
        if mod<min:
            min = mod
        if mod==0:
            print("{}".format(mod))
            exit()
print("{}".format(min))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

IS = lambda: int(input())
IA = lambda: [int(x) for x in input().split()]
IM = lambda N: [IA() for _ in range(N)]

L, R = IA()

def f():
    if L // 2019 != R // 2019:
        return 0
    ans = float('inf')
    la, ra = L % 2019, R % 2019
    for i in range(la, ra):
        for j in range(i+1, ra+1):
            ans = min(ans, (i * j) % 2019)
    return ans

print(f())

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline

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

def main():
    if R // 2019 != L // 2019:
        ans = 0
    else:
        # ansLi = L % 2019
        # ansLj = (L+1) % 2019
        # ansL = ansLi * ansLj

        # ansRi = R % 2019
        # ansRj = (R-1) % 2019
        # ansR = ansRi * ansRj
        ansL = L*(L+1) % 2019
        ansR = R*(R-1) % 2019

        ans = min(ansL, ansR)

    return int(ans)

# print(main())

def search_all():
    if R // 2019 != L // 2019:
        return 0
    ans = float("inf")
    for i in range(L, R):
        for j in range(i+1, R+1):
            ans = min(i*j % 2019, ans)
            if ans == 0:
                break
    return ans

print(search_all())

Submission status: Accepted

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

res = []
for i in range(L,R):
    for j in range(i+1,R+1):
        res.append((i*j)%2019)
        if (i*j)%2019 == 0:
            break
    else:
        continue
    break

print(min(res))

Submission status: Accepted

Solution code:
l,r=map(int,input().split())
mod=2019
ans=((10**9)*2)**2
for i in range(l,r):
    for j in range(i+1,r+1):
        x=i*j

        if x%mod==0:
            print(0)
            exit()
        else:
            ans=min(ans,x%mod)
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
l, r = map(int, input().split())
mod = 2019
r = min(r, l+mod+1)

ans = 2020

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())
r2 = r+0
l2 = l+0
l%=2019
r%=2019
ans = 20000
if r2-l2 >= 2019 or r<=l:
  r += 2019
for i in range(l,r+1):
  for j in range(i+1,r+1):
    ans = min(i*j%2019,ans)
if ans == 20000:
  ans = 0
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def search(lower, upper, mod):
    min_remain = mod
    for i in range(lower, min(lower + mod - lower % mod, upper - 1) + 1):
        for j in range(i + 1, min(i + mod, upper) + 1):
            remain = i * j % mod
            if remain == 0:
                return 0
            if min_remain > remain:
                min_remain = remain
    return min_remain


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

Submission status: Accepted

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

Submission status: Accepted

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

chk = 0
flg = 1
i = l
mod_min = 100000

while flg:
    for j in range(i+1,r+1):
        chk = (i*j)%2019
        if chk == 0:
            print(0)
            flg = 0
            break
        elif chk < mod_min:
            mod_min = chk
    i += 1
    if i >= r-1:
        print(mod_min)
        flg = 0

Submission status: Accepted

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

module = []
for i in range(L, R):
    for j in range(i+1, R+1):
        #print("({} * {}) mod 2019 = {}".format(i, j, (i * j) % 2019))
        if (i * j) % 2019 == 0:
            print("0")
            exit()
        else:
            module.append((i * j) % 2019)

if not module:
    print("0")
else:
    print(min(module))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
l, r = map(int, input().split())
m = 10**9
for i in range(l, r + 1)[:2019]:
    for j in range(i + 1, r + 1)[:2019]:
        m = min(m, i * j % 2019)
print(m)

Submission status: Accepted

Solution code:
a1=list(input().split( ))
a=list(map(int, a1))
b= a[1] - a[0]
d=2018

if b > 2019:
 print(0)
else:
 for j in range(b):
  for k in range(b-j):
    c= ((a[0] + j )* (a[0] + j  + k + 1)) % 2019
    if c<=d:
     d=c
 print(d)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L,R=map(int,input().split())
M=2019
import sys
for i in range(L,R):
    for j in range(i+1,R+1) :
        if (i*j)%2019 < M :
            M = (i*j)%2019
            if M == 0:
                print(M)
                sys.exit()
print (M)

Submission status: Accepted

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

ans = 2018
max_l = min(l, (r//2019+1)*2019)

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

Submission status: Accepted

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

ans = 0 if l - r >= 2019 else 2018
max_l = min(l, (r//2019+1)*2019)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

flag = False
if l % 2019 == 0 or r // 2019 - l // 2019 != 0:
    flag = True

if flag:
    print(0)
else:
    lmod = l % 2019
    rmod = r % 2019

    ans = 10**5
    for i in range(lmod, rmod):
        for j in range(i+1, rmod+1):
            ans = min((i * j) % 2019, ans)
    print(ans)

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, L+2018):
    if flag:
        for j in range(i+1, R+1):
            if i > R:
                flag = False
                break
            ans = min(((i % 2019) * (j % 2019)) % 2019, ans)

print(ans)

Submission status: Accepted

Solution code:
import sys
import math
import numpy as np
INF = 1000000000
MOD = 2019


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


def main():
    l, r = [int(e) for e in input().split()]
    ans = INF
    for i in range(l, min(l + MOD, r + 1)):
        for j in range(i + 1, min(l + MOD, r + 1)):
            ans = min(ans, ((i % MOD) * (j % MOD)) % MOD)
    print(ans)


main()

Submission status: Accepted

Solution code:
import math
import sys
import itertools
import queue
from fractions import gcd
import numpy as np


def lcm(a, b):
    return a * b // gcd(a, b)

mod = 2019

if __name__ == "__main__":
    L,R= map(int, sys.stdin.readline().split())
    if R-L>=2018:
        print(0)
    else:
        ans=2019
        for i in range(L,R):
            for j in range(i+1,R+1):
                ans=min(ans,(j*i)%mod)
        print(ans)

Submission status: Accepted

Solution code:
def smaller(x, y):
	if x < y: return x
	return y

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

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
mod = 2019
if (R-L+1) >= 2019:
    nums = [i for i in range(2019)]
else:
    nums = list(set([i % 2019for i in range(L, R+1)]))

res = []
for i in range(len(nums)):
    for j in range(i+1, len(nums)):
       res.append((nums[i]*nums[j])%mod)
print(min(res))

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

Submission status: Accepted

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

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

Submission status: Accepted

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

mod=2019
r=min(r,l+mod+1)
res=float('inf')

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

Submission status: Accepted

Solution code:

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

print(ans)

Submission status: Accepted

Solution code:
import sys

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

remainder_list = []

if r - l >= 2019:
    print(0)
    sys.exit()
else :
    for x in range(l, r):
        for y in range(x + 1, r + 1):
            remainder_list.append((x * y) % 2019)

remainder_list.sort()
print(remainder_list[0])

Submission status: Accepted

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

mod=2019
r=min(r,l+mod)
res=float('inf')

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

Submission status: Accepted

Solution code:
import itertools

def resolve():
	l,r=map(int,input().split())
	k=min(r+1,l+2020)
	lst=[i%2019 for i in range(l,k)]
	if 0 in lst:
		ans=0
	elif 673 in lst:
		if len(lst)>3:
			ans=0
		elif 672 in lst or 675 in lst:
			ans=0
		else:
			ans=1346
	else:
		ans=min([(i[0]*i[1])%2019 for i in list(itertools.combinations(lst,2))])
	
	print(ans)
resolve()

Submission status: Accepted

Solution code:
import sys, itertools, collections
sys.setrecursionlimit(10000)

read_ints = lambda: list(map(int, input().split()))
read_int  = lambda: int(input())

MOD = 2019

l, r = read_ints()
r = min(r + 1, l + MOD)

ans = min(
    (i * j) % MOD
    for i in range(l, r)
    #for j in range(l + 1, r)  # WA
    for j in range(i + 1, r)
)

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

mod = 2019

r = min(r, l+mod+1)

ans = 2020

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())
mn=2018
if r-l<2019:
  for i in range(l%2019,r%2019+1):
    for j in range(l%2019,r%2019+1):
      if i<j:
        mn=min(mn,(i*j)%2019)
  print(mn)
else:
  print(0)

Submission status: Accepted

Solution code:
# ABC133C - Remainder Minimization 2019
def main():
    L, R = list(map(int, input().rstrip().split()))
    MOD = 2019
    if R - L + 1 >= MOD:  # L <= 2019n <= R
        print(0)
    else:  # max: 2018 * 2017 patterns
        L, R = L % MOD, R % MOD
        if L <= 3 and R >= 673:  # 2019 = 3 * 673
            print(0)
            return
        ans = float("inf")
        for i in range(L, R):
            for j in range(i + 1, R + 1):
                tmp = (i * j) % MOD
                if tmp < ans:
                    ans = tmp
        print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# ABC133C - Remainder Minimization 2019
def main():
    L, R = list(map(int, input().rstrip().split()))
    MOD = 2019
    if R - L + 1 >= MOD:  # L <= 2019n <= R
        print(0)
    else:  # max: 2018 * 2017 patterns
        L, R = L % MOD, R % MOD
        if L <= 3 and R >= 673:
            print(0)
            return
        ans = float("inf")
        for i in range(L, R):
            for j in range(i + 1, R + 1):
                ans = min(ans, (i * j) % MOD)
        print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# ABC133C - Remainder Minimization 2019
def main():
    L, R = list(map(int, input().rstrip().split()))
    MOD = 2019
    if R - L + 1 >= MOD:  # L <= 2019n <= R
        print(0)
    else:  # max: 2018 * 2017 patterns
        ans = float("inf")
        L, R = L % MOD, R % MOD
        for i in range(L, R):
            for j in range(i + 1, R + 1):
                ans = min(ans, (i * j) % MOD)
                if ans == 0:
                    print(ans)
                    return
        print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# ABC133C - Remainder Minimization 2019
def main():
    L, R = list(map(int, input().rstrip().split()))
    MOD = 2019
    if R - L + 1 >= MOD:  # L <= 2019n <= R
        print(0)
    else:  # max: 2018 * 2017 patterns
        ans = float("inf")
        L, R = L % MOD, R % MOD
        for i in range(L, R):
            for j in range(i + 1, R + 1):
                ans = min(ans, (i * j) % MOD)
        print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# ABC133C - Remainder Minimization 2019
def main():
    L, R = list(map(int, input().rstrip().split()))
    MOD = 2019
    if (R // MOD) - (L // MOD) > 0:  # L <= 2019n <= R
        print(0)
    else:  # R - L <= 2018 -> max: 2018 * 2017 patterns
        ans = float("inf")
        L, R = L % MOD, R % MOD
        for i in range(L, R):
            for j in range(i + 1, R + 1):
                ans = min(ans, (i * j) % MOD)
        print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# ABC133C - Remainder Minimization 2019
def main():
    L, R = list(map(int, input().rstrip().split()))
    MOD = 2019
    if (R // MOD) - (L // MOD) > 0:  # L <= 2019n <= R
        print(0)
    else:  # R - L <= 2018 -> max: 2018 * 2017 patterns
        ans = float("inf")
        for i in range(L, R):
            for j in range(i + 1, R + 1):
                i, j = i % MOD, j % MOD
                ans = min(ans, (i * j) % MOD)
        print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# ABC133C - Remainder Minimization 2019
def main():
    L, R = list(map(int, input().rstrip().split()))
    MOD = 2019
    if (R // MOD) - (L // MOD) > 0:  # L <= 2019n <= R
        print(0)
    else:
        ans = float("inf")
        for i in range(L, R):
            for j in range(i + 1, R + 1):
                i, j = i % MOD, j % MOD
                ans = min(ans, (i * j) % MOD)
        print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
l,r=map(int,input().split());s=range(l,r+1);print(+(r-l<2e3)and min(i*j%2019for i in s for j in s if i<j))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l,r=map(int,input().split())
if r-l+1<=2019:
	modlist=[]
	lst=list(range(l,r+1))
	for i in range(len(lst)):
		for j in range(i+1,len(lst)):
			q,mod = divmod(lst[i]*lst[j],2019)
			modlist.append(mod)
	print(min(modlist))
else:
	print(0)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# print(count)
L,R= map(int,input().split())
#境界条件
bool = True
l = L % 2019
r = R % 2019
if L ==0:
    ans = 0
elif R == L+1:
    ans = R*L%2019
elif R-L > 2019:
    ans = 0
else:
    if l >= r:
        r += 2019
    for i in range(l,r):
        for j in range(i+1,r+1):
            temp = (i * j) % 2019
            if bool:
                min = temp
                ans = min
                bool = False
            elif min > temp:
                min = temp
                ans = min
print(ans)