Problem p02983 (python)

Fixed submission:
l, r = map(int, input().split())

flag = False
if l % 2019 == 0 or r // 2019 - l // 2019 != 0:
    flag = True

if flag:
    print(0)
else:
    lmod = l % 2019
    rmod = r % 2019

    ans = 10**5
    for i in range(lmod, rmod):
        for j in range(i+1, rmod+1):
            ans = min((i * j) % 2019, ans)
    print(ans)

Buggy submission (verdict: Runtime Error):
import math
l, r = map(int, input().split())

flag = False
if l % 2019 == 0 or r // 2019 - l // 2019 != 0:
    flag = True

if flag:
    print(0)
else:
    lmod = l % 2019
    rmod = r % 2019

    tmp = math.inf
    for i in range(lmod, rmod):
        for j in range(i+1, rmod+1):
            if (i * j) % 2019 < tmp:
                tmp = (i * j) % 2019
    print(tmp)

Buggy submission (verdict: Runtime Error):
import math
l, r = map(int, input().split())

flag = False
if l % 2019 == 0 or r // 2019 - l // 2019 != 0:
    flag = True

if flag:
    print(0)
else:
    lmod = l % 2019
    rmod = r % 2019
    root = math.sqrt(2019)

    n1, n2 = math.inf, math.inf
    p = lmod // 45
    q = rmod // 44
    for m in range(p, q+1):
        for i in range(lmod, rmod+1):
            if i - m * root > 0 and i - m * root < n1:
                tmp = n1
                n1 = i
                n2 = tmp
            elif i - m * root > 0 and i - m * root < n2:
                n2 = i

    print((n1 * n2) % 2019)

    # lmod = l % 2019
    # print((lmod * (lmod + 1)) % 2019)

Buggy submission (verdict: Runtime Error):
import math
l, r = map(int, input().split())

flag = False
if l % 2019 == 0 or r // 2019 - l // 2019 != 0:
    flag = True

if flag:
    print(0)
else:
    lmod = l % 2019
    rmod = r % 2019
    root = math.sqrt(2019)

    n1, n2 = math.inf, math.inf
    p = lmod // root
    q = rmod // root + 1
    for m in range(p, q+1):
        for i in range(lmod, rmod+1):
            if i - m * root > 0 and i - m * root < n1:
                tmp = n1
                n1 = i
                n2 = tmp
            elif i - m * root > 0 and i - m * root < n2:
                n2 = i

    print((n1 * n2) % 2019)

    # lmod = l % 2019
    # print((lmod * (lmod + 1)) % 2019)

Buggy submission (verdict: Runtime Error):
from math import sqrt, inf

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

flag = False
if l % 2019 == 0 or r // 2019 - l // 2019 != 0:
    flag = True

if flag:
    print(0)
else:
#     lmod = l % 2019
#     rmod = r % 2019
#     root = sqrt(2019)

#     n1, n2 = inf, inf
#     p = lmod // root
#     q = rmod // root + 1
#     for m in range(p, q+1):
#         for i in range(lmod, rmod+1):
#             if i - m * root > 0 and i - m * root < n1:
#                 tmp = n1
#                 n1 = i
#                 n2 = tmp
#             elif i - m * root > 0 and i - m * root < n2:
#                 n2 = i

#     print((n1 * n2) % 2019)

    lmod = l % 2019
    print((lmod * (lmod + 1)) % 2019)

Buggy submission (verdict: Runtime Error):
from math import sqrt, inf

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

flag = False
if r // 2019 - l // 2019 != 0:
    flag = True

if flag:
    print(0)
else:
    lmod = l % 2019
    rmod = r % 2019
    root = sqrt(2019)

    n1, n2 = inf, inf
    p = lmod // root
    q = rmod // root + 1
    for m in range(p, q+1):
        for i in range(lmod, rmod+1):
            if i - m * root > 0 and i - m * root < n1:
                tmp = n1
                n1 = i
                n2 = tmp
            elif i - m * root > 0 and i - m * root < n2:
                n2 = i

    print((n1 * n2) % 2019)

    # lmod = l % 2019
    # print((lmod * (lmod + 1)) % 2019)

Buggy submission (verdict: Runtime Error):
from math import sqrt, inf

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

flag = False
if r // 2019 - l // 2019 != 0:
    flag = True

if flag:
    print(0)
else:
    lmod = l % 2019
    rmod = r % 2019
    root = int(sqrt(2019))

    n1, n2 = inf, inf
    p = lmod // root
    q = rmod // root + 1
    for m in range(p, q+1):
        for i in range(lmod, rmod+1):
            if i - m * root > 0 and i - m * root < n1:
                tmp = n1
                n1 = i
                n2 = tmp
            elif i - m * root > 0 and i - m * root < n2:
                n2 = i

    print((n1 * n2) % 2019)

Buggy submission (verdict: Runtime Error):
from math import sqrt, inf

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

flag = False
if r // 2019 - l // 2019 != 0:
    flag = True

if flag:
    print(0)
else:
    lmod = l % 2019
    rmod = r % 2019
    root = int(sqrt(2019))

    n1, n2 = inf, inf
    p = lmod // root
    q = rmod // root + 1
    for m in range(p, q+1):
        for i in range(lmod, rmod+1):
            if abs(i - m * root) < n1:
                tmp = n1
                n1 = i
                n2 = tmp
            elif abs(i - m * root) < n2:
                n2 = i

    print((n1 * n2) % 2019)

Buggy submission (verdict: Runtime Error):
from math import sqrt, inf

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

flag = False
if r // 2019 - l // 2019 != 0:
    flag = True

if flag:
    print(0)
else:
    lmod = l % 2019
    rmod = r % 2019
    root = int(sqrt(2019))

    n1, n2 = inf, inf
    p = lmod // root
    q = rmod // root + 1
    for m in range(p, q+1):
        for i in range(lmod, rmod+1):
            if abs(i - m * root) < n1:
                tmp = n1
                n1 = i
                n2 = tmp
            elif abs(i - m * root) < n2:
                n2 = i

    print((n1 * n2) % 2019)

Buggy submission (verdict: Runtime Error):
from math import sqrt, inf

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

flag = False
if r // 2019 - l // 2019 != 0:
    flag = True

if flag:
    print(0)
else:
    lmod = l % 2019
    rmod = r % 2019
    root = int(sqrt(2019))

    n1, n2 = inf, inf
    for i in range(lmod, rmod+1):
        if abs(i - root) < n1:
            tmp = n1
            n1 = i
            n2 = tmp
        elif abs(i - root) < n2:
            n2 = i

    print((n1 * n2) % 2019)