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

# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0099
"""
import sys
import bisect



def main(args):
    #data = [(1, 4), (2, 5), (1, 3), (3, 6), (2, 7)]
    #data = [(1, 4), (2, 5), (2, -3),(3, 4), (1, -1)]
    fisher, event = [int(x) for x in input().split(' ')]
    fishes = [0 for _ in range(fisher + 1)]

    winner = 9999999999
    max_fish = -1
    for _ in range(event):
        id, fish = [int(x) for x in input().strip().split(' ')]
        fishes[id] += fish
        if fish > 0:
            if fishes[id] > max_fish:
                max_fish = fishes[id]
                winner = id
            elif fishes[id] == max_fish:
                winner = min(winner, id)
            else:
                pass
        else:
            max_fish = max(fishes)
            winner = fishes.index(max_fish)
        print('{} {}'.format(winner, max_fish))


if __name__ == '__main__':
    main(sys.argv[1:])

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0099
"""
import sys
import bisect



def main(args):
    #data = [(1, 4), (2, 5), (1, 3), (3, 6), (2, 7)]
    #data = [(1, 4), (2, 5), (2, -3),(3, 4), (1, -1)]
    fisher, event = [int(x) for x in input().split(' ')]
    fishes = [0 for _ in range(fisher + 1)]

    winner = 9999999999
    max_fish = -1
    for _ in range(event):
        id, fish = [int(x) for x in input().strip().split(' ')]
        fishes[id] += fish
        if fish > 0:
            if fishes[id] > max_fish:
                max_fish = fishes[id]
                winner = id
            elif fishes[id] == max_fish:
                winner = min(winner, id)
            else:
                pass
        else:
            if winner == id:
                max_fish = max(fishes)
                winner = fishes.index(max_fish)
        print('{} {}'.format(winner, max_fish))


if __name__ == '__main__':
    main(sys.argv[1:])
### BUGGY CODE ###

n = int(input())
LeftEnd = [0 for i in range(n)]
Center = [0 for i in range(n)]
RightEnd = [0 for i in range(n)]
for i in range(n):
  robot, arm = map(int, input().split())
  LeftEnd[i] = robot - arm
  Center[i] = robot
  RightEnd[i] = robot + arm

now_rightend = min(RightEnd)

for counter in range(n):
  next_candidates = [RightEnd[i] for i, v in enumerate(LeftEnd) if v >= now_rightend]
  if not next_candidates:
    break
  now_rightend = min(next_candidates)

print(counter+1)

### FIXED CODE ###

n = int(input())
List = [[0 for i in range(3)] for j in range(n)]
for i in range(n):
    robot, arm = map(int, input().split())
    List[i][0] = robot - arm # LeftEnd
    List[i][1] = robot # Center
    List[i][2] = robot + arm # RightEnd

sorted_List = sorted(List, key=lambda x: x[2])

now_rightend = sorted_List[0][2]
counter = 1

for i in range(n):
    if sorted_List[i][0] >= now_rightend:
        now_rightend = sorted_List[i][2]
        counter += 1

print(counter)
### BUGGY CODE ###

def main():
	N, M = map(int, input().split())
	S = list(map(int, input().split()))
	T = list(map(int, input().split()))
	S.append(0)
	T.append(0)
	MOD = 10**9+7

	dp0 = [[0 for _ in range(M+2)] for _ in range(N+2)]
	dp1 = [[0 for _ in range(M+2)] for _ in range(N+2)]
	dp0[0][0] = 1
	for i in range(N+1):
		for j in range(M+1):
			dp0[i+1][j] += dp0[i][j]%MOD
			dp0[i+1][j] %= MOD
			dp1[i][j] += dp0[i][j]%MOD
			dp1[i][j] %= MOD
			dp1[i][j+1] += dp1[i][j]%MOD
			dp1[i][j+1] %= MOD

			if S[i] == T[j]:
				dp0[i+1][j+1] += dp1[i][j]
				dp0[i+1][j+1] %= MOD
	print(dp1[N][M])


if __name__ == '__main__':
	main()

### FIXED CODE ###

def main():
	N, M = map(int, input().split())
	S = list(map(int, input().split()))
	T = list(map(int, input().split()))
	S.append(0)
	T.append(0)
	MOD = 10**9+7

	dp0 = [[0 for _ in range(M+2)] for _ in range(N+2)]
	dp1 = [[0 for _ in range(M+2)] for _ in range(N+2)]
	dp0[0][0] = 1
	for i in range(N+1):
		for j in range(M+1):
			dp0[i+1][j] += dp0[i][j]
			dp0[i+1][j] %= MOD
			dp1[i][j] += dp0[i][j]
			dp1[i][j] %= MOD
			dp1[i][j+1] += dp1[i][j]
			dp1[i][j+1] %= MOD

			if S[i] == T[j]:
				dp0[i+1][j+1] += dp1[i][j]
				dp0[i+1][j+1] %= MOD
	print(dp1[N][M])


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

# -*- coding:utf-8 -*-
N=int(input())
button=[]
for i in range(N):
  button.append(int(input()))

number=0
count=0
footprint=[0]
while number!=1:
  number=button[number]-1
  count+=1
  if number in footprint:
    print(-1)
    exit()
  footprint.append(number)
print(count)

### FIXED CODE ###

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

a=[int(i)-1 for i in sys.stdin]
N=a[0]+1
a=a[1:]

done=[False]*N

ans=0
i=0

while True:
  if done[i]==False:
    done[i]=True
    ans+=1
    if a[i]==1:
      break
    i=a[i]

  
  else:
    ans=-1
    break
    
print(ans)
### BUGGY CODE ###

ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
INF = 10**18

S=input()
N=len(S)

buf = []
ans = 0
for s in S:
    if buf:
        if buf[-1] != s:
            buf = buf[:-1]
            ans += 2
        else:
            buf += s
    else:
        buf += s

print(ans)


### FIXED CODE ###

ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
INF = 10**18

S=input()
N=len(S)

buf = []
h = 0
ans = 0
for s in S:
    if s=='0':
        h -= 1
    else:
        h += 1
ans = N-abs(h)

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

import sys
sys.setrecursionlimit(10**9)

def search(arr,arr2,cost,flag):
  global mincost
  if cost>mincost:
    return 0
  if flag==0:
    if len(arr2)==0:
      ans.add(cost)
      if mincost>cost:
        mincost=cost
      return 0
    for i in range(len(arr)):
      search(arr[:i]+arr[i+1:],arr2[1:],cost+abs(arr2[0]-arr[i]),0)
  else:
    if len(arr)>=len(arr2)+1:
      for i in range(len(arr)):
        for j in range(i+1,len(arr)):
          search(arr[:i]+arr[i+1:j]+arr[j+1:]+[arr[i]+arr[j]],arr2,cost+10,0)
          search(arr[:i]+arr[i+1:j]+arr[j+1:]+[arr[i]+arr[j]],arr2,cost+10,1)

n,a,b,c=map(int,input().split())
arr=[int(input()) for _ in range(n)]
arr2=[a,b,c]
ans=set()
mincost=10**9

search(arr,arr2,0,0)
search(arr,arr2,0,1)

ans=sorted(list(ans))
print(ans[0])

### FIXED CODE ###

import collections
from copy import deepcopy

n,a,b,c=map(int,input().split())
arr=[int(input()) for _ in range(n)]
l=collections.deque()
l.append([[],[],[]])
cnt=0

while 1:
  if cnt==n:
    break
  base=l.popleft()
  if len(base[0])==0 and len(base[1])==0 and len(base[2])==0:
    l.append([[arr[cnt]],[],[]])
    l.append([[],[arr[cnt]],[]])
    l.append([[],[],[arr[cnt]]])
    l.append([[],[],[]])
    cnt+=1
  else:
    tmp1=deepcopy(base)
    tmp1[0].append(arr[cnt])
    l.append(tmp1)
    tmp2=deepcopy(base)
    tmp2[1].append(arr[cnt])
    l.append(tmp2)
    tmp3=deepcopy(base)
    tmp3[2].append(arr[cnt])
    l.append(tmp3)
    tmp4=deepcopy(base)
    l.append(tmp4)

mincost=10**9
for bl in l:
  if len(bl[0])==0 or len(bl[1])==0 or len(bl[2])==0:
    continue
  else:
    tmpcost=abs(sum(bl[0])-a)+abs(sum(bl[1])-b)+abs(sum(bl[2])-c)+10*(len(bl[0])-1+len(bl[1])-1+len(bl[2])-1)
    if mincost>tmpcost:
      mincost=tmpcost
print(mincost)
### BUGGY CODE ###

N = int(input())
A_list = list(map(int, input().split()))
ans = 10000000000
cum_sum1 = []
cum_sum2 = []
for i in range(N-1):
    tmp = abs(sum(A_list[0:i+1])-sum(A_list[i+1:N]))
    if tmp < ans:
        ans = tmp
print(ans)

### FIXED CODE ###

N = int(input())
A_list = list(map(int, input().split()))
ans = 10000000000
cum_sum1 = 0
cum_sum2 = sum(A_list)
for i in range(N-1):
    cum_sum1 += A_list[i]
    cum_sum2 -= A_list[i]
    tmp = abs(cum_sum1-cum_sum2)
    if tmp < ans:
        ans = tmp
print(ans)
### BUGGY CODE ###

n = int(input())
a = input().split()

du = False
for i in range(n):
    for j in range(n):
        if a[i] == a[j] and i != j:
            du = True
print('YES' if not du else 'NO')

### FIXED CODE ###

n = int(input())
a = input().split()
b = set(a)
if len(b)<len(a):
    print("NO")
else:
    print("YES")
### BUGGY CODE ###

n=int(input())
hs=list(map(int, input().split()))
a_s=list(map(int, input().split()))

sum_a=[0]*n
sum_a[0]=a_s[0]
for ai,a in enumerate(a_s[1:]):
    mx = 0
    h=hs[ai+1]
    for i in range(ai+1):
        if h>hs[i]:
            if sum_a[i]>mx:
                mx=sum_a[i]
    sum_a[ai+1]=a+mx
print(sum_a[-1])

### FIXED CODE ###

def get(i):
    mx = 0
    while i > 0:
        if bit[i] > mx:
            mx = bit[i]
        i -= i & -i
    return mx


def update(i, x):
    while i < n + 1:
        if x > bit[i]:
            bit[i] = x
        i += i & -i


n = int(input())
hs = list(map(int, input().split()))
a_s = list(map(int, input().split()))

bit = [0] * (n + 1)
for h, a in zip(hs, a_s):
    update(h, get(h - 1) + a)
print(max(bit))
### BUGGY CODE ###

N, K = map(int,input().split())
A = list(map(int,input().split()))
F = list(map(int,input().split()))
X = []
A = sorted(A)
F = sorted(F)[::-1]
for i in range(N):
  X.append([A[i] * F[i],A[i],F[i]])

import heapq
from heapq import heapify

heapq._heapify_max(X)

def _heappush_max(heap, item):
    heap.append(item)
    heapq._siftdown_max(heap, 0, len(heap)-1)
def _heappop_max(heap):
    lastelt = heap.pop()
    if heap:
        returnitem = heap[0]
        heap[0] = lastelt
        heapq._siftup_max(heap, 0)
        return returnitem
    return lastelt
  
for i in range(K):
    x = _heappop_max(X)
    if x[0] < 1:
        _heappush_max(X,x)
        break
    else:       
        x[1] -= 1
        x[0] = x[1] * x[2]
        _heappush_max(X,x)
from operator import itemgetter
X.sort(key=itemgetter(0))
print(X[-1][0])



### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N,K = map(int,readline().split())
A = np.array(readline().split(),np.int64)
F = np.array(readline().split(),np.int64)

A.sort(); F.sort(); F=F[::-1]

def test(x):
    return np.maximum(0,A-x//F).sum() <= K

left = -1
right = 10**13
while left+1 < right:
    mid = (left+right)//2
    if test(mid):
        right = mid
    else:
        left = mid
answer = right
print(answer)
### BUGGY CODE ###

N = input()
N = int(N)
S = [int(input()) for _ in range(N)]
result = 0

for i in range(N):
    if S[i] >= 0:
        result += 1
        hoge = S[i]
        for j in range(i+1,N):
            if S[j] > hoge and hoge != -1:
                hoge = S[j]
                S[j] = -1 
print(result)

### FIXED CODE ###

import bisect

N = input()
N = int(N)
S = [-int(input()) for _ in range(N)]
result = []

for i in range(N):
    hoge = bisect.bisect(result,S[i])
    if hoge == len(result):
        result.append(S[i])
    else:
        result[hoge] = S[i]
print(len(result))
### BUGGY CODE ###

N,K = map(int, input().split())
A = list(map(int, input().split()))
dp = [0 for i in range(N)]
dp[0] = 0
if N > K:
    for k in range(1,K+1):
        dp[k] = abs(A[k]-A[0])
    for i in range(K+1,N):
        L = []
        for j in range(1,K+1):
            L.append(abs(A[i]-A[i-j]) + dp[i-j])
        dp[i] = min(L)

    print(dp[N-1])
else:
    print(abs(A[N-1]-A[0]))

### FIXED CODE ###

import numpy as np

N,K = map(int, input().split())
A = list(map(int, input().split()))
A = np.array(A)
dp = np.zeros(N, dtype=int)
dp[0] = 0
if N > K:
    for i in range(1,N):
        if i <= K:
            dp[i] = abs(A[i] - A[0])
        else:
            j = max(i - K, 0)
            dp[i] = np.min(np.abs(A[i] - A[j:i]) + dp[j:i])
    print(dp[N-1])
else:
    print(abs(A[N-1]-A[0]))
### BUGGY CODE ###

from fractions import gcd
N = int(input())

ll = [i for i in range(1,N+1)]   
ans = 0

for i in ll:
    for j in ll:
        s = gcd(i,j)
        for k in ll:
            ans += gcd(s,k)
print(ans)

### FIXED CODE ###

K = int(input())
ans = 0
from math import gcd
for i in range(1,K+1):
    for k in range(1,K+1):
        for j in range(1,K+1):
            ans += gcd(gcd(i, k),j)
            
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
from collections import deque

h, w = map(int, input().split())
ch, cw = map(int, input().split())
gh, gw = map(int, input().split())

s = ''
for i in range(h):
   s =  s + input().rstrip('\n')

INF = 10 ** 10
d = [INF] * (h*w)

stack = deque([[ch-1, cw-1, 0]])
stack_append = stack.append
stack_popleft = stack.popleft

nex = []
for i in range(-2, 3):
    for j in range(-2, 3):
        if (i, j) in [(-1,0),(1,0),(0,-1),(0,1),(0,0)]:
            continue
        else:
            nex.append((i,j))

while stack:
    curh, curw, cnt = stack_popleft()
    if d[curh * w + curw] <= cnt:
        continue
    else:
        d[curh * w + curw] = cnt
    for dh, dw in ((-1,0), (1,0), (0,1), (0,-1)):
        nh = curh + dh
        nw = curw + dw
        if nh >= 0 and nh < h and nw >= 0 and nw < w and s[nh * w + nw] == '.':
            stack_append([nh, nw, cnt])
    for dh, dw in nex:
        nh = curh + dh
        nw = curw + dw
        if nh >= 0 and nh < h and nw >= 0 and nw < w and s[nh * w + nw] == '.':
            stack_append([nh, nw, cnt+1])

# for item in d:
#     print(item)
gh -= 1
gw -= 1

if d[gh*w + gw] == INF:
    print(-1)
else:
    print(d[gh*w + gw])

### FIXED CODE ###

import sys
input = sys.stdin.readline

import heapq

INF = 10 ** 10

def dijkstra(n, G, s):
    dist = [INF] * n
    dist[s] = 0
    h = []
    heapq.heappush(h, (0, s))

    while h:
        # 使っていない頂点のうち、現時点で最も距離の近いものを選びvとする
        d, v = heapq.heappop(h)
        if dist[v] < d:
            continue
        # vから到達可能な頂点について、距離が短くなれば更新
        for end, cost in G[v]:
            if dist[end] > dist[v] + cost:
                dist[end] = dist[v] + cost
                heapq.heappush(h, (dist[end], end))
    return dist


H, W = map(int, input().split())
N = H * W
ch, cw = map(lambda x:int(x)-1, input().split())
gh, gw = map(lambda x:int(x)-1, input().split())

s = []
es = tuple([] for i in range(N))

for h in range(H):
   s.append(input().rstrip('\n'))

for h in range(H):
    for w in range(W):
        if s[h][w] != '.':
            continue
        a = h*W+w
        esappend = es[a].append
        for dh in (-2, -1, 0, 1, 2):
            for dw in (-2, -1, 0, 1, 2):
                if dh == 0 and dw == 0:
                    continue
                nh = h + dh
                nw = w + dw
                if 0 <= nh and nh < H and 0 <= nw and nw < W and s[nh][nw] == '.':
                    b = nh*W+nw
                    if (dh, dw) in [(-1,0),(1,0),(0,-1),(0,1)]:
                        esappend((b, 0))
                    else:
                        esappend((b, 1))

dist = dijkstra(N, es, ch*W+cw)
if dist[gh*W+gw] == INF:
    print(-1)
else:
    print(dist[gh*W+gw])
### BUGGY CODE ###

import bisect as bi

N=int(input())
A=sorted(list(map(int,input().split())))
B=sorted(list(map(int,input().split())))
C=sorted(list(map(int,input().split())))

ans=0
for i in range(N):
    for j in range(bi.bisect_left(B,C[i])):
        ans+=bi.bisect_left(A,B[j])

print(ans)

### FIXED CODE ###

import bisect as bi

N=int(input())
A=sorted(list(map(int,input().split())))
B=sorted(list(map(int,input().split())))
C=sorted(list(map(int,input().split())))

ans=0
for Bi in B:
    a=bi.bisect_left(A,Bi)
    c=N-bi.bisect_right(C,Bi)
    ans+=a*c

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

# -*- coding: utf-8 -*-
"""
Created on Sun Apr  7 00:03:49 2019

@author: Yamazaki Kenichi
"""
import heapq

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()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
Q = []
T = [[[-1 for i in range(Z+1)] for i in range(Y+1)] for i in range(X+1)]
T[0][0][0] = 1
heapq.heappush(Q,[-(A[0]+B[0]+C[0]),0,0,0])
for i in range(K-1):
    k = heapq.heappop(Q)
    s1,s2,s3 = k[1],k[2],k[3]
    if s1 + 1 != X and T[s1+1][s2][s3] == -1:
        heapq.heappush(Q,[-(A[s1+1]+B[s2]+C[s3]),s1+1,s2,s3])
        T[s1+1][s2][s3] = 1
    if s2 + 1 != Y and T[s1][s2+1][s3] == -1:
        heapq.heappush(Q,[-(A[s1]+B[s2+1]+C[s3]),s1,s2+1,s3])
        T[s1][s2+1][s3] = 1
    if s3 + 1 != Z and T[s1][s2][s3+1] == -1:
        heapq.heappush(Q,[-(A[s1]+B[s2]+C[s3+1]),s1,s2,s3+1])
        T[s1][s2][s3+1] = 1
    print(-k[0])
k = heapq.heappop(Q)
print(-k[0])


### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Wed Apr 10 22:30:07 2019

@author: Yamazaki Kenichi
"""
import heapq
#import random
#X,Y,Z,K = 1000,1000,1000,3000
#A = random.sample(range(10**9),1000)
#B = random.sample(range(10**9),1000)
#C = random.sample(range(10**9),1000)

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()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
Q = []
T = [[-1 for i in range(X)] for i in range(Y)]
T[0][0] = 0
heapq.heappush(Q,[-(A[0]+B[0]+C[0]),0,0,0])
for i in range(K-1):
    k = heapq.heappop(Q)
    s1,s2,s3 = k[1],k[2],k[3]
    if s1 + 1 != X and T[s1+1][s2] < s3:
        heapq.heappush(Q,[-(A[s1+1]+B[s2]+C[s3]),s1+1,s2,s3])
        T[s1+1][s2] += 1
    if s2 + 1 != Y and T[s1][s2+1] < s3:
        heapq.heappush(Q,[-(A[s1]+B[s2+1]+C[s3]),s1,s2+1,s3])
        T[s1][s2+1] += 1
    if s3 + 1 != Z and T[s1][s2] < s3 + 1:
        heapq.heappush(Q,[-(A[s1]+B[s2]+C[s3+1]),s1,s2,s3+1])
        T[s1][s2] += 1
    print(-k[0])
k = heapq.heappop(Q)
print(-k[0])
### BUGGY CODE ###

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

def generate_D(maxA):
  seq = [i for i in range(maxA+1)]
  p = 2
  while p*p <= maxA:
    if seq[p]==p:
      for q in range(p*2,maxA+1,p):
        if seq[q]==q:
          seq[q] = p
    p += 1
  return seq

cur = a[0]
for v in a[1:]:
  cur = math.gcd(cur,v)
if cur > 1:
  print('not coprime')
else:  
  d = generate_D(max(a))
  primes = set([])
  tf = 1
  for v in a:
    tmp = set([])
    while v > 1:
      tmp.add(d[v])
      v //= d[v]
    for k in tmp:
      if k in primes:
        tf = 0
      else:
        primes.add(k)
  if tf:
    print('pairwise coprime')
  else:
    print('setwise coprime')

### FIXED CODE ###

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

def generate_D(maxA):
  seq = [i for i in range(maxA+1)]
  p = 2
  while p*p <= maxA:
    if seq[p]==p:
      for q in range(p*2,maxA+1,p):
        if seq[q]==q:
          seq[q] = p
    p += 1
  return seq

cur = a[0]
for v in a[1:]:
  cur = math.gcd(cur,v)
if cur > 1:
  print('not coprime')
else:  
  d = generate_D(max(a))
  primes = set([])
  tf = 1
  for v in a:
    tmp = set([])
    while v > 1:
      tmp.add(d[v])
      v //= d[v]
    for k in tmp:
      if k in primes:
        tf = 0
      else:
        primes.add(k)
  if tf:
    print('pairwise coprime')
  else:
    print('setwise coprime')
### BUGGY CODE ###

N, Q = map(int, input().split())
S = input()
lr = []
for _ in range(Q):
    lr.append(list(map(int, input().split())))
for l,r in lr:
    print(S[l-1:r].count('AC'))

### FIXED CODE ###

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

n, q = map(int, (input().split()))
s = input()

tbl = [0] * n
for i in range(n - 1):
    if s[i] == 'A' and s[i + 1] == 'C':
        tbl[i] = 1

for i in range(q):
    l, r = map(int, input().split())
    print(sum(tbl[l - 1:r - 1]))


### FIXED CODE ###

n, q = map(int, (input().split()))
s = input()

tbl = [0] * n
cnt = 0
for i in range(1, n):
    if s[i - 1] == 'A' and s[i] == 'C':
        cnt += 1
    tbl[i] = cnt

for i in range(q):
    l, r = map(int, input().split())
    print(tbl[r - 1] - tbl[l - 1])
### BUGGY CODE ###

# -*- coding: utf-8 -*-
from collections import deque
h,w = map(int, input().split())
s = [input() for _ in range(h)]

if h==1 and w==1:
    print(0)
    exit()

maxr = 0
for hi in range(h):
    for wi in range(w):
        if s[hi][wi]==".":
            maxr += 1

def solve(sh,sw,gh,gw):
    if s[sh][sw]=="#" or s[gh][gw]=="#":
        return -1

    visited = [[False for _ in range(w)] for _ in range(h)]
    visited[sh][sw] = True
    q = deque([(sh,sw,0)])
    while len(q)>0:
        hi,wi,r = q.popleft()
        for dh,dw in [[1,0],[0,1],[-1,0],[0,-1]]:
            if hi+dh>=0 and hi+dh<h and wi+dw>=0 and wi+dw<w and s[hi+dh][wi+dw]==".":
                if hi+dh==gh and wi+dw==gw:
                    return r+1
                elif not visited[hi+dh][wi+dw]:
                    visited[hi+dh][wi+dw] = True
                    q.append((hi+dh,wi+dw,r+1))

    return -1

res = -1
for shi in range(h):
    for swi in range(w):
        if s[shi][swi]=="#":
            continue
        for ghi in range(h-1,-1,-1):
            for gwi in range(w-1,-1,-1):
                if shi>=ghi and swi>=gwi:
                    break
                r = solve(shi,swi,ghi,gwi)
                if maxr==r:
                    print(r)
                    exit()
                res = max(res, r)

print(res)

### FIXED CODE ###

# -*- coding: utf-8 -*-
from collections import deque
h,w = map(int, input().split())
s = [input() for _ in range(h)]

if h==1 and w==1:
    print(0)
    exit()

maxr = 0
for hi in range(h):
    for wi in range(w):
        if s[hi][wi]==".":
            maxr += 1

def solve(sh,sw):
    res = -1
    visited = [[False for _ in range(w)] for _ in range(h)]
    visited[sh][sw] = True
    q = deque([(sh,sw,0)])
    while len(q)>0:
        hi,wi,r = q.popleft()
        for dh,dw in [[1,0],[0,1],[-1,0],[0,-1]]:
            if hi+dh>=0 and hi+dh<h and wi+dw>=0 and wi+dw<w and s[hi+dh][wi+dw]==".":
                if not visited[hi+dh][wi+dw]:
                    visited[hi+dh][wi+dw] = True
                    q.append((hi+dh,wi+dw,r+1))
                    res = max(res, r+1)

    return res

res = -1
for shi in range(h):
    for swi in range(w):
        if s[shi][swi]=="#":
            continue
        r = solve(shi,swi)
        res = max(res, r)

print(res)
### BUGGY CODE ###

cnt = 0
R, G, B, N = map(int, input().split())
rgb = sorted([R,G,B], reverse=True)

for r in range((N//rgb[0])+1):
    for g in range((N-r*rgb[0])//rgb[1]+1):
        m = N - r*rgb[0] - g*rgb[1]
        if m == 0 or (m % rgb[2] == 0 and m >= rgb[2]):
            cnt += 1

print(cnt)


### FIXED CODE ###

cnt = 0
R, G, B, N = map(int, input().split())
comb = []
tmp = []
rgb = [R, G, B]

for r in range((N//R)+2):
    for g in range((N//G)+2):
        m = N - r*R - g*G
        if m == 0 or (m % B == 0 and m >= B):
            cnt += 1

print(cnt)