Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

a = [input() for i in range(n)]

print(max(a[1:]))

for i in range(1, n-1):
    a1 = max(a[:i])
    a2 = max(a[i+1:])
    max_a = a1 if a1 > a2 else a2
    print(max_a)
    
print(max(a[:-1]))

Fixed submission:
n = int(input())

a = [int(input()) for i in range(n)]
 
b = sorted(a, reverse=True)
 
 
for ai in a:
    if ai == b[0]:
        print(b[1])
    else:
        print(b[0])
Buggy python submission (verdict: Time Limit Exceeded):
l, r = map(int, input().split())

ans = 2020

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

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

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

Buggy python submission (verdict: Time Limit Exceeded):
import math

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

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

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

ans = 2020
if r - l >= 2019:
    r = l + 2018
for i in range(l, r):
    for j in range(i + 1, r + 1):
        tmp = i * j % 2019
        if ans > tmp:
            ans = tmp
    
print(ans)
Buggy python submission (verdict: Runtime Error):
n, l = map(int, input().split())
pie = 0
min_aji = 100
for i in range(1, n+1):
    aji = l + i - 1
    pie += aji
    if abs(aji) < min_aji:
        min_aji = abs(aji)
        apple = i
        
pie -= l + apple -1

print(pie)

Fixed submission:
n, l = map(int, input().split())
aji = []

for i in range(1, n+1):
    aji.append(l + i - 1)

aji.sort(key=abs)
print(sum(aji[1:]))

Buggy python submission (verdict: Runtime Error):
n, l = map(int, input().split())
pie = 0
min_aji = 100
for i in range(1, n+1):
    pie += l + i - 1
    if abs(l + i - 1) < min_aji:
        min_aji = abs(l + i - 1)
        apple = i
        
pie -= l + apple -1

print(pie)

Fixed submission:
n, l = map(int, input().split())
aji = []

for i in range(1, n+1):
    aji.append(l + i - 1)

aji.sort(key=abs)
print(sum(aji[1:]))

Buggy python submission (verdict: Runtime Error):
n, l = map(int, input().split())
pie = 0
min_aji = 100
for i in range(1, n+1):
    if abs(l + i - 1) < min_aji:
        min_aji = abs(l + i - 1)
        apple = i
        
for i in range(1, n+1):
    if apple == i:
        continue
    pie += l + i - 1

print(pie)

Fixed submission:
n, l = map(int, input().split())
aji = []

for i in range(1, n+1):
    aji.append(l + i - 1)

aji.sort(key=abs)
print(sum(aji[1:]))
Buggy python submission (verdict: Runtime Error):
import math

a, b, c, d = map(int, input().split())

# cとdの最大公約数
g = math.gcd(c, d)

# cとdの最小公倍数
l = c * d // g

# cとdで割り切れないb以下の数の個数
# (全体) - (cの倍数の個数) - (dの倍数の個数) + (cの倍数かつdの倍数の個数)
x = b - b // c - b // d + b // l

# cとdで割り切れない(a-1)以下の数の個数
y = (a - 1) - (a - 1) // c - (a - 1) // d + (a - 1) // l
    
print(x - y)

Fixed submission:
import fractions

a, b, c, d = map(int, input().split())

# cとdの最大公約数
g = fractions.gcd(c, d)

# cとdの最小公倍数
l = c * d // g

# cとdで割り切れないb以下の数の個数
# (全体) - (cの倍数の個数) - (dの倍数の個数) + (cの倍数かつdの倍数の個数)
x = b - b // c - b // d + b // l

# cとdで割り切れない(a-1)以下の数の個数
y = (a - 1) - (a - 1) // c - (a - 1) // d + (a - 1) // l
    
print(x - y)
Buggy python submission (verdict: Runtime Error):
n, x = map(int, input().split())
l = [int(i) for i in input().split()]

i = 1
d = 0
c = 1
while True:
    d += l[i-1]
    if d > x or i == n + 1:
        break
    c += 1
    i += 1
    
print(c)

Fixed submission:
N, X = map(int, input().split())
L = [int(i) for i in input().split()]

count = 1
d = 0
for l in L:
    d += l
    if d > X:
        break
    count += 1
    
print(count)

Buggy python submission (verdict: Runtime Error):
n, x = map(int, input().split())
l = [int(i) for i in input().split()]

i = 0
d = 0
c = 0
while d <= x:
    c += 1
    d += l[i-1]
    i += 1
    
print(c)

Fixed submission:
N, X = map(int, input().split())
L = [int(i) for i in input().split()]

count = 1
d = 0
for l in L:
    d += l
    if d > X:
        break
    count += 1
    
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
lst = [0 for i in range(n+1)]
cnt = 0
for _ in range(m):
    l, r = map(int, input().split())
    for i in range(l, r+1):
        lst[i] += 1 

cnt = lst.count(m)
print(cnt)

Fixed submission:
n, m = map(int, input().split())
l_list = []
r_list = []
cnt = 0
for _ in range(m):
    l, r = map(int, input().split())
    l_list.append(l)
    r_list.append(r)

print(min(r_list) - max(l_list) + 1) if min(r_list) >= max(l_list) else print(0)
Buggy python submission (verdict: Runtime Error):
import numpy as np
import math
N = int(input())
a = list()
for i in range(N):
    a.append(list(map(int, input().split())))
a = np.array(a)    
dis = 0
for i in range(N):
    for j in range(N):
        dis = dis + numpy.linalg.norm(a[i]-a[j])
dis = dis/2
print(dis*2/N)

Fixed submission:
import numpy as np
import math
N = int(input())
a = list()
for i in range(N):
    a.append(list(map(int, input().split())))
a = np.array(a)    
dis = 0
for i in range(N):
    for j in range(N):
        dis = dis + math.sqrt((a[i][0]-a[j][0])**2+(a[i][1]-a[j][1])**2)
dis = dis/2
print(dis*2/N)
Buggy python submission (verdict: Runtime Error):
import numpy as np

N = 3

hyo = np.zeros((N,2))

for NN in range(N):
    hyo[NN] = input().split(' ')

hyo_sorted = hyo[np.argsort(hyo[:,1])]

tooktime = hyo_sorted[:,0].cumsum()

timeup = hyo_sorted[:,1]

if any(tooktime > timeup) ==True:
    print("No")
else:
    print("Yes")

Fixed submission:
import numpy as np

N = int(input())

hyo = np.zeros((N,2))

for NN in range(N):
    hyo[NN] = input().split(' ')

hyo_sorted = hyo[np.argsort(hyo[:,1])]

tooktime = hyo_sorted[:,0].cumsum()

timeup = hyo_sorted[:,1]

if any(tooktime > timeup) ==True:
    print("No")
else:
    print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

dp = [[] for i in range(n)]
for i in range(n):
    r = dp[i]
    prev = s[i]
    r.append(prev)
    for j in range(i + 1, n):
        nxt = prev + s[j]
        r.append(nxt)
        prev = nxt

res = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        tt = res
        mx = min(j - i, n - j)
        if tt >= mx:
            continue
        while tt < mx:
            if dp[i][tt] != dp[j][tt]:
                break
            else:
                tt += 1
        res = max(res, tt)

print(res)

Fixed submission:
n = int(input())
s = input()

dp = [[0 for i in range(5005)] for j in range(5005)]

for i in range(n - 1, -1, -1):
    for j in range(n - 1, -1, -1):
        dp[i][j] = 0 if s[i] != s[j] else dp[i + 1][j + 1] + 1

res = 0
for i in range(n):
    for j in range(n):
        if i >= j:
            continue
        curr = min(dp[i][j], j - i)
        res = max(res, curr)

print(res)

Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()

tmp = n // 2
if s[0:tmp + 1] == s[tmp + 1:]:
    return tmp

res = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        tt = res
        mx = min(j - i, n - j)
        if tt >= mx:
            continue
        while tt <= mx:
            tt += 1
            if s[i:i + tt] != s[j:j + tt]:
                break
        _res = tt - 1
        res = max(res, _res)

print(res)

Fixed submission:
n = int(input())
s = input()

dp = [[0 for i in range(5005)] for j in range(5005)]

for i in range(n - 1, -1, -1):
    for j in range(n - 1, -1, -1):
        dp[i][j] = 0 if s[i] != s[j] else dp[i + 1][j + 1] + 1

res = 0
for i in range(n):
    for j in range(n):
        if i >= j:
            continue
        curr = min(dp[i][j], j - i)
        res = max(res, curr)

print(res)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

res = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        tt = res
        mx = min(j - i, n - j)
        if tt >= mx:
            continue
        while tt <= mx:
            tt += 1
            if s[i:i + tt] != s[j:j + tt]:
                break
        _res = tt - 1
        res = max(res, _res)

print(res)

Fixed submission:
n = int(input())
s = input()

dp = [[0 for i in range(5005)] for j in range(5005)]

for i in range(n - 1, -1, -1):
    for j in range(n - 1, -1, -1):
        dp[i][j] = 0 if s[i] != s[j] else dp[i + 1][j + 1] + 1

res = 0
for i in range(n):
    for j in range(n):
        if i >= j:
            continue
        curr = min(dp[i][j], j - i)
        res = max(res, curr)

print(res)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
arr = [i for i in range(1, n)]
print(int(sum(arr)))

Fixed submission:
n = int(input())

res = n * ((n - 1) // 2)
if (n - 1) % 2 == 1:
    res += ((n - 1) // 2) + 1

print(int(res))
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a_list = list(map(int, input().split()))
mod = 10 ** 9 + 7

s = 0
for i in range(k):
    s += i

res = 0
for i in range(n):
    for j in range(n):
        if j == i:
            continue
        if a_list[i] > a_list[j]:
            if i < j:
                res += s + k
            else:
                res += s

res %= mod
print(int(res))

Fixed submission:
n, k = map(int, input().split())
a_list = list(map(int, input().split()))
mod = 10 ** 9 + 7

s = k * ((k - 1) // 2)
if (k - 1) % 2 != 0:
    s += (k - 1) // 2 + 1

res = 0
for i in range(n):
    for j in range(n):
        if j == i:
            continue
        if a_list[i] > a_list[j]:
            if i < j:
                res += s + k
            else:
                res += s

res %= mod
print(int(res))
Buggy python submission (verdict: Runtime Error):
s = str(input())
l = len(s)

counter = 0
prev = None
pivot = 0

while pivot < l:
    n = 1
    if prev == s[pivot]:
        if pivot + 1 < l:
            prev = s[pivot + 2]
            counter += 2
            pivot += 3

        else:
            break
    else:
        counter += 1
        prev = s[pivot]
        pivot += n

print(int(counter))

Fixed submission:
s = str(input())
l = len(s)

counter = 0
prev = None
pivot = 0

while pivot < l:
    n = 1
    if prev == s[pivot]:
        if pivot + 1 < l:
            if pivot + 2 < l:
                prev = s[pivot + 2]
                counter += 2
                pivot += 3
            else:
                counter += 1
                break
        else:
            break
    else:
        counter += 1
        prev = s[pivot]
        pivot += n

print(int(counter))

Buggy python submission (verdict: Time Limit Exceeded):
s = list(str(input()))

counter = 0
prev = None
while len(s) > 0:
    x = s.pop(0)
    if prev == x:
        if len(s) == 0:
            break

        x += s.pop(0)

    counter += 1
    prev = x

print(int(counter))

Fixed submission:
s = str(input())
l = len(s)

counter = 0
prev = None
pivot = 0

while pivot < l:
    n = 1
    if prev == s[pivot]:
        if pivot + 1 < l:
            if pivot + 2 < l:
                prev = s[pivot + 2]
                counter += 2
                pivot += 3
            else:
                counter += 1
                break
        else:
            break
    else:
        counter += 1
        prev = s[pivot]
        pivot += n

print(int(counter))

Buggy python submission (verdict: Time Limit Exceeded):
s = list(str(input()))

counter = 0
prev = None
while len(s) > 0:
    x = s.pop(0)
    if prev == x:
        if len(s) == 0:
            break

        x += s.pop(0)

    counter += 1
    prev = x

print(int(counter))

Fixed submission:
s = str(input())
l = len(s)

counter = 0
prev = None
pivot = 0

while pivot < l:
    n = 1
    if prev == s[pivot]:
        if pivot + 1 < l:
            if pivot + 2 < l:
                prev = s[pivot + 2]
                counter += 2
                pivot += 3
            else:
                counter += 1
                break
        else:
            break
    else:
        counter += 1
        prev = s[pivot]
        pivot += n

print(int(counter))
Buggy python submission (verdict: Runtime Error):
def resolve():
    a, b, c = map(int, input())
    return c - a + b
  
resolve()

Fixed submission:
def resolve():
    a, b, c = map(int, input().split(" "))
    print(max(0, c - a + b))
    
    
resolve()
Buggy python submission (verdict: Runtime Error):
5
2 4 3 5 15
2 4 3 5 1

Fixed submission:
n = int(input())
arr = list(map(int, input().split()))
sorted_arr = sorted(arr)

counter = 0
for i in range(n):
    if arr[i] != sorted_arr[i]:
        counter += 1
    if counter > 2:
        break

if counter == 2 or counter == 0:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_list = list(map(int, input().split()))
first = a_list[0]

mem = {}
for i in range(1, n + 1):
    mem[i] = {}

counter = 0

for i in range(first + 1):
    curr = i
    arr = [0] * (n + 1)
    arr[0] = curr * 2

    valid = True
    for j in range(0, n):
        curr = arr[j]
        nxt = 0
        if curr not in mem[j + 1]:
            nxt = int(( a_list[j] - curr / 2) * 2)
            mem[j + 1][curr] = nxt
            counter += 1
        else:
            nxt = mem[j + 1][curr]

        if nxt < 0:
            valid = False
            break
        arr[j + 1] = nxt

    if not valid:
        continue

    if arr[0] == arr[n]:
        print(*arr[:n])
        break

Fixed submission:
n = int(input())
a_list = list(map(int, input().split()))
first = a_list[0]

def check(m0):
    arr = [0] * (n + 1)
    arr[0] = m0
    for j in range(0, n):
        curr = arr[j]
        nxt = int((a_list[j] - curr / 2) * 2)
        arr[j + 1] = nxt
    return arr

r = (0, first)
while r[0] <= r[1]:
    mid = (r[0] + r[-1]) // 2
    m0 = mid * 2
    arr = check(m0)
    mn = arr[n]
    if m0 == mn:
        print(*arr[:n])
        break
    elif mn > m0:
        r = (mid + 1, r[1])
    else:
        r = (r[0], mid - 1)
Buggy python submission (verdict: Time Limit Exceeded):
from heapq import heappush, heappop

n, m = map(int, input().split())
a_list = input().split()
a_queue = []
for a in a_list:
    heappush(a_queue, int(a))

for i in range(m):
    b, c = map(int, input().split())
    for j in range(b):
        m = heappop(a_queue)
        heappush(a_queue, max(m, c))

print(sum(a_queue))

Fixed submission:
from heapq import heappush, heappop

n, m = map(int, input().split())
a_list = input().split()
priority_queue = []
for a in a_list:
    heappush(priority_queue, (-int(a), 1))

for i in range(m):
    b, c = map(int, input().split())
    heappush(priority_queue, (-c, b))

res = 0
for i in range(n):
    c_, b = heappop(priority_queue)
    res += -c_
    b -= 1
    if b > 0:
        heappush(priority_queue, (c_, b))

print(res)
Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np

def main():
    input = sys.stdin.readline
    N, T = map(int, input().split())
    dishes = []
    for _ in range(N):
        a, b = map(int, input().split())
        dishes.append((a, b))
    
    dishes = sorted(dishes, key=lambda x: x[0])
    
    ans = 0
    dp = np.zeros(T, dtype=int)
    for a, b in dishes:
        ans = max(ans, dp.max() + b)
        np.maximum(dp[:-a] + b, dp[a:], out=dp[a:])

    return ans

if __name__ == '__main__':
    print(main())

Fixed submission:
import sys
import numpy as np

def main():
    input = sys.stdin.readline
    N, T = map(int, input().split())
    dishes = []
    for _ in range(N):
        a, b = map(int, input().split())
        dishes.append((a, b))
    
    dishes = sorted(dishes, key=lambda x: x[0])
    
    ans = 0
    dp = np.zeros(T, dtype=int)
    for a, b in dishes:
        ans = max(ans, dp.max() + b)
        np.maximum(dp[:-a] + b, dp[a:], out=dp[a:])

    return ans

if __name__ == '__main__':
    print(main())
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import deque

def main():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    q = deque()
    for _ in range(N):
        a, b = map(int, input().split())
        if a > M:
            continue
        q.append((a, b))

    ans = 0
    cnt = 1
    while cnt <= M:
        q_ = deque()
        max_a, max_b = 0, 0
        while q:
            a, b = q.pop()
            if a > cnt:
                q_.append((a, b))
                continue
            elif b > max_b:
                q_.append((max_a, max_b))
                max_a, max_b = a, b
            else:
                q_.append((a, b))

        ans += max_b
        cnt += 1
        q = q_


    return ans


if __name__ == '__main__':
    print(main())


Fixed submission:
import sys
from collections import defaultdict
from heapq import heappop, heappush

def main():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    d = defaultdict(list)
    for _ in range(N):
        a, b = map(int, input().split())
        d[a].append(-b)

    ans = 0
    heap = []
    for i in range(1, M+1):
        for b in d[i]:
            heappush(heap, b)
        if heap:
            ans -= heappop(heap)

    return ans


if __name__ == '__main__':
    print(main())
Buggy python submission (verdict: Time Limit Exceeded):
import sys

def main():
    input = sys.stdin.readline
    MOD = 10**9 + 7
    S = list(str(input().strip()))
    n = len(S)

    dp = [[0] * 13 for _ in range(n)]
    s = S.pop()
    if s == '?':
        for i in range(10):
            dp[0][i] = 1
    else:
        s = int(s)
        dp[0][s] = 1

    digit = 1
    m = 1
    while S:
        s = S.pop()
        m = (m * 10) % 13
        if s == '?':
            for k in range(10):
                M = (m * k) % 13
                for i in range(13):
                    j = (i + M) % 13
                    dp[digit][j] += dp[digit-1][i]
                    dp[digit][j] %= MOD
        else:
            s = int(s)
            M = (m * s) % 13
            for i in range(13):
                j = (i + M) % 13
                dp[digit][j] += dp[digit-1][i]
                dp[digit][j] %= MOD
        digit += 1

    return dp[n-1][5]


if __name__ == '__main__':
    print(main())


Fixed submission:
import sys

def main():
    input = sys.stdin.readline
    MOD = 10**9 + 7
    T = list(str(input().strip()))
    S = [int(t) if t != '?' else -1 for t in T]
    n = len(S)

    dp = [[0] * 13 for _ in range(n)]
    s = S.pop()
    if s < 0:
        for i in range(10):
            dp[0][i] = 1
    else:
        dp[0][s] = 1

    digit = 1
    m = 1
    while S:
        s = S.pop()
        m = (m * 10) % 13
        if s < 0:
            for k in range(10):
                M = (m * k) % 13
                for i in range(13):
                    j = (i + M) % 13
                    dp[digit][j] += dp[digit-1][i]
                    dp[digit][j] %= MOD
        else:
            M = (m * s) % 13
            for i in range(13):
                j = (i + M) % 13
                dp[digit][j] += dp[digit-1][i]
                dp[digit][j] %= MOD
        digit += 1

    return dp[n-1][5]


if __name__ == '__main__':
    print(main())
Buggy python submission (verdict: Time Limit Exceeded):
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    A = [0] + list(map(int, input().split()))

    M = 0
    ans = ''
    B = [0] * (N+1)
    for i in range(N, 0, -1):
        cnt = 0
        for j in range(2*i, N+1, i):
            cnt += B[j]

        if A[i] != cnt % 2:
            B[i] += 1
            M += 1
            ans = str(i) + ' ' + ans

    if M == 0:
        print(0)
    else:
        print(M)
        print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
import sys
 
def main():
    input = sys.stdin.readline
    N = int(input())
    A = [0] + list(map(int, input().split()))
 
    M = 0
    ans = []
    B = [0] * (N+1)
    for i in range(N, 0, -1):
        cnt = 0
        for j in range(2*i, N+1, i):
            cnt += B[j]
 
        if A[i] != cnt % 2:
            B[i] += 1
            M += 1
            ans.append(i)
 
    if M == 0:
        print(0)
    else:
        ans = ans[::-1]
        print(M)
        print(' '.join(map(str, ans)))
 
 
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    A = [0] + list(map(int, input().split()))

    M = 0
    ans = ''
    B = [0] * (N+1)
    for i in range(N, 0, -1):
        cnt = 0
        for j in range(2*i, N+1, i):
            cnt += B[j]

        if A[i] != cnt % 2:
            B[i] += 1
            M += 1
            ans = str(i) + ' ' + ans

    if M == 0:
        print(0)
    else:
        print(M)
        print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
import sys
 
def main():
    input = sys.stdin.readline
    N = int(input())
    A = [0] + list(map(int, input().split()))
 
    M = 0
    ans = []
    B = [0] * (N+1)
    for i in range(N, 0, -1):
        cnt = 0
        for j in range(2*i, N+1, i):
            cnt += B[j]
 
        if A[i] != cnt % 2:
            B[i] += 1
            M += 1
            ans.append(i)
 
    if M == 0:
        print(0)
    else:
        ans = ans[::-1]
        print(M)
        print(' '.join(map(str, ans)))
 
 
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys

def main():
    input = sys.stdin.readline
    L, R = map(int, input().split())
    R = min(R, L + 2019*2)

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

    return ans


if __name__ == '__main__':
    print(main())


Fixed submission:
import sys

def main():
    input = sys.stdin.readline
    L, R = map(int, input().split())
    R = min(R, L + 2019)

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

    return ans


if __name__ == '__main__':
    print(main())

Buggy python submission (verdict: Runtime Error):
import sys

def main():
    input = sys.stdin.readline
    L, R = map(int, input().split())

    if L == 0:
        return 0

    if (R // 2019) > ((L-1) // 2019):
        return 0

    if (R // 673) > ((L-1) // 673):
        if R - L >= 2:
            return 0
        if (R % 3) == 0 or (L % 3) == 0:
            return 0

    left = L % 2019
    return (left * (left + 1)) % MOD


if __name__ == '__main__':
    print(main())


Fixed submission:
import sys

def main():
    input = sys.stdin.readline
    L, R = map(int, input().split())
    R = min(R, L + 2019)

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

    return ans


if __name__ == '__main__':
    print(main())