Problem:


Score : 300 points

Problem Statement

You are given two non-negative integers L and R.
We will choose two integers i and j such that L \leq i < j \leq R.
Find the minimum possible value of (i \times j) \mbox{ mod } 2019.

Constraints

All values in input are integers.

0 \leq L < R \leq 2 \times 10^9

Input

Input is given from Standard Input in the following format:

L R

Output

Print the minimum possible value of (i \times j) \mbox{ mod } 2019 when i and j are chosen under the given condition.

Sample Input 1

2020 2040

Sample Output 1

2

When (i, j) = (2020, 2021), (i \times j) \mbox{ mod } 2019  = 2.

Sample Input 2

4 5

Sample Output 2

20

We have only one choice: (i, j) = (4, 5).



Sample input:
2020 2040


Sample output:
2

Submission status: Wrong Answer

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

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

    for j in range(L, R+1):
        if j == ans:
            continue
        if (j % 2019) < minib:
            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())
mini = 2018
minib = 2018

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

    for j in range(L, R+1):
        if j == ans:
            continue
        if (j % 2019) < minib:
            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())
r2 = r+0
l%=2019
r%=2019
ans = 20000
if r2 >= r+2019:
  r += 2019
for i in range(l,r+1):
  for j in range(i+1,r+1):
    ans = min(i*j%2019,ans)
if ans == 20000:
  ans = 0
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

module = []
for i in range(L, R):
    for j in range(i+1, R+1):
        print("({} * {}) mod 2019 = {}".format(i, j, (i * j) % 2019))
        if (i * j) % 2019 == 0:
            print("0")
            exit()
        else:
            module.append((i * j) % 2019)

if not module:
    print("0")
else:
    print(min(module))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
l, r = map(int, input().split())
ans = 10 ** 5
for i in range(l, r):
    n = i * (i + 1) % 2019
    ans = min(ans, n)
    if n == 0:
        print(0)
        exit()
print(ans)

Submission status: Wrong Answer

Solution code:
l,r = map(int,input().split())
ans = 10**9
for i in range(l,r+1):
    n = i*(i+1)%2019
    ans = min(ans,n)
    if n ==0:
        print(0)
        exit()
print(ans)

Submission status: Wrong Answer

Solution code:
l,r = map(int,input().split())
 
L = l%2019
R = r%2019
ans = float('inf')
for i in range(L,R+1):
    for j in range(L,R+1):
        temp = (i*j)%2019
        if temp < ans and i != j:
            ans = temp
if l - r >= 2019:
  print(0)
else:
  print(ans)

Submission status: Wrong Answer

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

min = L * R % 2019
a = 0

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

print(min)

Submission status: Wrong Answer

Solution code:
L,R=map(int,input().split())
M=2019
import sys
for i in range(L,R):
    for j in range(i+1,R+1) :
        if (i*j)%2019 < M :
            M = (i*j)%2019
            if M == 0:
                sys.exit()
        print(M)

Submission status: Wrong Answer

Solution code:
L,R=map(int,input().split())
M=2019
import sys
for i in range(L,R):
    for j in range(i+1,R+1) :
        if (i*j)%2019 < M :     
            M = (i*j)%2019
            if M == 0:
                sys.exit()
            print(M)

Submission status: Wrong Answer

Solution code:
L,R=map(int,input().split())
M=2019
import sys
for i in range(L,R):
    for j in range(i+1,R+1) :
        if (i*j)%2019 < M :
            M = (i*j)%2019
            if M == 0:
                sys.exit()
print (M)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
L,R=map(int,input().split())
l=L//2019
ll=L%2019
r=R//2019
rr=R%2019
Ans=[2019]
if R-L>=2019:
  print(0)
else:
    for i in range(R,L+1):
      for j in range(R+1,L+1):
        Ans.append(i*j%2019)
print(min(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):
  mod_i = i % 2019
  for j in range(i +1,R +1):
    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())

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

Submission status: Wrong Answer

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

ans = 2018

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys
import math
import numpy as np
INF = 1000000000
MOD = 2019


def input():
    return sys.stdin.readline().rstrip()


def main():
    l, r = [int(e) for e in input().split()]
    ans = INF
    for i in range(l, min(l + MOD, r + 1)):
        for j in range(l + 1, min(l + MOD, r + 1)):
            ans = min(ans, ((i % MOD) * (j % MOD)) % MOD)
    print(ans)


main()

Submission status: Wrong Answer

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

ans = 2018

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys

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

remainder_list = []

if r - l >= 2019:
  print(0)
  sys.exit()
else :
  for x in range(l, r):
    remainder_list.append((l * (x + 1)) % 2019)

remainder_list.sort()
print(remainder_list[0])

Submission status: Wrong Answer

Solution code:
A = [int(x) for x in input().split()]
N = [i for i in range(A[0],A[1]+1) ]
N.sort()
print((N[0]*N[1])%2019)

Submission status: Wrong Answer

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

chk = 0
flg = 1
i = l
mod_min = 100000

while flg:
    for j in range(i+1,r+1):
        chk = (i*j)%2019
        if chk == 0:
            print(0)
            flg = 0
        elif chk < mod_min:
            mod_min = chk
    i += 1
    if i >= r-1:
        print(mod_min)
        flg = 0

Submission status: Wrong Answer

Solution code:
L,R=map(int,input().split())
l=L//2019
ll=L%2019
r=R//2019
rr=R%2019
if l<r or ll==0:
  print(0)
else:
  print(min ([i*i+1 for i in range(ll,rr+1)]))

Submission status: Wrong Answer

Solution code:
import sys, itertools, collections
sys.setrecursionlimit(10000)

read_ints = lambda: list(map(int, input().split()))
read_int  = lambda: int(input())

MOD = 2019

l, r = read_ints()
r = min(r + 1, l + MOD)

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

Submission status: Wrong Answer

Solution code:
L,R = map(int,input().split())
flag = True if L // 2019 < R // 2019 else False
L %= 2019
R %= 2019
mn = min(L,R) if not flag else 0
print((mn*(mn+1)) %1029)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# ABC133C - Remainder Minimization 2019
def main():
    L, R = list(map(int, input().rstrip().split()))
    MOD = 2019
    if (R // MOD) - (L // MOD) >= 1:  # L <= 2019n <= R
        print(0)
    else:
        print((L * (L + 1)) % MOD)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
l,r=map(int,input().split());s=range(l,r+1);print(+(r-l<2019)and min(i*j%2019for i in s for j in s))

Submission status: Wrong Answer

Solution code:
l, r = map(int, input().split())
if r-l>=2019:
    print("0")
elif r%2019==0 or l%2019==0:
    print("0")
else:
    min = 2019
    for i in range(l,r):
        for j in range(i+1,r+1):
            tmp = i*j%2019
            if min > tmp:
                min = tmp
            if min == 0:
                print("0")
                break
    print(min)

Submission status: Wrong Answer

Solution code:
from itertools import permutations
l, r = map(int,input().split())
a = []
for i in range(l,r+1):
    tmp = i%2019
    if tmp not in a:
        a.append(tmp)
print (a)
perm = permutations(a,2)
min = 2019
for i in list(perm):
    tmp = i[0]*i[1]%2019
    if min > tmp:
        min = tmp
print(min)

Submission status: Wrong Answer

Solution code:
l, r = map(int,input().split())
amari = l - 2019
t = (l*(l+1)) % 2019
a = []
a.append(t)
for i in range(1,r-l):
    tmp = a[i-1]+amari
    a.append(tmp)
    if t > abs(tmp):
        t = tmp
print (t)

Submission status: Wrong Answer

Solution code:
inf = 2019
L, R = map(int, input().split())
ans = 0
df = R - L
if df < 2019:
    L = L % inf
    R = L + df
    ans = 2019
    for i in range(L, R):
        for j in range(i, R):
            tmp = int(((i + 1) * j) % inf)
            ans = min(ans, tmp)

print(ans)

Submission status: Wrong Answer

Solution code:
inf = 2019
L, R = map(int, input().split())
ans = 2018

for i in range(L, L + 2019):
    if i >= R:
        break
    for j in range(i + 1, R):
        tmp = int((i * j) % inf)
        ans = min(ans, tmp)
    if ans == 0:
        break

print(ans)

Submission status: Wrong Answer

Solution code:
inf = 2019
L, R = map(int, input().split())
ans = 2018

for i in range(L, R):
    for j in range(i + 1, R + 1):
        tmp = int((i%inf * j%inf) % inf)
        ans = min(ans, tmp)
        break
    if ans == 0:
        break

print(ans)

Submission status: Wrong Answer

Solution code:
inf = 2019
L, R = map(int, input().split())
ans = 2018

for i in range(L, R):
    for j in range(i + 1, R + 1):
        tmp = int((i * j) % inf)
        ans = min(ans, tmp)
        break
    if ans == 0:
        break

print(ans)

Submission status: Wrong Answer

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

for i in range(L, R):
    for j in range(i + 1, R + 1):
        tmp = int((i * j) % inf)
        ans = min(ans, tmp)
        break
    if ans == 0:
        break

print(ans)

Submission status: Wrong Answer

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

for i in range(L, R):
    for j in range(i + 1, R):
        tmp = int((i + 1) * j) % inf
        ans = min(ans, tmp)
        break
    if ans == 0:
        break

print(ans)

Submission status: Wrong Answer

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

for i in range(L, R):
    for j in range(i, R):
        tmp = int((i + 1) * j) % inf
        ans = min(ans, tmp)
        break
    if ans == 0:
        break

print(ans)

Submission status: Wrong Answer

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

for i in range(L, L + 2019):
    if i >= R:
        break
    for j in range(i, R):
        tmp = int((i + 1) * j) % inf
        ans = min(ans, tmp)
        break
    if ans == 0:
        break

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

if l <= 2019 and r >= 2019:
    print(0)
elif l > 2019:
    print(2)
elif r < 2019:
    print(l * r)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
MOD = 2019

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

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

Submission status: Wrong Answer

Solution code:
MOD = 2019

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
l,r = map(int,input().split())
r = min(r,l+673)
ans = 2018

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

Submission status: Wrong Answer

Solution code:
l,r = map(int,input().split())
r = min(r,l+678)
ans = 2018

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

Submission status: Wrong Answer

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

ans = 2018
R = min(R, L+2020)
for i in range(L, R+1):
    f = False
    for j in range(i+1, R+1):
        m = (i*j)%2019
        if  m  == 0:
            print(0)
            f = True
            break     
        ans = min(ans, m)
    if f:
        break
print(ans)

Submission status: Wrong Answer

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

ans = 2018
R = min(R, L+2020)
for i in range(L, R+1):
    f = False
    print(i, L, R)
    for j in range(i+1, R+1):
        print(i, j, L, R)
        m = (i*j)%2019
        if  m  == 0:
            print(0)
            f = True
            break     
        ans = min(ans, m)
    if f:
        break
print(ans)

Submission status: Wrong Answer

Solution code:
#ABC133-C
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
l,r=IL()
ans=2019
for i in range(l,min(l+2019,r)-1):
    for j in range(i+1,min(l+2019,r)):
        ans=min(ans,i*j%2019)
print(ans)

Submission status: Wrong Answer

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

ans = 2018
R = min(R, L+4038)
for i in range(L, R):
    f = False
    for j in range(i+1, R+1):
        m = (i*j)%2019
        if  m  == 0:
            print(0)
            f = True
            break     
        ans = min(ans, m)
    if f:
        break
print(ans)

Submission status: Wrong Answer

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

ans = 2019
R = min(R, L+4038)
for i in range(L, R):
    f = False
    for j in range(i+1, R+1):
        m = (i*j)%2019
        if  m  == 0:
            print(0)
            f = True
            break     
        ans = min(ans, m)
    if f:
        break
print(ans)

Submission status: Wrong Answer

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

ans = 2019
R = min(R, L+4038)
for i in range(L, R):
    f = False
    for j in range(i, R):
        m = (i*j)%2019
        if  m  == 0:
            print(0)
            f = True
            break     
        ans = min(ans, m)
    if f:
        break
print(ans)

Submission status: Wrong Answer

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

ans = 2019
R = min(R, L+2019)
for i in range(L, R):
    f = False
    for j in range(i, R):
        m = (i*j)%2019
        if  m  == 0:
            print(0)
            break     
        ans = min(ans, m)
    if f:
        break
print(ans)

Submission status: Wrong Answer

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

ans = 2019
for i in range(L, R):
    f = False
    for j in range(i, R):
        if  ((i*j) % 2019) == 0:
            print(0)
            break
        ans = min(ans, (i*j)%2019)
    if f:
        break
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%673
    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 a==0:
      break
  print((min_d*min_d2)%2019)
  
main()

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline


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

    if r // 2019 >= 1:
        print(0)
    else:
        num = [i for i in range(l, min(r + 1, l + 2019))]
        min_ = 2019
        for i, n in enumerate(num):
            for j in num[i + 1 :]:
                min_ = min(n * j % 2019, min_)
        print(min_)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

P = 2019

R = min(R, L+10)

tmp = 2018
for i in range(L, R):
    for j in range(L+1, R+1):
        tmp = min((i*j)%P, tmp)
        
print(tmp)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

min_ = np.inf
for i in range(L, 4040):
    for j in range(i + 1, 4040 + 1):
        if (i * j) % 2019 <= min_:
            min_ = (i * j) % 2019
            if min_ == 0:
                print(min_)
                exit()

print(min_)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, D = map(int, input().split())

dif = D - N
mod_l = N % 2019

if dif >= (2019 - mod_l):
    print(0)
else:
    mod = mod_l * (mod_l+1)
    if mod >= 2019:
        mod = mod % 2019
    print(mod)

Submission status: Wrong Answer

Solution code:
l, r = map(int, input().split())
tmp = 2019*(l//2019)
l -= tmp
r -= tmp
if r >= 2019:
  print(0)
else:
  m = 9999999
  for i in range(l, r):
    for j in range(i, r+1):
      if m > i*j%2019:
        m = i*j%2019
  print(m)

Submission status: Wrong Answer

Solution code:
N, D = map(int, input().split())

dif = D - N
mod_l = N % 2019

if dif >= (2019 - mod_l):
    print('0')
else:
    mod = mod_l * (mod_l+1)
    if mod > 2019:
        mod = mod % 2019
    print(mod)

Submission status: Wrong Answer

Solution code:
L,R = map(int,input().split())
R = min(R,L+4038)
ans = 10**9
print(L)
print(R)
for r in range(L,R+1):
    for l in range(L,R+1):
        if r==l:
            continue
        ans=min(ans,(r*l)%2019)
print(ans)

Submission status: Wrong Answer

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

P = 2019

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

tmp = 2018
for i in range(L, R):
    for j in range(L+1, R+1):
        tmp = min((i*j)%P, tmp)
        
print(tmp)

Submission status: Wrong Answer

Solution code:
N, D = map(int, input().split())

dif = D - N
mod_l = N % 2019

if dif >= (2019 - mod_l):
    print('0')
else:
    print(mod_l * (mod_l+1))

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
import sys

L,R = map(int,input().split())
if R-L>673:
    print(0)
else:
    counter1 = 0
    counter2 = 0
    A =[]
    for i in range(R-L+1):
        n = (L+i)
        if n % 673 == 0:
            counter1 = 1
            if counter2 ==1:
                print(0)
                sys.exit()
        elif n % 3 == 0:
            counter2 = 1
            if counter1 == 1:
                print(0)
                sys.exit()
        A.append(n%2019)
    A.sort()
    print((A[0]*A[1])%2019)

Submission status: Wrong Answer

Solution code:
L,R = (int(i) for i in input().split()) 
r = min(R,R+4038)
m = 2018
for i in range(L,R-1):
  for j in range(i+1,R):
    x = (i*j)%2019
    m = min(m,x)
print(m)

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline


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

    if r // 2019 * 2019 >= 1:
        print(0)
    else:
        num = [i for i in range(l, min(r + 1, l + 2019))]
        min_ = 2019
        for i, n in enumerate(num):
            for j in num[i + 1 :]:
                min_ = min([n * j % 2019, min_])
        print(min_)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys

L,R = map(int,input().split())
if R-L>673:
    print(0)
else:
    counter1 = 0
    counter2 = 0
    A =[]
    for i in range(R-L+1):
        n = (L+i)
        if n % 673 == 0:
            counter1 += 1
            if counter2 ==1:
                print(0)
                sys.exit()
        elif n % 3 == 0:
            counter2 += 1
            if counter1 == 1:
                print(0)
                sys.exit()
        A.append(n%2019)
    A.sort()
    print((A[0]*A[1])%2019)

Submission status: Wrong Answer

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

res = []
for i in range(l, r + 1):
  res.append(i % 2019)

a=False
b=False
for num in res:
  if(num % 3 == 0):
    a = True
  if(num % 673 == 0):
    b = True     
if(a and b):
  print(0)
else:
  print((res[0] * res[1]) % 2019)

Submission status: Wrong Answer

Solution code:
import numpy as np
L,R = map(int, input().split())
if (L//2019!=R//2019) or L%2019==0 or R%2019==0:
  print(0)
else:
  l = L%2019
  r = R%2019
  ## l<r<2019
  a = []
  for i in range(r-l):
    for j in range(r-l-i):
      a.append((l+i)*(l+i+j+1))
  print(min(a))

Submission status: Wrong Answer

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

# n mod 2019 の答えは 0 ~ 2018 のいずれか
# それぞれのmodを取った積のmodでも同じ答えになる


def get_ans():
    # 差が2018以上なら積が0の組み合わせが存在する
    if R - L >= 2018:
        return 0

    # 総当たり
    ans = 2019
    for X in range(L, R):
        for Y in range(X + 1, R + 1):
            ans = min((ans, (X * Y) % 2019))
            if ans == 0:
                return 0
            if ans == 1:
                return 1

    return ans


print(get_ans())

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline


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

    if r // 2019 >= 1:
        print(0)
    else:
        l = l % 2019
        r = r % 2019
        num = [i for i in range(l, r + 1)]
        min_ = 2019
        for i, n in enumerate(num):
            for j in num[i + 1 :]:
                min_ = min([n * j % 2019, min_])
        print(min_)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

  a=False
  b=False
  for num in res:
    if(num % 3 == 0):
      a = True
    if(num % 673 == 0):
      b = True     
  if(a and b):
    print(0)
  else:
    print((res[0] * res[1]) % 2019)

Submission status: Wrong Answer

Solution code:
import numpy as np
L,R = map(int, input().split())
if (L//2019!=R//2019) or L%2019==0 or R%2019==0:
  print(0)
elif R-L==1:
  print((L*R)%2019)
else:
  l = L%2019
  r = R%2019
  ## l<r<2019
  a = []
  for i in range(r-l):
    for j in range(r-l-i):
      a.append((l+i)*(l+i+j+1))
  print(min(a))

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline


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

    if r // 2019 >= 1:
        print(0)
    else:
        print(1)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

r = min(r, 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())

r = min(r, 4038);
ans = 2018
for i in range(l, r + 1):
    for j in range(i + 1, r + 1):
        x = i * j % 2019
        ans = min(ans, x)

print(ans)

Submission status: Wrong Answer

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

result = 2019

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

print(result)

Submission status: Wrong Answer

Solution code:
L,R = [int(x) for x in input().split()]
 
min_ans = 10**18
R2 = R%2018
R = L+R2
for i in range(L,R):
    for j in range(i+1,R+1):
        ans = (i*j)%2019
        
        if ans < min_ans:
            min_ans = ans
        if min_ans == 0:
            break
print(min_ans)

Submission status: Wrong Answer

Solution code:
L,R = [int(x) for x in input().split()]
 
min_ans = 10**18
R2 = R%2019
R = L+R2
for i in range(L,R):
    for j in range(i+1,R+1):
        ans = (i*j)%2019
        
        if ans < min_ans:
            min_ans = ans
        if min_ans == 0:
            break
print(min_ans)

Submission status: Wrong Answer

Solution code:
L,R = [int(x) for x in input().split()]
 
min_ans = 10**18
R = R%2019
for i in range(L,R):
    for j in range(i+1,R+1):
        ans = (i*j)%2019
        
        if ans < min_ans:
            min_ans = ans
        if min_ans == 0:
            break
print(min_ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

    mod_min = 2019

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

    print(mod_min)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
L,R = [int(x) for x in input().split()]
 
L = L%2019
R = L%2019
 
min_ans = 10**18
for i in range(L,R):
    for j in range(i+1,R+1):
        ans = (i*j)%2019
        
        if ans < min_ans:
            min_ans = ans
        if min_ans == 0:
            break
print(min_ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
mod=2019
l,r=map(int,input().split())
d={}
for i in range(l,r+1):
    w=i%2019
    if w in d:
        d[w]+=1
    else:
        d[w]=1
ans=2020
for i in d:
    for j in d:
        if i!=j:
            ans=min(ans,i*j)
        elif i==j and d[i]>1:
            ans=min(ans,i*j)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

# n mod 2019 の答えは 0 ~ 2018 のいずれか
# それぞれのmodを取った積のmodでも同じ答えになる


def get_ans():
    # 差が2018以上なら積が0の組み合わせが存在する
    if R - L >= 2018:
        return 0

    # 総当たり
    ans = 2019
    for X in range(L, R):
        for Y in range(X + 1, R + 1):
            ans = min((ans, (X * Y) % 2019))
            if ans == 1:
                break
        if ans == 1:
            break

    return ans


print(get_ans())

Submission status: Wrong Answer

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