import re


def rename_duplicate_names(names):
    """
    Given a list of names, rename the duplicated names by appending an integer at the end. This function returns a list of tuples each of
    which contains an index of the duplicate name and a new name.
    For example,
    ['a', 'b', 'a', 'a'] -> [(2, 'a0'), (3, 'a0')]
    ['a', 'b'] -> []

    :param names: the list of names
    :type names: [str]
    :returns: a list of tuples each of which contains an index of the duplicate name and a new name.
    :rtypes: [tuple]
    """
    all_names = set(names)
    if len(all_names) == len(names):
        return []
    cur_names = set()
    prog = re.compile(r'^(.*)(\d+)$')
    renames = []
    for i, n in enumerate(names):
        if n in cur_names:
            res = prog.match(n)
            if res is None or len(res.groups())==0:
                prefix = n
                count = 0
            else:
                prefix = res.groups()[0]
                count = int(res.groups()[1])+1
            while prefix + str(count) in all_names:
                count += 1
            renames.append((i, prefix + str(count)))
            all_names.add(prefix + str(count))
        else:
            cur_names.add(n)
    return renames