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:
import numpy as np

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

if R - L > 2019:
  print(0)
else:
  arr = np.array(range(L, R + 1))
  l4min = sorted(arr % 2019)
  l4max = sorted(arr % 2019, reverse=True)
  a_1 = (l4min[0] * l4min[1]) % 2019
  a_2 = (l4max[0] * l4max[1]) % 2019
  a_3 = (l4max[0] * l4min[0]) % 2019
  l4mod3 = sorted(arr % 3)
  l4mod673 = sorted(arr % 673)
  if l4mod3 == 0 and l4mod673 == 0:
    print(0)
  else:
    print(min([a_1, a_2, a_3]))

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)

result = []

for index, num in enumerate(mods):
	if index == len(mods) - 1:
		break
	result.append(num*mods[index+1]%2019)

result.sort()
print(result[0])

Submission status: Wrong Answer

Solution code:
import math
[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)
elif math.ceil(q / 673)-math.ceil(p / 673) > 0 and math.ceil(q/3) - math.ceil(p/3) > 0:
    print(0)
else:
    #p < q かつ r - l < 2019
    #すなわち 2020 2040みたいな状況
    print((p * (p+1))% 2019)

Submission status: Wrong Answer

Solution code:
num = input().split()
l, r = int(num[0]), int(num[1])
ans = 0

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

Submission status: Wrong Answer

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

lm = l % mod
rm = r % mod

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

Submission status: Wrong Answer

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

#f = 0
l = []

if R-L>=2019:
    #f = 1
    print(0)
    exit()

for i in range(L,R):
    for j in range(i+1,R+1):
        l.append((i*j)%2019)
else:
    l.sort()

if 3 in l and 673 in l:
    print(0)
elif 3 in l:
    print(min(l),637)
elif 637 in l:
    print(min(l),3)
else:
    print(min(l))

Submission status: Wrong Answer

Solution code:
def main():
    l, r = map(int, input().split(' '))
    if (r - l) >= 2019:
        ans = 0
    else:
        ans = 0 if mod_2019(l) >= mod_2019(r) else mod_2019(l * (l + 1))
    print(ans)


def mod_2019(x):
    while x >= 2019:
        x %= 2019
    return x

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
hoge = input().split()
L = int(hoge[0])
R = int(hoge[1])

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

Submission status: Wrong Answer

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


if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

minimum = l%2019
maximum = r%2019


if r-l >= 2019:
    print(0)
if r-l < 2019 and maximum == (minimum + r - l):
    print(minimum * (minimum + 1) % 2019)
if r-l < 2019 and (r - l) != maximum - minimum:
    print(0)

Submission status: Wrong Answer

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

i=s[0]
j=s[0]+1
i0= i%2019
j0= j%2019

for i in range(s[0],s[1]+1):
        i1 = i%2019
        if i1<i0:
            i0=i1
        else:
            pass

        for j in range(i+1,s[1]+1):
            j1 = j%2019
            if j1<j0:
                j0=j1
            else:
                pass
        
b0 = (j0*i0)

print(b0)

Submission status: Wrong Answer

Solution code:
import sys

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

min = L // 2019
max = R // 2019

if max - min > 0:
  print("0")
  exit()

modMin1=2019
modMin2=2019

for i in range(L, R+1, 1):
  tmp = i % 2019
  if tmp <  modMin1:
    modMin1 = tmp
  elif tmp <  modMin2:
    modMin2 = tmp
        
print((modMin1 * modMin2) % 2019);

Submission status: Wrong Answer

Solution code:
import numpy as np 

L, R = list(map(int, input().split()))
data = np.array([x for x in range(L, R+1)]) % 2019
len_data = R - L + 1
mod_min = np.inf

for i in range(len_data):
    t = len_data - i - 1
    
    for j in range(t):
        mod = data[t] * data[j]
        mod_min = mod if mod_min > mod else mod_min

print(mod_min)

Submission status: Wrong Answer

Solution code:
N,M=list(map(int,input().split()))
if M-N>2018 or (N%2019>M%2019):
    print(0)
else:

    N=N%2019
    M=M%2019
    ans=2018
    for i in range(N,M+1):
        for j in range(i,M+1):
            ans=min(ans,(i*j)%2019)
    print(ans)

Submission status: Wrong Answer

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

min = 2020

L = L % 2019
R = R % 2019

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

    for i in range(x[1]-x[0]+1):
        if m1 == 0 or m2 == 0:
            #print('break')
            break
        v = (i+x[0]) % 2019
        if v < m1:
            m2 = m1
            m1 = v

            a2 = a1
            a1 = i+x[0]
        elif v < m2:
            m2 = v

            a2 = i+x[0]
    #print(a1, a2)
    #print(a1%2019, a2%2019)
    #print((a1*a2)%2019)
    print(m1*m2)

Submission status: Wrong Answer

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

if l == r:
    l = 0
    r = 2018
#else:
#    tmp = min(l, r)
#    r = max(l, r)
#    l = tmp

for i in range(l, r):
    for j in range(l + 1, r + 1):
        if j <= i:
            continue
        else:
            ans = min(ans, i * j % MOD)

print(ans)

Submission status: Wrong Answer

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

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

else:
    for i in range(r - l + 1):
        a.append((l + i) % 2019)

print(a)
a.sort()
print(a[0] * a[1])

Submission status: Wrong Answer

Solution code:
l, r = map(int, input().split())
if r < 2019:
    print(l*r)
elif l <= 2019 and 2019 <= r:
    print(0)
else:
    if (r-l) >= 2018:
        print(0)
    else:
        new_l = l % 2019
        new_r = r % 2019
        count_l = l // 2019
        count_r = r // 2019
        if new_r >= 2 and count_l != count_r:
            print(2)

Submission status: Wrong Answer

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

min_i = 2019
for i in range(L, R):
    #print(i)
    mod_i = i % 2019
    if min_i > mod_i:
        min_i = mod_i
        if min_i == 0:
            break

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8

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

while L >= 2019:
    L -= 2019
while (R >= 2019) and (R-2019 >= L):
    R -= 2019

#print(L,R)    
output = 2*(10**9)
for i in range(R-L):
    i += L
    for j in range(R-i):
        j += i+1
        #print(i, j)
        output = min(output, (i*j) % 2019)

print(output)

Submission status: Wrong Answer

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

if R-L >= 2019:
    ans = 0
else:
    ans = 4000
    for i in range(L,R):
        p = ((i%2019) * ((i+1)%2019))%2019
        if p < ans:
            ans = p

    for i in range(L,R):
        p = (((2019-i)%2019) * ((2018-i)%2019))%2019
        if p < ans:
            ans = p

print(ans)

Submission status: Wrong Answer

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

if r-l >= 2019:
    print(0)
elif l > r:
    print(0)
else:
    l  %= 2019
    r %= 2019
    res=2019
    for i in range(r-l):
        if res > l*(l+1):
            res = l*(l+1)
        l += 1
    print(res)

Submission status: Wrong Answer

Solution code:
a,b=input().split()
a=int(a)
b=int(b)
c=0
for i in range(a,b):
  if b-a>=674:
    c=1
    break
  elif i%673==0:
    c=1
    break
ll=[]
if b-a==1:
  print(a*b%2019)
elif c==1 and b-a>1:
  print(0)
elif b-a>=102:
  print(1)
elif b-a>=48:
  print(2)
else:
  for i in range(a,b):
    for j in  range(i+1,b):
      ll.append(i*j%2019)
      
  print(min(ll))

Submission status: Wrong Answer

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

for i in range(r - l):
    t = 2019
    for j in range(i + 1, r - l + 1):
        tmp = (l + i) * (l + j) % 2019
        if tmp > t:
            break
        t = tmp
        if a > tmp:
            a = tmp

print(a)

Submission status: Wrong Answer

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

if L // 2019 < R // 2019 or L % 2019 == 0:
    ans = 0
else:
    l = L % 2019
    r = R % 2019
    ans = 2019
    for i in range(l, r):
        ans = min(ans, (i * (i + 1)) % 2019)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(1000000)
 
l,r = map(int,input().split())

mod = 673

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

MOD = 2019

ans = 2019

if r_s > l_s:
    for i in range(abs(l_s - r_s)+1):
        for j in range(1,abs(l_s - r_s)+2):
            if l_s+i+j > r_s:
                break
            tmp = (l_s+i)*(l_s+i+j) % MOD
            if ans > tmp:
                #print(l_s+i,l_s+i+j)
                ans = tmp
    print(ans)
    exit()
else:
    print(0)
    exit()

Submission status: Wrong Answer

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

lower = 2020
lowest = 2020

for i in range(l, r+1):
	
	mod = i % 2019

	if mod==0:
		ans = 0
		break
	
	list_ = [lower, lowest, mod]
	list_.sort()
	lower = list_[1]
	lowest = list_[0]
	ans = lower * lowest 

print(ans % 2019)

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
print(L_mod)
print(R_mod)

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

Submission status: Wrong Answer

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

for i in range(r - l):
    t = 2019
    for j in range(i + 1, r - l + 1):
        tmp = (l + i) * (l + j) % 2019
        print(l + i,l + j,tmp)
        if tmp > t:
            break
        t = tmp
        if a > tmp:
            a = tmp

print(a)

Submission status: Wrong Answer

Solution code:
l,r=map(int, input().split())
x=[i for i in range(l,r+1)]
if 0 in [i%3 for i in x] and 0 in [i%673 for i in x]:
  print(0)
  exit()
y=sorted([i%2019 for i in x])
print(y[0]*y[1])

Submission status: Wrong Answer

Solution code:
l,r = map(int, input().split())
a = (l-1)//2019
b = r//2019
c = l%2019
d = (l+1)%2019
e = (c*d)%2019
print(e)

Submission status: Wrong Answer

Solution code:
# coding: utf-8

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

while L >= 2019:
    L -= 2019
while (R >= 2019) and (R-2019 >= L):
    R -= 2019

print(L,R)    
output = 2*(10**9)
for i in range(R-L):
    i += L
    for j in range(R-i):
        j += i+1
        #print(i, j)
        output = min(output, (i*j) % 2019)

print(output)

Submission status: Wrong Answer

Solution code:
l, r = [int(s) for s in input().split(" ")]
m = l * (l + 1) % 2019
print("%d" % m)

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
L1 = L%2019
R1 = R%2019
L2 = L//2019
R2 = R//2019
if L2 != R2:#LとRの間に0でなるとき
  ans = 0
else:
  ans = (L*(L+1))%2019
  for i in range(L+1,R):
    for j in range(i+1,R):
      x = (i*j)%2019
      ans = min(ans,x)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
L,R = map(int,input().split(" "))
BASE = (L * (L + 1)) % 2019
MAX = ((R - 1) * R) % 2019
if L < 2019 and R < 2019:
    print(BASE)
elif L < 2019 and R > 2019:
    print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
l, r = map(int, input().split())
if r - l >= 2019:
    print(0)
else:
    a = l // 2019
    l = l - 2019*a
    r = r - 2019*a
    nums = [i for i in range(l, r+1)]
    nums.sort()
    print(((nums[0]+2019*a) * (nums[1]+2019*a)) % 2019)

Submission status: Wrong Answer

Solution code:
L,R=map(int,input().split())
dif=R-L
if(dif>2019*2):
    dif=2019*2
l=L%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)
min=2019
for i in range(len(arr)):
    for j in range(i+1,len(arr)):
        if min>(arr[i]*arr[j])%2019:
            min=(arr[i]*arr[j])%2019
        if min==0:
            break
    if min==0:
            break
print(min)

Submission status: Wrong Answer

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

for i in range(l, r + 1):
    if divmod(i, 2019)[1] == 0:
        print(0)
        exit()

tmp = set()
for i in range(l, r + 1):
    for j in range(l + 1, r + 1):
        tmp.add(divmod(i * j, 2019)[1])

print(min(tmp))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# C - Remainder Minimization 2019



def remind2019(L, R):
    # 0 2019の倍数がある
    if (R-L)> 2019:
        return 0

    if (R%2019 == 0) or (L%2019==0):
        return 0
    else:
        qL, mL = divmod(L,2019)
        qR, mR = divmod(R, 2019)

        if mR <= mL: #１周している
            return 0
        else:
            return int((mL*(mL+1))%2019)



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

Submission status: Wrong Answer

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

indexs = []
for index in range(L,min(R+1,L+2018)):
	indexs.append(index%2019)
	
#print(indexs)
	
indexs = sorted(indexs)
	
print((indexs[0]*indexs[1]) % 2019)

Submission status: Wrong Answer

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

if l*r < 2019:
    print(l*r)
elif l*r%2019 == 0:
    print(0)

else:
    #1項
    mod1 = (l**2)
    #2項
    mod_min = 10000000
    for i in range(1,r-l+1):
        mod2 = i*mod1
        chk = (mod1+mod2)%2019
        
        if chk < mod_min:
            mod_min = chk
    print(mod_min)

Submission status: Wrong Answer

Solution code:
l,r = map(int, input().split())
a = (l-1)//2019
b = r//2019
c = l%2019
d = (l+1)%2019
e = (c*d)%2019
print(0)

Submission status: Wrong Answer

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

import copy
import math
import itertools

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

PPP = 1000000007

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

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

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

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

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

#cache = dict()

import re
import fractions

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

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

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

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

Submission status: Wrong Answer

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

minimum = 2019
checked = set()

L=L%2019
R=R%2019
for i in range(L, R+1):
    a = i%2019
    if a not in checked:
        checked.add(a)
        for j in range(i+1, R+1):
            v = (i * j) % 2019
            minimum = min([v, minimum])

print(minimum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
L1 = L%2019
R1 = R%2019
L2 = L//2019
R2 = R//2019
if L2 != R2:#LとRの間に0でなるとき
  ans = 0
else:
  ans = L*(L+1)
  for i in range(L+1,R):
    for j in range(i+1,R):
      x = (i*j)%2019
      ans = min(ans,x)
print(ans)

Submission status: Wrong Answer

Solution code:
import math
l,r=map(int,input().split())
a=l%2019
b=r%2019
if l-r>=2018:
    print(0)
elif b-a<=0:
    print(0)
elif (a<=672)&(b>=673):
    print(0)
elif(a<=673)&(b>=675):
    print(0)
elif (a<=1345)&(b>=1346):
    print(0)
elif(a<=1346)&(b>=1348):
    print(0)
else:
    ans=2018
    for i in range(a,b+1):
        for j in range(i+1,b+1):
            ans=min(ans,i*j%2019)
    print(ans)

Submission status: Wrong Answer

Solution code:
l, r = map(int, input().split())
m = 2 * (10 ** 9) + 1
n = 2 * (10 ** 9) + 1
flag = 0
for i in range(l, r+1):
    a = m
    m = min(m, i % 2019)
    if i % 2019 == 0:
        flag = 1
        break
    if a == m:
        n = min(n, i % 2019)
    else:
        n = min(n, a)

if flag == 0:
    print((n*m) % 2019)
else:
    print(0)

Submission status: Wrong Answer

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

print(val)

Submission status: Wrong Answer

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

l = L % 2019
r = R % 2019
if (l >= r):
  if (2019 <= (R - L)):
    r += 2019

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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


def get_ans():
    # mod後の最小値コンビを十分大きな値で初期化しておく
    nums = [2019, 2020]
    for n in range(L, R + 1):
        mod = n % 2019
        # 0が来た瞬間終了
        if mod == 0:
            return 0

        # 新しい値を加えて昇順ソートして先頭から2つの値で更新
        nums.append(mod)
        nums = sorted(nums)[:2]

    # ループ終わったら最小値コンビの積のmodを取る
    return (nums[0] * nums[1]) % 2019


print(get_ans())

Submission status: Wrong Answer

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

minimum = l%2019
maximum = r%2019


if r-l >= 2019:
    print(0)
if r-l < 2019 and maximum == (minimum + r - l):
    print(minimum * (minimum + 1))
if r-l < 2019 and (r - l) != maximum - minimum:
    print(0)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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


if L % 2019 == 0:
        print(0)
        exit()
elif L % 2019 < R % 2019:
        li = range(L, R)
        cmb = list(itertools.combinations(li,2))
        ans = (R -1) * R
        for i,j in cmb:
                ans = min(ans, (i*j) % 2019)
        print(ans)

else:
        print(0)
        exit()

Submission status: Wrong Answer

Solution code:
parents = list(map(int,input().split(' ')))

a = parents[0] % 2019
b = parents[1] % 2019
diff = parents[1]-parents[0]
if (parents[0]%2019 + diff) >= 2019:
    print(0)
elif a==b:
    res = a*a % 2019
    print(res)
elif a<b:
    res = a*(a+1) % 2019
    print(res)
else:
    res = b*(b-1) % 2019
    print(res)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
n = list(map(int,input().split()))
i = n[0] % 2019
j = n[1] % 2019
if i >= j or n[1] - n[0] >= 2018:
  print(0)
else:
  print(i*(i+1))

Submission status: Wrong Answer

Solution code:
L, R = (int(i) for i in input().split())
Z = 2020
if R - L >= 2019:
  print(0)
else:
  for i in range(L,R+1):
    a = i % 2019
    for j in range(L,R+1):
      b = j % 2019
    if i != j and (a*b)%2019 < Z:
      X = a
      Y = b
      Z = (a*b) % 2019
  print(Z)

Submission status: Wrong Answer

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

import sys

input = sys.stdin.readline

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

    if (r - l) > 2019:
        r = (r - l) % 2019 + l

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

main()

Submission status: Wrong Answer

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

LR = input().split(' ')
L = int(LR[0])
R = int(LR[1])

n = 2019 * 2019

L2 = L % n
R2 = R % n
if L2 >= R2:
    R2 += n

r = sorted(map(lambda x: x % n, range(L2, R2 + 1)))

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

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)
elif (q // 673)-(p // 673) > 0 and (q//3) - (p//3) > 0:
    print(0)
else:
    #p < q かつ r - l < 2019
    #すなわち 2020 2040みたいな状況
    print((p * (p+1))% 2019)

Submission status: Wrong Answer

Solution code:
hoge = input().split()
L = int(hoge[0])
R = int(hoge[1])

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

Submission status: Wrong Answer

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

indexs = []
for index in range(L,min(R+1,L+2018)):
	indexs.append(index%2019)
	
#print(indexs)
	
indexs = sorted(indexs)
	
print(indexs[0]*indexs[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

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

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

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

Submission status: Wrong Answer

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

circle = (R- L)/ 2019
if circle >=2:
    R = L+2019*2+10
# print(R)

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

mod_list.sort()

result_list = []
for i in range(len(mod_list)-1):
    for j in range(i+1, len(mod_list)):
        result_list.append((mod_list[0]*mod_list[1])%2019)
print(min(result_list))

Submission status: Wrong Answer

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

s = l % mod
e = r % mod

if s >= e:
    e = s + mod - 1


'''
if s > e:
    t = s
    s = e
    e = t

if s == e:
    e = s + mod - 1
'''
for i in range(s,e):
    for j in range(i+1,e+1):

        #m = ((i % mod) * (j % mod)) % mod
        m = (i * j) % mod
        #print(i,j,m)

        if m < mod_min:
            mod_min = m

print(mod_min)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

L %= 2019
R %= 2019

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

Submission status: Wrong Answer

Solution code:
l,r = map(int,input().split())
ans=2018
z=1
while r/z>2019:
    if l/z<=2019 and r/z>=2019:
        ans=0
    z+=1
else:
    for i in range(l,r):
        mod2019=(l*(i+1))%2019
        if ans>mod2019:
            ans=mod2019
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np 

L, R = list(map(int, input().split()))
data = np.array([x for x in range(L, R+1)]) % 2019
len_data = R - L
mod_min = np.inf

for i in range(len_data):
    t = len_data - i - 1
    
    for j in range(t):
        mod = data[t] * data[j]
        mod_min = mod if mod_min > mod else mod_min

print(mod_min)

Submission status: Wrong Answer

Solution code:
l,r = map(int,input().split())
mod = 2019
start = l % mod
end = r % mod
if r - l >= 2018:
  s = 0
elif start < end:
  s = (start*(start+1))%mod
else:
  s = 0
print(s)

Submission status: Wrong Answer

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

if l*r < 2019:
    print(l*r)
else:
    #1項
    mod1 = (l**2)
    #2項
    mod_min = 10000000
    for i in range(1,r-l+1):
        mod2 = i*mod1
        chk = (mod1+mod2)%2019
        
        if chk < mod_min:
            mod_min = chk
    print(mod_min)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
input_arr = [int(x) for x in input().split()]
 
L = input_arr[0]
R = input_arr[1]
 
min_ans = 10**18
for i in range(L,R):
    for j in range(i+1,R):
        ans = (i*j)%2019
        if ans < min_ans:
            min_ans = ans
print(min_ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
l,r=[int(i) for i in input().split()]
tmpl=2019*(l//2019+1)
modl=1000000000000000
numl=0
for i in range(l,min(tmpl,r+1)):
    if i%2019<modl:
        modl=i%2019
        numl=i
tmpr=2019*(r//2019)
ans=100000000000000
for i in range(max(tmpr-1,l),r+1):
    if i!=numl:
        ans=min(ans,(numl*i)%2019)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

mod = 1000000
for i in range(L, R+1):
  for j in range(i+1, R+1):
    tmp = (i * j) % 2019
    if tmp == 0:
      break
    if mod > tmp:
      mod = tmp
  else:
    continue      
    
    
print(mod)

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
mod = 2019
ans = mod -1

L %= mod
R %= mod

if L > R:
    R += mod

for i in range(L, R):
    for j in range(i+1, R+1):
        if i * j % mod < ans:
            ans = i * j % mod

print(ans)