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

def main():
    L, R = list(map(int, input().rstrip().split()))
    MOD = 2019
    if R - L + 1 >= MOD:  
        print(0)
    else:  
        L, R = L % MOD, R % MOD
        if L <= 3 and R >= 673:
            print(0)
            return
        ans = float("inf")
        for i in range(L, R):
            for j in range(i + 1, R + 1):
                ans = min(ans, (i * j) % MOD)
        print(ans)


if __name__ == "__main__":
    main()

Solution (Python):

def main():
    L, R = list(map(int, input().rstrip().split()))
    MOD = 2019
    if R - L + 1 >= MOD:  
        print(0)
    else:  
        ans = float("inf")
        L, R = L % MOD, R % MOD
        for i in range(L, R):
            for j in range(i + 1, R + 1):
                ans = min(ans, (i * j) % MOD)
                if ans == 0:
                    print(ans)
                    return
        print(ans)


if __name__ == "__main__":
    main()

Solution (Python):

def main():
    L, R = list(map(int, input().rstrip().split()))
    MOD = 2019
    if R - L + 1 >= MOD:  
        print(0)
    else:  
        ans = float("inf")
        L, R = L % MOD, R % MOD
        for i in range(L, R):
            for j in range(i + 1, R + 1):
                ans = min(ans, (i * j) % MOD)
        print(ans)


if __name__ == "__main__":
    main()

Solution (Python):

def main():
    L, R = list(map(int, input().rstrip().split()))
    MOD = 2019
    if (R // MOD) - (L // MOD) > 0:  
        print(0)
    else:  
        ans = float("inf")
        L, R = L % MOD, R % MOD
        for i in range(L, R):
            for j in range(i + 1, R + 1):
                ans = min(ans, (i * j) % MOD)
        print(ans)


if __name__ == "__main__":
    main()

Solution (Python):

def main():
    L, R = list(map(int, input().rstrip().split()))
    MOD = 2019
    if (R // MOD) - (L // MOD) > 0:  
        print(0)
    else:  
        ans = float("inf")
        for i in range(L, R):
            for j in range(i + 1, R + 1):
                i, j = i % MOD, j % MOD
                ans = min(ans, (i * j) % MOD)
        print(ans)


if __name__ == "__main__":
    main()

Solution (Python):

def main():
    L, R = list(map(int, input().rstrip().split()))
    MOD = 2019
    if (R // MOD) - (L // MOD) > 0:  
        print(0)
    else:
        ans = float("inf")
        for i in range(L, R):
            for j in range(i + 1, R + 1):
                i, j = i % MOD, j % MOD
                ans = min(ans, (i * j) % MOD)
        print(ans)


if __name__ == "__main__":
    main()

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

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

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

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

if R-L > 2020:
  print(0)
  exit()

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

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

if R-L > 2020:
  print(0)
  exit()

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

Solution (Python):
l,r=map(int,input().split());s=range(l,r+1);print(+(r-l<2e3)and min(i*j%2019for i in s for j in s if i<j))

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

Solution (Python):
l,r=map(int,input().split())
if r-l+1<=2019:
	modlist=[]
	lst=list(range(l,r+1))
	for i in range(len(lst)):
		for j in range(i+1,len(lst)):
			q,mod = divmod(lst[i]*lst[j],2019)
			modlist.append(mod)
	print(min(modlist))
else:
	print(0)

Solution (Python):
import sys
l, r = map(int, input().split())
if r-l>=2019:
    print("0")
elif r%2019==0 or l%2019==0:
    print("0")
else:
    min = 2019
    for i in range(l,r):
        for j in range(i+1,r+1):
            tmp = i*j%2019
            if min > tmp:
                min = tmp
            if min == 0:
                print("0")
                sys.exit()
    print(min)

Solution (Python):
import sys
L,R = map(int,input().split())
if R-L >=2019:
  print(0)
elif R%2019==0 or L%2019==0:
  print(0)
else:
  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 ans == 0:
      print(0)
      sys.exit()
  print(ans)

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

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

Solution (Python):
l,r=map(int,input().split())
if r-l>=2019:
    print(0)
    exit()
else:
    mini=10000000000000000 
    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):

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

bool = True
l = L % 2019
r = R % 2019
if L ==0:
    ans = 0
elif R == L+1:
    ans = R*L%2019
elif R-L > 2019:
    ans = 0
else:
    if l >= r:
        r += 2019
    for i in range(l,r):
        for j in range(i+1,r+1):
            temp = (i * j) % 2019
            if bool:
                min = temp
                ans = min
                bool = False
            elif min > temp:
                min = temp
                ans = min
print(ans)

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

mod = 2019
R = min(R, L + mod + 1)

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

print(ans)

Solution (Python):
l, r = list(map(int, input().split()))
MOD = 2019
diff = r - l
ans = 0
if diff < 2019:
    l = l % MOD
    r = l + diff
    ans = 2018
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            ans = min(ans, (i % MOD * j % MOD) % MOD)

print(ans)

Solution (Python):
inf = 2019
L, R = map(int, input().split())
ans = 0
df = R - L
if df < 2019:
    L = L % inf
    R = L + df
    ans = 2019
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            tmp = int((i * j) % inf)
            ans = min(ans, tmp)

print(ans)

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

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

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

min=2020
if r-l>=2019:
    min=0
else:
    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):
MOD = 2019

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

if R - L >= 2018 or R % MOD <= L % MOD:
    print(0)
else:
    ans, LM, RM = 2019, L % MOD, R % MOD
    for i in range(LM, RM):
        for j in range(i + 1, RM + 1):
            ans = min(ans, (i * j) % MOD)
    print(ans)

Solution (Python):
l, r = map(int, input().split())
mod = 2019
r = min(r, l+673)

res = mod
for i in range(l, r):
    for j in range(r, l-1, -1):
        if i == j:
            break
        res = min(res, i*j % mod)

print(res)

Solution (Python):
l, r = map(int, input().split())
mod = 2019
r = min(r, l+673)

res = mod
for i in range(l, r):
    for j in range(r, l-1, -1):
        if i == j:
            break
        tmp = i*j % mod
        if tmp < res:
            res = tmp

print(res)

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

print(min(
    (i * j) % MOD
    for i in range(L, R + 1)
    for j in range(i + 1, R + 1)
) if R - L < MOD - 1 else 0)

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

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

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

Solution (Python):
a,b=input().split()
a=int(a)
b=int(b)
c=0
for i in range(a,b+1):
  if b-a>=672:
    c=1
    break
  elif i%673==0:
    c=1
    break
ll=[]
if b-a==1:
  print(a*b%2019)
elif c==1:
  print(0)
elif b-a>=100:
  print(1)
elif b-a>=46:
  print(2)
else:
  for i in range(a,b):
    for j in  range(i+1,b+1):
      ll.append(i*j%2019)
  print(min(ll))

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

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

    print(ans)

if __name__ == "__main__":
    main()

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

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

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 = list(map(int, input().split()))
L_mod = L%2019
R_mod = R%2019
L_shou = L//2019
R_shou = R//2019
ans = 2020
if L_shou == R_shou:
    for l in range(L_mod, R_mod):
        for r in range(l+1, R_mod+1):
            if (l*r)%2019 < ans:
                ans = (l*r)%2019
    print(ans)
else:
    print(0)

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

ans = 2018
R = min(R, L+2020)
for i in range(L, R+1):
    f = False
    for j in range(i+1, R+1):
        m = (i*j)%2019
        if  m  == 0:
            ans = m
            f = True
            break     
        ans = min(ans, m)
    if f:
        break
print(ans)

Solution (Python):



def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, m=1, typ=int):
    return [read_h() if m > 1 else typ(input()) for _ in range(n)]


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

    if R - L >= 2019 or R % 2019 <= L % 2019:
        print(0)
        return

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

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):

def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
l,r=IL()
ans=2019
for i in range(l,min(l+2019,r+1)-1):
    for j in range(i+1,min(l+2019,r+1)):
        ans=min(ans,i*j%2019)
print(ans)

Solution (Python):
def main():
	L, R = map(int,input().split())
	K = R - L
	ans = 2019
	if K >= 2019:
		ans = 0
	else:
		for k in range(K+1):
			for d in range(k):
				ans = min(ans,(((L + k)%2019)*((L + d)%2019))%2019)
	print(ans)
main()

Solution (Python):
L,R = [int(x) for x in input().split()]
 
min_ans = 10**18

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

          if ans < min_ans:
              min_ans = ans
          if min_ans == 0:
              break
print(min_ans)

Solution (Python):
import math
L, R = map(int, input().split())
R=min(R,L+2019)
m=2018
for i in range(L,R+1):
  for j in range(i,R+1):
    if i==j:
      continue
    if (i*j)%2019<m:
      m=(i*j)%2019
print(m)

Solution (Python):
import numpy as np

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

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

print(min_)

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

ll = l % 2019
ans = 2018
if l-n >= 672:
    ans = 0
elif n-l > 2:
    for i in range(ll,ll + n-l +1):
        if i % 673 == 0:
            ans = 0
            break
        else:
            for j in range(ll,ll + n-l +1):
                if i != j:
                    ansss = i*j%2019
                    if ansss == 0:
                        ans = 0
                        break
                    elif ansss < ans:
                        ans = ansss
else:
    ans = l*n%2019

print(ans)

Solution (Python):
l,r = map(int, input().split())
if (r - l >= 2019):
  print(0)
else:
  res = []
  for i in range(l, r + 1):
    res.append(i % 2019)
  res.sort()
  ans = 2019 * 2019
  for hoge in res:
    for fuga in res:
      if(hoge != fuga and ans > ((hoge * fuga) % 2019)):
        ans = (hoge * fuga) % 2019
  print(ans)

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

P = 2019

R = min(R, L+673)

tmp = 2018
for i in range(L, R):
    for j in range(L+1, R+1):
        tmp = min((i*j)%P, tmp)
        
print(tmp)

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

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

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

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

Solution (Python):
import sys

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

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

Solution (Python):
L, R = map(int, input().split())
from itertools import combinations

mod = 2019

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

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

l_q = l // 2019
r_q = r // 2019
l_mod = l % 2019
r_mod = r % 2019

mod_min = 2019

if l_q < r_q:
    print(0)
else:
    for i in range(l_mod, r_mod):
        for j in range(i+1, r_mod+1):
            mod = (i * j) % 2019
            if mod < mod_min:
                mod_min = mod
    
    print(mod_min)

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

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

if R - L + 1 > 2019:
    remainder_list = [N%2019 for N in range(L, L+2019)]
else:
    remainder_list = [N%2019 for N in range(L, R+1)]  
remainder_list = list(set(remainder_list))
all_list = [(i*j)%2019 for i, j in list(itertools.combinations(remainder_list, 2))]
print(min(all_list))

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

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

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

R=min(R,L+2019)

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

Solution (Python):
def exam(L, R):
    min = 2019
    if L-R > 2019:
        return 0
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            modval = i*j % 2019
            if modval < min:
                min = modval
                if min == 0:
                    return 0
    return min


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

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

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

Solution (Python):
import numpy as np
L,R = map(int, input().split())
if (L//2019!=R//2019) or L%2019==0 or R%2019==0:
  print(0)
elif R-L==1:
  print((L*R)%2019)
else:
  l = L%2019
  r = R%2019
  
  a = []
  for i in range(r-l):
    for j in range(r-l-i):
      a.append(((l+i)*(l+i+j+1))%2019)
  print(min(a))

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

if r-l > 2019:
    print(0)
else:
    ret = 2020
    for i in itertools.combinations(range(l,r+1,1),2):
        ret = min(ret,(i[0]*i[1])%2019)
    print(ret)

Solution (Python):
import sys

def main():
    input = sys.stdin.readline
    L, R = map(int, input().split())
    R = min(R, L + 2019)

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

    return ans


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

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





def get_ans():
    
    if R - L >= 2018:
        return 0

    
    ans = 2019
    for X in range(L, R):
        for Y in range(X + 1, R + 1):
            ans = min((ans, (X * Y) % 2019))
            if ans == 0:
                return 0

    return ans


print(get_ans())

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

R = min(R, L+673)
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)

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

Solution (Python):
import math;

def swap(a,b):
    return (b,a)

def gcd(a,b):
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

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

if __name__ == '__main__':
    main()

Solution (Python):
l,r=map(int,input().split())
s=[]
i=0
j=0
if (r-l)>4038:
    while i!=(r-l)+1 and i!=2019:
        while j!=(r-l)+1 and j!=2019:
            s.append(((l+i)*(l+j))%2019)
            j+=1
        j=0
        i+=1
    print(min(s))
else:
    while i!=(r-l)+1:
        while j!=(r-l)+1:
            if i!=j:
                s.append(((l+i)*(l+j))%2019)
            j+=1
        j=0
        i+=1
    
    print(min(s))

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

result = 2019

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

print(result)

Solution (Python):
import math
L, R = map(int, input().split())
if (R - L + 1) > 673:
  print(0)
else:
  i = L
  min = 2020
  while(i < R):
    j = i + 1
    while(j <= R):
      tmp = i * j % 2019
      if(min > tmp):
        min = tmp
      j += 1
    i += 1
  print(min)

Solution (Python):
L, R = map(int, input().split())
m = 2*(10**9)+1

R = int(min([R, L+2019*2]))

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

Solution (Python):
def main():
    L, R = list(map(int, input().split()))
    minmod = 10000000
    for i in range(L, R):
        for j in range(i+1, R+1):
            prod = i * j
            mod = prod % 2019
            
            if mod < minmod:
                minmod = mod
            if minmod < 1:
                break
        else: continue
        break
    print(minmod)

main()

Solution (Python):
l,r = map(int, input().split())
if r-l >= 2019:
  print(0)
  exit()
else:
  m = 2018
  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())
NUM = 2019

if (L <= 673 <= R and R - L >= 3) or (R - L >= 673):
    print(0)
else:
    mods = []
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            m = (i * j) % NUM
            mods.append(m)
            if m == 1:
                print(1)
                exit()
    print(min(mods))

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

x = 2020

for i in range(R + 1)[L:]:
    if x == 0:
        break
    for j in range(R + 1)[i + 1:]:
        mod = i * j % 2019

        x = min(mod, x)
        if x == 0:
            break
print(x)

Solution (Python):
def c_remainder_minimization_2019(L, R, ITER=673):
    ans = float('inf')
    for i in range(L, min(R, L + ITER)):
        for j in range(i + 1, min(R + 1, L + ITER + 1)):
            ans = min(ans, (i * j) % 2019)
            if ans == 0:
                return 0
    return ans

L, R = [int(i) for i in input().split()]
print(c_remainder_minimization_2019(L, R))

Solution (Python):
L, R = list(map(int, input().split()))
a = (L * (L + 1)) % 2019
for i in range(L, min(R + 1, L + 2019)):
    for j in range(i + 1, min(i + 2020, R + 1)):
        if (i * j) % 2019 < a:
            a = (i * j) % 2019
print(a)

Solution (Python):
import numpy as np

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

if R - L > 2019:
    print(0)
else:
    arr = np.array(np.arange(L, R+1))
    mod_list = []
    min_mod_list = []
    
    if (0 in (arr % 2019)) or (0 in arr):
        print(0)
    else:
    
        for i in arr:
            mod_list = []
            index_ = np.where(arr==i)
            if i == arr[-1]:
                break
            
            for j in arr[int(index_[0])+1:]:
                mod_list.append((i * j) % 2019)
     
            min_mod_list.append(min(mod_list))
            if min(mod_list) == 0:
                break
    
    
        print(min(min_mod_list))

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

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

Solution (Python):

S=input()

tmp=S.split()

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

R=min(L+2019,R)

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



print(result)

Solution (Python):
L,R = map(int,input().split())
 
x = 2019**2
for i in range(L, R):
    for r in range(i+1, R+1):
        ans = (i*r) % 2019 
        if x > ans:
            x = ans
            if x == 0:
        	    break
    if x == 0:
      break
print(x)

Solution (Python):
mod=2019
l,r=map(int,input().split())
d={}
for i in range(l,min(r+1,l+2020)):
    w=i%2019
    if w in d:
        d[w]+=1
    else:
        d[w]=1
ans=2020
for i in d:
    for j in d:
        if i!=j:
            ans=min(ans,i*j%mod)
        elif i==j and d[i]>1:
            ans=min(ans,i*j%mod)
print(ans)

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

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

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

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

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

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

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

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

MOD=[0] * (2019*2019)

def myidx(i,j):
    return i * 2019 + j

for i in range(2019):
    for j in range(i+1,2019):
        idx = myidx(i,j)
        MOD[idx] = (i*j) % 2019





MMM = []
MIN = 2019
Lmod = L % 2019
Rmod = R % 2019

if L+2019 <= R:
    for i in range(2019):
        for j in range(i+1,2019):
            idx = myidx(i,j)
            MIN = min(MIN, MOD[idx])
            
elif Lmod <= Rmod:
    for i in range(Lmod, Rmod+1):
        for j in range(i+1, Rmod+1):
            idx = myidx(i,j)
            MIN = min(MIN, MOD[idx])
            

elif Lmod > Rmod:
    for i in list(range(0,Rmod+1)) + list(range(Lmod, 2019)):
        for j in list(range(i+1,Rmod+1)) + list(range(max(Lmod,i+1), 2019)):
            idx = myidx(i,j)
            MIN = min(MIN, MOD[idx])
            




print(MIN)

Solution (Python):
L,R = list(map(int,input().split()))
def main(L,R):
    mod_min = 2019
    if L // mod_min == R // mod_min:
        L %= mod_min
        R %= mod_min
        for i in range(L,R):
            for j in range(i+1, R+1):
                Y = i*j % 2019
                if Y < mod_min:
                    mod_min = Y
    else:
        mod_min = 0
    return mod_min
print(main(L,R))

Solution (Python):


import math

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


l = L % 2019
r = R % 2019

ans = None

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

print(ans)

Solution (Python):
s = input().rstrip().split(' ')
L = int(s[0])
R = int(s[1])
cnt = 2020
 
for i in range(L, R):
    for r in range(i+1, R+1):
        ans = (i*r) % 2019 
        if ans < cnt:
            cnt = ans
            if cnt == 0:
        	    break
    if cnt == 0:
      break
 
print(cnt)

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

bool = True
flag = False
for i in range(L,R):
    for j in range(i+1,R+1):
        temp = (i * j) % 2019
        if bool:
            min = temp
            ans = min
            bool = False
        elif min > temp:
            min = temp
            ans = min
        if min == 0:
            flag = True
            break
    if flag:
        break
print(ans)

Solution (Python):
import sys

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:
            print(0)
            sys.exit()

print(ans)

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

if L // 2019 < R // 2019:
    print(ans)
    exit()

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

Solution (Python):
def c_remainder_minimization_2019(L, R):
    ans = float('inf')
    for i in range(L, min(R, L + 2019)):
        for j in range(i + 1, min(R + 1, L + 2020)):
            ans = min(ans, (i * j) % 2019)
            if ans == 0:
                return 0
    return ans

L, R = [int(i) for i in input().split()]
print(c_remainder_minimization_2019(L, R))

Solution (Python):


"""
Created on Sun Jul  7 20:52:12 2019

@author: YudNK
"""

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

if R - L >= 2019:
    print(0)
else:
    a = L%2019
    mod = [a]
    for i in range(R - L):
        if a + i + 1 < 2019:
            mod.append(a + i + 1)
        else:
            mod.append(0)
    mini = 2018
    while len(mod) > 1:
        for i in range(len(mod) - 1):
            b = (mod[-1] * mod[i]) % 2019
            if b < mini:
                mini = b
        mod.pop(-1)
    print(mini)

Solution (Python):
s = input().split()
L = int(s[0])
R = int(s[1])

MIN = 2020
flag = 0

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

if R == 0 or L == 0:
    print(0)
elif R - L == 1:
     print((R*L)%2019)
else:
    print(MIN)

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

MOD=[0] * (2019*2019)

def myidx(i,j):
    return i * 2019 + j

for i in range(2019):
    for j in range(i+1,2019):
        idx = myidx(i,j)
        MOD[idx] = (i*j) % 2019





MMM = []
MIN = 2019
Lmod = L % 2019
Rmod = R % 2019

if L+2019 <= R:
    for i in range(2019):
        for j in range(i+1,2019):
            idx = myidx(i,j)
            MIN = min(MIN, MOD[idx])
            
elif Lmod <= Rmod:
    for i in range(Lmod, Rmod+1):
        for j in range(i+1, Rmod+1):
            idx = myidx(i,j)
            MIN = min(MIN, MOD[idx])
            

elif Lmod > Rmod:
    for i in list(range(0,Rmod+1)) + list(range(Lmod, 2019)):
        for j in list(range(i+1,Rmod+1)) + list(range(max(Lmod,i+1), 2019)):
            idx = myidx(i,j)
            MIN = min(MIN, MOD[idx])
            




print(MIN)

Solution (Python):
import sys
sys.setrecursionlimit(4100000)

l,r = [int(i) for i in input().split()]
if abs(l - r) >= 2019:
    temp = 0
else:
    temp = float('inf')
l = l%2019
r = r%2019
if l>r:
    r,l = l,r

for i in range(l,r+1):
    for k in range(i+1,r+1):
        if i*k%2019 < temp:
            temp = (i*k)%2019

print(temp) if l != r else print(temp)