Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
cand = [1, 2, 3, 4, 5, 6, 7, 8, 9]
temp = []
for i in range(k):
    t = cand.pop(0)
    temp.append(t)
    if t % 10 != 0:
        cand.append(t*10+(t%10-1))
    cand.append(t*10+(t%10))
    if t % 10 != 9:
        cand.append(t*10+(t%10+1))
print(temp[k-1])

Fixed submission:
from collections import deque

k = int(input())
cand = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])
temp = []
for i in range(k):
    t = cand.popleft()
    temp.append(t)
    if t % 10 != 0:
        cand.append(t*10+(t%10-1))
    cand.append(t*10+(t%10))
    if t % 10 != 9:
        cand.append(t*10+(t%10+1))
print(temp[k-1])
Buggy python submission (verdict: Time Limit Exceeded):
n, a, b = map(int, input().split())

count = 0
while n > 0:
    for i in range(a):
        count += 1
        n -= 1
        if n == 0:
            break
    if n != 0:
        for j in range(b):
            n -= 1
            if n == 0:
                break
print(count)

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

x = n//(a+b)
y = n%(a+b)

if y <= a:
    print(x*a + y)
else:
    print(x*a + a)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
for i in range(q):
    tfc = input().split()
    if int(tfc[0]) == 1:
        s = s[::-1]
    else:
        if int(tfc[1]) == 1:
            s = tfc[2] + s
        else:
            s = s + tfc[2]
print(s)

Fixed submission:
from collections import deque
s = input()
d = deque(s)
q = int(input())
flag = 0
for i in range(q):
    tfc = input().split()
    if tfc[0] == '1':
        if flag == 0:
            flag = 1
        else:
            flag = 0
    else:
        if flag == 0:
            if int(tfc[1]) == 1:
                d.appendleft(tfc[2])
#                 print('appendleft:', d)
            else:
                d.append(tfc[2])
#                 print('append:', d)
        else:
            if int(tfc[1]) == 1:
                d.append(tfc[2])
#                 print('append:', d)
            else:
                d.appendleft(tfc[2])
#                 print('appendleft:', d)
if flag == 0:
    print(''.join(d))
else:
    print(''.join(reversed(d)))
Buggy python submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
mod = pow(10, 9) + 7

def comb(N, x):
    numerator = 1
    for i in range(N-x+1, N+1):
        numerator = numerator * i % mod
    denominator = 1
    for j in range(1, x+1):
        denominator = denominator * j % mod
    d = pow(denominator, mod-2, mod)
    return numerator * d

a = comb(n, a)
b = comb(n, b)

print((pow(2, n, mod) -1 -a -b) % mod)

Fixed submission:
n, r = map(int, input().split())
if n<10:
    print(100*(10-n)+r)
else:
    print(r)
Buggy python submission (verdict: Time Limit Exceeded):
n, a, b = map(int, input().split())
mod = pow(10, 9) + 7
total = pow(2, n) - 1

def comb(N, x):
    numerator = 1
    for i in range(N-x+1, N+1):
        numerator = numerator * i % mod
    denominator = 1
    for j in range(1, x+1):
        denominator = denominator * j % mod
    d = pow(denominator, mod-2, mod)
    return numerator * d

a = comb(n, a)
b = comb(n, b)

print((total -a -b) % mod)

Fixed submission:
n, a, b = map(int, input().split())
mod = pow(10, 9) + 7

def comb(N, x):
    numerator = 1
    for i in range(N-x+1, N+1):
        numerator = numerator * i % mod
    denominator = 1
    for j in range(1, x+1):
        denominator = denominator * j % mod
    d = pow(denominator, mod-2, mod)
    return numerator * d

a = comb(n, a)
b = comb(n, b)

print((pow(2, n, mod) -1 -a -b) % mod)
Buggy python submission (verdict: Runtime Error):
=input()
ans=0
for i in range(3):
    if int(n[i]) == 7:
        ans=1
print("YES" if ans == 1 else "NO")

Fixed submission:
n=input()
ans=0
for i in range(3):
    if int(n[i]) == 7:
        ans=1
print("Yes" if ans == 1 else "No")
Buggy python submission (verdict: Time Limit Exceeded):
a,b=sorted(map(int,input().split()))
ans=0
ans2=0
for i in range(a,b+1):
    if abs(a-i)==abs(b-i):
        ans=1
        ans2=i
print(ans2 if ans==1 else "IMPOSSIBLE")

Fixed submission:
a,b=map(int,input().split())
print(int(min(a,b)+abs(a-b)/2) if (a-b)%2==0 else "IMPOSSIBLE")
Buggy python submission (verdict: Time Limit Exceeded):
l,r=map(int,input().split())
ans=2019
for i in range (l,r+1):
    for j in range(i+1,r+1):
       ans=min(ans,(i*j)%2019)
print(ans)

Fixed submission:
L,R=map(int,input().split())
if R-L>=2019:
    minimum=0
else:
    left,right=L%2019,R%2019
    minimum=2018**2
    for i in range(left,right+1):
        for j in range(i+1,right+1):
            minimum=min(minimum,i*j%2019)
print(minimum)
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
cost=[]
count=[]
ans=0
temp=0
for i in range(n):
    a,b=map(int,input().split())
    cost.append(a)
    count.append(b)
for i in range(len(cost)):
    ans+=min(cost)*count[cost.index(min(cost))]
    temp+=count[cost.index(min(cost))]
#   print("ans,temp,min(cost),min(count)=",ans,temp,min(cost),count[cost.index(min(cost))])
    if temp>=m:
        ans-=min(cost)*(temp-m)
        break
    else:
        count.remove(count[cost.index(min(cost))])
        cost.remove(min(cost))
print(ans)

Fixed submission:
n,m=map(int,input().split())
list=[list(map(int,input().split())) for _ in range(n)]
list.sort()
ans=0
temp=0
for i in range(n):
    ans+=list[i][0]*list[i][1]
    temp+=list[i][1]
    if temp>=m:
        ans-=list[i][0]*(temp-m)
        print(ans)
        break
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**9)
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
from collections import defaultdict
def resolve():
    N, M, K = lr()
    MOD = 998244353
    dp = defaultdict(lambda: -1)
    def narabi(n, k):
        tmp = 0
        if k > K:
            return 0
        if n == 0:
            return 1
        if dp[n, k] != -1:
            return dp[n, k]
        if n == N:
            tmp += (M*narabi(n-1, k))%MOD
        else:
            tmp += (narabi(n-1, k+1) + (M-1)*narabi(n-1, k))%MOD
        tmp %= MOD
        dp[n, k] = tmp
        return tmp
    ans = narabi(N, 0)
    print(ans)
resolve()

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def resolve():
    N, M, K = lr()
    MOD = 998244353
    SIZE = 4*10**5+1
    SIZE += 1
    inv = [0]*SIZE  # inv[j] = j^{-1} mod MOD
    fac = [0]*SIZE  # fac[j] = j! mod MOD
    finv = [0]*SIZE # finv[j] = (j!)^{-1} mod MOD
    inv[1] = 1
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    for i in range(2,SIZE):
        inv[i] = MOD - (MOD//i)*inv[MOD%i]%MOD
        fac[i] = fac[i-1]*i%MOD
        finv[i]= finv[i-1]*inv[i]%MOD
    def choose(n,r): # nCk mod MOD の計算
        if 0 <= r <= n:
            return (fac[n]*finv[r]%MOD)*finv[n-r]%MOD
        else:
            return 0
    ans = 0
    for i in range(K+1):
        ans += choose(N-1, i)*M*pow((M-1), N-1-i, MOD)%MOD
        ans %= MOD
    print(ans)
resolve()
Buggy python submission (verdict: Runtime Error):
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def resolve():
    X = ir()
    c = {0:0}
    cnt = 1
    while True:
        c[pow(cnt, 5)] = cnt
        r = cnt-X
        if r in c.keys():
            print(c[cnt], c[r])
            break
        if -r in c.keys():
            print(c[cnt], -c[-r])
            break
        cnt += 1
resolve()

Fixed submission:
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def resolve():
    X = ir()
    c = {0:0}
    s = set([0])
    cnt = 1
    flag = True
    while flag:
        k = pow(cnt, 5)
        c[k] = cnt
        s.add(k)
        r = k-X
        if r in s:
            print(c[k], c[r])
            flag = False
            break
        if -r in s:
            print(c[k], -c[-r])
            flag = False
            break
        cnt += 1
resolve()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
from collections import defaultdict
def resolve():
    N = ir()
    A = sorted([[i+1, d] for i, d in enumerate(lr())], key=lambda x: x[1])[::-1]
    dp = defaultdict(lambda: -float('inf'))
    dp[0, 0] = 0
    for s in range(1, N+1):
        for x in range(s):
            for y in range(s-x):
                i, d = A[x+y]
                dp[x+1, y] = max(dp[x, y]+d*(i-x-1), dp[x+1, y])
                dp[x, y+1] = max(dp[x, y]+d*(N-y-i), dp[x, y+1])
    ans = 0
    for i in range(N+1):
        ans = max(ans, dp[i, N-i])
    print(ans)
resolve()

Fixed submission:
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
from collections import defaultdict
def resolve():
    N = ir()
    A = sorted([[i+1, d] for i, d in enumerate(lr())], key=lambda x: x[1])[::-1]
    dp = defaultdict(lambda: -float('inf'))
    dp[0, 0] = 0
    for x in range(N):
        for y in range(N-x):
            i, d = A[x+y]
            dp[x+1, y] = max(dp[x, y]+d*(i-x-1), dp[x+1, y])
            dp[x, y+1] = max(dp[x, y]+d*(N-y-i), dp[x, y+1])
    ans = 0
    for i in range(N+1):
        ans = max(ans, dp[i, N-i])
    print(ans)
resolve()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def resolve():
    N, K, C = lr()
    S = [i for i, s in enumerate(sr()) if s == 'o']
    ans = []
    for i in S:
        no_work = -1
        cnt = 0
        for j in S:
            if j == i:
                continue
            if j <= no_work:
                continue
            cnt += 1
            no_work = j+C
        if cnt < K:
            ans.append(i+1)
    print(*ans, sep='\n')
resolve()

Fixed submission:
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
from collections import Counter
def resolve():
    N, K, C = lr()
    S = [i+1 for i, s in enumerate(sr()) if s == 'o']
    l = [S[0]]
    for i in S[1:]:
        if l[-1]+C >= i or len(l) > K:
            continue
        l.append(i)
    S = S[::-1]
    r = [S[0]]
    for i in S[1:]:
        if r[-1]-C <= i or len(r) > K:
            continue
        r.append(i)
    r = r[::-1]
    for i in range(K):
        if l[i] == r[i]:
            print(l[i])
resolve()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
from collections import deque
def resolve():
    N, X, Y = lr()
    edges = [[1]]
    for i in range(1, N-1):
        edges.append([i-1, i+1])
    edges.append([N-2])
    edges[X-1].append(Y-1)
    edges[Y-1].append(X-1)
    cnt = [0]*(N-1)
    for i in range(N):
        s = deque([[i, 1]])
        vis = [0]*N
        vis[i] = 1
        while len(s) > 0:
            v, dis = s.popleft()
            for j in edges[v]:
                if not vis[j]:
                    s.append([j, dis+1])
                    vis[j] = 1
                    cnt[dis-1] += 1
    for c in cnt:
        print(c//2)
resolve()

Fixed submission:
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
from collections import deque
def resolve():
    N, X, Y = lr()
    edges = [[1]]
    for i in range(1, N-1):
        edges.append([i-1, i+1])
    edges.append([N-2])
    edges[X-1].append(Y-1)
    edges[Y-1].append(X-1)
    cnt = [0]*(N-1)
    for i in range(N):
        s = deque([[i, 1]])
        vis = [0]*N
        vis[i] = 1
        while len(s) > 0:
            v, dis = s.popleft()
            for j in edges[v]:
                if not vis[j]:
                    s.append([j, dis+1])
                    vis[j] = 1
                    cnt[dis-1] += 1
    for c in cnt:
        print(c//2)
resolve()
Buggy python submission (verdict: Runtime Error):
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def resolve():
    X, Y, A, B, C = lr()
    p = sorted(lr())[-X:][::-1]
    q = sorted(lr())[-Y:][::-1]
    r = sorted(lr())
    tmp = r.pop()
    pt = p[-1]
    qt = q[-1]
    ext = [0]
    while (tmp > pt or tmp > qt) and len(r) >= 0:
        if pt > qt:
            g = q.pop()
            ext.append(tmp)
            qt = q[-1]
        else:
            g = p.pop()
            ext.append(tmp)
            pt = p[-1]
        if len(r) > 0:
            tmp = r.pop()
    print(sum(p)+sum(q)+sum(ext))
resolve()

Fixed submission:
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def resolve():
    X, Y, A, B, C = lr()
    p = sorted(lr())[-X:][::-1]
    q = sorted(lr())[-Y:][::-1]
    r = sorted(lr())
    tmp = r.pop()
    pt = p[-1]
    qt = q[-1]
    ext = [0]
    while (tmp > pt or tmp > qt) and len(r) >= 0:
        if pt > qt:
            g = q.pop()
            ext.append(tmp)
            if len(q) == 0:
                qt = pow(10, 9)+1
            else:
                qt = q[-1]
        else:
            g = p.pop()
            ext.append(tmp)
            if len(p) == 0:
                pt = pow(10, 9)+1
            else:
                pt = p[-1]
        if len(r) > 0:
            tmp = r.pop()
        else:
            break
    print(sum(p)+sum(q)+sum(ext))
resolve()
Buggy python submission (verdict: Runtime Error):
H, W = map(int, input().split())
a = H*W
if a%2 == 1:
    print((a+1)//2)
else:
    print(a//2)
return

Fixed submission:
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def resolve():
    H, W = lr()
    a = H*W
    if H == 1 or W == 1:
        print(1)
    elif a%2 == 1:
        print((a+1)//2)
    else:
        print(a//2)
    return
resolve()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
import numpy as np
def resolve():
    N, M = lr()
    rev = 0
    if N < M:
        M, N = N, M
        rev = 1
    T = np.zeros(1, dtype=np.int8)
    for i in range(N):
        T = np.tile(T, (2, 2))
        T[1<<i:, 1<<i:] ^= 1
    T = np.diff(T, axis=0)
    T = np.diff(T, axis=1)
    T = T[:, :(1<<M)-1]%2
    if rev:
        T = np.transpose(T)
    for i in range(len(T)):
        print(*T[i], sep='')
resolve()

Fixed submission:
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
import numpy as np
def resolve():
    N, M = lr()
    rev = 0
    if N < M:
        M, N = N, M
        rev = 1
    T = np.zeros(1, dtype=np.int8)
    for i in range(N):
        T = np.tile(T, (2, 2))
        T[1<<i:, 1<<i:] ^= 1
    T = np.diff(T, axis=0)
    T = np.diff(T, axis=1)
    T = T[:, :(1<<M)-1]%2
    if rev:
        T = np.transpose(T)
    for t in T:
        print(''.join(t.astype(str)))
resolve()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
import numpy as np
def resolve():
    N, M = lr()
    rev = 0
    if N < M:
        M, N = N, M
        rev = 1
    T = np.zeros((1<<M, 1<<N), dtype=np.int8)
    for i in range(1<<M):
        for j in range(1<<N):
            T[i][j] = bin(i&j).count("1")%2
    T = np.diff(T, axis=0)%2
    T = np.diff(T, axis=1)%2
    if not rev:
        T = np.transpose(T)
    for i in range(len(T)):
        print(*T[i], sep='')
resolve()

Fixed submission:
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
import numpy as np
def resolve():
    N, M = lr()
    rev = 0
    if N < M:
        M, N = N, M
        rev = 1
    T = np.zeros(1, dtype=np.int8)
    for i in range(N):
        T = np.tile(T, (2, 2))
        T[1<<i:, 1<<i:] ^= 1
    T = np.diff(T, axis=0)
    T = np.diff(T, axis=1)
    T = T[:, :(1<<M)-1]%2
    if rev:
        T = np.transpose(T)
    for t in T:
        print(''.join(t.astype(str)))
resolve()
Buggy python submission (verdict: Runtime Error):
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def resolve():
    N, M, K = lr()
    fri = [[] for _ in range(N)]
    for i in range(M):
        a, b = lr()
        fri[a-1].append(b-1)
        fri[b-1].append(a-1)
    blo = [[] for _ in range(N)]
    for i in range(K):
        c, d = lr()
        blo[c-1].append(d-1)
        blo[d-1].append(c-1)

    can = [[] for _ in range(N)]
    for i in range(N):
        vis = [False for _ in range(N)]
        s = [i]
        while len(s) > 0:
            v = s.pop()
            vis[v] = True
            for j in fri[v]:
                if vis[j]:
                    continue
                s.append(j)
                if j not in fri[i] and j not in blo[i] and j not in can[i]:
                    can[i].append(j)
    ans = []
    for i in range(N):
        ans.append(len(can[i]))
    print(*ans, sep=' ')
resolve()

Fixed submission:
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def resolve():
    N = ir()
    print(N//2+N%2)
resolve()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
MOD = 10 ** 9 + 7
from functools import reduce
def Comb(N, A):
    num = reduce(lambda x, y: x * y % MOD, range(N, N-A, -1))
    den = reduce(lambda x, y: x * y % MOD, range(1, A+1))
    return num * pow(den, MOD-2, MOD) % MOD
def resolve():
    n, k = lr()
    ans = Comb(2*n-1, n)
    if n-1 > k:
        for i in range(1, n-k):
            ans -= Comb(n, i)*Comb(n-1, n-i)
            ans %= MOD
    print(ans)
resolve()

Fixed submission:
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
SIZE=4*10**5+1; MOD=10**9+7 #998244353 #ここを変更する
 
SIZE += 1
inv = [0]*SIZE  # inv[j] = j^{-1} mod MOD
fac = [0]*SIZE  # fac[j] = j! mod MOD
finv = [0]*SIZE # finv[j] = (j!)^{-1} mod MOD
inv[1] = 1
fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
for i in range(2,SIZE):
    inv[i] = MOD - (MOD//i)*inv[MOD%i]%MOD
    fac[i] = fac[i-1]*i%MOD
    finv[i]= finv[i-1]*inv[i]%MOD
 
def choose(n,r): # nCk mod MOD の計算
    if 0 <= r <= n:
        return (fac[n]*finv[r]%MOD)*finv[n-r]%MOD
    else:
        return 0
def resolve():
    n, k = lr()
    ans = choose(2*n-1, n)
    if n-1 > k:
        for i in range(1, n-k):
            ans -= choose(n, i)*choose(n-1, n-i)
            ans %= MOD
    print(ans)
resolve()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
from collections import defaultdict
def resolve():
    N = ir()
    S = defaultdict(int)
    for i in range(N):
        S[sr()] += 1
    max_k_list = sorted([kv[0] for kv in S.items() if kv[1] == max(S.values())])
    for l in max_k_list:
        print(l)
resolve()

Fixed submission:
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
from collections import defaultdict
def resolve():
    N = ir()
    S = defaultdict(int)
    for i in range(N):
        S[sr()] += 1
    max_value = max(S.values())
    max_k_list = sorted([kv[0] for kv in S.items() if kv[1] == max_value])
    for l in max_k_list:
        print(l)
resolve()
Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    N, K = map(int, input().split())
    p = list(map(int, input().split()))
    ans = 0
    l = []
    for i in range(K):
        l.append(p[i]+1)
    ans = sum(l)
    for i in range(K, N):
        l.append(p[i]+1)
        tmp = sum(l[-K:])
        if ans < tmp:
            ans = tmp
    print(ans/2)
resolve()

Fixed submission:
def resolve():
    N, K = map(int, input().split())
    p = list(map(int, input().split()))
    l = [0]*N
    l[0] = p[0]+1
    for i in range(1, N):
        l[i] = l[i-1]+p[i]+1
    ans = l[K-1]
    for i in range(N-K):
        tmp = l[K+i]-l[i]
        if tmp > ans:
            ans = tmp
    print(ans/2)
resolve()

Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    N, K = map(int, input().split())
    p = list(map(int, input().split()))
    ans = 0
    l = []
    for i in range(K):
        l.append((p[i]*(p[i]+1))//2/p[i])
    ans = sum(l)
    for i in range(K, N):
        l.append((p[i]*(p[i]+1))//2/p[i])
        tmp = sum(l[-K:])
        if ans < tmp:
            ans = tmp
    print(ans)
resolve()

Fixed submission:
def resolve():
    N, K = map(int, input().split())
    p = list(map(int, input().split()))
    l = [0]*N
    l[0] = p[0]+1
    for i in range(1, N):
        l[i] = l[i-1]+p[i]+1
    ans = l[K-1]
    for i in range(N-K):
        tmp = l[K+i]-l[i]
        if tmp > ans:
            ans = tmp
    print(ans/2)
resolve()

Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    N, K = map(int, input().split())
    p = list(map(int, input().split()))
    ans = 0
    l = [0 for i in range(K)]
    for i in range(K):
        l[i] = (p[i]*(p[i]+1))//2/p[i]
    ans = sum(l)
    for i in range(K, N):
        l[i%K] = (p[i]*(p[i]+1))//2/p[i]
        tmp = sum(l)
        if ans < tmp:
            ans = tmp
    print(ans)
resolve()

Fixed submission:
def resolve():
    N, K = map(int, input().split())
    p = list(map(int, input().split()))
    l = [0]*N
    l[0] = p[0]+1
    for i in range(1, N):
        l[i] = l[i-1]+p[i]+1
    ans = l[K-1]
    for i in range(N-K):
        tmp = l[K+i]-l[i]
        if tmp > ans:
            ans = tmp
    print(ans/2)
resolve()

Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    N, K = map(int, input().split())
    p = list(map(int, input().split()))
    ans = 0
    l = []
    for i in range(K):
        l.append((p[i]*(p[i]+1))//2/p[i])
    ans = sum(l)
    for i in range(K, N):
        l[i%K] = (p[i]*(p[i]+1))//2/p[i]
        tmp = sum(l)
        if ans < tmp:
            ans = tmp
    print(ans)
resolve()

Fixed submission:
def resolve():
    N, K = map(int, input().split())
    p = list(map(int, input().split()))
    l = [0]*N
    l[0] = p[0]+1
    for i in range(1, N):
        l[i] = l[i-1]+p[i]+1
    ans = l[K-1]
    for i in range(N-K):
        tmp = l[K+i]-l[i]
        if tmp > ans:
            ans = tmp
    print(ans/2)
resolve()
Buggy python submission (verdict: Runtime Error):
def resolve():
    r1, c1, r2, c2 = map(int, input().split())

    def cmb(n, r, mod):
        if (r<0 or r>n):
            return 0
        r = min(r, n-r)
        return g1[n] * g2[r] * g2[n-r] % mod

    mod = 10**9+7 #出力の制限
    N = 10**6
    g1 = [1, 1] # 元テーブル
    g2 = [1, 1] #逆元テーブル
    inverse = [0, 1] #逆元テーブル計算用テーブル

    for i in range(2, N + 1):
        g1.append((g1[-1] * i ) % mod)
        inverse.append((-inverse[mod % i] * (mod//i)) % mod)
        g2.append((g2[-1] * inverse[-1]) % mod)

    print((cmb(r2+1+c2+1, r2+1, mod) - cmb(r1+c2+1, r1, mod) - cmb(r2+1+c1, c1, mod) + cmb(r1+c1, r1, mod)%mod))
resolve()

Fixed submission:
def resolve():
    r1, c1, r2, c2 = map(int, input().split())
    r1 -= 1
    c1 -= 1

    def cmb(n, r, mod):
        if (r<0 or r>n):
            return 0
        r = min(r, n-r)
        return g1[n] * g2[r] * g2[n-r] % mod

    mod = 10**9+7 #出力の制限
    N = 3*10**6
    g1 = [1, 1] # 元テーブル
    g2 = [1, 1] #逆元テーブル
    inverse = [0, 1] #逆元テーブル計算用テーブル

    for i in range(2, N + 1):
        g1.append((g1[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod//i)) % mod)
        g2.append((g2[-1] * inverse[-1]) % mod)

    print((cmb(r2+c2+2, r2+1, mod) - cmb(r1+c2+2, r1+1, mod) - cmb(r2+c1+2, c1+1, mod) + cmb(r1+c1+2, r1+1, mod))%mod)
resolve()