Given a word dictionary {kite, yellow} and a list of words {KITe, kiTE, yollow, yeellow}, output the corrected words based on specific rules. Matching is case-insensitive, and every dictionary word is returned in lowercase. Correct a nonmatching word only when exactly one dictionary word is either one character substitution away or can produce the input by inserting one duplicate adjacent character; otherwise, leave the input lowercase and unchanged. Implement def correct_words(dictionary, words):, returning a list with one output per input word.
def correct_words(dictionary, words):