input: from typing import List
  
  def frequent_words(words: List[str], n: int) -> List[str]:
      """ Counts the occurrences of each word in the list and returns a list of words that appear at least n times.
      >>> frequent_words(['a', 'b', 'a', 'c', 'd', 'a', 'x', 'd', 'd'], 3)
      ['a', 'd']
      >>> frequent_words(['cat', 'in', 'the', 'hat', 'in', 'the'], 2)
      ['in', 'the']
      """
      
      from collections import Counter
      counts = Counter(words)
      return [word for word, count in counts.items() if count >= n]
output:     from collections import Counter
      counts = Counter(words)
      return [word for word, count in counts.items() if count >= n]