import re


def replaceTags(value, data_record):
    """
    As efficiently as possible, replace tags in input string with corresponding values in
    data_record dictionary.

    The idea is to iterate through all of the elements of the data_record, and replace each
    instance of a bracketed key in the input string with the associated value indicated by
    the data record.

    This function will be used a lot, so it's important to make it as efficient as possible.

    Args:
        value (str): The string with tags to replace
        data_record (dict): A dict containing the tags to replace, and what to replace them with

    Returns:
        str: `value` with the tags replaced

    Examples:
        >>> data_record = {"a": "AAA", "b": "BBB"}
        >>> input_value = "aye [a] and bee [b]"
        >>> replaceTags(input_value, data_record)
        'aye AAA and bee BBB'
    """

    prog = re.compile(r"\[([a-zA-Z_][a-zA-Z0-9_\(\)]*)\]")
    matches = prog.finditer(value)

    for match in matches:
        if match.group(1) in data_record:
            value = value.replace(match.group(0), data_record[match.group(1)])

    return value