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: Time Limit Exceeded

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

ans =[]
for i in range(L,R+1):
    for j in range(i+1,R+1):
        ans.append(i*j%2019)
print(min(ans))

Submission status: Time Limit Exceeded

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

j_cnt = 0
i_cnt = 0
i = L
j = L+1
min_num = 2020
while i <= R and i_cnt <= 2019:
    j = i+1
    while j <= R and j_cnt <= 2019:
        min_num = min(min_num,((i%2019)*j)%2019)
        j += 1
        j_cnt += 1
    i += 1
    i_cnt += 1
    j_cnt = 0
print(min_num)

Submission status: Time Limit Exceeded

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

N = 2019

if R - L == 1:
    print((R * L) % N)
    exit(0)

q = L // N
L_min = L % N
R_min = R - N * q

ans = 2019

for i in range(L_min, R_min):
    for j in range(i + 1, R_min + 1):
        mod = (i * j) % N
        if ans > mod:
            ans = mod

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
L,R = map(int,input().split())
m = float("inf")
for i in range(L,R+1):
    for j in range(i+1,R+1):
        m = min(m,(i*j)%2019)
        if m == 0:
            break
print(m)

Submission status: Time Limit Exceeded

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

x = R - L
L %= 2019
R = L + x

#print(L,R)

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

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

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

L,R = map(int,input().split())
lst = []

if L <= 2019 and R >= 2019:
    print(0)
else:
    for i in range(L,R+1):
        if i % 2019 == 0:
            print(0)
            break
        for j in range(i+1,R+1):
            if j % 2019 == 0:
                print(0)
            lst.append((i*j)%2019)
    print(min(lst))

Submission status: Time Limit Exceeded

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

L,R = map(int,input().split())
lst = []

if L <= 2019 and R >= 2019:
    print(0)
else:
    for i in range(L,R+1):
        for j in range(i+1,R+1):
            lst.append((i*j)%2019)
    print(min(lst))

Submission status: Time Limit Exceeded

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

mod = 2019
ans = mod
for i in range(l, r):
    res = 0
    for j in range(i+1, r+1):
        res = (i*j) % mod
        ans = min(ans, res)
    if res == 0:
        print(ans)
        exit()

print(ans)

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from fractions import gcd
from math import ceil, floor, sqrt
from copy import deepcopy

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

    for i in range(l,r+1):
        for j in range(i+1,r+1):
            if i%2019 == 0 or j%2019 == 0:
                ans = 0
                break
            else:
                ans = min(ans, (i*j)%2019)
    print(ans)
   
if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
def mod2019(x):
    return x%2019

L,R = list(map(int, input().split()))
a=list(set([mod2019(i) for i in range(L,R+1)]))
ans=2019
for i in range(len(a)):
    for j in range(i+1, len(a)):
        ans = min(ans, mod2019(a[i]*a[j]))
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
L,R = map(int,input().split())
ans = float('inf')

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

Submission status: Time Limit Exceeded

Solution code:
L,R = map(int,input().split())
ans = float('inf')

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

Submission status: Time Limit Exceeded

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

mod = 2019
min_num = float("inf")

tmp_L = L

while tmp_L < R and tmp_L <= L + 2019:
    tmp_R = tmp_L + 1

    while tmp_R <= R and tmp_R <= tmp_L + 2019:
        min_num = min((tmp_L*tmp_R)%mod ,min_num)
        tmp_R += 1
    tmp_L = tmp_L + 1

print(min_num)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

MOD = 2019
MIN = float('inf')
for i in range(L, R):
    for j in range(i+1, R+1):
        buf = (i*j) % MOD
        MIN = min(buf, MIN)

print(MIN)

Submission status: Time Limit Exceeded

Solution code:
L, R = map(int, input().split())
ans = 2018
END = False

for i in range(2019):
    j = i + 1
    while j <= R-L:
        ans = min( ((L+i)*(L+j)) % 2019, ans)
        j += 1
        if ans == 0:
            END = True
    if END or i > R-L:
        break

print(ans)

Submission status: Time Limit Exceeded

Solution code:
L, R = map(int, input().split())
ans = 2018
END = False

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

print(ans)

Submission status: Time Limit Exceeded

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

ans = 10 ** 9
for i in range(L, R):
  for j in range(i+1, R+1):
    tmp = (i*j)%2019
    if ans > tmp:
      ans = tmp
    if ans == 0:
      break
print(ans)

Submission status: Time Limit Exceeded

Solution code:

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

b = 2018
for i in range(L,R+1):
    for j in range(i+1,R+1):
        a = (i*j)%2019
        b = min(b,a)
        if b == 0:
            break
print(b)

Submission status: Time Limit Exceeded

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

if l == 0:
    print(0)
    quit()

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

print(ans)

Submission status: Time Limit Exceeded

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

if l == 0:
    print(0)
    quit()

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

print(ans)

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

a =[]
v=2019*2019

for i in range(x,r):
    for n in range(i+1,r+1):
        v=min(v,(i*n)%2019)


print(v)

Submission status: Time Limit Exceeded

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

a =[]

for i in range(x,r):
    for n in range(x+1,r+1):
        v=(i*n)%2019
        a.append(v)


k = min(a)

print(k)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
#mod = 10**9 + 7

mod=2019
l,r=MI()
mn=inf
mods=[]

#print(mods)
if l-r>=2018:
    ans=0
else:
    for i in range(l,r+1):
        mods.append(i%mod)
    for i in range(r-l+1):
        for j in range(i+1,r-l+1):
            u=(mods[i])*(mods[j])%mod
            if u<mn:
                mn=u
    ans=mn
print(ans)

Submission status: Time Limit Exceeded

Solution code:
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
#mod = 10**9 + 7

mod=2019
l,r=MI()
mn=inf
mods=[]
for i in range(l,r+1):
    mods.append(i%mod)
#print(mods)
if l-r>=2019:
    ans=0
else:
    for i in range(r-l+1):
        for j in range(i+1,r-l+1):
            u=(mods[i])*(mods[j])%mod
            if u<mn:
                mn=u
    ans=mn
print(ans)

Submission status: Time Limit Exceeded

Solution code:
l,r=map(int,input().split())
i=1
temp=0
while r>2019*i:
  if l<=2019*i:
    temp=1
    break
  i=i+1
i=1
temp1=0
while r>3*i:
  if l<=3*i:
    temp1=1
    break
  i=i+1
i=1
temp2=0
while r>673*i:
  if l<=673*i:
    temp2=1
    break
  i=i+1

if temp==1:
  print(0)
elif temp1==1 and temp2==1:
  print(0)
else:
  print(l%2019*(l+1)%2019)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
L, R = map(int, input().split())
a = 2020
for i in range(L,R+1):
    for j in range(i+1,R+1):
        ans = i*j%2019
        if(a > ans):
            a = ans
print(a)

Submission status: Time Limit Exceeded

Solution code:
l,r=map(int,input().split())
a=range(l,r+1)
m=float('inf')
for i in a:
    for j in range(i+1,r+1):
        m=min(m,(i*j)%2019)
print(m)

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
l, r = map(int, input().split())
ans = 2019
for i in range(l, r+1):
    for j in range(i+1, r+1):
        tmp = 0
        tmp = i * j % 2019
        ans = min(ans, tmp)
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

a = 0
ans = 10 ** 9
for i in range(L, R):
    for j in range(i + 1, R + 1):
        a = (i * j) % 2019
        ans = min(a, ans)
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
L, R = map(int, input().split())
ans = []

def calc_mod(x, y):
    return x * y % 2019

left = L % 2019
right = (R-L) + left

if left==0 or right==0:
    print(0)
    sys.exit(0)

for i in range(left, right):
    for j in range(i+1, right+1):
        ans.append(calc_mod(i, j))

print(min(ans))

Submission status: Time Limit Exceeded

Solution code:
import sys
L, R = map(int, input().split())
ans = []

def calc_mod(x, y):
    return (x % 2019) * (y % 2019) % 2019

for i in range(L, R):
    for j in range(i+1, R+1):
        x = calc_mod(i, j)
        ans.append(x)

print(min(ans))

Submission status: Time Limit Exceeded

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

def calc_mod(x, y):
    return (x%2019) * (y%2019) % 2019

for i in range(L, R):
    for j in range(i+1, R+1):
        ans.append(calc_mod(i, j))

print(min(ans))

Submission status: Time Limit Exceeded

Solution code:
a,b=map(int,input().split())
c=[]
for i in range(a,b+1):
  for j in range(a,b+1):
    if i<j:
        c.append((i*j)%2019)
print(min(set(c)))

Submission status: Time Limit Exceeded

Solution code:
import itertools
L,R = list(map(int,input().split()))
N_list = [i for i in range(L,R+1)]
P = itertools.combinations(N_list,2)
P = list(P)
ans = L*(L+1)%2019
for p in P[1:]:
    ans = min(ans,p[0]*p[1]%2019)
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
read = sys.stdin.buffer.read # 全読み込み
readline = sys.stdin.buffer.readline # 一行読み込み
readlines = sys.stdin.buffer.readlines # 一行ずつ全読み込み
sys.setrecursionlimit(10**7) # 再帰限界変更（デフォルトは1000）


def main():
    l,r=map(int,readline().rstrip().split())
    
    min_2019=2019

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

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

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:

"""
単純な全探索は二重ループでできそうだが、
L,R≤2×109 とかなので、このままだとダメ。
そこで工夫を考えることになる。
例えば L=10, R=3000 とかだったら、
x=2019 とかにすれば、xy は 2019 で割り切れる。
「2019 個以上の整数が連続すると、その中に必ず 2019 の倍数がある」
よってR−L≥2019 のときは答えが 0
それ以外のときは、全探索できる！候補数は多く見積もっても (R−L)^2 程度
"""

import sys
read = sys.stdin.buffer.read # 全読み込み
readline = sys.stdin.buffer.readline # 一行読み込み
readlines = sys.stdin.buffer.readlines # 一行ずつ全読み込み
sys.setrecursionlimit(10**7) # 再帰限界変更（デフォルトは1000）


def main():
    l,r=map(int,readline().rstrip().split())
    
    min_2019=2019

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

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

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:

import sys
read = sys.stdin.buffer.read # 全読み込み
readline = sys.stdin.buffer.readline # 一行読み込み
readlines = sys.stdin.buffer.readlines # 一行ずつ全読み込み
sys.setrecursionlimit(10**7) # 再帰限界変更（デフォルトは1000）

l,r=map(int,readline().rstrip().split())

min_2019=2019

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

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

print(min_2019)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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


def convert(LL,LR):
    LL = LL % 2019
    LR = LR % 2019

    return LL,LR

def kansu(LL,LR):

    ans = 2020

    for ll in range(LL,LR):
        for lr in range(ll+1,LR+1):
    #        print(lr)
            tmp  = (ll * lr) % 2019
            if ans > tmp:
                ans = tmp

    print(ans)

ML,MR = nyu()
#ML,MR = convert(ML,MR)
kansu(ML,MR)

Submission status: Time Limit Exceeded

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

ans = 2018
for i in range(L, R):
    for j in range(i+1, R + 1):
        tmp = (i * j) % 2019
        if ans  > tmp:
            ans = tmp
        if tmp == 0:
            ans = 0
            break

print(ans)

Submission status: Time Limit Exceeded

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

ans = 2018
for i in range(L, R):
    for j in range(i+1, R + 1):
        tmp = (i * j) % 2019
        if ans  > tmp:
            ans = tmp

print(ans)

Submission status: Time Limit Exceeded

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

res = []
for i in range(L, R+1):
    for j in range(i+1, R+1):
        res.append((i*j) % 2019)
print(min(res))

Submission status: Time Limit Exceeded

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

num = []
for i in range(l,r+1):
    num.append(i)

minimum = 10**9
for v in itertools.combinations(num, 2):
    minimum = min(minimum,v[0]*v[1]%2019)

print(minimum)

Submission status: Time Limit Exceeded

Solution code:
mod, min_value = 2019, 2019
l, r = map(int, input().split())
length = r - l
for i in range(mod):
  for j in range(mod):
    if length - j - i <= 0:
      break
    min_value = min(min_value, (l + i) * (r - j) % mod)
print(min_value)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
L, R = [int(i) for i in input().split()]
min_mod = (L * R) % 2019 
for i in range(L, R):
    for j in range(i+1,R+1):
        if min_mod > (i * j) % 2019:
            min_mod =(i * j) % 2019
            if min_mod == 0:
                break
print(min_mod)

Submission status: Time Limit Exceeded

Solution code:
L, R = [int(i) for i in input().split()]
min_mod = (L * R) % 2019 
for i in range(L, R):
    for j in range(i+1,R+1):
        if min_mod > (i * j) % 2019:
            min_mod =(i * j) % 2019
            
print(min_mod)

Submission status: Time Limit Exceeded

Solution code:
L,R=map(int,input().split())
ans=2018
for i in range(L,R+1):
  for j in range(L,R+1):
    if i>=j: continue
    cnt=(i*j)%2019
    ans=min(ans,cnt)
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
L, R = map(int, input().split())
res = 10 ** 15
for i in range(L, R):
    for j in reversed(range(i + 1, R + 1)):
        res = min((i % 2019) * (j % 2019) % 2019, res)

print(res)

Submission status: Time Limit Exceeded

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

r=min(r,l+4038)

ans=2020

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
L,R=map(int, input().split())
#2019の倍数が入っていれば０→R-Lが２０１９以上
if L-R>=2019:
    print(0)
    exit()

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

Submission status: Time Limit Exceeded

Solution code:
# C - Remainder Minimization 2019
import numpy as np

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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
l,r=map(int,input().split())
amari = 2018
for i in range(l, l+2020):
  for j in range(i+1, r+1):
    temp = (i*j)%2019
    if temp < amari:
      amari = temp
print(amari)

Submission status: Time Limit Exceeded

Solution code:
l,r=map(int,input().split())
amari = 2018
for i in range(l, r+1):
  for j in range(i+1, r+1):
    temp = (i*j)%2019
    if temp < amari:
      amari = temp
print(amari)

Submission status: Time Limit Exceeded

Solution code:
import sys
import os
import math
import string

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    L, R = il()
    ret = 2019
    for i in range(L, R+1):
        for j in range(i + 1, R + 1):
            ret = min(ret, (i * j) % 2019)
            if ret == 0:
                break
    else:
        print(ret)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
L,R = list(map(int, input().split()))
ans = 2018

s = list(map(int, range(L, R+1)))
if 2019 in s:
    print(0)
    exit()

for i in s:
    for j in s[s.index(i)+1:]:
        ans = min(ans, i*j%2019)

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
L, R = map(int, input().split())
MOD = 2019
# L = 2020
# R = 2040
diff = (R - L) % MOD
new_L = L % MOD
new_R = R + diff

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

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
l, r = map(int, input().split())

r = min(r, l+4038)
ans = 2018

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
l,r=map(int,input().split())
if r-l+1>=2019:
  print(0)
else:
  l=l%2019
  r=r%2019
  
  if l>=r:
    print(0)
    exit()
ans=10000000
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: Time Limit Exceeded

Solution code:
l,r=map(int,input().split())
if r-l+1>=2019:
  print(0)
else:
  l=l%2019
  r=r%2019
  
  if l>=r:
    r+=2019
ans=10000000
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: Time Limit Exceeded

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

r = min(r, l+4038)
ans = 2018
for i in range(l, r+1):
    for j in range(i+1, r+1):
        x = i * j % mod
        ans = min(ans, x)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
# import sys
# sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solve():
    l, r = MI()
    mod = 2019

    r = min(r, l+4038)
    ans = 2018
    for i in range(l, r+1):
        for j in range(i+1, r+1):
            x = i * j % mod
            ans = min(ans, x)
    print(ans)

if __name__ == '__main__':
    solve()

Submission status: Time Limit Exceeded

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


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

print(mod)

Submission status: Time Limit Exceeded

Solution code:
l,r=map(int,input().split())
k=[]
for i in range(l,r):
    for j in range(i+1,r+1):
        k.append((i*j)%2019)
print(min(k))

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
l,r=map(int,input().split())
if r%2019<l%2019:
  print(0)
  exit()
L=[]
for i in range(l,r+1):
  for k in range(i+1,r+1):
    L.append((i*k)%2019)
print(min(L))

Submission status: Time Limit Exceeded

Solution code:
l,r = map(int,input().split())
cnt = 0
mod_list = []
for i in range(l,r):
    for j in range(i+1,r+1):
        mod_list.append(i*j%2019)
        cnt += 1
        if cnt == 2019**2:
            break
print(min(mod_list))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

R = min(R, L+4038)

ans = 2018

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
l, r = map(int, input().split())
"""
もしl~rの範囲に2019の倍数を含むならば、2019の倍数をi,jのいずれかに設定して0を得る。
それ以外の場合、l~rの範囲は高々2019程度なので、全探索で間に合う
"""
if l//2019 - r//2019 > 0:
    print(0)
else:
    ans = 2019
    for i in range(l, r):
        for j in range(l+1, r+1):
            ans = min(ans, (i*j)%2019)
            if ans == 0:
                break
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
l, r = map(int, input().split())
"""
もしl~rの範囲に2019の倍数を含むならば、2019の倍数をi,jのいずれかに設定して0を得る。
それ以外の場合、l~rの範囲は高々2019程度なので、全探索で間に合う
"""
if l//2019 - r//2019 > 0:
    print(0)
else:
    ans = 2019
    for i in range(l, r):
        for j in range(l+1, r+1):
            ans = min(ans, (i*j)%2019)
    print(ans)

Submission status: Time Limit Exceeded

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

x = 3 * 10**9
for i in range(L, R):
    for j in range(i+1, R+1):
        x = min([x, (i * j % 2019)])
 
print(x)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
L, R = list(map(int, input().split()))
ans = 2020
if abs(L-R)>=2019:
    while 1:
        pass
    print(0)
else:
    for i in range(L, R):
        for j in range(L, R+1):
            if i==j:
                continue
            else:
                ans = min(ans, (i*j)%2019)

print(ans)

Submission status: Time Limit Exceeded

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

if L - R + 1 >= 2019:
     print(0)
else:
    ans = float('Inf')
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            ans = min(ans, (i * j) % 2019)
    print(ans)

Submission status: Time Limit Exceeded

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

if L - R + 1 >= 2019:
     print(0)
else:
    ans = float('Inf')
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            ans = min(ans, (i * j) % 2019)
    print(ans)