from typing import List
from typing import Match
import re


def replace_math(input: str, math: List[str]) -> str:
    """
    input: a string, already processed into HTML by some markdown renderer;
    may contain @@number@@ blocks indicating where math was removed by
    remove_math.

    math: a list of strings containing math blocks to be spliced back into input

    Put back the math strings that were saved
    """

    def replacer(match: Match):
        index = int(match.group(1))
        return math[index]

    text = re.sub(r'@@(\d+)@@', replacer, input)
    return text