You are an expert Python programmer. Write correct, efficient Python 3 code that solves the problem and passes all tests. Output the code in the following format: ```python
<code>
```

PROBLEM:
You are given an array of strings message and an array of strings bannedWords.
An array of words is considered spam if there are at least two words in it that exactly match any word in bannedWords.
Return true if the array message is spam, and false otherwise.

Example 1:

Input: message = ["hello","world","leetcode"], bannedWords = ["world","hello"]
Output: true
Explanation:
The words "hello" and "world" from the message array both appear in the bannedWords array.

Example 2:

Input: message = ["hello","programming","fun"], bannedWords = ["world","programming","leetcode"]
Output: false
Explanation:
Only one word from the message array ("programming") appears in the bannedWords array.

Constraints:

1 <= message.length, bannedWords.length <= 105
1 <= message[i].length, bannedWords[i].length <= 15
message[i] and bannedWords[i] consist only of lowercase English letters.

Your solution to the problem should be a method of the class Solution called reportSpam and should pass all tests. Use the following starter code:
```python
class Solution:
    def reportSpam(self, message: List[str], bannedWords: List[str]) -> bool:
        # Add your code here
```

SOLUTION:

Question:
PROBLEM:
You are given an array of strings message and an array of strings bannedWords.
An array of words is considered spam if there are at least two words in it that exactly match any word in bannedWords.
Return true if the array message is spam, and false otherwise.

Example 1:

Input: message = ["hello","world","leetcode"], bannedWords = ["world","hello"]
Output: true
Explanation:
The words "hello" and "world" from the message array both appear in the bannedWords array.

Example 2:

Input: message = ["hello","programming","fun"], bannedWords = ["world","programming","leetcode"]
Output: false
Explanation:
Only one word from the message array ("programming") appears in the bannedWords array.

Constraints:

1 <= message.length, bannedWords.length <= 105
1 <= message[i].length, bannedWords[i].length <= 15
message[i] and bannedWords[i] consist only of lowercase English letters.

Your solution to the problem should be a method of the class Solution called reportSpam and should pass all tests. Use the following starter code:
```python
class Solution:
    def reportSpam(self, message: List[str], bannedWords: List[str]) -> bool:
        # Add your code here
```

SOLUTION:

assert Solution().reportSpam(message = ["spam","egg","ham"], bannedWords = ["spam","bacon","egg"]) == True

assert Solution().reportSpam(message = ["spam","eggs","spam"], bannedWords = ["spam"]) == True

assert Solution().reportSpam(message = ["spam","spam","spam"], bannedWords = ["spam"]) == True

assert Solution().reportSpam(message = ["spam","egg","spam"], bannedWords = ["spam"]) == True

assert Solution().reportSpam(message = ["python","java","c++"], bannedWords = ["ruby","swift"]) == False

assert Solution().reportSpam(message = ["python","java","c++"], bannedWords = ["java","c#","ruby"]) == False

assert Solution().reportSpam(message = ["hello","programming","fun"], bannedWords = ["world","programming","leetcode"]) == False

assert Solution().reportSpam(message = ["a","b","c","d","e"], bannedWords = ["a","b"]) == True

assert Solution().reportSpam(message = ["apple","banana","cherry"], bannedWords = ["date","fig","grape"]) == False

assert Solution().reportSpam(message = ["code","is","fun"], bannedWords = ["code","cool"]) == False

assert Solution().reportSpam(message = ["apple","banana","cherry"], bannedWords = ["mango","pineapple"]) == False

assert Solution().reportSpam(message = ["coding","is","fun"], bannedWords = ["fun","coding","is","cool"]) == True

assert Solution().reportSpam(message = ["code","code","code"], bannedWords = ["code"]) == True

assert Solution().reportSpam(message = ["python","java","c++"], bannedWords = ["ruby","go","swift"]) == False

assert Solution().reportSpam(message = ["hello","world","leetcode"], bannedWords = ["world","hello"]) == True

assert Solution().reportSpam(message = ["python","java","c++"], bannedWords = ["ruby","go"]) == False

assert Solution().reportSpam(message = ["python","java","c++","python","java"], bannedWords = ["python","java","c#"]) == True

assert Solution().reportSpam(message = ["python","java","c++","java"], bannedWords = ["java","c#","swift"]) == True

assert Solution().reportSpam(message = ["one","two","three","four","five"], bannedWords = ["three","four","five","six"]) == True

assert Solution().reportSpam(message = ["python","java","c++","ruby","go","swift"], bannedWords = ["python","swift","java","c++","go","ruby"]) == True

assert Solution().reportSpam(message = ["same","same","same","different","same"], bannedWords = ["same","different"]) == True

assert Solution().reportSpam(message = ["coding","fun","coding","learning"], bannedWords = ["coding","fun","hello"]) == True

assert Solution().reportSpam(message = ["cat","dog","mouse","cat"], bannedWords = ["dog","cat","bird"]) == True

assert Solution().reportSpam(message = ["this","is","a","test","case"], bannedWords = ["test","case","example","input"]) == True

assert Solution().reportSpam(message = ["short","longer","words","in","the","message"], bannedWords = ["longer","words","phrase"]) == True

assert Solution().reportSpam(message = ["unique","words","only","here"], bannedWords = ["duplicate","words","overlap"]) == False

assert Solution().reportSpam(message = ["hello","world","hello","world"], bannedWords = ["hello","world","programming"]) == True

assert Solution().reportSpam(message = ["data","science","machine","learning"], bannedWords = ["data","science"]) == True

assert Solution().reportSpam(message = ["apple","banana","cherry","date","elderberry","fig","grape"], bannedWords = ["apple","banana","cherry","date","elderberry","fig","grape","honeydew"]) == True

assert Solution().reportSpam(message = ["test","test","test","test"], bannedWords = ["test","example","sample"]) == True

assert Solution().reportSpam(message = ["hello","hello","hello","hello"], bannedWords = ["world","hello","programming"]) == True

assert Solution().reportSpam(message = ["example","test","case","example","test"], bannedWords = ["example","test","case","input"]) == True

assert Solution().reportSpam(message = ["python","programming","code","python"], bannedWords = ["python","java","c++"]) == True

assert Solution().reportSpam(message = ["data","science","and","ai"], bannedWords = ["ai","machine","learning"]) == False

assert Solution().reportSpam(message = ["one","two","three","four","five"], bannedWords = ["one","two","three","four","five"]) == True

assert Solution().reportSpam(message = ["lets","go","for","a","walk","in","the","park"], bannedWords = ["walk","run","jog"]) == False

assert Solution().reportSpam(message = ["coding","python","java","coding"], bannedWords = ["java","coding","ruby"]) == True

assert Solution().reportSpam(message = ["quick","brown","fox","jumps","over","lazy","dog"], bannedWords = ["fox","dog","lazy"]) == True

assert Solution().reportSpam(message = ["hello","world","leetcode","world","hello"], bannedWords = ["world","hello"]) == True

assert Solution().reportSpam(message = ["test","test","test","test","test"], bannedWords = ["test","example","case"]) == True

assert Solution().reportSpam(message = ["python","java","python"], bannedWords = ["python","ruby"]) == True

assert Solution().reportSpam(message = ["one","two","three","four","five","six","seven","eight","nine","ten"], bannedWords = ["one","two","three","four","five"]) == True

assert Solution().reportSpam(message = ["happy","birthday","to","you"], bannedWords = ["birthday","to","you","happy"]) == True

assert Solution().reportSpam(message = ["one","two","three","four","five"], bannedWords = ["two","three","four","five"]) == True

assert Solution().reportSpam(message = ["spam","egg","ham","spam","egg","ham","spam"], bannedWords = ["spam","egg","ham"]) == True

assert Solution().reportSpam(message = ["hello","world","this","is","a","test"], bannedWords = ["test","sample","example"]) == False

assert Solution().reportSpam(message = ["python","java","c++","java"], bannedWords = ["java","swift"]) == True

assert Solution().reportSpam(message = ["spam","spam","eggs"], bannedWords = ["spam","bacon","eggs"]) == True

assert Solution().reportSpam(message = ["secure","your","data","with","encryption"], bannedWords = ["data","with","secure"]) == True

assert Solution().reportSpam(message = ["spam","eggs","ham","spam"], bannedWords = ["spam","bacon"]) == True

assert Solution().reportSpam(message = ["alice","bob","charlie","david","eve"], bannedWords = ["bob","charlie","frank"]) == True

assert Solution().reportSpam(message = ["unique","words","here","no","matches"], bannedWords = ["match","found","here"]) == False

assert Solution().reportSpam(message = ["python","java","c++","python"], bannedWords = ["ruby","go","c++","python"]) == True

assert Solution().reportSpam(message = ["algorithm","data","structure","algorithm"], bannedWords = ["data","algorithm","structure","code"]) == True

assert Solution().reportSpam(message = ["one","two","three","four","five","six"], bannedWords = ["one","two","three","four","five"]) == True

assert Solution().reportSpam(message = ["repeat","repeat","repeat","repeat"], bannedWords = ["repeat","duplicate"]) == True

assert Solution().reportSpam(message = ["programming","is","fun","and","challenging"], bannedWords = ["boring","difficult"]) == False

assert Solution().reportSpam(message = ["spam","is","bad","spam"], bannedWords = ["spam","junk","garbage"]) == True

assert Solution().reportSpam(message = ["python","java","python","java"], bannedWords = ["c","c++","java","python"]) == True

assert Solution().reportSpam(message = ["apple","banana","cherry","apple","banana"], bannedWords = ["banana","cherry","apple"]) == True

assert Solution().reportSpam(message = ["hello","world","leetcode"], bannedWords = ["leetcode","world","hello","code"]) == True

assert Solution().reportSpam(message = ["algorithm","data","structure","algorithm","data"], bannedWords = ["algorithm","graph","tree","data"]) == True

assert Solution().reportSpam(message = ["apple","banana","apple","cherry"], bannedWords = ["banana","cherry","apple"]) == True

assert Solution().reportSpam(message = ["first","second","third","fourth","fifth"], bannedWords = ["third","fourth","fifth","sixth"]) == True

assert Solution().reportSpam(message = ["spam","eggs","spam","ham"], bannedWords = ["spam","bacon","eggs"]) == True

assert Solution().reportSpam(message = ["python","java","python","c++","java"], bannedWords = ["java","python","c#"]) == True

assert Solution().reportSpam(message = ["cat","dog","bird","fish"], bannedWords = ["dog","fish","cat","bird"]) == True

assert Solution().reportSpam(message = ["repeat","repeat","repeat","repeat"], bannedWords = ["repeat","again","once"]) == True

assert Solution().reportSpam(message = ["cat","dog","bird","cat","dog"], bannedWords = ["cat","dog","fish"]) == True

assert Solution().reportSpam(message = ["repeat","repeat","repeat","unique"], bannedWords = ["repeat","distinct","clone"]) == True

assert Solution().reportSpam(message = ["data","science","machine","learning"], bannedWords = ["deep","learning","data"]) == True

assert Solution().reportSpam(message = ["lets","play","some","games"], bannedWords = ["play","games","watch"]) == True

assert Solution().reportSpam(message = ["one","two","three","four","five","six","seven","eight","nine","ten"], bannedWords = ["three","six","nine"]) == True

assert Solution().reportSpam(message = ["hello","world","leetcode","programming"], bannedWords = ["world","programming","leetcode"]) == True

assert Solution().reportSpam(message = ["spam","spam","spam","spam"], bannedWords = ["ham","spam","eggs"]) == True

assert Solution().reportSpam(message = ["hello","world"], bannedWords = ["hello","world","hello","world"]) == True

assert Solution().reportSpam(message = ["one","two","three","four","five","six"], bannedWords = ["one","three","five","seven","nine"]) == True

assert Solution().reportSpam(message = ["hello","world","hello","world","hello"], bannedWords = ["hello","world","test"]) == True

assert Solution().reportSpam(message = ["spam","is","bad","for","health"], bannedWords = ["spam","junk","rubbish"]) == False

assert Solution().reportSpam(message = ["a","b","c","d","e","f","g","h","i","j"], bannedWords = ["a","b","c"]) == True

assert Solution().reportSpam(message = ["test","test","test","test"], bannedWords = ["test","example","case"]) == True

assert Solution().reportSpam(message = ["hello","world","hello","world"], bannedWords = ["hello","world","goodbye"]) == True

assert Solution().reportSpam(message = ["coding","is","awesome"], bannedWords = ["coding","programming","hacking"]) == False

assert Solution().reportSpam(message = ["longwordexample","anotherlongword","shortword","averylongwordindeed"], bannedWords = ["longwordexample","averylongwordindeed"]) == True

assert Solution().reportSpam(message = ["one","two","three","four","five"], bannedWords = ["four","six","seven"]) == False

assert Solution().reportSpam(message = ["red","blue","green","yellow"], bannedWords = ["blue","green","purple"]) == True

assert Solution().reportSpam(message = ["unique","words","only"], bannedWords = ["different","words","unique"]) == True

assert Solution().reportSpam(message = ["hello","world","this","is","a","test"], bannedWords = ["hello","test","example"]) == True

assert Solution().reportSpam(message = ["unique","words","only","here"], bannedWords = ["not","here","any"]) == False

assert Solution().reportSpam(message = ["python","java","c++","python"], bannedWords = ["python","java","c#"]) == True

assert Solution().reportSpam(message = ["hello","world","hello","world"], bannedWords = ["world","hello","code"]) == True

assert Solution().reportSpam(message = ["repeat","repeat","repeat","repeat","repeat"], bannedWords = ["repeat","different","words"]) == True

assert Solution().reportSpam(message = ["banana","apple","cherry","mango","pineapple","kiwi"], bannedWords = ["banana","apple","cherry","mango","pineapple"]) == True

assert Solution().reportSpam(message = ["abcdef","ghijkl","mnopqr","stuvwx","yz"], bannedWords = ["mnopqr","stuvwx","yz","abcdef"]) == True

assert Solution().reportSpam(message = ["optimize","code","efficiency","optimize"], bannedWords = ["optimize","performance","speed"]) == True

assert Solution().reportSpam(message = ["unique","words","only","here"], bannedWords = ["not","here","found","words","unique"]) == True

assert Solution().reportSpam(message = ["python","java","c++","java","python"], bannedWords = ["java","python","swift"]) == True

assert Solution().reportSpam(message = ["hello","world","leetcode","hello"], bannedWords = ["world","hello"]) == True

assert Solution().reportSpam(message = ["hello","world","hello","world"], bannedWords = ["hello","world"]) == True

assert Solution().reportSpam(message = ["algorithm","data","structure","code"], bannedWords = ["code","data","algorithm","structure"]) == True

assert Solution().reportSpam(message = ["find","me","if","you","can"], bannedWords = ["me","can","find","you","if"]) == True

assert Solution().reportSpam(message = ["fast","and","furious"], bannedWords = ["slow","steady","fast"]) == False

assert Solution().reportSpam(message = ["spam","ham","eggs","spam","eggs","spam"], bannedWords = ["spam","eggs","bacon"]) == True

assert Solution().reportSpam(message = ["quick","brown","fox","jumps","over","lazy","dog"], bannedWords = ["quick","lazy","cat","dog"]) == True

Answer: assert Solution().reportSpam(message = ["spam","egg","ham"], bannedWords = ["spam","bacon","egg"]) == True

Answer: assert Solution().reportSpam(message = ["spam","eggs","spam"], bannedWords = ["spam"]) == True

Answer: assert Solution().reportSpam(message = ["spam","spam","spam"], bannedWords = ["spam"]) == True

Answer: assert Solution().reportSpam(message = ["spam","egg","spam"], bannedWords = ["spam"]) == True

Answer: assert Solution().reportSpam(message = ["python","java","c++"], bannedWords = ["ruby","swift"]) == False

Answer: assert Solution().reportSpam(message = ["python","java","c++"], bannedWords = ["java","c#","ruby"]) == False

Answer: assert Solution().reportSpam(message = ["hello","programming","fun"], bannedWords = ["world","programming","leetcode"]) == False

Answer: assert Solution().reportSpam(message = ["a","b","c","d","e"], bannedWords = ["a","b"]) == True

Answer: assert Solution().reportSpam(message = ["apple","banana","cherry"], bannedWords = ["date","fig","grape"]) == False

Answer: assert Solution().reportSpam(message = ["code","is","fun"], bannedWords = ["code","cool"]) == False

Answer: assert Solution().reportSpam(message = ["apple","banana","cherry"], bannedWords = ["mango","pineapple"]) == False

Answer: assert Solution().reportSpam(message = ["coding","is","fun"], bannedWords = ["fun","coding","is","cool"]) == True

Answer: assert Solution().reportSpam(message = ["code","code","code"], bannedWords = ["code"]) == True

Answer: assert Solution().reportSpam(message = ["python","java","c++"], bannedWords = ["ruby","go","swift"]) == False

Answer: assert Solution().reportSpam(message = ["hello","world","leetcode"], bannedWords = ["world","hello"]) == True

Answer: assert Solution().reportSpam(message = ["python","java","c++"], bannedWords = ["ruby","go"]) == False

Answer: assert Solution().reportSpam(message = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o"], bannedWords = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o"]) == True

Answer: assert Solution().reportSpam(message = ["python","java","c++","python","java"], bannedWords = ["python","java","c#"]) == True

Answer: assert Solution().reportSpam(message = ["python","java","c++","java"], bannedWords = ["java","c#","swift"]) == True

Answer: assert Solution().reportSpam(message = ["one","two","three","four","five"], bannedWords = ["three","four","five","six"]) == True

Answer: assert Solution().reportSpam(message = ["python","java","c++","ruby","go","swift"], bannedWords = ["python","swift","java","c++","go","ruby"]) == True

Answer: assert Solution().reportSpam(message = ["same","same","same","different","same"], bannedWords = ["same","different"]) == True

Answer: assert Solution().reportSpam(message = ["coding","fun","coding","learning"], bannedWords = ["coding","fun","hello"]) == True

Answer: assert Solution().reportSpam(message = ["cat","dog","mouse","cat"], bannedWords = ["dog","cat","bird"]) == True

Answer: assert Solution().reportSpam(message = ["this","is","a","test","case"], bannedWords = ["test","case","example","input"]) == True

Answer: assert Solution().reportSpam(message = ["short","longer","words","in","the","message"], bannedWords = ["longer","words","phrase"]) == True

Answer: assert Solution().reportSpam(message = ["unique","words","only","here"], bannedWords = ["duplicate","words","overlap"]) == False

Answer: assert Solution().reportSpam(message = ["hello","world","hello","world"], bannedWords = ["hello","world","programming"]) == True

Answer: assert Solution().reportSpam(message = ["data","science","machine","learning"], bannedWords = ["data","science"]) == True

Answer: assert Solution().reportSpam(message = ["apple","banana","cherry","date","elderberry","fig","grape"], bannedWords = ["apple","banana","cherry","date","elderberry","fig","grape","honeydew"]) == True

Answer: assert Solution().reportSpam(message = ["a","b","c","d","e","f","g","h","i","j"], bannedWords = ["a","b","c","d","e","f","g","h","i","j"]) == True

Answer: assert Solution().reportSpam(message = ["test","test","test","test"], bannedWords = ["test","example","sample"]) == True

Answer: assert Solution().reportSpam(message = ["hello","hello","hello","hello"], bannedWords = ["world","hello","programming"]) == True

Answer: assert Solution().reportSpam(message = ["example","test","case","example","test"], bannedWords = ["example","test","case","input"]) == True

Answer: assert Solution().reportSpam(message = ["python","programming","code","python"], bannedWords = ["python","java","c++"]) == True

Answer: assert Solution().reportSpam(message = ["data","science","and","ai"], bannedWords = ["ai","machine","learning"]) == False

Answer: assert Solution().reportSpam(message = ["one","two","three","four","five"], bannedWords = ["one","two","three","four","five"]) == True

Answer: assert Solution().reportSpam(message = ["lets","go","for","a","walk","in","the","park"], bannedWords = ["walk","run","jog"]) == False

Answer: assert Solution().reportSpam(message = ["coding","python","java","coding"], bannedWords = ["java","coding","ruby"]) == True

Answer: assert Solution().reportSpam(message = ["quick","brown","fox","jumps","over","lazy","dog"], bannedWords = ["fox","dog","lazy"]) == True

Answer: assert Solution().reportSpam(message = ["hello","world","leetcode","world","hello"], bannedWords = ["world","hello"]) == True

Answer: assert Solution().reportSpam(message = ["test","test","test","test","test"], bannedWords = ["test","example","case"]) == True

Answer: assert Solution().reportSpam(message = ["python","java","python"], bannedWords = ["python","ruby"]) == True

Answer: assert Solution().reportSpam(message = ["one","two","three","four","five","six","seven","eight","nine","ten"], bannedWords = ["one","two","three","four","five"]) == True

Answer: assert Solution().reportSpam(message = ["happy","birthday","to","you"], bannedWords = ["birthday","to","you","happy"]) == True

Answer: assert Solution().reportSpam(message = ["one","two","three","four","five"], bannedWords = ["two","three","four","five"]) == True

Answer: assert Solution().reportSpam(message = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"], bannedWords = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]) == True

Answer: assert Solution().reportSpam(message = ["spam","egg","ham","spam","egg","ham","spam"], bannedWords = ["spam","egg","ham"]) == True

Answer: assert Solution().reportSpam(message = ["hello","world","this","is","a","test"], bannedWords = ["test","sample","example"]) == False

Answer: assert Solution().reportSpam(message = ["python","java","c++","java"], bannedWords = ["java","swift"]) == True

Answer: assert Solution().reportSpam(message = ["spam","spam","eggs"], bannedWords = ["spam","bacon","eggs"]) == True

Answer: assert Solution().reportSpam(message = ["secure","your","data","with","encryption"], bannedWords = ["data","with","secure"]) == True

Answer: assert Solution().reportSpam(message = ["spam","eggs","ham","spam"], bannedWords = ["spam","bacon"]) == True

Answer: assert Solution().reportSpam(message = ["alice","bob","charlie","david","eve"], bannedWords = ["bob","charlie","frank"]) == True

Answer: assert Solution().reportSpam(message = ["unique","words","here","no","matches"], bannedWords = ["match","found","here"]) == False

Answer: assert Solution().reportSpam(message = ["python","java","c++","python"], bannedWords = ["ruby","go","c++","python"]) == True

Answer: assert Solution().reportSpam(message = ["algorithm","data","structure","algorithm"], bannedWords = ["data","algorithm","structure","code"]) == True

Answer: assert Solution().reportSpam(message = ["one","two","three","four","five","six"], bannedWords = ["one","two","three","four","five"]) == True

Answer: assert Solution().reportSpam(message = ["repeat","repeat","repeat","repeat"], bannedWords = ["repeat","duplicate"]) == True

Answer: assert Solution().reportSpam(message = ["programming","is","fun","and","challenging"], bannedWords = ["boring","difficult"]) == False

Answer: assert Solution().reportSpam(message = ["spam","is","bad","spam"], bannedWords = ["spam","junk","garbage"]) == True

Answer: assert Solution().reportSpam(message = ["python","java","python","java"], bannedWords = ["c","c++","java","python"]) == True

Answer: assert Solution().reportSpam(message = ["apple","banana","cherry","apple","banana"], bannedWords = ["banana","cherry","apple"]) == True

Answer: assert Solution().reportSpam(message = ["hello","world","leetcode"], bannedWords = ["leetcode","world","hello","code"]) == True

Answer: assert Solution().reportSpam(message = ["algorithm","data","structure","algorithm","data"], bannedWords = ["algorithm","graph","tree","data"]) == True

Answer: assert Solution().reportSpam(message = ["apple","banana","apple","cherry"], bannedWords = ["banana","cherry","apple"]) == True

Answer: assert Solution().reportSpam(message = ["first","second","third","fourth","fifth"], bannedWords = ["third","fourth","fifth","sixth"]) == True

Answer: assert Solution().reportSpam(message = ["spam","eggs","spam","ham"], bannedWords = ["spam","bacon","eggs"]) == True

Answer: assert Solution().reportSpam(message = ["python","java","python","c++","java"], bannedWords = ["java","python","c#"]) == True

Answer: assert Solution().reportSpam(message = ["cat","dog","bird","fish"], bannedWords = ["dog","fish","cat","bird"]) == True

Answer: assert Solution().reportSpam(message = ["repeat","repeat","repeat","repeat"], bannedWords = ["repeat","again","once"]) == True

Answer: assert Solution().reportSpam(message = ["cat","dog","bird","cat","dog"], bannedWords = ["cat","dog","fish"]) == True

Answer: assert Solution().reportSpam(message = ["repeat","repeat","repeat","unique"], bannedWords = ["repeat","distinct","clone"]) == True

Answer: assert Solution().reportSpam(message = ["data","science","machine","learning"], bannedWords = ["deep","learning","data"]) == True

Answer: assert Solution().reportSpam(message = ["lets","play","some","games"], bannedWords = ["play","games","watch"]) == True

Answer: assert Solution().reportSpam(message = ["one","two","three","four","five","six","seven","eight","nine","ten"], bannedWords = ["three","six","nine"]) == True

Answer: assert Solution().reportSpam(message = ["hello","world","leetcode","programming"], bannedWords = ["world","programming","leetcode"]) == True

Answer: assert Solution().reportSpam(message = ["spam","spam","spam","spam"], bannedWords = ["ham","spam","eggs"]) == True

Answer: assert Solution().reportSpam(message = ["hello","world"], bannedWords = ["hello","world","hello","world"]) == True

Answer: assert Solution().reportSpam(message = ["one","two","three","four","five","six"], bannedWords = ["one","three","five","seven","nine"]) == True

Answer: assert Solution().reportSpam(message = ["hello","world","hello","world","hello"], bannedWords = ["hello","world","test"]) == True

Answer: assert Solution().reportSpam(message = ["spam","is","bad","for","health"], bannedWords = ["spam","junk","rubbish"]) == False

Answer: assert Solution().reportSpam(message = ["a","b","c","d","e","f","g","h","i","j"], bannedWords = ["a","b","c"]) == True

Answer: assert Solution().reportSpam(message = ["test","test","test","test"], bannedWords = ["test","example","case"]) == True

Answer: assert Solution().reportSpam(message = ["hello","world","hello","world"], bannedWords = ["hello","world","goodbye"]) == True

Answer: assert Solution().reportSpam(message = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"], bannedWords = ["a","b","c","d","e"]) == True

Answer: assert Solution().reportSpam(message = ["coding","is","awesome"], bannedWords = ["coding","programming","hacking"]) == False

Answer: assert Solution().reportSpam(message = ["longwordexample","anotherlongword","shortword","averylongwordindeed"], bannedWords = ["longwordexample","averylongwordindeed"]) == True

Answer: assert Solution().reportSpam(message = ["one","two","three","four","five"], bannedWords = ["four","six","seven"]) == False

Answer: assert Solution().reportSpam(message = ["red","blue","green","yellow"], bannedWords = ["blue","green","purple"]) == True

Answer: assert Solution().reportSpam(message = ["unique","words","only"], bannedWords = ["different","words","unique"]) == True

Answer: assert Solution().reportSpam(message = ["hello","world","this","is","a","test"], bannedWords = ["hello","test","example"]) == True

Answer: assert Solution().reportSpam(message = ["unique","words","only","here"], bannedWords = ["not","here","any"]) == False

Answer: assert Solution().reportSpam(message = ["python","java","c++","python"], bannedWords = ["python","java","c#"]) == True

Answer: assert Solution().reportSpam(message = ["hello","world","hello","world"], bannedWords = ["world","hello","code"]) == True

Answer: assert Solution().reportSpam(message = ["repeat","repeat","repeat","repeat","repeat"], bannedWords = ["repeat","different","words"]) == True

Answer: assert Solution().reportSpam(message = ["banana","apple","cherry","mango","pineapple","kiwi"], bannedWords = ["banana","apple","cherry","mango","pineapple"]) == True

Answer: assert Solution().reportSpam(message = ["abcdef","ghijkl","mnopqr","stuvwx","yz"], bannedWords = ["mnopqr","stuvwx","yz","abcdef"]) == True

Answer: assert Solution().reportSpam(message = ["optimize","code","efficiency","optimize"], bannedWords = ["optimize","performance","speed"]) == True

Answer: assert Solution().reportSpam(message = ["unique","words","only","here"], bannedWords = ["not","here","found","words","unique"]) == True

Answer: assert Solution().reportSpam(message = ["python","java","c++","java","python"], bannedWords = ["java","python","swift"]) == True

Answer: assert Solution().reportSpam(message = ["hello","world","leetcode","hello"], bannedWords = ["world","hello"]) == True

Answer: assert Solution().reportSpam(message = ["hello","world","hello","world"], bannedWords = ["hello","world"]) == True

Answer: assert Solution().reportSpam(message = ["algorithm","data","structure","code"], bannedWords = ["code","data","algorithm","structure"]) == True

Answer: assert Solution().reportSpam(message = ["find","me","if","you","can"], bannedWords = ["me","can","find","you","if"]) == True

Answer: assert Solution().reportSpam(message = ["fast","and","furious"], bannedWords = ["slow","steady","fast"]) == False

Answer: assert Solution().reportSpam(message = ["spam","ham","eggs","spam","eggs","spam"], bannedWords = ["spam","eggs","bacon"]) == True

Answer: assert Solution().reportSpam(message = ["quick","brown","fox","jumps","over","lazy","dog"], bannedWords = ["quick","lazy","cat","dog"]) == True

import random
import functools
import collections
import string
import math
import datetime

from typing import *
from functools import *
from collections import *
from itertools import *
from heapq import *
from bisect import *
from string import *
from operator import *
from math import *

inf = float('inf')

class ListNode:
    def __init__(self, val=0, next=None):
        self.val = val
        self.next = next

def list_node(values: list):
    if not values:
        return None
    head = ListNode(values[0])
    p = head
    for val in values[1:]:
        node = ListNode(val)
        p.next = node
        p = node
    return head

def is_same_list(p1, p2):
    if p1 is None and p2 is None:
        return True
    if not p1 or not p2:
        return False
    return p1.val == p2.val and is_same_list(p1.next, p2.next)

class TreeNode:
    def __init__(self, val=0, left=None, right=None):
        self.val = val
        self.left = left
        self.right = right

def tree_node(values: list):
    if not values:
        return None
    root = TreeNode(values[0])
    i = 1
    queue = deque()
    queue.append(root)
    while queue:
        node = queue.popleft()
        if i < len(values) and values[i] is not None:
            node.left = TreeNode(values[i])
            queue.append(node.left)
        i += 1
        if i < len(values) and values[i] is not None:
            node.right = TreeNode(values[i])
            queue.append(node.right)
        i += 1
    return root

def is_same_tree(p, q):
    if not p and not q:
        return True
    elif not p or not q:
        return False
    elif p.val != q.val:
        return False
    else:
        return is_same_tree(p.left, q.left) and is_same_tree(p.right, q.right)

class Solution:
    def reportSpam(self, message: List[str], bannedWords: List[str]) -> bool:
        s = set(bannedWords)
        return sum(w in s for w in message) >= 2

class Solution:
    def reportSpam(self, message: List[str], bannedWords: List[str]) -> bool:


You are an expert Python programmer. Write correct, efficient Python 3 code that solves the problem and passes all tests. Output the code in the following format: ```python
<code>
```

PROBLEM:
You are given an integer mountainHeight denoting the height of a mountain.
You are also given an integer array workerTimes representing the work time of workers in seconds.
The workers work simultaneously to reduce the height of the mountain. For worker i:

To decrease the mountain's height by x, it takes workerTimes[i] + workerTimes[i] * 2 + ... + workerTimes[i] * x seconds. For example:

To reduce the height of the mountain by 1, it takes workerTimes[i] seconds.
To reduce the height of the mountain by 2, it takes workerTimes[i] + workerTimes[i] * 2 seconds, and so on.

Return an integer representing the minimum number of seconds required for the workers to make the height of the mountain 0.

Example 1:

Input: mountainHeight = 4, workerTimes = [2,1,1]
Output: 3
Explanation:
One way the height of the mountain can be reduced to 0 is:

Worker 0 reduces the height by 1, taking workerTimes[0] = 2 seconds.
Worker 1 reduces the height by 2, taking workerTimes[1] + workerTimes[1] * 2 = 3 seconds.
Worker 2 reduces the height by 1, taking workerTimes[2] = 1 second.

Since they work simultaneously, the minimum time needed is max(2, 3, 1) = 3 seconds.

Example 2:

Input: mountainHeight = 10, workerTimes = [3,2,2,4]
Output: 12
Explanation:

Worker 0 reduces the height by 2, taking workerTimes[0] + workerTimes[0] * 2 = 9 seconds.
Worker 1 reduces the height by 3, taking workerTimes[1] + workerTimes[1] * 2 + workerTimes[1] * 3 = 12 seconds.
Worker 2 reduces the height by 3, taking workerTimes[2] + workerTimes[2] * 2 + workerTimes[2] * 3 = 12 seconds.
Worker 3 reduces the height by 2, taking workerTimes[3] + workerTimes[3] * 2 = 12 seconds.

The number of seconds needed is max(9, 12, 12, 12) = 12 seconds.

Example 3:

Input: mountainHeight = 5, workerTimes = [1]
Output: 15
Explanation:
There is only one worker in this example, so the answer is workerTimes[0] + workerTimes[0] * 2 + workerTimes[0] * 3 + workerTimes[0] * 4 + workerTimes[0] * 5 = 15.

Constraints:

1 <= mountainHeight <= 105
1 <= workerTimes.length <= 104
1 <= workerTimes[i] <= 106

Your solution to the problem should be a method of the class Solution called minNumberOfSeconds and should pass all tests. Use the following starter code:
```python
class Solution:
    def minNumberOfSeconds(self, mountainHeight: int, workerTimes: List[int]) -> int:
        # Add your code here
```

SOLUTION:

Question:
PROBLEM:
You are given an integer mountainHeight denoting the height of a mountain.
You are also given an integer array workerTimes representing the work time of workers in seconds.
The workers work simultaneously to reduce the height of the mountain. For worker i:

To decrease the mountain's height by x, it takes workerTimes[i] + workerTimes[i] * 2 + ... + workerTimes[i] * x seconds. For example:

To reduce the height of the mountain by 1, it takes workerTimes[i] seconds.
To reduce the height of the mountain by 2, it takes workerTimes[i] + workerTimes[i] * 2 seconds, and so on.

Return an integer representing the minimum number of seconds required for the workers to make the height of the mountain 0.

Example 1:

Input: mountainHeight = 4, workerTimes = [2,1,1]
Output: 3
Explanation:
One way the height of the mountain can be reduced to 0 is:

Worker 0 reduces the height by 1, taking workerTimes[0] = 2 seconds.
Worker 1 reduces the height by 2, taking workerTimes[1] + workerTimes[1] * 2 = 3 seconds.
Worker 2 reduces the height by 1, taking workerTimes[2] = 1 second.

Since they work simultaneously, the minimum time needed is max(2, 3, 1) = 3 seconds.

Example 2:

Input: mountainHeight = 10, workerTimes = [3,2,2,4]
Output: 12
Explanation:

Worker 0 reduces the height by 2, taking workerTimes[0] + workerTimes[0] * 2 = 9 seconds.
Worker 1 reduces the height by 3, taking workerTimes[1] + workerTimes[1] * 2 + workerTimes[1] * 3 = 12 seconds.
Worker 2 reduces the height by 3, taking workerTimes[2] + workerTimes[2] * 2 + workerTimes[2] * 3 = 12 seconds.
Worker 3 reduces the height by 2, taking workerTimes[3] + workerTimes[3] * 2 = 12 seconds.

The number of seconds needed is max(9, 12, 12, 12) = 12 seconds.

Example 3:

Input: mountainHeight = 5, workerTimes = [1]
Output: 15
Explanation:
There is only one worker in this example, so the answer is workerTimes[0] + workerTimes[0] * 2 + workerTimes[0] * 3 + workerTimes[0] * 4 + workerTimes[0] * 5 = 15.

Constraints:

1 <= mountainHeight <= 105
1 <= workerTimes.length <= 104
1 <= workerTimes[i] <= 106

Your solution to the problem should be a method of the class Solution called minNumberOfSeconds and should pass all tests. Use the following starter code:
```python
class Solution:
    def minNumberOfSeconds(self, mountainHeight: int, workerTimes: List[int]) -> int:
        # Add your code here
```

SOLUTION:

assert Solution().minNumberOfSeconds(mountainHeight = 15, workerTimes = [5,5,5]) == 75

assert Solution().minNumberOfSeconds(mountainHeight = 15, workerTimes = [1,2,3]) == 30

assert Solution().minNumberOfSeconds(mountainHeight = 15, workerTimes = [1,2,3,4,5]) == 18

assert Solution().minNumberOfSeconds(mountainHeight = 1, workerTimes = [100]) == 100

assert Solution().minNumberOfSeconds(mountainHeight = 50, workerTimes = [1,2,3,4,5]) == 140

assert Solution().minNumberOfSeconds(mountainHeight = 50, workerTimes = [10,20,30,40,50]) == 1400

assert Solution().minNumberOfSeconds(mountainHeight = 30, workerTimes = [3,3,3]) == 165

assert Solution().minNumberOfSeconds(mountainHeight = 100, workerTimes = [10,10,10,10]) == 3250

assert Solution().minNumberOfSeconds(mountainHeight = 100000, workerTimes = [1]) == 5000050000

assert Solution().minNumberOfSeconds(mountainHeight = 10, workerTimes = [3,2,2,4]) == 12

assert Solution().minNumberOfSeconds(mountainHeight = 5, workerTimes = [1]) == 15

assert Solution().minNumberOfSeconds(mountainHeight = 7, workerTimes = [2,3]) == 20

assert Solution().minNumberOfSeconds(mountainHeight = 1, workerTimes = [100000]) == 100000

assert Solution().minNumberOfSeconds(mountainHeight = 100, workerTimes = [1,1,1,1,1,1,1,1,1,1]) == 55

assert Solution().minNumberOfSeconds(mountainHeight = 1, workerTimes = [1000000]) == 1000000

assert Solution().minNumberOfSeconds(mountainHeight = 100, workerTimes = [1,2,3,4,5,6,7,8,9,10]) == 234

assert Solution().minNumberOfSeconds(mountainHeight = 20, workerTimes = [5,5,5]) == 140

assert Solution().minNumberOfSeconds(mountainHeight = 7, workerTimes = [7]) == 196

assert Solution().minNumberOfSeconds(mountainHeight = 30, workerTimes = [2,3,4]) == 165

assert Solution().minNumberOfSeconds(mountainHeight = 50, workerTimes = [10,20,30]) == 2720

assert Solution().minNumberOfSeconds(mountainHeight = 4, workerTimes = [2,1,1]) == 3

assert Solution().minNumberOfSeconds(mountainHeight = 20, workerTimes = [5,5,5,5]) == 75

assert Solution().minNumberOfSeconds(mountainHeight = 800, workerTimes = [100, 200, 300, 400, 500, 600, 700, 800]) == 1703000

assert Solution().minNumberOfSeconds(mountainHeight = 50, workerTimes = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 75

assert Solution().minNumberOfSeconds(mountainHeight = 100000, workerTimes = [100000, 200000, 300000]) == 95812470300000

assert Solution().minNumberOfSeconds(mountainHeight = 50, workerTimes = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 140

assert Solution().minNumberOfSeconds(mountainHeight = 300, workerTimes = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == 5673

assert Solution().minNumberOfSeconds(mountainHeight = 75000, workerTimes = [1000, 2000, 3000, 4000, 5000]) == 269335050000

assert Solution().minNumberOfSeconds(mountainHeight = 90, workerTimes = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 135

assert Solution().minNumberOfSeconds(mountainHeight = 50000, workerTimes = [50000, 25000, 10000, 5000]) == 1024120650000

assert Solution().minNumberOfSeconds(mountainHeight = 300, workerTimes = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1050

assert Solution().minNumberOfSeconds(mountainHeight = 1000, workerTimes = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == 23595

assert Solution().minNumberOfSeconds(mountainHeight = 250, workerTimes = [10000, 20000, 30000, 40000, 50000]) == 31050000

assert Solution().minNumberOfSeconds(mountainHeight = 75, workerTimes = [1000, 2000, 3000, 4000]) == 406000

assert Solution().minNumberOfSeconds(mountainHeight = 200, workerTimes = [1, 2, 4, 8, 16, 32, 64]) == 2208

assert Solution().minNumberOfSeconds(mountainHeight = 100, workerTimes = [10, 20, 30, 40, 50]) == 5250

assert Solution().minNumberOfSeconds(mountainHeight = 50, workerTimes = [1000, 2000, 3000, 4000, 5000]) == 140000

assert Solution().minNumberOfSeconds(mountainHeight = 200, workerTimes = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 210

assert Solution().minNumberOfSeconds(mountainHeight = 30, workerTimes = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == 90

assert Solution().minNumberOfSeconds(mountainHeight = 75, workerTimes = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70]) == 980

assert Solution().minNumberOfSeconds(mountainHeight = 200, workerTimes = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 8610

assert Solution().minNumberOfSeconds(mountainHeight = 200, workerTimes = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 55

assert Solution().minNumberOfSeconds(mountainHeight = 600, workerTimes = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 465

assert Solution().minNumberOfSeconds(mountainHeight = 75000, workerTimes = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 257157181

assert Solution().minNumberOfSeconds(mountainHeight = 100, workerTimes = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 55

assert Solution().minNumberOfSeconds(mountainHeight = 50, workerTimes = [10, 20, 30, 40, 50]) == 1400

assert Solution().minNumberOfSeconds(mountainHeight = 200, workerTimes = [1, 10, 100, 1000, 10000]) == 9900

assert Solution().minNumberOfSeconds(mountainHeight = 80, workerTimes = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 252

assert Solution().minNumberOfSeconds(mountainHeight = 100, workerTimes = [5, 10, 15, 20]) == 3465

assert Solution().minNumberOfSeconds(mountainHeight = 1000, workerTimes = [500, 400, 300, 200, 100]) == 4833000

assert Solution().minNumberOfSeconds(mountainHeight = 75, workerTimes = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 280

assert Solution().minNumberOfSeconds(mountainHeight = 50, workerTimes = [5, 15, 25, 35]) == 1260

assert Solution().minNumberOfSeconds(mountainHeight = 100, workerTimes = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 1170

assert Solution().minNumberOfSeconds(mountainHeight = 99, workerTimes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 153

assert Solution().minNumberOfSeconds(mountainHeight = 1000, workerTimes = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 202000

assert Solution().minNumberOfSeconds(mountainHeight = 120, workerTimes = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 3300

assert Solution().minNumberOfSeconds(mountainHeight = 30000, workerTimes = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 178622640

assert Solution().minNumberOfSeconds(mountainHeight = 99999, workerTimes = [99999]) == 499990000050000

assert Solution().minNumberOfSeconds(mountainHeight = 300, workerTimes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 1200

assert Solution().minNumberOfSeconds(mountainHeight = 100, workerTimes = [5, 10, 15, 20, 25]) == 2625

assert Solution().minNumberOfSeconds(mountainHeight = 75, workerTimes = [7, 14, 21, 28, 35, 42, 49]) == 1470

assert Solution().minNumberOfSeconds(mountainHeight = 200, workerTimes = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 4305

assert Solution().minNumberOfSeconds(mountainHeight = 100000, workerTimes = [1, 1, 1, 1, 1]) == 200010000

assert Solution().minNumberOfSeconds(mountainHeight = 500, workerTimes = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 650

assert Solution().minNumberOfSeconds(mountainHeight = 20000, workerTimes = [300, 200, 150, 100, 50]) == 981466500

assert Solution().minNumberOfSeconds(mountainHeight = 200, workerTimes = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 630

assert Solution().minNumberOfSeconds(mountainHeight = 50, workerTimes = [1, 10, 100, 1000, 10000]) == 666

assert Solution().minNumberOfSeconds(mountainHeight = 50000, workerTimes = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 5559445

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 15, workerTimes = [5,5,5]) == 75

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 15, workerTimes = [1,2,3]) == 30

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 15, workerTimes = [1,2,3,4,5]) == 18

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 1, workerTimes = [100]) == 100

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 50, workerTimes = [1,2,3,4,5]) == 140

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 50, workerTimes = [10,20,30,40,50]) == 1400

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 30, workerTimes = [3,3,3]) == 165

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 100, workerTimes = [10,10,10,10]) == 3250

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 100000, workerTimes = [1]) == 5000050000

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 10, workerTimes = [3,2,2,4]) == 12

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 5, workerTimes = [1]) == 15

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 7, workerTimes = [2,3]) == 20

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 1, workerTimes = [100000]) == 100000

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 100, workerTimes = [1,1,1,1,1,1,1,1,1,1]) == 55

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 1, workerTimes = [1000000]) == 1000000

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 100, workerTimes = [1,2,3,4,5,6,7,8,9,10]) == 234

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 20, workerTimes = [5,5,5]) == 140

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 7, workerTimes = [7]) == 196

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 30, workerTimes = [2,3,4]) == 165

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 50, workerTimes = [10,20,30]) == 2720

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 4, workerTimes = [2,1,1]) == 3

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 20, workerTimes = [5,5,5,5]) == 75

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 500, workerTimes = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500]) == 257550

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 800, workerTimes = [100, 200, 300, 400, 500, 600, 700, 800]) == 1703000

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 50, workerTimes = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 75

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 100000, workerTimes = [100000, 200000, 300000]) == 95812470300000

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 50, workerTimes = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 140

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 50000, workerTimes = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == 49602375000

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 300, workerTimes = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == 5673

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 75000, workerTimes = [1000, 2000, 3000, 4000, 5000]) == 269335050000

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 90, workerTimes = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 135

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 50000, workerTimes = [50000, 25000, 10000, 5000]) == 1024120650000

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 99999, workerTimes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 54452541

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 300, workerTimes = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1050

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 7500, workerTimes = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 111826000

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 30000, workerTimes = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 210504421

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 1000, workerTimes = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == 23595

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 250, workerTimes = [10000, 20000, 30000, 40000, 50000]) == 31050000

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 120, workerTimes = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]) == 1100

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 400, workerTimes = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000]) == 33210000

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 10000, workerTimes = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192]) == 8794190

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 75, workerTimes = [1000, 2000, 3000, 4000]) == 406000

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 200, workerTimes = [1, 2, 4, 8, 16, 32, 64]) == 2208

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 100, workerTimes = [10, 20, 30, 40, 50]) == 5250

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 120000, workerTimes = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536]) == 621255624

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 50, workerTimes = [1000, 2000, 3000, 4000, 5000]) == 140000

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 15000, workerTimes = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == 4468554000

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 200, workerTimes = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 210

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 30000, workerTimes = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 17662788

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 300, workerTimes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == 2601

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 120, workerTimes = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 22000

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 90000, workerTimes = [100, 150, 200, 250, 300, 350, 400, 450, 500]) == 12526645950

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 30, workerTimes = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == 90

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 75, workerTimes = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70]) == 980

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 65000, workerTimes = [500, 400, 300, 200, 100, 50, 25, 10, 5, 1]) == 358439550

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 200, workerTimes = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 8610

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 10000, workerTimes = [999999, 999998, 999997, 999996, 999995]) == 2000997999000

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 300, workerTimes = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == 1891000

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 300, workerTimes = [50, 40, 30, 20, 10, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == 5775

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 200, workerTimes = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 55

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 600, workerTimes = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 465

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 75000, workerTimes = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 257157181

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 45000, workerTimes = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 246276030

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 100, workerTimes = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 55

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 50000, workerTimes = [100000, 50000, 25000, 12500, 6250]) == 989124000000

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 80000, workerTimes = [999999, 888888, 777777, 666666, 555555, 444444, 333333, 222222, 111111]) == 16066085933898

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 5000, workerTimes = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 2183000

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 50, workerTimes = [10, 20, 30, 40, 50]) == 1400

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 10000, workerTimes = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == 1987020000

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 200, workerTimes = [1, 10, 100, 1000, 10000]) == 9900

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 80, workerTimes = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 252

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 1000, workerTimes = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 20100

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 45000, workerTimes = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200]) == 3217223100

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 7500, workerTimes = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 4895150

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 100, workerTimes = [5, 10, 15, 20]) == 3465

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 1000, workerTimes = [500, 400, 300, 200, 100]) == 4833000

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 800, workerTimes = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 1296000

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 1000, workerTimes = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 595

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 75, workerTimes = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 280

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 50, workerTimes = [5, 15, 25, 35]) == 1260

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 50, workerTimes = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 4800

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 100, workerTimes = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 1170

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 99, workerTimes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 153

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 1000, workerTimes = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 202000

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 120, workerTimes = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 3300

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 90000, workerTimes = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == 140466750

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 30000, workerTimes = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 178622640

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 99999, workerTimes = [99999]) == 499990000050000

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 100000, workerTimes = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 1250250000000

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 300, workerTimes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 1200

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 5000, workerTimes = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 1091500

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 90, workerTimes = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == 196000

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 100, workerTimes = [5, 10, 15, 20, 25]) == 2625

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 150, workerTimes = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 495

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 60000, workerTimes = [10000, 15000, 20000, 25000, 30000]) == 1291626280000

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 25000, workerTimes = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 1240518000

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 80000, workerTimes = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 31747590

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 100000, workerTimes = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 12502500

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 75, workerTimes = [7, 14, 21, 28, 35, 42, 49]) == 1470

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 200, workerTimes = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 4305

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 500, workerTimes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == 5456

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 25000, workerTimes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 5425125

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 100000, workerTimes = [1, 1, 1, 1, 1]) == 200010000

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 500, workerTimes = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000]) == 51510000

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 90000, workerTimes = [90000, 45000, 30000, 22500, 18000, 15000, 12857, 11250, 10000, 9000, 8182, 7500, 7000, 6667, 6316, 6000, 5714, 5455, 5217, 5000]) == 99351014202

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 500, workerTimes = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 650

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 600, workerTimes = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 41000

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 1000, workerTimes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 8976

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 80000, workerTimes = [80000, 40000, 20000, 10000, 5000, 2500, 1250, 625, 312, 156, 78, 39, 19, 9, 4, 2, 1]) == 292563920

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 80000, workerTimes = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 40010000

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 20000, workerTimes = [300, 200, 150, 100, 50]) == 981466500

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 200, workerTimes = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 630

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 250, workerTimes = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 133200

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 50000, workerTimes = [1000000, 500000, 250000, 125000, 62500]) == 9891240000000

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 50, workerTimes = [1, 10, 100, 1000, 10000]) == 666

Answer: assert Solution().minNumberOfSeconds(mountainHeight = 50000, workerTimes = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 5559445

import random
import functools
import collections
import string
import math
import datetime

from typing import *
from functools import *
from collections import *
from itertools import *
from heapq import *
from bisect import *
from string import *
from operator import *
from math import *

inf = float('inf')

class ListNode:
    def __init__(self, val=0, next=None):
        self.val = val
        self.next = next

def list_node(values: list):
    if not values:
        return None
    head = ListNode(values[0])
    p = head
    for val in values[1:]:
        node = ListNode(val)
        p.next = node
        p = node
    return head

def is_same_list(p1, p2):
    if p1 is None and p2 is None:
        return True
    if not p1 or not p2:
        return False
    return p1.val == p2.val and is_same_list(p1.next, p2.next)

class TreeNode:
    def __init__(self, val=0, left=None, right=None):
        self.val = val
        self.left = left
        self.right = right

def tree_node(values: list):
    if not values:
        return None
    root = TreeNode(values[0])
    i = 1
    queue = deque()
    queue.append(root)
    while queue:
        node = queue.popleft()
        if i < len(values) and values[i] is not None:
            node.left = TreeNode(values[i])
            queue.append(node.left)
        i += 1
        if i < len(values) and values[i] is not None:
            node.right = TreeNode(values[i])
            queue.append(node.right)
        i += 1
    return root

def is_same_tree(p, q):
    if not p and not q:
        return True
    elif not p or not q:
        return False
    elif p.val != q.val:
        return False
    else:
        return is_same_tree(p.left, q.left) and is_same_tree(p.right, q.right)

class Solution:
    def minNumberOfSeconds(self, mountainHeight: int, workerTimes: List[int]) -> int:
        def check(t: int) -> bool:
            h = 0
            for wt in workerTimes:
                h += int(sqrt(2 * t / wt + 1 / 4) - 1 / 2)
            return h >= mountainHeight

        return bisect_left(range(10**16), True, key=check)


You are an expert Python programmer. Write correct, efficient Python 3 code that solves the problem and passes all tests. Output the code in the following format: ```python
<code>
```

PROBLEM:
You are given two strings word1 and word2.
A string x is called valid if x can be rearranged to have word2 as a prefix.
Return the total number of valid substrings of word1.
Note that the memory limits in this problem are smaller than usual, so you must implement a solution with a linear runtime complexity.

Example 1:

Input: word1 = "bcca", word2 = "abc"
Output: 1
Explanation:
The only valid substring is "bcca" which can be rearranged to "abcc" having "abc" as a prefix.

Example 2:

Input: word1 = "abcabc", word2 = "abc"
Output: 10
Explanation:
All the substrings except substrings of size 1 and size 2 are valid.

Example 3:

Input: word1 = "abcabc", word2 = "aaabc"
Output: 0

Constraints:

1 <= word1.length <= 106
1 <= word2.length <= 104
word1 and word2 consist only of lowercase English letters.

Your solution to the problem should be a method of the class Solution called validSubstringCount and should pass all tests. Use the following starter code:
```python
class Solution:
    def validSubstringCount(self, word1: str, word2: str) -> int:
        # Add your code here
```

SOLUTION:

Question:
PROBLEM:
You are given two strings word1 and word2.
A string x is called valid if x can be rearranged to have word2 as a prefix.
Return the total number of valid substrings of word1.
Note that the memory limits in this problem are smaller than usual, so you must implement a solution with a linear runtime complexity.

Example 1:

Input: word1 = "bcca", word2 = "abc"
Output: 1
Explanation:
The only valid substring is "bcca" which can be rearranged to "abcc" having "abc" as a prefix.

Example 2:

Input: word1 = "abcabc", word2 = "abc"
Output: 10
Explanation:
All the substrings except substrings of size 1 and size 2 are valid.

Example 3:

Input: word1 = "abcabc", word2 = "aaabc"
Output: 0

Constraints:

1 <= word1.length <= 106
1 <= word2.length <= 104
word1 and word2 consist only of lowercase English letters.

Your solution to the problem should be a method of the class Solution called validSubstringCount and should pass all tests. Use the following starter code:
```python
class Solution:
    def validSubstringCount(self, word1: str, word2: str) -> int:
        # Add your code here
```

SOLUTION:

assert Solution().validSubstringCount(word1 = "bcca", word2 = "abc") == 1

assert Solution().validSubstringCount(word1 = "abcdefghijklmnopqrstuvwxyz", word2 = "zyxwvutsrqponmlkjihgfedcba") == 1

assert Solution().validSubstringCount(word1 = "aabbcc", word2 = "abc") == 4

assert Solution().validSubstringCount(word1 = "abcabcabcabc", word2 = "abcabc") == 28

assert Solution().validSubstringCount(word1 = "hellothere", word2 = "oth") == 21

assert Solution().validSubstringCount(word1 = "abcabc", word2 = "aaabc") == 0

assert Solution().validSubstringCount(word1 = "aaaaaaa", word2 = "a") == 28

assert Solution().validSubstringCount(word1 = "abcabc", word2 = "abc") == 10

assert Solution().validSubstringCount(word1 = "mississippi", word2 = "issi") == 27

assert Solution().validSubstringCount(word1 = "teststring", word2 = "ttt") == 5

assert Solution().validSubstringCount(word1 = "abcabcabcabcabcabcabcabcabcabc", word2 = "abcabc") == 325

assert Solution().validSubstringCount(word1 = "abacabadabacabadabacabadabacabad", word2 = "abacabad") == 325

assert Solution().validSubstringCount(word1 = "aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz", word2 = "mnopqrstuv") == 260

assert Solution().validSubstringCount(word1 = "hellohellohellohellohello", word2 = "hello") == 231

assert Solution().validSubstringCount(word1 = "xyzyzyzyzyzyzyzyzy", word2 = "zyx") == 16

assert Solution().validSubstringCount(word1 = "cccccccaaaaaaaabbbbbbb", word2 = "abc") == 49

assert Solution().validSubstringCount(word1 = "hellohellohellohello", word2 = "lohel") == 136

assert Solution().validSubstringCount(word1 = "abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc", word2 = "abcabcabc") == 1225

assert Solution().validSubstringCount(word1 = "xyzzxyzzxyzz", word2 = "zzxy") == 45

assert Solution().validSubstringCount(word1 = "abcdefghijabcdefghijabcdefghij", word2 = "abcdefghij") == 231

assert Solution().validSubstringCount(word1 = "abcabcabcabcabcabcabc", word2 = "abcabc") == 136

assert Solution().validSubstringCount(word1 = "longstringwithmanyvowelsaeiou", word2 = "aeiou") == 25

assert Solution().validSubstringCount(word1 = "aaaabbbbcccc", word2 = "bbbaaccc") == 6

assert Solution().validSubstringCount(word1 = "abcdabcdabcdabcd", word2 = "dcba") == 91

assert Solution().validSubstringCount(word1 = "patternpatternpattern", word2 = "ternpat") == 120

assert Solution().validSubstringCount(word1 = "xyxyxyxyxyxyxyxyxyxyxyxyxyxyxy", word2 = "xyxyxyxy") == 276

assert Solution().validSubstringCount(word1 = "abracadabra", word2 = "abra") == 25

assert Solution().validSubstringCount(word1 = "abababababababababababab", word2 = "ab") == 276

assert Solution().validSubstringCount(word1 = "xyzabcdexyzabcdef", word2 = "abcdef") == 12

assert Solution().validSubstringCount(word1 = "xzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzy", word2 = "xzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzy") == 325

assert Solution().validSubstringCount(word1 = "bbaaccdd", word2 = "abcd") == 4

assert Solution().validSubstringCount(word1 = "thisisanotherexample", word2 = "another") == 61

assert Solution().validSubstringCount(word1 = "aabbaabbaabbaabb", word2 = "aabb") == 91

assert Solution().validSubstringCount(word1 = "banana", word2 = "nan") == 6

assert Solution().validSubstringCount(word1 = "abcdefghijabcdefghij", word2 = "jihgfedcba") == 66

assert Solution().validSubstringCount(word1 = "hellohellohello", word2 = "hello") == 66

assert Solution().validSubstringCount(word1 = "aaaaaabbbbccccdddd", word2 = "bbbcccdddd") == 8

assert Solution().validSubstringCount(word1 = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz", word2 = "abcdefghijklmnopqrstuvwxyz") == 378

assert Solution().validSubstringCount(word1 = "mnopqrlmnopqrlmnopqr", word2 = "mnopqr") == 108

assert Solution().validSubstringCount(word1 = "abracadabra", word2 = "aca") == 29

assert Solution().validSubstringCount(word1 = "randomstringwithsomerepeatedcharacters", word2 = "som") == 402

assert Solution().validSubstringCount(word1 = "longwordwithmanysamecharactersllllllllllllllllllllllllllllllllllllllll", word2 = "lllllllll") == 1489

assert Solution().validSubstringCount(word1 = "thisisaverylongstringthatneedsmanyvalidsubstrings", word2 = "this") == 565

assert Solution().validSubstringCount(word1 = "abcdefghijklmnopqrstuvwxyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz", word2 = "z") == 1445

assert Solution().validSubstringCount(word1 = "abababababababababab", word2 = "ab") == 190

assert Solution().validSubstringCount(word1 = "pppppqqqqqrrrrrsssss", word2 = "pqrs") == 25

assert Solution().validSubstringCount(word1 = "uniquestringwithoutrepeatedcharacters", word2 = "que") == 128

assert Solution().validSubstringCount(word1 = "aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz", word2 = "mnop") == 572

assert Solution().validSubstringCount(word1 = "abcdefghijk", word2 = "jki") == 9

assert Solution().validSubstringCount(word1 = "mississippiissi", word2 = "iss") == 76

assert Solution().validSubstringCount(word1 = "xyzzxyzzxyzz", word2 = "xyzz") == 45

assert Solution().validSubstringCount(word1 = "aaabbbccc", word2 = "abc") == 9

assert Solution().validSubstringCount(word1 = "repeatedrepeatedrepeated", word2 = "repeated") == 153

assert Solution().validSubstringCount(word1 = "repeatedpatternsrepeatedpatterns", word2 = "pattern") == 237

assert Solution().validSubstringCount(word1 = "aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz", word2 = "zyxwvutsrqponmlkjihgfedcba") == 4

assert Solution().validSubstringCount(word1 = "thisisaverylongstringthatcontainsmanywords", word2 = "word") == 76

assert Solution().validSubstringCount(word1 = "repeatedrepeatedrepeated", word2 = "atedrep") == 159

assert Solution().validSubstringCount(word1 = "thisisaverylongwordthatcontainsmanyletters", word2 = "verylong") == 224

assert Solution().validSubstringCount(word1 = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", word2 = "aaaaaaaaaaaaaaaaa") == 595

assert Solution().validSubstringCount(word1 = "ababababababababab", word2 = "ab") == 153

assert Solution().validSubstringCount(word1 = "zzzzzzzzzzzzzzzzzzzzzzz", word2 = "zzzz") == 210

assert Solution().validSubstringCount(word1 = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz", word2 = "zzzzz") == 465

assert Solution().validSubstringCount(word1 = "mississippiississim", word2 = "issi") == 117

assert Solution().validSubstringCount(word1 = "abracadabra", word2 = "abr") == 31

assert Solution().validSubstringCount(word1 = "oneonetwoonetwoone", word2 = "twoone") == 86

assert Solution().validSubstringCount(word1 = "xyxyxyxyxyxyxyxyxyxy", word2 = "xyx") == 162

assert Solution().validSubstringCount(word1 = "bbaaccaabbaaccaabbaaccaabb", word2 = "aabbaacc") == 190

assert Solution().validSubstringCount(word1 = "zyxzyxzyxzyxzyx", word2 = "zyxzyx") == 55

Answer: assert Solution().validSubstringCount(word1 = "bcca", word2 = "abc") == 1

Answer: assert Solution().validSubstringCount(word1 = "abcdefghijklmnopqrstuvwxyz", word2 = "zyxwvutsrqponmlkjihgfedcba") == 1

Answer: assert Solution().validSubstringCount(word1 = "aabbcc", word2 = "abc") == 4

Answer: assert Solution().validSubstringCount(word1 = "abcabcabcabc", word2 = "abcabc") == 28

Answer: assert Solution().validSubstringCount(word1 = "hellothere", word2 = "oth") == 21

Answer: assert Solution().validSubstringCount(word1 = "abcabc", word2 = "aaabc") == 0

Answer: assert Solution().validSubstringCount(word1 = "aaaaaaa", word2 = "a") == 28

Answer: assert Solution().validSubstringCount(word1 = "abcabc", word2 = "abc") == 10

Answer: assert Solution().validSubstringCount(word1 = "mississippi", word2 = "issi") == 27

Answer: assert Solution().validSubstringCount(word1 = "teststring", word2 = "ttt") == 5

Answer: assert Solution().validSubstringCount(word1 = "abcabcabcabcabcabcabcabcabcabc", word2 = "abcabc") == 325

Answer: assert Solution().validSubstringCount(word1 = "abacabadabacabadabacabadabacabad", word2 = "abacabad") == 325

Answer: assert Solution().validSubstringCount(word1 = "aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz", word2 = "mnopqrstuv") == 260

Answer: assert Solution().validSubstringCount(word1 = "hellohellohellohellohello", word2 = "hello") == 231

Answer: assert Solution().validSubstringCount(word1 = "xyzyzyzyzyzyzyzyzy", word2 = "zyx") == 16

Answer: assert Solution().validSubstringCount(word1 = "cccccccaaaaaaaabbbbbbb", word2 = "abc") == 49

Answer: assert Solution().validSubstringCount(word1 = "hellohellohellohello", word2 = "lohel") == 136

Answer: assert Solution().validSubstringCount(word1 = "abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc", word2 = "abcabcabc") == 1225

Answer: assert Solution().validSubstringCount(word1 = "xyzzxyzzxyzz", word2 = "zzxy") == 45

Answer: assert Solution().validSubstringCount(word1 = "abcdefghijabcdefghijabcdefghij", word2 = "abcdefghij") == 231

Answer: assert Solution().validSubstringCount(word1 = "abcabcabcabcabcabcabc", word2 = "abcabc") == 136

Answer: assert Solution().validSubstringCount(word1 = "longstringwithmanyvowelsaeiou", word2 = "aeiou") == 25

Answer: assert Solution().validSubstringCount(word1 = "aaaabbbbcccc", word2 = "bbbaaccc") == 6

Answer: assert Solution().validSubstringCount(word1 = "abcdabcdabcdabcd", word2 = "dcba") == 91

Answer: assert Solution().validSubstringCount(word1 = "patternpatternpattern", word2 = "ternpat") == 120

Answer: assert Solution().validSubstringCount(word1 = "xyxyxyxyxyxyxyxyxyxyxyxyxyxyxy", word2 = "xyxyxyxy") == 276

Answer: assert Solution().validSubstringCount(word1 = "abracadabra", word2 = "abra") == 25

Answer: assert Solution().validSubstringCount(word1 = "abababababababababababab", word2 = "ab") == 276

Answer: assert Solution().validSubstringCount(word1 = "xyzabcdexyzabcdef", word2 = "abcdef") == 12

Answer: assert Solution().validSubstringCount(word1 = "xzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzy", word2 = "xzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzy") == 325

Answer: assert Solution().validSubstringCount(word1 = "bbaaccdd", word2 = "abcd") == 4

Answer: assert Solution().validSubstringCount(word1 = "thisisanotherexample", word2 = "another") == 61

Answer: assert Solution().validSubstringCount(word1 = "aabbaabbaabbaabb", word2 = "aabb") == 91

Answer: assert Solution().validSubstringCount(word1 = "banana", word2 = "nan") == 6

Answer: assert Solution().validSubstringCount(word1 = "abcdefghijabcdefghij", word2 = "jihgfedcba") == 66

Answer: assert Solution().validSubstringCount(word1 = "hellohellohello", word2 = "hello") == 66

Answer: assert Solution().validSubstringCount(word1 = "aaaaaabbbbccccdddd", word2 = "bbbcccdddd") == 8

Answer: assert Solution().validSubstringCount(word1 = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz", word2 = "abcdefghijklmnopqrstuvwxyz") == 378

Answer: assert Solution().validSubstringCount(word1 = "mnopqrlmnopqrlmnopqr", word2 = "mnopqr") == 108

Answer: assert Solution().validSubstringCount(word1 = "abracadabra", word2 = "aca") == 29

Answer: assert Solution().validSubstringCount(word1 = "randomstringwithsomerepeatedcharacters", word2 = "som") == 402

Answer: assert Solution().validSubstringCount(word1 = "longwordwithmanysamecharactersllllllllllllllllllllllllllllllllllllllll", word2 = "lllllllll") == 1489

Answer: assert Solution().validSubstringCount(word1 = "thisisaverylongstringthatneedsmanyvalidsubstrings", word2 = "this") == 565

Answer: assert Solution().validSubstringCount(word1 = "abcdefghijklmnopqrstuvwxyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz", word2 = "z") == 1445

Answer: assert Solution().validSubstringCount(word1 = "abababababababababab", word2 = "ab") == 190

Answer: assert Solution().validSubstringCount(word1 = "pppppqqqqqrrrrrsssss", word2 = "pqrs") == 25

Answer: assert Solution().validSubstringCount(word1 = "uniquestringwithoutrepeatedcharacters", word2 = "que") == 128

Answer: assert Solution().validSubstringCount(word1 = "aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz", word2 = "mnop") == 572

Answer: assert Solution().validSubstringCount(word1 = "abcdefghijk", word2 = "jki") == 9

Answer: assert Solution().validSubstringCount(word1 = "mississippiissi", word2 = "iss") == 76

Answer: assert Solution().validSubstringCount(word1 = "xyzzxyzzxyzz", word2 = "xyzz") == 45

Answer: assert Solution().validSubstringCount(word1 = "aaabbbccc", word2 = "abc") == 9

Answer: assert Solution().validSubstringCount(word1 = "repeatedrepeatedrepeated", word2 = "repeated") == 153

Answer: assert Solution().validSubstringCount(word1 = "repeatedpatternsrepeatedpatterns", word2 = "pattern") == 237

Answer: assert Solution().validSubstringCount(word1 = "aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz", word2 = "zyxwvutsrqponmlkjihgfedcba") == 4

Answer: assert Solution().validSubstringCount(word1 = "thisisaverylongstringthatcontainsmanywords", word2 = "word") == 76

Answer: assert Solution().validSubstringCount(word1 = "repeatedrepeatedrepeated", word2 = "atedrep") == 159

Answer: assert Solution().validSubstringCount(word1 = "thisisaverylongwordthatcontainsmanyletters", word2 = "verylong") == 224

Answer: assert Solution().validSubstringCount(word1 = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", word2 = "aaaaaaaaaaaaaaaaa") == 595

Answer: assert Solution().validSubstringCount(word1 = "ababababababababab", word2 = "ab") == 153

Answer: assert Solution().validSubstringCount(word1 = "zzzzzzzzzzzzzzzzzzzzzzz", word2 = "zzzz") == 210

Answer: assert Solution().validSubstringCount(word1 = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz", word2 = "zzzzz") == 465

Answer: assert Solution().validSubstringCount(word1 = "mississippiississim", word2 = "issi") == 117

Answer: assert Solution().validSubstringCount(word1 = "abracadabra", word2 = "abr") == 31

Answer: assert Solution().validSubstringCount(word1 = "oneonetwoonetwoone", word2 = "twoone") == 86

Answer: assert Solution().validSubstringCount(word1 = "xyxyxyxyxyxyxyxyxyxy", word2 = "xyx") == 162

Answer: assert Solution().validSubstringCount(word1 = "bbaaccaabbaaccaabbaaccaabb", word2 = "aabbaacc") == 190

Answer: assert Solution().validSubstringCount(word1 = "zyxzyxzyxzyxzyx", word2 = "zyxzyx") == 55

import random
import functools
import collections
import string
import math
import datetime

from typing import *
from functools import *
from collections import *
from itertools import *
from heapq import *
from bisect import *
from string import *
from operator import *
from math import *

inf = float('inf')

class ListNode:
    def __init__(self, val=0, next=None):
        self.val = val
        self.next = next

def list_node(values: list):
    if not values:
        return None
    head = ListNode(values[0])
    p = head
    for val in values[1:]:
        node = ListNode(val)
        p.next = node
        p = node
    return head

def is_same_list(p1, p2):
    if p1 is None and p2 is None:
        return True
    if not p1 or not p2:
        return False
    return p1.val == p2.val and is_same_list(p1.next, p2.next)

class TreeNode:
    def __init__(self, val=0, left=None, right=None):
        self.val = val
        self.left = left
        self.right = right

def tree_node(values: list):
    if not values:
        return None
    root = TreeNode(values[0])
    i = 1
    queue = deque()
    queue.append(root)
    while queue:
        node = queue.popleft()
        if i < len(values) and values[i] is not None:
            node.left = TreeNode(values[i])
            queue.append(node.left)
        i += 1
        if i < len(values) and values[i] is not None:
            node.right = TreeNode(values[i])
            queue.append(node.right)
        i += 1
    return root

def is_same_tree(p, q):
    if not p and not q:
        return True
    elif not p or not q:
        return False
    elif p.val != q.val:
        return False
    else:
        return is_same_tree(p.left, q.left) and is_same_tree(p.right, q.right)

class Solution:
    def validSubstringCount(self, word1: str, word2: str) -> int:
        if len(word1) < len(word2):
            return 0
        cnt = Counter(word2)
        need = len(cnt)
        ans = l = 0
        win = Counter()
        for c in word1:
            win[c] += 1
            if win[c] == cnt[c]:
                need -= 1
            while need == 0:
                if win[word1[l]] == cnt[word1[l]]:
                    need += 1
                win[word1[l]] -= 1
                l += 1
            ans += l
        return ans

class Solution:
    def validSubstringCount(self, word1: str, word2: str) -> int: