Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import numpy as np

n,k = map(int, input().split())

cnt = np.array(list([0]*n))

for i in range(k):
    d = int(input())
    a = np.array([list(map(int, input().split()))])
    if d != n:
        a = np.append(a,[0]*(n-d))
    cnt += a

print(np.count_nonzero(cnt==0))

Fixed submission:
import numpy as np

n,k = map(int, input().split())

cnt = np.array(list([0]*n))

for _ in range(k):
    d = int(input())
    a = np.array(list(map(int, input().split())))
    for i in a:
        cnt[i-1] += 1

print(np.count_nonzero(cnt==0))

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

n,k = map(int, input().split())

cnt = np.array(list([0]*n))

for i in range(k):
    d = int(input())
    a = np.array([list(map(int, input().split()))])
    a = np.append(a,[0]*(n-d))
    cnt += a

print(np.count_nonzero(cnt==0))

Fixed submission:
import numpy as np

n,k = map(int, input().split())

cnt = np.array(list([0]*n))

for _ in range(k):
    d = int(input())
    a = np.array(list(map(int, input().split())))
    for i in a:
        cnt[i-1] += 1

print(np.count_nonzero(cnt==0))
Buggy python submission (verdict: Runtime Error):
import numpy as np

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

sub = np.bincount(A, weights=None, minlength=N+1)

for i in range(N):
    print(sub[i+1])

Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 26 13:36:36 2020

@author: hiroki
"""

import math

a = input()
print(int(a)*2*math.pi)

Buggy python submission (verdict: Runtime Error):

import numpy as np

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

sub = np.bincount(A, weights=None, minlength=N+1)
sub1 = sub.reshape(N+1, 1)

print(sub1[1:])

Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 26 13:36:36 2020

@author: hiroki
"""

import math

a = input()
print(int(a)*2*math.pi)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

#5sub = [A.count(i) for i in range(N)]

[print(j) for j in [A.count(i+1) for i in range(N)]]

Fixed submission:
import numpy as np

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

sub = np.bincount(A, weights=None, minlength=N+1)

for i in range(N):
    print(sub[i+1])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
sub = []

for i in range(N):
    sub.append(A.count(i+1))

[print(i) for i in sub]

Fixed submission:
import numpy as np

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

sub = np.bincount(A, weights=None, minlength=N+1)

for i in range(N):
    print(sub[i+1])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
sub = []

for i in range(N):
    sub.append(A.count(i+1))

for i in range(len(sub)):
    print(sub[i])

Fixed submission:
import numpy as np

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

sub = np.bincount(A, weights=None, minlength=N+1)

for i in range(N):
    print(sub[i+1])

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 26 16:50:16 2020

@author: hiroki
"""


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

for i in range(N):
    sub.append(A.count(i+1))

for i in range(len(sub)):
    print(sub[i])



Fixed submission:
import numpy as np

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

sub = np.bincount(A, weights=None, minlength=N+1)

for i in range(N):
    print(sub[i+1])
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce

k = int(input())
ans = 0

def gcd(*numbers):
    return reduce(math.gcd, numbers)

for a in range(1,k+1):
    for b in range(1,k+1):
        for c in range(1,k+1):
            ans += gcd(a,b,c)

print(ans)

Fixed submission:
import math

k = int(input())

box = [0]*(k+1)
ans = 0

for a in range(1,k+1):
    for b in range(1,k+1):
        box[math.gcd(a,b)] += 1

for a in range(1,k+1):
    for c in range(1,k+1):
        ans += math.gcd(a,c)*box[a]

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
ans = 0
while all( a%2 == 0 for a in A ):
        a = [ i/2 for i in A ]
        ans += 1
print(ans)


Fixed submission:
import numpy as np
import sys

n = int(input())
a = np.array(list(map(int, input().split())))

cnt = 1

if np.any(a%2==1):
    print(0)
    sys.exit()

while True:
    a2 = a % 2**cnt
    if np.all(a2==0):
        cnt += 1
        continue
    else:
        print(cnt-1)
        break
Buggy python submission (verdict: Runtime Error):
import numpy as np
a,b,h,m=map(float,input().split())
pi=np.pi
h_deg=(1/6)*pi*h
m_deg=(1/30)*pi*m
deg=abs(m_deg-h_deg)
if(deg>pi):
    deg=2*pi-deg
else:
    pass
c=a**2+b**2-2*a*b*np.cos(deg)
print(c**(1/2))
print(deg/pi)

Fixed submission:
import numpy as np
a,b,h,m=map(int,input().split())
pi=np.pi
h_deg=(1/6)*pi*h+(1/360)*pi*m
m_deg=(1/30)*pi*m
deg=abs(m_deg-h_deg)
if(deg>pi):
    deg=2*pi-deg
else:
    pass
c=a**2+b**2-2*a*b*np.cos(deg)
print(c**(1/2))
Buggy python submission (verdict: Runtime Error):
s=input()
l=len(s)
n=l//2
count=0
for num in range(n):
  if(s[num]==s[l-num-]):
    pass
  else:
    count+=1
print(count)

Fixed submission:
s=input()
l=len(s)
n=l//2
count=0
for num in range(n):
  if(s[num]==s[l-num-1]):
    pass
  else:
    count+=1
print(count)
Buggy python submission (verdict: Runtime Error):
hoge = [input() for i in range(2)]
tmp = hoge[1].split()
num = int(hoge[0])

tmp = list(map(int,tmp))

flag = 1
count = 0
j = 1
for i in range(num):
    now_list = tmp[:j]
    if len(now_list) == len([None for piyo in now_list if piyo >= now_list[-1]]):
        count += 1

    j += 1

print(count)


Fixed submission:
hoge = input()
tmp = hoge.split()

if tmp[0] == tmp[1]:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
a,b = int(input().split())

count = 0

if a > b :
  count += a
  a -= 1
else:
  count += b
  b -= 1
  
if a > b :
  count += a
  a -= 1
else:
  count += b
  b -= 1
  
print(count)
  

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

count = 0

if a > b :
  count += a
  a -= 1
else:
  count += b
  b -= 1

if a > b :
  count += a
  a -= 1
else:
  count += b
  b -= 1
  
print(count)
Buggy python submission (verdict: Runtime Error):
import collections

N = int(input())
W = []
jud = 1

for _ in range(N):
    W.append(input())

c = collections.Counter(W)
ct = len(c)

for i in range(N-1):
    fst = W[i]
    fnl = W[i+1]
    if fst[-1] != fnl[1]:
        jud = 0

if ct != N:
    print("No")
elif jud == 0:
    print("No")
else: print("Yes")

Fixed submission:
N = int(input())
ketu = ""
mozi = []
frag = 0
for i in range(N):
    stri = input()
    if (ketu != "" )and(ketu != stri[0]):
        frag = 1

    ketu = stri[-1]
    mozi.append(stri)

if frag == 1:
    print("No")
    exit()

if len(mozi) != len(list(set(mozi))):
    print("No")
    exit()

print("Yes")

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

N = int(input())
W = []
jud = 1

for _ in range(N):
    W.append(input())

c = collections.Counter(W)
ct = len(c)

for i in range(N-1):
    fst = W[i]
    fnl = W[i+1]
    if fst[-1] == fnl[1]:
        jud = 0

if ct != N:
    print("No")
elif jud == 0:
    print("No")
else: print("Yes")

Fixed submission:
N = int(input())
ketu = ""
mozi = []
frag = 0
for i in range(N):
    stri = input()
    if (ketu != "" )and(ketu != stri[0]):
        frag = 1

    ketu = stri[-1]
    mozi.append(stri)

if frag == 1:
    print("No")
    exit()

if len(mozi) != len(list(set(mozi))):
    print("No")
    exit()

print("Yes")
Buggy python submission (verdict: Runtime Error):
n,m,k= input().split()

n = int(n)
m = int(m)
k = int(k)

for i in range(n+1):
  for j in range(m+1):
	if i*(m-j) + (n-i)j == k:
      print("Yes")
      exit()


print("No")
     

Fixed submission:
n,m,k= input().split()

n = int(n)
m = int(m)
k = int(k)

for i in range(n+1):
    for j in range(m+1):
        if k == (i*(m-j) + (n-i)*j) :
            print("Yes")
            exit()


print("No")
Buggy python submission (verdict: Runtime Error):
NM=list(map(int,input().split()))
person=[0 for i in range(NM[0])]
for i in range(NM[1]):
    d=input() 
    snack=list(map(int,input().split()))
    for i in snack:
        person[i-1]=1
d=0
for i in range(len(person)):
    if person[i]==0:
        d+=1
print(d)


Fixed submission:
a =input()
if a == "ABC":
  print("ARC")
elif a =="ARC":
  print("ABC")
Buggy python submission (verdict: Runtime Error):
NM=list(map(int,input().split()))
person=[0 for i in range(NM[0])]
for i in range(NM[1]):
    d=input() 
    snack=list(map(int,input().split()))
    for i in snack:
        person[i-1]=1
d=0
for i in range(len(person)):
    if person[i]==0:
        d+=1
print(d)


Fixed submission:
NM=list(map(int,input().split()))
H=list(map(int,input().split()))
A=[0 for i in range(NM[0])]
for i in range(NM[1]):
    ab=list(map(int,input().split()))
    A[ab[0]-1]=max(A[ab[0]-1],H[ab[1]-1])
    A[ab[1]-1]=max(A[ab[1]-1],H[ab[0]-1])
d=0
for i in range(NM[0]):
    if(H[i]>A[i]):
        d+=1
print(d)
Buggy python submission (verdict: Runtime Error):
#include<bits/stdc++.h>
using namespace std;

void solve(){
  int X;
  int A,B;
  cin >> X ;
  for (A=-118;A<120;A++){
    for (B=-119;B<A;B++){
      if (pow(A,5.0)-pow(B,5.0)==X){
	cout << A << B << endl;
	goto OUT;
      }
    }
  }
 OUT:;
}

int main(){
  solve();
  return 0;
}


Fixed submission:
def func(x):
    for A in range(-118,120):
        for B in range(-119,119):
            if (A**5-B**5)==x:
                return A,B

def main():
    x=int(input())
    print("%d %d" %func(x))
                

if __name__=="__main__":
    main()
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

a, v = map(int, input().split())
b, w = map(int, input().split())
T = int(input())

k = b - a
l = b*w + a*w

if (k < l):
    flag = False

if (flag):
    print('YES')
else:
    print('NO')

Fixed submission:
# -*- coding: utf-8 -*-

a, v = map(int, input().split())
b, w = map(int, input().split())
T = int(input())

k = b - a
flag = False

if k >= 0:
    l = T*v - T*w 
    if (k <= l):
        flag = True

if k < 0:
    k = a - b
    l = T*v - T*w
    if (k <= l):
        flag = True


if (flag == True):
    print('YES')
else:
    print('NO')

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

a, v = map(int, input().split())
b, w = map(int, input().split())
T = int(input()

k = b - a
l = bw + aw

if (k < l):
    flag = False

if (flag):
    print('YES')
else:
    print('NO')

Fixed submission:
# -*- coding: utf-8 -*-

a, v = map(int, input().split())
b, w = map(int, input().split())
T = int(input())

k = b - a
flag = False

if k >= 0:
    l = T*v - T*w 
    if (k <= l):
        flag = True

if k < 0:
    k = a - b
    l = T*v - T*w
    if (k <= l):
        flag = True


if (flag == True):
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

N, K = map(int, input().split())

if K == 1:
    N = 0

else:
    while abs(N-K)<N:
        N = abs(N-K)
print(N)



Fixed submission:
# -*- coding: utf-8 -*-

N, K = map(int, input().split())

if K == 1:
    N = 0

else:
    if N // K > 0:
        i = N//K
        N = N - (K * i)
    while abs(N-K)<N:
        N = abs(N-K)
print(N)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

N, K = map(int, input().split())

if K == 1:
    N = 0

else:
    while abs(N-K)<N:
        N = abs(N-K)
print(N)

Fixed submission:
# -*- coding: utf-8 -*-

N, K = map(int, input().split())

if K == 1:
    N = 0

else:
    if N // K > 0:
        i = N//K
        N = N - (K * i)
    while abs(N-K)<N:
        N = abs(N-K)
print(N)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

from decimal import *
import numpy as np


getcontext().prec = 2

L = int(input())
L = Decimal(L)

x=y=z=0
x = Decimal(x)
y = Decimal(y)
z = Decimal(z)


p = 0.01
p = Decimal(p)

for x in np.arange(p,L+1,p):
    for y in np.arange(p,L+1,p):
        z = L-(x+y)
        V = x*y*z
        
        if x*y*z < V:
            V = x*y*z


print(V)

Fixed submission:
L = int(input())

x=y=z=0

x=y=z=L/3

V = x*y*z




print(V)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

from decimal import *
import numpy as np


getcontext().prec = 2

L = int(input())
L = Decimal(L)

x=y=z=0
x = Decimal(x)
y = Decimal(y)
z = Decimal(z)


p = 0.01
p = Decimal(p)

maxV = 0

for x in np.arange(p,L+1,p):
    for y in np.arange(p,L+1,p):
        z = L-(x+y)

        V = x*y*z
    
        if maxV < V:
            maxV = V


print(maxV)

Fixed submission:
L = int(input())

x=y=z=0

x=y=z=L/3

V = x*y*z




print(V)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

from decimal import *
import numpy as np


getcontext().prec = 4

L = int(input())
L = Decimal(L)

x=y=z=0
x = Decimal(x)
y = Decimal(y)
z = Decimal(z)


p = 0.01
p = Decimal(p)

maxV = 0

for x in np.arange(p,L+1,p):
    for y in np.arange(p,L+1,p):
        z = L-(x+y)

        V = x*y*z
    
        if maxV < V:
            maxV = V


print(maxV)

Fixed submission:
L = int(input())

x=y=z=0

x=y=z=L/3

V = x*y*z




print(V)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

from decimal import *
import numpy as np


getcontext().prec = 6

L = int(input())
L = Decimal(L)

x=y=z=0
x = Decimal(x)
y = Decimal(y)
z = Decimal(z)


p = 0.01
p = Decimal(p)

maxV = 0

for x in np.arange(p,L+1,p):
    for y in np.arange(p,L+1,p):
        z = L-(x+y)

        V = x*y*z
    
        if maxV < V:
            maxV = V


print(maxV)

Fixed submission:
L = int(input())

x=y=z=0

x=y=z=L/3

V = x*y*z




print(V)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

from decimal import *
import numpy as np


getcontext().prec = 6

L = int(input())
L = Decimal(L)

x=y=z=0
x = Decimal(x)
y = Decimal(y)
z = Decimal(z)


p = 0.01
p = Decimal(p)

maxV = 0

for x in np.arange(p,L+1,p):
    for y in np.arange(p,L+1,p):
        z = L-(x+y)

        V = x*y*z
    
        if maxV < V:
            maxV = V


print(maxV)

Fixed submission:
L = int(input())

x=y=z=0

x=y=z=L/3

V = x*y*z




print(V)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

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

sum = 0

if n <= a:
    sum = n

elif n <= (a + b):
    sum = a

else:
    while n >= (a + b):
        sum += a
        n -= (a + b)

    if n <= a:
        sum += n

    elif n <= (a + b):
        sum += a

print(sum)

Fixed submission:
# -*- coding: utf-8 -*-

#入力
n, a, b = map(int, input().split())

sum = 0

if n <= a:
    sum = n

elif n <= (a + b):
    sum = a

else:
    p = n // (a + b)
    sum += a * p
    n -= p * (a + b)

    if n <= a:
        sum += n

    elif n <= (a + b):
        sum += a


#出力
print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

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

sum = 0

if n <= a:
    sum = n

elif n <= (a + b):
    sum = a

else:
    while n >= (a + b):
        sum += a
        n -= (a + b)

    if n <= a:
        sum += n

    elif n <= (a + b):
        sum += a

print(sum)


Fixed submission:
# -*- coding: utf-8 -*-

#入力
n, a, b = map(int, input().split())

sum = 0

if n <= a:
    sum = n

elif n <= (a + b):
    sum = a

else:
    p = n // (a + b)
    sum += a * p
    n -= p * (a + b)

    if n <= a:
        sum += n

    elif n <= (a + b):
        sum += a


#出力
print(sum)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

#入力
n = int(input())

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

result = 'YES'

#処理
for i in range(n):
    for j in range(n):
        if j == i:
            continue
        else:
            if A[i] == A[j]:
                result = 'NO'
                
                goto .end


label.end
#出力
print(result)

    


Fixed submission:
# -*- coding: utf-8 -*-

#入力
S, T = map(str, input().split())
A, B = map(int, input().split())
U = str(input())

#処理
if S == U:
    A -= 1
else:
    B -= 1

#出力
print('{} {}'.format(A, B))
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

from collections import defaultdict

#入力   
n = int(input())
v = list(int, input().split())

def f(v):
    d = defaultdict(int)
    d[0] = 0

    for i in v:
        d[i] += 1
    return sorted(d.items(), key=lambda x: x[1], reverse=True)

t1 = f(v[::2])
t2 = f(v[1::2])

if t1[0][0] == t2[0][0]:
    if t1[0][1] + t2[1][1] > t1[1][1] + t2[0][1]:
        print(n - t1[0][1] - t2[1][1])
    else:
        print(n - t1[1][1] - t2[0][1])
else:
    print(n - t1[0][1] - t2[0][1])

Fixed submission:
# -*- coding: utf-8 -*-

from collections import defaultdict

#入力   
n = int(input())
v = tuple(int(i) for i in input().split())

def f(v):
    d = defaultdict(int)
    d[0] = 0

    for i in v:
        d[i] += 1
    return sorted(d.items(), key=lambda x: x[1], reverse=True)

t1 = f(v[::2])
t2 = f(v[1::2])

if t1[0][0] == t2[0][0]:
    if t1[0][1] + t2[1][1] > t1[1][1] + t2[0][1]:
        print(n - t1[0][1] - t2[1][1])
    else:
        print(n - t1[1][1] - t2[0][1])
else:
    print(n - t1[0][1] - t2[0][1])
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

A, B, C, K = map(int, input().split())

for i in range(K):
    a = A
    b = B
    c = C

    A = b + c
    B = a + c
    C = a + b

ans = A - B

if ans >= 10**18 or (-1)*ans >= 10**18:
    ans = 'Unfair'


print(ans)


Fixed submission:
# -*- coding: utf-8 -*-

'''
A, B, C, K = map(int, input().split()) 

for i in range(K):
    a = A
    b = B
    c = C

    A = b + c
    B = a + c
    C = a + b

ans = A - B

if ans >= 10**8:
    ans = 'Unfair'
elif ans >*10**8:
    ans = 'Unfair'

print(ans)
'''



A, B, C, K= map(int, input().split())

if K%2==1: 
    ans = B - A
else:
    ans = A - B

if ans >= 10**18 or (-1)*ans >= 10**18:
    ans = 'Unfair'

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
A, B, C, K = map(int, input().split()) 

for i in range(K):
    a = A
    b = B
    c = C

    A = b + c
    B = a + c
    C = a + b

ans = A - B

if ans >= 10**8:
    ans = 'Unfair'
elif ans <= -1*10**8:
    ans = 'Unfair'

print(ans)

Fixed submission:
# -*- coding: utf-8 -*-

'''
A, B, C, K = map(int, input().split()) 

for i in range(K):
    a = A
    b = B
    c = C

    A = b + c
    B = a + c
    C = a + b

ans = A - B

if ans >= 10**8:
    ans = 'Unfair'
elif ans >*10**8:
    ans = 'Unfair'

print(ans)
'''



A, B, C, K= map(int, input().split())

if K%2==1: 
    ans = B - A
else:
    ans = A - B

if ans >= 10**18 or (-1)*ans >= 10**18:
    ans = 'Unfair'

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, M, K = map(int, input().split())
A = tuple(map(int, input().split()))
B = tuple(map(int, input().split()))


def cumsum(l):
    s = 0
    for v in l:
        s += v
        yield s


a = (0,) + tuple(cumsum(A))
b = (0,) + tuple(cumsum(B))
ans = 0
m = M
for i in range(N + 1):
    if a[i] > K:
        continue
    for j in range(m, -1, -1):
        if a[i] + b[j] <= K:
            k = j
            break
        else:
            continue
    ans = max(ans, i + j)
print(ans)

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


def cumsum(l):
    s = 0
    for v in l:
        s += v
        yield s


a = [0] + list(cumsum(A))
b = [0] + list(cumsum(B))
ans = 0
n = N + 1
m = M
for i in range(n):
    if a[i] > K:
        continue
    for j in range(m, -1, -1):
        if a[i] + b[j] <= K:
            m = j
            break
        else:
            continue
    ans = max(ans, i + j)
print(ans)
Buggy python submission (verdict: Runtime Error):
def main():
    _ = int(input())
    a = tuple(map(int, input().split()))

    res = 0
    for i in a:
        res ^= i
    ans = [res ^ j for j in a]
    for k in ans:
        print(ans)


if __name__ == "__main__":
    main()

Fixed submission:
from functools import reduce

n = int(input())
a = tuple(map(int, input().split()))

res = reduce(lambda x, y: x ^ y, a)
ans = [res ^ i for i in a]
print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

ans = 1
for i in map(int, input().split()):
    ans = ans * i

if ans > 10 ** 18:
    print(-1)
else:
    print(ans)

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

ans = 1
if 0 in a:
    print(0)
else:
    for i in a:
        ans = ans * i
        if ans > 10 ** 18:
            print(-1)
            break
    else:
        print(ans)
Buggy python submission (verdict: Runtime Error):
import sympy

n = int(input())

ans = 0
if n > 1:
    tmp = sympy.factorint(n)
    for v in tmp.values():
        i = 1
        while v > 0:
            if v - i >= 0:
                v -= i
                ans += 1
                i += 1
            else:
                break
print(ans)

Fixed submission:
import collections

n = int(input())


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


ans = 0
if n > 1:
    tmp = collections.Counter(prime_factorize(n))
    for v in tmp.values():
        i = 1
        while v > 0:
            if v - i >= 0:
                v -= i
                ans += 1
                i += 1
            else:
                break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from functools import lru_cache

T = int(input())

for t in range(T):
    N, A, B, C, D = map(int, input().split())

    def dist(n):
        if n == 0:
            return 0
        if n == 1:
            return D

        ret = min(
            D * n,
            D * abs(n - n // 5 * 5) + C + dist(n // 5),
            D * abs(n - (n + 4) // 5 * 5) + C + dist((n + 4) // 5),
            D * abs(n - n // 3 * 3) + B + dist(n // 3),
            D * abs(n - (n + 2) // 3 * 3) + B + dist((n + 2) // 3),
            D * abs(n - n // 2 * 2) + A + dist(n // 2),
            D * abs(n - (n + 1) // 2 * 2) + A + dist((n + 1) // 2),
        )

        return ret

    print(dist(N))

Fixed submission:
from functools import lru_cache

T = int(input())

for t in range(T):
    N, A, B, C, D = map(int, input().split())

    @lru_cache(maxsize=None)
    def dist(n):
        if n == 0:
            return 0
        if n == 1:
            return D

        ret = min(
            D * n,
            D * abs(n - n // 5 * 5) + C + dist(n // 5),
            D * abs(n - (n + 4) // 5 * 5) + C + dist((n + 4) // 5),
            D * abs(n - n // 3 * 3) + B + dist(n // 3),
            D * abs(n - (n + 2) // 3 * 3) + B + dist((n + 2) // 3),
            D * abs(n - n // 2 * 2) + A + dist(n // 2),
            D * abs(n - (n + 1) // 2 * 2) + A + dist((n + 1) // 2),
        )

        return ret

    print(dist(N))
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())

tmp = [n]

while True:
    m = abs(n - k)
    if m in tmp:
        ans = min(tmp)
        break
    else:
        tmp.append(m)
        n = m

print(ans)

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

tmp = n % k
if n >= k:
    ans = min(tmp, k - tmp)
else:
    ans = min(n, k - n)

print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
x = [int(x) for x in input().split()]

ans = []

for i in range(x[0], x[-1] + 1):
    tmp = 0
    for j in x:
        tmp += (j - i) ** 2
    ans.append(tmp)

print(min(ans))

Fixed submission:
n = int(input())
x = [int(x) for x in input().split()]

ans = []

for i in range(1, 101):
    tmp = 0
    for j in x:
        tmp += (j - i) ** 2
    ans.append(tmp)

print(min(ans))