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:
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
            res1 < res
            res = res1
        print(res)

Submission status: Wrong Answer

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

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

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

    count += 1

Submission status: Wrong Answer

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

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

modL=L%2019
modR=R%2019
LL=L//2019
RR=R//2019

distRL=R-L
distRRLL=RR-LL



if distRRLL>=2:
    #print("2:",distRRLL)
    i=L+2019-(modL)
    j=i*2
    #print(i,j)
elif distRRLL==1:
    #print("1:",distRRLL)
    i=L+2019-(modL)
    j=i+1
    #print(i,j)
else:
    if abs(modL-2019)<abs(modR-2019):
        i=modL
        j=modL+1
        #print(modL,modR)
        #print("modL",i,j)
    else:
        i=modR
        j=modR-1
        #print(modL,modR)
        #print("modR",i,j)
    
print(i*j%2019)

Submission status: Wrong Answer

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


list_a = []
for i in range(l,r+1):
    list_a.append(i)
list_b = []
for i in range(l,r+1):
    list_b.append(i%2019)
    
if min(list_b)==0:
    print(0)
else:
    min1=min(list_b)
    min2=min(list_b)+1
    ans=(min1*min2)%2019
    print(ans)

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 l == 0:
  print(2)
elif modl == modr:
    print((l*(l+1)) % mod)
else:
    print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
L,R=map(int,input().split())
num=2018
for i in range(L,R):
    for k in range(i+1,R+1):
        #print(k*i)
        if(R<L//2019*2019*2):
            num=L*(L+1)%2019
        if(i*k%2019==0):
            num=0
            break
        num=min(num,i*k%2019)
    #print("##")
print(num)

Submission status: Wrong Answer

Solution code:
str = input().split()
l_org = int(str[0])
r_org = int(str[1])

l = 2019
r = 2019

if (2019 > l_org):
	l = l_org
	
if (2019 > r_org):
	r = r_org

min = 2019

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

print(min)

Submission status: Wrong Answer

Solution code:
L,R = map(int, input().split())
def g(L,R):
    for i in range(L,R+1):
        yield i%2019

A = list(g(L,R))
A.sort
print(A[0]*A[1]%2019)

Submission status: Wrong Answer

Solution code:
import itertools
lr = list(map(int, input().split()))
l, r = lr[0] % 2019, lr[1] % 2019

nums = []

if l < r:
    while l <= r:
        nums.append(l)
        l += 1
else:
    c = 1
    while l < 2019:
        nums.append(l)
        l += 1
    while c <= r:
        nums.append(c)
        c += 1
    nums.append(0)
nums.sort()

moduluses = []
for i in list(itertools.combinations(nums, 2)):
    moduluses.append(i[0]*i[1] % 2019)
moduluses.sort()
print(moduluses[0])

Submission status: Wrong Answer

Solution code:
l,r=map(int,input().split())
if (l//2019) == (r//2019):
    l,r=l%2019,r%2019
    ans=(l*(l+1))%2019
    if l<=20 and 101<=r:
        ans=1
    print(ans)
else:
    print(0)

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(l3*(l3+1))

#for i in range()

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

Submission status: 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 = 0
    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:
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):
  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 = map(int, input().split())
mi = L
l_mod=int(L/2019)
r_mod=int(R/2019)
for i in range(l_mod, r_mod+1):
    if L <= 2019*i and 2019*i <= R:
        mi = 2019*i
        break


m_mod = mi%2019
if R-mi>=2019:
    m2_mod = 0
else:
    m2_mod = (mi+1)%2019


print(m_mod*m2_mod%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)
  elif(b<a):
       ans=b*(b-1)
print(ans)

Submission status: Wrong Answer

Solution code:
l, r = map(int, input().split())
diff = r - l
l = l % 2019
r = l + diff
if l == 0 or r >= 2019 or ((l % 673 == 0 or (l % 673 + diff) >= 673) and (l % 3 == 0 or (l % 3 + diff) >= 3)) :
  print(0)
else:
  print(l * (l + 1))

Submission status: Wrong Answer

Solution code:
s, e = map(int, input().split())
if s//2019 != e//2019: print(1)
else: print(s*(s+1)%2019)

Submission status: Wrong Answer

Solution code:
import math

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

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

Submission status: Wrong Answer

Solution code:
l, r = map(int, input().split())
step = r - l
mod = 2019
if step >= mod:
    print(0)
else:
    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:
n = list(map(int,input().split()))
i = n[0] % 2019
j = n[1] % 2019
k = n[0] % 673
l = n[1] % 673
if (n[1]-n[0] >= 2 and k >= l) or n[1] - n[0] >= 672 or i >= j:
  print(0)
elif n[1]-n[0] == 1 and (i*j)%2019 == 0:
  print(0)
else:
  print((i*(i+1))%2019)

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, r+1):
            _min = min(_min, i*j%mod)

print(_min)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
def main():
    L,R = map(int,input().split())
    LR = R-L
    M = []
    count = 0
    for i in range(LR):
        for j in range(LR):
            M.append(((L+i)*(L+1+j))%2019)
            if count == 2019:
                print(0)
                exit()
            count+=1
    print(min(M))
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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_res2 = L + tmp

        if param_res2 == R:
            param_res1 = L
        else:
            param_res1 = param_res2 + 1

    else:
        param_res1 = L
        param_res2 = L + 1


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

Submission status: Wrong Answer

Solution code:
def min_mod(l, r):
    tmp = [i % 2019 for i in range(l, min(l + 2020, r + 1))]
    tmp.sort()
    return (tmp[0] * tmp[1]) % 2019
 
 
l, r = map(int, input().split())
print(min_mod(l, r))

Submission status: Wrong Answer

Solution code:
import itertools
p=list(map(int,input().split()))

datalist=[]
for i in range(p[0],p[1]+1):
    datalist.append(i) 
ans = 2019 
for i in range(len(datalist)):
    for j in range(i+1,len(datalist)-1):
        l =datalist[i] * datalist[j] % 2019
        if ans > l:
            ans = l 
print(ans)

Submission status: Wrong Answer

Solution code:
l, r = map(int,input().split())
if l % 2019 == 0 or r % 2019 == 0:
    print(0)
    exit()
m = 2019
i = 0
for a in range(l, min(l+2019, r)):
    if a % 2019 < m:
        i = a
        m = a % 2019


A = (i % 2019) * ((i+1) % 2019) % 2019

m = 2019
i = 0
for a in range(max(l+1, r+1-2018), r+1):
    if a % 2019 < m:
        i = a
        m = a % 2019

B = (i % 2019) * ((i-1) % 2019) % 2019

print(min(A,B))

Submission status: Wrong Answer

Solution code:
a = input().split()
li = [int(i)for i in a]
mikk = float("inf")
for i in range(li[0],li[1]):
    for j in range(i+1,li[1]+1):
        k=(j*i) % 2019
        if k<mikk: 
            mikk=k 
        else:
            break
print(mikk)

Submission status: Wrong Answer

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

mod = 2019

for i in range(50):
  if L <= (3**i)%(1e9+7) <= R or L <= (673**i)%(1e9+7) <= R:
    print(0)
    exit()
for i in range(100):
  if 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:
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:
    a=l%2019
    b=r%2019
    ans=99999999
    for i in range(a,b+1):
      for j in range(a+1,b+1):
        tmpans=(i*j)%2019
        if ans>tmpans:
          ans=tmpans
    print(ans)

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(min(L,R),max(L,R)+1):
    for j in range(i,max(L,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)
else:
    print(MIN)

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+=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())
rem_list = []
if 4038 > r-l+1 >= 2019:
    print(1)
elif r-l+1 <= 2019:
    frag = 0
    for i in range(r-l+1):
        rem = (l+i)%2019
        if rem == 0:
            frag = 1
            continue
        rem_list.append(rem)
    if frag == 1:
        print(min(rem_list))
    else:
        re_rem_list = []
        for i in range(len(rem_list)-1):
             for j in range(len(rem_list)-i-1):
                re_rem_list.append((rem_list[i]*rem_list[j+1])%2019)
        print(min(re_rem_list))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

# n mod 2019 の答えは 0 ~ 2018 のいずれか
# それぞれのmodを取った積のmodでも同じ答えになる


def get_ans():
    # 差が2018以上なら積が0の組み合わせが存在する
    if R - L >= 2018:
        return 0

    # 各値のmodを取ってユニークにする
    mods = np.mod(np.arange(L, R + 1), 2019)
    u_mods = np.unique(mods)

    length = len(u_mods)
    # 総当たり
    ans = 2019
    # TLEだったので直した
    for X in range(length - 1):
        r = min([(u_mods[X] * u_mods[Y]) % 2019 for Y in range(X + 1, length)])
        if r < ans:
            ans = r
        # for Y in range(X + 1, length)
        #     mod = (u_mods[X] * u_mods[Y]) % 2019
        #     if mod < ans:
        #         ans = mod


print(get_ans())

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect
import sys
import random
import time
inf = 10**9


def main():
    l, r = list(map(int, input().split()))
    a = l % 2019
    b = r % 2019

    if a >= b:
        print(0)
        return

    ans = 2018

    if l-r >= 2018:
        for i in range(a, b+1):
            for j in range(i, b+1):
                ans = min(ans, i*j % 2019)
    else:
        for i in range(a, b):
            for j in range(i+1, b+1):
                ans = min(ans, i*j % 2019)

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
p = 2019
if (R-L+1)//p>=0:
    print(0)
else:
    c = L%p
    d = c+1
    print(c*d)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
s, e = map(int, input().split())
if s//2019 != e//2019: print(2)
else: print(s*(s+1)%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 and b-c <673:
    ans_r = b % 2019
    ans = (ans_r +1)*ans_r
    print(ans)
else:
    ans = 0
    print(ans)

Submission status: Wrong Answer

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

import copy
import math
import itertools

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

PPP = 1000000007

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

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

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

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

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

#cache = dict()

import re
import fractions

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

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([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())
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))%2019)

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

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+1):
        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:
if __name__ == "__main__":
    n, a = map(int, input().split())

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

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

    elif 2019 < n:
        print((n * (n+1)) % 2019)

Submission status: Wrong Answer

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

cnt = 0
ans = 10 ** 10
for i in range(L+1, R+1):
    if cnt >= 10 ** 7:
        break
    ans = min(ans, i * L % 2019)
    cnt += 1

print(ans)

Submission status: Wrong Answer

Solution code:
# (i%2019)*(j%2019)の最小値

l, r = map(int, input().split())
if r - l < 2019 * 2:
    for i in range(l, r + 1):
        if i % 2019 == 1:
            if i == r + 1:
                print((i * (i - 1)) % 2019)
                exit()
            else:
                print((i*(i+1)) % 2019)
                exit()
    print((l*(l+1) % 2019))
else:
    print(2)

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+=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= list(map(int, input().split()))
# array = np.arange(L, R+1)

def get_flg3():
    if R-L >= 3:
        return True
    elif R//3 != L//3:
        return True
    else:
        return False
    

def get_flg673():
    if R-L >= 673:
        return True
    elif R//673 != L//673:
        return True
    else:
        return False

def mataganai_2019():
    return (L*(L+1))//2019 == ((R-1)*R)//2019
        
if get_flg3() & get_flg673():
    print(0)
elif mataganai_2019():
    print('{}'.format(L*(L+1)%2019))
else:
    print(1)

Submission status: Wrong Answer

Solution code:
#!venv/bin/python
#from collections import defaultdict 
from itertools import combinations
import math
import datetime
L, R = [int(x) for x in input().split()]
MOD = 2019

l = L
r = min(l + MOD * 30, R)
ans = MOD
for i in range(l, r - 1):
    for j in (i + 1, r):
        mod = (i * j) % MOD
        if mod < ans:
            ans = mod
print(ans)

Submission status: Wrong Answer

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

mod = 2019

for i in range(20):
  if L <= (3**i)%(1e9+7) <= R or L <= (673**i)%(1e9+7) <= R:
    print(0)
    exit()
for i in range(100):
  if 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:
import sys
 
n, r = map(int, input().split())
if abs(n - r) == 1:
  print((n * r) % 2019)
  sys.exit(0)
min = 2019
nM = n % 2019
rM = r % 2019
if nM == 0 or rM == 0:
  print(0)
  sys.exit(0)
for i in range(nM, rM):
  for j in range(i+1, rM):
    if ((i * j) % 2019) < min:
      min = (i * j) % 2019
    if min == 0:
      print(0)
      sys.exit(0)
print(min)

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

Submission status: Wrong Answer

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

if R - L >= 2050:
    print(0)
elif R == L:
    print(0)
else:
    ans = 2000
    for i in range(L, R+1):
        for j in range(i, R+1):
            x = (i * j) % 2019
            if ans > x:
                ans = x
    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
else:
    ans = tmp
print(ans)

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:
    a=l%2019
    b=r%2019
    ans=99999999
    for i in range(a,b+1):
      for j in range(a+1,b+1):
        tmpans=(i*j)%2019
        if ans>tmpans:
          ans=tmpans
    print(tmpans)

Submission status: Wrong Answer

Solution code:
l,r = map(int,input().split(" "))
a = l%2019
b = l//2019
if 2019*(b+1) < r:
    print(0)
else:
    print(l*(l+1)%2019)

Submission status: Wrong Answer

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

L%=2019
R%=2019
for i in range(L,R+1):
    for j in range(L+1,R+1):
        if((i==L and j==L+1) or min>i*j%2019):
            min=i*j%2019

print(min)

Submission status: Wrong Answer

Solution code:
str = input().split()
l_org = int(str[0])
r_org = int(str[1])

l = 2019
r = 2019

if (2019 > l_org):
	l = l_org
	
if (2019 > r_org):
	r = r_org

min = 2019

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

print(min)

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

Submission status: Wrong Answer

Solution code:
import math
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect
import sys
import random
import time
inf = 10**9


def main():
    l, r = list(map(int, input().split()))
    a = l % 2019
    b = r % 2019

    if a >= b:
        print(0)
        return

    ans = 2018

    if l-r > 2019:
        for i in range(a, b+1):
            for j in range(i, b+1):
                ans = min(ans, i*j % 2019)
    else:
        for i in range(a, b):
            for j in range(i+1, b+1):
                ans = min(ans, i*j % 2019)

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
l,r = list(map(int,input().split()))
f = [0]*2020
x = []
if r-l == 1:
    print(((r%2019)*(l%2019))%2019)
    exit()
for i in range(l,r+1):
    n = i%2019
    if f[n] == 0:
        x.append(n)
        f[n] = 1
    else:
        break
x.sort()
ans = 2020
for i in range(len(x)-1):
    ans = min(x[i]*(x[i+1])%2019,ans)
print(ans)

Submission status: Wrong Answer

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

if L == 0:
  print(0)
  exit()
elif R - L == 1:
  print((L*R)%2019)
  exit()
  
for a in range(L,R+1):
  if a%2019 == 0:
    print(0)
    exit()

print(2)

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+200

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

print(low)

Submission status: Wrong Answer

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

minnum = 3000
a = 3000
b = 3000
count = 0
for i in range(3):
    for j in range(i+1,4051):
        c = ((l + i)*(l + j))%2019
        a = min(a,c)
        b = min(max(a,c),b)
print(a*b)

Submission status: Wrong Answer

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

print(val)

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 <672:
    if (l % 673)+r-l > 672:
        print(0)
    else:
        print(min((l % 673)*((l+1)% 673),(l % 673)*((l+2)% 673),((l+2) % 673)*((l+1)% 673)))
else:
    print(0)

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):
            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:
l,r =map(int,input().split())

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

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]) % 2019)

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*j%2019)
        print(min(m_l))

Submission status: Wrong Answer

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

if l > 2018:
    l = l%2019
if r > 2018:
    l = l%2019    

ls = [2018]

for i in range(l,r):
    for j in range(i+1,r+1):
        if (i*j) % 2019 < min(x%2019 for x in ls):
            ls.append(i*j)
        
print(min([ x%2019 for x in ls]))

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
p = 2019
if (R-L+1)//p>0:
    print(0)
else:
    c = L%p
    d = c+1
    print(c*d)

Submission status: Wrong Answer

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

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


output=0


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


print(output)

Submission status: Wrong Answer

Solution code:
l,r = map(int,input().split(" "))
a = l%2019
b = l//2019
if 2019*(b+1) <= r:
    print(0)
else:
    print(l*(l+1)%2019)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

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

    if (l % 2019 < 1010) and (r % 2019 < 1010):
        print((l * (l + 1)) % 2019)
    elif (l % 2019 > 1010) and (r % 2019 > 1010):
        print((r * (r + 1)) % 2019)
    elif (l % 2019 < 1010) and (r % 2019 > 1010):
        if (l % 2019) < (2019 - r % 2019):
            print((l * (l + 1)) % 2019)
        elif (l % 2019) > (2019 - r % 2019):
            print((r * (r + 1)) % 2019)
        else:
            print((l * r) % 2019)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

tmp = 0
ans = 2019

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

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

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

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

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

print(ans)

Submission status: Wrong Answer

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

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