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

Fixed submission:
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def dfs(G, v, p, point):
    """G: graph, v: vertex, p: parent"""
    # Loop for each child
    for c in G[v]:
        if c == p:
            continue
        point[c] += point[v]
        dfs(G, c, v, point)


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

    point = [0] * N
    for i in range(Q):
        p, x = map(int, input().split())
        p -= 1
        point[p] += x

    dfs(G, 0, -1, point)
    print(" ".join(map(str, point)))


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def run_count(counter, edges, p, x):
    counter[p] += x
    p_list = edges[p]
    if p_list is None:
        return counter

    for _p in p_list:
        counter = run_count(counter, edges, _p, x)

    return counter


N, Q = [int(i) for i in input().rstrip().split()]

a = [0] * (N - 1)
b = [0] * (N - 1)
for i in range(N - 1):
    a[i], b[i] = [int(j) for j in input().rstrip().split()]

p = [0] * Q
x = [0] * Q
for i in range(Q):
    p[i], x[i] = [int(j) for j in input().rstrip().split()]

edges = {}
for i in range(N):
    edges[i + 1] = []

for i in range(N - 1):
    edges[a[i]].append(b[i])

counter = {}
for i in range(N):
    counter[i + 1] = 0

for i in range(Q):
    counter = run_count(counter, edges, p[i], x[i])

res = ""
for i in range(N):
    res += str(counter[i + 1])
    res += " "
res.rstrip(" ")

print(res)
Problem p03006 (python)

Fixed submission:
import sys
from collections import defaultdict
from itertools import combinations

input = sys.stdin.readline


def main():
    N = int(input())
    x = [0] * N
    y = [0] * N
    for i in range(N):
        x[i], y[i] = map(int, input().split())

    if N == 1:
        print(1)
        sys.exit()

    vector = defaultdict(int)
    for a, b in combinations(range(N), 2):
        dx = x[a] - x[b]
        dy = y[a] - y[b]
        if dx == 0:
            vector[(0, abs(dy))] += 1
        elif dx > 0:
            vector[(dx, dy)] += 1
        else:
            vector[(-dx, -dy)] += 1

    ans = N - max(vector.values())
    print(ans)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
from collections import defaultdict
from itertools import combinations

input = sys.stdin.readline


def main():
    N = int(input())
    x = [0] * N
    y = [0] * N
    for i in range(N):
        x[i], y[i] = map(int, input().split())

    vector = defaultdict(int)
    for a, b in combinations(range(N), 2):
        dx = x[a] - x[b]
        dy = y[a] - y[b]
        if dx == 0:
            vector[(0, abs(dy))] += 1
        elif dx > 0:
            vector[(dx, dy)] += 1
        else:
            vector[(-dx, -dy)] += 1

    ans = N - max(vector.values())
    print(ans)


if __name__ == "__main__":
    main()
Problem p03014 (python)

Fixed submission:
H, W = map(int, input().split())
S = [None] * H
for i in range(H):
    S[i] = input()

up = [[0 for w in range(W)] for h in range(H)]
down = [[0 for w in range(W)] for h in range(H)]
left = [[0 for w in range(W)] for h in range(H)]
right = [[0 for w in range(W)] for h in range(H)]

# up and left
for h in range(H):
    for w in range(W):
        if S[h][w] == "#":
            up[h][w] = 0
            left[h][w] = 0
        else:
            # up
            if h == 0:
                up[h][w] = 1
            else:
                up[h][w] = up[h - 1][w] + 1
            # left
            if w == 0:
                left[h][w] = 1
            else:
                left[h][w] = left[h][w - 1] + 1

# down and right
for h in reversed(range(H)):
    for w in reversed(range(W)):
        if S[h][w] == "#":
            down[h][w] = 0
            right[h][w] = 0
        else:
            # down
            if h == H - 1:
                down[h][w] = 1
            else:
                down[h][w] = down[h + 1][w] + 1
            # right
            if w == W - 1:
                right[h][w] = 1
            else:
                right[h][w] = right[h][w + 1] + 1


ans = 0
for h in range(H):
    for w in range(W):
        masu = -3
        masu += up[h][w]
        masu += down[h][w]
        masu += left[h][w]
        masu += right[h][w]
        if masu > ans:
            ans = masu

print(ans)

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
S = [None] * H
for i in range(H):
  S[i] = input()

# direction definition
# 0: up
# 1: down
# 2: left
# 3: right
grid = [[[-1, -1, -1, -1] for w in range(W)] for h in range(H)]

# Initialize top and bottom sides
for w in range(W):
  grid[0][w][0] = 1
  grid[H-1][w][1] = 1

# Initialize left and right sides
for h in range(H):
  grid[h][0][2] = 1
  grid[h][W-1][3] = 1

# height, width, direction
def dfs(h, w, d):
  if not (0<=h<=H-1 and 0<=w<=W-1):
    return 0
  
  if S[h][w] == "#":
    grid[h][w] = [0, 0, 0, 0]
    return 0

  # up
  if d == 0:
    if grid[h][w][d] == -1:
      grid[h][w][d] = 1 + dfs(h-1, w, d)
    return grid[h][w][d]
  # down
  elif d == 1:
    if grid[h][w][d] == -1:
      grid[h][w][d] = 1 + dfs(h+1, w, d)
    return grid[h][w][d]
  # left
  elif d == 2:
    if grid[h][w][d] == -1:
      grid[h][w][d] = 1 + dfs(h, w-1, d)
    return grid[h][w][d]
  # right
  elif d == 3:
    if grid[h][w][d] == -1:
      grid[h][w][d] = 1 + dfs(h, w+1, d)
    return grid[h][w][d]

ans = 0
for h in range(H):
  for w in range(W):
    if S[h][w] == ".":
      count = 1
      count += dfs(h-1, w, 0)
      count += dfs(h+1, w, 1)
      count += dfs(h, w-1, 2)
      count += dfs(h, w+1, 3)
      if count >= ans:
        ans = count
    
print(ans)
Problem p03044 (python)

Fixed submission:
import sys
sys.setrecursionlimit(100000)

N = int(input())
G = [[] for _ in range(N)]
for _ in range(N - 1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    G[u].append((v, w))
    G[v].append((u, w))

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


def dfs(pos, color):
    C[pos] = color
    for e in G[pos]:
        if C[e[0]] != -1:
            continue
        # odd
        if e[1] & 1:
            c = 1 - color
            dfs(e[0], c)
        # even
        else:
            c = color
            dfs(e[0], c)


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

Buggy submission (verdict: Runtime Error):
N = int(input())
G = [[] for _ in range(N)]
for _ in range(N - 1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    G[u].append((v, w))
    G[v].append((u, w))

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


def dfs(pos, color):
    for e in G[pos]:
        if C[e[0]] != -1:
            continue
        # odd
        if e[1] & 1:
            c = 1 - color
            C[e[0]] = c
            dfs(e[0], c)
        # even
        else:
            c = color
            C[e[0]] = c
            dfs(e[0], c)


C[0] = 0
dfs(0, 0)
for i in range(N):
    print(C[i])

Buggy submission (verdict: Runtime Error):
N = int(input())
G = [[]] * N
for _ in range(N - 1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    G[u].append((v, w))
    G[v].append((u, w))

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


def dfs(pos, color):
    for e in G[pos]:
        if C[e[0]] != -1:
            continue
        # odd
        if e[1] & 1:
            c = 1 - color
            C[e[0]] = c
            dfs(e[0], c)
        # even
        else:
            c = color
            C[e[0]] = c
            dfs(e[0], c)


C[0] = 0
dfs(0, 0)
for i in range(N):
    print(C[i])
Problem p03096 (python)

Fixed submission:
import sys

input = sys.stdin.readline
P = 10 ** 9 + 7


def main():
    N = int(input())
    C = [None] * N
    for i in range(N):
        C[i] = int(input())

    MAX_C = 2 * 10 ** 5
    C = [-1] + C
    D = [-1] * (MAX_C + 1)
    dp = [0] * (N + 1)
    dp[0] = 1
    for i in range(N):
        if C[i + 1] == C[i]:
            dp[i + 1] = dp[i]
        else:
            j = D[C[i + 1]]
            if j != -1:
                dp[i + 1] = dp[i] + dp[j]
            else:
                dp[i + 1] = dp[i]
        dp[i + 1] %= P
        D[C[i + 1]] = i + 1

    ans = dp[N]
    print(ans)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys

input = sys.stdin.readline
P = 10 ** 9 + 7


def main():
    N = int(input())
    C = [None] * N
    for i in range(N):
        C[i] = int(input())

    C = [-1] + C
    D = [-1] * (N + 1)
    dp = [0] * (N + 1)
    dp[0] = 1
    for i in range(N):
        if C[i + 1] == C[i]:
            dp[i + 1] = dp[i]
        else:
            j = D[C[i + 1]]
            if j != -1:
                dp[i + 1] = dp[i] + dp[j]
            else:
                dp[i + 1] = dp[i]
        dp[i + 1] %= P
        D[C[i + 1]] = i + 1

    ans = dp[N]
    print(ans)


if __name__ == "__main__":
    main()
Problem p03102 (python)

Fixed submission:
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [0] * N
for i in range(N):
  A[i] = list(map(int, input().split()))

ans = 0
for i in range(N):
  y = C
  for j in range(M):
    y += A[i][j]*B[j]
  if y > 0:
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [0] * N
for i in range(N):
  A[i] = list(map(int, input().split()))

ans = 0
for i in range(N):
  y = C
  for j in range(M):
    y += A[j]*B[j]
  if y > 0:
    ans += 1
print(ans)
Problem p03161 (python)

Fixed submission:
import sys

input = sys.stdin.readline
INF = float("inf")


def main():
    N, K = map(int, input().split())
    h = list(map(int, input().split()))

    dp = [0] * N
    for i in range(1, N):
        min_cost = INF
        for k in range(1, min(K + 1, i + 1)):
            cost = dp[i - k] + abs(h[i] - h[i - k])
            if cost < min_cost:
                min_cost = cost
        dp[i] = min_cost

    ans = dp[-1]
    print(ans)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys

import numba as nb

input = sys.stdin.readline
INF = float("inf")


@nb.njit
def solve(N, K, h):
    dp = [0] * N
    for i in range(1, N):
        min_cost = INF
        for k in range(1, min(K + 1, i + 1)):
            cost = dp[i - k] + abs(h[i] - h[i - k])
            if cost < min_cost:
                min_cost = cost
        dp[i] = min_cost
    return dp[-1]


def main():
    N, K = map(int, input().split())
    h = tuple(map(int, input().split()))

    ans = solve(N, K, h)
    print(ans)


if __name__ == "__main__":
    main()
Problem p03229 (python)

Fixed submission:
import sys
from collections import deque

input = sys.stdin.readline


def main():
    N = int(input())
    A = [0] * N
    for i in range(N):
        A[i] = int(input())

    A.sort()
    d = deque(A)
    min_A = d.popleft()
    max_A = d.pop()
    ans = max_A - min_A
    v1 = min_A
    v2 = max_A
    while d:
        if len(d) == 1:
            v = d.pop()
            ans += max(abs(v1 - v), abs(v2 - v))
        else:
            v_min = d[0]
            v_max = d[-1]
            diff = 0
            is_popleft = None
            if diff < abs(v1 - v_min):
                diff = abs(v1 - v_min)
                next_v1 = v_min
                next_v2 = v2
                is_popleft = True
            if diff < abs(v2 - v_min):
                diff = abs(v2 - v_min)
                next_v1 = v_min
                next_v2 = v1
                is_popleft = True
            if diff < abs(v1 - v_max):
                diff = abs(v1 - v_max)
                next_v1 = v_max
                next_v2 = v2
                is_popleft = False
            if diff < abs(v2 - v_max):
                diff = abs(v2 - v_max)
                next_v1 = v_max
                next_v2 = v1
                is_popleft = False
            if is_popleft is None:
                next_v1 = v_min
                next_v2 = v2
                is_popleft = True
            ans += diff
            v1, v2 = next_v1, next_v2
            if is_popleft:
                d.popleft()
            else:
                d.pop()

    print(ans)


if __name__ == "__main__":
    main()

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

input = sys.stdin.readline


def main():
    N = int(input())
    A = [0] * N
    for i in range(N):
        A[i] = int(input())

    A.sort()
    d = deque(A)
    min_A = d.popleft()
    max_A = d.pop()
    ans = max_A - min_A
    v1 = min_A
    v2 = max_A
    while d:
        if len(d) == 1:
            v = d.pop()
            ans += max(abs(v1 - v), abs(v2 - v))
        else:
            v_min = d[0]
            v_max = d[-1]
            diff = 0
            is_popleft = True
            if diff < abs(v1 - v_min):
                diff = abs(v1 - v_min)
                next_v1 = v_min
                next_v2 = v2
            if diff < abs(v2 - v_min):
                diff = abs(v2 - v_min)
                next_v1 = v_min
                next_v2 = v1
            if diff < abs(v1 - v_max):
                diff = abs(v1 - v_max)
                next_v1 = v_max
                next_v2 = v2
                is_popleft = False
            if diff < abs(v2 - v_max):
                diff = abs(v2 - v_max)
                next_v1 = v_max
                next_v2 = v1
                is_popleft = False
            ans += diff
            v1, v2 = next_v1, next_v2
            if is_popleft:
                d.popleft()
            else:
                d.pop()

    print(ans)


if __name__ == "__main__":
    main()
Problem p03273 (python)

Fixed submission:
import numpy as np

H, W = map(int, input().split())
a = np.zeros(shape=(H, W), dtype=bool)
for i in range(H):
  a[i] = [s == "." for s in input()]

y = [True] * H
for i in range(H):
  if all(a[i,:]):
    y[i] = False

x = [True] * W
for i in range(W):
  if all(a[:,i]):
    x[i] = False

ans = []
for i in range(H):
  if not y[i]:
    continue
  s = ""
  for j in range(W):
    if not x[j]:
      continue
    s = "".join([s, "." if a[i,j] else "#"])
  ans.append(s)

print(*ans, sep="\n")

Buggy submission (verdict: Runtime Error):
 numpy as np

H, W = map(int, input().split())
a = np.zeros(shape=(H, W), dtype=bool)
for i in range(H):
  a[i] = [s == "." for s in input()]

y = [True] * H
for i in range(H):
  if all(a[i,:]):
    y[i] = False

x = [True] * W
for i in range(W):
  if all(a[:,i]):
    x[i] = False

ans = []
for i in range(H):
  if not y[i]:
    continue
  s = ""
  for j in range(W):
    if not x[j]:
      continue
    s = "".join([s, "." if a[i,j] else "#"])
  ans.append(s)

print(*ans, sep="\n")

Buggy submission (verdict: Runtime Error):
 numpy as np

H, W = map(int, input().split())
a = np.zeros(shape=(H, W), dtype=bool)
for i in range(H):
  a[i] = [s == "." for s in input().split()]

y = [True] * H
for i in range(H):
  if all(a[i,:]):
    y[i] = False

x = [True] * W
for i in range(W):
  if all(a[:,i]):
    x[i] = False

ans = []
for i in range(H):
  if not y[i]:
    continue
  s = ""
  for j in range(W):
    if not x[j]:
      continue
    s = "".join([s, "." if a[i,j] else "#"])
  ans.append(s)

print(*ans, sep="\n")

Buggy submission (verdict: Runtime Error):
import numpy as np

H, W = map(int, input().split())
a = np.array(shape=(H, W), dtype=bool)
for i in range(H):
  a[i] = [s == "." for s in input().split()]

y = [True] * H
 i in range(H):
  if all(a[i,:]):
    y[i] = False

x = [True] * W
for i in range(W):
  if all(a[:,i]):
    x[i] = False

ans = []
for i in range(H):
  if not y[i]:
    continue
  s = ""
  for j in range(W):
    if not x[j]:
      continue
    s = "".join([s, "." if a[i,j] else "#"])
  ans.append(s)

print(*ans, sep="\n")
Problem p02606 (python)

Fixed submission:
l,r,d=map(int,input().split())
c=0
for i in range(l,r+1):
  if i%d==0:
    c+=1
print(c)

Buggy submission (verdict: Runtime Error):
N=int(input())
la=list(range(2,10**2+1))
l=[]
for i in range(len(la)):
  l.append(la[i]**2)
for n in range(1,N+1):
  if n<6:
    print(0)
  else:
    c=0
    for x in range(len(l)):
      if l[x]*3>2*n:
        break
      else:
        for y in range(x,len(l)):
          if l[x]+2*l[y]>2*n:
            break
          else:
            for z in range(y,x+y+2):
              if z>len(l)-1:
                break
              if l[x]+l[y]+l[z]>2*n:
                break
              else:
                
                if l[x]+l[y]+l[z]==2*n:
                  
                  if (x+y+z)%2==0: 
                      if l[x]==l[y] and l[y]==l[z]:
                        c+=1
                      elif l[x]==l[y] or l[y]==l[z]:
                        c+=3
                      else:
                        c+=6
                   
    print(c)
Problem p02608 (python)

Fixed submission:
n=int(input())
dp=[0]*(10**5)
for x in range(1,10**2):
  for y in range(1,10**2):
    for z in range(1,10**2):
      dp[x**2+y**2+z**2+x*y+y*z+z*x]+=1
for i in range(n):
  print(dp[i+1])

Buggy submission (verdict: Runtime Error):
N=int(input())
la=list(range(2,10**2+1))
l=[]
for i in range(len(la)):
  l.append(la[i]**2)
for n in range(1,N+1):
  if n<6:
    print(0)
  else:
    c=0
    for x in range(len(l)):
      if l[x]*3>2*n:
        break
      else:
        for y in range(x,len(l)):
          if l[x]+2*l[y]>2*n:
            break
          else:
            for z in range(y,x+y+2):
              if l[x]+l[y]+l[z]>2*n:
                break
              else:
                
                if l[x]+l[y]+l[z]==2*n:
                  
                  if (x+y+z)%2==0: 
                      if l[x]==l[y] and l[y]==l[z]:
                        c+=1
                      elif l[x]==l[y] or l[y]==l[z]:
                        c+=3
                      else:
                        c+=6
                   
    print(c)
Problem p02630 (python)

Fixed submission:
import numpy as np
n=int(input())
a=np.array(list(map(int,input().split())))
q=int(input())
num=np.zeros(100001)
for i in a:
  num[i]+=1
sum=a.sum()
for i in range(q):
  b,c=map(int,input().split())
  sum+=(c-b)*num[b]
  num[c]+=num[b]
  num[b]=0
  print(int(sum))

Buggy submission (verdict: Runtime Error):
import numpy as np
n=int(input())
a=np.array(list(map(int,input().split())))
q=int(input())
bc=np.array([list(map(int,input().split())) for _ in range(q)])
a.sort()
def find(i):#iは参照番号
  j=0
  while a[j]<bc[i][0]:
    if j==q-1:
      break
    j+=1
  while a[j]==bc[i][0]:
    a[j]=bc[i][1]
    j+=1
    if j==len(a):
      break
  a.sort()
  
for i in range(q):
  find(i)
  print(np.sum(a))
Problem p02639 (python)

Fixed submission:
l=list(map(int,input().split()))
for i in range(5):
  if l[i]==0:
    print(i+1)
    break

Buggy submission (verdict: Runtime Error):
l=list(map(int,input().split()))
c=collections.Counter(l)
def j(n):
  judge=1
  for k  in c.keys():
      if n%k==0:
        if n!=k:
          judge=0
          break
  return judge
count=0
if len(list(c.keys()))==1:
       print(count)
else:
  for k in c.keys():
    if j(k)==1:
      count+=1
  print(count)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
l.sort()
sum=1#個数
if l[0]==l[1]:
  sum=0
for j in range(1,n):
  i=1
  for m in range(0,j):
    if l[j]%l[m]==0:
      i=0
      break
  sum+=i
    
print(sum)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
if 2*a<=b and b<=4*a and b%2==0:
  print('yes')
else:print('no')
Problem p02640 (python)

Fixed submission:
X,Y=map(int,input().split())
if 2*X <= Y and Y <= 4*X and Y%2 == 0:
  print('Yes')
else:print('No')

Buggy submission (verdict: Runtime Error):
X,Y=map(int,input().split())
if 2＊X<=Y and Y<=4＊X and Y%2==0:
  print('yes')
else:print('no')
Problem p02642 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
dp=[0]*(10**6+1)
for i in a:
  dp[i]+=1
for i in range(1,10**6+1):
  if dp[i]:
    for  j in range(2*i,10**6+1,i):
      dp[j]=0
print(dp.count(1))

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
l.sort()
sum=1#個数
if l[0]==l[1]:
  sum=0
for j in range(1,n):
  i=1
  for m in range(0,j):
    if l[j] % l[m]==0:
      i=0
      break
  sum+=i
    
print(sum)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
sum=1#個数
if l[0]==l[1]:
  sum=0
l.sort()
for j in range(1,n):
  i=1
  for m in range(0,j):
    if l[j]%l[m]==0:
      i=0
      break
  sum+=i
    
print(sum)
Problem p02657 (python)

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

print(M[0]*M[1])

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
def f():
  if 0 in a:
    print(0)
  else:
    b=1
    for i in range(0,n):
      b*=a[i]

      if b>10**8:
        print(-1)
        exit()
   
    print(b)

f()

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
def main():
  if 0 in a:
    print(0)
  else:
  b=1
  for i in range(0,n):
    b*=a[i]

  if b<=10**8:
    print(b)
  else: print(-1)
Problem p02658 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=1
if 0 in a:
  print(0)
else:
  for i in range(n):
    b*=a[i]
    if b>10**18:
      print(-1)
      exit()
  print(b)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
def f():
  if 0 in a:
    print(0)
  else:
    b=1
    for i in range(0,n):
      b*=a[i]

      if b>10**8:
        print(-1)
        return
   
  print(b)

f()
Problem p02660 (python)

Fixed submission:
import numpy as np
n=int(input())
if n==1:
  print(0)
else:
  def factorization(n):
      arr = []
      temp = n
      for i in range(2, int(-(-n**0.5//1))+1):
          if temp%i==0:
              cnt=0
              while temp%i==0:
                  cnt+=1
                  temp //= i
              arr.append([i, cnt])

      if temp!=1:
          arr.append([temp, 1])

      if arr==[]:
          arr.append([n, 1])

      return arr

  y=factorization(n)
  def judge(y):
    i=1
    while np.arange(i+2).sum()<=y:
      i+=1
    return i
  ans=0
  for i in range(len(y)):
    ans+=judge(y[i][1])
  print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
n=int(input())
count=[1]*(n+1)
x=[]#素因数格納
for i in range(2,n+1):
  if n%i==0 and count[i]==1:
    x.append(i)
    for j in range(2*i,n+1,i):
      count[j]=0
y=[]#指数
for i in x:
  c=1
  while n%(i**(c+1))==0:
    c+=1
  y.append(c)

def judge(y):
  i=1
  while np.arange(i+2).sum()<=y:
    i+=1
  return i
ans=0
for i in range(len(y)):
  ans+=judge(y[i])
print(ans)
Problem p03502 (python)

Fixed submission:
import math
N=int(input())
def g(N):#桁数を返す
  i=0#桁数
  while N>=1:
    N=N/10
    i+=1
  return i

def f(N):
  j=g(N)
  S=0
  while j!=0:
    d=math.floor(N/(10**(j-1)))
    S+=d
    N-=d*(10**(j-1))
    j-=1
  return S
  
if N%f(N)==0:
  print("Yes")
else: print("No")

Buggy submission (verdict: Runtime Error):
N=int(input())
def f(N):
  i=0#桁数
  while N>1:
    N=N/10
    i+=1
  return i

x=f(N)
if N%x==0:
  print("Yes")
else: print("No")

Buggy submission (verdict: Runtime Error):
N=int(input())
def f(N):
  i=0#桁数
  while N>1:
    N=N/10
    i+=1
  return i

x=f(N)
if N%x==0:
  print("yes")
else: print("no")
Problem p02812 (python)

Fixed submission:
n=int(input())
s=input()
print(s.count("ABC"))

Buggy submission (verdict: Runtime Error):
n=int(input())
s=int(input())
print(s.count("ABC"))
Problem p03455 (python)

Fixed submission:
a,b=input().split()
c = int(a) * int(b)
d = int(c) % 2
if (d == 0):
    print("Even")
    
if (d == 1):
    print("Odd")

Buggy submission (verdict: Runtime Error):
a,b = int(input().rstrip().split())

c = a * b

d = c / 2

if(d==0):
  print("Even")
else:
  print("Odd")