Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
from math import gcd
from functools import reduce
from collections import Counter
from itertools import chain


# 素因数分解
def prime_factors(n):
    i = 2
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            yield i
    if n > 1:
        yield n


def solve(A):
    d = reduce(gcd, A)
    if d != 1:
        return 'not coprime'

    A = [a for a in A if a != 1]

    if len(set(A)) < len(A):
        return 'setwise coprime'

    c = Counter(chain.from_iterable(set(prime_factors(a)) for a in A))
    if c and max(c.values()) > 1:
        return 'setwise coprime'
    else:
        return 'pairwise coprime'


if __name__ == '__main__':
    N = int(input())
    A = list(map(int,input().split()))

    print(solve(A))


Fixed submission:
from math import gcd
from functools import reduce
from collections import Counter
from itertools import chain


# 素因数分解
def prime_factors(n):
    i = 2
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            while n % i == 0:
                n //= i
            yield i
    if n > 1:
        yield n


def solve(A):
    d = reduce(gcd, A)
    if d != 1:
        return 'not coprime'

    A.sort()

    s = set()
    for a in A:
        for p in prime_factors(a):
            if p in s:
                return 'setwise coprime'
            else:
                s.add(p)

    return 'pairwise coprime'


if __name__ == '__main__':
    N = int(input())
    A = list(map(int,input().split()))

    print(solve(A))

Buggy python submission (verdict: Runtime Error):
from math import gcd
from functools import reduce
from collections import Counter
from itertools import chain


# 素因数分解
def prime_factors(n):
    i = 2
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            yield i
    if n > 1:
        yield n


def solve(A):
    d = reduce(gcd, A)
    if d != 1:
        return 'not coprime'

    c = Counter(chain.from_iterable(set(prime_factors(a)) for a in A))
    if max(c.values()) > 1:
        return 'setwise prime'
    else:
        return 'pairwise prime'


if __name__ == '__main__':
    N = int(input())
    A = list(map(int,input().split()))

    print(solve(A))


Fixed submission:
from math import gcd
from functools import reduce
from collections import Counter
from itertools import chain


# 素因数分解
def prime_factors(n):
    i = 2
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            while n % i == 0:
                n //= i
            yield i
    if n > 1:
        yield n


def solve(A):
    d = reduce(gcd, A)
    if d != 1:
        return 'not coprime'

    A.sort()

    s = set()
    for a in A:
        for p in prime_factors(a):
            if p in s:
                return 'setwise coprime'
            else:
                s.add(p)

    return 'pairwise coprime'


if __name__ == '__main__':
    N = int(input())
    A = list(map(int,input().split()))

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

A = [A[0]] + [b for a,b in zip(A,A[1:]) if a != b]

diff = [a-b for a,b in zip(A[1:],A)]
B = [A[0]] if diff[0] > 0 else []

for i,(d1,d2) in enumerate(zip(diff, diff[1:]),start=1):
    if d1*d2 < 0:
        B.append(A[i])
B.append(A[-1])
t = iter(B)
c = 1000
for a,b in zip(t,t):
    c = c//a*b + c%a

print(c)


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

A = [A[0]] + [b for a,b in zip(A,A[1:]) if a != b]

if len(A) < 2:
    print(1000)
    exit()

diff = [a-b for a,b in zip(A[1:],A)]
B = [A[0]] if diff[0] > 0 else []

for i,(d1,d2) in enumerate(zip(diff, diff[1:]),start=1):
    if d1*d2 < 0:
        B.append(A[i])
B.append(A[-1])
t = iter(B)
c = 1000
for a,b in zip(t,t):
    c = c//a*b + c%a

print(c)

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

A = [A[0]] + [b for a,b in zip(A,A[1:]) if a != b]

diff = [a-b for a,b in zip(A[1:],A)]
B = [A[0]] if diff[0] > 0 else []

for i,(d1,d2) in enumerate(zip(diff, diff[1:]),start=1):
    if d1*d2 < 0:
        B.append(A[i])
B.append(A[-1])
t = iter(B)
c = 1000
for a,b in zip(t,t):
    c = c//a*b + c%a

print(c)


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

A = [A[0]] + [b for a,b in zip(A,A[1:]) if a != b]

if len(A) < 2:
    print(1000)
    exit()

diff = [a-b for a,b in zip(A[1:],A)]
B = [A[0]] if diff[0] > 0 else []

for i,(d1,d2) in enumerate(zip(diff, diff[1:]),start=1):
    if d1*d2 < 0:
        B.append(A[i])
B.append(A[-1])
t = iter(B)
c = 1000
for a,b in zip(t,t):
    c = c//a*b + c%a

print(c)
Buggy python submission (verdict: Runtime Error):
from functools import reduce
import operator
MOD = 10**9+7
product = lambda it: reduce(lambda x,y: (x*y)%MOD,it,1)

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

from fractions import Fraction

def solve():
    if N == K:
        return product(A)

    if all(v < 0 for v in A):
        A.sort()
        return product(A[-K:])

    A.sort(key=lambda x: abs(x))

    if A[-K] == 0:
        return 0

    parity = sum(v < 0 for v in A[-K:])%2
    if parity == 0:
        return product(A[-K:])

    fp = N-K
    while fp < N and A[fp] < 0:
        fp += 1

    fn = N-K
    while fn < N and A[fn] > 0:
        fn += 1


    lp = N-K-1
    while lp >= 0 and A[lp] < 0:
        lp -= 1

    ln = N-K-1
    while ln >= 0 and A[ln] > 0:
        ln -= 1

    if fp < N and ln >= 0:
        r1 = Fraction(-A[ln],A[fp])
    else:
        r1 = 0
    if fn < N and lp >= 0:
        r2 = Fraction(-A[lp],A[fn])
    else:
        r2 = 0
    if r1 > r2:
        return (product(A[-K:])*A[ln]*pow(A[fp],-1,MOD))%MOD
    else:
        return (product(A[-K:])*A[lp]*pow(A[fn],-1,MOD))%MOD

print(solve())

Fixed submission:
from functools import reduce
import operator
MOD = 10**9+7
mprod = lambda it: reduce(lambda x,y: (x*y)%MOD,it,1)
nprod = lambda it: reduce(lambda x,y: (x*y),it,1)


from fractions import Fraction

def solve(A,K):
    N = len(A)
    if N == K:
        return mprod(A)

    if all(v <= 0 for v in A) and K%2 == 1:
        A.sort()
        return mprod(A[-K:])

    A.sort(key=lambda x: abs(x))

    if A[-K] == 0:
        return 0

    parity = sum(v < 0 for v in A[-K:])%2
    if parity == 0:
        return mprod(A[-K:])

    rp = N-K
    while rp < N and A[rp] < 0:
        rp += 1

    rn = N-K
    while rn < N and A[rn] > 0:
        rn += 1


    lp = N-K-1
    while lp >= 0 and A[lp] < 0:
        lp -= 1

    ln = N-K-1
    while ln >= 0 and A[ln] > 0:
        ln -= 1

    if rp < N and ln >= 0:
        r1 = Fraction(-A[ln],A[rp])
    else:
        r1 = 0
    if rn < N and lp >= 0:
        r2 = Fraction(-A[lp],A[rn])
    else:
        r2 = 0
    if r1 > r2:
        return (mprod(A[-K:])*A[ln]*pow(A[rp],-1,MOD))%MOD
    else:
        return (mprod(A[-K:])*A[lp]*pow(A[rn],-1,MOD))%MOD

from itertools import combinations
def naive(A,K):
    return max(nprod(p) for p in combinations(A,K))%MOD


if __name__ == '__main__':
    N,K = map(int,input().split())
    A = list(map(int,input().split()))
    
    print(solve(A,K)%MOD)

    # from random import randrange

    # N = 9
    # K = 8
    # for _ in range(100000):
    #     A = [randrange(-8,8) for _ in range(N)]
    #     if solve(A.copy(),K) != naive(A.copy(), K):
    #         print(A, solve(A.copy(),K),naive(A.copy(), K) )
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
memo = [0]*(N+1)
for x in range(1,N+1):
    for y in range(x,N+1,x):
        memo[y] += 1
print(sum(c*m for c,m in enumerate(memo)))

Fixed submission:
N = int(input())

memo = list(range(N+1))

temp = [0]*(N+1)
temp[0] = 1
temp[1] = 1

for x,c in enumerate(memo):
    if temp[x] == 0:
        for y in range(x,N+1,x):
            memo[y] *= temp[y]+1
            temp[y] = 1
        k = 2
        while x**k <= N:
            for y in range(x**k,N+1,x**k):
                temp[y] += 1
            k += 1
    memo[x] *= temp[x]+1

print(sum(memo)-1)
Buggy python submission (verdict: Runtime Error):

def factorials_with_inv(k,mod):
    """
    0! ... k! とそれらのmod逆元を求めて返す
    """
    fac = [1]*(k+1)
    inv = [1]*(k+1)
    t = 1
    for i in range(1,k+1):
        t *= i
        t %= mod
        fac[i] = t

    t = pow(t,-1,mod)
    for i in reversed(range(1,k+1)):
        inv[i] = t
        t *= i
        t %= mod

    return fac, inv

MOD = 10**9+7

def solve(N,M):
    fac,inv = factorials_with_inv(max(N,M), MOD)

    # (M-k)!/(k!(N-k)!) * N!M!/((M-N)!^2)

    res = 0
    sign = True
    for k in range(N+1):
        t = fac[M-k]*inv[k]*inv[N-k]
        if sign:
            res += t
        else:
            res -= t
        res %= MOD
        sign = not sign

    res *= fac[N]*fac[M]*inv[M-N]**2
    res %= MOD
    return res

from itertools import permutations

def naive(N,M):
    res = 0
    for A in permutations(range(M),N):
        for B in permutations(range(M),N):
            res += all(a != b for a,b in zip(A,B))
    return res%MOD

if __name__ == '__main__':
    N,M = map(int,input().split())

    # print(naive(N,M))
    print(solve(N,M))

Fixed submission:

def factorials_with_inv(k,mod):
    """
    0! ... k! とそれらのmod逆元を求めて返す
    """
    fac = [1]*(k+1)
    inv = [1]*(k+1)
    t = 1
    for i in range(1,k+1):
        t *= i
        t %= mod
        fac[i] = t

    t = pow(t,-1,mod)
    for i in reversed(range(1,k+1)):
        inv[i] = t
        t *= i
        t %= mod

    return fac, inv

MOD = 10**9+7

def solve(N,M):
    fac,inv = factorials_with_inv(max(N,M), MOD)

    # (M-k)!/(k!(N-k)!) * N!M!/((M-N)!^2)

    res = 0
    sign = True
    for k in range(N+1):
        t = fac[M-k]*inv[k]*inv[N-k]
        if sign:
            res += t
        else:
            res -= t
        res %= MOD
        sign = not sign

    res *= fac[N]*fac[M]*inv[M-N]**2
    res %= MOD
    return res

from itertools import permutations

def naive(N,M):
    res = 0
    for A in permutations(range(M),N):
        for B in permutations(range(M),N):
            res += all(a != b for a,b in zip(A,B))
    return res%MOD

if __name__ == '__main__':
    N,M = map(int,input().split())

    # print(naive(N,M))
    print(solve(N,M))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict

MOD = 998244353
N,S = map(int,input().split())
A = map(int,input().split())

dp = defaultdict(int)
dp[(0,0)] = 1
for a in A:
    for (size,total),cnt in tuple(dp.items()):
        if total+a <= S:
            dp[(size+1,total+a)] += cnt
            dp[(size+1,total+a)] %= MOD

res = 0
c = 1
for size in reversed(range(1,N+1)):
    res += c*dp[(size,S)]
    res %= MOD
    c *= 2
    c %= MOD
print(res)

Fixed submission:
from collections import defaultdict

MOD = 998244353
N,S = map(int,input().split())
A = map(int,input().split())

dp = [0]*(S+1)
dp[0] = 1
for a in A:
    ndp = [0]*(S+1)
    for total,cnt in enumerate(dp):
        ndp[total] += (dp[total]*2)%MOD
        if total+a <= S:
            ndp[total+a] += dp[total]
            ndp[total+a] %= MOD
    dp = ndp

print(dp[-1]%MOD)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict

MOD = 998244353
N,S = map(int,input().split())
A = map(int,input().split())

dp = defaultdict(int)
dp[(0,0)] = 1
for a in A:
    for (size,total),cnt in tuple(dp.items()):
        if total+a <= S:
            dp[(size+1,total+a)] += cnt
            dp[(size+1,total+a)] %= MOD

res = 0
c = 1
for size in reversed(range(1,N+1)):
    res += c*dp[(size,S)]
    res %= MOD
    c *= 2
    c %= MOD
print(res)

Fixed submission:
from collections import defaultdict

MOD = 998244353
N,S = map(int,input().split())
A = map(int,input().split())

dp = [0]*(S+1)
dp[0] = 1
for a in A:
    ndp = [0]*(S+1)
    for total,cnt in enumerate(dp):
        ndp[total] += (dp[total]*2)%MOD
        if total+a <= S:
            ndp[total+a] += dp[total]
            ndp[total+a] %= MOD
    dp = ndp

print(dp[-1]%MOD)
Buggy python submission (verdict: Runtime Error):
from bisect import bisect


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


res = [None]*N
dp = [float('inf') for _ in range(N)]

def rec(v, ml):
    """
    dp[l]: min tail value of increasing subsequence of length l+1
    """
    a = A[v]
    i = bisect(dp, a)
    ml += int(ml == i)
    res[v] = ml

    orig = dp[i]
    dp[i] = a
    for u in adj[v]:
        if res[u] is None:
            rec(u, ml)
    dp[i] = orig

rec(0, 0)

print(*res, sep='\n')


Fixed submission:
from bisect import bisect
from sys import setrecursionlimit

setrecursionlimit(10000000)

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


res = [None]*N
dp = [float('inf') for _ in range(N)]

def rec(v, ml):
    """
    dp[l]: min tail value of increasing subsequence of length l+1
    """
    a = A[v]
    i = bisect(dp, a-1)
    ml += int(ml == i)
    res[v] = ml

    orig = dp[i]
    dp[i] = a
    for u in adj[v]:
        if res[u] is None:
            rec(u, ml)
    dp[i] = orig

rec(0, 0)

print(*res, sep='\n')
Buggy python submission (verdict: Time Limit Exceeded):
S = input()

cnt = 0
for i in range(len(S)):
    for j in range(i+1,len(S)+1):
        if int(S[i:j])%2019 == 0:
            cnt += 1

print(cnt)

Fixed submission:
from itertools import accumulate,chain
from collections import Counter

MOD = 2019

S = input()

memo = [None]*len(S)
x = 1
for i,c in enumerate(reversed(S)):
    memo[i] = x*int(c)%MOD
    x = (10*x)%MOD

acc = tuple(chain((0,), accumulate(memo, lambda x,y: (x+y)%MOD)))

print(sum(c*(c-1)//2 for c in Counter(acc).values()))
Buggy python submission (verdict: Runtime Error):
from collections import Counter

N = int(input())
C = tuple(map(lambda x: int(x)-1,input().split()))

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


parent = [None]*N
parent[0] = -1

stack = [0]
order = []
while stack:
    p = stack.pop()
    order.append(p)
    for c in adj[p]:
        if parent[c] is None:
            parent[c] = p
            stack.append(c)

dp = [Counter() for _ in range(N)] # color-wise counter
subtreesize = [0]*N
cnt = [N*(N+1)//2]*N

for c in reversed(order):
    p = parent[c]
    if p >= 0:
        dp[c][C[c]] = subtreesize[c]+1
        x = subtreesize[c]-dp[c][C[p]]+1
        cnt[C[p]] -= x*(x+1)//2
        subtreesize[p] += subtreesize[c]+1

        a,b = dp[p],dp[c]
        if len(a) > len(b):
            a += b
            dp[p] = a
        else:
            b += a
            dp[p] = b
        dp[c] = None

dp[0][C[0]] = subtreesize[0]+1
for c in range(N):
    x = subtreesize[0]-dp[0][c]+1
    cnt[c] -= x*(x+1)//2

print(*cnt, sep='\n')


Fixed submission:
import math
R = int(input())

print(R*2*math.pi)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

def binary_search_int(ok, ng, solve):
    """
    :param ok: solve(x) = True を必ず満たす点
    :param ng: solve(x) = False を必ず満たす点
    """
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if solve(mid):
            ok = mid
        else:
            ng = mid
    return ok, ng

##############################################################

def solve(x):
    """ ある点 x を境にして True と False が二分されるような関数"""
    return N - K*x >= 0

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

a, b = binary_search_int(0, 10**18, solve)
print(min(abs(N-a*K), abs(N-b*K)))


Fixed submission:
K = int(input())

N = [0]

for _ in range(K):
    i = 0
    while i < len(N) and N[i] == 9:
        i += 1
    while i+1 < len(N) and N[i] == N[i+1]+1:
        i += 1
    if i == len(N):
        N = [0]*len(N) + [1]
    else:
        N[i] += 1
        i -= 1
        while i >= 0:
            N[i] = max(N[i+1]-1,0)
            i -= 1

print(*reversed(N),sep='')
Buggy python submission (verdict: Runtime Error):
# 拡張ユークリッド互除法
# ax + by = gcd(a,b)の最小整数解を返す
def egcd(a, b):
    if a == 0:
        return (b, 0, 1)
    else:
        g, y, x = egcd(b % a, a)
        return (g, x - (b // a) * y, y)


# mを法とするaの乗法的逆元
def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m

def lcm(num1, num2): 
    if(num1>num2): 
        num = num1 
        den = num2 
    else: 
        num = num2 
        den = num1 
    rem = num % den 
    while(rem != 0): 
        num = den 
        den = rem 
        rem = num % den 
    gcd = den 
    lcm = int(int(num1 * num2)/int(gcd)) 
    return lcm 


MOD = 10**9+7

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

s = sum(modinv(a,MOD) for a in A)%MOD


m = A[0]
for a in A:
    m = lcm(m,a)

s *= m
print(s%MOD)


Fixed submission:
from collections import Counter, defaultdict
# 拡張ユークリッド互除法
# ax + by = gcd(a,b)の最小整数解を返す
def egcd(a, b):
    if a == 0:
        return (b, 0, 1)
    else:
        g, y, x = egcd(b % a, a)
        return (g, x - (b // a) * y, y)


# mを法とするaの乗法的逆元
def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m


# 素因数分解
def prime_factors(n):
    i = 2
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            yield i
    if n > 1:
        yield n

# mを法とするときのa^n
def modpow(a,n,m):
    res = 1
    t = a
    while n:
        if n%2:
            res = (res*t)%m
        t = (t*t)%m
        n //= 2
    return res

def lcm_mod(nums, mod):
    p = defaultdict(int)
    for n in nums:
        c = Counter(prime_factors(n))
        for v,cnt in c.items():
            p[v] = max(p[v],cnt)

    res = 1
    for v,cnt in p.items():
        res *= modpow(v,cnt,mod)
        res %= mod
    return res


MOD = 10**9+7

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

s = sum(modinv(a,MOD) for a in A)%MOD

s *= lcm_mod(A, MOD)
print(s%MOD)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
 
x4 = [ 1,0,-1,0 ]
y4 = [ 0,1,0,-1 ] 
max_int = 2**63-1
 
 
h,w = map(int, input().split(' '))
S = []
for i in range(h):
    S.append(input())

grid = [[False]*(w+2) for _ in range(h+2)]
for i in range(h):
    for j in range(w):
        grid[i+1][j+1] = S[i][j] == '.'

ans = 0
 
for i in range(1,h+1):
    for j in range(1,w+1):
        if not grid[i][j]:
            continue
 
        visited = [[False for o in range(w+2)] for l in range(h+2)]
        q = deque()
        d = [[max_int for o in range(w+2)] for l in range(h+2)]
 
        visited[i][j] = True
        q.append((i,j))
        d[i][j] = 0
 
        while q:
            cy, cx = q.popleft()
            visited[cy][cx] = True
            for dy,dx in zip(y4,x4):
                ny = cy + dy
                nx = cx + dx
                if grid[ny][nx] and not visited[ny][nx]:
                    q.append((ny, nx))
                    d[ny][nx] = min(d[ny][nx], d[cy][cx] + 1)
                    ans = max(d[ny][nx], ans)
 
print(ans)

Fixed submission:
from itertools import count, combinations, product

H,W = map(int,input().split())

grid = [[False]*(W+2) for _ in range(H+2)]

for i in range(1,H+1):
    S = input()
    for j,v in zip(range(1,W+1),S):
        grid[i][j] = v == '.'

visited = [[0 if v else float('inf') for v in row] for row in grid]
cnt = 1
def dist(p1,p2):
    global cnt
    q = [p1]
    visited[p1[0]][p1[1]] = cnt 
    for d in count():
        if not q:
            break
        nq = []
        for x,y in q:
            if (x,y) == p2:
                cnt += 1
                return d
            else:
                for dx,dy in ((1,0),(-1,0),(0,1),(0,-1)):
                    if visited[x+dx][y+dy] < cnt:
                        visited[x+dx][y+dy] = cnt
                        nq.append((x+dx,y+dy))
        q = nq
    cnt += 1
    return float('inf')

emp = [(i,j) for i,j in product(range(H+2),range(W+2)) if grid[i][j]]

print(max(dist(*p) for p in combinations(emp,2)))
Buggy python submission (verdict: Runtime Error):
import numpy as np
from math import sqrt
from itertools import combinations

N = int(input())

P = [np.array(list(map(int,input().split())), dtype=np.int64) for _ in range(N)]

d2 = lambda v: v.dot(v)

def radius(A,B,C):
    a = d2(B-C)
    b = d2(C-A)
    c = d2(A-B)

    r = float('inf')
    if c > d2(A+B - 2*C):
        r = min(r, c)

    if a > d2(B+C - 2*A):
        r = min(r, a)

    if b > d2(C+A - 2*B):
        r = min(r, b)

    if r != float('inf'):
        return sqrt(float(r))/2

    U = a*(b+c-a)*A + b*(c+a-b)*B + c*(a+b-c)*C
    v = a*(b+c-a) + b*(c+a-b) + c*(a+b-c)
    return sqrt(float(d2(U-v*A)))/v

if N == 2:
    print(sqrt(float(d2(P[0]-P[1])))/2)
else:
    print(max(radius(a,b,c) for a,b,c in combinations(P,3)))


Fixed submission:
import numpy as np
from itertools import combinations

N = int(input())

P = [np.array(list(map(int,input().split())), dtype=float) for _ in range(N)]

d2 = lambda v: np.sum(np.square(v))

def radius(A,B,C):
    a = d2(B-C)
    b = d2(C-A)
    c = d2(A-B)

    r = float('inf')
    if c > d2(A+B - 2*C):
        r = min(r, c)

    if a > d2(B+C - 2*A):
        r = min(r, a)

    if b > d2(C+A - 2*B):
        r = min(r, b)

    if r != float('inf'):
        return np.sqrt(r)/2

    U = a*(b+c-a)*A + b*(c+a-b)*B + c*(a+b-c)*C
    v = a*(b+c-a) + b*(c+a-b) + c*(a+b-c)
    U /= v
    r = np.linalg.norm(U-A)
    return r

if N == 2:
    print(np.linalg.norm(P[0]-P[1])/2)
else:
    print(max(radius(a,b,c) for a,b,c in combinations(P,3)))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
from itertools import combinations

N = int(input())

P = [np.array(list(map(int,input().split())), dtype=float) for _ in range(N)]

d2 = lambda v: np.sum(np.square(v))

def radius(A,B,C):
    a = d2(B-C)
    b = d2(C-A)
    c = d2(A-B)

    r = float('inf')
    if c > 4*d2((A+B)/2 - C):
        r = min(r, c)

    if a > 4*d2((B+C)/2 - A):
        r = min(r, a)

    if b > 4*d2((C+A)/2 - B):
        r = min(r, b)

    if r != float('inf'):
        return np.sqrt(r)/2

    U = a*(b+c-a)*A + b*(c+a-b)*B + c*(a+b-c)*C
    v = a*(b+c-a) + b*(c+a-b) + c*(a+b-c)
    U /= v
    r = np.linalg.norm(U-A)
    return r

if N == 2:
    print(np.linalg.norm(P[0]-P[1])/2)
else:
    print(max(radius(a,b,c) for a,b,c in combinations(P,3)))


Fixed submission:
import numpy as np
from itertools import combinations

N = int(input())

P = [np.array(list(map(int,input().split())), dtype=float) for _ in range(N)]

d2 = lambda v: np.sum(np.square(v))

def radius(A,B,C):
    a = d2(B-C)
    b = d2(C-A)
    c = d2(A-B)

    r = float('inf')
    if c > d2(A+B - 2*C):
        r = min(r, c)

    if a > d2(B+C - 2*A):
        r = min(r, a)

    if b > d2(C+A - 2*B):
        r = min(r, b)

    if r != float('inf'):
        return np.sqrt(r)/2

    U = a*(b+c-a)*A + b*(c+a-b)*B + c*(a+b-c)*C
    v = a*(b+c-a) + b*(c+a-b) + c*(a+b-c)
    U /= v
    r = np.linalg.norm(U-A)
    return r

if N == 2:
    print(np.linalg.norm(P[0]-P[1])/2)
else:
    print(max(radius(a,b,c) for a,b,c in combinations(P,3)))