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

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


def get_ans():
    # mod後の最小値コンビを十分大きな値で初期化しておく
    nums = [2019, 2020]
    for n in range(L, R + 1):
        mod = n % 2019
        # 0が来た瞬間終了
        if mod == 0:
            return 0

        # 最小値コンビの内どっちかより小さいなら置き換える
        if nums[0] > n:
            nums[0] = n
        elif nums[1] > n:
            nums[1] = n

    # ループ終わったら最小値コンビの積のmodを取る
    return (nums[0] * nums[1]) % 2019


print(get_ans())

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

x = L // 2019
y = R // 2019

if x != y:
    print(0)
else:
    xx = math.sqrt(2019 * (L**2//2019+1))
    if (xx+1) <= R:
        l = int(xx)
        r = int(xx+1)
        print(l*r%2019)
    else:
        print(L*(L+1)%2019)

Submission status: Wrong Answer

Solution code:
parents = list(map(int,input().split(' ')))

a = parents[0] % 2019
if (2019-a)<=1010:
    a = (2019-a)
b = parents[1] % 2019
if (2019-b)<=1010:
    b = (2019-b)
diff = parents[1]-parents[0]
if (parents[0]%2019 + diff) >= 2019:
    print(0)
elif a==b:
    res = a*a % 2019
    if (2019-res)<=1010:
        res = (2019-res)
    print(res)
elif diff>=1009 and a<b:
    res = a*a % 2019
    if (2019-res)<=1010:
         res = (2019-res)
    print(res)
elif diff>=1009 and b<a:
    res = b*b % 2019
    if (2019-res)<=1010:
        res = (2019-res)
    print(res)
elif a<b:
    res = a*(a+1) % 2019
    if (2019-res)<=1010:
         res = (2019-res)
    print(res)
else:
    res = b*(b+1) % 2019
    if abs(2019-res)<=1010:
        res = abs(2019-res)
    print(res)

Submission status: Wrong Answer

Solution code:
L,R=map(int,input().split())
dif=R-L
if(dif>2019*2):
    dif=2019*2
l=L%2019
arr=[]
while(dif):
    arr.append(l)
    l+=1
    if(l==2019):
        l=0
    dif-=1
arr.sort()
if(len(arr)==1):
    arr.append(l)
min=2019
for i in range(len(arr)):
    for j in range(i+1,len(arr)):
        if min>(arr[i]*arr[j])%2019:
            min=(arr[i]*arr[j])%2019
print(min)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np


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

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

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


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


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

Submission status: Wrong Answer

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

for i in range(l, r + 1):
    if divmod(i, 2019)[1] == 0:
        print(0)
        exit()

print(divmod(l * (l + 1), 2019)[1])

Submission status: Wrong Answer

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

print((n*m) % 2019)

Submission status: Wrong Answer

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

l = L % 2019
r = R % 2019
if (l >= r):
  r += 2019

if (0 == l):
  print(0)
  exit()

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

Submission status: Wrong Answer

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

if L <= 2019 and 2019 <= R:
    ans = 0

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys
from itertools import combinations
L, R = map(int, input().split())
    
if R - L + (L % 2019) >= 2019:
    print(0)
    sys.exit()

else:
    tmp = R
    lis = list(range(L, R + 1))
    for item in list(combinations(lis, 2)):
        if tmp > (((item[0] % 2019) * item[1]) % 2019):
            tmp = ((item[0] % 2019) * item[1]) % 2019
            #print(item[0], item[1])
            #print(tmp)
print(tmp)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

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

if L == R:
    print((L * R) % 2019)

Submission status: Wrong Answer

Solution code:
import numpy as np

S=input()

tmp=S.split()

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

L_list=np.sort(np.array(range(L,R+1),dtype=np.int32)%2019)
#R_list=L_list.copy()

#print(R_list)

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

Submission status: Wrong Answer

Solution code:
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

a, b = readmi()
t = 0xFFFFFFFF
if a <= 2019:
    if a + 1 <= b:
        t = a * (a + 1) % 2019
    elif a - 1 >= 0:
        t = min(a * (a - 1) % 2019, t)
if b <= 2019:
    t = min(t,b * (b - 1) % 2019)
if b >= 2019:
    if a <= 2019 <= b:
        t = min(t, 2019 * (2018) % 2019)
    else:
        t = min(t, a * (a + 1) % 2019)
print(t)

Submission status: Wrong Answer

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

mod = []
if R-L<=2019**2:
    for i in range(L,R):
        for j in range(i+1,R):
            mod.append((i*j)%2019)

else:
    for i in range(L, L+2019**2):
        for j in range(i, L+2019**2+1):
            mod.append((i*j)%2019)


if len(mod)==0:
    print((L*R)%2019)
else:
    print(min(mod))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys;
import string;
sys.setrecursionlimit(20000) # 再起呼び出しの最大数をセット

import copy
import math
import itertools

from functools import lru_cache
#@lru_cache(maxsize = None)

PPP = 1000000007

# 整数の入力
#n = int(input())

# スペース区切りの整数の入力
#a = [int(x) for x in input().split()]
l, r = map(int, input().split())
#print("sp", n, k, file=sys.stderr)
#p, q, r = map(int, input().split())
#s = [int(x) for x in input().split()]
#t = [int(x) for x in input().split()]

# 改行区切りの整数の入力
#a = []
#for x in range(n):
#  a.append(int(input()))
#  a.append([int(x) for x in input().split()])
#p = [int(x) for x in input().split()]
#a.sort()
#print(l, file=sys.stderr)

# 文字列の入力
#s = input()

# 出力
#print("{} {}".format(a+b+c, s))
#a.sort()
#print(set(a), file=sys.stderr)
#print(len(set(a)))

#cache = dict()

import re
import fractions

def lcm(x, y):
  return (x * y) // fractions.gcd(x, y)
  
def count(c):
  r = b // c - (a - 1) // c;
  print(c, r, file=sys.stderr)
  return r

def doit(l, r):
  #print(l, r, file=sys.stderr)
  l = l % 2019
  r = r % 2019
  if r < l:
    r += 2019
  #  if r < l:
  #    r = r2
  #print(l, r, file=sys.stderr)

  res = 2019
  for x in range(l, r):
    for y in range(l + 1, r + 1):
      #print(x, y, file=sys.stderr)
      res = min(res, (x * y) % 2019)
      if res == 0:
        return 0
  return res % 2019

#print(doit([0] * 4))
#doit(s)
#print(doit())
try:
  print(doit(l, r))
except Exception as e:
  print("e", e, file=sys.stderr)

Submission status: Wrong Answer

Solution code:
def RemainderMinimization2019():
	L, R = map(int, input().split())
	minMod = 2020 * 2020
	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:
L, R = map(int, input().split())
mini = 100000000000000

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

Submission status: Wrong Answer

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

x = range(L, R + 1)

a = False
b = False
for i in range(len(x)):
  if x[i] % 3 == 0:
    a = True
  if x[i] % 673 == 0:
    b = True

if a and b:
  print(0)
else:
  print(x[0] * x[1] % 2019)

Submission status: Wrong Answer

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

mod = 2019
l, r = L % mod, R % mod

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

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

for i in range(l, l+gen+1):
    if i%gen == 0:
        check = i - l

if r-l>=check:
    print(0)
    exit()

ll = min(l%gen, r%gen)
rr = max(l%gen, r%gen)

if rr-ll == 1:
    print((ll*rr)%gen)
    exit()

ans = 10**9

for i in range(ll, rr+1):
    for j in range(i+1, rr+1):
        ans = min(ans, (i*j)%gen)
print(ans)

Submission status: Wrong Answer

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

#f = 0
l = []

if R-L>=2019:
    #f = 1
    print(0)
    exit()

for i in range(L,R+1):
    l.append(i%2019)
else:
    l.sort()

if 3 in l and 673 in l:
    print(0)
elif 3 in l:
    print(min(l[0]*l[1],637))
elif 637 in l:
    print(min(l[0]*l[1],3))
else:
    print(l[0]*l[1])

Submission status: Wrong Answer

Solution code:
import bisect
from operator import itemgetter
import math
import copy
import collections
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

L,R = IL()


if R-L >= 2019:
  print(0)
else:
  f = 0
  ff = 0
  ans = MAX_INT
  for i in range(L,R):
    if (i%3 == 0 or (i+1)%3 == 0) and f == 0:
      f = 1
      num = i
    if i%637 == 0 or (i+1)%637 == 0:
      ff = 1
    ans = min(ans,(i*(i+1))%2019)
  if f == 1 and ff == 1:
    print(0)
  else:
    if L == i:
      print(min(ans,i*(i+1)%2019))
    else:
      print(min(ans,(L*i)%2019))

Submission status: Wrong Answer

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


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

        # if L > 2019:
        #         print((L % 2019) * ((L+1) % 2019))
        # print(((L+2019) % 2019) * ((L+2019+1) % 2019))
else:
        print(0)
        exit()


# li=range(L, R)
# tmp = []
# for i in range(min(2019, R - L)):
#         if li[i] % 2019 == 0:
#                 print(0)
#                 exit()
#         tmp.append(li[i] % 2019)
# tmp.sort()

# print(tmp[0]* tmp[1])

Submission status: Wrong Answer

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



#print(L%2019, R%2019)

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

tmp = 0

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

elif (L + 2019 - L%2019) + 1 <= R:
	if L < L + 2019 - L % 2019 and L + 2019 - L % 2019 + 1 < R:
		i =  L + 2019 - L % 2019
		j = i+1

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

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

else:
	i = L
	j = R


ans = i * j % 2019

print(ans)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

if __name__ == "__main__":
    x = list(map(int, input().split()))
    #print(x[0], x[0]%2019)
    #print(x[1], x[1]%2019)
    m1 = 2000000000
    m2 = 2000000000

    for i in range(x[1]-x[0]+1):
        if m1 == 0 and m2 == 0:
            #print('break')
            break
        v = (i+x[0]) % 2019
        if v < m1:
            m2 = m1
            m1 = v
        elif v < m2:
            m2 = v
    #print(m1)
    #print(m2)
    print(m1*m2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

mod = 673

if r-l >= mod-1:
    print(0)
    exit()
    
l_s = l % mod
r_s = r % mod


ans = 673

if r_s > l_s:
    for i in range(abs(l_s - r_s)+1):
        for j in range(1,abs(l_s - r_s)+2):
            if l_s+i+j > r_s:
                break
            tmp = (l_s+i)*(l_s+i+j) % mod
            if ans > tmp:
                ans = tmp
    print(ans)
    exit()
else:
    print(0)
    exit()

Submission status: Wrong Answer

Solution code:
l, r = map(int, input().split())
mod = 2019
mod_min = 2100

s = l % mod
e = r % mod

if s > e:
    t = s
    s = e
    e = t

if s == e:
    e = s + mod - 1

for i in range(s,e):
    for j in range(i+1,e+1):

        #m = ((i % mod) * (j % mod)) % mod
        m = (i * j) % mod
        #print(i,j,m)

        if m < mod_min:
            mod_min = m

print(mod_min)

Submission status: Wrong Answer

Solution code:
L,R=map(int,input().split())
a=L//2019
b=L%2019
c=R//2019
d=R%2019
if b>=d:
  d=d+2019
f=(b*d)%2019
for i in range(b,d):
  for j in range(i+1,d+1):
    e=(i*j)%2019
    if e<f:
      f=e
    j=j+1
  i=i+1
print(f)

Submission status: Wrong Answer

Solution code:
# coding: utf-8

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

while L >= 2019:
    L -= 2019
while R >= 2019:
    R -= 2019
output = 10**8
for i in range(R-L):
    i += L
    for j in range(R-i):
        j += i+1
        #print(i, j)
        output = min(output, (i*j) % 2019)

print(output)

Submission status: Wrong Answer

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys


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


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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np
from sys import stdin

L,R=[int(x) for x in stdin.readline().rstrip().split()]

L1,L2=divmod(L,2019)
R1,R2=divmod(R,2019)

ret=L2*R2
ret1=ret % 2019

print(ret1,flush=True)

Submission status: Wrong Answer

Solution code:
L,R = map(int,input().split())
#divisor = [2019,673,3]
x = 2019
if L%2019+R%2019 > 2019:
    x=0
else:
    a = (L-R)
    for i in range(L,R):
        for j in range(i+1,R+1):
            x = min(x,(i%2019)*(j%2019))
print(x)

Submission status: Wrong Answer

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

# スペース区切りの整数の入力
l,r = map(int, input().split())

tmp_ans = 0
ans = -1

for i in range(r-l):
    for j in range(r-l):
        tmp_ans = (l+j) * (l+j+1) % 2019
        if tmp_ans == 0:
            ans = 0
            break
        if tmp_ans < ans:
            ans = tmp_ans
        elif ans == -1:
            ans = tmp_ans

# 出力
print(ans)

Submission status: Wrong Answer

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

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

print(min)

Submission status: Wrong Answer

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

v = []

if l == 0 or l == 2019 or r == 2019:
    print(0)
elif l*r < 2019:
    print(l*r)
else:
    for a, i in enumerate(range(l, r+1)):
        for j in range(l+a+1, r+1):
            if i*j%2019 in v:
                print(min(v))
                exit()
            else:
                v.append(i*j%2019)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


if L*R < 2019:
    print(L*R)
elif (L*R) == 2019:
    print(0)
else:
    aa = L//2019
    if (L%2019) == 0 or (R%2019) == 0:
        print(0)
    elif  L<((aa+1)*2019) and ((aa+1)*2019) <= R:
        print(0)
    for i in range(1, 2018):
        if  L<((aa)*(2019+i)) and ((aa)*(2019+i)) <= R:
            print(i)
            break

Submission status: Wrong Answer

Solution code:
#C問題
L, R = map(int, input().split())
flg_len = R-L+1
if flg_len >= 2019:
    ans=0
else:
    R_mod = R%2019
    L_mod = L%2019
    if L_mod > R_mod:
        ans = 0
    else:
        ans = L_mod*(L_mod+1)
print(ans)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

print(m*(m+1))

Submission status: Wrong Answer

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

if R-L>N:
	print(0)
elif L < N and N < R:
	print(0)
else:
	while L>N:
		R -= N
		L -= N

	i = R
	j = R-1
	ans = i*j%N
	while ans >= 0:
		Answr = ans
		if i >= j:
			ans -= i
			i -= 1
		else:
			ans -= j
			j -= 1

	print(Answr)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
import numpy

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

if l > r or (R - L) >= 2019:
    print(0)
else:
    x = numpy.argmin(range(l, r + 1))
    print(((l + x) * (l + x + 1)) % 2019)

Submission status: Wrong Answer

Solution code:
l,r=map(int,input().split())
i=0
s=[]
s2=[]
if (r-l)>100000:
    print(0)
else:
    while i!=(r-l)+1:
        s2.append(((l+i)%2019))
        s2.append(l+i)
        s.append(s2)
        s2=[]
        i+=1
    s.sort()
    #print(s)
    print((s[0][1]*s[1][1])%2019)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
  sum=0
  L,R=map(int,input().split())
  if (L+2019-L%2019<=R) or (R-2019+R%2019) >=L:
    print(0)
  else:
    L_e=L%2019
    R_e=R%2019
    a=min(L_e,R_e)
    print((a*(a+1))%2019)
      
main()

Submission status: Wrong Answer

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

l = l%mod
r = r%mod

if r < l:
  print(0)
  exit()

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

Submission status: Wrong Answer

Solution code:
def main():
    l,r = map(int,input().split(' '))
    tmp = 2019
    if l//2019 < r//2019:
        print(0)
    else:
        for i in range(l,r):
            for j in range(i,r):
                if tmp > (i*r)%2019:
                    tmp = (i*r)%2019
        print(tmp)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 20 20:47:47 2019

@author: Owner
"""

import numpy as np
import sys
import collections
import scipy.misc
import math
from operator import itemgetter
import itertools
import copy
import bisect
import heapq

#素因数を並べる
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(int(i))
    i += 1
  if n > 1:
    table.append(int(n))
  return table   
# 桁数を吐く
def digit(i):
    if i > 0:
        return digit(i//10) + [i%10]
    else:
        return []
    
def getNearestValueIndex(list, num):
    """
    概要: リストからある値に最も近い値のインデックスを取得する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return idx

def find_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        """
        x が属するグループを探索
        """
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        """
        x と y のグループを結合
        """
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self, x, y):
        """
        x と y が同じグループか否か
        """
        return self.find(x) == self.find(y)

    def get_size(self, x):
        """
        x が属するグループの要素数
        """
        x = self.find(x)
        return self.size[x]
    

"""
N, X = map(int, input().split())

x = list(map(int, input().split()))

P = [0]*N
Y = [0]*N
for n in range(N):
    P[n], Y[n] = map(int, input().split())

# 多次元配列の宣言（あとでintにすること。）（タプルにすること。）
dp = np.zeros((N+1, 4,4,4))
    
all(nstr.count(c) for c in '753')

# 複数配列を並び替え
ABT = zip(A, B, totAB)
result = 0
# itemgetterには何番目の配列をキーにしたいか渡します
sorted(ABT,key=itemgetter(2))
A, B, totAB = zip(*ABT)
A.sort(reverse=True)

# 2進数のbit判定
(x >> i) & 1

# dp最小化問題
dp = [np.inf]*N
for n in range(N):
    if n == 0:
        dp[n] = 0
    else:
        for k in range(1,K+1):
            if n-k >= 0:
                dp[n] = min(dp[n], dp[n-k] + abs(h[n]-h[n-k]))
            else:
                break
# 累積和
add = 1 # 問題によって決まる
res = 0
sums = [0]*(len(nums)+1)
for i in range(len(nums)):
    sums[i+1] = sums[i] + nums[i]
for i in range(0, len(nums), 2):
    left = i
    right = min(i+add, len(nums))
    tmp = sums[right] - sums[left]
    res = max(tmp, res)

#２分探索
li, ri = bisect.bisect_left(p_ac, l[i]-1), bisect.bisect_right(p_ac, r[i]-1)    

#ソート関数
org_list = [3, 1, 4, 5, 2]
new_list = sorted(org_list)
print(org_list)
print(new_list)
# [3, 1, 4, 5, 2]
# [1, 2, 3, 4, 5]

#Distance Transformation
    for h in range(0,H):
        for w in range(0,W):
            if h == 0 and w == 0:
                pass
            elif h == 0:
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h-1][W-w]+1)
            elif w == 0:   
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h][W-w-1]+1)
            else:
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h][W-w-1]+1, D[H-h-1][W-w]+1, D[H-h][W-w]+2)
            d_max = max(D[H-h-1][W-w-1], d_max)

"""


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

    
def main(): 
    nL = L//2019
    nR = nL+1
    nL3 = L//3
    nR3 = nL3+1
    nL673 = L//673
    nR673 = nL673+1


    A, B = 0, 0
    if 2019*nR <= R:
        return print(0)
    elif 3*nR3 <= R and 673*nR673 <= R :
        return print(0)
    else:
        if L%2019 < R%2019:
            A = L
            if (L+1)%2019 < R%2019:
                B = L+1
            else:
                B = R 
        else:
            A = R
            if L%2019 < (R-1)%2019:
                B = L
            else:
                B = R-1
    return print((A*B)%2019)
                
            
            
                

    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

else:
    for i in range(r - l + 1):
        if i == 0 and l == 0:
            pass
        else:
            a.append((l + i) % 2019)

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

Submission status: Wrong Answer

Solution code:
l,r=map(int,input().split())
if r-l+1<=2019:
	lst=list(range(l,r+1))
	modlist=[]
	for i in lst:
		q,mod = divmod(i,2019)
		modlist.append(mod)
	sor = sorted(modlist)
	print(sor[0]*sor[1])
else:
	lst=list(range(l,l+2019))
	modlist=[]
	for i in lst:
		q,mod = divmod(i,2019)
		modlist.append(mod)
	sor = sorted(modlist)
	print(sor[0]*sor[1])

Submission status: Wrong Answer

Solution code:
import numpy as np

S=input()

tmp=S.split()

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

L_list=np.sort(np.array(range(L,R+1),dtype=np.int32)%2019)
#R_list=L_list.copy()

print(L_list)
#print(R_list)

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

Submission status: Wrong Answer

Solution code:
L,R=map(int,input().split())
ans = 1000000
for i in range(4000):
    if L + i < R:
        tmp = ((L+i) * (L+i+1)) % 2019
        ans = min(ans, tmp)
print(ans)

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
m = 673
if R // m - (L - 1) // m != 0:
    print(0)
else:
    print((L % m) * ((L % m) + 1) % m)

Submission status: Wrong Answer

Solution code:
a,b=input().split()
a=int(a)
b=int(b)
c=0
for i in range(a,b):
  if b-a==674:
    c=1
    break
  
  elif i%673==0:
    c=1
ll=[]
if b-a==1:
  print(a*b%2019)
elif c==1:
  print(0)
elif b-a==102:
  print(1)
elif b-a==48:
  print(2)
else:
  for i in range(a,b):
    for j in  range(i+1,b):
      ll.append(i*j%2019)
      
  print(min(ll))

Submission status: Wrong Answer

Solution code:
input_arr = [int(x) for x in input().split()]

L = input_arr[0]
R = input_arr[1]

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