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:
# lll = [i*2019 for i in range(1, 1000000)]

L, R = map(int, input().split())
# if L == R - 1:
#     print((L * R) % 2019)
# elif L <= 2019 or R >= 2019:
#     print(0)
# else:
#     pass


if R - L >= 2019:
    print(0)
elif L <= 2019 and R >= 2019:
    print(0)
else:
    ans = float("inf")
    for i in range(L, R):
        ans = min(i * (i + 1) % 2019, ans)
    print(ans)

Submission status: Wrong Answer

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

mod_list = []
min1 = 2019
min2 = 2019

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

else:
    for i in range(L, R+1):
        tmp = i % 2019

        if tmp < min1:
            min2 = min1
            min1 = tmp
        
        elif tmp < min2:
            min2 = tmp


    print(min1 * min2)

Submission status: Wrong Answer

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

# 1，2番目に小さい数字を入れておく
mins = [2019, 2019]

for i in range(L, R + 1):
    mod = i % 2019
    if mod == 0:
        mins[0] = mod
        break
    if mod < mins[0]:
        mins[0] = mod
    elif mins[0] <= mod and mod < mins[1]:
        mins[1] = mod

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

Submission status: Wrong Answer

Solution code:
import sys

L, R = map(int, sys.stdin.readline().split())
mod = 2019

mod_L = L%2019
mod_R = R%2019

if R - L >= 2019:
    temp_i = mod_L
    temp_j = 2018
else:
    temp_i = mod_L
    temp_j = mod_R

min_mod = 9999
for i in range(mod_L, mod_R):
    for j in range(i + 1, mod_R + 1):
        if ((i*j)%mod) < min_mod:
            min_mod = (i*j)%mod
print(min_mod)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
l,r = map(int, input().split())

if r < 2019:
    ans = float("inf")
    for i in range(l,r-1):
        for j in range(i+1,r):
            mod = (i*j)%2019
            if mod < ans:
                ans = mod
    print(ans)
elif l%2019==0 or r%2019==0:
    print(0)
elif l//2019 < r //2019:
    print(0)
else:
    ans = float("inf")
    for i in range(l,r-1):
        for j in range(i+1,r):
            mod = (i*j)%2019
            if mod < ans:
                ans = mod
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

L2, R2 = L % Y, R % Y
dist = (R - L) // Y

if L2 == 0 or R2 == 0 or R2 <= L2 or 1 <= dist:
    res = 0
elif Y < L:
    res = 2
else:
    res = L2 * R2

print(res)

Submission status: Wrong Answer

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

L = L % 2019
R = R % 2019

if L >R:
    print(0)
else:
    mi = (L*(L+1)) %2019
    for i in range(L, R):
        for j in range(i+1, R+1):
            tmp = (i*j) % 2019
            if tmp < mi:
                mi = tmp
                
    print(mi)

Submission status: Wrong Answer

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

l %= 2019
r %= 2019

if l>r:
    l, r = r, l

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys


def input():
    return sys.stdin.readline()[:-1]


def main():
    l, r = map(int, input().split())
    if r-l >= 2018:
        print(0)
    else:
        n = [i % 2019 for i in range(l, r+1)]
        n.sort(reverse=True)
        print(n.pop()*n.pop())


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np

str = [int(i) for i in input().split()]
l, r = str

if l >= 2019:
    print(l * (l + 1) % 2019)
elif r >= 2019:
    print(0)
else:
    s = 2020
    for i in range(l, r):
        for j in range(i + 1, r + 1):
          if (i * j) % 2019 < s:
              s = (i * j) % 2019
    print(s)

Submission status: Wrong Answer

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

res = 1000000007

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

print(res)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
l, r = map(int, input().split())

# prime_factor = 3, 673
mod = 2019

div_set = set()
min_div = mod

for i in range(l, r + 1):
    div = i % mod
    div_set.add(div)
    min_div = min(min_div, div)

    if min_div == 0:
        break

if min_div == 0:
    print(0)
else:
    cnt = 0
    ans = 1
    for val in sorted(div_set):
        ans *= val
        cnt += 1
        if cnt == 2:
            break
    print(ans % mod)

Submission status: Wrong Answer

Solution code:
L,R = map(int,input().split())
h = L//2019
h += 1
if(L<=2019*h)and(2019*h<=R):
  print(0)
else:
  ans = 2020
  l = L%2019
  r = R%2019
  for i in range(l,r):
    for j in range(i+1,r):
      min(ans,(i*j)%2019)
  print(ans)

Submission status: Wrong Answer

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

modarr=[]
for i in range(L,R+1):
    modarr.append(i%2019)
modarr.sort()
print(modarr[0]*modarr[1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
L, R = map(int, input().split())
    
if R - L + (L % 2019) >= 2019:
    print(0)
    sys.exit()
else:
    print(((L % 2019) * (L+ 1)) % 2019)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
[l,r] = [int(i) for i in input().split()]
i = 0
check = 1
ans = 0
p = l % 2019
q = r % 2019
# 2019の倍数が挟まっている
# lの方があまりが大きい → 挟まってる
# 差が2019以上 → 挟まってる
if p >= q or r - l >= 2019:
    print(0)
else:
    #p < q かつ r - l < 2019
    #すなわち 2020 2040みたいな状況
    print((p * (p+1)) % 2019)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys

MOD = 2019  # type: int

def solve(L: int, R: int):
    if R - L >= 2019 - 1:
        print(0)
    else:
        result = (L % 2019) * ((L + 1) % 2019)
        print(result)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = int(next(tokens))  # type: int
    R = int(next(tokens))  # type: int
    solve(L, R)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

mods = []

for num in range(2019):
	i = num + L
	if i > R:
		break
	mods.append(i%2019)

mods.sort()

print(mods[0] * mods[1])

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

print(l, r, file=sys.stderr)
l = l % 2019
r2 = r % 2019
if r2 < l:
  r2 += 2019
  if r2 < r:
    r = r2
print(l, r, file=sys.stderr)

def doit():
  res = 2019
  for x in range(l, r):
    for y in range(l + 1, r + 1):
      #print(x, y, file=sys.stderr)
      res = min(res, (x * y) % 2019)
  return res % 2019

#print(doit([0] * 4))
#doit(s)
#print(doit())
try:
  print(doit())
except Exception as e:
  print("e", e, file=sys.stderr)

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split())
c = 1
cmin = 2018

for i in range(a,b+1):
  for j in range(a+1,b+1):
    c = (i*j) % 2019
    if(cmin > c):
      cmin = c
      if cmin == 0:
        break
    
print(cmin)

Submission status: Wrong Answer

Solution code:
L,R = map(int,input().split(" "))
remind = 2020
if L + 1 == R:
    print((R * L) % 2019)
else:
    for i in range(L, R - 1):
        for j in range(i + 1, R):
            r = (i * j) % 2019
            if r < remind:
                remind = r
                if remind == 0:
                    print(0)
                    exit(0)
    print(remind)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

R1 = L % 2019
R2 = (L + 1) % 2019

R3 = R1 * R2
print(R3)

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 * 2, 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())
if R - L + 1 == 2:
    print((R * L) % 2019)
    quit

if R - L + 1 >= 673:
    print(0)
    quit

for num in range(L, R + 1):
    if num % 673 == 0:
        print(0)
        quit


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

Submission status: Wrong Answer

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

a=l%2019
b=r%2019

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

Submission status: Wrong Answer

Solution code:
L,R = map(int,input().split(' '))
if R-L>=2019:
    print(0)
else:
    f = True
    for i in range(L,R+1):
        t = i % 2019
        if t==0:
            f = False
            break
    if f:
        k = L*(L+1)%2019
        kk = (R-1)*R%2019
        if k>=kk:
            print(kk)
        else:
            print(k)
    else:
        print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

L, R = [int(i) for i in input().split()]

if R - L > 2019:
  print(0)
else:
  l = sorted(np.array(range(L, R + 1)) % 2019)
  print(l[0] * l[1])

Submission status: Wrong Answer

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

l %= 2019
r %= 2019


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

Submission status: Wrong Answer

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

l=l%2019
r=r%2019

if l>r:
    tmp=r
    r=l
    l=tmp

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


print(ans)

Submission status: Wrong Answer

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

if 2019 < R - L:
    print(0)

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

Submission status: Wrong Answer

Solution code:
L, R = map(int,input().split())
L_mod = L%2019
if L_mod ==0:
  print(0)
else:
  R_mod = R%2019
  if R_mod ==0:
    print(0)
  else:
    if L_mod<R_mod:
      list =[]
      for i in range(L_mod,R_mod,1):
        mod_i = i%2019
        for j in range(i+1,R_mod+1,1):
          mod_j = j%2019
          mod = (mod_i *mod_j)%2019
          list.append(mod)

      print(min(list))
      
    else:
      print(0)

Submission status: Wrong Answer

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

if L <= 2019 and 2019 <= R:
    ans = 0
else:
    ans = min(L*(L+1)%2019, R*(R-1)%2019)
    
print(ans)

Submission status: Wrong Answer

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

print(result)

Submission status: Wrong Answer

Solution code:
A=[int(i) for i in input().split()]
L=A[0]
R=A[1]
num=L-1
am=2020
se=2021
n=0
while True:
	num+=1
	if num>R:
		break
	n=num%2019
	if	n<se:
		if n<=am:
			se=am
			am=n		
		else:
			se=n	
	if num-L>2019:
		break
	
ans=am*se
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 20 20:47:47 2019

@author: Owner
"""

import numpy as np
import sys
import collections
import scipy.misc
import math
from operator import itemgetter
import itertools
import copy
import bisect
import heapq

#素因数を並べる
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(int(i))
    i += 1
  if n > 1:
    table.append(int(n))
  return table   
# 桁数を吐く
def digit(i):
    if i > 0:
        return digit(i//10) + [i%10]
    else:
        return []
    
def getNearestValueIndex(list, num):
    """
    概要: リストからある値に最も近い値のインデックスを取得する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return idx

def find_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        """
        x が属するグループを探索
        """
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        """
        x と y のグループを結合
        """
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self, x, y):
        """
        x と y が同じグループか否か
        """
        return self.find(x) == self.find(y)

    def get_size(self, x):
        """
        x が属するグループの要素数
        """
        x = self.find(x)
        return self.size[x]
    

"""
N, X = map(int, input().split())

x = list(map(int, input().split()))

P = [0]*N
Y = [0]*N
for n in range(N):
    P[n], Y[n] = map(int, input().split())

# 多次元配列の宣言（あとでintにすること。）（タプルにすること。）
dp = np.zeros((N+1, 4,4,4))
    
all(nstr.count(c) for c in '753')

# 複数配列を並び替え
ABT = zip(A, B, totAB)
result = 0
# itemgetterには何番目の配列をキーにしたいか渡します
sorted(ABT,key=itemgetter(2))
A, B, totAB = zip(*ABT)
A.sort(reverse=True)

# 2進数のbit判定
(x >> i) & 1

# dp最小化問題
dp = [np.inf]*N
for n in range(N):
    if n == 0:
        dp[n] = 0
    else:
        for k in range(1,K+1):
            if n-k >= 0:
                dp[n] = min(dp[n], dp[n-k] + abs(h[n]-h[n-k]))
            else:
                break
# 累積和
add = 1 # 問題によって決まる
res = 0
sums = [0]*(len(nums)+1)
for i in range(len(nums)):
    sums[i+1] = sums[i] + nums[i]
for i in range(0, len(nums), 2):
    left = i
    right = min(i+add, len(nums))
    tmp = sums[right] - sums[left]
    res = max(tmp, res)

#２分探索
li, ri = bisect.bisect_left(p_ac, l[i]-1), bisect.bisect_right(p_ac, r[i]-1)    

#ソート関数
org_list = [3, 1, 4, 5, 2]
new_list = sorted(org_list)
print(org_list)
print(new_list)
# [3, 1, 4, 5, 2]
# [1, 2, 3, 4, 5]

#Distance Transformation
    for h in range(0,H):
        for w in range(0,W):
            if h == 0 and w == 0:
                pass
            elif h == 0:
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h-1][W-w]+1)
            elif w == 0:   
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h][W-w-1]+1)
            else:
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h][W-w-1]+1, D[H-h-1][W-w]+1, D[H-h][W-w]+2)
            d_max = max(D[H-h-1][W-w-1], d_max)

"""


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

    
def main(): 
    nL = L//2019
    nR = nL+1
    A, B = 0, 0
    if 2019*nR <= R:
        return print(0)
    else:
        if L - 2019*nL < 2019*nR - R:
            A = L
            if (L+1) - 2019*nL < 2019*nR - R:
                B = L+1
            else:
                B = R 
        else:
            A = R
            if (L) - 2019*nL < 2019*nR - (R-1):
                B = L
            else:
                B = R-1            
    return print((A*B)%2019)
                
            
            
                

    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

cnt = 0
for i in range(R, L+1, 2019):
    cnt += 1

if cnt:
    print(0)
else:
    a = R % 2019
    b = L % 2019
    
    if a > 2019 // 2:    
        a = 2019 - a
    if b > 2019 // 2:
        b = 2019 - b

    print(min(a * (a+1), b * (b+1)))

Submission status: Wrong Answer

Solution code:
L,R=map(int,input().split())
dif=R-L
dif%=2019
l=L%2019
r=R%2019
arr=[]
while(dif):
    arr.append(l)
    l+=1
    if(l==2019):
        l=0
    dif-=1
arr.sort()
if(len(arr)==1):
    arr.append(l)
print(arr[0]*arr[1])

Submission status: Wrong Answer

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

L = L % 2019
R = R % 2019

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

Submission status: Wrong Answer

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

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

band = (R // 2019) - (L // 2019)
if L == 0:
    print(0)
elif (L % 2019 == 0) or (R % 2019 == 0):
    print(0)
elif band >=1:
    #この中に一個必ず2019の倍数がある
    print(0)
else:
    print((L * (L+1)) % 2019)

Submission status: Wrong Answer

Solution code:
import math
def solve():
    l, r = map(int, input().split())
    min_int = l % 2019
    diff = r - l + 1
    if diff >= 2019:
        print(0)
    else:
        l_div = math.floor(l / 2019)
        r_div = math.floor(r / 2019)
        if(l_div != r_div):
            print(0)
        else:
            k = l % 2019
            print((k * (k+1))%2019)


if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
l,r = map(int,input().split())
MOD = 2019
l %=MOD
r %=MOD
if r <= l:
    r +=2019

ans = 2018
now = 0
for i in range(l,r+1):
    for j in range(i+1,r+1):
        now = (i*j)%MOD
        ans = min(ans,now)


print(ans)

Submission status: Wrong Answer

Solution code:
import sys

l, r = [int(i) for i in input().split()]

lower = 2020
lowest = 2020

for i in range(l, r+1):
	if i%2019==0:
		print(0)
		sys.exit()
	mod = i % 2019
	list_ = [lower, lowest, mod]
	list_.sort()
	lower = list_[1]
	lowest = list_[0]


print(lower * lowest)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

ans = 1
if r-l >= 2019:
    ans = 0
elif l//2019+1 == r//2019:
    ans = 0
else:
    ans = (l*(l+1))%2019
    
print(ans)

Submission status: Wrong Answer

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

i=2018
j=2018

for n in range(L,R+1):
    if n%2019<i%2019:
        i=n
    if i%2019==0:
        break

for n in range(i+1,R+1):
    if n%2019<j%2019:
        j=n
    if j%2019==0:
        break

print(i*j%2019)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
l,r=map(int,input().split())
flg=0
m=10*20
for i in range(10**6):
    if l<=2019*i<=r:
        flg=1
        m=0

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

print(m)

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
L %= 2019
R %= 2019
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: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
L, R = map(int , input().split())
mod = 2019
ans = float('inf')
for i in range(10**5):
    if L + 1 + i > R:
        print(ans)
        exit()
    tmp_mod = ((L + i) % mod * (L + 1 + i) % mod) % mod
    if ans > tmp_mod:
        ans = tmp_mod

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
import math

MOD = 2019  # type: int


def solve(L: int, R: int):
    r = 2018
    for i in range(L, R):
        t = (i * (i + 1)) % 2019

        if t > r:
            break

        r = t

    print(r)

    # r = 0
    # for i in range(L, R):
    #     t = ((i * R) % 2019)
    #     if t < r:
    #         break

    #     r = t

    # print(r)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    L = int(next(tokens))  # type: int
    R = int(next(tokens))  # type: int
    solve(L, R)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if r//mod - l//mod >= 1:
  print(0)
  exit()
  
l = l%mod
r = r%mod

if r < l:
  print(0)
  exit()

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

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np

str = [int(i) for i in input().split()]
l, r = str

if l >= 2019:
    print(l * (l + 1) % 2019)
elif r >= 2019:
    print(0)
else:
    s = 2020
    for i in range(l, r):
        for j in range(l + 1, r + 1):
          if (i * j) % 2019 < s:
              s = (i * j) % 2019
    print(s)

Submission status: Wrong Answer

Solution code:
n, a = map(int, input().split())

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

if n < 2019 and n < 2019:
    print(n * a % 2019)

if 2019 < n and 2019 < a:
    print(n * n+1 % 2019)


if n <= 2019:
    print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
l, r = map(int, input().split())  # 複数数値入力

lm = l % 2019
rm = r % 2019

if (r - l) + lm < 2019:  # 間に2019の倍数はない
    print((lm*(lm+1)) % 2019)

else:
    print(0)


# li = [2019, 2019]
# for i in range(l, r + 1):
#     if li[1] > i % 2019:
#         li[1] = i % 2019

#     if li[1] < li[0]:
#         li[0], li[1] = li[1], li[0]

# print(li)
# print(li[0]*li[1])

Submission status: Wrong Answer

Solution code:
l,r = [int(_) for _ in input().split()]
c = (r-l+1)//2019
m = 10**10
if c == 0:
    if r%2019 <= l%2019:
        print(0)
    else:
        print((l*(l+1))%2019)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3

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

lm = (l // 2019)
rm = (r // 2019)

if lm != rm:
    print(0)
else:
    li = l % 2019
    print(li * (li + 1))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

L, R = map(int, input().split())
L_mod = L % 2019
R_mod = R % 2019
min_mod = pow(2018,2)
num = 0

for i in range(L_mod, R_mod ):
    for j in range(L_mod + 1, R_mod + 1):
        num = (i * j) % 2019
        if min_mod > num:
            min_mod = num
print(min_mod)

Submission status: Wrong Answer

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

l = L // 2019
r = R // 2019
ans= 0
if(l == r):
    ans = (L*(L+1)%2019)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

L = L % 2019
R = R % 2019

if L > R:
    R = R + 2019

A = np.arange(L, R+1)

if  R-L > 2018:
    print(0)
    
else:
    ans = 2019
    for i in np.arange(L, R+1):
        for j in np.arange(i+1, R+1):
            ans = np.amin(np.array([i * j % 2019, ans]))
    print(ans)

Submission status: Wrong Answer

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

if (r-l+1)>=2019:
    print(0)
else:
    m = [-1]*(r-l+1)
    for i in range(r-l+1):
        m[i] = (l+i)%2019
    sm = sorted(m)
    print(sm[0]*sm[1])

Submission status: Wrong Answer

Solution code:
#入力
i, j = map(int, input().split())
#前処理
i_mod = i % 2019


pool = []
for value in range(j-i):
  value = (value+1) + i 
  pool.append((i_mod*value)%2019)
print(min(pool))

Submission status: Wrong Answer

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

ls = []

for i in range(l,r+1):
    ls.append(int(int(i)%2019))

    if len(ls)==10000:
        break
ls = sorted(ls)
print(int(ls[0]*ls[1])%2019)

Submission status: Wrong Answer

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

def gcd(m,n):
    temp=0
    while m%n!=0:
        temp=n
        n=m%n
        m=temp
    return n
def lcm(m,n):
    return m*n/gcd(m,n)


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

#print(temp)
print(min([min(e) for e in temp]))

Submission status: Wrong Answer

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

ans = []
I = L % 2019
if R - L + 1 > 2019:
    print(0)
    exit()
else:
    imax = R - L + 1

for i in range(imax - 1 ):
    ans.append(((L + i)*(L + i + 1))%2019)

print(min(ans))

Submission status: Wrong Answer

Solution code:
LR = list(map(int,input().split()))
L = LR[0]%2019
R = LR[1]%2019
K = 2018
if R >= L:
    for j in range(L,R+1):
        for i in range(L,j):
            if K > (i*j)%2019:
                K =  (i*j)%2019
else:
    for j in range(R,L+1):
        for i in range(R,j):
            if K > (i*j)%2019:
                K =  (i*j)%2019
if R == L:
    print((R*L)%2019)
else:
    print(K)

Submission status: Wrong Answer

Solution code:
l,r = map(int,input().split())
MOD = 2019
l %=MOD
r %=MOD
if r < l:
    r +=2019

ans = 2018
now = 0
for i in range(l,r+1):
    for j in range(i+1,r+1):
        now = (i*j)%MOD
        ans = min(ans,now)


print(ans)

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
left = min(L%2019, R%2019)
right = max(L%2019, R%2019)
l = [i for i in range(left, right+1)]
ans = 9999
for i in range(len(l)-1):
    for j in range(i+1, len(l)):
        mo = l[i]*l[j]%2019
        ans = min(ans, mo)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

s=input()
#s = ("4 2 9")
#print(s) 
s = s.split(" ")

L = int( s[0] )
R = int( s[1] )


result =4.0e9  
for i in range(L,R-1):
    for j in range(i,R):
        mod = i*j % 2019
        if result > mod:
            result = mod

print(result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

s = l//2019
t = r//2019

l -= 2019*s
r -= 2019*t

ans = 10**10
for i in range(l,r+1):
    for j in range(l,r+1):
        #print(i,j,i*j)
        #print((i*j)%2019)
        if i >= j:
            continue
        ans = min(ans, (i*j)%2019)

print(ans)

Submission status: Wrong Answer

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