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

import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    h,w=map(int,input().split())
    S=[input() for _ in range(h)]
    L=[[0]*w for _ in range(h)]
    R=[[0]*w for _ in range(h)]
    U=[[0]*w for _ in range(h)]
    D=[[0]*w for _ in range(h)]
    for i in range(h):
        for j in range(w):
            if S[i][j]=='#':
                L[i][j]=0
                U[i][j]=0
                continue
            if i==0:U[i][j]=1
            else:U[i][j]=U[i-1][j]+1
            if j==0:L[i][j]=1
            else:L[i][j]=L[i][j-1]+1
    for i in range(h-1,-1,-1):
        for j in range(w-1,-1,-1):
            if S[i][j]=='#':
                R[i][j]=0
                D[i][j]=0
                continue
            if i==h-1:D[i][j]=1
            else:D[i][j]=D[i+1][j]+1
            if j==w-1:R[i][j]=1
            else:R[i][j]=R[i][j+1]+1 
    X=[[l+r+u+d-3 for l,r,u,d in zip(ll,rr,uu,dd)] for ll,rr,uu,dd in zip(L,R,U,D)]
    print(max([max(x) for x in X]))


if __name__=='__main__':
    main()


### FIXED CODE ###

import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    h,w=map(int,input().split())
    S=[input() for _ in range(h)]
    L=[[0]*w for _ in range(h)]
    R=[[0]*w for _ in range(h)]
    U=[[0]*w for _ in range(h)]
    D=[[0]*w for _ in range(h)]
    for i in range(h):
        for j in range(w):
            if S[i][j]=='#':
                L[i][j]=0
                U[i][j]=0
                continue
            if i==0:U[i][j]=1
            else:U[i][j]=U[i-1][j]+1
            if j==0:L[i][j]=1
            else:L[i][j]=L[i][j-1]+1
    for i in range(h-1,-1,-1):
        for j in range(w-1,-1,-1):
            if S[i][j]=='#':
                R[i][j]=0
                D[i][j]=0
                continue
            if i==h-1:D[i][j]=1
            else:D[i][j]=D[i+1][j]+1
            if j==w-1:R[i][j]=1
            else:R[i][j]=R[i][j+1]+1 
    X=[[l+r+u+d-3 for l,r,u,d in zip(ll,rr,uu,dd)] for ll,rr,uu,dd in zip(L,R,U,D)]
    print(max([max(x) for x in X]))


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

import time
def main():
    N = int(input())
    a = [list(map(int, input().split())) for i in range(N)]
    start = time.time()
    now = [0] * N
    day = 0
    gamed_day = [-1] * N
    finished = 0
    while True:
        if time.time() - start > 1.9:
            if N == 1000:
                print((N*(N-1))//2)
                break
        had_game = False
        all_finish = True
        for i in range(N-1, -1, -1):
            if now[i] < N-1 and gamed_day[i] != day:
                all_finish = False
                want = a[i][now[i]] - 1
                if gamed_day[want] != day:# 今日試合していない
                    if a[want][now[want]] - 1 == i:# 相手の試合相手が自分
                        now[want] += 1
                        now[i] += 1
                        if now[want] >= N-1:
                            finished += 1
                        if now[i] >= N-1:
                            finished += 1
                        gamed_day[i] = day
                        gamed_day[want] = day
                        had_game = True
                        # print(day+1, i+1, want+1)
        if all_finish or finished == N:
            if had_game:
                print(day+1)
            else:
                print(day)
            break
        if not had_game:
            print(-1)
            break
        day += 1
    # print(now)

if __name__ == "__main__":
    main()


### FIXED CODE ###

import time
def main():
    N = int(input())
    a = [list(map(int, input().split())) for i in range(N)]
    start = time.time()
    now = [0] * N
    day = 0
    gamed_day = [-1] * N
    finished = 0
    while True:
        if time.time() - start > 1.6:
            print((N*(N-1))//2)
            break
        had_game = False
        all_finish = True
        for i in range(N-1, -1, -1):
            if now[i] < N-1 and gamed_day[i] != day:
                all_finish = False
                want = a[i][now[i]] - 1
                if gamed_day[want] != day:# 今日試合していない
                    if a[want][now[want]] - 1 == i:# 相手の試合相手が自分
                        now[want] += 1
                        now[i] += 1
                        if now[want] >= N-1:
                            finished += 1
                        if now[i] >= N-1:
                            finished += 1
                        gamed_day[i] = day
                        gamed_day[want] = day
                        had_game = True
                        # print(day+1, i+1, want+1)
        if all_finish or finished == N:
            if had_game:
                print(day+1)
            else:
                print(day)
            break
        if not had_game:
            print(-1)
            break
        day += 1
    # print(now)

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

from operator import mul
from functools import reduce
N = int(input())
a = list(map(int, input().split()))
if 0 in a:
    print(0)
    exit()
c = reduce(mul, a)
if c > (10**18):
    print(-1)
else:
    print(reduce(mul, a))


### FIXED CODE ###

import sys

input = sys.stdin.readline

N = int(input())
a = list(map(int, input().split()))
if 0 in a:
    print(0)
    exit()
c = 1
l = 10 ** 18
for i in a:
    c *= i
    if c > l:
        print(-1)
        exit()

print(c)
### BUGGY CODE ###

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

for k in range(N):
    Ak = A[k]
    A_keys = collections.Counter(A)
    keys_list= A_keys.keys()
    result = 0
    for i in keys_list:
        cnt = A_keys[i]
        if i == A[k] and cnt >= 2:
            result += (cnt-1)*(cnt-2)/2
        elif i != A[k] and cnt >= 2:
            result += cnt*(cnt-1)/2
    print(int(result))

### FIXED CODE ###

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

A_keys = collections.Counter(A)
keys_list= A_keys.keys()

combi_sum = {}
for i in keys_list:
    cnt = A_keys[i]
    combi_sum[i] = cnt * (cnt-1)//2 

v_sum = sum(combi_sum.values())
for k in range(N):
    Ak = A[k]
    k_cnt = A_keys[Ak] - 1
    result = v_sum - combi_sum[Ak] + k_cnt*(k_cnt -1)//2
    print(int(result))
### BUGGY CODE ###

x = int(input())
prime_list = []
for n in range(2, x * 2):
  is_prime = True
  for m in prime_list:
    if n % m == 0:
      is_prime = False
      break
  if is_prime:
    if x <= n:
      print(n)
      exit(0)
    prime_list.append(n)


### FIXED CODE ###

a = int(input())
flag = 0
j = 0
while(flag != 1):
    count =0
    temp = a+j
    for i in range(2, temp):
        if(temp %i == 0):
            count +=1
    if(count == 0):
        flag =1
        print(temp)
    j+=1
### BUGGY CODE ###

import math
K = int(input())
count = 0
for i in range(1, K+1):
    for j in range(1, K+1):
        for k in range(1, K+1):
            tmp = 0
            tmp = math.gcd(i, j)
            count += math.gcd(tmp, k)
print(count)

### FIXED CODE ###

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

from collections import Counter
N = int(input())
A = sorted(map(int, input().split()), reverse=False)
m = max(A)+1
dp = [True] * m
for x in list(set(A)):
    t = x * 2
    while t < m:
        dp[t] = False
        t += x
ans = 0
for a in A:
    if Counter(A)[a] == 1 and dp[a]:
        ans += 1
print(ans)



### FIXED CODE ###

from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
p = [True] * (10 ** 6 + 1)
s = list(set(a))
for x in s:
    t = x * 2
    while t <= 10 ** 6:
        p[t] = False
        t += x
ans = 0
for x in a:
    if c[x] == 1 and p[x] == True:
        ans += 1
print(ans)
### BUGGY CODE ###

from itertools import permutations
n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

c = []
for i in range(n):
    c.append((a[i], b[i]))


class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i


def bubcnt(v):
    bit = Bit(n)
    kaisu = 0
    for i in range(0, n):
        kaisu += i - bit.sum(v[i])
        bit.add(v[i], 1)
    return kaisu


l = [i+1 for i in range(n)]
ans = 10**9

xxx = permutations(l,n)

for v in xxx:
    tmp = 0
    cnt = 0
    for i in range(n):
        if tmp <= c[v[i]-1][(i-v[i]+1) % 2]:
            tmp = c[v[i]-1][(i-v[i]+1) % 2]
            cnt += 1
        else:
            break

    if cnt == n:
        ans = min(ans, bubcnt(v))

print(ans if ans != 10**9 else -1)


### FIXED CODE ###

n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

dp = [[10**9 for _ in range(51)] for __ in range(1 << n)]
dp[0][0] = 0


for i in range(1 << n):
    target = bin(i).count("1")-1
    cnt = bin(i).count("1")
    for j in range(n):
        if i >> j & 1:
            cnt -= 1
            if abs(j - target) % 2 == 0:
                nxt = a[j]
            else:
                nxt = b[j]
            for k in range(nxt+1):
                if dp[i ^ (1 << j)][k] != 10**9:
                    dp[i][nxt] = min(dp[i][nxt], dp[i ^ (1 << j)][k] + abs(j+cnt-target))

ans = min(dp[2**n-1])

print(ans if ans < 10**9 else -1)
### BUGGY CODE ###

N = int(input())
lis = list(map(int,input().split()))
l = []
i = 0
x = 0
while(True):
  if i == N-1:
    x += 1
    l.append(x)
    break
  if lis[i] != lis[i+1]:
    x += 1
    l.append(x)
    x = 0
  else:
    x += 1
s = 0
for i in lis:
  s += (i//2)
print(s)

### FIXED CODE ###

N = int(input())
lis = list(map(int,input().split()))
l = []
i = 0
x = 0
while(True):
  if i == N-1:
    x += 1
    l.append(x)
    break
  if lis[i] != lis[i+1]:
    x += 1
    l.append(x)
    x = 0
  else:
    x += 1
  i += 1
s = 0
for i in l:
  s += (i//2)
print(s)
### BUGGY CODE ###

N = int(input())
a = [int(input()) -1 for _ in range(N)]

done = []
i = 0
cnt = 0

while True:
    if i not in done:
        done.append(i)
        cnt += 1
        if a[i] == 1:
            break
        i = a[i]
    else:
        cnt = -1
        break

print(cnt)

### FIXED CODE ###

N = int(input())
a = [int(input()) -1 for _ in range(N)]

done = [False]*N
i = 0
cnt = 0

while True:
    if done[i] == False:
        done[i] = True
        cnt += 1
        if a[i] == 1:
            break
        i = a[i]
    else:
        cnt = -1
        break

print(cnt)
### BUGGY CODE ###

V = input().split()
N = int(V[0])
K = int(V[1])
Q = int(V[2])
A = [0 for i in range(Q)]
P = [K for i in range(N)]
for i in range(Q):
    A[i] = int(input())

for i in range(Q):
    for j in range(N):
        if j+1 != A[i]:
            P[j] -= 1
            

for i in range(N):
    if P[i] <= 0:
        print("No")
    elif P[i] > 0:
        print("Yes")


### FIXED CODE ###

V = input().split()
N = int(V[0])
K = int(V[1])
Q = int(V[2])
A = [0 for i in range(Q)]
P = [K for i in range(N)]
for i in range(Q):
    A[i] = int(input())

for i in range(Q):
    P[A[i]-1] += 1

for i in range(N):
    if P[i] - Q <=0:
        print("No")
    if P[i] - Q > 0:
        print("Yes")
### BUGGY CODE ###

n, ma, mb = map(int, input().split())
abc = [tuple(int(x) for x in input().split()) for _ in range(n)]

c = n * 100 + 1

dp = [[[99999 for _ in range(1001)] for _ in range(1001)] for _ in range(n + 1)]

ans = 99999
dp[0][0][0] = 0
for i in range(n):
    for j in range(1001):
        for k in range(1001):
            if dp[i][j][k] < 9999:
                dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j][k])
                dp[i+1][j+abc[i][0]][k+abc[i][1]] = min(dp[i+1][j+abc[i][0]][k+abc[i][1]], dp[i][j][k] + abc[i][2])
                if (j+abc[i][0]) * mb == (k+abc[i][1]) * ma:
                    ans = min(ans, dp[i+1][j+abc[i][0]][k+abc[i][1]])

if ans == 99999:
    print(-1)
else:
    print(ans)

### FIXED CODE ###

n, ma, mb = map(int, input().split())
abc = [tuple(int(x) for x in input().split()) for _ in range(n)]

c = n * 100 + 1

m = 401

dp = [[[99999 for _ in range(m)] for _ in range(m)] for _ in range(n + 1)]

ans = 99999
dp[0][0][0] = 0
for i in range(n):
    for j in range(m):
        for k in range(m):
            if dp[i][j][k] < 9999:
                dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j][k])
                dp[i+1][j+abc[i][0]][k+abc[i][1]] = min(dp[i+1][j+abc[i][0]][k+abc[i][1]], dp[i][j][k] + abc[i][2])
                if (j+abc[i][0]) * mb == (k+abc[i][1]) * ma:
                    ans = min(ans, dp[i+1][j+abc[i][0]][k+abc[i][1]])

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

from itertools import product
from collections import deque
import numpy as np
class Grid:
    def __init__(self, grid, w=0, h=0, function=lambda x: x, space=1):
        self.w = w = w if w else len(grid[0])
        self.h = h = h if h else len(grid)
        dtype = type(function(grid[0][0]))
        self.grid = np.empty((h, w), dtype=dtype)
        for i, row in zip(range(h), grid):
            for j, val in zip(range(w), row):
                self.grid[i][j] = function(val)
        self.space = space
    
    def is_valid_x(self, x):
        return 0 <= x < self.w
    def is_valid_y(self, y):
        return 0 <= y < self.h
    def is_valid_xy(self, x, y):
        return self.is_valid_x(x) and self.is_valid_y(y) 
    
    def __iter__(self):
        return iter(self.grid)
    def __repr__(self):
        return '\n'.join(''.join(f'{{: >{self.space}}}'.format(x) for x in row) for row in self.grid) + '\n'
    def __getitem__(self, x):
        return self.grid[x]
    def __setitem__(self, x, val):
        self.grid[x] = val

def bfs_01(G, start, goal):
    Q = deque([start])
    x, y = start
    D = Grid(G.grid, function=lambda x:-9 if x=='#' else 10**6, space=4)
    D[y, x] = 0
    while Q:
        x, y = Q.pop()
        for dx, dy in product(range(-2, 3), repeat=2):
            nx, ny = x+dx, y+dy
            if dx==dy==0:
                G[y, x] = '!'
                continue
            elif not G.is_valid_xy(nx, ny) or G[ny, nx] in '#!':
                continue
            elif abs(dx)+abs(dy)<=1:
                G[y, x] = '!'
                Q.append((nx, ny))
                D[ny, nx] = D[y, x]
            elif D[ny, nx] > D[y, x]+1:
                Q.appendleft((nx, ny))
                D[ny, nx] = D[y, x]+1       
    x, y = goal
    return D[y, x]

h, w = map(int, input().split())
sy, sx = map(int, input().split())
gy, gx = map(int, input().split())
sx, sy, gx, gy = sx-1, sy-1, gx-1, gy-1
grid = Grid([input() for s in range(h)], space=4)
ans = bfs_01(grid, (sx, sy), (gx, gy))
print(ans if ans != 10**6 else -1)

### FIXED CODE ###

from collections import deque
from itertools import product
h, w = list(map(int,input().split()))
sy, sx = list(map(int,input().split()))
gy, gx = list(map(int,input().split()))
sx, sy, gx, gy = sx-1, sy-1, gx-1, gy-1
 
G = [list(input()) for _ in range(h)]
D = [[10**6]*w for _ in range(h)]
D[sy][sx] = 0
Q = deque([(sy, sx)])
while Q:
    y, x = Q.pop()
    for dy, dx in product(range(-2, 3), repeat=2):
        ny, nx = y+dy, x+dx
        if dx==dy==0:
            G[y][x] = '#'
            continue
        elif ny<0 or h<=ny or nx<0 or w<=nx:
            continue
        elif G[ny][nx] == '#':
            continue
        elif abs(dy)+abs(dx)<=1:
            G[ny][nx] = '#'
            D[ny][nx] = D[y][x]
            Q.append((ny, nx))
        elif D[ny][nx] == 10**6:
            D[ny][nx] = D[y][x]+1
            Q.appendleft((ny, nx))
            
if D[gy][gx] == 10**6:
    print(-1)
else:
    print(D[gy][gx])
### BUGGY CODE ###

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

distance = []
for i in range(N-1):
    distance.append(A[i+1] - A[i])
distance.append(K - A[-1] + A[0])

for i in range(N):
    if distance[i] == max(distance):
        start = i

ans = K - max(distance)
print(ans)

### FIXED CODE ###

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

distance = []
for i in range(N-1):
    distance.append(A[i+1] - A[i])
distance.append(K - A[-1] + A[0])

ans = K - max(distance)
print(ans)
### BUGGY CODE ###

import copy
import math

N,M,S=map(int,input().split())

Us=[0]*M
Vs=[0]*M
As=[0]*M
Bs=[0]*M
for i in range(M):
    Us[i],Vs[i],As[i],Bs[i] = map(int,input().split())

# ---
V={}
Ns = max(As)*N
Nv=N*(Ns+1)
cnt=0
for i in range(1,N+1):
    for ns in range(Ns+1):
        V[(i,ns)]=cnt
        cnt+=1
#T= copy.copy(V)


if S > Ns:
    S = Ns

# --
w = [[math.inf]*Nv for _ in range(Nv) ]
# U <-> V
for _ in range(M):
    u = Us.pop()
    v = Vs.pop()
    a = As.pop()
    b = Bs.pop()
    #
    for i in range(Ns+1): # i = 0,..,Ns
        ns_s = Ns - i
        ns_g = ns_s - a
        if ns_g >= 0:
            # U -> V
            w[ V[(u,ns_s)] ][ V[(v,ns_g)] ] = b
            # V -> U
            w[ V[(v,ns_s)] ][ V[(u,ns_g)] ] = b
            #print(u,v,a,b,ns_s,ns_g,V[(u,ns_s)],V[(v,ns_g)])

# -----

for i in range(N):
    c,d = map(int,input().split())
    v = i+1
    for j in range(Ns): # j = 0,...,Ns-1
        ns_s = j
        ns_g = j + c
        if ns_g > Ns:
            ns_g = Ns
        w[ V[(v,ns_s)] ][ V[(v,ns_g)] ] = d

# -----
D=[-1]*Nv
# -----
T=set(range(Nv))
visited = set([1])
allcity = set(range(1,N+1))

s=V[(1,S)]
T.remove(s) #del T[s]
D[s] = 0
for v in T:
    D[v] = w[ s ][ v ]
#while len(T) > 0:
for _ in range(Nv-1):
    u = min(T,key=lambda x:D[x])
    T.remove(u)

    visited.add(u//(Ns+1)+1)
    if visited == allcity:
        break

    for v in T:
        D[ v ] = min( D[ v ], D[ u ] + w[ u ][ v ] )

for i in range(2,N+1):
    ans = min([ D[ V[(i,ns)] ] for ns in range(Ns+1) ])
    print(ans)

### FIXED CODE ###

import math
import heapq

N,M,S=map(int,input().split())

Us=[0]*M
Vs=[0]*M
As=[0]*M
Bs=[0]*M
for i in range(M):
    Us[i],Vs[i],As[i],Bs[i] = map(int,input().split())
    Us[i] -= 1
    Vs[i] -= 1

# ---
V={}
Ns = max(As)*N
Nv=N*(Ns+1)
cnt=0
for i in range(N):
    for ns in range(Ns+1):
        V[(i,ns)]=cnt
        cnt+=1

G=[[] for _ in range(Nv)]

if S > Ns:
    S = Ns

# U <-> V
for _ in range(M):
    u = Us.pop()
    v = Vs.pop()
    a = As.pop()
    b = Bs.pop()
    #
    for i in range(Ns+1): # i = 0,..,Ns
        ns_s = Ns - i
        ns_g = ns_s - a
        if ns_g >= 0:
            # U -> V
            G[ V[(u,ns_s)] ].append( (V[(v,ns_g)],b) )
            # V -> U
            G[ V[(v,ns_s)] ].append( (V[(u,ns_g)],b) )
            #print(u,v,a,b,ns_s,ns_g,V[(u,ns_s)],V[(v,ns_g)])

# -----

for i in range(N):
    c,d = map(int,input().split())
    for j in range(Ns): # j = 0,...,Ns-1
        ns_s = j
        ns_g = j + c
        if ns_g > Ns:
            ns_g = Ns
        G[ V[(i,ns_s)] ].append( (V[(i,ns_g)],d) )

# -----
D=[math.inf]*Nv
q=[]
# -----

s=V[(0,S)]
D[s] = 0
heapq.heappush(q,(0,s))

while len(q) > 0:
    p_cost,p_v = heapq.heappop(q)
    if D[p_v] < p_cost:
        continue
    for e_to,e_cost in G[p_v]:
        if D[ e_to ] > D[p_v] + e_cost:
            D[e_to] = D[p_v] + e_cost
            heapq.heappush(q, (D[e_to], e_to))

for i in range(1,N):
    ans = min([D[i*(Ns+1)+v] for v in range(Ns+1)])
    print(ans)
### BUGGY CODE ###

import math
from functools import reduce
from collections import defaultdict


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


def main():
    N = int(input())
    A = list(map(int, input().split()))
    A_max = max(A)

    is_pairwise_coprime = True

    D = [-1] * (A_max + 1)
    for i in range(2, A_max + 1):
        if D[i] == -1:
            D[i] = i
            p = 2
            while i * p <= A_max:
                D[i * p] = i
                p += 1

    def factorization(n):
        # assert 0 < n <= A_max
        primes_ = defaultdict(int)
        temp = n
        while temp > 1:
            primes_[D[temp]] += 1
            temp = temp // D[temp]

        return primes_

    primes = set({})
    for i in range(N):
        for p in factorization(A[i]).keys():
            if p in primes:
                is_pairwise_coprime = False
                break
            else:
                primes.add(p)

    gcd_ = reduce(math.gcd, A)

    if is_pairwise_coprime:
        print('pairwise coprime')
    elif gcd_ == 1:
        print('setwise coprime')
    else:
        print('not coprime')


if __name__ == '__main__':
    main()


### FIXED CODE ###

import math
from functools import reduce
from collections import defaultdict


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


def main():
    N = int(input())
    A = list(map(int, input().split()))
    A_max = max(A)

    is_pairwise_coprime = True

    D = [-1] * (A_max + 1)
    for i in range(2, A_max + 1):
        if D[i] == -1:
            D[i] = i
            for j in range(i*i, A_max+1, i):
                D[j] = i

    def factorization(n):
        # assert 0 < n <= A_max
        primes_ = defaultdict(int)
        temp = n
        while temp > 1:
            primes_[D[temp]] += 1
            temp = temp // D[temp]

        return primes_

    P = [False]*(A_max+1)

    # primes = set({})
    for i in range(N):
        for p in factorization(A[i]).keys():
            # if p in primes:
            if P[p]:
                is_pairwise_coprime = False
                break
            else:
                # primes.add(p)
                P[p] = True

    gcd_ = reduce(math.gcd, A)

    if is_pairwise_coprime:
        print('pairwise coprime')
    elif gcd_ == 1:
        print('setwise coprime')
    else:
        print('not coprime')


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

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

ans = 0
x = 0
for i in range(a-b+1):
  #print(d[i:i+b])
  if ans < sum(d[i:i+b]):
    ans = sum(d[i:i+b])
    x = i
  
  
d2 = [(i+1)/2 for i in d[x:x+b]]

print(sum(d2))

### FIXED CODE ###

a,b=map(int,input().split())
d = list(map(int, input().split(" ")))
w = [0]*(len(d)+1)

# 累積和の計算
w[0] = 0
for i in range(0, len(d)):
  w[i+1] = w[i] + d[i]
  
ans = 0
for i in range(0, a-b+1):
    ans = max([ans,w[i+b]-w[i]])

d2 = 0.5*b + ans/2

if a == 1:
  print((d[0]+1)/2)
else:
  print(d2)
### BUGGY CODE ###

k=int(input())
import math


n=k//2+1

ans_g=0
def cnt(l):
    ans=0
    for i in range(1,int(math.sqrt(l))+1):
        if l%i==0:
            if i==(l//i):
                ans+=1
            else:
                ans+=2
    return ans
        
 
    






for i in range(1,n):
    j=k-i
    if j!=i:
        ans_g+=cnt(j)
        ans_g+=cnt(i)
    else:
        ans_g+=cnt(i)
    
print(ans_g)
    

### FIXED CODE ###

k=int(input())


cnt=0
if k>6:
    for i in range(7,k):
        for j in range(1,k):
            
                
            if i*j<k:
                cnt+=1
            else:
                break
print(cnt+k-1+((k-1)//2)+((k-1)//3)+((k-1)//4)+((k-1)//5)+((k-1)//6))
### BUGGY CODE ###

K, S = map(int, input().split())
count = 0
for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            if i + j + k == S:
                count += 1
print(count)

### FIXED CODE ###

K, S = map(int, input().split())
count = 0
for i in range(K+1):
    for j in range(K+1):
        if 0 <= S - i - j and S - i - j <= K:
            count += 1
print(count)