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

def solve(N, A):
    days = 0
    n_games = N * (N-1) / 2
    while n_games > 0:
        n_games_today = 0
        has_game_today = [False] * (N+1)
        for i in range(1, N+1):
            if has_game_today[i]:
                continue
            j = A[i][0]
            if j != -1 & A[j][0] == i:
                has_game_today[i] = True
                has_game_today[j] = True
        n_games_today = sum(has_game_today) // 2
        for i in range(1, N+1):
            if has_game_today[i]:
                A[i].pop(0)
        if n_games_today > 0:
            days += 1
            n_games -= n_games_today
        else:
            return -1
    return days


def main():
    N = int(input())
    A = list()
    A.append([])
    for i in range(N):
        a = list(map(int, input().strip().split()))
        a += [-1, ]
        A.append(a)
    print(solve(N, A))


if __name__ == "__main__":
    main()


### FIXED CODE ###

def make_state(N):
    state = [[-1 for j in range(N+1)] for i in range(N+1)]
    min_state = 0
    s = min_state
    for i in range(1, N+1):
        for j in range(1, i):
            state[i][j] = s
            state[j][i] = s
            s += 1
    return state


def solve(N, A):
    state = make_state(N)
    max_state = N * (N-1) // 2
    n_prev_states = [0 for i in range(max_state)]
    next_states = [set() for i in range(max_state)]
    for i in range(1, N+1):
        for k in range(N-2):
            ps = state[i][A[i][k]]
            ns = state[i][A[i][k+1]]
            n_prev_states[ns] += 1
            next_states[ps].add(ns)
    
    today_states = set()
    for s in range(max_state):
        if n_prev_states[s] == 0:
            today_states.add(s)
    
    n_days = 0
    n_states_left = max_state
    while len(today_states) > 0:
        n_days += 1
        if len(today_states) == 0:
            break
        n_states_left -= len(today_states)
        nextday_states = set()
        for s in today_states:
            for ns in next_states[s]:
                n_prev_states[ns] -= 1
                if n_prev_states[ns] == 0:
                    nextday_states.add(ns)
        today_states = nextday_states
    return n_days if n_states_left == 0 else -1


def main():
    N = int(input())
    A = list()
    A.append([])
    for i in range(N):
        a = list(map(int, input().strip().split()))
        A.append(a)
    print(solve(N, A))


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

a,b,k=map(int,input().split())
for i in range(k):
    if a>=1:
        a-=1
    else:
        b-=1
l=[]
l.append(a)
l.append(b)
print(' '.join(map(str, l)))

### FIXED CODE ###

a,b,k=map(int,input().split())
if a-k<1:
    if b-(k-a)>=1: 
        print(0,b-(k-a))
    else:
        print(0,0)
else:
    print(a-k,b)
### BUGGY CODE ###

N,M,Q = map(int,input().split())
LR = [ list(map(int,input().split())) for i in range(M)]
pq = [ list(map(int,input().split())) for i in range(Q)]

lr = [ [0]*(N+1) for i in range(N+1)]
for i in range(M):
    l,r = LR[i][0],LR[i][1]
    lr[l][r] += 1

for i in range(Q):
    ans = 0
    p,q = pq[i][0],pq[i][1]
    for i in range(p,q+1):
        for j in range(p,q+1):
            ans += lr[i][j]
    print(ans)



### FIXED CODE ###

N,M,Q = map(int,input().split())
LR = [ list(map(int,input().split())) for i in range(M)]
pq = [ list(map(int,input().split())) for i in range(Q)]

lr = [ [0]*(N+1) for i in range(N+1)]
for i in range(M):
    l,r = LR[i][0],LR[i][1]
    lr[l][r] += 1

for i in range(N):
    for j in range(N):
        lr[i][j+1] += lr[i][j]

for i in range(Q):
    ans = 0
    p,q = pq[i][0],pq[i][1]
    for i in range(p,q+1):
        ans += (lr[i][q] - lr[i][p-1])
    print(ans)
### BUGGY CODE ###

# C - Lamps
# imos法, 累積和

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

for _ in range(K):
    B = [0] * (N+1)
    for i, a in enumerate(A):
        left = max(0, i-a)
        right = min(i+a+1, N)
        B[left] += 1
        B[right] -= 1
    for i in range(N):
        B[i+1] += B[i]
    B.pop()
    if A == B:
        break
    else:
        A = B

print(' '.join(map(str, A)))


### FIXED CODE ###

# C - Lamps
# imos法, 累積和

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

for _ in range(K):
    B = [0] * (N+1)
    for i, a in enumerate(A):
        left = max(0, i-a)
        right = min(i+a+1, N)
        B[left] += 1
        B[right] -= 1
    for i in range(N):
        B[i+1] += B[i]
    B.pop()
    if A == B:
        break
    else:
        A = B

print(' '.join(map(str, A)))
### BUGGY CODE ###

import itertools
N = int(input())
S = list(input())
S = tuple(S)
X = list(itertools.combinations(S, 3))
print(len(set(X)))

### FIXED CODE ###

N = int(input())
S = input()
count = 0
for i in range(1000):
    t = str(i).zfill(3)
    a = S.find(t[0])
    b = S.find(t[1], a+1)
    c = S.find(t[2], b+1)
    if a != -1 and b != -1 and c != -1:
        count += 1
print(count)
### BUGGY CODE ###

K = int(input())

count = -1
n = 7
for i in range(K):
    if n % K == 0:
        count = i+1
        break
    n = int(str(n)+'7')

print(count)

### FIXED CODE ###

K = int(input())

count = -1
n = 7
for i in range(K):
    if n % K == 0:
        count = i+1
        break
    n = int(str(n)+'7')
    n %= K
print(count)
### BUGGY CODE ###

import numpy as np
N, K= map(int,input().split())
A = list(map(int,input().split()))
p=0
while p<K:
  B=[0]*(N+1)
  for i in range(N):
    l = max(i-A[i],0)
    r = min(i+A[i]+1,N)
    B[l] +=1
    B[r] -=1
  A = np.cumsum(B)
  p +=1        
  if min(A[0:N])==N:
    break
print(*A[0:N])

### FIXED CODE ###

N, K= map(int,input().split())
A = list(map(int,input().split()))
a=A[:]
for _ in range(K):
  B=[0]*(N+1)
  for i in range(N):
    t = a[i]
    B[max(i-t,0)] +=1
    B[min(i+t+1,N)] -=1
  for i in range(N):
    B[i+1] += B[i]
  a=B[:N]        
  if min(a)==N:
    break
print(*a)
### BUGGY CODE ###

h,w,m=map(int,input().split())
bomb=[]
x=[0]*(h+1)
y=[0]*(w+1)
for i in range(m):
    h1,w1=map(int,input().split())
    x[h1]+=1
    y[w1]+=1
    bomb.append((h1,w1))
maxx=max(x)
maxy=max(y)
r=[]
c=[]
for i in range(1,h+1):
    if x[i]==maxx:
        r.append(i)
for j in range(1,w+1):
    if y[j]==maxy:
        c.append(j)
for j in r:
    for k in c:
        if not (j,k) in bomb:
            print(maxx+maxy)
            exit()
print(maxx+maxy-1)

### FIXED CODE ###

h,w,m=map(int,input().split())
bomb=[]
x=[0]*(h+1)
y=[0]*(w+1)
for i in range(m):
    h1,w1=map(int,input().split())
    x[h1]+=1
    y[w1]+=1
    bomb.append((h1,w1))
maxx=max(x)
maxy=max(y)
r=[]
c=[]
bomb=set(bomb)
for i in range(1,h+1):
    if x[i]==maxx:
        r.append(i)
for j in range(1,w+1):
    if y[j]==maxy:
        c.append(j)
for j in r:
    for k in c:
        if (j,k) not in bomb:
            print(maxx+maxy)
            exit()
print(maxx+maxy-1)
### BUGGY CODE ###

N,Q=map(int,input().split())
S=[i for i in input()]
L=[list(map(int, input().split())) for _ in range(Q)]
d=[]
for j in range(len(S)-1):
  if S[j]=='A' and S[j+1]=='C':
    d.append(j)
for i in L:
  m=0
  for j in range(len(d)):
    if d[j]>=i[0]-1 and d[j]+1<=i[1]-1:
      m+=1
  print(m)

### FIXED CODE ###

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

# E
import fractions
N = int(input()) 
A = list(map(int, input().split()))

def main():
    value = A[0]
    for i in range(1, N):
        value = value * A[i] // fractions.gcd(value, A[i])

    z = 10**9+7
    ans = 0
    for i in A:
        ans += (value//i) % z

    print(ans % z)

if __name__ == '__main__':
    main()

### FIXED CODE ###

# E
from fractions import gcd

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

value = 1
for a in A:
    value = value * a // gcd(value, a)

mod = 10**9+7

ans = 0
for i in A:
    ans += value // i

print(ans%mod)
### BUGGY CODE ###

k, s = map(int,input().split())
cnt = 0
for x in range(0, k+1):
    for y in range(0, k+1):
        for z in range(0, k+1):
            sum = x+y+z
            if sum==s:
                cnt += 1
print(cnt)

### FIXED CODE ###

k, s = map(int,input().split())
cnt = 0
for x in range(0, k+1):
    for y in range(0, k+1):
        if (0 <= s-x-y) and (s-x-y <= k):
            cnt += 1
print(cnt)
### BUGGY CODE ###

import numpy as np


def read_input(trans=int):
    return list(map(trans, input().split()))


N, K = read_input()
A = np.array(read_input(), dtype="int")
coordinate = np.arange(1, N+1)

K = np.minimum(K, 41)

for _ in range(K):
    B = np.zeros(N, dtype="int")
    for i in range(N):
        end = np.minimum(coordinate[i]+A[i], N)
        start = np.maximum(coordinate[i]-A[i], 1)

        B[start-1] += 1
        if end < N:
            B[end] -= 1
    B = np.cumsum(B)
    A = B.copy()


print(" ".join(map(str, A.tolist())))


### FIXED CODE ###

def read_input(trans=int):
    return list(map(trans, input().split()))


N, K = read_input()
A = read_input()
K = min(K, 41)

for _ in range(K):
    B = [0]*N
    for i in range(N):
        start = max(i-A[i], 0)
        end = min(i+A[i], N-1)

        B[start] += 1
        if end+1 < N:
            B[end+1] -= 1
    for i in range(1, N):
        B[i] += B[i-1]
    A = B.copy()


print(" ".join(map(str, A)))
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
a = list(range(1,N+1))
bbef = -N
baft = -N+1
elementbef = [abs(i-j-bbef) for (i,j) in zip(A,a)]
sumbef = sum(elementbef)
elementaft = [abs(i-j-baft) for (i,j) in zip(A,a)]
sumaft = sum(elementaft)
while(sumaft-sumbef < 0):
    bbef = bbef+1
    baft = baft+1
    elementbef = [abs(i-j-bbef) for (i,j) in zip(A,a)]
    sumbef = sum(elementbef)
    elementaft = [abs(i-j-baft) for (i,j) in zip(A,a)]
    sumaft = sum(elementaft)
print(sumbef)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
a = list(range(1,N+1))
elements = sorted([i-j for (i,j) in zip(A,a)])
if(N%2 == 1):
    b = elements[N//2]
else:
    b = elements[(N//2)-1]
answer = sum([abs(i-j-b) for (i,j) in zip(A,a)])
print(answer)
### BUGGY CODE ###

import numpy as np
N,K = map(int,input().split())
h = np.array([int(i) for i in input().split()])
dp = [10**10 for _ in range(N)]
dp[0] = 0
for i in range(1,N):
    dp[i:i+K] = np.fmin(dp[i:i+K], dp[i-1] + np.abs(h[i:i+K] - h[i-1]))
        
print(dp[-1])

### FIXED CODE ###

import numpy as np
N,K = map(int,input().split())
h = np.array([int(i) for i in input().split()])
dp = np.full(N,10**10,dtype=int)
dp[0] = 0
for i in range(1,N):
    dp[i:i+K] = np.fmin(dp[i:i+K], dp[i-1] + np.abs(h[i:i+K] - h[i-1]))
        
print(dp[-1])
### BUGGY CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = []
for _ in range(M):
    bc = list(map(int, input().split()))
    BC.append(bc)
BC = sorted(BC, key=lambda x:x[1], reverse=True)
#print(BC)
for b, c in BC:
    A = sorted(A)
    if A[0] >= c:
        break
    for i in range(b):
        if A[i] < c:
            A[i] = c
        else:
            break
print(sum(A))

### FIXED CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = []
for _ in range(M):
    bc = list(map(int, input().split()))
    BC.append(bc)
BC = sorted(BC, key=lambda x:x[1], reverse=True)
cnt = 0
for b, c in BC:
    A += [c] * b
    cnt += b
    if cnt >= N:
        break
A.sort(reverse=True)
print(sum(A[:N]))
### BUGGY CODE ###

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

MOD=10**9+7

ans=0
for i in range(N-1):
    for j in range(i,N):
        ans+=A[i] ^ A[j] #XOR
        ans%=MOD
print(ans)


### FIXED CODE ###

def pos(x, n, m):
    if n == 0:
        return 1
    res = pos(x*x%m, n//2, m)
    if n%2 == 1:
        res = res*x%m
    return res

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

MOD=10**9+7

ans=0
for i in range(60):
    count1=0
    count0=0
    for j in range(N):
        if A[j]>>i & 1:
            count1+=1
        else:
            count0+=1
    ans+=count0*count1%MOD*pos(2,i,MOD)
    ans%=MOD
print(ans)
### BUGGY CODE ###

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

from_one = []
to_n = []

for i in range(M):
    a, b = map(int, input().split())
    if a == 1:
        from_one.append(b)
    elif b == N:
        to_n.append(a)

pos = "IMPOSSIBLE"

for island in from_one:
    if island in to_n:
        pos = "POSSIBLE"

print(pos)

### FIXED CODE ###

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

f = set()
t = set()

for i in range(M):
    a, b = map(int, input().split())
    if a == 1:
        f.add(b)
    elif a == N:
        t.add(b)
    if b == 1:
        f.add(a)
    elif b == N:
        t.add(a)

pos = "IMPOSSIBLE"

if f&t:
    pos = "POSSIBLE"

print(pos)
### BUGGY CODE ###

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

def floor(x):
  return int(x//1)

list = []
for x in range(N+1):
  list.append(floor((A*x)/B)-(A*floor(x/B)))
print(max(list))

### FIXED CODE ###

A,B,N = map(int,input().split())
def floor(x):
  return int(x//1)
list = []
if N >= B:
    list.append(floor((A*(B-1))/B)-(A*floor((B-1)/B)))
else:
    list.append(floor((A*N)/B)-(A*floor(N/B)))
print(max(list))
### BUGGY CODE ###

N = int(input())
S = []
count = 0
for i in range(N):
  S.append(input())

for i in range(0,N):
  if S[i] != '0':
    count += 1
    for j in range(i+1,N):
      if (S[j] != '0'):
        if S[i] == S[j]:
          S[j] = '0'
         
print (count)  

### FIXED CODE ###

import collections

N = int(input())
S = []
count = 0
for i in range(N):
  S.append(input())

count = len(collections.Counter(S))
         
print (count)
### BUGGY CODE ###

# coding: utf-8
# Your code here!
n = int(input())
s = list(map(int,input().split()))
for i in range(n):
    ans = 0
    #print("a")
    a = []
    for j,k in enumerate(s):
        if j == i:
            continue
        elif not k in a:
            if s[i] == k:
                p = (s.count(k)-2)*(s.count(k)-1)
                ans += p//2
            else:
                p = s.count(k)*(s.count(k)-1)
                ans += p//2
            a.append(k)
            #print(ans,p,j)
#    print(s)
    print(ans)        


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
List={}
x=0
for i in range(n):
    if not a[i] in List:
        List[a[i]] = 1
    else:
        List[a[i]]+=1
    
sigma=0
 
for key,item in List.items():
    sigma += item*(item-1)//2
for i in range(n):
    print(sigma-List[a[i]]+1)
### BUGGY CODE ###

""" dpはi桁,あまりj
[[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
"""
MOD = 10**9+7

S = str(input())
S = S[::-1]
n = len(S)

dp = [[0]*(13) for _ in range(n+1)]
dp[0][0]=1 #0を割ったあまりは0

q = 1 # はじめの1桁のときはあまりは1

# i桁目のあまりが何通りあるか
for i in range(1,n+1): # 「1-n」桁まで
  s = S[i-1]
  for j in range(13): # 13で割ったあまり
    
    if s == '?': # ?の場合は0-9を計算する
      for k in range(10):
        dp[i][(j+k*q)%13] += dp[i-1][j] # i-1桁目からi桁目 +=を忘れずに！
    else:
      k = int(s)
      dp[i][(j+k*q)%13] += dp[i-1][j] # i-1桁目からi桁目
  for m in range(13):
    dp[i][m] %= MOD
  q = (10*q)%13 # 「10^iをqで割ったあまり」

print(dp[n][5] % MOD)

### FIXED CODE ###

""" dpはi桁,あまりj
[[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
"""
MOD = 10**9+7

S = str(input())
S = S[::-1]
n = len(S)

dp = [[0]*(13) for _ in range(n+1)]
dp[0][0]=1 #0を割ったあまりは0

q = 1 # はじめの1桁のときはあまりは1

# i桁目のあまりが何通りあるか
for i in range(1,n+1): # 「1-n」桁まで
  s = S[i-1]
  for j in range(13): # 13で割ったあまり
    
    if s == '?': # ?の場合は0-9を計算する
      for k in range(10):
        dp[i][(j+k*q)%13] += dp[i-1][j] # i-1桁目からi桁目 +=を忘れずに！
    else:
      k = int(s)
      dp[i][(j+k*q)%13] += dp[i-1][j] # i-1桁目からi桁目
  for m in range(13):
    dp[i][m] %= MOD
  q = (10*q)%13 # 「10^iをqで割ったあまり」

print(dp[n][5] % MOD)
### BUGGY CODE ###

# import bisect
from collections import Counter, deque
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, m = list(map(int, ipti().split()))
    node_next = [set() for _ in range(n)]

    for i in range(m):
        u, v = list(map(int, ipti().split()))
        u, v = u - 1, v - 1
        node_next[u].add(v)

    s, t = list(map(int, ipti().split()))
    s, t = s - 1, t - 1

    seen = [[0] * 3 for _ in range(n)]

    que = deque()
    que.append((s, 0, 0))

    while que:
        cnode, cstate, dist = que.popleft()
        seen[cnode][cstate] = 1
        dist += 1
        nstate = (cstate + 1) % 3
        for nnode in node_next[cnode]:
            if nstate == 0 and nnode == t:
                print(dist // 3)
                sys.exit()
            else:
                if seen[nnode][nstate] == 0:
                    que.append((nnode, nstate, dist))

    print(-1)


if __name__ == '__main__':
    main()


### FIXED CODE ###

# import bisect
from collections import Counter, deque
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, m = list(map(int, ipti().split()))
    node_next = [set() for _ in range(n)]

    for i in range(m):
        u, v = list(map(int, ipti().split()))
        node_next[u - 1].add(v - 1)

    s, t = list(map(int, ipti().split()))
    s, t = s - 1, t - 1

    dist = [[INF] * n for _ in range(3)]
    dist[0][s] = 0

    que = deque()
    que.append((0, s))

    while que:
        cstate, cnode = que.popleft()
        d = dist[cstate][cnode]
        nstate = (cstate + 1) % 3
        for nnode in node_next[cnode]:
            if dist[nstate][nnode] == INF:
                dist[nstate][nnode] = d + 1
                que.append((nstate, nnode))

    if dist[0][t] != INF:
        print(dist[0][t] // 3)
    else:
        print(-1)


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

# coding: utf-8
N, S = list(map(int, input().split()))
A = [0]+list(map(int, input().split()))

dt = [[0 for _ in range(S+1)] for x in range(N+1)]

for n in range(1, N+1):
  if A[n] <= S:
    dt[n][A[n]] += n
  for i in range(1,S+1):
    step = dt[n-1][i] * 2 - dt[n-2][i]
    if (i + A[n]) <= S:
      dt[n][i+A[n]] += step - dt[n-1][i]
    dt[n][i] += step

print(dt[N][S] % 998244353)

### FIXED CODE ###

# coding: utf-8
import numpy as np
N, S = list(map(int, input().split()))
A = [0]+list(map(int, input().split()))

dt = np.array([[0 for _ in range(S+1)] for x in range(N+1)])

for n in range(1, N+1):
  if A[n] <= S:
    dt[n,A[n]] += n
  if A[n] < S:
    dt[n, A[n]+1:] += dt[n-1,1:S-A[n]+1] - dt[n-2,1:S-A[n]+1]
  dt[n,:] += dt[n-1,:] * 2 - dt[n-2,:]
  dt[n,:] %= 998244353
print(dt[N,S] % 998244353)
### BUGGY CODE ###

N, K = map(int, input().split())
h = list(map(int, input().split()))
dp = [10 ** 9 for _ in range(N)]
dp[0] = 0
for i in range(1, N):
  x = dp[i-1] + abs(h[i]-h[i-1])
  for j in range(2, K+1):
    if i-j < 0:
      continue
    x = min(dp[i-j] + abs(h[i]-h[i-j]), x)
  dp[i] = x
print(dp[N-1])

### FIXED CODE ###

N, K = map(int, input().split())
h = list(map(int, input().split()))
dp = [10 ** 9 for _ in range(N)]
dp[0] = 0
for i in range(1, N):
  x = dp[i-1] + abs(h[i]-h[i-1])
  for j in range(2, K+1):
    if i-j >= 0:
      x = min(dp[i-j] + abs(h[i]-h[i-j]), x)
    else:
      pass
  dp[i] = x
print(dp[N-1])
### BUGGY CODE ###

l = [int(x) for x in input().split()]
N = l[0]
K = l[1]
P = [int(x) for x in input().split()]

expected = []
a = 0
ans = []

for i in range(len(P)):
    expected.append((P[i]+1)/2)
#print(expected)

for k in range(N - K + 1):
    a = 0
    for x in range(K):
        a += expected[k+x]
    ans.append(a)
#print(ans)
print(max(ans))

### FIXED CODE ###

from itertools import accumulate
n,k=map(int, input().split())
A=[((int(i)*(int(i)+1))/2)/int(i) for i in input().split()]
al = list(accumulate(A))
ans = al[k-1]
for i in range(k, n):ans=max(ans, al[i]-al[i-k])
print(ans)
### BUGGY CODE ###

def green_bin(n,s):
    count = 0
    x = [sorted(i) for i in s]

    for i in range(n-1):
        for j in range(i+1,n):
            if x[i] == x[j]:
                count += 1

    return count
if __name__ == '__main__':
    n = int(input())
    s = [ input() for i in range(n)]

    print(green_bin(n,s))

### FIXED CODE ###

# -*- coding: utf-8 -*-
n = int(raw_input())
d = {}
ans = 0
for i in range(n):
    si = ''.join(sorted(raw_input()))
    if si in d:
        ans += d[si]
        d[si] += 1
    else:
        d[si] = 1
print(ans)
### BUGGY CODE ###

from collections import deque

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

a = deque(map(int, input().split()))
ad = {}
for i in range(n):
    ad[i] = a.popleft()

def makea(ad):
    newa = {}
    for i in range(n):
        newa[i] = 0
    for i in range(n):
        if i - ad[i] >= 0:
            if i + ad[i] <= n-1:
                for j in range(i-ad[i], i+ad[i]+1):
                    newa[j] += 1
            else:
                for j in range(i-ad[i], n):
                    newa[j] += 1
        elif i + ad[i] <= n-1:
            for j in range(i+ad[i]+1):
                newa[j] += 1
        else:
            for j in range(n):
                newa[j] += 1
    return newa

for _ in range(k):
    ad = makea(ad)

for i in ad.values():
    print(i, end=" ")


### FIXED CODE ###

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

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

def IMOS(a):
    imos = [0]*n
    for i, ai in enumerate(a):
        imos[max(i-ai, 0)] += 1
        if i+ai+1 < n:
            imos[i+ai+1] -= 1
    for i in range(1, n):
        imos[i] += imos[i-1]
    return imos

for _ in range(k):
    if sum(a) == n*n:
        break
    a = IMOS(a)

print(*a)
### BUGGY CODE ###

from collections import Counter
n = int(input())
S = Counter()
ans = 0
for _ in range(n):
    s = str(sorted(input()))
    if S[s] > 0:
        ans += S[s]
    S[s] += 1

print(ans)

### FIXED CODE ###

from collections import Counter
n = int(input())
S = Counter()
ans = 0
for _ in range(n):
    s = "".join(sorted(input()))
    if S[s] > 0:
        ans += S[s]
    S[s] += 1

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

N = int(input())
S = list(input())

ans = 0
ans_ = 0
for i in range(len(S)):
  for j in range(len(S)-i-1):
    for k in range(len(S)-i-j-2):
      if j != k and S[i] != S[i+k+1] and S[i] != S[i+k+j+2] and S[i+k+j+2] != S[i+k+1]:
        ans+=1
print(ans)

### FIXED CODE ###

S = input()
S = list(input())
S_len = len(S)
ans = 0
i = 0
for _ in range(S_len):
  if S[0] == 'R':
    ans += S[1:].count('B') * S[1:].count('G')
    for j in range(int(len(S)/2+1)):
      try:
        if S[j+1] != S[j*2+2] and S[j*2+2] !='R' and S[j+1] !='R':
          ans-=1
      except:
        pass
  if S[0] == 'B':
    ans += S[1:].count('R') * S[1:].count('G')
    for j in range(int(len(S)/2+1)):
      try:
        if S[j+1] != S[j*2+2] and S[j*2+2] !='B' and S[j+1] !='B':
          ans-=1
      except:
        pass
  if S[0] == 'G':
    ans += S[1:].count('B') * S[1:].count('R')
    for j in range(int(len(S)/2+1)):
      try:
        if S[j+1] != S[j*2+2] and S[j*2+2] !='G' and S[j+1] !='G':
          ans-=1
      except:
        pass
  S  = S[1:]
print(ans)