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

Fixed submission:
import numpy as np
N = int(input())

x = []
y = []
xy1 = []
xy2 = []

for i in range(N):
    a, b = (int(t) for t in input().split())
    x.append(a)
    y.append(b)
    xy1.append(a + b)
    xy2.append(a - b)

max1 = max(xy1) - min(xy1)
max2 = max(xy2) - min(xy2)
print(max((max1, max2)))

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())

x = np.empty(N, dtype=np.longlong)
y = np.empty(N, dtype=np.longlong)

for i in range(N):
    x[i], y[i] = (int(t) for t in input().split())

ind = np.argsort(x)
X = x[ind]
Y = y[ind]

# max_dist = [0]
# for i in range(1, N):
#     max_dist.append(np.max(-X[:i] - Y[:i]) + X[i] + Y[i])
#     max_dist.append(np.max(-X[:i] + Y[:i]) + X[i] - Y[i])

# print(max(max_dist))


dist = np.abs(x.reshape([-1, 1]) - x.reshape([1, -1])) + np.abs(y.reshape([-1, 1]) - y.reshape([1, -1]))

print(dist.max())

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())

x = np.empty(N, dtype=np.longlong)
y = np.empty(N, dtype=np.longlong)

for i in range(N):
    x[i], y[i] = (int(t) for t in input().split())

ind = np.argsort(x)
X = x[ind]
Y = y[ind]

# max_dist = [0]
# for i in range(1, N):
#     max_dist.append(np.max(-X[:i] - Y[:i]) + X[i] + Y[i])
#     max_dist.append(np.max(-X[:i] + Y[:i]) + X[i] - Y[i])

# print(max(max_dist))


dist = np.abs(x.reshape([-1, 1]) - x.reshape([1, -2])) + np.abs(y.reshape([-1, 1]) - y.reshape([1, -2]))

print(dist.max())

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())

x = np.empty(N, dtype=np.longlong)
y = np.empty(N, dtype=np.longlong)


for i in range(N):
    x[i], y[i] = (int(t) for t in input().split())

    
dist = np.abs(x.reshape([-1, 1]) - x.reshape([1, -1])) + np.abs(y.reshape([-1, 1]) - y.reshape([1, -1]))

print(dist.max())
Problem p02573 (python)

Fixed submission:
N, M = (int(d) for d in input().split())

C = [set() for i in range(N+1)]
for i in range(M):
    A, B = (int(d) for d in input().split())
    C[A].update([B])
    C[B].update([A])

# BFS
seen = set()
G = []

for i in range(1, N+1):
    if i in seen:
        continue

    # create new group
    G.append(set())

    # create queue
    Q = [i]
    G[-1].update(Q)
    seen.update(Q)

    while len(Q) > 0:
        # queue is not empty

        I = Q.pop(0)
        J = C[I].difference(seen)
        Q += list(J)
        G[-1].update(J)

        seen.update(J)

print(max([len(g) for g in G]))

Buggy submission (verdict: Runtime Error):
N, M = (int(d) for d in input().split())

C = [[] for i in range(N+1)]
for i in range(M):
    A, B = (int(d) for d in input().split())
    C[A].append(B)
    C[B].append(A)

# BFS
Q = []
ungrouped = [i for i in range(1, N+1)]
G = []

while len(ungrouped) > 0:
    init = ungrouped.pop(0)
    Q += C[init]
    G.append([])
    G[-1].append(init)

    while len(Q) > 0:
        I = Q.pop(0)
        for J in C[I]:
            if J in ungrouped:
                Q.append(J)
        G[-1].append(I)
        ungrouped.remove(I)

print(max([len(g) for g in G]))
Problem p02612 (python)

Fixed submission:
N = int(input())

print((1000 - (N % 1000)) % 1000)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())

A = np.array([int(i) for i in input().split()])
A_sort = np.sort(A)

#print(A_sort)
score = 0
score += A_sort[-1]
for i in range(0, (N-2)//2):
    score += A_sort[-2-i] * 2
    
if (N-2) % 2 == 1:
    score += A_sort[-3-i]
    
print(score)
Problem p02801 (python)

Fixed submission:
C = ord(raw_input())
print(chr(C+1))

Buggy submission (verdict: Runtime Error):
C = raw_input()
C_ord = ord(C)
print(chr(C_ord + 1))

Buggy submission (verdict: Runtime Error):
C = raw_input()
C_ord = ord(C)
print(str(C_ord+1))
Problem p02848 (python)

Fixed submission:
N = int(raw_input())
S = raw_input()
I = map(ord, S)
I_shifted = map(lambda x: x+N if x+N<91 else x+N-26, I)
print "".join(map(chr, I_shifted))

Buggy submission (verdict: Runtime Error):
N = int(raw_input())
S = raw_input
I = map(ord, S)
I_shifted = map(lambda x: x+N if x+N<91 else x+N-26, I)
print map(chr, I_shifted)
Problem p03029 (python)

Fixed submission:
A, P = map(int, raw_input().split())

N_piec = A * 3  + P
N_pie  = N_piec / 2
print N_pie

Buggy submission (verdict: Runtime Error):

A, P = map(int, raw_input.split())

N_piec = A * 3  + P
N_pie  = N_piec / 2
print N_pie
Problem p03781 (python)

Fixed submission:
from math import sqrt
X = int(raw_input())

ans = 0
Init = int(sqrt(2*X)) + 1
for N in xrange(X+1):
    if (N+1) * N >= 2 * X:
        ans = N
        break
    
print ans

Buggy submission (verdict: Runtime Error):
import numpy as np
N, K = map(int, raw_input().split())
A = np.array(map(int, raw_input().split()))
A = np.sort(A)
Sum = A.sum()
if Sum < K:
    print N
else:
    # Find the Smallest Necessary Number 
    # SmallNec = N-1
    A_cumsum = np.concatenate(([0], np.cumsum(A)))
    # SubSet A[0:I]
    I = np.where(A_cumsum<K)[0][-1] + 1
    Sum_ = A_cumsum[I]
    while Sum_ >= K:
        for J in xrange(I-1, -1, -1):
            if A[J] >= Sum_ - K:
                # A[J] is Necessary
                I = J
                pass
            else:
                # A[J] Maybe Unnecessary
                break
        Sum_ = A_cumsum[I]
    print I

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np
N, K = map(int, raw_input().split())
A = np.array(map(int, raw_input().split()))
A = np.sort(A)
Sum = A.sum()
if Sum < K:
    print N
    sys.exit()
   
A_cumsum = np.concatenate(([0], np.cumsum(A)))
I = np.where(A_cumsum<K)[0][-1] + 1

Sum_ = A_cumsum[I]
while Sum_ > K:
    for J in xrange(I-1, -1, -1):
        if A[J] <= Sum_ - K:
            break
    I = J + 1
    Sum_ = A_cumsum[I]

print I
Problem p03043 (python)

Fixed submission:
'''input
100000 5
'''
from math import ceil, log2
N, K = [int(x) for x in input().split()]

ats = 0.0

for i in range(1, N+1):
	if i >= K:
		ats += 1/N
		continue

	ats += 1/N/(2.0**(float(ceil(log2(K/i)))))

print(ats)

Buggy submission (verdict: Runtime Error):
'''input
100000 5
'''
from math import ceil, log2
N, K = [int(x) for x in input().split()]

ats = 0.0

for i in range(1, N+1):
	if i >= K:
		ats += 1/N
		continue

	ats += 1/N/(2.0**(float(ceil(log2(K/i)))))

print(ats)

Buggy submission (verdict: Runtime Error):
'''input
100000 5
'''
from math import ceil, log2
N, K = [int(x) for x in input().split()]

ats = 0.0

for i in range(1, N+1):
	if i >= K:
		ats += 1/N
		continue

	ats += 1/N*2**(-ceil(log2(K/i)))

print(ats)
Problem p03044 (python)

Fixed submission:
'''input
3
1 2 2
2 3 1
'''
import sys
sys.setrecursionlimit(100100)
N = int(input())

edges = [[] for i in range(N)]

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


color = [None]*N

color[0] = 0

def dfs(curr, prev):
	for i in edges[curr]:
		if i[0] == prev: continue

		if i[1] % 2 == 0: color[i[0]] = color[curr]
		else: color[i[0]] = 1 - color[curr]

		dfs(i[0], curr)

dfs(0, -1)

for i in color:
	print(i)

Buggy submission (verdict: Runtime Error):
'''input
3
1 2 2
2 3 1
'''
import sys
sys.setrecursionlimit(100100)
N = int(input())

edges = [[] for i in range(N)]

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


color = [None]*N

color[0] = 0

def dfs(curr, prev):
	for i in edges[curr]:
		if i[0] == prev: continue

		if i[1] % 2 == 0: color[i[0]] = color[curr]
		else: color[i[0]] = 1 - color[curr]

		dfs(i[0], curr)

dfs(0, -1)

for i in color:
	print(i)

Buggy submission (verdict: Runtime Error):
'''input
3
1 2 2
2 3 1
'''

N = int(input())

edges = [[] for i in range(N)]

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


color = [None]*N

color[0] = 0

def dfs(curr, prev):
	for i in edges[curr]:
		if i[0] == prev: continue

		if i[1] % 2 == 0: color[i[0]] = color[curr]
		else: color[i[0]] = 1 - color[curr]

		dfs(i[0], curr)

dfs(0, -1)

for i in color:
	print(i)

Buggy submission (verdict: Runtime Error):
'''input
1

'''

N = int(input())

edges = [[] for i in range(N)]

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


color = [None]*N

color[0] = 0

def dfs(curr, prev):
	for i in edges[curr]:
		if i[0] == prev: continue

		color[i[0]] = color[curr] if i[1] % 2 == 0 else 1 - color[curr]
		dfs(i[0], curr)

dfs(0, -1)

for i in color:
	print(i)

Buggy submission (verdict: Runtime Error):
'''input
5
2 5 2
2 3 10
1 3 8
3 4 2
'''

N = int(input())

edges = [[] for i in range(N)]

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


color = [None]*N

color[0] = 0

def dfs(curr, prev):
	
	for i in edges[curr]:
		if i[0] == prev: continue

		color[i[0]] = color[curr] if i[1] % 2 == 0 else 1 - color[curr]
		dfs(i[0], curr)

dfs(0, -1)

for i in color:
	print(i)
Problem p02642 (python)

Fixed submission:
from numba import njit

N = int(input())
A = list(map(int, input().split()))
maxA = max(A)
dp = [0] * maxA

for i in range(N):
    if dp[A[i]-1] != 0:
        dp[A[i]-1] = 2
        continue
    else:
        for j in range(1, maxA//A[i]+1):
            dp[A[i]*j-1] += 1

ans = 0
for i in range(N):
    if dp[A[i]-1] == 1:
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
def quick_sort(arr):
    left = []
    right = []
    if len(arr) <= 1:
        return arr
    ref = arr[0]
    ref_count = 0
    for ele in arr:
        if ele < ref:
            left.append(ele)
        elif ele > ref:
            right.append(ele)
        else:
            ref_count += 1
    left = quick_sort(left)
    right = quick_sort(right)
    return right + [ref] * ref_count + left

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

A = [x for x in A if A.count(x) == 1]
A = quick_sort(A)

ans = 0
if len(A) == 0:
    print(ans)
    exit()
for i in range(N):
    flag = True
    for j in range(i+1, N):
        if A[i] % A[j] == 0:
            flag = False
            break
    if flag: ans += 1
print(ans)
Problem p02678 (python)

Fixed submission:
import sys
import math
import numpy as np
from collections import deque

def I():
  return int(input())
def IS():
  return map(int, input().split())
def IL():
  return [int(x) for x in input().split()]
def ILL(n):
  return [list(map(int, input().split())) for _ in range(n)]
def S():
  return input()
def SS():
  return input().split()

def main():
  N, M = IS()
  to = [[] for _ in range(N)]
  INF = float('inf')
  for i in range(M):
    A, B = IS()
    A -= 1
    B -= 1
    to[A].append(B)
    to[B].append(A) 
  # queue
  q = deque()
  q.append(0)
  # diatance to first room
  dist = [INF] * N
  # previous room
  prev = [-1] * N
 
  #### BFS ####
  while len(q) != 0:
    # pop from queue
    v = q.popleft()
    # seatch room of v's neighboor
    for u in to[v]:
      if prev[u] == -1:
        dist[u] = dist[v] + 1
        prev[u] = v
        q.append(u)
  # print answer
  print("Yes")
  for i in range(1, len(prev)):
    print(prev[i] + 1)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import numpy as np
from scipy.sparse.csgraph import shortest_path
from scipy.sparse import csr_matrix

n, m = map(int, input().split())
l = [[0 for _ in range(m)] for _ in range(m)]
for _ in range(m):
  a, b = map(int, input().split())
  l[a-1][b-1] = 1
  l[b-1][a-1] = 1

csr = csr_matrix(l)
d, p = shortest_path(csr, indices=0, directed=False, unweighted=True, return_predecessors=True)
p += 1

print('Yes')
for i in p:
  if i < 0: continue
  print(i)
Problem p02755 (python)

Fixed submission:
a, b = map(int, input().split())
for i in range(1, 10**5):
    if (i*8) // 100 == a and i // 10 == b:
        print(i)
        exit()
print(-1)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
for i in range(1, 10**5):
    if (i*8) // 100 == a and i // 10 == b:
        print(n)
        exit()
print(-1)
Problem p02814 (python)

Fixed submission:
from fractions import gcd

N, M = map(int, input().split())
A = [int(i) // 2 for i in input().split()]  

A_lcm = 1
for i in range(N):
    A_lcm *= A[i] // gcd(A_lcm, A[i])
    
for i in A:
    if A_lcm // i % 2 == 0:
        print(0)
        exit()

print((M // A_lcm + 1) // 2)

Buggy submission (verdict: Runtime Error):
from math import gcd

N, M = map(int, input().split())
A = [int(i) // 2 for i in input().split()]  

A_lcm = 1
for i in range(N):
    A_lcm *= A[i] // gcd(A_lcm, A[i])
    
for i in A:
    if A_lcm // i % 2 == 0:
        print(0)
        exit()

print((M // A_lcm + 1) // 2)

Buggy submission (verdict: Runtime Error):
import fractions
def lcm(a, b):
    return a // fractions.gcd(a, b) * b

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

A_half = [0.5 * a for a in A]
A_lcm = A_half[0]

for i in range(1, N):
    A_lcm = lcm(int(A_lcm), int(A_half[i]))

for i in A_half:
    if A_lcm // i % 2 == 0:
        print(0)
        exit()
ans = (M // A_lcm + 1) // 2
print(int(ans))

Buggy submission (verdict: Runtime Error):
import fractions
def lcm(a, b):
    return a * b / fractions.gcd(a, b)

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

A_half = [0.5 * a for a in A]
A_lcm = A_half[0]

for i in range(1, N):
    A_lcm = lcm(int(A_lcm), int(A_half[i]))

for i in A_half:
    if A_lcm // i % 2 == 0:
        print(0)
        exit()
ans = (M // A_lcm + 1) // 2
print(int(ans))

Buggy submission (verdict: Runtime Error):
import fractions
def lcm(a, b):
    return a * b / fractions.gcd(a, b)

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

A_half = [0.5 * a for a in A]
A_lcm = A_half[0]

for i in range(1, N):
    A_lcm = lcm(int(A_lcm), int(A_half[i]))

ans = 0
if (M // 2) % 2 == 0:
    ans = (M // A_lcm) // 2
else:
    ans = (M // A_lcm) // 2 + 1

print(int(ans))

Buggy submission (verdict: Runtime Error):
import math
def lcm(a, b):
    return a * b / math.gcd(a, b)

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

A_half = [0.5 * a for a in A]
A_lcm = A_half[0]

for i in range(1, N):
    A_lcm = lcm(int(A_lcm), int(A_half[i]))

ans = 0
if (M // 2) % 2 == 0:
    ans = (M // A_lcm) // 2
else:
    ans = (M // A_lcm) // 2 + 1

print(int(ans))

Buggy submission (verdict: Runtime Error):
import math
def lcm(a, b):
    return a * b / math.gcd(a, b)

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

A_half = [0.5 * a for a in A]
A_lcm = A_half[0]

for i in range(1, N):
    A_lcm = lcm(int(A_lcm), int(A_half[i]))

ans = (M // A_lcm) // 2 if (M // 2) % 2 == 0 else (M // A_lcm) // 2 + 1
print(int(ans))
Problem p02900 (python)

Fixed submission:
from fractions import gcd
def factorization(n):
    fac = {}
    count = 0
    while n % 2 == 0:
        n //= 2
        count += 1
    if count > 0:
        fac[2] = count
    for i in range(3, int(n ** .5) + 1, 2):
        count = 0
        while n % i == 0:
            n //= i
            count += 1
        if count > 0:
            fac[i] = count
    if n > 1:
        fac[n] = 1
    return fac

A, B = map(int, input().split())
fac = factorization(gcd(A, B))
print(len(fac) + 1)

Buggy submission (verdict: Runtime Error):
from fractions import gcd

def get_primes(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, n+1, i):
            is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]

def factorization_num(n, pl):
    count = 0
    for p in pl:
        if n % p == 0: count += 1
    return count

A, B = map(int, input().split())
print(factorization_num(gcd(A, B), get_primes(gcd(A, B))) + 1)

Buggy submission (verdict: Runtime Error):
from math import gcd

def get_primes(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, n+1, i):
            is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]

def factorization_num(n, pl):
    count = 0
    for p in pl:
        if n % p == 0: count += 1
    return count

A, B = map(int, input().split())
print(factorization_num(gcd(A, B), get_primes(gcd(A, B))) + 1)

Buggy submission (verdict: Runtime Error):
import math

def get_primes(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, n+1, i):
            is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]

def factorization_num(n, pl):
    count = 0
    for p in pl:
        if n % p == 0: count += 1
    return count

A, B = map(int, input().split())
print(factorization_num(math.gcd(A, B), get_primes(math.gcd(A, B))) + 1)
Problem p02918 (python)

Fixed submission:
N, K = map(int, input().split())
S = input()

ans = N - 1
initial = 0
for i in range(N-1):
    if S[i] == S[i+1]: initial += 1
ans = min(ans, initial + 2 * K)
print(ans)

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

ans = N - 1
initial = 0
for i in range(N-1):
    if S[i] == S[i+1]: initial += 1
ans = min(ans, initial + 2 * K)
print(ans)v
Problem p02936 (python)

Fixed submission:
from collections import deque
 
N, Q = map(int, input().split())
Ki = [[] for _ in range(N)]
for _ in range(N-1):
    p, c = map(int, input().split())
    Ki[p-1].append(c-1)
    Ki[c-1].append(p-1)
S = [0]*N
for _ in range(Q):
    node, score = map(int, input().split())
    S[node-1] += score
 
stack = deque([0])
done = [0]*N
done[0] = 1
 
while len(stack) > 0:
    now = stack.pop()
    
    for new in Ki[now]:
        if done[new] == 0:
            done[new] = 1
            stack.append(new)
            S[new] += S[now]
    
print(*S)

Buggy submission (verdict: Runtime Error):
N, Q = map(int, input().split())
connect = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    connect[a].append(b)
    connect[b].append(a)
score = [0] * N
for _ in range(Q):
    p, x = map(int, input().split())
    p -= 1
    score[p] += x

def dfs(now, prev = -1):
    for nx in connect[now]:
        if nx == prev: continue
        score[nx] += score[now]
        dfs(nx, now)

dfs(0)
print(*score)

Buggy submission (verdict: Runtime Error):
N, Q = map(int, input().split())
connect = {i:set() for i in range(1, N+1)}
for _ in range(N-1):
    a, b = map(int, input().split())
    connect[a].add(b)
    connect[b].add(a)
score = {i:0 for i in range(1, N+1)}
for _ in range(Q):
    p, x = map(int, input().split())
    score[p] += x

def dfs(now, prev = -1):
    for nx in connect[now]:
        if nx == prev: continue
        score[nx] += score[now]
        dfs(nx, now)

dfs(1)
print(*score.values())

Buggy submission (verdict: Runtime Error):
N,Q = (int(x) for x in input().split())
connection ={i:set() for i in range(1,N+1)}
for i in range(N-1):
    a,b = (int(x) for x in input().split())
    connection[a].add(b)
    connection[b].add(a)
#point =OrderedDict({i:0 for i in range(1,N+1)})
point ={i:0 for i in range(1,N+1)}
for i in range(Q):
    p,x = (int(x) for x in input().split())
    point[p] +=x
 
def DFS(now,prev = -1):
    for next in connection[now]:
        if next == prev:
            continue
        point[next] +=point[now] 
        DFS(next,now)
 
DFS(1)
print(*point.values())

Buggy submission (verdict: Runtime Error):
N, Q = map(int, input().split())
connect = {i:set() for i in range(1, N+1)}
for _ in range(N-1):
    a, b = map(int, input().split())
    connect[a].add(b)
    connect[b].add(a)
score = {i:0 for i in range(1, N+1)}
for _ in range(Q):
    p, x = map(int, input().split())
    score[p] += x

def dfs(now, prev = -1):
    for nx in connect[now]:
        if nx == prev: continue
        score[nx] += score[now]
        dfs(nx, now)

dfs(1)
print(*score.values())

Buggy submission (verdict: Runtime Error):
def dfs(now, prev = -1):
    for nx in connect[now]:
        if nx == prev: continue
        score[nx] += score[now]
        dfs(nx, now)

N, Q = map(int, input().split())
connect = {i:set() for i in range(1, N+1)}
for _ in range(N-1):
    a, b = map(int, input().split())
    connect[a].add(b)
    connect[b].add(a)
score = {i:0 for i in range(1, N+1)}
for _ in range(Q):
    p, x = map(int, input().split())
    score[p] += x

dfs(1)
print(*score.values())
Problem p02660 (python)

Fixed submission:

aaa = [0,1,1,2,2,2,3,3,3,3,4,4,4,4,4,5,5,5,5,5,5,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,8]

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
N = int(input())
l = factorization(N) 

ans = 0

for arr in l:
  if arr[0] != 1:
    a = arr[1]
    b = aaa[a]
    ans += b
  
print(ans)

Buggy submission (verdict: Runtime Error):

aaa = [0,1,1,2,2,2,3,3,3,3,4,4,4,4,4,5,5,5,5,5,5,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7]

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
N = int(input())
l = factorization(N) 

ans = 0

for arr in l:
  if arr[0] != 1:
    a = arr[1]
    b = aaa[a]
    ans += b
  
print(ans)
Problem p02677 (python)

Fixed submission:
import math

A,B,H,M = map(int,input().split())

a = 360 * (H/12 + 1/12*M/60)
b = 360 * M/60

c = abs(a-b)
c = min(c,360-c)
cos = math.cos(math.radians(c))

hypotenuse = math.sqrt(math.pow(A, 2) + math.pow(B, 2) - 2 *A*B*cos)

print(hypotenuse)

Buggy submission (verdict: Runtime Error):
import math

A,B,H,M = map(int, input().split())
##Aは短針の長さ、Bは長針の長さ
##ARは短針の進んだ針の角度、BRは長針の進んだ針の角度
AR = 360*H/12+30*M/60
BR = 360*M/60

if abs(AR-BR)<180:
  X = abs(AR-BR)
elif abs(AR-BR)>180:
  X = 360-abs(AR-BR)
else :
  X = 0

C = math.sqrt(　A**2+B**2-abs(2*A*B*math.cos(math.radians(X)))　)

if X ==0:
  print(A+B)
else:
  print(C)