Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/python
# -*- coding: UTF-8 -*-

import sys


def input():
    return sys.stdin.readline().strip()


def _main():
	input()
    s = sorted(list(input().split()))
    print("".join(s))


if __name__ == "__main__":
    _main()


Fixed submission:
#!/usr/bin/python
# -*- coding: UTF-8 -*-

import sys


def get_ints():
    return map(int, sys.stdin.readline().strip().split())


def input():
    return sys.stdin.readline().strip()


def _main():
    n, length = get_ints()
    s_list = [""] * n
    for i in range(n):
        s_list[i] = input()
    s = sorted(s_list)
    print("".join(s))


if __name__ == "__main__":
    _main()
Buggy python submission (verdict: Runtime Error):
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


N,M = map(int, input().split())
uf = UnionFind(N)
for _ in range(M):
    a,b=map(int, input().split())
    uf.union(a,b)
cnt = 0
for i in range(N-1):
    if(not uf.same(i,i+1)):
        cnt += 1
        uf.union(i,i+1)
print(cnt)

Fixed submission:
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


N,M = map(int, input().split())
uf = UnionFind(N)
for _ in range(M):
    a,b=map(int, input().split())
    uf.union(a-1,b-1)
cnt = 0
for i in range(N-1):
    if(not uf.same(i,i+1)):
        cnt += 1
        uf.union(i+1,i)
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().split())
L = [0]*N
R = [0]*N
DP = [0]*(N+10)
DP[0] = 1
SDP = [0]*(N+10)
SDP[1] = 1
MOD=998244353
for i in range(K):
    L[i],R[i] = map(int, input().split())

for i in range(1,N):
    for j in range(K):
        l = max(0,i-R[j])
        r = max(0,i-L[j]+1)
        DP[i] += SDP[r] - SDP[l]
    SDP[i+1] = SDP[i] + DP[i]
print(DP[N-1]%MOD)


Fixed submission:
N,K = map(int, input().split())
L = [0]*N
R = [0]*N
DP = [0]*(N+10)
DP[0] = 1
SDP = [0]*(N+10)
SDP[1] = 1
MOD=998244353
for i in range(K):
    L[i],R[i] = map(int, input().split())

for i in range(1,N):
    for j in range(K):
        l = max(0,i-R[j])
        r = max(0,i-L[j]+1)
        DP[i] += SDP[r] - SDP[l]
    SDP[i+1] = (SDP[i] + DP[i])%MOD
print(DP[N-1]%MOD)
Buggy python submission (verdict: Runtime Error):
N,Q = map(int, input().split())
ANS = (N-2)**2
R,C=N,N
RLEN=[]
CLEN=[]
for i in range(Q):
    RC,num = map(int, input().split())
    if RC==1:
        if R>num:
            for j in range(R-num-2):
                RLEN.append(C)
            ANS-=C-2
            R=num
        else:
            if len(RLEN)>0:
                ANS-=RLEN[N-num-1]-2
            else:
                ANS-=R-2
    else:
        if C>num:
            for j in range(C-num-2):
                CLEN.append(R)
            ANS-=R-2
            C=num
        else:
            if len(CLEN)>0:
                ANS-=CLEN[N-num-1]-2
            else:
                ANS-=C-2

print(ANS)



Fixed submission:
N,Q = map(int, input().split())
ANS = (N-2)**2
R,C=N,N
RLEN=[]
CLEN=[]
for i in range(Q):
    RC,num = map(int, input().split())
    if RC==1:
        if R>num:
            for j in range(R-num):
                RLEN.append(C)
            ANS-=C-2
            R=num
        else:
            if len(RLEN)>0:
                ANS-=RLEN[N-num-1]-2
            else:
                ANS-=R-2
    else:
        if C>num:
            for j in range(C-num):
                CLEN.append(R)
            ANS-=R-2
            C=num
        else:
            if len(CLEN)>0:
                ANS-=CLEN[N-num-1]-2
            else:
                ANS-=C-2

print(ANS)

Buggy python submission (verdict: Runtime Error):
N,Q = map(int, input().split())
ANS = (N-2)**2
R,C=N,N
RLEN=[]
CLEN=[]
for i in range(Q):
    RC,num = map(int, input().split())
    if RC==1:
        if R>num:
            for j in range(R-num-1):
                RLEN.append(C)
            ANS-=C-2
            R=num
        else:
            if len(RLEN)>0:
                ANS-=RLEN[N-num-1]-2
            else:
                ANS-=R-2
    else:
        if C>num:
            for j in range(C-num-1):
                CLEN.append(R)
            ANS-=R-2
            C=num
        else:
            if len(CLEN)>0:
                ANS-=CLEN[N-num-1]-2
            else:
                ANS-=C-2

print(ANS)



Fixed submission:
N,Q = map(int, input().split())
ANS = (N-2)**2
R,C=N,N
RLEN=[]
CLEN=[]
for i in range(Q):
    RC,num = map(int, input().split())
    if RC==1:
        if R>num:
            for j in range(R-num):
                RLEN.append(C)
            ANS-=C-2
            R=num
        else:
            if len(RLEN)>0:
                ANS-=RLEN[N-num-1]-2
            else:
                ANS-=R-2
    else:
        if C>num:
            for j in range(C-num):
                CLEN.append(R)
            ANS-=R-2
            C=num
        else:
            if len(CLEN)>0:
                ANS-=CLEN[N-num-1]-2
            else:
                ANS-=C-2

print(ANS)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict

N = int(input())
A = list(map(int, input().split()))
d = defaultdict(lambda: 0)
d[0] = 1000

for i in range(N):
    dd = d.copy()
    for s,m in dd.items():
        temp = m//A[i]
        for j in range(1,temp+1):
            if(d[s+j]<m-j*A[i]):
                d[s+j]=m-j*A[i]
        for j in range(1,s+1):
            if(d[s-j]<m+j*A[i]):
                d[s-j]=m+j*A[i]

print(d[0])





Fixed submission:
N = int(input())
A = list(map(int, input().split()))
m=1000
s=0
for i in range(N-1):
    if A[i] < A[i+1]:
        s+=m//A[i]
        m=m%A[i]
    if A[i] > A[i+1]:
        m += A[i]*s
        s=0

print(m+A[N-1]*s)
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
FA = list(map(int,input().split()))
A = [0]*N
ANS = [N]*N
for i in range(N):
    mi = max(0,i-FA[i])
    ma = min(N-1,i+FA[i])
    for i in range(mi,ma+1):
        A[i] +=1

for i in range(N):
    mi = i-A[i]-K+1
    ma = i+A[i]+K-1
    if mi>=0:
        for j in range(0,mi+1):
            ANS[j] -=1
    if ma<=N-1:
        for j in range(ma,N):
            ANS[j] -=1

if K == 1:
    print(*A)
else:
    print(*ANS)


Fixed submission:
import itertools

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

for i in range(K):
    TEMP = [0]*(N+1)
    for j in range(N):
        TEMP[max(0,j-A[j])] +=1
        TEMP[min(N,j+A[j]+1)] -=1
    A = list(itertools.accumulate(TEMP))
    if A[0] == N and A[N-1] == N:
        break

A.pop()
print(*A)
Buggy python submission (verdict: Time Limit Exceeded):

def main():
    N,M = map(int, input().split())
    H = list(map(int, input().split()))
    H.insert(0,0)
    A = [0] * (M)
    B = [0] * (M)
    cnt = 0
    

    for index in range(M):
        A[index],B[index] = map(int, input().split())

    for index in range(1,len(H)):
        ok = True
        for jn in range(M):
            if A[jn] == index :
                if H[A[jn]] <= H[B[jn]]:
                    ok = False
                    break
            if B[jn] == index :
                if H[B[jn]] <= H[A[jn]]:
                    ok = False
                    break
        if ok :
            cnt+=1

    print(cnt)


if __name__ == '__main__':
    main()


Fixed submission:

def main():
    N,M = map(int, input().split())
    H = list(map(int, input().split()))
    H.insert(0,0)
    A = [0] * (M)
    B = [0] * (M)
    TOP = [0] * len(H)
    cnt = 0

    for index in range(M):
        A[index],B[index] = map(int, input().split())

    for jn in range(M):
        if H[A[jn]] <= H[B[jn]]:
            TOP[A[jn]] = 1
        if H[B[jn]] <= H[A[jn]]:
            TOP[B[jn]] = 1

    cnt = TOP.count(0) -1

    print(cnt)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
cnt = 0 
for i in range(N):
    for j in range(i+1,N):
        if(A[j]==j-i-A[i]):
            cnt+=1

print(cnt)

Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
AP = [0]*N
AM = [0]*N

for i in range(N):
    AP[i]=i+A[i]
    AM[i]=i-A[i]

cnt=0
QC = Counter(AP)
for m in AM:
    cnt += QC[m]

print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
import re
def main():
    S = input()
    S = input()
    cnt = 0

    for i in range(1000):
        PIN = "{:03d}".format(i)
        pattern = '^.*' + PIN[0] + '.*' + PIN[1] + '.*' + PIN[2] + '.*$' 
        repatter = re.compile(pattern)
        if repatter.match(S):
            cnt+=1
        
    print(cnt)



if __name__ == '__main__':
    main()


Fixed submission:
import re
def main():
    S = input()
    S = input()
    l = len(S)
    cnt = 0


    for i in range(10):
        iti = 0
        iti = S.find(str(i))
        if iti == -1 :
            continue
        for j in range(10):
            s = S[iti+1:]
            itj = s.find(str(j))
            if itj == -1 :
                continue
            for k in range(10):
                t = s[itj+1:]
                itk = t.find(str(k))
                if itk != -1 :
                    cnt += 1

    print(cnt)



if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
A,B = map(int, input().split())  
if A<=9 && B<=9:
  print(A*B)
else:
  print(-1)

Fixed submission:
A,B = map(int, input().split())  
if A<=9 and B<=9:
  print(A*B)
else:
  print(-1)
Buggy python submission (verdict: Runtime Error):
N = int(input())  
for i in range(1,10):
  for j in range(1,10):
    if i*j == N:
      print('Yes')
      return
print('No')

Fixed submission:
def main():
    N = int(input())  
    for i in range(1,10):
        for j in range(1,10):
            if i*j == N:
                print('Yes')
                return
    print('No')

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#1は含まれない
def cf(x1,x2):
    cf=[]
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf

def is_prime(n):
    for i in range(2, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            return False
    return n != 1


A,B=map(int,input().split())
L = cf(A,B)
cnt = 1
for l in L:
    if is_prime(l):
        cnt+=1

print(cnt)


Fixed submission:
#1は含まれない
def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = set(table)
    return table

def is_prime(n):
    for i in range(2, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            return False
    return n != 1


A,B=map(int,input().split())
AL = divisor(A)
BL = divisor(B)
AB = list(AL & BL)
cnt = 1
for l in AB:
    if is_prime(l):
        cnt+=1

print(cnt)
Buggy python submission (verdict: Runtime Error):
print(sum(list(range(int(input())))))

Fixed submission:
N = int(input())
print(N*(N-1)//2)
Buggy python submission (verdict: Runtime Error):
import math

def main():
    A,B,C,D = map(int, input().split())  
    lc = lcm(C, D)
    Bsum = B - (B//C) - (B//D) + (B//lc)
    A1 = A-1
    Asum = A1 - (A1//C) - (A1//D) + (A1//lc)
    print(Bsum-Asum)
    
def lcm(x, y):
    return (x * y) // math.gcd(x, y)



if __name__ == '__main__':
    main()


Fixed submission:
import fractions

def main():
    A,B,C,D = map(int, input().split())  
    lc = lcm(C, D)
    Bsum = B - (B//C) - (B//D) + (B//lc)
    A1 = A-1
    Asum = A1 - (A1//C) - (A1//D) + (A1//lc)
    print(Bsum-Asum)
    
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)



if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
R,G,B,N = map(int, input().split())  

BALL = [0]*(N+100)
BALL[0] = 1

for num in range(0,N+1,1):
    if BALL[num] != 0:
        BALL[num+R] += BALL[num]
for num in range(0,N+1,1):
    if BALL[num] != 0:
        BALL[num+G] += BALL[num]

for num in range(0,N+1,1):
    if BALL[num] != 0:
        BALL[num+B] += BALL[num]

print(BALL[N])




Fixed submission:
R,G,B,N = map(int, input().split())  

BALL = [0]*(N+100)
BALL[0] = 1

for num in range(0,N+1,1):
    if BALL[num] != 0 and num + R <= N:
        BALL[num+R] += BALL[num]
for num in range(0,N+1,1):
    if BALL[num] != 0 and num + G <= N:
        BALL[num+G] += BALL[num]

for num in range(0,N+1,1):
    if BALL[num] != 0 and num + B <= N:
        BALL[num+B] += BALL[num]

print(BALL[N])
Buggy python submission (verdict: Time Limit Exceeded):
K,A,B = map(int,input().split())
bis = K+1
tempbis = 1
while K>0:
    if tempbis<A:
        tempbis+=1
    else:
        if K>=2:
            K-=1
            tempbis += B-A
        else:
            tempbis +=1
    K-=1

print(max(bis,tempbis))

Fixed submission:
K,A,B = map(int,input().split())
bis = K+1
tempbis = 1
if A<B and A<K:
    tempbis=A
    K -= A-1
    tempbis += K%2
    tempbis += (B-A)*(K//2)

print(max(bis,tempbis))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

def main():
    N = int(input())
    V = list(map(int, input().split()))
    V1 = []
    V2 = []
    for i in range(0,len(V),2):
        V1.append(V[i])
    for i in range(1,len(V),2):
        V2.append(V[i])  
    VC1 = Counter(V1)
    VC2 = Counter(V2)
    count = 0
    for i in range(1,len(VC1)):
        count += VC1.most_common()[i][1]
    for i in range(1,len(VC2)):
        count += VC2.most_common()[i][1]
    if str(VC1.most_common()[0][0]) == str(VC2.most_common()[0][0]) and len(VC1)==1:
        count += VC1.most_common()[0][1]
    elif  str(VC1.most_common()[0][0]) == str(VC2.most_common()[0][0]):
        vc1sa = VC1.most_common()[0][1] - VC1.most_common()[1][1]
        vc2sa = VC1.most_common()[0][1] - VC1.most_common()[1][1]
        count += min([vc1sa,vc2sa])


    print(count)




if __name__ == '__main__':
    main()


Fixed submission:
from collections import Counter

def main():
    N = int(input())
    V = list(map(int, input().split()))
    V1 = []
    V2 = []
    for i in range(0,len(V),2):
        V1.append(V[i])
    for i in range(1,len(V),2):
        V2.append(V[i])  
    VC1 = Counter(V1)
    VC2 = Counter(V2)
    count = 0

    VC1mosc = VC1.most_common()[0][0]
    VC1mosv = VC1.most_common()[0][1]
    VC2mosc = VC2.most_common()[0][0]
    VC2mosv = VC2.most_common()[0][1]

    count += len(V1) - VC1mosv
    count += len(V2) - VC2mosv

    if VC1mosc  == VC2mosc and len(VC1)==1:
        count += VC1mosv
    elif  VC1mosc  == VC2mosc:
        vc1sa = VC1mosv - VC1.most_common()[1][1]
        vc2sa = VC2mosv - VC2.most_common()[1][1]
        count += min([vc1sa,vc2sa])


    print(count)




if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    S  = input()
    K  = int(input())

    cnt = 0
    while S[cnt]=='1' and cnt<len(S):
        cnt = cnt + 1
    
    if K<=cnt:
        print(S[0])
    elif cnt==len(S):
        print(S[cnt-1])
    else:
        print(S[cnt])


if __name__ == '__main__':
    main()

Fixed submission:
def main():
    S  = input()
    K  = int(input())

    cnt = 0
    while cnt<len(S) and  S[cnt]=='1':
        cnt = cnt + 1
    
    if K<=cnt:
        print(S[0])
    elif cnt==len(S):
        print(S[cnt-1])
    else:
        print(S[cnt])


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
def main():
    S  = input()
    K  = int(input())

    cnt = 0
    while S[cnt]=='1' and cnt<len(S):
        cnt = cnt + 1
    
    if K<=cnt:
        print(S[0])
    else:
        print(S[cnt])


if __name__ == '__main__':
    main()

Fixed submission:
def main():
    S  = input()
    K  = int(input())

    cnt = 0
    while cnt<len(S) and  S[cnt]=='1':
        cnt = cnt + 1
    
    if K<=cnt:
        print(S[0])
    elif cnt==len(S):
        print(S[cnt-1])
    else:
        print(S[cnt])


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):

def main():
    S  = input()
    K  = input()

    cnt = 0
    while S[cnt]=='1':
        cnt = cnt + 1
    
    if K<=cnt:
        print(S[0])
    else:
        print(S[cnt+1])




if __name__ == '__main__':
    main()


Fixed submission:
def main():
    S  = input()
    K  = int(input())

    cnt = 0
    while cnt<len(S) and  S[cnt]=='1':
        cnt = cnt + 1
    
    if K<=cnt:
        print(S[0])
    elif cnt==len(S):
        print(S[cnt-1])
    else:
        print(S[cnt])


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
def main():
    S  = input()
    K  = input()
    if K==1:
        print(S[0])
    elif S[0]=='1':
        print(S[1])
    else:
        print(S[0])



if __name__ == '__main__':
    main()


Fixed submission:
def main():
    S  = input()
    K  = int(input())

    cnt = 0
    while cnt<len(S) and  S[cnt]=='1':
        cnt = cnt + 1
    
    if K<=cnt:
        print(S[0])
    elif cnt==len(S):
        print(S[cnt-1])
    else:
        print(S[cnt])


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result




n = int(input())
A = list(map(int, input().split()))
AS = sorted(list(set(A)))
n = AS[-1]
r = AS[0]
combM = cmb(n, r)

for i in range(1,len(AS)):
    tempr = AS[i]
    tempc = cmb(n, tempr)
    if combM >= tempc:
        break
    r = tempr
    combM = tempc


print(str(n) + ' ' + str(r))



Fixed submission:
n = int(input())
A = list(map(int, input().split()))
AS = sorted(list(set(A)))
n = AS[-1]
checkAS = len(AS)-1
nHalf = n/2
min = 10**10


for i in range(checkAS):
    temp = abs(AS[i]-nHalf)
    if min > temp:
        r = AS[i]
        min = temp

print(str(n) + ' ' + str(r))
Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
q = int(input())

for i in range(q):
    op = input().split()
    if op[0] == "1":
        s.reverse()
    else:
        if op[1] == "1":
            s.insert(0, op[2])
        else:
            s.append(op[2])
    
for i in s:
    print(i, end='')
print()

Fixed submission:
s = input()
q = int(input())

rvs = False
front = []
back = []
for i in range(q):
    op = input().split()
    if op[0] == "1":
        rvs = rvs ^ 1
    else:
        if op[1] == "1":
            if rvs:
                back.append(op[2])
            else:
                front.append(op[2])
        else:
            if rvs:
                front.append(op[2])
            else:
                back.append(op[2])

if rvs:
    for c in reversed(back):
        print(c, end='')
    for c in reversed(s):
        print(c, end='')
    for c in front:
        print(c, end='')
else:
    for c in reversed(front):
        print(c, end='')
    print(s, end='')
    for c in back:
        print(c, end='')

print()
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
p = list(map(int, input().split()))

max_x = 0
idx = 0
x = 0

for i in range(n-k+1):
    x += p[i+k] - p[i]
    if max_x < x:
        max_x = x
        idx = i

ans = (sum(p[i:i+k]) + k) / 2
print(ans)

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

max_x = 0
idx = 0
x = 0

if n == k:
    print((sum(p) + k) / 2)
    exit()

for i in range(n-k):
    x += p[i+k] - p[i]
    if max_x < x:
        max_x = x
        idx = i+1

ans = (sum(p[idx:idx+k]) + k) / 2
print(ans)

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
p = list(map(int, input().split()))

max_x = 0
idx = 0
x = 0

for i in range(n-k):
    x += p[i+k] - p[i]
    if max_x < x:
        max_x = x
        idx = i

ans = (sum(p[i:i+k]) + k) / 2
print(ans)

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

max_x = 0
idx = 0
x = 0

if n == k:
    print((sum(p) + k) / 2)
    exit()

for i in range(n-k):
    x += p[i+k] - p[i]
    if max_x < x:
        max_x = x
        idx = i+1

ans = (sum(p[idx:idx+k]) + k) / 2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
p = list(map(int, input().split()))

max_sum = 0

for i in range(n-k+1):
    max_sum = max(max_sum, sum(p[i:i+k]))

ans = (max_sum + k) / 2
print(ans)

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

max_x = 0
idx = 0
x = 0

if n == k:
    print((sum(p) + k) / 2)
    exit()

for i in range(n-k):
    x += p[i+k] - p[i]
    if max_x < x:
        max_x = x
        idx = i+1

ans = (sum(p[idx:idx+k]) + k) / 2
print(ans)
Buggy python submission (verdict: Runtime Error):
n, k, s = map(int, input().split())
ans = [s] * k
ex = [s//2+1] * (n-k) if s != 1 else 2
ans.extend(ex)

for e in ans:
    print(e, end=' ')
print()

Fixed submission:
n, k, s = map(int, input().split())
ans = [s] * k
if s // 2 + 1 == s:
    ss = s // 2 + 10
else:
    ss = s // 2 + 1
ex = [ss] * (n-k)
ans.extend(ex)

for e in ans:
    print(e, end=' ')
print()