from itertools import chain, repeat
from typing import Iterable
from typing import Iterator


def ncycles(it: Iterable, n: int) -> Iterator:
    """
    Returns the sequence elements n times

    >>> [*ncycles(range(3), 3)]
    [0, 1, 2, 0, 1, 2, 0, 1, 2]
    """
    return chain.from_iterable(repeat(it, n))