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: Wrong Answer

Solution code:
l, r = map(int, input().split())
k1 = 2019
a = l %2019
b = r % 2019
if r - l > 2018:
    k1 = 0

elif b < a:
    k1 = 0

else:
    k = a * b
    k1 = k % 2019

print(k1)

Submission status: Wrong Answer

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

if L-R+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: Wrong Answer

Solution code:
l, r = map(int, input().split())
k1 = 2019
if r - l > 2018:
    k1 = 0

else:
    for i in range(l,r-1):
        for j in range(i+1,r):
            a = i % 2019
            b = j % 2019
            k = (a * b) % 2019
            if k < k1: k1 = k
print(k1)

Submission status: Wrong Answer

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

if L-R+1>=2019:
  print(0)
else:
  L %= 2019
  R %= 2019
  if L<R: 
    print((L*(L+1)%2019))
  else:
    print(0)

Submission status: Wrong Answer

Solution code:

l, r = map(int, input().split())
k1 = 2019
if r - l > 3019:
    k1 = 0

else:
    for i in range(l,r-1):
        for j in range(i+1,r):
            a = i % 2019
            b = j % 2019
            k = (a * b) % 2019
            if k < k1: k1 = k
print(k1)

Submission status: Wrong Answer

Solution code:

l, r = map(int, input().split())
k1 = 2019
if r - l > 2019:
    k1 = 0

else:
    for i in range(l,r-1):
        for j in range(i+1,r):
            a = i % 2019
            b = j % 2019
            k = (a * b) % 2019
            if k < k1: k1 = k
print(k1)

Submission status: Wrong Answer

Solution code:

l, r = map(int, input().split())
k1 = 2019
if r - l > 2019:
    print(0)

else:
    for i in range(l,r-1):
        for j in range(i+1,r):
            a = i % 2019
            b = j % 2019
            k = (a * b) % 2019
            if k < k1: k1 = k
    print(k1)

Submission status: Wrong Answer

Solution code:

l, r = map(int, input().split())
k1 = 2019
if r - l > 2018:
    print(0)

else:
    for i in range(l,r-1):
        for j in range(i+1,r):
            a = i % 2019
            b = j % 2019
            k = (a * b) % 2019
            if k < k1: k1 = k
    print(k1)

Submission status: Wrong Answer

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: Wrong Answer

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==0:
            min=0
            break
        if mod<min:
            min=mod
        else:
            continue
        break
print(min)

Submission status: Wrong Answer

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==0:
            min=0
            break
        if mod<min:
            min=mod
        else:
            continue
    break
print(min)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
print(0)

Submission status: Wrong Answer

Solution code:
l,r = map(int,input().split())
ans = float('inf')
if r - l > 2019:
    print(0)
    exit()
num = list(set([i%2019 for i in range(l,r+1)]))
num.sort()
try:
    ans = num[0]*num[1]
except:
    ans = num[0]*num[0]
print(ans)

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split())
q, mod = divmod(a*b, 2019)
print(mod)

Submission status: Wrong Answer

Solution code:
left, right = map(int, input().split())
mod = 2019

left %= mod

if right >= mod:
    right = (right % mod) + mod
else:
    right %= mod

min_mod = float("inf")
for i in range(left, right):
    for j in range(i + 1, right + 1):
        curr_mod = i * j % mod
        min_mod = min(min_mod, curr_mod)
        if min_mod == 0:
            break

print(min_mod)

Submission status: Wrong Answer

Solution code:
left, right = map(int, input().split())
mod = 2019

left %= mod
right %= mod

if right <= left:
    right += mod

min_mod = float("inf")
for i in range(left, right):
    for j in range(i + 1, right + 1):
        curr_mod = i * j % mod
        min_mod = min(min_mod, curr_mod)
        if min_mod == 0:
            break

print(min_mod)

Submission status: Wrong Answer

Solution code:
left, right = map(int, input().split())
mod = 2019

left %= mod
right %= mod

if right < left:
    right += mod

min_mod = float("inf")
for i in range(left, right):
    for j in range(i + 1, right + 1):
        curr_mod = i * j % mod
        min_mod = min(min_mod, curr_mod)
        if min_mod == 0:
            break

print(min_mod)

Submission status: Wrong Answer

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

ans=2019

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

Submission status: Wrong Answer

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

R = min(R, L + 4038)

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

print(ans)

Submission status: Wrong Answer

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

L = L % 2019
R = R % 2019
if L > R:
    R += 2019

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

print(res)

Submission status: Wrong Answer

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

L = L % 2019
R = R % 2019
if R < L:
    R += 2019

i = L
res = 2020
while i < R:
    j = i + 1
    while j <= R:
        res = min(res, i * j % 2019)
        j += 1
    i += 1

if res >= 2019:
    res = 0

print(res)

Submission status: Wrong Answer

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

L = L % 2019
R = R % 2019
if R < L:
    R += 2019

i = L
res = 2020
while i < R:
    j = i + 1
    while j <= R:
        res = min(res, i * j % 2019)
        j += 1
    i += 1

if res == 2020:
    res = 0

print(res)

Submission status: Wrong Answer

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

L = L % 2019
R = R % 2019
if R < L:
    R += 2019

i = L
res = 2020
while i < R:
    j = i + 1
    while j <= R:
        res = min(res, i * j % 2019)
        j += 1
    i += 1

print(res)

Submission status: Wrong Answer

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

L = L % 2019
R = R % 2019

i = L
res = 2020
while i < R:
    j = i + 1
    while j <= R:
        res = min(res, i * j % 2019)
        j += 1
    i += 1

print(res)

Submission status: Wrong Answer

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

left = L % 2019
right = (L + 1) % 2019

print((left * right) % 2019)

Submission status: Wrong Answer

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


print((L % 2019 * (L + 1) % 2019) % 2019)

Submission status: Wrong Answer

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)):
        print(l, r)
        if l < r:
            ans = min([ans, (l*r)%2019])
print(ans)

Submission status: Wrong Answer

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):

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

    ans = min_mod
    
print(ans)

Submission status: Wrong Answer

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 == 0:
      min_mod = (L*R) % 2019
    else :
      for i in range(L,R) :

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

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

    ans = min_mod
    
print(ans)

Submission status: Wrong Answer

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

ans = 0
min_mod = 2019

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

    print("min_mod:",min_mod)
    ans = min_mod
    
print(ans)

Submission status: Wrong Answer

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

ans = 0
min_mod = 2019

if R-L<2019-1 :
  if R % 2019 > 0:
    for i in range(R-L) :

      if min_mod > ((L + i) * (L + i +1)) % 2019 :
        min_mod = ((L + i) * (L + i +1)) % 2019

    ans = min_mod
    
print(ans)

Submission status: Wrong Answer

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

ans = 0
min_mod = 2019

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

Submission status: Wrong Answer

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

ans = 0
min_mod = 2019

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
L,R = map(int,input().split())
while R > L:
    R -= 2019

R += 2019

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

print(min(o))

Submission status: Wrong Answer

Solution code:
L,R = map(int,input().split())
L,R = L % 2019 , (L % 2019)+ ((R - L) % 2019)
o = []
for i in range(L,R+1):
    for j in range(L,R+1):
        if i >= j:
            continue
        o.append((i*j)%2019)

print(min(o))

Submission status: Wrong Answer

Solution code:
L,R = map(int,input().split())
L,R = L % 2019 , L % 2019 + (R - L) % 2019
o = []
for i in range(L,R+1):
    for j in range(L,R+1):
        if i >= j:
            continue
        o.append(i*j%2019)

print(min(o))

Submission status: Wrong Answer

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

if (R - L) >= 2019:
    ans = 0
else:
    l_mod = L % 2019
    r_mod = R % 2019
    if (r_mod - l_mod) > 0:
        ans = (l_mod * (l_mod + 1)) % 2019
    else:
        ans = 0
print(ans)

Submission status: Wrong Answer

Solution code:
a,b = input().split(' ')
a = int(a)
b = int(b)

ans = 100000000000
check = False

for i in range(a, b):
    if check:
        break
    for j in range(i + 1, b + 1):
        if (i * j) % 2019 < ans:
            ans = (i * j) % 2019
            check = True
            break

print(ans)

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
mod = 2019
modlist = [(L + i)%mod for i in range(min(2019,R-L+1))]
print(modlist)
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: Wrong Answer

Solution code:
a,b = input().split(' ')
a = int(a)
b = int(b)

ans = 5000
check = False

for i in range(a, b):
    if check:
        break
    for j in range(i + 1, b + 1):
        if (i * j) % 2019 < ans:
            ans = (i * j) % 2019
            check = True
            break

print(ans)

Submission status: Wrong Answer

Solution code:
a,b = input().split(' ')
a = int(a)
b = int(b)

ans = 5000
check = False

for i in range(a, b):
    if check:
        break
    for j in range(i + 1, b + 1):
        print(i, j)
        if (i * j) % 2019 < ans:
            ans = (i * j) % 2019
            check = True
            break

print(ans)

Submission status: Wrong Answer

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

if (R - L) >= 2019:
    ans = 0
else:
    r_mod = R % 2019
    l_mod = L % 2019
    if (r_mod - l_mod) > 0:
        ans = l_mod * (l_mod + 1)
    else:
        ans = 0
print(ans)

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
mod = 2019
modlist = [(L + i)%mod for i in range((R-L)%mod+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: Wrong Answer

Solution code:
a,b = input().split(' ')
a = int(a)
b = int(b)

ans = 5000

for i in range(a, b - 1):
    for j in range(i + 1, b):
        for k in range(2, ans):
            if (i * j) % k == 2019 % k:
                #print((i * j) % k, 2019 % k)
                ans = k
                break

print(ans)

Submission status: Wrong Answer

Solution code:
a,b = input().split(' ')
a = int(a)
b = int(b)

ans = 5000

for i in range(a, b - 1):
    for j in range(i + 1, b):
        for k in range(2, ans):
            if (i * j) % k == 2019 % k:
                print((i * j) % k, 2019 % k)
                ans = k
                break

print(ans)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
if R - L >= 2019:
    print(0)
else:
    minmod = L % 2019
    maxmod = R % 2019
    if minmod > maxmod:
        print(0)
    else:
        print((minmod * (minmod + 1)) % 2019)

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
if R - L >= 2019:
    print(0)
else:
    minmod = L % 2019
    maxmod = R % 2019
    if minmod > maxmod:
        print(0)
    else:
        print(minmod * (minmod + 1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

ans = 2019
for i in range(l, r):
    if i % 2019 > ans:
        continue
    for j in range(r, l-1, -1):
        if i == j:
            break
        mod = (i * j) % 2019
        if mod < ans:
            ans = mod
    
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
min = 2019
if (R - L >= 2018):
  min = 0
else:
  L = L % 2019
  R = R % 2019
modulo = 2019

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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)
        if min_rem == 1:
            print(1)
            sys.exit()

print(min_rem)

Submission status: Wrong Answer

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, R + 1):
        rem_i = i % 2019
        rem_j = j % 2019
        min_rem = min((rem_i * rem_j) % 2019, 2018)

print(min_rem)

Submission status: Wrong Answer

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

if L // 2019 == R // 2019 \
  and L % 2019 != 0 and R % 2019 != 0:
    print(L % 2019 * (L % 2019 + 1))
else:
  print(0)

Submission status: Wrong Answer

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

#2019……3*673
#素因数分解して3,673が含有してればフラグたてる
flag_3   = False
flag_673 = False

i = 2017
j = 2018

for k in range(R,L-1,-1):
    if flag_3== False and k%3 ==0:
        flag_3 = True
    if flag_673== False and k%673 ==0:
        flag_673 = True
        
    if k%2019 < i:
        j = i
        i = k%2019
    elif k%2019 < j:
        j = k%2019
    
    if flag_3 == True and flag_673 == True:
        break
    
if flag_3 == True and flag_673 == True:
    print("0")  
else:
    print(i*j%2019)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Solution code:
L,R = map(int,input().split())
if R - L > 4100:
    print(0)
    quit()
table = [(i % 2019) for i in range(L,R+1)]
table= sorted(table)
print((table[0]*table[1])%2019)

Submission status: Wrong Answer

Solution code:
L,R = map(int,input().split())
if R - L > 4100:
    print(0)
    quit()
table = [(i % 2019) for i in range(L,R+1)]
table= sorted(table)
print(table[0]*table[1])

Submission status: Wrong Answer

Solution code:
L,R = map(int,input().split())
if R - L > 4100:
    print(1)
    quit()
table = [(i % 2019) for i in range(L,R+1)]
table= sorted(table)
print(table[0]*table[1])

Submission status: Wrong Answer

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の調べる範囲は、

L%2019 ≦ i < j ≦ min(R, (L+2019)%2019)

なぜL+2019かというと、 mod2019の1周分の範囲を取れば、必ず0をかけることができ、そのとき最小値0になるから。

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

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

    L %= MOD
    R = L+2019

    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()

Submission status: Wrong Answer

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の調べる範囲は、

L%2019 ≦ i < j ≦ min(R, (L+2019)%2019)

なぜL+2019かというと、 mod2019の1周分の範囲を取れば、必ず0をかけることができ、そのとき最小値0になるから。

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

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

    R = min(R, L+2019)
    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()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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の調べる範囲は、

L%2019 ≦ i < j ≦ min(R, (L+2019)%2019)

なぜL+2019かというと、 mod2019の1周分の範囲を取れば、必ず0をかけることができ、そのとき最小値0になるから。

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

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

    L %= MOD
    R %= MOD
    R = min(R, L+2019)

    # ans = MOD
    ans = (L * (L + 1)) % 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()

Submission status: Wrong Answer

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の調べる範囲は、

L%2019 ≦ i < j ≦ min(R, (L+2019)%2019)

なぜL+2019かというと、 mod2019の1周分の範囲を取れば、必ず0をかけることができ、そのとき最小値0になるから。

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

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

    L %= MOD
    R %= MOD
    R = min(R, L+2020)

    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()

Submission status: Wrong Answer

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の調べる範囲は、

L%2019 ≦ i < j ≦ min(R, (L+2019)%2019)

なぜL+2019かというと、 mod2019の1周分の範囲を取れば、必ず0をかけることができ、そのとき最小値0になるから。

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

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

    L %= MOD
    R %= MOD
    R = min(R, L+2019)

    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()

Submission status: Wrong Answer

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(l, r+1):
    mini = min(mini, (i*j)%2019)

    if mini==0:
      break
  if mini==0:
    break
print(mini)

Submission status: Wrong Answer

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の調べる範囲は、

L%2019 ≦ i < j ≦ min(R, (L+4038)%2019)

なぜ4038かというと、 i < j より、 1*1を作りたいときは、1 * 2020を作る必要があり、
mod2019の2周分の範囲を取る必要があるから。

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

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

    L %= MOD
    R %= MOD
    R = min(R, L+2020)

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


if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
L,R = map(int,input().split())
 
# Rが2019未満のとき
if R < 2019 :
    print((L * (L + 1)) % 2019)
# 範囲内に2019を含む時
elif L <= 2019 and R >= 2019 :
    print(0)
# LもRも2019より高い場合
else :
    R = min(R, L + 4038)
    ans = 2018
    for i in range(L,R + 1):
        for j in range(i + 1,R):
            x = (i * j) % 2019
            ans = min(ans, x)
    print(ans)

Submission status: Wrong Answer

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

mod_min = l * r
for i in range(l, l + int(math.sqrt(r)) + 1):
    for j in range(i + 1, l + int(math.sqrt(r)) + 2):
        mod_tmp = (i * j) % 2019
        if mod_tmp < mod_min:
            mod_min = mod_tmp

print(mod_min)

Submission status: Wrong Answer

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の調べる範囲は、

L%2019 ≦ i < j ≦ min(R, (L+4038)%2019)

なぜ4038かというと、 i < j より、 1*1を作りたいときは、1 * 2020を作る必要があり、
mod2019の2周分の範囲を取る必要があるから。

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

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

    L %= MOD
    R %= MOD
    R = min(R, L+4038)

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


if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
L,R = list(map(int,input().split()))
a = 2018
b = L
c = L+1
for i in range(R-L):
    b = b + i
    for j in range(R-L):
        c = b+1+j
        if a > b*c%2019:
            a = b*c%2019

print(a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
L,R = map(int,input().split())
ans = 9999
for i in range(L,R):
	for i in range(i,R + 1):
		tot = (i * (i+1)) % 2019
		if ans >= tot:
			ans = tot
print(ans)

Submission status: Wrong Answer

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

div_l = L//2019
div_r = R//2019
div_ll = L//673
div_rr = R//673

ans = 0
if div_l == div_r and div_ll == div_rr:
  mod_l = L%2019
  mod_r = R%2019
  ans = mod_l * (mod_l+1)
print(ans)

Submission status: Wrong Answer

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

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

else:
    result = 2019
    for i in range(num, r-l+num):
        for j in range(i, r-l+num+1):
            result = min(result, i*j%2019)
            if result == 0:
                break

        if result == 0:
            break

    print(result)

Submission status: Wrong Answer

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

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

else:
    print(num * (num+1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
l,r = input().split()
l = int(l)
r = int(r)
N = int(2019)
flag = False
  
ans = N - 1
count = 0
for i in range(l,r):
  for j in range(i+1,r+1):
    if(count >= (N - 1)):
      flag = True
      break
    if(ans > (i * j) % N):
      ans = (i * j) % N
    count += 1
  if flag:
    break
    
print(ans)

Submission status: Wrong Answer

Solution code:
l,r = input().split()
l = int(l)
r = int(r)
N = int(2019)
flag = False
  
ans = N - 1
count = 0
for i in range(l,r):
  for j in range(i+1,r+1):
    if(count >= (N - 1)):
      flag = True
      break
    if(ans > (i * j) % N):
      ans = (i * j) % N
    count += 1
  if flag:
    break
    
print(ans)