input: from typing import List
  from collections import defaultdict
  
  def find_prefix_suffix_pairs(words: List[str]) -> int:
      """
      You are provided with a zero-indexed list of strings called words.
  
      Define a boolean function called isPrefixAndSuffix which accepts two strings, str1 and str2:
  
      isPrefixAndSuffix(str1, str2) returns true if str1 is both a prefix and a suffix of str2, and false otherwise.
      For example, isPrefixAndSuffix("aba", "ababa") returns true because "aba" is a prefix as well as a suffix of "ababa", but isPrefixAndSuffix("abc", "abcd") returns false.
  
      Return an integer representing the count of index pairs (i, j) where i < j, and isPrefixAndSuffix(words[i], words[j]) is true.
  
      Examples:
      >>> words = ["a","aba","ababa","aa"]
      4
      >>> words = ["pa","papa","ma","mama"]
      2
      >>> words = ["abab","ab"]
      0
  
      Constraints:
      1 <= words.length <= 10^5
      1 <= words[i].length <= 10^5
      words[i] contains only lowercase English characters.
      The total length of all words[i] does not exceed 5 * 10^5.
      """
output:     def isPrefixAndSuffix(prefix: str, word: str) -> bool:
      return word.startswith(prefix) and word.endswith(prefix)
  
  def find_prefix_suffix_pairs(words: List[str]) -> int:
      pairs_count = 0
      for i in range(len(words)):
          for j in range(i + 1, len(words)):
              if isPrefixAndSuffix(words[i], words[j]):
                  pairs_count += 1
      return pairs_count