import collections
import itertools


def find_repeat(data):
    """You notice that the device repeats the same frequency change list over and
    over. To calibrate the device, you need to find the first frequency it
    reaches twice.

    >>> find_repeat([+1, -1])
    0
    >>> find_repeat([+3, +3, +4, -2, -4])
    10
    >>> find_repeat([-6, +3, +8, +5, -6])
    5
    >>> find_repeat([+7, +7, -2, -7, -4])
    14
    """

    count = collections.defaultdict(int)
    value = 0

    for increment in itertools.cycle(data):
        count[value] += 1

        if count[value] == 2:
            return value

        value += increment