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 = 0
    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:
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

# import numpy as np
# from scipy.misc import perm
# from scipy.misc import comb

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

INF = int(1e18)
MOD = int(1e9)+7 # 10^9 + 7

########

L, R = l_inpl()
L %= 2019
R %= 2019

if R<=L:
    R += L

ans = INF
for i in range(L, R+1):
    for j in range(i+1, R+1):
        ans = min(ans, i*j%2019)

print(ans)

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 <= 672 and _R >= 673:
        return 0
    if _L <= 1344 and _R >= 1346:
        return 0
    if _L <= 673 and _R >= 675:
        return 0
    if _L <= 1346 and _R >= 1347:
        return 0
    smallest2 =  [L, L+1]
    return smallest2[0] * smallest2[1]

print(main(L,R))

Submission status: Wrong Answer

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

if abs(l - r) == 1:
    print(l * r % 2019)
else:
    lower = l // 2019
    upper = r // 2019
    start = l % 2019
    stop = r % 2019
    if 2019 * (lower + 1) < r:
        print(0)
    else:
        ans = 1000000
        if start == 0:
            print(0)
        elif stop == 0:
            print(0)
        elif stop < start:
            print(0)
        elif stop > start:
            if start * (start+1)%2019 < 10:
                print(start * (start+1)%2019)
            else:
                while stop > start:
                    total = stop * start % 2019
                    if total < ans:
                        ans = total
                    start += 1
                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
for i in reversed(range(a + 1, b + 1)):
    t = min(t, (b) * (i) % 2019)
    if i % 2019 == 0:
        break
print(t)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


def slv(L, R):
    m = []
    M = 673
    for i in range(L, R+1):
        m.append(i%M)
        if i % M == 0:
            return 0
    m.sort()
    return (m[0] * m[1]) % M

@mt
def slv2(L, R):
    ans = sys.maxsize
    for i in range(L, R+1):
        for j in range(i+1, R+1):
            if ans > (i*j) % 2019:
                print(i, j)
            ans = min((i*j)%2019, ans)
    return ans

def main():
    L, R = read_int_n()
    print(slv(L, R))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

L, R = map(int, input().split())
min_mod = 2019
if R - L < 2019:
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            mod = (i % 2019) * (j % 2019)
            if mod < min_mod:
                min_mod = mod
else:
    min_mod = 0
print(min_mod)

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 * 10, R)
ans = MOD
for i in range(l, r):
    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())
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:
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:
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=0
    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())

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

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

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+1, R+1):
            x = (i * j) % 2019
            if ans > x:
                ans = x
    print(ans)

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):
        return min(
            [(u_mods[X] * u_mods[Y]) % 2019 for Y in range(X + 1, length)]
        )
        # 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 >= 2019:
    print(0)
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)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

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 divL < divR:
    print(0)
elif modL1 < modR:
    print(modL * modL1)
else:
    print(modL * modR)

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,r):
		m = (i * j) % 2019
		if m < min:
			min = m

print(min)

Submission status: Wrong Answer

Solution code:
L,R=[int(_) for _ in input().split()]
if R-L>2018:
    print(2018*2018)
else:
    ans=0
    for i in range(L,R+1):
        ans=max([ans,i])
    print(ans*ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

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

        v = (i+x[0]) % y
        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((m1*m2)%y)

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

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

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

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

Submission status: Wrong Answer

Solution code:
import sys

L,R = map(int,input().split())
if R-L>673:
    print(0)
else:
    A =[]
    if L == 0 and R-L>1:
        L = 1
    else:
        print(0)
        sys.exit()
    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:
# -*- coding: utf-8 -*-
import numpy as np

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

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

Submission status: Wrong Answer

Solution code:
L,R=map(int,input().split())
length=R-L
start2019=L%2019
start673=L%673
if start673+length<673:
    print((start2019*(start2019+1))%2019)
elif length+1<3:
    print((start2019*(start2019+1))%2019)
else:
    print(0)

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
        
    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())
 
v = []

if l == 0:
    print(0)
if l*r < 2019:
    print(l*r)
else:
    for i in 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 = 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)):
    ans = min(i*(i+1)%2019,ans)
print(ans)

Submission status: Wrong Answer

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

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

while True:
    if 2019 * baisuc > R:
        break
    baisu.append(2019 * baisuc)
    baisuc += 1
while True:
    for i in baisu:
        if L <= i + count <= R:
            print(count + 1)
            exit(0)

    count += 1

Submission status: Wrong Answer

Solution code:
import numpy as np
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 = np.mod(i*j, 2019)
      if min_val > val:
        min_val = val
  print(min_val)

Submission status: Wrong Answer

Solution code:
A=list(map(int,input().split()))
C=[t*i%2019 for i in range((A[1]))
for t in range((A[1])+1)]
D=sorted(C)
print(D[0])

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

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

Submission status: Wrong Answer

Solution code:
#C
l,r = map(int,input().split())
a = l % 673
b = r % 673
if(a >= b):
    #print(0)
    print((l*(l+1))%2019)
elif(r-l >= 673):
    print((l*(l+1))%2019)
    #print(0)
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):
            for j in range(r-l):
                if l < r:
                    if res > (l*(l+1))%2019:
                        res = (l*(l+1))%2019
                r += 1
            l += 1
        print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
L,R=map(int, raw_input().split())
L%=2019
R%=2019

T=[]
ans=float("inf")
if L<R:
	T=range(L,R+1)
	l=len(T)
else:
	print 0
	quit()

for i in range(l):
	for j in range(i+1,l):
		ans=min(ans, (T[i]*T[j])%2019 )

print ans

Submission status: Wrong Answer

Solution code:
p=2019
l,r=map(int,input().split( ))
if l%p==0 or r%p==0 or (r-l) >= p:
	print(0)
else:
	x=r%p
	bb=r-x
	if bb>=l:
		print(0)
		exit(0)
	if l<p and r>p:
		print(0)
		exit(0)
	else:
		a,b=l,l+1
		print(((a%p)*(b%p))%p)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# 133C
"""
L<=i<=j<=R
(i×j)mod 2019
0≤L<R≤2×10^9
"""
 
L, R = map(int, input().split())
 
min2019 = 2019
for i in range(L, R):
    temp = min2019
    for j in range(R, i, -1):
        if (i * j) % 2019 > temp:
            break
        elif (i * j) % 2019 < min2019:
            min2019 = (i * j) % 2019
print(min2019)

Submission status: Wrong Answer

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

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 = 2019
    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 = map(int, input().split())
if r < 2019:
	print((l*(l+1)) % 2019)
	exit()
elif r-l >=  2019:
	print(0)
	exit()
elif r-l < 2019:
	if r % 2019 == 0 or l % 2019 == 0:
		print(0)
		exit()
	else:
		mini = 2018
		for i in range(0,r-l):
			for j in range(1,r-l+1):
				if i >= j:
					continue
				mod = ((l+i)*(l+j)) % 2019
				print(i,j)
				if mod < mini:
					mini = mod
print(mini)

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

Submission status: Wrong Answer

Solution code:
import math

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

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

else:
    if L!=0:
        a = math.floor(L/2019)
    else:
        a = 0
    b = math.floor(R/2019)
    if b!=a:
        print(0)
    else:
        Lmod = L - a*2019
        s = Lmod*(Lmod+1)
        print(s)

Submission status: Wrong Answer

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

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

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

lm3 = min(674, r-l+1)
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:
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]) % 2019)

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

Submission status: Wrong Answer

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

if (l<=2019 or r>=2019*2):
    print(0)
    exit(0)
if (r<2019):
    print(l*(l+1))
    exit(0)
if (l==2019 or r==2019):
    print(0)
    exit(0)
# if (l>=2019):
#     if (2019*2<=r and 2019*2>l):
#         print(0)
#         exit(0)
#     else:
#         print(l%2019*(l+1)%2019)

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
L,R = map(int,input().split(" "))
modnum = 2019
if(R-L+1>modnum):
    print(0)
else:
    diff_l = []
    for i in range(L,R+1):
        diff_l.append(i%modnum)
    diff_l = sorted(diff_l)
    print((diff_l[0]*diff_l[1])%modnum)

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

Submission status: Wrong Answer

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

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:
        for i in range(l,r):
            for j in (i+1,r+1):
                if i*j%2019==0:
                    print(0)
                    sys.exit(0)      
        ans=((min(i_l)%2019) * ((min(i_l)+1)%2019))%2019
        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:
    if l >= r:
        r += 2019
    for i in range(l,r):
        for j in range(i+1,r+1):
            temp = (i * j) % 2019
            if bool:
                min = temp
                ans = min
                bool = False
            elif min > temp:
                min = temp
                ans = min
print(ans)

Submission status: Wrong Answer

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

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
else:

	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

	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:
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:
        print(r*(r-1) % e)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

L,R = myinput_int()

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

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

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

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(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())
min_remainder = 2018
tmp = 0

for i in range(l, r+1):
    if i % 2019 < min_remainder:
        min_remainder = i % 2019
        tmp = i
        if min_remainder == 0:
            print(0)
            exit()

print((tmp*(tmp+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:
def mod_2019(L, R):
  year = 2019

  import numpy as np
  array = np.array([[i for i in range(L, R)]])
  if (array % year).min() == 0:
    return 0
  array_2d = np.dot(array.T, array)
  for i in range(len(array_2d[0])):
     array_2d[i][i] = 2019 -1
  return (array_2d % 2019).min()

L, R = (int(i) for i in input().split())
print(mod_2019(L, R))

Submission status: Wrong Answer

Solution code:
l, r = map(int, input().split())
if r - l >= 2019:
    print(0)
else:
    print("hage")

Submission status: Wrong Answer

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

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