input: from typing import List
  from collections import defaultdict
  
  def count_prefix_suffix_pairs(words: List[str]) -> int:
      """
      You are provided with a list of strings indexed from zero.
  
      Let's define a function isPrefixSuffix that takes two strings, str1 and str2:
  
      isPrefixSuffix(str1, str2) returns true if str1 is both a prefix and a suffix of str2, and false otherwise.
      For example, isPrefixSuffix("aba", "ababa") is true because "aba" is both a prefix and a suffix of "ababa", but isPrefixSuffix("abc", "abcd") is false.
  
      Return the total number of index pairs (i, j) where i < j, and isPrefixSuffix(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 letters.
      The total length of all words[i] does not exceed 5 * 10^5.
      """
output:     
      def isPrefixSuffix(str1: str, str2: str) -> bool:
          return str2.startswith(str1) and str2.endswith(str1)
  
      count = 0
      for i in range(len(words)):
          for j in range(i + 1, len(words)):
              if isPrefixSuffix(words[i], words[j]):
                  count += 1
      return count
  