Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02802 (python)

Fixed submission:
n, m = map(int, input().split())
ps = []
for i in range(m):
    p, s = input().split()
    ps.append([int(p), s])
flag = [False for _ in range(n)]
ac = [0 for _ in range(n)]
wa = [0 for _ in range(n)]
i = 0
sumac = 0
sumwa = 0

for i in range(m):
    p = ps[i][0]
    s = ps[i][1]
    if s == "WA" and ac[p - 1] == 0:
        wa[p - 1] += 1
    elif s == "AC" and ac[p - 1] == 0:
        ac[p - 1] += 1
        sumac += 1
        sumwa += wa[p - 1]

print(str(sumac) + " " + str(sumwa))

Buggy submission (verdict: Runtime Error):


n, m = map(int, input().split())
ps = []
for i in range(m):
    p, s = input().split()
    ps.append([int(p), s])
flag = [False for _ in range(n)]
ac = [0 for _ in range(n)]
wa = [0 for _ in range(n)]
i = 0
sumac = 0
sumwa = 0

for i in range(m):
    p = ps[i][0]
    s = ps[i][1]
    if s == "WA" and ac[p - 1] == 0:
        wa[p - 1] += 1
    elif s == "AC" and ac[p - 1] == 0:
        ac[p - 1] += 1
        sumac += 1
        sumwa += wa[p - 1]

print(str(int(ac)) + " " + str(int(wa)))
Problem p02803 (python)

Fixed submission:
from collections import deque
h, w = map(int, input().split())

maze = [list(input()) for _ in range(h)]
#print(maze)
ans = 0
def solve(sx, sy):
    INF = 1000000
    reached = [[INF for _ in range(w)] for _ in range(h)]
    reached[sx][sy] = 0
    d = deque()
    d.append([sx, sy])
    dx = [-1, 0, 1, 0]
    dy = [0, 1, 0, -1]    
    while d:
        x, y = d.popleft()
        for i in range(4):
            next_y = y + dy[i]
            next_x = x + dx[i]
            if next_x < 0 or next_x > h - 1 or next_y < 0 or next_y > w - 1:
                continue
            if maze[next_x][next_y] == "#":
                continue
            if reached[next_x][next_y] != INF:
                continue
            d.append([next_x, next_y])
            reached[next_x][next_y] = reached[x][y] + 1
    gl = 0
    for i in range(h):
        for j in range(w):
            if maze[i][j] == ".":
                gl = max(gl, reached[i][j])
    return gl

for i in range(h):
    for j in range(w):
        if maze[i][j] == ".":
            res = solve(i, j)
            ans = max(ans, res)
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import deque
h, w = map(int, input().split())

maze = [list(input()) for _ in range(h)]
#print(maze)
ans = 0
def solve(sx, sy):
    reached = [[0 for _ in range(w)] for _ in range(h)]
    d = deque()
    d.append([sx, sy])
    dx = [-1, 0, 1, 0]
    dy = [0, 1, 0, -1]    
    while d:
        x, y = d.popleft()
        for i in range(4):
            next_y = y + dy[i]
            next_x = x + dx[i]
            if next_x < 0 or next_x > h - 1 or next_y < 0 or next_y > w - 1:
                continue
            if maze[next_x][next_y] == "#":
                continue
            if reached[next_x][next_y] != 0:
                continue
            d.append([next_x, next_y])
            reached[next_x][next_y] = reached[x][y] + 1
    return max(reached)

for i in range(h):
    for j in range(w):
        if maze[i][j] == ".":
            res = solve(i, j)
            ans = max(ans, res)
print(ans)
Problem p02850 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
N = int(input())

V = [[] for _ in range(N)]
C = [-1 for _ in range(N - 1)]


# v:頂点, c:色, p:親
def dfs(v, c, p):
    k = 1
    for _v, _id  in V[v]:
        if _v == p:
            continue
        if k == c:
            k += 1
        C[_id] = k
        dfs(_v, k, v)
        k += 1

for i in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    V[a].append([b, i])
    V[b].append([a, i])
#print(V)
dfs(0, -1, -1)
print(max(C))
for i in C:
    print(i)

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

def dfs(v, c, p):
    k = 1
    for _v, _id in V[v]:
        if _v == p:
            continue
        if k == c:
            k += 1
        C[_id] = k
        dfs(_v, k, v)
        k += 1

V = [[] for _ in range(N)]
C = [-1 for _ in range(N-1)]

for i in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    V[a].append([b, i])
    V[b].append([a, i])

dfs(0, -1, -1)
print(max(C))
for i in range(N-1):
    print(C[i])

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

V = [[] for _ in range(N)]
C = [-1 for _ in range(N - 1)]


# v:頂点, c:色, p:親
def dfs(v, c, p):
    k = 1
    for _v, _id  in V[v]:
        if _v == p:
            continue
        if k == c:
            k += 1
        C[_id] = k
        dfs(_v, k, v)
        k += 1

for i in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    V[a].append([b, i])
    V[b].append([a, i])
print(V)
dfs(0, -1, -1)
print(max(C))
for i in C:
    print(i)
Problem p02882 (python)

Fixed submission:
from math import atan, degrees
a, b, x = map(int, input().split())

#ans = max(90 - degrees(atan(0.5 * a ** 3/(a ** 2 * b - x))), 90 - degrees(atan(2 * x / (a * b ** 2))))
if a ** 2 * b == x:
    ans = 0
else:
    if 0.5 * a ** 2 * b < x:
        ans = 90 - degrees(atan(0.5 * a ** 3/(a ** 2 * b - x)))
    else:
        ans = 90 - degrees(atan(2 * x / (a * b ** 2)))

print(ans)

Buggy submission (verdict: Runtime Error):
from math import atan, degrees
a, b, x = map(int, input().split())

#ans = max(90 - degrees(atan(0.5 * a ** 3/(a ** 2 * b - x))), 90 - degrees(atan(2 * x / (a * b ** 2))))
if 0.5 * a ** 2 * b < x:
    ans = 90 - degrees(atan(0.5 * a ** 3/(a ** 2 * b - x)))
else:
    ans = 90 - degrees(atan(2 * x / (a * b ** 2)))
print(ans)

Buggy submission (verdict: Runtime Error):
from math import atan, degrees
a, b, x = map(int, input().split())

ans = max(90 - degrees(atan(0.5 * a ** 3/(a ** 2 * b - x))), 90 - degrees(atan(2 * x / (a * b ** 2))))
print(ans)
Problem p02936 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 6)
def input():
    return sys.stdin.readline()[:-1]
 
n , q = map(int,input().split())
point = [0] * n
edge = [[] for i in range(n)]
 
for i in range(n-1):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    edge[a].append(b)
    edge[b].append(a)
 
for _ in range(q):
    a , b = map(int,input().split())
    point[a-1] += b
 
def dfs(now, last=-1):
    for nxt in edge[now]:
        if nxt==last: continue
        point[nxt] += point[now]
        dfs(nxt, now)
dfs(0)
print(*point)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10 ** 6)
def input():
    return sys.stdin.readline()[:-1]
 
n , q = map(int,input().split())
point = [0] * n
edge = [[] for i in range(n)]
 
for i in range(n-1):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    edge[a].append(b)
    edge[b].append(a)
 
for _ in range(q):
    a , b = map(int,input().split())
    point[a-1] += b
 
def dfs(now, last=-1):
    for nxt in edge[now]:
        if nxt==last: continue
        point[nxt] += point[now]
        dfs(nxt, now)
dfs(0)
print(*point)
import sys
sys.setrecursionlimit(10 ** 6)
def input():
    return sys.stdin.readline()[:-1]

n , q = map(int,input().split())
point = [0] * n
edge = [[] for i in range(n)]

for i in range(n-1):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    edge[a].append(b)
    edge[b].append(a)

for _ in range(q):
    a , b = map(int,input().split())
    point[a-1] += b

def dfs(now, last=-1):
    for nxt in edge[now]:
        if nxt==last: continue
        point[nxt] += point[now]
        dfs(nxt, now)
dfs(0)
print(*point)

Buggy submission (verdict: Runtime Error):
N, Q = map(int, input().split())
V = [[] for _ in range(N)]
X = [0 for _ in range(N)]

for _ in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    V[a].append(b)
    V[b].append(a)

for _ in range(Q):
    p, x = map(int, input().split())
    p -= 1
    X[p] += x
# p親、n現在、s合計
def dfs(p, n, s):
    X[n] += s
    for i in V[n]:
        if i == p:
            continue
        else:
            dfs(n, i, X[n])
dfs(-1,0,0)
for i in range(N):
    print(X[i], end=" ")
Problem p03000 (python)

Fixed submission:
n, x = map(int, input().split())
l = list(map(int, input().split()))

d = []
d.append(0)
for i in range(n):
    d.append(d[i]+l[i])
ans = 0
for i in d:
    if i <= x:
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
n, x = map(int, input().split())
l = list(map(int, input().split()))

tmp = 0
cnt = 0
i = 0
while tmp <= x and i <= len(l):
    d = tmp + l[i]
    tmp = d
    cnt += 1
    i += 1

print(cnt)

Buggy submission (verdict: Runtime Error):
n, x = map(int, input().split())
l = list(map(int, input().split()))

tmp = 0
cnt = 0
i = 0
while tmp <= x:
    d = tmp + l[i]
    tmp = d
    cnt += 1
    i += 1

print(cnt)
Problem p03164 (python)

Fixed submission:
N, W = map(int, input().split())
wv = []

for i in range(N):
    w, v = map(int, input().split())
    wv.append([w, v])
MAX_V = 10**5+100
INF = 10**10
dp = [[INF]*MAX_V for _ in range(N+1)]
dp[0][0] = 0
for i in range(N):
    for j in range(MAX_V):
        if j - wv[i][1] >= 0:
            dp[i+1][j] = min(dp[i][j], dp[i][j-wv[i][1]]+wv[i][0])
        else:
            dp[i+1][j] = min(dp[i+1][j], dp[i][j])
ans = 0
for i in range(MAX_V):
    if dp[N][i] <= W:
        ans = i
print(ans)

Buggy submission (verdict: Runtime Error):
N, W = map(int, input().split())
wv = []

for i in range(N):
    w, v = map(int, input().split())
    wv.append([w, v])

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

for i in range(N):
    for j in range(W+1):
        if j - wv[i][0] >= 0:
            dp[i+1][j] = max(dp[i][j], dp[i][j-wv[i][0]]+wv[i][1])
        else:
            dp[i+1][j] = dp[i][j]
print(dp[N][W])
Problem p03282 (python)

Fixed submission:
s = input()
k = int(input())
tmp = 1
for i in range(len(s)):
    if s[i] != '1' and i + 1 <= k:
        tmp = int(s[i])
        break
print(tmp)

Buggy submission (verdict: Runtime Error):
import sys
s = input()
k = input()

for i in range(len(s)):
    if s[i] != "1" and i + 1 < k:
        print(s[i])
        sys.exit(0)
print(1)
Problem p03294 (python)

Fixed submission:
import fractions
from functools import reduce

n = int(input())
a = list(map(int, input().split()))
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
m = lcm(*a)

ans = 0

for i in range(n):
    ans += (m - 1) % a[i]
print(int(ans))

Buggy submission (verdict: Runtime Error):
from functools import reduce
n = int(input())
a = list(map(int, input().split()))

def gcd(x, y):
    try:
    if y == 0:
        return x
    return gcd(y, x % y)
    

def gcd2(number):
    return reduce(gcd, number)

def lcm(x, y):
    return x * y // gcd(x, y)
def lcm2(number):
    return reduce(lcm, number)

m = lcm2(a) - 1
#print(m)
ans = 0
for i in range(n):
    ans += m % a[i]
print(ans)

Buggy submission (verdict: Runtime Error):
from functools import reduce
n = int(input())
a = list(map(int, input().split()))

def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x % y)

def gcd2(number):
    return reduce(gcd, number)

def lcm(x, y):
    return int(x * y / gcd(x, y))
def lcm2(number):
    return reduce(lcm, number)

m = lcm2(a) - 1
#print(m)
ans = 0
for i in range(n):
    ans += m % a[i]
print(ans)
Problem p03624 (python)

Fixed submission:
import sys
S = input()
alphabet = "abcdefghijklmnopqrstuvwxyz"

for s in alphabet:
    if s not in S:
        print(s)
        sys.exit()

print("None")

Buggy submission (verdict: Runtime Error):
import sys
S = input()
cnt = [False] * 30
for i in S:
    if i in "abcdefghijklmnopqrstuvwxyz"
        cnt[ord(i) - ord('a')] = True
 
for i in range(len(cnt)):
    if not cnt[i]:
        print(chr(ord('a')+i))
        sys.exit()
print("None")

Buggy submission (verdict: Runtime Error):
import sys
S = input()
cnt = [False] * 30
for i in S:
    if i in "abcdefghijklmnopqrstuvwxyz"
    cnt[ord(i) - ord('a')] = True
 
for i in range(len(cnt)):
    if not cnt[i]:
        print(chr(ord('a')+i))
        sys.exit()
print("None")

Buggy submission (verdict: Runtime Error):
S = input()
alphabet = "abcdefghijklmnopqrstuvwxyz"

for s in alphabet:
    if s not in S:
        print(s)
        sys.exit()

print("None")

Buggy submission (verdict: Runtime Error):
import sys
S = input()
cnt = [0] * 26
for i in range(len(S)):
    cnt[ord(S[i]) - ord('a')] += 1

for i in range(len(S)):
    if not cnt[i]:
        print(chr(ord('a')+i))
        sys.exit()
print("None")

Buggy submission (verdict: Runtime Error):
S = input()
cnt = [0] * 26
for i in range(len(S)):
    cnt[ord(S[i]) - ord('a')] += 1

for i in range(len(S)):
    if not cnt[i]:
        print(chr(ord('a')+i))
        break
Problem p02573 (python)

Fixed submission:
import collections
import sys
import resource
sys.setrecursionlimit(1000000)

n, m = map(int, input().split(' '))

f = [x for x in range(n)]

def find(x):
  if f[x] == x:
    return x
  root = find(f[x])
  f[x] = root
  return root

for i in range(m):
  a, b = map(int, input().split(' '))
  a -= 1
  b -= 1
  if find(a) != find(b):
    f[find(a)] = find(b)

for i in range(n):
  find(i)
  
print(max(collections.Counter(f).values()))

Buggy submission (verdict: Runtime Error):
import collections
import sys
import resource
sys.setrecursionlimit(200000)

n, m = map(int, input().split(' '))

f = [x for x in range(n)]

def find(x):
  if f[x] == x:
    return x
  root = find(f[x])
  f[x] = root
  return root

for i in range(m):
  a, b = map(int, input().split(' '))
  a -= 1
  b -= 1
  if find(a) != find(b):
    f[find(a)] = find(b)

for i in range(n):
  find(i)
  
print(max(collections.Counter(f).values()))

Buggy submission (verdict: Runtime Error):
import collections
import sys

n, m = map(int, input().split(' '))

if m == 0:
  print(1)
  sys.exit()

f = [x for x in range(n)]

def find(x):
  if f[x] == x:
    return x
  root = find(f[x])
  f[x] = root
  return root

for i in range(m):
  a, b = map(int, input().split(' '))
  a -= 1
  b -= 1
  if find(a) != find(b):
    f[find(a)] = find(b)

for i in range(n):
  find(i)
  
print(max(collections.Counter(f).values()))

Buggy submission (verdict: Runtime Error):
import collections

n, m = map(int, input().split(' '))

f = [x for x in range(n)]

def find(x):
  if f[x] == x:
    return x
  root = find(f[x])
  f[x] = root
  return root

for i in range(m):
  a, b = map(int, input().split(' '))
  a -= 1
  b -= 1
  if find(a) != find(b):
    f[find(a)] = find(b)

for i in range(n):
  find(i)
  
print(max(collections.Counter(f).values()))
print(f)
Problem p02614 (python)

Fixed submission:
import numpy as np
import copy
from itertools import product
h, w, k = map(int, input().split())
C = [list(input()) for _ in range(h)]
C = np.array(C)

cnt = 0
for i in product([True, False], repeat=h):
    c = copy.deepcopy(C)
    c = np.array(c)
    for p, q in enumerate(i):
        if q:
            c[p, :] = "$"
    for j in product([True, False], repeat=w):
        d = copy.deepcopy(c)
        d = np.array(d)
        for s,t in enumerate(j):
            if t:
                d[:, s] = "$"
        if np.count_nonzero(d == "#") == k:
            cnt += 1

print(cnt)

Buggy submission (verdict: Runtime Error):
import numpy as np
import copy
from itertools import product
h, w, k = map(int, input().split())
C = [list(input()) for _ in range(h)]
C = np.array(C)

cnt = 0
for i in product([True, False], repeat=h):
    c = copy.deepcopy(C)
    c = np.array(c)
    for p, q in enumerate(i):
        if q:
            c[p, :] = "$"
    for j in product([True, False], repeat=w):
        d = copy.deepcopy(c)
        d = np.array(d)
        for s,t in enumerate(j):
            if t:
                d[:, s] = "$"
        if np.count_nonzero(d == "#") == k:
            cnt += 1

print(cnt)
Problem p02630 (python)

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
q = int(input())
total = sum(a)

a = Counter(a)
for _ in range(q):
    b, c = map(int, input().split())
    total += a[b] * c
    total -= a[b] * b
    a[c] += a[b]
    del a[b]
    print(total)

Buggy submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
q = int(input())

a = Counter(a)
for _ in range(q):
    b, c = map(int, input().split())
    a[c] += a[b]
    a.pop(b)
    ans = [x * y for x, y in a.items()]
    print(sum(ans))
Problem p02664 (python)

Fixed submission:
t = list(input())

if len(t) == 1 and t[0] == "?":
    t[0] = "D"
    print(t[0])
    exit()

if t[0] == "?":
    if t[1] == "P":
        t[0] = "D"
    else:
        t[0] = "P"
for i in range(1, len(t)-1):
    if t[i] == "?" and t[i-1] == "P":
        t[i] = "D"
    elif t[i] == "?" and t[i+1] == "D":
        t[i] = "P"
    elif t[i] == "?" and t[i+1] == "?":
        t[i] = "P"
        t[i+1] = "D"
    elif t[i] == "?":
        t[i] = "D"
if len(t) > 1:
    if t[-1] == "?":
        t[-1] = "D"

print("".join(t))

Buggy submission (verdict: Runtime Error):
t = list(input())

if t[0] == "?":
    if t[1] == "P":
        t[0] = "D"
    else:
        t[0] = "P"
for i in range(1, len(t)-1):
    if t[i] == "?" and t[i-1] == "P":
        t[i] = "D"
    elif t[i] == "?" and t[i+1] == "D":
        t[i] = "P"
    elif t[i] == "?" and t[i+1] == "?":
        t[i] = "P"
        t[i+1] = "D"
    elif t[i] == "?":
        t[i] = "D"
if t[-1] == "?":
    t[-1] = "D"

print("".join(t))

Buggy submission (verdict: Runtime Error):
t = list(input())

if t[0] == "?":
    if t[1] == "P":
        t[0] = "D"
    else:
        t[0] = "P"
for i in range(1, len(t)-1):
    if t[i-1] == "P":
        t[i] = "D"
    elif t[i+1] == "D":
        t[i] = "P"
    elif t[i+1] == "?":
        t[i] = "P"
        t[i+1] = "D"
    else:
        t[i] = "D"
if t[-1] == "?":
    t[-1] = "D"

print("".join(t))
Problem p02756 (python)

Fixed submission:
from collections import deque

s = deque(str(input()))
q = int(input())

t = 0
for i in range(q):
    o = list(map(str, input().split()))
    if o[0] == "1":
        t += 1
    else:
        if o[1] == "1" and t%2 == 0 or o[1] == "2" and t%2 == 1:
            s.appendleft(o[2])
        else:
            s.append(o[2])

if t%2 == 1:
    s.reverse()

print("".join(s))

Buggy submission (verdict: Runtime Error):
from collections import deque
s = input()
q = int(input())
former = deque()
latter = deque()

flg = False
for i in range(q):
    p = list(map(str, input().split()))
    if p[0] == "1":
        flg = True if flg == False else False
        continue
    else:
        if (p[1] == "1" and not flg) or (p[1] == "2" and flg):
            former.appendleft(p[2])
        else:
            latter.append(p[2])

ans = former + deque(s) + latter
ans = "".join(ans)
print(ans if not flg else ans[::-1])
Problem p02761 (python)

Fixed submission:
n, m = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(m)]
sc = list(map(list, set(map(tuple, sc))))

ans = [-1] * n
for i in sc:
    if i[0] == 1 and i[1] == 0 and n == 1:
        print(0)
        exit()
    if i[0] == 1 and i[1] == 0:
        print(-1)
        exit()
    if i[0] > n or ans[i[0]-1] != -1:
        print(-1)
        exit()
    ans[i[0]-1] = i[1]

for i, val in enumerate(ans):
    if val == -1:
        ans[i] = 0

if (m == 0 and n != 1) or (ans[0] == 0 and n != 1):
    ans[0] = 1

flg = False
for i in ans:
    if i != 0:
        flg = True
if not flg:
    print(0)
    exit()

ans = map(lambda x: str(x), ans)
print("".join(ans))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(m)]
sc = list(map(list, set(map(tuple, sc))))

l = list()
for i in range(1000):
    i = str(i).zfill(3)
    flg = True
    for j in sc:
        if int(i[j[0]-1]) != j[1]:
            flg = False
    if flg:
        l.append(int(i))

print(min(l))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(m)]
sc = list(map(list, set(map(tuple, sc))))

l = list()
for i in range(1000):
    i = str(i).zfill(3)
    flg = True
    for j in sc:
        if i[j[0]-1] != j[1]:
            flg = False
    if flg:
        l.append(int(i))

print(min(l))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(m)]
sc = list(map(list, set(map(tuple, sc))))

l = list()
for i in range(1000):
    i = str(i)
    flg = True
    for j in sc:
        if i[j[0]-1] != j[1]:
            flg = False
    if flg:
        l.append(int(i))

print(min(l))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(m)]
sc = list(map(list, set(map(tuple, sc))))

l = list()
for i in range(1000):
    i = str(i)
    flg = True
    for j in sc:
        if i[j[0]-1] != j[1]:
            flg = False
    if flg:
        l.append(i)

print(min(l))
Problem p02765 (python)

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

if n >= 10:
    print(r)
else:
    print(r + 100*(10-n))

Buggy submission (verdict: Runtime Error):
n, r = map(itn, input().split())

if n >= 10:
  print(r)
else:
  print(r + 100 * (10 - n))
Problem p02780 (python)

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

p = list(map(lambda x: x * (x+1) /2 /x, p))

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

m = p[k-1]
for i in range(k, n):
    a = p[i] - p[i-k]
    if m < a:
        m = a

print(m)

Buggy submission (verdict: Runtime Error):
from itertools import accumulate
N, K = map(int, input().split())
P = list(map(int, input().split()))

A = list(accumulate(P))

largest = A[2]
point = 0
for i in range(K, N):
    if largest < A[i] - A[i-K]:
        largest = A[i] - A[i-K]
        point = i

ans = 0
for j in range(point - K + 1, point+1):
    p = P[j]
    ans += (((p + 1) * p) / 2) / p

print(ans)
Problem p02786 (python)

Fixed submission:
from functools import lru_cache
h = int(input())
count = 0

while h > 1:
  h = h//2
  count +=1

@lru_cache(maxsize=100000)
def f(n):
    if n < 1:
        return 1
    else:
        return f(n - 1)*2 + 1

print(f(count))

Buggy submission (verdict: Runtime Error):
from functools import lru_cache
h = int(input())
count = 0

while n==1:
  n = h//2
  count +=1

@lru_cache(maxsize=100000)
def f(n):
    if n < 1:
        return 3
    else:
        return f(n - 1)*2 + 1

print(f(count))
Problem p02791 (python)

Fixed submission:
n = int(input())
p = list(map(int, input().split()))
count = 0
m = [0] * n

memo = n
for i in range(n):
    if memo > p[i]:
        m[i] = p[i]
        memo = p[i]
    else:
        m[i] = memo

for i in range(1, n+1):
    if p[i-1] <= m[i-1]:
        count += 1

print(count)

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
p = list(map(int, input().split()))
count = 0
tof = True


for i in range(1, n+1):
    if p[i-1] <= np.min(p[:i]):
        count += 1

print(count)
Problem p02830 (python)

Fixed submission:
N = int(input())
S, T = input().split()
A = str()
 
for i in range(N):
    A += S[i]
    A += T[i]
    
print(A)

Buggy submission (verdict: Runtime Error):
N = int(input())
S, T = [input().split()]
A = ""

for i in N
	A += S[i]
	A += T[i]
    
print(A)
Problem p02838 (python)

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

mod = 10 ** 9 + 7
ans = 0
for i in range(60):
    ones = 0
    for a in A:
        # 数列Aの全要素の(二進法表記の)i桁目の１の数を集計する
        if a & (1 << i):
            ones += 1
    # Aの要素から任意の2つを選んで排他的論理和をとってできた数列をBとすると、
    # 数列Bの全要素のi桁目の合計は、(Aのi桁目の１の数)*(0の数)となる
    # 選んだ２つのAの要素が(0,1)の組み合わせになっている場合(XOR)だけに、Bの桁を構成する要素になるため
    ans = (ans + ones * (N - ones) * (1 << i)) % mod

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

mod = 10 ** 9 + 7
ans = 0
for i in range(60):
    ones = 0
    for a in A:
        # 数列Aの全要素の(二進法表記の)i桁目の１の数を集計する
        if a & (1 << i):
            ones += 1
    # Aの要素から任意の2つを選んで排他的論理和をとってできた数列をBとすると、
    # 数列Bの全要素のi桁目の合計は、(Aのi桁目の１の数)*(0の数)となる
    # 選んだ２つのAの要素が(0,1)の組み合わせになっている場合(XOR)だけに、Bの桁を構成する要素になるため
    ans = (ans + ones * (N - ones) * (1 << i)) % mod

print(ans)