Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math

def solve(a: list):
    length = len(a)
    if length <= 3:
        return min((p1[0]-p2[0])**2+(p1[1]-p2[1])**2 for p1, p2 in zip(a, a[1:]))

    med = length//2
    x_l, x_r = a[:med], a[med:]
    delta = min(solve(x_l), solve(x_r))
    median_x = a[med][0]
    m_a = []
        
    for p in x_l[::-1]:
        if p[0] < median_x-delta:
            break
        m_a.append(p)
    m_a.reverse()
    for p in x_r:
        if p[0] > median_x+delta:
            break
        m_a.append(p)

    for i, (x1, y1) in enumerate(m_a):
        to_y = y1 + delta
        for j, (x2, y2) in enumerate(m_a[i+1:]):
            if y2 > to_y:
                break
            delta = min(delta, (x1-x2)**2+(y1-y2)**2)

    return delta

if __name__ == "__main__":
    N = int(input())
    m = 1000000
    a = sorted([tuple(map(lambda s: int(float(s)*m), l.split())) for l in sys.stdin.readlines()])
    print("{:.10f}".format(math.sqrt(solve(a)/(m**2))))


Fixed submission:
import sys
from operator import itemgetter
from itertools import combinations, takewhile
from math import sqrt

def solve(a: list, sorted_axis: int = -1):
    length = len(a)
    if length <= 3:
        return sqrt(min((x1-x2)**2+(y1-y2)**2 for (x1, y1), (x2, y2) in combinations(a, 2)))

    x_set_len = len(set(x for x, _ in a))
    axis1 = 0 if x_set_len > length/2 else 1

    if sorted_axis != axis1:
        a.sort(key=itemgetter(axis1))

    mid_index = length//2
    left, right = a[:mid_index], a[mid_index:]
    delta = min(solve(left, axis1), solve(right, axis1))

    axis2 = not axis1
    median = a[mid_index][axis1]
    mid_a = sorted([p for _iter in (
        (takewhile(lambda p: median-delta < p[axis1], left[::-1])),
        (takewhile(lambda p: p[axis1] < median+delta, right))
    ) for p in _iter], key=itemgetter(axis2))

    for i, (x1, y1) in enumerate(mid_a):
        ub = (x1 if axis1 else y1) + delta
        for x2, y2 in takewhile(lambda p: p[axis2] < ub, mid_a[i+1:]):
            delta = min(delta, sqrt((x1-x2)**2+(y1-y2)**2))

    return delta

if __name__ == "__main__":
    N = int(input())
    a = [tuple(map(float, l.split())) for l in sys.stdin.readlines()]
    print("{:.10f}".format(solve(a)))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from math import sqrt

def solve(a: list):
    length = len(a)
    if length <= 3:
        return min(sqrt((p1[0]-p2[0])**2+(p1[1]-p2[1])**2) for p1, p2 in zip(a, a[1:]))

    med = length//2
    x_l, x_r = a[:med], a[med:]
    delta = min(solve(x_l), solve(x_r))
    median_x = a[med][0]
    m_a = []
        
    for p in x_l[::-1]:
        if p[0] < median_x-delta:
            break
        m_a.append(p)
    m_a.reverse()
    for p in x_r:
        if p[0] > median_x+delta:
            break
        m_a.append(p)

    for i, (x1, y1) in enumerate(m_a):
        to_y = y1 + delta
        for j, (x2, y2) in enumerate(m_a[i+1:]):
            if y2 > to_y:
                break
            delta = min(delta, sqrt((x1-x2)**2+(y1-y2)**2))

    return delta

if __name__ == "__main__":
    N = int(input())
    a = sorted([tuple(map(float, l.split())) for l in sys.stdin.readlines()])
    print("{:.10f}".format(solve(a)))


Fixed submission:
import sys
from operator import itemgetter
from itertools import combinations, takewhile
from math import sqrt

def solve(a: list, sorted_axis: int = -1):
    length = len(a)
    if length <= 3:
        return sqrt(min((x1-x2)**2+(y1-y2)**2 for (x1, y1), (x2, y2) in combinations(a, 2)))

    x_set_len = len(set(x for x, _ in a))
    axis1 = 0 if x_set_len > length/2 else 1

    if sorted_axis != axis1:
        a.sort(key=itemgetter(axis1))

    mid_index = length//2
    left, right = a[:mid_index], a[mid_index:]
    delta = min(solve(left, axis1), solve(right, axis1))

    axis2 = not axis1
    median = a[mid_index][axis1]
    mid_a = sorted([p for _iter in (
        (takewhile(lambda p: median-delta < p[axis1], left[::-1])),
        (takewhile(lambda p: p[axis1] < median+delta, right))
    ) for p in _iter], key=itemgetter(axis2))

    for i, (x1, y1) in enumerate(mid_a):
        ub = (x1 if axis1 else y1) + delta
        for x2, y2 in takewhile(lambda p: p[axis2] < ub, mid_a[i+1:]):
            delta = min(delta, sqrt((x1-x2)**2+(y1-y2)**2))

    return delta

if __name__ == "__main__":
    N = int(input())
    a = [tuple(map(float, l.split())) for l in sys.stdin.readlines()]
    print("{:.10f}".format(solve(a)))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from operator import itemgetter
from itertools import permutations
from math import sqrt

def solve(a: list):
    length = len(a)
    if length <= 3:
        return min(sqrt((p1[0]-p2[0])**2+(p1[1]-p2[1])**2) for p1, p2 in permutations(a, 2))

    med = length//2
    x_l, x_r = a[:med], a[med:]
    delta = min(solve(x_l), solve(x_r))
    median_x = a[med][0]
    m_a = []
        
    for p in x_l[::-1]:
        if p[0] < median_x-delta:
            break
        m_a.append(p)
    for p in x_r:
        if p[0] > median_x+delta:
            break
        m_a.append(p)
    m_a.sort(key=itemgetter(1))

    for i, (x1, y1) in enumerate(m_a):
        to_y = y1 + delta
        for j, (x2, y2) in enumerate(m_a[i+1:]):
            if y2 > to_y:
                break
            delta = min(delta, sqrt((x1-x2)**2+(y1-y2)**2))

    return delta

if __name__ == "__main__":
    N = int(input())
    a = sorted([tuple(map(float, l.split())) for l in sys.stdin.readlines()])
    print("{:.10f}".format(solve(a)))


Fixed submission:
import sys
from operator import itemgetter
from itertools import combinations, takewhile
from math import sqrt

def solve(a: list, sorted_axis: int = -1):
    length = len(a)
    if length <= 3:
        return sqrt(min((x1-x2)**2+(y1-y2)**2 for (x1, y1), (x2, y2) in combinations(a, 2)))

    x_set_len = len(set(x for x, _ in a))
    axis1 = 0 if x_set_len > length/2 else 1

    if sorted_axis != axis1:
        a.sort(key=itemgetter(axis1))

    mid_index = length//2
    left, right = a[:mid_index], a[mid_index:]
    delta = min(solve(left, axis1), solve(right, axis1))

    axis2 = not axis1
    median = a[mid_index][axis1]
    mid_a = sorted([p for _iter in (
        (takewhile(lambda p: median-delta < p[axis1], left[::-1])),
        (takewhile(lambda p: p[axis1] < median+delta, right))
    ) for p in _iter], key=itemgetter(axis2))

    for i, (x1, y1) in enumerate(mid_a):
        ub = (x1 if axis1 else y1) + delta
        for x2, y2 in takewhile(lambda p: p[axis2] < ub, mid_a[i+1:]):
            delta = min(delta, sqrt((x1-x2)**2+(y1-y2)**2))

    return delta

if __name__ == "__main__":
    N = int(input())
    a = [tuple(map(float, l.split())) for l in sys.stdin.readlines()]
    print("{:.10f}".format(solve(a)))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from operator import itemgetter
from itertools import permutations
from math import sqrt

def solve(a: list, axis: int = 0):
    length = len(a)
    if length <= 3:
        return min(sqrt((p1[axis]-p2[axis])**2+(p1[not axis]-p2[not axis])**2) for p1, p2 in permutations(a, 2))

    med = length//2
    left, right = a[:med], a[med:]
    delta = min(solve(left, axis), solve(right, axis))
    median_x = a[med][axis]
    m_a = []
        
    for p in left[::-1]:
        if p[axis] < median_x-delta:
            break
        m_a.append(p)
    for p in right:
        if p[axis] > median_x+delta:
            break
        m_a.append(p)
    m_a.sort(key=itemgetter(not axis))

    for i, p1 in enumerate(m_a):
        ub = p1[not axis] + delta
        for j, p2 in enumerate(m_a[i+1:]):
            if p2[not axis] > ub:
                break
            delta = min(delta, sqrt((p1[0]-p2[0])**2+(p1[1]-p2[1])**2))

    return delta

if __name__ == "__main__":
    N = int(input())
    a = sorted([tuple(map(float, l.split())) for l in sys.stdin.readlines()])
    axis = 0 if len(set(p[0] for p in a)) > len(set(p[1] for p in a)) else 1
    print("{:.10f}".format(solve(a, axis)))


Fixed submission:
import sys
from operator import itemgetter
from itertools import combinations, takewhile
from math import sqrt

def solve(a: list, sorted_axis: int = -1):
    length = len(a)
    if length <= 3:
        return sqrt(min((x1-x2)**2+(y1-y2)**2 for (x1, y1), (x2, y2) in combinations(a, 2)))

    x_set_len = len(set(x for x, _ in a))
    axis1 = 0 if x_set_len > length/2 else 1

    if sorted_axis != axis1:
        a.sort(key=itemgetter(axis1))

    mid_index = length//2
    left, right = a[:mid_index], a[mid_index:]
    delta = min(solve(left, axis1), solve(right, axis1))

    axis2 = not axis1
    median = a[mid_index][axis1]
    mid_a = sorted([p for _iter in (
        (takewhile(lambda p: median-delta < p[axis1], left[::-1])),
        (takewhile(lambda p: p[axis1] < median+delta, right))
    ) for p in _iter], key=itemgetter(axis2))

    for i, (x1, y1) in enumerate(mid_a):
        ub = (x1 if axis1 else y1) + delta
        for x2, y2 in takewhile(lambda p: p[axis2] < ub, mid_a[i+1:]):
            delta = min(delta, sqrt((x1-x2)**2+(y1-y2)**2))

    return delta

if __name__ == "__main__":
    N = int(input())
    a = [tuple(map(float, l.split())) for l in sys.stdin.readlines()]
    print("{:.10f}".format(solve(a)))