def dist(x, y):
    """
    Calculate dist^2 between two points
    @param x: first point
    @param y: second point
    @return: distance^2
    """
    r = 0.0
    for i in range(3):
        r += (x[i] - y[i]) ** 2
    return r
