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: Time Limit Exceeded

Solution code:
import math
L,R=map(int,input().split())
x=[]

for i in range(L,R):
    for j in range(i+1,R+1):
        x.append((i*j)%2019)

print(min(x))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
L,R=map(int,input().split())
li=[]
for i in range(L,R):
  for j in range(i+1,R+1):
    q,mod=divmod(i*j, 2019)
    li.append(mod)
    if i ==j:
      break
print(min(li))

Submission status: Time Limit Exceeded

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

n = R - L
rep = 100000
for i in range(n):
    i += L
    for j in range(n-(i-L)):
        j += i+1
        ans = (i*j) % 2019
        if rep > ans:
            rep = ans

print(rep)

Submission status: Time Limit Exceeded

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

d=2018
for i in range(R-L+1):
  a=L+i
  for j in range(R-a):
    b=a+j+1
    c=(a*b)%2019
    if c<d:
      d=c
print(d)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
L, R = map(int, input().split())
l = []
frag = False
if R - L >= 2019:
    l.append(0)
    frag = True
for i in range(L, R):
    if frag: break
    for j in range(i+1, R+1):
        l.append((i*j) % 2019)
        n = len(l)
        if n % 2 == 0:
            if l[:n//2] == l[n//2:]:
                frag = True
                break
print(min(l))

Submission status: Time Limit Exceeded

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
L, R = map(int, input().split())
ans = float("inf")
frag = False
if R - L >= 2018:
    ans = 0
for i in range(L, R):
    for j in range(i+1, R+1):
        ans = min(ans, (i*j)%2019)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
L, R = map(int, input().split())
l = []
frag = False
if R - L >= 2019:
    l.append(0)
    frag = True
for i in range(L, R):
    for j in range(i+1, R+1):
        l.append((i*j) % 2019)
        n = len(l)
        if n % 2 == 0:
            if l[:n//2] == l[n//2:]:
                frag = True
                break
    if frag: break

print(min(l))

Submission status: Time Limit Exceeded

Solution code:
L, R = map(int, input().split())
l = []
frag = False
for i in range(L, R):
    for j in range(i+1, R+1):
        l.append((i*j) % 2019)
        n = len(l)
        if n % 2 == 0:
            if l[:n//2] == l[n//2:]:
                frag = True
                break
    if frag: break

print(min(l))

Submission status: Time Limit Exceeded

Solution code:
import itertools
import sys

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

if c<2019:
  print(L*(L+1))
  sys.exit()

else:
  l = []
  for i in range(0,R-L+1):
    l.append(L+i)
    if L+i % 2019==0:
      print("0")
      sys.exit()
    
  mylist = list(itertools.combinations(l, 2))
  
    
  mod_list=[]

  for i in range(len(mylist)):
    a = mylist[i][0]
    b = mylist[i][1]
    t = a*b
    if t%2019==0:
      print("0")
      sys.exit()
    q, mod = divmod(t, 2019)
    mod_list.append(mod)

  if i == len(mylist)-1:
  	print(min(mod_list))

Submission status: Time Limit Exceeded

Solution code:
import itertools
import sys

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

if c<2019:
  print(L*(L+1))
  

else:
  l = []
  for i in range(0,R-L+1):
    l.append(L+i)
    if L+i % 2019==0:
      print("0")
      sys.exit()
    
  mylist = list(itertools.combinations(l, 2))
  
    
  mod_list=[]

  for i in range(len(mylist)):
    a = mylist[i][0]
    b = mylist[i][1]
    t = a*b
    if t%2019==0:
      print("0")
      break
    q, mod = divmod(t, 2019)
    mod_list.append(mod)

  if i == len(mylist)-1:
  	print(min(mod_list))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
a = list(map(int, input().split()))
b = 0
c = 10000

L = int(a[0])
R = int(a[1])

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

Submission status: Time Limit Exceeded

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

R = min(R, L + 4038)

i = L
res = 2019
while i < R:
    j = i + 1
    while j <= R:
        res = min(res, i * j % 2019)
        j += 1
    i += 1

print(res)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

tmp = float("inf")

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

Submission status: Time Limit Exceeded

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

ans = 100000000000
check = False

for i in range(a, b):
    if check:
        break
    for j in range(i + 1, b + 1):
        if (i * j) % 2019 < ans:
            ans = (i * j) % 2019

print(ans)

Submission status: Time Limit Exceeded

Solution code:
a = [ int(i) for i in input().split()]

b = (a[0]*a[1]) % 2019

for i in range (a[0], a[1]):
  for j in range (i+1, a[1]+1):
    b = min (b, (i*j)%2019)
    if b == 0:
      break
    
print(b)

Submission status: Time Limit Exceeded

Solution code:
a = [ int(i) for i in input().split()]

b = (a[0]*a[1]) % 2019

for i in range (a[0], a[1]):
  for j in range (i+1, a[1]+1):
    if (i*j)%2019 < b:
      b = (i*j)%2019
      
print(b)

Submission status: Time Limit Exceeded

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

ans = 2019
for i in range(l, r):
    for j in range(r, l-1, -1):
        if i == j:
            break
        mod = (i * j) % 2019
        if mod < ans:
            ans = mod
    if ans == 0:
        break
print(ans)

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

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)
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

hasamu=R-L
kotae=10000
if hasamu>2017:
  kotae=0

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

Submission status: Time Limit Exceeded

Solution code:
s = list(map(int, input().strip().split(' ')))
L = s[0]
R = s[1]
ans = 2020

for i in range(1, 100):
    a = 2019 * i
    if L < a:
        i = i - 1
        a = 2019 * i
        L = L - a
        break
for i in range(1, 100):
    a = 2019 * i
    if R < a:
        i = i - 1
        a = 2019 * i
        R = R - a
        break

if L > R:
    temp = R
    R = L
    L = temp

for i in range(0, R - L):
    for j in range(0, R - L):
        x = L + i
        y = L + 1 + j
        z = (x * y) % 2019
        if ans > z:
            ans = z

if R == 0 or L == 0:
    print(0)
else:
    print(ans)

Submission status: Time Limit Exceeded

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

# Rが2019未満のとき
if R < 2019 :
    print((L * (L + 1)) % 2019)
# 範囲内に2019を含む時
elif L <= 2019 and R >= 2019 :
    print(0)
# LもRも2019より高い場合
else :
    R = min(R, L + 4038)
    ans = 2018
    for i in range(L,R + 1):
        for j in range(i + 1,R + 1):
            x = (i * j) % 2019
            ans = min(ans, x)
    print(ans)

Submission status: Time Limit Exceeded

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

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

print(mod_min)

Submission status: Time Limit Exceeded

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

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

print(a)

Submission status: Time Limit Exceeded

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

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

print(a)

Submission status: Time Limit Exceeded

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

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

print(min(a))

Submission status: Time Limit Exceeded

Solution code:
L,R = list(map(int,input().split()))
a = 2018
b = L
c = L+1
for i in range(R-L):
    for j in range(R-L-i):
        c = b+j+1
        if a > b*c%2019:
            a = b*c%2019
    b = b + 1

print(a)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8

import sys
import math
import collections
import itertools
def input(): return sys.stdin.readline().strip()
def gcd(x, y): return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y): return (x * y) // gcd(x, y)
MOD = 10 **9 + 7

# N = int(input())
# S = input()
L, R = map(int, input().split())
# 横
# L = [int(x) for x in input().split()]
# 縦
# A = [int(input()) for _ in range(N)]
# 多次元
# L = [[int(x) for x in input().split()] for _ in range(N)]
ans = 3000

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

Submission status: Time Limit Exceeded

Solution code:
L,R = map(int,input().split())
ans = 100000000
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: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import itertools

n = list(map(int,input().split()))

answer = 2019

mylist = []
for i in range(n[1]-n[0]+1):
    mylist.append(n[0]+i)

for element in itertools.combinations(mylist,2):
    mod = (element[0] * element[1]) % 2019
    if(mod < answer):
        answer = mod

print(answer)

Submission status: Time Limit Exceeded

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

if L-R > 2018:
    print(0)
else:
    minMod = 100000000
    for i in range(L,R):

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

import math

#L<=i<j<=R
# i*j mod 2019の最小値

if L - R > 2020:
    L = 0
    R = 2019

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

Submission status: Time Limit Exceeded

Solution code:
def main():
    N, M = map(int, input().split())
    ans = -1
    for n in range(M)[N:]:
        for i in range(M + 1)[n + 1:]:
            mod = n * i % 2019
            if ans < 0 or mod < ans:
                ans = mod
        if mod == 0:
            break
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def main():
    N, M = map(int, input().split())
    ans = -1
    for n in range(M)[N:]:
        for i in range(M + 1)[n + 1:]:
            mod = n * i % 2019
            if ans < 0 or mod < ans:
                ans = mod
                if mod == 0:
                    break
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def main():
    N, M = map(int, input().split())
    ans = -1
    for n in range(M)[N:]:
        for i in range(M + 1)[n + 1:]:
            mod = n * i % 2019
            if ans < 0 or mod < ans:
                ans = mod
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
p=m=2019;A=[[0]*p]*p;a,b=[int(x)for x in input().split()]
for i in range(a,b+1):
    for j in range(i+1,b+1):
        k,l=i%p,j%p;m=min(m,k*l%p)
print(m)

Submission status: Time Limit Exceeded

Solution code:
import sys
L,R=map(int,input().split())
if R-L>2019:
    print(0)
    sys.exit()
c1=R-L
for i in range(L,R+1):
    if i%2019==0:
        print(0)
        sys.exit()
    if c1>2 and i%673==0:
        print(0)
        sys.exit

ls1=[]
for i in range(L,R+1):
    ls1.append(i%2019)
    m=2018
    for i in range(len(ls1)-1):
        for j in range(i+1,len(ls1)):
            m1=(ls1[i]*ls1[j])%2019
            m=min([m1,m])
print(m)

Submission status: Time Limit Exceeded

Solution code:
mod=[]
answer = 2018
count = 0
sub=0
mod = [int(i) for i in input().split()]
if(mod[0]==mod[1]):
    answer = (mod[0]*mod[1])%2019

for i in range(mod[0],mod[1]+1):
    for j in range(i+1,mod[1]+1):
        sub = (i*j)%2019
        if sub<answer:
            answer = sub
    if count == 2018:
        break
    count = count + 1
print(answer)

Submission status: Time Limit Exceeded

Solution code:
L, R = map(int, input().split())
if R - L >= 2019:
    print(0)
result = float('inf')
for i in range(L, R):
    for j in range(i + 1, R + 1):
        mod = (i * j) % 2019
        if mod == 0:
            result = 0
            break
        elif mod < result:
            result = mod
print(result)

Submission status: Time Limit Exceeded

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

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

print(minmod)

Submission status: Time Limit Exceeded

Solution code:
def main():
    L, R = map(int, input().split())
    minCount = float('inf')

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

if __name__ == "__main__":
     main()

Submission status: Time Limit Exceeded

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

mini = 2020
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: Time Limit Exceeded

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

if R-L>=2018:
    print(0)
elif L==0:
    print(0)
elif L<=672 and R>=673:
    print(0)
elif L>=2019:
    p=R-L
    L=L%2019
    R=L+p
    
p=0
for i in range(L,R):
    for j in range(i+1,R+1):
        if p==0:
            ans=(i*j)%mod
        elif (i*j)%mod<ans:
            ans=(i*j)%mod
        p+=1
print(ans)

Submission status: Time Limit Exceeded

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

if L<=672 and R>=673:
    print(0)
elif L>=2019:
    p=R-L
    L=L%2019
    R=L+p
    
p=0
for i in range(L,R):
    for j in range(i+1,R+1):
        if p==0:
            ans=(i*j)%mod
        elif (i*j)%mod<ans:
            ans=(i*j)%mod
        p+=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
A=list(map(int,input().split()))
t=True
C=2019
if (A[1]-A[0])<2019:
    for i in range(A[1]):
        for t in range(A[1]+1):
            if t>i and i>=A[0]:
                if t*i%2019<C:
                        C=t*i%2019
else:
    C=0
print(C)

Submission status: Time Limit Exceeded

Solution code:
A=list(map(int,input().split()))
t=True
C=2019
if t:
    for i in range(A[1]):
        for t in range(A[1]+1):
            if t>i and i>=A[0]:
                if t*i%2019<C:
                        C=t*i%2019
                        if C==0:
                            t=False 
                            break
print(C)

Submission status: Time Limit Exceeded

Solution code:
A=list(map(int,input().split()))
t=True
C=2019
if t:
    for i in range(A[1]):
        for t in range(A[1]+1):
            if t>i and i>=A[0]:
                if t-i>=2019:
                    C=0
                    t=False
                    break
                else:
                    if t*i%2019<C:
                        C=t*i%2019
print(C)

Submission status: Time Limit Exceeded

Solution code:
L, R = map(int, input().split())
ans_l = []
for i in range(L,R):
    for j in range(i+1,R+1):
        ans = (i*j)%2019
        if ans !=0:
            ans_l.append(ans)
        else:
            ans_l.append(0)
            break;
print(min(ans_l))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

all_mod = []

for i in range(l, r, 1):
    cnt = 0
    for j in range(l + 1, r + 1, 1):
        mod = (i * j) % 2019
        all_mod.append(mod)

        cnt += 1

        if cnt > 2019:
            break
            
print(min(all_mod))

Submission status: Time Limit Exceeded

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)
print(ans)

Submission status: Time Limit Exceeded

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

LUT = [[(i*j)%2019 for i in range(2019)] for j in range(2019)]

ans = 2018
m = 2019
for i in range(l, r + 1):
  for j in range(i + 1, r + 1):
    ans = min(ans, LUT[i % m][j % m])
    if ans == 0:
      break
    
print(ans)

Submission status: Time Limit Exceeded

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

LUT = [[(i*j)%2019 for i in range(2019)] for j in range(2019)]

ans = 2018

for i in range(l, r + 1):
  for j in range(l, i):
    ans = min(ans, LUT[i % 2019][j % 2019])
    if ans == 0:
      break
    
print(ans)

Submission status: Time Limit Exceeded

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

LUT = [[(i*j)%2019 for i in range(2019)] for j in range(2019)]

ans = 2018

for i in range(l, r + 1):
  for j in range(i + 1, r + 1):
    ans = min(ans, LUT[i % 2019][j % 2019])
    if ans == 0:
      break
    
print(ans)

Submission status: Time Limit Exceeded

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

LUT = [[(i*j)%2019 for i in range(2019)] for j in range(2019)]

ans = 2019 ** 2

for i in range(l, r + 1):
  for j in range(i + 1, r + 1):
    ans = min(ans, LUT[i % 2019][j % 2019] % 2019)
    if ans == 0:
      break
    
print(ans)

Submission status: Time Limit Exceeded

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

LUT = [[(i*j)%2019 for i in range(2019)] for j in range(2019)]

ans = 2019 ** 2

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

Submission status: Time Limit Exceeded

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

ans = 2019 ** 2

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

Submission status: Time Limit Exceeded

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

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

print(m)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ans = 2019

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# -*- encoding : UTF-8 -*-
l, r = list(map(int, input().split()))

mod_min = 2018

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

print(mod_min)

Submission status: Time Limit Exceeded

Solution code:
firstvar = input()
l = int(firstvar.split(" ")[0])
r = int(firstvar.split(" ")[1])
i = l
min = 2019
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;
        j = j + 1
    i = i + 1
print(min)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
firstvar = input()
l = int(firstvar.split(" ")[0])
r = int(firstvar.split(" ")[1])
i = l
min = 2019
while i <= r:
    j = i + 1
    while j <= r:
        mod = (i*j)%2019
        if mod < min:
            min = mod
            if mod == 0:
                break;
        j = j + 1
    i = i + 1
print(min)

Submission status: Time Limit Exceeded

Solution code:
firstvar = input()
l = int(firstvar.split(" ")[0])
r = int(firstvar.split(" ")[1])
i = l
min = 2019
while i <= r:
    j = i + 1
    while j <= r:
        mod = (i*j)%2019
        if mod < min:
            min = mod
        j = j + 1
    i = i + 1
print(min)

Submission status: Time Limit Exceeded

Solution code:
import copy
firstvar = input()
l = int(firstvar.split(" ")[0])
r = int(firstvar.split(" ")[1])
i = copy.deepcopy(l)
min = 2019
while i <= r:
    j = copy.deepcopy(i) + 1
    while j <= r:
        mod = (i*j)%2019
        if mod < min:
            min = copy.deepcopy(mod)
        j = j + 1
    i = i + 1
print(min)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
L,R = map(int,input().split())
mods = set()
for i in range(L,R):
  for j in range(i+1,R+1):
    mods.add(i*j%2019)
print(min(mods))

Submission status: Time Limit Exceeded

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

if l > r:
    l, r = r, l

mod = 2020

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

Submission status: Time Limit Exceeded

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

if l > r:
    l, r = r, l

mod = 2020

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

print(mod)

Submission status: Time Limit Exceeded

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

lenD = 0
D = []

it = L
while(it<=R):
    D.append(it%2019)
    lenD += 1
    if lenD>=2019*2:break
    it += 1

ans = 2019
for i in range(lenD):
    for j in range(i+1,lenD):
        a = (D[i]*D[j]) % 2019
        if ans > a:
            ans = a
            
print(ans)

Submission status: Time Limit Exceeded

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

D = []

it = L
while(it<=R):
    D.append(it%2019)
    if len(D)>=2019*2:break
    it += 1

ans = 2019
for i in range(len(D)):
    for j in range(i+1,len(D)):
        a = (D[i]*D[j]) % 2019
        if ans > a:
            ans = a
            
print(ans)

Submission status: Time Limit Exceeded

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

D = []

for i in range(L,R+1):
    D.append(i%2019)
    if len(D)>=4038:
        break

ans = 2019
for i in range(len(D)):
    for j in range(i+1,len(D)):
        a = (D[i]*D[j]) % 2019
        if ans > a:
            ans = a
            if ans==0:break
            
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

print(min(x))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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:
        ans = 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: Time Limit Exceeded

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 L - R >= 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)
    return ans

print(search_all())