Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from sys import stdin
N = int(stdin.readline().rstrip())
ans = stdin.readline().rstrip()
sum = 0
left = 0
right = 0
for itr in range(0,len(ans)):
    count_dot = 0
    count_sharp = 0
    left = itr
    right = left + 1
    if left == len(ans)-1:
        break
    if ans[left] == '#' and ans[right] == '.':
        while(right < N and ans[right] == '.'):
            count_dot += 1
            right += 1
        while(left >= 0 and ans[left] == '#'):
            count_sharp += 1
            left -= 1
        if tmp != 0:
            count += 1
        sum += max(count_dot, count_sharp)
print(count)

Fixed submission:
from sys import stdin
N = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()
sum = 0
wh = s.count('.')
cnt = 0
for itr in range(N):
    if s[itr] == '#':
        cnt += 1
        continue
    if cnt > 0:
        sum += 1
        cnt -= 1
print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin

sN, sQ = stdin.readline().split()
N, Q = int(sN), int(sQ)
# print(N,Q)
S = stdin.readline().rstrip()
data = [stdin.readline().split() for itr in range(Q)]
# print(data)

for itr in range(Q):
    l = int(data[itr][0]) - 1 
    r = int(data[itr][1])
    s = S[l:r]
    # print(s)
    print(s.count('AC'))

Fixed submission:
from sys import stdin

sN, sQ = stdin.readline().split()
N, Q = int(sN), int(sQ)
# print(N,Q)
S = stdin.readline().rstrip()
data = [stdin.readline().split() for itr in range(Q)]
# print(data)

grid = [None] * N
# print(grid)
count = 0
for num in range(N):
    if num == 0:
        grid[num] = count
        continue
    if S[num] == 'C' and S[num-1] == 'A':
        count += 1
        grid[num] = count
        continue
    grid[num] = count

# print(grid)

for itr in range(Q):
    l = int(data[itr][0]) - 1
    r = int(data[itr][1]) - 1
    # print(grid[r],grid[l])
    print(grid[r]-grid[l])
Buggy python submission (verdict: Runtime Error):
from sys import stdin
import numpy as np
n, m = map(int, raw_input().split())
# print(n)
vals_list = np.zeros((n, 2))
# print(vals_list)
for itr in range(n):
    a, b = map(int, raw_input().split())
    vals_list[itr][0], vals_list[itr][1] = a, b
sorted_vals_list = vals_list[np.argsort(vals_list[:, 0])]
# print(sorted_vals_list)

cnt = m
total_money = 0
for itr in range(n):
    if (cnt - sorted_vals_list[itr][1]) <= 0:
        total_money += sorted_vals_list[itr][0] * cnt
        break
    else:
        cnt -= sorted_vals_list[itr][1]
        total_money += sorted_vals_list[itr][0] * sorted_vals_list[itr][1]
print(total_money)

Fixed submission:
from sys import stdin
import numpy as np
n, m = (int(i) for i in input().rstrip().split())
# print(n)
vals_list = np.zeros((n, 2))
# print(vals_list)
for itr in range(n):
    a, b = (int(i) for i in input().rstrip().split())
    vals_list[itr][0], vals_list[itr][1] = a, b
sorted_vals_list = vals_list[np.argsort(vals_list[:, 0])]
# print(sorted_vals_list)

cnt = m
total_money = 0
for itr in range(n):
    if (cnt - sorted_vals_list[itr][1]) <= 0:
        total_money += sorted_vals_list[itr][0] * cnt
        break
    else:
        cnt -= sorted_vals_list[itr][1]
        total_money += sorted_vals_list[itr][0] * sorted_vals_list[itr][1]
print(int(total_money))
Buggy python submission (verdict: Runtime Error):
N = int(input())
pay == (N%1000)
if(pay = 0):
  print(0)
else:
  print(1000 - pay)

Fixed submission:
N = int(input())
pay = (N%1000)
if(pay == 0):
  print(0)
else:
  print(1000 - pay)

Buggy python submission (verdict: Runtime Error):
N = int(input())
pay = (N%1000)
if(pay = 0):
  print(0)
else:
  print(1000 - pay)

Fixed submission:
N = int(input())
pay = (N%1000)
if(pay == 0):
  print(0)
else:
  print(1000 - pay)
Buggy python submission (verdict: Runtime Error):
n = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(n):
  s = input()
  if (s == "AC"):
    ac += 1
  elif (s == "WA"):
    wa += 1
  elif (s == "TLE"):
    tle += 1
  elif(s == "RE"):
    re += 1
    
print("AC x "+ac)
print("WA x "+wa)
print("TLE x "+tle)
print("RE x "+re)

Fixed submission:
n = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(n):
  s = input()
  if (s == "AC"):
    ac += 1
  elif (s == "WA"):
    wa += 1
  elif (s == "TLE"):
    tle += 1
  elif(s == "RE"):
    re += 1
    
print("AC x {0}".format(ac))
print("WA x {0}".format(wa))
print("TLE x {0}".format(tle))
print("RE x {0}".format(re))
Buggy python submission (verdict: Runtime Error):
n = int(input())
str = input()
char_list = list(str)
#del_num = []

count =0
ans =0

#dellist = lambda items, indexes: [item for index, item in enumerate(items) if index not in indexes]
for i in range(len(char_list)-1):
    if char_list[i] == char_list[i+1]:
        #del_num.append(i+1)
        count += 1

ans = n - count

print(ans)


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

if a-2*b>0:
    print(a-2*b)
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
n = int(input())
str = input()
char_list = list(str)
del_num = []

dellist = lambda items, indexes: [item for index, item in enumerate(items) if index not in indexes]
ans =0
for i in range(len(char_list)-1):
    if char_list[i] == char_list[i+1]:
        del_num.append(i+1)

print(len(dellist(char_list,del_num)))


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

if a-2*b>0:
    print(a-2*b)
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
str = input()
char_list = list(str)
del_num = []

dellist = lambda items, indexes: [item for index, item in enumerate(items) if index not in indexes]
ans =0
for i in range(len(char_list)-1):
    if char_list[i] == char_list[i+1]:
        del_num.append(i+1)

print(len(dellist(char_list,del_num)))


Fixed submission:
n = int(input())
str = input()
char_list = list(str)
#del_num = []

count =0
ans =0

#dellist = lambda items, indexes: [item for index, item in enumerate(items) if index not in indexes]
for i in range(len(char_list)-1):
    if char_list[i] == char_list[i+1]:
        #del_num.append(i+1)
        count += 1

ans = n - count

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import copy

n = int(input())
str = input()
char_list = list(str)
del_num = []

dellist = lambda items, indexes: [item for index, item in enumerate(items) if index not in indexes]

for i in range(len(char_list)-1):
    if char_list[i] == char_list[i+1]:
        del_num.append(i+1)

print(len(dellist(char_list,del_num)))


Fixed submission:
n = int(input())
str = input()
char_list = list(str)
#del_num = []

count =0
ans =0

#dellist = lambda items, indexes: [item for index, item in enumerate(items) if index not in indexes]
for i in range(len(char_list)-1):
    if char_list[i] == char_list[i+1]:
        #del_num.append(i+1)
        count += 1

ans = n - count

print(ans)
Buggy python submission (verdict: Runtime Error):
r,d,x0 = map(int,input().split())

xlist = []

xlist.append(r*x0-d)

for i in range(9):
    xlist.append(r*xlist[i]-d)
    map(int,xlist)
    print(xlist[i])




Fixed submission:

a,b = map(int, input().split())

if a<=5:
    ans = 0
elif 6<=a and a<=12:
    ans = b/2
else:
    ans = b

print(int(ans))

Buggy python submission (verdict: Runtime Error):
r,d,x0 = map(int,input().split())

xlist = []

xlist.append(r*x0-d)

for i in range(9):
    xlist.append(r*xlist[i]-d)
    print(int(xlist[i]))




Fixed submission:

a,b = map(int, input().split())

if a<=5:
    ans = 0
elif 6<=a and a<=12:
    ans = b/2
else:
    ans = b

print(int(ans))

Buggy python submission (verdict: Runtime Error):

a,b = map(int, input().split())

if a<=5:
    ans = 0
elif 6<=a and a<=12:
    ans = b/2
else:
    ans = b

print((int)ans)




Fixed submission:

a,b = map(int, input().split())

if a<=5:
    ans = 0
elif 6<=a and a<=12:
    ans = b/2
else:
    ans = b

print(int(ans))
Buggy python submission (verdict: Runtime Error):
n = int(input())
    if n == 1:
        print("Hello World")
    elif n == 2:
        a = int(input())
        b = int(input())
        print(a+b)

Fixed submission:
n = int(input())
if n == 1:
    print("Hello World")
elif n == 2:
    a = int(input())
    b = int(input())
    print(a + b)

Buggy python submission (verdict: Runtime Error):
N = int(input())
    if N == 1:
        print("Hello World")
    elif N == 2:
        a,b = int(input().split())
        print(a+b)

Fixed submission:
n = int(input())
if n == 1:
    print("Hello World")
elif n == 2:
    a = int(input())
    b = int(input())
    print(a + b)

Buggy python submission (verdict: Runtime Error):
N = int(input())
    if N == 1:
        print("Hello World")
    elif N == 2
        a,b = int(input().split())
        print(a+b)



Fixed submission:
n = int(input())
if n == 1:
    print("Hello World")
elif n == 2:
    a = int(input())
    b = int(input())
    print(a + b)

Buggy python submission (verdict: Runtime Error):
N = int(input())
    if N == 1:
        print("Hello World")
    elif N == 2
        a,b = int(input().split())
        print(a+b)


Fixed submission:
n = int(input())
if n == 1:
    print("Hello World")
elif n == 2:
    a = int(input())
    b = int(input())
    print(a + b)

Buggy python submission (verdict: Runtime Error):
N = int(input())
if N == 1:
    print("Hello World)
elif N == 2
    a,b = int(input().split())
    print(a+b)


Fixed submission:
n = int(input())
if n == 1:
    print("Hello World")
elif n == 2:
    a = int(input())
    b = int(input())
    print(a + b)
Buggy python submission (verdict: Runtime Error):
    a,b = [int(i) for i in input().split()]
     
    souwa = 0
    n = b - a
    for i in range(n):
        souwa += i
         
    x = souwa - b
         
    print(x)

Fixed submission:
n = int(input())
if n<1000:
    print('ABC')
else:
    print('ABD')

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

souwa = 0
n = b - a
for i in range(n):
    souwa += i
     
x = souwa - b
     
print(x)

Fixed submission:
n = int(input())
if n<1000:
    print('ABC')
else:
    print('ABD')

Buggy python submission (verdict: Runtime Error):
a, b  = [int(i) for i in input().split()]
     
souwa = 0
n = b - a
for i in range(n):
    souwa += i
     
x = souwa - b
     
print(x)

Fixed submission:
n = int(input())
if n<1000:
    print('ABC')
else:
    print('ABD')
Buggy python submission (verdict: Runtime Error):
    a,b = [int(i) for i in input().split()]
     
    souwa = 0
    n = b - a
    for i in range(n):
        souwa += i
         
    x = souwa - b
         
    print(x)

Fixed submission:
a,b = [int(i) for i in input().split()]
     
souwa = 0
n = b - a
for i in range(n+1):
    souwa += i
         
x = souwa - b
         
print(x)

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())

souwa = 0
n = b - a
for i in range(n):
    souwa += i

x = souwa - b

print(x)

Fixed submission:
a,b = [int(i) for i in input().split()]
     
souwa = 0
n = b - a
for i in range(n+1):
    souwa += i
         
x = souwa - b
         
print(x)
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
  if (a*b % 2):
    print("Even") 
  else:
    print("Odd")                                                             
 

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

Buggy python submission (verdict: Runtime Error):
 a,b = map(int,input().split())                                                  
  2     if (a*b % 2):                                                               
  3         print("Even")                                                           
  4     else:                                                                       
  5        print("Odd")                                                             
  6                                                                                        
~                                                                                          
~                                                          

Fixed submission:
a,b = map(int,input().split())
if (a*b % 2 == 0):
  print("Even") 
else:
  print("Odd")
Buggy python submission (verdict: Runtime Error):
n = int(input())

a = []
a = list(map(int, input().split()))

counter = 0
check = 0

for i in range(n):
    if a[i] % 2 = 0:
        check += 1



while check == n:
    for i in range(n):
        a[i] = a[i]/2
    for i in range(n):
        product = 1
        product *= a[i]
    counter += 1
print(counter)




Fixed submission:
s = input()
count = 0

if s[0] == '1':
  count += 1
if s[1] == '1':
  count += 1
if s[2] == '1':
  count += 1

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

a = []
a = list(map(int, input().split()))

counter = 0
check = 0

for i in range(n):
    if a[i] % 2 == 0:
        check += 1



while check == n:
    for i in range(n):
        a[i] = a[i]/2
    for i in range(n):
        product = 1
        product *= a[i]
    counter += 1
print(counter)




Fixed submission:
n = int(input())

a = []
a = list(map(int, input().split()))

counter = 0
check = 0

for i in range(n):
    if a[i] % 2 == 0:
        check += 1



while check == n:
    check = 0
    for i in range(n):
        a[i] = a[i]/2
    for i in range(n):
        if a[i] % 2 == 0:
            check += 1
    counter += 1
print(counter)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ans = 0
for i in range(1, N+1):
    a_1 = i
    n = int(N/i)
    a_n = n * i
    ans += int((1+n)*n*i/2) 
    # print((a_1+a_n)*n/2)
print(ans)

Fixed submission:
N = int(input())

ans = 0
for x in range(1, N + 1):
    n = N // x
    ans += n*x* (1+n)//2

print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
alpha = [-1]
alpha.extend([chr(ord('a') + i) for i in range(26)])
q = N
mod = N
ans = ''
while q >= 27:
    q, mod = divmod(q, 26)
    ans = alpha[mod] + ans
if mod != 0:
    ans = alpha[q] + ans
print(ans)


Fixed submission:
import re

input_str = input()
if re.match(r'[A-Z]', input_str):
    print('A')
else:
    print('a')
Buggy python submission (verdict: Runtime Error):
N = int(input())
alpha = ['z']
alpha.extend([chr(ord('a') + i) for i in range(25)])
# print(alpha)
q = N
mod = N
ans = ''
while q >= 27:
    q, mod = divmod(q, 26)
    # print(alpha[mod])
    ans = alpha[mod] + ans
if mod != 0:
    ans = alpha[q] + ans
print(ans)


Fixed submission:
# 自力では解けなかった(2020.7.6)

alpha = ['Z']
alpha.extend([chr(ord('a') + i) for i in range(26)])
N = int(input())
q = N
ans = ''
while True:
    if q <= 26:
        ans += str(alpha[q])
        break
    else:
        q, mod = divmod(q, 26)
        if mod == 0:
            q -= 1
            mod = 26
        ans += str(alpha[mod])

print(ans[::-1])

Buggy python submission (verdict: Runtime Error):
N = int(input())
alpha = [-1]
alpha.extend([chr(ord('a') + i) for i in range(26)])
q = N
mod = N
ans = ''
while q >= 27:
    q, mod = divmod(q, 26)
    ans = alpha[mod] + ans
if mod != 0:
    ans = alpha[q] + ans
print(ans)


Fixed submission:
# 自力では解けなかった(2020.7.6)

alpha = ['Z']
alpha.extend([chr(ord('a') + i) for i in range(26)])
N = int(input())
q = N
ans = ''
while True:
    if q <= 26:
        ans += str(alpha[q])
        break
    else:
        q, mod = divmod(q, 26)
        if mod == 0:
            q -= 1
            mod = 26
        ans += str(alpha[mod])

print(ans[::-1])

Buggy python submission (verdict: Runtime Error):
alpha = [-1]
alpha.extend([chr(ord('a') + i) for i in range(26)])
q = N
mod = N
ans = ''
while q >= 27:
    q, mod = divmod(q, 26)
    ans = alpha[mod] + ans
if mod != 0:
    ans = alpha[q] + ans
print(ans)


Fixed submission:
# 自力では解けなかった(2020.7.6)

alpha = ['Z']
alpha.extend([chr(ord('a') + i) for i in range(26)])
N = int(input())
q = N
ans = ''
while True:
    if q <= 26:
        ans += str(alpha[q])
        break
    else:
        q, mod = divmod(q, 26)
        if mod == 0:
            q -= 1
            mod = 26
        ans += str(alpha[mod])

print(ans[::-1])

Buggy python submission (verdict: Runtime Error):
N = int(input())
alpha = [chr(ord('a') + i) for i in range(26)]
q = N
ans = ''
while q >= 26:
    q, mod = divmod(q, 26)
    ans = alpha[mod-1] + ans
if mod != 0:
    ans = alpha[q-1] + ans
print(ans)

Fixed submission:
# 自力では解けなかった(2020.7.6)

alpha = ['Z']
alpha.extend([chr(ord('a') + i) for i in range(26)])
N = int(input())
q = N
ans = ''
while True:
    if q <= 26:
        ans += str(alpha[q])
        break
    else:
        q, mod = divmod(q, 26)
        if mod == 0:
            q -= 1
            mod = 26
        ans += str(alpha[mod])

print(ans[::-1])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split(' ')))
Q = int(input())
BC = [list(map(int, input().split(' '))) for _ in range(Q)]
temp = A
for i in range(Q):
    temp = [BC[i][1] if a == BC[i][0] else a for a in temp]
    print(sum(temp))

Fixed submission:
N = int(input())
A = list(map(int, input().split(' ')))
Q = int(input())
BC = [list(map(int, input().split(' '))) for _ in range(Q)]
cnt = [0 for _ in range(10**5+1)]
sum_a = sum(A)
# print(A)
for i in range(len(A)):
    cnt[A[i]] += 1
    # print(A[i])
    # print(cnt[A[i]])
for bc in BC:
    # print(sum_a)
    # print(cnt.count(bc[0]))
    # print((bc[1]-bc[0])*cnt.count(bc[0]))
    sum_a = sum_a + (bc[1]-bc[0])*cnt[bc[0]]
    print(sum_a)
    cnt[bc[1]] += cnt[bc[0]]
    cnt[bc[0]] = 0
Buggy python submission (verdict: Runtime Error):
N = int(input())
A_n = sorted(list(map(int, input().split(' '))))
count = 0
for i in range(len(A_n)):
    # print(list(map(lambda x: x%A_n[i], A_n)))
    if list(map(lambda x: A_n[i]%x, A_n)).count(0) == 1:
        count += 1
print(count)

Fixed submission:
X, N = map(int, input().split(' '))
if N != 0:
    P_n = list(map(int, input().split(' ')))

    for i in range(X, 150):
        if i not in set(P_n):
            min_1 = i
            break
    for i in range(X, -150, -1):
        if i not in set(P_n):
            min_2 = i
            break
    if abs(min_1-X) == abs(min_2-X):
        print(min(min_1, min_2))
    elif abs(min_1-X) < abs(min_2-X):
        print(min_1)
    else:
        print(min_2)
else:
    print(X)

Buggy python submission (verdict: Runtime Error):
X, N = map(int, input().split(' '))
if N != 0:
    P_n = list(map(int, input().split(' ')))

    for i in range(X, 101):
        if i not in set(P_n):
            min_1 = i
            break
    for i in range(X, -100, -1):
        if i not in set(P_n):
            min_2 = i
            break
    if abs(min_1-X) == abs(min_2-X):
        print(min(min_1, min_2))
    elif abs(min_1-X) < abs(min_2-X):
        print(min_1)
    else:
        print(min_2)
else:
    print(X)

Fixed submission:
X, N = map(int, input().split(' '))
if N != 0:
    P_n = list(map(int, input().split(' ')))

    for i in range(X, 150):
        if i not in set(P_n):
            min_1 = i
            break
    for i in range(X, -150, -1):
        if i not in set(P_n):
            min_2 = i
            break
    if abs(min_1-X) == abs(min_2-X):
        print(min(min_1, min_2))
    elif abs(min_1-X) < abs(min_2-X):
        print(min_1)
    else:
        print(min_2)
else:
    print(X)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = sorted(list(map(int, input().split(' '))))
A_max = A[-1]
dp = [True]*(A_max+1)
ans = 0
for i in range(N-1):
    p = A[i]
    if dp[i] == True:
        for q in range(A_max//p+1):
            dp[p*q] = False
        if A[i] != A[i+1]:
            ans += 1
if dp[-1] != True:
    ans += 1 
print(ans)

Fixed submission:
N = int(input())
A = sorted(list(map(int, input().split(' '))))
# print(A)
a_max = A[-1]
dp = [True]*(a_max+1)
ans = 0
for i in range(N-1):
    p = A[i]
    if dp[p] == True:
        # print(math.sqrt(p))
        for q in range(a_max//p+1):
            # print(p*q)
            dp[p*q] = False
        if A[i] != A[i+1]:
            ans += 1
if dp[A[-1]]:
    ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A_n = sorted(list(map(int, input().split(' '))))
count = 0
for i in range(len(A_n)):
    # print(list(map(lambda x: x%A_n[i], A_n)))
    if list(map(lambda x: A_n[i]%x, A_n)).count(0) == 1:
        count += 1
print(count)

Fixed submission:
N = int(input())
A = sorted(list(map(int, input().split(' '))))
# print(A)
a_max = A[-1]
dp = [True]*(a_max+1)
ans = 0
for i in range(N-1):
    p = A[i]
    if dp[p] == True:
        # print(math.sqrt(p))
        for q in range(a_max//p+1):
            # print(p*q)
            dp[p*q] = False
        if A[i] != A[i+1]:
            ans += 1
if dp[A[-1]]:
    ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A_n = list(map(int, input().split(' ')))
total = 1
boolean = True
for i in A_n:
    total *= i

if total <= 10 ** 18:
    print(total)
else:
    print('-1')


Fixed submission:
N = int(input())
A_n = list(map(int, input().split(' ')))
zero = 0 in A_n
if zero:
    total = 0
else:
    total = 1
    for i in A_n:
        total *= i
        if total > 10 ** 18:
            total = -1
            break
print(total)
Buggy python submission (verdict: Runtime Error):
import math

#引数nが素数かどうかを判定
def is_prime(n):
    for i in range(2, int(math.sqrt(n))+1):
        if n%i == 0:
            return False
    return True

def getPrimeExp(n):
    array = [True]*(n+1)
    result = []
    for i in range(2, n+1):
        if array[i]:
            array[i] = False
            result.append(i)
            for j in range(2, n+1):
                ij = i**j
                if ij <= n and array[ij]:
                    result.append(ij)
                    array[ij] = False
                elif ij > n:
                    break
            for j in range(i*2, n+1, i):
                array[j] = False

            # for j in range(2, n):
            #     ij = i**j
            #     if ij <= n:
            #         result.append(ij)
            #         array[ij] = False
    return sorted(result)

N = int(input())
if is_prime(N):
    print(1)
else:
    cnt = 0
    primeExp = getPrimeExp(N) 
    n = N
    # print(primeExp)
    for z in primeExp:
        if n%z == 0:
            n = int(n/z)
            cnt += 1
    print(cnt)

Fixed submission:
import math

# 素数か否かを判定する関数
def is_prime(n):
    for i in range(2, int(math.sqrt(n))+1):
        if n%i == 0:
            return False
    return True      

# nまでの素数を返す関数（エラトステネスの篩）
def getPrime(n):
    n_sqrt = int(math.sqrt(n))
    array = [True]*(n_sqrt+1)
    result = []
    for i in range(2, n_sqrt+1):
        if array[i]:
            array[i] = False
            result.append(i)
            for j in range(i*2, n_sqrt+1, i):
                array[j] = False
    return result

N = int(input())
n = N
prime = getPrime(n)
prime_exp = []
# print(prime)
for p in prime:
    cnt = 0
    while n%p == 0:
        n = int(n/p)
        # print(n)
        cnt += 1
    if cnt != 0:
        prime_exp.append([p, cnt])
if is_prime(n) and n != 1:
    prime_exp.append([n, 1])
ans = 0
for pe in prime_exp:
    ans += int((-1+math.sqrt(1+8*pe[1]))/2)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split(' '))
H = list(map(int, input().split(' ')))
paths = [list(map(int, input().split(' '))) for _ in range(M)]
good_observatory = [True]*N
for i in range(N):
    for path in paths:
        if i == (path[0]-1) and H[i] <= H[path[1]-1]:
            good_observatory[i] = False
        elif i == (path[1]-1) and H[i] <= H[path[0]-1]:
            good_observatory[i] = False

print(sum(boolean for boolean in good_observatory))

Fixed submission:
N, M = map(int, input().split(' '))
H = list(map(int, input().split(' ')))
paths = [list(map(int, input().split(' '))) for _ in range(M)]
good_observatory = [True]*N
for path in paths:
    if good_observatory[path[0]-1] and H[path[0]-1] <= H[path[1]-1]:
        good_observatory[path[0]-1] = False
    if good_observatory[path[1]-1] and H[path[1]-1] <= H[path[0]-1]:
        good_observatory[path[1]-1] = False

print(sum(boolean for boolean in good_observatory))