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

l %= 2019
r %= 2019

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy

L, R = map(int, input().split())
x = numpy.argmin([i % 2019 for i in range(L, R + 1)])
print((L + x) % 2019 * (L + x + 1) % 2019)

Submission status: Wrong Answer

Solution code:
L, R = map(int , input().split())
mod = 2019
ans = float('inf')
for i in range(mod+100):
    if L + 1 + i > R:
        print(ans)
        exit()
    tmp_mod = ((L + i) * (L + 1 + i)) % mod
    if ans > tmp_mod:
        ans = tmp_mod

print(ans)

Submission status: Wrong Answer

Solution code:
A=[int(i) for i in input().split()]
L=A[0]
R=A[1]
num=L-1
am=2020
se=2021
n=0
while True:
	num+=1
	if num>R:
		break
	n=num%2019
	if	n<se:
		if n<=am:
			se=am
			am=n		
		else:
			se=n	
	if num-L>2019:
		print(n)
		break
	
ans=am*se
print(ans)

Submission status: Wrong Answer

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

diff = R//2019 - L//2019

if L % 2019 == 0:
  answer = 0
elif diff == 0:
  answer = (L * (L+1)) % 2019
else:
  answer = 0

print(answer)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from sys import stdin

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

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

print(v_min)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3


def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, m=1, typ=int):
    return [read_h() if m > 1 else typ(input()) for _ in range(n)]


def main():
    L, R = read_h()
    l, r = L % 2019, R % 2019

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

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    l,r  = list(map(int, input().split(" ")))

    if l <= 2019 and 2019 <= r:
        print(0)
    else:
        print(l*(l+1) % 2019)

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
L %= 2019
R %= 2019
if L > R:
    R += 2019

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

print(val)

Submission status: Wrong Answer

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

ans = 2019
m = []
for i in range(L,R+1):
	m.append(i%2019)

for i in range(len(m)):
	for j in range(i+1,len(m)):
		tmp = m[i]*m[j]
		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

if l >= r:
    r = r + 2019

min = 2019

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

print(min)

Submission status: Wrong Answer

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

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

first = 2020
second = 2020
for n in range(L, R+1):
    mod = n%2019
    if mod < first:
        first, second = mod, first
    elif mod < second:
        second = mod
print((first * second)%2019)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

min_=10000000000000000000000
for i in range(l+1,r+1):
    min_=min((i*l)%2019,min_)

print(min_)

Submission status: Wrong Answer

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

def gcd(m,n):
    temp=0
    while m%n!=0:
        temp=n
        n=m%n
        m=temp
    return n
def lcm(m,n):
    return m*n/gcd(m,n)


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

#print(temp)
print(min([min(e) for e in temp]))

Submission status: Wrong Answer

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

from collections import defaultdict

d = defaultdict(int)

for i in range(L,R+1):
  d[i%2019] += 1
  if sum(d.values())>2019:
    break

cnt = 0
ans = list()

for k,v in sorted(d.items()):
  _v = v
  
  while _v > 0:
    cnt +=1
    ans += [k]
    _v -= 1
    if cnt >=2:
      print((ans[0]*ans[1])%2019)
      break
  if cnt >=2:
    break

Submission status: Wrong Answer

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

for i in range(1,10**6):
    if i * 2019 >= L and i*2019 <= R:
        print(0)
        exit()

if R < 2019:
    print(R*(R-1)%2019)
    exit()
ans = 10**20
ans = min(ans , L*(L+1) % 2019)
ans = min(ans , R*(R-1) % 2019)
print(ans)

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) ]
N.sort()
print(N[0]*N[1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
l,r=map(int, input().split())
List=[]
for i in range(l, min(r+1, l+2019*3+1)):
    List.append(i%2019)
List=sorted(List)
print((List[0]*List[1])%2019)

Submission status: Wrong Answer

Solution code:
l, r = map(int, input().split())  # 複数数値入力

lm = l % 2019
rm = r % 2019

if (r - l) + lm < 2019:  # 間に2019の倍数はない
    if lm >= rm:
        print(lm * (lm + 1))
    else:
        print(rm*(rm-1))
else:
    print(0)


# li = [2019, 2019]
# for i in range(l, r + 1):
#     if li[1] > i % 2019:
#         li[1] = i % 2019

#     if li[1] < li[0]:
#         li[0], li[1] = li[1], li[0]

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

Submission status: Wrong Answer

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

left = L // 2019
right = R // 2019

if left != right:
    print(0)
else:
    left_edge = L * (L + 1) % 2019
    right_edge = R * (R - 1) % 2019
    edge = L * R % 2019
    print(min(left_edge, right_edge, edge))

Submission status: Wrong Answer

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

if L % 2019 > R % 2019:
    print(0)
else:
    L = L % 2019
    R = R % 2019
    min_m = 1000000000000
    for i in range(L, R+1):
        for j in range(i+1, R+1):
            m = (i * j) % 2019 
            if m < min_m:
                min_m = m
    print(min_m)

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 a!=c:
  print("0")
else:
  f=(b*d)%2019
  for i in range(b,d-1):
    for j in range(i+1,d):
      e=(i*j)%2019
      if e<f:
        f=e
      j=j+1
    i=i+1
  print(f)

Submission status: Wrong Answer

Solution code:

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


mod = 2019

ans = 0
if r//mod == l//mod:
    
    smallest = min(l%mod,r%mod)
    ans = smallest*(smallest+1)

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

# mod 2019 の答えは 0 ~ 2018 のいずれか
# modは積のそれぞれを取ってから掛けても同じ
# 先にmodを取ったsetを作ってしまえば良さそう

np_nums = np.array(list(set([n % 2019 for n in range(L, R + 1)])))

# 総当たりする
L = len(np_nums)
# 十分大きな値
ans = 2019
for p in range(L):
    for q in range(p + 1, L):
        current_ans = (p * q) % 2019
        if ans > current_ans:
            ans = current_ans

print(ans)

Submission status: Wrong Answer

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

l = l % 2019
r = r % 2019

mod_min = 2019

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

print(mod_min)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


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


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


def slv(L, R):
    m = []
    M = 2019
    for i in range(L, min(R+1, L+4*M+1)):
        m.append(i%M)
    m.sort()
    return (m[0] * m[1]) % M

@mt
def slv2(L, R):
    ans = sys.maxsize
    for i in range(L, R+1):
        for j in range(i+1, R+1):
            ans = min((i*j)%2019, ans)
    return ans

def main():
    L, R = read_int_n()
    print(slv(L, R))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

elif 2019 < L and L < R:
    ans = (L * (L + 1)) % 2019
    
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

LR = input().split(' ')
L = int(LR[0])
R = int(LR[1])

L2 = L % 2019
R2 = R % 2019
if L2 >= R2:
    R2 += 2019

r = sorted(map(lambda x: x % 2019, range(L2, R2 + 1)))

print((r[0] * r[1]) % 2019)

Submission status: Wrong Answer

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

# 1，2番目に小さい数字を入れておく
mins = [2019, 2019]

for i in range(L, R + 1):
    mod = i % 2019
    if mod == 0:
        print(0)
        sys.exit()
    if mod < mins[0]:
        mins[0] = mod
    elif mins[0] <= mod and mod <= mins[1]:
        mins[1] = mod

print((mins[0] * mins[1]) % 2019)

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
elif L <= 2019:
    print(0)
    exit()
else:
    for k in range(L, R+1):
        m = k%2019
        #print("m", m)
        #print(i, j)
        if imod > m or jmod > m:
            if imod < jmod:
                j = k
                jmod = m
            else:
                i = k
                imod = m

#print(i, j)
print((i*j)%2019)

Submission status: Wrong Answer

Solution code:
import sys

l,r=map(int,input().split())
minimum=2019
if r-l>=2019:
	print(0)
	sys.exit()
else:
	l,r=l%2019,r%2019
	if l>r:
		print(0)
		sys.exit()
	elif r-l==1:
		print((l*r)%2019)
	else:
		for i in range(l,r):
			for j in range(l,r):
				if minimum==0:
					print(0)
					sys.exit()
				if i>=j:
					pass
				else:
					if minimum>(i*j)%2019:
						minimum=(i*j)%2019
		print(minimum)

Submission status: Wrong Answer

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

ml = l % 2019
mr = r % 2019

if ml >= mr:
    print(0)
else:
    mi = (ml * (ml+1)) % 2019
    for i in range(ml,mr):
        for j in range(i+1, mr+1):
            #print(i,j,i*j,(i*j)%2019)
            mi = min(mi, (i*j) % 2019)
    print(mi)

Submission status: Wrong Answer

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

if r-l >= 2018:
    print(0)
else:
    cand = []
    ans = float("inf")
    for i in range(l,r+1):
        cand.append(i%2019)
    cand = sorted(cand)
    for i in range(len(cand)):
        for j in range(i,len(cand)):
            ans = min(ans,cand[i]*cand[j]%2019)
    print(ans)

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
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)
  return res

#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:
l,r  = map(int,input().split())
small = l // 2019
big = r // 2019
num = [l % 2019,r % 2019,l % 2019 + 1,r % 2019 - 1]
num.sort()
num = list(set(num))
if big - small >= 1:
    print(0)
else: 
    print((num[0] * num[1]) % 2019)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
l,r = map(int,input().split())
li = []
for i in range(l,r+1):
    li.append(i%2019)
m1 = min(li)
li.remove(m1)
print(m1*min(li))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import sys
# import bisect
# import math
# import numpy as np
# from fractions import gcd

"""Template"""


class IP:
    """
    入力を取得するクラス
    """
    def __init__(self):
        self.input = sys.stdin.readline

    def I(self):
        """
        1文字の取得に使います
        :return: int
        """
        return int(self.input())

    def S(self):
        """
        1文字の取得(str
        :return: str
        """
        return self.input()

    def IL(self):
        """
        1行を空白で区切りリストにします(int
        :return: リスト
        """
        return list(map(int, self.input().split()))

    def SL(self):
        """
        1行の文字列を空白区切りでリストにします
        :return: リスト
        """
        return list(map(str, self.input().split()))

    def ILS(self, n):
        """
        1列丸々取得します(int
        :param n: 行数
        :return: リスト
        """
        return [int(self.input()) for _ in range(n)]

    def SLS(self, n):
        """
        1列丸々取得します（str
        :param n: 行数
        :return: リスト
        """
        return [self.input() for _ in range(n)]

    def SILS(self, n):
        """
        Some Int LineS
        横に複数、縦にも複数
        :param n: 行数
        :return: list
        """
        return [self.IL() for _ in range(n)]

    def SSLS(self, n):
        """
        Some String LineS
        :param n: 行数
        :return: list
        """
        return [self.SL() for _ in range(n)]


class Idea:
    def __init__(self):
        pass

    def HF(self, p):
        """
        Half enumeration
        半分全列挙です
        pの要素の和の組み合わせを作ります。
        ソート、重複削除行います
        :param p: list : 元となるリスト
        :return: list : 組み合わせられた和のリスト
        """
        return sorted(set(p[i] + p[j] for i in range(len(p)) for j in range(i, len(p))))

    def Bfs2(self, a):
        """
        bit_full_search2
        bit全探索の改良版
        全探索させたら2進数のリストと10進数のリストを返す
        :return: list２つ : １個目 2進数(16桁)  2個目 10進数
        """
        # 参考
        # https://blog.rossywhite.com/2018/08/06/bit-search/
        # https://atcoder.jp/contests/abc105/submissions/4088632
        value = []
        for i in range(1 << len(a)):
            output = []

            for j in range(len(a)):
                if self.bit_o(i, j):
                    """右からj+1番目のiが1かどうか判定"""
                    # output.append(a[j])
                    output.append(a[j])
            value.append([format(i, 'b').zfill(16), sum(output)])

        value.sort(key=lambda x: x[1])
        bin = [value[k][0] for k in range(len(value))]
        val = [value[k][1] for k in range(len(value))]
        return bin, val

    def S(self, s, r=0, m=-1):
        """
        ソート関係行います。色々な設定あります。
        :param s: 元となるリスト
        :param r: reversするかどうか 0=False 1=True
        :param m: （2次元配列）何番目のインデックスのソートなのか
        :return: None
        """
        r = bool(r)
        if m == -1:
            s.sort(reverse=r)
        else:
            s.sort(reverse=r, key=lambda x: x[m])

    def bit_n(self, a, b):
        """
        bit探索で使います。0以上のときにTrue出します
        自然数だからn
        :param a: int
        :param b: int
        :return: bool
        """
        return bool((a >> b & 1) > 0)

    def bit_o(self, a, b):
        """
        bit探索で使います。1のときにTrue出すよ
        oneで1
        :param a: int
        :param b: int
        :return: bool
        """
        return bool(((a >> b) & 1) == 1)

    def ceil(self, x, y):
        """
        Round up
        小数点切り上げ割り算
        :param x: int
        :param y: int
        :return: int
        """
        return -(-x//y)

    def ave(self, a):
        """
        平均を求めます
        :param a: list
        :return: int
        """
        return sum(a) / len(a)

    def gcd(self, x, y):
        if y == 0:
            return x
        else:
            return self.gcd(y, x % y)

    def lcm(self, x, y):
        return (x * y) // self.gcd(x, y)


"""ここからメインコード"""


def main():
    # 1文字に省略
    r, e = range, enumerate
    ip = IP()
    id = Idea()

    """この下から書いてね"""
    l, r = ip.IL()
    a = l % 2019
    b = r % 2019
    # print(a, b)
    memo1 = id.ceil(l, 2019) * 2019
    # print(memo1)
    if memo1 <= r:
        if memo1 + 2019 >= 2019:
            print(0)
        else:
            print(2)
    else:
        memo2 = l // 2019 * 2019
        memo3 = id.ceil(r, 2019) * 2019
        #  print(memo2, memo3)
        if l - memo2 <= memo3 - r:
            # print("koko")
            print((l * (l + 1)) % 2019)
        else:
            print((r * (r - 1)) % 2019)



main()

Submission status: Wrong Answer

Solution code:
L, R = (map(int, input().split()))
range = R - L
if range > 4036:
	print(0)
elif range < 2019:
	if L // 2019 == R // 2019:
		print((L * (L + 1)) % 2019)
	elif L // 2019 != R //2019:
		if R % 2019 == 0:
			print((L * R) % 2019)
		else:
			print((R * (R - 1)) % 2019)
else:
	if R // 2019 - L // 2019 >= 2:
		print(0)
	else:
		if R % 2019 == 0:
			print(0)
		else:
			print(0)

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
    if 2019*(nL+1) <= R:
        return print(0)
    else:
        nR = nL+1
        if L - 2019*nL < 2019*(nR) - R:
            if (L+1) - 2019*nL < 2019*(nR) - R:
                return print((L*(L+1))%2019)
            else:
                return print((L*R)%2019)
        else:
            if (L) - 2019*nL < 2019*(nR) - (R-1):
                return print((R*(R-1))%2019)
            else:
                return print((L*R)%2019)            
                
                
            
            
                

    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
if L//2019 != R//2019:
    print(0)
elif L % 2019 <= 673 and R % 2019 >= 673 and R - L >= 2:
    print(0)
else:
    ans = 2019
    for i in range(L, R):
        for j in range(i,R+1):
            ans = min(ans, (i*j)%2019)
    print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
from collections import defaultdict, deque
import math
from math import factorial
import re

def main():
    L, R = map(int, input().split())
    diff = (L - R) / 2019
    if L % 2019 == 0 or diff >= 1:
        print(0)
        return

    mods = set()
    for i in range(L, R+1):
        i_mod = i % 2019
        mods.add(i_mod)
    ones = [(2, 1010), (4, 505), (5, 404), (10, 202), (20, 101)]
    for l, r in ones:
        if l in mods and r in mods:
            print(1)
            return

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

if (L<=3 and 673<=R) or (L<=2019 and 2019<=R):
    ans = 0
else:
    for i in range(L,R+1):
        c = i%2019
        if c < a:
            b = a
            a = c
        else:
            if c < b:
                b = c
    ans = a*b
print(ans)

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
start = L % 2019
end = R % 2019
dist = abs(end - start)

if dist == 1:
    print((start * end) % 2019)
    exit()

ra = 3000
for i in range(dist):
    for j in range(1, dist-1):
        r = (i + start) * (j + start)
        if ra > r:
            ra = r
print(ra)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np


# なんこか入力
l,r = map(int, input().split())

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

answer = 9999
for j in range(l,r+1):
    for i in range(l,j):
        a = i % 2019
        b = j % 2019
        answer = min(answer,(a*b)%2019)

print(answer)

Submission status: Wrong Answer

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

l = l % 2019
r = r % 2019
l = min(l,r)
r = max(l,r)
ans = []
if r == l:
  print((r*l) %2019)
  exit()
for i in range(l,r+1):
  for j in range(i,r+1):
    if i != j:
      ans += [(i * j) %2019]
      
print(min(ans))

Submission status: Wrong Answer

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

diff = R//2019 - L//2019

if L % 2019 == 0:
  answer = 0
elif diff == 0:
  answer = L * (L+1)
else:
  answer = 0

print(answer)

Submission status: Wrong Answer

Solution code:
L,R = map(int,input().split())
mod = 2019
L_mod = L%mod
R_mod = R%mod
sa = R-L
if sa >= mod*2:
    ans = 1
elif sa >= mod:
    ans = 2
    if L_mod == 1:
        ans = 1
else:
    if R_mod < L_mod:
        ans = 2
    else:
        ans = L_mod*(L_mod+1)
    if R_mod == 1:
        ans = L_mod
print(ans)

Submission status: Wrong Answer

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

ls = []

for i in range(l,r+1):
    ls.append(i%2019)

    if len(ls)==10000:
        break
ls = sorted(ls)
print(int(ls[0]*ls[1]))

Submission status: Wrong Answer

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

MOD = 2019
ub = max(R % MOD, L % MOD)
lb = min(R % MOD, L % MOD)

if ub == lb:
    print(0)
    exit()

ans = float('inf')
for i in range(lb, ub + 1):
    for j in range(i + 1, ub + 1):
        ans = min(ans, i * j % MOD)
print(ans)

Submission status: Wrong Answer

Solution code:
def resolve():
    l,r=map(int,input().split())
    k=min(r+1,l+2021)
    lst=[i%2019 for i in range(l,k)]
    a=min(lst)
    lst.remove(a)
    b=min(lst)
    print((a*b)%2019)
resolve()

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    l, r = map(int, input().split())
    res_l = l % 2019
    res_r = r % 2019
    a = res_r
    b = res_l
    if res_l < res_r:
        a = res_l
        b = res_r
    min = 2020

    for i in range(a, b):
        res_i = i % 2019
        for j in range(a + 1, b + 1):
            res_j = j % 2019
            res = (res_i * res_j) % 2019
            if min > res:
                min = res
    print(min)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
l, r = map(int, input().split())
l %= 2019
r %= 2019
if l > r:
    print(0)
m = 1e9
for i in range(l, r + 1):
    for j in range(i + 1, r + 1):
        m = min(m, i * j % 2019)
print(m)

Submission status: Wrong Answer

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

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

min_j = 2020
for j in range(Li + 1, R + 1):
    mod_j = j % 2019
    if min_j > mod_j:
        min_j = mod_j
        if min_j == 0:
            break

print(min_i * min_j)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-



def solve():
  MOD = 2019
  L,R = map(int, input().split())
  mins = [2*10**9+1,2*10**9+1]
  for i in range(L,R+1):
    if i%MOD == 0:
      return 0
    else:
      if i%MOD < max(mins):
        mins = [min(mins),i%MOD]
  return (mins[0]*mins[1])%MOD

print(solve())

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

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

band = (R // 2019) - (L // 2019)
if L == 0:
    print(0)
elif band >=1:
    #この中に一個必ず2019の倍数がある
    print(0)
else:
    print((L * (L+1)) % 2019)

Submission status: Wrong Answer

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

if ml >= mr:
  print(0)
elif R - L >= 2019:
  print(0)
else:
  print(ml * (ml + 1))

Submission status: Wrong Answer

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

mod = []	
if abs(l-r) == 1:
	print(l*r%2019)

else:
	a = l%2019
	b = (l+1)%2019
	print(a*b)

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:
    res = 0
elif R2 <= L2 or 2 <= dist:
    res = 1
elif 1 <= dist or Y < L:
    res = 2
else:
    res = L2 * R2

print(res)