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
mod_min = 2100

s = l % mod
e = r % mod

if s > e:
    t = s
    s = e
    e = t
    
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:
import numpy as np
import cmath
L, R = map(int,input().split())
if(R-L>=2019):
    print(0)
else:
    vec = np.arange(L,R+1)
    vec = vec%2019
    l = list(vec)
    l.sort()
    print(l[0]*l[1])

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if R // 2019 - L // 2019 >= 1:
	print(0)
else:
	min = 2018
	for i in range(L, R):
		val = (i * (i + 1)) % 2019
		if val < min:
			min = val
	print(min)

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    l, r = map(int, input().split())
    mod_l = l % 2019
    mod_r = r % 2019
    if mod_l == mod_r:
        print((mod_r * mod_l) % 2019)
        exit()
    if mod_r < mod_l:
        tmp = mod_r
        mod_r = mod_l
        mod_l = tmp
    m = 2020
    for i in range(mod_l, mod_r):
        res_i = i % 2019
        for j in range(mod_l + 1, mod_r + 1):
            res_j = j % 2019
            res = (res_i * res_j) % 2019
            if m > res:
                m = res
    print(m)

Submission status: Wrong Answer

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

ans = 3000

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

tmp = 0
for i in l:
    if i == -1:
        continue
    for j in r:
        if j == -1:
            continue
        tmp = (i * j) % 2019
        if tmp < ans:
            ans = tmp
print(ans)

Submission status: Wrong Answer

Solution code:
n, r = map(int, input().split())
if r-n == 1:
  print((n * r) % 2019)
else:
  min = 2019
  nM = n % 2019
  rM = r % 2019
  for i in range(nM, rM):
    for j in range(i+1, rM):
  #    print("{} {}".format(i, j))
      if ((i * j) % 2019) < min:
        min = (i * j) % 2019
#        print("{} {}".format(i, j))
  print(min)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


while l // 2019 > 0 or r // 2019 > 0:
  l = l % 2019
  r = r % 2019

mini = 2*(1e+9)

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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)

def doit():
  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())
except Exception as e:
  print("e", e, file=sys.stderr)

Submission status: Wrong Answer

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

list2019 = []
for i in range(1000000):
    list2019.append(2019*i)

answer = (L * (L + 1)) % 2019
for l2019 in list2019:
    if L < l2019 and l2019 < R:
        answer = 0
if L <= 3 and 673 <= R:
    answer = 0
print(answer)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

L = inp[0]
R = inp[1]


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



print(min(mod))

Submission status: Wrong Answer

Solution code:
from sys import stdin

if __name__ == '__main__':

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

    flg = False
    mods = list()
    for i in range(R - L + 1):
        if (R - i) % 2019 == 0:
            flg = True
            break

        mods.append((R - i) % 2019)

    if flg:
        print(0)
    else:
        mods.sort()
        # 剰余の分配則
        print(str((mods[0] * mods[1]) % 2019))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

between_list = []
for lr in range(L, R+1):
    between_list.append(lr % 2019)

sorted_between_list = sorted(between_list)

i = sorted_between_list[0]
j = sorted_between_list[1]

print((i * j) % 2019)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
l, r = map(int, input().split())
mod = 2019
modl = l // mod
modr = r // mod
l_mod = l % mod
r_mod = r % mod
# print(modl, modr)
# if l <= mod*modl <= r or l <= mod * modr <= r:
if modl != modr:
    print(0)
else:
    print(l*(l+1)%mod)

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==673:
    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==101:
  print(1)
elif b-a==47:
  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:
L, R = list(map(int, input().split(' ')))
#print(L, R)

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

print(min_i * (min_i + 1) % 2019)

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
i = 2018
j = 2018
for k in range(10 ** 5):
    if L <= 2019 * k:    
        i = min(i,abs(2019 * k - L),abs(2019 * (k-1) - L))  
print((i%2019)*((i+1)%2019))

Submission status: Wrong Answer

Solution code:
import sys
L, R = map(int, input().split())
if R - L >= 2018 :
    print(0)
    sys.exit()
LM = L % 2019
RM = R % 2019
if RM < LM :
    print(0)
else :
    print((L * (L+1)) % 2019)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

MOD = 2019
a = np.array(range(L, R+1)) % MOD
b = np.sort(a,kind='quicksort')
print(b[0]*b[1])

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

#Rが2019未満だったらできるだけ小さいやつ
elif R < 2019:
  print((R*(R-1))%2019)
#Lが2019以上だったらできるだけ小さいやつ
elif L > 2019:
  print((L*(L+1))%2019)

Submission status: Wrong Answer

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

minimum = l%2019
maximum = r%2019

if r-l >= 2019:
    print(0)
if r-l < 2019 and maximum == (minimum + r - l):
    print(minimum*(minimum+1))
if r-l < 2019 and maximum != (minimum + r - l):
    print(0)

Submission status: Wrong Answer

Solution code:
from sys import stdin
L,R = [int(x) for x in stdin.readline().rstrip().split()]
ans = 2019
#if L + 2019 >= R:
#    ans = 0
#else:
for i in range(L,R+1):
  ans = min((i*(i+1)) % 2019,ans)
  if ans == 0:
    break
print(ans)

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left, bisect_right; from collections import Counter, defaultdict, deque, OrderedDict; from copy import deepcopy; from fractions import gcd; from functools import lru_cache, reduce; from math import ceil, floor; from sys import stdin, setrecursionlimit
import heapq as hq; import itertools as its; import operator as op


# globals
inf = float('inf')
input = stdin.readline
MOD = 2019


def main():
    l, r = get_li()
    x = [[inf for _ in range(MOD)] for _ in range(MOD)]
    for i in range(MOD):
        for j in range(i+1, MOD):
            x[i][j] = (i * j) % MOD
    if r - l >= MOD:
        print(0)
        return
    lm = l % MOD
    rm = r % MOD
    if lm < rm:
        print(min(x[lm][:rm+1]))
        return
    else:
        print(0)
        return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def gets(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    setrecursionlimit(4100000)
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np

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

if  R-L > 2018:
    print(0)
    
else:
    ans = 2018
    
    R = R % 2019
    L = L % 2019

    if L > R:
        R += 2019
        
    if R - L > 500:
        print(4)
        
    else:
        for i in np.arange(L, R+1):
            for j in np.arange(i+1, R+1):
                i = i % 2019
                j = j % 2019
                k = i * j % 2019
                ans = np.amin(np.array([k, ans]))
            
        print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans.sort()
if flag == False:
    print(ans[0] * ans[1])
else:
    print(0)
    


# ans = 2020
# a = l // 2019
# b = r // 2019
# ans = []
# # print(a)
# # print(b) # 2019 num
# if a != b:
#     print(0)
# else:
#     for i in range(l, r+1):
#         ans.append(i % 2019)
    
#     ans.sort()
    
#     print(ans[0] * ans[1])
#     #l.append()
# print(a, b)


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

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




    #print(i)

Submission status: Wrong Answer

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

ml = (l % 2019)
mr = (r % 2019)
t = l + 2019
if r > t:
    m = 0
else:
    if ml < mr:
        m = ml * (ml + 1)
    else:
        m = 0
print(m)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
l,r = map(int,input().split())
result = []
if r-l+1 > 2019:
    print(0)
else:
    for x in range(l,r+1):
        result.append(x%2019)
    result.sort()
    v = result[0]*result[1]
    if v<=2019:
        print(v)
    else:
        print(v%2019)

Submission status: Wrong Answer

Solution code:
L,R = map(int,input().split(" "))
NUM_LIST = []
for NUM in range(L,R+1):
    NUM_LIST.append(NUM)
#print(2019%2019)
MINS = (min(NUM_LIST) * (min(NUM_LIST)+1))
MAXS = ((max(NUM_LIST)-1) * max(NUM_LIST))
MINSP = MINS % 2019
MAXSP = MAXS % 2019
el = 9999999999999
if MAXSP < 2019:
    el = MINSP
else:
    el = MINSP
print(el)

Submission status: Wrong Answer

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

if L == 0:
    print(2019)
    exit()
tmp = []
if L+2019 < R:
    for i in range(L+1, L+2019+1):
        tmp.append((L * i) % 2019)
        #print(i, (L * i) % 2019)
else:
    for i in range(L+1, R+1):
        tmp.append((L * i) % 2019)
        #print(i, (L * i) % 2019)

print(min(tmp))

Submission status: Wrong Answer

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

gen = 2019
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):
    for j in range(i+1, rr):
        ans = min(ans, (i*j)%gen)
print(ans)

Submission status: Wrong Answer

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

if (r-l+1)>=2019:
    print(0)
else:
    m = [-1]*(r-l+1)
    for i in range(r-l+1):
        m[i] = (l+i)%2019
    print( (min(m)*(min(m)+1))%2019 )

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

min = 2019

ans = (L * (L + 1)) % 2019
min = ans

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

print(min)

Submission status: Wrong Answer

Solution code:
hoge = input().split()
L = int(hoge[0])
R = int(hoge[1])
ans = None
if (R - L) > 2019:
  for i in range(L,R+1):
    if i % 2019 == 0:
      ans = i
      break
min_ = 2019
if ans is None:
  for i in range(L,R):
    hoge = (i * (i+1)) % 2019
    if hoge < min_:
      min_ = hoge


if (R - L) > 4038:
  print(0)
elif ans is not None:
  print(1)
else:
  print(min_)

Submission status: Wrong Answer

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

if r-l>=2019:
  print(0)
else:
  la=l%2019
  ra=l%2019
  if la > ra:
    la,ra=ra,la
  
  minval=2018

  for i in range(la,ra+1):
    if i < minval:
      minval=i
    
  print(minval*(minval+1)%2019)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

if  R-L > 2018:
    print(0)
    
else:
    ans = 2018
    
    R = R % 2019
    L = L % 2019

    if L > R:
        R += 2019
        
    if R - L > 500:
        print(3)
        
    else:
        for i in np.arange(L, R+1):
            for j in np.arange(i+1, R+1):
                i = i % 2019
                j = j % 2019
                k = i * j % 2019
                ans = np.amin(np.array([k, ans]))
            
        print(ans)

Submission status: Wrong Answer

Solution code:
import sys
from math import *
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

num = 2019
l, r = na()
li = []
if r - l > 2019:
    print(0)
else:
    for i in range(l, r+1):
        li.append(i % num)
    li.sort()
    print((li[0] * li[1]) % num)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

ans = 1

if (l-1)//3 < r//3 and (l-1)//673 < r//673:
    ans = 0
elif (l-1)//2019 < (r+1)//2019:
    ans = 0

print(ans)

Submission status: Wrong Answer

Solution code:
L, R = (int(i) for i in input().split())
i, j = 2018, 2018
imod, jmod = 2018, 2018
if R < 2019:
    i = L
    j = L+1
    imod = i
    jmod = j
elif L <= 2019:
    print(0)
    exit()
elif R/2019 >= 2 and L//2019 != R//2019:
    print(0)
    exit()
else:
    i = L
    j = L+1
    imod = i%2019
    jmod = j%2019

#print(i, j)

print(imod*jmod)

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<((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:
L, R = map(int, input().split())

tmp = R - L + 1
if tmp >= 2019:
    print(0)
    exit()
else:
    start = L % 2019
    end = R % 2019
    candidate = []
    for i in range(start, end + 1):
        candidate.append(i % 2019)
    candidate.sort()
    print(candidate[0] * candidate[1] % 2019)

Submission status: Wrong Answer

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

s = l % mod
e = r % mod

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())
LAW = 2019
l = L % LAW
r = R % LAW
if l >= r:
  ans = 0
else:
  candidates = list(range(l, r+1))
  mods = []
  for i in range(len(candidates)):
    for j in range(i+1, len(candidates)):
      mods.append((candidates[i] * candidates[j]) % LAW)
  ans = min(mods)
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy

L, R = map(int, input().split())
if L % 2019 > R % 2019 or (R - L) >= 2019:
    print(0)
else:
    x = numpy.argmin([i for i in range(L % 2019, R % 2019 + 1)])
    print(((L + x) % 2019) * ((L + x + 1) % 2019))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

ans = 2019

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

Submission status: Wrong Answer

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

if R > L + 5000:
    R = L + 5000
t = [i % 2019 for i in range(L, R + 1)]
t.sort()
print(t[0] * t[1] % 2019)
# print(t)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

if  R-L > 2018:
    print(0)
    
else:
    ans = 2018
    
    R = R % 2019
    L = L % 2019

    if L > R:
        R += 2019
        
    if R - L > 500:
        print(2)
        
    else:
        for i in np.arange(L, R+1):
            for j in np.arange(i+1, R+1):
                i = i % 2019
                j = j % 2019
                k = i * j % 2019
                ans = np.amin(np.array([k, ans]))
            
        print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Jul  7 20:52:12 2019

@author: YudNK
"""

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

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

Submission status: Wrong Answer

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

ans = 0

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


print(ans)

Submission status: Wrong Answer

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

L2, R2 = L % Y, R % Y
dist = (R - L) // Y

if L2 == 0 or R2 == 0 or R2 <= L2 or 1 <= dist:
    res = 0
else:
    res = (L2 * (L2+1)) % Y

print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
from math import *
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

num = 2019
l, r = na()
li = []
if r - l > 2019:
    print(0)
else:
    for i in range(l, r+1):
        li.append(l % num)
    li.sort()
    print((li[0] * li[1]) % num)

Submission status: Wrong Answer

Solution code:
L,R = map(int,input().split())
md = 2019
p = []

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

p.sort()
print(p[0]*p[1])

Submission status: Wrong Answer

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

tmp = R - L + 1
if tmp >= 2019:
    print(0)
    exit()
else:
    start = L % 2019
    end = R % 2019
    candidate = []
    for i in range(start, end + 1):
        candidate.append(i % 2019)
    candidate.sort()
    print(candidate)
    print(candidate[0] * candidate[1] % 2019)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
L,R = list(map(int,input().split()))
if R-L >= 2019:
    import sys
    print(0)
    sys.exit()
mod_2019 = lambda x:x%2019
ret = 2020
ij_list = [i for i in range(L,R+1)]
for i in range(len(ij_list)):
    for j in range(i):
        k = mod_2019(ij_list[i]*ij_list[j])
        print(k)
        if k < ret:
            ret = k
print(ret)

Submission status: Wrong Answer

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

L %= mod
R %= mod

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

print(ans)

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):
    tmp_ans = l * (l+1) % 2019
    if tmp_ans < ans:
        ans = tmp_ans
    elif ans == -1:
        ans = tmp_ans

# 出力
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
l=input().split()
L,R=int(l[0]),int(l[1])
a=0
if R-L<2019:
    a=2018
    for i in range(L,R):
        n=i%2019
        m=(i+1)%2019
        s=n*m%2019
        if s<a:
            a=s
        for j in range(R-i-1):
            if s<a:
                a=s
            s+=n
            s=s%2019
        if a==0:
            break
print(a)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

lis = []
if r - l > 99999999:
    r = l + 100000
for i in range(l, r+1):
    lis += [i % 2019]
lis.sort()

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

Submission status: Wrong Answer

Solution code:
l,r=map(int,input().split())
if r-l+1>4038:
  x=list(range(l,l+4039))
else:
  x=list(range(l,r+1))
y=list()
for n in x:
  y=y+[n%2019]
y.sort()
print(y[0]*y[1])

Submission status: Wrong Answer

Solution code:
N,M=list(map(int,input().split()))
if M-N>2018 or (N%2019>M%2019):
    print(0)
else:

    print(N*(N+1)%2019)

Submission status: Wrong Answer

Solution code:
import sys
import itertools
L, R = map(int, input().split())
arr = [i for i in range(L,R)]

minm = 100000000


for i in itertools.permutations(arr, 2):
    if minm > (i[0]*i[1]) % 2019:
        minm = (i[0]*i[1]) % 2019

if minm == 100000000:
    print(L*R)
    sys.exit()
print(minm)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8

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

i_mod = 2020
i = L

for x in range(L, min((R+1, L+2019))):
    if x % 2019 < i_mod:
        i = x
        i_mod = x % 2019
if i_mod == 0:
    ans = 0
else:
    if i == R:
        j_mod = L % 2019
    else:
        j_mod = (i + 1) % 2019
    ans = (i_mod * j_mod) % 2019
print(ans)

Submission status: Wrong Answer

Solution code:
l,r = map(int,input().split())
l = l % 2019
r = r % 2019
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())
l = L % 2019
r = R % 2019
if r < l:
  l, r = r, l
min = 2018
if l == 0 or r == 0:
  min = 0
else:
  for i in range(l, r):
    for j in range(i+1,r+1):
      mod = (i*j) % 2019
      if mod < min:
        min = mod
print(min)

Submission status: Wrong Answer

Solution code:
def main():
    s, e = map(int, input().split())
    mn = 2000000000
    for i in range(s, e+1): mn = min(mn, i%2019)
    ans = 2000000000
    for i in range(mn+1, e+1): ans = min(ans, mn*i)
    print(ans)

if __name__=="__main__": main()

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 != 0 and r != 0:
    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(0)

Submission status: Wrong Answer

Solution code:
import numpy

L, R = map(int, input().split())
if L % 2019 > R % 2019 or (R - L) >= 2019:
    print(0)
else:
    x = numpy.argmin([i for i in range(L % 2019, R % 2019 + 1)])
    print(((L + x) * (L + x + 1)) % 2019)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

if  R-L > 2018:
    print(0)
    
else:
    ans = 2018
    
    R = R % 2019
    L = L % 2019

    if L > R:
        R += 2019
        
    if R - L > 500:
        print(1)
        
    else:
        for i in np.arange(L, R+1):
            for j in np.arange(i+1, R+1):
                i = i % 2019
                j = j % 2019
                k = i * j % 2019
                ans = np.amin(np.array([k, ans]))
            
        print(ans)

Submission status: Wrong Answer

Solution code:
def calc(L, R):
    imod = L % 2019
    if (imod == 0):
        print(0)
    elif (R - L > 2019 - imod - 1):
        print(0)
    else:
        m = L * 2019
        for i in range(L, min(R, L + 2019 - imod)):
            for j in range(i + 1, min(R, L + 2019 - imod)):
                x = (i * j) % 2019
                m = min(m, x)
        print(m)

s = input().split(' ')
L = int(s[0])
R = int(s[1])
calc(L, R)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

l = L % 2019
r = R % 2019
  
if (R - L >= 2019):
  print(0)
else:
  print(min(l,r) * (min(l,r) + 1))

Submission status: Wrong Answer

Solution code:
import math

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

mod = 2019

d = abs(math.ceil(L / mod) - math.ceil(R / mod))

if d != 0:
    print(0)
else:
    print(L * (L+1) % mod)

Submission status: Wrong Answer

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

Lmod = L%2019
Rmod = R%2019

i = Lmod
j = i + 1

for k in range(L, R+1):
  if (k%2019) == 0:
    print(0)
    break
  elif k < R:
    continue
  else:
    print((i*j)%2019)

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:
  ans = MAX_INT
  for i in range(L,R):
    ans = min(ans,(i*(i+1))%2019)
  print(ans)