Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
s = input()
l, count = [], 0
for i in s:
    if i=='>': count+=1
    else:
        if count: l.append(count)
        count = 0
if count: l.append(count); count = 0
j = 0
ans = []
if s[0]=='<':
    ans.append(0)
    for i in range(len(s)):
    if s[i]=='<': ans.append(ans[-1]+1)
    else:
        if l[j]==0: j+=1
        if ans[-1]>=l[j]:
            l[j]-=1
            ans.append(l[j])
                
        else:
            ans[-1]=l[j]
            l[j]-=1
            ans.append(l[j])
    print(sum(ans))

else:
    ans.append(l[j])
    l[j]-=1
    for i in range(len(s)):
    if s[i]=='<': ans.append(ans[-1]+1)
    else:
        if l[j]==0: j+=1
        if j<len(l):
            
            if ans[-1]>=l[j]:
                ans.append(l[j])
                l[j]-=1
                
                    
            else:
                ans[-1]=l[j]
                ans.append(l[j])
                l[j]-=1
                
        else: ans.append(0)
    print(sum(ans))


Fixed submission:
s = input()
l, count = [], 0
for i in s:
    if i=='>': count+=1
    else:
        if count: l.append(count)
        count = 0
if count: l.append(count); count = 0
j = 0
ans = []
if s[0]=='<': ans.append(0)
else:
    ans.append(l[0])
    l[0]-=1

for i in range(len(s)):
    if s[i]=='<': ans.append(ans[-1]+1)
    else:
        if i==0: ans.append(ans[-1]-1); continue
        if l[j]==0: j+=1
        if ans[-1]>=l[j]:
            l[j]-=1
            ans.append(l[j])
                
        else:
            ans[-1]=l[j]
            l[j]-=1
            ans.append(l[j])
print(sum(ans))

Buggy python submission (verdict: Runtime Error):
'''
    TC_1 : 0<2>1>0 : sum : 3
    TC_2 : 0<2>1>0>1<2<3>0<1<2<3<4<5>2>1>0<1 : sum : 28
'''
s = input()
l, count = [], 0
for i in s:
    if i=='>': count+=1
    else:
        if count: l.append(count)
        count = 0
if count: l.append(count); count = 0
j = 0
ans = []
if s[0]=='<': ans.append(0)
else:
    ans.append(l[j])
    l[j]-=1
for i in range(len(s)):
    if s[i]=='<': ans.append(ans[-1]+1)
    else:
        if l[j]==0: j+=1
        if ans[-1]>=l[j]:
            l[j]-=1
            ans.append(l[j])
                
        else:
            ans[-1]=l[j]
            l[j]-=1
            ans.append(l[j])
print(sum(ans))

Fixed submission:
s = input()
l, count = [], 0
for i in s:
    if i=='>': count+=1
    else:
        if count: l.append(count)
        count = 0
if count: l.append(count); count = 0
j = 0
ans = []
if s[0]=='<': ans.append(0)
else:
    ans.append(l[0])
    l[0]-=1

for i in range(len(s)):
    if s[i]=='<': ans.append(ans[-1]+1)
    else:
        if i==0: ans.append(ans[-1]-1); continue
        if l[j]==0: j+=1
        if ans[-1]>=l[j]:
            l[j]-=1
            ans.append(l[j])
                
        else:
            ans[-1]=l[j]
            l[j]-=1
            ans.append(l[j])
print(sum(ans))
Buggy python submission (verdict: Runtime Error):
s = input()
s1 = set(input())
if len(s1)==2:
  if s.count(list(s1)[0])==2 and s.count(list(s1)[1])==2: print('YES')
  else: print('NO')
else: print('NO')

Fixed submission:
s = input()
s1 = set(s)
if len(s1)==2:
  if s.count(list(s1)[0])==2 and s.count(list(s1)[1])==2: print('Yes')
  else: print('No')
else: print('No')
Buggy python submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
x = list(map(int, input().split()))
ans = 0
for i in range(1, n): ans+=min((x[i+1]-x[i])*a, b)
print(ans)

Fixed submission:
n, a, b = map(int, input().split())
x = list(map(int, input().split()))
ans = 0
for i in range(1, n): ans+=min((x[i]-x[i-1])*a, b)
print(ans)
Buggy python submission (verdict: Runtime Error):
n, r = lambda(int,input().split())
print(r-100*max(0,10-n))

Fixed submission:
n, r = map(int,input().split())
print(r+100*max(0,10-n))
Buggy python submission (verdict: Runtime Error):
s = map(int,input().split())
m = 10000000
for p in s:
  t = 0
  for x in s:
    t+=(x-p)**2
   m = min(t,m)
print(m)
    
  

Fixed submission:
n = input()
s = list(map(int,input().split()))
m = 10000000
for p in range(0,101):
  t = 0
  for x in s:
    t+=(x-p)**2
  m = min(t,m)
print(m)
Buggy python submission (verdict: Runtime Error):
if len(input().split().set())==2:
  print("Yes")
else:
  print("No")

Fixed submission:
if len(set(input().split()))==2:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
print(input().split()[::-1].join())

Fixed submission:
t=input().split()
print(t[1]+t[0])
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!

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

c=0
for m in range(1,M+1):
    for d in range(1,D+1):
        if d>=10:
            t=str(d)
            if int(t[0])>1 and int(t[1])>1 and int(t[0])*int(t[1]) == m:
                c+=1

print(c)

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


Fixed submission:
# coding: utf-8
# Your code here!

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

c=0
for m in range(1,M+1):
    for d in range(1,D+1):
        if d>=10:
            t=str(d)
            if int(t[0])>1 and int(t[1])>1 and int(t[0])*int(t[1]) == m:
                c+=1

print(c)
Buggy python submission (verdict: Runtime Error):
a, b = map(int,input().split())
if (a - b) % 2 == 0:
  print(a-(a-b//2)
else:
  print("IMPOSSIBLE")


Fixed submission:
a, b = map(int,input().split())
if (a - b) % 2 == 0:
  print(a-(a-b)//2)
else:
  print("IMPOSSIBLE")
Buggy python submission (verdict: Runtime Error):
s = input()
t = set(s)
if len(t) == 2 and s.count(list(t[0])) == 2:
  print("Yes")
else:
  print("No")

Fixed submission:
s = input()
t = set(s)
if len(t) == 2 and s.count(list(t)[0]) == 2:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
s = input()
t = set(s)
if len(t) == 2 and s.count(t[0]) == 2:
  print("Yes")
else:
  print("No")

Fixed submission:
s = input()
t = set(s)
if len(t) == 2 and s.count(list(t)[0]) == 2:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
(a,b) = map(int,input().split())
print(max(a,b)+max(max(a,b)-1,min(a,b))

Fixed submission:
(a,b) = map(int,input().split())
print(max(a,b)+max(max(a,b)-1,min(a,b)))
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
return a - b + 1

Fixed submission:
a,b = map(int,input().split())
print(a-b+1)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a = list(map(int, input().split()))

now = a[0]
idx = 0
gabbege = a[idx]
length = 1
for i in range(1, n):
    if length < k:
        length += 1
        now *= a[i]
    else:
        if now < now // gabbege * a[i]:
            print("Yes")
        else:
            print("No")
        now = now // gabbege * a[i]
        idx += 1
        gabbege = a[idx]

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))

now = a[0]
idx = 0
gabbege = a[idx]
length = 1
for i in range(1, n):
    if length < k:
        length += 1
        now += a[i]
    else:
        if now < now - gabbege + a[i]:
            print("Yes")
        else:
            print("No")
        now = now - gabbege + a[i]
        idx += 1
        gabbege = a[idx]
Buggy python submission (verdict: Time Limit Exceeded):
# 全部使え オールオアナッシングや

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


def rec(i, money, stock):
    if i == n:
        return money
    # 有り金全部株に変える
    ret2 = 0
    if money > 0:
        p = money // a[i]
        ret2 = rec(i + 1, money - p * a[i], stock + p)
    # 有り株全部金に変える
    ret3 = 0
    if stock > 0:
        ret3 = rec(i + 1, money + stock * a[i], 0)
    return max(money, ret2, ret3)


print(rec(0, 1000, 0))

Fixed submission:
# まず底をみつけてそのあと山で売るを繰り返す
n = int(input())
arr = list(map(int, input().split()))
arr2 = []
cur = arr[0] if arr[0] < arr[1] else 10**10
f = 1
for i in range(1, n):
    if f == 1:
        # print("底値を求める")
        if cur < arr[i]:
            arr2.append(cur)
            f *= -1
    else:
        # print("天井を求める")
        if cur > arr[i]:
            arr2.append(cur)
            f *= -1
    cur = arr[i]
if f == -1:
    arr2.append(cur)
ans = 1000
stock = 0
for i, a in enumerate(arr2):
    if i % 2 == 0:
        # 買いまくる
        stock = ans // a
        ans %= a
    else:
        # うりまくる
        ans += stock * a
        stock = 0
print(ans)
Buggy python submission (verdict: Runtime Error):
package main
import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main(){
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()
	N, M, K := nextInt(), nextInt(), nextInt()
	A := append([]int{0}, nextInts(N)...)
	B := append([]int{0}, nextInts(M)...)
	for i:=1; i<=N; i++{
		A[i] += A[i-1]
	}
	for i:=1; i<=M; i++{
		B[i] += B[i-1]
	}
	ans := 0
	for i:=0; i<=N; i++{
		rest := K-A[i]
		if rest < 0{
			break
		}
		// golangでupper_boundどうやるんだ？？？？？？・
		/// bidx := max(0, sort.Search(len(B), func(j int)bool{return rest<=B[j]}))
		// bidx := sort.Search(len(B), func(j int)bool{return rest<=B[j]})-1
		// bidx := sort.SearchInts(B, rest)
		// わからんので仕方なく手書き
		left, right := -1, len(B)
		for right - left > 1{
			mid := (left+right)/2
			if rest-B[mid]>=0{
				left = mid
			}else{
				right = mid
			}
		}
		bidx := left
		ans = max(ans, i+bidx)
	}
	fmt.Fprintln(out, ans)
}

func min(a, b int) int {
	if a<b{
		return a
	}
	return b
}

func max(a, b int) int {
	if a<b{
		return b
	}
	return a
}
func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInts(n int) []int{
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func chars(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}


Fixed submission:
n, m, k = map(int, input().split())
a = [0] + list(map(int, input().split()))
b = [0] + list(map(int, input().split()))
for i in range(1, n + 1):
    a[i] += a[i - 1]
for i in range(1, m + 1):
    b[i] += b[i - 1]

ans = 0
for i in range(len(a)):
    rest = k - a[i]
    if rest < 0:
        break
    left, right = -1, len(b)
    while right - left > 1:
        mid = (left + right) // 2
        if rest - b[mid] >= 0:
            left = mid
        else:
            right = mid
    # print(f"{rest}を越えない最大のBiは{b[left]}")
    ans = max(ans, i + left)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
table = [0] * (n + 1)
ans = 0
for i in range(1, n + 1):
    # こいつが地獄のように遅い
    # for v in tes.values():
    #     tmp *= (v + 1)
    # print(i, tmp)
    # 1からnまでの約数の個数を数えるズバリのやつがあるらしい エラトステネスを使ってるらしい
    # http://sucrose.hatenablog.com/entry/2016/11/06/234635
    for j in range(i, n + 1, i):
        table[j] += 1
for i in range(1, n + 1):
    ans += i * table[i]
print(ans)


Fixed submission:
n = int(input())
table = [0] * (n + 1)
ans = 0
for i in range(1, n + 1):
    # こいつが地獄のように遅い
    # for v in tes.values():
    #     tmp *= (v + 1)
    # print(i, tmp)
    # 1からnまでの約数の個数を数えるズバリのやつがあるらしい エラトステネスを使ってるらしい
    # http://sucrose.hatenablog.com/entry/2016/11/06/234635
    for j in range(i, n + 1, i):
        table[j] += 1
for i in range(1, n + 1):
    ans += i * table[i]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# 問題文の意味がわからんコンテスト
# 0の場合も自分自身を照らす、っての気づくところからやっと読解
# Kを5000兆回やったあとはすべての要素がNになっとる この収束はわりと早いらしい
n, k = map(int, input().split())
a = list(map(int, input().split()))

for _ in range(k):
    b = [0] * (n + 1)
    for i in range(n):
        b[max(0, i - a[i])] += 1
        b[min(n, i + a[i] + 1)] -= 1
    for i in range(n):
        b[i + 1] += b[i]
    a = b[:n]
    if b[-1] == n:
        break
print(" ".join(list(map(str, a))))

Fixed submission:
# 問題文の意味がわからんコンテスト
# 0の場合も自分自身を照らす、っての気づくところからやっと読解
# Kを5000兆回やったあとはすべての要素がNになっとる この収束はわりと早いらしい
n, k = map(int, input().split())
a = list(map(int, input().split()))

for _ in range(min(k, 100)):
    b = [0] * (n + 1)
    for i in range(n):
        b[max(0, i - a[i])] += 1
        b[min(n, i + a[i] + 1)] -= 1
    for i in range(n):
        b[i + 1] += b[i]
    a = b[:n]
print(" ".join(list(map(str, a))))

Buggy python submission (verdict: Time Limit Exceeded):
# 問題文の意味がわからんコンテスト
# 0の場合も自分自身を照らす、っての気づくところからやっと読解
# Kを5000兆回やったあとはすべての要素がNになっとる この収束はわりと早いらしい
n, k = map(int, input().split())
a = list(map(int, input().split()))

for _ in range(k):
    b = [0] * (n + 1)
    for i in range(n):
        b[max(0, i - a[i])] += 1
        b[min(n, i + a[i] + 1)] -= 1
    for i in range(n):
        b[i + 1] += b[i]
    a = b[:n]
    if b[-1] == n:
        break
print(" ".join(list(map(str, a))))


Fixed submission:
# 問題文の意味がわからんコンテスト
# 0の場合も自分自身を照らす、っての気づくところからやっと読解
# Kを5000兆回やったあとはすべての要素がNになっとる この収束はわりと早いらしい
n, k = map(int, input().split())
a = list(map(int, input().split()))

for _ in range(min(k, 100)):
    b = [0] * (n + 1)
    for i in range(n):
        b[max(0, i - a[i])] += 1
        b[min(n, i + a[i] + 1)] -= 1
    for i in range(n):
        b[i + 1] += b[i]
    a = b[:n]
print(" ".join(list(map(str, a))))
Buggy python submission (verdict: Runtime Error):
# 暴力即可
# 範囲指定 A=100 B=-100で20000000000とかになるしどっちも|100|程度でいいのではないか
x = int(input())
for a in range(-100, 101):
    for b in range(-100, 101):
        if a**5 - b**5 == x:
            print(a, b)
            exit()
print(3 / 0)  # はい


Fixed submission:
# 暴力即可
# 範囲指定 A=100 B=-100で20000000000とかになるしどっちも|100|程度でいいのではないか
# なんか足りんみたい（なんで？）なので4X^2<=10^9なる最大のXを求めよう
# 2X = 1000ちょい だから500くらいあればいいのか
# 1000^2なので時間的には間に合いそう
x = int(input())
for a in range(-500, 501):
    for b in range(-500, 501):
        if a**5 - b**5 == x:
            print(a, b)
            exit()
print(3 / 0)  # はい

Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())

# x^5−y^5=(x−y)(x^4+x3^y+x^2y^2+xy^3+y^4)
# x-yをみつける x-y = d[i]
# と思ったができない
# ひょっとして総当りで間に合うのでは

for i in range(x):
    tmpx = i
    tmpy = i**5 - x
    if isinstance(tmpy, int) and tmpx**5 - tmpy**5 == x:
        print(tmpx, tmpy)
        exit()
print(0 / 0)


Fixed submission:
# 暴力即可
# 範囲指定 A=100 B=-100で20000000000とかになるしどっちも|100|程度でいいのではないか
# なんか足りんみたい（なんで？）なので4X^2<=10^9なる最大のXを求めよう
# 2X = 1000ちょい だから500くらいあればいいのか
# 1000^2なので時間的には間に合いそう
x = int(input())
for a in range(-500, 501):
    for b in range(-500, 501):
        if a**5 - b**5 == x:
            print(a, b)
            exit()
print(3 / 0)  # はい
Buggy python submission (verdict: Time Limit Exceeded):
# 先頭と末尾を保ちつつ
s = input()
q = int(input())
x, y = [], []
r = 0
for _ in range(q):
    query = input().split()
    if query[0] == "1":
        r += 1
        # これ遅いか？
        x, y = y[::-1], x[::-1]
    elif query[0] == "2":
        f, c = query[1], query[2]
        if f == "1":
            # x.append(c)
            x = x[::-1]
            x.append(c)
            x = x[::-1]
        elif f == "2":
            y.append(c)
if r % 2 == 1:
    s = s[::-1]
print("".join(x) + s + "".join(y))


Fixed submission:
# 先頭と末尾を保ちつつ
from collections import deque

s = input()
q = int(input())
x, y = deque(), deque()
r = 0
for _ in range(q):
    query = input().split()
    if query[0] == "1":
        r += 1
        x, y = y, x
    elif query[0] == "2":
        f, c = query[1], query[2]
        if f == "1":
            if r % 2 == 0:
                x.appendleft(c)
            else:
                x.append(c)
        elif f == "2":
            if r % 2 == 1:
                y.appendleft(c)
            else:
                y.append(c)

if r % 2 == 1:
    s = s[::-1]
    x = reversed(x)
    y = reversed(y)
print("".join(x) + s + "".join(y))
Buggy python submission (verdict: Runtime Error):
41 7 46
26 89 2
78 92 8
5
6
45
16
57
17


Fixed submission:
bingo = []
for i in range(3):
    bingo.append(list(map(int, input().split())))

n = int(input())
for _ in range(n):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if bingo[i][j] == b:
                bingo[i][j] = "o"

for i in range(3):
    flag = 0
    for j in range(3):
        if bingo[i][j] == "o":
            flag += 1
    if flag == 3:
        print("Yes")
        exit()
    flag = 0
    for j in range(3):
        if bingo[j][i] == "o":
            flag += 1
    if flag == 3:
        print("Yes")
        exit()
# 斜め
if (
    bingo[0][0] == bingo[1][1] == bingo[2][2] == "o"
    or bingo[0][2] == bingo[1][1] == bingo[2][0] == "o"
):
    print("Yes")
    exit()
print("No")
Buggy python submission (verdict: Runtime Error):
# 同じ木に属する(==そこまでたどりつけるかどうか）の判定にunionfind
# 同じ木に属しているノードはあとで数えることができる（そうだね）
# 除外するやつが出てくる。直の友達+ブロック関係にあるやつ（と自分）
# 同じ木に属しているノードの総数 - (直の友達+ブロック関係+自分自身)が答え
n, m, k = map(int, input().split())
par = [i for i in range(n)]
ans = [0 for _ in range(n)]


def root(x):
    if x == par[x]:
        return x
    y = root(par[x])
    par[x] = y
    return y


def union(x, y):
    if x > y:
        x, y = y, x
    rx, ry = root(x), root(y)
    if rx != ry:
        par[ry] = rx


friends = [[] for _ in range(n)]
blocks = [[] for _ in range(n)]

for _ in range(m):
    a, b = map(int, input().split())
    union(a - 1, b - 1)
    friends[a - 1].append(b - 1)
    friends[b - 1].append(a - 1)
for _ in range(k):
    c, d = map(int, input().split())
    blocks[c - 1].append(d - 1)
    blocks[d - 1].append(c - 1)

# 木に属しているやつを数えるぜ
group_count = [0 for _ in range(n)]
for i in range(n):
    group_count[root(i)] += 1
# 答えを作るぜ
for i in range(n):
    # 初期化（じゃないけど）
    ans[i] += group_count[root(i)]
    # 直の友達を除く
    ans[i] -= len(friends[i])
    # ブロックしてるやつを除く
    for b in blocks[i]:
        ra, rb = root(i), root(b)
        if ra == rb:
            ans[i] -= 1
    # 自分自身を除く
    ans[i] -= 1
print(" ".join(list(map(str, ans))))


Fixed submission:
 # 同じ木に属する(==そこまでたどりつけるかどうか）の判定にunionfind
# 同じ木に属しているノードはあとで数えることができる（そうだね）
# 除外するやつが出てくる。直の友達+ブロック関係にあるやつ（と自分）
# 同じ木に属しているノードの総数 - (直の友達+ブロック関係+自分自身)が答え
from sys import setrecursionlimit
setrecursionlimit(10**8)
n, m, k = map(int, input().split())
par = [i for i in range(n)]
ans = [0 for _ in range(n)]


def root(x):
    if x == par[x]:
        return x
    y = root(par[x])
    par[x] = y
    return y


def union(x, y):
    if x > y:
        x, y = y, x
    rx, ry = root(x), root(y)
    if rx != ry:
        par[ry] = rx


friends = [[] for _ in range(n)]
blocks = [[] for _ in range(n)]

for _ in range(m):
    a, b = map(int, input().split())
    union(a - 1, b - 1)
    friends[a - 1].append(b - 1)
    friends[b - 1].append(a - 1)
for _ in range(k):
    c, d = map(int, input().split())
    blocks[c - 1].append(d - 1)
    blocks[d - 1].append(c - 1)

# 木に属しているやつを数えるぜ
group_count = [0 for _ in range(n)]
for i in range(n):
    group_count[root(i)] += 1
# 答えを作るぜ
for i in range(n):
    # 初期化（じゃないけど）
    ans[i] += group_count[root(i)]
    # 直の友達を除く
    ans[i] -= len(friends[i])
    # ブロックしてるやつを除く
    for b in blocks[i]:
        ra, rb = root(i), root(b)
        if ra == rb:
            ans[i] -= 1
    # 自分自身を除く
    ans[i] -= 1
print(" ".join(list(map(str, ans))))
Buggy python submission (verdict: Runtime Error):
# きりみんちゃんの配信をみてたので期待値は分かる
# 素直にTLEくらったので累積和で加減する
# え これでもだめなの
# あほだった sumしてるし
# 単純にみたら 0.5ずつ増えてるのでそうするか
# 1WA...
# N = 1の場合か？


n, k = map(int, input().split())
arr = list(map(int, input().split()))
table = {}
ans = 0
for i in range(1, 1000 + 1):
    table[i] = (i + 1) * 0.5
if n == 1:
    print(etable[arr[0]])
    exit()
lis = [0 for _ in range(n)]
lis[0] = table[arr[0]]
for i in range(n - 1):
    if i + 1 < k:
        lis[i + 1] = lis[i] + table[arr[i + 1]]
    else:
        lis[i + 1] = lis[i] + table[arr[i + 1]] - table[arr[i - k + 1]]
    ans = max(ans, lis[i + 1])
print(ans)


Fixed submission:
# きりみんちゃんの配信をみてたので期待値は分かる
# 素直にTLEくらったので累積和で加減する
# え これでもだめなの
# あほだった sumしてるし
# 単純にみたら 0.5ずつ増えてるのでそうするか
# 1WA...
# N = 1の場合か？


n, k = map(int, input().split())
arr = list(map(int, input().split()))
table = {}
ans = 0
for i in range(1, 1000 + 1):
    table[i] = (i + 1) * 0.5
if n == 1:
    print(table[arr[0]])
    exit()
lis = [0 for _ in range(n)]
lis[0] = table[arr[0]]
for i in range(n - 1):
    if i + 1 < k:
        lis[i + 1] = lis[i] + table[arr[i + 1]]
    else:
        lis[i + 1] = lis[i] + table[arr[i + 1]] - table[arr[i - k + 1]]
    ans = max(ans, lis[i + 1])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# きりみんちゃんの配信をみてたので期待値は分かる
n, k = map(int, input().split())
arr = list(map(int, input().split()))
lis = [0 for _ in range(n)]
for i in range(n):
    lis[i] = sum(list(range(1, arr[i] + 1))) / arr[i]
ans = 0
for i in range(0, n - k + 1):
    ans = max(ans, sum(lis[i : i + k]))
print(ans)


Fixed submission:
# きりみんちゃんの配信をみてたので期待値は分かる
# 素直にTLEくらったので累積和で加減する
# え これでもだめなの
# あほだった sumしてるし
# 単純にみたら 0.5ずつ増えてるのでそうするか
# 1WA...
# N = 1の場合か？


n, k = map(int, input().split())
arr = list(map(int, input().split()))
table = {}
ans = 0
for i in range(1, 1000 + 1):
    table[i] = (i + 1) * 0.5
if n == 1:
    print(table[arr[0]])
    exit()
lis = [0 for _ in range(n)]
lis[0] = table[arr[0]]
for i in range(n - 1):
    if i + 1 < k:
        lis[i + 1] = lis[i] + table[arr[i + 1]]
    else:
        lis[i + 1] = lis[i] + table[arr[i + 1]] - table[arr[i - k + 1]]
    ans = max(ans, lis[i + 1])
print(ans)
Buggy python submission (verdict: Runtime Error):
n, k, s = map(int, input().split())
if k == n:
    print(" ".join([str(s) for _ in range(n)]))
    exit()
x = 0
arr = [1]
while True:
    if x == k:
        break
    arr.append(s - arr[-1])
    print(arr, x)
    x += 1
print(arr)
while len(arr) < n:
    arr.append(10 ** 9)

print(" ".join(list(map(str, arr))))


Fixed submission:
n, k, s = map(int, input().split())
if k == n:
    print(" ".join([str(s) for _ in range(n)]))
    exit()

arr = []
for i in range(1, n + 1):
    if i <= k:
        arr.append(s)
    else:
        arr.append(8 ** 9 + 14499)  # テキトー
print(" ".join(list(map(str, arr))))
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
table = {}
ac = 0
pena_arr = [0 for _ in range(m + 1)]
for _ in range(n):
    a, b = input().split()
    a = int(a)
    if a not in table and b == "AC":
        ac += 1
        table[a] = True
    elif a not in table and b == "WA":
        pena_arr[a] += 1
pena = 0
for i in range(1, m + 1):
    if pena_arr[i] > 0 and i in table:
        pena += pena_arr[i]
print(ac, pena)


Fixed submission:
n, m = map(int, input().split())
table = {}
ac = 0
pena = 0
pena_arr = [0 for _ in range(n + 1)]
for _ in range(m):
    a, b = input().split()
    a = int(a)
    if a in table:
        continue
    if b == "AC":
        ac += 1
        table[a] = True
    elif b == "WA":
        pena_arr[a] += 1
pena = 0
for i in range(1, n + 1):
    if pena_arr[i] > 0 and i in table:
        pena += pena_arr[i]
print(ac, pena)

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
table = {}
ac = 0
pena_arr = [0 for _ in range(m + 1)]
for _ in range(m):
    a, b = input().split()
    a = int(a)
    if a not in table and b == "AC":
        ac += 1
        table[a] = True
    elif a not in table and b == "WA":
        pena_arr[a] += 1
pena = 0
for i in range(1, m + 1):
    if pena_arr[i] > 0 and i in table:
        pena += pena_arr[i]
print(ac, pena)


Fixed submission:
n, m = map(int, input().split())
table = {}
ac = 0
pena = 0
pena_arr = [0 for _ in range(n + 1)]
for _ in range(m):
    a, b = input().split()
    a = int(a)
    if a in table:
        continue
    if b == "AC":
        ac += 1
        table[a] = True
    elif b == "WA":
        pena_arr[a] += 1
pena = 0
for i in range(1, n + 1):
    if pena_arr[i] > 0 and i in table:
        pena += pena_arr[i]
print(ac, pena)
Buggy python submission (verdict: Runtime Error):
# このくらい10秒で実装しろ。。。
 n, a, b = map(int, input().split())

if (b - a) % 2 == 0:
    print(b - (a + b) // 2)
else:
    print(max(n - a - 1, b - 1))



Fixed submission:
n, a, b = map(int, input().split())

if (b - a) % 2 == 0:
    print(b - (a + b) // 2)
else:
    # 折り返して会いにいく
    ans = 0
    if a - 1 < n - b:
        ans = a
        a, b = 1, b - a
    else:
        ans = n - b + 1
        a, b = a + (n - b) + 1, n
    print(b - (a + b) // 2 + ans)