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

from itertools import combinations, product
import copy
H, W = map(int, input().split())


def search_steps(maze, cy, cx, gy, gx, step):
    if (cy, cx) == (gy, gx):
        return step
    ss = []
    for dy, dx in ((0, 1), (0, -1), (1, 0), (-1, 0)):
        ny, nx = cy + dy, cx + dx
        new_maze = copy.deepcopy(maze)
        new_maze[cy][cx] = "#"
        if 0 <= ny <= H - 1 and 0 <= nx <= W - 1 and maze[ny][nx] == ".":
            s = search_steps(new_maze, ny, nx, gy, gx, step + 1)
            if s >= 0:
                ss.append(s)

    if len(ss) == 0:
        return -1
    else:
        mss = min(ss)
        return min(ss) if mss >= 0 else -1


S = [0] * H
for i in range(H):
    S[i] = list(input())

max_steps = 0
for s, g in combinations(range(H * W), 2):
    sy, sx = s // W, s % W
    gy, gx = g // W, g % W
    if S[sy][sx] == "#" or S[gy][gx] == "#":
        continue

    steps = search_steps(copy.deepcopy(S), sy, sx, gy, gx, 0)
    if steps > max_steps:
        max_steps = steps
    if steps == H * W - 1:
        break

print(max_steps)


### FIXED CODE ###

H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]

max_step = 0
for i in range(H * W):
    sy, sx = i // W, i % W
    if S[sy][sx] == "#":
        continue

    steps = [[-1] * W for _ in range(H)]
    steps[sy][sx] = 0
    queue = [(sy, sx)]
    while len(queue) >= 1:
        cy, cx = queue.pop(0)
        for dy, dx in ((0, 1), (0, -1), (1, 0), (-1, 0)):
            ny, nx = cy + dy, cx + dx
            if not (0 <= ny <= H - 1 and 0 <= nx <= W - 1):
                continue
            if S[ny][nx] == "#" or steps[ny][nx] >= 0:
                continue
            queue.append((ny, nx))
            steps[ny][nx] = steps[cy][cx] + 1

    ms = max(max(r) for r in steps)
    max_step = max(ms, max_step)

print(max_step)
### BUGGY CODE ###

n=int(input())
ans=1
m=list(map(int,input().split()))
for i in range(n):
  ans=ans*m[i]
if ans<=pow(10,18):
  print(ans)
else:
  print(-1)



### FIXED CODE ###

import sys

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

ans=1
if 0 in m:
  print(0)
  sys.exit()

for i in range(n):
  ans=ans*m[i]
  if ans>pow(10,18):
    print(-1)
    sys.exit()

if ans<=pow(10,18):
  print(ans)
### BUGGY CODE ###

D, G = map(int, input().split())
scores = []
bonus = []
for i in range(1, 1 + D):
    p, c = map(int, input().split())
    bonus.append([c, (2 ** p) - 1 << len(scores)])
    scores += [i * 100] * p

n = len(scores)
bit = 0
problems = []
while bit < (1 << n):
    total_score = 0
    problem = 0
    # add score
    for i in range(n):
        if bit & 1 << i:
            total_score += scores[i]
            problem += 1
    # add bonus
    for c, bb in bonus:
        if (bit & bb) == bb:
            total_score += c

    if G <= total_score:
        problems.append(problem)

    bit += 1

print(min(problems))

### FIXED CODE ###

# https://atcoder.jp/contests/abc104/submissions/7167759

INF = float('inf')
D, G = map(int, input().split())
problems = [] * D
bonus = [] * D
ans = 0
for _ in range(D):
    p, c = map(int, input().split())
    problems.append(p)
    bonus.append(c)

ans = INF
for bit in range(1 << D):
    total_problem = 0
    total_score = 0
    # --------------
    # bit全探索
    # --------------
    for i in range(D):
        if bit & (1 << i):
            s = (i + 1) * 100
            total_score += s * problems[i] + bonus[i]
            total_problem += problems[i]

    for i in range(D - 1, -1, -1):
        if G <= total_score:
            break
        if bit & (1 << i):
            continue

        s = (i + 1) * 100
        required_score = G - total_score
        required_problem = (required_score + s - 1) // s
        total_score += min(required_problem, problems[i]) * s
        total_problem += min(required_problem, problems[i])

    if G <= total_score:
        ans = min(ans, total_problem)

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

import sys
sys.setrecursionlimit(10**6)

n = int(input())
edges = [[] for i in range(2*10**5)]
for i in range(n):
    xi, yi = map(int, input().split())
    xi -= 1
    yi = yi - 1 + 10**5
    edges[xi].append(yi)
    edges[yi].append(xi)

already = set([])
def dfs(x, y, node):
    if node in already:
        return x, y
    if node < 10**5:
        x += 1
    else:
        y += 1
    already.add(node)
    for next_node in edges[node]:
        x, y = dfs(x, y, next_node)
    return x, y

num = 0
for i in range(10**5):
    x, y = dfs(0, 0, i)
    num += x * y
print(num-n)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)

n = int(input())
edges = [[] for i in range(2*10**5)]
for i in range(n):
    xi, yi = map(int, input().split())
    xi -= 1
    yi = yi - 1 + 10**5
    edges[xi].append(yi)
    edges[yi].append(xi)

already = set([])
def dfs(x, y, node):
    if node in already:
        return x, y
    if node < 10**5:
        x += 1
    else:
        y += 1
    already.add(node)
    for next_node in edges[node]:
        x, y = dfs(x, y, next_node)
    return x, y

num = 0
for i in range(10**5):
    x, y = dfs(0, 0, i)
    num += x * y
print(num-n)
### BUGGY CODE ###

N, M = map(int, input().split())
PY = []
array1 = []
array2 = []

for _ in range(M):
    P, Y = map(int, input().split())
    PY.append([P, Y])
    if P in array1:
        array2[array1.index(P)].append(Y)
    else:
        array1.append(P)
        array2.append([Y])

for i in PY:
    print('{:06}'.format(i[0]), end='')
    print('{:06}'.format(sorted(array2[array1.index(i[0])]).index(i[1])+1))


### FIXED CODE ###

import bisect

N, M = map(int, input().split())
PY = []
array = [[] for _ in range(N)]

for _ in range(M):
    P, Y = map(int, input().split())
    PY.append([P, Y])
    array[P-1].append(Y)
    
for i in range(N):
    array[i].sort()

for p, y in PY:
    n = bisect.bisect_left(array[p-1], y) + 1
    print('%06d%06d' % (p, n))
### BUGGY CODE ###

s=input()
t=input()
ns=len(s)
nt=len(t)
dp=[[(0,'') for j in range(ns+1)] for i in range(nt+1)] # dp[i][j] = max len and string using up to t[i],s[j]

for i in range(1,nt+1):
    for j in range(1,ns+1):
        if t[i-1]==s[j-1]:
            dp[i][j]=(dp[i-1][j-1][0]+1,dp[i-1][j-1][1]+t[i-1])
        else:
            a,b=dp[i-1][j],dp[i][j-1]
            c=max(a[0],b[0])
            if c==a[0]:
                dp[i][j]=a
            else:
                dp[i][j]=b

print(dp[-1][-1][-1])


### FIXED CODE ###

#n,W=map(int, input().split())
s=input()
t=input()
ns=len(s)
nt=len(t)
dp=[[0 for j in range(ns+1)] for i in range(nt+1)]
    
for i in range(1,nt+1):
    for j in range(1,ns+1):
        if t[i-1]==s[j-1]:
            dp[i][j]=dp[i-1][j-1]+1
        else:
            dp[i][j]=max(dp[i-1][j],dp[i][j-1])

cnt=dp[-1][-1]
ans=[]
ct,cs=nt,ns
while cnt>0:
    while dp[ct][cs]==dp[ct-1][cs] and ct>0:
        ct-=1
        
    while dp[ct][cs]==dp[ct][cs-1] and cs>0:
        cs-=1

    ans.append(t[ct-1])
    cnt-=1
    #print(ct,cs,t[ct-1])
    ct-=1
    cs-=1

print(''.join(ans[::-1]))
### BUGGY CODE ###

N=int(input())
#f=nf(n-2)

count=0
if N%2==1:
    print(0)
else:
    while N%5!=0:
        if (N-2)%5==0:
            N-=2
    count+=N//10
    #print(count)
    N//=10
    while N>=5:
        count+=N//5
        #print(count)
        N//=5
    print(count)
#
"""
def f(n):
    if n>=2:
        answer=n
        n-=2
    while n>=2:
        answer*=n
        n-=2
    return answer
print(f(N))
"""
    

### FIXED CODE ###

N=int(input())
#f=nf(n-2)

count=0
if N%2==1:
    print(0)
else:
    count+=N//10
    #print(count)
    N//=10
    while N>=5:
        count+=N//5
        #print(count)
        N//=5
    print(count)
#
"""
def f(n):
    if n>=2:
        answer=n
        n-=2
    while n>=2:
        answer*=n
        n-=2
    return answer
print(f(N))
"""
### BUGGY CODE ###

n, m = map(int,input().split())
l = []
for i in range(m):
    p,s=map(str,input().split())
    l.append([int(p),s])

ac = 0 
wa = 0
    
for i in range(m):
    if l[i][1] == "WA":
        flag = True
        for j in range(0,i):
            if l[j][1] == "AC" and l[j][0] == l[i][0]:
                flag = False
        if flag:
            wa += 1
        
    if l[i][1] == "AC":
        flag = True
        for j in range(0,i):
            if l[j][1] == "AC" and l[j][0] == l[i][0]:
                flag = False
        if flag:
            ac += 1

print(ac,wa)

### FIXED CODE ###

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

a = [0]*n
b = [False]*n
for i in range(m):
    p,s = input().split()
    p = int(p) - 1
    if s == 'AC':
        b[p] = True
    elif b[p] == False:
        a[p] += 1

ac = b.count(True)
wa = 0
for i in range(n):
    if b[i] == True:
        wa += a[i]
print(ac,wa)
### BUGGY CODE ###

from collections import deque
n, m = map(int, input().split())
G = [[] for _ in range(n)]
for _ in range(m):
    x, y = map(lambda x: int(x)-1, input().split())
    G[x].append(y)

counts = [-1] * n

while -1 in counts:
    start = counts.index(-1)
    q = deque([[start, 0]])
    while q:
        i, l = q.pop()
        counts[i] = max(counts[i], l)
        for ni in G[i]:
            q.append([ni, l+1])

print(max(counts))


### FIXED CODE ###

import sys
sys.setrecursionlimit(500000)
n, m = map(int, input().split())
G = [[] for _ in range(n)]
for _ in range(m):
    x, y = map(lambda x: int(x)-1, input().split())
    G[x].append(y)

# iを始点としたときの有効パスの最大長さ
dp = [-1] * n
 
def rec(s):
    if dp[s] != -1:
        return dp[s]

    ret = 0
    for ns in G[s]:
        ret = max(ret, rec(ns)+1)
    dp[s] = ret
    return ret

ml = 0    
for i in range(n):
    ml = max(ml, rec(i))
print(ml)
### BUGGY CODE ###

def main():
    N = int(input())
    A = []
    for n in range(N):
        A.append(int(input()))
        
    for n in range(N):
        tmp = A.pop(n)
        print(max(A))
        A.insert(n, tmp)
        
if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    N = int(input())
    A = []
    for n in range(N):
        A.append(int(input()))

    A_cp = sorted(A)
    max1_A = A_cp.pop(-1)
    max2_A = max(A_cp)
    for a in A:
        if a == max1_A:
            print(max2_A)
        else:
            print(max1_A)
            
        
if __name__ == '__main__':
    main()
### BUGGY CODE ###

n,c,k=map(int,input().split())
t=[int(input()) for _ in range(n)]
t.sort()
res=0
while(t):
    i=0
    j=t[0]+k
    if len(t)==1:
        res+=1
        break
    while(i<len(t) and t[i]<=j and i<c):
        i+=1
    res+=1
    for _ in range(i):
        del t[0]
print(res)

### FIXED CODE ###

n,c,k=map(int,input().split())
t=[int(input()) for _ in range(n)]
t.sort()
res=0
i1=0
while(i1<n):
    i2=0
    j=t[i1]+k
    if i1==n-1:
        res+=1
        break
    while(i1+i2<len(t) and t[i1+i2]<=j and i2<c):
        i2+=1
    res+=1
    i1+=i2
print(res)
### BUGGY CODE ###

N, X = map(int, input().split())
A = list(map(int, input().split()))

ans = 1e15

"""
abcdef
f +4(f-e) + 9+(e-d) + 16(d-c) + ...
= 5f + 5e + 7d + 9c + 11b + 13a
"""
mul = [5] + [5 + 2*i for i in range(N)]
#print(mul)

for k in range(1,N+1): # Number of robots (this loop will be ended early)
  cost = N*X + k*X # pickup and throw costs(fixed with k)
  for i in range(1,N+1):
    cost += A[N-i] * mul[(i-1)//k]
  #print(k,cost)
  ans = min(ans,cost)
  if N//k <= 1: # early stopping (after mul is 5 for all A's, cost is monotonicaly increasing)
    print(ans)
    exit(0)
    
#print(ans)
  
  

### FIXED CODE ###

N, X = map(int, input().split())
A = list(map(int, input().split()))

ans = 1e19

"""
abcdef
f +4(f-e) + 9+(e-d) + 16(d-c) + ...
= 5f + 5e + 7d + 9c + 11b + 13a
"""
mul = [5] + [5 + 2*i for i in range(N)]
#print(mul)

CX = [0] * (N+1)

#cum_sum
for i in range(N):
  CX[i+1] = CX[i] + A[i]
  
for k in range(1,N+1): # Number of robots (this loop will be ended early)
  cost = N*X + k*X # pickup and throw costs(fixed with k)
  
  # partial point answer (not using cumulative sum)
  # for i in range(1,N+1):
  #  cost += A[N-i] * mul[(i-1)//k]
  ix = N
  loopc = 0
  while ix > 0:
    if ix-k > 0:
      cost += (CX[ix] - CX[ix-k]) * mul[loopc]
    else:
      cost += (CX[ix]) * mul[loopc]
    loopc += 1
    ix -= k
  
  #print(k,cost)
  ans = min(ans,cost)
  if N//k <= 1: # early stopping (after mul is 5 for all A's, cost is monotonicaly increasing)
    print(ans)
    exit(0)
    
#print(ans)
### BUGGY CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

for i in range(M):
  B, C = map(int, input().split())
  for j in range(B):
    if A[j] < C:
      A[j] = C
    else:
      break
  A.sort()

print(sum(A))

### FIXED CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for _ in range(M)]
lenA = len(A)
minA = min(A)
BC.sort(reverse = True, key = lambda x:x[1])

i = 0
cnt = 0
while cnt < lenA and i < M:
  A.extend([BC[i][1] for _ in range(BC[i][0])])
  cnt += BC[i][0]
  i += 1
A.sort(reverse = True)
l = A[0:lenA]

print(sum(l))
### BUGGY CODE ###

from collections import defaultdict
from itertools import accumulate
n, k = map(int, input().split())
A = list(map(int, input().split()))
Acum = [0]
Acum.extend(accumulate(A))
cnt = defaultdict(int)
for i in range(n):
    for j in range(i+1, n+1):
        beauty = Acum[j]-Acum[i]
        cnt[beauty] += 1

x = 0
for t in reversed(range(41)):
    y = 1 << t
    cnt_k = 0
    for beauty, c in cnt.items():
        if (x+y) & beauty == (x+y):
            cnt_k += c
    if k <= cnt_k:
        x += y

print(x)

### FIXED CODE ###

from collections import defaultdict
from itertools import accumulate
n, k = map(int, input().split())
A = list(map(int, input().split()))
Acum = [0]
Acum.extend(accumulate(A))
cnt = defaultdict(int)
for i in range(n):
    for j in range(i+1, n+1):
        beauty = Acum[j]-Acum[i]
        cnt[beauty] += 1

x = 0
for t in reversed(range(41)):
    y = 1 << t
    cnt_k = 0
    for beauty, c in cnt.items():
        if (x+y) & beauty == (x+y):
            cnt_k += c
    if k <= cnt_k:
        x += y

print(x)
### BUGGY CODE ###

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

mx = 0
for i in range(n):
    popped = a.pop(i)
    g = a[0]
    for aa in a[1:]:
        g = fractions.gcd(g, aa)
    a.insert(i, popped)
    mx = max(mx, g)
print(mx)

### FIXED CODE ###

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

mx = 0
gd_pos = [] # 0からiまでのgcd
gd_pos.append(a[0])
for i in range(1, n):
    gd_pos.append(fractions.gcd(gd_pos[i-1], a[i]))
gd_neg = [] # 末尾からiまでのgcd
gd_neg.append(a[-1])
a_rev = a[::-1]
for i in range(1, n):
    gd_neg.append(fractions.gcd(gd_neg[i-1], a_rev[i]))

def popped_g(i):
    if i == 0: return gd_neg[n-2]
    elif i == n-1: return gd_pos[n-2]
    else:
        return fractions.gcd(gd_pos[i-1], gd_neg[n-i-2])

ans = [popped_g(i) for i in range(n)]
print(max(ans))
### BUGGY CODE ###

N = int(input())
S = input()
Q = int(input())
k = [int(i) for i in input().split()]

for ki in k :
    ret = 0
    dp = [[0] * 3 for _ in range(ki)]
    for i in range(N) :
        j = i % ki
        dp[j][0] = dp[j-1][0]
        dp[j][1] = dp[j-1][1]
        dp[j][2] = dp[j-1][2]
        
        j = i % ki
        if i >= ki :
            if S[i-ki] == 'D' :
                dp[j][0] -= 1
                dp[j][2] -= dp[j][1]
            elif S[i-ki] == 'M' :
                dp[j][1] -= 1

        if S[i] == 'D' :
            dp[j][0] += 1
        elif S[i] == 'M' :
            dp[j][1] += 1
            dp[j][2] += dp[j][0]
        elif S[i] == 'C' :
            ret += dp[j][2]
            
    print(ret)
        

### FIXED CODE ###

import sys
input = sys.stdin.readline

N = int(input())
S = input()
Q = int(input())
k = list(map(int, input().split()))

for ki in k :
    ret = 0
    dp = [0] * 3
    for i in range(N) :
        if i >= ki :
            j = i - ki
            if S[j] == 'D' :
                dp[0] -= 1
                dp[2] -= dp[1]
            elif S[j] == 'M' :
                dp[1] -= 1

        if S[i] == 'D' :
            dp[0] += 1
        elif S[i] == 'M' :
            dp[1] += 1
            dp[2] += dp[0]
        elif S[i] == 'C' :
            ret += dp[2]
            
    print(ret)
### BUGGY CODE ###

s = input()
Q = int(input())
for i in range(Q):
    tmp = list(input())
    if len(tmp)==1:
        s = s[::-1]
    else:
        f,c = tmp[2], tmp[4]
        if f=='1':
            s = c + s
        elif f=='2':
            s = s + c
print(s)

### FIXED CODE ###

from collections import deque
s = input()
Q = int(input())
s = deque([s])
rev = 1
for i in range(Q):
    tmp = list(input().split())
    if len(tmp)==1:
        rev *= -1
    else:
        f,c = tmp[1], tmp[2]
        if rev > 0:
            if f=='1':
                s.appendleft(c)
            else:
                s.append(c)
        else:
            if f=='1':
                s.append(c)
            else:
                s.appendleft(c)
s = ''.join(list(s))
print(s if rev > 0 else s[::-1])
### BUGGY CODE ###

from bisect import bisect_left as bl
A, B, Q = map(int, input().split())
inf = 10 ** 11
Sh = [int(input()) for _ in range(A)] + [inf, inf]
Te = [int(input()) for _ in range(B)] + [inf, inf]

for _ in range(Q):
  q = int(input())
  temp = inf
  i = bl(Sh, q)
  #print(q, Sh[i - 1])
  que = []
  que.append(i)
  if i != 0:
    que.append(i - 1)
  while len(que):
    j = que.pop()
    k = bl(Te, Sh[j])
    #print(Sh[j], Te[k])
    temp = min(temp, abs(Sh[j] - Te[k]) + abs(Sh[j] - q))
    if k != 0:
      temp = min(temp, abs(Sh[j] - Te[k - 1]) + abs(Sh[j] - q))
    
  i = bl(Te, q)
  que.append(i)
  if i != 0:
    que.append(i - 1)
  while len(que):
    j = que.pop()
    k = bl(Sh, Te[j])
    temp = min(temp, abs(Te[j] - Sh[k]) + abs(Te[j] - q))
    if k != 0:
      temp = min(temp, abs(Te[j] - Sh[k - 1]) + abs(Te[j] - q))
  print(temp)
    

### FIXED CODE ###

from bisect import bisect_left as bl
A, B, Q = map(int, input().split())
inf = 10 ** 11
Sh = [-1 * inf] + [int(input()) for _ in range(A)] + [inf]
Te = [-1 * inf] + [int(input()) for _ in range(B)] + [inf]
for _ in range(Q):
  x = int(input())
  b, d = bl(Sh, x), bl(Te, x)
  res = inf
  for S in [Sh[b - 1], Sh[b]]:
    for T in [Te[d - 1], Te[d]]:
      d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
      res = min(res, d1, d2)
  print(res)
### BUGGY CODE ###

import heapq;

n, u, v = [int(v) for v in input().split()]

vert = []

for i in range(n):
    vert.append([])

for i in range(n - 1):
    a, b = [int(v) - 1 for v in input().split()]
    vert[a].append(b)
    vert[b].append(a)

taka = u-1
aoki = v-1

q = []
heapq.heappush(q, (0, aoki))
aoki_dist = [-1] * n
closed = 0

while len(q) > 0:
    c0, i = heapq.heappop(q)
    aoki_dist[i] = c0
    c = c0 + 1
    for l in vert[i]:
        if closed & (1 << l) != 0:
            continue
        closed |= (1 << i)
        heapq.heappush(q, (c, l))

heapq.heappush(q, (0, taka))
closed = (1 << taka)
max_dist = aoki_dist[taka]

while len(q) > 0:
    c0, i = heapq.heappop(q)
    c = c0 + 1
    for l in vert[i]:
        if closed & (1 << l) != 0:
            continue
        closed |= (1 << l)
        if c >= aoki_dist[l]:
            continue
        if max_dist < aoki_dist[l]:
            max_dist = aoki_dist[l]
        heapq.heappush(q, (c, l))

print(max_dist - 1)

### FIXED CODE ###

import heapq;

n, u, v = [int(v) for v in input().split()]

vert = []

for i in range(n):
    vert.append([])

for i in range(n - 1):
    a, b = [int(v) - 1 for v in input().split()]
    vert[a].append(b)
    vert[b].append(a)

taka = u-1
aoki = v-1

if taka == aoki:
    print(0)
    exit()

def bfs(begin):
    q = [(0, begin)]
    dist = [-1] * n
    dist[begin] = 0

    index = 0
    while index < len(q):
        c0, i = q[index]
        c = c0 + 1
        for l in vert[i]:
            if dist[l] >= 0:
                continue
            dist[l] = c
            q.append((c, l))
        index += 1
    return dist

aoki_dist = bfs(aoki)
taka_dist = bfs(taka)

ans = 0
for i in range(n):
    if taka_dist[i] < aoki_dist[i]:
        ans = max(ans, aoki_dist[i] - 1)

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

N = int(input())
S = str(input())
Answer = 0
rList,gList,bList = list(),list(),list()
for n in range(N):
    if S[n] == "R":
        rList.append(n)
    if S[n] == "G":
        gList.append(n)
    if S[n] == "B":
        bList.append(n)

for r in rList:
    for g in gList:
        for b in bList:
            if ((b-g)**2 == (g-r)**2) or ((b-r)**2 == (g-b)**2) or ((b-r)**2 == (g-r)**2):
                pass
            else:
                Answer += 1



print(Answer)
                        


### FIXED CODE ###

N = int(input())-1
S = str(input())
r,g,b = 0,0,0
rgb = str()
d = 0
for n in range(N+1):
    rgb = str(S[n])
    if rgb == "R":
        r += 1
    if rgb == "G":
        g += 1
    if rgb == "B":
        b += 1
    rang = int((N - n - 2) / 2)
    for j in range(rang,-1,-1):
        if S[n+j+1] != rgb and n+2*j+2 <= N:
           
            if S[n+2*j+2] != rgb:
                if S[n+2*j+2] != S[n+j+1]:
                    d -= 1
                    
                else:
                    pass
            else:
                pass
        else:
            pass
        

Answer = r*g*b + d

print(Answer)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
inf = float('inf')

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

# dp[i][j][k] := (i,j)にk = 赤-青で到達できるか (-(H+W)*K <= k <= +(H+W)*K)
dp = [[[0] * (2*(H+W)*80 + 1) for _ in range(W)] for _ in range(H)]
adjust = (H+W) * 80
d = A[0][0] - B[0][0]
dp[0][0][d + adjust] = 1
dp[0][0][-d + adjust] = 1

for i in range(H):
    for j in range(W):
        d = A[i][j] - B[i][j]
        for k in range(2*(H+W)*80 + 1):
            res = 0
            try:
                res |= dp[i-1][j][k-d]
            except:
                pass
            try:
                res |= dp[i-1][j][k+d]
            except:
                pass
            try:
                res |= dp[i][j-1][k-d]
            except:
                pass
            try:
                res |= dp[i][j-1][k+d]
            except:
                pass
            dp[i][j][k] |= res

ans = inf

for k in range(2*(H+W)*80 + 1):
    if dp[H-1][W-1][k]:
        ans = min(ans, abs(k-adjust))

print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline
import numpy as np
inf = float('inf')

H, W = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(H)]
A = np.array(A)
B = [list(map(int,input().split())) for _ in range(H)]
B = np.array(B)
D = A - B
D = np.vectorize(abs)(D)

N = (H + W) * 80
M = 2*N + 1
# [-N, N] を [0,2*N] として扱う(右にNだけずらす)
dp = [[np.zeros(M, np.bool) for _ in range(W)] for _ in range(H)]
d = D[0][0]
dp[0][0][d+N] = 1
dp[0][0][-d+N] = 1

for i, Di in enumerate(D):
    for j, Dij in enumerate(Di):
        if i != 0:
            dp[i][j][Dij:M] |= dp[i-1][j][0:M-Dij]
            dp[i][j][0:M-Dij] |= dp[i-1][j][Dij:M]
        if j != 0:
            dp[i][j][Dij:M] |= dp[i][j-1][0:M-Dij]
            dp[i][j][0:M-Dij] |= dp[i][j-1][Dij:M]

ind = np.where(dp[H-1][W-1])[0]
ind -= N
ans = np.vectorize(abs)(ind).min()
print(ans)
### BUGGY CODE ###

import numpy as np
n,k = map(int,input().split())
s = list(map(int,input().split()))
s = np.array(s)
ans = 0
for i in range(n-k+1):
  a = (np.sum(s[i:i+k])+k)/2
  if a > ans:
    ans = a
print(ans)  

### FIXED CODE ###

import numpy as np
n,k = map(int,input().split())
s = list(map(int,input().split()))
s = np.array(s)
ans =  np.sum(s[:k])
a = ans
for i in range(n-k):
  a = a - s[i] + s[i+k]
  if a > ans:
    ans = a  
print((ans+k)/2)