Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
input = sys.stdin.readline
n, k = map(int,input().split())

lst = [[int(i) for i in input().split()] for _ in range(n)]

lst.sort(key = lambda x: x[0])

for [i, j] in lst:
    if j >= k:
        print(i)
        quit()
    else:
        k -= j

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

lst = [[int(i) for i in input().split()] for _ in range(n)]

lst.sort(key = lambda x: x[0])

for [i, j] in lst:
    if j >= k:
        print(i)
        quit()
    else:
        k -= j
Buggy python submission (verdict: Runtime Error):
a,b = int(input()), int(input())

print('GREATER' if a>b or 'LESS')

Fixed submission:
a,b = int(input()), int(input())

if a > b:
    print('GREATER')
elif a < b:
    print('LESS')
else:
    print('EQUAL')
Buggy python submission (verdict: Runtime Error):
import sys


def func(lst, sign):
  cur, res = 0, 0
  for i in alst:
    cur += i
    if sign and cur <= 0:
      res += abs(cur) + 1
      cur = 1
    elif not sign and cur >= 0:
      res += abs(cur) + 1
      cur = -1
    sign = not sign
  return res


def main():
  n, *alst = map(int, sys.stdin.read().split())
  print(min(func(alst, True), func(alst, False)))


if __name__ == '__main__':
  main()

Fixed submission:
import sys


def func(alst, sign):
  cur, res = 0, 0
  for i in alst:
    cur += i
    if sign and cur <= 0:
      res += abs(cur) + 1
      cur = 1
    elif not sign and cur >= 0:
      res += abs(cur) + 1
      cur = -1
    sign = not sign
  return res


def main():
  n, *alst = map(int, sys.stdin.read().split())
  print(min(func(alst, True), func(alst, False)))


if __name__ == '__main__':
  main()
Buggy python submission (verdict: Runtime Error):
n = int(input())
mod = 10 ** 9 + 7
def a(n):
    if n == 1:
        return n
    else:
        return n * (a(n - 1))

print(a(n) % mod)

Fixed submission:
n = int(input())
mod = 10 ** 9 + 7
def a(n):
    s = 1
    for i in range(1, n + 1):
        s = (s * i) % mod
    return s

print(a(n))
Buggy python submission (verdict: Runtime Error):
n, ma, mb = [int(i) for i in input().split()]
lst = [[int(i) for i in input().split()] for _ in range(n)]
lst.sort(key=lambda x: x[2])

def push(k,v):
    if k in dic:
        dic[k] = min(dic[k],v)
    else:
        dic[k] = v


for i in lst:
    k, v = i[0] * mb - i[1] * ma, i[2]
    l = [[j, dic[j]] for j in dic]
    for item in l:
        push(item[0] + k, item[1] + v)
    push(k, v)

print(dic[0] if 0 in dic else '-1')

Fixed submission:
n, ma, mb = [int(i) for i in input().split()]
lst = [[int(i) for i in input().split()] for _ in range(n)]
lst.sort(key=lambda x: x[2])
dic = {}
def push(k,v):
    if k in dic:
        dic[k] = min(dic[k],v)
    else:
        dic[k] = v


for i in lst:
    k, v = i[0] * mb - i[1] * ma, i[2]
    l = [[j, dic[j]] for j in dic]
    for item in l:
        push(item[0] + k, item[1] + v)
    push(k, v)

print(dic[0] if 0 in dic else '-1')
Buggy python submission (verdict: Runtime Error):
k,s = [int(i) for i in input().split()]
def a(n):
return int(n * (n + 1) / 2)
  
if s <= k:
  print(a(s + 1))
elif s >= 2 * k and s <= 3 * k:
  print(a(3 * k - s + 1))
elif s > k and s < 2 * k:
  print(a(s + 1) - 3 * a(s - k))
else:
  print(0)

Fixed submission:
k,s = [int(i) for i in input().split()]
def a(n):
  return int(n * (n + 1) / 2)
  
if s <= k:
  print(a(s + 1))
elif s >= 2 * k and s <= 3 * k:
  print(a(3 * k - s + 1))
elif s > k and s < 2 * k:
  print(a(s + 1) - 3 * a(s - k))
else:
  print(0)

Buggy python submission (verdict: Runtime Error):
k,s = [int(i) for i in input().split()]
def a(n):
  if n == 1:
    return n
  else:
    return n + a(n-1)
  
if s <= k:
  print(a(s + 1))
elif s >= 2 * k and s <= 3 * k:
  print(a(3 * k - s + 1))
elif s > k and s < 2 * k:
  print(a(s + 1) - 3 * a(s - k))
else:
  print(0)

Fixed submission:
k,s = [int(i) for i in input().split()]
def a(n):
  return int(n * (n + 1) / 2)
  
if s <= k:
  print(a(s + 1))
elif s >= 2 * k and s <= 3 * k:
  print(a(3 * k - s + 1))
elif s > k and s < 2 * k:
  print(a(s + 1) - 3 * a(s - k))
else:
  print(0)

Buggy python submission (verdict: Runtime Error):
k,s = [int(i) for i in input().split()]
def a(n):
  if n == 1:
    return n
  else:
    return n + a(n-1)
  
if s <= k:
  print(a(s+1))
elif s >= 2 * k and s <= 3 * k:
  print(a(3 * k - s + 1))
elif s > k and s < 2 * k:
  print(a(s + 1) - 3 * a(s - k))

Fixed submission:
k,s = [int(i) for i in input().split()]
def a(n):
  return int(n * (n + 1) / 2)
  
if s <= k:
  print(a(s + 1))
elif s >= 2 * k and s <= 3 * k:
  print(a(3 * k - s + 1))
elif s > k and s < 2 * k:
  print(a(s + 1) - 3 * a(s - k))
else:
  print(0)

Buggy python submission (verdict: Runtime Error):
k,s = [int(i) for i in input().split()]


def a(n):
  if n == 1:
    return n
  else:
    return n + a(n-1)
  
if k >= s:
  print(a(s+1))
elif s >= 2 * k and s <= 3 * k:
  print(a(3 * k - s + 1))
elif s > k and s < 2 * k:
  print(a(s + 1) - 3 * a(s - k))
else:

Fixed submission:
k,s = [int(i) for i in input().split()]
def a(n):
  return int(n * (n + 1) / 2)
  
if s <= k:
  print(a(s + 1))
elif s >= 2 * k and s <= 3 * k:
  print(a(3 * k - s + 1))
elif s > k and s < 2 * k:
  print(a(s + 1) - 3 * a(s - k))
else:
  print(0)

Buggy python submission (verdict: Runtime Error):
k,s = [int(i) for i in input().split()]


def a(n):
  if n == 1:
    return n
  else:
    return n + a(n-1)
  
if k >= s:
  print(a(s+1))
elif s >= 2 * k and s <= 3 * k:
  print(a(3 * k - s + 1))
else:
  print(a(s + 1) -3 * a(s - k))

Fixed submission:
k,s = [int(i) for i in input().split()]
def a(n):
  return int(n * (n + 1) / 2)
  
if s <= k:
  print(a(s + 1))
elif s >= 2 * k and s <= 3 * k:
  print(a(3 * k - s + 1))
elif s > k and s < 2 * k:
  print(a(s + 1) - 3 * a(s - k))
else:
  print(0)
Buggy python submission (verdict: Runtime Error):
a,b,c = input(),input(),input()
print(a[0]+b[0]+c[0])

Fixed submission:
a,b,c = input().split()
print(a[0]+b[0]+c[0])
Buggy python submission (verdict: Runtime Error):
import sys

n, x, *lst = map(int, sys.stdin.read().split())
re1 = 0
lst.append(0)
for i in range(n, 0, -1):
  tmpsum = lst[i] + lst[i - 1]
  if tmpsum > x:
    res += tmpsum - x
    lst[i - 1] -= tmpsum - x

print(res)


Fixed submission:
import sys

n, x, *lst1 = map(int, sys.stdin.read().split())
res1 = res2 = 0
lst2 = [0] + lst1
lst1.append(0)
for i in range(n):
  tmpsum = lst2[i] + lst2[i + 1]
  if tmpsum > x:
    res1 += tmpsum - x
    lst2[i + 1] -= tmpsum - x

for i in range(n, 0, -1):
  tmpsum = lst1[i] + lst1[i - 1]
  if tmpsum > x:
    res2 += tmpsum - x
    lst1[i - 1] -= tmpsum - x  
print(min(res1, res2))
Buggy python submission (verdict: Runtime Error):
lst = [int(i) for i in input().split()]

m = max(lst)
if sum(lst) = 2*m:
  print('Yes')
else:
  print('No')

Fixed submission:
lst = [int(i) for i in input().split()]

m = max(lst)
if sum(lst) == 2*m:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

s = input()

grid = [0 if i == 'g' else 1 for i in s]


def biggest(grid):
    dist = [float('-inf')] * len(s)
    move = (0, 1)
    st = deque([[0, 0, 0, 0]])
    while st:
        g, p, idx, cur = st.popleft()
        if idx > len(s) - 1:
            continue
        for a in move:
            if a:
                if p + 1 > g:
                    continue
                tmpg, tmpp = g, p + 1
            else:
                tmpg, tmpp = g + 1, p
            if a > grid[idx]:
                tmp = cur + 1
            elif a < grid[idx]:
                tmp = cur - 1
            else:
                tmp = cur
            if dist[idx] < tmp:
                dist[idx] = tmp
            st.append([tmpg, tmpp, idx + 1, tmp])
    return dist[-1]


print(biggest(grid))


Fixed submission:
s = input()
p = sum(1 for i in s if i == 'p')
l = len(s)
print(l // 2 - p)

Buggy python submission (verdict: Runtime Error):
s = input()

grid = [0 if i == 'g' else 1 for i in s]


def biggest(grid):
    dist = [float('-inf')] * len(s)
    move = (0, 1)
    st = deque([[0, 0, 0, 0]])
    while st:
        g, p, idx, cur = st.popleft()
        if idx > len(s) - 1:
            continue
        for a in move:
            if a:
                if p + 1 > g:
                    continue
                tmpg, tmpp = g, p + 1
            else:
                tmpg, tmpp = g + 1, p
            if a > grid[idx]:
                tmp = cur + 1
            elif a < grid[idx]:
                tmp = cur - 1
            else:
                tmp = cur
            if dist[idx] < tmp:
                dist[idx] = tmp
            st.append([tmpg, tmpp, idx + 1, tmp])
    return dist[-1]


print(biggest(grid))


Fixed submission:
s = input()
p = sum(1 for i in s if i == 'p')
l = len(s)
print(l // 2 - p)
Buggy python submission (verdict: Runtime Error):
x = input()
res = [x[0]]
for i in x[1:]:
  if i == 'S':
    res += [i]
  else:
    if res[-1] == 'S':
      res.pop()
    else:
      res += [i]
print(len(res))


Fixed submission:
x = input()
res = [x[0]]
for i in x[1:]:
  if i == 'S':
    res += [i]
  elif not res:
    res += [i]
  else:
    if res[-1] == 'S':
      res.pop()
    else:
      res += [i]
print(len(res))
Buggy python submission (verdict: Runtime Error):
def powerset(iterable):
    s = list(iterable)
    return chain.from_iterable(combinations(s, r) for r in range(len(s) + 1))


def s_to_num(s):
    numlst = list(map(int, s))
    res = 0
    for i in numlst:
        res *= 10
        res += i
    return res


s = input()
length = len(s)
res = 0
for i in powerset(range(1, length)):
    if not i:
        res += int(s)
    else:
        jlst = [0] + list(i) + [length]
        for j in range(len(jlst) - 1):
            res += s_to_num(s[jlst[j]:jlst[j + 1]])
print(res)

Fixed submission:
from itertools import chain, combinations


def powerset(iterable):
    s = list(iterable)
    return chain.from_iterable(combinations(s, r) for r in range(len(s) + 1))


def s_to_num(s):
    numlst = list(map(int, s))
    res = 0
    for i in numlst:
        res *= 10
        res += i
    return res


s = input()
length = len(s)
res = 0
for i in powerset(range(1, length)):
    if not i:
        res += int(s)
    else:
        jlst = [0] + list(i) + [length]
        for j in range(len(jlst) - 1):
            res += s_to_num(s[jlst[j]:jlst[j + 1]])
print(res)
Buggy python submission (verdict: Runtime Error):
def a(s):
  if s == 1:
    return s
  return s + a(s-1) 

print(a(int(input()))

Fixed submission:
def a(s):
  if s == 1:
    return s
  return s + a(s-1) 

print(a(int(input())))
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
#
# Author: Tetsuya Ishikawa <tiskw111@gmail.com>
# Date  : July 05, 2020
##################################################### SOURCE START #####################################################

import heapq

N = int(input().strip())
As = list(map(lambda s: -int(s), input().strip().split()))

heapq.heapify(As)

for n in range(N):
    a = - heapq.heappop(As)
    if   n == 0:
        g, gs = 0, [a]
    elif n == 1:
        g, gs = gs[0], [a, a]
    else:
        max_g = max(gs)
        idx_g = gs.index(max_g)
        g += gs[idx_g]
        gs[idx_g] = a
        gs.insert(idx_g, a)

print(g)

##################################################### SOURCE FINISH ####################################################
# vim: expandtab tabstop=4 shiftwidth=4 fdm=marker


Fixed submission:
#!/usr/bin/env python3
#
# Author: Tetsuya Ishikawa <tiskw111@gmail.com>
# Date  : July 05, 2020
##################################################### SOURCE START #####################################################

import heapq
import collections

N = int(input().strip())
As = list(map(lambda s: -int(s), input().strip().split()))

heapq.heapify(As)

g  = 0
gs = collections.deque()

for n in range(N):

    a = - heapq.heappop(As)

    if n == 0:
        gs.append(a)    
    else:
        g += gs.popleft()
        gs.append(a)
        gs.append(a)

print(g)

##################################################### SOURCE FINISH ####################################################
# vim: expandtab tabstop=4 shiftwidth=4 fdm=marker
Buggy python submission (verdict: Runtime Error):
n = int(input())
inp = {}
for i in range(n):
  a = input()
  if inp.get(a) is None:
    inp[a] = 0
  inp[a] += 1

  print(f"AC x {inp['AC']}")
  print(f"WA x {inp['WA']}")
  print(f"TLE x {inp['TLE']}")
  print(f"RE x {inp['RE']}")


Fixed submission:
n = int(input())
inp = {}
for i in range(n):
    a = input()
    if inp.get(a) is None:
        inp[a] = 0
    inp[a] += 1
print(f"AC x {0 if inp.get('AC') is None else inp.get('AC')}")
print(f"WA x {0 if inp.get('WA') is None else inp.get('WA')}")
print(f"TLE x {0 if inp.get('TLE') is None else inp.get('TLE')}")
print(f"RE x {0 if inp.get('RE') is None else inp.get('RE')}")

Buggy python submission (verdict: Runtime Error):
n = int(input())
inp = {}
for i in range(n):
  a = input()
  if inp.get(a) is None:
    inp[a] = 0
  inp[a] += 1

  print(f"AC x {result['AC']}")
  print(f"WA x {result['WA']}")
  print(f"TLE x {result['TLE']}")
  print(f"RE x {result['RE']}")


Fixed submission:
n = int(input())
inp = {}
for i in range(n):
    a = input()
    if inp.get(a) is None:
        inp[a] = 0
    inp[a] += 1
print(f"AC x {0 if inp.get('AC') is None else inp.get('AC')}")
print(f"WA x {0 if inp.get('WA') is None else inp.get('WA')}")
print(f"TLE x {0 if inp.get('TLE') is None else inp.get('TLE')}")
print(f"RE x {0 if inp.get('RE') is None else inp.get('RE')}")

Buggy python submission (verdict: Runtime Error):
n = int(input())
inp = {}
for i in range(n):
  a = input()
  if inp.get(a) is not None:
    inp[a] = 0
  inp[a] += 1

  print(f"AC x {result['AC']}")
  print(f"WA x {result['WA']}")
  print(f"TLE x {result['TLE']}")
  print(f"RE x {result['RE']}")


Fixed submission:
n = int(input())
inp = {}
for i in range(n):
    a = input()
    if inp.get(a) is None:
        inp[a] = 0
    inp[a] += 1
print(f"AC x {0 if inp.get('AC') is None else inp.get('AC')}")
print(f"WA x {0 if inp.get('WA') is None else inp.get('WA')}")
print(f"TLE x {0 if inp.get('TLE') is None else inp.get('TLE')}")
print(f"RE x {0 if inp.get('RE') is None else inp.get('RE')}")
Buggy python submission (verdict: Time Limit Exceeded):
import sys
# sys.setrecursionlimit(10**10)
N = int(sys.stdin.readline().rstrip())
# S = sys.stdin.readline().rstrip()
# N, K = map(int, sys.stdin.readline().rstrip().split())
A = list(map(int, sys.stdin.readline().rstrip().split()))

ans = 1
for a in A:
    ans *= a
if ans > 10 **18:
    print(-1)
else:
    print(ans)

Fixed submission:
import sys
# sys.setrecursionlimit(10**10)
N = int(sys.stdin.readline().rstrip())
# S = sys.stdin.readline().rstrip()
# N, K = map(int, sys.stdin.readline().rstrip().split())
A = list(map(int, sys.stdin.readline().rstrip().split()))

if 0 in A:
    print(0)
    exit()

ans = 1
for a in A:
    ans *= a
    if ans > 10 **18:
        print(-1)
        exit()
else:
    print(ans)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3

N, M, K = map(int, input().split())
mod = 998244353

table = [0]
inv_table = [0]
M_table = []

tmp = pow(M - 1, N - 1, mod)
for i in range(K + 1):
    if i > 0:
        tmp *= pow(M - 1, mod - 2, mod)
        tmp %= mod
    M_table.append(tmp)

tmp = 1
for i in range(1, N + 1):
    tmp *= i
    tmp %= mod
    table.append(tmp)

tmp = 1
for i in range(1, N + 1):
    tmp *= pow(i, mod - 2, mod)
    tmp %= mod
    inv_table.append(tmp)

def cmb(n, r):
    if r == 0:
        return 1
    if n == r:
        return 1
    return table[n] * inv_table[r] * inv_table[n - r]

if M == 1:
    if K >= cmb(N, 2):
        print(1)
    else:
        print(0)

ans = 0
for i in range(K + 1):
    ans += M * M_table[i] * cmb(N - 1, i)
    ans %= mod

print(ans)

Fixed submission:
#!/usr/bin/env python3

N, M, K = map(int, input().split())
mod = 998244353

table = [0]
inv_table = [0]
M_table = []

tmp = pow(M - 1, N - 1, mod)
for i in range(K + 1):
    if i > 0:
        tmp *= pow(M - 1, mod - 2, mod)
        tmp %= mod
    M_table.append(tmp)

tmp = 1
for i in range(1, N + 1):
    tmp *= i
    tmp %= mod
    table.append(tmp)

tmp = 1
for i in range(1, N + 1):
    tmp *= pow(i, mod - 2, mod)
    tmp %= mod
    inv_table.append(tmp)

def cmb(n, r):
    if r == 0:
        return 1
    if n == r:
        return 1
    return table[n] * inv_table[r] * inv_table[n - r]

if M == 1:
    if N - 1 == K:
        print(1)
    else:
        print(0)
    exit()

ans = 0
for i in range(K + 1):
    ans += M * M_table[i] * cmb(N - 1, i)
    ans %= mod

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
diff_i = [A[i] + i + 1 for i in range(N)]
diff_j = [i + 1 - A[i] for i in range(N)]
diff = set(diff_i) & set(diff_j)
ans = 0
for d in diff:
    ans += diff_i.count(d) * diff_j.count(d)
print(ans)


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

cnt1 = {}
cnt2 = {}

for i in range(N):
    tmp1 = A[i] + i + 1
    tmp2 = i + 1 - A[i]
    if tmp1 not in cnt1:
        cnt1[tmp1] = 1
    else:
        cnt1[tmp1] += 1
    if tmp2 not in cnt2:
        cnt2[tmp2] = 1
    else:
        cnt2[tmp2] += 1

diff = set(list(cnt1.keys())) & set(list(cnt2.keys()))

ans = 0
for d in diff:
    ans += cnt1[d] * cnt2[d]
print(ans)
Buggy python submission (verdict: Runtime Error):
rom collections import deque
 
K = int(input())
que = deque([i for i in range(1, 10)])
lunlun = []
 
while que:
    num = que.pop()
    lunlun.append(num)
    for i in range(10):
        if abs(int(str(num)[-1]) - i) <= 1:
            cand = int(str(num) + str(i))
            if cand < 10000000000:
                que.append(cand)
 
lunlun.sort()
print(sorted(lunlun)[K - 1])

Fixed submission:
from collections import deque

K = int(input())
que = deque([i for i in range(1, 10)])
lunlun = []

while que:
    num = que.pop()
    lunlun.append(num)
    for i in range(10):
        if abs(int(str(num)[-1]) - i) <= 1:
            cand = int(str(num) + str(i))
            if cand < 10000000000:
                que.append(cand)

lunlun.sort()
print(sorted(lunlun)[K - 1])
Buggy python submission (verdict: Time Limit Exceeded):
import collections
import numpy as np

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

cnt = collections.Counter(A)

def cmb(n):
    return n * (n - 1) // 2
    
for i in range(N):
    tmp = cnt.copy()
    tmp[A[i]] -= 1
    ans = int(np.sum(np.array([cmb(k) for k in tmp.values() if k >= 2])))
    print(ans)
    

Fixed submission:
import collections
import numpy as np

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

cnt = collections.Counter(A)

B = [cnt[a] for a in A]

def cmb(n):
    return n * (n - 1) // 2
    
ans = int(sum([cmb(k) for k in cnt.values()]))

for b in B:
    print(ans - cmb(b) + cmb(b - 1))
Buggy python submission (verdict: Runtime Error):
nums = list(map(int, input.split(" ")))
if len(set(nums)) == 2:
    print("Yes")
else:
    print("No")


Fixed submission:
nums = list(map(int, input().split(" ")))
if len(set(nums)) == 2:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
import numpy as np
N, K = map(int, input().split(" "))
p = np.array(list(map(int, input().split(" "))))
ex = np.array([(i + 1) / 2 for i in p])
ans = np.sum(ex[0: K])
max_ans = ans
for i in range(K, N):
    diff = ex[i] - ex[i - K]
    ans += diff
    if diff > 0:
        max_ans = ans
print(max_ans)

Fixed submission:
s, t = input().split(" ")
a, b = map(int, input().split(" "))
if input() == s:
    print(a - 1, b)
else:
    print(a, b - 1)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N, K = map(int, input().split(" "))
p = np.array(list(map(int, input().split(" "))))
ex = np.array([(i + 1) / 2 for i in p])
ans = 0
for i in range(0, N - K + 1):
    ans = max(np.sum(ex[i: i + K]), ans)
print(ans)

Fixed submission:
import numpy as np
N, K = map(int, input().split(" "))
p = list(map(int, input().split(" ")))
ex = [i + 1 for i in p]
ans = sum(ex[0: K])
max_ans = ans
for i in range(K, N):
    ans += ex[i] - ex[i - K]
    max_ans = max(ans, max_ans)
print(max_ans / 2.0)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N, K = map(int, input().split(" "))
p = np.array(list(map(int, input().split(" "))))
ans = 0
total = 0
for i in range(N - K + 1):
    total = 0
    c = 1
    for k in range(i, i + K):
        total += (p[k] * (p[k] + 1) / 2) * c * np.prod(p[k + 1: i + K])
        c *= p[k]
    ans = max(total / c, ans)
print(ans)

Fixed submission:
import numpy as np
N, K = map(int, input().split(" "))
p = list(map(int, input().split(" ")))
ex = [i + 1 for i in p]
ans = sum(ex[0: K])
max_ans = ans
for i in range(K, N):
    ans += ex[i] - ex[i - K]
    max_ans = max(ans, max_ans)
print(max_ans / 2.0)

Buggy python submission (verdict: Runtime Error):
import numpy as np
N, K = map(int, input().split(" "))
P = np.array(list(map(int, input().split(" "))))
ans_max = 0
for i in range(N - K + 1):
    p = P[i: i + K]
    p_i = np.array([k for k in range(1, p[0] + 1)])
    for p_k in p[1:]:
        p_i = np.array([p_i + k for k in range(1, p_k + 1)]).flatten()
    ans_max = max(np.sum(p_i) / np.prod(p), ans_max)
print(ans_max)

Fixed submission:
import numpy as np
N, K = map(int, input().split(" "))
p = list(map(int, input().split(" ")))
ex = [i + 1 for i in p]
ans = sum(ex[0: K])
max_ans = ans
for i in range(K, N):
    ans += ex[i] - ex[i - K]
    max_ans = max(ans, max_ans)
print(max_ans / 2.0)

Buggy python submission (verdict: Runtime Error):
import numpy as np
N, K = map(int, input().split(" "))
P = np.array(list(map(int, input().split(" "))))
ans = []
for i in range(N - K + 1):
    p = P[i: i + K]
    p_i = np.array([k for k in range(1, p[0] + 1)])
    for p_k in p[1:]:
        p_i = np.array([p_i + k for k in range(1, p_k + 1)]).flatten()
    ans.append(np.sum(p_i) / np.prod(p))
print(max(ans))
    

Fixed submission:
import numpy as np
N, K = map(int, input().split(" "))
p = list(map(int, input().split(" ")))
ex = [i + 1 for i in p]
ans = sum(ex[0: K])
max_ans = ans
for i in range(K, N):
    ans += ex[i] - ex[i - K]
    max_ans = max(ans, max_ans)
print(max_ans / 2.0)
Buggy python submission (verdict: Time Limit Exceeded):
H, N = map(int, input().split())
mahou = []
a_max = 0
for _ in range(N):
    a, b = map(int, input().split())
    mahou.append([a, b])
    a_max = max(a_max, a)

dp = [[10 ** 9 for _ in range(H + a_max)] for _ in range(N + 1)]

for i in range(N + 1):
    dp[i][0] = 0

for i in range(1, N + 1):
    for j in range(H + a_max):
        if j >= mahou[i - 1][0]:
            dp[i][j] = min(dp[i][j - mahou[i - 1][0]] + mahou[i - 1][1], dp[i - 1][j])
        else:
            dp[i][j] = dp[i - 1][j]

print(min(dp[N][H:]))


Fixed submission:
H, N = map(int, input().split())
mahou = []
a_max = 0
for _ in range(N):
    a, b = map(int, input().split())
    mahou.append([a, b])
    a_max = max(a_max, a)

dp = [[10 ** 9 for _ in range(H + a_max)] for _ in range(N + 1)]

for i in range(N + 1):
    dp[i][0] = 0

for i in range(1, N + 1):
    for j in range(H + a_max):
        if j >= mahou[i - 1][0]:
            dp[i][j] = min(dp[i][j - mahou[i - 1][0]] + mahou[i - 1][1], dp[i - 1][j])
        else:
            dp[i][j] = dp[i - 1][j]

print(min(dp[N][H:]))