Returns lowest i such as a[i] >= x, or -1 if x > all elements in a

    So, if x is in between two elements in a, this function will return the
    index of the higher element, hence "Ceil".

    Arguments:
      a -- ordered numeric sequence
      x -- element to search within a
      lo -- lowest index to consider in search
      hi -- highest index to consider in search

def BSearchCeil(a, x, lo=0, hi=None):
    """Returns lowest i such as a[i] >= x, or -1 if x > all elements in a

    So, if x is in between two elements in a, this function will return the
    index of the higher element, hence "Ceil".

    Arguments:
      a -- ordered numeric sequence
      x -- element to search within a
      lo -- lowest index to consider in search
      hi -- highest index to consider in search"""
    if len(a) == 0: return -1
    hi = hi if hi is not None else len(a)
    pos = bisect_left(a, x, lo, hi)
    return pos if pos < hi else -1