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: Wrong Answer

Solution code:
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n, a, b = LI()
    print(min(n * a, b))
    return

#B
def B():
    n, d = LI()
    x = LIR(n)
    a = list(itertools.combinations(range(n), 2))
    ans = 0
    for a1,a2 in a:
        b = 0
        for bi in range(d):
            b += (x[a1][bi] - x[a2][bi])** 2
        if float.is_integer(math.sqrt(b)):
            ans += 1
    print(ans)
    return

#C
def C():
    l, r = LI()
    ans = 2018
    if l // 2019 == r // 2019:
        for i in range(l, r + 1):
            for k in range(i+1, r + 1):
                ans = min(ans, (i * k) % 2019)
    else:
        print(0)
    return

#D
def D():
    n = II()
    a = LI()
    
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    C()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
mod = 2019
L,R = [int(x) for x in input().split()]
if(R-L>=2018):
    print(0)
else:
    l = L%mod
    r = R%mod
    if(r<l):
        print(0)
    else:
        print(l*(l+1))

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
if L // 2019 < R // 2019:
    print(0)
else:
    print((L * (L + 1)) % 2019)

Submission status: Wrong Answer

Solution code:
l, r = map(int, input().split())
a = l % 2019
b = r % 2019
print(min(a,b)*(min(a,b)+1))

Submission status: Wrong Answer

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

ans = float('inf')
for i in range(L, L + 2020):
    for j in range(L + 1, L + 2020):
        if (i > R) or (j > R):
            continue
        ans = min(ans, (i * j) % MOD)

print(ans)

Submission status: Wrong Answer

Solution code:
L, R = [int(item) for item in input().split()]
l, ml = divmod(L, 2019)
r, mr = divmod(R, 2019)
if (l==r):
  print(ml*(ml+1))
elif (l < r):
  print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys

input = sys.stdin.readline

def main():
    L, R = map(int, input().split())
    m = 100000000
    l = L % 2019
    r = R % 2019
    for i in range(l, r):
        for j in range(i+1, r+1):
            m = min(m, i*j % 2019)
    print(m)

main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from itertools import combinations

l, r = [int(x) for x in input().split()]

l %= 2019
r %= 2019
if l >= r:
    r += 2019

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

Submission status: Wrong Answer

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

Lmod = L%2019
Rmod = R%2019

i = Lmod
j = i + 1

print(i*j)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 2018
now = 0
for i in range(l,r+1):
    for j in range(i+1,r+1):
        now = (i*j)%MOD
        ans = min(ans,now)


print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from itertools import combinations

l, r = [int(x) for x in input().split()]

l %= 2019
r %= 2019
if l > r:
    r += 2019

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

Submission status: Wrong Answer

Solution code:
def find(L,R):
    if R-L>=2019:
        return 0
    MIN=2019
    for i in range(L,R+1):
        for j in range(L+1,R+1):
            MIN=min((i*j)%2019,MIN)
    return MIN
L,R=list(map(int,input().strip().split(' ')))
print(find(L,R))

Submission status: Wrong Answer

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

i=L
j=i+1

print(i*j%2019)

Submission status: Wrong Answer

Solution code:
l,r=map(int,input().split())
if l//2019!=r//2019:
  print(0)
else:
  print((l%2019)*((l+1)%2019))

Submission status: Wrong Answer

Solution code:
l,r=map(int,input().split())
print(l*(l+1)%2019)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n, a, b = LI()
    print(min(n * a, b))
    return

#B
def B():
    n, d = LI()
    x = LIR(n)
    a = list(itertools.combinations(range(n), 2))
    ans = 0
    for a1,a2 in a:
        b = 0
        for bi in range(d):
            b += (x[a1][bi] - x[a2][bi])** 2
        if float.is_integer(math.sqrt(b)):
            ans += 1
    print(ans)
    return

#C
def C():
    l, r = LI()
    if l // 2019 == r // 2019:
        print((l * (l + 1)) % 2019)
    else:
        print(0)
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    C()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)

MOD = 2019  # type: int

def solve(L: int, R: int):
    mn = 2018
    for i in range(L, min(L + 2020, R + 1)):
        mn = min(mn, i % MOD)
    if mn == 0:
        ret = 0
    else:
        mn2 = 2018
        for i in range(L, min(L + 2020, R + 1)):
            if i % MOD < mn2 and i % MOD != mn:
                mn2 = i % MOD
        ret = mn * mn2
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = int(next(tokens))  # type: int
    R = int(next(tokens))  # type: int
    solve(L, R)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
L %= 2019
R %= 2019
print(min(L, R)*(min(L,R)+1))

Submission status: Wrong Answer

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

Lmod = L//2019
Rmod = R//2019

i = Lmod
j = i + 1

print(i*j)

Submission status: Wrong Answer

Solution code:


def main():
    left, right = map(int, input().split())
    mod = 2019

    a, b = left, left + 1
    c, d = right, right - 1

    ans = min((a % mod) * (b % mod), (c % mod) * (d % mod))

    print(ans)




if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

if L - R >= 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: Time Limit Exceeded

Solution code:
l, r = map(int, input().split())
ans = 2*10**9
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())
m,ans=2019,2018
r=min(r,l+2019*2)
for i in range(l,r+1):
  for j in range(i+1,r+1):
    i%=m
    j%=m
    ans=min(ans,(i*j)%m)
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

c = set()

for i in range(L, R + 1):
  t = i % 2019
  if i in c:
    break
  c.add(i)


m = float('inf')
l = list(c)
for i in range(len(l)):
  for j in range(i + 1, len(l)):
    m = min(m, l[i] * l[j] % 2019)

print(m)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def LI():
    return list(map(int, input().split()))


L, R = LI()
ans = 2020
for i in range(L, R+1):
    for j in range(i+1, R+1):
        y = (i*j) % 2019
        ans = min(ans, y)
        if ans == 0:
            break
print(ans)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
def main():
    l, r = map(int, input().split())
    mi = 2019
    c = 0

    for i in range(l, r):
        a = (i*i) % 2019
        for _ in range(min(r-l-c, 2019)):
            a = (a+i) % 2019

            if a < mi:
                mi = a
                if a == 0:
                    break
        c += 1

    print(mi)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def main():
    l, r = map(int, input().split())
    mi = 2019
    c = 0

    for i in range(l, r):
        a = (i*i) % 2019
        for _ in range(r-l-c):
            a = (a+i) % 2019

            if a < mi:
                mi = a
                if a == 0:
                    break
        c += 1

    print(mi)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
L,R=map(int,input().split())
l=L%2019
r=R%2019
l1=L//2019
r1=R//2019
if l1<r1:
  print(0)
elif l1==r1:
  res=[]
  for i in range(l,r):
    for j in range(i+1,r+1):
      if (i*j)%2019 not in res:
        res.append((i*j)%2019)
  print(min(res))

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3

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


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

amr = []
for x in range(l,r+1):
    amr.append(x%2019)
# print(amr)
amr = list(set(amr))
ij_mod = []
for i in range(len(amr)-1):
    for j in range(i+1,len(amr)):
        ij_mod.append((amr[i]*amr[j])%2019)
print(min(ij_mod))

Submission status: Time Limit Exceeded

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

amr = []
for x in range(l,r+1):
    amr.append(x%2019)
# print(amr)
ij_mod = []
for i in range(len(amr)-1):
    for j in range(i+1,len(amr)):
        ij_mod.append((amr[i]*amr[j])%2019)
print(min(ij_mod))

Submission status: Time Limit Exceeded

Solution code:
import bisect,collections,copy,heapq,itertools,math,string
from collections import defaultdict as D
from functools import reduce
import numpy as np
import sys
import os
from operator import mul

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353    

l,r = LI()
m = 2019

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

# ans = (l * r) % m
# print(ans)

# N = I()
#A,B = LI()
#AB = [LI() for _ in range(N)]
#A,B = zip(*AB)
#Ap = np.array(A)
#C = np.zeros(N + 1)

# if ans:
#     print('Yes')
# else:
#     print('No')

Submission status: Time Limit Exceeded

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

t = []

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

print(min(t))

Submission status: Time Limit Exceeded

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

t = []

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

u = sorted(t)
print(u[0])

Submission status: Time Limit Exceeded

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

if L - R >= 2019:
    print(0)
else:
    min_mod = 2019
    for a in range(L, R):
        for b in range(a+1, R+1):
            min_mod = min(min_mod, (a * b) % 2019)

    print(min_mod)

Submission status: Time Limit Exceeded

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

#L = L % 2019
#R = R % 2019

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

print(min_mod)

Submission status: Time Limit Exceeded

Solution code:
l,r=map(int,open(0).read().split())

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

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

n=len(m)
ans=2019

for i in range(n):
    for j in range(i+1,n):
        ans=min(ans,(m[i]*m[j])%2019)
    
print(ans)

Submission status: Time Limit Exceeded

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

if 2019<=L-R:
  A+=[0]
else:
  for i in range(L,R+1):
    for j in range(L,i):
      A+=[((i%2019)*(j%2019))%2019]

print(min(A))

Submission status: Time Limit Exceeded

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

if 2019<=L-R:
  A+=[0]
else:
  for i in range(L,R+1):
    for j in range(L,i):
      A+=[(i*j)%2019]

print(min(A))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

print(heapq.heappop(ans))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    l, r = [int(x) for x in input().split()]
    # if r - l + 1 >= 5000:
    #     print(0)
    # else:
    M = 2019
    mn = []
    for i in range(l, r + 1):
        for j in range(i+1, r + 1):
            mn.append((i*j)%M)

    mn.sort()
    print(mn[0])
        



t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""



"""

Submission status: Time Limit Exceeded

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

res = float("inf")
for i in range(L, R + 1):
    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=map(int, input().split())
rem=2019
for i in range(l, r):
  if i%2019==0:
    print(0)
    exit()
  else:
    for j in range(i+1, r+1):
      if i%2019==0:
        print(0)
        exit()
      else:
        rem=min(rem, i*j%2019)
print(rem)

Submission status: Time Limit Exceeded

Solution code:

def solve():
    i = L//2019
    ans = 0
    if L <= 2019*i <= R:
        print(ans)
    else:
        ans = 2020
        for n in range(L,R):
            for m in range(n+1,R+1):
                ans = min(ans, (n*m)%2019)
            if ans == 0:
                break
        print(ans)

if __name__ == "__main__":
    L,R = list(map(int, input().split()))
    solve()

Submission status: Time Limit Exceeded

Solution code:

def solve():
    i = L//2019
    ans = 0
    is_ok = False
    if 2019*i < L and R < 2019*i:
        is_ok = True
#    print(i)
    if is_ok:
        print(ans)
    else:
        ans = 2020
        for n in range(L,R):
            for m in range(n+1,R+1):
                ans = min(ans, (n*m)%2019)
            if ans == 0:
                break
        print(ans)

if __name__ == "__main__":
    L,R = list(map(int, input().split()))
    solve()

Submission status: Time Limit Exceeded

Solution code:

def solve():
    i = L//2019
    ans = 0
    is_ok = False
    if L <= 2019*i <= R:
        is_ok = True
#    print(i)
    if is_ok:
        print(ans)
    else:
        ans = 2020
        for n in range(L,R):
            for m in range(n+1,R+1):
                ans = min(ans, (n*m)%2019)
            if ans == 0:
                break
        print(ans)

if __name__ == "__main__":
    L,R = list(map(int, input().split()))
    solve()

Submission status: Time Limit Exceeded

Solution code:

def solve():
    i = L//2019
    ans = 0
    is_ok = False
    while L <= 2019*i <= R:
        i += 1
        is_ok = True
#    print(i)
    if is_ok:
        print(ans)
    else:
        ans = 2020
        for n in range(L,R):
            for m in range(n+1,R+1):
                ans = min(ans, (n*m)%2019)
            if ans == 0:
                break
        print(ans)

if __name__ == "__main__":
    L,R = list(map(int, input().split()))
    solve()

Submission status: Time Limit Exceeded

Solution code:

def solve():
    i = L//2019
    ans = 0
    is_ok = False
    while L <= 2019*i <= R:
        i += 1
        is_ok = True
#    print(i)
    if is_ok:
        print(ans)
    else:
        ans = 2020
        for n in range(L,R):
            for m in range(n+1,R+1):
                ans = min(ans, (n*m)%2019)
        print(ans)

if __name__ == "__main__":
    L,R = list(map(int, input().split()))
    solve()

Submission status: Time Limit Exceeded

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

ans = 2018

for i in range(L,min(R,L+2020)):
    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())

ans = 2019

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
def resolve():
    L, R = list(map(int, input().split()))
    MOD = 2019
    ans = float("inf")
    l = list(map(lambda x: x%MOD, range(L, R+1)))
    import itertools
    for i, j in itertools.combinations(l, 2):
        ans = min(ans, (i*j)%MOD)
    print(ans)

if '__main__' == __name__:
    resolve()

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

Submission status: Time Limit Exceeded

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

for i in range(L,R):
    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())

if r-l > 2018:
    print(0)

ans = 2018
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())
if l-r>=2019:
    print(0)
    exit()
ans=2020
for i in range(l,r+1):
    for j in range(i+1,r+1):
        i,j=i%2019,j%2019
        ans=min((i*j)%2019,ans)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
l,r=map(int,input().split())
if l-r>=2019:
    print(0)
    exit()
ans=2020
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=map(int,input().split())
list=[]
for i in range(l,r):
  for k in range(i+1,r+1):
    test=(i*k)%2019
    list.append(test)
print(min(list))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ans = 3000

if R-L >= 2100 :
    ans = 0

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
l,r = map(int,input().split())
ans = 100000000000000000
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:
l,r=map(int,input().split())
m=[i%2019 for i in range(l,r+1)]
print(0 if r-l>671 else min(i*j%2019 for i in m for j in m if i<j))

Submission status: Time Limit Exceeded

Solution code:
l,r = map(int,input().split())
number_list=[i for i in range(l,r+1)]
c=2019
for i in number_list:
  if i%2019==0:
    print(0)
    break
else:
  for j in number_list:
    for k in number_list[(number_list.index(j)+1):]:
      if c>(j*k%2019):
        c=(j*k%2019)
  print(c)

Submission status: Time Limit Exceeded

Solution code:
l,r = map(int,input().split())
number_list=[i for i in range(l,r+1)]
c=2019
for i in number_list:
  if i%2019==0:
    print(0)
    break
else:
  for j in number_list:
    for k in number_list[(number_list.index(j)+1):]:
      if c>(((j%2019)*(k%2019))%2019):
        c=(((j%2019)*(k%2019))%2019)
  print(c)

Submission status: Time Limit Exceeded

Solution code:
l,r = map(int,input().split())
number_list=[i for i in range(l,r+1)]
c=2019
for i in number_list:
  if i%2019==0:
    print(0)
    break
else:
  for j in number_list:
    for k in number_list:
      if j<k:
        if c>(((j%2019)*(k%2019))%2019):
          c=(((j%2019)*(k%2019))%2019)
  print(c)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ans=2018
i=L
while i<R:
    j=i+1
    while j<=R:
        if i*j%2019==0:
            ans=0
            break
        else:
            ans=min(ans,i*j%2019)
            j+=1
    i+=1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
def main():
    L, R = map(int, input().split())
    R = min(R, L + 4038)
    ans = 2018

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

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
def main():
    L, R = map(int, input().split())
    R = min(R, L + 4038)
    ans = 2018

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

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
#n=int(input())
l,r=map(int,input().split())
#t=int(input())
#al=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

if l-r>=2019:
    mn=0
else:
    mn=(l*r)%2019
    for i in range(l,r):
        for j in range(i+1,r+1):
            mn=min(mn,(i*j)%2019)
print(mn)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

j_cnt = 0
i_cnt = 0
i = L
j = L+1
min_num = 2020
while i <= R:
    j = i+1
    while j <= R:
        min_num = min(min_num,((i%2019)*j)%2019)
        if not min_num:
            break
        j += 1
    i += 1
print(min_num)