Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
# mod = 10 ** 9 + 7
mod = 998244353 

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]
def init_dp1(init, N): return [init for _ in range(N)]
def init_dp2(init, N, M): return [[init for _ in range(M)] for _ in range(N)]


def main():
    N, X = read_values()
    A = read_list()

    dp = [[[0 for _ in range(N * X + 1)] for _ in range(N + 1)] for _ in range(N + 1)]
    

    dp[0][0][0] = 1

    for i, a in enumerate(A):
        for j in range(N + 1):
            for k in range(N * X):
                if k + a <= N * X and j < N:
                    dp[i + 1][j + 1][k + a] += dp[i][j][k]
                dp[i + 1][j][k] += dp[i][j][k]
    
    res = 0
    for i in range(1, N + 1):
        res += dp[N][i][i * X]

    print(res)


if __name__ == "__main__":
    main()



Fixed submission:
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
# mod = 10 ** 9 + 7
mod = 998244353 

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]
def init_dp1(init, N): return [init for _ in range(N)]
def init_dp2(init, N, M): return [[init for _ in range(M)] for _ in range(N)]


def main():
    N, X = read_values()
    A = read_list()

    dp = [[[0 for _ in range(N * X + 1)] for _ in range(N + 1)] for _ in range(N + 1)]
    

    dp[0][0][0] = 1

    for i, a in enumerate(A):
        for j in range(N + 1):
            for k in range(N * X):
                if k + a <= N * X and j < N:
                    dp[i + 1][j + 1][k + a] += dp[i][j][k]
                dp[i + 1][j][k] += dp[i][j][k]
    
    res = 0
    for i in range(1, N + 1):
        res += dp[N][i][i * X]

    print(res)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import math
n = int(input())


#if math.sqrt(n-1).is_integer():

def yakusu(n):
    count=0
    if math.sqrt(n).is_integer():
        for i in range(1,int(math.sqrt(n))+1):
            if n% i == 0:
                count+=1
        return (count*2-1)
    else:
        for i in range(1,int(math.sqrt(n))+1):
            if n%i ==0:
                count+=1
        return count*2        

ans=0
for i in range(1,n):
    ans+=yakusu(i)
print(ans)


Fixed submission:
N = int(input())

ans = 0
for A in range(1, N):
    ans += (N // A)
    if N % A == 0:
        ans -= 1


print(ans)
Buggy python submission (verdict: Runtime Error):
N,X,M = map(int,input().split())

ans = X
A = X
TF = True
srt = 1000000
retu = [X]
d = dict()
d[X] = 0
loop = X
for i in range(N-1):
    if TF:
        A = A**2 % M
        if d.get(A) != None:
          srt = d[A] + 1
          goal = i
          TF = False
          
        if TF:
          retu.append(A)
          d[A] = i
          loop += A
    else:
      break
      
if N-1 > srt:
    n = (N-srt)//(goal-srt+1)
    saisyo = sum(retu[:srt])
    loop -= saisyo
    print(saisyo + loop*n + sum(retu[srt:N-n*(goal-srt+1)]))
    
else:
    print(sum(retu[:N]))


Fixed submission:
N, X, M = map(int, input().split())

candicate = [pow(i, 2, M) for i in range(M)]
ans = 0
now = X
A = [0]
X2 = pow(X, 2, M)

d = dict()

flag = True
for i in range(1, N+1):
    if i == 1:
        A.append(X)
    
    else:
        nxt = candicate[A[i-1]]

        if d.get(nxt) == None:
            if nxt == 0:
                A.append(nxt)
                break
            else:
                A.append(nxt)
                d[nxt] = i

        else:
            flag = False
            break


if flag:
    print(sum(A))
else:
    l = d[nxt]
    r = i - 1
    circle_total = 0
    for j in range(l, r+1):
        circle_total += A[j]
    
    for j in range(1, l):
        ans += A[j]

    width = r - l + 1
    N -= (l - 1)
    ans += circle_total * (N // width)

    for j in range(l, l + N % width):
        ans += A[j]

    print(ans)

Buggy python submission (verdict: Runtime Error):
N,X,M = map(int,input().split())

ans = X
A = X
TF = True
srt = 1000000
retu = dict()
retu[X] = 1
loop = X
for i in range(N-1):
    if TF:
        A = A**2 % M
        if retu.get(A) != None:
          srt = j
          goal = i
          TF = False
          break   
        if TF:
          retu[A] = 1
          loop += A
    else:
      break
      
if N-1 > srt:
    n = (N-srt)//(goal-srt+1)
    saisyo = sum(retu[:srt])
    loop -= saisyo
    print(saisyo + loop*n + sum(retu[srt:N-n*(goal-srt+1)]))
    
else:
    print(sum(retu[:N]))


Fixed submission:
N, X, M = map(int, input().split())

candicate = [pow(i, 2, M) for i in range(M)]
ans = 0
now = X
A = [0]
X2 = pow(X, 2, M)

d = dict()

flag = True
for i in range(1, N+1):
    if i == 1:
        A.append(X)
    
    else:
        nxt = candicate[A[i-1]]

        if d.get(nxt) == None:
            if nxt == 0:
                A.append(nxt)
                break
            else:
                A.append(nxt)
                d[nxt] = i

        else:
            flag = False
            break


if flag:
    print(sum(A))
else:
    l = d[nxt]
    r = i - 1
    circle_total = 0
    for j in range(l, r+1):
        circle_total += A[j]
    
    for j in range(1, l):
        ans += A[j]

    width = r - l + 1
    N -= (l - 1)
    ans += circle_total * (N // width)

    for j in range(l, l + N % width):
        ans += A[j]

    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# import math
N = int(input())

def f(x,y,z):
    return x**2 + y**2 + z**2 + x*y + y*z + z*x

ans = [0]*(N+1)

# upper = math.ceil(math.sqrt(N/6)) + 1
upper = N
for x in range(1, upper+1):
    for y in range(1, upper + 1):
        for z in range(1, upper + 1):
            v = f(x,y,z)
            if v <= N:
                ans[v] += 1
            else:
                break

for i in range(1, N+1):
    print(ans[i])

Fixed submission:
N = int(input())

ans = [0]*(N+1)
for x in range(1, 101):
  for y in range(1, 101):
    for z in range(1, 101):
      n = pow(x,2) + pow(y,2) + pow(z,2) + x*y + y*z + z*x
      if n <= N:
        ans[n] += 1
        
for i in range(1,N+1):
  print(ans[i])

Buggy python submission (verdict: Runtime Error):
N = int(input())

ans = [0]*(N+1)
for x in range(1, 101):
  for y in range(1, 101):
    for z in range(1, 101):
      n = x^2 + y^2 + z^2 + xy + yz + zx
      if n <= N:
        ans[n] += 1
        
for i in range(1,N):
  print(ans[i])

Fixed submission:
N = int(input())

ans = [0]*(N+1)
for x in range(1, 101):
  for y in range(1, 101):
    for z in range(1, 101):
      n = pow(x,2) + pow(y,2) + pow(z,2) + x*y + y*z + z*x
      if n <= N:
        ans[n] += 1
        
for i in range(1,N+1):
  print(ans[i])
Buggy python submission (verdict: Runtime Error):
from collections import deque

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

A.sort()
d = deque()
for i in range(N-1):
    if A[i] != A[i+1]:
        d.append(A[i])
if A[N-1] != A[N-2]:
    d.append(A[N-1])

ans = 0
max_A = max(A)
ban = [0]*max_A
while len(d):
    num = d.popleft()
    if ban[num] != 1:
        ans += 1
        ban_num = num
        while ban_num <= max_A:
            ban[ban_num] = 1
            ban_num += num

print(ans)

Fixed submission:
from collections import deque

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

A.sort()

ans = 0
max_A = max(A)
ban = [0]*(max_A+1)
again = list()

last = 0
for i in range(N-1):
    if A[i] == A[i+1] and A[i] != last:
        again.append(A[i])
        last = A[i]
if N > 1 and A[N-1] == A[N-2] and A[N-1] != last:
    again.append(A[N-1])

for num in again:
    ban_num = num
    while ban_num <= max_A:
        ban[ban_num] = 1
        ban_num += num
 
for num in A:
    if ban[num] != 1:
        ans += 1
        ban_num = num
        while ban_num <= max_A:
            ban[ban_num] = 1
            ban_num += num

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
MOD = 998244353
N, S = map(int, input().split())
A = list(map(int, input().split()))

dp = [[0 for j in range(S+1)] for i in range(N+1)] #dp[i][j] = i番目まで見て重さjのものを取る方法
dp[0][0] = 1

for i in range(N):
    for j in range(S+1):
        dp[i+1][j] += 2*dp[i][j]
        dp[i+1][j] %= MOD
        if j + A[i] <= S:
            dp[i+1][j+A[i]] += dp[i][j]
            dp[i+1][j+A[i]] %= MOD

for i in range(1, N):
    for j in range(S+1):
        non_get = 0
        get = 0
        non_get = dp[i-1][j] % MOD
    
        if j - A[i] >= 0:
            get = dp[i-1][j - A[i]] % MOD
        dp[i][j] = (2*non_get + get) % MOD
        
        

print(dp[N][S])            

# print(dp)
        

Fixed submission:
MOD = 998244353
N, S = map(int, input().split())
A = list(map(int, input().split()))

dp = [[0 for j in range(S+1)] for i in range(N+1)] #dp[i][j] = i番目まで見て重さjのものを取る方法
dp[0][0] = 1

# for i in range(N):
#     for j in range(S+1):
#         dp[i+1][j] += 2*dp[i][j]
#         dp[i+1][j] %= MOD
#         if j + A[i] <= S:
#             dp[i+1][j+A[i]] += dp[i][j]
#             dp[i+1][j+A[i]] %= MOD

for i in range(1, N+1):
    for j in range(S+1):
        get = 0
        non_get = 2*dp[i-1][j] % MOD
    
        if j - A[i-1] >= 0:
            get = dp[i-1][j - A[i-1]]
        dp[i][j] = (non_get + get) % MOD
        
        

print(dp[N][S])            

# print(dp)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
Sunuke = [0]*N
d = list()
A = list()
for _ in range(K):
  d = int(input()
  A = list(map(int, input().split()))
  for a in A:
    Sunuke[a-1] += 1

ans = 0
for s in Sunuke:
  if s == 0:
     ans += 1
print(ans)


Fixed submission:
N, K = map(int, input().split())
people = [1]*N
for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for j in range(d):
        if people[A[j] - 1] == 1:
            people[A[j] - 1] = 0

print(sum(people))
Buggy python submission (verdict: Time Limit Exceeded):
A, B, N = map(int, input().split())
pre_x = list()
ind = B-1
while ind <= N:
    pre_x.append(ind)
    ind += B

if len(pre_x) == 0:
    ans = int(A*N/B) - A*int(N/B)
    print(ans)
else:
    ans = 0
    for x in pre_x:
        ans = max(ans, int(A*x/B) - A*int(x/B))
    
    print(ans)

Fixed submission:
A, B, N = map(int, input().split())
# pre_x = list()
# ind = B-1
# while ind <= N:
#     pre_x.append(ind)
#     ind += B

# if len(pre_x) == 0:
#     ans = int(A*N/B) - A*int(N/B)
#     print(ans)
# else:
#     ans = 0
#     for x in pre_x:
#         ans = max(ans, int(A*x/B) - A*int(x/B))
    
#     print(ans)

# if B > N:
#     print(int(A*N/B) - A*int(N/B))
# else:
#     x_under = max(int())

if B > N:
    print(int(A*N/B) - A*int(N/B))
else:
    x = B - 1
    print(int(A*x/B) - A*int(x/B))

Buggy python submission (verdict: Time Limit Exceeded):
A, B, N = map(int, input().split())
pre_x = list()
ind = B-1
while ind <= N:
    pre_x.append(ind)
    ind += B

if len(pre_x) == 0:
    ans = int(A*N/B) - A*int(N/B)
    print(ans)
else:
    ans = 0
    for x in pre_x:
        ans = max(ans, int(A*x/B) - A*int(x/B))
    
    print(ans)

Fixed submission:
A, B, N = map(int, input().split())
# pre_x = list()
# ind = B-1
# while ind <= N:
#     pre_x.append(ind)
#     ind += B

# if len(pre_x) == 0:
#     ans = int(A*N/B) - A*int(N/B)
#     print(ans)
# else:
#     ans = 0
#     for x in pre_x:
#         ans = max(ans, int(A*x/B) - A*int(x/B))
    
#     print(ans)

# if B > N:
#     print(int(A*N/B) - A*int(N/B))
# else:
#     x_under = max(int())

if B > N:
    print(int(A*N/B) - A*int(N/B))
else:
    x = B - 1
    print(int(A*x/B) - A*int(x/B))
Buggy python submission (verdict: Time Limit Exceeded):
def get_ij(ij, S, rem_i):
    length = len(rem_i)
    for i in range(length):
        for j in range(i+1, length):
            ij.append([rem_i[i], rem_i[j]])
    
    return 0

S = input()
length = len(S)
ruiseki_sum = [0]*length
ruiseki_sum[0] = int(S[0])
for i in range(length):
    if i != 0:
        ruiseki_sum[i] = ruiseki_sum[i-1] + int(S[i])

ruiseki_rem = [0]*length
for i in range(length):
    ruiseki_rem[i] = ruiseki_sum[i] % 3

rem_0_i = list()
rem_1_i = list()
rem_2_i = list()

for i in range(length):
    if ruiseki_rem[i] == 0:
        rem_0_i.append(i)
    elif ruiseki_rem[i] == 1:
        rem_1_i.append(i)
    else:
        rem_2_i.append(i)
    
ij = list()
get_ij(ij, S, rem_0_i)
get_ij(ij, S, rem_1_i)
get_ij(ij, S, rem_2_i)

# print(rem_0_i)
# print(rem_1_i)
# print(rem_2_i)
# print(ij)

ans = 0
for ind in range(len(ij)):
    i = ij[ind][0] + 1
    j = ij[ind][1] + 1
    if int(S[i:j]) % 2019 == 0:
        # print(S[i:j], i, j)
        ans += 1

for i in range(1, length):
    if int(S[:i]) % 2019 == 0:
        # print(S[:i], i, j)
        ans += 1
print(ans)

Fixed submission:
S = list(reversed(input()))

length = len(S)

a = [0]*length
for i in range(length):
    pickup = int(S[i])
    a[i] = pickup*pow(10, i, 2019)

b = [0]*(length+1)
for i in range(1, length+1):
    b[i] = (b[i-1] + a[i-1]) % 2019
cnt, ans = [0] * 2019, 0
for x in b:
    ans += cnt[x]
    cnt[x] += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def get_ij(ij, S, rem_i):
    length = len(rem_i)
    for i in range(length):
        for j in range(i+1, length):
            ij.append([rem_i[i], rem_i[j]])
    
    return 0

S = input()
length = len(S)
ruiseki_sum = [0]*length
ruiseki_sum[0] = int(S[0])
for i in range(length):
    if i != 0:
        ruiseki_sum[i] = ruiseki_sum[i-1] + int(S[i])

ruiseki_rem = [0]*length
for i in range(length):
    ruiseki_rem[i] = ruiseki_sum[i] % 3

rem_0_i = list()
rem_1_i = list()
rem_2_i = list()

for i in range(length):
    if ruiseki_rem[i] == 0:
        rem_0_i.append(i)
    elif ruiseki_rem[i] == 1:
        rem_1_i.append(i)
    else:
        rem_2_i.append(i)
    
ij = list()
get_ij(ij, S, rem_0_i)
get_ij(ij, S, rem_1_i)
get_ij(ij, S, rem_2_i)

# print(rem_0_i)
# print(rem_1_i)
# print(rem_2_i)
# print(ij)

ans = 0
for ind in range(len(ij)):
    i = ij[ind][0] + 1
    j = ij[ind][1] + 1
    if int(S[i:j]) % 2019 == 0:
        # print(S[i:j], i, j)
        ans += 1

for i in range(1, length):
    if int(S[:i]) % 2019 == 0:
        # print(S[:i], i, j)
        ans += 1
print(ans)

Fixed submission:
S = list(reversed(input()))

length = len(S)

a = [0]*length
for i in range(length):
    pickup = int(S[i])
    a[i] = pickup*pow(10, i, 2019)

b = [0]*(length+1)
for i in range(1, length+1):
    b[i] = (b[i-1] + a[i-1]) % 2019
cnt, ans = [0] * 2019, 0
for x in b:
    ans += cnt[x]
    cnt[x] += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math

K = int(input())

ans = 0
for a in range(1, K+1):
  for b in range(1, K+1):
    for c in range(1, K+1):
      tmp = math.gcd(a,b)
      ans += math.gcd(tmp, c)

print(ans)


Fixed submission:
import math

K = int(input())

gcd_tmp = list()
total = 0
for b in range(1, K+1):
    for c in range(1, K+1):
        tmp = math.gcd(b, c)
        gcd_tmp.append(tmp)

gcd_tmp.sort()
length = len(gcd_tmp)

type_of_gcd = list()
num_of_gcd = list()

counter = 0
for i in range(length-1):
    counter += 1
    if gcd_tmp[i] != gcd_tmp[i+1]:
        type_of_gcd.append(gcd_tmp[i])
        num_of_gcd.append(counter)
        counter = 0
type_of_gcd.append(gcd_tmp[-1])
num_of_gcd.append(counter+1)

# print(gcd_tmp)
# print(type_of_gcd)
# print(num_of_gcd)


for a in range(1, K+1):
    for i in range(len(type_of_gcd)):
        tmp = math.gcd(a, type_of_gcd[i])
        total += tmp*num_of_gcd[i]

print(total)

Buggy python submission (verdict: Runtime Error):
import math

K = int(input(K))

ans = 0
for a in range(1, K+1):
  for b in range(1, K+1):
    for c in range(1, K+1):
      tmp = math.gcd(a,b)
      ans += math.gcd(tmp, c)

print(ans)


Fixed submission:
import math

K = int(input())

gcd_tmp = list()
total = 0
for b in range(1, K+1):
    for c in range(1, K+1):
        tmp = math.gcd(b, c)
        gcd_tmp.append(tmp)

gcd_tmp.sort()
length = len(gcd_tmp)

type_of_gcd = list()
num_of_gcd = list()

counter = 0
for i in range(length-1):
    counter += 1
    if gcd_tmp[i] != gcd_tmp[i+1]:
        type_of_gcd.append(gcd_tmp[i])
        num_of_gcd.append(counter)
        counter = 0
type_of_gcd.append(gcd_tmp[-1])
num_of_gcd.append(counter+1)

# print(gcd_tmp)
# print(type_of_gcd)
# print(num_of_gcd)


for a in range(1, K+1):
    for i in range(len(type_of_gcd)):
        tmp = math.gcd(a, type_of_gcd[i])
        total += tmp*num_of_gcd[i]

print(total)

Buggy python submission (verdict: Runtime Error):
import math

K = int(input(K))

ans = 0
for a in range(1, K+1):
  for b in range(1, K+1):
    for c in range(1, K+1):
      tmp = gcd(a,b)
      ans += gcd(tmp, c)

print(ans)

Fixed submission:
import math

K = int(input())

gcd_tmp = list()
total = 0
for b in range(1, K+1):
    for c in range(1, K+1):
        tmp = math.gcd(b, c)
        gcd_tmp.append(tmp)

gcd_tmp.sort()
length = len(gcd_tmp)

type_of_gcd = list()
num_of_gcd = list()

counter = 0
for i in range(length-1):
    counter += 1
    if gcd_tmp[i] != gcd_tmp[i+1]:
        type_of_gcd.append(gcd_tmp[i])
        num_of_gcd.append(counter)
        counter = 0
type_of_gcd.append(gcd_tmp[-1])
num_of_gcd.append(counter+1)

# print(gcd_tmp)
# print(type_of_gcd)
# print(num_of_gcd)


for a in range(1, K+1):
    for i in range(len(type_of_gcd)):
        tmp = math.gcd(a, type_of_gcd[i])
        total += tmp*num_of_gcd[i]

print(total)
Buggy python submission (verdict: Runtime Error):
N, M = map(int,input().split())
s = [0]*M
c = [0]*M

for i in range(M):
    s[i], c[i] = map(int,input().split())

ans = [0]*N
if N != 1:
    ans[0] = 1
error = 0

assign = [0]*M
for i in range(M):
    assign[s[i]- 1] += 1

    if assign[s[i] - 1] > 1 and ans[s[i] - 1] != c[i]:
        error += 1

    ans[s[i] - 1] = c[i]
    


if ans[0] == 0 and N != 1:
    error += 1 

if error == 0:
    for i in range(N):
        print(ans[i], end = "")
    print()
else:
    print(-1)


Fixed submission:
N, M = map(int,input().split())
s = [0]*M
c = [0]*M

for i in range(M):
    s[i], c[i] = map(int,input().split())

ans = [0]*N
if N != 1:
    ans[0] = 1
error = 0

assign = [0]*N
for i in range(M):
    assign[s[i]- 1] += 1

    if assign[s[i] - 1] > 1 and ans[s[i] - 1] != c[i]:
        error += 1

    ans[s[i] - 1] = c[i]
    


if ans[0] == 0 and N != 1:
    error += 1 

if error == 0:
    for i in range(N):
        print(ans[i], end = "")
    print()
else:
    print(-1)

Buggy python submission (verdict: Runtime Error):
N, M = map(int,input().split())
s = [0]*M
c = [0]*M

for i in range(M):
    s[i], c[i] = map(int,input().split())

ans = [0]*M
ans[0] = 1
error = 0

assign = [0]*M
for i in range(M):
    assign[s[i]- 1] += 1

    if assign[s[i] - 1] > 1 and ans[s[i] - 1] != c[i]:
        error += 1

    ans[s[i] - 1] = c[i]
    


if ans[0] == 0:
    error += 1 

if error == 0:
    for i in range(M):
        print(ans[i], end = "")
    print()
else:
    print(-1)


Fixed submission:
N, M = map(int,input().split())
s = [0]*M
c = [0]*M

for i in range(M):
    s[i], c[i] = map(int,input().split())

ans = [0]*N
if N != 1:
    ans[0] = 1
error = 0

assign = [0]*N
for i in range(M):
    assign[s[i]- 1] += 1

    if assign[s[i] - 1] > 1 and ans[s[i] - 1] != c[i]:
        error += 1

    ans[s[i] - 1] = c[i]
    


if ans[0] == 0 and N != 1:
    error += 1 

if error == 0:
    for i in range(N):
        print(ans[i], end = "")
    print()
else:
    print(-1)
Buggy python submission (verdict: Time Limit Exceeded):

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

s_max = 0
for j in range(N - K + 1):
    s = sum(p[j:j+K])

    if s_max < s:
        s_max = s

print((s_max+K)/2)

Fixed submission:

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


s = sum(p[0:K])
s_max = s

for i in range(N-K):
    s = s -p[i] + p[i+K]

    if s_max < s:
        s_max = s

print((s_max+K)/2)

Buggy python submission (verdict: Time Limit Exceeded):

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

for i in range(N):
    p[i] = (p[i]+1) / 2

s_max = 0
for j in range(N - K + 1):
    s = sum(p[j:j+K])

    if s_max < s:
        s_max = s

print(s_max)

Fixed submission:

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


s = sum(p[0:K])
s_max = s

for i in range(N-K):
    s = s -p[i] + p[i+K]

    if s_max < s:
        s_max = s

print((s_max+K)/2)

Buggy python submission (verdict: Time Limit Exceeded):

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

s_max = 0
for j in range(N - K + 1):
    s = 0
    for i in range(K):
        s += (p[i+j] + 1) / 2

    if s_max < s:
        s_max = s

print(s_max)

Fixed submission:

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


s = sum(p[0:K])
s_max = s

for i in range(N-K):
    s = s -p[i] + p[i+K]

    if s_max < s:
        s_max = s

print((s_max+K)/2)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(map(int, input().split()))
ans = 1

min_P = P[0]

for i in range(1, N):
    tmp_P = P[:i]
    if min_P >= P[i]:
        ans += 1
        min_P = P[i]

print(ans)

Fixed submission:
N = int(input())
P = list(map(int, input().split()))
ans = 1

min_P = P[0]

for i in range(1, N):
    if min_P >= P[i]:
        ans += 1
        min_P = P[i]

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(map(int, input().split()))
ans = 1

for i in range(1, N):
    tmp_P = P[:i]
    if min(tmp_P) >= P[i]:
        ans += 1

print(ans)

Fixed submission:
N = int(input())
P = list(map(int, input().split()))
ans = 1

min_P = P[0]

for i in range(1, N):
    if min_P >= P[i]:
        ans += 1
        min_P = P[i]

print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
P = list(map(int, input().split()))
ans = 0

for i in range(N):
    tmp_P = P[:i]
    if min(tmp_P) >= P[i]:
        ans += 1

print(ans)

Fixed submission:
N = int(input())
P = list(map(int, input().split()))
ans = 1

min_P = P[0]

for i in range(1, N):
    if min_P >= P[i]:
        ans += 1
        min_P = P[i]

print(ans)