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

MOD = 2019  


def solve(L: int, R: int):
    lmod = L % MOD
    rmod = R % MOD
    if R-L > MOD:
        
        print(0)
        return
    elif rmod < lmod:
        
        print(0)
        return
    else:
        
        m = +INF
        for i in range(lmod, rmod+1):
            for j in range(i+1, rmod+1):
                curr = (i*j) % MOD
                if curr < m:
                    m = curr
                    
        print(m)
        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))  
    R = int(next(tokens))  
    solve(L, R)


if __name__ == '__main__':
    main()

Solution (Python):
import sys
sys.setrecursionlimit(10**7)








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

    l = L % 2019
    r = R % 2019
    if R - L >= 2019:
        print(0)
        return

    if r <= l:
        r = min(r+2019, R)

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

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

if L // 2019 != R // 2019:
    print(0)
    exit()

l = L % 2019
r = R % 2019

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

print(minval)

Solution (Python):
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)
    elif(l<=3 and r>=673):
        print(0)
    else:
        ans = 2020
        for i in range(l,r):
            for j in range(i+1,r+1):
                ans = min(ans,(i*j)%mod)
        print(ans)

Solution (Python):
def main():
  l, r = map(int, input().split())
  if r - l >= 2019:
    print(0)
  else:
    ans = 2020
    for li in range(l, r+1):
      for ri in range(li+1, r+1):
        if (li*ri)%2019 < ans:
          ans = (li*ri)%2019
    print(ans)


if __name__ == '__main__':
  main()

Solution (Python):
import sys,heapq
from collections import deque,defaultdict
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True 
def ddprint(x):
  if DBG:
    print(x)

l,r = inm()
if r-l >= 2018:
    print(0)
    exit()
mn = 2020
for i in range(l,r):
    for j in range(i+1,r+1):
        s = (i*j)%2019
        if s < mn:
            mn = s
print(mn)

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

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

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

Solution (Python):



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

    a = L%2019
    b = min(R-L+1, 2019)+a
    m = 2018

    for i in range(a, b):
        for j in range(i+1, b):
            m = min(m, i*j%2019)
            
    print(m)



if __name__ == '__main__':
    main()

Solution (Python):

n = 2019
L,R =map(int,input().split())
l = L%n
N =min(2019,R-L+1)
ans = 2019
for i in range(N):
    for j in range(i):
        foo = (i+l)*(j+l)%n
        if ans > foo:
            ans = foo
print(ans)

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

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

print(ans)

Solution (Python):

def remainder_2019(l, r):
    min_r = 2019
    for i in range(l, r):
        for j in range(i+1, r+1):
            min_r = min(min_r, (i*j) % 2019)
            if min_r == 0:
                return 0
    return min_r

l, r = map(int, input().split())
if r - l >= 2019:
    print(0)
else:
    print(remainder_2019(l, r))

Solution (Python):
import numpy as np
import math

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


out = 2018
flag = False
for i in range(l,r+1):
    for j in range(i+1, r+1):
        out = min(out, int((i*j)%2019))
        if out == 0:
            flag = True
            break
    if flag:
        break

print(out)

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


answer = 2019

if R - L + 1 >= 2019:
    answer = 0
else:
    for x in range(L,R+1):
        for y in range(x+1,R+1):
            sumple = x * y
            test = sumple % 2019 
            if test < answer:
                answer = test

print(answer)

Solution (Python):



import sys  
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools



sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe


def local_input():
    from pcm.utils import set_stdin
    import sys
    from pathlib import Path
    parentdir = Path(os.path.dirname(__file__)).parent
    inputfile = parentdir.joinpath('test/sample-1.in')
    if len(sys.argv) == 1:
        set_stdin(inputfile)


def solve():
    l,r = map(int,input().split())
    if r-l > 2019:
        print(0)
    else:
        c = 2018
        for i in range(l,r+1):
            for j in range(i+1,r+1):
                c = min(c,(i*j % 2019))
        print(c)
    
    return 0

if __name__ == "__main__":
    try:
        local_input()
        def dump(*args):
            names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
            print(', '.join(names.get(id(arg),'???')+' => '+repr(arg) for arg in args), file=sys.stderr)
    except:
        def dump(*args):
            pass

    solve()

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

Solution (Python):
l, r = map(int, input().split())
if r - l >= 2018:
    print(0)
else:
    mod_l = l % 2019
    mod_r = r % 2019
    if mod_r > mod_l:
        mod_list = [mod_l + i for i in range(mod_r - mod_l + 1)]
        mod = []
        for i in range(len(mod_list)):
            for j in range(len(mod_list)):
                if i < j:
                    mod.append(mod_list[i] * mod_list[j] % 2019)
        print(min(mod))
    else:
        print(0)

Solution (Python):


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

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

Solution (Python):
import numpy as np

a, b = map(int, input().split())

if b - a > 2019:
    b = a + 2019
s = set()

for i in range(a, b+1):
    s.add(i%2019)
    
import itertools
minval = a*b
for pair in list(itertools.combinations(s,2)):
    val = (pair[0]*pair[1])%2019
    if minval > val:
        minval = val
print(minval)

Solution (Python):
def BC133_C():
    l, r = map(int, input().split())
    a, b = divmod(l, 2019)
    c, d = divmod(r, 2019)
    e = 2018
    if b == 0 or d == 0:
        print(0)
    elif a < c:
        print(0)
    else:
        for i in range(b, d):
            for j in range(i + 1, d + 1):
                e = min(e, (i * j) % 2019)
        print(e)


BC133_C()

Solution (Python):
import sys

L, R = map(int,input().split())
if R - L >= 2018:
    print("0")
else:
    for i in range(L, R+1):
        if i % 2019 == 0:
            print("0")
            sys.exit()
    
    min = 2018
    for i in range(L, R+1):
        for j in range(i+1, R+1):
            calc = ((i%2019)*(j%2019)) % 2019
            if calc < min:
                min = calc
    print(str(min))

Solution (Python):


def main():
    Q = 2019
    L, R = map( int, input().split())
    if L%Q == 0:
        print(0)
        return
    if (L//Q+1)*Q <= R:
        print(0)
        return
    T = [0]*2019
    for i in range(L%Q, R%Q+1):
        T[i] = 1
    ans = 2018
    for i in range(Q-1):
        if T[i] == 0:
            continue
        for j in range(i+1,Q):
            if T[j] == 0:
                continue
            if i*j%Q < ans:
                ans = i*j%Q
    print(ans)
if __name__ == '__main__':
    main()

Solution (Python):
n,m=map(int,input().split())
if m-n+1>=673:
    print(0)
else:
    s,t=n%2019,m%2019
    s,t=min(s,t),max(s,t)+1
    c=2019
    for i in range(s,t-1):
        for j in range(s+1,t):
            c=min(c,(i*j)%2019)
    print(c)

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

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



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

else:
    
    print(0)

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

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

if l//2019 != r//2019:
    print(0)
elif l%2019 == 0 or r%2019 == 0:
    print(0)
else:
    ans = 10**19
    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)

Solution (Python):
L,R=map(int,input().split())
if R-L>=2018:
    A=list(range(2019))
else:
    A=set([n%2019 for n in range(L,R+1)])
    A=list(A)
n=len(A)
minimun=2019
for i in range(n):
    for j in range(i+1,n):
        new=(A[i]*A[j])%2019
        if new<minimun:
            minimun=new
print(minimun)

Solution (Python):



def do():
    L, R = list(map(int, input().split(" ")))
    ans = 10 ** 15
    if R - L < 5000: 
        for i in range(L,R + 1):
            for j in range(i+1,R + 1):
                if (i*j) % 2019 < ans:
                    ans = (i*j) % 2019
    else:
        ans = 0
    print(ans)

if __name__ == "__main__":
    do()

Solution (Python):
a,b=map(int,input().split())
mod=2019

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

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


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

print(0)

Solution (Python):
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**9)
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

l,r = na()
mod = 2019
ans = mod

for i in range(mod):
    for j in range(mod):
        ll = l+i
        rr = r-j
        if ll >= rr:
            continue
        ans = min(ans,ll*rr%mod)

print(ans)

Solution (Python):
l,r=map(int,input().split())
mod=2019
l_mod=l%2019
ll=l//2019
r_mod=r%2019
rr=r//2019
if ll<rr:
    print(0)
else:
    ans=[]
    for i in range(l_mod,r_mod+1):
        for j in range(l_mod,r_mod+1):
            if i<j:
                ans.append((i*j)%2019)
    print(min(ans))

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

MOD = 2019

v = []
if R+1 - L < MOD:
    for i in range(L, R+1):
        v.append(i % MOD)
else:
    v = list(range(0, MOD))
v.sort()

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

print(ans)

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

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

Solution (Python):
ans = 2019
L, R = map(int, input().split())
if R-L+1 >= 673:
  ans = 0
else:
  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
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):
        _x = i % 2019
        if _x in x:
            break
        x.add(_x)
        y = set()
        for j in range(i + 1, r + 1):
            _y = j % 2019
            if _y in y:
                break
            y.add(_y)
            ans = min(ans, (_x * _y) % 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()

Solution (Python):
L,R = map(int,input().split())
flg = 1
for i in range(10**6+1) :
    if 2019*i < L :
        continue
    
    if 2019*i <= R :
        ans = 0
        flg = 0
        break
    
    else :
        break
if flg :
    ans = float("inf")
    
    for i in range(L,R) :
        for j in range(i+1,R+1) :
            calc = (i*j) % 2019
            ans = min(ans,calc)
print(ans)

Solution (Python):
[L,R] = list(map(int,input().split()))
output = 2020
flag = 0
for k in range(1,int(2*10**9/2019)+1):
    if (L<=k*2019)and(k*2019<=R):
        flag = 1
if flag ==1:
    print(0)
else:
    for d in range(R-L+1):
        A = L+d
        for e in range(d,R-L+1):
            B = L+e
            if d==e:
                continue
            else:
                amari = (A*B)%2019
                if amari < output:
                    output = amari
    print(output)

Solution (Python):
l, r = [int(item) for item in input().split()]
ans = 2020
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):
import sys

def InputToInt():
    A = input().split()
    for i in range(len(A)):
        A[i] = int(A[i])
    return A
    
if __name__ == '__main__':
    N, M = InputToInt()

    n = int(N/2019)
    m = int(M/2019)

    if n != m:
        print('0')
        sys.exit()

    n = N%2019
    m = M%2019

    a = 2018
    for i in range(n, m):
        for j in range(i+1, m+1):
            a = min(a, (i*j)%2019)
    print(a)

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

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

else:
    array = range(l, r + 1, 1)
    kouho = 2018
    for i in array:
        for j in array:
            if i != j:
                mod = (i * j) % 2019
                if kouho > mod:
                    kouho = mod

    print(kouho)

Solution (Python):
def inpl():
    return list(map(int, input().split()))


L, R = inpl()

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

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

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

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

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

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

l = [i%2019 for i in range(L, R+1)]
min_num = 10**18
for i in range(len(l)):
    for j in range(i+1, len(l)):
        m = (l[i]*l[j])%2019
        if m < min_num:
            min_num = m

print(min_num)

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

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

Solution (Python):

import sys

MOD = 2019  

def solve(L: int, R: int):
    if L == 0:
        L = 1
    res = float('inf')
    for i in range(L,R):
        for j in range(i+1,R+1):
            res = min(res,(i*j)%MOD)
            if res == 0:
                break
        if res == 0:
            break
    print(res)

    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))  
    R = int(next(tokens))  
    solve(L, R)

if __name__ == '__main__':
    main()

Solution (Python):
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)

L, R = LI()



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



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

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

if r-l>2017:
    print(0)
else:
    ans = 1000000000
    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 readInts():
  return [int(s) for s in input().split(" ")]

def solve(L, R):
  if R - L >= 2019:
    return 0
  if R % 2019 <= L % 2019:
    return 0

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

def main():
  L, R = readInts()
  ans = solve(L, R)
  print(ans)

if __name__ == "__main__":
  main()

Solution (Python):
l,r=map(int,input().split())
if l//2019!=r//2019:
  print(0)
else:
  ans=10000000
  L,R=l%2019,r%2019
  for i in range(L,R):
    for j in range(i+1,R+1):
      c=(i*j)%2019
      if c<ans:
        ans=c
  print(ans)

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

x = [i % 2019 for i in range(l, min(r+1, l+2019+1))]
x.sort()

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

print(ans)

Solution (Python):
l,r = map(int,input().split())
if r-l >= 2019 or l == 0:
    print(0)
    exit()
res = 10000000
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):
l, r = map(int, input().split())
if (r // 2019) > (l // 2019):
    l = l % 2019
    r = 2019 + (r % 2019)
else:
    l = l % 2019
    r = r % 2019
ans = 10 ** 9
for i in range(l, r+1):
    for j in range(i+1, r+1):
        ans = min((i*j) % 2019, ans)
print(ans)

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

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

Solution (Python):

import sys
sys.setrecursionlimit(300000)

MOD = 2019  

def solve(L: int, R: int):
    mn = 2018
    for i in range(L, min(L + 2019, R + 1)):
        mn = min(mn, i % MOD)
    if mn == 0:
        ret = 0
    else:
        ret = float('inf')
        for i in range(L, R):
            for j in range(i + 1, R + 1):
                ret = min(ret, (i * j) % MOD)
    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))  
    R = int(next(tokens))  
    solve(L, R)

if __name__ == '__main__':
    main()

Solution (Python):




def solve():
    L, R = list(map(int, input().split()))
    if R - L >= 2019:
        return 0
    L %= 2019
    R %= 2019
    if R < L:
        return 0
    ans = 2020
    for i in range(L, R + 1):
        for j in range(i + 1, R + 1):
            if ans > (i * j) % 2019:
                ans = (i * j) % 2019
    return ans


def main():
    print(solve())


if __name__ == "__main__":
    main()

Solution (Python):
MOD = 2019
p = 673
l,r = map(int,input().split())
r += 1

if (r-1)//p - (l-1)//p >= 1:
    print(0)
    exit()


def it():
    for dx in range(r-l):
        x = (l+dx)%MOD
        for dy in range(dx+1,r-l):
            y = (l+dy)%MOD
            yield x*y%MOD

print(min(it()))

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

mL = L % 2019
mR = R % 2019

if R-L >= 2019:
    print(0)
elif mL >= mR:
    print(0)
else:
    ans = 10**10
    for i in range(mL, mR+1):
        for j in range(mL, mR+1):
            if i < j:
                ans = min(ans, (i*j)%2019)
    print(ans)

Solution (Python):
def getlist():
	return list(map(int, input().split()))

L, R = getlist()

if R - L >= 2019:
	print(0)
else:
	X = []
	for i in range(L, R + 1):
		X.append(i % 2019)
	n = len(X)
	ans = float("inf")
	for i in range(n):
		for j in range(i + 1, n):
			val = (X[i] * X[j]) % 2019
			if val < ans:
				ans = val

	print(ans)

Solution (Python):
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


l, r = li()
MOD = 2019

ans = float("inf")
if r-l >= 2018:
    ans = 0
else:
    for i in range(l, min(r+1, l+2*MOD)):
        for j in range(i+1, min(r+1, l+2*MOD)):
            ans = min(ans, i*j % MOD)

print(ans)

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

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

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

if L % MOD == 0 or L + (MOD - L % MOD) <= R:
  print(0)
  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 sys
def input(): return sys.stdin.readline().strip()

mi = lambda: map(int, input().split())

L, R = mi()

m = 2019
if L // 2019 != R // 2019 or L % 2019 == 0 or R % 2019 == 0:
  m = 0
else:
  for i in range(L, R):
    for j in range(i+1, R+1):
      if i * j % 2019 < m:
        m = i * j % 2019
print(m)

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

min_mod = 2018
for l in range(L, R):
    for r in range(l+1, R+1):
        min_mod = min(min_mod, (l*r)%2019)
        if min_mod == 0:
            print(min_mod)
            exit()

print(min_mod)

Solution (Python):
from collections import deque
from itertools import accumulate
import sys
sys.setrecursionlimit(10**6)

mo=10**9+7

l,r=map(int,input().split())
r=min(l+2019+10,r)

ans=2018
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())
if R-L >= 2019: print(0)
else:
    if L % 2019 > R % 2019: print(0)
    else:
        s,t = L % 2019, R % 2019 + 1
        ans = 2019
        for i in range(s,t):
            for j in range(i+1,t):
                temp = (i*j) % 2019
                if temp < ans:  ans = temp
        print(ans)

Solution (Python):
def solve(L, R):
    if L == 0:
        return 0

    if R - L + 1 >= 2019:
        return 0

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


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

Solution (Python):
from itertools import combinations

L, R = map(int, input().split())
MOD = 2019
if R - L >= MOD: print(0)
else:
    L, R = L % MOD, R % MOD
    if L < R: cands = list(range(L, R+1))
    else: cands = list(set(list(range(R+1)) + list(range(L, MOD))))
    ans = MOD
    for i, j in combinations(cands, 2):
        ans = min(ans, (i*j) % MOD)
    print(ans)

Solution (Python):
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

L, R = nl()

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

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

print(res)

Solution (Python):
inpl = lambda: list(map(int,input().split()))
MOD = 2019
L, R = inpl()
if R-L >= MOD-1:
    print(0)
else:
    Lm = L % MOD
    Rm = R % MOD
    if Lm == 0 or Rm < Lm:
        print(0)
    else:
        ans = MOD - 1
        for i in range(Lm, Rm+1):
            for j in range(i+1, Rm+1):
                m = i*j % MOD
                if m < ans:
                    ans = m
        print(ans)

Solution (Python):











import sys
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log 
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
inf=float('inf')
mod = 2019
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    L,R = MI()
    ans = inf
    if R-L >= 2019:
        print(0)
    else:
        for i in range(L,R+1):
            for j in range(i+1, R+1):
                ans = min(ans,(i*j)%mod)
        print(ans)

if __name__ == '__main__':
    main()

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

Solution (Python):
L, R = list(map(int, input().split()))
if R - L >= 2019:
    print(0)
elif R // 2019 > L // 2019:
    print(0)
else:
    Lm = L % 2019
    Rm = R % 2019
    minM = 9999
    for i in range(Lm, Rm):
        for j in range(i + 1, Rm + 1):
            m = (i * j) % 2019
            if minM > m:
                minM = m
    print(minM)

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

Solution (Python):
def remainder_minimization_2019(L: int, R: int)->int:
    if R-L < 2018:
        ans = float('inf')
        for i in range(L, R):
            for j in range(i+1, R+1):
                ans = min(ans, (i * j) % 2019)

        return ans

    return 0


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

    ans = remainder_minimization_2019(L, R)
    print(ans)

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

flag = False
ans = float("inf")
for i in range(L, min(R + 1, L + 2018)):
  for j in range(i + 1, min(R + 1, L + 2019)):
    ans = min(ans, (i * j) % 2019)
    if ans == 0:
      flag = True
      break
  if flag:
    break
print(ans)