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:
import sys
l, r = map(int, input().split())
lmod673 = l % 673
dif = r - l

if lmod673 + dif >= 673:
  print(0)
  sys.exit()

min_val = 2018
for bigger in range(l, r+1):
  for smaller in range(l, bigger):
    min_val = min(min_val, bigger*smaller % 2019)
print(min_val)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
MOD = 2019

l, r = map(int, sys.stdin.readline().split())
r = min(r, l + MOD - 1)

def main():
    res = MOD - 1
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            res = min(res, (i % MOD) * (j % MOD) % MOD)
    print(res)

if __name__ ==  '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#C
l,r = map(int,input().split())
tmp = []
if r*(r-1) < 2019:
    print(r*(r-1))
    
else:
    if r - l >= 2019 or l <= (r//2019) * 2019 <= r :
        print(0)       
    else:
        for i in range(l,r+1):
            for j in range(i+1,r+1):
                m = (i*j) % 2019
                tmp.append(m)
        print(min(tmp))

Submission status: Accepted

Solution code:
s=range(*eval(input().replace(' ',',1+')))[:673];print(min(i*j%2019for i in s for j in s if i<j))

Submission status: Accepted

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list
#from itertools import combinations # (string,3) 3回
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    # R - L >= 2019のときは　答えが 0
    # それ以外の時は全探索できる
    l,r = readInts()
    if r-l > 3000:
        print(0)
    else:
        res = 2018
        for i in range(l,r):
            for j in range(i+1,r+1): # 一緒じゃだめやねん
                res = min(res,(i * j) % 2019)
        print(res)
if __name__ == '__main__':
  main()

Submission status: Accepted

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

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

A = []
for i in range(L, R + 1):
    A.append(i % 2019)

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
if (L <= 673 <= R and R - L >= 3) or (R - L >= 673):
    print(0)
else:
    mods = []
    mods_append = mods.append
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            m = (i * j) % 2019
            mods_append(m)
            if m == 2:
                break

    print(min(mods))

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
MOD = 2019
if R - L >= MOD:
  print(0)
  exit(0)
lst = [x % MOD for x in range(L, R+1)]
N = len(lst)
mi = 10e9
for i in range(N-1):
  for j in range(i+1, N):
    mi = min(mi, lst[i] * lst[j] % MOD)
print(mi)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

min = 2019

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

        if min == 0:
            print("0")
            exit()

print(min)

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
ans = float('inf')
for i in range(L, min(L+2019, R)):
    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, input().split())
mod = 2019
_min = mod
for i in range(l, min(l + mod, r)):
  i_mod = i % mod
  for j in range(i + 1, min(i + mod, r) + 1):
    _min = min(_min, j % mod * i_mod % mod)
print(_min)

Submission status: Accepted

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

ans = 2019
for i in range(L,min(L+2019,R)):
  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,input().split())
s = range(l, r+1)[:673]
print(min(i*j % 2019 for i in s for j in s if i<j))

Submission status: Accepted

Solution code:
import math
def main():
    l, r = map(int,input().split())
    if r - l >= 637:
        print(0)
        return
    l_mod = l % 2019
    r_mod = r % 2019
    ans = []
    if l_mod > r_mod :
        ans = [i for i in range(l_mod,2019)]
        ans.extend([i for i in range(r_mod+1)])
    else:
        ans = [i for i in range(l_mod,r_mod+1)]
    ans.sort()
    a = 2019
    for i in range(len(ans)):
        for j in range(i + 1, len(ans)):
            a = min(a,(ans[i] * ans[j]) % 2019)
    print(a)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.readline
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#N = int(input())
#S = list(input())
#S.remove("\n")
N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = list(map(int,input().split()))
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
if M -N >= 2019 or (N % 2019) > (M % 2019):
    print(0)
else:
    N = N % 2019
    M = M % 2019
    Min = 2019
    for i in range(N,M):
        for j in range(i+1,M+1):
            c = (i * j ) % 2019
            if c < Min:
                Min = c
    print(Min)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
if L == 0 or L // 2019  != R // 2019:
    print(0)
else:
    mod_min = 2019
    for i in range(L, R):
        for j in range(i+1, R+1):
            mod = (i * j) % 2019
            mod_min = min(mod_min, mod)
    print(mod_min)

Submission status: Accepted

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

if (2019-(L%2019))+L <= R:
  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:
l,r = map(int, input().split())

q1 = l//2019
q2 = r//2019

if q1!=q2:
  print(0)
  exit()

r1 = l%2019
r2 = r%2019
ans = 2019
for i in range(r1,r2+1):
  for j in range(i+1,r2+1):
    rr = (i*j)%2019
    ans = min(ans,rr)
    if ans==0:
      print(ans)
      exit()
      
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
L,R = map(int,input().split())
if 2019 <= (R - L) + 1:
  print(0)
  exit()
  
lst = list(range(L,R+1))
md = [x * y % 2019 for x,y in itertools.combinations(lst,2)]
md.sort()
print(md[0])

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
import math

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

l,r=MI()
mod=[]
if r-l>=2019:
    rm=0
    print(rm)
    sys.exit()
else:
    for i in range(l,r+1):
        mod.append(i%2019)
#print(mod)
mn=10**7
for i in range(len(mod)-1):
    for j in range(i+1,len(mod)):
        #print(mod[i],end=" ")
        #print(mod[j])
        ans=(mod[i]*mod[j])%2019
        if ans<mn:
            mn=ans
print(mn)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
 
kleine = 2018
 
if b-a == 1:
	print((a*b)%2019)
elif b-a>= 2018:
	print(0)    
else:
	for i in range (a, b):
		for j in range (i+1, b+1):
			k = (i*j)%2019
			if k < kleine:
				kleine = k
			else:
				continue
	print(kleine)

Submission status: Accepted

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

if r-l >= 2018:
  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:
L, R = map(int,input().split())
if R - L >= 2018:
    print(0)
else:
    a = L % 2019
    b = R % 2019
    if b < a:
        b += 2019
    ans = 2018
    for i in range(a,b+1,1):
        for j in range(i+1,b+1,1):
            if ans > (i*j) % 2019:
                ans = (i*j) % 2019
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L,R = map(int,input().split())
l = L%2019
r = R%2019
Min_Answer = 2018

if L//2019 == R//2019:
    for i in range(l,r+1):
        for j in range (i,r+1):
            if i ==j :
                continue
            Answer = (i*j) % 2019
            Min_Answer = min(Answer,Min_Answer)

else:
 Min_Answer = 0

print(Min_Answer)

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
dif = R-L+1 if R-L+1<2019 else 2019

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

Submission status: Accepted

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

ans = 2019
if(R-L >= 2019):
  for i in range(2019):
    for j in range(i+1, 2019):
      tmp = (i * j) % 2019
      if(tmp < ans):
        ans = tmp
else:
  d = L // 2019
  l = L % 2019
  r = R - (d*2019)
  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:
L, R = map(int, input().split())

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

print(ans)

Submission status: Accepted

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

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

ans = mod
for a in range(l, r):
    for b in range(a+1, r+1):
        if (a * b) % mod < ans:
            ans = (a * b) % mod
print(ans)

Submission status: Accepted

Solution code:
a, b = map(int, input().split())

c  = []
for i in range(a, min(b, a+2019) + 1):
    for j in range(i+1, min(b, a+2019) + 1):
        c.append((i * j) % 2019)

print(min(c))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l, r = [int(i) for i in input().split()]
if r - l >= 2018:
    print(0)
    exit()

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

print(mn)

Submission status: Accepted

Solution code:
mod = 10 ** 9 + 7
mod2 = 2 ** 61 + 1
from collections import deque
import heapq
from bisect import bisect_left, insort_left, bisect_right

_NUMINT_ALL = list(range(10))


def main():
    ans = solve()
    if ans is not None:
        print(ans)


def solve():
    L, R = iip(False)

    if L //2019 != R //2019:
        return 0
    L %= 2019
    R %= 2019

    if L >= R or L == 0 or R == 0:
        return 0

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

    return mm % 2019



#####################################################ライブラリ集ここから

def iip(listed=True, num_only=True):
    if num_only:
        ret = [int(i) for i in input().split()]
    else:
        ret = [int(i) if i in _NUMINT_ALL else i for i in input().split()]

    if len(ret) == 1 and not listed:
        return ret[0]
    return ret


def sort_tuples(l, index):
    if isinstance(l, list):
        l.sort(key=lambda x: x[index])
        return l
    else:
        l = list(l)
        return sorted(l, key=lambda x: x[index])


def count_elements(l):
    d = {}
    for i in l:
        if i in d:
            d[i] += 1
        else:
            d[i] = 1
    return d


def safeget(l, index, default="exception"):
    if index >= len(l):
        if default == "exception":
            raise Exception("".join(["safegetに不正な値 ", index, "が渡されました。配列の長さは", len(l), "です"]))
        else:
            return default
    elif index < 0:
        if default == "exception":
            raise Exception("".join(["safegetに不正な値 ", index, "が渡されました。負の値は許可されていません"]))
        else:
            return default
    else:
        return l[index]


def iipt(l, listed=False, num_only=True):
    ret = []
    for i in range(l):
        ret.append(iip(listed=listed, num_only=num_only))
    return ret


def sortstr(s):
    return "".join(sorted(s))


def iip_ord(startcode="a"):
    if isinstance(startcode, str):
        startcode = ord(startcode)
    return [ord(i) - startcode for i in input()]


def YesNo(s):
    if s:
        print("Yes")
    else:
        print("No")


def fprint(s):
    for i in s:
        print(i)


def bitall(N):
    ret = []
    for i in range(2 ** N):
        a = []
        for j in range(N):
            a.append(i % 2)
            i //= 2
        ret.append(a)
    return ret


def split_print_space(s):
    print(" ".join([str(i) for i in s]))


def split_print_enter(s):
    print("\n".join([str(i) for i in s]))


def koenai_saidai_x_index(sorted_list, n):
    l = 0
    r = len(sorted_list)
    if len(sorted_list) == 0:
        return False
    if sorted_list[0] > n:
        return False

    while r - l > 1:
        x = (l + r) // 2
        if sorted_list[x] == n:
            return x
        elif sorted_list[x] > n:
            r = x
        else:
            l = x
    return l


def searchsorted(sorted_list, n, side="left"):
    if side not in ["right", "left"]:
        raise Exception("sideはrightかleftで指定してください")

    l = 0
    r = len(sorted_list)

    if n > sorted_list[-1]:
        # print(sorted_list)
        return len(sorted_list)
    if n < sorted_list[0]:
        return 0

    while r - l > 1:
        x = (l + r) // 2
        if sorted_list[x] > n:
            r = x
        elif sorted_list[x] < n:
            l = x
        else:
            if side == "left":
                r = x
            elif side == "right":
                l = x

    if side == "left":
        if sorted_list[l] == n:
            return r - 1
        else:
            return r

    if side == "right":
        if sorted_list[l] == n:
            return l + 1
        else:
            return l


def soinsuu_bunkai(n):
    ret = []
    for i in range(2, int(n ** 0.5) + 1):
        while n % i == 0:
            n //= i
            ret.append(i)
        if i > n:
            break
    if n != 1:
        ret.append(n)
    return ret


def conbination(n, r, mod, test=False):
    if n <= 0:
        return 0
    if r == 0:
        return 1
    if r < 0:
        return 0
    if r == 1:
        return n
    ret = 1
    for i in range(n - r + 1, n + 1):
        ret *= i
        ret = ret % mod

    bunbo = 1
    for i in range(1, r + 1):
        bunbo *= i
        bunbo = bunbo % mod

    ret = (ret * inv(bunbo, mod)) % mod
    if test:
        # print(f"{n}C{r} = {ret}")
        pass
    return ret


def inv(n, mod):
    return power(n, mod - 2)


def power(n, p, mod_=mod):
    if p == 0:
        return 1
    if p % 2 == 0:
        return (power(n, p // 2, mod_) ** 2) % mod_
    if p % 2 == 1:
        return (n * power(n, p - 1, mod_)) % mod_


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from itertools import combinations
l, r = map(int,input().split())
if r-l >= 2019:
    print(0)
else:
    min_n = float('inf')
    for i, j in combinations([k for k in range(l, r+1)], 2):
        min_n = min(min_n, (i*j)%2019)
    print(min_n)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l, r = map(int, input().split())
"""
もしl~rの範囲に2019の倍数を含むならば、2019の倍数をi,jのいずれかに設定して0を得る。
それ以外の場合、l~rの範囲は高々2019程度なので、全探索で間に合う
"""
if r//2019 - l//2019 > 0:
    print(0)
else:
    ans = 2019
    for i in range(l, r):
        for j in range(l+1, r+1):
            ans = min(ans, (i*j)%2019)
            if ans == 0:
                break
    print(ans)

Submission status: Accepted

Solution code:
l,r = map(int,input().split())
if l - r >= 2019:
     print(0)
else:
     s = l % 2019

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

Submission status: Accepted

Solution code:
DEVISOR = 2019

L, R = (int(word) for word in input().split())

if (R // DEVISOR) > (L // DEVISOR):
    print(0)
    exit()

L %= DEVISOR
R %= DEVISOR

print(min(i * j % DEVISOR for i in range(L, R) for j in range(i+1, R+1)))

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+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())
#print(l,r)

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

print(best)

Submission status: Accepted

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

if 2018 <= r-l:
  ans = 0
elif r-l <= 2017:
  r_mod = r%2019
  l_mod = l%2019
  ans = 2019
  
  if l_mod < r_mod:
    for i in range(r_mod-l_mod):
      for j in range(1,r_mod-l_mod-i+1):
        temp = (l_mod+i)*(l_mod+i+j)%2019
        
        if temp < ans:
          ans = temp
      
      
  elif r_mod < l_mod:
    ans = 0
    
print(ans)

Submission status: Accepted

Solution code:
L, R = list(map(int, input().split()))
ans = 2020
if abs(L-R)>=2020:
    print(0)
else:
    for i in range(L, R):
        for j in range(L, R+1):
            if i==j:
                continue
            else:
                ans = min(ans, (i*j)%2019)
    print(ans)

Submission status: Accepted

Solution code:
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
#pypyではscipy, numpyは使えない
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
#from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
#import numpy as np
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7

def main():
  l, r = map(int, readline().split())
  if r-l>=2018:
    print(0)
  else:
    mod = []
    for i in range(l, r):
      for j in range(i+1, r+1):
        mod.append(i*j%2019)
    print(min(mod))
  
  
  
if __name__ == '__main__':
  main()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

MOD = 2019  # type: int


def solve(L: int, R: int):
    if R - L >= 2019:
        return 0
    def f():
        for i in range(L, R):
            for j in range(i+1, R+1):
                yield i * j % MOD
    return min(f())


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = int(next(tokens))  # type: int
    R = int(next(tokens))  # type: int
    print(solve(L, R))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
MOD = 2019
INF = 10**5
ans = INF


if 2019 <= R-L:
    print(0)
else:
    x = L % MOD
    y = R % MOD
    if x < y:
        for i in range(x, y):
            for j in range(i+1, y+1):
                ans = min(ans, (i*j) % MOD)
            if ans == 0:
                break
        print(ans)
    else:
        print(0)

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
MOD = 2019
INF = 10**5
ans = INF


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

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    L, R = input_nums()
    MOD = 2019
    ans = 2019
    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)
                exit(0)
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
mtx = [[0] * 2019 for _ in range(2019)]

for i in range(len(mtx)):
    for j in range(len(mtx)):
        mtx[i][j] = (i * j) % 2019

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

min_val = 10000000

l_mod = l % 2019
r_mod = r % 2019

if r_mod < l_mod:
    r_mod += 2019

for i in range(l, r):
    for j in range(i+1 , r + 1):
        a = i % 2019
        b = j % 2019
        ret = mtx[a][b]
        min_val = min(min_val, ret)
        if min_val == 0:
            print(0)
            exit()

print(min_val)

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    l,r = map(int, input().split())
    res = 10**10
    if r-l>=2019:
        print(0)
        exit()
    else:
        for i in range(l, r):
            n = i % 2019
            for j in range(i+1, r+1):
                p = j % 2019
                res = min(res, (n*p)%2019)
    print(res)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

if 2018<=r-l:
  print(0)
  sys.exit()

L=l%2019
R=r%2019
m=2018

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

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

print(m)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l,r = map(int,input().split())
dp = [0]*2019
L = []
cur = l
for i in range(r-l+1):
    t = cur%2019
    if dp[t] == 0:
        dp[t] = 1
        L.append(t)
        cur += 1
    else:
        break
ans = 10**9
for i in range(len(L)):
    for j in range(i+1, len(L)):
        ans = min(ans, (L[i]*L[j])%2019)
print(ans)

Submission status: Accepted

Solution code:
x,y=list(map(int, input().split()))

if y>x+2020:
	y=x+2020

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

Submission status: Accepted

Solution code:
import sys

L, R = map(int, input().split())
mod = 2019
ans = []
if R-L > 3000:
    print(0)
    sys.exit()
elif R-L <= 3000:
    for i in range(L, R + 1):
        for j in range(i + 1, R + 1):
            tmp = (i * j) % mod
            ans.append(tmp)
print(min(ans))