input: 
  def num_common_substrings(s1: str, s2: str) -> int:
      """
      Returns the number of common substrings between two given strings.
  
      >>> num_common_substrings("abcd", "bae")
      2
      """
      count = 0
      for i in range(len(s1)):
          for j in range(len(s2)):
              if s1[i] == s2[j]:
                  count += 1
      return count
  
output:     for length in range(1, min(len(s1), len(s2)) + 1):
          for i in range(len(s1) - length + 1):
              for j in range(len(s2) - length + 1):
                  if s1[i:i+length] == s2[j:j+length]:
                      count += 1
      return count