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

file_input = sys.stdin

n = file_input.readline()

def distance(s_p1, s_p2):
    x1, y1 = map(float, s_p1.split())
    x2, y2 = map(float, s_p2.split())
    return ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5

import itertools

min_d = 400

for p1, p2 in itertools.combinations(file_input, 2):
    min_d = min(min_d, distance(p1, p2))

print('{:f}'.format(min_d))

Fixed submission:
import itertools

def _get_distance(p1, p2):
    return ((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2) ** 0.5

def _get_min_distance(points):
    min_d = 400
    for p1, p2 in itertools.combinations(points, 2):
        min_d = min(min_d, _get_distance(p1, p2))
    return min_d

def closest_pair_distance(points):
    n = len(points)
    if n <= 3:
        return _get_min_distance(points)
    else:
        mid = n // 2
        px, py = zip(*points)
        if len(set(px)) > len(set(py)):
            points.sort(key = lambda p: p[0])
            # axis: x; 0, y; 1
            axis1 = 0
            axis2 = 1
        else:
            points.sort(key = lambda p: p[1])
            axis1 = 1
            axis2 = 0
        A_points = points[:mid]
        B_points = points[mid:]
        d_Amin = closest_pair_distance(A_points.copy())
        d_Bmin = closest_pair_distance(B_points.copy())
        dist = min(d_Amin, d_Bmin)
        min_d = dist
        for ap in A_points[::-1]:
            if B_points[0][axis1] - ap[axis1] >= dist:
                break
            for bp in B_points:
                if bp[axis1] - ap[axis1] >= dist:
                    break
                if ap[axis2] - dist < bp[axis2] < ap[axis2] + dist:
                    min_d = min(min_d, _get_distance(ap, bp))
        return min_d

# Acceptance of input
import sys

file_input = sys.stdin

n = int(file_input.readline())

P = [tuple(map(float, line.split())) for line in file_input]

# Solve
ans = closest_pair_distance(P)

print('{:f}'.format(ans))

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

def _get_min_distance(points):
    min_d = 400
    for p1, p2 in itertools.combinations(points, 2):
        min_d = min(min_d, abs(p1 - p2))
    return min_d

def closest_pair_distance(points):
    n = len(points)
    if n <= 3:
        return _get_min_distance(points)
    else:
        mid = n // 2
        left_points = points[:mid]
        right_points = points[mid:]
        d_Lmin = closest_pair_distance(left_points)
        d_Rmin = closest_pair_distance(right_points)
        dist = min(d_Lmin, d_Rmin)
        min_d = dist
        for lp in left_points[::-1]:
            if right_points[0].real - lp.real >= dist:
                break
            for rp in right_points:
                if rp.real -lp.real >= dist:
                    break
                if lp.imag - dist < rp.imag < lp.imag + dist:
                    min_d = min(min_d, abs(lp - rp))
        return min_d

# Acceptance of input
def string_to_complex(s):
    x, y = map(float, s.split())
    return x + y * 1j

import sys

file_input = sys.stdin

n = int(file_input.readline())

P = [string_to_complex(line) for line in file_input]

P.sort(key = lambda c: c.real)

# Output
ans = closest_pair_distance(P)
print('{:f}'.format(ans))

Fixed submission:
import itertools

def _get_distance(p1, p2):
    return ((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2) ** 0.5

def _get_min_distance(points):
    min_d = 400
    for p1, p2 in itertools.combinations(points, 2):
        min_d = min(min_d, _get_distance(p1, p2))
    return min_d

def closest_pair_distance(points):
    n = len(points)
    if n <= 3:
        return _get_min_distance(points)
    else:
        mid = n // 2
        px, py = zip(*points)
        if len(set(px)) > len(set(py)):
            points.sort(key = lambda p: p[0])
            # axis: x; 0, y; 1
            axis1 = 0
            axis2 = 1
        else:
            points.sort(key = lambda p: p[1])
            axis1 = 1
            axis2 = 0
        A_points = points[:mid]
        B_points = points[mid:]
        d_Amin = closest_pair_distance(A_points.copy())
        d_Bmin = closest_pair_distance(B_points.copy())
        dist = min(d_Amin, d_Bmin)
        min_d = dist
        for ap in A_points[::-1]:
            if B_points[0][axis1] - ap[axis1] >= dist:
                break
            for bp in B_points:
                if bp[axis1] - ap[axis1] >= dist:
                    break
                if ap[axis2] - dist < bp[axis2] < ap[axis2] + dist:
                    min_d = min(min_d, _get_distance(ap, bp))
        return min_d

# Acceptance of input
import sys

file_input = sys.stdin

n = int(file_input.readline())

P = [tuple(map(float, line.split())) for line in file_input]

# Solve
ans = closest_pair_distance(P)

print('{:f}'.format(ans))

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

def _get_min_distance(points):
    min_d = 400
    for p1, p2 in itertools.combinations(points, 2):
        min_d = min(min_d, abs(p1 - p2))
    return min_d

# Search based on x axis
def closest_pair_distance_x(points):
    n = len(points)
    if n <= 3:
        return _get_min_distance(points)
    else:
        mid = n // 2
        left_points = points[:mid]
        right_points = points[mid:]
        d_Lmin = closest_pair_distance(left_points)
        d_Rmin = closest_pair_distance(right_points)
        dist = min(d_Lmin, d_Rmin)
        min_d = dist
        for lp in left_points[::-1]:
            if right_points[0].real - lp.real >= dist:
                break
            for rp in right_points:
                if rp.real -lp.real >= dist:
                    break
                if lp.imag - dist < rp.imag < lp.imag + dist:
                    min_d = min(min_d, abs(lp - rp))
        return min_d

# Search based on y axis
def closest_pair_distance_y(points):
    n = len(points)
    if n <= 3:
        return _get_min_distance(points)
    else:
        mid = n // 2
        lower_points = points[:mid]
        upper_points = points[mid:]
        d_Lmin = closest_pair_distance(lower_points)
        d_Umin = closest_pair_distance(upper_points)
        dist = min(d_Lmin, d_Umin)
        min_d = dist
        for lp in lower_points[::-1]:
            if upper_points[0].imag - lp.imag >= dist:
                break
            for up in upper_points:
                if up.imag -lp.imag >= dist:
                    break
                if lp.real - dist < up.real < lp.real + dist:
                    min_d = min(min_d, abs(lp - up))
        return min_d

# Acceptance of input
def string_to_complex(s):
    x, y = map(float, s.split())
    return x + y * 1j

import sys

file_input = sys.stdin

n = int(file_input.readline())

P = [string_to_complex(line) for line in file_input]

# Solve
P.sort(key = lambda c: (c.real, c.imag))

if P[-1].real - P[0].real >= P[-1].imag - P[0].imag:
    ans = closest_pair_distance_x(P)
    print('{:f}'.format(ans))
else:
    P.sort(key = lambda c: c.imag)
    ans = closest_pair_distance_y(P)
    print('{:f}'.format(ans))

Fixed submission:
import itertools

def _get_distance(p1, p2):
    return ((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2) ** 0.5

def _get_min_distance(points):
    min_d = 400
    for p1, p2 in itertools.combinations(points, 2):
        min_d = min(min_d, _get_distance(p1, p2))
    return min_d

def closest_pair_distance(points):
    n = len(points)
    if n <= 3:
        return _get_min_distance(points)
    else:
        mid = n // 2
        px, py = zip(*points)
        if len(set(px)) > len(set(py)):
            points.sort(key = lambda p: p[0])
            # axis: x; 0, y; 1
            axis1 = 0
            axis2 = 1
        else:
            points.sort(key = lambda p: p[1])
            axis1 = 1
            axis2 = 0
        A_points = points[:mid]
        B_points = points[mid:]
        d_Amin = closest_pair_distance(A_points.copy())
        d_Bmin = closest_pair_distance(B_points.copy())
        dist = min(d_Amin, d_Bmin)
        min_d = dist
        for ap in A_points[::-1]:
            if B_points[0][axis1] - ap[axis1] >= dist:
                break
            for bp in B_points:
                if bp[axis1] - ap[axis1] >= dist:
                    break
                if ap[axis2] - dist < bp[axis2] < ap[axis2] + dist:
                    min_d = min(min_d, _get_distance(ap, bp))
        return min_d

# Acceptance of input
import sys

file_input = sys.stdin

n = int(file_input.readline())

P = [tuple(map(float, line.split())) for line in file_input]

# Solve
ans = closest_pair_distance(P)

print('{:f}'.format(ans))

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

def _get_min_distance(points):
    min_d = 400
    for p1, p2 in itertools.combinations(points, 2):
        min_d = min(min_d, abs(p1 - p2))
    return min_d

# Search based on x axis
def closest_pair_distance_x(points):
    n = len(points)
    if n <= 3:
        return _get_min_distance(points)
    else:
        mid = n // 2
        left_points = points[:mid]
        right_points = points[mid:]
        d_Lmin = closest_pair_distance_x(left_points)
        d_Rmin = closest_pair_distance_x(right_points)
        dist = min(d_Lmin, d_Rmin)
        min_d = dist
        for lp in left_points[::-1]:
            if right_points[0].real - lp.real >= dist:
                break
            for rp in right_points:
                if rp.real -lp.real >= dist:
                    break
                if lp.imag - dist < rp.imag < lp.imag + dist:
                    min_d = min(min_d, abs(lp - rp))
        return min_d

# Search based on y axis
def closest_pair_distance_y(points):
    n = len(points)
    if n <= 3:
        return _get_min_distance(points)
    else:
        mid = n // 2
        lower_points = points[:mid]
        upper_points = points[mid:]
        d_Lmin = closest_pair_distance_y(lower_points)
        d_Umin = closest_pair_distance_y(upper_points)
        dist = min(d_Lmin, d_Umin)
        min_d = dist
        for lp in lower_points[::-1]:
            if upper_points[0].imag - lp.imag >= dist:
                break
            for up in upper_points:
                if up.imag -lp.imag >= dist:
                    break
                if lp.real - dist < up.real < lp.real + dist:
                    min_d = min(min_d, abs(lp - up))
        return min_d

# Acceptance of input
def string_to_complex(s):
    x, y = map(float, s.split())
    return x + y * 1j

import sys

file_input = sys.stdin

n = int(file_input.readline())

P = [string_to_complex(line) for line in file_input]

# Solve
P.sort(key = lambda c: (c.real, c.imag))

if P[-1].real - P[0].real >= P[-1].imag - P[0].imag:
    ans = closest_pair_distance_x(P)
    print('{:f}'.format(ans))
else:
    P.sort(key = lambda c: c.imag)
    ans = closest_pair_distance_y(P)
    print('{:f}'.format(ans))

Fixed submission:
import itertools

def _get_distance(p1, p2):
    return ((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2) ** 0.5

def _get_min_distance(points):
    min_d = 400
    for p1, p2 in itertools.combinations(points, 2):
        min_d = min(min_d, _get_distance(p1, p2))
    return min_d

def closest_pair_distance(points):
    n = len(points)
    if n <= 3:
        return _get_min_distance(points)
    else:
        mid = n // 2
        px, py = zip(*points)
        if len(set(px)) > len(set(py)):
            points.sort(key = lambda p: p[0])
            # axis: x; 0, y; 1
            axis1 = 0
            axis2 = 1
        else:
            points.sort(key = lambda p: p[1])
            axis1 = 1
            axis2 = 0
        A_points = points[:mid]
        B_points = points[mid:]
        d_Amin = closest_pair_distance(A_points.copy())
        d_Bmin = closest_pair_distance(B_points.copy())
        dist = min(d_Amin, d_Bmin)
        min_d = dist
        for ap in A_points[::-1]:
            if B_points[0][axis1] - ap[axis1] >= dist:
                break
            for bp in B_points:
                if bp[axis1] - ap[axis1] >= dist:
                    break
                if ap[axis2] - dist < bp[axis2] < ap[axis2] + dist:
                    min_d = min(min_d, _get_distance(ap, bp))
        return min_d

# Acceptance of input
import sys

file_input = sys.stdin

n = int(file_input.readline())

P = [tuple(map(float, line.split())) for line in file_input]

# Solve
ans = closest_pair_distance(P)

print('{:f}'.format(ans))

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

def _get_min_distance(points):
    min_d = 400
    for p1, p2 in itertools.combinations(points, 2):
        min_d = min(min_d, abs(p1 - p2))
    return min_d

# Search based on x axis
def closest_pair_distance_x(points):
    n = len(points)
    if n <= 3:
        return _get_min_distance(points)
    else:
        mid = n // 2
        left_points = points[:mid]
        right_points = points[mid:]
        d_Lmin = closest_pair_distance_x(left_points)
        d_Rmin = closest_pair_distance_x(right_points)
        dist = min(d_Lmin, d_Rmin)
        min_d = dist
        for lp in left_points[::-1]:
            if right_points[0].real - lp.real >= dist:
                break
            for rp in right_points:
                if rp.real -lp.real >= dist:
                    break
                if lp.imag - dist < rp.imag < lp.imag + dist:
                    min_d = min(min_d, abs(lp - rp))
        return min_d

# Search based on y axis
def closest_pair_distance_y(points):
    n = len(points)
    if n <= 3:
        return _get_min_distance(points)
    else:
        mid = n // 2
        lower_points = points[:mid]
        upper_points = points[mid:]
        d_Lmin = closest_pair_distance_y(lower_points)
        d_Umin = closest_pair_distance_y(upper_points)
        dist = min(d_Lmin, d_Umin)
        min_d = dist
        for lp in lower_points[::-1]:
            if upper_points[0].imag - lp.imag >= dist:
                break
            for up in upper_points:
                if up.imag -lp.imag >= dist:
                    break
                if lp.real - dist < up.real < lp.real + dist:
                    min_d = min(min_d, abs(lp - up))
        return min_d

# Acceptance of input
def string_to_complex(s):
    x, y = map(float, s.split())
    return x + y * 1j

import sys

file_input = sys.stdin

n = int(file_input.readline())

P = [string_to_complex(line) for line in file_input]

# Solve
P.sort(key = lambda c: c.imag)
ans = closest_pair_distance_y(P)
print('{:f}'.format(ans))

Fixed submission:
import itertools

def _get_distance(p1, p2):
    return ((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2) ** 0.5

def _get_min_distance(points):
    min_d = 400
    for p1, p2 in itertools.combinations(points, 2):
        min_d = min(min_d, _get_distance(p1, p2))
    return min_d

def closest_pair_distance(points):
    n = len(points)
    if n <= 3:
        return _get_min_distance(points)
    else:
        mid = n // 2
        px, py = zip(*points)
        if len(set(px)) > len(set(py)):
            points.sort(key = lambda p: p[0])
            # axis: x; 0, y; 1
            axis1 = 0
            axis2 = 1
        else:
            points.sort(key = lambda p: p[1])
            axis1 = 1
            axis2 = 0
        A_points = points[:mid]
        B_points = points[mid:]
        d_Amin = closest_pair_distance(A_points.copy())
        d_Bmin = closest_pair_distance(B_points.copy())
        dist = min(d_Amin, d_Bmin)
        min_d = dist
        for ap in A_points[::-1]:
            if B_points[0][axis1] - ap[axis1] >= dist:
                break
            for bp in B_points:
                if bp[axis1] - ap[axis1] >= dist:
                    break
                if ap[axis2] - dist < bp[axis2] < ap[axis2] + dist:
                    min_d = min(min_d, _get_distance(ap, bp))
        return min_d

# Acceptance of input
import sys

file_input = sys.stdin

n = int(file_input.readline())

P = [tuple(map(float, line.split())) for line in file_input]

# Solve
ans = closest_pair_distance(P)

print('{:f}'.format(ans))

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

def _get_min_distance(points):
    min_d = 400
    for p1, p2 in itertools.combinations(points, 2):
        min_d = min(min_d, abs(p1 - p2))
    return min_d

# Search based on x axis
def closest_pair_distance_x(points):
    n = len(points)
    if n <= 3:
        return _get_min_distance(points)
    else:
        mid = n // 2
        left_points = points[:mid]
        right_points = points[mid:]
        d_Lmin = closest_pair_distance_x(left_points)
        d_Rmin = closest_pair_distance_x(right_points)
        dist = min(d_Lmin, d_Rmin)
        min_d = dist
        for lp in left_points[::-1]:
            if right_points[0].real - lp.real >= dist:
                break
            for rp in right_points:
                if rp.real -lp.real >= dist:
                    break
                if lp.imag - dist < rp.imag < lp.imag + dist:
                    min_d = min(min_d, abs(lp - rp))
        return min_d

# Search based on y axis
def closest_pair_distance_y(points):
    n = len(points)
    if n <= 3:
        return _get_min_distance(points)
    else:
        mid = n // 2
        lower_points = points[:mid]
        upper_points = points[mid:]
        d_Lmin = closest_pair_distance_y(lower_points)
        d_Umin = closest_pair_distance_y(upper_points)
        dist = min(d_Lmin, d_Umin)
        min_d = dist
        for lp in lower_points[::-1]:
            if upper_points[0].imag - lp.imag >= dist:
                break
            for up in upper_points:
                if up.imag -lp.imag >= dist:
                    break
                if lp.real - dist < up.real < lp.real + dist:
                    min_d = min(min_d, abs(lp - up))
        return min_d

# Acceptance of input
import sys

file_input = sys.stdin

n = int(file_input.readline())

P = []
pX = []
pY = []

for line in file_input:
    x, y = map(float, line.split())
    P.append(x + y * 1j)
    pX.append(x)
    pY.append(y)

# Solve
if len(set(pX)) > len(set(pY)):
    P.sort(key = lambda c: c.real)
    ans = closest_pair_distance_x(P)
else:
    P.sort(key = lambda c: c.imag)
    ans = closest_pair_distance_y(P)

print('{:f}'.format(ans))

Fixed submission:
import itertools

def _get_distance(p1, p2):
    return ((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2) ** 0.5

def _get_min_distance(points):
    min_d = 400
    for p1, p2 in itertools.combinations(points, 2):
        min_d = min(min_d, _get_distance(p1, p2))
    return min_d

def closest_pair_distance(points):
    n = len(points)
    if n <= 3:
        return _get_min_distance(points)
    else:
        mid = n // 2
        px, py = zip(*points)
        if len(set(px)) > len(set(py)):
            points.sort(key = lambda p: p[0])
            # axis: x; 0, y; 1
            axis1 = 0
            axis2 = 1
        else:
            points.sort(key = lambda p: p[1])
            axis1 = 1
            axis2 = 0
        A_points = points[:mid]
        B_points = points[mid:]
        d_Amin = closest_pair_distance(A_points.copy())
        d_Bmin = closest_pair_distance(B_points.copy())
        dist = min(d_Amin, d_Bmin)
        min_d = dist
        for ap in A_points[::-1]:
            if B_points[0][axis1] - ap[axis1] >= dist:
                break
            for bp in B_points:
                if bp[axis1] - ap[axis1] >= dist:
                    break
                if ap[axis2] - dist < bp[axis2] < ap[axis2] + dist:
                    min_d = min(min_d, _get_distance(ap, bp))
        return min_d

# Acceptance of input
import sys

file_input = sys.stdin

n = int(file_input.readline())

P = [tuple(map(float, line.split())) for line in file_input]

# Solve
ans = closest_pair_distance(P)

print('{:f}'.format(ans))

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

def _get_min_distance(points):
    min_d = 400
    for p1, p2 in itertools.combinations(points, 2):
        min_d = min(min_d, abs(p1 - p2))
    return min_d

# Search based on x axis
def closest_pair_distance_x(points):
    n = len(points)
    if n <= 3:
        return _get_min_distance(points)
    else:
        mid = n // 2
        left_points = points[:mid]
        right_points = points[mid:]
        d_Lmin = closest_pair_distance_x(left_points)
        d_Rmin = closest_pair_distance_x(right_points)
        dist = min(d_Lmin, d_Rmin)
        min_d = dist
        for lp in left_points[::-1]:
            if right_points[0].real - lp.real >= dist:
                break
            for rp in right_points:
                if rp.real -lp.real >= dist:
                    break
                if lp.imag - dist < rp.imag < lp.imag + dist:
                    min_d = min(min_d, abs(lp - rp))
        return min_d

# Search based on y axis
def closest_pair_distance_y(points):
    n = len(points)
    if n <= 3:
        return _get_min_distance(points)
    else:
        mid = n // 2
        lower_points = points[:mid]
        upper_points = points[mid:]
        d_Lmin = closest_pair_distance_y(lower_points)
        d_Umin = closest_pair_distance_y(upper_points)
        dist = min(d_Lmin, d_Umin)
        min_d = dist
        for lp in lower_points[::-1]:
            if upper_points[0].imag - lp.imag >= dist:
                break
            for up in upper_points:
                if up.imag -lp.imag >= dist:
                    break
                if lp.real - dist < up.real < lp.real + dist:
                    min_d = min(min_d, abs(lp - up))
        return min_d

# Acceptance of input
import sys

file_input = sys.stdin

n = int(file_input.readline())

P = []
pX = []
pY = []

for line in file_input:
    x, y = map(float, line.split())
    P.append(x + y * 1j)
    pX.append(x)
    pY.append(y)

# Solve
if len(set(pX)) > len(set(pY)):
    P.sort(key = lambda c: c.real)
    ans = closest_pair_distance_x(P)
else:
    P.sort(key = lambda c: c.imag)
    ans = closest_pair_distance_y(P)

print('{:f}'.format(ans))

Fixed submission:
import itertools

def _get_distance(p1, p2):
    return ((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2) ** 0.5

def _get_min_distance(points):
    min_d = 400
    for p1, p2 in itertools.combinations(points, 2):
        min_d = min(min_d, _get_distance(p1, p2))
    return min_d

def closest_pair_distance(points):
    n = len(points)
    if n <= 3:
        return _get_min_distance(points)
    else:
        mid = n // 2
        px, py = zip(*points)
        if len(set(px)) > len(set(py)):
            points.sort(key = lambda p: p[0])
            # axis: x; 0, y; 1
            axis1 = 0
            axis2 = 1
        else:
            points.sort(key = lambda p: p[1])
            axis1 = 1
            axis2 = 0
        A_points = points[:mid]
        B_points = points[mid:]
        d_Amin = closest_pair_distance(A_points.copy())
        d_Bmin = closest_pair_distance(B_points.copy())
        dist = min(d_Amin, d_Bmin)
        min_d = dist
        for ap in A_points[::-1]:
            if B_points[0][axis1] - ap[axis1] >= dist:
                break
            for bp in B_points:
                if bp[axis1] - ap[axis1] >= dist:
                    break
                if ap[axis2] - dist < bp[axis2] < ap[axis2] + dist:
                    min_d = min(min_d, _get_distance(ap, bp))
        return min_d

# Acceptance of input
import sys

file_input = sys.stdin

n = int(file_input.readline())

P = [tuple(map(float, line.split())) for line in file_input]

# Solve
ans = closest_pair_distance(P)

print('{:f}'.format(ans))