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 = [int(_) for _ in input().split()]

# L, R = [4 + 2019, 5 + 2019 ]
if L - R >= 2019:
    ans = 0
    print(ans)
else:
    ans = 2018
    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(ans)
                exit()

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
import numpy as np
LL = L%2019
RR = R%2019

min = 2019
if LL >= RR:
    min = 0
elif R-L >= 2018:
    min = 0
else:
    for i in range(LL, RR+1):
        for j in range(i+1, RR+1):
            if (i*j)%2019 < min:
                min = (i*j)%2019
            if (i*j)%2019 == 0:
                min = 0
                break
        else:
            continue
        break


print(min)

Submission status: Accepted

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

Submission status: Accepted

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

 
if r - l >= 2019:
    print(0)
else:
    l_mod = l % 2019
    r_mod = r % 2019
    min_val = 2020
    for i in range(r_mod - l_mod + 1):
        for j in range(r_mod - l_mod + 1):
            if i >= j:
                continue
            min_val = min([min_val, ((l_mod+i)*(l_mod+j))%2019])
            
    print(min_val)

Submission status: Accepted

Solution code:
l,r = map(int,input().split())
mi = 2019
for x in range(l,min(r,l+2019)):
    for y in range(x+1,min(r+1,l+2019)):
        if mi > (x*y)%2019:
            mi = (x*y)%2019
print(mi)

Submission status: Accepted

Solution code:
import numpy as np
S = input().split() 
L = int(S[0])
R = int(S[1])
ans = 2019*2019
if(R-L >=2019):
    print(0)
else:
    for i in range(L,R):
        for j in range(i+1,R+1):
            ans = np.minimum(ans,(i*j)%2019)
            if(ans == 0):
                print(0)
                exit()
    print(ans)

Submission status: Accepted

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

#l,r = 4,5

if r-l>=2019:
    times = 2019
else:
    times = r-l

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

Submission status: Accepted

Solution code:
L,R = map(int,input().split(" "))
min = 1000000000000
if (R-L >= 2019):
    print("0")
    quit()
for i in range(L%2019,R%2019 + 1):
  for j in range(i+1, R%2019 + 1):
    tmp = (i * j)%2019
    if min > tmp:
      min = tmp
print(min)

Submission status: Accepted

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

MOD = 2019  # type: int

def solve(L: int, R: int):
    if R - L + 1 >= 2019:
        print(0)
    else:
        m = 2019
        for i, j in itertools.combinations(range(R-L+1), 2):
            if m > ((i+L)*(j+L) % 2019):
                m = (i+L) * (j + L) % 2019
        print(m)
    return


# Generated by 1.1.4 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
    solve(L, R)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
L,R = map(int,input().split())
l = L
m = (L *(L + 1)) % 2019
while l < min (R, L + 2019):
  r = l + 1
  while r <= min (R, L + 2019):
  	n = (l * r) % 2019 
  	m = min(m,n)
  	r = r + 1
  l = l + 1
print(m)

Submission status: Accepted

Solution code:
def solve(left, right):
    if right - left >= 2019:
        return 0
    l_mod = left % 2019
    r_mod = right % 2019
    if r_mod < l_mod:
        return 0
    ans = 2019
    for i in range(l_mod, r_mod + 1):
        for j in range(i + 1, r_mod + 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())
ans=10000000000
for i in range(l,r):
    for j in range(i+1,r+1):
        p=(i*j)%2019
        ans=min(p,ans)
        if(ans==0):
            break
    else:
        continue
    break
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from copy import *
from sys import *
import math
import queue
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)

#h,w
def main():
	l,r = map(int,input().split())
	if(r-l+1>2018):
		print(0)
		exit()
	else:
		min = 2020
		for i in range(l,r+1):
			for j in range(i+1,r+1):
				if(min>i*j%2019):
					min=i*j%2019
	print(min)
	exit()


def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(m,n):
	x = max(m,n)
	y = min(m,n)
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	return y

class queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-

def solve():
    L, R = list(map(int, input().split()))
    MOD = 2019
    
    if R-L >= MOD:
        print(0)
        return

    L %= MOD
    R %= MOD

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

if __name__ == "__main__":
    solve()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
L, R = map(int, (input().split()))
Lmod, Rmod = L%2019, R%2019
result = 2019
if Lmod < Rmod and (R - L >= 2019):
    print(0)
elif Lmod < Rmod and (R - L < 2019):
    for i in range(L,R,1):
        for j in range(i+1, R+1, 1):
            if result > (i*j)%2019:
                result = (i*j)%2019
    print(result)
elif Lmod > Rmod:
    print(0)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#abc133c

l,r=map(int,raw_input().split())
r=min(r,l+673)
res=2018
for i in  xrange(l,r+1):
 for j in xrange(i+1,r+1):
  res=min(res,i*j%2019)
print res

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

S = input()

S = S.split()

L = int(S[0])
R = int(S[1])
min = 2 * (10**10)

flg = 0

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

print(min)

Submission status: Accepted

Solution code:
a=(list(map(int,input().split())))
l=a[0]
r=a[1]
if(l-r>2021):
	print(0)
else:
	mini=2019
	i=l
	notFound=True
	while(i<=r-1 and notFound):
		j=i+1
		while(j<=r and notFound):
			p=(i*j)%2019
			
			mini=min(mini,p)
			if(mini==0):
				notFound=False	
			j+=1

		i+=1
	print(mini)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

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

l = L%2019
r = R%2019
answer = 0

if l-r < 0 and R - L < 2018:
    for i in range(r-l):
        for j in range(r-l-i):
            k = i + l
            m = j + l + i + 1
            if i == 0 and j == 0:
                answer = (k*m)%2019
            if answer >= (k*m)%2019:
                answer = (k*m)%2019
print(answer)

Submission status: Accepted

Solution code:
import numpy as np

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

N = int(L/2019)
M = int(R/2019)
l = L%2019
r = R%2019

answer = 0
delta = M - N

if delta == 0:
    for i in range(r-l):
        for j in range(r-l-i):
            k = i + l
            m = j + l + i + 1
            if i == 0 and j == 0:
                answer = (k*m)%2019
            if answer >= (k*m)%2019:
                answer = (k*m)%2019
print(answer)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

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

    ans = tmp_min
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

N, M, = map(int, input().split())

ans = 10 ** 18
for i in range(N, M):
    for j in range(i + 1, M + 1):
        ans = min(ans, i * j % 2019)
        if ans == 0:
            print(ans)
            exit()
print(ans)

Submission status: Accepted

Solution code:
def C_RemainderMinimization2019():
    L, R = map(int, input().split())
    ans = (L * R) % 2019
    if R - L < 2019:
        for i in range(L, R ):
            for j in range(i + 1, R + 1):
                ans = min(ans, (i * j) % 2019)
    else:
        for i in range(L, L + 2019):
            for j in range(i + 1, L + 2020):
                ans = min(ans, (i*j) % 2019)
                if ans == 0:
                    break
    print(ans)
if __name__ == "__main__":
    C_RemainderMinimization2019()

Submission status: Accepted

Solution code:

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

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

Submission status: Accepted

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

Submission status: Accepted

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

maxitr = min([R,L+2019])

minval = 2020

for i in range(L,maxitr+1):
  for j in range(i + 1,maxitr+1):
    if minval > i*j%2019:
      minval = i*j%2019

print(minval)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
m = 2019

def compute(L, R):
    global m
    #print("L={}, R={}".format(L, R))
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            v = i * j % 2019
            if v < m:
                m = v

            #print("({}, {})".format(i, j))
            if m == 0:
                return


L, R = list(map(int, input().rstrip().split()))
compute(L, R)
print(m)

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
x=0;md=0;min=4000
if a+2022<b:
    b=a+2022

for i in range(a,b,1):
    for j in range(a+1,b+1,1):
        x = i * j
        md = x % 2019
        if md < min:
            min = md


print(min)

Submission status: Accepted

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

mod = 2019
ans = 10 ** 7
results = [False for _ in range(2019)]
for low in range(L, R+1):
    for up in range(low+1, R+1):
        ans = min(ans, low * up % mod)
        if ans == 0:
            print(ans)
            exit()
        # results[low * up % mod] = True
        # if all(results):
        #     print(ans)
        #     exit()
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 2018
if R-L >= 2018:
	print(0)
else:
	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(i) for i in input().split()]

if l//2019 == r//2019:
  min_mod = 2017*2018
  for i in range(l, r):
    for j in range(l+1, r+1):
      temp = (i*j)%2019
      if temp < min_mod:
        min_mod = temp
  print(min_mod)
  
else:
  print(0)

Submission status: Accepted

Solution code:
import itertools

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

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

print(ans)

Submission status: Accepted

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

if not L // 2019 == R // 2019:
    print(0)
else:
    L %= 2019
    R %= 2019
    ans = 2020
    for i in range(L, R):
        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 L == 0:
    print(0)
elif not L // 2019 == R // 2019:
    print(0)
else:
    L %= 2019
    R %= 2019
    ans = 2020
    for i in range(L, R):
        for j in range(i+1, R+1):
            tmp = (i * j) % 2019
            if tmp < ans:
                ans = tmp
    print(ans)

Submission status: Accepted

Solution code:
import sys
l, r = (int(x) for x in input().split())
tmpmin = 2019
if r-l >= 2019:
    print(0)
else:
    for i in range(l, r):
        for j in range(l+1, r+1):
            tmp = (i*j)%2019
            if tmp < tmpmin:
                tmpmin = tmp
                if tmpmin == 0:
                    print(tmpmin)
                    sys.exit()
    print(tmpmin)

Submission status: Accepted

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


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

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

Submission status: Accepted

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

r = 2019
for i in range(L, R):
    for j in range(i+1, R+1):
        r = min(r, (i*j)%2019)
        if r == 0:
            print(r)
            sys.exit()

print(r)

Submission status: Accepted

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

l = L % 2019
r = min(R-L+l,2019)

ans = 2019

if r == 2019:
    print(0)
    exit()

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

print(ans)

Submission status: Accepted

Solution code:
L, R = map(int,input().split())
if R-L >= 2019:
    print(0)
    exit(0)
ans = 100000
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())
a = (l-1)//2019
b = r//2019
if a!=b:
  print('0')
  exit()
l=l%2019
r=r%2019
res=2019
for i in range(l, r+1):
  for j in range(i+1, r+1):
    temp = (i*j)%2019
    if temp<res:
      res=temp
print(res)

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())
l1=l%2019
lm=l+2019-l1

if r>lm:
    ans=0
else:
    r1=r%2019
    ans=4072324
    for x in range(l1,r1+1):
        for z in range(x+1,r1+1):
            ansnow=x*z%2019

            if ansnow<ans:
                ans=ansnow
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, math, itertools, bisect, copy, re
from collections import Counter, deque, defaultdict

# from itertools import accumulate, permutations, combinations, takewhile, compress, cycle
# from functools import reduce
# from math import ceil, floor, log10, log2, factorial
# from pprint import pprint

INF = float('inf')
MOD = 10 ** 9 + 7
EPS = 10 ** -7
sys.setrecursionlimit(1000000)

# N = int(input())
# N,M = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]
# A = [int(input()) for _ in range(N)]
# DP = [[0] * 100 for _ in range(100)]
# DP = defaultdict(lambda: float('inf'))

L, R = [int(x) for x in input().split()]

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

ans = 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:
import itertools

l, r = map(int, input().split())
if(r - l) > 2019:
    ans = 0
else:
    ans = 2018
    combs = list(itertools.combinations_with_replacement(range(l, r + 1), 2))
    for comb in combs:
        if comb[0] != comb[1]:
            a = (comb[0] * comb[1]) % 2019
            if ans > a:
                ans = a

print(ans)

Submission status: Accepted

Solution code:
import itertools

l, r = map(int, input().split())
if(r - l) > 2019:
    ans = 0
else:
    a = []
    combs = list(itertools.combinations_with_replacement(range(l, r + 1), 2))
    for comb in combs:
        if comb[0] != comb[1]:
            a.append((comb[0]*comb[1]%2019))

    ans = min(a)

print(ans)

Submission status: Accepted

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

if r - l >= 2019:
    print(0)
else:
    m = 2019
    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)

Submission status: Accepted

Solution code:
from collections import Counter
from collections import deque
from functools import reduce
from operator import mul
from pprint import pprint
import bisect
import copy
import fractions
import itertools
import math
import queue
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers): return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers): return reduce(LCM, numbers)
def LCM(m, n): return (m * n // fractions.gcd(m, n))
def COMBINATION(n, r):
    if n < 0 or r < 0 or n < r:
        return 0
    r = min(n-r, r)
    if r == 0:
        return 1
    o = reduce(mul, range(n, n - r, -1))
    u = reduce(mul, range(1, r + 1))
    return o // u
class UnionFind():

    def __init__(self, n):
        self.n = n
        self.node = [i for i in range(n)]
        self.size = [1 for _ in range(n)]

    def same(self, x, y):
        return bool(self.root(x) == self.root(y))

    def root(self, x):
        if self.node[x] == x:
            return x
        else:
            self.node[x] = self.root(self.node[x])  # 経路圧縮
            return self.node[x]

    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x == y:
            return  # 結合不要
        if self.size[x] < self.size[y]:
            x, y = y, x
        self.node[y] = x
        self.size[x] += self.size[y]

    def return_size(self, x):
        return self.size[self.root(x)]


left, right = MI()
if right - left >= 2019:
    print(0)
else:
    ans = INF
    for i in range(left, right+1):
        for j in range(i+1, right+1):
            ans = min(ans, (i * j) % 2019)
            if ans == 0:
                print(0)
                exit()
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l,r = map(int, input().split())
n = r - l + 1
if 2019<=n:
    print(0)
elif 3<=n and n<2019:
    for k in range(l,r+1):
        if k%673==0:
            print(0)
            exit()

    mod = 2019
    for i in range(l,r):
        for j in range(l+1,r+1):
            mod_new = (i*j)%2019
            if mod_new == 1:
                print(1)
                exit()
            else:
                mod = min(mod,mod_new)
    print(mod)                             
else:
    print((l*r)%2019)

Submission status: Accepted

Solution code:
import itertools
import sys

num = list(map(int,input().split()))
per = []

for i in range(num[0],num[1]+1):
    for j in range(num[0],num[1]+1):
        if i <= j:
            break
        else:
            per.append((i*j)%2019)
            if (i*j)%2019 == 0:
                print(0)
                sys.exit()
per.sort()

print(per[0])

Submission status: Accepted

Solution code:
list1 = [int(i) for i in input().split()]
l = list1[0]
r = list1[1]
if (l// 2019 != r//2019):
	print(0)
else:
	max1 = 10000000000
	if l - r >= 2019:
		for i in range(l,l+2020):
			for j in range(i+1,l+2020):
				temp = ((i%2019)*(j%2019))%2019
				if temp < max1 :
					max1 = temp
	else :
		for i in range(l,r+1):
			for j in range(i+1,r+1):
				temp = ((i%2019)*(j%2019))%2019
			
				if temp < max1 :
					max1 = temp
		
	print(max1)

Submission status: Accepted

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

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

print(minimum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L, R = [int(i) for i in(input().split(' '))]
minn=2019
if R-L+1>2019:
  print(0)
  exit()
for i in range(L,R):
    for j in range(i+1,R+1):
        mo = i*j
        amari = mo%2019
        minn = min(amari,minn)
        if minn==0:
          break
print(minn)

Submission status: Accepted

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

choices = set()
for i in range(L, R + 1):
    choices.add(i % 2019)
    if len(choices) == 2019:
        break

min_ = None
choices = sorted(choices)
for i in range(len(choices)):
    vi = choices[i]
    for j in range(i + 1, len(choices)):
        vj = choices[j]
        if min_ is None or (vi * vj) % 2019 < min_:
            min_ = (vi * vj) % 2019
print(min_)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
def main02():
    data = input().split()
    num = []

    for i in range(2):
        num.append(int(data[i]))
    if (num[1]-num[0]) > 2020:
        num[1] = num[0] + 2020
    kaisu = num[1] - num[0] + 1
    result = 3000
    for i in range(num[0],num[0]+kaisu-1,1):
        for j in range(i+1,num[0]+kaisu,1):
            kari = (i * j) % 2019
            if kari < result:
                result = kari
    print(result)


if __name__ == "__main__":
    main02()

Submission status: Accepted

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