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: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import sys
from itertools import combinations


def answer(L, R):
    return min([divmod(i*j, 2019)[1] for i, j in combinations(range(L, R+1, 1), 2)])


if __name__ == '__main__':
    args = sys.stdin.read().split()
    print(answer(int(args[0]), int(args[1])))

Submission status: Runtime Error

Solution code:
import itertools
L,R = map(int, input().strip().split(' '))
min_m = float('inf')
for i,j in itertools.combinations(range(L,R+1), 2):
  min_m = min_m((i*j)%2019, min_m)
  if min_m == 0:
    break
print(min_m)

Submission status: Runtime Error

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

flag = False
if l % 2019 == 0 or r // 2019 - l // 2019 != 0:
    flag = True

if flag:
    print(0)
else:
    lmod = l % 2019
    rmod = r % 2019

    tmp = math.inf
    for i in range(lmod, rmod):
        for j in range(i+1, rmod+1):
            if (i * j) % 2019 < tmp:
                tmp = (i * j) % 2019
    print(tmp)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import sys
from itertools import combinations


# def pairwise(iterable):
#     "s -> (s0,s1), (s1,s2), (s2, s3), ..."
#     a, b = tee(iterable)
#     next(b, None)
#     return zip(a, b)


def answer(L, R):
    return min([divmod(i*j, 2019)[1] for i, j in combinations(range(L, R+1, 1), 2)])


if __name__ == '__main__':
    args = input().split()
    print(answer(int(args[0]), int(args[1])))

Submission status: Runtime Error

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

flag = 0
for i in range(l, r+1):
    if i % 2019 == 0:
        flag = 1
        break

if flag == 0:
    a = (l % 2019) * ((l+1) % 2019)) % 2019
    print(a)
elif flag == 1:
    print(0)

Submission status: Runtime Error

Solution code:
#入力
I, J = map(int, input().split())
#前処理
if J - I > 2019:
  print(0)
mod_I = I % 2019

  
pool = []
for i in range(J-I):
  mod_I = mod_I + i
  for j in range(J-I-i-1):
    mod_J = mod_I + i + j + 1
    pool.append((mod_I *mod_J) % 2019)      
print(min(pool))

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
n, r = map(int, input().split())
if r-n >= 2019:
  print(0)
  sys.exit(0)
mini = 2019
#nM = n % 2019
#rM = r % 2019
for i in range(n, r+1):
  for j in range(i+1, r+1):
    mini = min((i*j)%2019, mini)
print(mini)

Submission status: Runtime Error

Solution code:
L,R= map(int,input().split())
#境界条件
bool = True
l = L % 2019
r = R % 2019
if l == 0 or r == 0:
    ans = 0
elif R = L +1:
    ans = L*R%2019
else:
    if l > r:
        r+=2019
    if l == r:
        l = L
        r = R
    for i in range(l,r):
        for j in range(i+1,r+1):
            temp = (i * j) % 2019
            if bool:
                min = temp
                ans = min
                bool = False
            elif min > temp:
                min = temp
                ans = min
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n, r = map(int, input().split())
if r - n >= 2019:
  print(0)
  sys.exit(0)
min = 2019
#nM = n % 2019
#rM = r % 2019
for i in range(n, r+1):
  for j in range(i+1, r+1):
    min = min((i*j)%2019, min)
print(min)

Submission status: Runtime Error

Solution code:
def mod(x,y):
    return x % y


l, r = map(int, input().split())
if l <= 2019 <= r:
    print(0)
    exit()
elif r*(r-1) <= 2019:
    print(l*(l+1))
    exit()
lr = list(range(l,r+1))
lr = [mod(lr[x]*lr[y], 2019) for x in range(len(lr)) for y in range(x+1, len(lr))]

print(min(lr))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#C
l,r = map(int,input().split())
a = l % 673
b = r % 673
if(a >= b):
    print(0)
elif(r-l >= 673):
    print(0)
else:
    ans = 2019
    for i in range(a,b):
        ans = min(ans, (i*(i+1))%2019)
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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


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

Submission status: Runtime Error

Solution code:
L, R = map(int, input().split())
if L + (673 - L % 673) <= R or L % 673 == 0:
  if L + (3 - L % 3) <= R or L % 3 == 0:
    print(0)
    sys.exit()
ans = 2019
a = L % 2019
b = R % 2019
for i in range(a, b):
  for j in range(i+1, b+1):
    ans = min(ans, i * j % 2019)
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
L, R = map(int, input().split(" "))
arr = np.array(np.arange(L, R+1))
mod_list = []
min_mod_list = []
if (0 in (arr % 2019)) or (0 in arr):
  print(0)
else:
  for i in arr:
#    index_ = np.extract(i, arr)
    index_ = np.where(arr==i)
    for j in arr[int(index_[0])+1:]:
      mod_list.append(((i * j) % 2019))
    
    min_mod_list.append(min(mod_list))
    del mod_list
    mod_list = []
  
  
  print(min(min_mod_list))

Submission status: Runtime Error

Solution code:
import numpy as np
L,R = map(int,input().split())
ans = L*(L+1)%2019

np1 = np.array(range(L,R+1))
np2 = np.multiply.outer(np1,np1)
np3 = np2%2019
np3[0,0] = 2019
np3[R-L-1,R-L-1]=2019
print(np.amin(np3))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import sys
from itertools import combinations


# def pairwise(iterable):
#     "s -> (s0,s1), (s1,s2), (s2, s3), ..."
#     a, b = tee(iterable)
#     next(b, None)
#     return zip(a, b)


def answer(L, R):
    return min([divmod(i*j, 2019)[1] for i, j in combinations(range(L, R+1, 1), 2)])


if __name__ == '__main__':
    args = sys.stdin.read().split()
    print(answer(int(args[0]), int(args[1])))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import numpy as np


l, r = map(int, input().split())
#if l <= 2019 <= r:
#    print(0)
#    exit()
#elif r*(r-1) <= 2019:
#    print(l*(l+1))
#    exit()

lr = np.arange(l, r+1)
lr = np.reshape(lr, (1, len(lr)))
lr_t = lr.T
mod = (lr*lr_t) % 2019
mod = mod[np.triu_indices_from(mod, k=1)]

print(mod.min())

Submission status: Runtime Error

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

if flag != 1:
    if l == 0:
        a = (l+1 % 2019) * (l+2 % 2019) % 2019
    else:
        a = (l % 2019) * (l+1 % 2019) % 2019

if l == 0 and a == 0:
    flag = 2

if flag == 0:
    print(a)
elif flag == 1:
    print(0)
else:
    print(2019)

Submission status: Runtime Error

Solution code:
import numpy as np
L, R = map(int, input().split(" "))
arr = np.array(np.arange(L, R+1))
mod_list = []
min_mod_list = []
if (0 in (arr % 2019)) or (0 in arr):
  print(0)
else:
  for i in arr:
#    index_ = np.extract(i, arr)
    index_ = np.where(arr==i)
    for j in arr[int(index_[0]):]:
      mod_list.append(((i * j) % 2019))
    
    min_mod_list.append(min(mod_list))
    del mod_list
    mod_list = []
  
  
  print(min(min_mod_list))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import sys
from itertools import combinations


# def pairwise(iterable):
#     "s -> (s0,s1), (s1,s2), (s2, s3), ..."
#     a, b = tee(iterable)
#     next(b, None)
#     return zip(a, b)


def answer(L, R):
    return min([divmod(i*j, 2019)[1] for i, j in combinations(range(L, R+1, 1))])


if __name__ == '__main__':
    args = sys.stdin.read().split()
    print(answer(int(args[0]), int(args[1])))

Submission status: Runtime Error

Solution code:
import numpy as np
L,R = map(int,input().split())
ans = L*(L+1)%2019

np1 = np.array(range(L,R))
np2 = np.multiply.outer(np1,np1)
np3 = np2%2019
np3[0,0] = 2019
np3[R-L-1,R-L-1]=2019
print(np.amin(np3))

Submission status: Runtime Error

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

s = sum(a)
p = 0
for i in range(n):
    if i%2 == 1:
        p += a[i]*2

q = s-p
for i in range(n):
    print(q)
    q = a[i]*2-q

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
L,R=map(input().split())
if int(R/2019)-int(L/2019)>=1 or (R/2019.is_integer)==True or (L/2019.is_integer)==True:
	print(0)
elif R-L>=3:
	if int((R+1346)/2019)-int(L/2019)>=1 or int(R/2019)-int((L-674)/2019)>=1:
		print(0)
	elif int((R+673)/2019)-int(L/2019)>=1 or int(R/2019)-int((L-1347)/2019)>=1:
		print(0)
	else:
		print(min((i*j)/2019 for i<j in range(L,R+1)))
else:
	print(min((i*j)/2019 for i<j in range(L,R+1)))

Submission status: Runtime Error

Solution code:
import numpy as np

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

tmp = 0
ans = 2019

i = L
j = R
tmp = (i * j) % 2019
if tmp < ans:
	ans = tmp
if (L + 2019 - L%2019) + 1 <= R:
	i =  L + 2019 - L % 2019
	j = i+1
	tmp = (i * j) % 2019
		if tmp < ans:
			ans = tmp

i = L
j = i+1
tmp = (i * j) % 2019
if tmp < ans:
	ans = tmp

j = R
i = j-1
tmp = (i * j) % 2019
if tmp < ans:
	ans = tmp

i = L
j = R
tmp = (i * j) % 2019
if tmp < ans:
	ans = tmp

print(ans)

Submission status: Runtime Error

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

ans = []

if l > 2019 and r > 2019:
	l %= 2019
	r %= 2019
	
elif l <= 2019 and r > 2019:
	r %= 2019
	s = l
	l = r
	r = s
	
if l == r:
	l %= 2019
	r %= 2019
	print(l*r%2019)
	
else:	
	for i in range(l,r):
		for j in range(i+1,r+1):
			rem = i*j%2019
			ans.append(rem)

	print(min(ans))

Submission status: Runtime Error

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

ans = 10**20

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

Submission status: Runtime Error

Solution code:
def comb(n, k):
    m = 1
    if n < 2 * k:
        k = n - k
    for i in range(1, k + 1):
        m = m * (n - i + 1) / i    
    return m % 2019
L,R = map(int,input().split())
min = 999999999
lists = list(range(L,R+1))
for i in range(len(lists)):
    if min > comb(L,lists[i]) and min !=1 :
        min = comb(L,lists[i])
print(min)

Submission status: Runtime Error

Solution code:
"""
#include <stdio.h>
int main(){
  int l, r, ans=99999;
  int lst[99999];
  scanf("%d",&l);
  scanf("%d",&r);
  l %= 2019;
  r %= 2019;
  for(int i=l;i<r;i++){
    for(int j=i+1;j<r+1;j++){
      if(ans>(i*j)%2019){
        ans = (i*j)%2019;
        //printf("%d\n",ans);
      }
    }
  }
  printf("%d\n",ans);

}
/*"""
l, r = map(int, input().split())
l = l3
l2 = 2019*(l//2019)
r -= l2
l %= 2019

if r>= 2019:
  print(0)
else:
  print(l3*(l3+1))

#for i in range()

#lst = []
sum = 9999999999
#lm = 99999999999
#rm = 99999999999
#for 
#print(l%2019)
"""
for i in range(l,r):
  for j in range(i+1,r+1):
    #lst.append(i*j%2019)
    if sum > i*j%2019:
      sum = i*j%2019
print(sum)
"""
#*/

Submission status: Runtime Error

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

listX = []
sw = 0
i = 1
while i * 2019 > 2000000000:
  i3 = i *2019
  listX.append(i3)
  i += 1

for n in range(len(listX)):
  if L < listX[n] and R > listX[n]:
    sw += 1

if sw > 0:
  print(0)

elif sw == 0:      
  L_1 = L % 2019
  R_1 = R % 2019
  
  idx1 = 0
  listA = []
  for idx1 in range(L_1, R_1):
    for idx2 in range(idx1 + 1, R_1 + 1):
      listA.append(idx1 * idx2)
 
  print(min(listA))

Submission status: Runtime Error

Solution code:
import math

l, r = map(int, input().split())
e = 2019
e1 = 3
e2 = e // e1

if r-l == 1:
    print(l*r % e)
else:
    if divmod(l,e2)[0] < divmod(r,e2)[0]:
        print(0)
    else:
        if r < e
            print(r*(r-1) % e)
        elif e < l:
            print(l*(l+1) % e)

Submission status: Runtime Error

Solution code:
L, R = map(int, input().split())
a = L % 2019
if a == 0:
  print(0)
else:
  if L + (673 - L % 673) <= R or L % 673 == 0:
    if L + (3 - L % 3) <= R or L % 3 == 0:
      print(0)
      sys.exit()
  ans = 2019
  b = R % 2019
  for i in range(a, b):
    for j in range(i+1, b+1):
      ans = min(ans, i * j % 2019)
  print(ans)

Submission status: Runtime Error

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

Answers = []

for i in range(R-L):
  for j in range(R-L-i-1):
    Answers.append((L+i)*(L+i+j+1)%2019)

#print(len(Answer))

print(min(Answers))

Submission status: Runtime Error

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

taste = [l + i for i in range(n)]

idx_eaten = -1
if taste[0] <= 0:
    if taste[n-1] < 0:
        idx_eaten = n - 1
    else:
        idx_eaten = -taste[0]
else:
    idx_eaten = 0
    
result = 0
for i in range(n):
    if i == idx_eaten:
        continue
    result += taste[i]
    
print(result)

Submission status: Runtime Error

Solution code:
import itertools

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

answer = 2019

mylist = []
for i in range(n[1]-n[0]+1):
    mylist.append(n[0]+i)

for element in itertools.combinations(mylist,2):
    mod = (element[0] * element[1]) % 2019
    if(mod < answer):
	answer = mod

print(answer)

Submission status: Runtime Error

Solution code:
import numpy as np

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

tmp = 0
ans = 2019

i = L
j = R
tmp = (i * j) % 2019
if tmp < ans:
	ans = tmp

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

i = L
j = i+1
tmp = (i * j) % 2019
if tmp < ans:
	ans = tmp

j = R
i = j-1
tmp = (i * j) % 2019
if tmp < ans:
	ans = tmp

i = L
j = R
tmp = (i * j) % 2019
if tmp < ans:
	ans = tmp

print(ans)

Submission status: Runtime Error

Solution code:
import itertools


def ij(m):
    return m[0] < m[1]


def mod(m):
    return (m[0] * m[1]) % 2019


def main():
    (l, r) = list(map(int, input().split()))

    print(min(map(mod, filter(ij, itertools.product(range(l, r + 1), range(l, r + 1))))))


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
from sys import stdin
import math
input = [int(x) for x in stdin.readline().rstrip().split()]

L=input[0]
R=input[1]


output=0

if R>673 and
if R//673 != L//673 and L>=673 and R-L>=2:
    output=0
#elif  R//673 != L//673:
    #output=0
else:
    output=(L*(L+1)%2019)


print(output)

Submission status: Runtime Error

Solution code:
A,B=map(int,input().split())
mod = 2018
flag =0
for i in range(A,B):
  x = i % 2019
  for j in range(i+1,B+1):
    j = j % 2019
    mod = min(mod, (x*j)%2019)
    if mod = 0:
      flag = 1
      break
  if flag:
    break

print(mod)

Submission status: Runtime Error

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

if l =< 2019 =< r:
  print(0)
elif r - l > 2018:
  print(0)
else:
  x = []
  for i in range(l, r):
    for j in range(i+1, r+1):
      m = i * j % 2019
      x.append(m) 
  print(min(x))

Submission status: Runtime Error

Solution code:
import numpy as np


l, r = map(int, input().split())
if l <= 2019 <= r:
    print(0)
    exit()
elif r*(r-1) <= 2019:
    print(l*(l+1))
    exit()

lr = np.arange(l, r+1)
lr = np.reshape(lr, (1, len(lr)))
lr_t = lr.T
mod = (lr*lr_t) % 2019
mod = mod[np.triu_indices_from(mod, k=1)]
print(mod.min())

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import itertools
L , R  = map(int,input().split())
num_list = list(range(L,R+1))
mod = list()
for j in itertools.combinations(num_list,2):
	mod.append((j[0]*j[1])%2019)
print(min(mod))

Submission status: Runtime Error

Solution code:
import itertools

l,r=map(int, input().split())
lis1 = list(range(l,r+1))
lis2=[]

for v in itertools.combinations(lis1, 2):
      lis2.append(v[0]*v[1]%2019)
    
print(min(lis2))

Submission status: Runtime Error

Solution code:
import itertools
l,r = map(int, input().split())
a = (l-1)//2019
b = r//2019
x = [0]*(r-l+1)
c = l%2019
if b-a>0:
    print(0)
else:
    for i in range(r-l+1):
        x[i] = c+i
    z = [0]*(r-l)
    for j in range(r-l):
        z[j] = x[j]*x[j+1]
    print(min(z))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import numpy as np


l, r = map(int, input().split())
if l <= 2019 <= r:
    print(0)
    exit()
elif r*(r-1) <= 2019:
    print(l*(l+1))
    exit()

lr = np.arange(l, r+1)
lr = np.reshape(lr, (1, len(lr)))
lr_t = lr.T
mod = (lr*lr_t) % 2019
mod = np.triu(mod, k=1)
mod = mod[np.triu_indices_from(mod, k=1)]
print(mod.min())

Submission status: Runtime Error

Solution code:
l, r = list(map(int,input().split()))
Set = set([l%2019])
for i in range(r-l):
	Set.add((l+1+i)%2019)
List = list(Set)
answer = (l * r) % 2019
k = 0
for i in range(len(List)):
	for j in range(len(List)):
		if(i < j):
			if(k == 0 or (i >= 45 and j >= 46))
				if(answer > (List[i] * List[j])% 2019):
					answer = (List[i] * List[j])% 2019
					k = 1
print(answer)

Submission status: Runtime Error

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


MOD=[0] * (2019*2019)

def myidx(i,j):
    return i * 2019 + j

for i in range(2019):
    for j in range(2019):
        idx = myidx(i,j)
        MOD[idx] = (i*j) % 2019

for i in range(2019):
    idx = myidx(i,i)
    MOD[idx] = 2019

MMM = []
Lmod = L % 2019
Rmod = R % 2019

if L+2019 <= R:
    for i in range(2019):
        for j in range(i+1,2019):
            idx = myidx(i,j)
            MMM.append(MOD[idx])
elif Lmod <= Rmod:
    for i in range(Lmod, Rmod+1):
        for j in range(i+1, Rmod+1):
            idx = myidx(i,j)
            MMM.append(MOD[idx])

elif Lmod > Rmod:
    for i in list(range(0,Rmod+1)) + list(range(Lmod, 2019)):
        for j in list(range(i+1,Rmod+1)) + list(range(i+1, 2019)):
            idx = myidx(i,j)
            MMM.append(MOD[idx])

MMM=list(set(MMM)).sort()
print(MMM.pop(0))

Submission status: Runtime Error

Solution code:
L,R = map(int,input().split())
ls = []
if L*R < 2019:
    print(L*R)
elif R - L > 4037:
    print(0)
elif R - L > 2018:
    print(1)
else;
    print(2)

Submission status: Runtime Error

Solution code:
import itertools

l,r=map(int, input().split())
lis1 = list(range(l,r+1))

lis2=[]

for v in itertools.combinations(lis1, 2):
      lis2.append(v[0]*v[1]%2019)
    
print(min(lis2))

Submission status: Runtime Error

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

if abs(l - r) == 1:
    print(l * r % 2019)
else:
    lower = l // 2019
    upper = r // 2019
    start = l % 2019
    stop = r % 2019
    if 2019 * (lower + 1) < r:
        print(0)
    else:
        if start == 0:
            print(0)
        elif stop == 0:
            print(0)
        elif stop < start:
            print(0)
        elif stop > start:
            while stop > start:
                total = stop * start % 2019
                if total < ans:
                    ans = total
                start += 1
            print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np

n,d = map(int,input().split())
x = [[int(i) for i in input().split()] for n in range(n)]
count = 0
def distance(m):
    for c in range(d):
        s = list((x[b][c] - x[b+1][c]) ** 2)
        t = sum(s)
        return np.sqrt(t)

for b in range(n - 1):
    if distance(b) == int(distance(b)):
        count += 1
        
print(count)

Submission status: Runtime Error

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

import sys
import math
#from pprint import pprint
import numpy as np
def myinput_int():
    return list(map(int, input().split()))
def myinput_str():
    return list(input().split())

L,R = myinput_int()

if 2019<=R-L :
    print(0)
    exit(0)

a = np.arange(L,R+1)%2019
a2 = (2019-a)
b = np.sort((*a,*a2))

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

Submission status: Runtime Error

Solution code:
import itertools
import numpy as np

def mod(n):
    return n % 2019


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

a = list(range(L,R+1))
p = list(itertools.combinations(a, 2))
a1, a2 = map(list, zip(*p))
ans = np.array(a1)*np.array(a2)
ans = map(mod,ans)
print(min(ans))

Submission status: Runtime Error

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

if R-L >= 2019:
    print(0)
else:
    bet =  sorted([i%2019 for i in range(L,R+1)])
    if max(bet)*min(bet) > 2019:
      	mi = 1000000000000
        for i in range(len(bet)):
          for j in range(i+1,len(bet)-i):
            fig =  (bet[i] * bet[j])%2019
            if fig <= mi:
              mi = fig
    else:
        print(bet[0]*bet[1])

Submission status: Runtime Error

Solution code:
from sys import stdin
import math
import itertools
import numpy as np

l = stdin.readline().rstrip().split()
l = [int(s) for s in l]

hoge = list(range(l[0], l[1] + 1))
piyo = []

for v in itertools.combinations(hoge, 2):
    piyo.append(divmod(v[0] * v[1], 2019)[1])

print(min(piyo))

Submission status: Runtime Error

Solution code:

import sys
import math
#from pprint import pprint
import numpy as np
def myinput_int():
    return list(map(int, input().split()))
def myinput_str():
    return list(input().split())

L,R = myinput_int()

if 2019<=R-L :
    print(0)
    exit(0)

a = np.arange(L,R+1)%2019
a2 = (2019-a)
b = np.sort((*a,*a2))

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

Submission status: Runtime Error

Solution code:
l,r=map(int,input().split())
a=list(range(l,r+1))
b=[]
for i in range(r+1-l):
  b.append(a[i]%2019)
b=sorted(enumerate(b), key=lambda x: x[1])
print((a[c[0][0]]*a[c[1][0]])%2019)

Submission status: Runtime Error

Solution code:
l,r=map(int,input().split())
s=[]
if ((r//2019)!=(l//2019)):
        a=0
    s.append(a)
elif((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: Runtime Error

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

minimum = l%2019
maximum = r%2019

ans = 10000
if r-l >= 673:
    print(0)    
elif r-l < 2019:
    for i in range(l,r):
        if i%673 ==0:
            flag = 1
        ans = min(i*(i+1)%2019,ans)
    
    if flag==1:
        print(0)
    else:
        print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np


l, r = map(int, input().split())
if l <= 2019 <= r:
    print(0)
    exit()
elif r*(r-1) <= 2019:
    print(l*(l+1))
    exit()

lr = np.arange(l,r+1)
lr = np.reshape(lr, (1,len(lr)))
lr_t = lr.T
mod = (lr*lr_t)%2019
mod = np.triu(mod, k=1)
mod = mod[np.triu_indices(len(mod),k=1)]
print(mod.min())

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
L,R= map(int,input().split())
#境界条件
bool = True
l = L % 2019
r = R % 2019
if l == 0 or r == 0:
    ans = 0
else:
    for i in range(l,r):
        for j in range(i+1,r+1):
            temp = (i * j) % 2019
            if bool:
                min = temp
                ans = min
                bool = False
            elif min > temp:
                min = temp
                ans = min
print(ans)

Submission status: Runtime Error

Solution code:
import itertools


def ij(m):
    return m[0] < m[1]


def mod(m):
    return m[0] * m[1] % 2019


def main():
    (l, r) = list(map(int, input().split()))

    print(min(map(mod, filter(ij, itertools.product(range(l, r + 1), range(l, r + 1))))))


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
def mod(n):
    return n % 2019

import itertools
import numpy as np
import operator as op
L, R = map(int, input().split())

a = list(range(L,R+1))
p = list(itertools.combinations(a, 2))
a1, a2 = map(list, zip(*p))
ans = np.array(a1)*np.array(a2)
ans = map(mod,ans)
print(min(ans))

Submission status: Runtime Error

Solution code:
L,R = map(int,input().split())
mod = 2019
if R-L==1:
    print((L*R)%mod)
    exit()
li = [i%mod for i in range(L,R+2019)]
li.sort()
if li[0]==0:
    print(li[1]*li[2])
else:
    print(li[0*li[1])

Submission status: Runtime Error

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

if R-L >= 2019:
    print(0)
else:
    bet =  sorted([i%2019 for i in range(L,R+1)])
    if max(bet)*min(bet) > 2019:
      	mi = 1000000000000
        for i in range(len(bet)):
          for j in range(1,len(bet)):
            fig =  (bet[i] * bet[j])%2019
            if fig <= mi:
              mi = fig
    else:
        print(bet[0]*bet[1])

Submission status: Runtime Error

Solution code:
L, R = map(int, input().split())
C = []
flag = False
for i in range(L, R+1):
    if i%2019==0:
        flag = True
        break
    else:
        C.append(i)
        
if flag:
    print(0)
else:
    ans = 4080400
    for x, y in list(itertools.combinations(C, 2)):
        if (x*y)%2019<ans:
            ans = (x*y)%2019
    print(ans)

Submission status: Runtime Error

Solution code:
L,R= map(int,input().split())
#境界条件
bool = True
l = L % 2019
r = R % 2019
if l == 0 or r == 0:
    ans = 0
else:
    for i in range(l,r):
        for j in range(i+1,r+1):
            temp = (i * j) % 2019
            if bool:
                min = temp
                bool = False
            elif min > temp:
                min = temp
                ans = min
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

ans = 2019 #3*673
# 要素に2個出現
w = list(range(l,r+1))
mp = list(map(lambda x: x / 2019, w))
w = np.array(w)
mp = np.array(mp)
b = np.reshape(np.hstack((w, mp)), (2, len(w))).T.tolist()
b.sort(key=lambda x: x[1])
print(int((b[0][0]*b[1][0])%2019))

Submission status: Runtime Error

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

mod = 2019
for i in range(500):
  if L <= (3**i)%(1e9+7) <= R or L <= (673**i)%(1e9+7) <= R or L <= (3*673*i)%(1e9+7) <= R or L <= (3*i)%(1e9+7) <= R or L <= (673*i)%(1e9+7) <= R:
    print(0)
    exit()
else:
  print(min((L*(L+1))%mod, R*(R-1)%mod, R*L%mod))

Submission status: Runtime Error

Solution code:
import itertools
l,r = map(int, input().split())
a = (l-1)//2019
b = r//2019
x = [0]*(r-l+1)
c = l%2019
if b-a>0:
    print(0)
else:
    for i in range(r-l+1):
        x[i] = c+i
    y = list(itertools.combinations(x, 2)) 
    z = [0]*len(y)
    for j in range(len(y)):
        z[j] = (y[j][0]*y[j][1])%2019
    print(min(z))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
l,r = (int(i) for i in input().split())
mod = 2019
t,i = 0,1
lim = 10**9
while t<=lim:
    t = mod*i
    if l<=mod<=r:
        print(0)
        exit()
    i+=1
print(min(l*(l+1)%mod,r*(r-1)%mod)

Submission status: Runtime Error

Solution code:
x,y = map(int,input().split())
x = x % 2019
y = y % 2019
min = 2019
n = y-x
i=0
while i<n:
  s = (x + i) % 2019
  i = i +1
  if s == 0:
    print(s)
    break
  elif min > s:
    min = s:
min2 = 2019
j=0
while j<n:
  g = (x + j) % 2019
  j=j+1
  if g == 0:
    break
  elif min2 > g and g != min:
    min2 =g

if min != 0:
  z = (min*min2)%2019
  print(z)

Submission status: Runtime Error

Solution code:
l,r=map(int,input().split())
a=list(range(l,r+1))
b=[]
for i in range(r+1-l):
  b.append(a[i]%2019)
  
c=sorted(enumerate(b), key=lambda x: x[1])
print((int(a[c[0][0]])*int(a[c[1][0]]))%2019)

Submission status: Runtime Error

Solution code:
N = R - L + 1
l = L % 2019

if N >= 2019:
    print(0)
    exit()

m = 2018
for i in range(N):
    a = (l + i) % 2019
    if a < m:
        m = a

print(m * (m + 1))