input: from typing import List
  from collections import defaultdict
  
  def count_matching_prefix_suffix_pairs(words: List[str]) -> int:
      """
      You are given a 0-indexed list of strings words.
  
      Define a boolean function checkPrefixSuffix that takes two strings, str1 and str2:
  
      checkPrefixSuffix(str1, str2) returns true if str1 is both a prefix and a suffix of str2, and false otherwise.
      For instance, checkPrefixSuffix("abc", "ababc") is true because "abc" is a prefix of "ababc" and also a suffix, but checkPrefixSuffix("xyz", "xyza") is false.
  
      Return an integer representing the count of index pairs (i, j) such that i < j, and checkPrefixSuffix(words[i], words[j]) is true.
  
      Examples:
      >>> words = ["test","testing","testest","tt"]
      3
      >>> words = ["ca","caca","la","lala"]
      1
      >>> words = ["testtest","test"]
      0
  
      Constraints:
      1 <= words.length <= 10^5
      1 <= words[i].length <= 10^5
      words[i] consist only of lowercase English letters.
      The total length of all words[i] does not exceed 5 * 10^5.
      """
output:     
      def checkPrefixSuffix(str1: str, str2: str) -> bool:
          return str2.startswith(str1) and str2.endswith(str1)
  
      count = 0
      n = len(words)
      
      for i in range(n):
          for j in range(i + 1, n):
              if checkPrefixSuffix(words[i], words[j]):
                  count += 1
                  
      return count
  