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

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

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

print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
# 初期入力
import sys
input = sys.stdin.readline
L,R = (int(x) for x in input().split())

mod_L =L %2019
mod_R =R %2019
ans =0
xx=[]
if 2018 <= R -L:
    ans =0
elif mod_R < mod_L:
    ans =0
elif mod_L==0 :
    ans =0
else:
    for i in range(L,R):
        for j in range(i+1,R+1):
            x =i*j %2019
            xx.append(x)
    ans =min(xx)
print(ans)

Submission status: Accepted

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

result=float("inf")
R=min(R,L+4038)
for i in range(L,R+1):
  for j in range(i+1,R+1):
    result=min(result,i*j%2019)
#if R-L>= 2019:
#  result=0
#else:
#  l=L%2019
#  r=R%2019
#  for i in range(l,r+1):
#    for j in range(i+1,r+1):
#      result=min(result,i*j%2019)

print(result)

Submission status: Accepted

Solution code:
import sys

a, b = map(int,input().split())
num = int(a*b%2019)

for i in range(a, b + 1):
  for j in range(i + 1, b + 1):
    if(i >= j):
      continue
    num = min(num, (i*j)%2019)
    if(num == 0):
      print(0)
      sys.exit()

print(num % 2019)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

l,r = nm()

MOD = 2019

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

print(ans)

Submission status: Accepted

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

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

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

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

Submission status: Accepted

Solution code:
i, j = map(int, input().split())
a = i % 2019
a_r = i // 2019

b = j % 2019
b_r = j // 2019

if a_r == b_r:
    minv = float('INF')
    for first in range(a, b):
        for second in range(a+1, b+1):
            result = first*second%2019
            if result < minv:
                minv = result

    print(minv)
else:
    print(0)

Submission status: Accepted

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

ans=2018
for i in range(l,r+1):
  for j in range(i+1,r+1):
    amari=(i*j)%2019
    if amari<ans:
      ans=amari
    if ans==0:
      break
  else:
    continue
  break

print(ans)

Submission status: Accepted

Solution code:
a, b = list(map(int, input().split()))
if b-a >= 2019:
  print(0)
  quit()

lis = list(range(a, b+1))
  
ans = 2019

for i in range(b-a+1):
  for j in range(i+1, b-a+1):
    #print("i: " + str(lis[i]) + "  j: "+ str(lis[j]))
    temp = ((lis[i]%2019)*(lis[j]%2019))%2019
    #print(temp)
    if temp < ans:
      ans = temp
print(ans)

Submission status: Accepted

Solution code:
from sys import exit

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

if l%673 == 0 or r%673 == 0:
    if l%3 == 0 or r%3 == 0:
        print(0)
        exit()
    else:
        for i in range(l, min(r,l+2)+1):
            if i%3 == 0:
                print(0)
                exit()
elif l//673 != r//673:
    for i in range(l, min(r,l+2)+1):
        if i%3 == 0:
            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))
        if ans == 0:
            break
    if ans == 0:
        break
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L,R = map(int,input().split())
if R-L > 673 or (L%2019) > (R%2019):
  print(0)
else:
  l = L%2019
  r = R%2019
  c = 2018
  w = set()
  for i in range(l,r):
    for j in range(i+1,r+1):
      t = (i*j)%2019
      if c > t:
        c = t
  print(c)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

MOD = 2019

if r - l > 2019:
    print(0)
    exit()
else:
    mi = 2019
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            mi = min(mi, (i * j) % MOD)
    print(mi)

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
mod = 2019
ij_mod_min = 2019  # 解答の初期値を2019に設定
for i in range(L, R):  # 二重のforで全探索
    for j in range(i+1, R+1):
        ij_mod = (i*j) % mod
        if ij_mod_min > ij_mod:
            ij_mod_min = ij_mod
        if ij_mod_min == 0:  # もし解が0になったら探索をやめる
            break
    else:
        continue
    break
print(ij_mod_min)

Submission status: Accepted

Solution code:
def resolve():
    L, R = [int(i) for i in input().split()]
    ans = 2019
    end = min(R, (L + 2019)) + 1
    for i in range(L, end):
        for j in range(i + 1, end):
            ans = min(ans, i * j % 2019)
            if ans == 0:
                break
        else:
            continue
        break
    print(ans)


resolve()

Submission status: Accepted

Solution code:
from itertools import combinations

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

# check
mod0 = [n for n in range(0, R + 1, 2019) if L <= n]
if not mod0:
    target_num = list(range(L, R + 1))
    nC2 = list(combinations(target_num, 2))
    mods_ans = [(i * j) % 2019 for i, j in nC2]

    print(min(mods_ans))
else:
    print(0)

Submission status: Accepted

Solution code:
def abc133_c():
  L,R = map(int,input().split())
  if R - L > 673: return 0
  ans = 2019
  for i in range(L, R):
    for j in range(i+1, R+1):
      ans = min(ans, i*j%2019)
      if ans == 1: return 1
  return ans

print(abc133_c())

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
R -= (L // 2019) * 2019
L %= 2019

while R-4038 > L:
  R -= 2019

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

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

ans = 2018**2
if R-L >= 2019:
    ans = 0
else:
    l, r = L % 2019, R % 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: Accepted

Solution code:
import math,numpy, collections

a,b = map(int,input().split())
ans = 2018**2
if b-a >=2019:
    ans = 0
else:
    aa, bb = a%2019,b%2019
    for i in range(aa,bb):
        for j in range(i+1,bb+1):
            ans = min(ans,i*j%2019)

print(ans)

Submission status: Accepted

Solution code:
L,R = map(int,input().split())
mod = 2019
k = 2018
limit = R-L
if limit >= 2019:
    k = 0
else:
    for i in range(limit):
        for j in range(limit-i):
            s = ((L+i)*(L+i+j+1)) % mod
            if s < k:
                k = s 
print(k)

Submission status: Accepted

Solution code:
import collections
import numpy as np
import sys
sys.setrecursionlimit(10000000)
import copy
#N=int(input())
L,R=map(int,input().split())
if R-L>=2019:
    print(0)
    exit()
else:
    ans=2019999
    for i in range(L,R+1):
        for j in range(i+1,R+1):
            ans=min(i*j%2019,ans)
            if ans==0:
                print(ans)
                exit()
    print(ans)

Submission status: Accepted

Solution code:
import collections
import numpy as np
import sys
sys.setrecursionlimit(10000000)
import copy
#N=int(input())
L,R=map(int,input().split())
l=[]
for i in range(2021):
    l.append(L%2019)
    if L==R:
        break
    L+=1
ans=2019999
for i in range(len(l)):
    for j in range(i+1,len(l)):
        ans=min(l[i]*l[j]%2019,ans)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def abc133_c():
    L, R = map(int, input().split())
    # 区間の幅が673あれば、673の倍数と3の倍数が含まれて、2019の倍数が作れる
    if R - L > 673: return 0
    # それ以外は試す
    ans = 2019
    for i in range(L, R+1):
        for j in range(L, i):
            m = i * j % 2019
            ans = min(m, ans)
            if ans == 1: return 1
    return ans

print(abc133_c())

Submission status: Accepted

Solution code:
def abc133_c():
    L, R = map(int, input().split())
    # 区間の幅が673あれば、673の倍数と3の倍数が含まれて、2019の倍数が作れる
    if R - L > 673: return 0
    # それ以外は試す
    ans = 2019
    for i in range(L, R+1):
        for j in range(L, i):
            m = i * j % 2019
            ans = min(m, ans)
    return ans

print(abc133_c())

Submission status: Accepted

Solution code:
# 参考 https://atcoder.jp/contests/abc133/submissions/7966658

import numpy as np

def abc133_c():
    L, R = map(int, input().split())
    if R - L > 673: return 0
    x = np.arange(L, R+1, dtype=np.int64)
    #y = x[:, None] * x[None, :] % 2019
    y = x.reshape(-1, 1) * x.reshape(1, -1)  # 区間内のすべての組合せの積
    y %= 2019
    np.fill_diagonal(y, 2019)  # 対角成分は無視する (同じ数を2回選べない) のでinf値で埋める
    return y.min()

print(abc133_c())

Submission status: Accepted

Solution code:
l,r = map(int,input().split())
num2019 = r//2019 - l//2019
ans = 9999999999
if num2019>=1 or l == 0 or l%2019 ==0:
    ans = 0
else:
    modr = r%2019
    modl = l%2019
    for a in range(l,r+1):
        for b in range(a+1,r+1):
            tmp = (a*b)%2019
            ans = min(ans,tmp)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
l, r = list(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
    else:
        continue
    break
print(int(ans))

Submission status: Accepted

Solution code:
l,r = map(int,input().split())
if r-l >= 673:
    print(0)
else:
    ans = 2018
    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: Accepted

Solution code:
import itertools
import math
import fractions
import functools
import copy

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

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

minimum = 10**10
for i in range(l, r+1):
    for j in range(l, r+1):
        if(i != j):
            minimum = min(minimum, (i*j) % 2019)

print(minimum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def f(l,r):
    p=2019
    for i in range(l,r+1):
        for j in range(l,r+1):
            if i==j:
                continue
            p=min((i*j)%2019,p)
    return p
    
l,r=map(int,input().split())
print(0 if r//2019-(l-1)//2019!=0 else f(l,r))

Submission status: Accepted

Solution code:
def f(l,r):
    p=2019
    for i in range(l,r+1):
        for j in range(l,r+1):
            if i==j:
                continue
            p=min((i*j)%2019,p)
    return p
    
l,r=map(int,input().split())
print(0 if r//2019-(l-1)//2019!=0 or (r//673-(l-1)//673!=0 and r//3-(l-1)//3!=0) else f(l,r))

Submission status: Accepted

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

Submission status: Accepted

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

    ans = 2018
    for i in range(L, min(R, L + 2018) + 1):
        p = i % 2019
        for j in range(i + 1, min(R, L + 2018) + 1):
            q = j % 2019
            t = p * q % 2019
            if ans > t:
                ans = t
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def resolve():
    '''
    code here
    '''
    L, R = [int(item) for item in input().split()]
    aL, bL = divmod(L, 2019)
    aR, bR = divmod(R, 2019)

    if bL == 0:
        res = 0
    elif aL < aR:
        res = 0
    elif aL == aR:
        res = 2019
        for i in range(bL,bR):
            for j in range(bL+1,bR+1):
                res = min(res, i*j%2019)

    print(res)
if __name__ == "__main__":
    resolve()

Submission status: Accepted

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)
    else:
        continue
    break

print(ans)

Submission status: Accepted

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

if r - l >= 2018:
  print(0)
else:
  res = float('inf')
  for i in range(l, r):
    for j in range(i+1, r+1):
      res = min(res, (i%2019)*(j%2019)%2019)
      
  print(res)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
def resolve():
    l,r=pin()
    L=l%2019
    R=r%2019
    #print(L,R)
    if r-l>=2019:R+=2019


    t=20192019
    for i in range(L,R):
        for j in range(i+1,R+1):
            t=min(t,(i*j)%2019)
    print(t)
#%%submit!
resolve()

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l,r = map(int, input().split())
ans = float("INF")

for i in range(l,r):
  for j in range(l+1, r+1):
    a = (i*j)%2019
    if a == 0:
      print(0)
      exit()
    elif a < ans: ans = a
print(ans)

Submission status: Accepted

Solution code:
L,R=map(int,input().split())
ans=2020
if R-L>=2019:
    ans=0
else:
    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: Accepted

Solution code:
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
L,R = map(int,input().split())
c = 0
for i in range(L,R+1):
    if i % 2019 == 0:
        print(0)
        c = 1
        break
if c == 0:
    MIN = 3000
    for i in range(L,R):
        for j in range(i+1,R+1):
            a = (i*j)%2019
            MIN = min(a,MIN)
    print(MIN)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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(l,r)

#print(mods)
if (r-l)>=2018:
    ans=0
    #print(1)
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: Accepted

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

l,r = iim()

if l//2019 != r//2019 or l%2019 == 0 or r%2019 == 0:
    print(0)
else:
    num = float('INF')
    for i in range(l,r+1):
        for j in range(i+1,r+1):
            num = min((i*j)%2019,num)
    print(num)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
import sys
from collections import Counter
from collections import deque
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

l,r=mp()
if l//2019 != r//2019:
    print(0)
    exit()
ans=10000
for i in range(l,r):
    for k in range(i+1,r+1):
        ans=min(ans,(i*k)%2019)
print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 2019
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

# https://atcoder.jp/contests/abc133/tasks/abc133_c
# i,jの2019倍は必ず2019で割り切れる
# i+2019a ≡ i (mod 2019)より iもjもそれぞれ2019で割った余りを採用すれば良い

L, R = read_ints()
if R - L >= MOD:
    print(0)
    exit()

L = L % MOD
R = R % MOD

if R <= L:
    R += MOD

ans = INF
for i, j in combinations(ra(L, R + 1), r=2):
    # print(i, j, i * j % MOD)
    ans = min(ans, i * j % MOD)
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

l,r = inpl()
r = min(r,l+3000)
res = INF
for i in range(l,r):
    for j in range(i+1,r+1):
        res = min(res, (i*j)%2019)
print(res)

Submission status: Accepted

Solution code:
l, r = map(int, input().split())
if l//2019<r//2019:
    print(0)
else:
    ans = 2019
    for ll in range(l, r):
        for rr in range(ll+1, r+1):
            ans = min(ans, (ll*rr)%2019)
    print(ans)

Submission status: Accepted

Solution code:
def solve():
    L, R = map(int, input().split())
    mod = 2019
    table = [[0]*2019 for _ in range(2019)]
    for i in range(2019):
        for j in range(2019):
            table[i][j] = i*j%mod
    ans = 10**7
    if R-L>=2018:
        for i in range(2019):
            for j in range(i+1,2019):
                ans = min(ans,table[i][j])
        return ans
    r = R%mod
    l = L%mod
    if r>=l:
        for i in range(l,r+1):
            for j in range(i+1,r+1):
                ans = min(ans,table[i][j])
        return ans
    for i in range(2019):
        if i<=r or i>=l:
            for j in range(i+1,2019):
                if j<=r or j>=l:
                    ans = min(ans,table[i][j])
    return ans
print(solve())

Submission status: Accepted

Solution code:
L,R = map(int,input().split())
a = [False for i in range(2019)]

for i in range(L,min(L+2019,R)+1):
    a[i%2019] = True
ans = 4000
for i in range(2019):
    if not a[i]:
        continue
    for j in range(i+1,2019):
        if not a[j]:
            continue
        ans = min(ans,i*j%2019)
print(ans)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 2019


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

    for i in range(L, R + 1):
        if i % mod == 0:
            print(0)
            break
    else:
        res = f_inf
        for i in range(L, R):
            for j in range(L + 1, R + 1):
                calc = i * j % mod
                res = min(res, calc)

        print(res)


if __name__ == '__main__':
    resolve()

Submission status: Accepted

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

R=min(L+2019,r)

amari=[]
for i in range(L,R+1):
	amari+=[i%2019]

#print(amari)

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


print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 10 ** 9
if R - L >= 673:
    ans = 0
else:
    for i in range(L, R):
        for j in range(L + 1, R + 1):
            work = (i * j) % 2019
            # print(i, j, work, ans)
            ans = min(ans, work)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 2019

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

R = min(R, L + 2019)

ans = 2019
for l in range(L, R + 1):
    for r in range(l + 1, R + 1):
        ans = min(ans, l * r % MOD)

print (ans)