def map_dict_to_list(d, width):
    """
    Given a dictionary -> {start: quantity, start: quantity, ...}
    Return a list of tuples [(start, end, quantity), (start, end, quantity), ...]
    """
    assert width >= 0
    for startTimeMillis in d:
        yield int(startTimeMillis), int(startTimeMillis) + width, d[
            startTimeMillis]
