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:
"""
#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())
#l %= 2019
#r %= 2019

#lst = []
sum = 999999
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, R = list(map(int, input().split()))
a = (L * (L + 1)) % 2019
for i in range(L, R + 1):
    for j in range(i + 1, R + 1):
        if (i * j) % 2019 < a:
            a = (i * j) % 2019
print(a)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

L = inp[0]
R = inp[1]


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


print(min(mod))

Submission status: Time Limit Exceeded

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

for i in range(L,R):
    for j in range(i+1,R+1):
        lst.append(int((i*j)%2019))
print(min(lst))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

# if L == R:
#     tmp = L % MOD
#     print(tmp*tmp)
# else:
#     a = np.array(range(L, R+1)) % MOD
#     b = np.sort(a,kind='quicksort')
#     print(b[0]*b[1])

minMOD = 2019
# minMOD2 = 2019
#
# for i in range(L, R+1):
#     tmp = i % MOD
#     if tmp == 0:
#         minMOD = 0
#         break
#
#     if tmp < minMOD:
#         minMOD = tmp
#     elif tmp < minMOD2:
#         minMOD2 = tmp

#print((minMOD * minMOD2) % MOD)

for i in range(L, R+1):
    for j in range(i+1, R+1):
        tmp = (i*j)%MOD
        if tmp < minMOD:
            minMOD = tmp
            if(tmp == 0):
                break

print(minMOD)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# 133C
"""
L<=i<=j<=R
(i×j)mod 2019
0≤L<R≤2×10^9
"""

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

min2019 = 2019
for i in range(L, R):
    for j in range(i+1, R+1):
        #print((i * j) % 2019)
        if (i * j) % 2019 == 2019:
            break
        elif (i * j) % 2019 < min2019:
            min2019 = (i * j) % 2019
            
print(min2019)

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

Submission status: Time Limit Exceeded

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

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

ans = float('inf')

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

print(ans)

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

print(d)

Submission status: Time Limit Exceeded

Solution code:
Low, Hight = (int(n) for n in input().split())
List = []

for n in range(Low, Hight+1):
    for j in range(n+1, Hight+1):
        if (n*j) > 2019:
            List.append((n*j)%2019)
        else:
            List.append(n*j)
print(min(List))

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

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

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

print(min(tmp))

Submission status: Time Limit Exceeded

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

m = None
for i in range(L, R+1):
    for j in range(i+1, R+1):
        n = (i*j) % 2019
        if m is None or n < m:
            m = n

print(m)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

minimize()

Submission status: Time Limit Exceeded

Solution code:
L, R = [int(i) for i in input().split()]
tmp = 2018
diff = R-L
for i in range(diff):
    ii = L+i
    for j in range(diff-i):
#         ii = L+i
        jj = R-j
        mod = ii*jj%2019
        #print(ii, jj, mod)
        if tmp>mod:
            tmp=mod
        if tmp==0:
            break
print(tmp)

Submission status: Time Limit Exceeded

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

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):
        for j in range(R-L):
            listA.append(i%2019 * (L%2019 + j+1) % 2019)
    print(min(listA))

Submission status: Time Limit Exceeded

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

ls = [2018]

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

    return a



print(yo())

Submission status: Time Limit Exceeded

Solution code:
import math
import itertools

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

num = []
for i in range(L,R+1):
	num.append(int(i))

min = 2018
for v in itertools.permutations(num, 2):
	i = v[0]
	j = v[1]
	if(i<j):
		imod = i % 2019
		jmod = j % 2019
		mod = imod*jmod % 2019
		if(mod < min):
			min = mod
			
print(min)

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):
    for j in range(R-L-i):
        I = L + i
        J = L + i + j + 1
        now = (I * J) % 2019
        if(now < mod):
            mod = now

print(mod)

Submission status: Time Limit Exceeded

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

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

print(a)

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

Submission status: Time Limit Exceeded

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

mod=2019

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

print(mod)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

tmp = R - L + 1
if tmp >= 2019:
    print(0)
    exit()
else:
    start = L % 2019
    end = R % 2019
    candidate = []
    for i in range(start, end + 1):
        candidate.append(i % 2019)
    candidate.sort()
    ans = []
    for i in range(len(candidate)):
        for j in range(len(candidate)):
            if i == j:
                continue
            else:
                ans.append((candidate[i] * candidate[j]) % 2019)
    ans.sort()
    print(ans[0])

Submission status: Time Limit Exceeded

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

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):
        for j in range(R-L):
            listA.append(i * (L%2019 + j+1) % 2019)
    print(min(listA))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
L, R = list(map(int, input().split(' ')))
t = [i for i in range(L, R+1)]
s = t[0] % 2019
x = []
x.append(s)
for i in range(1, len(t)):
    m = t[i] % 2019
    if s == m:
        break
    x.append(m)
min_v = 2018
for i in range(0, len(x)-1):
    tmp = np.amin(np.mod([x[i]*x[j] for j in range(i+1, len(x))], 2019))
    if tmp < min_v:
        min_v = tmp

print(min_v)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
L, R = [int(s) for s in 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:
import sys
import numpy as np 
def minimize():
    L, R=map(int,input().split())
    lis=[]
    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)

minimize()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
L, R = [int(i) for i in input().split()]
tmp = 2018
diff = R-L
for i in range(diff):
    ii = L+i
    for j in range(diff-i):
#         ii = L+i
        jj = R-j
        mod = ii*jj%2019
        #print(ii, jj, mod)
        if tmp>mod:
            tmp=mod
print(tmp)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
import sys
L, R = list(map(int, str(input()).split()))

output = 2 * pow(10,9)
for i in range(L,R+1):
    for j in range(i+1, R+1):
        if (i*j) % 2019 < output:
            output =  (i*j) % 2019
            if output == 0:
                break
print(output)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
raw_data = sys.stdin.readlines()

l = int(raw_data[0].split()[0])
r = int(raw_data[0].split()[1])

import math

min_mod = 2018
for val1 in range(l, r + 1):
    for val2 in range(val1 + 1, r + 1):
        product = val1 * val2
        mod = product % 2019
        if mod < min_mod:
            min_mod = mod

print(min_mod, end="")

Submission status: Time Limit Exceeded

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

idx1 = 0
listA = []
for idx1 in range(L, R):
  for idx2 in range(idx1 + 1, R + 1):
    listA.append(idx1 * idx2)

idx3 = 0
listB = []
for idx3 in range(len(listA)):
  listB.append(listA[idx3] % 2019)

print(min(listB))

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

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:
L,R= [int(i) for i in input().split()]
a = 2019
for i in range(L,R+1):
    for j in range(i+1,R+1):
        b = (i*j) % 2019
        if b<a:
            a = b
print(a)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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


print(a)

Submission status: Time Limit Exceeded

Solution code:
import sys
L,R = map(int,input().split())
mod = 2019
cnt = 0
ans = float('inf')
List = [False for i in range(2019)]
for i in range(L,R):
    for j in range(i+1,R+1):
        tmp = (i*j)%mod
        List[tmp] = True
        ans = min(tmp,L*R,ans)
        if all(List):
            print(ans)
            sys.exit()
print(ans)

Submission status: Time Limit Exceeded

Solution code:
L,R=map(int,input().split())
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:
import sys
import math
import itertools

input = sys.stdin.readline


def main():
    l, r = [int(i) for i in input().split()]
    num = set(list([i % 2019 for i in range(l, r + 1)]))
    min_ = 2019
    for i, j in itertools.combinations(num, 2):
        min_ = min([i * j % 2019, min_])
        if min_ == 0:
            break
    print(min_)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

l =[]

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

print(min(l))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math
import itertools

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

num = []
for i in range(L,R+1):
	num.append(int(i))

min = 2018
for v in itertools.permutations(num, 2):
	i = v[0]
	j = v[1]
	if(i<j):
		mod = i*j % 2019
		if(mod < min):
			min = mod
			
print(min)

Submission status: Time Limit Exceeded

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

min = 2*(10**9)+1
for i in range(L, R):
    for j in range(i+1, R+1):
        #print("i, j = {}, {}".format(i, j))
        a = (i*j) % 2019
        if(min >= a):
            min = a

print(min)
#print( (L*R) % 2019)

Submission status: Time Limit Exceeded

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

a=2*10**9
for i in range(R+1)[L:]:
  for j in range(R+1)[i+1:]:
    imod = i % 2019
    jmod = j % 2019
    m = (imod * jmod) % 2019
    a = min(a,m)

print(a)

Submission status: Time Limit Exceeded

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

minimum = 2019
checked = set()
for i in range(L, R+1):
    a = i%2019
    if a not in checked:
        checked.add(a)
        for j in range(i+1, R+1):
            v = (i * j) % 2019
            minimum = min([v, minimum])

print(minimum)

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
L, R = list(map(int, input().split(' ')))
t = [i for i in range(L, R+1)]
s = t[0] % 2019
x = []
x.append(s)
for i in range(1, len(t)):
    m = t[i] % 2019
    if s == m:
        break
    x.append(m)
min_v = 2018
for i in range(0, len(x)):
    for j in range(i+1, len(x)):
        ij = (x[i]*x[j]) % 2019
        if ij < min_v:
            min_v = ij
print(min_v)

Submission status: Time Limit Exceeded

Solution code:
L, R = list(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())
ans=2019
for i in range(l,r+1):
    for j in range(i+1,r+1):
        ans=min((i*j)%2019,ans)
        
        
print(ans)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

i=s[0]+1
j=s[0]
i= i%2019
j= j%2019
a = i*j
b0 = a%2019

for i in range(s[0]+2,s[1]+1):
    for j in range(s[0],i-1):
        i = i%2019
        j = j%2019
        a = i*j
        b1 = a%2019
        if b1<b0:
            b0=b1
        else:
            pass

print(b0)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
l, r = list(map(int, input().split()))
ans = r*r
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=r*(r-1)
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:
from sys import stdin

L, R = [int(x) for x in stdin.readline().rstrip().split()]

v_min = 2019
for i in range(L, R+1):
    if i+1 == R:
        j = i+1
        v = (i*j) % 2019
        if v <= v_min:
            v_min = v
            break
    for j in range(i+1, R+1):
        if (i*j) - (i*(j-1)) < 2019:
            continue
        v = (i*j) % 2019
        if v <= v_min:
            v_min = v

print(v_min)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

m = 2019
mod_min = []

input_list = [i for i in range(l,r+1,1)]
input_list = np.asarray(input_list)

input_list = input_list % 2019
#print(input_list)

for i in range(len(input_list)):
    for j in range(len(input_list)-1, i, -1):
        mod_min.append((input_list[i] * input_list[j]) % m)

#print(mod_min)
print(np.asarray(mod_min).min())

Submission status: Time Limit Exceeded

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

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

ans = 2 * (10**9)

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

D = R - L
Ans = {2018}
J_Set = {2018}


for i in range(min(D, 2019)):
    A = L+i
    for j in range(D-i):
        B = (L+i+j+1)%2019
        Ans.add((A*B)%2019)
        if j > 2019:
            break

print(min(Ans))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

mod_min = 10000000
chk = 10000000000

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

print(mod_min)

Submission status: Time Limit Exceeded

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

for i in range(a[0],a[1]+1):
  for j in range(a[0],i):
    c = (i*j)%2019
    b.append(c)
else:
  print(min(b))

Submission status: Time Limit Exceeded

Solution code:
def RemainderMinimization2019():
	L, R = map(int, input().split())
	minMod = 2020 * 2020
	for i in range(L, R):
		for j in range(i + 1, R + 1):
			if minMod == 0:
				break
			tmpA = (i % 2019)
			tmpB = (j % 2019)
			tmp = (tmpA * tmpB) % 2019
			# print(i, j, tmp)
			if minMod > tmp:
				minMod = tmp
	print(minMod)
RemainderMinimization2019()

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python
from collections import defaultdict, deque
import math
from math import factorial
import re

def main():
    L, R = map(int, input().split())
    diff = (L - R) / 2019
    if L % 2019 == 0 or R % 2019 == 0 or diff >= 1:
        print(0)
        return

    min_mod = 2019
    i_mods = {i: i % 2019 for i in range(L, R+1)}
    j_mods = {j: j % 2019 for j in range(L, R+1)}
    for i in range(L, R):
        for j in range(i+1, R+1):
            mod = (i_mods[i] * j_mods[j]) % 2019
            if min_mod > mod:
                min_mod = mod
            if min_mod == 1:
                break
    print(min_mod)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

from itertools import combinations

ans = [(x1*x2)%2019 for (x1, x2) in combinations(range(l, r+1), 2)]

print(min(ans))

Submission status: Time Limit Exceeded

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

i=s[0]+1
j=s[0]
a = i*j
b0 = a%2019

for i in range(s[0]+2,s[1]+1):
    for j in range(s[0],i-1):
        a = i*j
        b1 = a%2019
        if b1<b0:
            b0=b1
        else:
            pass

print(b0)

Submission status: Time Limit Exceeded

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

D = R - L
Ans = {2018}
J_Set = {2018}
def cal(a, b):
    return int((a*b)%2019)

for i in range(min(D, 2019)):
    A = (L+i)%2019
    for j in range(D-i):
        B = (L+i+j+1)%2019
        Ans.add((A*B)%2019)
        if j > 2019:
            break
        
print(min(Ans))

Submission status: Time Limit Exceeded

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

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

print(min(num))

Submission status: Time Limit Exceeded

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

    mod=2018
    flag=True
    if flag:
        for i in range(L,R):
            if i%2019 ==0:
                mod=0
                flag=False

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

    print(mod)    

if __name__=="__main__":
    main()

Submission status: Time Limit Exceeded

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

while L > mod:
    L -= mod
    R -= mod
for i in range(L, R):
    for j in range(i+1, R+1):
        if i * j % mod < ans:
            ans = i * j % mod

print(ans)

Submission status: Time Limit Exceeded

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

mod_arr = []

for i in range(r+1):
  for j in range(r+1):
    if i >= l and i < j:
      mod = (i * j) % 2019
      mod_arr.append(mod)

print(min(mod_arr))

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))
else:
    for i in range(L,R):
        for j in range(R-L):
            listA.append(i * (L%2019 + j+1) % 2019)
    print(min(listA))

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
import itertools

input = sys.stdin.readline


def main():
    l, r = [int(i) for i in input().split()]
    num = [i % 2019 for i in range(l, r + 1)]
    print(min([i * j % 2019 for i, j in itertools.combinations(num, 2)]))


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
from enum import Enum
from queue import Queue
import collections
import numpy as np


import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

L,R = map(int,input().split())
min = BIG_NUM
if L <= 2019 and R >= 2019:
    print(0)
else:
    for i in range(L,R+1):
        for j in range(i+1,R+1):
            tmp = (i*j)%2019
            if tmp < min:
                min = tmp
            if min == 0:
                break
    print(min)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

if  R-L > 2018:
    print(0)
    
else:
    ans = 2018
    
    R = R % 2019
    L = L % 2019

    if L > R:
        R += 2019
        
    if R - L > 1000:
        print(1)
        
    for i in np.arange(L, R+1):
        for j in np.arange(i+1, R+1):
            i = i % 2019
            j = j % 2019
            k = i * j % 2019
            ans = np.amin(np.array([k, ans]))
            
    print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
#coding:utf-8
import math
l, r = map(int, input().split())
ans = (l*r) % 2019

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

result = []

for i in range (l, r):
	for j in range(i+1, r +1 ):

		temp = i * j % 2019
		result.append(temp)

print(min(result))

Submission status: Time Limit Exceeded

Solution code:
L, R = map(int, input().split())
min_mod = 2019
flg=[1]*2019
for i in range(L,R):
    flg2=[1]*2019
    idx=i%2019
    if flg[idx]==1:
        for j in range(i+1,R+1):
            mod  = (i*j)%2019
            if flg2[mod]==1:                       
                if min_mod > mod:
                    min_mod=mod
                flg2[mod]=0
            if sum(flg2)==0:
                break
        flg[idx]=0
    if sum(flg)==0:
        break
print(min_mod)

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())
k=[]
a=l-(l-1)%2019+2018
if a<=r:
  print(0)
for i in range(l+1,r+1):
  for j in range(l,i):
    k.append((i*j)%2019)
print(min(k))

Submission status: Time Limit Exceeded

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

for i in range(L, R) :
	for j in range(i + 1, R + 1) :
		if((i * j) % 2019 < mod) :
			mod = (i * j) % 2019
			x = ((i * j) // 2019) * 2019 + 2019
			if(x > i * R) :
				break
			else :
				pass
		else :
			pass
	if(mod == 0) :
		break
	else :
		pass
	
print(mod)