import time


def delay(ticks: int) -> int:
    """pause the program for an amount of time

    Will pause for a given number of nanoseconds.
    This function will use the processor (rather than sleeping) in order to make the delay more accurate than nygame.time.wait().

    Parameters
    ----------
    ticks
        The amount of time to pause in nanoseconds.

    Returns
    -------
        The actual number of nanoseconds used.
    """
    start = time.perf_counter_ns()
    ticks -= 26000  # arbitrary offset to make up for poor timer precision
    if ticks <= 0:
        return 0
    end = start + ticks
    while time.perf_counter_ns() < end:
        pass
    return time.perf_counter_ns() - start