def uniquify_names(names):
    """
    Takes a list of strings. If there are repeated values, appends some suffixes
    to make them unique.
    """
    count = {}
    for name in names:
        count.setdefault(name, 0)
        count[name] += 1

    seen = set()
    res = []
    for name in names:
        unique = count[name] == 1
        new_name = name
        i = 0
        # If a name is not unique, append suffix to all occurrences.
        # E.g. turn ["a", "a"] into ["a[0]", "a[1]"], not ["a", "a[0]"]
        while new_name in seen or (not unique and i == 0):
            new_name = name + "[" + str(i) + "]"
            i += 1
        seen.add(new_name)
        res.append(new_name)
    return res