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 = [int(x) for x in input().split()]
 
#L = input_arr[0]
#R = input_arr[1]
 
min_ans = 10**18
for i in range(L+1,R+1):
  ans = (L*i)%2019
  if ans < min_ans:
    min_ans = ans
  if min_ans == 0:
    break

print(min_ans)

Submission status: Wrong Answer

Solution code:
L,R= [int(i) for i in input().split()]
a = 2019
l = L % 2019
r = R % 2019
M = L+(2019-l)

i = L
j = -1
if M<R:
    i = M
else:
    if l<r:
        i = L
    else:
        i = 0
if -1==j:
    j = i+1
else:
    i = j-1
print((i*j)%2019)

Submission status: Wrong Answer

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

l = L % 2019
r = R % 2019

ans = 2019*2019

if L // 2019 == R // 2019:
    # print(l,r)
    for i in range(l, r):
        # print('i', i)
        for j in range(l+1,r):
            # print('j', j)

            ans = min(ans, (i*j)%2019)
else:
    ans = 0

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

    a = l*r%2019
    for i in range(l,r) :
        for j in range(i+1,r+1):
            ij = i*j%2019
 
            if(ij==0) :
                return a

            if (a > ij) :
                a = ij


    return a



print(yo())

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:
  temp = 2 * 10 ** 9 + 1
  for i in range(ml, mr + 1):
    for j in range(ml + 1, mr + 1):
      temp = min(temp, (i * j) % mod)
  print(temp)

Submission status: Wrong Answer

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

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

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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())
l3 = l
l2 = 2019*(l//2019)
r -= l2
l %= 2019

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

#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: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(4100000)

l,r = [int(i) for i in input().split()]
a = []
l = l%2019
r = r%2019
temp = float('inf')
for i in range(l,r):
    for k in range(l+1,r+1):
        if i*k%2019 < temp:
            temp = i*k%2019
print(temp)

Submission status: Wrong Answer

Solution code:
L,R = map(int, input().split())
baisuc = 1
count = 0

if R < 2019:
    print(L * (L + 1) % 2019)
    exit(0)

while True:
    for i in range(int(L / 2019) * 2019, R+1, 2019):
        if L <= i + count <= R:
            print(count + 1)
            exit(0)

    count += 1

Submission status: Wrong Answer

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


def solve(l, r):
    minimum = r
    if r - l >= 2019:
        return 0
    a, b = l % 2019, r % 2019
    for i in range(a, b):
        for j in range(a + 1, b + 1):
            minimum = min(minimum, (i * j) % 2019)
    result = minimum
    return result


def main():
    l, r = input_from_console()
    print(solve(l, r))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main()

Submission status: Wrong Answer

Solution code:
import numpy as np

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

if r - l > 4040:
    print(0)
else:
    LR = np.arange(l, r + 1)
    LR = LR % 2019
    idx_1 = LR.argmin()
    min_1 = LR[idx_1]
    LR[idx_1] = 2018
    min_2 = LR.min()

    print((min_1 * min_2) % 2019)

Submission status: Wrong Answer

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: Wrong Answer

Solution code:
L,R = [int(i) for i in input().split()]
if L%2019==0 or L <= (L//2019 + 1)*2019 <= R:
    print(0)
elif R*(R-1)<2019 or L*(L+1)>2019:
    print((L*(L+1))%2019)
else:
    min_mod = 100000
    for i in range(L, min(L+2019,R)):
        for j in range(i+1, min(L+2019+1,R+1)):
            mod = i*j%2019
            if mod < min_mod:
                min_mod = mod
    print(min_mod)

Submission status: Wrong Answer

Solution code:
L,R = map(int, input().split())
baisuc = 1
count = 0

if R < 2019:
    print(int(L * (L + 1) / 2019))
    exit(0)

while True:
    for i in range(int(L / 2019) * 2019, R+1, 2019):
        if L <= i + count <= R:
            print(count + 1)
            exit(0)

    count += 1

Submission status: Wrong Answer

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

mod = 2019
l, r = L % mod, R % mod
if l > r:
    l, r = r, l

mini = l*r % mod
for i, j in combinations(range(l, r+1), 2):
    mini = min(mini, i*j % mod)
    if mini == 0:
        break
print(mini)

Submission status: Wrong Answer

Solution code:
l, r = map(int, input().split())
def doit(l, r):
  l = l % 2019
  r = r % 2019
  if l == 0:
    return 0
  if r == 0:
    return 0
  if r <= l:
    r += 2019
  res = 2019
  for x in range(l, r):
    for y in range(x + 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(l, r))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys

l,r = list(map(int, input().split()))
imin = 0

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

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    l,r  = list(map(int, input().split(" ")))
    res = 2019
    n = l // 2019
    if l % 2019 == 0:
        print(0)
    elif l//(n+1) <= 2019  and 2019 <= r//(n+1):
        print(0)
    else:
        for i in range(2019):
            for j in range(2019):
                if l + i + j > r:
                    break
                res1 = (((l+i) % 2019) * ((l+j+i) % 2019)) % 2019
                if res1 < res:
                    res = res1
        print(res)

Submission status: Wrong Answer

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

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

low = 2*1e+200

for i in range(l,r-1):
    for j in range(i+1,r):
        if(((i%2019)*(j%2019))%2019<low):
            low = ((i%2019)*(j%2019))%2019

print(low)

Submission status: Wrong Answer

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

l = L % 2019
r = R % 2019

ans = 2019*2019

if L // 2019 == R // 2019:
    # print(l,r)
    for i in range(l, r-1):
        # print('i', i)
        for j in range(l+1,r):
            # print('j', j)

            ans = min(ans, (i*j)%2019)
else:
    ans = 0

print(ans)

Submission status: Wrong Answer

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


def solve(l, r):
    minimum = r
    if r - l >= 2019:
        return 0
    a, b = l % 2019, r % 2019
    if r // 2019 > l // 2019:
        return 0
    for i in range(a, b):
        for j in range(a + 1, b + 1):
            minimum = min(minimum, (i * j) % 2019)
    result = minimum
    return result


def main():
    l, r = input_from_console()
    print(solve(l, r))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

if r - l > 4040:
    print(0)
else:
    LR = np.arange(l, r + 1)
    LR = LR % 2019
    idx_1 = LR.argmin()
    min_1 = LR[idx_1]
    LR[idx_1] = 2018
    min_2 = LR.min()

    print((min_1 * min_2) % 2)

Submission status: Wrong Answer

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

ans = 2018

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
			if rem < ans:
				ans = rem
			if ans == 0:
				break
				
		if ans == 0:
			break

	print(ans)

Submission status: Wrong Answer

Solution code:
import sys

l,r = list(map(int, input().split()))
imin = 0

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

Submission status: Wrong Answer

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

minv = 1145141919810931
for i in range(l, r + 1):
    for j in range(l, r + 1):
        if (i * j) % 2019 == 0:
            break
        minv = min(minv, (i * j) % 2019)

print(minv)

Submission status: Wrong Answer

Solution code:
import math

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

if R-L>=2019:
    print(0)

else:
    if L!=0:
        a = math.floor(L/2019)
        c = math.floor(L/673)
        e = math.floor(L/3)
    else:
        a = 0
        c = 0
        e = 0
    b = math.floor(R/2019)
    d = math.floor(R/673)
    f = math.floor(R/3)
    if b!=a:
        print(0)
    elif c!=d and e!=f:
        print(0)
    else:
        Lmod = L - a*2019
        s = Lmod*(Lmod+1)
        print(s)

Submission status: Wrong Answer

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

for i in range(l, r+1):
  for j in range(i+1, r+1):
    temp = i * j % 2019
    if ans < temp:
      ans = temp
      if ans:
        break
  if ans:
    break


print(ans if ans != r else l * r)

Submission status: Wrong Answer

Solution code:
import numpy as np

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


ans = 2018
    
R = R % 2019
L = L % 2019

if L > R:
        R += 2019
        
        
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]))
        
        if ans == 0:
            break
    if ans == 0:
        break        

print(ans)

Submission status: Wrong Answer

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: Wrong Answer

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 == 1:
    print('0')
else:
    print( '{}'.format((L * (L+1)) % 2019) )

Submission status: Wrong Answer

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

mod = 2019
l, r = L % mod, R % mod
if l > r:
    l, r = r, l

mini = l*r % mod
for i, j in combinations(range(l, r+1), 2):
    mini = min(mini, i*j % mod)
print(mini)

Submission status: Wrong Answer

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

minv = 1145141919810931
for i in range(l, r + 1):
    for j in range(l, r + 1):
        if (i * j) % 2019 == 0:
            continue
        minv = min(minv, (i * j) % 2019)

print(minv)

Submission status: Wrong Answer

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

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

if R-L >= 2019:
    print(0)
else:
    tmp = np.array(range(L, R+1))
    tmp = tmp % 2019
    tmp = np.sort(tmp)
    if(tmp[0] * tmp[1] > 2019):
        tmp2 = []
        for i in range(len(tmp)):
            for j in range(i+1, len(tmp)):
                tmp2.append((tmp[i] * tmp[j]) % 2019)
        print(min(tmp2))
    else:
        print((tmp[0] * tmp[1]) % 2019)

Submission status: Wrong Answer

Solution code:
L,R = map(int, input().split())
baisuc = 1
count = 0

L / 2019

if R < 2019:
    print(L * (L + 1))
    exit(0)

while True:
    for i in range(int(L / 2019) * 2019, R+1, 2019):
        if L <= i + count <= R:
            print(count + 1)
            exit(0)

    count += 1

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

Solution code:
import numpy as np
L,R = map(int, input().split())
if (L//2019!=R//2019) or L%2019==0 or R%2019==0:
  print(0)
elif R-L==1:
  print((L*R)%2019)
else:
  l = L%2019
  r = R%2019
  ## l<r<2019
  a = []
  for i in range(r-l-1):
    for j in range(r-l-1-i):
      a.append((l+i)*(l+i+j+1))
  print(min(a))

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

minv = 1145141919810931
for i in range(l, r + 1):
    for j in range(i + 1, r + 1):
        if (i * j) % 2019 == 0:
            continue
        minv = min(minv, (i * j) % 2019)

print(minv)

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    l,r  = list(map(int, input().split(" ")))
    res = 2019
    n = l // 2019
    if l % 2019 == 0:
        print(0)
    elif l//(n+1) <= 2019  and 2019 <= r//(n+1):
        print(0)
    else:
        for i in range(2019):
            if l + i + 1 > r:
                break
            res1 = (((l+i) % 2019) * ((l+1+i) % 2019)) % 2019
            if res1 < res:
                res = res1
        print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

MIN = 2020

for i in range(L,R+1):
    for j in range(i,R+1):
        mod = i*j
        MIN = min(MIN,mod%2019)
        if MIN == 0:
            break
# if R == 0 or L == 0:
#     print(0)
# elif R - L == 1:
#      print((R*L)%2019)
print(MIN)

Submission status: Wrong Answer

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

m = 2019
mod_min = m

for j in range(l,r+1,1):
    j_ = j % m
    if j_ == 0:
        break
    for i in range(l,j,1):
        i_ = i % m
        i_j = (i_ * j_) % m
        
        if i_j < mod_min:
            mod_min = i_j
            
        if i_ == 0:
            break
            
print(mod_min)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
l, r = map(int, input().split())
def doit(l, r):
  l = l % 2019
  r = r % 2019
#  if r <= l:
#    r += 2019
  res = 2019
  for x in range(l, r):
    for y in range(x + 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(l, r))

Submission status: Wrong Answer

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

MIN = 2020

for i in range(L,R+1):
    for j in range(i,R+1):
        mod = i*j
        MIN = min(MIN,mod%2019)
        if MIN == 0:
            break
# if R == 0 or L == 0:
#     print(0)
# elif R - L == 1:
#      print((R*L)%2019)
else:
    print(MIN)

Submission status: Wrong Answer

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:
    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: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

if R-L>=2019:
    print(0)

else:
    if L!=0:
        a = math.floor(L/2019)
        c = math.floor(L/673)
        e = math.floor(L/3)
    else:
        a = 0
    b = math.floor(R/2019)
    d = math.floor(R/673)
    f = math.floor(R/3)
    if b!=a:
        print(0)
    elif c!=d and e!=f:
        print(0)
    else:
        Lmod = L - a*2019
        s = Lmod*(Lmod+1)
        print(s)

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):
    if R -L > 2019:
        return 0
    ans = sys.maxsize
    for i in range(L, R+1):
        for j in range(i+1, R+1):
            if ans > (i*j) % 2019:
                print(i, j)
            ans = min((i*j) % 2019, ans)
    return ans

@mt
def slv2(L, R):
    ans = sys.maxsize
    for i in range(L, R+1):
        for j in range(i+1, R+1):
            if ans > (i*j) % 2019:
                print(i, j)
            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:
import numpy as np
L, R = list(map(int, input().split()))

min_val = 2019
for i in range(L, R):
  for j in range(i+1, R+1):
    val = (i*j)%2019
    if min_val > val:
      if min == 0:
        break
print(min_val)

Submission status: Wrong Answer

Solution code:
L,R= [int(i) for i in input().split()]
a = 2019
if (R-L+1)>=2019:
    print(0)
    exit(0)
l = L % 2019
r = R % 2019
M = L+(2019-l)

i = L
j = -1
if M<R:
    i = M
else:
    if l<r:
        i = L
    else:
        i = M
if -1==j:
    j = i+1
else:
    i = j-1
print((i*j)%2019)

Submission status: Wrong Answer

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: Wrong Answer

Solution code:
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right
 
# import numpy as np
# from scipy.misc import perm
# from scipy.misc import comb
 
def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W
 
# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]
 
INF = int(1e18)
MOD = int(1e9)+7 # 10^9 + 7
 
########
 
L, R = l_inpl()
L %= 2019
R %= 2019
 
if R<=L:
    R += L
 
ans = INF
for i in range(L, R+1):
    for j in range(i+1, R+1):
        ans = min(ans, (i*j%2019)%2019)
 
print(ans)

Submission status: Wrong Answer

Solution code:
L, R= list(map(int, input().split()))
# array = np.arange(L, R+1)


flg = True
min_ = 2019
for i in range(L,R):
    for j in range(i+1, R+1):
        if (i*j)%2019==0:
            print(0)
            flg = False
            break
        elif (i*j)%2019 < min_:
            min_ = (i*j)%2019
if flg:
    print(min_)

Submission status: Wrong Answer

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

if((r*(r-1))<2019): # ok
    min = (l*(l+1)) % 2019
    print('a')

elif(int(((r-1)*r)/2019) == int((l*(l+1))/2019)): # ok
    min = (l * (l+1)) % 2019
    print('b')

elif((r-l)>2 and (int(l/673) != int(r/673))):
    min = 0
    print('c')

else:
    min = (l * (l+1)) % 2019
    print('d')



print(min)

Submission status: Wrong Answer

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

if L < 3 and 673 <= R:
    print(0)
else:
    mods = []
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            m = (i * j) % NUM
            mods.append(m)
            if m == 1:
                print(1)
                exit()
    print(min(mods))

Submission status: Wrong Answer

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

for i in range(L, R+1):
    for j in range(i+1,R+1):
        tmp = (i*j) % 2019
        if tmp < result:
            result = tmp
            break;

print(result)

Submission status: Wrong Answer

Solution code:
def solve():
  L, R = map(int, input().split())
  ans = 2019
  for i in range(L, R):
    for j in range(i + 1, R + 1):
      v = i * j % 2019
      if v < ans: ans = v
      if ans == 0: return
  return ans

print(solve())

Submission status: Wrong Answer

Solution code:
L, R = [int(x) for x in input().strip().split()]

new_L = (L*(L+1)) % 2019
new_R = (R*(R-1)) % 2019
num_range = new_R - new_L
if num_range >= 2019 or new_L > new_R or L == 0: print(0)
else: print(new_L)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
ans = 10 ** 9
b = min(L + 2020, R)
for i in range(L, b + 1):
    for j in range(1, b - L + 1):
        ans = min(ans, i * (i + j) % 2019)
print(ans)

Submission status: Wrong Answer

Solution code:
# ABC133-C

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  l,r=LI()

  a=[]
  for i in range(l,min(r+1,l+2019+1)):
    a.append(i%2019)

  a.sort()
  return a[0]*a[1]

print(main())

Submission status: Wrong Answer

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

l_mod = l % 2019
r_mod = r % 2019

if l_mod >= r_mod:
    print(0)
else:
    min_val = 2020
    for i in range(r_mod - l_mod + 1):
        for j in range(r_mod - l_mod + 2):
            
            if i >= j:
                 continue
#            print([l_mod+i,l_mod+j])
            min_val = min([min_val, ((l_mod+i)*(l_mod+j))%2019])
#            print(((l_mod+i)*(l_mod+j))%2019)
            
    print(min_val)

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

Submission status: Wrong Answer

Solution code:
import sys
import math
import itertools

input = sys.stdin.readline


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

    l = l % 2019
    r = r % 2019
    if r < l:
        print(0)
        return
    else:
        num = [i for i in range(l, r + 1)]
        min_ = 2019
        for i, n in enumerate(num):
            for j in num[i + 1 :]:
                min_ = min([n * j % 2019, min_])
    print(min_)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
l, r = map(int, input().split())
def doit(l, r):
  #print(l, r, file=sys.stderr)
  l = l % 2019
  r = r % 2019
  if r <= l:
    r += 2019
  #  if r < l:
  #    r = r2
  #print(l, r, file=sys.stderr)

  res = 2019
  for x in range(l, r):
    for y in range(x + 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(l, r))

Submission status: Wrong Answer

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:
    r+=2019
    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: Wrong Answer

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

d1 = (3 - L % 3) % 3
d2 = (673 - L % 673) % 673
if L + d1 <= R and L + d2 <= R:
    print(0)
else:
    r = L % 2019
    print(r * (r+1) % 2019)

Submission status: Wrong Answer

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: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def solve():
  L, R = map(int, input().split())
  ans = 2019
  for _i in range(L, R):
    i = _i % 2019
    v = i * (i + 1) % 2019
    for _j in range(_i + 1, R + 1):
      if v < ans: ans = v
      v += i
      v %= 2019
      if ans == 0: return
  return ans

print(solve())

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
L,R=map(int,input().split())
mod=2019
ans=[]
if R-L>2017:
    print(0)
elif L%mod>R%mod:
    print(0)
else:
    if R//673!=L//673:
        print(min(L*(L+1)%mod,(((R//673)*673)*((R//673)*673+1))%mod,(((R//673)*673)*((R//673)*673-1))%mod))
    else:
        print(L*(L+1)%mod)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

#i*jmodk=(imodk*jmodk)modk

#l以上r以下の整数で2019の倍数を含むものがあれば、imod2019=0となるiを選ぶことでijmod2019=0になり、最小

#r-lが2018以上ならかならず、imod2019=0となるiか、jmod2019=0となるjが存在する

if r-l>2020:
    print(0)
elif l%2019==0:
    print(0)
elif r%2019==0:
    print(0)
elif l%3==0 and r%673==0:
    print(0)
elif r%3==0 and l%673==0:
    print(0)


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

Submission status: Wrong Answer

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

d1 = (3 - L % 3) % 3
d2 = (673 - L % 673) % 673
if L + d1 <= R and L + d2 <= R:
    print(0)
else:
    r = L % 2019
    print(2 * r % 2019)