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:
from __future__ import print_function

import sys
input = sys.stdin.readline

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# import math
# import string
# import fractions
# from fractions import Fraction
# from fractions import gcd

# def lcm(n,m):
#     return int(n*m/gcd(n,m))

# import re
# import array
# import copy
# import functools
# import operator

# import collections
# import itertools
# import bisect
# import heapq


# from heapq import heappush
# from heapq import heappop
# from heapq import heappushpop
# from heapq import heapify
# from heapq import heapreplace

# from queue import PriorityQueue as pq

# def reduce(p, q):
#     common = fractions.gcd(p, q)
#     return (p//common , q//common )
# # from itertools import accumulate
# # from collections import deque

# from operator import mul
# from functools import reduce

# def combinations_count(n, r):
#     r = min(r, n - r)
#     numer = reduce(mul, range(n, n - r, -1), 1)
#     denom = reduce(mul, range(1, r + 1), 1)
#     return numer // denom

# import random

# def round_lower(n, m_modulo):
#     n % modulo
#     return


def crange(l,r):
    return range(l,r+1)
        
        
def main():
    l,r = map(int, input().strip().split())
    l=l % 2019
    r = 2018 if r > ((l//2018)+1)*2019 else r % 2019

    ans=sys.maxsize
    for i in crange(l,r):
        for j in crange(i+1,r):
            ans=i*j%2019
    print(ans)
        
    return

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
L,R = map(int,input().split())
sa = R - L
ans = 220
if sa > 673:
	print("0")
else:
	for i in range (L,R):
		for j in range (i+1,R+1):
			tmp = (i * j) % 2019
			if ans > tmp:
				ans = tmp
	print(ans)

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
L = L%2019
R = R%2019
can = []
if R - L >= 2019:
    can = list(range(2019))
elif L < R:
    can = list(range(L, R+1))
elif L==R:
    print(L%2019)
    exit(0)
else:
    can = list(range(L, 2019))+list(range(0, R+1))

ans = float('inf')
for i in range(len(can)-1):
    for j in range(i+1, len(can)):
        tmp = can[i]*can[j]%2019
        if ans >= tmp:
            ans = tmp
        if ans==0:
            print(0)
            exit(0)
ans = max(ans, 0)
print(ans%2019)

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
L = L%2019
R = R%2019
can = []
if R - L > 2019:
    can = list(range(2019))
elif L < R:
    can = list(range(L, R+1))
elif L==R:
    print(L%2019)
    exit(0)
else:
    can = list(range(L, 2019))+list(range(0, R+1))

ans = float('inf')
for i in range(len(can)-1):
    for j in range(i+1, len(can)):
        tmp = can[i]*can[j]%2019
        if ans >= tmp:
            ans = tmp
        if ans==0:
            print(0)
            exit(0)
ans = max(ans, 0)
print(ans%2019)

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
L = L%2019
R = R%2019
can = []
if L < R:
    can = list(range(L, R+1))
elif L==R:
    print(L%2019)
    exit(0)
else:
    can = list(range(L, 2019))+list(range(0, R+1))

ans = float('inf')
for i in range(len(can)-1):
    for j in range(i+1, len(can)):
        tmp = can[i]*can[j]%2019
        if ans >= tmp:
            ans = tmp
        if ans==0:
            print(0)
            exit(0)
ans = max(ans, 0)
print(ans%2019)

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
L = L%2019
R = R%2019
can = []
if L < R:
    can = list(range(L, R+1))
elif L==R:
    print(L%2019)
    exit(0)
else:
    can = list(range(L, 2020))+list(range(0, R+1))

ans = float('inf')
for i in range(len(can)-1):
    for j in range(i+1, len(can)):
        tmp = can[i]*can[j]%2019
        if ans >= tmp:
            ans = tmp
        if ans==0:
            print(0)
            exit(0)
ans = max(ans, 0)
print(ans%2019)

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
L = L%2019
R = R%2019
can = []
if L < R:
    can = list(range(L, R+1))
elif L==R:
    print(L%2019)
    exit(0)
else:
    can = list(range(L, 2020))+list(range(0, R+1))

ans = float('inf')
for i in range(len(can)-1):
    for j in range(i+1, len(can)):
        tmp = can[i]*can[j]%2019
        if ans >= tmp:
            ans = tmp
        if ans==0:
            print(0)
            exit(0)
print(max(ans, 0))

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
L = L%2019
R = R%2019
can = []
if L < R:
    can = list(range(L, R+1))
elif L==R:
    print(L%2019)
    exit(0)
else:
    can = list(range(L, 2020))+list(range(0, R+1))

ans = float('inf')
for i in range(len(can)-1):
    for j in range(i+1, len(can)):
        tmp = can[i]*can[j]%2019
        if ans >= tmp:
            ans = tmp
        if ans==0:
            print(0)
            exit(0)
print(ans)

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
L = L%2019
R = R%2019
can = []
if L < R:
    can = list(range(L, R+1))
elif L==R:
    print(L%2019)
    exit(0)
else:
    can = list(range(L, 2020))+list(range(0, R+1))

ans = float('inf')
for i in range(len(can)-1):
    for j in range(i+1, len(can)):
        tmp = can[i]*can[j]%2019
        if ans > tmp:
            ans = tmp
print(ans)

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
L = L%2019
R = R%2019
can = []
if L <= R:
    can = list(range(L, R+1))
else:
    can = list(range(L, 2020))+list(range(0, R+1))

ans = float('inf')
for i in range(len(can)-1):
    for j in range(i+1, len(can)):
        tmp = can[i]*can[j]%2019
        if ans > tmp:
            ans = tmp
print(ans)

Submission status: Wrong Answer

Solution code:
import sys

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

MOD = 2019

L %= MOD
R %= MOD

if R - L > 1000:
    print(0)
    sys.exit()

ans = 2018
for i in range(L, R):
    for j in range(i + 1, R + 1):
        if ans > (i * j) % MOD:
            ans = (i * j) % MOD
print(ans)

Submission status: Wrong Answer

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

MOD = 2019

L %= MOD
R %= MOD

ans = 2018
for i in range(L, R):
    for j in range(i + 1, R + 1):
        if ans > (i * j) % MOD:
            ans = (i * j) % MOD
print(ans)

Submission status: Wrong Answer

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

MOD = 2019

L %= MOD
R %= MOD

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

Submission status: Wrong Answer

Solution code:
#ABC-133-C
L, R = map(int, input().split())
ans = 10 ** 10

for i in range(L, R+1):
    if i % 2019 == 0:
        ans = 0
        break

if ans != 0:
    ans = L * (L + 1) % 2019

print(ans)

Submission status: Wrong Answer

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

if r - l >= 2018:
    print(0)
elif r % 2019 == 0 or l % 2019 == 0:
    print(0)
else:
    if r // 2019 != l // 2019:
        print(0)
    else:
        i = l
        j = l + 1
        ans = i*j % 2019
        print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

mod_i = i % 2019
mod_j = j % 2019

if mod_j - mod_i == 1:
    print(mod_j * mod_i % 2019)
else:
    ans = 2019
    for k in range(mod_i + 1, j-i + 1):
        if mod_i * k < ans:
            ans = mod_i * k
    print(ans)

Submission status: Wrong Answer

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

mod_i = i % 2019
mod_j = j % 2019

if mod_j - mod_i == 1:
    print(mod_j * mod_i % 2019)
else:
    ans = j
    for k in range(mod_i + 1, j-i + 1):
        if mod_i * k < ans:
            ans = mod_i * k
    print(ans)

Submission status: Wrong Answer

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

ans = 0

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

print(ans)

Submission status: Wrong Answer

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

ans = i % 2019 * (i % 2019 + 1)

print(ans)

Submission status: Wrong Answer

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

ans = i // 2019 * (i // 2019 + 1)

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if r-l >= 2019:
    ans = 0
else:
    ans = 2018
    for i in range(r-1):
        for j in range(i+1,r-l+1):
            mod = ((i+1)*(j+1))%2019
            if ans > mod:
                ans = mod

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
import copy

def main():
    l, r = map(int, input().split())
    
    ans_tmp = 2019
    if r-l >= 2019:
        ans_tmp = 0
    else:
        for j in range(r-l):
            for k in range(r-l-1):
                ans = ((l+j)*(l+(k+1)))% 2019
                if ans == 0:
                    ans_tmp = 0
                    break
                elif ans < ans_tmp:
                    ans_tmp = ans
                
        
    print(ans_tmp)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np

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

if R - L >= 2019:
    ans = 0
else:
    A = np.sort(np.arange(L, R + 1) % 2019)
    ans = (A[0] * A[1]) % 2019

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

if R - L >= 2019:
    ans = 0
else:
    A = np.arange(L, R + 1)
    A = np.sort(A % 2019)
    ans = A[0] * A[1]

print(ans % 2019)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

if L - R >= 2019:
    ans = 0
else:
    a = 2019
    b = 2019
    for i in range(R, L - 1, -1):
        c = i % 2019
        if c < b:
            if c < a:
                a, b = c, a
            else:
                b = c

    ans = (a * b) % 2019

print(ans)

Submission status: Wrong Answer

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

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

    ans = (a * b) % 2019

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
import copy

def main():
    l, r = map(int, input().split())
    
    l_tmp = l//2019
    l_ = l-2019*l_tmp
    r_tmp = r//2019
    r_ = r-2019*r_tmp

    if l_ < r_:
        r_ = l_+1
    else:
        l_ = r_-1
    
    ans = l_*r_
    
    print(ans%2019)
    

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
L,R=map(int, input().split())
#2019=3*673

mod=2019
if L//mod != R//mod:
    print(0)
else:
    flg3=0
    flg673=0
    for i in range(L,R+1):
        if i%673==0:
            flg673=1
            break
    for i in range(L,R+1):
        if i%3==0:
            flg3=1
            break
    if flg3==flg673==1:
        print(0)
        
    elif L%mod<R%mod:
        print((L*(L+1))%mod)
    else:
        print((R*(R-1))%mod)

Submission status: Wrong Answer

Solution code:
# 22:28
l,r = map(int,input().split())
if r-l > 2019:
    print(0)
    exit(0)
m = (l*(l+1))%2019
for i in range(l,r):
    for j in range(l+i,r+1):
        if (i*j)%2019 < m:
            m = (i*j)%2019
print(m)

Submission status: Wrong Answer

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

mod=2019
if L//mod != R//mod:
    print(0)
elif L//3 != R//3 and L//673 != R//673:
    print(0)
else:
    if L%mod<R%mod:
        print((L*(L+1))%mod)
    else:
        print((R*(R-1))%mod)

Submission status: Wrong Answer

Solution code:
# 22:28
l,r = map(int,input().split())
m = (l*(l+1))%2019
for i in range(l,r):
    if m == 0:
        print(m)
        exit(0)
    for j in range(l+i,r+1):
        if (i*j)%2019 < m:
            m = (i*j)%2019
print(m)

Submission status: Wrong Answer

Solution code:
# 22:28
l,r = map(int,input().split())
if r//2019 - l//2019 > 0:
    print(0)
    exit(0)
m = (l*(l+1))%2019
for i in range(l,r):
    for j in range(l+i,r+1):
        if (i*j)%2019 < m:
            m = (i*j)%2019
print(m)

Submission status: Wrong Answer

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

mod=2019
if L//mod != R//mod:
    print(0)
elif L%3 == 0 and R%673==0:
    print(0)
elif L%673==0 and R%3==0:
    print(0)
else:
    if L%mod<R%mod:
        print((L*(L+1))%mod)
    else:
        print((R*(R-1))%mod)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

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

ans = 2019

if L+2019<R:
    print(0)
else:
    L %= 2019
    R %= 2019
    if L>R:
        tmp=R
        R=L
        L=tmp
    for l in range(L, R):
        for r in range(l + 1, R):
            tmp = (l * r) % 2019
            # tmp = ((l%2019) * (r%2019)) % 2019
            ans = min(ans, tmp)
            if ans == 0:
                break
    print(ans)

Submission status: Wrong Answer

Solution code:

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

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

Submission status: Wrong Answer

Solution code:
def calculate(l,r):
    K = 2019

    min = r*r

    if r > K * 2:
        r = K * 2

    for i in range(l,r+1):
        for j in range(i+1,r+1):
            ret = (i*j) % K
            if ret < min:
                min = ret

    return min

S = input().split()

L = int(S[0])
R = int(S[1])

print(calculate(L,R))

Submission status: Wrong Answer

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

min = 2 * 10 ** 9

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

        for j in range(i + 1, r):
            sub = (i * j) % 2019
            print(j)
            if (min > sub):
                min = sub
            if (min == 1):
                break
            if (j - i >= 2019):
                break
        if (min == 1):
            break
        elif (j - i >= 2019):
            break

    print(min)

Submission status: Wrong Answer

Solution code:
l,r = map(int, input().split())
import sys
if r - l == 1:
    print((l*r)%2019)
    sys.exit()
if l%2019 == 0 or r%2019 == 0:
    print(0)
    sys.exit()
div, mod = divmod(l, 2019)
if (div+1)*2019 <= r:
    print(0)
else:
    print((l*(l+1))%2019)

Submission status: Wrong Answer

Solution code:
l,r = map(int, input().split())
import sys
if r - l == 1:
    print((l*r)%2019)
    sys.exit()
if l%2019 == 0 or r%2019 == 0:
    print(0)
    sys.exit()
div, mod = divmod(l, 2019)
if (div+1)*2019 + mod <= r:
    print(0)
else:
    print((l*(l+1))%2019)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

A=[]

for i in range(R-L+1):
    A.append((i+L)%2019)
B=sorted(A)
print(B[0]*B[1])

Submission status: Wrong Answer

Solution code:
def main():
    lr = list(map(int, input().split()))
    divmod_lr = [divmod(x, 2019) for x in lr]

    if divmod_lr[0][1] == 0 or divmod_lr[1][1] == 0 or divmod_lr[0][0] != divmod_lr[1][0]:
        ans = 0
    else:
        if divmod_lr[0][1] < divmod_lr[1][1]:
            temp = divmod_lr[0][1] * (divmod_lr[0][1] + 1)
        else:
            temp = divmod_lr[1][1] * (divmod_lr[1][1] + 1)
        ans = temp % 2019

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    lr = list(map(int, input().split()))
    divmod_lr = [divmod(x, 2019) for x in lr]

    if divmod_lr[0][1] > divmod_lr[1][1] or divmod_lr[0][1] == 0 or divmod_lr[1][1] == 0:
        ans = 0
    else:
        temp = divmod_lr[0][1] * (divmod_lr[0][1] + 1)
        ans = temp % 2019

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
L,R = map(int, input().split())
if R - L >= 2018:
    print(0)
    exit()
else:
    ans = 2019**2
    for i in (L, R):
        for j in (i+1, R+1):
            #i %= 2019
            #j %= 2019
            k = (i*j) % 2019
            ans = min(ans, k)
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import heapq
L,R = map(int, input().split())
if R - L >= 672:
    print(0)
    exit()
else:
    hq3 = []
    hq673 = []
    hq2019 = []
    for i in range(L, R+1):
        heapq.heappush(hq2019, i%2019)
        heapq.heappush(hq673, i%673)
        heapq.heappush(hq3, i%3)
    a = heapq.heappop(hq2019)
    b = heapq.heappop(hq673)
    c = heapq.heappop(hq3)
    if a == 0:
        print(0)
        exit()
    elif b == 0 and c == 0:
        print(0)
        exit()
    else:
        print(heapq.heappop(hq2019) * a % 2019)

Submission status: Wrong Answer

Solution code:
import heapq
L,R = map(int, input().split())
if R - L >= 2018:
    print(0)
    exit()
else:
    hq = []
    for i in range(L, R+1):
        i = i % 2019
        heapq.heappush(hq, i)
    print(heapq.heappop(hq) * heapq.heappop(hq) % 2019)

Submission status: Wrong Answer

Solution code:
import heapq
L,R = map(int, input().split())
if R - L >= 2018:
    print(0)
    exit()
hq = []
for i in range(L, R+1):
    i = i % 2019
    heapq.heappush(hq, i)
print(heapq.heappop(hq) * heapq.heappop(hq) % 2019)

Submission status: Wrong Answer

Solution code:
import heapq
L,R = map(int, input().split())
if R - L >= 2018:
    print(0)
    exit()
hq = []
for i in range(L, R+1):
    i = i % 2019
    heapq.heappush(hq, i)
print(heapq.heappop(hq) * heapq.heappop(hq))

Submission status: Wrong Answer

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

ANS = 2020
if R - L <= 2019:
  for i in range(L,R):
    for j in range(i,R):
    	ANS = min(ANS, (i * j) % 2019)
else:
  ANS = 0
print(ANS)

Submission status: Wrong Answer

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

ANS = 2020
if R - L <= 2019:
  for i in range(L,R):
    ANS = min(ANS, (i * (i+1)) % 2019)
else:
  ANS = 0
print(ANS)

Submission status: Wrong Answer

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

ANS = -1
if L / 2019 > 1:
  L2 = L // 2019
  R2 = R // 2019
  if L2 == R2:
    ANS = (L * (L + 1)) % 2019
  else:
    ANS = 0
else:
  ANS = (L % 2019) * ((L + 1) % 2019)
print(ANS)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ANS = -1
if L / 2019 > 1:
  L2 = L // 2019
  R2 = R // 2019
  if L2 == R2:
    ANS = (L2 % 2019) * ((L2 + 1) % 2019)
  else:
    ANS = 0
else:
  ANS = (L % 2019) * ((L + 1) % 2019)
print(ANS)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

L, R = MAP()

if R-L>2019:
	print(0)
else:
	min = float('INF')
	l = 0
	r = 0
	for i in range(L, R+1):
		for j in range(i, R+1):
			if i==j: continue
			mo = (i*j) % 2019
			if mo < min:
				min = mo
				l = i
				r = j
print(min)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

L, R = MAP()

if R-L>2019:
	print(0)
else:
	min = float('INF')
	l = 0
	r = 0
	for i in range(L, R):
		mo = (i*(i+1)) % 2019
		if mo < min:
			min = mo
			l = i
			r = i+1
print(min)

Submission status: Wrong Answer

Solution code:
import sys
a,b=map(int,input().split())
l=[x for x in range(a,b+1)]
for i in l:
  if(i%2019==0):
    print(0)
    sys.exit()
print ((l[0]*l[1])%2019)

Submission status: Wrong Answer

Solution code:
l,r=map(int,input().split())
g = list(set([i%2019 for i in range(l,r+1)]))
fa=2020
for i in range(len(g)-1):
    for j in range(1,len(g)):
        if g[i]*g[j]%2019<fa:
            fa = g[i]*g[j]%2019
print(fa)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

p = bisect.bisect_left(range(l, r+1), (r//2019)*2019)
a = l+p
b = a+1
if a == r:
    print(((a-1)*(b-1))%2019)
else:
    print((a*b)%2019)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
l=list(map(int,input().split()))
a=l[0]*(l[0]+1)
while(a>2019):
  print(a)
  a=a//2019+1
print(a%2019)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
l,r=map(int,input().split())
#if r-l>2018:
#  print(0)
#  exit()
x=sorted(i%2019 for i in range(l,r+1))
print(x[0]*x[1])

Submission status: Wrong Answer

Solution code:
l,r=map(int,input().split())
if r-l>2018:
  print(0)
  exit()
x=sorted(n%2019 for n in range(l,r+1))
print(x[0]*x[1])

Submission status: Wrong Answer

Solution code:
l,r=map(int,input().split())
if r-l>2018:
  print(1)
  exit()
x=sorted(range(l%2019,r%2019+1))
print(x[0]*x[1])

Submission status: Wrong Answer

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

num_list = []
if R-L >= 2019:
  num_list = [int(i) for i in range(0,2)]
else:
  num_list = [int(i)%2019 for i in range(L,R+1)]

num_list.sort()
ans = (num_list[0] * num_list[1])%2019

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

num_list = [int(i)%2019 for i in range(L,R+1)]

num_list.sort()
ans = num_list[0] * num_list[1]
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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