def split(head, x, y, dx, dy):
    """Split the area define by x, y, dx, dy into two rectangular boxes
    along the longer axis

    Returns two split rectanges (x1, y1, dx1, dy1), (x2, y2, dx2, dy2)
    """
    covered_area = sum(head)
    if dx >= dy:
        width = covered_area / dy
        return (x, y, width, dy), (x + width, y, dx - width, dy)
    else:
        height = covered_area / dx
        return (x, y, dx, height), (x, y + height, dx, dy - height)
