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

Solution (Python):

import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


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


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


def main():
    l, r = MI()

    if r - l >= 2018:
        print(0)
        return

    mod_l = l % 2019
    mod_r = r % 2019

    candidates = []

    if mod_l < mod_r:
        candidates.extend(range(mod_l, mod_r + 1))
    else:
        candidates.extend(range(0, mod_r + 1))
        candidates.extend(range(mod_l, 2019))
    min_ans = 2019

    for i in range(len(candidates)):
        for j in range(i + 1, len(candidates)):
            tmp = (candidates[i] * candidates[j]) % 2019
            if tmp < min_ans:
                min_ans = tmp

    print(min_ans)


main()

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

Solution (Python):
l,r=list(map(int,input().split()))
s=[]
import sys

if r-l>2050:
  print(0)
  sys.exit()
else:
  for i in range(l,r+1):
    s.append(i%2019)

n=len(s)
ans=30000
for i in range(n-1):
  for j in range(i+1,n):
    ans=min(ans,(s[i]*s[j])%2019)


print(ans)

Solution (Python):
L, R = map(int, input().split())
  
if R - L >= 2018:
  print(0)
  exit()
  
lst = []
for i in range(L,R+1):
  lst.append(i%2019)
  
lst.sort()

if lst[0] == 0:
  print(0)
  exit()
  
rlt = 2020
for i in range(len(lst)):
  for j in range(i+1,len(lst)):
    rlt = min(rlt, (lst[i]*lst[j])%2019)
    
print(rlt)

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

    print(ans)

Solution (Python):
L, R = map(int, input().split())
ama=[]
for i in  range(L,R+1):
    amari = i%2019
    if amari ==0:
        print(amari)
        exit()
minimi = 2019
for j in range(L,R+1):
    for s in range(j+1,R+1):
        waka = (j*s)%2019
        minimi = min(minimi,waka)
print(minimi)

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

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

Solution (Python):
L, R = map(int,input().rstrip().split())
if R - L >=2018:
    ans = 0
else:
    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)

Solution (Python):
import sys
from io import StringIO
import unittest


def resolve():
    l, r = map(int, input().split())
    ll = []

    for i in range(l, r + 1, 1):
        if i % 2019 in ll:
            break
        else:
            ll.append(i % 2019)

    ll.sort()
    ans = 2020

    for i in range(len(ll)):
        for j in range(i + 1, len(ll)):
            tmp = (ll[i] * ll[j]) % 2019
            if tmp < ans:
                ans = tmp

    print(ans)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """2020 2040"""
        output = """2"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """4 5"""
        output = """20"""
        self.assertIO(input, output)


if __name__ == "__main__":
    
    resolve()

Solution (Python):
r, l = map(int, input().split())
ans = 2018
for i in range(r,l):
    for j in range(r+1,l+1):
        if ans > (i*j) % 2019:
            ans = (i*j) % 2019
            if ans == 0:
                break

    if ans == 0:
        break

print(ans)

Solution (Python):
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
    if ans == 0:
        break
print(ans)

Solution (Python):
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)

Solution (Python):
L, R = map(int, input().split())
if R - L >= 673:
    print(0)
elif R - L == 1:
    print((R*L)%2019)
else:
    L %= 2019
    R %= 2019
    if L > R:
        print(0)
    else:
        ans = (L*R)%2019
        for l in range(L, R):
            for r in range(l+1, R+1):
                val = (l*r)%2019
                ans = min(ans, val)
        print(ans)

Solution (Python):
l,r=map(int,input().split())
if r-l>=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)

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

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

ans = float("inf")
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)

Solution (Python):
L, R = map(int, input().split())
a=[]

if R-L>=2019:
  ans=0
else:
  l, r = L%2019, R%2019
  ans=2018**2
  for i in range(l,r):
    for j in range(l+1,r+1):
        k = (i*j) % 2019
        ans = min(ans,k)
print(ans)

Solution (Python):
L,R = map(int,input().split())
r = 2019
if R//2019 != L//2019:
    print(0)
else:
    Rmod = R%2019
    Lmod = L%2019
    for i in range(Lmod,Rmod+1):
        for j in range(i+1,Rmod+1):
            r = min(r,(i*j)%2019)
    print(r)

Solution (Python):
import math
INF = 2_000_000_001
L, R = list(map(int, input().split()))
if math.ceil(L / 2019) <= R // 2019:
    print(0)
else:
    res = INF
    for i in range(L % 2019, R % 2019):
        for j in range(L % 2019 + 1, R % 2019 + 1):
            res = min(res, (i * j) % 2019)
    print(res)

Solution (Python):
l,r = map(int,input().split())
minimum = 2019
for i in range(l,r+1):
  if minimum == 0:
    break
  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)

Solution (Python):
def readinput():
    l,r=map(int,input().split())
    return l,r

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

if __name__=='__main__':
    l,r=readinput()
    ans=main(l,r)
    print(ans)

Solution (Python):
L, R = [int(i) for i in input().split()]
min = 1 << 30
for i in range(L, R + 1):
    if i % 2019 == 0:
        print(0)
        exit()
L %= 2019
R %= 2019
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)

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

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

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

Solution (Python):
l,r=map(int,input().split())
mini=2019
L=l
R=r+1 if r-l<2019*2 else l+2019+1
for i in range(L,R):
    for j in range(i+1,R):
        mini=min(mini,i*j%2019)
print(mini)

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

Solution (Python):
import sys

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

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

Solution (Python):


import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

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


MOD = 2019

l = L % 2019
r = R % 2019

if (R//MOD) - (L//MOD) > 0:
    r += 2019

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

print(res)

Solution (Python):
L,R=map(int,input().split())
if R-L>=2019:
    minimum=0
else:
    left,right=L%2019,R%2019
    minimum=2018**2
    for i in range(left,right+1):
        for j in range(i+1,right+1):
            minimum=min(minimum,i*j%2019)
print(minimum)

Solution (Python):
L,R=map(int,input().split())
if L//2019 != R//2019:
    print(0)
elif L%2019==0:
    print(0)
else:
    ans=float("inf")
    for i in range(L,R):
        for j in range(L+1,R+1):
            ans=min(ans,i*j%2019)
    print(ans)

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

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

Solution (Python):
L, R = map(int, input().split())
min_mod = 2019

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

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

print(min_mod)

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

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

Solution (Python):
l,r=map(int,input().split())
s=10000
for i in range(l,r+1):
    if i%2019==0:
        s=0
        break
    elif (i%673==0 and r-l!=1) or (i%673==0 and (r%3==0 or l%3==0)):
        s=0
        break
if s==0:
    print(0)
else:
    t=10000
    for i in range(l,r):
        for j in range(i+1,r+1):
            if ((i%2019)*(j%2019))%2019<t:
                t=((i%2019)*(j%2019))%2019
    print(t)

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

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

Solution (Python):
L,R=map(int,input().split())
ans=float('inf')
for i in range(L,R):
  for j in range(L+1,R+1):
    s=(i*j)%2019
    
    if s==0:
      print(0)
      exit()
    else:
      ans=min(s,ans)
      
print(ans)

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

Solution (Python):
l,r=map(int,input().split())
if r - l >= 2018:
    print(0)
    exit()

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

print(m)

Solution (Python):
l,r=map(int,input().split())
if r - l >= 2018:
    print(0)
    exit()
l %= 2019
r %= 2019

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

print(m)

Solution (Python):
L, R = map(int, input().split())
if R - L > 2019:
  print(0)
else:
  l = []
  for i in range(L, R + 1):
    for j in range(i + 1, R + 1):
      l.append(i * j % 2019)
  print(min(l))

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

minimize = 2018
P = 0

if R-L >= 2019:
	print(0)
	exit()
else:
	for i in range (L, R):
		for j in range (i+1, R+1):
			P = (i*j)%2019
			if P < minimize:
				minimize = P
print(minimize)

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

Solution (Python):
l, r = map(int, input().split())
n = r-l+1
ans1 = 0
ans2 = 0
min1 = 1000000000
min2 = 10000000000


for i in range(min(n, 2024)):
   
    if (l+i) % 2019 == 0:
        print(0)
        break
else:
    ans = 10000000000
    for i in range(min(n, 2019)):
        for j in range(i+1, min(n, 2020)):
            
            if ((l+i)*(l+j)) % 2019 < ans:
                ans = ((l+i)*(l+j)) % 2019
                
    print(ans)

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











mod = 2019
a = l//mod
b = r//mod

if b-a > 0:
    print(0)
else:
    m = 2020
    for i in range(l, r+1):
        for j in range(i+1, r+1):
            a = (i*j) % mod
            if a < m:
                m = a

    print(m)

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

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

Solution (Python):

import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd





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

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


"""



"""

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

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

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


if __name__ == "__main__":
    main()

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

if R - L >= 2019:
    print(0)
    exit()

L %= 2019
R %= 2019

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

print(ans)

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

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

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

Solution (Python):







__giturl__ = "$URL$"


from sys import stdin
input = stdin.readline


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

  if R-L+1 >= 2019:
    print(0)
    return
  else:
    mods = []
    for i in range(L, R+1):
      mods.append(i)
  mods = sorted(mods)
  min_ = float('inf')
  for i in mods:
    for j in mods:
      if i==j:
        continue
      min_ = min(min_, (i*j) % 2019)

  print(min_)


if(__name__ == '__main__'):
  main()

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

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

Solution (Python):
def main():
    mod = 2019
    l,r = map(int,input().split())
    ans = 10**9
    for i in range(l,min(l+2020,r+1)):
        for j in range(i+1,min(l+2020,r+1)):
            ans = min(ans,(i*j)%mod)
    print(ans)
main()

Solution (Python):
import sys


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


def main():
    mod  =2019
    L,R = map(int,input().split())
    if R //mod - (L-1) //mod >1:
        print(0)
        exit()
    ans = 10**9
    for i in range(L,R):
        for j in range(i+1,R+1):
            a = (i * j ) %mod
            ans = min(a,ans)
    print(ans)



if __name__ == "__main__":
    main()

Solution (Python):






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





MOD = 2019
res = MOD
if R - L < MOD:
    for l in range(L, R):
        for r in range(l+1, R+1):
            res = min(res, (l * r) % MOD)
else:
    res = 0
print(res)

Solution (Python):
MOD = 2019
L, R = map(int, input().split())
res = MOD
if R - L < MOD:
    for l in range(L, R):
        for r in range(l+1, R+1):
            res = min(res, (l * r) % MOD)
else:
    res = 0
print(res)

Solution (Python):
from collections import defaultdict
from collections import deque
from collections import Counter
import itertools
import math

def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

l,r = readInts()

ans = float("inf")
for i in range(l,min(r+1,l+2020)):
  for j in range(i+1, min(r+1,l+2020)):
    ans = min(ans,(i*j)%2019)

print(ans)

Solution (Python):
l, r = map(int, input().split())
if r-l >=2020:
    print(0)
    exit()
ans = 2018
for i in range(l, r+1):
    for j in range(l, r+1):
        if i != j:
            a = i*j%2019
            ans = min(ans, a)
print(ans)

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

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

Solution (Python):
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

L, R = rl()

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

Solution (Python):
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0
inf = float("inf")

l,r = I()

if r-l >= 673:
    print(0)
    exit()
ans = 2018
for i in range(l,r):
    for j in range(i+1,r+1):
        ans = min(ans,i*j%2019)

print(ans)

Solution (Python):
import sys

sys.setrecursionlimit(10**9)
input = sys.stdin.readline

def ii(): return int(input())
def mi(): return map(int, input().split())
def lmi(): return list(map(int, input().split()))
def lmif(n): return [list(map(int, input().split())) for _ in range(n)]
def ss(): return input().split()

def main():
    L, R = mi()

    mod = 2019
    min_mod = mod
    if R - L >= mod:
        print(0)
        return
    
    for i in range(L, R+1):
        for j in range(i+1, R+1):
            if i * j % mod < min_mod:
                min_mod = i * j % mod
        
    print(min_mod)

    return

main()

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

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

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

min_val = 2019
flag = 1
for i in range(L, min(R,L+2019-1), 1):
  for j in range(i+1, min(R+1,L+2019), 1):
    tmp = (i*(j)) % 2019
    if tmp == 0:
      flag = 0
      break
    elif tmp < min_val:
      min_val = tmp
  if flag == 0:
    break
if flag == 0:
  print(0)
else:
  print(min_val)

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

Solution (Python):

def input2():
	return map(int,input().split())
  
l,r=input2()


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

Solution (Python):

def solve():
    i = (L//2019) + 1
    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()

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

ans = 2018

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

print(ans)

Solution (Python):
N, K = map(int,input().split())
ans = float('inf')
for i in range(N,K):
    for j in range(i+1,K+1):
        mod = (i*j)%2019
        ans = min(mod, ans)
        if mod==0:
            break
    else:
        continue
    break
print(ans)

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

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

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

Solution (Python):
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    L, R = LI()

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

    print(ans)

if __name__ == '__main__':
    resolve()

Solution (Python):
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    L, R = LI()

    
    
    
    

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

    print(ans)

if __name__ == '__main__':
    resolve()

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

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

print(ans)

Solution (Python):
l,r=map(int,input().split())
x=l//2019
if 2019*x<l and r<2019*(x+1):
    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)
else:
    print(0)

Solution (Python):

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

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

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

Solution (Python):
L, R = map(int, input().split())
if L+2019 <= R:
  print(0)
else:
  m = 2019
  for a in range(L, R+1):
    for b in range(a+1, R+1):
      m = min(m, ((a%2019)*(b%2019))%2019)
  print(m)

Solution (Python):
import sys
import itertools
input = lambda: sys.stdin.readline().rstrip()

def main():
    l, r = map(int, input().split())
    if r - l >= 2018:
        print(0)
    else:
        ans = 2018
        for i, j in itertools.combinations(range(l, r+1), 2):
            ans = min(ans, i * j % 2019)
        print(ans)
    
if __name__ == '__main__':
    main()

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

a = 0
while a < l:
    a += 2019
if r - a >= 2019:
    print(0)
    exit()

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

print(d)

Solution (Python):
def resolve():
    L, R = list(map(int, input().split()))
    MOD = 2019
    if R - L >= 2019:
        print(0)
        return
    import itertools
    ans = float("inf")
    for i, j in itertools.combinations(list(range(L, R+1)), 2):
        ans = min(ans, i*j%MOD)
    print(ans)

if '__main__' == __name__:
    resolve()

Solution (Python):
import sys
sys.setrecursionlimit(10**7) 
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right

from collections import deque, defaultdict


from collections import Counter

from itertools import accumulate,combinations,permutations

from heapq import heapify,heappop,heappush


from functools import reduce,lru_cache

from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    

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

    if R-L>=2019:
        print(0)
        return
    ans=2019
    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()

Solution (Python):
l, r = map(int, input().split())
ans = 2018

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

Solution (Python):
import sys
import itertools

import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines



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

l = L % 2019

nums = set()
for i in range(min(R - L + 1, 2019)):
    nums.add((l + i) % 2019)



ans = 2018
for i in nums:
    for j in nums:
        if i == j:
            continue
        ans = min(ans, (i * j) % 2019)
print(ans)

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

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

print(ans)

Solution (Python):
L, R = map(int, input().split())
li = []

if R-L >= 2018:
  ans = 0
else:
  for i in range(L, R+1):
    l = i % 2019
    li.append(l)
  ans = 10000
  for i in range(len(li)-1):
    for j in range(i+1, len(li)):
      ans = min((li[i]*li[j])%2019, ans)
  
print(ans)

Solution (Python):
l, r = map(int, input().split())
res = 2018

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

Solution (Python):
L, R = map(int, input().split())
ans = 2019
    
if L//2019 != R//2019:
    print(0)
    exit(0)
else:
    L = L%2019
    R = R%2019

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

print(ans)

Solution (Python):
import sys
l, r = map(int, input().split())
mod = 2019

if l%mod == 0 or r%mod == 0 or l//mod != r//mod:
  print(0)
  sys.exit()

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

Solution (Python):
import bisect,copy,heapq,itertools,string
from collections import *
from math import *
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

l,r = MAP()
if(l%2019>=r%2019) or (r-l>=2018):
  print(0)
  exit()
else:
  l %= 2019
  r %= 2019

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

print(ans)

Solution (Python):
l,r = map(int,input().split())
 
x = []
 
if r-l >4038:
    print(0)
else:
    for i in range(l,r+1):
        x.append(i%2019)
        
    x.sort()
    
    ans = x[0]*x[1]%2019
    
    x = list(set(x))
    
    for s in range(len(x)):
        for t in range(s+1,len(x)):
            ans = min(ans,x[s]*x[t]%2019)
        
    print(ans)

Solution (Python):
r,l = map(int,input().split())
if l-r+1 >= 2019:
    print("0")
    exit()
li = []
for i in range(l-r+1):
    li.append((r+i)%2019)
li.sort()
lia = []
for i in range(len(li)):
    for j in range(len(li)):
        if i != j:
            lia.append((li[i]*li[j])%2019)
print(min(lia))

Solution (Python):
l,r = map(int, input().split())
if l//2019 != r//2019:
  print(0)
  exit(0)
l = l%2019
r = r%2019
a = 2019
for i in range(l,r+1):
  for j in range(l,i):
    a = min(a,(i*j)%2019)
    if a == 0:
      print(0)
      exit(0)
print(a)