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:
from sys import stdin

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

    if R - L > 2018:
        print(0)
        return

    mod = []
    for i in range(L, R + 1):
        mod.append(i % 2019)
    mod.sort()
    print((mod[0] * mod[1]) % 2019)

input = lambda: stdin.readline()
main()

Submission status: Wrong Answer

Solution code:
L,R =(int(x) for x in input().split())
if(L<=3 and R>=673):
    print(0)
elif(L<2019<R):
    print(1)
else:
    print((L*(L+1))%2019)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

ans = (L * (L + 1)) % MOD
for i in range(L, L + 5000):
    for j in range(L + 1, L + 5000):
        if (i > R) or (j > R):
            continue
        ans = min(ans, (i * j) % MOD)

print(ans if ans != float('inf') else 0)

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
m = 673
if R // m - (L - 1) // m != 0:
    print(0)
else:
    minnum = 1000
    Lmod = L % 2019
    Rmod = R % 2019
    for i in range(Lmod, Rmod+1):
        for j in range(i + 1, Rmod+1):
            #print(i, j, (i * j) % 2019)
            minnum = min(minnum, (i * j) % 2019)
    print(minnum)

Submission status: Wrong Answer

Solution code:
l,r=map(int,raw_input().split())
if l<2019 and r<2019:
  print(((l%2019)*(r%2019))%2019)

elif min(l,r)<2019 and max(l,r)>2019:
  print('0')
  
else:
  if (r-l)>=2019:
    print('0')
  else:
  	print(((l%2019)*((l+1)%2019))%2019)

Submission status: Wrong Answer

Solution code:
L,R = map(int, input().split())
MOD = 2019
mL = L%MOD
mR = R%MOD
if mL>=mR:
    mR +=MOD
min_mod = MOD+1
#print(mL, mR)
for i in range(mL, mR):
    for j in range(i+1, mR+1):
        min_mod=min(i*j%MOD, min_mod)
        #print(i, j)
print(min_mod)

Submission status: Wrong Answer

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

tmp = L % 2019
param_res1 = 0
param_res2 = 0

if tmp == 0:
    param_res1 = L
    param_res2 = L + 1
else:
    if L + (2019 - tmp) <= R:
        param_res1 = L
        param_res2 = L + tmp
    elif tmp < 1010:
        param_res1 = L
        param_res2 = L + 1
    else:
        param_res1 = R
        param_res2 = R - 1


res = ( (param_res1 % 2019) * (param_res2 % 2019) ) % 2019
print(res)

Submission status: Wrong Answer

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

L1 = L % 2019
R1 = R % 2019
i = L1 * (L1+1)
j = (R1-1) * R1
if i // K != j // K:
    print(0)
else:
    print(i % K)

Submission status: Wrong Answer

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

L = L%2019
R = R%2019
MIN = 2020

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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)
elif (R%2019) > (L%2019):
    i = 0
    ls = []
    while R > L:
        ls.append(R%2019)
        if ls[i] < ls[i-1]:
            print(ls[i]%2019 + 1)
            break
        R += 1
else:
    i = 0
    ls = []
    while R > L:
        ls.append(L%2019)
        if ls[i] < ls[i-1]:
            print(ls[i]%2019 + 1)
            break
        L += 1

Submission status: Wrong Answer

Solution code:
import numpy as np

L, R = map(int, input().split())
modL = L % 2019
modR = R % 2019

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

Submission status: Wrong Answer

Solution code:
l, r = map(int, input().split())
ans = []
l = l % 2019
r = r % 2019
if l > r:
    r, l = l, r

for i in range(l, r):
    for j in range(i + 1, r + 1):
        ans.append((i * j) % 2019)
print(min(ans))

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 + 1):
            
#             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 = [int(x) for x in input().split()]
l = l
r = r % 2019

ret = 2019

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

Submission status: Wrong Answer

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

    print(val)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#入力
i, j = map(int, input().split())
#前処理
i_mod = i % 2019
 
 
pool = []
for value in range(j-i):
  pool.append(((i_mod+value+1)*i_mod)%2019)

 
print(min(pool))

Submission status: Wrong Answer

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

if l < 2020:
  print(0)
elif r - l > 2019:
  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: Wrong Answer

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


print(LR[0]*(LR[0]+1)%2019)

Submission status: Wrong Answer

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: 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
    mod_min = 0

print(mod_min)

Submission status: Wrong Answer

Solution code:

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


gap = y-x
F = 0
t = x%2019
e = y%2019

tq = x%673
eq = y%673

m = min(t,e)
M = max(t,e)

mq = min(tq,eq)
Mq = max(tq,eq)

t2 = 2200
t1 = (m*(m+1))%2019
if gap > 2 and (eq < tq):
    t2 = 0

k = 2200 
if gap <= 2 and (eq < tq):
    k = 1
    for i in range(x,y+1):
        k*=i
    if k%2019 == 0:
        k = 0
    else:
        k = 2022

print(min(t1,t2,k))
# print((t1,t2,k))

Submission status: Wrong Answer

Solution code:
import sys

L,R = map(int,input().split())
if L == 0:
    print(0)
elif R-L>673:
    print(0)
else:
    A =[]
    for i in range(R-L+1):
        n = (L+i)
        if n % 673 == 0 and (R-L+1) >= 3:
            print(0)
            sys.exit()
        else:
            A.append(n%2019)
    A.sort()
    print((A[0]*A[1])%2019)

Submission status: Wrong Answer

Solution code:
def hantei3(w,L,R):
    if w>=2:
        return True
    for i in range(L,R+1):
        if i%3==0:
            return True
    return False

def hantei673(w,L,R):
    if w>=672:
        return True
    for i in range(L,R+1):
        if i in [673,1346]:
            return True
    return False

L,R=map(int,input().split())
w=R-L
L%=2019
R%=2019
if w>=2018 or L>R:
    print(0)
else:
    if hantei3(w,L,R) and hantei673(w,L,R):
        print(0)
    else:
        ans=[x*(x+1)%2019 for x in range(L,R)]
        print(min(ans))

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

'''
2020, 2040 の場合、2020 * 2021 ～ 2020 * 2040 までの数値が候補
最小の 2020 * 2021 を考えた場合

(2019 + 1) * (2019 + 2)
= x^2 + 3x + 2
に分解できるので、2019(=x) の剰余は、２項それぞれにおける 2019に対する余りの値同士の乗算が候補として考えられる

(2019*n + 1) * (2019*m)
= nmx^2 + mx

L + 1 と R との間に 2019(=x) の倍数値(例：mx) が入り込んでいるなら、余りの値が片方ゼロなので、候補値もゼロとなる

(2019*n + 1) * (2019*m+1)
= nmx^2 + (n+m)x + 1
'''

divL, modL = L // 2019, L % 2019
divR, modR = R // 2019, R % 2019

modL1 = modL + 1
if modL1 < modR:
    print(modL * modL1)
else:
    print(modL * modR)

Submission status: Wrong Answer

Solution code:
import math

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

mod = 2019

l = L % 2019
r = R % 2019


if l > r:
    print(0)
    exit()
else:
    _min = 2*1000000000+5
    for i in range(l, r):
        for j in range(i+1, r+1):
            _min = min(_min, i*j%mod)

print(_min)

Submission status: Wrong Answer

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

import copy
import math
import itertools

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

PPP = 1000000007

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

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

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

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

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

#cache = dict()

import re
import fractions

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

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

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

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

Submission status: Wrong Answer

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


def divisors(num):
    """
    約数全列挙
    """
    divisors = []
    for i in range(1, int(num ** 0.5) + 1):
        if num % i == 0:
            divisors.append(i)
            if i != num // i:
                divisors.append(num // i)

    return divisors


mod = 2019
tar = []
for i in range(1, 10 ** 6):
    tar.append(673 * i)

ans = float("inf")
f = -1
for t in tar:
    if L <= t <= R:
        f = t
        break

s = -1
for i in range(L, R + 1):
    if i != f and i % 3 == 0:
        s = i
        break

if f == -1 and s == -1:
    print((L * (L + 1)) % mod)
elif f == -1:
    print((L * (L + 1)) % mod)
elif s == -1:
    t = -1
    for i in range(L, R + 1):
        if i != f:
            t = i
            break
    print((f * t) % mod)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
import numpy as np

L, R = map(int, input().split())
modL = L % 2019
modR = R % 2019

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

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

print(ans)

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 + 2):
        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 = (int(i) for i in input().split())
mod = 2019
t,i = 0,1
lim = 10**9
while t<=lim:
    t = mod*i
    if l<=t<=r:
        print(0)
        exit()
    i+=1
print(min(l*(l+1)%mod,r*(r-1)%mod))

Submission status: Wrong Answer

Solution code:
MOD=2019

l,r=map(int,input().split()) #l<=i<i+1<=j<=r
res=2020
l=l%MOD
r=r%MOD
l,r=min(l,r),max(l,r)

for i in range(l,r+1):
  for j in range(i,r+1):
    res =min((i*j)%MOD,res)
print(res)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

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

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

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

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

print(ans)

Submission status: Wrong Answer

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

if (R - L) <= 2019:
    temp1 = float("inf")
    for i in range(R - L):
        if (R-i-1) < L:
            break
        temp2 = ((R - i) * (R - i - 1)) % 2019
        if temp2 < temp1:
            temp1 = temp2
    print(temp1)
else:
    temp1 = float("inf")
    for i in range(2019):
        if (R-i-1) < L:
            break
        temp2 = ((R - i) * (R - i - 1)) % 2019
        if temp2 < temp1:
            temp1 = temp2
    print(temp1)

Submission status: Wrong Answer

Solution code:
l,r = map(int,input().split())
if r-l >= 2019:
    temp = 0

l %= 2019
r %= 2019
ans = 99999999999999

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

Submission status: Wrong Answer

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

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

a, b = readmi()
t = 0xFFFFFFFF
for i in range(a + 1, b + 1):
    t = min(t, (a) * (i) % 2019)
    if i % 2019 == 0:
        break
print(t)

Submission status: Wrong Answer

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

tmp = L % 2019
param_res1 = 0
param_res2 = 0

if tmp == 0:
    param_res1 = L
    param_res2 = L + 1
else:
    if L + (2019 - tmp) <= R:
        param_res1 = L
        param_res2 = L + tmp
    elif tmp < 1010:
        param_res1 = L
        param_res2 = L + 1
    else:
        param_res1 = R
        param_res2 = R - 1


res = ( (param_res1 % 2019) * (param_res1 % 2019) ) % 2019
print(res)

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

ans = 10**20

for i in range(L,min(L+2019,R+1)):
    ans = min(ans,(i*(i+1))%2019)
for i in range(max(L,R-2019),R+1):
    if i < L or i > R:
        break
    ans = min(ans,(i*(i+1))%2019)
print(ans)

Submission status: Wrong Answer

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

if((r-1)*r<=2019):
    print(l*(l+1))
    exit()

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

low = 2*1e+9

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

print(low)

Submission status: Wrong Answer

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

base = 2019
l_mod = l % base
r_mod = r % base

if r - l >= base:
    print(0)
elif r_mod <= l_mod:
    print(0)
else:
    print(l_mod * (l_mod + 1))

Submission status: Wrong Answer

Solution code:
l,r = map(int,input().split())
ln = l // 2019
rn = r // 2019
if ln != rn :
    ans = 0
else :
    l = l % 2019
    r = r % 2019
    ld = min(l,abs(2019-l))
    rd = min(r,abs(2019-r))
    i = min(ld,rd)
    ans = i*(i+1)
print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin

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

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

    mod = []
    for i in range(L, R + 1):
        mod.append(i % 2019)
    mod.sort()
    print(mod[0] * mod[1])

input = lambda: stdin.readline()
main()

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
l = L % 2019
ans = l * (l + 1)
Lw = int(L / 2019)
Rw = int(R / 2019)
if Rw - Lw >= 1:
    ans = 0
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

i = l
j = l+1

t = r // 2019
if t > 0:
    if t > 1:
        j = 2019 * 1
        if j < l+1:
            j = l+1
        i = j-1
    else:
        i=l
        j=l+1

print((i*j)%2019)

Submission status: Wrong Answer

Solution code:
#入力
i, j = map(int, input().split())
#前処理
i_mod = i % 2019
 
 
pool = []
for value in range(j-i):
  pool.append(((i_mod+value+1)*i_mod)%2019)
  if value > 2019:
    break
 
print(min(pool))

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
m = 673
if R // m - (L - 1) // m != 0:
    print(0)
else:
    minnum = 1000
    Lmod = L % m
    Rmod = R % m
    for i in range(Lmod, Rmod+1):
        for j in range(i + 1, Rmod+1):
            #print(i, j, (i * j) % 2019)
            minnum = min(minnum, (i * j) % 2019)
    print(minnum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

L2, R2 = L % MOD, R % MOD
ans = float('inf')
for i in range(L, L + 4000):
    for j in range(L + 1, L + 4000):
        if (i > R) or (j > R):
            continue
        ans = min(ans, (i * j) % MOD)

if L == R:
    print((L * R) % MOD)
else:
    print(ans if ans != float('inf') else 0)

Submission status: Wrong Answer

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

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

elif L <= 2019 and  R >= 2019:   
  print(0)
  
else:  
  print((L*(L+1))%2019)

Submission status: Wrong Answer

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

L = L%2019
R = R%2019
MIN = 2020


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

Submission status: Wrong Answer

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:
                    listA.append(i%2019 * (L%2019 + j+1) % 2019)
    print(min(listA))

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 num_range == 0 or L == 0: print(0)
else:
    delim_L = new_L % 2019
    delim_R = new_R % 2019
    if delim_L > delim_R: print(delim_R)
    else: print(delim_R)

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 ):
        for j in range(r_mod - l_mod ):
            
            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:
#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:
    print((l*(l+1))%2019)

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
l = L % 2019
ans = l * (l + 1)
Lw = int(L / 2019)
Rw = int(R / 2019)
if Rw - Lw> 1:
    ans = 0
print(ans)

Submission status: Wrong Answer

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

if l <= 2019 <= r or r <= 2019 <= l:
  print(0)
  exit()

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

mini = 2*(1e+9)
print(l,r)
if l < r:
  for i in range(l,r+1):
    for j in range(i+1,r+1):
      print(i,j)
      mini = min(mini, (i*j) % 2019)
elif l > r:
  for i in range(r,l+1):
    for j in range(i+1,l+1):
      print(i,j)

      mini = min(mini, (i*j) % 2019)
elif l == r:
  print(l*r% 2019)
  exit(0)
print(mini)

Submission status: Wrong Answer

Solution code:
if __name__ == "__main__":
    n, a = map(int, input().split())

    if n % 2019 == 0 or a % 2019 == 0 or n * a % 2019 == 0 or (n < 2019 and 2019 < a):
        print(0)

    elif a < 2019:
        print((n * a) % 2019)

    elif 2019 < n:
        print((n % 2019) * ((n+1) % 2019) if (n % 2019) * ((n+1) % 2019) < (a % 2019) * ((a-1) % 2019) else print((a % 2019) * ((a-1) % 2019)))

Submission status: Wrong Answer

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

ml = (l % 2019)
mr = (r % 2019)
t = l + 2019
if r > t:
    m = 0
else:
    print(ml, mr)
    if ml < mr:
        for x in range(ml, mr):
            m = min(m, (x * (x+1)) % 2019)
    else:
        m = 0
print(m)

Submission status: Wrong Answer

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

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

# prime_factor = 3, 673
mod = 2019

if r // mod * mod >= l:
    print(0)

vals = set()
multiple_3 = False
multiple_673 = False
for i in range(l, r + 1):
    val = i % mod
    if val % 3 == 0:
        multiple_3 = True
    if val % 673 == 0:
        multiple_673 = True
    vals.add(val)

if multiple_3 and multiple_673:
    print(0)
    sys.exit(0)

ans = mod
val_list = list(vals)
for i in range(len(val_list)):
    for j in range(i + 1, len(val_list)):
        ans = min(ans, (val_list[i] * val_list[j]) % mod)
    if ans == 1:
        break

print(ans)

Submission status: Wrong Answer

Solution code:
n = list(map(int, input().rstrip().split(" ")))
if n[1] - n[0] >= 2019:
    print(0)
else:
    a = n[0]%2019
    b = n[1]%2019
    l = [i%2019 for i in range(a,b+1)]
    print(l.pop(l.index(min(l)))*l.pop(l.index(min(l))))

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline

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

def main():
    if R // 2019 != L // 2019:
        ans = 0
    else:
        # ansLi = L % 2019
        # ansLj = (L+1) % 2019
        # ansL = ansLi * ansLj

        # ansRi = R % 2019
        # ansRj = (R-1) % 2019
        # ansR = ansRi * ansRj
        ansL = L*(L+1) % 2019
        ansR = R*(R-1) % 2019

        ans = min(ansL, ansR)

    return int(ans)

print(main())

Submission status: Wrong Answer

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

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

    print(min(v))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

import math
L, R = map(int, input().split(' '))

def main(_L, _R):
    # find largest 2019N
    largest = math.floor(_R / 2019.0) * 2019
    if _L <= largest:
        return 0
    L = _L - largest
    R = _R - largest
    if _L <= 3 and _R >= 673:
        return 0
    smallest2 =  [L, L+1]
    return smallest2[0] * smallest2[1]

print(main(L,R))

Submission status: Wrong Answer

Solution code:
import sys

def input():
    return sys.stdin.readline().rstrip()

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

    n = r // 2019 - l // 2019

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

Submission status: Wrong Answer

Solution code:
L,R=map(int,input().split())
tmp=L
while tmp<R:
	if tmp%2019==0:
		print(0)
		exit()
	tmp+=(tmp+1)
if abs(L%2019)<abs(R%2019):
	print(L*(L+1)%2019)
else:
	print(R*(R-1)%2019)

Submission status: Wrong Answer

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

x=0
y=2019


if l >= 2019:
    for i in range(l,r+1):
        for j in range(i+1,r+1):
        #print(i,j)
            x=(i*j)%2019
            if y > x:
                y=x
    print(y)
else:
    print(l*(l+1))

Submission status: Wrong Answer

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

s = []
for i in range(l,r):
    s.append(i%mod)

s.sort()
if(l+1==r):
    ans = l*r%mod
else:
    ans=s[0]*s[1]

print(ans)

Submission status: Wrong Answer

Solution code:
l, r = map(int, input().split())
step = r - l
mod = 2019
value = (l * (l+1)) % mod
if step < mod - value:
    min_value = value
else:
    min_value = 0
print(min_value)

Submission status: Wrong Answer

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

listX = []
sw = 0
for i in range(1, 990590):
  listX.append(i*2019)

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

if sw > 0:
  print(0)

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

    print(val)

Submission status: Wrong Answer

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

P = 2019

l = L%P
r = R%P

print(max(1, r-(R-L-1))*l)

Submission status: Wrong Answer

Solution code:
l,r = map(int, input().split())
gap = r-l
 
vlist = []
mini = 2019
 
for x in range(gap+1):
    v = (l+x) % 2019
    vlist.append(v)
    if v == 0:
        print(0)
        exit()
 
vlist.sort()

mini = 2019

for i in vlist:
    for j in vlist:
        temp = (i*j) %2019
        mini = min(temp, mini)
        if mini == 0:
            print(0)
            exit()

print(mini)
    
#print((vlist[0]*vlist[1])%2019)
#print((vlist[0]*vlist[1])%2019)

Submission status: Wrong Answer

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

N = R - L + 1
r = L % 2019

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

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

an = m * (m + 1)
print(an % 2019)

Submission status: Wrong Answer

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

base = 2019
l_mod = l % base
r_mod = r % base

print(l_mod * (l_mod + 1))