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

H,W=map(int, input().split())
A=[input() for i in range(H)]

from collections import deque

q=deque([])
B=[[None]*W for _ in range (H)]
for i in range(H):
    for j in range(W):
        if A[i][j]=="#":
            q.append((i,j))
            B[i][j]=0
dx=[-1,1,0,0]
dy=[0,0,-1,1]
while len(q)>0:
  XY=[]
  while len(q)>0:
     XY.append(q.popleft())
  for xy in XY:
    for i in range(4):
      if 0<=(xy[0]+dx[i])<=H-1 and 0<=(xy[1]+dy[i])<=W-1:
        if B[xy[0]+dx[i]][xy[1]+dy[i]]==None:
          B[xy[0]+dx[i]][xy[1]+dy[i]]=B[xy[0]][xy[1]]+1
          q.append((xy[0]+dx[i],xy[1]+dy[i]))
        else: pass
      else: pass
print(max([max(B[i]) for i in range(H)]))

### FIXED CODE ###

H,W=map(int, input().split())
A=[input() for i in range(H)]

from collections import deque

q=deque([])
B=[[None]*W for _ in range (H)]
for i in range(H):
    for j in range(W):
        if A[i][j]=="#":
            q.append((i,j))
            B[i][j]=0
dx=[-1,1,0,0]
dy=[0,0,-1,1]
while len(q)>0:
  XY=[]
  while len(q)>0:
     XY.append(q.popleft())
  for xy in XY:
    for i in range(4):
      if 0<=(xy[0]+dx[i])<=H-1 and 0<=(xy[1]+dy[i])<=W-1:
        if B[xy[0]+dx[i]][xy[1]+dy[i]]==None:
          B[xy[0]+dx[i]][xy[1]+dy[i]]=B[xy[0]][xy[1]]+1
          q.append((xy[0]+dx[i],xy[1]+dy[i]))
        else: pass
      else: pass
print(max([max(B[i]) for i in range(H)]))
### BUGGY CODE ###

from collections import deque
s=list(input())
n=len(s)
K=int(input())
d=deque()
l={}
li=[]
cnt=0
for i in range(n):
    d.append(s[i])
for i in range(n):
    buf=deque()
    for j in range(n-i):
        v=d.popleft()
        buf.append(v)
        s="".join(buf)
        l[s]=cnt
    buf.popleft()
    d=buf
#print(l)
li=list(l)
li.sort()

#print(l)
print(li[K-1])

### FIXED CODE ###

from collections import deque
s=list(input())
K=int(input())
#max(K)=5でaaaaaはa,aa,aaa,aaaa,aaaaaの順
#よって5文字まで取れば良い
d=deque()
for i in range(len(s)):
    d.append(s[i])
comp=[]
#print(d)
for i in range(len(s)):
    buf=deque()
    for j in range(len(d)):
        v=d.popleft()
        buf.append(v)
        if j<5:
            comp.append("".join(buf))
    d=deque()
    for j in range(len(buf)):
        d.append(buf[j])
    d.popleft()
comp=list(set(comp))
comp.sort()
print(comp[K-1])
### BUGGY CODE ###

def main():
    N, T = map(int, input().split())

    AB = [tuple(map(int, input().split())) for i in range(N)]

    AB.sort(key=lambda x: x[0])
    maxA = 0
    for a, b in AB:
        maxA = max(maxA, a)

    dp = [-1]*(T+maxA)
    dp[0] = 0

    for a, b in AB:
        for i in range(T+maxA-1, -1, -1):
            if i >= T:
                if i-a < T and i-a >= 0 and dp[i-a] >= 0:
                    dp[i] = max(dp[i], dp[i-a] + b)

            elif i - a >= 0 and dp[i-a] >= 0:
                dp[i] = max(dp[i], dp[i-a] + b)

    print(max(dp))
main()

### FIXED CODE ###

def main():
    import sys
    input = sys.stdin.readline
    N, T = map(int, input().split())
    ab = [list(map(int, input().split())) for i in range(N)]
    ab.sort(key=lambda x: (x[0], x[1]))
    dp = [-1 for i in range(T*2 + 1)]
    dp[0] = 0
    for a, b in ab:
        for i in range(T*2, 0, -1):
            if i >= a:
                if dp[i-a] >= 0 and i - a < T:
                    dp[i] = max(dp[i], dp[i-a] + b)

    for i in range(1, T*2+1):
        dp[i] = max(dp[i], dp[i-1])
    ans = dp[-1]

    ab.sort(key=lambda x: x[1])
    tmp = ab.pop()
    dp = [-1 for i in range(T)]
    dp[0] = 0
    for a, b in ab:
        for i in range(T-1, 0, -1):
            if i >= a:
                if dp[i-a] >= 0:
                    dp[i] = max(dp[i], dp[i-a] + b)

    for i in range(1, T):
        dp[i] = max(dp[i], dp[i-1])
    ans = max(ans, tmp[1] + dp[-1])

    # print(dp)
    print(ans)


main()
### BUGGY CODE ###

def Factorial(A):
    X = 1
    for num in range(1, A+1):
        X *= num
    return X

n, m = map(int, input().split())

if n == m+1:
    ans = Factorial(n)*Factorial(m)
elif n == m:
    ans = Factorial(n)*Factorial(m)*2
elif n+1 == m:
    ans = Factorial(n)*Factorial(m)
else:
    ans = 0
print(ans)

### FIXED CODE ###

def Factorial(A):
    MOD = 10**9+7
    X = 1
    for num in range(1, A+1):
        X *= num
        X %= MOD
    return X

n, m = map(int, input().split())
MOD = 10**9+7

if n == m+1:
    ans = Factorial(n)*Factorial(m)
elif n == m:
    ans = Factorial(n)*Factorial(m)*2
elif n+1 == m:
    ans = Factorial(n)*Factorial(m)
else:
    ans = 0
print(ans%MOD)
### BUGGY CODE ###

n, q = map(int, input().split())
s = input()
for i in range(q):
    cnt = 0
    l, r = map(int, input().split())
    print(s[l-1:r].count("AC"))

### FIXED CODE ###

N,Q=map(int,input().split())
S=input()
count=[0]*N
for i in range(1,N):
    count[i]+=count[i-1]
    if S[i-1:i+1]=="AC":count[i]+=1
for i in range(Q):
    l,r=map(int,input().split())
    print(count[r-1]-count[l-1])
### BUGGY CODE ###

N = int(input())
D = [int(input()) for i in range(N)]

e = [0 for j in range(N)]

for i in range(N):
    e = D[:]
    del e[i]
    print(max(e))

### FIXED CODE ###

N = int(input())
d = [int(input()) for i in range(N)]

M = max(d)
D = d[:]
d.remove(M)
m = max(d)

for j in range(N):
    if D[j]==M:
        print(m)
    else:
        print(M)
### BUGGY CODE ###

import math
def equal(x,y,z):
    return x**2 + y**2 + z**2 +x*y+y*z+z*x

N = int(input())

for i in range(1,N+1):
    cnt = 0
    for x in range(1,math.ceil(math.sqrt(i))+1):
        for y in range(1,math.ceil(math.sqrt(i))+1):
            for z in range(1,math.ceil(math.sqrt(i))+1):
                if equal(x,y,z) == i:
                    #print(x,y,z)
                    cnt+=1
    print(cnt)


### FIXED CODE ###

import math
def equal(x,y,z):
    return x**2 + y**2 + z**2 +x*y+y*z+z*x

N = int(input())
ans = [0 for _ in range(10050)]
for x in range(1,105):
        for y in range(1,105):
            for z in range(1,105):
                v = equal(x,y,z)
                if v < 10050:
                    ans[v]+=1
for i in range(N):
    print(ans[i+1])
### BUGGY CODE ###

n=int(input())
x=1
lst=list(map(int,input().split()))
for i in lst:
  x*=i
if x<=10**18:
  print(x)
else:
  print('-1')


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
if 0 in a:
  print(0)
else:
  cnt=1
  for i in a:
    cnt*=i
    if cnt>10**18:
      cnt=-1
      break
  print(cnt)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import math

H,W,D = map(int, input().split())

A = [0]*(H*W)
for h in range(H):
    As = list(map(int, input().split()))
    for w in range(W):
        A[As[w]-1] = (h,w)

Q = int(input())

def solve(l, r):
    ans = 0
    while l != r:
        x,y = A[l-1]
        x2,y2 = A[l+D-1]
        ans += abs(x-x2) + abs(y-y2)
        l += D
    return ans

lrs = []
for q in range(Q):
    L, R = map(int, input().split())
    lrs.append((L,R))

for info in lrs:
    L,R = info
    print(solve(L, R))



### FIXED CODE ###

# -*- coding: utf-8 -*-
import math
H,W,D = map(int, input().split())

# Ah = np.array([0]*(H*W))
# Aw = np.array([0]*(H*W))
A = [0]*(H*W)
for h in range(H):
    As = list(map(int, input().split()))
    for w in range(W):
        A[As[w]-1] = (h,w)
    # Aw[As-1] = np.arange(W)
    # Ah[As-1] = h


Q = int(input())

# def solve(l, r):
#     ans = 0
#     # ah = Ah[l-1:r][::D]
#     # ans += np.sum(np.abs(ah[1:] - ah[0:-1]))
#     # aw = Aw[l-1:r][::D]
#     # ans += np.sum(np.abs(aw[1:] - aw[0:-1]))
#     ans = sum(Ah[l-1:l+D][::D])
#     while l != r:
#         x,y = A[l-1]
#         x2,y2 = A[l+D-1]
#         ans += abs(x-x2) + abs(y-y2)
#         l += D
#     return ans

Ans = [0]*(H*W)
aa = (H*W) // D
bb = (H*W) % D
for dth in range(1,aa+1):
    for d in range(D):
        if dth*D+d >=H*W:
            break
        x,y = A[(dth-1)*D+d]
        x2,y2 = A[dth*D+d]
        ans = abs(x-x2) + abs(y-y2)
        Ans[dth*D+d] = Ans[(dth-1)*D+d] + ans



lrs = []
for q in range(Q):
    L, R = map(int, input().split())
    print(Ans[R-1] - Ans[L-1])
    #lrs.append((L,R))

# for info in lrs:
#     L,R = info
#     print(solve(L, R))
### BUGGY CODE ###

def main():
    X, K, D = map(int, input().split())

    val = [0] * 100000000
    val[0] = X
    #val = X
    #val_new = 0
    if K % 2 == 0 :
        limit = 10
    else :
        limit = 11
    i = 0
    if abs(X) > K * D :
        if X > 0 :
            print(X - K * D)
        else :
            print(abs(X + K * D))
    elif abs(X) == K * D :
        print("0")
    else :
        for j in val :
            #print(i)
            if abs(val[i] - D) < abs(val[i] + D) :
                val[i+1] = val[i] - D
            else :
                val[i+1] = val[i] + D
            if (val[i+1] == val[i-1]) and i > limit :
                print(abs(val[i + 1]))
                break
            i += 1
            if i == K :
                print(abs(val[i]))
                break


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    X, K, D = map(int, input().split())

    val = [0] * 100000000
    val[0] = X
    #val = X
    #val_new = 0
    if K % 2 == 0 :
        limit = 4
    else :
        limit = 5
    i = 0
    if abs(X) > K * D :
        if X > 0 :
            print(X - K * D)
        else :
            print(abs(X + K * D))
    elif abs(X) == K * D :
        print("0")
    elif X == 0 :
        if limit == 4 :
            print('0')
        else :
            print(abs(D))
    else :
        syo = abs(X) // D
        #print(syo)
        if syo > 3 :
            if X > 0 :
                val[0] = X - (syo-2) * D
            else :
                val[0] = X + (syo - 2) * D
            #print(val[0])
            K = K -(syo-2)
            if K % 2 == 0:
                limit = 2
            else:
                limit = 3
        for j in val :
            #print(i)
            if abs(val[i] - D) < abs(val[i] + D) :
                val[i+1] = val[i] - D
            else :
                val[i+1] = val[i] + D
            #print(val[i+1])
            if (abs(val[i+1]) == abs(val[i-1])) and i > limit :
                #print("a")
                print(abs(val[i + 1]))
                break
            i += 1
            if i == K :
                #print("b")
                print(abs(val[i]))
                break


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

from collections import deque

N,M=map(int,input().split())
rinsetu=[set() for _ in range(N+1)]
for i in range(M):
    a,b=map(int,(input().split()))
    rinsetu[a].add(b)
    rinsetu[b].add(a)
grp=0
color=["white"]*(N+1)
color[0]="black"
for i in range(1,N+1):
    if color[i]=="white":
        d = deque()
        d.append(i)
        a = set()
        a.add(i)
        while(d):
            k=d.popleft()
            color[k]="black"
            for j in rinsetu[k]:
                if color[j]=="white":
                    d.append(j)
                    a.add(j)
        grp=max(grp,len(a))
print(grp)


### FIXED CODE ###

from collections import deque

N, M = map(int, input().split())
rinsetu = [set() for _ in range(N + 1)]
for i in range(M):
    a, b = map(int, (input().split()))
    rinsetu[a].add(b)
    rinsetu[b].add(a)

grp = 0
color = ["white"] * (N + 1)
color_2 = ["white"] * (N + 1)
color[0] = "black"
for i in range(1, N + 1):
    count=1
    if color[i] == "white":
        d = deque()
        d.append(i)
        a = set()
        a.add(i)
        while (d):
            k = d.popleft()
            color[k] = "black"
            color_2[k]="black"
            for j in rinsetu[k]:
                if color[j] == "white" and color_2[j]=="white":
                    color_2[j]="black"
                    d.append(j)
                    count+=1
        grp=max(grp,count)
print(grp)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
mul = 1
for i in a:
    mul *= i
if mul > 10 ** 18:
    mul = -1
print(mul)


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
mul = 1
if 0 in a:
    mul = 0

for i in a:
    mul *= i
    if mul > 10 ** 18:
        mul = -1
        break
print(mul)
### BUGGY CODE ###

import sys
N = int(input())
D = list(map(int, input().split()))

argminD = 0#np.argmin(D)
for i in range(0, D[argminD]*2+1, 2):
  first = int(i)
  final = D[argminD]*2 - int(i)
  for j in range(argminD+1, N+argminD):
    j = j % N
    final = D[j]*2-final
    if final < 0:
      break
  if first == final:
    result = [str(first)]
    final = D[argminD]*2 - first
    for j in range(argminD+1, N+argminD):
      j = j % N
      result.append(str(final))
      final = D[j]*2-final
    print(" ".join(result))
    #print(" ".join(result[argminD:]) + " " + " ".join(result[:argminD]))
    sys.exit(0)
  

### FIXED CODE ###

import numpy as np
import sys
N = int(input())
D = np.asarray(list(map(int, input().split())))

first = np.sum(D) - np.sum(D[1::2])*2
result = [str(first)]
final = D[0]*2 - first
for j in range(1, N):
  result.append(str(final))
  final = D[j]*2-final
print(" ".join(result))
### BUGGY CODE ###

import sys
input=sys.stdin.readline

def main():
    X = input().strip()

    for i in range(9,-1,-1): # 注: 長さは根拠なし
        # "S..ST..T"
        s = "S"*(2**i) + "T"*(2**i)
        while X.find(s) != -1:
            X = X.replace(s,"")
        # "ST..ST"
        s = "ST"*(2**i)
        while X.find(s) != -1:
            X = X.replace(s,"")
    print(len(X))

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
input=sys.stdin.readline

def main():
    X = input().strip()
    A = []
    for c in X:
        if len(A) > 0 and A[-1] == "S" and c == "T":
            A.pop()
        else:
            A.append(c)
    print(len(A))

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

# -*- coding: utf-8 -*-
import sys
from collections import defaultdict
sys.setrecursionlimit(10**9)
INF=10**18
MOD=2019
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    A=list(map(int,list(input())))
    N=len(A)
    d=[0]*2019
    for i in range(2019):
        d[i]=(i*10)%MOD
    dp=[defaultdict(int) for _ in range(N+1)]
    ans=0
    for i,x in enumerate(A):
        for j in dp[i]:
            dp[i+1][(d[j]+x)%MOD]+=dp[i][j]
        dp[i+1][x]+=1
        ans+=dp[i+1][0]
    print(ans)

    

if __name__ == '__main__':
    main()


### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=2019
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    A=list(map(int,list(input())[::-1]))
    N=len(A)
    S=[0]*(N+1)
    for i in range(N):
        S[i+1]=(S[i]+A[i]*pow(10,i,MOD))%MOD
    l=[0]*2019
    ans=0
    for i in range(N+1):
        ans+=l[S[i]]
        l[S[i]]+=1
    print(ans)


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

S_n = lambda n:n*(n+1)//2

def solve():
  N,K = map(int, input().split())
  P = list(map(int, input().split()))
  Q = P[:K]
  Q_ = P[:K]
  sum_Q = sum(Q)
  sum_Q_ = sum(Q)
  for i in range(N-K):
    sum_Q_ = sum_Q_ - Q_[0] + P[K+i]
    Q_ = Q_[1:]+[P[K+i]]

    if sum_Q < sum_Q_:
      Q = Q_
      sum_Q = sum_Q_

  # print(Q)

  print(sum(S_n(q)/q for q in Q))
  
solve()

### FIXED CODE ###

S_n = lambda n:n*(n+1)//2

def solve():
  N,K = map(int, input().split())
  P = list(map(int, input().split()))
  Q_idx = 0
  Q = P[:K]
  sum_Q = sum(Q)
  sum_Q_ = sum(Q)
  for i in range(N-K):
    sum_Q_ = sum_Q_ - P[i] + P[K+i]
    if sum_Q < sum_Q_:
      Q_idx = i+1
      sum_Q = sum_Q_

  Q = P[Q_idx:Q_idx+K]
  # print(Q)
  print(sum(S_n(q)/q for q in Q))
  
solve()
### BUGGY CODE ###

A,B,K = map(int,input().split())

for i in range(K):
  if A >= 1:
    A -= 1
  elif B >= 1:
    B -= 1
    
print(A,B)

### FIXED CODE ###

A,B,K = map(int,input().split())

if A - K >= 0:
  print(A-K,B)
elif A + B >= K:
  print(0,B+A-K)
else:
  print(0,0)
### BUGGY CODE ###

s = input()

checkedList = []
noCheckedList = []
tmp_index = 0

while(True) :

	if( s[tmp_index] == 'd' ) :
		if ( not (tmp_index in checkedList) ) and ( s[tmp_index:tmp_index+5] == 'dream' ) and ( s[tmp_index:tmp_index+7] == 'dreamer' ) :
			noCheckedList.append(tmp_index)
			checkedList.append(tmp_index)
			tmp_index += 7
		elif s[tmp_index:tmp_index+5] == 'dream' :
			tmp_index += 5
		elif s[tmp_index:tmp_index+7] == 'dreamer' :
			tmp_index += 7
	elif( s[tmp_index] == 'e' ) :
		if ( not (tmp_index in checkedList) )  and ( s[tmp_index:tmp_index+5] == 'erase' ) and ( s[tmp_index:tmp_index+6] == 'eraser' ) :
			noCheckedList.append(tmp_index)
			checkedList.append(tmp_index)
			tmp_index += 6
		elif s[tmp_index:tmp_index+5] == 'erase' :
			tmp_index += 5
		elif s[tmp_index:tmp_index+6] == 'eraser' :
			tmp_index += 6
	else :
		if len(noCheckedList) != 0 :
			tmp_index = noCheckedList.pop() + 5
			continue
		else :
			print('NO')
			break
	if tmp_index == len(s):
		print('YES')
		break
	elif len(s) - tmp_index < 5 :
		if len(noCheckedList) != 0 :
			tmp_index = noCheckedList.pop() + 5
		else :
			print('NO')
			break

### FIXED CODE ###

s = input()

tmp_index = 0

while(len(s) - tmp_index > 4) :

	if( s[tmp_index] == 'd' ) :
		if s[tmp_index:tmp_index+7] == 'dreamer' :
			if ( s[tmp_index + 5:tmp_index + 10] == 'erase' ):
				tmp_index += 5
			else :
				tmp_index += 7
		elif s[tmp_index:tmp_index+5] == 'dream' :
			tmp_index += 5
		else :
			tmp_index = len(s) - 1
			
	elif( s[tmp_index] == 'e' ) :
		if  s[tmp_index:tmp_index + 6] == 'eraser' :
			tmp_index += 6
		elif s[tmp_index:tmp_index+5] == 'erase' :
			tmp_index += 5
		else :
			tmp_index = len(s) - 1
	else :
		tmp_index = len(s) - 1
	if len(s) == tmp_index :
		print('YES')
	elif len(s) - tmp_index < 5 :
		print('NO')
### BUGGY CODE ###

import sys
sys.setrecursionlimit(500000)

n = int(input())
mod = 10 ** 9 + 7
node = [[] for _ in range(n)]
memo_f, memo_g = [0] * n, [0] * n
for i in range(n - 1):
    x, y = map(int, input().split())
    node[x - 1].append(y - 1)
    node[y - 1].append(x - 1)

def f(x, prev):
    if memo_f[x]:
        return memo_f[x]
    memo_f[x] = 1
    for i in node[x]:
        if i == prev:
            continue
        memo_f[x] = (memo_f[x] * g(i, x)) % mod
    memo_f[x] = (memo_f[x] + g(x, prev)) % mod
    return memo_f[x]

def g(x, prev):
    if memo_g[x]:
        return memo_g[x]
    memo_g[x] = 1
    for i in node[x]:
        if i == prev:
            continue
        memo_g[x] = (memo_g[x] * f(i, x)) % mod
    return memo_g[x]

print(f(0, -1))

### FIXED CODE ###

import sys
sys.setrecursionlimit(500000)

n = int(input())
mod = 10 ** 9 + 7
node = [[] for _ in range(n)]
memo_f, memo_g = [0] * n, [0] * n
for i in range(n - 1):
    x, y = map(int, input().split())
    node[x - 1].append(y - 1)
    node[y - 1].append(x - 1)

def f(x, prev):
    if memo_f[x]:
        return memo_f[x]
    memo_f[x] = 1
    for i in node[x]:
        if i == prev:
            continue
        memo_f[x] = (memo_f[x] * g(i, x)) % mod
    memo_f[x] = (memo_f[x] + g(x, prev)) % mod
    return memo_f[x]

def g(x, prev):
    if memo_g[x]:
        return memo_g[x]
    memo_g[x] = 1
    for i in node[x]:
        if i == prev:
            continue
        memo_g[x] = (memo_g[x] * f(i, x)) % mod
    return memo_g[x]

print(f(0, -1))
### BUGGY CODE ###

x, y, z, k = map(int, input().split(" "))
a = list(map(int, input().split(" ")))
b = list(map(int, input().split(" ")))
c = list(map(int, input().split(" ")))

ab = []
for i in range(x):
    for j in range(y):
        ab.append(a[i]+b[j])
ab.sort(reverse=True)
ab = ab[:min(x*y, k)]
abc = []
for i in range(len(ab)):
    for j in range(z):
        abc.append(ab[i]+c[j])
abc.sort(reverse=True)
for i in range(k):
    print(abc[i])

### FIXED CODE ###

x, y, z, k = map(int, input().split(" "))
a = list(map(int, input().split(" ")))
b = list(map(int, input().split(" ")))
c = list(map(int, input().split(" ")))

ab = []
for i in range(x):
    for j in range(y):
        ab.append(a[i]+b[j])
ab.sort(reverse=True)
ab = ab[:min(x*y, k)]
abc = []
for i in range(len(ab)):
    for j in range(z):
        abc.append(ab[i]+c[j])
abc.sort(reverse=True)
for i in range(k):
    print(abc[i])
### BUGGY CODE ###

#!/usr/bin/env python3


def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, m=1, typ=int):
    return [read_h() if m > 1 else typ(input()) for _ in range(n)]


def main():
    L, R = read_h()

    if R % 2019 == 0 or L % 2019 == 0 or (R - L) % 2019 == 0:
        print(0)
        return

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

    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3


def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, m=1, typ=int):
    return [read_h() if m > 1 else typ(input()) for _ in range(n)]


def main():
    L, R = read_h()

    ans = 3000
    for di in range(R - L + 1 if R - L < 2019 else 2019):
        i = L + di
        for dj in range(1, R - i + 1 if R - i < 2019 else 2019):
            j = i + dj
            ans = min(ans, ((i % 2019) * (j % 2019)) % 2019)

    print(ans)


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

from sys import stdin
input = stdin.readline
from fractions import gcd
 
mod = 10**9+7
 
n = int(input())
a = list(map(int,input().split()))
d = 1
for i in range(n):
  d *= a[i] // gcd(a[i],d)
ans = 0
for i in range(n):
  ans += d//a[i]
 
print(ans%mod)

### FIXED CODE ###

from sys import stdin
input = stdin.readline
from fractions import gcd
 
mod = 10**9+7
 
n = int(input())
a = list(map(int,input().split()))
d = 1
for i in range(n):
  d *= a[i] // gcd(a[i],d)
ans = 0
for i in range(n):
  ans += d//a[i]
 
print(ans%mod)
### BUGGY CODE ###

import math as m
N=int(input())
for n in range(1,N+1):
    if n>5:
        xmax=int(m.sqrt(n-5))
        ans=0
        for x in range(1,xmax+1):

            ymax=int((-(x+1)+m.sqrt(4*n-3*x**2-2*x-3))/2)
            if ymax>x:
                ymax=x 
            for y in range(1,ymax+1):
                D=4*n-3*(x**2+y**2)-2*x*y
                if D>=0 and m.sqrt(D)-(x+y)>1 and m.sqrt(D).is_integer():
                    z=int((-(x+y)+m.sqrt(D))/2)
                    if z<=y:
                        #if x**2+y**2+z**2+x*y+y*z+z*y==n:
                        #print('n=',n,[x,y,z])
                        if len(list(set([x,y,z])))==3:
                            ans+=6
                        elif len(list(set([x,y,z])))==2:
                            ans+=3
                        elif len(list(set([x,y,z])))==1:
                            ans+=1
    else:
        ans=0
    print(ans)


### FIXED CODE ###

import math as m
N=int(input())
ans=[0]*N
if N>5:
    for x in range(1,int(m.sqrt(N-5))+1):
        for y in range(1,x+1):
            if x**2+y**2+x*y+x+y+1>N:
                break
            for z in range(1,y+1):
                if x**2+y**2+x*y+x*z+y*z+z**2>N:
                    break
                if len(list(set([x,y,z])))==3:
                    ans[x**2+y**2+x*y+x*z+y*z+z**2-1]+=6
                elif len(list(set([x,y,z])))==2:
                    ans[x**2+y**2+x*y+x*z+y*z+z**2-1]+=3
                elif len(list(set([x,y,z])))==1:
                    ans[x**2+y**2+x*y+x*z+y*z+z**2-1]+=1

for a in ans:
    print(a)