Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

h, w = [int(i) for i in input().split()]

s = [input() for i in range(h)]

light = [[0 for i in range(w)] for j in range(h)]

for j in range(h):
    point = 0
    for i in range(w):
        if s[j][i] == ".":
            point += 1
            light[j][i] += point
        else:
            point = 0

    point = 0
    for i in range(w):
        if s[j][-1-i] == ".":
            point += 1
            light[j][-1-i] += point
        else:
            point = 0

for j in range(w):
    point = 0
    for i in range(h):
        if s[i][j] == ".":
            point += 1
            light[i][j] += point
        else:
            point = 0

    point = 0
    for i in range(h):
        if s[-1-i][j] == ".":
            point += 1
            light[-1-i][j] += point
        else:
            point = 0

ans = 0
for i in range(h):
    ans = max(ans, max(light[i]))
print(ans-3)

### FIXED CODE ###

h, w = [int(i) for i in input().split()]

s = [input() for i in range(h)]

light = [[0 for i in range(w)] for j in range(h)]

for j in range(h):
    point = 0
    for i in range(w):
        if s[j][i] == ".":
            point += 1
            light[j][i] += point
        else:
            point = 0

    point = 0
    for i in range(w):
        if s[j][-1-i] == ".":
            point += 1
            light[j][-1-i] += point
        else:
            point = 0

for j in range(w):
    point = 0
    for i in range(h):
        if s[i][j] == ".":
            point += 1
            light[i][j] += point
        else:
            point = 0

    point = 0
    for i in range(h):
        if s[-1-i][j] == ".":
            point += 1
            light[-1-i][j] += point
        else:
            point = 0

ans = 0
for i in range(h):
    ans = max(ans, max(light[i]))
print(ans-3)
### BUGGY CODE ###

import sys
A, B = [int(x) for x in input().split()]

for K in range(10**9):
    if abs(A - K) == abs(B - K):
        print(K)
        sys.exit

print("IMPOSSIBLE")

### FIXED CODE ###

import sys
A, B = [int(x) for x in input().split()]

if (A + B)%2 == 0:
    print((A + B)//2)
else:
    print("IMPOSSIBLE")
### BUGGY CODE ###

from heapq import heappush, heappushpop

N = int(input())
a = list(map(int, input().split()))

max_score = float('-inf')
for i in range(N, 2 * N + 1):
    rm_count_1 = i - N
    rm_count_2 = N - rm_count_1
    a_list_1 = []
    a_list_2 = []
    for k in a[0:i]:
        if len(a_list_1) >= N:
            heappushpop(a_list_1, k)
        else:
            heappush(a_list_1, k)
    for k in a[i:3*N]:
        if len(a_list_2) >= N:
            heappushpop(a_list_2, -k)
        else:
            heappush(a_list_2, -k)
    sum_1 = sum(a_list_1)
    sum_2 = sum(a_list_2)
    score = sum_1 + sum_2
    if score > max_score:
        max_score = score

print(max_score)

### FIXED CODE ###

from heapq import heappush, heappushpop

N = int(input())
a = list(map(int, input().split()))

a_list_1 = []
a_list_2 = []
for i in a[0:N]:
    heappush(a_list_1, i)
for i in list(reversed(a))[0:N]:
    heappush(a_list_2, -i)

sum_1 = sum(a_list_1)
sum_2 = sum(a_list_2)
sum_arr_1 = [0] * (N + 1)
sum_arr_1[0] = sum_1
sum_arr_2 = [0] * (N + 1)
sum_arr_2[-1] = sum_2
for k in range(N, 2 * N):
    l = heappushpop(a_list_1, a[k])
    sum_1 += a[k] - l
    sum_arr_1[k - N + 1] = sum_1

for k in reversed(range(N, 2 * N)):
    l = heappushpop(a_list_2, -a[k])
    sum_2 += -a[k] - l
    sum_arr_2[k - N] = sum_2

max_score = float('-inf')
for s1, s2 in zip(sum_arr_1, sum_arr_2):
    score = s1 + s2
    if score > max_score:
        max_score = score

print(max_score)
### BUGGY CODE ###

N, K = map(int, input().split())
p=list(map(int,input().split()))

for i in range(N):
  p[i]=(1+p[i])/2
  
ans=0

for i in range(N-K+1):
  ans=max(ans, sum(p[i:i+K]))

print(ans)

### FIXED CODE ###

N, K = map(int, input().split())
p=list(map(int,input().split()))

for i in range(N):
  p[i]=(1+p[i])/2
  
ans=[0]*(N-K+1)
ans[0]=sum(p[:K])
for i in range(1, N-K+1):
  ans[i]=ans[i-1]-p[i-1]+p[i+K-1]

print(max(ans))
### BUGGY CODE ###

def main():
    cards = []
    for _ in range(int(input())):
        cards.append(Card(input()))

    base_cards = cards.copy()
    quickSort(cards, 0, len(cards) - 1)

    print(check_stable(base_cards, cards))
    for c in cards:
        print(c.cha, c.num)


def quickSort(A, p, r):
    if p < r:
        q = partiton(A, p, r)
        quickSort(A, p, q - 1)
        quickSort(A, q + 1, r)


def partiton(A, p, r):
    x = A[r]
    i = p - 1

    for j in range(p, r):
        if A[j].num <= x.num:
            i = i + 1
            A[i], A[j] = A[j], A[i]

    A[i + 1], A[r] = A[r], A[i + 1]
    return i + 1


def check_stable(base, card):
    nums = []
    for c in card:
        if c.num not in nums:
            nums.append(c.num)

    for n in nums:
        if list(filter(lambda x: x.num == n, base)) != list(filter(lambda x: x.num == n, card)):
            return 'Not stable'

    return 'Stable'


class Card:
    def __init__(self, imp):
        cha, num = imp.split(' ')
        self.cha = cha
        self.num = int(num)


main()

### FIXED CODE ###

"""Quick Sort."""
 
def partition(A, p, r):
    """Divide list A into A[p:q] whose elements aren't greater than A[q] and
    A[q+1:r] whose elements are greater than A[q].
 
    Each element of A is a list [x, y].
    x is a character of S, H, C or D (trump suits).
    y is a natural number.
    Sorting is done based on y numbers.
     
    Default value of p is 0.
    The number as a refernce of the division is A[r].
     
    Return the index q.
    """
 
    x = A[r][1]
    i = p - 1
    for j in range(p, r):
        if A[j][1] <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i + 1], A[r] = A[r], A[i + 1]
    return i + 1
 
 
def quickSort(A, p, r):
    """Sort list A in ascending order with quick sort algorithm.
 
    Default value of p is 0 (the start index).
    r is 1 less than the length of A (the last index of A).
    """
 
    if p < r:
        q = partition(A, p, r)
        quickSort(A, p, q - 1)
        quickSort(A, q + 1, r)
 
 
def is_stable(A, B):
    """Check the stability of sorted list A.
 
    A is a sorted list.
    B is a original list.
 
    Return True or False.
    """
 
    cA = list(A)
    for x in B:
        i = cA.index(x)
        if i == 0:
            pass
        elif cA[i - 1][1] == x[1]:
            return False
        del cA[i]
    return True
 
 
 
import sys
 
r = int(sys.stdin.readline()) - 1
 
A = []
 
for x in sys.stdin.readlines():
    suit, num = x.split()
    num = int(num)
    A.append([suit, num])
 
B = list (A)
 
quickSort(A, 0, r)
 
if is_stable(A, B):
    print('Stable')
else:
    print('Not stable')
 
for x in A:
    print(*x)
### BUGGY CODE ###

import sys #追加
sys.setrecursionlimit(10**6)
n,q = map(int,input().split())

from collections import defaultdict
dic = defaultdict(list)


for _ in range(n-1):
    a,b = map(int,input().split())
    dic[a-1].append(b-1)
    dic[b-1].append(a-1)


dic2 = defaultdict(int)

for _ in range(q):
    p,x = map(int,input().split())
    dic2[p-1] += x

ansl = [0 for i in range(n)]
used = [-1 for i in range(n)]
used[0] = 1
que = [0]
while que:
    pos = que.pop()
    for p in dic[pos]:
        if used[p] == -1:
            ansl[p] = ansl[pos] + dic2[pos]
            used[p] = 1
            que.append(p)


for idx, a in enumerate(ansl):
    print(a + dic2[idx])





### FIXED CODE ###

n,q = map(int,input().split())
m = [[] for i in range(n)]
for _ in range(n-1):
   a,b = map(int,input().split())
   m[a-1].append(b-1)
   m[b-1].append(a-1)

from collections import defaultdict
dic = defaultdict(int)
for _ in range(q):
   p,x = map(int,input().split())
   dic[p-1] += x

ans = [0 for i in range(n)]
ans[0] = dic[0]

used = [0 for i in range(n)]
used[0] = 1
quu = [0]
while quu:
   k = quu.pop()
   for l in m[k]:
      if used[l] == 0:
         used[l] = 1
         quu.append(l)
         ans[l] = ans[k] + dic[l]

for i in ans:
   print(i)
### BUGGY CODE ###

n = int(input())

a = list(map(int,input().split()))
m = 10 ** 18
ans = 1
for i in range(n):
	ans *= a[i]

if ans > m:
	print(-1)
else:
	print(ans)


### FIXED CODE ###

n = int(input())

a = list(map(int,input().split()))
a.sort(reverse=True)

if a[-1] == 0:
	print(0)
	exit()

m = 10 ** 18
ans = 1
for i in range(n):
	ans *= a[i]
	if ans > m:
		print(-1)
		exit()
print(ans)
### BUGGY CODE ###

from itertools import chain
 
double = lambda c: int(c)*2
 
N = int(input())
T = tuple(map(double,input().split()))
V = tuple(map(double,input().split()))
 
dp = [0]
 
for t,v_max,vf_max in zip(T,V,chain(V[1:],(0,))):
  ndp = [None]*(min(vf_max,v_max)+1)
  
  for vf in range(len(ndp)):
    vi_min = max(0,vf-t)
    vi_max = min(v_max,vf+t)
    vf2 = vf*vf
    vt = vf+t
    def it():
      for vi,d in enumerate(dp[vi_min:vi_max+1], start=vi_min):
        vp = (vt+vi)/2
        yield d + 2*vp*vp-vf2-vi*vi - 2*max(0,vp-v_max)**2
    ndp[vf] = max(it(), default=-float('inf'))
  
  dp = ndp
 
print(dp[0]/8)

### FIXED CODE ###

from itertools import chain
 
double = lambda c: int(c)*2
 
N = int(input())
T = tuple(map(double,input().split()))
V = tuple(map(double,input().split()))
 
dp = [0]
 
for t,v_max,vf_max in zip(T,V,chain(V[1:],(0,))):

  ndp = [None]*(min(vf_max,v_max)+1)
  
  for vf in range(len(ndp)):
    vi = min(len(dp)-1,vf+t)
    while vi >= 0 and dp[vi] is None:
      vi -= 1

    if vi < max(0,vf-t):
      ndp[vf] = None
    else:
      vp = (vf+t+vi)/2
      ndp[vf] = dp[vi] + 2*vp*vp-vf*vf-vi*vi - 2*max(0,vp-v_max)**2
  dp = ndp
 
print(dp[0]/8)
### BUGGY CODE ###

N,K = map(int, input().split())
h= list(map(int, input().split()))
INF=float('inf')
dp=[INF]*(N)
dp[0]=0
dp[1]=abs(h[0]-h[1])

for i in range(2,N):
    for k in range(1,K+1):
        dp[i]=min(dp[i-k]+abs(h[i]-h[i-k]),dp[i])
print(dp[-1])

### FIXED CODE ###

N,K = map(int, input().split())
h = list(map(int, input().split()))

DP=[0]*(N)
DP[0]=0
DP[1]=abs(h[1]-h[0])
#print(DP)
for i in range(2,N):
    DP[i]=DP[i-1]+abs(h[i]-h[i-1])
    for u in range(1,K+1):
        if i-u>=0:
            DP[i]=min(DP[i],DP[i-u]+abs(h[i]-h[i-u]))
        else:
            break
    #print(DP)
print(DP[N-1])
### BUGGY CODE ###

from heapq import heappush, heappop
from itertools import permutations, accumulate, combinations
from math import pi, ceil, floor
import numpy as np
from collections import defaultdict, deque
from operator import itemgetter
from bisect import bisect_left, bisect_right, insort_left, insort_right
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10 ** 6)
# MOD = 10 ** 9 + 7
# INF = float("inf")


def main():
    n, m = map(int, input().split())
    A = list(map(int, input().split()))
    for i in range(m):
        b, c = map(int,input().split())
        A += [c] * b
    A.sort(reverse=True)
    print(sum(A[:n]))


if __name__ == '__main__':
    main()

### FIXED CODE ###

from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations
from math import pi, ceil, floor
import numpy as np
from collections import defaultdict, deque
from operator import itemgetter
from bisect import bisect_left, bisect_right, insort_left, insort_right
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10 ** 6)
# MOD = 10 ** 9 + 7
# INF = float("inf")


def main():
    n, m = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort()
    B = [tuple(map(int, input().split())) for _ in range(m)]
    B.sort(reverse=True, key=itemgetter(1))
    tmp = 0
    for b, c in B:
        for i in range(tmp, b+tmp):
            if A[i] < c:
                A[i] = c
                tmp += 1
                if i == n-1:
                    print(sum(A))
                    exit()
            else:
                print(sum(A))
                exit()
    print(sum(A))


if __name__ == '__main__':
    main()
### BUGGY CODE ###

MOD = 998244353
MAXN = 2*(10**5)+10
f = [1]
for i in range(MAXN):
    f.append(f[-1] * (i+1) % MOD)
def nCr(n, r, mod=MOD):
    return f[n] * pow(f[r], mod-2, mod) * pow(f[n-r], mod-2, mod) % mod


N, M, K = map(int, input().split())
ans = 0
for i in range(K+1):
    tmp = pow(M-1, N-i-1, MOD) * M % MOD
    tmp *= nCr(N-1,i,MOD)
    ans += tmp % MOD
    ans %= MOD
print(ans)

### FIXED CODE ###

MOD = 998244353
MAXN = 2*(10**5)+10
f = [1]
for i in range(MAXN):
    f.append(f[-1] * (i+1) % MOD)
def nCr(n, r, mod=MOD):
    return f[n] * pow(f[r], mod-2, mod) * pow(f[n-r], mod-2, mod) % mod


N, M, K = map(int, input().split())
ans = 0
for i in range(K+1):
    tmp = pow(M-1, N-i-1, MOD) * M % MOD
    tmp *= nCr(N-1,i,MOD)
    ans += tmp % MOD
    ans %= MOD
print(ans)
### BUGGY CODE ###

import math
def main():
    n,p=map(int,input().split())
    if n==1:
        print(p)
    else:
        q=math.ceil(p**(1/n))
        ans=1
        for i in range(q,0,-1):
            if p%(i**n)==0:
                ans=i
                break
        print(ans)
if __name__=="__main__":
    main()

### FIXED CODE ###

import math
def main():
    n,p=map(int,input().split())
    if n==1:
        print(p)
    elif n>39:
        print(1)
    else:
        q=math.ceil(p**(1/n))
        ans=1
        for i in range(q,0,-1):
            if p%(i**n)==0:
                ans=i
                break
        print(ans)
if __name__=="__main__":
    main()
### BUGGY CODE ###

n,k = map(int,input().split())
A = list(map(int,input().split()))

prev = 1
for i in range(k):
  prev *= A[k-i-1]
 
left = 0
right = k
tmp = prev
while right<n:
  tmp /= A[left]
  tmp *= A[right]
  if tmp>prev:
    print("Yes")
  else:
    print("No")
  prev = tmp
  left += 1
  right += 1

### FIXED CODE ###

n,k = map(int,input().split())
A = list(map(int,input().split()))
left = 0
right = k
while right<n:
  if A[right]>A[left]:
    print("Yes")
  else:
    print("No")
  left += 1
  right += 1
### BUGGY CODE ###

from functools import reduce
from fractions import gcd

n = int(input())
a = list(map(int, input().split()))
ans = []

for i in a:
    b = sorted(a)
    b.remove(i)
    ans.append(reduce(gcd, b))

print(max(ans))


### FIXED CODE ###

from functools import reduce
from fractions import gcd

n = int(input())
a = list(map(int, input().split()))
A = list(set(a))
ans = [reduce(gcd, A)]

if len(A) == 1:
    print(A[0])
    exit()
for i in A:
    b = sorted(A)
    b.remove(i)
    if a.count(i) == 1:
        ans.append(reduce(gcd, b))

print(max(ans))
### BUGGY CODE ###

#D

line = [int(x) for x in input().split()]
n = line[0]
x = line[1]
y = line[2]

results =[0]*(n+2)

for i in range(1, n+1):
    for j in range(i,n+1):
        yeet = min([abs(j-i), abs(x-i) + 1 + abs(j-y), abs(y-i) + 1 + abs(j-x)])
        results[yeet] = results[yeet] + 1

for i in range(1, n):
    print(results[i])



### FIXED CODE ###

#D

line = [int(x) for x in input().split()]
n = line[0]
x = line[1]
y = line[2]

results =[0]*(n+2)

for i in range(1, n):
    for j in range(i+1,n+1):
        results[min([abs(j-i), abs(x-i) + 1 + abs(j-y)])-1] += 1

for i in range(0, n-1):
    print(results[i])
### BUGGY CODE ###

n, a = map(int, input().split())
xlist = list(map(int, input().split()))

j = n
k = n
t = n * a



dp = [[[0 for t in range(t + 1)] for k in range(k + 1)] for j in range(j + 1)]

dp[1][0][0] = 1
dp[0][0][0] = 1

# for d in dp:
#     print(d)
# print(dp[1][1][15])

for ji in range(1, j + 1):
    for ki in range(0, k + 1):
        for ti in range(0, t + 1):
            # print('now', ji, ki, ti)
            if ti < xlist[ji - 1]:
                dp[ji][ki][ti] = dp[ji - 1][ki][ti]
                # print('branch 2')
            else:
                # print('branch 3', ji - 1)
                dp[ji][ki][ti] = dp[ji - 1][ki][ti] + dp[ji - 1][ki - 1][ti - xlist[ji - 1]]
            # print(dp[ji][ki][ti])

count = 0
for i in range(1, k + 1):
    count += dp[j][i][i*a]

print(count)

### FIXED CODE ###

n, a = map(int, input().split())
xlist = list(map(int, input().split()))

j = n
k = n
t = n * a
maxv = max(a, max(xlist))


dp = [[[0 for t in range(n*maxv + 1)] for k in range(k + 1)] for j in range(j + 1)]

dp[1][0][0] = 1
dp[0][0][0] = 1

# for d in dp:
#     print(d)
# print(dp[1][1][15])

for ji in range(0, j + 1):
    for ki in range(0, ji + 1):
        for ti in range(0, ki * maxv + 1):
            # print('now', ji, ki, ti)
            if ji == 0 and ki == 0 and ti == 0:
                # print('branch 1')
                dp[ji][ki][ti] = 1
            elif ji >= 1 and ti < xlist[ji - 1]:
                dp[ji][ki][ti] = dp[ji - 1][ki][ti]
                # print('branch 2')
            elif ji >= 1 and ki >= 1 and ti >= xlist[ji - 1]:
                # print('branch 3', ji - 1)
                dp[ji][ki][ti] = dp[ji - 1][ki][ti] + dp[ji - 1][ki - 1][ti - xlist[ji - 1]]
            # print(dp[ji][ki][ti])

count = 0
for i in range(1, k + 1):
    count += dp[j][i][i*a]

print(count)
### BUGGY CODE ###

# 法Pの下での組み合わせ数 nCk を求める
# MAX: nの最大値

P = (10**9)+7

fac=[]
inv=[]
finv=[]

# 拡張ユークリッドアルゴリズム
# (d, x, y): d=ax+by を満たすd, x, yを求める
# aとbが互いに素な整数であればgcd(a,b)=d=1, ax=1 (mod b)
# xは法bの元でaの乗法逆元a^-1になる
def exEuclid(a, b):
    if (b==0):
        return (a, 1, 0)
    else:
        (dd, xx, yy) = exEuclid(b, a % b)
        return (dd, yy, xx - (a//b)*yy)

def COMinit(MAX):
    global fac, inv, finv
    fac=[1 for _ in range(MAX)]
    inv=[1 for _ in range(MAX)]
    finv=[1 for _ in range(MAX)]
    #print('len(fac): {}'.format(len(fac)))
    #print(MAX)
    for i in range(2,MAX):
        #print(i)
        fac[i] = fac[i-1]*i % P
        (d, x, y) = exEuclid(i, P)
        inv[i] = x
        finv[i] = finv[i-1]*inv[i] % P

def COM(n, k):
    if(n<k):
        return 0
    elif ( (n<0)or(k<0)):
        return 0
    else:
        return fac[n]*(finv[n-k]*finv[k] % P) % P

####

#print('x, y:')
x, y = list(map(int,input().split()))
MAX = (x+y)//3 +1  # (X+Y)/3より大きい整数 1 <= X, Y <= 10**6
COMinit(MAX)

if ((x+y)%3 != 0):
    print(0)
    exit()
else:
    n1 = (-x+2*y)//3
    n2 = (2*x -y)//3
    if (n1<0):
        print(0)
        exit()
    elif(n2<0):
        print(0)
        exit()
    else:
        npath = COM(n1+n2, n1)
        print(npath)



### FIXED CODE ###

# 法Pの下での組み合わせ数 nCk を求める
# MAX: nの最大値

P = (10**9)+7

fac=[]
inv=[]
finv=[]

# 拡張ユークリッドアルゴリズム
# (d, x, y): d=ax+by を満たすd, x, yを求める
# aとbが互いに素な整数であればgcd(a,b)=d=1, ax=1 (mod b)
# xは法bの元でaの乗法逆元a^-1になる
def exEuclid(a, b):
    if (b==0):
        return (a, 1, 0)
    else:
        (dd, xx, yy) = exEuclid(b, a % b)
        return (dd, yy, xx - (a//b)*yy)

def COMinit(MAX):
    global fac, inv, finv
    fac=[1 for _ in range(MAX)]
    inv=[1 for _ in range(MAX)]
    finv=[1 for _ in range(MAX)]
    #print('len(fac): {}'.format(len(fac)))
    #print(MAX)
    for i in range(2,MAX):
        #print(i)
        fac[i] = fac[i-1]*i % P
        (d, x, y) = exEuclid(i, P)
        inv[i] = x
        finv[i] = finv[i-1]*inv[i] % P

def COM(n, k):
    if(n<k):
        return 0
    elif ( (n<0)or(k<0)):
        return 0
    else:
        return fac[n]*(finv[n-k]*finv[k] % P) % P

####

#print('x, y:')
x, y = list(map(int,input().split()))
MAX = (x+y)//3 +1  # (X+Y)/3より大きい整数 1 <= X, Y <= 10**6
COMinit(MAX)

if ((x+y)%3 != 0):
    print(0)
    exit()
else:
    n1 = (-x+2*y)//3
    n2 = (2*x -y)//3
    if (n1<0):
        print(0)
        exit()
    elif(n2<0):
        print(0)
        exit()
    else:
        npath = COM(n1+n2, n1)
        print(npath)
### BUGGY CODE ###

n = int(input())
s = input()

ans = 0
for a in range(10):
    ai = 0
    while ai < n:
        if s[ai] == str(a):
            break
        else:
            ai += 1
    if ai == n:
        continue
    for b in range(10):
        bi = ai + 1
        while bi < n:
            if s[bi] == str(b):
                break
            else:
                bi += 1
        if bi == n:
            continue
        for c in range(10):
            ci = bi + 1
            while ci < n:
                if s[ci] == str(c):
                    break
                else:
                    ci += 1
            if ci == n:
                continue
            else:
                ans += 1

print(ans)
exit(0)


### FIXED CODE ###

n = int(input())
s = input()

t = [set() for _ in range(n)]
t[-1] = {int(s[-1])}

for i in range(1, n):
    base = t[n - i].copy()
    base.add(int(s[n - i - 1]))
    t[n - i - 1] = base

ans = 0
for a in range(10):
    ai = 0

    if a not in t[ai]:
        continue

    while ai < n:
        if s[ai] == str(a):
            break
        else:
            ai += 1
    if ai >= n - 2:
        continue
    for b in range(10):
        bi = ai + 1

        if b not in t[bi]:
            continue

        while bi < n:
            if s[bi] == str(b):
                break
            else:
                bi += 1
        if bi >= n - 1:
            continue
        for c in range(10):
            ci = bi + 1

            if c not in t[ci]:
                continue

            while ci < n:
                if s[ci] == str(c):
                    break
                else:
                    ci += 1
            if ci == n:
                continue
            else:
                ans += 1

print(ans)
exit(0)


x = int(input())
dp = [False for _ in range(x + 1)]
dp[0] = True
for item in [100, 101, 102, 103, 104, 105]:
    for i in range(x + 1):
        if i - item >= 0:
            if dp[i - item]:
                dp[i] = True

print(1 if dp[x] else 0)
exit(0)
### BUGGY CODE ###

n = int(input())
s = [input() for i in range(n)]
s.sort()
l = sorted(set(s))

ans = 0
ans_l = []
for i in l:
    sc = s.count(i)
    if sc > ans:
        ans_l = [i]
        ans = sc
    elif sc == ans:
        ans_l.append(i)
      
print("\n".join(ans_l))

### FIXED CODE ###

from collections import Counter

n = int(input())
S = [input() for i in range(n)]

s = Counter(S)
max_cnt = max(s.values())
names = [name for name, cnt in s.items() if cnt == max_cnt]
names.sort()

print("\n".join(names))
### BUGGY CODE ###

import numpy as np

h, n = map(int, input().strip().split())
AB = [list(map(int, input().split())) for i in range(n)]

dp=[np.inf]*(h+1)

dp[0]=0
for ab in AB:
    a=ab[0]
    b=ab[1]
    for i in range(h):
        ni=min(i+a,h)
        dp[ni] = min(dp[ni],dp[i]+b)
        
print(dp[h])

### FIXED CODE ###

h, n = map(int, input().strip().split())
# AB = [list(map(int, input().split())) for i in range(n)]

dp=[10**9]*(h+1)

dp[0]=0
for _ in range(n):
    a, b = map(int, input().strip().split())
    for i in range(h):
        ni=min(i+a,h)
        dp[ni] = min(dp[ni],dp[i]+b)
        
print(dp[h])
### BUGGY CODE ###

m=input();n=int(m);s=n/2;a=[];i=6
while n%2==0:a+=[2];n//=2
while n%3==0:a+=[3];n//=3
while i<s:
 if n%(i-1)==0:a+=[i-1];n//=i-1
 elif n%(i+1)==0:a+=[i+1];n//=i+1
 else:i+=6
if n==int(m):a+=[m]
print(m+':',*a)


### FIXED CODE ###

p=lambda x:print(x,end=' ')
n=input();p(n+':')
m=n=int(n)
while n%2==0 and n>3:p(2);n//=2
d=3
while d*d<m and n>d:
 if n%d>0:d+=2
 else:p(d);n//=d
print(n)
### BUGGY CODE ###

dellist = lambda items, indexes: [item for index, item in enumerate(items) if index not in indexes]
n=int(input())
s=input()
ans=[]
for i in range(n-1):
    if s[i]==s[i+1]:
        ans+=[i+1]
v=dellist(s,ans)
print(len(v))

### FIXED CODE ###

n=int(input())
s=input()
ans=[]
if len(set(s))==1:
    print(1)
else:
    for i in range(n-1):
        if s[i]!=s[i+1]:
            ans+=s[1]
    print(len(ans)+1)
### BUGGY CODE ###

import sys
import numpy as np 
def minimize():
    L, R=map(int,input().split())
    lis=[]
    for i in range(L,R):
        for j in range(i+1, R+1):
            x=(i*j) %2019
            lis.append(x)
            if x==0:
                break
    lis=np.array(lis)
    ans=lis.min()
    print(ans)

minimize()


### FIXED CODE ###

import sys
import numpy as np 
def minimize():
    L, R=map(int,input().split())
    lis=[]
    if (L+2019) >= R:
        
        for i in range(L,R):
            for j in range(i+1, R+1):
                x=(i*j) %2019
                lis.append(x)
        lis=np.array(lis)
        ans=lis.min()
        print(ans)
    
    else :
        for i in range(L,(L+2019)):
            for j in range(i+1, L+2020):
                x=(i*j) %2019
                lis.append(x)
        lis=np.array(lis)
        ans=lis.min()
        print(ans)


minimize()