import math


def grid_size(N):
    """
    Find optimal dimensions to put elements on 2D grid,
    with the resulting grid being as quadratic as possible.
    @param N: number of elements to put on a grid
    """
    n = int(math.ceil(math.sqrt(N)))
    m = int(math.ceil(N/float(n)))
    return n,m