from math import ceil, sqrt


def chooseGridThread(n):
    """
    Modify this function to change how we choose number of
    threads and blocks

    Args:
        n (int): number of datapoints

    Returns:
        (int, int): (nblocks, nthreads)
    """
    nroot = sqrt(n)
    curr = 32
    while curr + 32 < nroot and curr < 2048:
        curr += 32
    nthreads = curr

    nblocks = ceil(n / nthreads)
    return nblocks, nthreads