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:
"""
#include <stdio.h>
int main(){
  int l, r, ans=99999;
  int lst[99999];
  scanf("%d",&l);
  scanf("%d",&r);
  l %= 2019;
  r %= 2019;
  for(int i=l;i<r;i++){
    for(int j=i+1;j<r+1;j++){
      if(ans>(i*j)%2019){
        ans = (i*j)%2019;
        //printf("%d\n",ans);
      }
    }
  }
  printf("%d\n",ans);

}
/*"""
l, r = map(int, input().split())

l2 = 2019*(l//2019)
r -= l2
l %= 2019

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

#for i in range()

#lst = []
sum = 9999999999
#lm = 99999999999
#rm = 99999999999
#for 
#print(l%2019)
"""
for i in range(l,r):
  for j in range(i+1,r+1):
    #lst.append(i*j%2019)
    if sum > i*j%2019:
      sum = i*j%2019
print(sum)
"""
#*/

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import numpy as np

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

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

Submission status: Wrong Answer

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


l = L % 2019
r = R % 2019

if l == 0 or l >= r:
    print(0)
else:
    print(l*(l+1))

Submission status: Wrong Answer

Solution code:
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

a, b = readmi()
t = 0xFFFFFFFF
for i in range(a + 1, b + 1):
    t = min(t, (a) * (i) % 2019)
    t = min(t, (b) * (i) % 2019)
    if i % 2019 == 0:
        break
print(t)

Submission status: Wrong Answer

Solution code:
n = list(map(int,input().split()))
i = n[0] % 2019
j = n[1] % 2019
k = n[0] % 673
l = n[1] % 673
if (n[1]-n[0] >= 2 and k >= l) or n[1] - n[0] >= 672 :
  print(0)
elif n[1]-n[0] == 1 and (i*j)%2019 == 0:
  print(0)
else:
  print((i*(i+1))%2019)

Submission status: Wrong Answer

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

mod = []
for i in range(l, r+1):
  mod.append(i%2019)
mod.sort(reverse=False)
print(mod[0]*mod[1])

Submission status: Wrong Answer

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

modL=L%2019
modR=R%2019
LL=L//2019
RR=R//2019

distRL=R-L
distRRLL=RR-LL



if distRRLL>=2:
    #print("2:",distRRLL)
    i=L+2019-(modL)
    j=i*2
    #print(i,j)
elif distRRLL==1:
    #print("1:",distRRLL)
    i=L+2019-(modL)
    j=i+1
    #print(i,j)
else:
    if modL<modR:
        i=modL
        j=modL+1
        #print("modL",i,j)
    else:
        i=modR
        j=modR-1
        #print("modR",i,j)
    
print(i*j%2019)

Submission status: Wrong Answer

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

if L // 2019 == R // 2019:

    if abs (L % 2019 - 1009) < abs(R % 2019 - 1009):
        ans = ((R % 2019) * ((R-1) % 2019)) % 2019

    elif abs (L % 2019 - 1009) == abs(R % 2019 - 1009):
        ans = ((L % 2019) * (R % 2019)) % 2019

    else:

        ans = ((L % 2019) * (L+1) % 2019) % 2019
else:
    ans = 0

print(ans)

Submission status: Wrong Answer

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

l_mod = l % 2019
r_mod = r % 2019

if l_mod >= r_mod:
    print(0)
else:
    min_val = 2020
    for i in range(r_mod - l_mod ):
        for j in range(r_mod - l_mod + 1):
            
            if i >= j:
                 continue
#            print([l_mod+i,l_mod+j])
            min_val = min([min_val, ((l_mod+i)*(l_mod+j))%2019])
#            print(((l_mod+i)*(l_mod+j))%2019)
            
    print(min_val)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

div_l = L//2019
div_r = R//2019

ans = 0
if div_l == div_r:
    mod_l = L%2019
    mod_r = R%2019
    if (mod_l <= 673 and mod_r >= 673) and R-L >= 2:
        ans = 0
    else:
        ans = mod_l * (mod_l+1)
print(ans)

Submission status: Wrong Answer

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

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

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

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

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

########

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

if R<L:
    R += 2019
    if diff > 10000:
        R += 10000

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

print(ans)

Submission status: Wrong Answer

Solution code:
import sys

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

if r-l+1 <3:
    imin = 10**9+7
    for i in range(r-l):
        for j in range(i+1,r-l+1):
            if imin > ((l+i)*(l+j))%2019:
                imin = ((l+i)*(l+j))%2019
    print(imin)
elif r-l+1 <672:
    if (l % 673)+r-l > 672:
        print(0)
    else:
        print((l % 673)*((l+1)% 673))
        """
        if l % 3 == 0 or l % 3 == 2:
            print((l % 673)*((l+1)% 673))
        else:
            print((l % 673)*((l+2)% 673))
        """
else:
    print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
a = L % 2019
if a == 0:
  print(0)
else:
  if L + (673 - L % 673) <= R and L + (3 - L % 3) <= R:
    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:
# -*- coding: utf-8 -*-
import sys
from itertools import tee


def pairwise(iterable):
    "s -> (s0,s1), (s1,s2), (s2, s3), ..."
    a, b = tee(iterable)
    next(b, None)
    return zip(a, b)


def answer(L, R):
    return min([divmod(i*j, 2019)[1] for i, j in pairwise(range(L, R+1, 1))])


if __name__ == '__main__':
    args = sys.stdin.read().split()
    print(answer(int(args[0]), int(args[1])))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

if r - l > 4040:
    print(0)
else:
    LR = np.arange(l, r + 1)
    LR = LR % 2019
    idx_1 = LR.argmin()
    min_1 = LR[idx_1]
    LR[idx_1] = 2018
    min_2 = LR.min()

    print(min_1 * min_2)

Submission status: Wrong Answer

Solution code:
L,R = map(int, input().split())
def g(L,R):
    for i in range(L,R+1):
        yield i%2019

A = list(g(L,R))
A.sort
print(A[0]*A[1])

Submission status: Wrong Answer

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

for i in range(L,R+1):
    for j in range(L+1,R+1):
        if((i==L and j==L+1) or min>i*j%2019):
            min=i*j%2019

print(min)

Submission status: Wrong Answer

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

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

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

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

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

Submission status: Wrong Answer

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

minimum = l%2019
maximum = r%2019
flag=0
ans = 10000
if r-l >= 673:
    print(0)    
elif r-l < 2019:
    for i in range(l,r):
        ans = min(i*(i+1)%2019,ans)
        ans = min(i*(i+2)%2019,ans)
        ans = min(i*(i+3)%2019,ans)
        if i%673 ==0:
            flag = 1 
    if flag==1:
        print(0)
    else:
        print(ans)

Submission status: Wrong Answer

Solution code:
# prob C

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

def mod(n):
    return n % 2019


if diff >= 2018:
    print(0)
else:
    m = sorted(list(map(mod, list(range(l % 2019, (l % 2019) + diff + 1)))))
    print(min(mod(m[0]*m[1]) , mod((2019 - m[-1])*(2019 - m[-2]))))

Submission status: Wrong Answer

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

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

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

lm3 = min(674, r-l)
key3 = 0
for k in range(lm3):
  check = l+k
  if check % 673 == 0:
    key3 = 1
    
#print(key1,key2,key3)
if (key1 == 1 or (key2 == 1 and key3 ==1)):
  print(0)
else:
  print((l*(l+1))%2019)

Submission status: Wrong Answer

Solution code:
n = list(map(int, input().rstrip().split(" ")))
if n[1] - n[0] >= 2019:
    print(0)
else:
    a = n[0]%2019
    b = n[1]%2019
    l = [i%2019 for i in range(a,b+1)]
    if 673 in l or 1346 in l:
        for a in l:
            if a%3==0:
                print(0)
                break
    else:
        print((l.pop(l.index(min(l)))*l.pop(l.index(min(l))))%2019)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
l, r = list(map(int, input().split()))
if l // 2019 == r // 2019:
    _l = l % 2019
    a0 = (l * (l+ 1)) % 2019
    a1 = ((r - 1) * r) % 2019
    print(min(a0, a1))
else:
    print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
L %= 2019
R %= 2019
if L >= R:
    tmp = L
    L = R
    R = tmp
L = int(L)
R = int(R)
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:
# coding: utf-8

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

i_mod = 2020
i = L

for x in range(L, min((R+1, L+2018))):
    if x % 2019 < i_mod:
        i = x
        i_mod = x % 2019
if i_mod == 0:
    ans = 0
else:
    if i == R:
        j_mod = min((L % 2019, (i-1) %2019))
    else:
        j_mod = (i + 1) % 2019
    ans = (i_mod * j_mod) % 2019
print(ans)

Submission status: Wrong Answer

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

if (R - L) <= 2019:
    temp1 = float("inf")
    for i in range(R - L):
        if (R-i-1) < L:
            break
        temp2 = (R * (R - i - 1)) % 2019
        if temp2 < temp1:
            temp1 = temp2
    print(temp1)
else:
    temp1 = float("inf")
    for i in range(2019):
        if (R-i-1) < L:
            break
        temp2 = (R * (R - i - 1)) % 2019
        if temp2 < temp1:
            temp1 = temp2
    print(temp1)

Submission status: Wrong Answer

Solution code:
import math

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

mod = 2019

l = L % 2019
r = R % 2019


if l >= r:
    print(0)
    exit()
else:
    _min = 2*1000000000+5
    for i in range(l, r):
        for j in range(i+1, r+1):
            _min = min(_min, i*j%mod)

print(_min)

Submission status: Wrong Answer

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

N = R - L + 1
r = L % 2019

if N >= 2019:
    print(0)
    exit()

m1 = 2018
m2 = 2017
for i in range(N):
    a = (r + i) % 2019
    if a < m1:
        m1 = a
    elif a < m2:
        m2 = a

an = m1 * m2
print(an % 2019)

Submission status: Wrong Answer

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

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


else:
    for i in range(r - l + 1):
        a.append((l + i) % 2019)
a.sort()
print(a[0] * a[1])

Submission status: Wrong Answer

Solution code:
L,R = map(int,input().split())
if L*R < 2019:
    print(L*R)
elif R - L > 4037:
    print(0)
elif R - L > 2018:
    print(1)
else:
    print(2)

Submission status: Wrong Answer

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

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

print(min)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

L = L%2019
R = R%2019
MIN = 2020

for i in range(min(L,R),max(L,R)+1):
    for j in range(i,max(L,R)+1):
        if i != j:
            mod = i*j
            MIN = min(MIN,mod%2019)
if R == 0 or L == 0:
    print(0)
elif R - L == 1:
    print((R*L)%2019)
elif R == L:
    print((R*L)%2019)
else:
    print(MIN)

Submission status: Wrong Answer

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

x = 2020

for i in range(R+1)[L:]:
    if x == 1:
        break
    for j in range(R+1)[i+1:]:

        mod = i * j % 2019

        if mod != 0:
            x = min(mod, x)
            if x == 1:
                break

print(x)

Submission status: Wrong Answer

Solution code:
a1=list(input().split( ))
a=list(map(int, a1))
b= a[1] - a[0]
d=2018

for j in range(b):
 for k in range(b-j):
  if (a[0]+j) != 0:
   c=( (a[0] + j ) % 2019) * ( (a[0] + j  + k + 1) % 2019)
   if c<=d:
    d=c
   if d==0:
    break

print(d)

Submission status: Wrong Answer

Solution code:
l,r=map(int,input().split())
nl=2019*(l//2019)
nr=2019*((l//2019)+1)

if l <= 2019*((l//2019)+(1 if l%2019!=0 else 0)) <= r:
  print(0)
elif r-l==1:
  print(r*l)
else:
  i=l if l-nl <= nr-r else r
  #変化量
  v=l-nl if i==l else nr-r
  f=i%2019
  syu=round(f/v)+1
  if i==l:
    firstmin=min((i*syu)%2019,(i*(syu+1))%2019)
  else:
    firstmin=min((i*syu)%2019,(i*(syu-1))%2019)
  print(firstmin)

Submission status: Wrong Answer

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

ans = 0
flag = False
for i in range(L, R):
    if i % 2019 == 0:
        flag = True
        break

if not flag:
    if R - L >= 2018:
        ans = 0
    elif L <= 2019 <= R:
        ans = 0
    elif R < 2019:
        ans = (L * (L + 1)) % 2019
    else:
        ans = (L * (L + 1)) % 2019

print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    l, r = map(int,input().split())
    if 2019<l:
        print(l*(l+1)%2019)
    elif l<=2019<=r:
        print(1)
    elif r<2019:
        print(l*(l+1)%2019)

main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

    if x[1]-x[0]+1 >= y:
        print(0)
    elif x[0]%y < x[1]%y:
        print((x[0]*(x[0]+1))%y)
    else:
        print(0)

Submission status: Wrong Answer

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

l = l % 2019
r = r % 2019

mod_min = 2019

if l < r:
    for i in range(l, r):
        for j in range(i+1, r+1):
            mod = (i * j) % 2019
            if mod < mod_min:
                mod_min = mod
else:
    # for i in range(l, r + 2019):
    #     for j in range(i+1, r+2019 + 1):
    #         mod = i * j % 2019
    #         if mod < mod_min:
    #             mod_min = mod
    mod_min = 0

print(mod_min)

Submission status: Wrong Answer

Solution code:
import sys

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

if r-l+1 <3:
    imin = 10**9+7
    for i in range(r-l):
        for j in range(i+1,r-l+1):
            if imin > ((l+i)*(l+j))%2019:
                imin = ((l+i)*(l+j))%2019
    print(imin)
elif r-l+1 <672:
    if (l % 673)+r-l > 672:
        print(0)
    else:
        if l % 3 == 0 or l % 3 == 2:
            print((l % 673)*((l+1)% 673))
        else:
            print((l % 673)*((l+2)% 673))
else:
    print(0)

Submission status: Wrong Answer

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

tmp = L % 2019
param_res1 = 0
param_res2 = 0

if tmp == 0:
    param_res1 = L
    param_res2 = L + 1
else:
    if L + (2019 - tmp) <= R:
        param_res2 = L + tmp
        param_res1 = param_res2 - 1
    elif tmp < 1010:
        param_res1 = L
        param_res2 = L + 1
    else:
        param_res1 = R
        param_res2 = R - 1


res = ( (param_res1 % 2019) * (param_res2 % 2019) ) % 2019
print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

L,R = map(int,input().split())
if R-L>673:
    print(0)
else:
    A =[]
    if L == 0:
        L = 1
    for i in range(R-L+1):
        n = (L+i)
        if n % 673 == 0 and (R-L+1) >= 3:
            print(0)
            sys.exit()
        else:
            A.append(n%2019)

            A.sort()
    print((A[0]*A[1])%2019)

Submission status: Wrong Answer

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

if R-L >= 2019:
    print(0)
else:
    bet =  sorted([i%2019 for i in range(L,R+1)])
    mi = 10000000000
    if max(bet)*min(bet) > 2019:
        for i in range(len(bet)):
          for j in range(i+1,len(bet)-i):
            fig =  (bet[i] * bet[j])%2019
            if fig <= mi:
              mi = fig
    else:
        print(bet[0]*bet[1])

Submission status: Wrong Answer

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

min_mod = 2*10**9
min_i = 0
for i in range(l, r+1):
    if i % 2019 < min_mod:
        min_mod = i%2019
        min_i = i

min = 2*10**9
for i in range(l, r+1):
    if i == min_i:
        continue
    mod = i*min_i % 2019
    if mod < min:
        min = mod
        if min == 0:
            break

print(min)

Submission status: Wrong Answer

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

l_mod = l % 2019
r_mod = r % 2019

if l_mod >= r_mod:
    print(0)
else:
    min_val = 2020
    for i in range(r_mod - l_mod ):
        for j in range(r_mod - l_mod + 1):
            
#             if i >= j:
#                 continue
#            print([l_mod+i,l_mod+j])
            min_val = min([min_val, ((l_mod+i)*(l_mod+j))%2019])
#            print(((l_mod+i)*(l_mod+j))%2019)
            
    print(min_val)

Submission status: Wrong Answer

Solution code:
import math

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

MOD = 2019
number_range = range(L*(L+1), R*(R-1)+1)

if math.floor(R / MOD) - math.ceil(L / MOD) >= 1:
  print(0)
else: 
  print(L*(L+1) % MOD)

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
if R // 2019 - (L - 1) // 2019 != 0:
    print(0)
else:
    minnum = 1000
    Lmod = L % 2019
    Rmod = R % 2019
    for i in range(Lmod, Rmod+1):
        for j in range(i + 1, Rmod+1):
            #print(i, j, (i * j) % 2019)
            minnum = min(minnum, (i * j) % 2019)
    print(minnum)

Submission status: Wrong Answer

Solution code:
L,R = map(int, input().split())
MOD = 2019
mL = L%MOD
mR = R%MOD
if mL>mR:
    mR +=MOD
min_mod = MOD+1
#print(mL, mR)
for i in range(mL, mR):
    for j in range(i+1, mR+1):
        min_mod=min(i*j%MOD, min_mod)
        #print(i, j)
print(min_mod)

Submission status: Wrong Answer

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

if((r-1)*r<=2019):
    print(l*(l+1))
    exit()

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

low = 2*1e+200

for i in range(l,r-1):
    for j in range(i,r):
        if(i*j%2019<low):
            low = i*j%2019

print(low)

Submission status: Wrong Answer

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

minimum = l%2019
maximum = r%2019
flag=0
ans = 10000
if r-l >= 673:
    print(0)    
elif r-l < 2019:
    for i in range(l,r):
        ans = min(i*(i+1)%2019,ans)
        if i%673 ==0:
            flag = 1 
    if flag==1:
        print(0)
    else:
        print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
l,r=map(int,input().split())
s=[]
if ((r//2019)!=(l//2019)):
    a=0
    s.append(a)
elif((r-l!=1)):
    for i in range(l,r-1):
        for j in range(i+1,r):
            #print(i,j)
            a=(i*j)%2019
            #print(a)
            s.append(a)
            if (a==0):
                break
else:
    a=(l*r)%2019
    s.append(a)
print(min(s))

Submission status: Wrong Answer

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

ml = (l % 2019)
mr = (r % 2019)
t = l + 2019
if r > t:
    m = 0
else:
    if ml < mr:
        for x in range(ml, mr):
            m = min(m, (x * (x+1)) % 2019)
    else:
        m = 0
print(m)

Submission status: Wrong Answer

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

min

for i in range(L,R+1):
    for j in range(L+1,R+1):
        if((i==L and j==L+1) or min>i*j%2019):
            min=i*j%2019

print(min)

Submission status: Wrong Answer

Solution code:
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

a, b = readmi()
t = 0xFFFFFFFF
for i in range(a + 1, b + 1):
    t = min(t, (a) * (i) % 2019)
    if i != b:
        t = min(t, (b) * (i) % 2019)
    if i % 2019 == 0:
        break
print(t)

Submission status: Wrong Answer

Solution code:
import sys
raw_data = sys.stdin.readlines()

data_l = int(raw_data[0].split()[0])
data_r = int(raw_data[0].split()[1])

def min_mod(l, r):
    
    if l - r + 1 >= 673:
        return 0
    
    else:
        
        a = l + (l % 673)
        b = l + (l % 2019)
        
        if a > r:
            if b > r:
                sdf = ((l * (l+1) ) % 2019)
                return sdf
        
        min_mod = min( (a * (a + 1)) % 2019, (b * (b+1)) % 2019, (l * (l+1)) % 2019)
        return min_mod

print(min_mod(data_l, data_r), end="")

Submission status: Wrong Answer

Solution code:
import math

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

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

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

Submission status: Wrong Answer

Solution code:
l,r=map(int,input().split())
if r-l+1<=2019:
	lst=list(range(l,r+1))
	modlist=[]
	for i in lst:
		q,mod = divmod(i,2019)
		modlist.append(mod)
	sor = sorted(modlist)
	if sor[0]==0:
		print(0)
	else:
		if 673 in sor or 1346 in sor:
			if 672 in sor or 675 in sor or 1344 in sor or 1347 in sor:
				print(0)
			else:
				q,mod = divmod(sor[0]*sor[1],2019)
				print(mod)
		else:
			q,mod = divmod(sor[0]*sor[1],2019)
			print(mod)
else:
	print(0)

Submission status: Wrong Answer

Solution code:
l,r=map(int,input().split())
ans=0
if l%2019>r%2019 or r-l>=2018:
    ans=0
else:
    if (l%673>r%673 and r-l>=2) or r-l>=672:
        ans=0
    else:
        ll=l%2019
        rr=r%2019
        ans=min((rr*(rr-1))%2019,(ll*(ll+1))%2019)
print(ans)

Submission status: Wrong Answer

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

l %= 2019
r %= 2019
ans = 99999999999999

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

a = l%mod
b = r%mod

if(a<b):
    ans = a*(a+1)
else:
    ans = b*(b-1)

print(ans)

Submission status: Wrong Answer

Solution code:
import sys

MOD = 2019

def solve(L, R):
    if L%MOD == 0 or R%MOD == 0:
        print(0)
        return

    ms = [ False ] * 2019
    for i in range(L, R+1):
        if ms[i%MOD]:
            break
        ms[i%MOD] = True
    
    x = 0
    while not ms[x]:
        x += 1
    
    ans = x * (x+1) % MOD
    print(ans)


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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

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

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

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

########

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

if R<L:
    R = L + diff

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

print(ans)

Submission status: Wrong Answer

Solution code:
MOD = 2019

L, R = map(int, input().split())
minx = float("inf")
for i in range(L, R):
    im = i % MOD
    if i != L and im == L % MOD:
        break
    for j in range(i + 1, R + 1):
        jm = j % MOD
        if j != i + 1 and jm == (i + 1) % MOD:
            break
        minx = min(minx, im * jm)
print(minx)

Submission status: Wrong Answer

Solution code:
L,R=map(int,input().split())
w=R-L
L%=2019
R%=2019
if w>=2018 or L>R:
    print(0)
else:
    ans=[x*(x+1)%2019 for x in range(L,R)]
    print(min(ans))

Submission status: Wrong Answer

Solution code:
import sys
import itertools
L, R = map(int, input().split())
arr = [i for i in range(L,R)]

minm = 100000000


arr1 = [(i[0]*i[1]) % 2019 for i in  itertools.permutations(arr, 2)]
arr1.sort()
if not arr1:
    print((L*R)%2019)
    sys.exit()
print(arr1[0])

Submission status: Wrong Answer

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

N = R - L + 1
r = L % 2019

if N >= 2019:
    print(0)
    exit()

m1 = 2018
m2 = 2017
for i in range(N):
    a = (r + i) % 2019
    if a < m1:
        m1 = a
    elif a < m2:
        m2 = a

an = m1 * (m2 + 1)
print(an % 2019)

Submission status: Wrong Answer

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

if l < 2020:
  print(0)
elif r - l > 2018:
  print(0)
else:
  x = []
  for i in range(l, r):
    for j in range(i+1, r+1):
      m = i * j % 2019
      x.append(m) 
  print(min(x))

Submission status: Wrong Answer

Solution code:
n = list(map(int, input().rstrip().split(" ")))
if n[1] - n[0] >= 2019:
    print(0)
else:
    a = n[0]%2019
    b = n[1]%2019
    l = [i%2019 for i in range(a,b+1)]
    if 673 in l:
        for a in l:
            if a%3==0:
                print(0)
                break
    else:
        print((l.pop(l.index(min(l)))*l.pop(l.index(min(l))))%2019)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

def input_from_console():
    l, r = map(int, input().split())
    return l, r


def solve(l, r):
    if r - l >= 2019:
        return 0
    a, b = l % 2019, r % 2019
    if r// 2019 > l //2019:
        return 0

    first = min(a, b)
    result = (first * (first + 1)) % 2019
    return result


def main():
    l, r = input_from_console()
    print(solve(l, r))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main()