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:
def main():
    L, R = map(int, input().split())
    if R // 2019 > L // 2019:
        print(0)
        return
    retval = 2019
    for i in range(L, R):
        for j in range(i+1, R+1):
            retval = min(retval, (i % 2019 * j % 2019) % 2019)
            if retval == 0:
                print(0)
                return
            
    print(retval)
    return
    
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
YEAR = 2019  # 3 * 673
l, r = map(int, input().split())

ans = 10e8

for sr in range(l + 1, r + 1):
    for sl in range(l, sr):
        ans = min(ans, sl * sr % YEAR)
        if ans == 0:
            break
    if ans == 0:
        break

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import combinations
L, R = map(int, input().split())
if (L % 2019 > R % 2019) or R - L >=2019:
    print(0)
else:
    ans = 2018
    for i, j in combinations(range(L, R + 1), 2):
        a = i % 2019
        b = j % 2019
        mod = (a * b) % 2019
        if ans > mod:
            ans = mod
    print(ans)

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
if L % 2019 == 0:
    low = L // 2019
else:
    low = L // 2019 + 1
high = R // 2019

if low <= high:
    # 2019の倍数が範囲内に存在する
    print(0)
else:
    minmod = 2018
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            temp = (i * j) % 2019
            if temp < minmod:
                minmod = temp
    print(minmod)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# 133C
"""
L<=i<=j<=R
(i×j)mod 2019
0≤L<R≤2×10^9
"""

def solve(L, R):
    if R - L > 2019:
        return 0
    
    tmp = 2019
    for i in range(L, R):
        for j in range(R, i, -1):
            if (i * j) % 2019 < tmp:
                tmp = (i * j) % 2019
    return tmp
 
L, R = map(int, input().split())
print(solve(L, R))

Submission status: Accepted

Solution code:
import sys

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

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

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)
        if ans == 0:
            break
    if ans == 0:
        break

print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
l, r = map(int, input().split())
tmp = 2019
if (l%2019 > r%2019) or r - l >= 2019:
    print(0)
else:
    for i in range(l%2019, r%2019):
        for j in range(i + 1, r%2019 + 1):
            if (i * j) % 2019 < tmp:
                tmp = (i * j) % 2019
    print(tmp)

Submission status: Accepted

Solution code:
import sys

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

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

ans = 2018
L = L % 2019
R = R % 2019

if L >= R:
    print(0)
    sys.exit()
for i in range(L, R):

    for j in range(i + 1, R + 1):
        tmp = int((i * j) % inf)
        ans = min(ans, tmp)
        if ans == 0:
            break
    if ans == 0:
        break

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Min = 2019
N = R - L

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

print(Min)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
a, b = map(int, input().split())
if b-a>=673:
    print(0)
else:
    x=[]
    for i in range(a, b):
        for j in range(i+1, b+1):
            x.append((i*j)%2019)
    print(min(x))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l, r = map(int, input().split())
if r - l >= 2019:
    print(0)
elif l % 2019 > 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 sys
L,R=map(int,input().split())
modifyed=[]
flag=0
for i in range(L,R+1):
    modifyed.append(i%2019)
    if i%2019==0:
        print(0)
        sys.exit()
ans=[]
for m in range(len(modifyed)):
    for j in range(m+1,len(modifyed)):
        ans.append(modifyed[m]*modifyed[j]%2019)
        if modifyed[m]*modifyed[j]%2019==0:
          print(0)
          sys.exit()
print(min(ans))

Submission status: Accepted

Solution code:
import sys
L,R=map(int,input().split())
modifyed=[]
flag=0
for i in range(L,R+1):
    modifyed.append(i%2019)
    if i%2019==0:
        print(0)
        sys.exit()
ans=[]
for m in range(len(modifyed)):
    for j in range(m+1,len(modifyed)):
        ans.append(modifyed[m]*modifyed[j]%2019)
print(min(ans))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L,R=map(int,input().split())
if R-L>=673:
    print(0)
else:
    x=[]

    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:
# -*- coding:utf-8 -*-

def solve():
    L, R = list(map(int, input().split()))
    MOD = 2019

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

    L %= MOD
    R %= MOD

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

if __name__ == "__main__":
    solve()

Submission status: Accepted

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

Submission status: Accepted

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

print(m)

Submission status: Accepted

Solution code:
from heapq import heappush, heappop
import re
from collections import deque
import sys
import math
input = sys.stdin.readline


def int_raw():
    return int(input())


def ss_raw():
    return input().split()


def ints_raw():
    return tuple(map(int, ss_raw()))


DIV = 10**9+7


def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def ncr(n, r, mod=DIV):
	r = min(r, n-r)
	ret = 1
	for i in range(1, r+1):
		ret = ret * (n-i+1) % mod
		ret = ret * mod_inv(i, mod) % mod
	return ret


def main():
    L,R = ints_raw()
    neoR = min(L+2019,R+1)
    ans = 2019
    for i in range(L,neoR):
        for j in range(i+1,neoR):
            ans = min((i*j)%2019,ans)
    return ans
print(main())

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools

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

if r-l >= 2019:
    print(0)
else:
    mods = []
    nums = list(range(l,r+1))
    for v in itertools.combinations(nums,2):
        mods.append(v[0]*v[1]%2019)
    print(min(mods))

Submission status: Accepted

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

#if R-L > 2019:
#  print (0)
#else:
#  mod1 = L%2019
#  mod2 = R%2019
#  if mod2 < mod1:
#    print (0)
#    sys.exit()
#  else:
modmin =2019 -1
for i in range(L,R):
  for j in range(i+1,R+1):
    mod3 = (i*j)%2019
    if mod3 == 0:
      print(0)
      sys.exit()
    elif modmin > mod3:
      modmin = mod3

print(modmin)

Submission status: Accepted

Solution code:
# -*- coding utf-8 -*-
L, R = map(int, input().split())

a = L // 2019
L -= a * 2019
R -= a * 2019
R = min(R, L + 2018)

ans = 10000


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())
ans=[]
for i in range(l,r+1):
    for j in range(i+1,r+1):
        ans.append((i*j)%2019)
        if (i*j)%2019==0:
            print('0')
            exit()
print(min(ans))

Submission status: Accepted

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


all_mod = []

cnt1 = 0
for i in range(l, r, 1):
    cnt = 0
    for j in range(l + 1, r + 1, 1):
        mod = (i * j) % 2019

        all_mod.append(mod)

        if mod == 0:
            break

        cnt += 1

        if cnt > 2019:
            break

    if mod == 0:
        break

    cnt1 += 1
    if cnt1 > 2019:
        break

print(min(all_mod))

Submission status: Accepted

Solution code:
import sys
l,r=map(int,sys.stdin.readline().split())
r=min(r,l+673)
ans=2019
for i in range(l,r+1):
    for j in range(i+1,r+1):
        ans=min(ans,(i*j)%2019)
print(ans)

Submission status: Accepted

Solution code:
import numpy as np

s = input().split()
L=int(s[0])
R=int(s[1])
m=2019
count=0
if R-L>2019:
    m=0
else:
    for j in range(L,R+1):
        for i in range(L,j):
            d=(i*j) % 2019
            m=min(d,m)
print(m)

Submission status: Accepted

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

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

Submission status: Accepted

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

ans = 2019

for left in range(L, min(L+2019, R)):
    for right in range(left+1, min(R+1, left+1+2019)):
        ans = min(ans, right * left % 2019)
print(ans)

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

Solution code:
mod = 2019
l, r = map(int, input().split())
e = []
for i in range(l, min(r, l + mod * 2) + 1):
    e.append(i % mod)
e.sort()

ans = mod
for i in range(len(e)):
    for j in range(i + 1, len(e)):
        ans = min(ans, e[i] * e[j] % mod)
        if ans == 0:
            break
    else:
        continue
    break
print(ans)

Submission status: Accepted

Solution code:
l,r=map(int,input().split())
mod=2019
if l%mod==0 or r%mod ==0 or l//mod != r//mod:
    print(0)
    exit()
l%=mod
r%=mod

ans = 123456789
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 = map(int, input().split())

# # 
# l = 2020
# r = 2040
r = min(r, l + 2019)

min = -1
for tl in range(l, r + 1):
  for tr in range(tl + 1, r + 1):
    tmp = (tl * tr) % 2019
    if min == -1 or min > tmp:
      min = tmp

print(min)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

d=2018
for i in range(min(R-L,2019)):
  a=L+i
  for j in range(min(R-a,2019)):
    b=a+j+1
    c=(a*b)%2019
    if c<d:
      d=c
print(d)

Submission status: Accepted

Solution code:
l,r=[int(i) for i in input().split()]
mod = 2019
ans=10**9

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

Submission status: Accepted

Solution code:
L,R=map(int,input().split())
min=2019
for i in range(L,R+1):
    for k in range(i+1,R+1):
        mod=(i*k)%2019
        if mod<min:
            min=mod
        if mod==0:
            min=0
            break
    else:
        continue
    break
print(min)

Submission status: Accepted

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

aaa = []

if r - l >= 2019:
    ans = 0
else:
    r_mod = r % 2019
    l_mod = l % 2019
    if l_mod > r_mod:
        ans = 0
    else:
        for i in range(l_mod, r_mod+1):
            for j in range(i+1, r_mod+1):
                rl_mod = i * j % 2019 
                aaa.append(rl_mod)
        ans = min(aaa)

print(ans)

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
c = 10 ** 9
for i in range(a, b+1):
    for j in range(i+1, b+1):

        c = min(c, i * j % 2019)
        if c == 0:
            print(c)
            exit()
print(c)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
L,R = map(int,input().split())
ans = float("inf")
for i in range(L,min(L+2019,R+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:
l, r = list(map(int, input().split()))
if r-l >=2019:
	print(0)
else:
	x= [i*j%2019 for i in range(l,r) for j in range (i+1,r+1)]
	x.sort()
	print(x[0])

Submission status: Accepted

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

ans = 10 ** 8

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
# min = float("inf")
# for i in range(L, R + 1):
# 	for j in range(i + 1, R + 1):
# 		mod = ((i % 2019) * (j % 2019)) % 2019
# 		if min > mod:
# 			min = mod

# 2019 = 3 * 673

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

# 2020 2040 -> 1 21
# 2010 2030 -> 2010 11

Submission status: Accepted

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

ans = 2019

R = min(R, L + 2019)
for l in range(L, R):
    for r in range(l + 1, R + 1):
        ans = min(ans, l * r % 2019)
print(ans)

Submission status: Accepted

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

ans = 2019

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

Submission status: Accepted

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

ans = 0
min_mod = 2019

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

          if min_mod > (i*j) % 2019:
            min_mod = (i*j) % 2019
      
    
    ans = min_mod
    
print(ans)

Submission status: Accepted

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

tmp = float("inf")
count_i = 0
count_j = 0

for i in range(L,R+1):
    if count_i > 2019:break
    
    count_j = 0
    for j in range(i+1,R+1):
        if count_j >2019:break
        mod = i*j%2019
        if mod<tmp:
            tmp = mod
            
        count_j += 1
    count_i += 1
print(tmp)

Submission status: Accepted

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

def solve():
    L, R = list(map(int, input().split()))
    MOD = 2019

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

    L %= MOD
    R %= MOD

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

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
import itertools

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

if (R - L) >= 2019:
    ans = 0
else:
    l_mod = L % 2019
    r_mod = R % 2019
    if l_mod > r_mod:
        ans = 0
    else:
        ans = 2018
        for i, j in itertools.combinations(list(range(L, R+1)), 2):
            ans = min(ans, (i * j) % 2019)
print(ans)

Submission status: Accepted

Solution code:
a,b = input().split(' ')
a = int(a)
b = int(b)
 
ans = 100000000000
 
for i in range(a, min(b, a + 2019)):
    for j in range(i + 1, min(b + 1, a + 2019)):
        if (i * j) % 2019 < ans:
            ans = (i * j) % 2019
 
print(ans)

Submission status: Accepted

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

if R - L >= 2018:
      ans = 0
else:
    tempL = L%2019
    tempR = R%2019
    if tempR - tempL < R-L-1:
        temp = tempL
        tempL = 0
        X = list(range(tempL,temp))
        Y = list(range(tempR,2018+1))
        Z = X + Y
    else:
        Z = list(range(tempL,tempR+1))

    ans = 2019
    for i in range(len(Z)):
        for j in range(i+1, len(Z)):
            if (Z[i]*Z[j])%2019 < ans:
                ans = (Z[i]*Z[j])%2019
print(ans)

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
mod = 2019
modlist = [(L + i)%mod for i in range(min(2019,R-L+1))]
length = len(modlist)
ans = 2019
for i in range(length):
    for j in range(i+1,length):
        ans = min(ans, modlist[i]*modlist[j]%mod)

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
a = [ int(i) for i in input().split()]

b = (a[0]*a[1]) % 2019

for i in range (a[0], a[1]):
  for j in range (i+1, a[1]+1):
    b = min (b, (i*j)%2019)
    
    if b == 0:
      break
      
  if b == 0:
    break
    
print(b)

Submission status: Accepted

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

Submission status: Accepted

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

lq = l // 2019
lr = l % 2019
rq = r // 2019
rr = r % 2019

if lq < rq:
    print(0)
else:
    m = 2018 * 2018
    for i in range(lr,rr+1):
        for j in range(i+1,rr+1):
            if m > (i*j)%2019:
                m = (i*j)%2019
    print(m)

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):
        for j in range(i+1, R+1):
            ans = min([ans, (i*j)%2019])
    print(ans)

Submission status: Accepted

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

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

mod = 2019
ans = 2019
for l in range(L, R):
    for r in range(l+1, R+1):
        tmp = l * r % mod
        ans = min(ans, tmp)

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

ans = 2019
#差が2018より大きいものは商が必ず1以上になるので、計算の量を減らす
if r - l >= 2018:
  print(0)
else:
  #for文でその他全て計算する
  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:
L2, R2= map(int, input().split())

L=L2%2019
R=R2%2019

hasamu=R2-L2
kotae=10000
if hasamu>2017:
  kotae=0
if L>R:
  kotae=0
else:
  for i in range(L,R):
    for j in range(i+1,R+1):
      seki=i*j
      amari=seki%2019
      if amari<kotae:
        kotae=amari
print(kotae)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

L, R = [int(i) for i in input().split(" ")]
min_rem = 2018

for i in range(L, R + 1):
    if i % 2019 == 0:
        print(0)
        sys.exit()
    else:
        pass

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

print(min_rem)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L2, R2= map(int, input().split())

L=L2%2019
R=R2%2019

hasamu=R2-L2
kotae=10000
if hasamu>2017:
  kotae=0
if L>R:
  kotae=0
else:
  for i in range(L,R):
    for j in range(i+1,R+1):
      seki=i*j
      amari=seki%2019
      if amari<kotae:
        kotae=amari
print(kotae)

Submission status: Accepted

Solution code:
L,R = map(int,input().split())
if R - L > 2020:
    print(0)
    quit()
table = [i for i in range(L,R+1)]
from itertools import combinations
# combinations('ABCD', 2) --> AB AC AD BC BD CD
# combinations(range(4), 3) --> 012 013 023 123
combi_list = list(combinations(table,2))

cand = []

for x in combi_list:
    cand.append((x[0] * x[1]) % 2019)

print(min(cand))

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-
"""解説
2019で割った余りが同じであるような2数a, bにおいて、

a * c mod 2019
b * c mod 2019

は同じ値になる。

今求めたいのは、

(i*j) ≡ x (mod 2019)

のxの最小値である。

(例)
L=2020のとき、
mod 2019の世界では、2020は1と等価

よって、
2020 * 2021 は、
1 * 2 と等価

つまり、

(i*j) ≡ x (mod 2019) は、

(i%2019) * (j%2019) ≡ x (mod 2019) と同じ

そう考えると、i, jの調べる範囲は、

・R-L < 2019のとき、

L%2019 ≦ i < j ≦ R%2019

でよい。

・R-L >= 2019のとき、

 mod2019の1周分の範囲を取れるので、必ずiかjが0になり、そのとき最小値0になるから。


よって、(i, j)として調べる候補はたかだか2019**2 であり、全探索で間に合う。
"""

def solve():
    L, R = list(map(int, input().split()))
    MOD = 2019

    if R-L >= MOD:
        print(0)
        return

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


if __name__ == "__main__":
    solve()