Problem:


Score : 300 points

Problem Statement

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

Constraints

All values in input are integers.

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

Input

Input is given from Standard Input in the following format:

L R

Output

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

Sample Input 1

2020 2040

Sample Output 1

2

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

Sample Input 2

4 5

Sample Output 2

20

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



Sample input:
2020 2040


Sample output:
2

Submission status: Accepted

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

mod = 2019
R = min(R, L + mod + 1)

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

print(ans)

Submission status: Accepted

Solution code:
l, r = list(map(int, input().split()))
MOD = 2019
diff = r - l
ans = 0
if diff < 2019:
    l = l % MOD
    r = l + diff
    ans = 2018
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            ans = min(ans, (i % MOD * j % MOD) % MOD)

print(ans)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
MOD = 2019

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

if R - L >= 2018 or R % MOD <= L % MOD:
    print(0)
else:
    ans, LM, RM = 2019, L % MOD, R % MOD
    for i in range(LM, RM):
        for j in range(i + 1, RM + 1):
            ans = min(ans, (i * j) % MOD)
    print(ans)

Submission status: Accepted

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

res = mod
for i in range(l, r):
    for j in range(r, l-1, -1):
        if i == j:
            break
        res = min(res, i*j % mod)

print(res)

Submission status: Accepted

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

res = mod
for i in range(l, r):
    for j in range(r, l-1, -1):
        if i == j:
            break
        tmp = i*j % mod
        if tmp < res:
            res = tmp

print(res)

Submission status: Accepted

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

print(min(
    (i * j) % MOD
    for i in range(L, R + 1)
    for j in range(i + 1, R + 1)
) if R - L < MOD - 1 else 0)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b=input().split()
a=int(a)
b=int(b)
c=0
for i in range(a,b+1):
  if b-a>=672:
    c=1
    break
  elif i%673==0:
    c=1
    break
ll=[]
if b-a==1:
  print(a*b%2019)
elif c==1:
  print(0)
elif b-a>=100:
  print(1)
elif b-a>=46:
  print(2)
else:
  for i in range(a,b):
    for j in  range(i+1,b+1):
      ll.append(i*j%2019)
  print(min(ll))

Submission status: Accepted

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

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

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l,r = map(int,input().split())
r = min(r,l+678)
ans = 2018

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 = list(map(int, input().split()))
L_mod = L%2019
R_mod = R%2019
L_shou = L//2019
R_shou = R//2019
ans = 2020
if L_shou == R_shou:
    for l in range(L_mod, R_mod):
        for r in range(l+1, R_mod+1):
            if (l*r)%2019 < ans:
                ans = (l*r)%2019
    print(ans)
else:
    print(0)

Submission status: Accepted

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

ans = 2018
R = min(R, L+2020)
for i in range(L, R+1):
    f = False
    for j in range(i+1, R+1):
        m = (i*j)%2019
        if  m  == 0:
            ans = m
            f = True
            break     
        ans = min(ans, m)
    if f:
        break
print(ans)

Submission status: Accepted

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


def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, m=1, typ=int):
    return [read_h() if m > 1 else typ(input()) for _ in range(n)]


def main():
    L, R = read_h()

    if R - L >= 2019 or R % 2019 <= L % 2019:
        print(0)
        return

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

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#ABC133-C
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
l,r=IL()
ans=2019
for i in range(l,min(l+2019,r+1)-1):
    for j in range(i+1,min(l+2019,r+1)):
        ans=min(ans,i*j%2019)
print(ans)

Submission status: Accepted

Solution code:
def main():
	L, R = map(int,input().split())
	K = R - L
	ans = 2019
	if K >= 2019:
		ans = 0
	else:
		for k in range(K+1):
			for d in range(k):
				ans = min(ans,(((L + k)%2019)*((L + d)%2019))%2019)
	print(ans)
main()

Submission status: Accepted

Solution code:
L,R = [int(x) for x in input().split()]
 
min_ans = 10**18

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

          if ans < min_ans:
              min_ans = ans
          if min_ans == 0:
              break
print(min_ans)

Submission status: Accepted

Solution code:
import numpy as np

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

min_ = np.inf
for i in range(L, R):
    for j in range(i + 1, R + 1):
        if (i * j) % 2019 <= min_:
            min_ = (i * j) % 2019
            if min_ == 0:
                print(min_)
                exit()

print(min_)

Submission status: Accepted

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

ll = l % 2019
ans = 2018
if l-n >= 672:
    ans = 0
elif n-l > 2:
    for i in range(ll,ll + n-l +1):
        if i % 673 == 0:
            ans = 0
            break
        else:
            for j in range(ll,ll + n-l +1):
                if i != j:
                    ansss = i*j%2019
                    if ansss == 0:
                        ans = 0
                        break
                    elif ansss < ans:
                        ans = ansss
else:
    ans = l*n%2019

print(ans)

Submission status: Accepted

Solution code:
l,r = map(int, input().split())
if (r - l >= 2019):
  print(0)
else:
  res = []
  for i in range(l, r + 1):
    res.append(i % 2019)
  res.sort()
  ans = 2019 * 2019
  for hoge in res:
    for fuga in res:
      if(hoge != fuga and ans > ((hoge * fuga) % 2019)):
        ans = (hoge * fuga) % 2019
  print(ans)

Submission status: Accepted

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

P = 2019

R = min(R, L+673)

tmp = 2018
for i in range(L, R):
    for j in range(L+1, R+1):
        tmp = min((i*j)%P, tmp)
        
print(tmp)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

L,R = map(int,input().split())
if R-L>673:
    print(0)
else:
    ans =2019
    for i in range(R-L+1):
        for j in range(R-(L+i)):
            m = L+i
            n = L+j+i+1
            ans = min(ans, m*n%2019)
            if ans == 0:
                print(ans)
                sys.exit()
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
from itertools import combinations

mod = 2019

if R - L >= mod:
    print(0)
else:
    mini = mod - 1
    for i, j in combinations(range(L, R+1), 2):
        mini = min(mini, i*j % mod)
        if mini == 0:
            break
    print(mini)

Submission status: Accepted

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

l_q = l // 2019
r_q = r // 2019
l_mod = l % 2019
r_mod = r % 2019

mod_min = 2019

if l_q < r_q:
    print(0)
else:
    for i in range(l_mod, r_mod):
        for j in range(i+1, r_mod+1):
            mod = (i * j) % 2019
            if mod < mod_min:
                mod_min = mod
    
    print(mod_min)

Submission status: Accepted

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

Submission status: Accepted

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

if R - L + 1 > 2019:
    remainder_list = [N%2019 for N in range(L, L+2019)]
else:
    remainder_list = [N%2019 for N in range(L, R+1)]  
remainder_list = list(set(remainder_list))
all_list = [(i*j)%2019 for i, j in list(itertools.combinations(remainder_list, 2))]
print(min(all_list))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

R=min(R,L+2019)
#print(L,R)  
 
COUNT=2019
NUMBER=0
 
for i in range(L,R+1):
  for j in range(i+1,R+1):
    
    NUMBER=i*j%2019
    #print(i,j,NUMBER)
    if COUNT>NUMBER:
      COUNT=NUMBER
      #print(i,j,NUMBER)
 
    
print(COUNT)

Submission status: Accepted

Solution code:
def exam(L, R):
    min = 2019
    if L-R > 2019:
        return 0
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            modval = i*j % 2019
            if modval < min:
                min = modval
                if min == 0:
                    return 0
    return min


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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import numpy as np
L,R = map(int, input().split())
if (L//2019!=R//2019) or L%2019==0 or R%2019==0:
  print(0)
elif R-L==1:
  print((L*R)%2019)
else:
  l = L%2019
  r = R%2019
  ## l<r<2019
  a = []
  for i in range(r-l):
    for j in range(r-l-i):
      a.append(((l+i)*(l+i+j+1))%2019)
  print(min(a))

Submission status: Accepted

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

if r-l > 2019:
    print(0)
else:
    ret = 2020
    for i in itertools.combinations(range(l,r+1,1),2):
        ret = min(ret,(i[0]*i[1])%2019)
    print(ret)

Submission status: Accepted

Solution code:
import sys

def main():
    input = sys.stdin.readline
    L, R = map(int, input().split())
    R = min(R, L + 2019)

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

    return ans


if __name__ == '__main__':
    print(main())

Submission status: Accepted

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

# n mod 2019 の答えは 0 ~ 2018 のいずれか
# それぞれのmodを取った積のmodでも同じ答えになる


def get_ans():
    # 差が2018以上なら積が0の組み合わせが存在する
    if R - L >= 2018:
        return 0

    # 総当たり
    ans = 2019
    for X in range(L, R):
        for Y in range(X + 1, R + 1):
            ans = min((ans, (X * Y) % 2019))
            if ans == 0:
                return 0

    return ans


print(get_ans())

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

Submission status: Accepted

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

Submission status: Accepted

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

result = 2019

for i in range(2019):
    if L+i > R-1:
        break;
    for j in range(i+1, 2019):
        if(L+j > R):
            break
        else:
            result = min(result,((L+i)*(L+j))%2019)

print(result)

Submission status: Accepted

Solution code:
import math
L, R = map(int, input().split())
if (R - L + 1) > 673:
  print(0)
else:
  i = L
  min = 2020
  while(i < R):
    j = i + 1
    while(j <= R):
      tmp = i * j % 2019
      if(min > tmp):
        min = tmp
      j += 1
    i += 1
  print(min)

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
m = 2*(10**9)+1

R = int(min([R, L+2019*2]))

for i in range(L, R):
    for j in range(i+1, R+1):
        a = (i*j) % 2019
        if(m >= a):
            m = a
print(m)

Submission status: Accepted

Solution code:
def main():
    L, R = list(map(int, input().split()))
    minmod = 10000000
    for i in range(L, R):
        for j in range(i+1, R+1):
            prod = i * j
            mod = prod % 2019
            #mod = np.mod([prod], 2019)[0]
            if mod < minmod:
                minmod = mod
            if minmod < 1:
                break
        else: continue
        break
    print(minmod)

main()

Submission status: Accepted

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

if (L <= 673 <= R and R - L >= 3) or (R - L >= 673):
    print(0)
else:
    mods = []
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            m = (i * j) % NUM
            mods.append(m)
            if m == 1:
                print(1)
                exit()
    print(min(mods))

Submission status: Accepted

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

x = 2020

for i in range(R + 1)[L:]:
    if x == 0:
        break
    for j in range(R + 1)[i + 1:]:
        mod = i * j % 2019

        x = min(mod, x)
        if x == 0:
            break
print(x)

Submission status: Accepted

Solution code:
def c_remainder_minimization_2019(L, R, ITER=673):
    ans = float('inf')
    for i in range(L, min(R, L + ITER)):
        for j in range(i + 1, min(R + 1, L + ITER + 1)):
            ans = min(ans, (i * j) % 2019)
            if ans == 0:
                return 0
    return ans

L, R = [int(i) for i in input().split()]
print(c_remainder_minimization_2019(L, R))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

L, R = map(int, input().split(" "))
#L, R = 2020, 4000000000
if R - L > 2019:
    print(0)
else:
    arr = np.array(np.arange(L, R+1))
    mod_list = []
    min_mod_list = []
    
    if (0 in (arr % 2019)) or (0 in arr):
        print(0)
    else:
    
        for i in arr:
            mod_list = []
            index_ = np.where(arr==i)
            if i == arr[-1]:
                break
            
            for j in arr[int(index_[0])+1:]:
                mod_list.append((i * j) % 2019)
     
            min_mod_list.append(min(mod_list))
            if min(mod_list) == 0:
                break
    
    
        print(min(min_mod_list))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l, r = list(map(int,input().split()))
lmod = l % 2019
rmod = r % 2019
if(r-l) >= 2018:
	answer = 0
elif(lmod > rmod):
	answer = 0
else:
	answer = (rmod * lmod)% 2019
	for i in range(rmod - lmod + 1):
		for j in range(rmod - lmod + 1):
			if(i < j):
				if(answer > (lmod + i) * (lmod + j) % 2019):
					answer = (lmod + i) * (lmod + j) % 2019
print(answer)

Submission status: Accepted

Solution code:

S=input()

tmp=S.split()

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

R=min(L+2019,R)

flag=False
result=1000000000000
for i in range(L,R+1):
    for j in range(i+1,R+1):
        if i>=j:
            flag=True
            break
        n=(i*j)%2019
        if result>n:
            result=n
    if(flag):
        break



print(result)

Submission status: Accepted

Solution code:
L,R = map(int,input().split())
 
x = 2019**2
for i in range(L, R):
    for r in range(i+1, R+1):
        ans = (i*r) % 2019 
        if x > ans:
            x = ans
            if x == 0:
        	    break
    if x == 0:
      break
print(x)

Submission status: Accepted

Solution code:
mod=2019
l,r=map(int,input().split())
d={}
for i in range(l,min(r+1,l+2020)):
    w=i%2019
    if w in d:
        d[w]+=1
    else:
        d[w]=1
ans=2020
for i in d:
    for j in d:
        if i!=j:
            ans=min(ans,i*j%mod)
        elif i==j and d[i]>1:
            ans=min(ans,i*j%mod)
print(ans)

Submission status: Accepted

Solution code:
l, r = map(int, input().split())
if r - l >= 2019:
    print(0)
else:
    ans = 2019
    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())
step = r - l
mod = 2019
if step >= mod:
    print(0)
else:
    min_value = 2019
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            value = i * j % mod
            if value < min_value:
                min_value = value
    print(min_value)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

min_mod = 2019
for i in range(L, R+1):
    for j in range(i+1, R+1):
        mod = (i*j)%2019
        min_mod = mod if min_mod > mod else min_mod
print(min_mod)

Submission status: Accepted

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

MOD=[0] * (2019*2019)

def myidx(i,j):
    return i * 2019 + j

for i in range(2019):
    for j in range(i+1,2019):
        idx = myidx(i,j)
        MOD[idx] = (i*j) % 2019

#for i in range(2019):
#    idx = myidx(i,i)
#    MOD[idx] = 2019

MMM = []
MIN = 2019
Lmod = L % 2019
Rmod = R % 2019

if L+2019 <= R:
    for i in range(2019):
        for j in range(i+1,2019):
            idx = myidx(i,j)
            MIN = min(MIN, MOD[idx])
            #MMM.append(MOD[idx])
elif Lmod <= Rmod:
    for i in range(Lmod, Rmod+1):
        for j in range(i+1, Rmod+1):
            idx = myidx(i,j)
            MIN = min(MIN, MOD[idx])
            #MMM.append(MOD[idx])

elif Lmod > Rmod:
    for i in list(range(0,Rmod+1)) + list(range(Lmod, 2019)):
        for j in list(range(i+1,Rmod+1)) + list(range(max(Lmod,i+1), 2019)):
            idx = myidx(i,j)
            MIN = min(MIN, MOD[idx])
            #MMM.append(MOD[idx])

#MMM=list(set(MMM))
#MMM.sort()
#print(MMM.pop(0))
print(MIN)

Submission status: Accepted

Solution code:
L,R = list(map(int,input().split()))
def main(L,R):
    mod_min = 2019
    if L // mod_min == R // mod_min:
        L %= mod_min
        R %= mod_min
        for i in range(L,R):
            for j in range(i+1, R+1):
                Y = i*j % 2019
                if Y < mod_min:
                    mod_min = Y
    else:
        mod_min = 0
    return mod_min
print(main(L,R))

Submission status: Accepted

Solution code:
# [i, j] の中に2019の倍数があれば、その倍数を選択すれば最小値を0

import math

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

# (A * B) % mod = (A % mod) * (B % mod) % mod
l = L % 2019
r = R % 2019

ans = None
# mod以上差があれば2019の倍数を含んでいる (ex. 2 & 2025)
if R - L >= mod:
    ans = 0
else:
    # mod以上差がなくても、あまりが0をまたぐ (ex. 2018 & 2025 => 2018 & 6) 場合
    if l > r:
        ans = 0
    else:
        _min = 2019 * 2019
        for i in range(l, r):
            for j in range(i+1, r+1):
                _min = min(_min, i*j%mod)
        ans = _min

print(ans)

Submission status: Accepted

Solution code:
s = input().rstrip().split(' ')
L = int(s[0])
R = int(s[1])
cnt = 2020
 
for i in range(L, R):
    for r in range(i+1, R+1):
        ans = (i*r) % 2019 
        if ans < cnt:
            cnt = ans
            if cnt == 0:
        	    break
    if cnt == 0:
      break
 
print(cnt)

Submission status: Accepted

Solution code:
L,R= map(int,input().split())
#境界条件
bool = True
flag = False
for i in range(L,R):
    for j in range(i+1,R+1):
        temp = (i * j) % 2019
        if bool:
            min = temp
            ans = min
            bool = False
        elif min > temp:
            min = temp
            ans = min
        if min == 0:
            flag = True
            break
    if flag:
        break
print(ans)

Submission status: Accepted

Solution code:
import sys

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

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

print(ans)

Submission status: Accepted

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

if L // 2019 < R // 2019:
    print(ans)
    exit()

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

Submission status: Accepted

Solution code:
def c_remainder_minimization_2019(L, R):
    ans = float('inf')
    for i in range(L, min(R, L + 2019)):
        for j in range(i + 1, min(R + 1, L + 2020)):
            ans = min(ans, (i * j) % 2019)
            if ans == 0:
                return 0
    return ans

L, R = [int(i) for i in input().split()]
print(c_remainder_minimization_2019(L, R))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Jul  7 20:52:12 2019

@author: YudNK
"""

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

if R - L >= 2019:
    print(0)
else:
    a = L%2019
    mod = [a]
    for i in range(R - L):
        if a + i + 1 < 2019:
            mod.append(a + i + 1)
        else:
            mod.append(0)
    mini = 2018
    while len(mod) > 1:
        for i in range(len(mod) - 1):
            b = (mod[-1] * mod[i]) % 2019
            if b < mini:
                mini = b
        mod.pop(-1)
    print(mini)

Submission status: Accepted

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

MIN = 2020
flag = 0

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

if R == 0 or L == 0:
    print(0)
elif R - L == 1:
     print((R*L)%2019)
else:
    print(MIN)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(4100000)

l,r = [int(i) for i in input().split()]
if abs(l - r) >= 2019:
    temp = 0
else:
    temp = float('inf')
l = l%2019
r = r%2019
if l>r:
    r,l = l,r

for i in range(l,r+1):
    for k in range(i+1,r+1):
        if i*k%2019 < temp:
            temp = (i*k)%2019

print(temp) if l != r else print(temp)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
def main():
    L,R = map(int,input().split())
    LR = R-L
    M = []
    if L <= 2019 <= R:
        print(0)
        exit()
    for i in range(LR):
        for j in range(LR):
            M.append(((L+i)*(L+1+j))%2019)
            if ((L+i)*(L+1+j))%2019 == 0:
                print(0)
                exit()
    print(min(M))
if __name__ == '__main__':
    main()

Submission status: Accepted

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


for i in range(l,r):
    for j in range(i+1,r+1):
        m = (i * j) % mod
        if m < mod_min:
            mod_min = m
        if mod_min == 0:
            break
    if mod_min == 0:
        break

print(mod_min)

Submission status: Accepted

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

Submission status: Accepted

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

if ml >= mr:
  print(0)
elif R - L >= 2019:
  print(0)
else:
  temp = 2 * 10 ** 9 + 1
  for i in range(ml, mr + 1):
    for j in range(i + 1, mr + 1):
      temp = min(temp, (i * j) % mod)
  print(temp)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

st = l % 2019

if r - l >= 3500:
    print(0)

else:
    ans = float("inf")
    amari = []
    for i in range(l, r+1):
        for j in range(i+1, r+1):
            ans = min(ans, ((i%2019) * (j%2019)) % 2019)
    print(ans)

Submission status: Accepted

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

min=10**9
if((r-l)>=2019):
    min = 0
else:
    for i in range(l, r):
        for j in range(l+1, r+1):
            if(i<j and l<j):
                mod = (i*j)%2019
                if(mod<min):
                    min=mod

print(min)

Submission status: Accepted

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

ans = float('inf')
for i in range(L, L + 2020):
    for j in range(L + 1, L + 2020):
        if (i >= j) or (j > R):
            continue
        ans = min(ans, (i * j) % MOD)

print(ans)

Submission status: Accepted

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

minimum=2019
z=0
for i in range(L, R+1):
    for j in range(i+1, R+1):
        tmp = (i*j)%2019
        if minimum>tmp:
            minimum = tmp
        if minimum==0:
            z=1
            break
    if z==1:
        break
    
print(minimum)

Submission status: Accepted

Solution code:
l, r = map(int, input().split())
diff = r - l
l = l % 2019
r = l + diff
a = 2019
for x in range(l, r):
  for y in range(x + 1, r + 1):
    a = min(a, (x * y) % 2019)
    if a == 0:
      break
  else:
    continue
  break
print(a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
intnumber = []
for i in range(L, min(R+1, L+2019)):
    intnumber.append(i%2019)

intnumber.sort()
ans = 2019
for i in range(len(intnumber)):
    for j in range(i+1, len(intnumber)):
        ans = min(ans, (intnumber[i]*intnumber[j])%2019)

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
l, r = map(int, input().split())
if l <= 2019 <= r:
    print(0)
    exit()
elif r*(r-1) <= 2019:
    print(l*(l+1))
    exit()

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

print(a)

Submission status: Accepted

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