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:
import sys
import numpy as np

str = [int(i) for i in input().split()]
l, r = str

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

Submission status: Wrong Answer

Solution code:
def main():
    l, r = map(int,input().split())
    #if r<2019:
    print(l * (l+1) % 2019)
    #elif l<=2019<=r:
        #print(l * (l+1) % 2019)

main()

Submission status: Wrong Answer

Solution code:
l,r=map(int,input().split())
if r-l+1>2020:
  x=list(range(l,l+2020))
else:
  x=list(range(l,r+1))
y=list()
for n in x:
  y=y+[n%2019]
y.sort()
k=len(y)
print(min((y[0]*y[1])%2019,y[0]*y[k-1]%2019,y[k-1]*y[k-2]%2019))

Submission status: Wrong Answer

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

min = 2020

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A = [int(x)  for x in input().split()]
if A[1] - A[0] < (2019 - A[1]%2019):
  print((A[0]*(A[0] +1)) %2019)
else:
  print(0)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 2018

l %= 2019
r %= 2019

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

print(ans)

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
min_num = 2*(10**9)
max_num = 0
for k in range(L, R+1):
    min_num = min(min_num, k%2019)
    max_num = max(max_num, k%2019)
if min_num == 0:
    print(0)
else:
    ans = 2020
    for h in range(min_num+1, max_num+1):
        ans = min(ans, (min_num*h)%2019)
        
    print(ans)

Submission status: Wrong Answer

Solution code:
L, R = [int(x) for x in input().split()]
MOD = 2019
if (R - L > 2017):
    print(0)
    exit()
L %= MOD
R %= MOD
if (L * R == 0 or R < L):
    print(0)
    exit()
elif (R-L == 1):
    print(L*R % MOD)
    exit()
i = L
ans = L*R % MOD
while(i != R-1):
    j = i+1
    while (j != R):
        if (ans > (i*j % MOD)):
            ans = i*j % MOD
        j += 1
    i += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import itertools
L, R = map(int, input().split())
arr = [i for i in range(L,R)]

minm = 100000000


for i in itertools.permutations(arr, 2):
    tmp = (i[0]*i[1]) % 2019
    if tmp < minm and tmp != 0:
        minm = tmp
    elif tmp == 0:
        break

if minm == 100000000:
    print((L*R)%2019)
    sys.exit()
print(minm)

Submission status: Wrong Answer

Solution code:
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
	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 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

ans = i * j % 2019

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np 

L, R = list(map(int, input().split()))
data = np.array([x for x in range(L, R+1)]) % 2019
len_data = R - L
mod_min = np.inf

for i in range(len_data + 1):
    t = len_data - i
    
    for j in range(t):
        mod = data[t] * data[j]
        mod_min = mod if mod_min > mod else mod_min

print(mod_min)

Submission status: Wrong Answer

Solution code:
def main():
    L,R=map(int,input().split())
    
    min_n=L*(L+1)%2019
    max_n=R*(R+1)%2019
    
    if min_n>max_n:
        print(1)
    
    else:
        flag=True
        if flag:
            for i in range(L,R+1):
                if i%2019 ==0:
                    flag=False
                    print(0)
                    
        if flag:
            print(min_n%2019)    

if __name__=="__main__":
    main()

Submission status: Wrong Answer

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


if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

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

temp = []

for i in range(L, R+1):
    if not ((i%2019) in temp):
        temp.append(i%2019)
    else:
        continue

temp.sort()

print(temp[0]*temp[1])

Submission status: Wrong Answer

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

min_ans = 10**9

start_mod = L % mod
current_mod = start_mod
for _ in range(R - L):
    current_mod += 1
    if current_mod == mod:
        min_ans = 0
        break
if min_ans != 0:
    min_ans = start_mod * (start_mod + 1) % mod
print(min_ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
l, r = map(int, input().split())
mod = 2019
modl = l // mod
modr = r // mod
l_mod = l % mod
r_mod = r % mod
# print(modl, modr)
# if l <= mod*modl <= r or l <= mod * modr <= r:
if modl != modr or l_mod == 0 or r_mod == 0:
# if modl != modr:
    print(0)
else:
    print((l*(l+1))%mod)

Submission status: Wrong Answer

Solution code:
L,R = map(int, input().split())
MOD = 2019
#mL = L%MOD
mL = L
divL = L//MOD
mR = R%MOD
#if mL>=mR:
#    mR +=MOD
mR +=divL*MOD

min_mod = MOD+1
#print(mL, mR)
for i in range(mL, mR):
    for j in range(i+1, mR+1):
        min_mod=min((i*j)%MOD, min_mod)
        #print(i, j, (i*j)%MOD)
print(min_mod)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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


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

else:
        print(0)
        exit()

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
ans = 0
if R <= 2019:
    ans = ((L)*(L+1)) % 2019
elif L <= 2019 and 2019 <= R:
    ans = 0
elif 2019 <= L:
    ans = (L*(L+1)) % 2019
print(ans)

Submission status: Wrong Answer

Solution code:
l, r = map(int, input().split())
x = []
y = []

for i in range(l, r+1):
  for j in range(i+1, r+1):
    m = i * j % 2019
    x.append(m)
    y.append(i*j)
print(y[x.index(min(x))])

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
l, r = map(int, input().split())
if r < 2019:
    print(l*r)
elif l <= 2019 and 2019 <= r:
    print(0)
elif l > 2019:
    if (r-l) >= 2018:
        print(0)
    else:
        new_l = l % 2019
        new_r = r % 2019
        count_l = l // 2019
        count_r = r // 2019
        if new_r >= 2 and count_l != count_r:
            print(2)
        else:
            print(new_l*(new_l+1))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

#LかRが2019以上だったら割り切れる
if L <= 2019 and R >= 2019:
  print(0)

elif L <= 673 and R >= 673:
  print(0)


#Rが2019未満だったらできるだけ小さいやつ
elif R < 2019:
  print((R*(R-1))%2019)
#Lが2019以上だったらできるだけ小さいやつ
elif L > 2019:
  print((L*(L+1))%2019)

Submission status: Wrong Answer

Solution code:
L,R=map(int,input().split())
length=R-L
start=L%2019
if start+length<3:
    print((start*(start+1))%2019)
else:
    print(0)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if R-L>673:
    print(0)
else:
    A =[]
    for i in range(R-L+1):
        A.append((L+i)%2019)
    A.sort()
    print((A[0]*A[1])%2019)

Submission status: Wrong Answer

Solution code:
import sys


def input():
    return sys.stdin.readline()[:-1]


def main():
    l, r = map(int, input().split())
    n = [[i % 2019, i] for i in range(l, r+1)]
    n.sort(key=lambda x: x[0])
    print((n[0][1]*n[1][1]) % 2019)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
a,b=input().split()
a=int(a)
b=int(b)
c=0
for i in range(a,b+1):
  if b-a>=674:
    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>=102:
  print(1)
elif b-a>=48:
  print(2)
else:
  for i in range(a,b):
    for j in  range(i+1,b):
      ll.append(i*j%2019)
  print(min(ll))

Submission status: Wrong Answer

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

mod = 2019
l, r = L % mod, R % mod
if l > r:
    l, r = r, l

mini = l*r % mod
for i, j in combinations(range(l, r+1), 2):
    val = i*j % mod
    if val < mini:
        mini = val 
print(mini)

Submission status: Wrong Answer

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

minimum = l%2019
maximum = r%2019


if r-l >= 2019:
    print(0)
if r-l < 2019 and maximum == (minimum + r - l):
    print(min((minimum * (minimum + 1)) % 2019,(maximum * (maximum + 1)) % 2019))
if r-l < 2019 and (r - l) != (maximum - minimum):
    print(0)

Submission status: Wrong Answer

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

min = 2020

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

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

Submission status: Wrong Answer

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

m_mod = L%2019
if R-L>=2019:
    m2_mod = 0
else:
    m2_mod = (L+1)%2019

print(m_mod*m2_mod)

Submission status: Wrong Answer

Solution code:
l, r = map(int, input().split())
m = 2 * (10 ** 9) + 1
n = 2 * (10 ** 9) + 2
flag = 0
for i in range(l, r+1):
    a = m
    m = min(m, i % 2019)
    if i % 2019 == 0:
        flag = 1
        break
    if a == m:
        n = min(n, i % 2019)
    else:
        n = min(n, a)

if flag == 0:
    print((n*m) % 2019)
else:
    print(0)

Submission status: Wrong Answer

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

temp = []
c = -1
for i in range(L, R+1):
    if not ((i%2019) in temp):
        temp.append(i%2019)
        c+=1
    else:
        break

temp.sort()

print(temp[0]*temp[1])

Submission status: Wrong Answer

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

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

print(min)

Submission status: Wrong Answer

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

minNum = 0
maxNum = 0
ans = 0

tempL = int(L / 2019)
tempR = int(R / 2019)

if(tempL != tempR):
    ans = 0
else:
    minNum = ((L % 2019) * ((L+1) % 2019)) % 2019
    maxNum = (((R - 1) % 2019) * ((R) % 2019)) % 2019

    if minNum < maxNum:
        ans = minNum
    else:
        ans = maxNum

print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
l, r = list(map(int, input().split()))
if l // 2019 == r // 2019:
    a = l % 2019
    print(a * (a + 1))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
L,R = map(int,input().split())
ls = []
if L*R < 2019:
    print(L*R)
elif R - L > 2019:
    print(1)
elif (2019%R) == (2019%L):
    print(2)

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
m = 673
if R // m - (L - 1) // m != 0:
    print(0)
else:
    minnum = 1000
    Lmod = L % m
    Rmod = R % m
    for i in range(Lmod, Rmod+1):
        for j in range(i + 1, Rmod+1):
            minnum = min(minnum, (i * j) % m)
    print(minnum)

Submission status: Wrong Answer

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

if l >= r:
    l = 0
    r = 2018

for i in range(l, r):
    for j in range(l + 1, r + 1):
        if j <= i:
            continue
        else:
            ans = min(ans, i * j % MOD)

print(ans)

Submission status: Wrong Answer

Solution code:
l,r = list(map(int,input().split()))
f = [0]*2020
x = []
if r-l == 1:
    print(((r%2019)*(l%2019))%2019)
    exit()
for i in range(l,r+1):
    n = i%2019
    if f[n] == 0:
        x.append(n)
        f[n] = 1
    else:
        break
x.sort()

print(min(x[0]*x[1]%2019,x[-1]*x[-2]%2019))

Submission status: Wrong Answer

Solution code:
# input
l, r = map(int, input().split())
if r-l == 1:
    print(int((l*r) % 2019))
elif r % 673 < r-l+1:
    print(0)
else:
    print(min(int((l*(l+1)) % 2019), int((l*(l+2)) % 2019), int((l*(l+3)) % 2019)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
# print("debug: " + str(L*R%2019))
if L * R <= 2019:
    print(L*R%2019)
elif R - L >= 2019:
    print(0)
else:
    ans = 2020
    L_mod = L % 2019
    R_mod = R % 2019
    for i in range(min(L_mod,R_mod),max(L_mod,R_mod)):
        for j in range(i+1,max(L_mod,R_mod)):
            # print((i*j)%2019, i, j)
            ans = min(ans, (i*j)%2019)
    print(ans)

Submission status: Wrong Answer

Solution code:

L,R = map(int,input().split())
md = 2019
p = []

for i in range(L,R+1):
    p.append(i % 2019)
    if i % 2019 == 0:
        print(0)
        exit()
    
p.sort()
print((p[0]*p[1])%md)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    input = sys.stdin.readline
 
    l, r = [int(i) for i in input().split()]
    
    minmod = float('inf')
    mini = -1
    count = 0
    
    if(r - l) >= 2019:
        print(0)
        exit()
    
    for i in range(l, r+1):
        if i%2019 < minmod:
            minmod = i%2019
            mini = i
        
        
    if mini != r:
        print((mini * (mini+1))%2019)
    else:
        print((mini * (mini-1))%2019)
    
 
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

for i in range(1,10**6):
    if i * 2019 >= L and i*2019 <= R:
        print(0)
        exit()

ans = 10**20
ans = min(ans , L*(L+1) % 2019)
ans = min(ans , R*(R-1) % 2019)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
if R - L >= 100000:
    print(0)
# elif L == 0:
#     print(0)
else:
    ans = float("inf")
    for i in range(L, R):
        ans = min(i * (i + 1) % 2019, ans)
        # if ans == i * (i + 1) % 2019:
        #     print(i)
    print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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


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

else:
        print(0)
        exit()

Submission status: Wrong Answer

Solution code:
L,R = map(int, input().split())
MOD = 2019
#mL = L%MOD
mL = L
divL = L//MOD
mR = R%MOD
#if mL>=mR:
#    mR +=MOD
mR +=divL*MOD

min_mod = MOD
#print(mL, mR)
for i in range(mL, mR):
    for j in range(i+1, mR+1):
        min_mod=min((i*j)%MOD, min_mod)
        #print(i, j, (i*j)%MOD)
print(min_mod)

Submission status: Wrong Answer

Solution code:
#C
from math import floor, ceil
def clc(a,b):
    #return min(a * b % 2019, 2019 - a*b % 2019)
    return a*b%2019
def c(l):
    return min(l % 2019, 2019 - l % 2019)
l, r = map(int, input().split())
if ceil(l/2019) <= floor(r/2019): #include 2019*n
    ans = 0
else: #
    l1 = l
    l2 = l+1
    r1 = r
    r2 = r-1
    ans = min(clc(l1,l2), clc(l1,r1), clc(l2,r1), clc(l2,r2), clc(r1,r2))

print(ans) #min((i*j) %2019)

Submission status: Wrong Answer

Solution code:
def solve():
  L, R = map(int, input().split())
  ans = 2019
  for i in range(L, R):
    v = i * (i + 1) % 2019
    if v < ans: ans = v
  return ans

print(solve())

Submission status: Wrong Answer

Solution code:
l, r = map(int, input().split())
if r < 2019:
    print(l*r)
elif l <= 2019 and 2019 <= r:
    print(0)
else:
    if (r-l) >= 2018:
        print(0)
    else:
        new_l = l % 2019
        new_r = r % 2019
        count_l = l // 2019
        count_r = r // 2019
        if new_r >= 2 and count_l != count_r:
            print(2)
        else:
            print(new_l*(new_l+1))

Submission status: Wrong Answer

Solution code:
l,r=map(int,input().split())
L=l%2019
R=r%2019



if(R<=(r-l)%2019 or r-l>=2019):
    print(0)
elif(2019<=r):
    print(min(l*(l+1)%2019,r*(r-1)%2019))
else:
    print(l*r%2019)

Submission status: Wrong Answer

Solution code:
l,r = map(int,input().split())
syol = l//2019
syor = r//2019
if syol != syor:
    print(0)
else:
    flag673 = 0
    flag3 = 0
    for i in range(l,r):
        if i//673 == 0:
            flag673 = 1
            if flag3 == 1:
                break
        if i//3 == 0:
            flag3 = 1
            if flag673 == 1:
                break
    if (flag673==1)and(flag3==1):
        print(0)
    else:
        print(l*(l+1)%2019)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

i = l
j = l+1

if j-i == 1:
    i = l
    r = j

print((i*j)%2019)

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np

str = [int(i) for i in input().split()]
l, r = str

for i in range(991):
  if l <= 2019 * i and r >= 2019 * i:
    print(0)
    exit(0)

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

Submission status: Wrong Answer

Solution code:
def cal_min(a,b):
    c = [i%2019 for i in range(a,b+1)]
    min1 = min(c)
    if min1 == 0:
        return 0
    
    c.remove(min1)
    return (min1*min(c))%2019


l,r = map(int, input().split())
# ml= l%2019
# mr= r%2019

print(cal_min(l,r))

Submission status: Wrong Answer

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

vlist = []
mini = 2019

for x in range(gap+1):
    v = (l+x) % 2019
    mini = min(v, mini)
    if v <= mini+1:
        vlist.append(v)

vlist.sort()
#print(vlist)

#res = i*j % 2019
print((vlist[0]*vlist[1])%2019)

Submission status: Wrong Answer

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

for i in range(r - l):
    t = 2019
    for j in range(i + 1, r - l + 1):
        tmp = (l + i) * (l + j) % 2019
        if a > tmp:
            a = tmp
        if tmp > t:
            break
        t = tmp

print(a)

Submission status: Wrong Answer

Solution code:
import numpy as np 

L, R = list(map(int, input().split()))
data = np.array([x for x in range(L, R+1)]) % 2019
len_data = R - L + 1
mod_min = np.inf

for i in reversed(range(len_data)):
    for j in range(i):
        mod = data[i] * data[j]
        mod_min = mod if mod_min > mod else mod_min

print(mod_min)

Submission status: Wrong Answer

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

l = l % 2019
r = r % 2019
if l > r:
    r, l = l, r

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

Submission status: Wrong Answer

Solution code:
L,R = map(int,input().split())
ans = 0
dis_modL = min(abs(2019 - L%2019),L%2019)
dis_modR = min(abs(2019 - R%2019),R%2019)
if(dis_modL < dis_modR):
    ans = dis_modL*(dis_modL+1)
elif(dis_modL == dis_modR):
    ans = dis_modL * dis_modR
elif(dis_modL > dis_modR):
    ans = dis_modR*(dis_modR+1)

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
L,R = map(int, input().strip().split(' '))
def inNLR(l,r,n):
  return (r-l+1) >= n or l%n >= r%n or l%n == 0

if inNLR(L,R,2019):
  print(0)
elif inNLR(L,R,3) and inNLR(L,R,673):
  print(0)
else:
  print(min((L*(L+1))%2019, R*(R-1)%2019, (R*L)%2019))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
L, R = map(float, input().split())
while (L >= 2019):
    L -= 2019
while (R >= 2019):
    R -= 2019
if L >= R:
    R += 2019
L = int(L)
R = int(R)
val = 2019
for i in range(L, R):
    for j in range(i + 1, R+1):
        tmp = (i * j % 2019) % 2019
        val = tmp if val > tmp else val

print(val)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if l // m == r // m:
    print((l % m) * (l % m + 1))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
import sys

def solve(l, r):
  if abs(l - r) >= 2019:
    return 0

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

      # print(i, j)
      ans = min(ans, (i * j) % 2019)

  return ans


if __name__ == "__main__":
  l, r = map(int, sys.stdin.readline().rstrip().split(" "))
  print solve(l, r)

Submission status: Wrong Answer

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

output = 2 * pow(10,9)
i = L
for j in range(i+1, R+1):
    if (i*j) % 2019 < output:
        output =  (i*j) % 2019
        if output == 0:
            break
print(output)

Submission status: Wrong Answer

Solution code:
from fractions import gcd


l, r = map(int, input().split())
lr_ans = []
if r - l + 1 >= 2019:
    print(2)
    exit()
for i in range(l, min(l+2019+1, r+1)):
    lr_ans.append(i%2019)
lr_ans.sort()
print(int((lr_ans[0]*lr_ans[1])/gcd(lr_ans[0], lr_ans[1])))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
l,r=map(int,input().split())
ans=0
if l%2019>r%2019 or r-l>=2018:
    ans=0
else:
    if l%673>r%673 or r-l>=672:
        ans=0
    else:
        ll=l%2019
        rr=r%2019
        ans=min((rr*(rr+1))%2019,(ll*(ll+1))%2019)
print(ans)

Submission status: Wrong Answer

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

ans = []

l %= 2019
r %= 2019

if l > r:
	s = l
	l = r
	r = s
	
for i in range(l,r):
	for j in range(i+1,r+1):
		rem = i*j%2019
		ans.append(rem)

print(min(ans))

Submission status: Wrong Answer

Solution code:
a = input().split()
a = [int(i) for i in a]
a = sorted(a)
if a[0] + 2019 <= a[1]:
    print(0)
else:
    b = [i + 1 for i in range(abs(a[0] - a[1]) + 1)]
    b_1 = [i for i in range(a[0], a[1] + 1)]
    c = [i % 2019 for i in b_1]
    c = sorted(c)
    print((c[0]*c[1])%2019)

Submission status: Wrong Answer

Solution code:
import numpy as np


def calc(ell: int, r: int) -> int:
    if ell % 2019 > r % 2019:  # 間に2019の倍数があるパターン1
        return 0
    if r >= ell + 2019:  # 間に2019の倍数があるパターン2
        return 0

    start = ell
    # stop = min(ell + 2019, r)
    stop = r

    searching_array = np.arange(start, stop, 1)
    searching_mat = np.tile(searching_array, (searching_array.shape[0],))
    seki = searching_mat * (searching_mat.T + 1)
    results = np.mod(seki, 2019)
    return results.min()


def load_input_as_int_array():
    return [int(v) for v in input().split(" ")]


ell, r = load_input_as_int_array()
print(calc(ell, r))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

minimum = l%2019
maximum = r%2019


if r-l >= 2019:
    print(0)
if r-l < 2019 and maximum == (minimum + r - l):
    print((minimum * (minimum + 1)) % 2019)
if r-l < 2019 and (r - l) != maximum - minimum:
    print(0)

Submission status: Wrong Answer

Solution code:
import sys


def input():
    return sys.stdin.readline()[:-1]


def main():
    l, r = map(int, input().split())
    n = [[i % 2019, i] for i in range(l, r+1)]
    n.sort(key=lambda x: x[0])
    print(n)
    print((n[0][1]*n[1][1]) % 2019)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np

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

# if L == R:
#     tmp = L % MOD
#     print(tmp*tmp)
# else:
#     a = np.array(range(L, R+1)) % MOD
#     b = np.sort(a,kind='quicksort')
#     print(b[0]*b[1])

minMOD = 2019
minMOD2 = 2019

for i in range(L, R+1):
    tmp = i % MOD
    if tmp == 0:
        minMOD = 0
        break

    if tmp < minMOD:
        minMOD = tmp
    elif tmp < minMOD2:
        minMOD2 = tmp

print((minMOD * minMOD2) % MOD)

Submission status: Wrong Answer

Solution code:
import numpy as np

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



#print(L%2019, R%2019)

#print((L + 2019 - L%2019))

tmp = 0
if L * R < 2019:
	i = L
	j = R

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

elif L % 2019 < R % 2019:
	i = L
	j = i+1

elif R % 2019 > L % 2019:
	j = R
	i = j-1

else:
	i = L
	j = R

ans = i * j % 2019

print(ans)

Submission status: Wrong Answer

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