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 numpy as np

a = input().split(" ")

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

if int(L/2019) < int(R/2019):
    print(0)
else:
    flag = 0
    min = 2018
    max = 0
    for i in range(L,R+1):
        if max < i%2019:
            max = i%2019
        if min > i%2019:
            min = i%2019
        if i%2019 == 0:
            print(0)
            flag = 1
            break
    if flag == 0:
        flag2 = 0
        ans = 2018
        for i in range(min,max):
            for j in range(i+1,max+1):
                if ans > (i*j)%2019:
                    ans = (i*j)%2019
                if ans == 0:
                    print(0)
                    flag2 = 1
                    break
            if flag2 == 1:
                break
        if flag2 == 0:
            print(ans)

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
left = L%2019
right = R%2019
if R-L>2017 or left > right:
    print(0)
else:
    l = [i for i in range(left, right+1)]
    ans = 9999
    for i in range(len(l)-1):
        for j in range(i+1, len(l)):
            mo = l[i]*l[j]%2019
            if mo<ans:
                ans = mo
    print(ans)

Submission status: Accepted

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

tmp = []
if L + 2019 < R:
    for i in range(L, L+2019+1):
        for j in range(L, L+2019+1):
            if i == j:
                continue
            tmp.append(i * j % 2019)
else:
    for i in range(L, R+1):
        for j in range(L, R+1):
            if i == j:
                continue
            tmp.append((i * j) % 2019)

print(min(tmp))

Submission status: Accepted

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

Submission status: Accepted

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

result = []

for i in range (l, min(r,l + 2019)):
	for j in range(i+1, min(r +1 , i + 1 +2019)):

		temp = i * j % 2019
		result.append(temp)

print(min(result))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
i, j = map(int, input().split())

if i + 2019 < j:
    print(int(0))
else:
    min_ = 2019
    for a in range(i,j+1):
        for b in range(a+1,j+1):
            min_ = min(min_, ((a%2019)*(b%2019))%2019)
    print(min_)

Submission status: Accepted

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


if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
L,R = map(int, input().split())
if (R - L) + 1 >= 2019:
        print(0)
        exit()
elif (R - L) + 1 >= 673:
        print(0)
        exit()

if (R - 1) * R < 2019:
        print(L * R)
        exit()


if L % 2019 == 0:
        print(0)
        exit()
elif L % 673 < R % 673:
        li = range(L, R + 1)
        cmb = list(itertools.combinations(li,2))
        ans = (R-1) * R
        for i,j in cmb:
                ans = min(ans, (i*j) % 2019)
        print(ans)

else:
        print(0)
        exit()

Submission status: Accepted

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

ans = float('inf')

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

print(ans)

Submission status: Accepted

Solution code:
# C - Remainder Minimization 2019



def remind2019(L, R):
    # 0 2019の倍数がある
    if (R-L)> 2019:
        return 0

    if (R%2019 == 0) or (L%2019==0):
        return 0
    else:
        qL, mL = divmod(L,2019)
        qR, mR = divmod(R, 2019)

        if mR <= mL: #１周している
            return 0
        else:
            min_m = 2017*2018
            for i in range(mL, mR):
                for j in range(i+1, mR+1):
                    m = (i*j)%2019

                    if m < min_m:
                        min_m = m 
            return min_m



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

Submission status: Accepted

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

minValue = 2018
rR = R if R < L + 2019 else L + 2019
for i in range(L, rR):
    temp = 0
    for j in range(i+1, rR):
        temp = i*j % 2019
        if(temp < minValue):
            minValue = temp
    temp = i*rR % 2019
    if(temp < minValue):
        minValue = temp
print(minValue)

Submission status: Accepted

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

v = 2019

mins = []
for i in range(L,min(R,L + v)):
    tmp_min = 10e10
    for h in range(i + 1,min(R,L + v) + 1):
        res = (i * h) % v
        if res < tmp_min:
            tmp_min = res
    mins.append(tmp_min)


print(min(mins))

Submission status: Accepted

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

l = L // mod
r = R // mod

if l != r:
    print(0)
else:
   l_ = L % mod
   r_ = R % mod
   ans = 2019
   for i in range(l_, r_):
       for j in range(i+1, r_+1):
           a = i * j % mod
           ans = min(ans, a)
   print(ans)

Submission status: Accepted

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

if r - l >= 2018:
    print(0)
elif (l % MOD) >= (r% MOD):
    print(0)
else:
    left = l % MOD
    right = r % MOD
    L = list(range(left, right+1))
    n = len(L)
    ans = 10**4
    for i, elm in enumerate(L):
        for j in range(i+1, n):
            ans = min(ans, ((elm * L[j]) % MOD))
    print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

mod = 1000000
for i in range(L, R+1):
  for j in range(i+1, R+1):
    tmp = (i * j) % 2019
    if tmp == 0:
      print(tmp)
      sys.exit()
      
    if mod > tmp:
      mod = tmp
    
print(mod)

Submission status: Accepted

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

if L // 2019 < R // 2019 or L % 2019 == 0:
    ans = 0
else:
    l = L % 2019
    r = R % 2019
    ans = 2019
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            ans = min(ans, (i * j) % 2019)
print(ans)

Submission status: Accepted

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

l =[]

for j in range(L, R+1):
    for i in range(j+1, R+1):
        l.append(i * j % 2019)
        if i * j % 2019 == 0:
            break
    else:
        continue
    break

print(min(l))

Submission status: Accepted

Solution code:
l, r = map(int, input().split())
f = 0
mod_list = []

for i in range(l, r+1):
    if i%2019 == 0:
        f = 1
        break
    mod_list.append(i%2019)

if f == 1:
    print(0)
else:
    #print(mod_list)
    ans = 2018
    for i in range(len(mod_list)):
        for j in range(i+1, len(mod_list)):
            if mod_list[i]*mod_list[j]%2019 < ans:
                ans = (mod_list[i]*mod_list[j])%2019
    print(ans)

Submission status: Accepted

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

# スペース区切りの整数の入力
l,r = map(int, input().split())

tmp_ans = 0
ans = -1

for i in range(r-l):
    for j in range(r-l):
        tmp_ans = ((l+i) * (l+j+1)) % 2019
        # print("({} = ({}+{}) * ({}+{}+1)) % 2019".format(tmp_ans,l,i,l,j))
        if tmp_ans == 0:
            ans = 0
            break
        if tmp_ans < ans:
            ans = tmp_ans
        elif ans == -1:
            ans = tmp_ans
    if ans == 0:
        break

# 出力
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

R = min(l+2018, r)
min_x = 2018

for i in range(l, R+1):
    for j in range(i+1, R+1):

        x = (i*j) % 2019
        if x < min_x:
            min_x = x
print(min_x)

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
L1 = L%2019
R1 = R%2019
L2 = L//2019
R2 = R//2019
if L2 != R2:#LとRの間に0でなるとき
  ans = 0
else:
  ans = (L*(L+1))%2019
  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:
#!/usr/bin/env python3
import sys

MOD = 2019  # type: int

def solve(L: int, R: int):
    if R - L >= 2019:
        print(0)
        return
    L = L % 2019
    R = R % 2019
    if L >= R:
        print(0)
        return
    res = 2019
    for i in range(L, R):
        for j in range(i+1, R+1):
            res = min(res, (i*j)%2019)
    print(res)
    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())

from itertools import combinations

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

ans = [(x1*x2)%2019 for (x1, x2) in combinations(range(l, r+1), 2)]

print(min(ans))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import numpy as np
import cmath
L, R = map(int,input().split())
saisyo = 2019
if(R-L>=2019):
    print(0)
else:
    vec = np.arange(L,R+1)
    vec = vec%2019
    for i in range(0,len(vec)):
        minvec = np.where(vec==vec[i],2018,vec*vec[i]%2019)
        tmp = np.min(minvec)
        if tmp < saisyo:
            saisyo = tmp
    print(saisyo)

Submission status: Accepted

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

Submission status: Accepted

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

if int(arg[0] / 2019) != int(arg[1] / 2019):
  arg[1] = arg[0] + 2019
  
min_value = 2019
for i in range(arg[0], arg[1]+1):
  for j in range(i+1, arg[1]+1):
    value = (i*j) % 2019
    if value < min_value:
      min_value = value
      
print(min_value)

Submission status: Accepted

Solution code:
import sys
lr = list(map(int, input().split()))
l = lr[0]
r = lr[1]
lmod = l%2019

def minfunc(x, y):
    if x > y:
        return y
    else:
        return x

if r - l >= 2019:
    print(0)
elif 2019 <= r - l + lmod:
    print(0)
else:
    min = 9999999
    modlist = list(map(lambda x: x%2019,range(l,r+1)))
    for i in range(r-l):
        for j in range(i+1, r-l+1):
            min = minfunc((modlist[i]*modlist[j])%2019,min)
    print(min)

Submission status: Accepted

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

l_quo = l // 2019
r_quo = r // 2019
l_mod = l % 2019
r_mod = r % 2019

if l_quo < r_quo:
	print(0)
else:
	min = 2020
	for i in range(l_mod, r_mod+1):
		for j in range(i+1, r_mod+1):
			if (i*j)%2019 < min:
				min = (i*j)%2019
				
	print(min)

Submission status: Accepted

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

minVal = 2018
for l in range(L, R):
    if l == L+2019:
        break
    for r in range(l+1, R+1):
        if r == l+2019:
            break
        if minVal >= (l*r) % 2019:
            minVal = (l*r) % 2019
print(minVal)

Submission status: Accepted

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

#f = 0
l = []

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

for i in range(L,R):
    for j in range(i+1,R+1):
        l.append((i*j)%2019)
else:
    l.sort()

print(l[0])

Submission status: Accepted

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

res=2019

x_q=x//2019
#x_mod=x%2019
#y_q=y//2019
#y_mod=y%2019

#if x_mod>0 or y_mod>0:
#	res=0
#else:

y_mod=min(y,2019*(x_q+1))

for i in range(x, y_mod):
	for j in range(i+1,y_mod+1):
		res=min(res,(i*j)%2019)

print(res)

Submission status: Accepted

Solution code:
import sys
from itertools import combinations
L, R = map(int, input().split())
    
if R - L + (L % 2019) >= 2019:
    print(0)
    sys.exit()

else:
    tmp = 2 * (10 ** 9)
    lis = list(range(L, R + 1))
    for item in list(combinations(lis, 2)):
        mini = min((((item[0] % 2019) * item[1]) % 2019), (((item[1] % 2019) * item[0]) % 2019))
        if tmp >= mini:
            tmp = mini
            #print(item[0], item[1])
            #print(tmp)
print(tmp)

Submission status: Accepted

Solution code:
hoge = input().split()
L = int(hoge[0])
R = int(hoge[1])

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

Submission status: Accepted

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

for i in range(l, r + 1):
    if divmod(i, 2019)[1] == 0:
        print(0)
        exit()

tmp = set()
for i in range(l, r):
    for j in range(l + 1, r + 1):
        tmp.add(divmod(i * j, 2019)[1])

print(min(tmp))

Submission status: Accepted

Solution code:
# 2つの入力を空白で分割し、数値化
L, R = map(int, input().split())

left = range(L, R)
right = range(L+1, R+1)

minmond = 2019
for l in left:
    for r in right:
        x = l * r
        mod = x % 2019
        minmond = min(minmond, mod)
        if minmond == 0:
            print(0)
            exit(0)
print(minmond)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
LAW = 2019
l = L % LAW
r = R % LAW
if R - L >= LAW:
  ans = 0
elif l >= r:
  ans = 0
else:
  candidates = list(range(l, r+1))
  mods = []
  for i in range(len(candidates)):
    for j in range(i+1, len(candidates)):
      mods.append((candidates[i] * candidates[j]) % LAW)
  ans = min(mods)
print(ans)

Submission status: Accepted

Solution code:
N,M=list(map(int,input().split()))
if M-N>2018 or (N%2019>M%2019):
    print(0)
else:


    ans=2018
    for i in range(N,M+1):
        for j in range(i+1,M+1):
            ans=min(ans,(i*j)%2019)
    print(ans)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    l, r = map(int, input().split())
    if l + 2019 <= r:
        print(0)
        exit()
    m = 2019
    for i in range(l, r):
        res_i = i % 2019
        for j in range(l + 1, r + 1):
            res_j = j % 2019
            res = (res_i * res_j) % 2019
            if m > res:
                m = res
    print(m)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

n1, n2 = [int(i) for i in input().split()]

r1 = 2018

if n2 - n1 >= 2019:
    print(0)
    sys.exit()


for i3 in range(n2 - n1):
    n4 = i3 + n1

    t1 = n2 - n4
    if t1 >= 2019:
        t1 = 2019
    for i5 in range(t1):
        n5 = i5 + n4 + 1

        if ((n4 * n5) % 2019)  < r1:
            r1 = ((n4 * n5) % 2019)

print(r1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L,R = map(int,input().split())
 
ans = 2019
m = []
l = R-L+1
if l < 2019:
	for i in range(L,R+1):
		m.append(i%2019)
else:
	for i in range(L,L+2019):
		m.append(i%2019)

for i in range(len(m)):
	for j in range(i+1,len(m)):
		tmp = (m[i]*m[j])%2019
		if ans> tmp:
			ans = tmp
		if tmp == 0:
			break				
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

tmp = R - L + 1
if tmp >= 2019:
    print(0)
    exit()
else:
    start = L % 2019
    end = R % 2019
    candidate = []
    for i in range(start, end + 1):
        candidate.append(i % 2019)
    candidate.sort()
    ans = []
    for i in range(len(candidate)):
        if i == (len(candidate) - 1):
            continue
        for j in range(i + 1, len(candidate)):
            if i == j:
                continue
            else:
                ans.append((candidate[i] * candidate[j]) % 2019)
    ans.sort()
    print(ans[0])

Submission status: Accepted

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

if (r-l)>=2019:
    print(0)
else:
    l %= 2019
    r %= 2019

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

Submission status: Accepted

Solution code:
l, r = map(int, input().split())
m = 2019
for i in range(l, r+1):
  for j in range(i+1, r+1):
    mod1 = i % 2019
    mod2 = j % 2019
    if mod1 == 0 or mod2 == 0:
      print(0)
      exit()
    mod = (mod1 * mod2) % 2019
    if mod < m:
      m = mod

print(m)

Submission status: Accepted

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

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

Submission status: Accepted

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

ans = []
imax = R - L + 1

for i in range(2019):
    a = L + i
    if a >= R:
        break
    for j in range(i + 1, 2020):
        b = L + j
        if b > R:
            break

        if (a*b)%2019 == 0:
            print(0)
            exit()
        ans.append((a*b)%2019)

print(min(ans))

Submission status: Accepted

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

ans = 3000

l = [-1] * 2019 
r = [-1] * 2019

flagl = False
for i in range(L, R):
    if l[i%2019] != -1:
        flagl = True
    l[i%2019] = i%2019
    flagr = False
    for j in range(i+1, R+1):
        if r[j%2019] != -1:
            flagr = True
            break
        r[j%2019] = j%2019
    if flagl == True and flagr == True:
        break

tmp = 0
for i in l:
    if i == -1:
        continue
    for j in r:
        if j == -1:
            continue
        tmp = (i * j) % 2019
        if tmp < ans:
            ans = tmp
print(ans)

Submission status: Accepted

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

mod = []
if R+1-L<=2019:
    for i in range(L,R):
        for j in range(i+1,R+1):
            mod.append((i*j)%2019)

else:
    for i in range(L, L+2019):
        for j in range(i, L+2019+1):
            mod.append((i*j)%2019)


if len(mod)==0:
    print((L*R)%2019)
else:
    print(min(mod))

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
mod = 2019
left = L // mod
right = R // mod
l_mod = L % mod
r_mod = R % mod

if left != right or l_mod == 0 or r_mod == 0:
    print(0)
else:
    ans = float('inf')
    for i in range(l_mod, r_mod):
        for j in range(i + 1, r_mod + 1):
            ans = min(ans, (i * j) % mod)
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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


if R-L > 2019 :
    print(0)
elif r <= l :
    print(0)

else:
    MOD = 2019
    N = r - l
    A = []
    for i in range(l,r+1):
        A.append(i)
    #print(A)
    for i in range(N):
        for k in range(i+1,N+1):
            X = (A[i] * A[k]) % 2019
            if X < MOD:
                MOD = X
        
    print(MOD)

Submission status: Accepted

Solution code:
L,R=map(int,input().split())
ans = 1000000
for i in range(2100):
    for j in range(1, 2100):
        if i < j and L + j <= R:
            tmp = ((L+i) * (L+j)) % 2019
            ans = min(ans, tmp)
print(ans)

Submission status: Accepted

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

l = L % 2019
r = R % 2019

lst = []
if (R - L >= 2019):
  print(0)
else:
  for i in range(L, R):
    for j in range(i+1, R+1):
      lst.append((i * j) % 2019)
  print(min(lst))

Submission status: Accepted

Solution code:
import numpy as np
l,r = map(int,input().split())
mod = 2019
arr = np.array(list(set([i%mod for i in range(l,min(r+1,l+2019))])))
ans = 2019

for left in range(len(arr)-1):
    ans = min(min(arr[left]*arr[left+1:]%mod),ans)
    if ans == 0:
        print(ans)
        exit()
print(ans)

Submission status: Accepted

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

a = L // 2019
b = R // 2019
if L > R or L == 0:
  ans = 0
  print(ans)
  exit()

c = L // 3
d = R // 3
e = L // 673
f = R // 673
if d > c and f > e:
  ans = 0
  print(ans)
  exit()
else:
  ans = 2019
  for i in range(L,R+1):
    for j in range(i+1, R+1):
      ans = min((i*j)%2019,ans)
print(ans)

Submission status: Accepted

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

flag3 = flag673 = False
if R % 3 == 0 or L % 3 == 0:
    flag3 = True
for i in range((L // 673) * 673, 2 * 10 ** 9, 673):
    if L <= i and i <= R:
        flag673 = True
        break

ans = 0
if (flag3 and flag673) is False:
    ans = 10**9
    if R - L > 2100:
        R = L + 2100
    for i in range(L, R + 1):
        for j in range(i + 1, R + 1):
            if (i * j) % 2019 < ans:
                ans = (i * j) % 2019
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
L,R=map(int,input().split())
a=(L-1)//2019
b=L%2019
c=R//2019
d=R%2019
if a!=c:
  print("0")
else:
  if b>=d:
    d=d+2019
  f=(b*d)%2019
  for i in range(b,d):
    for j in range(i+1,d+1):
      e=(i*j)%2019
      if e<f:
        f=e
      j=j+1
    i=i+1
  print(f)

Submission status: Accepted

Solution code:
import sys
l,r=map(int,input().split())
anslist=20000000000
for i in range(l,r):
    if r-i>=(2019-i%2019):
        print(0)
        sys.exit()
    for u in range(i+1,r+1):
        ans=min(anslist,i*u%2019)
        anslist=ans
print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def calc(L, R):
    imod = L % 2019
    if (imod == 0):
        print(0)
    elif (R - L > 2019 - imod - 1):
        print(0)
    else:
        m = L * 2019
        for i in range(L, min(R + 1, L + 2019 - imod)):
            for j in range(i + 1, min(R + 1, L + 2019 - imod)):
                x = (i * j) % 2019
                m = min(m, x)
        print(m)


s = input().split(' ')
L = int(s[0])
R = int(s[1])
calc(L, R)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
AtCoder A
"""

import sys, math, random
import numpy as np

# N = int(input())
# A = list(map(int,input().split())) # N row 1 column
# A = [int(input()) for _ in range(N)] # 1 row N column
# S = str(input()) # str(input()) == input() -> 'abc'
# S = list(input()) # abc -> ['a','b','c']
# S.replace('ABC','X') # "testABCABC" -> "testXX"
 
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
 
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 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 I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    L, R = list(map(int,input().split()))
    m=2020
    if R%2019==0:
        print(0)
    elif R-L>2025:
        print(0)
    else:
        for i in range(L,R+1):
            # print(i)
            for j in range(i+1,R+1):
                # print(i,j)
                t=(i*j)%2019
                if t<m:
                    m=t
                    # print(m,i)
        print(m)
        # for i in range(L,R):
        #     # print(m,i)
        #     t=(i*(i+1))%2019
        #     print(t)
        #     if t<m:
        #         m=t
        #         print(m,i)
        # print(m)

    # print(A,B)
    
if __name__ == "__main__":
    main()

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

ans = 2020
if l%2019==0 or r%2019==0 or (l // 2019 != r // 2019):
	ans = 0
else:
	for i in range(l,r):
		if ans == 0:
			break
		for j in range(i+1,r+1):
			# print(i,j)
			ans = min(ans,i*j%2019)
			if ans == 0:
				break
print(ans)

Submission status: Accepted

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

L_amari= L%2019
R_amari= R%2019

if R-L <2018:
    if L_amari <= R_amari:
        if L_amari==0:
            ans=0
        else:
            amari_list = [i for i in range(L_amari,R_amari+1)]
            amari_min=114514
            for i in range(len(amari_list)):
                for j in range(i+1,len(amari_list)):
                    amari=amari_list[i]*amari_list[j]%2019
                    if amari_min > amari:
                        amari_min = amari
            ans =amari_min
    else:
        ans=0
else:
    ans=0

print(ans)

Submission status: Accepted

Solution code:
L, R = (int(i) for i in input().split())
i, j = 2018, 2018
imod, jmod = 2018, 2018
min_val = 2018

if L <= 2019 and 2019 < R:
    print(0)
    exit()
elif R/2019 >= 2 and L//2019 != R//2019:
    print(0)
    exit()
else:
    for k in range(L, R+1):
        for s in range(k+1, R+1):
            new = (k*s)%2019
            if new < min_val:
                min_val = new

#print(i, j)

print(min_val)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
L,R = [int(x) for x in stdin.readline().rstrip().split()]
ans = 2019
#if L + 2019 >= R:
#    ans = 0
#else:
for i in range(L,R):
    for j in range(L+1,R+1):
        ans = min((i*j % 2019,ans))
        if ans == 0:
            break
    else:
        continue
    break
        
        
print(ans)

Submission status: Accepted

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

L2, R2 = L % Y, R % Y
dist = (R - L) // Y

if L2 == 0 or R2 == 0 or R2 <= L2 or 1 <= dist:
    res = 0
else:
    mn = (L2 * (L2+1)) % Y
    for i in range(L2, R2+1):
        for j in range(i+1, R2+1):
            if (i*j%Y) < mn:
                mn = i*j % Y
    res = mn

print(res)