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:
if __name__ == "__main__":
    n, a = map(int, input().split())

    if n % 2019 == 0 or a % 2019 == 0 or n * a % 2019 == 0:
        print(0)

    elif a < 2019:
        print((n * a) % 2019)

    elif 2019 < n:
        print((n % 2019) * ((n+1) % 2019))

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
l,r = map(int, input().split())
if (r//673 - (l-1)//673 > 0)&(r-l >= 2):
    print(0)
else:
    print((l * (l+1)) % 2019)

Submission status: Wrong Answer

Solution code:
l,r = map(int,input().split())
mods = l*r
for i in range(l,r+1):
    for j in range(l,i+1):
        if i == j:
            continue
        elif i%2==0 & j%2==0:
            continue
        elif i%2==1 & j%2==1:
            continue
        else:
            q, mod = divmod(i*j, 2019)
            mods = min(mod,mods)
print(mods)

Submission status: Wrong Answer

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

if r - l + 1 >= 2019:
    print(0)
    exit(0)


else:
    for i in range(r - l + 1):
        a.append((l + i) % 2019)

# print(a)
a.sort()
print(a[0] * a[1])

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
l,r = map(int, input().split())
gap = r-l
 
vlist = []
min = 2019
 
for x in range(gap+1):
    v = (l+x) % 2019
    vlist.append(v)
    if v == 0:
        print(0)
        exit()
 
vlist.sort()
#print((vlist[0]*vlist[1])%2019)
print((vlist[0]*vlist[1]))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# 133C
"""
L<=i<=j<=R
(i×j)mod 2019
0≤L<R≤2×10^9
"""
 
L, R = map(int, input().split())
 
min2019 = 2019
for i in range(L, R):
    for j in range(R, i, -1):
        if (i * i-1) % 2019 >= min2019:
            break
        elif (i * j) % 2019 < min2019:
            min2019 = (i * j) % 2019
print(min2019)

Submission status: Wrong Answer

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

if R-L > 2019:
    print('0')
elif R - L == 1:
    print((R*L)%2019)
else:
    for i in range(L, R):
        if (i % 2019) < mini:
            mini = i % 2019
            ans = i

    for j in range(L, R):
        if j == ans:
            continue
        if (j % 2019) < minib:
            print(j)
            minib = j % 2019
            ansb = j

    calc = ((ans%2019) * (ansb%2019)) % 2019
    print(calc)

Submission status: Wrong Answer

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

i = l
j = l+1

t = r // 2019
if t > 0:
    j = 2019 * t
    if j < l+1:
        j = l+1
    i = j-1

print((i*j)%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 % 2019 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())


if (r<2019): print(l*(l+1))

if (l>2019):
    if (2019*2<=r):
        print(0)
        exit(0)
    else:
        print(l%2019*(l+1)%2019)

Submission status: Wrong Answer

Solution code:
L,R = map(int,input().split())
l = L % 2019
print(l*(l+1))

Submission status: Wrong Answer

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

if R == 2019:
    print(0)
    exit()

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

if (R-L) < 2019:
    temp1 = float("inf")
    for i in range(R-L):
        temp2=((R-i)*(R-i-1))%2019
        if temp2 < temp1:
            temp1 = temp2
    print(temp1)

Submission status: Wrong Answer

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

ans = 10 ** 7

L=L%2019
R=R%2019

di = R//2019 - L//2019

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

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

else:
    R += 2019*2
    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:
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)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
mod = 2019
 
l = L % mod
c = L // mod
d = R // mod

if c != d:
  print(0)
else:
  print(l * (l + 1))

Submission status: Wrong Answer

Solution code:
MOD = 2019

L, R = map(int, input().split())
minx = float("inf")
iset = set()
for i in range(L, R):
    im = i % MOD
    if im in iset:
        break
    jset = set()
    for j in range(i + 1, R + 1):
        jm = j % MOD
        if jm in jset:
            break
        minx = min(minx, im * jm)
print(minx)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math

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

mod = 2019

l = L % 2019
r = R % 2019


if l > r:
    print(0)
    exit()
else:
    _min = 1000000
    for i in range(l, r):
        for j in range(i+1, r+1):
            _min = min(_min, i*j%mod)

print(_min)

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[k-1]*y[k-2])%2019))

Submission status: Wrong Answer

Solution code:
def baisuaru(l,r,m):
  if l//m < r//m:
    return True
  elif l%m==0:
    return True
  else:
    return False
    

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


if baisuaru(l,r,2019):
  print(0)
else:
  if baisuaru(l,r,3) and baisuaru(l,r,673):
    print(0)
  else:
    print((l%2019 * ((l%2019) +1)) % 2019)

Submission status: Wrong Answer

Solution code:
l,r=map(int,input().split())
if r-l+1<=2019:
	lst=list(range(l,r+1))
	modlist=[]
	for i in lst:
		q,mod = divmod(i,2019)
		modlist.append(mod)
	sor = sorted(modlist)
	if sor[0]==0:
		print(0)
	else:
		if 672 in sor and 673 in sor:
			print(0)
		elif 675 in sor and 673 in sor:
			print(0)
		else:
			q,mod = divmod(sor[0]*sor[1],2019)
			print(mod)
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):
        for j in range(i+1,r_mod+1):
            if mod>(i*j)%2019:
                mod=(i*j)%2019
    print(mod)

Submission status: Wrong Answer

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

main()

Submission status: Wrong Answer

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

minimum = l%2019
maximum = r%2019

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

Submission status: Wrong Answer

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

if __name__=="__main__":
    main()

Submission status: Wrong Answer

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

if (r - l >= 672):
    print(0)
else:
    a = 2018
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            b = i % 2019
            print(b)
            c = j % 2019
            print(c)
            d = (b * c) % 2019
            a = min(a, d)
    print(a)

Submission status: Wrong Answer

Solution code:
L,R=map(int,input().split())
if R*(R-1)<2019:
  print(L*(L+1))
elif  R//2019-L//2019>=1:
  print(0)
else:
  val=(L+R)//2
  if (val+1)%2019<val%2019:
    p=val
    while (p+1)%2019<p%2019 and p<=R-1:
      p+=1
    if p/2>=L:
      print((p**2)%2019)
    else:
      print((p*(p-1))%2019)
  else:
    p=val
    while (p-1)%2019<p%2019 and p>=L+1:
      p-=1
    if p*2<=R:
      print((p**2)%2019)
    else:
      print(p*(p+1)%2019)

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%2019)

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):
        n = (L+i)
        if n % 673 == 0 and (R-L+1) >= 3:
            print(0)
            break;
        else:
            A.append(n%2019)
    A.sort()
    print((A[0]*A[1])%2019)

Submission status: Wrong Answer

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

indexs = []
for index in range(L,min(R+1,L+2019)):
	indexs.append(index%2019)
	
#print(indexs)
	
indexs = sorted(indexs)

#print(indexs)
	
print((indexs[0]*indexs[1]) % 2019)

Submission status: Wrong Answer

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

for i in range(L,R+1):
    c = i%2019
    if c < a:
        b = a
        a = c
    else:
        if c < b:
            b = c
ans = a*b
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
ans = 0
if R <= 2019:
    ans = 2018
    for i in range(L, R + 1):
        for j in range(i + 1, R + 1):
            tmp = (i * j) % 2019
            if tmp < ans:
                ans = tmp
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())

ans = 0

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


print(ans)

Submission status: Wrong Answer

Solution code:
x,y = map(int,input().split())


gap = y-x
F = 0
t = x%2019
e = y%2019

tq = x%673
eq = y%673

m = min(t,e)
M = max(t,e)

mq = min(tq,eq)
Mq = max(tq,eq)

t2 = 2200
t1 = (m*(m+1))%2019
if gap > 672:
    t2 = 0
if gap > 2 and (eq < tq):
    t2 = 0

k = 1 
if gap <= 2:
    for i in range(x,y+1):
        k*=i
k = k%2019

print(min(t1,t2,k))

Submission status: Wrong Answer

Solution code:
# C
L, R = map(int, input().split())
l = L % 2019
r = R % 2019
if R - L >= 2019:
    print(0)
else:
    if l >= r:
        print(0)        
    else:
        if r < 673:
            print((l * (l+1)) % 2019)
        elif r == 673:
            print(0)
        elif l == 673 and r == 674:
            print((673 * 674) % 2019)
        elif r == 673 and l < 673:
            print(0)
        elif l == 673:
            print(0)
        elif 673 < l and r < 1346:
            print((l * (l + 1)) % 2019)
        elif r == 1346 and l < 1345:
            print(0)
        elif r == 1346 and l == 1345:
            print((r * l) % 2019)
        elif r > 1346 and l < 1346:
            print(0)
        elif l > 1346:
            print((l * (l+1)) % 2019)

Submission status: Wrong Answer

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

minv = 1145141919810931
for i in range(l, r + 1):
    for j in range(i + 1, r + 1, 2):
        minv = min(minv, (i * j) % 2019)

print(minv)

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    l,r  = list(map(int, input().split(" ")))

    n = l // 2019
    if l % 2019 == 0:
        print(0)
    elif l <= 2019 * (n+1) and 2019 * (n+1) <= r:
        print(0)
    else:
        print(((l % 2019) * ((l+1) % 2019)) % 2019)

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 (R%2019) > (L%2019):
    print(L%2019 + 1)
else:
    print(R%2019 + 1)

Submission status: Wrong Answer

Solution code:
import numpy as np 

L, R = list(map(int, input().split()))
data = np.sort(np.array([x for x in range(L, R+1)]) % 2019)
min_mod = (data[0] * data[1]) % 2019
print(min_mod)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if L <= R//d * 2019: print(0)
else: 
    L = L % 2019
    R = R % 2019
    ans = 2020
    for i in range(L,R+1):
        tmp = i*(i+1)%d
        if tmp < ans: ans = tmp
    print(ans)

Submission status: Wrong Answer

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

list2019 = []
list673 = []
for i in range(3000000):
    list673.append(673 * i)

answer = (L * (L + 1)) % 2019
for l673 in list673:
    if L <= l673 and l673 <= R:
        for i in [1, 2, 3]:
            if (l673 * (l673 - i) % 2019 == 0) and L <= l673 - i:
                answer = 0
            elif (l673 * (l673 + i) % 2019 == 0) and l673 + i <= R:
                answer = 0

if L == 0:
    answer = 0

print(answer)

Submission status: Wrong Answer

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

minimum = l%2019
maximum = r%2019

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

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:
            num = 2019
            for i in range(l, r+1):
                for j in range(i+1, r+1):
                    ans = (i*j)%2019
                    if ans < num:
                        num = ans
            print(num)

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
l = L % 2019
r = R % 2019
ans = 10 ** 12
if l >= r:
    ans = 0
else:
    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: Wrong Answer

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

if L // 2019 == R // 2019:
    if abs (L % 2019 - 1009) < abs(R % 2019 - 1009):
        ans = (R % 2019 - 2019) * (((R-1) % 2019) - 2019) % 2019
    else:
        ans = ((L % 2019) * (L+1) % 2019) % 2019
else:
    ans = 0

print(ans)

Submission status: Wrong Answer

Solution code:
def main():
  min_max=0
  f_1=2+10**9
  f_2=2+10**9
  min_d=2019
  min_d2=2019
  L,R=map(int,input().split())
  for i in range(L,R+1):
    a=i%2019
    if a<=min_d and a<=min_d2:
      min_d2=min_d
      min_d=a
      f_2=f_1
      f_1=i
    elif a<=min_d2:
      f_2=i
      min_d2=a
    if min_d==0:
      break
  print((f_1*f_2)%2019)
  
main()

Submission status: Wrong Answer

Solution code:
L,R = map(int, input().split())
if R//2019 - (L-1)//2019 > 0:
    print(0)
elif R//673 - (L-1)//673 > 0 and R-L > 2:
    print(0)
else:
    l = L%673
    r = R%673
    shou = (L//673)%3
    print((l*(l+1) + shou*673)%2019)

Submission status: Wrong Answer

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

x = 2020

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

print(x)

Submission status: Wrong Answer

Solution code:
l,r = map(int,input().split())
ln = l // 2019
rn = r // 2019
if ln != rn :
    ans = 0
else :
    l = l % 2019
    r = r % 2019
    ld = min(l,abs(1010-l))
    rd = min(r,abs(1010-r))
    i = min(ld,rd)
    ans = i*(i+1)
print(ans)

Submission status: Wrong Answer

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

indexs = []
for index in range(L,min(R+1,L+2019)):
	indexs.append(index%2019)
	
print(indexs)
	
indexs = sorted(indexs)

print(indexs)
	
print((indexs[0]*indexs[1]) % 2019)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
L %= 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+2):
        tmp = (i * (j % 2019)) % 2019
        val = tmp if val > tmp else val

print(val)

Submission status: Wrong Answer

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

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

l = int(l % 2019)
r = int(r % 2019)

m = 2018
for i in range(l, r):
    for j in range(i + 1, r + 1):
        if m > int((i * j) % 2019):
            m = int((i * j) % 2019)

print(m)

Submission status: Wrong Answer

Solution code:
l,r = map(int, input().split())
gap = r-l
 
vlist = []
min = 2019
 
for x in range(gap+1):
    v = (l+x) % 2019
    vlist.append(v)
    if v == 0:
        print(0)
        exit()
 
vlist.sort()
#print(vlist)
 
#res = i*j % 2019
print((vlist[0]*vlist[1])%2019)

Submission status: Wrong Answer

Solution code:
A,B=map(int,input().split())
mod = 2018
flag=0
for i in range(A,B):
  for j in range(i+1,B+1):
    if (i*j)%2019>mod:
      flag = 1
      break
    mod = min(mod,(i*j)%2019)
  if flag:
    break
print(mod)

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
# print("debug: " + str(L*R%2019))
if R - L >= 2019:
    print(0)
# elif L <= 2019 and R <= 2019:
#     print(L*R%2019)
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:
import math

l, r = [int(i) for i in input().split()]
if math.floor(r/3) - math.floor((l-1)/3) >= 1 and math.floor(r/673) - math.floor((l-1)/673) >= 1:
    print(0)
elif math.floor(r/2019) - math.floor((l-1)/2019) >= 1:
    print(0)
else:
    print((l*(l+1)) % 2019)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

mod = 2019
for i in range(100):
  if L <= 3**i%(1e9+7) <= R or L <= 673**i%(1e9+7) <= R or L <= 3*673*i%(1e9+7) <= R or L <= 3*i%(1e9+7) <= R or L <= 673*i%(1e9+7) <= R or L <= 3*673**i%(1e9+7) <= R:
    print(0)
    exit()
else:
  print(min((L*(L+1))%mod, R*(R-1)%mod, R*L%mod))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
l, r = list(map(int, input().split()))
if l // 2019 == r // 2019:
    _l = l % 2019
    n = min(r - l + 1, 2019)
    a = list(range(_l, min(2019, _l + n)))
    a.extend(list(range(0, n - len(a))))
    a.sort()
    print((a[0] * a[1]) % 2019)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
from fractions import gcd


l, r = map(int, input().split())
lr_ans = []
if r - l  >= 2019:
    print(0)
    exit()
for i in range(l, 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:
num = input().split()
l, r = int(num[0]), int(num[1])
ans = 0

if r-l+1>=2019:
  ans = 0
else:
  if r-l == (r%2019)-(l%2019):
    ans = (l%2019)*((l+1)%2019)
  else:
    ans = 0
    
print(ans)

Submission status: Wrong Answer

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

lis = []
if r - l > 9999:
    r = l + 9999
for i in range(l, r+1):
    lis += [i % 2019]
lis.sort()
print(lis[0] * lis[1] % 2019)

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_1 = [i for i in range(a[0], a[1] + 1)]
    c = [i % 2019 for i in b_1]
    c = sorted(c)
    epoc = 2019
    if c[0] * c[1] > 2019:
        for i in range(len(c)):
            for u in range(i):
                epoc1 = (c[i] * c[u]) % 2019
                if epoc1 < epoc:
                    epoc = epoc1
        print(epoc)
                
        
    else:
        print((c[0] * c[1]) % 2019)

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:
            num = 2019
            for i in range(l, r+1):
                for j in range(i, r+1):
                    ans = (i*j)%2019
                    if ans < num:
                        num = ans
            print(num)

Submission status: Wrong Answer

Solution code:
from sys import stdin
import math
input = [int(x) for x in stdin.readline().rstrip().split()]

L=input[0]
R=input[1]


output=0
if R//673 != L//673:
    output=0
else:
    output=(L*(L+1)%2019)




print(output)

Submission status: Wrong Answer

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

if(r-l>=2019):
    print(0)
elif(2019<=r):
    Min=2019
    for i in range(l,r):
        tmp=i*(i+1)%2019
        if(tmp<Min):
            Min=tmp
    print(Min)
else:
    print(l*r%2019)

Submission status: Wrong Answer

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

if abs(l - r) == 1:
    print(l * r % 2019)
else:
    lower = l // 2019
    upper = r // 2019
    start = l % 2019
    stop = r % 2019
    if 2019 * (lower + 1) < r:
        print(0)
    else:
        if start == 0:
            print(0)
        elif stop == 0:
            print(0)
        elif stop < start:
            print(0)
        elif stop > start or start == stop:
            print(start * (start + 1) % 2019)

Submission status: Wrong Answer

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

#i*jmodk=(imodk*jmodk)modk

#l以上r以下の整数で2019の倍数を含むものがあれば、imod2019=0となるiを選ぶことでijmod2019=0になり、最小

#r-lが2018以上ならかならず、imod2019=0となるiか、jmod2019=0となるjが存在する

if r-l>=2018:
    print(0)
elif l%2019==0:
    print(0)
elif r%2019==0:
    print(0)
else:
    i_l=[]
    for i in range(l,r):
        i_l.append(i%2019)
    ans_l=min(i_l)
    ans=((ans_l%2019) * ((ans_l+1)%2019))%2019
    print(ans)

Submission status: Wrong Answer

Solution code:
l,r = map(int,input().split())
if l//2019 != r//2019:
    print(0)
else:
    print(min(l*(l+1)%2019,r*(r-1)%2019))

Submission status: Wrong Answer

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

temp = 2019
for i in range(0,min(r-l+1,2020)):
    temp = min(temp,(l+i)%2019)
    
print(temp*(temp+1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
print(L*(L+1)%2019)

Submission status: Wrong Answer

Solution code:
MOD=2019

l,r=map(int,input().split()) #l<=i<i+1<=j<=r
res=[2020]

l=l%MOD
r=r%MOD
l,r=min(l,r),max(l,r)

for i in range(l,r+1):
  for j in range(i+1,r+1):
    res += [(i*j)%MOD]
print(min(res))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if (r<2019): print(l*(l+1))

if (l>2019):
    if (l*2<=r):
        print(0)
        exit(0)
    else:
        print(l%2019*(l+1)%2019)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
L,R=(int(x) for x in input().split())
L_mod=L%2019
R_mod=R%2019
c=0
for n in range(2019):
    if L+n>=R:
        break
    if (L+n)%2019==0:
        c=1
        break
if c==1:
    print(0)
else:
    print(L_mod*(L_mod+1)%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())
m = 673
minnum = 1000
Lmod = L % m
Rmod = R % m
for i in range(Lmod, Rmod+1):
    for j in range(i + 1, Rmod+1):
        #print(i, j, (i * j) % m)
        minnum = min(minnum, (i * j) % m)

print(minnum)

Submission status: Wrong Answer

Solution code:
import math

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

mod = 2019

l = L % 2019
r = R % 2019


if l > r:
    print(0)
else:
    print(L * (L+1) % mod)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:


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



if (R - L) >= 2019:
    x = list(range(0, 2019+1))

else:
    l = L % 2019
    r = R % 2019
    if r < l:
        x = list(range(l, 2019+1))
        x += list(range(0, r+1))
    else:
        x = list(range(min(l, r+1), max(l, r+1)))

    






ans = 3000
for i in range(len(x)):
    for j in range(len(x)):
        if ans > (x[i]*x[j])%2019:
            ans = (x[i]*x[j])%2019





print(ans)

Submission status: Wrong Answer

Solution code:
l, r = [int(i) for i in input().split()]
if int(r/3) - int((l-1)/3) >= 1 and int(r/673) - int((l-1)/673) >= 1:
    print(0)
elif int(r/2019) - int((l-1)/2019) >= 1:
    print(0)
else:
    print((l*(l+1)) % 2019)

Submission status: Wrong Answer

Solution code:
import math

l, r = map(int, input().split())
e = 2019
e1 = 3
e2 = e // e1

if r-l == 1:
    print(l*r % e)
else:
    if math.ceil(l / e2) < math.ceil(r / e2):
        print(0)
    else:
        print(l*(l+1) % e)

Submission status: Wrong Answer

Solution code:
def make_list(L, R):
    mod_list = list()

    for i in range(L, R):
        for j in range(i + 1, i + 2020):
            mod_list.append((i * j) % 2019)

    return mod_list


def main():
    L, R = map(int, input().split())

    mod_list = make_list(L, R)

    print(min(mod_list))

    return


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

def solve(l, r):
  if r - l >= 2018:
    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)