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, raw_input().split())

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

Submission status: Accepted

Solution code:
from enum import Enum
from queue import Queue
import collections
import numpy as np


import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

L,R = map(int,input().split())
min = BIG_NUM
if (R/2019 - L/2019)>=1.0:
    print(0)
else:
    for i in range(L,R+1):
        for j in range(i+1,R+1):
            tmp = (i*j)%2019
            if tmp < min:
                min = tmp
            if min == 0:
                break
    print(min)

Submission status: Accepted

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

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

for i in range(l, l+gen+1):
    if i%gen == 0:
        check = i - l

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

ll = min(l%gen, r%gen)
rr = max(l%gen, r%gen)

if rr-ll == 1:
    print((ll*rr)%gen)
    exit()

ans = 10**9

for i in range(ll, rr+1):
    for j in range(i+1, rr+1):
        ans = min(ans, (i*j)%gen)
print(ans)

Submission status: Accepted

Solution code:
import numpy as np
from collections import defaultdict
from functools import reduce

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

p, l = divmod(L, 2019)
q, r = divmod(R, 2019)

if p != q:
  print(0)
else:
  res = 2020
  for x in range(l, r+1):
    for y in range(x+1, r+1):
      res = min(res, x*y%2019)
  print(res)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

x = r // mod
line = x * mod

if l*r < mod:
    print(l*r)

elif l < line < r:
    print(0)

else:
    ans = 0
    for i in range(l,r):
        for j in range(i+1,r+1):
            x = i * j
            x = x % mod
            if i==l and j==i+1:
                ans = x
            elif x < ans:
                ans = x
    print(ans)

Submission status: Accepted

Solution code:
l=input().split()
L,R=int(l[0]),int(l[1])
a=0
if R-L<2019:
    a=2018
    for i in range(L,R):
        n=i%2019
        m=(i+1)%2019
        s=(n*m)%2019
        if s<a:
            a=s
        for j in range(R-i-1):
            s+=n
            s=s%2019
            if s<a:
                a=s
        if a==0:
            break
print(a)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
import math
import itertools

L, R = (int(i) for i in input().split()) 
if R - L >= 2019: 
  print(0)
else:
  ans = R * (R - 1)
  for x, y in itertools.combinations(range(L, R + 1), 2):
      mod = ((x % 2019) * (y % 2019)) % 2019
      ans = min(mod, ans)
  
  print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L,R=map(int,input().split())
min=20000
newR=L+2019
if newR<R: #Rを小さくする
    R=newR
for i in range(L,R): #L～R-1
    for j in range(i+1,R+1): #i+1～R
        a=(i*j)%2019
        if a<min:
            min=a
print(min)

Submission status: Accepted

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

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

ans = 2 * (10**9)

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

print(ans)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    [L, R] = string_to_int(inputs[0])

    if R - L >= 2019:
        return 0

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


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)

Submission status: Accepted

Solution code:
l,r=map(int,input().split())
ll=[]
mod=2019
if r-l+1>=2019:
    print(0)
    import sys
    sys.exit()
ans=10**100
import itertools
for i,j in itertools.combinations(range(l,r+1),2):
    ans=min(ans,(i*j)%mod)
print(ans)

Submission status: Accepted

Solution code:
inf = float('inf')

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

if R > L + 3000:
    R = L + 3000
t = [i % 2019 for i in range(L, R + 1)]
t.sort()
if (3 in t and 673 in t) or (0 in t):
    print(0)
else:
    n = len(t)
    ans = inf
    for i in range(n - 1):
        for j in range(i + 1, n):
            ans = min(ans, t[i] * t[j] % 2019)
    print(ans)
    # print(t)

Submission status: Accepted

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

if (R - L) // 2019 > 0:
    print(0)
elif (R - L) != (R % 2019 - L % 2019):
    print(0)
else:
    answer = 2019
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            tmp = i * j % 2019
            if tmp < answer:
                answer = tmp
    print(answer)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
_input = [i for i in open(0).read().split('\n') if i]
l, r = [int(i) for i in _input[0].split()]
i_start = l
j_start = l + 1
i_end = min(r-1, i_start+(2019-1))
j_end = min(r, j_start+(2019-1))

min_val = 2018
for i in range(i_start, i_end+1):
    for j in range(j_start, j_end+1):
        if i >= j:
            continue
        min_val = min(min_val, (i * j) % 2019)
print(min_val)

Submission status: Accepted

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

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

print(minimam)

Submission status: Accepted

Solution code:
import sys
from math import *
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

num = 2019
l, r = na()
li = []
if r - l > 2019:
    print(0)
else:
    for i in range(l, r+1):
        li.append(i % num)
    li.sort()
    n = len(li)
    m = 1000000000
    for i in range(n):
        for j in range(i+1, n):
            kazu = (li[i] * li[j]) % num
            if m > kazu:
                m = kazu
    print(m)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
L,R = list(map(int,input().split()))
if R-L >= 2019:
    import sys
    print(0)
    sys.exit()
mod_2019 = lambda x:x%2019
ret = 2020
ij_list = [i for i in range(L,R+1)]
for i in range(len(ij_list)):
    for j in range(i):
        k = mod_2019(ij_list[i]*ij_list[j])
        if k < ret:
            ret = k
print(ret)

Submission status: Accepted

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

x = 2019
xL = L // x
xR = R // x
if xL < xR or L == 0:
    print(0)
    exit()

mL = L % x
mR = R % x

ans = 2019
for i in range(mL,mR):
    for j in range(i+1,mR+1):
        cr = (i*j)%2019
        if ans > cr:
            ans = cr
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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



def solve():
  MOD = 2019
  L,R = map(int, input().split())
  ans = set()
  for i in range(L+1,R+1):
    for j in range(L,i):
      ans.add((i*j)%MOD)
    if min(ans)==0:
      return 0
  return min(ans)


def main():
  print(solve())


if __name__ == "__main__":
  main()

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
if R - L >= 2019:
  print(0)
else:
  L1 = L % 2019
  R1 = R % 2019
  if L1 > R1:
    print(0)
  else:
    ans = 2 * 10 ** 9
    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())

D = R - L
Ans = {2018}
J_Set = {2018}


for i in range(min(D, 2019)):
    A = L+i
    for j in range(D-i):
        B = L+i+j+1
        Ans.add((A*B)%2019)
        if j > 2019:
            break

print(min(Ans))

Submission status: Accepted

Solution code:
d = list(map(int, input().split()))
L = d[0]
R = d[1]

a = L//2019
b = R//2019
c = L%2019
d = R%2019

list = []

if b-a >= 2:
  print(0)

elif b-a == 1:
  if d >= c:
    print(0)
  else:
    for i in range(c,d+2019):
      for j in range(i+1,d+2019+1):
        list.append(i*j%2019)
    print(min(list)) 

else :
  for i in range(c,d):
    for j in range(i+1,d+1):
        list.append(i*j%2019)
  print(min(list))

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
min_mod = 2019
flg=[0]*2019
flg2=[0]*2019
for i in range(L,R):
    idx=i%2019
    if flg[idx]==1:
        break
    if flg[idx]==0:
        for j in range(i+1,R+1):
            mod  = (i*j)%2019
            if flg2[mod]==1:
                break
            flg2[mod]=1
            if min_mod > mod:
                min_mod=mod
        flg[idx]=1
print(min_mod)

Submission status: Accepted

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

import sys

#def xcheck(n):
#	
#    m = int(n**.5)
#    return 1 if abs(m*m - n) < 1e-6 else 0
#	if(1):
#		#兵法数なら
#		return 1
#	return 0

tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))
l=hoge[0]
r=hoge[1]

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

l=l%2019
r=((r-1)%2019)+1

#r=((r-1)%2019)+1
#if(l>r):
#	r+=2019

###
#print(l)
#print(r)

minans=2018
for i in range(l,r):
	for j in range(i+1,r+1):
		tmp = (i*j)%2019
		if tmp < minans:
			minans = tmp


#		print("{} {} minans {}".format(i,j,minans))
print(minans)





#print(min(n*a,b))

#print(n)
#print(a)
#print(b)

Submission status: Accepted

Solution code:
l,r=map(int, input().split())
List=[]
for i in range(l, min(r+1, l+2019*2+1)):
    List.append(i%2019)
List=sorted(List)
if len(List)<2019:
    ans=2018
    for i in range(len(List)):
        for j in range(i, len(List)):
            if i==j:
                continue
            ans=min(ans, List[i]*List[j]%2019)
    print(ans)
else:
    print((List[0]*List[1])%2019)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l,r = map(int, input().split())
import numpy as np
import itertools
MOD = 2019
if r-l+1 >= 673:
  print(0)
else:
  k = [i for i in range(l,r+1)]
  can = [0] * ((r-l+1)*(r-l)//2)
  for idx,(m,n) in enumerate(itertools.combinations(k,2)):
    can[idx] = (m*n)%MOD
  print(min(can))

Submission status: Accepted

Solution code:
import numpy as np

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

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

    if L > R:
        R += 2019
        
    if R - L > 500:
        print(0)
        
    else:
        for i in np.arange(L, R+1):
            for j in np.arange(i+1, R+1):
                i = i % 2019
                j = j % 2019
                k = i * j % 2019
                ans = np.amin(np.array([k, ans]))
            
        print(ans)

Submission status: Accepted

Solution code:
l,r=[int(i) for i in input().split()]
ss=2019
ans=200000000
if r-l<2019:
    for j in range(l,r+1):
        for k in range(l,r+1):
            if j==k:
                cnt=0
            else:
                ans=min(ans,j*k%2019)
    print(ans)
else:
    for i in range(1,10**9):
        ss=2019*i
        if l<=ss<=r:
            for j in range(ss,ss+2019):
                for k in range(ss,ss+2019):
                    if j==k:
                        cnt=0
                    else:
                        ans=min(ans,j*k%2019)
            print(ans)
            break

Submission status: Accepted

Solution code:
import sys
L,R = map(int,input().split())
list1 = []
i = L
j = L + 1
jcount = 0
while True:
    if i < R:
        if i*j %2019 == 0:
            print(0)
            sys.exit()
        list1.append(i*j%2019)
        if j < R:
            j += 1
        else:
            jcount += 1
            j = L+1 + jcount
            i += 1
    else:
        break
if len(list1) == 0:
    print(i*j%2019)
print(min(list1))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np


def main():
	L, R = [int(x) for x in input().split()]
	tmp_min = np.inf
	for i in range(L, R+1):
		for j in range(i+1, R+1):
			if (i * j) % 2019 < tmp_min:
				tmp_min = (i * j) % 2019
				if tmp_min == 0:
					print(tmp_min)
					exit()
	print(tmp_min)

if __name__ == "__main__":
	main()

Submission status: Accepted

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

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

numbers = list(range(l, r+1))


amari = list(set([x%2019 for x in numbers]))
#print(amari)


cnt = 2019
for i in range(len(amari)):
    for j in range(len(amari)):
        if i == j:
            continue
        if amari[i]*amari[j]%2019 < cnt:
            cnt = amari[i]*amari[j]%2019


print(cnt)

Submission status: Accepted

Solution code:
def main():
    L, R = [int(n) for n in input().split()]
    if R - L >= 2019:
        L = 0
        R = 2018
    
    li = [[0]*2019 for i in range(2019)]
    for i in range(2019):
        for j in range(i, 2019):
            li[i][j] = (i * j) % 2019
    res = 2030
    for i in range(L, R+1):
        for j in range(i+1, R+1):
            a, b = sorted([i%2019, j%2019])
            old = res
            res = min(res, li[a][b])
    print(res)
main()

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 - 1) or (R % 2019 <= L % 2019):
        print(0)
        return
    else:
        L = L % 2019
        R = R % 2019
        
        smallest = 10000000
        for i in range(L, R):
            for j in range(i+1, R+1):
                calc = (i*j)%2019
                if calc < smallest:
                    smallest = calc
    print(smallest)
    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())
mod=2019
if R-L>=2020:
    print(0)
    exit()
else:
    l=[]
    for i in range(L,R+1):
        l.append(i%mod)
ans=2018
for i in l:
    for j in l:
        if i!=j:
            ans=min(ans,i*j%mod)
print(ans)

Submission status: Accepted

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

if abs(L-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:
import numpy as np
import sys

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

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

r = np.array(list(i for i in range(L, R+1)))


mins = 2018

for i, ri in enumerate(r):
    for j in range(i+1, len(r)):
        rj = r[j]
        s  = np.mod(ri * rj, 2019)
        if(s < mins):
            mins = s
        if(s == 0):
            print(0)
            sys.exit()



print(mins)

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

for i in range(L, R) :
	for j in range(i + 1, R + 1) :
		if((i * j) % 2019 < mod) :
			mod = (i * j) % 2019
			x = ((i * j) // 2019) * 2019 + 2019
			if(x > i * R) :
				break
			else :
				pass
		elif(mod == 0) :
			break
		else :
			pass
	if(mod == 0) :
		break
	else :
		pass
	
print(mod)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
s=input()
#s = ("2020 2040")
#print(s) 
s = s.split(" ")
 
L = int( s[0] )
R = int( s[1] )
 
 
result =4.0e9  
for i in range(L,min(L+2019,R)):
    for j in range(i+1,min(R+1,L+2020)):
        mod = i*j % 2019
        #print(i,j,i*j,mod)
        if result > mod:
            result = mod
 
print(result)

Submission status: Accepted

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

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

Submission status: Accepted

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

A = []

ans = 2019

if (R-L) >= 2018:
    print(0)
else:
    for i in range(L,R+1):
        A.append(i % 2019)
    a = min(A)
    b = max(A)
    for j in range(a+1,b+1):
            for k in range(a,j):
                ans = min(ans,(j*k)%2019)
    print(ans)

Submission status: Accepted

Solution code:
import sys
import math


def get_iv():
    args = sys.stdin.readline()
    argv = args.split()
    iargv = [int(arg) for arg in argv]
    return iargv


def min_mod_prod(L, R):
    min_rem = 2019
    for i in range(L, R + 1):
        if min_rem == 0:
            break
        for j in range(i + 1, R + 1):
            if min_rem == 0:
                break
            tst = (i * j) % 2019
            if tst < min_rem:
                minij = [i, j]
                min_rem = tst

    minij.append(min_rem)
    return minij


def main():
    specs = get_iv()
    L = specs[0]
    R = specs[1]
    rv = min_mod_prod(L, R)
    # print(rv)
    print(rv[2])


if __name__ == '__main__':
    main()

Submission status: Accepted

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

min = 2019
diff = r-l+1

if diff > 2019:
  diff = 2019

for i in range(diff):
  for j in range(diff):
    if j > i:
      total = (i+l)*(j+l)
      if total > 2019:
        mod = total % 2019
        if min > mod:
           min = mod
      else:
        if min > total:
          min = total
print(min)

Submission status: Accepted

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

counter1 = 0
counter2 = 0

for i in range(L, R):
    counter1 += 1
    if counter1 > 20190:
        break
    for j in range(i + 1, R + 1):
        counter2 += 1
        if counter2 > 20190:
            break
        i_ = i % 2019
        j_ = j % 2019
        mod_ij = i_ * j_ % 2019
        if min > mod_ij:
            min = mod_ij
        
 
print(min)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L,R = map(int,input().split())
def judge_distance(i,j):
    if j-i >= 2019:
        return True

def search_2019(i,j):
    res = False
    for p in range(j-i+1):
        if i+p % 2019 == 0:
            res = True
            exit()

if judge_distance(L,R) or search_2019(L,R):
    print(0)
else:
    mincount = float("inf")
    for i in range(L,R):
        for j in range(L+1,R+1):
            if i*j%2019 <= mincount:
                mincount = (i*j)%2019

    print(mincount)

Submission status: Accepted

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


if (r-l)//2019 >= 1 :
    d = 0
else :
    ll = l%2019
    rr = r%2019
    if rr > ll :
        d = 2019
        for i in range(ll, rr) :
            for j in range(i+1, rr+1) :
                d = min(d, i*j%2019)
    else :
        d = 2019
        for i in range(ll, rr+2019) :
            for j in range(i+1, rr+2020) :
                d = min(d, i*j%2019)
print(d)

Submission status: Accepted

Solution code:
L, R = [int(x) for x in input().split()]
if R-L >= 2019:
  print(0)
elif L%2019 > R%2019:
  print(0)
else:
  s = 20190
  for i in range(L%2019,1+(R%2019)):
    for j in range(L%2019,1+(R%2019)):
      if i < j:
        t = (i*j)%2019
        if s > t:
          s = t
  print(s)

Submission status: Accepted

Solution code:
import os, sys, re, math

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

base = 2019
temp = L
mod = []
while (temp <= R) and (temp-L <= base):
    mod.append(temp % base)
    temp += 1

mod = list(set(mod))

ret = base
for i in range(len(mod)-1):
    for j in range(i+1,len(mod)):
        ret = min(ret, (mod[i]*mod[j])%base)

print(ret)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

print(res)

Submission status: Accepted

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

'''
d = R - L
if d >= 2019:
    ans = 0
else:
    l = L % 2019
    r = R % 2019
    
    if l + d >= 2019:
        ans = 0
    else:
        ans = l * (l+1)
        for i in range(l,l+d):
            for j in range(i+1,d):
                now = i * j % 2019
                ans = min(ans, now)
'''
d = R - L
if d >= 2019-1:
    ans = 0
else:
    I = L
    J = R
    ans = L * R % 2019
    for i in range(L,R):
        for j in range(i+1,R+1):
            now = i * j % 2019
            #ans = min(ans, now)
            if ans > now:
                ans = now
                I = i
                J = j
print(ans)

Submission status: Accepted

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

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

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
from operator import itemgetter, mul
from copy import deepcopy,copy
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

def main():
    l,r=MAP()

    if l//2019==r//2019:
        l%=2019
        r%=2019
        mi=INF
        for i in range(l,r):
            for j in range(i+1,r+1):
                mi = min(mi,(i*j)%2019)
        print(mi)

    else:
        print(0)


if  __name__=='__main__':
    main()

Submission status: Accepted

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

d = R - L
if d > 2019:
  d = 2019

min_r  = 2018
for i in range(L, L+d+1):
  for j in range(i+1, L+d+1):
    r = i*j % 2019
    if r < min_r:
      min_r = r

print(min_r)

Submission status: Accepted

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

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

    print(pot)

Submission status: Accepted

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

ans = 2019
if r - l >= 673:
  ans = 0
else:
  for i in range(l, r + 1):
    for j in range(i + 1, r + 1):
      cand = (i * j) % 2019
      if cand < ans:
        #print(i, j, cand)
        ans = cand
          
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)
#     print("s1")
elif (L//673<R//673 and L//3<R//3) or (L%3==0 and R%673==0) or (L%673==0 and R%3==0):
    print(0)
#     print("s2")
else:
    l=list(range(L,R+1))
    arr=[]
    for i in range(len(l)):
        for j in range(len(l)):
            if i < j:
                arr.append(l[i]*l[j]%2019)
    print(min(arr))

Submission status: Accepted

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

y=2019

if l//y != r//y:
    print(0)
else:
    a=l%y
    b=r%y
    m=y
    for i in range(a,b):
        for j in range(i+1,b+1):
            m=min(m,i*j%2019)
    print(m)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L,R=map(int,input().split())
mod=2019
ans=2019**2
for i in range(L,min(R+1,L+mod)):
    for j in range(L,min(R+1,L+mod)):
        if i>=j:
            continue
        ans=min(ans,i*j%mod)
print(ans)