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:

S=input()

tmp=S.split()

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

result=100000000000

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

print(result)

Submission status: Time Limit Exceeded

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

s = set()
for i in range(l, r+1):
    s.add(i % 2019)
s = list(s)

ans = 2018
for i, x in enumerate(s):
    for y in s[i+1:]:
        tmp = (x * y) % 2019
        if ans > tmp:
            ans = tmp
print(ans)

Submission status: Time Limit Exceeded

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

if l - r <= 2019:
    ans = float('inf')
    for i in range(l,r+1):
        for j in range(i+1,r+1):
            temp = (i*j)%2019
            if temp < ans and i != j:
                ans = temp
    print(ans)
else:
    print(0)

Submission status: Time Limit Exceeded

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

list =[]
for i in range(L,R,1):
  mod_i = i%2019
  for j in range(i+1,R+1,1):
    mod_j = j%2019
    mod = (mod_i *mod_j)%2019
    list.append(mod)
    
print(min(list))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

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

Submission status: Time Limit Exceeded

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

min_num = 2019

for i in range(L, R):
    for s in range(i+1, R+1):
        if (i*s)%2019 < min_num:
            min_num = (i*s)%2019

print(min_num)

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(l+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:
A=list(map(int,input().split()))
C=[]
for i in range(int(A[1])):
    if i>=A[0]:
        for t in range (int(A[1])+1):
            if t>i:
                C.append(t*i%2019)
D=sorted(C)
print(D[0])

Submission status: Time Limit Exceeded

Solution code:
L, R = map(int, input().split())
if R - L + 1 >= 2019:
    print(0)
    quit

for num in range(L, R + 1):
    if num % 2019 == 0:
        print(0)
        quit

ans = 2018
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 = map(int, input().split())
mn = 2020
 
for i in range(L, R):
    for j in range(i+1, R+1):
        if mn > (i*j)%2019:
            mn = (i*j)%2019
        elif mn == 0:
            break
print(mn)

Submission status: Time Limit Exceeded

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

res = 1000000007

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

print(res)

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

Submission status: Time Limit Exceeded

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

from itertools import combinations

ans = 2019

for (x1, x2) in combinations(range(l, r+1), 2):
    a = (x1 * x2) % 2019
    if a < ans:
        ans = a

print(ans)

Submission status: Time Limit Exceeded

Solution code:
L,R = map(int, input().split())
Smin=2019
Lo=L%2019
Ro=R-(L-Lo)
for x in range(Lo,Ro):
    for y in range(x+1,Ro+1):
        Sa=x*y
        S=Sa%2019
        if Smin>S:
            Smin=S
print(Smin)

Submission status: Time Limit Exceeded

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

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

print(min(mods))

Submission status: Time Limit Exceeded

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

mod = []	
if abs(l-r) == 1:
	print(l*r%2019)

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

	print(min(mod))

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

min_ = np.inf
for i in range(L, R):
    for j in range(i + 1, R + 1):
        if (i * j) % 2019 <= min_:
            min_ = (i * j) % 2019

print(min_)

Submission status: Time Limit Exceeded

Solution code:
L,R = map(int, input().split())
Smin=2019
Lo=L%2019
Ro=R-(L-Lo)
for x in range(L,R):
    for y in range(x+1,R+1):
        Sa=x*y
        S=Sa%2019
        if Smin>S:
            Smin=S
print(Smin)

Submission status: Time Limit Exceeded

Solution code:
L, R = [int(x) for x in input().split()]


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

Submission status: Time Limit Exceeded

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

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

print(minimum)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

print(solve())

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

Submission status: Time Limit Exceeded

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

if l - r <= 2019:
    ans = float('inf')
    for i in range(l,r+1):
        for j in range(l,r+1):
            temp = (i*j)%2019
            if temp < ans and i != j:
                ans = temp
    print(ans)
else:
    print(0)

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 diff >= 1:
        print(0)
        return

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

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

num_list = []

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

print(min(num_list))

Submission status: Time Limit Exceeded

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

amari=[(a*(a+1)%2019)]
for i in range(a,b):
    for j in range(i+1,b+1):
        if (i*j)%2019<amari[-1]:
            amari.append((i*j)%2019)

print(amari[-1])

Submission status: Time Limit Exceeded

Solution code:
l, r = map(int, input().split())
mod_min = 2100
for i in range(l,r):
    for j in range(i+1,r+1):
        m = (i*j) % 2019
        if m < mod_min:
            mod_min = m

print(mod_min)

Submission status: Time Limit Exceeded

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

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

print(minimam)

Submission status: Time Limit Exceeded

Solution code:
def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct
L,R = map(int,input().split())
ans = 10**9
for i in range(L,R+1):
    for j in range(L,R+1):
        if i==j:
            continue
        ans = min(ans,i*j%2019)
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ans = []

for i in range(L,R+1):
	for j in range(i+1,R+1):
		ans.append((i*j)%2019)
ans.sort()
print(ans[0])

Submission status: Time Limit Exceeded

Solution code:
import math
import sys
input = sys.stdin.readline

L, R = map(int, input().split())
min_mod = float('inf')
for i in range(L, R + 1):
    for j in range(i + 1, R + 1):
        mod = (i * j) % 2019
        if mod < min_mod:
            min_mod = mod
print(min_mod)

Submission status: Time Limit Exceeded

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

# 出力
mod = 2019
# if r-l>=673:
#     print(0)
#     sys.exit()

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

Submission status: Time Limit Exceeded

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

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

print(m)

Submission status: Time Limit Exceeded

Solution code:
l, r = list(map(int, input().split()))
ans = 2*10**9
for i in range(l, r+1):
  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:
[l,r] = [int(i) for i in input().split()]

if l > 2019:
	l -= 2019
	
if r > 2019:
	r -= 2019

mod = []	
if abs(l-r) == 1:
	print(l*r%2019)

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

	print(min(mod))

Submission status: Time Limit Exceeded

Solution code:
import math
l,r = list(map(int,input().split()))
MOD = 2019
res = 100000000000000000000000000000000
ans = []
for i in range(l,r+1):
    for j in range(i+1,r+1):
        if (i*j)%2019 < res:
            res = (i*j)%2019
print(res)

Submission status: Time Limit Exceeded

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

ans = 2018

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 = map(int, input().split())
lst = []
for i in range(l,r):
  for j in range(i+1,r+1):
    lst.append(i*j%2019)
print(min(lst))

Submission status: Time Limit Exceeded

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

ls = []

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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



    #print(i)

Submission status: Time Limit Exceeded

Solution code:
L,R = map(int, input().split())
Smin=2019
for x in range(L,R):
    for y in range(x+1,R+1):
        S=x*y%2019
        if Smin>S:
            Smin=S
print(Smin)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
#    !/usr/bin/env python3
#    encoding: UTF-8
#    Modified: <07/Jul/2019 05:47:37 PM>


#    ✪ H4WK3yE乡
#    Mohd. Farhan Tahir
#    Indian Institute Of Information Technology (IIIT), Gwalior


import sys
import os
from io import IOBase, BytesIO


def main():
    l, r = get_ints()
    ans = float("inf")
    x = set()
    for i in range(l, r + 1):
        if i in x:
            break
        x.add(i)
        y = set()
        for j in range(i + 1, r + 1):
            if j in y:
                break
            y.add(j)
            ans = min(ans, (i % 2019 * j % 2019) % 2019)
    print(ans)


BUFSIZE = 8192


class FastIO(BytesIO):
    newlines = 0

    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
        return s

    def read(self):
        while self._fill():
            pass
        return super(FastIO, self).read()

    def readline(self):
        while self.newlines == 0:
            s = self._fill()
            self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.getvalue())
            self.truncate(0), self.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        py2 = round(0.5)
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2 == 1:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            self.write = lambda s: self.buffer.write(s.encode("ascii"))
            self.read = lambda: self.buffer.read().decode("ascii")
            self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)


def get_array(): return list(map(int, sys.stdin.readline().split()))


def get_ints(): return map(int, sys.stdin.readline().split())


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


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
def solve():
  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(ans, (i * j) % 2019)
  return ans

print(solve())

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
#    !/usr/bin/env python3
#    encoding: UTF-8
#    Modified: <07/Jul/2019 05:46:57 PM>


#    ✪ H4WK3yE乡
#    Mohd. Farhan Tahir
#    Indian Institute Of Information Technology (IIIT), Gwalior


import sys
import os
from io import IOBase, BytesIO


def main():
    l, r = get_ints()
    ans = float("inf")
    x = set()
    for i in range(l, r + 1):
        if i in x:
            break
        y = set()
        for j in range(i + 1, r + 1):
            if j in y:
                break
            ans = min(ans, (i % 2019 * j % 2019) % 2019)
    print(ans)


BUFSIZE = 8192


class FastIO(BytesIO):
    newlines = 0

    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
        return s

    def read(self):
        while self._fill():
            pass
        return super(FastIO, self).read()

    def readline(self):
        while self.newlines == 0:
            s = self._fill()
            self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.getvalue())
            self.truncate(0), self.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        py2 = round(0.5)
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2 == 1:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            self.write = lambda s: self.buffer.write(s.encode("ascii"))
            self.read = lambda: self.buffer.read().decode("ascii")
            self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)


def get_array(): return list(map(int, sys.stdin.readline().split()))


def get_ints(): return map(int, sys.stdin.readline().split())


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


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
L,R = map(int,input().split())
a = []
for i in range(L,min(R,L+2019*2)+1):
    a.append(i)
ans = 10**10
b = len(a)
for i in range(b):
    for j in range(b):
        if i<=j:
            break
        ans=min(ans,(a[i]*a[j])%2019)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
def input():
    return sys.stdin.readline()[:-1]

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

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

print(res)

Submission status: Time Limit Exceeded

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

min = 2019

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

print(min)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

ls = []

for i in range(l,r):
    for j in range(l+1,r+1):
        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())

minMod= 2019

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

print(minMod)

Submission status: Time Limit Exceeded

Solution code:
L,R = map(int,input().split())
a = []
for i in range(L,min(R,L+2019*2)+1):
    a.append(i%2019)
ans = 10**10
b = len(a)
for i in range(b):
    for j in range(b):
        if i<=j:
            break
        ans=min(ans,(a[i]*a[j])%2019)
print(ans)

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

Submission status: Time Limit Exceeded

Solution code:
L,R = map(int,input().split())
a = []
for i in range(L,min(R,L+2019*3)+1):
    a.append(i%2019)
ans = 10**10
b = len(a)
for i in range(b):
    for j in range(b):
        if i<=j:
            break
        ans=min(ans,(a[i]*a[j])%2019)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
l,r = map(int,input().split())
c = 4*10**18
for i in range(l,r):
    for j in range(i+1,r+1):
        d = (i*j)%2019
        if d < c:
            c = d
print(c)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
l, r = list(map(int,input().split()))
mod = 2019
min = 2019
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:
A=list(map(int,input().split()))
t=True
sum=2019
if t:
    for i in range(int(A[1])):
        if i>=A[0]:
            for t in range (int(A[1])+1):
                if t>i:
                    if i*t%2019<=sum:
                        sum=i*t%2019
print(sum)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

    print(min)

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
#    !/usr/bin/env python3
#    encoding: UTF-8
#    Modified: <07/Jul/2019 05:41:03 PM>


#    ✪ H4WK3yE乡
#    Mohd. Farhan Tahir
#    Indian Institute Of Information Technology (IIIT), Gwalior


import sys
import os
from io import IOBase, BytesIO


def main():
    d = {}
    l, r = get_ints()
    ans = float("inf")
    for i in range(l, r + 1):
        for j in range(i + 1, r + 1):
            x = i % 2019
            y = j % 2019
            if (x, y) in d:
                break
            d[(x, y)] = (x * y) % 2019
            ans = min(ans, d[(x, y)])
    print(ans)


BUFSIZE = 8192


class FastIO(BytesIO):
    newlines = 0

    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
        return s

    def read(self):
        while self._fill():
            pass
        return super(FastIO, self).read()

    def readline(self):
        while self.newlines == 0:
            s = self._fill()
            self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.getvalue())
            self.truncate(0), self.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        py2 = round(0.5)
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2 == 1:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            self.write = lambda s: self.buffer.write(s.encode("ascii"))
            self.read = lambda: self.buffer.read().decode("ascii")
            self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)


def get_array(): return list(map(int, sys.stdin.readline().split()))


def get_ints(): return map(int, sys.stdin.readline().split())


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


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
#    !/usr/bin/env python3
#    encoding: UTF-8
#    Modified: <07/Jul/2019 05:40:28 PM>


#    ✪ H4WK3yE乡
#    Mohd. Farhan Tahir
#    Indian Institute Of Information Technology (IIIT), Gwalior


import sys
import os
from io import IOBase, BytesIO


def main():
    d = {}
    l, r = get_ints()
    ans = float("inf")
    for i in range(l, r + 1):
        for j in range(i + 1, r + 1):
            x = i % 2019
            y = j % 2019
            if (i, j) in d:
                break
            d[(x, y)] = (x * y) % 2019
            ans = min(ans, d[(x, y)])
    print(ans)


BUFSIZE = 8192


class FastIO(BytesIO):
    newlines = 0

    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
        return s

    def read(self):
        while self._fill():
            pass
        return super(FastIO, self).read()

    def readline(self):
        while self.newlines == 0:
            s = self._fill()
            self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.getvalue())
            self.truncate(0), self.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        py2 = round(0.5)
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2 == 1:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            self.write = lambda s: self.buffer.write(s.encode("ascii"))
            self.read = lambda: self.buffer.read().decode("ascii")
            self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)


def get_array(): return list(map(int, sys.stdin.readline().split()))


def get_ints(): return map(int, sys.stdin.readline().split())


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


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

l_max = min(L + 2018, R-1)
r_min = min(R - 2018, L+1)
ans = float("inf")
for l in range(L, l_max+1):
    for r in range(r_min, R+1):
        if l >= r:
            continue
        ans = min(ans, l*r%2019)
print(ans)

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools

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

for i in range((2*10**9)//2019+1):
	if L<=i*2019 and i*2019<=R:
		print(0)
		exit()

ans=2020

for h in range(L,R+1):
	for g in range(h+1,R+1):
		ans=min(ans,(h*g)%2019)

print(ans)

Submission status: Accepted

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

import sys
minimum = sys.maxsize
for i in range(L, min(L + 2019, R)):
  for j in range(i+1, min(i + 1 + 2019, R+1)):
    minimum = min(minimum, i * j % 2019)
print(minimum)

Submission status: Accepted

Solution code:
#import math
#import itertools
#import numpy as np
#from collections import deque
# sys.setrecursionlimit(10 ** 6)
#mod = 10 ** 9 + 7
#INF = 10 ** 9
#PI = 3.14159265358979323846

INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))

def do():
    l,r=INTM()
    mods=[]
    for i in range(l,min(l+3000,r+1)):
        mods.append(i%2019)
    
    ans=2018
    ml=len(mods)
    for i in range(ml-1):
        for j in range(i+1,ml):
            ans=min(ans,(mods[i]*mods[j])%2019)

    print(ans)


if __name__=='__main__':
    do()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#ABC133 C

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if (r-l) > 2100:
  print(0)
  sys.exit()

ans=9999

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
l,r = map(int,input().split())
if r-l >= 2019:
    print(0)
    exit()
w = []
q = list(itertools.combinations(range(l,r+1),2))
for i in range(len(q)):
    w.append((q[i][0]*q[i][1])%2019)

print(min(w))