Problem:


Score : 300 points

Problem Statement

You are given two non-negative integers L and R.
We will choose two integers i and j such that L \leq i < j \leq R.
Find the minimum possible value of (i \times j) \mbox{ mod } 2019.

Constraints

All values in input are integers.

0 \leq L < R \leq 2 \times 10^9

Input

Input is given from Standard Input in the following format:

L R

Output

Print the minimum possible value of (i \times j) \mbox{ mod } 2019 when i and j are chosen under the given condition.

Sample Input 1

2020 2040

Sample Output 1

2

When (i, j) = (2020, 2021), (i \times j) \mbox{ mod } 2019  = 2.

Sample Input 2

4 5

Sample Output 2

20

We have only one choice: (i, j) = (4, 5).



Sample input:
2020 2040


Sample output:
2

Submission status: Accepted

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

minVal = -1
for i in range(l, r):
    for j in range(i+1, r+1):
        modVal = (i * j) % 2019
        if minVal == -1 or minVal > modVal:
            minVal = modVal
            if minVal == 0:
                break
    if minVal == 0:
        break
print(minVal)

Submission status: Accepted

Solution code:
def prob_c():
    l, r = [int(a) for a in input().split()]
    if r - l >= 2018:
        print("0")
    else:
        l = l % 2019
        r = r % 2019
        ans = 2018
        for i in range(l, r):
            for j in range(i+1, r+1):
                candidate = (i * j) % 2019
                if ans > candidate:
                    ans = candidate
            if ans == 0:
                break
        print(str(ans))

prob_c()

Submission status: Accepted

Solution code:
def solve():
    l, r = map(int, input().split())
    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(ans, i * j % 2019)
    print(ans)
solve()

Submission status: Accepted

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

mod = 2018

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

print(mod)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if r-l >= 2019:
	best = 0
else:
	lm = l%2019
	rm = r%2019
	if r > l:
		a = range(lm,rm+1)
		best = 2019
		for i in xrange(len(a)-1):
			for j in xrange(i+1,len(a)):
				temp = (a[i]*a[j])%2019
				if temp < best:
					best = temp
	else:
		best = 0
print best

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

# 2019 = 3 * 673

def f():
    if L % 2019 == 0 or R % 1029 == 0:
        return 0

    p_L = L // 2019
    p_R = R // 2019
    if p_L != p_R:
        return 0
    # (2 * 10^3) ** 2 = 4 * 10^6
    S = [(i * j) % 2019 for i in range(L, R) for j in range(i + 1, R + 1)]
    return min(S)

print(f())

Submission status: Accepted

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

ans = float('inf')

if R - L + 1 >= 2019:
    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)

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

mi = 9999
for i in range(min(r-l+1,2019)):
    ll = l+i
    for j in range(min(r-l+1,2019)):
        if(i<=j):
            continue
        rr = l+j
        mi = min((ll*rr)%2019,mi)
print(mi)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

ans = 10**8

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

Submission status: Accepted

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

ans = 2019*2019

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

Submission status: Accepted

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

Submission status: Accepted

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

if r-l>=2019:
    kotae=0
else:
    a=l%2019
    b=r%2019
    if a>b:
        kotae=0
    else:
        kotae=2019
        for i in range(b-a):
            sho=a+i
            for j in range(b-a-i):
                dai=a+j+i+1
                #print(sho,dai)
                koho=(sho*dai)%2019
                if koho<kotae:
                    kotae=koho

print(kotae)

Submission status: Accepted

Solution code:
import sys
L,R=map(int,input().split())
mod=2019
q,r=L//mod,L%mod
q1,r1=R//mod,R%mod
#print(r,q,r1,q1)
if r==0 or r1==0 or q<q1:
    print(0)
    sys.exit()
mi=10**9
for i in range(r,r1):
    for j in range(i+1,r1+1):
        #print(i,j)
        mi=min(mi,(i*j)%mod)
print(mi)

Submission status: Accepted

Solution code:
L,R = map(int,input().split())
if R-L >= 2019:
    modL = 0
    modR = 2018
else:
    l = L%2019
    r = R%2019
    if r>l:
        modR = r
        modL = l
    else:
        modL = r
        modR = l+2019

ans = 100000000
for x in range(modL+1,modR+1):
    for y in range(modL,x):
        ans = min(ans,(x*y)%2019)
print(ans)

Submission status: Accepted

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

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

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

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

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

Submission status: Accepted

Solution code:
import numpy as np

L,R  = list(map(lambda x: int(x),input().split()))
ans=2019
for i in range(2019):
    for j in range(2019):
        l = L+i
        r = R-j
        if l>=r :
            continue
        candidate = (l*r)%2019
        if ans>candidate:
            ans=candidate
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

def Solve():
    if R-L>=672: #3*673=2019
        return 0
    
    result=2*10**9
    for i in range(L,R+1):
        for j in range(L,R+1):
            if j==i:
                continue
            result=min(result,(j*i)%2019)

    return result
    
print(Solve())

Submission status: Accepted

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


L,R=acinput()

minv=10**5
for i in range(L,min(R+1,L+2019)):
    for j in range(i+1,min(R+1,L+2019)):
        tmp=(i*j)%2019
        #print(tmp)
        if minv>tmp:
            minv=tmp
    
print(minv)

Submission status: Accepted

Solution code:
L,R=map(int,input().split())
if R-L>2017:
    print(0)
    quit()
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)

Submission status: Accepted

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

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

l = l % mod
r = r % mod
if r < l:
	r += mod 

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

print(ans)

Submission status: Accepted

Solution code:
def solve(L, R):
    if R - L >= 2019:
        return 0

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

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

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
if L // 2019 < R // 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)

Submission status: Accepted

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

def solve():
    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(l, r + 1):
            if i == j:
                continue
            ans = min(ans, (i * j) % 2019)
        if ans == 0:
            break
    print(ans)

if __name__=="__main__":
    solve()

Submission status: Accepted

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

ans = float('inf')
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)
            exit()
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

# n = int(input())
# a, b
# s = input()


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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L,R = map(int,input().split())
mod_list = []
if R-L >= 2019:
	mod_list = [i for i in range(2020)]
else:
	for i in range(L,R+1):
		mod_list.append(i%2019)
mod_list.sort()
ans = (mod_list[0]*mod_list[1]) % 2019
len_modlist = len(mod_list)
for i in range(len_modlist-1):
	for j in range(i+1, len_modlist):
		tmp = (mod_list[i] * mod_list[j]) % 2019
		ans = min(ans, tmp)
print(ans)

Submission status: Accepted

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

m = float('inf')
if L + MOD < R :
    for i in range(MOD) :
        for j in range(MOD) :
            m = min(m, i*j%MOD)
else :
    for i in range(L, R) :
        for j in range(i+1, R+1) :
            m = min(m, i*j%MOD)
            
print(m)

Submission status: Accepted

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

Submission status: Accepted

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

l0 = l % 2019
l1 = l // 2019
r0 = r % 2019
r1 = r // 2019

if l1 != r1:
    res = 0
else:
    amari = 2019
    for i in range(l0, r0+1):
        for j in range(i+1, r0+1):
            amari = min(amari, (i * j) % 2019)

    res = amari

print(res)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
L, R = [int(elem) for elem in input().split()]
diff = R - L + 1
if L == 0 or diff >= 2019:
    print(0)
    exit(0)

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

print(min_val)

Submission status: Accepted

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

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

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

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

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

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

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

Submission status: Accepted

Solution code:
import numpy as np
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


l,r = map(int,input().split())
ans = 10000000

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

    print(ans)

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

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

Submission status: Accepted

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

mi = 10**20
for i in range(L, min(R, L+2030)):
    for j in range(i+1, min(R+1, i+2030)):
        mi = min(mi, i*j%2019)
print(mi)

Submission status: Accepted

Solution code:
import itertools
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

L, R = list(map(int, sys.stdin.readline().split()))

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

print(ans)

Submission status: Accepted

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

la=L//2019
ra=R//2019
lb=L%2019
rb=R%2019

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

    print(ans)

Submission status: Accepted

Solution code:
from functools import reduce
import math

MIN = -10 ** 9
MAX = 10 ** 9


def main():
    L, R = [int(a) for a in input().split()]

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

    r = 2 * (10 ** 9)
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            m = (i * j) % 2019
            if m < r:
                r = m
    print(r)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

mod = 2019
L,R = inpl()
Lm,Rm = L%mod, R%mod

if Lm < Rm and L//mod == R//mod:
    ans = INF
    for x in range(Lm,Rm+1):
        for y in range(x+1,Rm+1):
            ans = min(ans,x*y%mod)
    print(ans)
else:
    print(0)

Submission status: Accepted

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

m = 2019 + 1
value = float("inf")
for i in range(l, min(r + 1, l + m * 2)):
    for j in range(i + 1, min(r + 1, i + m * 2)):
        value = min((i * j) % 2019, value)
print(value)

Submission status: Accepted

Solution code:
import sys,collections as cl,bisect as bs,math
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l(): #intのlist
	return list(map(int,input().split()))
def m(): #複数文字
	return map(int,input().split())
def onem(): #Nとかの取得
	return int(input())
def s(x): #圧縮
	a = []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa == x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): #listをスペースごとに分ける
	return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
	return max(map(max,x))

n,m = m()

mi = 2019

if m-n >= 2019:
	print(0)
	exit()
else:
	n %= 2019
	m %= 2019
	if n > m:
		print(0)
		exit()
	else:
		for i in range(n,m):
			for j in range(i+1,m+1):
				if (i * j) % 2019 <= mi:
					mi = (i * j) % 2019
print(mi)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
L,R = map(int,input().split())
if R-L+1 >= 2019:
    print(0)
else:
    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)

Submission status: Accepted

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

ans = MOD
for l in range(L,L+MOD+2):
    for r in reversed(range(R-MOD-2,R+1)):
        if l>=r: break
        ans = min(ans, (l*r)%MOD)
print(ans)

Submission status: Accepted

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


if __name__ == '__main__':
	main()

Submission status: Accepted

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

ans = 2019

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)

Submission status: Accepted

Solution code:
import sys
# input = sys.stdin.readline
inf = 10 ** 18

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

if (L // 2019) < (R // 2019):
    print(0)
else:
    ans = inf
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            ans_tmp = (i * j) % 2019
            if ans > ans_tmp:
                ans = ans_tmp
    print(ans)

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    
    l, r = map(int, input().split())
    if r - l >= 2019:
        ans = 0
    else:
        ans = 100000
        for i in range(l, r):
            for j in range(i + 1, r + 1):
                ans = min(ans, i * j % 2019)
    
    print(ans)
    
    return 0

main()

Submission status: Accepted

Solution code:
def main():
    a, b = map(int, raw_input().split())
    if b - a >= 2019:
        print 0
        return
    best = 2018
    for i in xrange(a, b):
        for j in xrange(i + 1, b + 1):
            best = min(best, i * j % 2019)
    print best


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

l, r = getList()
if r >= l + 2019:
    r = l + 2018

# 1, 100
ans = 2020
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)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

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

if R>=L+2020:
    print(0)
else:
    D=list(range(L,R+1))

    L=len(D)

    ANS=1<<40

    for i in range(L-1):
        for j in range(i+1,L):
            ANS=min(ANS,D[i]*D[j]%mod)

    print(ANS)

Submission status: Accepted

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

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

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
U = [0]*2019
for i in range(L, min(L+2019, R)+1):
    U[i % 2019] = 1
ans = 10**18
for i in range(2019):
    if not U[i]:
        continue
    for j in range(i+1, 2019):
        if not U[j]:
            continue
        ans = min(ans, (i*j) % 2019)
print(ans)

Submission status: Accepted

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

from collections import deque
import itertools as ite
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

L, R = map(int, raw_input().split())
if R / 2019 != L / 2019 or L % 2019 == 0:
    print 0
    exit()
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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
from operator import itemgetter
# gcd
from fractions import gcd
# 切り上げ，切り捨て
from math import ceil, floor
# リストの真のコピー（変更が伝播しない）
from copy import deepcopy
# 累積和。list(accumulate(A))としてAの累積和
from itertools import accumulate
# l = ['a', 'b', 'b', 'c', 'b', 'a', 'c', 'c', 'b', 'c', 'b', 'a']
# S = Counter(l)  # カウンタークラスが作られる。S=Counter({'b': 5, 'c': 4, 'a': 3})
# print(S.most_common(2))  # [('b', 5), ('c', 4)]
# print(S.keys())  # dict_keys(['a', 'b', 'c'])
# print(S.values())  # dict_values([3, 5, 4])
# print(S.items())  # dict_items([('a', 3), ('b', 5), ('c', 4)])
from collections import Counter
import math
from functools import reduce
sys.setrecursionlimit(200000)
# input関係の定義
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
def debug(x): print("debug: ", x, file=sys.stderr)
# template


# fin = open('in_1.txt', 'r')
# sys.stdin = fin
# # local only

MOD = 2019  # type: int


def solve(L: int, R: int):
    if R > L + 2040:
        R = L + 2040
    ans = 10**9
    for i in range(L, R+1):
        for j in range(i+1, R + 1):
            ans = min(ans, i * j % 2019)
    print(ans)


def iterate_tokens():
    for line in sys.stdin:
        for word in line.split():
            yield word


def main():
    tokens = iterate_tokens()
    L = int(next(tokens))  # type: int
    R = int(next(tokens))  # type: int
    solve(L, R)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
num = float('inf')
for i in range(L, min(L + 2020, R + 1)):
    for j in range(i + 1, min(L + 2020, R + 1)):
        num = min(num, (i * j) % 2019)

print(num)

Submission status: Accepted

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

ans = 10**10
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)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# @author 

import sys

class CRemainderMinimization2019:
    def solve(self):
        l, r = [int(_) for _ in input().split()]
        if r - l > 2019:
            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) % 2019)
            
            print(ans)

solver = CRemainderMinimization2019()
input = sys.stdin.readline

solver.solve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

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

#B
def B():
    n,d = LI()
    x = LIR(n)
    f = defaultdict(lambda : 0)
    for i in range(1000000):
        f[i*i] = 1
    ans = 0
    for i in range(n):
        for j in range(i+1,n):
            s = 0
            for k in range(d):
                s += (x[i][k]-x[j][k])**2
            if f[s]:
                ans += 1
    print(ans)
    return

#C
def C():
    l,r = LI()
    if r-l > 2019:
        print(0)
        quit()
    ans = float("inf")
    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)
    return

#D
def D():
    n = I()

    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return


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

Submission status: Accepted

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