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:
lr = input().split()
l = int(lr[0])
r = int(lr[1])

mini = 2018
for i in range(l, r+1):
  if i==0:
    mini = 0
    break
  
  q = i*(i+1)%2019
  mini = min(mini, q)
  if (2019-q) > (r - i) * i:
    break
  elif (2019-q) == (r - i) * i:
    mini = 0
    break
  else:
    s = 2019 // i + 1 
    j = i + 2 + q // i 
    while j < r:
      mini = min(mini, (i*j)%2019)
      j += s
      if mini==0:
        break
  if mini==0:
    break
print(mini)

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):
  if i==0:
    mini = 0
    break
  
  q = i*(i+1)%2019
  mini = min(mini, q)
  if (2019-q) > (r - i) * i:
    break
  else:
    s = 2019 // i + 1 
    j = i + 2 + q // i 
    while j < r:
      mini = min(mini, (i*j)%2019)
      j += s
      if mini==0:
        break
  if mini==0:
    break
print(mini)

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):
  if i==0:
    print(0)
    break
  
  q = i*(i+1)%2019
  mini = min(mini, q)
  if (2019-q) > (r - i) * i:
    break
  else:
    s = 2019 // i + 1 
    j = i + 2 + q // i 
    while j < r:
      mini = min(mini, (i*j)%2019)
      j += s
      if mini==0:
        break
  if mini==0:
    break
print(mini)

Submission status: Wrong Answer

Solution code:
lr = input().split()
l = int(lr[0])
r = int(lr[1])

mini = 2020
for i in range(l, r+1):
  if i==0:
    print(0)
    break
    
  j = i+1
  while j>i and j<=r:
    q = (i*j)%2019
    j = j + (2018-q)//i
    mini = min(mini, q)
    
print(mini)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if R-L>=672:
    print(0)
elif R-L>=100:
    print(1)
elif L==0:
    print(0)
elif L<=672 and R>=673:
    print(0)
elif L>=2019:
    p=R-L
    L=L%2019
    R=L+p
    
p=0
for i in range(L,R):
    for j in range(i+1,R+1):
        if p==0:
            ans=(i*j)%mod
        elif (i*j)%mod<ans:
            ans=(i*j)%mod
        p+=1
print(ans)

Submission status: Wrong Answer

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

if L>=2019:
    p=R-L
    L=L%2019
    R=L+p
elif L<=672 and R>=673:
    print(0)
else:
    p=0
    for i in range(L,R):
        for j in range(i+1,R+1):
            if p==0:
                ans=(i*j)%mod
            elif (i*j)%mod<ans:
                ans=(i*j)%mod
            p+=1
    print(ans)

Submission status: Wrong Answer

Solution code:
mod=[]
modan=[]
mod = [int(i) for i in input().split()]
for i in range(mod[0],mod[1]):
    modan.append(i%2019)

modan.sort()

if len(modan)<2:
    modan.append(1)
print(modan[0]*modan[1])

Submission status: Wrong Answer

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

if L>=2019:
    L=L%2019
    R=R%2019
elif L<=672 and R>=673:
    print(0)
else:
    p=0
    for i in range(L,R):
        for j in range(i+1,R+1):
            if p==0:
                ans=(i*j)%mod
            elif (i*j)%mod<ans:
                ans=(i*j)%mod
            p+=1
    print(ans)

Submission status: Wrong Answer

Solution code:
mod=[]
mod = [int(i) for i in input().split()]
for i in range(mod[0],mod[1]):
    mod.append(i%2019)

mod.sort()

if len(mod)<2:
    mod.append(1)
print(mod[0]*mod[1])

Submission status: Wrong Answer

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

if L>=2019:
    L-=2019
    R-=2019
elif L<=672 and R>=673:
    print(0)
else:
    p=0
    for i in range(L,R):
        for j in range(i+1,R+1):
            if p==0:
                ans=(i*j)%mod
            elif (i*j)%mod<ans:
                ans=(i*j)%mod
            p+=1
    print(ans)

Submission status: Wrong Answer

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

yakusuu2019 = [3,673]

def mod2019(L, R):
  if R-L == 1:
    return L*R
  else:
    tmp = [(i,j,i*j,i*j%2019) for j in range(L,R+1) for i in range(L,R+1)].sort(key=lambda x:x[3])
    return tmp[0][2]

Submission status: Wrong Answer

Solution code:
A=list(map(int,input().split()))
f=True
C=2019
if f:
    if (A[1]-A[0])<2019:
        for i in range(A[1]):
            for t in range(A[1]+1):
                if t>i and i>=A[0]:
                    if t*i%2019<C:
                        C=t*i%2019
                        if C==0:
                            f=False
                            break
else:
    C=0
print(C)

Submission status: Wrong Answer

Solution code:
A=list(map(int,input().split()))
t=True
C=2019
if t:
    if (A[1]-A[0])<2019:
        for i in range(A[1]):
            for t in range(A[1]+1):
                if t>i and i>=A[0]:
                    if t*i%2019<C:
                            C=t*i%2019
                            if C==0:
                                t=False
                                break
else:
    C=0
print(C)

Submission status: Wrong Answer

Solution code:
A=list(map(int,input().split()))
t=True
C=2019
if t:
    if (A[1]-A[0])<2019:
        for i in range(A[1]):
            for t in range(A[1]+1):
                if t>i and i>=A[0]:
                    if t*i%2019<C:
                            C=t*i%2019
                            if C==0:
                                t=False
else:
    C=0
print(C)

Submission status: Wrong Answer

Solution code:
Q=[[2020,2040],[4,5]]
mod=[]
for i in range(2020,2040):
  mod.append(i%2019)
  
mod.sort()

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

Submission status: Wrong Answer

Solution code:
mod=[]
for i in range(2020,2040):
  mod.append(i%2019)
  
mod.sort()

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

Submission status: Wrong Answer

Solution code:
A=list(map(int,input().split()))
t=True
C=2019
if t:
    for i in range(A[1]):
        for t in range(A[1]+1):
            if t>i and i>=A[0]:
                if t-i>=2019:
                    if t*i%2019<C:
                        C=t*i%2019
                        if C==0:
                            t=False 
                            break
print(C)

Submission status: Wrong Answer

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

minmod = 2 * 10 ** 9

print(l,r)

if r - l >= 2019:
    print(0)
    sys.exit()

for i in range(l,r):
    imod = i % 2019
    for j in range(i+1,r+1):
        jmod = j % 2019
        minmod = min(minmod, (imod * jmod) % 2019)
        if minmod == 0:
            break

print(minmod)

Submission status: Wrong Answer

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

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



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

        

print(ans)

Submission status: Wrong Answer

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

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

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

        

print(ans)

Submission status: Wrong Answer

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

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

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

        

print(ans)

Submission status: Wrong Answer

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


def main():
    l, r = map(int, input().split())
    mod = 2019
    l %= mod
    r %= mod
    ans = float('inf')

    if l > r:
        l, r = r, l

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

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

minmod = 2 * 10 ** 9
for i in range(l,r):
    imod = i % 2019
    for j in range(i+1,r+1):
        jmod = j % 2019
        minmod = min(minmod, (imod * jmod))

print(minmod)

Submission status: Wrong Answer

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

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

print(m)

Submission status: Wrong Answer

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

N = R - L

m = (L * (L + 1)) % 2019
for i in range(L + 1, N - 1):
    for j in range(i + 1, N):
        m = min(m, (i * j) % 2019)

print(m)

Submission status: Wrong Answer

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

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

print(m)

Submission status: Wrong Answer

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

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

print(m)

Submission status: Wrong Answer

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

i = 2017
j = 2018

for k in range(R,L-1,-1):
    if k%2019 < i:
        j = i
        i = k%2019
        if i==0:
            break

print(i*j%2019)

Submission status: Wrong Answer

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

i = 2017
j = 2018

for k in range(R,L-1,-1):
    if k%2019 < i:
        j = i
        i = k%2019
        if i==0:
            break

print(i*j)

Submission status: Wrong Answer

Solution code:
L,R= list(map(int, input().split()))
N = min(R-L,2019)
MOD = 2019
m = MOD

for i in range(L,L+N):
    for j in range(i+1,L+N):
        m = min(m,(i*j)%MOD)

print(m)

Submission status: Wrong Answer

Solution code:
L,R= list(map(int, input().split()))
N = min(R-L+1,2019)
MOD = 2019
m = MOD
x = L

for i in range(N-1):
    m = min(m, x%MOD)
    x+=1

print((m*(m+1))%MOD)

Submission status: Wrong Answer

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

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

print(minimum)

Submission status: Wrong Answer

Solution code:
L,R= list(map(int, input().split()))
N = min(R-L+1,2019)
MOD = 2019
m = MOD
x = L

for i in range(N-1):
    m = min(m, L%MOD)

print((m*(m+1))%MOD)

Submission status: Wrong Answer

Solution code:
#!/bin/env python3
def main():
    l,r = map(int,input().split())
    res = 2019
    if r-l >= 2019:
      pass
    else:
      for i in range(l%2019,r-2019*(l//2019)+1):
        for j in range(i+1,r-2019*(l//2019)+1):
          res = min(res,(i*j)%2019)

    print(res)

main()

Submission status: Wrong Answer

Solution code:
#!/bin/env python3
def main():
    l,r = map(int,input().split())
    res = 2019
    if r-l >= 2019:
      pass
    else:
      for i in range(l%2019,r-2019*(l//2019)):
        for j in range(i+1,r-2019*(l//2019)):
          res = min(res,(i*j)%2019)

    print(res)

main()

Submission status: Wrong Answer

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

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

print(minimum)

Submission status: Wrong Answer

Solution code:
#!/bin/env python3
def main():
    l,r = map(int,input().split())
    res = 0
    if r-l >= 2019:
      pass
    else:
      for i in range(l%2019,r-2019*(l//2019)):
        for j in range(i+1,r-2019*(l//2019)):
          res = min(res,(i*j)%2019)

    print(res)

main()

Submission status: Wrong Answer

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

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

print(minimum)

Submission status: Wrong Answer

Solution code:
#!/bin/env python3
def main():
    l,r = map(int,input().split())
    res = 0
    if r-l >= 2019:
      pass
    else:
      for i in range(l%2019,r-2019*(l//2019)):
        for j in range(i,r-2019*(l//2019)):
          res = min(res,i*j%2019)

    print(res)

main()

Submission status: Wrong Answer

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

rl = r-l
l2 = l%2019
r2 = l2+rl

if rl>2019:
    print(0)
else:
    min_dif = 2019
    for j in range(l2, r2+1):
        if (l2*j)%2019 < min_dif:
            min_dif = (l2*j)%2019
    print(min_dif)

Submission status: Wrong Answer

Solution code:
l, r = map(int, input().split())
l_mod = l % 2019
r_mod = r % 2019
area = r_mod - l_mod
ans = -1
if area >= 0:
    ans = l_mod * (l_mod + 1) % 2019
else:
    ans = 0
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
l, r = map(int, input().split())
l_mod = l % 2019
r_mod = r % 2019
area = r_mod - l_mod
ans = -1
if area > 0:
    ans = l_mod * (l_mod + 1) % 2019
else:
    ans = 0
print(ans)

Submission status: Wrong Answer

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

rl = r-l
l2 = l%2019
r2 = l2+rl

if rl>2019:
    print(0)
else:
    min_dif = 2019
    for j in range(l2+1, r2+1):
        if (l2*j)%2019 < min_dif:
            min_dif = (l2*j)%2019
    print(min_dif)

Submission status: Wrong Answer

Solution code:
l, r = map(int, input().split())
l_mod = l % 2019
r_mod = r % 2019
area = r_mod - l_mod
ans = -1
if area > 0:
    ans = l * (l + 1) % 2019
else:
    ans = 0
print(ans)

Submission status: Wrong Answer

Solution code:
l,r = map(int,input().split(" "))
mn = 2019
n = 0
m = 0
for i in range(l,r+1):
    if i % 2019 < mn:
        mn = i % 2019
        n = i
mn = 2019
for i in range(l,r+1):
    if i != n:
        if i % 2019 < mn:
            mn = i % 2019
            m = i
print((n * m) % 2019)

Submission status: Wrong Answer

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

if r - l > 3 and r >= 673 * (r // 673) >= l:
  print(0)
else:
  print(l * (l + 1) % 2019)

Submission status: Wrong Answer

Solution code:
l,r = map(int,input().split(" "))
mn = 2019
n = 0
for i in range(l,r+1):
    if i % 2019 < mn:
        mn = i % 2019
        n = i
if n == r:
    print((n * (n-1) % 2019))
else:
    print((n * (n+1) % 2019))

Submission status: Wrong Answer

Solution code:
def RemainderMinimization2019():
	L, R = map(int, input().split())
	minMod = 2021 * 2021
	tmpL = L % 2019
	tmpR = R % 2019
	if tmpL == 0 or tmpR == 0:
		minMod = 0
		print(0)
		return
		
	for i in range(tmpL, tmpR):
		for j in range(i + 1, tmpR + 1):
			if minMod == 0:
				break
			tmp = (i * j) % 2019
			# print(i, j, tmp)
			if minMod > tmp:
				minMod = tmp
	print(minMod)
RemainderMinimization2019()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
L,R=map(int,input().split())
mod=2019
ans=[]
if R-L>2017:
    print(0)
elif L%mod>R%mod:
    print(0)
else:
    if R//673!=L//673:
        ans.append((L*(L+1)%mod))
        ans.append((((R//673)*673)*((R//673)*673-1))%mod)
        if R%673!=0:
            ans.append((((R//673)*673)*((R//673)*673+1))%mod)
        if R//673!=L//673+1:
            ans.append((((L//673+1)*673)*((L//673+1)*673-1))%mod)
            ans.append((((L//673+1)*673)*((L//673+1)*673+1))%mod)
        print(min(ans))
    else:
        print(L*(L+1)%mod)

Submission status: Wrong Answer

Solution code:
L,R=map(int, input().split())
m = 2020
for i in range(L,R):
    for j in range(L,R):
        if i == j:
            continue
        if i*j%2019 < m:
            m = i*j%2019
        if m == 0:
            break
    if m == 0:
        break
print(m)

Submission status: Wrong Answer

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


def main():
    l, r = map(int, input().split())
    l %= 2019
    r %= 2019
    min_value = min(l, r)
    print(min_value * (min_value + 1))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
L,R=map(int,input().split())
mod=2019
ans=[]
if R-L>2017:
    print(0)
elif L%mod>R%mod:
    print(0)
else:
    if R//673!=L//673:
        ans.append((L*(L+1)%mod))
        ans.append((((R//673)*673)*((R//673)*673-1))%mod)
        if R%673!=0:
            ans.append((((R//673)*613)*((R//673)*673+1))%mod)
        if R//673!=L//673+1:
            ans.append((((L//673+1)*673)*((L//673+1)*673-1))%mod)
            ans.append((((L//673+1)*673)*((L//673+1)*673+1))%mod)
        print(min(ans))
    else:
        print(L*(L+1)%mod)

Submission status: Wrong Answer

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

l = L // mod
r = R // mod

if l != r:
    print(0)
else:
    l_ = L % mod
    r_ = R % mod
    ans = 2019
    for i in range(l_, r_):
        for j in range(i+1, r_+1):
            a = i * j % mod
            ans = min(ans, a)
            if ans == 1:
                break
        if ans == 1:
            break
    print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
L,R=map(int,input().split())
mod=2019
ans=[]
if R-L>2017:
    print(0)
elif L%mod>R%mod:
    print(0)
else:
    if R//673!=L//673:
        ans.append((L*(L+1)%mod))
        ans.append((((R//673)*673)*((R//673)*673-1))%mod)
        if R%673!=0:
            ans.append((((R//673)*673)*((R//673)*673+1))%mod)
        if R//673!=L//673+1:
            ans.append((((L//673)*673)*((L//673)*673-1))%mod)
            ans.append((((L//673)*673)*((L//673)*673+1))%mod)
        print(min(ans))
    else:
        print(L*(L+1)%mod)

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
ans = 10**20

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

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
ans = 10**20

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

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
ans = 10**20

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

print(ans)

Submission status: Wrong Answer

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

diff = R - L

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

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

Submission status: Wrong Answer

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

L_quo = int((L - L % 2019) / 2019)
R_quo = int((R - R % 2019) / 2019)

if L_quo != R_quo:
    print(0)
else:
    L_rem = L % 2019
    R_rem = R % 2019
    for i in range(L_rem, R_rem):
        for j in range(i + 1, R_rem + 1):
            a = (i * j) % 2019
            ans = min(ans, a)

print(ans)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
L, R = map(int,input().split())
l , r = L//2019, R//2019
if R - L >= 2019:
    print(0)
elif R-L == 1:
    print(R*L%2019)
else:
    flag=0
    Amari=[]
    for i in range(L,R-1):
        amari = i % 2019
        if i %3 == 0:
            flag = True
        Amari.append(amari)
    if 673 in Amari and flag:
        print(0)
    else:
        print(min(Amari)*(min(Amari)+1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
L, R = map(int,input().split())
l , r = L//2019, R//2019
if R - L >= 2019:
    print(0)
else:
    flag=0
    Amari=[]
    for i in range(R-1):
        for j in range(i+1,L+1):
            amari = (i*j) % 2019
            Amari.append(amari)
    print(min(Amari))

Submission status: Wrong Answer

Solution code:
L, R = map(int,input().split())
l , r = L//2019, R//2019
if R - L >= 2019:
    print(0)
else:
    flag=0
    Amari=[]
    for i in range(L,R+1):
        amari = i % 2019
        if i %3 == 0:
            flag = True
        Amari.append(amari)
    if 673 in Amari and flag:
        print(0)
    else:
        print(min(Amari)*(min(Amari)+1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
L, R = map(lambda x:int(x)%2019, input().split())
x = min(L, R)
if x == 0:
    print(0)
else:
    print((x*(x+1))%2019)

Submission status: Wrong Answer

Solution code:
L, R = map(lambda x:int(x)%2019, input().split())
x = min(L, R)
if x == 0:
    print(0)
else:
    print(x*(x+1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
L, R = map(lambda x:int(x)%2019, input().split())
x = min(L, R)
if x == 0:
    print(0)
else:
    print(x+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
L, R = map(int,input().split())
l , r = L//2019, R//2019
L = L % 2019
R = R % 2019
if L >= R or l + 1 < r :
    print(0)
else:
    print(L*(L+1))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
l,r=map(int,input().split())
ltor=[i%2019 for i in range(l,r+1)]
ltor.sort()
print((ltor[0]*ltor[1])%2019)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
print(min((((R - L) < 2020) * (R % 2019 > L % 2019)) * min(R * (R - 1) % 2019, L * (L + 1) % 2019), ((R % 2019 < 101) or (L % 2019 > 20)) * 2019 + 1))

Submission status: Wrong Answer

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

one = 2019
two = 2019
three = 2019
for i in range(l, r+1):
  if i % 2019 < two:
    if i % 2019 < one:
      one = i % 2019
      a = i
    else:
      two = i % 2019
      b = i

print((a*b) % 2019)

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
print(min((((R - L) < 2019)) * min(R * (R - 1) % 2019, L * (L + 1) % 2019), ((R % 2019 < 101) or (L % 2019 > 20)) * 2019 + 1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

def solve():
    input = sys.stdin.readline
    L, R = map(int, input().split())
    if R - L >= 2018: print(0)
    elif R % 2019 < L % 2019: print(0)
    else:
        print((L * (L + 1)) % 2019)
    
    return 0

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
import sys

def solve():
    input = sys.stdin.readline
    L, R = map(int, input().split())
    if R - L >= 2018: print(0)
    elif R % 2019 < L % 2019: print(0)
    else:
        minmod = L % 2019
        print(minmod * (minmod + 1))
    
    return 0

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:


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

l, r = l % 2019, r % 2019

mod = 2018

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

Submission status: Wrong Answer

Solution code:
args = input().split()
l = int(args[0])
r = int(args[1])

ans = 0
if r - l < 2019:
    left = l % 2019
    if 2018 - left >= r - l:
        right = left + r - l
        ans = 2019
        for i in range(left, right + 1):
            for j in range(i + 1, right + 1):
                tmp = i * j % 2019
                if ans > tmp:
                    ans = tmp
                    print(str(i) + ", " + str(j))
                    
        
        
print(ans)

Submission status: Wrong Answer

Solution code:

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

if l > r:
    l, r = r, l

l, r = l % 2019, r % 2019

mod = 2020

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

Submission status: Wrong Answer

Solution code:
args = input().split()
l = int(args[0])
r = int(args[1])

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

Submission status: Wrong Answer

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

if l > r:
    l, r = r, l

mod = 2020

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

print(mod)

Submission status: Wrong Answer

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

if l > r:
    l, r = r, l

mod = 2020

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

print(mod)

Submission status: Wrong Answer

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

if l > r:
    l, r = r, l

mod = 2020

for i in range(l, r+1):
    for j in range(i, r):
        tmp = i * j // 2019
        if tmp < mod:
            mod = tmp

print(tmp)

Submission status: Wrong Answer

Solution code:
from sys import stdin
import numpy as np

L, R = [int(x) for x in stdin.readline().rstrip().split()]
MOD = 2019
L2019 = L//MOD
R2019 = R//MOD
LMOD = L%MOD
RMOD = R%MOD

if L2019 == R2019:
  print(LMOD*(LMOD+1))
else:
  print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

min_mod = 10 ** 12
for r in range(L + 1, min(L + 2019, R) + 1):
	min_mod = min(min_mod, (L * r) % 2019)
print(min_mod)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

f = 0

ans = 2020
if R-L > 2019:
    f = 1

if f==1:
    for i in range(L,L+2019):
        for j in range(i+1,2020):
            rem = (i*j)%2019
            if ans > rem:
                ans = rem

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

print(ans)

Submission status: Wrong Answer

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

Lw=L//2019
Rw=R//2019

if Lw < Rw :
    print(0)
else:
    print(L*(L+1) % 2019)

Submission status: Wrong Answer

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

f = 0

ans = 2020
if R-L > 2019:
    f = 1

if f==1:
    for i in range(L,L+2019):
        for j in range(i+1,2019):
            rem = (i*j)%2019
            if ans > rem:
                ans = rem

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

D = []

for i in range(L,R+1):
    D.append(i%2019)
    if i%2019==1 and len(D)>=2:
        break
        
D = sorted(D)
print(D[0]*D[1])

Submission status: Wrong Answer

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

D = []

for i in range(L,R+1):
    D.append(i%2019)
    if 1 in D and len(D)>=2:
        break
        
D = sorted(D)
print(D[0]*D[1])