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())
if R - L >= 2019:
    print(0)
else:
    val = 2019
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            tmp = ((i % 2019) * (j % 2019)) % 2019
            val = tmp if val > tmp else val
            if val == 0:
                print(val)
                exit()

    print(val)

Submission status: Accepted

Solution code:
l, r = map(int, input().split())
def doit(l, r):
#  l = l % 2019
#  r = r % 2019
#  if r <= l:
#    r += 2019
  res = 2018
  for x in range(l, r):
    for y in range(x + 1, r + 1):
      #print(x, y, file=sys.stderr)
      res = min(res, (x * y) % 2019)
      if res == 0:
        return 0
  return res % 2019

print(doit(l, r))

Submission status: Accepted

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

x = 2020

if R - L > 2019:
    print(0)

else:
    for i in range(R+1)[L:]:
        for j in range(R+1)[i+1:]:

            mod = i * j % 2019

            x = min(mod, x)

    print(x)

Submission status: Accepted

Solution code:
def solve():
  L, R = map(int, input().split())
  ans = 2019
  for i in range(L, R):
    for j in range(i + 1, R + 1):
      v = i * j % 2019
      if v < ans: ans = v
      if ans == 0: return 0
  return ans

print(solve())

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

L, R = map(int, input().split())
if L + (673 - L % 673) <= R or L % 673 == 0:
  if L + (3 - L % 3) <= R or L % 3 == 0:
    print(0)
    sys.exit()
ans = 2019
a = L % 2019
b = R % 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())
min = 2019

if R -L >= 2019:
	min = 0
else:

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

print(min)

Submission status: Accepted

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

print(min)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

print(min)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l, r = map(int, input().split())
rem_list = []
if 4038 > r-l+1 >= 2019:
    print(1)
elif r-l+1 <= 2019:
    frag = 0
    for i in range(r-l+1):
        rem = (l+i)%2019
        if rem == 0:
            frag = 1
            continue
        rem_list.append(rem)
    if frag == 1:
        print(min(rem_list))
    else:
        re_rem_list = []
        for i in range(len(rem_list)-1):
             for j in range(len(rem_list)-i-1):
                re_rem_list.append((rem_list[i]*rem_list[i+j+1])%2019)
        print(min(re_rem_list))
else:
    print(0)

Submission status: Accepted

Solution code:
import itertools


downer, upper = map(int, input().split(' '))

r_d = (downer // 2019) * 2019
u_d = (upper // 2019) * 2019

rng = range(downer, upper+1)

if r_d in rng or u_d in rng:
    print(0)
    exit(0)

numbers = set([min(i, abs(2019-i)) for i in rng])

c = itertools.combinations(numbers, 2)
s = [(i1 * i2) % 2019 for i1, i2 in c]
print(min(s))

Submission status: Accepted

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

cnt = 0
tank = []
for i in range(l,r+1):
    tank.append(i%mod)
    cnt += 1
    if cnt >= 2020:
        break

res = 2019

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L, R = list(map(int, input().split(' ')))
#print(L, R)

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

print(min)

Submission status: Accepted

Solution code:
def baisuaru(l,r,m):
  if l//m < r//m:
    return True
  elif l%m==0:
    return True
  else:
    return False
    

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


if baisuaru(l,r,2019):
  print(0)
else:
  if baisuaru(l,r,3) and baisuaru(l,r,673):
    print(0)
  else:
    a=l%2019
    b=r%2019
    ans=99999999
    for i in range(a,b+1):
      for j in range(i+1,b+1):
        tmpans=(i*j)%2019
        if ans>tmpans:
          ans=tmpans
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(1,10**6):
    if i * 2019 >= L and i*2019 <= R:
        print(0)
        exit()

ans = 10**20

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
l,r = (int(i) for i in input().split())

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

while l // 2019 > 0 or r // 2019 > 0:
  l = l % 2019
  r = r % 2019

mini = 2*(1e+9)
if l < r:
  for i in range(l,r+1):
    for j in range(i+1,r+1):
      mini = min(mini, (i*j) % 2019)
elif l > r:
  for i in range(r,l+1):
    for j in range(i+1,l+1):

      mini = min(mini, (i*j) % 2019)
elif l == r:
  print(l*r% 2019)
  exit(0)
print(mini)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A,B=map(int,input().split())
mod = 2018
flag =0
for i in range(A,B):
  x = i % 2019
  for j in range(i+1,B+1):
    j = j % 2019
    mod = min(mod, (x*j)%2019)
    if mod == 0:
      flag = 1
      break
  if flag:
    break

print(mod)

Submission status: Accepted

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

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

between_list = []
for lr in range(L, R+1):
    lr_mod = lr % 2019
    if lr_mod == 0:
        print(0)
        sys.exit()
    between_list.append(lr % 2019)

#あとは総当たり戦
min_number = 2019
for i in range(len(between_list)-1):
    for j in range(i+1, len(between_list)):
        #print(str(i) + ', ' + str(j))
        #print(str(between_list[i]) + ', ' + str(between_list[j]))
        if (between_list[i] * between_list[j]) % 2019 < min_number:
            min_number = (between_list[i] * between_list[j]) % 2019

print(min_number)

Submission status: Accepted

Solution code:
def hantei3(w,L,R):
    if w>=2:
        return True
    for i in range(L,R+1):
        if i%3==0:
            return True
    return False

def hantei673(w,L,R):
    if w>=672:
        return True
    for i in range(L,R+1):
        if i in [673,1346]:
            return True
    return False

L,R=map(int,input().split())
w=R-L
L%=2019
R%=2019
if w>=2018 or L>R:
    print(0)
else:
    mn=3000
    for i in range(L,R):
        for j in range(i+1,R+1):
            tmp=i*j%2019
            if tmp<mn:
                mn=tmp
    print(mn)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ml = (l % 2019)
mr = (r % 2019)
t = l + 2019
if r > t:
    m = 0
else:
    if ml < mr:
        for i in range(ml, mr):
            for j in range(i+1, mr+1):
                m = min(m, (i * j) % 2019)
    else:
        m = 0
print(m)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
l = L % 2019
b = min(R - L, 2019)
ans = 10 ** 12
for i in range(l, l + b + 1):
    for j in range(i + 1, l + b + 1):
        ans = min(ans, i * j % 2019)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
if R // 2019 - (L - 1) // 2019 != 0:
    print(0)
else:
    minnum = 5000
    Lmod = L % 2019
    Rmod = R % 2019
    for i in range(Lmod, Rmod+1):
        for j in range(i + 1, Rmod+1):
            #print(i, j, (i * j) % 2019)
            minnum = min(minnum, (i * j) % 2019)
    print(minnum)

Submission status: Accepted

Solution code:
import sys

L, R = map(int,input().split())
tmp = 2019
mod = 2019
for i in range(L, R):
  for j in range(i+1, R+1):
    tmp = (i * j) % 2019

    if tmp < mod:
      mod = tmp
    if mod == 0:
      break
  if mod == 0:
    break

print(mod)

Submission status: Accepted

Solution code:
#coding:utf-8
L, R = map(int,input().split())
mn = 1000000000
Y = 2019
if R >= L + Y:
    R = L + Y - 1
for j in range(L,R+1):
    for i in range(L,j):
        mn = min(mn, ((i%Y)*(j%Y))%Y)
print (mn)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

x = []
for i in range(2019):
    for j in range(L//2019, R//2019+1):
        tmp = 2019*j + i
        if tmp >= L and tmp <= R:
            x.append(i)
            break

from itertools import combinations

pairs = list(combinations(x, 2))
print(min([(p[0]*p[1])%2019 for p in pairs]))

Submission status: Accepted

Solution code:
import math
def serch(l, r):
    min_x = (l*l + l) % 2019
    for i in range(l+2, r+1):
        a = (l * i) % 2019
        #print("ll", l, "ii", i, "rr", r, "aa", a)
        if(a  < min_x):
            min_x = a
    return min_x

def solve():
    l, r = map(int, input().split())
    l_div = l // 2019
    r_div = r // 2019
    if(l_div != r_div):
        print(0)
    else:
        a = r % 2019
        b = a - 1
        if(a*b < 2019):
            print((l*l + l) % 2019)
        else:
            min_x = 2020
            for i in range(l, r):
                a  = serch(i, r)
               # print("i", i, "r", r, "a", a)
                if(a < min_x):
                    min_x = a
            print(min_x)



if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
MOD = 2019

L, R = map(int, input().split())
minx = float("inf")
for i in range(L, R):
    im = i % MOD
    if i != L and im == L % MOD:
        break
    for j in range(i + 1, R + 1):
        jm = j % MOD
        if j != i + 1 and jm == (i + 1) % MOD:
            break
        minx = min(minx, im * jm % MOD)
print(minx)

Submission status: Accepted

Solution code:
l,r=map(int,input().split())
s=[]
if ((r//2019)!=(l//2019)):
    a=0
    s.append(a)
elif((r-l!=1)):
    for i in range(l,r-1):
        for j in range(i+1,r+1):
            #print(i,j)
            a=(i*j)%2019
            #print(a)
            s.append(a)
            if (a==0):
                break
else:
    a=(l*r)%2019
    s.append(a)
print(min(s))

Submission status: Accepted

Solution code:
l,r = map(int, input().split())
gap = r-l
 
vlist = []
mini = 2019
 
for x in range(gap+1):
    v = (l+x) % 2019
    vlist.append(v)
    if v == 0:
        print(0)
        exit()
 
vlist.sort()

mini = 2019

for i in vlist:
    for j in vlist:
        if i==j:
            pass
        else:
            temp = (i*j) %2019
            mini = min(temp, mini)
            if mini == 0:
                print(0)
                exit()

print(mini)
    
#print((vlist[0]*vlist[1])%2019)
#print((vlist[0]*vlist[1])%2019)

Submission status: Accepted

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

ilist = [False for x in range(2020)]
a=2*10**9
for i in range(R+1)[L:L+2020]:
  imod = i % 2019
  if ilist[imod]:
    continue
  ilist[imod] = True
  for j in range(R+1)[i+1:i+1+2020]:
    jmod = j % 2019
    m = (imod * jmod) % 2019
    a = min(a,m)

print(a)

Submission status: Accepted

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

result = None
for i in range(l, min(l + 2019 - l % 2019, r - 1) + 1):
    for j in range(i + 1, min(i + 2019, r) + 1):
        mod = i * j % 2019
        if result is None or result > mod:
            result = mod
print(result)

Submission status: Accepted

Solution code:
l,r = map(int,input().split())
ans = 99999999999999
if r-l >= 2019:
    ans = 0

l %= 2019
r %= 2019

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l, r = map(int, input().split())
p = l // 2019
if 2019 * (p + 1) <= r:
    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:
# coding: utf-8
# Your code here!

L, R = map(int, input().split())
L_mod = L % 2019
R_mod = R % 2019
min_mod = pow(2018,2)
num = 0

if abs(L - R) >= 2019:
    min_mod = 0
elif L_mod < R_mod:
    for i in range(L_mod, R_mod):
        for j in range(i + 1, R_mod + 1):
            num = (i * j) % 2019
            if min_mod > num:
                min_mod = num
elif L_mod > R_mod:
    for i in range(R_mod, L_mod):
        for j in range(i + 1, L_mod + 1):
            num = (i * j) % 2019
            if min_mod > num:
                min_mod = num
else:
    min_mod = L_mod * R_mod % 2019
print(min_mod)

Submission status: Accepted

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

Submission status: Accepted

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

ilist = list()
a=2*10**9
for i in range(R+1)[L:L+2020]:
  imod = i % 2019
  if imod in ilist:
    continue
  ilist.append(imod)
  for j in range(R+1)[i+1:i+1+2020]:
    jmod = j % 2019
    m = (imod * jmod) % 2019
    a = min(a,m)

print(a)

Submission status: Accepted

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

for i in range(l, r):
    for j in range(i+1, r+1):
        tmp = (i*j % 2019)
        if (i == l and j == l+1) or tmp < mod:
            mod = tmp
            if mod == 0:
                print(mod)
                sys.exit()
print(mod)

Submission status: Accepted

Solution code:
L,R=(int(x) for x in input().split())
ans=[]
for n in range(2019):
    if L+n>=R:
        break
    for l in range(n+1,2019):
        if L+l>R:
            break
        a=(L+n)%2019
        b=(L+l)%2019
        c=a*b%2019
        ans.append(c)
print(min(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l, r = map(int,input().split())
MOD = 2019
ans = 10**9
lm, rm = l%MOD, r%MOD
if lm ==0 or rm==0 or l//MOD!=r//MOD:
    ans = 0
else:
    for i in range(lm,rm):
        for j in range(i+1,rm+1):
            ans = min(ans,(i*j)%MOD)
print(ans)

Submission status: Accepted

Solution code:
import itertools
def isinclude(l, r, x):
    if r-l >= x:
        return True
    elif r % x == 0 or l % x == 0:
        return True
    elif l % x > r % x:
        return True
    return False
    
l, r = map(int, input().split())
if r-1 == 1:
    print((l*r) % 2019)
else:
    if isinclude(l, r, 2019):
        print(0)
    elif isinclude(l, r, 673):
        print(0)
    else:
        checks = list(range(l, r+1))
        min_of_all = 9999
        for num1, num2 in itertools.combinations(checks, 2):
            ans = (num1 * num2) % 2019
            if ans < min_of_all:
                min_of_all = ans
        print(min_of_all)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, d=DVSR): return pow(x, d - 2, d)
def DIV(x, y, d=DVSR): return (x * INV(y, d)) % d
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
    
L,R=LI()

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

L,R = map(int,input().split())
md = 2019
p = []

for i in range(L,R+1):
    p.append(i)
    if i % 2019 == 0:
        print(0)
        exit()
c = 2020
#print(p)
for i in range(L,R+1):
    for j in range(i+1,R+1):
        #print(i,j)
        c = min(c,i*j%2019)
        
print(c)

Submission status: Accepted

Solution code:
import sys

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

if L <= 2019 and 2019 <= R:
    ans = 0

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

Submission status: Accepted

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

minimum = 2019
checked = set()

start = L
end   = R+1

end2 = min(end, start+1+2019)
for i in range(start, end2):
    a = i % 2019
    if a not in checked:
        checked.add(a)
        endd = min(end, i+1+2019)
        for j in range(i+1, endd):
            v = (i * j) % 2019
            minimum = min([v, minimum])

print(minimum)

Submission status: Accepted

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

if R-L>2017:
  print(0)
  sys.exit()

L%=2019
while(R-L>2019):
  R-=2019
  
#print(L,R)
answer=10**10
for i in range(L,R):
  for j in range(i+1,R+1):
    answer=min(answer,(i*j)%2019)
    
print(answer)

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
C = []
flag = False
for i in range(L, R+1):
    if i%2019==0:
        flag = True
        break
    else:
        C.append(i)
        
if flag:
    print(0)
else:
    import itertools
    ans = 4080400
    for x, y in list(itertools.combinations(C, 2)):
        if (x*y)%2019<ans:
            ans = (x*y)%2019
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    L, R = map(int, input().split())
    ans = float('INF')
    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)
                return
    print(ans)


main()

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

ll = l % 2019
ans = 2018
if l-n >= 672:
    ans = 0
else:
    for i in range(ll,ll + n-l +1):
        if i % 673 == 0:
            ans = 0
            break
        else:
            for j in range(ll,ll + n-l +1):
                if i != j:
                    ansss = i*j%2019
                    if ansss == 0:
                        ans = 0
                        break
                    elif ansss < ans:
                        ans = ansss

print(ans)

Submission status: Accepted

Solution code:
#C問題
L,R = map(int,input().split())
r = R%2019
l = L%2019
if R-L>=2019:
    print(0)
else:
    if r < l:
        print(0)
    else:
        MIN = 2018
        for i in range(r-l):
            I = i+l
            for j in range(r-l):
                J = j+l+1
                kari = (I*J)%2019
                MIN = min(MIN,kari)
        print(MIN)

Submission status: Accepted

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

Submission status: Accepted

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

indexs = []
for index in range(L,min(R+1,L+2019)):
	indexs.append(index%2019)
	
#print(indexs)
	
indexs = sorted(indexs)

#print(indexs)

anss = []
for i in indexs:
	for j in indexs:
		if i >= j:
			continue
		
		anss.append((i*j)%2019)
	
#print(anss)
print(min(anss))

Submission status: Accepted

Solution code:
import sys
import numpy as np 
def minimize():
    L, R=map(int,input().split())
    lis=[]
    if (L+2019) >= R:
        
        for i in range(L,R):
            for j in range(i+1, R+1):
                x=(i*j) %2019
                lis.append(x)
        lis=np.array(lis)
        ans=lis.min()
        print(ans)
    
    else :
        for i in range(L,(L+2019)):
            for j in range(i+1, L+2020):
                x=(i*j) %2019
                lis.append(x)
        lis=np.array(lis)
        ans=lis.min()
        print(ans)


minimize()

Submission status: Accepted

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


if int(l / 2019) == int(r / 2019):
    l = int(l % 2019)
    r = int(r % 2019)
    m = 2018
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            if m > int((i * j) % 2019):
                m = int((i * j) % 2019)

else:
    m = 0

print(m)

Submission status: Accepted

Solution code:
MOD = 2019

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

ans = 2019
if l // MOD != r // MOD:
    ans = 0
else:
    lmod = l % MOD
    rmod = r % MOD
    for i in range(lmod, rmod + 1):
        for j in range(i + 1, rmod + 1):
            ans = min(ans, (i * j) % MOD)
print(ans)

Submission status: Accepted

Solution code:
import numpy as np
l,r = map(int, input().split())
if ((l//2019)<(r//2019)):
  print(0)
else:
  arr1 = np.array(range(l,r+1))
  arr2 = np.array(range(l,r+1)).reshape(r-l+1,1)
  arr = arr1*arr2%2019 + (np.identity(r-l+1)*2019)
  print(int(np.min(arr)))

Submission status: Accepted

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

mod = 673

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

MOD = 2019

l_s = l % MOD
r_s = r % MOD


ans = 2019

if r_s > l_s:
    for i in range(abs(l_s - r_s)+1):
        for j in range(1,abs(l_s - r_s)+2):
            if l_s+i+j > r_s:
                break
            tmp = (l_s+i)*(l_s+i+j) % MOD
            if ans > tmp:
                #print(l_s+i,l_s+i+j)
                ans = tmp
    print(ans)
    exit()
else:
    print(0)
    exit()

Submission status: Accepted

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

m = 2018
cont = 0

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

Submission status: Accepted

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

lis = []
if r - l > 2000:
    print(0)
    exit()
    
for i in range(l, r+1):
    for j in range(l,r+1):
        if i != j:
            lis += [i * j % 2019]
print(min(lis))

Submission status: Accepted

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

m = 2018

if L + 2019 < R:
    R = L + 2019

for i in range (L,R):
    for j in range(i+1,R+1):
        r = divmod(i*j, 2019)[1]
        if (r < m):
            m = r
print(m)

Submission status: Accepted

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

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

	print(Ans)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 10 ** 7

di = R//2019 - L//2019

L=L%2019
R=R%2019



if(di == 0):
    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())
m=200000

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
l, r = map(int, input().split())
count = int()
baff = set()
if l <= 3 and r >= 673:
    print(0)
else:
    for i in range(l, r + 1):
        for j in range(i + 1, r + 1):
                baff.add((i * j) % 2019)
                if (i * j) % 2019 == 0:
                    break
        else:
            continue
        break
    print(min(baff))

Submission status: Accepted

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