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:
L, R = (int(i) for i in input().split())

if (R - L) <= 2019:
    temp1 = float("inf")
    for i in range(R - L):
        for j in range(R - L):
            temp2 = ((R-i) * (R - 1 -j)) % 2019
            if temp2 < temp1:
                temp1 = temp2
    print(temp1)
else:
    temp1 = float("inf")
    for i in range(2019):
        if (R-i-1) < L:
            break
        for j in range(R - L):
            temp2 = ((R - i) * (R - 1 - j)) % 2019
            if temp2 < temp1:
                temp1 = temp2
    print(temp1)

Submission status: Time Limit Exceeded

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

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

if a==0:
    print(a)
else:
    print(min(x))

Submission status: Time Limit Exceeded

Solution code:
S=input().split()
L=int(S[0])
R=int(S[1])
list=2018
L1=L
L2=L
while L2 <= R:
  while L1 < L2:
    if (L1*L2)%2019 <= list:
      list = (L1*L2)%2019
    L1 += 1
  L1 =int(L)
  L2 += 1
print(list)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
l,r = map(int,input().split())
 
if r-l >= 2019:
  ans = 0
else:
  mod_l = l % 2019  
  mod_r = r % 2019
  if mod_r < mod_l:
    ans = 0
  elif mod_l * mod_r == 0:
    ans = 0
    
  else:
    l_list=[]
    a = list(range(mod_l, mod_r+1))
    for i in range(len(a)):
      ai = a[i]
      for j in range(len(a)):
        aj = a[j]
        if (ai - aj) != 0:
          l = (ai*aj) % 2019
          l_list.append(l)
          ans = min(l_list)
    
print(ans)

Submission status: Time Limit Exceeded

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

min_mod = 2018
for key, i in enumerate(range(L, R+1)):
    t = R - key
    for j in range(L, t):
        mod = (t * j) % 2019
        if mod < min_mod:
            min_mod = mod
        
        if min_mod == 0:
            break

print(min_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):
    aa = i * j
    aaa = aa % 2019
    
    if aaa < ans:
      ans = aaa
      
print(ans)

Submission status: Time Limit Exceeded

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

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

print(min)

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):
		t = i*j%2019
		if m>t:
			m=t
print(m)

Submission status: Time Limit Exceeded

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

minnum = 3000
a = 3000
b = 3000
count = 0
for i in range(4050):
    for j in range(i+1,4051):
        c = ((l + i)*(l + j))%2019
        a = min(a,c)
        b = min(max(a,c),b)
print(a*b)

Submission status: Time Limit Exceeded

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

min_mod = 2018
for key, i in enumerate(range(L, R+1)):
    t = R - key
    for j in range(L, t):
        mod = (t * j) % 2019
        if mod < min_mod:
            min_mod = mod

print(min_mod)

Submission status: Time Limit Exceeded

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


MOD=[0] * (2019*2019)

def myidx(i,j):
    return i * 2019 + j

for i in range(2019):
    for j in range(2019):
        idx = myidx(i,j)
        MOD[idx] = (i*j) % 2019

for i in range(2019):
    idx = myidx(i,i)
    MOD[idx] = 2019

MMM = []
Lmod = L % 2019
Rmod = R % 2019

if L+2019 <= R:
    for i in range(2019):
        for j in range(i+1,2019):
            idx = myidx(i,j)
            MMM.append(MOD[idx])
elif Lmod <= Rmod:
    for i in range(Lmod, Rmod+1):
        for j in range(i+1, Rmod+1):
            idx = myidx(i,j)
            MMM.append(MOD[idx])

elif Lmod > Rmod:
    for i in list(range(0,Rmod+1)) + list(range(Lmod, 2019)):
        for j in list(range(i+1,Rmod+1)) + list(range(i+1, 2019)):
            idx = myidx(i,j)
            MMM.append(MOD[idx])

MMM=list(set(MMM))
MMM.sort()
print(MMM.pop(0))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
#import numpy as np

def main():
    L, R = list(map(int, input().split()))
    minmod = 10000000
    for i in range(L, R):
        for j in range(i+1, R+1):
            prod = i * j
            mod = prod % 2019
            #mod = np.mod([prod], 2019)[0]
            if mod < minmod:
                minmod = mod
    print(minmod)

main()

Submission status: Time Limit Exceeded

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

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

if a==0:
    print(a)
else:
    print(min(x))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
def main():
    L,R = map(int,input().split())
    LR = R-L
    M = []
    for i in range(LR):
        for j in range(LR):
            M.append(((L+i)*(L+1+j))%2019)
    print(min(M))
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
A,B=map(int,input().split())
mod = 2018

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)

print(mod)

Submission status: Time Limit Exceeded

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


MOD=[0] * (2019*2019)

def myidx(i,j):
    return i * 2019 + j

for i in range(2019):
    for j in range(2019):
        idx = myidx(i,j)
        MOD[idx] = (i*j) % 2019

for i in range(2019):
    idx = myidx(i,i)
    MOD[idx] = 2019

MMM = []
Lmod = L % 2019
Rmod = R % 2019

if L+2019 <= R:
    for i in range(2019):
        for j in range(i+1,2019):
            idx = myidx(i,j)
            MMM.append(MOD[idx])
elif Lmod <= Rmod:
    for i in range(Lmod, Rmod+1):
        for j in range(i+1, Rmod+1):
            idx = myidx(i,j)
            MMM.append(MOD[idx])

elif Lmod > Rmod:
    for i in list(range(0,Rmod+1)) + list(range(Lmod, 2019)):
        for j in list(range(i+1,Rmod+1)) + list(range(i+1, 2019)):
            idx = myidx(i,j)
            MMM.append(MOD[idx])

MMM.sort()
print(MMM.pop(0))

Submission status: Time Limit Exceeded

Solution code:
S=input().split()
L=int(S[0])
R=int(S[1])
list=2018
L1=L
L2=L
while L2 <= R:
  while L1 < L2:
    if (L1*L2)%2019 <= list:
      list = (L1*L2)%2019
    L1 += 1
  L1 =int(L)
  L2 += 1
print(list)

Submission status: Time Limit Exceeded

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

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

print(min_mod)

Submission status: Time Limit Exceeded

Solution code:
L,R=map(int,input().split())
num=2018
for i in range(L,R):
    for k in range(i+1,R+1):
        #print(k*i)
        if(i*k%2019==0):
            num=0
            break
        num=min(num,i*k%2019)
    #print("##")
print(num)

Submission status: Time Limit Exceeded

Solution code:
L, R = map(int, input().split())
I = range(L, R)
J = range(L + 1, R + 1)

ans = []
a = 0
for i in I:
    for j in J:
        a = i * j % 2019
        ans.append(a)
        if (a == 0):
            break
            
print(min(ans))

Submission status: Time Limit Exceeded

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

ans = 2020

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

Submission status: Time Limit Exceeded

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


MOD=[0] * (2019*2019)

def myidx(i,j):
    return i * 2019 + j

for i in range(2019):
    for j in range(2019):
        idx = myidx(i,j)
        MOD[idx] = (i*j) % 2019

for i in range(2019):
    idx = myidx(i,i)
    MOD[idx] = 2019

MMM = []
Lmod = L % 2019
Rmod = R % 2019

if L+2019 <= R:
    MMM = MOD
elif Lmod <= Rmod:
    for i in range(Lmod, Rmod+1):
        for j in range(i+1, Rmod+1):
            idx = myidx(i,j)
            MMM.append(MOD[idx])

elif Lmod > Rmod:
    for i in list(range(0,Rmod+1)) + list(range(Lmod, 2019)):
        for j in list(range(i+1,Rmod+1)) + list(range(i+1, 2019)):
            idx = myidx(i,j)
            MMM.append(MOD[idx])

MMM.sort()
print(MMM.pop(0))

Submission status: Time Limit Exceeded

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

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

print(result)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

# n mod 2019 の答えは 0 ~ 2018 のいずれか
# それぞれのmodを取った積のmodでも同じ答えになる


def get_ans():
    # 差が2018以上なら積が0の組み合わせが存在する
    if R - L >= 2018:
        return 0

    # 各値のmodを取ってユニークにする
    # mods = np.mod(np.arange(L, R + 1), 2019)
    mods = np.array([n % 2019 for n in range(L, R + 1)])
    u_mods = np.unique(mods)

    length = len(u_mods)
    # 総当たり
    ans = 2019
    for X in range(length - 1):
        for Y in range(X + 1, length):
            mod = (u_mods[X] * u_mods[Y]) % 2019
            if mod < ans:
                ans = mod
    return ans


print(get_ans())

Submission status: Time Limit Exceeded

Solution code:
A,B=map(int,input().split())
mod = 2018

for i in range(A,B):
  x = i % 2019
  for j in range(i+1,B+1):
    mod = min(mod, (x*j)%2019)

print(mod)

Submission status: Time Limit Exceeded

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

i = l-1
j = l
mod = l * (l+1)

while i < r:
  i += 1
  while j <= r:
    if i*j < 2019:
      break
    if i < j :
      result = (i * j) % 2019
      if result <= mod:
        mod = result  
    j += 1
    if j > r:
      j = i
      break
    
print(mod)

Submission status: Time Limit Exceeded

Solution code:
L,R = [int(x) for x in input().split()]
 
#L = input_arr[0]
#R = input_arr[1]
 
min_ans = 10**18
for i in range(L,R):
    for j in range(i+1,R+1):
        ans = (i*j)%2019
        
        if ans < min_ans:
            min_ans = ans
        if min_ans == 0:
            break
print(min_ans)

Submission status: Time Limit Exceeded

Solution code:
L, R = map(int, input().split())
I = range(L, R)
J = range(L + 1, R + 1)

ans = []
a = 0
for i in I:
    for j in J:
        a = i * j % 2019
        ans.append(a)
        if (a < 1):
            break
            
print(min(ans))

Submission status: Time Limit Exceeded

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
print("{}".format(min))

Submission status: Time Limit Exceeded

Solution code:
import itertools

l,r=map(int, input().split())
lis1 = []

for i in range(l,r+1):
      lis1.append(i)

lis2=[]

for v in itertools.combinations(lis1, 2):
      lis2.append(v[0]*v[1]%2019)
    
print(min(lis2))

Submission status: Time Limit Exceeded

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


MOD=[0] * (2019*2019)

def myidx(i,j):
    return i * 2019 + j

for i in range(2019):
    for j in range(2019):
        idx = myidx(i,j)
        MOD[idx] = (i*j) % 2019

for i in range(2019):
    idx = myidx(i,i)
    MOD[idx] = 2019

MMM = []

if L+2019 <= R:
    MMM = MOD

Lmod = L % 2019
Rmod = R % 2019
if Lmod <= Rmod:
    for i in range(Lmod, Rmod+1):
        for j in range(i+1, Rmod+1):
            idx = myidx(i,j)
            MMM.append(MOD[idx])

if Lmod > Rmod:
    for i in list(range(0,Rmod+1)) + list(range(Lmod, 2019)):
        for j in list(range(i+1,Rmod+1)) + list(range(i+1, 2019)):
            idx = myidx(i,j)
            MMM.append(MOD[idx])

MMM.sort()
print(MMM.pop(0))

Submission status: Time Limit Exceeded

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

minimum = 2019
checked = set()

start = L
end   = R+1

for i in range(start, end):
    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: Time Limit Exceeded

Solution code:
input_arr = [int(x) for x in input().split()]
 
L = input_arr[0]
R = input_arr[1]
 
min_ans = 10**18
for i in range(L,R):
    for j in range(i+1,R+1):
        ans = (i*j)%2019
        
        if ans < min_ans:
            min_ans = ans
        if min_ans == 0:
            break
print(min_ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

def main():
    L, R = list(map(int, input().split()))
    minmod = 10000000
    for i in range(L, R):
        for j in range(i+1, R+1):
            prod = i * j
            #mod = prod % 2019
            mod = np.mod([prod], 2019)[0]
            if mod < minmod:
                minmod = mod
    print(minmod)

main()

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)
        if y==0:
            a=0
            break
        x.append(y)

if a==0:
    print(a)
else:
    print(min(x))

Submission status: Time Limit Exceeded

Solution code:
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
                break
            tmp = (i*j) % 2019
            if tmp <= ans:
                ans = tmp

print(ans)

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

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

print(min_mod)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

# n mod 2019 の答えは 0 ~ 2018 のいずれか
# それぞれのmodを取った積のmodでも同じ答えになる


def get_ans():
    # 差が2018以上なら積が0の組み合わせが存在する
    if R - L >= 2018:
        return 0

    # 各値のmodを取ってユニークにする
    mods = np.mod(np.arange(L, R + 1), 2019)
    u_mods = np.unique(mods)

    length = len(u_mods)
    # 総当たり
    ans = 2019
    for X in range(length - 1):
        for Y in range(X + 1, length):
            mod = (u_mods[X] * u_mods[Y]) % 2019
            if mod < ans:
                ans = mod
    return ans


print(get_ans())

Submission status: Time Limit Exceeded

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


MOD=[0] * (2019*2019)

def myidx(i,j):
    return i * 2019 + j

for i in range(2019):
    for j in range(2019):
        idx = myidx(i,j)
        MOD[idx] = (i*j) % 2019

for i in range(2019):
    idx = myidx(i,i)
    MOD[idx] = 2019

MMM = []

if L+2019 <= R:
    MMM = MOD

Lmod = L % 2019
Rmod = R % 2019
if Lmod <= Rmod:
    for i in range(Lmod, Rmod+1):
        for j in range(i+1, Rmod+1):
            idx = myidx(i,j)
            MMM.append(MOD[idx])

if Lmod > Rmod:
    for i in list(range(0,Rmod+1)) + list(range(Lmod, 2019)):
        for j in list(range(i+1,Rmod+1)) + list(range(Lmod, 2019)):
            idx = myidx(i,j)
            MMM.append(MOD[idx])

MMM.sort()
print(MMM.pop(0))

Submission status: Time Limit Exceeded

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

COUNT=2019
NUMBER=0

for i in range(L,R+1):
  for j in range(i+1,R+1):
    
    NUMBER=i*j%2019
    #print(i,j,NUMBER)
    if COUNT>NUMBER:
      COUNT=NUMBER
      #print(i,j,NUMBER)

    
print(COUNT)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
l, r = list(map(int,input().split()))
Set = set([l%2019])
for i in range(r-l):
	Set.add((l+1+i)%2019)
List = list(Set)
answer = (l * r) % 2019
for i in range(len(List)):
	for j in range(len(List)):
		if(i < j):
			if(answer > (List[i] * List[j])% 2019):
				answer = (List[i] * List[j])% 2019
print(answer)

Submission status: Time Limit Exceeded

Solution code:
def main():
    L, R = list(map(int, input().split()))
    minmod = 10000000
    for i in range(L, R):
        for j in range(i+1, R+1):
            prod = i * j
            mod = prod % 2019
            if mod < minmod:
                minmod = mod
    print(minmod)

main()

Submission status: Time Limit Exceeded

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

x=0
y=2019



for i in range(l,r+1):
    for j in range(i+1,r+1):
        #print(i,j)
        x=(i*j)%2019
        if y > x:
            y=x
print(y)

Submission status: Time Limit Exceeded

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


ans = 2018
if l-n >= 672:
    ans = 0
else:
    ll = l % 2019
    for i in range(ll,ll + n-l +1):
        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: Time Limit Exceeded

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, R+1):
                x=(i*j) %2019
                lis.append(x)
        lis=np.array(lis)
        ans=lis.min()
        print(ans)


minimize()

Submission status: Time Limit Exceeded

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


MOD=[0] * (2019*2019)

def myidx(i,j):
    return i * 2019 + j

for i in range(2019):
    for j in range(2019):
        idx = myidx(i,j)
        MOD[idx] = (i*j) % 2019

for i in range(2019):
    idx = myidx(i,i)
    MOD[idx] = 2019

MMM = []

if L+2019 <= R:
    MMM = MOD

Lmod = L % 2019
Rmod = R % 2019
if Lmod <= Rmod:
    for i in range(Lmod, Rmod+1):
        for j in range(Lmod, Rmod+1):
            idx = myidx(i,j)
            MMM.append(MOD[idx])

if Lmod > Rmod:
    for i in list(range(0,Rmod+1)) + list(range(Lmod, 2019)):
        for j in list(range(0,Rmod+1)) + list(range(Lmod, 2019)):
            idx = myidx(i,j)
            MMM.append(MOD[idx])

MMM.sort()
print(MMM.pop(0))

Submission status: Time Limit Exceeded

Solution code:
def make_list(L, R):
    mod_list = list()

    if R - L <= 2019:
        for i in range(L, R):
            for j in range(i + 1, R + 1):
                mod_list.append((i * j) % 2019)
    else:
        for i in range(L, R):
            for j in range(i + 1, i + 2021):
                mod_list.append((i * j) % 2019)

    return mod_list


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

    mod_list = make_list(L, R)

    print(min(mod_list))

    return


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
a = input().split()
li = [int(i)for i in a]
an = [(j*i)%2019 for i in range(li[0],li[1]) for j in range(i+1,li[1]+1)]
print(min(an))

Submission status: Time Limit Exceeded

Solution code:
"""
#include <stdio.h>
int main(){
  int l, r, ans=99999;
  int lst[99999];
  scanf("%d",&l);
  scanf("%d",&r);
  l %= 2019;
  r %= 2019;
  for(int i=l;i<r;i++){
    for(int j=i+1;j<r+1;j++){
      if(ans>(i*j)%2019){
        ans = (i*j)%2019;
        //printf("%d\n",ans);
      }
    }
  }
  printf("%d\n",ans);

}
/*"""
l, r = map(int, input().split())

r -= 2019*(l//2019)
l %= 2019


#lst = []
sum = 9999999999
#lm = 99999999999
#rm = 99999999999
#for 
#print(l%2019)

for i in range(l,r):
  for j in range(i+1,r+1):
    #lst.append(i*j%2019)
    if sum > i*j%2019:
      sum = i*j%2019
print(sum)

#*/

Submission status: Time Limit Exceeded

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


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

print(ans)

Submission status: Time Limit Exceeded

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

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

print(min)

Submission status: Time Limit Exceeded

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

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
  if d==0:
   break

print(d)

Submission status: Time Limit Exceeded

Solution code:
L,R = map(int,input().split())
S = set()
T = set()
if (R-L)>=673:
    print(0)
else:
    l = L%2019
    for i in range(R-L+1):
        S = S | {l+i}
    for i in S:
        for j in S:
            if i != j:
                T = T | {(i*j)%2019}
    print(min(T))

Submission status: Time Limit Exceeded

Solution code:
l, r = map(int, input().split())
x = []
y = []
 
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: Time Limit Exceeded

Solution code:
import itertools
L, R = map(int, input().split())
 
remainder_list = [N%2019 for N in range(L, R+1)]
all_list = [(i*j)%2019 for i, j in list(itertools.combinations(remainder_list, 2))]
print(min(all_list))

Submission status: Time Limit Exceeded

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

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

print(min(x))

Submission status: Time Limit Exceeded

Solution code:
import itertools

l,r=map(int, input().split())
lis1 = []

for i in range(l,r+1):
      lis1.append(i)

lis2=[]

for v in itertools.permutations(lis1, 2):
    lis2.append(v[0]*v[1]%2019)
    
print(min(lis2))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

I = 0
J = 0
now = 0
mod = 2019

for i in range(R-L):
    if(L+i % 2019 == 0):
        mod = 0
        break
    for j in range(R-L-i):
        if (L + i + j + 1 % 2019 == 0):
            mod = 0
            break
        I = L + i
        J = L + i + j + 1
        now = (I * J) % 2019
        if(now < mod):
            mod = now
        if(mod == 0):
            break


print(mod)

Submission status: Time Limit Exceeded

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

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

print(min)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

min_ans = 10**9

for l in range(L, R):
    l_mod = l % mod
    for r in range(L + 1, R + 1):
        r_mod = r % mod
        ans = (l_mod * r_mod) % mod
        min_ans = ans if ans < min_ans else min_ans

print(min_ans)

Submission status: Time Limit Exceeded

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
l, r = map(int, input().split())
x = []
y = []
 
for i in range(l, r):
  for j in range(i+1, r+1):
    m = i * j % 2019
    x.append(m)
    y.append(i*j)

print(min(x))

Submission status: Time Limit Exceeded

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

x = range(L, R + 1)

minimum = 2018
for i in range(len(x) - 1):
  for j in range(i + 1, len(x)):
    minimum = min(minimum, x[i] * x[j] % 2019)
    if minimum == 0:
      break

print(minimum)

Submission status: Time Limit Exceeded

Solution code:
import itertools

L, R = map(int, input().split())
A = [L+i for i in range(R-L+1)]
abs_A = []

for x in itertools.combinations(A, 2):
    abs_A.append((x[0]*x[1])%2019)

print(sorted(abs_A)[0])

Submission status: Time Limit Exceeded

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

mod = []
for i in range(l, r):
  for j in range(i+1, r+1):
    mod.append((i*j)%2019)
print(min(mod))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

z=min(x)
print(z)

Submission status: Time Limit Exceeded

Solution code:
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
print(mod)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
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):
#             print(i, j)
            tmp = (i*j) % 2019
            if tmp <= ans:
                ans = tmp

print(ans)

Submission status: Time Limit Exceeded

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

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

print(min)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

x = range(L, R + 1)

minimum = 2018
for i in range(len(x) - 1):
  for j in range(i + 1, len(x)):
    minimum = min(minimum, x[i] * x[j] % 2019)

print(minimum)

Submission status: Time Limit Exceeded

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

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

print(minv)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
import math

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

count = 0
dif2sum = 0
ans = 2020
for i in range(l, r):
    for j in range(i + 1, r + 1):
        tmp = i * j % 2019
        if ans > tmp:
            ans = tmp
    
print(ans)

Submission status: Time Limit Exceeded

Solution code:
l,r = map(int,input().split())
mods = l*r
for i in range(l,r+1):
    for j in range(l,i+1):
        if i == j:
            continue
        else:
            q, mod = divmod(i*j, 2019)
            mods = min(mod,mods)
print(mods)

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
L, R = map(int, input().split())
mn = 0
res = 2*(10**9)
for i in range(L, R + 1):
    for j in range(L, R + 1):
        if i == j: continue
        mn = (i * j) % 2019
        if mn < res:
            res = mn
print(res)

Submission status: Time Limit Exceeded

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

i = l-1
j = l
mod = r ** 2

while i < r:
  i += 1
  while j <= r:
    if i < j:
      result = (i * j) % 2019
      if result <= mod:
        mod = result  
    j += 1
    if j > r:
      j = i
      break
    
print(mod)