Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(2000000)

class UnionFind():
    def __init__(self,n):
        self.n=n
        self.parents = [i for i in range(n+1)]
        self.size = [1]*(n+1)
    def find(self,x):
        if self.parents[x]==x:
            return x
        else:
            self.parents[x]=self.find(self.parents[x])
            return self.parents[x]
    def unite(self,x,y):
        xRoot = self.find(x)
        yRoot = self.find(y)
        if xRoot == yRoot:
            return
        if self.size[xRoot]>self.size[yRoot]:
            self.parents[yRoot] = xRoot
        else:
            self.parents[xRoot] = yRoot
            if self.size[xRoot] == self.size[yRoot]:
                self.size[yRoot]+=1
N,K,L = map(int,input().split())
roadTree = UnionFind(N)
railTree = UnionFind(N)
for _ in range(K):
    p,q = map(int,input().split())
    roadTree.unite(p,q)
for _ in range(L):
    p,q = map(int,input().split())
    railTree.unite(p,q)

roadGroup = {}
for i in range(1,N+1):
    p = roadTree.find(i)
    if p not in roadGroup:
        roadGroup[p] = [i]
    else:
        roadGroup[p].append(i)

railGroupNum = {}
for i in range(1,N+1):
    p = railTree.find(i)
    railGroupNum[i]=p

ans = [1]*(N)
for p,children in roadGroup.items():
    for i in range(len(children)):
        c1 = children[i]
        for j in range(i+1,len(children)):
            c2 = children[j]
            if railGroupNum[c1] == railGroupNum[c2]:
                ans[c1-1]+=1
                ans[c2-1]+=1
            
print(" ".join([str(a) for a in ans]))

Fixed submission:
"""
道路でつながっているやつが鉄道でもつながっているかどうかを調べるにはどうすればいい？
普通に木ごとのサイズを求めておけばいいのか？

道路ネットワークを根ごとにグルーピングする。その中で、さらに鉄道の根ごとにグルーピングする。
でchooseでペア数を求めれば良い。

"""
import math
import sys
sys.setrecursionlimit(200000)
class UnionFind():
    def __init__(self,n):
        self.parents = [i for i in range(n+1)]

    def find(self,x):
        if self.parents[x] != x:
            self.parents[x] = self.find(self.parents[x])
        return self.parents[x]

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

N,K,L = map(int,input().split())
A = UnionFind(N)
B = UnionFind(N)
for i in range(K):
    p,q = map(int,input().split())
    A.union(p,q)

for i in range(L):
    r,s = map(int,input().split())
    B.union(r,s)


group = {}
for i in range(1,N+1):
    roadRoot = A.find(i)
    if roadRoot not in group:
        group[roadRoot] = {}
    railRoot = B.find(i)
    if railRoot not in group[roadRoot]:
        group[roadRoot][railRoot] = []
    group[roadRoot][railRoot].append(i)

ans = [[]for _ in range(N)]
for i in group.items():
    for j in i[1].values():
        for k in j:
            ans[k-1] = str(len(j))

ans = " ".join(ans)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
s = s[::-1]
li = ['maerd', 'remaerd', 'esare', 'resare']
t = ''

for i in range(len(s)):
  t = t + s[i]
  for c in li:
    if t == c:
      t = ''

if t == '':
  print('YES')
else:
  print('NO')

Fixed submission:
s = input()
s = s[::-1]
li = ['maerd', 'remaerd', 'esare', 'resare']
t = ''

for i in range(len(s)):
  t = t + s[i]
  for c in li:
    if t == c:
      t = ''

if t == '':
  print('YES')
else:
  print('NO')
Buggy python submission (verdict: Runtime Error):
MOD = 10**9+7

s = int(input())
a = [0]*range(s+1)
a[0] = 1
for i in range(3, s+1):
    a[i] = sum(a[:i-2]) % MOD
print(a[s])


Fixed submission:
MOD = 10**9+7

s = int(input())
a = [0 for i in range(s+1)]
a[0] = 1
for i in range(3, s+1):
    a[i] = sum(a[:i-2]) % MOD
print(a[s])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import numpy as np
def main():
    n = int(input())
    a = np.array(list(map(int, input().split())))
    q = int(input())
    for x in sys.stdin.readlines():
        b, c = map(int, x.split())
        a = np.where(a == b, c, a)
        print(np.sum(a))

main()

Fixed submission:
import sys
import collections
def main():
    n = int(input())
    a = collections.Counter(list(map(int, input().split())))
    s = [0 for i in range(10**5+1)]
    sa = 0
    for i in a:
        s[i] += a[i]
        sa += i*a[i]
    q = int(input())
    for x in sys.stdin.readlines():
        b, c = map(int, x.split())
        s[c] += s[b]
        sa = sa + c*s[b] - b*s[b]
        s[b] = 0
        print(sa)

main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import numpy as np
def main():
    n = int(input())
    a = np.array(list(map(int, input().split())))
    q = int(input())
    for x in sys.stdin.readlines():
        b, c = map(int, x.split())
        a = [c if i == b else i for i in a]
        print(np.sum(a))

main()

Fixed submission:
import sys
import collections
def main():
    n = int(input())
    a = collections.Counter(list(map(int, input().split())))
    s = [0 for i in range(10**5+1)]
    sa = 0
    for i in a:
        s[i] += a[i]
        sa += i*a[i]
    q = int(input())
    for x in sys.stdin.readlines():
        b, c = map(int, x.split())
        s[c] += s[b]
        sa = sa + c*s[b] - b*s[b]
        s[b] = 0
        print(sa)

main()
Buggy python submission (verdict: Runtime Error):
from sys import stdin
n = int(input())
a = list(map(int, stdin.readline().split()))
amax = max(a)
e = [0]*(amax+1)
ans = 0

for i in range(n):
    e[a[i]] += 1
    if e[a[i]] == 1:
        for j in range(2*a[i], amax, a[i]):
            e[i] += 2

print(e.count(i))

Fixed submission:
from sys import stdin
n = int(input())
a = list(map(int, stdin.readline().split()))
a.sort()
amax = max(a)+1
e = [0]*amax
ans = 0

for i in range(n):
    e[a[i]] += 1
    if e[a[i]] == 1:
        for j in range(2*a[i], amax, a[i]):
            e[j] += 2

print(e.count(1))
Buggy python submission (verdict: Runtime Error):
import numpy as np
from numba import jit
n, k = map(int, input().split())
a = np.array(list(map(int, input().split())))
@jit
for j in range(1, min(k+1, 50)):
    tmp = np.zeros(n+1, dtype=np.int64)
    for i in range(n):
        tmp[max(0, i - a[i])] += 1
        tmp[min(i + a[i] + 1, n)] -= 1
    tmp = np.cumsum(tmp)
    a = tmp[:n]
print(*a)

Fixed submission:
import numpy as np
from numba import jit
n, k = map(int, input().split())
a = np.array(list(map(int, input().split())))
@jit
def imos(a):
    tmp = np.zeros(n+1, dtype=np.int64)
    for i in range(n):
        tmp[max(0, i - a[i])] += 1
        tmp[min(i + a[i] + 1, n)] -= 1
    tmp = np.cumsum(tmp)
    return tmp[:n]

for j in range(1, min(k+1, 50)):
    a = imos(a)
print(*a)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n, k = map(int, input().split())
a = np.array(list(map(int, input().split())))
for j in range(1, min(k+1, 50)):
    tmp = np.zeros(n+1, dtype=np.int64)
    for i in range(n):
        tmp[max(0, i - a[i])] += 1
        tmp[min(i + a[i] + 1, n)] -= 1
    tmp = np.cumsum(tmp)
    a = tmp[:n]
print(*a)

Fixed submission:
import numpy as np
from numba import jit
n, k = map(int, input().split())
a = np.array(list(map(int, input().split())))
@jit
def imos(a):
    tmp = np.zeros(n+1, dtype=np.int64)
    for i in range(n):
        tmp[max(0, i - a[i])] += 1
        tmp[min(i + a[i] + 1, n)] -= 1
    tmp = np.cumsum(tmp)
    return tmp[:n]

for j in range(1, min(k+1, 50)):
    a = imos(a)
print(*a)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n, k = map(int, input().split())
a = list(map(int, input().split()))
for j in range(1, min(k+1, 100)):
    tmp = [0]*(n+1)
    for i in range(n):
        tmp[max(0, i - a[i])] += 1
        tmp[min(i + a[i] + 1, n)] -= 1
    tmp = list(itertools.accumulate(tmp))
    a = tmp[:n]
print(*a)

Fixed submission:
import numpy as np
from numba import jit
n, k = map(int, input().split())
a = np.array(list(map(int, input().split())))
@jit
def imos(a):
    tmp = np.zeros(n+1, dtype=np.int64)
    for i in range(n):
        tmp[max(0, i - a[i])] += 1
        tmp[min(i + a[i] + 1, n)] -= 1
    tmp = np.cumsum(tmp)
    return tmp[:n]

for j in range(1, min(k+1, 50)):
    a = imos(a)
print(*a)
Buggy python submission (verdict: Runtime Error):
print(input.replace("?", "D"))

Fixed submission:
print(input().replace("?", "D"))

Buggy python submission (verdict: Time Limit Exceeded):
t = input()
if t[0] == "?":
    t = "D" + t[1:]
for i in range(1, len(t)):
    if t[i] =="?":
        if t[i-1] == "D":
            t = t[:i] + "P" + t[i+1:]
        else:
            t = t[:i] + "D" + t[i+1:]

print(t)

Fixed submission:
print(input().replace("?", "D"))
Buggy python submission (verdict: Time Limit Exceeded):
import math

a, b, n = map(int, input().split())
if n < b:
    print((a*n)//b)
else:
    ans = -1
    for x in range(b+1):
        tmp = math.floor((a*x)/b) - a*math.floor(x/b)
        if tmp > ans:
            ans = tmp
        elif tmp < ans:
            break
    print(ans)

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

def f(x):
    return (a*x)//b-a*(x//b)

if n < b:
    print(f(n))
else:
    print(f(b-1))

Buggy python submission (verdict: Time Limit Exceeded):
a, b, n = map(int, input().split())
if n < b:
    print((a*n)//b)
else:
    ans = -1
    for x in range(b+1):
        tmp = (a*x)//b - a*(x//b)
        if tmp > ans:
            ans = tmp
        elif tmp < ans:
            break
    print(ans)

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

def f(x):
    return (a*x)//b-a*(x//b)

if n < b:
    print(f(n))
else:
    print(f(b-1))

Buggy python submission (verdict: Time Limit Exceeded):
a, b, n = map(int, input().split())
if n < b:
    print((a*n)//b)
else:
    ans = -1
    for x in range(b//a, b+a):
        tmp = (a*x)//b - a*(x//b)
        if tmp > ans:
            ans = tmp
        elif tmp < ans:
            break
    print(ans)

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

def f(x):
    return (a*x)//b-a*(x//b)

if n < b:
    print(f(n))
else:
    print(f(b-1))

Buggy python submission (verdict: Time Limit Exceeded):
a, b, n = map(int, input().split())
if n < b:
    print((a*n)//b)
else:
    ans = -1
    for x in range(b//a, b*2+1):
        tmp = (a*x)//b - a*(x//b)
        if tmp > ans:
            ans = tmp
        elif tmp < ans:
            break
    print(ans)

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

def f(x):
    return (a*x)//b-a*(x//b)

if n < b:
    print(f(n))
else:
    print(f(b-1))

Buggy python submission (verdict: Time Limit Exceeded):
a, b, n = map(int, input().split())
if n < b:
    print((a*n)//b)
else:
    ans = -1
    for x in range(n+1):
        tmp = (a*x)//b - a*(x//b)
        if tmp > ans:
            ans = tmp
        elif tmp < ans:
            break
    print(ans)


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

def f(x):
    return (a*x)//b-a*(x//b)

if n < b:
    print(f(n))
else:
    print(f(b-1))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = []
for i in range(n):
    s = input()
    if s not in ans:
        ans.append(s)
print(len(ans))

Fixed submission:
import sys
import collections

n = int(input())
s = sys.stdin.readlines()
ans = collections.Counter(s)
print(len(ans))
Buggy python submission (verdict: Runtime Error):
n = int(input())
ans = 0
for i in range(1. n+1):
    if i%3 == 0 or i%5 == 0:
        ans += i
print(ans)

Fixed submission:
n = int(input())
ans = 0
for i in range(1, n+1):
    if i%3 != 0 and i%5 != 0:
        ans += i
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce

def gcd(m, n):
    r = m % n
    return gcd(n, r) if r else n

def mgcd(*a):
    return reduce(gcd, a)

k = int(input())
ans = 0
for i in range(1, k+1):
  for j in range(1, k+1):
    for l in range(1, k+1):
      ans += mgcd(i, j, l)

print(ans)

Fixed submission:
from math import gcd

k=int(input())
ans=0
for i in range(1,k+1):
    for j in range(1,k+1):
        for m in range(1,k+1):
            ans += gcd(i, gcd(j,m))
print(ans)

Buggy python submission (verdict: Runtime Error):
from functools import reduce

def gcd(m, n):
    r = m % n
    return gcd(n, r) if r else n

def mgcd(*a)
    return reduce(gcd, a)

k = int(input())
ans = 0
for i in range(1, k+1):
  for j in range(1, k+1):
    for l in range(1, k+1):
      tmp = mgcd(i, j, l)
      if i == j== k:
        ans += tmp
      else:
        ans += tmp*3
print(ans)

Fixed submission:
from math import gcd

k=int(input())
ans=0
for i in range(1,k+1):
    for j in range(1,k+1):
        for m in range(1,k+1):
            ans += gcd(i, gcd(j,m))
print(ans)
Buggy python submission (verdict: Runtime Error):
import collections

def main():
    k = int(input())
    Q = collections.deque([int(i) for i in range(1, 10)])
    for i in range(k):
        x = Q.popleft()
        if i + len(Q) < k:
            if x%10:
                Q.append(10*x + x%10 - 1)
            Q.append(10*x + x%10)
            if x%10 != 9:
                Q.append(10*x + x%10 + 1)
        print(Q)
    print(x)

if __name__ == "__main__":
    main()

Fixed submission:
import collections

k = int(input())
Q = collections.deque([int(i) for i in range(1, 10)])
for _ in range(k):
    x = Q.popleft()
    if x%10:
        Q.append(10*x + x%10 - 1)
    Q.append(10*x + x%10)
    if x%10 != 9:
        Q.append(10*x + x%10 + 1)
print(x)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import collections

n = int(input())
a = list(map(int, sys.stdin.readline().split()))
c = collections.Counter(a)
ans = [0 for i in range(sorted(c.keys())[-1]+1)]

for i in c.keys():
    tmp = 0
    for j in c.keys():
        if i == j:
            tmp += (c[j]-1)*(c[j]-2)//2
        else:
            tmp += c[j]*(c[j]-1)//2
    ans[i] = tmp

for i in a:
    print(ans[i])


Fixed submission:
import sys
import collections

n = int(input())
a = list(map(int, sys.stdin.readline().split()))
c = collections.Counter(a)
ans = [0 for i in range(sorted(c.keys())[-1]+1)]

for i in c.keys():
    ans[i] = c[i]*(c[i]-1)//2

sans = sum(ans)
for i in a:
    print(sans - ans[i] + ans[i]*(c[i]-2)//c[i])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import collections

n = int(input())
a = sys.stdin.readline().split()
c = collections.Counter(a)
for i in a:
    ans = 0
    for j in c.keys():
        if i == j:
            ans += (c[j]-1)*(c[j]-2)//2
        else:
            ans += c[j]*(c[j]-1)//2
    print(ans)


Fixed submission:
import sys
import collections

n = int(input())
a = list(map(int, sys.stdin.readline().split()))
c = collections.Counter(a)
ans = [0 for i in range(sorted(c.keys())[-1]+1)]

for i in c.keys():
    ans[i] = c[i]*(c[i]-1)//2

sans = sum(ans)
for i in a:
    print(sans - ans[i] + ans[i]*(c[i]-2)//c[i])
Buggy python submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
cnt = 0
ans = 0
if n//(a+b) <= 10**100:
    ans += a * n//(a+b)
    cnt += (n//(a+b))*(a+b)
else:
    ans += a * (10**100//(a+b))
    cnt += (10**100//(a+b))*(a+b)

if n - cnt >= a:
    ans += a:
else:
    ans += n - cnt
print(ans)

Fixed submission:
n, a, b = map(int, input().split())
cnt = 0
ans = 0
l = (a+b)
if n//l <= 10**100:
    ans += a * (n//l)
    cnt += (n//l)*l
    if n - cnt >= a:
        ans += a
    else:
        ans += max(n - cnt, 0)
else:
    ans += a * 10**100
    cnt += 10**100

print(ans)
Buggy python submission (verdict: Runtime Error):
import sys


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

    def _root(self, x):
        stack = []
        tbl = self.table
        while tbl[x] >= 0:
            stack.append(x)
            x = tbl[x]
        for y in stack:
            tbl[y] = x
        return x

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

    def union(self, x, y):
        r1 = self._root(x)
        r2 = self._root(y)
        if r1 == r2:
            return
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            self.table[r1] += d2
        else:
            self.table[r1] = r2
            self.table[r2] += d1


def main():
    n, m, k = map(int, sys.stdin.buffer.readline().split())
    uf = UnionFind(n)
    fb = [0]*n
    i = 0
    for x in sys.stdin.buffer.readlines():
        print(uf.table)
        if i < m:
            a, b = map(int, x.split())
            fb[a-1] += 1
            fb[b-1] += 1
            uf.union(a-1, b-1)
        else:
            c, d = map(int, x.split())
            if uf._root(c-1) == uf._root(d-1):
                fb[c-1] += 1
                fb[d-1] += 1
        i += 1

    ans = [-uf.table[uf._root(i)]-1-fb[i] for i in range(n)]
    print(*ans)


if __name__ == "__main__":
    main()


Fixed submission:
import sys


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

    def _root(self, x):
        stack = []
        tbl = self.table
        while tbl[x] >= 0:
            stack.append(x)
            x = tbl[x]
        for y in stack:
            tbl[y] = x
        return x

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

    def union(self, x, y):
        r1 = self._root(x)
        r2 = self._root(y)
        if r1 == r2:
            return
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            self.table[r1] += d2
        else:
            self.table[r1] = r2
            self.table[r2] += d1


def main():
    n, m, k = map(int, sys.stdin.buffer.readline().split())
    uf = UnionFind(n)
    fb = [0]*n
    i = 0
    for x in sys.stdin.buffer.readlines():
        if i < m:
            a, b = map(int, x.split())
            fb[a-1] += 1
            fb[b-1] += 1
            uf.union(a-1, b-1)
        else:
            c, d = map(int, x.split())
            if uf._root(c-1) == uf._root(d-1):
                fb[c-1] += 1
                fb[d-1] += 1
        i += 1

    ans = [-uf.table[uf._root(i)]-1-fb[i] for i in range(n)]
    print(*ans)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
n, r = map(int, input().split())
if n >= 10:
    print(r)
else:
    print(r + 100(10-n))

Fixed submission:
n, r = map(int, input().split())
if n >= 10:
    print(r)
else:
    print(r + 100*(10-n))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [input() for i in range(n)]
s.sort()
l = sorted(set(s))

ans = 0
ans_l = []
for i in l:
    sc = s.count(i)
    if sc > ans:
        ans_l = [i]
        ans = sc
    elif sc == ans:
        ans_l.append(i)
      
print("\n".join(ans_l))

Fixed submission:
from collections import Counter

n = int(input())
S = [input() for i in range(n)]

s = Counter(S)
max_cnt = max(s.values())
names = [name for name, cnt in s.items() if cnt == max_cnt]
names.sort()

print("\n".join(names))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [input() for i in range(n)]
s.sort()
l = sorted(set(s))
ms = len(s) - len(l)
if ms == 0:
    print("\n".join(s))
    exit()

ans = 0
ans_l = []
for i in l:
    sc = s.count(i)
    if sc > ans:
        ans_l = [i]
        ans = sc
    elif sc == ans:
        ans_l.append(i)
      
print("\n".join(ans_l))

Fixed submission:
from collections import Counter

n = int(input())
S = [input() for i in range(n)]

s = Counter(S)
max_cnt = max(s.values())
names = [name for name, cnt in s.items() if cnt == max_cnt]
names.sort()

print("\n".join(names))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [input() for i in range(n)]
s.sort()
l = sorted(set(s))
ans = 0
ans_l = []

for i in l:
    if s.count(i) > ans:
      ans_l.clear()
      ans_l.append(i)
      ans = s.count(i)
    elif s.count(i) == ans:
      ans_l.append(i)
    del s[:s.count(i)-1]
      

print("\n".join(ans_l))

Fixed submission:
from collections import Counter

n = int(input())
S = [input() for i in range(n)]

s = Counter(S)
max_cnt = max(s.values())
names = [name for name, cnt in s.items() if cnt == max_cnt]
names.sort()

print("\n".join(names))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [input() for i in range(n)]
s.sort()
l = sorted(set(s))
ans = 0
ans_l = []

for i in l:
    if s.count(i) > ans:
      ans_l.clear()
      ans_l.append(i)
      ans = s.count(i)
    elif s.count(i) == ans:
      ans_l.append(i)
    s.remove(i)
      

print("\n".join(ans_l))

Fixed submission:
from collections import Counter

n = int(input())
S = [input() for i in range(n)]

s = Counter(S)
max_cnt = max(s.values())
names = [name for name, cnt in s.items() if cnt == max_cnt]
names.sort()

print("\n".join(names))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [input() for i in range(n)]
l = set(s)
l = list(sorted(l))
ans = 0
ans_l = []
for i in l:
    if s.count(i) > ans:
      ans_l = [i]
      ans = s.count(i)
    elif s.count(i) == ans:
      ans_l.append(i)
print("\n".join(ans_l))

Fixed submission:
from collections import Counter

n = int(input())
S = [input() for i in range(n)]

s = Counter(S)
max_cnt = max(s.values())
names = [name for name, cnt in s.items() if cnt == max_cnt]
names.sort()

print("\n".join(names))
Buggy python submission (verdict: Runtime Error):
s t = map(str, input().split())
a b = map(int, input().split())
u = input()
if s == u:
    print(a-1, b)
else:
    print(a, b-1)

Fixed submission:
s, t = map(str, input().split())
a, b = map(int, input().split())
u = input()
if s == u:
    print(a-1, b)
else:
    print(a, b-1)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

def dice():
    n, k = map(int, input().split())
    p = np.asarray(list(map(int, input().split())))
    pp = np.zeros(n)
    for i in range(n):
      pp[i] = p[i]*(p[i]+1)/(2*p[i])

    ans = 0
    for i in range(n-k+1):
        tmp = sum(pp[i:i+k])
        if ans < tmp:
            ans = tmp
    print(ans)

if __name__ == '__main__':
    dice()

Fixed submission:
import numpy as np

def dice():
    n, k = map(int, input().split())
    p = np.asarray(list(map(int, input().split())))
    pp = np.zeros(n)
    for i in range(n):
      pp[i] = p[i]*(p[i]+1)/(2*p[i])
    ans = sum(pp[0:k]) 
    tmp = sum(pp[0:k])
    for i in range(1, n-k+1):
        tmp = tmp - pp[i-1] + pp[i+k-1]
        if ans < tmp:
            ans = tmp
    print(ans)

if __name__ == '__main__':
    dice()

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
p = list(map(int, input().split()))
pp = [0]*n
for i in range(n):
  pp[i] = p[i]*(p[i]+1)/(2*p[i])

ans = 0
for i in range(n-k+1):
    tmp = sum(pp[i:i+k])
    if ans < tmp:
        ans = tmp
print(ans)

Fixed submission:
import numpy as np

def dice():
    n, k = map(int, input().split())
    p = np.asarray(list(map(int, input().split())))
    pp = np.zeros(n)
    for i in range(n):
      pp[i] = p[i]*(p[i]+1)/(2*p[i])
    ans = sum(pp[0:k]) 
    tmp = sum(pp[0:k])
    for i in range(1, n-k+1):
        tmp = tmp - pp[i-1] + pp[i+k-1]
        if ans < tmp:
            ans = tmp
    print(ans)

if __name__ == '__main__':
    dice()

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
p = list(map(int, input().split()))
ans = 0
for i in range(n-k+1):
    tmp = 0
    for j in range(k):
        tmp += p[i+j]*(p[i+j]+1)/(2*p[i+j])
    if ans < tmp:
        ans = tmp
print(ans)

Fixed submission:
import numpy as np

def dice():
    n, k = map(int, input().split())
    p = np.asarray(list(map(int, input().split())))
    pp = np.zeros(n)
    for i in range(n):
      pp[i] = p[i]*(p[i]+1)/(2*p[i])
    ans = sum(pp[0:k]) 
    tmp = sum(pp[0:k])
    for i in range(1, n-k+1):
        tmp = tmp - pp[i-1] + pp[i+k-1]
        if ans < tmp:
            ans = tmp
    print(ans)

if __name__ == '__main__':
    dice()