Problem: 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.

Submission attempts (in order):
import numpy as np

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

tmp = 0
ans = 100000

if L * R < 2019:
	i = L
	j = R
	tmp = i * j % 2019
	
	if tmp < ans:
		ans = tmp

elif (L + 2019 - L%2019) + 1 <= R:
	if L <= L + 2019 - L % 2019 and L + 2019 - L % 2019 + 1 <= R:
		i =  L + 2019 - L % 2019
		j = i+1
		tmp = (i * j) % 2019
		
		if tmp < ans:
			ans = tmp

elif (R + 2019 - R%2019) - 1 >= L:
	if L <= R + 2019 - R % 2019 - 1 and R + 2019 - R % 2019 <= R:
		i =  L + 2019 - L % 2019
		j = i+1
		tmp = (i * j) % 2019
		
		if tmp < ans:
			ans = tmp

elif L % 2019 < R % 2019:
	i = L
	j = i+1
	tmp = (i * j) % 2019
	
	if tmp < ans:
		ans = tmp

elif R % 2019 < L % 2019:
	j = R
	i = j-1
	tmp = (i * j) % 2019
	
	if tmp < ans:
		ans = tmp

i = L
j = R
tmp = (i * j) % 2019

if tmp < ans:
	ans = tmp

print(ans)

import numpy as np

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

tmp = 0
ans = 2019

i = L
j = R
tmp = (i * j) % 2019
if tmp < ans:
	ans = tmp

i =  L + 2019 - L % 2019
j = i+1
tmp = (i * j) % 2019
if tmp < ans:
	ans = tmp

i = L
j = i+1
tmp = (i * j) % 2019
if tmp < ans:
	ans = tmp

j = R
i = j-1
tmp = (i * j) % 2019
if tmp < ans:
	ans = tmp

i = L
j = R
tmp = (i * j) % 2019
if tmp < ans:
	ans = tmp

print(ans)


import numpy as np

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

tmp = 0
ans = 2019
if L * R < 2019:
	i = L
	j = R
	tmp = i * j % 2019
	print(1)
	if tmp < ans:
		ans = tmp

elif (L + 2019 - L%2019) + 1 <= R:
	if L <= L + 2019 - L % 2019 and L + 2019 - L % 2019 + 1 <= R:
		i =  L + 2019 - L % 2019
		j = i+1
		tmp = (i * j) % 2019
		print(2)
		if tmp < ans:
			ans = tmp

elif L % 2019 < R % 2019:
	i = L
	j = i+1
	tmp = (i * j) % 2019
	print(3)
	if tmp < ans:
		ans = tmp

elif R % 2019 < L % 2019:
	j = R
	i = j-1
	tmp = (i * j) % 2019
	print(4)
	if tmp < ans:
		ans = tmp
else:
	i = L
	j = R
	tmp = (i * j) % 2019
	print(5)
	if tmp < ans:
		ans = tmp

print(ans)

import numpy as np

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

tmp = 0
ans = 100000

if L * R < 2019:
	i = L
	j = R
	tmp = i * j % 2019
	
	if tmp < ans:
		ans = tmp

elif (L + 2019 - L%2019) + 1 <= R:
	if L <= L + 2019 - L % 2019 and L + 2019 - L % 2019 + 1 <= R:
		i =  L + 2019 - L % 2019
		j = i+1
		tmp = (i * j) % 2019
		
		if tmp < ans:
			ans = tmp

elif (R + 2019 - R%2019) - 1 >= L:
	if L <= R + 2019 - R % 2019 - 1 and R + 2019 - R % 2019 <= R:
		i =  L + 2019 - L % 2019
		j = i+1
		tmp = (i * j) % 2019
		
		if tmp < ans:
			ans = tmp

elif L % 2019 < R % 2019:
	i = L
	j = i+1
	tmp = (i * j) % 2019
	
	if tmp < ans:
		ans = tmp

elif R % 2019 < L % 2019:
	j = R
	i = j-1
	tmp = (i * j) % 2019
	
	if tmp < ans:
		ans = tmp
else:
	i = L
	j = R
	tmp = (i * j) % 2019

	if tmp < ans:
		ans = tmp

print(ans)

import numpy as np

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

tmp = 0
ans = 2019

i = L
j = R
tmp = (i * j) % 2019
if tmp < ans:
	ans = tmp
if (L + 2019 - L%2019) + 1 <= R:
	i =  L + 2019 - L % 2019
	j = i+1
	tmp = (i * j) % 2019
		if tmp < ans:
			ans = tmp

i = L
j = i+1
tmp = (i * j) % 2019
if tmp < ans:
	ans = tmp

j = R
i = j-1
tmp = (i * j) % 2019
if tmp < ans:
	ans = tmp

i = L
j = R
tmp = (i * j) % 2019
if tmp < ans:
	ans = tmp

print(ans)


import numpy as np

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

tmp = 0
ans = 2019

i = L
j = R
tmp = (i * j) % 2019
if tmp < ans:
	ans = tmp

i =  L + 2019 - L % 2019
j = i+1
tmp = (i * j) % 2019
	if tmp < ans:
		ans = tmp

i = L
j = i+1
tmp = (i * j) % 2019
if tmp < ans:
	ans = tmp

j = R
i = j-1
tmp = (i * j) % 2019
if tmp < ans:
	ans = tmp

i = L
j = R
tmp = (i * j) % 2019
if tmp < ans:
	ans = tmp

print(ans)


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)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Runtime Error

Accepted