Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial
from bisect import bisect_left #bisect_left(list, value)
#from fractions import gcd
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

N = int(input())
INF = 10**18

res = 0
dp = [INF]*(2*N)
dp[0] = 0
for i in range(0, N+1):
    dp[i+1] = min(dp[i+1], dp[i]+1)

    j = 1
    while i+(6**j) <= N:
        dp[i+(6**j)] = min(dp[i+(6**j)], dp[i] + 1)
        j += 1

    l = 1
    while i+(9**l) <= N:
        dp[i+(9**l)] = min(dp[i+9**l], dp[i] + 1)
        l += 1

print(dp[N])




Fixed submission:
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial
from bisect import bisect_left #bisect_left(list, value)
#from fractions import gcd
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

N = int(input())
INF = 10**18

res = 0
dp = [INF]*(10*N)
dp[0] = 0
for i in range(0, N):
    dp[i+1] = min(dp[i+1], dp[i]+1)

    j = 1
    while i+6**j <= N:
        dp[i+6**j] = min(dp[i+6**j], dp[i]+1)
        j += 1

    l = 1
    while i+9**l <= N:
        dp[i+9**l] = min(dp[i+9**l], dp[i]+1)
        l += 1

print(dp[N])
Buggy python submission (verdict: Runtime Error):
# import numpy as np
import sys, math, heapq
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial, gcd
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep="\n")
# conv_matrix = lambda l: ["".join(l[i : i + 100]) for i in range(0, len(l), 100)]
A, B = map(int, input().split())

mat = [["."] * 10 for _ in range(5)] + [["#"] * 10 for _ in range(5)]
# for mati in mat:
#     print("".join(mati))

# mat[0][3] = "#"
# mat[3][6] = "#"
# for mati in mat:
#     print("".join(mati))
# exit()

black_count = 1
white_count = 1

for i in range(0, 50, 2):
    if black_count == B:
        break
    for j in range(0, 100, 2):
        if black_count == B:
            break
        mat[i][j] = "#"
        black_count += 1
for i in range(1, 50, 2):
    if white_count == A:
        break
    for j in range(0, 100, 2):
        if white_count == A:
            break
        mat[-i][j] = "."
        white_count += 1

for mati in mat:
    print("".join(mati))


Fixed submission:
# import numpy as np
import sys, math, heapq
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial, gcd
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep="\n")
# conv_matrix = lambda l: ["".join(l[i : i + 100]) for i in range(0, len(l), 100)]
A, B = map(int, input().split())

mat = [["."] * 100 for _ in range(50)] + [["#"] * 100 for _ in range(50)]
# for mati in mat:
#     print("".join(mati))

# mat[0][3] = "#"
# mat[3][6] = "#"
# for mati in mat:
#     print("".join(mati))
# exit()

black_count = 1
white_count = 1

for i in range(0, 50, 2):
    if black_count == B:
        break
    for j in range(0, 100, 2):
        if black_count == B:
            break
        mat[i][j] = "#"
        black_count += 1
for i in range(1, 50, 2):
    if white_count == A:
        break
    for j in range(0, 100, 2):
        if white_count == A:
            break
        mat[-i][j] = "."
        white_count += 1

print(100, 100)
for mati in mat:
    print("".join(mati))
Buggy python submission (verdict: Runtime Error):
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left, bisect_right #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

N = int(input())
txy = [list(map(int, input().split())) for _ in range(N)]

for txyi, txyip in zip([[0, 0, 0]] + txy[:-1], txy):
    ti, xi, yi = txyi
    tip, xip, yip = txyip
    dift = tip - ti
    difd = abs(xip-xi) + abs(yip-yi)
    if difd%2 != dfit%2:
        print('No')
        exit()
    if dift < difd:
        print('No')
        exit()
print('Yes')



Fixed submission:
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left, bisect_right #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

N = int(input())
txy = [list(map(int, input().split())) for _ in range(N)]

for txyi, txyip in zip([[0, 0, 0]] + txy[:-1], txy):
    ti, xi, yi = txyi
    tip, xip, yip = txyip
    dift = tip - ti
    difd = abs(xip-xi) + abs(yip-yi)
    if difd%2 != dift%2:
        print('No')
        exit()
    if dift < difd:
        print('No')
        exit()
print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
import bisect

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

A.sort()
B.sort()
C.sort()

lenC = len(C)
cnt = 0

for a in A:
    for b in B:
        if a >= b: continue

        ii = bisect.bisect_right(C, b)
        cnt += lenC - ii

print(cnt)

Fixed submission:
import bisect

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

A.sort()
B.sort()
C.sort()

lenC = len(C)

cnt = 0

for b in B:
    ind_a = bisect.bisect_left(A, b)
    ind_c = bisect.bisect_right(C, b)
    cnt += ind_a * (lenC - ind_c)

print(cnt)
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
answer=0
for n in range(N-1):
    if A[n]>A[n+1]:
        sa=A[n]-A[n+1]
        answer+=sa
        A[n+1]=A[n]
if A[-2]>A[-1]:
    answer+=A[-2]-A[-1]
print(answer)


Fixed submission:
N=int(input())
A=list(map(int,input().split()))
answer=0
if N==1:
    print(0)
else:
    for n in range(N - 1):
        if A[n] > A[n + 1]:
            sa = A[n] - A[n + 1]
            answer += sa
            A[n + 1] = A[n]
    if A[-2] > A[-1]:
        answer += A[-2] - A[-1]
    print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
a=input().split()
A=[int(b) for b in a]

numbers=[]

for n in range(N-K+1):
    suuji=A[n:n+K]
    answer=1
    for k in suuji:
        answer*=k
    numbers.append(answer)

for k in range(N-K):
    if numbers[k]<numbers[k+1]:
        print('Yes')
    else:
        print('No')
        

Fixed submission:
N,K=map(int,input().split())
a=input().split()
A=[int(b) for b in a]

for k in range(N-K):
    if A[k]<A[k+K]:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
for n in range(1,N+1):
    a=n/6

    saidai=int(a**0.5)+20
    answer=0
    for z in range(1,saidai+1):
        if 3+z**2+2*z>n:
            break
        for y in range(1,z+1):
            if y**2+z**2+1+y+z+y*z>n:
                break
            for x in range(1,y+1):
                if x**2+y**2+z**2+x*y+y*z+z*x==n:
                    if x==y==z:
                        answer+=1
                        break
                    elif x==y or y==z or z==x:
                        answer+=3
                        break
                    else:
                        answer+=6
                        break
    print(answer)


Fixed submission:
import math
N=int(input())
for n in range(1,N+1):
    saidai=math.floor((abs(n-2))**0.5)
    saishou=math.ceil((n//6)**0.5)
    answer=0
    for z in range(saishou,saidai+1):
        if 3+z**2+2*z>n:
            break
        for y in range(1,z+1):
            if y**2+z**2+1+y+z+y*z>n:
                break
            for x in range(1,y+1):
                if x**2+y**2+z**2+x*y+y*z+z*x>n:
                    break

                if x**2+y**2+z**2+x*y+y*z+z*x==n:
                    if x==y==z:
                        answer+=1
                        break
                    elif x==y or y==z or z==x:
                        answer+=3
                        break
                    else:
                        answer+=6
                        break
    print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
D=int(input())
c=input().split()
c=[int(a) for a in c]
S=[]
for _ in range(D):
    s=input().split()
    s=[int(a) for a in s]
    S.append(s)
T=[]
for _ in range(D):
    t=int(input())-1
    T.append(t)
M=int(input())
numbers=[]
for _ in range(M):
    d,q=map(int,input().split())
    numbers.append([d,q])
for m in range(M):
    ans = 0
    held = [0 for _ in range(26)]
    e=numbers[m][0]-1
    q=numbers[m][1]-1
    a=T[e]
    T[e]=q
    for d in range(D):
        s = S[d]
        place = T[d]
        held[place] = d + 1
        ans += s[place]
        for n in range(26):
            ans -= c[n] * (d + 1 - held[n])
    print(ans)


Fixed submission:
D=int(input())
c=input().split()
c=[int(a) for a in c]
S=[]
for _ in range(D):
    s=input().split()
    s=[int(a) for a in s]
    S.append(s)
T=[]
for _ in range(D):
    t=int(input())-1
    T.append(t)
M=int(input())
numbers=[]
for _ in range(M):
    d,q=map(int,input().split())
    numbers.append([d,q])
whole=sum(c)
for m in range(M):
    ans = 0
    held = [0 for _ in range(26)]
    e=numbers[m][0]-1
    q=numbers[m][1]-1
    a=T[e]
    T[e]=q
    wholes=0
    for d in range(D):
        s = S[d]
        place = T[d]
        ans += s[place]
        wholes+=whole
        wholes-=c[place]*((d+1)-held[place])
        held[place] = d + 1
        ans-=wholes
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,M,K=map(int,input().split())
a=input().split()
A=[int(c) for c in a]
b=input().split()
B=[int(c) for c in b]
answers=[0]
As=[0]
Bs=[0]
wholeA=0
wholeB=0
for a in range(N):
    wholeA+=A[a]
    As.append(wholeA)
for b in range(M):
    wholeB+=B[b]
    Bs.append(wholeB)

for a in range(N+1):
    for b in range(M+1):
        whole = As[a]
        whole+=Bs[b]
        if whole>K:
            break
        else:
            answers.append(a+b)

print(max(answers))


Fixed submission:
N,M,K=map(int,input().split())
a=input().split()
A=[int(c) for c in a]
b=input().split()
B=[int(c) for c in b]
answers=[0]
As=[0]
Bs=[0]
wholeA=0
wholeB=0
bs = [M]
for a in range(N):
    wholeA+=A[a]
    As.append(wholeA)
for b in range(M):
    wholeB+=B[b]
    Bs.append(wholeB)
for a in range(N+1):
    for b in range(bs[-1],-1,-1):
        whole = As[a]
        whole+=Bs[b]
        if whole<=K:
            answers.append(a+b)
            bs.append(b)
            break
print(max(answers))
Buggy python submission (verdict: Runtime Error):
import math
N=int(input())
n=1
while True:
    if N <= 26**n:
        break
    n+=1
c=N
for n_ in range(1,n):
    c-=26**n_

a=[chr(i) for i in range(97, 97+26)]
# [chr(i) for i in range(ord('a'), ord('z')+1)]

answers=[]
while N>=26:
    b=N%26
    answers.append(a[b-1])
    N=N//26

answers.append(a[b-1])
answers.reverse()
b=''
for a in answers:
    b+=a
print(b)


Fixed submission:
import math
N=int(input())

a=[chr(i) for i in range(97, 97+26)]
# [chr(i) for i in range(ord('a'), ord('z')+1)]
if N>26:
    answers = []
    while N > 0:
        N-=1
        b = N % 26
        answers.append(a[b ])
        N = N // 26

    answers.reverse()
    b = ''
    for a in answers:
        b += a
    print(b)
else:
    print(a[N-1])
Buggy python submission (verdict: Runtime Error):
A,B,C,K=map(int,input().split())
a=[1]*A
b=[0]*B
c=[-1]*C
S=a+b+c
T=S[:K]
print(sum(T))


Fixed submission:
A,B,C,K=map(int,input().split())
if A+B>=K:
    if A<=K:
        print(A)
    else:
        print(K)
else:
    print(A*2-K+B)
Buggy python submission (verdict: Runtime Error):
import math
X=int(input())
c=math.ceil(X**0.2)
answers=[]
for a in range(-c,c+1):
    for b in range(-c,c+1):
        if a**5-b**5==X:
            answers.append(a)
            answers.append(b)
            break
print(answers[0],answers[1])


Fixed submission:
import math
X=int(input())
a=pow(10,9)
c=math.ceil(a**0.3)
answers=[]
for a in range(-c,c+1):
    for b in range(-c,c+1):
        if pow(a,5)-pow(b,5)==X:
            answers.append(a)
            answers.append(b)
            break
print(answers[0],answers[1])

Buggy python submission (verdict: Runtime Error):
import math
X=int(input())
answers=[]
for a in range(-math.ceil(X**0.2),math.ceil(X**0.2)+1):
    for b in range(-math.ceil(X**0.2),math.ceil(X**0.2)+1):
        if a**5-b**5==X:
            answers.append(a)
            answers.append(b)
            break
print(answers[0],answers[1])


Fixed submission:
import math
X=int(input())
a=pow(10,9)
c=math.ceil(a**0.3)
answers=[]
for a in range(-c,c+1):
    for b in range(-c,c+1):
        if pow(a,5)-pow(b,5)==X:
            answers.append(a)
            answers.append(b)
            break
print(answers[0],answers[1])

Buggy python submission (verdict: Runtime Error):
import math
X=int(input())
answers=[]
for a in range(-math.ceil(X**0.2),math.ceil(X**0.2)+1):
    for b in range(-math.ceil(X**0.2),math.ceil(X**0.2)+1):
        if a**5-b**5==X:
            answers.append([a,b])
print(answers[0][0],answers[0][1])


Fixed submission:
import math
X=int(input())
a=pow(10,9)
c=math.ceil(a**0.3)
answers=[]
for a in range(-c,c+1):
    for b in range(-c,c+1):
        if pow(a,5)-pow(b,5)==X:
            answers.append(a)
            answers.append(b)
            break
print(answers[0],answers[1])

Buggy python submission (verdict: Runtime Error):
import math
answers=[]
X=int(input())
for a in range(-math.ceil(X**0.2),math.ceil(X**0.2)+1):
    for b in range(-math.ceil(X**0.2),math.ceil(X**0.2)+1):
        if a**5-b**5==X:
            answers.append([a,b])
print(answers[0][0],answers[0][1])


Fixed submission:
import math
X=int(input())
a=pow(10,9)
c=math.ceil(a**0.3)
answers=[]
for a in range(-c,c+1):
    for b in range(-c,c+1):
        if pow(a,5)-pow(b,5)==X:
            answers.append(a)
            answers.append(b)
            break
print(answers[0],answers[1])
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
a=input().split()
A=[int(number) for number in a]
pluss=[]
minuss=[]
number=1
for a in A:
    plus=a+number
    minus=number-a
    pluss.append(plus)
    minuss.append(minus)
    number+=1
answer=0
suuji=0
for n in pluss:
    answers=minuss[suuji:]
    answer+=answers.count(n)
    suuji+=1


print(answer)



Fixed submission:
import collections
from collections import Counter
N=int(input())
a=input().split()
A=[int(number) for number in a]
pluss=[]
minuss=[]
number=1
for a in A:
    plus=a+number
    minus=number-a
    pluss.append(plus)
    minuss.append(minus)
    number+=1

m=Counter(minuss)

answer=0
for p in pluss:
    if p in m.keys():
        answer+=m[p]
print(answer)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
a=input().split()
A=[int(number) for number in a]
answer=0
for n in range(N):
    target=A[n]
    plus = n+target
    if plus <=N-1:
        for o in range(plus,N):
            if target + A[o] == o - n:
                answer+=1
print(answer)


Fixed submission:
import collections
from collections import Counter
N=int(input())
a=input().split()
A=[int(number) for number in a]
pluss=[]
minuss=[]
number=1
for a in A:
    plus=a+number
    minus=number-a
    pluss.append(plus)
    minuss.append(minus)
    number+=1

m=Counter(minuss)

answer=0
for p in pluss:
    if p in m.keys():
        answer+=m[p]
print(answer)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
a=input().split()
A=[int(number) for number in a]
answer=0
for n in range(N):
    target=A[n]
    plus = n+target
    if plus <=N-1:
        for o in range(plus,N):
            if target + A[o] == o - n:
                answer+=1
print(answer)


Fixed submission:
import collections
from collections import Counter
N=int(input())
a=input().split()
A=[int(number) for number in a]
pluss=[]
minuss=[]
number=1
for a in A:
    plus=a+number
    minus=number-a
    pluss.append(plus)
    minuss.append(minus)
    number+=1

m=Counter(minuss)

answer=0
for p in pluss:
    if p in m.keys():
        answer+=m[p]
print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=input()
SS=[a for a in S]
SS.insert(0,0)
answer=0
for i in range(1,N-1):
    for j in range(i+1,N+1):
        if SS[i]==SS[j]:
            continue
        for k in range(j+1,N+1):
            if i+k==j*2:
                continue
            else:
                if SS[i]!=SS[j] and SS[j]!=SS[k] and SS[k]!=SS[i]:
                    answer+=1
print(answer)


Fixed submission:
N=int(input())
S=input()
SS=[a for a in S]
SS.insert(0,0)
nr=S.count("R")
ng=S.count("G")
nb=S.count("B")
n=0
for i in range(1,N-1):
    for j in range(i+1,N):
        k=j*2-i
        if k<=N :
            if SS[i]!=SS[j] and SS[j]!=SS[k] and SS[k]!=SS[i]:
                n+=1
answer=nr*ng*nb-n
print(answer)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=input()
SS=[a for a in S]
SS.insert(0,0)
answer=0
for i in range(1,N+1):
    for j in range(i+1,N+1):
        for k in range(j+1,N+1):
            if i+k==j*2:
                continue
            else:
                if SS[i]!=SS[j] and SS[j]!=SS[k] and SS[k]!=SS[i]:
                    answer+=1
print(answer)


Fixed submission:
N=int(input())
S=input()
SS=[a for a in S]
SS.insert(0,0)
nr=S.count("R")
ng=S.count("G")
nb=S.count("B")
n=0
for i in range(1,N-1):
    for j in range(i+1,N):
        k=j*2-i
        if k<=N :
            if SS[i]!=SS[j] and SS[j]!=SS[k] and SS[k]!=SS[i]:
                n+=1
answer=nr*ng*nb-n
print(answer)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=input()
SS=[a for a in S]
SS.insert(0,0)
answer=0
for i in range(1,N+1):
    for j in range(i+1,N+1):
        for k in range(j+1,N+1):
            if i+k==j*2:
                continue
            else:
                if SS[i]!=SS[j] and SS[j]!=SS[k] and SS[k]!=SS[i]:
                    answer+=1
print(answer)


Fixed submission:
N=int(input())
S=input()
SS=[a for a in S]
SS.insert(0,0)
nr=S.count("R")
ng=S.count("G")
nb=S.count("B")
n=0
for i in range(1,N-1):
    for j in range(i+1,N):
        k=j*2-i
        if k<=N :
            if SS[i]!=SS[j] and SS[j]!=SS[k] and SS[k]!=SS[i]:
                n+=1
answer=nr*ng*nb-n
print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
N,X,Y=map(int,input().split())
answers=[0]*(N-1)
for i in range(1,N+1):
    numbers=[a for a in range(1,N+1) if a!=i]
    for j in numbers:
        answer=min(abs(i-j),abs(X-i)+1+abs(j-Y),abs(i-Y)+1+abs(j-X))
        answers[answer-1]+=1
for a in answers:
    print(a//2)
    

Fixed submission:
N,X,Y=map(int,input().split())
answers=[0]*(N-1)
for i in range(1,N+1):
    numbers=[a for a in range(1,N+1) if a!=i]
    for j in numbers:
        answer=min(abs(i-j),abs(X-i)+1+abs(j-Y),abs(i-Y)+1+abs(j-X))
        answers[answer-1]+=1
for a in answers:
    print(a//2)
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
numbers=[' ',]*N
kotae=0
for a in range(M):
    suuji=[]
    s,c=input().split()
    if numbers[int(s)-1]==' ':
        numbers[int(s)-1]=c
    else:
        if numbers[int(s)-1]==c:
            continue
        else:
            print('-1')
            kotae+=1
            break

for a in range(3):
    if numbers[a]==' ':
        numbers[a]=0
if numbers[0]==0:
    del numbers[0]
    if numbers[0]==0:
        del numbers[0]
        if numbers[0]==0:
            del numbers[0]
if kotae==0:
    if len(numbers)!=N:
        print('-1')
    else:
       moji=''
       for a in numbers:
           moji+=str(a)
       print(int(moji))


Fixed submission:
N=int(input())

print(-(-N//2))
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=input().split()
S=[int(a) for a in A]
n=0
NN=[]
for b in S:
    if not b in NN:
        NN.append(b)
if len(NN)==N:
    print('YES')
else:
    print('NO')
    

Fixed submission:
import collections
N=int(input())
A=input().split()
c = collections.Counter(A)
if N==len(c):
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
p=input().split()
P=[int(z) for z in p]
hopes=[(1+a)/2 for a in P]
def goukei(i):
    return sum(hopes[:i+1])
numbers=[]
for a in range(N):
    numbers.append(goukei(a))
answers=[]
for a in range(N-K):
    i=numbers[a+K]-numbers[a]
    answers.append(i)
answers.append(numbers[K-1])
print(max(answers))



Fixed submission:
N,K=map(int,input().split())
p=input().split()
P=[int(z) for z in p]
hopes=[(1+a)/2 for a in P]
S=sum(hopes[:K])
answers=[S]
for a in range(1,N-K+1):
    S=S+hopes[a+K-1]-hopes[a-1]
    answers.append(S)
print(max(answers))

Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
p=input().split()
P=[int(z) for z in p]
hopes=[(1+a)/2 for a in P]
def goukei(i):
    S=0
    for a in range(i):
        S+=hopes[a]
    return S
numbers=[]
for a in range(N-K+1):
    number=goukei(a+K)-goukei(a)
    numbers.append(number)
print(max(numbers))


Fixed submission:
N,K=map(int,input().split())
p=input().split()
P=[int(z) for z in p]
hopes=[(1+a)/2 for a in P]
S=sum(hopes[:K])
answers=[S]
for a in range(1,N-K+1):
    S=S+hopes[a+K-1]-hopes[a-1]
    answers.append(S)
print(max(answers))

Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
p=input().split()
def hope(a):
    numbers=[int(b) for b in range(1,a+1)]
    goukei=sum(numbers)
    return goukei/a
P=[int(z) for z in p]
numbers=[]
for y in range(N-K+1):
    w=0
    for x in range(K):
        w+=P[x+y]
    numbers.append(w)
place=numbers.index(max(numbers))
answer=0
for q in range(K):
    answer+=hope(P[place+q])
print(answer)


Fixed submission:
N,K=map(int,input().split())
p=input().split()
P=[int(z) for z in p]
hopes=[(1+a)/2 for a in P]
S=sum(hopes[:K])
answers=[S]
for a in range(1,N-K+1):
    S=S+hopes[a+K-1]-hopes[a-1]
    answers.append(S)
print(max(answers))
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
def answer(i,j):
    kotae=0
    for k in range(1,N+1):
        if int(str(k)[0])==i and int(str(k)[-1])==j:
            kotae+=1
    return kotae
answers=0
for i in range(10):
    for j in range(10):
        answers+=answer(i,j)*answer(j,i)
print(answers)


Fixed submission:
N=int(input())
def answer(i,j):
    i=str(i)
    j=str(j)
    kotae=0
    for k in range(1,N+1):
        if str(k)[0]==i and str(k)[-1]==j:
            kotae+=1
    return kotae
answers=0
for i in range(1,10):
    for j in range(1,10):
        answers+=answer(i,j)*answer(j,i)
print(answers)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
def answer(i,j):
    kotae=0
    for k in range(1,N+1):
        if int(str(k)[0])==i and int(str(k)[-1])==j:
            kotae+=1
    return kotae
answers=0
for i in range(10):
    for j in range(10):
        answers+=answer(i,j)*answer(j,i)
print(answers)


Fixed submission:
N=int(input())
def answer(i,j):
    i=str(i)
    j=str(j)
    kotae=0
    for k in range(1,N+1):
        if str(k)[0]==i and str(k)[-1]==j:
            kotae+=1
    return kotae
answers=0
for i in range(1,10):
    for j in range(1,10):
        answers+=answer(i,j)*answer(j,i)
print(answers)