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:
import numpy as np

if __name__ == "__main__":
    x = list(map(int, input().split()))
    #print(x[0], x[0]%2019)
    #print(x[1], x[1]%2019)
    a1 = 0
    a2 = 0
    m1 = 2019
    m2 = 2019

    for i in range(x[1]-x[0]+1):
        #print(i+x[0])

        v = (i+x[0]) % 2019
        if v < m1:
            m2 = m1
            m1 = v
            #print(m1, m2)
            a2 = a1
            a1 = i+x[0]
        elif v < m2:
            m2 = v
            #print(m1, m2)

            a2 = i+x[0]

        if m1 == 0 or m2 == 0:
            #print('break')
            break
    #print(a1, a2)
    print((a1*a2)%2019)

Submission status: Wrong Answer

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

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

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

list673 = []
for i in range(5000000):
    list673.append(673 * i)

answer = (L * (L + 1)) % 2019
for l673 in list673:
    if L <= l673 and l673 <= R:
        for i in [1, 2, 3]:
            if L <= l673 - i and (l673 - i) % 3 == 0:
                answer = 0
                break
            elif l673 + i <= R and (l673 + i) % 3 == 0:
                answer = 0
                break
    if answer == 0:
        break

if L == 0:
    answer = 0

print(answer)

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

l2 = l//2019
r -= 2019*l2
l %= 2019

if r>= 2019:
  print(0)
else:
  print(l*(l+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: Wrong Answer

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

minm = 100000000


arr1 = [(i[0]*i[1]) % 2019 for i in  itertools.permutations(arr, 2)]

if not arr1:
    print((L*R)%2019)
    sys.exit()
print(arr[0])

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
            print(mod)
            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())
if l <= 2019 and 2019 <= r:
    print(0)
elif l > 2019:
    if (r-l) >= 2018:
        print(0)
    else:
        num = 2019
        for i in range(l, r+1):
            for j in range(i+1, r+1):
                ans = (i*j)%2019
                if ans < num:
                    num = ans
        print(num)

Submission status: Wrong Answer

Solution code:
def main():
    l, r = map(int, input().split(' '))
    if (r - l) >= 2019:
        ans = 0
    else:
        ml = l % 2019
        mr = r % 2019
        if ml >= mr:
            ans = 0
        elif ml <= 673 <= mr and mr - ml >= 2:
            ans = 0
        else:
            ans = (ml * (ml + 1)) % 2019
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
l,r=map(int,input().split())
nl=2019*(l//2019)
nr=2019*((l//2019)+1)

if l <= 2019*((l//2019)+(1 if l%2019!=0 else 0)) <= r:
  print(0)
elif r-l==1:
  print(r*l)
else:
  i=l if l-nl <= nr-r else r
  #変化量
  v=l-nl if i==l else nr-r
  f=i%2019
  syu=round(f/v)+1
  if i==l:
    firstmin=min((i*syu)%2019,(i*syu+1)%2019)
  else:
    firstmin=min((i*syu)%2019,(i*syu-1)%2019)
  print(firstmin)

Submission status: Wrong Answer

Solution code:
import math

l, r = map(int, input().split())
e = 2019
e1 = 3
e2 = e // e1
eps = 10**(-11)
if r-l == 1:
    print(l*r % e)
else:
    if divmod(l,e2)[0] < divmod(r,e2)[0]:
        print(0)
    else:
        print(l*(l+1) % e)

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
if L % 2019 == 0 or R % 2019 == 0:
    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 = (int(x) for x in input().split())

temp = []

for i in range(L, R+1):
    if not ((i%2019) in temp):
        temp.append(i%2019)
    else:
        break

temp.sort()
if temp[0] == 0:
    del temp[0]

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

Submission status: Wrong Answer

Solution code:
import math
def serch(l, r):
    min_x = (l*l + l) % 2019
    for i in range(l+2, r):
        a = l * i
        if(a % 2019 < min_x):
            min_x = a
    return min_x

def solve():
    l, r = map(int, input().split())
    l_div = l // 2019
    r_div = r // 2019
    if(l_div != r_div):
        print(0)
    else:
        a = r % 2019
        b = a - 1
        if(a*b < 2019):
            print((l*l + l) % 2019)
        else:
            min_x = 2020
            for i in range(l, r):
                a  = serch(i, r)
                if(a < min_x):
                    min_x = a
            print(min_x)



if __name__ == "__main__":
    solve()

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 * param_res2) % 2019
print(res)

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

tmp = 0
ans = 100000

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 (R + 2019 - R%2019) - 1 >= L:
	if L <= R + 2019 - R % 2019 - 1 and R + 2019 - R % 2019 <= 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 = list(map(int, input().split()))

check = 0
key1 = 0
lm1 = min(2020, r)
for i in range (lm1):
  check = l+i
  if check % 2019 == 0:
    key1 = 1

lm2 = min(4, r)
key2 = 0
for j in range(lm2):
  check = l+j
  if check % 3 == 0:
    key2 = 1

lm3 = min(674, r)
key3 = 0
for k in range(lm3):
  check = l+k
  if check % 673 == 0:
    key3 = 1
    
#print(key1,key2,key3)
if (key1 == 1 or (key2 == 1 and key3 ==1)):
  print(0)
else:
  print((l*(l+1))%2019)

Submission status: Wrong Answer

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


i = L
j = R

a=abs(i-2019)
b=abs(j-2019)

if(i*j<2019):
    ans =i*j
elif(L<2019 and R >=2019):
    ans=0
elif(j-i>= 2019):
    ans=0
else:
   
  if(a<=b):
       ans=a*(a+1)%2019
  elif(b<a):
       ans=b*(b-1)%2019
print(ans)

Submission status: Wrong Answer

Solution code:
L,R=(int(x) for x in input().split())
ans=[]
for n in range(2019):
    if L+n>=R:
        break
    a=(L+n)%2019
    b=(L+n+1)%2019
    c=a*b%2019
    ans.append(c)
print(min(ans))

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 = 1
print(ans)

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

L%=2019
while(R-L>2019):
  R-=2019
  
#print(L,R)
answer=10**10
for i in range(L,R):
  for j in range(i+1,R+1):
    answer=min(answer,(i*j)%2019)
    
print(answer)

Submission status: Wrong Answer

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

min = 2*(10**9)+1


sa = R - L


for i in range(L, R):
    l = i % 2019
    for j in range( l+1, l + sa + 1):
        if(l <= 2019//j and j!=l+1 ):
            continue
        a = (l*j) % 2019
        if(min >= a):
            min = a

print(min)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np 

L, R = list(map(int, input().split()))
data = np.array([x for x in range(L, R+1)]) % 2019

if np.where(data == 0):
    print(0)

else: 
    data = np.sort(data)
    min_mod = (data[0] * data[1]) % 2019
    print(min_mod)

Submission status: Wrong Answer

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

list673 = []
for i in range(3000000):
    list673.append(673 * i)

answer = (L * (L + 1)) % 2019
for l673 in list673:
    if L <= l673 and l673 <= R:
        for i in [1, 2, 3]:
            if L <= l673 - i and (l673 - i) % 3 == 0:
                answer = 0
                break
            elif l673 + i <= R and (l673 + i) % 3 == 0:
                answer = 0
                break
    if answer == 0:
        break

if L == 0:
    answer = 0

print(answer)

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

print(m * (m + 1))

Submission status: Wrong Answer

Solution code:
# prob C

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

def mod(n):
    return n % 2019


if diff >= 2018:
    print(0)
else:
    m = sorted(list(map(mod, list(range(l % 2019, (l % 2019) + diff + 1)))))
    print(min(m[0]*m[1] , (2019 - m[-1])*(2019 - m[-2])))

Submission status: Wrong Answer

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

min_45 = 44
min_2019 = 2018
i_3 = -1
i_673 = -1
for i in range(l, r+1):
    if i % 45 < min_45 % 45 and i % 45 != 0:
        min_i = i
    if i % 2019 < min_2019 % 2019:
        min_2019 = i
    if i % 2019 == 3:
        i_3 = i
    if i % 2019 == 673:
        i_673 = i

if i_3 != -1 and i_673 != -1:
    print(0)
else:
    print(min((min_45 * (min_45+1)) % 2019, (min_2019 * (min_2019+1)) % 2019))

Submission status: Wrong Answer

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

a = R % 2019
b = L % 2019

if a > 2019 // 2:
    a = 2019 - a
if b > 2019 // 2:
    b = 2019 - b

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
b, c = map(int, input().split())

b_mod = b // 2019 
c_mod = c // 2019

if b_mod == c_mod:
    ans_r = b % 2019
    ans = (ans_r +1)*ans_r
    print(ans)
else:
    ans = 0
    print(ans)

Submission status: Wrong Answer

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

mod = 2019
for i in range(100):
  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: Wrong Answer

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

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

min_j = (min_i + 1) % 2019

print(min_i * (min_j) % 2019)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ret = 2019

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

Submission status: Wrong Answer

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

COUNT=2019
NUMBER=0

for i in range(L,R+1):
  for j in range(i+1,R+1):
    
    NUMBER=i*j%2019
    #print(i,j,NUMBER)
    if COUNT>NUMBER:
      COUNT=NUMBER
      #print(i,j,NUMBER)

    
print(COUNT)

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):
                res = l*(l+1)
            l += 1
        print(res)

Submission status: Wrong Answer

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

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

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):
        temp2 = ((R - i) * (R - i - 1)) % 2019
        if temp2 < temp1:
            temp1 = temp2
    print(temp1)
else:
    temp1 = float("inf")
    for i in range(2019):
        temp2 = ((R - i) * (R - i - 1)) % 2019
        if temp2 < temp1:
            temp1 = temp2
    print(temp1)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

tmp = 0
ans = 100000

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 (R + 2019 - R%2019) - 1 >= L:
	if L <= R + 2019 - R % 2019 - 1 and R + 2019 - R % 2019 <= 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

i = L
j = R
tmp = (i * j) % 2019

if tmp < ans:
	ans = tmp

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

Solution code:
l, r = map(int,input().split())
MOD = 2019
ans = 10**9
lm, rm = l%MOD, r%MOD
for i in range(lm,rm):
    for j in range(i+1,rm+1):
        ans = min(ans,(i*j)%MOD)
print(ans)

Submission status: Wrong Answer

Solution code:
L, R = list(map(int, input().split()))
L_mod = L%2019
L_shou = L//2019
R_shou = R//2019
if L_shou == R_shou:
    print((L_mod*(L_mod+1))%2019)
else:
    print(0)

Submission status: Wrong Answer

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

i = min(ans)
j = i + 1
print((i*j)%2019)

Submission status: Wrong Answer

Solution code:

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

l %= 2019
r %= 2019

if r-l <= 0:
    print(0)
else:

    lr_min = 2018

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

    print(lr_min)

Submission status: Wrong Answer

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

while i <= R:
  if i % 2019 == 0:
    print(0)
    m=1
    break
  else:
    i += 1
if m==1:
  m=2
else:
  print(L*(L+1)%2019)

Submission status: Wrong Answer

Solution code:
l, r = map(int, input().split())
# m = 2 * (10 ** 9) + 1
# 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 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: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# 133 abc c
# input
l, r = map(int, input().split())
if r-l == 1:
    print(int((l*r) % 2019))
elif r-l+1 > 672:
    print(0)
else:
    print(min(int((l*(l+1)) % 2019), int((l*(l+2)) % 2019), int((l*(l+3)) % 2019)))

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

        ans = min(ansL, ansR)

    return int(ans)

print(main())

Submission status: Wrong Answer

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

if R-L > 2019:
    print('0')
if R - L == 1:
    print((R*L) % 2019)
else:
    for i in range(L, R):
        if (i % 2019) < mini:
            mini = i % 2019
            ans = i

    for j in range(L, R):
        if j == ans:
            continue
        if (j % 2019) < minib:
            minib = j % 2019
            ansb = j

    calc = ((ans%2019) * (ansb%2019)) % 2019
    print(calc)

Submission status: Wrong Answer

Solution code:
#C問題
L,R = map(int,input().split())
r = R%2019
l = L%2019
if R-L>=2019:
    print(0)
else:
    if r < l:
        print(0)
    else:
        MIN = 2018
        for i in range(r-l+1):
            I = i+l
            for j in range(r-l):
                J = j+l+1
                kari = (I*J)%2019
                MIN = min(MIN,kari)
        print(MIN)

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:
    print(L * (L + 1) % 2019)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
l, r = list(map(int, input().split()))
if l // 2019 == r // 2019:
    _l = l % 2019
    n = min(r - l + 1, 2019)
    a = list(range(_l, min(2019, _l + n)))
    a.extend(list(range(0, n - len(a))))
    a.sort()
    a0 = (a[0] * a[1]) % 2019
    a1 = (a[-1] * a[-2]) % 2019
    print(min(a0, a1))
else:
    print(0)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys

MOD = 2019

def solve(L, R):
    if L%MOD == 0 or R%MOD == 0:
        print(0)
        return

    if L%MOD > R%MOD:
        L, R = R%MOD, L%MOD
    else:
        L, R = L%MOD, R%MOD
    a, b = list(range(L, R+1))[0:2]
    ans = a*b % MOD
    print(ans)


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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:

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

for i in range(L,R+1):
    p.append(i)
    if i % 2019 == 0:
        print(0)
        exit()
c = 2020
#print(p)
for i in range(L,R):
    for j in range(i,R):
        #print(i,j)
        c = min(c,i*j%2019)
        
print(c)

Submission status: Wrong Answer

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

while(R-L>2019):
  R-=2019
  
#print(L,R)
answer=10**10
for i in range(L,R):
  for j in range(i+1,R+1):
    answer=min(answer,(i*j)%2019)
    
print(answer)

Submission status: Wrong Answer

Solution code:
S=input().split()
L=int(S[0])
R=int(S[1])
list=2018
L1=L
L2=L
while L2 <= R:
  while L1 <= R:
    if (L1*L2)%2019 <= list:
      list = (L1*L2)%2019
    L1 += 1
  L1 =int(L)
  L2 += 1
print(list)

Submission status: Wrong Answer

Solution code:
def baisuaru(l,r,m):
  if l//m < r//m:
    return True
  elif l%m==0:
    return True
  else:
    return False
    

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


if baisuaru(l,r,2019):
  print(0)
else:
  if baisuaru(l,r,3) and baisuaru(l,r,673):
    print(0)
  else:
    print((l*(l+1)) % 2019)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
import math

l, r = map(int, input().split())
e = 2019
e1 = 3
e2 = e // e1
eps = 10**(-11)
if r-l == 1:
    print(l*r % e)
else:
    if math.ceil((l+eps)  / e2) < math.ceil((r+eps) / e2):
        print(0)
    else:
        print(l*(l+1) % e)

Submission status: Wrong Answer

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

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

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):
        temp2 = ((R - i) * (R - i - 1)) % 2019
        if temp2 < temp1:
            temp1 = temp2
    print(temp1)
else:
    temp1 = float("inf")
    for i in range(2019):
        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):
  print(0)
else:
  res = []
  for num in range(l, r + 1):
    res.append(num % 2019)
  res.sort()
  print(res[0] * res[1])

Submission status: Wrong Answer

Solution code:
import sys

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

if r-l+1 <3:
    imin = 10**9+7
    for i in range(r-l):
        for j in range(i+1,r-l+1):
            if imin > ((l+i)*(l+j))%2019:
                imin = ((l+i)*(l+j))%2019
    print(imin)
elif r-l+1 <673:
    if (l % 673)+r-l > 672:
        print(0)
    else:
        if l % 3 == 0 or l % 3 == 2:
            print((l % 673)*((l+1)% 673))
        else:
            print((l % 673)*((l+2)% 673))
else:
    print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

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


def solve(l, r):
    a, b = l % 2019, r % 2019
    if r - l >= 2019:
        return 0
    
    first = min(l % 2019, r % 2019)
    result = (first * (first + 1)) % 2019
    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())
p = l // 2019
if 2019 * (p + 1) <= r:
    print(0)
elif l - 2019*p < 2019 * (p + 1) - r:
    print(l*(l+1)%2019)
else:
    print(r * (r - 1) % 2019)

Submission status: Wrong Answer

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

list673 = []
for i in range(3000000):
    list673.append(673 * i)

answer = (L * (L + 1)) % 2019
for l673 in list673:
    if L <= l673 and l673 <= R:
        answer = 0
        for i in [1, 2, 3]:
            if L <= l673 - i and (l673 - i) % 3 == 0:
                answer = 0
            elif l673 + i <= R and (l673 + i) % 3 == 0:
                answer = 0

if L == 0:
    answer = 0

print(answer)

Submission status: Wrong Answer

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

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)
    print((tmp[0] * tmp[1]) % 2019)

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(l+a+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:
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 > 672:
    t2 = 0
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
    k = k%2019

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

Submission status: Wrong Answer

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

if((l%mod)<(r%mod)):
    for i in range(l,r-1):
        tmp = i*(i+1)%mod
        if(ans>tmp):
            ans = tmp
elif((l%mod)>=(r%mod)):
    for i in range(r,l+1):
        tmp = i*(i-1)%mod
        if(ans>tmp):
            ans = tmp
print(ans)

Submission status: Wrong Answer

Solution code:
# prob C

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

def mod(n):
    return n % 2019


if diff >= 2019:
    print(0)
else:
    m = sorted(list(map(mod, list(range(l % 2019, (l % 2019) + diff + 1)))))
    print(min(m[0]*m[1] , (2019 - m[-1])*(2019 - m[-2])))

Submission status: Wrong Answer

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