```python
def isPalindrome(s, start, end):
    while start < end:
        if s[start] != s[end]:
            return False
        start += 1
        end -= 1
    return True

def dfs(s, start, results, current):
    if start == len(s):
        results.append(current[:])
        return

    for end in range(start, len(s)):
        if isPalindrome(s, start, end):
            current.append(s[start:end+1])
            dfs(s, end + 1, results, current)
            current.pop()

def partition(s):
    results = []
    dfs(s, 0, results, [])
    return results
```

aabbaaab aabb aabababbaab aabababababa aabababababab aababababba aaa aababbaa a aababab aa aabaab aabbaabab abba aabaaab aababbaabb abc aabaa aabbaabaa b baa aababaabbaa aababaab aababaa aabababaa aababbaaba aab aababababaa aabaaba aababaababba aababaababb baabaa manamaplanacanalpanama aabaaaba aababbaabab abba aaab abcd aabbaaa aabbaaabb aababaabab acbbaaca abbaab aababbaabbaa aababaaba aabababababaa aab ccaabba aabababbaa aabbaaaba

[[a, a, b, b, a, a, a, b, b], [a, a, b, b, a, a, a, bb], [a, a, b, b, a, aa, b, b], [a, a, b, b, a, aa, bb], [a, a, b, b, aa, a, b, b], [a, a, b, b, aa, a, bb], [a, a, b, b, aaa, b, b], [a, a, b, b, aaa, bb], [a, a, b, baaab, b], [a, a, bb, a, a, a, b, b], [a, a, bb, a, a, a, bb], [a, a, bb, a, aa, b, b], [a, a, bb, a, aa, bb], [a, a, bb, aa, a, b, b], [a, a, bb, aa, a, bb], [a, a, bb, aaa, b, b], [a, a, bb, aaa, bb], [a, a, bbaaabb], [a, abba, a, a, b, b], [a, abba, a, a, bb], [a, abba, aa, b, b], [a, abba, aa, bb], [aa, b, b, a, a, a, b, b], [aa, b, b, a, a, a, bb], [aa, b, b, a, aa, b, b], [aa, b, b, a, aa, bb], [aa, b, b, aa, a, b, b], [aa, b, b, aa, a, bb], [aa, b, b, aaa, b, b], [aa, b, b, aaa, bb], [aa, b, baaab, b], [aa, bb, a, a, a, b, b], [aa, bb, a, a, a, bb], [aa, bb, a, aa, b, b], [aa, bb, a, aa, bb], [aa, bb, aa, a, b, b], [aa, bb, aa, a, bb], [aa, bb, aaa, b, b], [aa, bb, aaa, bb], [aa, bbaaabb], [aabbaa, a, b, b], [aabbaa, a, bb]]

[[a, a, b, a, b, b, a, a], [a, a, b, a, b, b, aa], [a, a, b, a, bb, a, a], [a, a, b, a, bb, aa], [a, a, b, abba, a], [a, a, bab, b, a, a], [a, a, bab, b, aa], [a, aba, b, b, a, a], [a, aba, b, b, aa], [a, aba, bb, a, a], [a, aba, bb, aa], [aa, b, a, b, b, a, a], [aa, b, a, b, b, aa], [aa, b, a, bb, a, a], [aa, b, a, bb, aa], [aa, b, abba, a], [aa, bab, b, a, a], [aa, bab, b, aa]]

[[a, a, b, a, b, b, a, a, b, a], [a, a, b, a, b, b, a, aba], [a, a, b, a, b, b, aa, b, a], [a, a, b, a, b, baab, a], [a, a, b, a, bb, a, a, b, a], [a, a, b, a, bb, a, aba], [a, a, b, a, bb, aa, b, a], [a, a, b, abba, a, b, a], [a, a, b, abba, aba], [a, a, bab, b, a, a, b, a], [a, a, bab, b, a, aba], [a, a, bab, b, aa, b, a], [a, a, bab, baab, a], [a, aba, b, b, a, a, b, a], [a, aba, b, b, a, aba], [a, aba, b, b, aa, b, a], [a, aba, b, baab, a], [a, aba, bb, a, a, b, a], [a, aba, bb, a, aba], [a, aba, bb, aa, b, a], [aa, b, a, b, b, a, a, b, a], [aa, b, a, b, b, a, aba], [aa, b, a, b, b, aa, b, a], [aa, b, a, b, baab, a], [aa, b, a, bb, a, a, b, a], [aa, b, a, bb, a, aba], [aa, b, a, bb, aa, b, a], [aa, b, abba, a, b, a], [aa, b, abba, aba], [aa, bab, b, a, a, b, a], [aa, bab, b, a, aba], [aa, bab, b, aa, b, a], [aa, bab, baab, a]]

[[a, a, b, a, b, a, b, a, b, a, b, a, b], [a, a, b, a, b, a, b, a, b, a, bab], [a, a, b, a, b, a, b, a, b, aba, b], [a, a, b, a, b, a, b, a, bab, a, b], [a, a, b, a, b, a, b, a, babab], [a, a, b, a, b, a, b, aba, b, a, b], [a, a, b, a, b, a, b, aba, bab], [a, a, b, a, b, a, b, ababa, b], [a, a, b, a, b, a, bab, a, b, a, b], [a, a, b, a, b, a, bab, a, bab], [a, a, b, a, b, a, bab, aba, b], [a, a, b, a, b, a, babab, a, b], [a, a, b, a, b, a, bababab], [a, a, b, a, b, aba, b, a, b, a, b], [a, a, b, a, b, aba, b, a, bab], [a, a, b, a, b, aba, b, aba, b], [a, a, b, a, b, aba, bab, a, b], [a, a, b, a, b, aba, babab], [a, a, b, a, b, ababa, b, a, b], [a, a, b, a, b, ababa, bab], [a, a, b, a, b, abababa, b], [a, a, b, a, bab, a, b, a, b, a, b], [a, a, b, a, bab, a, b, a, bab], [a, a, b, a, bab, a, b, aba, b], [a, a, b, a, bab, a, bab, a, b], [a, a, b, a, bab, a, babab], [a, a, b, a, bab, aba, b, a, b], [a, a, b, a, bab, aba, bab], [a, a, b, a, bab, ababa, b], [a, a, b, a, babab, a, b, a, b], [a, a, b, a, babab, a, bab], [a, a, b, a, babab, aba, b], [a, a, b, a, bababab, a, b], [a, a, b, a, babababab], [a, a, b, aba, b, a, b, a, b, a, b], [a, a, b, aba, b, a, b, a, bab], [a, a, b, aba, b, a, b, aba, b], [a, a, b, aba, b, a, bab, a, b], [a, a, b, aba, b, a, babab], [a, a, b, aba, b, aba, b, a, b], [a, a, b, aba, b, aba, bab], [a, a, b, aba, b, ababa, b], [a, a, b, aba, bab, a, b, a, b], [a, a, b, aba, bab, a, bab], [a, a, b, aba, bab, aba, b], [a, a, b, aba, babab, a, b], [a, a, b, aba, bababab], [a, a, b, ababa, b, a, b, a, b], [a, a, b, ababa, b, a, bab], [a, a, b, ababa, b, aba, b], [a, a, b, ababa, bab, a, b], [a, a, b, ababa, babab], [a, a, b, abababa, b, a, b], [a, a, b, abababa, bab], [a, a, b, ababababa, b], [a, a, bab, a, b, a, b, a, b, a, b], [a, a, bab, a, b, a, b, a, bab], [a, a, bab, a, b, a, b, aba, b], [a, a, bab, a, b, a, bab, a, b], [a, a, bab, a, b, a, babab], [a, a, bab, a, b, aba, b, a, b], [a, a, bab, a, b, aba, bab], [a, a, bab, a, b, ababa, b], [a, a, bab, a, bab, a, b, a, b], [a, a, bab, a, bab, a, bab], [a, a, bab, a, bab, aba, b], [a, a, bab, a, babab, a, b], [a, a, bab, a, bababab], [a, a, bab, aba, b, a, b, a, b], [a, a, bab, aba, b, a, bab], [a, a, bab, aba, b, aba, b], [a, a, bab, aba, bab, a, b], [a, a, bab, aba, babab], [a, a, bab, ababa, b, a, b], [a, a, bab, ababa, bab], [a, a, bab, abababa, b], [a, a, babab, a, b, a, b, a, b], [a, a, babab, a, b, a, bab], [a, a, babab, a, b, aba, b], [a, a, babab, a, bab, a, b], [a, a, babab, a, babab], [a, a, babab, aba, b, a, b], [a, a, babab, aba, bab], [a, a, babab, ababa, b], [a, a, bababab, a, b, a, b], [a, a, bababab, a, bab], [a, a, bababab, aba, b], [a, a, babababab, a, b], [a, a, bababababab], [a, aba, b, a, b, a, b, a, b, a, b], [a, aba, b, a, b, a, b, a, bab], [a, aba, b, a, b, a, b, aba, b], [a, aba, b, a, b, a, bab, a, b], [a, aba, b, a, b, a, babab], [a, aba, b, a, b, aba, b, a, b], [a, aba, b, a, b, aba, bab], [a, aba, b, a, b, ababa, b], [a, aba, b, a, bab, a, b, a, b], [a, aba, b, a, bab, a, bab], [a, aba, b, a, bab, aba, b], [a, aba, b, a, babab, a, b], [a, aba, b, a, bababab], [a, aba, b, aba, b, a, b, a, b], [a, aba, b, aba, b, a, bab], [a, aba, b, aba, b, aba, b], [a, aba, b, aba, bab, a, b], [a, aba, b, aba, babab], [a, aba, b, ababa, b, a, b], [a, aba, b, ababa, bab], [a, aba, b, abababa, b], [a, aba, bab, a, b, a, b, a, b], [a, aba, bab, a, b, a, bab], [a, aba, bab, a, b, aba, b], [a, aba, bab, a, bab, a, b], [a, aba, bab, a, babab], [a, aba, bab, aba, b, a, b], [a, aba, bab, aba, bab], [a, aba, bab, ababa, b], [a, aba, babab, a, b, a, b], [a, aba, babab, a, bab], [a, aba, babab, aba, b], [a, aba, bababab, a, b], [a, aba, babababab], [a, ababa, b, a, b, a, b, a, b], [a, ababa, b, a, b, a, bab], [a, ababa, b, a, b, aba, b], [a, ababa, b, a, bab, a, b], [a, ababa, b, a, babab], [a, ababa, b, aba, b, a, b], [a, ababa, b, aba, bab], [a, ababa, b, ababa, b], [a, ababa, bab, a, b, a, b], [a, ababa, bab, a, bab], [a, ababa, bab, aba, b], [a, ababa, babab, a, b], [a, ababa, bababab], [a, abababa, b, a, b, a, b], [a, abababa, b, a, bab], [a, abababa, b, aba, b], [a, abababa, bab, a, b], [a, abababa, babab], [a, ababababa, b, a, b], [a, ababababa, bab], [a, abababababa, b], [aa, b, a, b, a, b, a, b, a, b, a, b], [aa, b, a, b, a, b, a, b, a, bab], [aa, b, a, b, a, b, a, b, aba, b], [aa, b, a, b, a, b, a, bab, a, b], [aa, b, a, b, a, b, a, babab], [aa, b, a, b, a, b, aba, b, a, b], [aa, b, a, b, a, b, aba, bab], [aa, b, a, b, a, b, ababa, b], [aa, b, a, b, a, bab, a, b, a, b], [aa, b, a, b, a, bab, a, bab], [aa, b, a, b, a, bab, aba, b], [aa, b, a, b, a, babab, a, b], [aa, b, a, b, a, bababab], [aa, b, a, b, aba, b, a, b, a, b], [aa, b, a, b, aba, b, a, bab], [aa, b, a, b, aba, b, aba, b], [aa, b, a, b, aba, bab, a, b], [aa, b, a, b, aba, babab], [aa, b, a, b, ababa, b, a, b], [aa, b, a, b, ababa, bab], [aa, b, a, b, abababa, b], [aa, b, a, bab, a, b, a, b, a, b], [aa, b, a, bab, a, b, a, bab], [aa, b, a, bab, a, b, aba, b], [aa, b, a, bab, a, bab, a, b], [aa, b, a, bab, a, babab], [aa, b, a, bab, aba, b, a, b], [aa, b, a, bab, aba, bab], [aa, b, a, bab, ababa, b], [aa, b, a, babab, a, b, a, b], [aa, b, a, babab, a, bab], [aa, b, a, babab, aba, b], [aa, b, a, bababab, a, b], [aa, b, a, babababab], [aa, b, aba, b, a, b, a, b, a, b], [aa, b, aba, b, a, b, a, bab], [aa, b, aba, b, a, b, aba, b], [aa, b, aba, b, a, bab, a, b], [aa, b, aba, b, a, babab], [aa, b, aba, b, aba, b, a, b], [aa, b, aba, b, aba, bab], [aa, b, aba, b, ababa, b], [aa, b, aba, bab, a, b, a, b], [aa, b, aba, bab, a, bab], [aa, b, aba, bab, aba, b], [aa, b, aba, babab, a, b], [aa, b, aba, bababab], [aa, b, ababa, b, a, b, a, b], [aa, b, ababa, b, a, bab], [aa, b, ababa, b, aba, b], [aa, b, ababa, bab, a, b], [aa, b, ababa, babab], [aa, b, abababa, b, a, b], [aa, b, abababa, bab], [aa, b, ababababa, b], [aa, bab, a, b, a, b, a, b, a, b], [aa, bab, a, b, a, b, a, bab], [aa, bab, a, b, a, b, aba, b], [aa, bab, a, b, a, bab, a, b], [aa, bab, a, b, a, babab], [aa, bab, a, b, aba, b, a, b], [aa, bab, a, b, aba, bab], [aa, bab, a, b, ababa, b], [aa, bab, a, bab, a, b, a, b], [aa, bab, a, bab, a, bab], [aa, bab, a, bab, aba, b], [aa, bab, a, babab, a, b], [aa, bab, a, bababab], [aa, bab, aba, b, a, b, a, b], [aa, bab, aba, b, a, bab], [aa, bab, aba, b, aba, b], [aa, bab, aba, bab, a, b], [aa, bab, aba, babab], [aa, bab, ababa, b, a, b], [aa, bab, ababa, bab], [aa, bab, abababa, b], [aa, babab, a, b, a, b, a, b], [aa, babab, a, b, a, bab], [aa, babab, a, b, aba, b], [aa, babab, a, bab, a, b], [aa, babab, a, babab], [aa, babab, aba, b, a, b], [aa, babab, aba, bab], [aa, babab, ababa, b], [aa, bababab, a, b, a, b], [aa, bababab, a, bab], [aa, bababab, aba, b], [aa, babababab, a, b], [aa, bababababab]]

[[a, a, b, b, a, a, b, a, a], [a, a, b, b, a, a, b, aa], [a, a, b, b, a, aba, a], [a, a, b, b, aa, b, a, a], [a, a, b, b, aa, b, aa], [a, a, b, b, aabaa], [a, a, b, baab, a, a], [a, a, b, baab, aa], [a, a, bb, a, a, b, a, a], [a, a, bb, a, a, b, aa], [a, a, bb, a, aba, a], [a, a, bb, aa, b, a, a], [a, a, bb, aa, b, aa], [a, a, bb, aabaa], [a, abba, a, b, a, a], [a, abba, a, b, aa], [a, abba, aba, a], [aa, b, b, a, a, b, a, a], [aa, b, b, a, a, b, aa], [aa, b, b, a, aba, a], [aa, b, b, aa, b, a, a], [aa, b, b, aa, b, aa], [aa, b, b, aabaa], [aa, b, baab, a, a], [aa, b, baab, aa], [aa, bb, a, a, b, a, a], [aa, bb, a, a, b, aa], [aa, bb, a, aba, a], [aa, bb, aa, b, a, a], [aa, bb, aa, b, aa], [aa, bb, aabaa], [aabbaa, b, a, a], [aabbaa, b, aa]]

[[a, a, b, a, b, a, b, a, a], [a, a, b, a, b, a, b, aa], [a, a, b, a, b, aba, a], [a, a, b, a, bab, a, a], [a, a, b, a, bab, aa], [a, a, b, aba, b, a, a], [a, a, b, aba, b, aa], [a, a, b, ababa, a], [a, a, bab, a, b, a, a], [a, a, bab, a, b, aa], [a, a, bab, aba, a], [a, a, babab, a, a], [a, a, babab, aa], [a, aba, b, a, b, a, a], [a, aba, b, a, b, aa], [a, aba, b, aba, a], [a, aba, bab, a, a], [a, aba, bab, aa], [a, ababa, b, a, a], [a, ababa, b, aa], [a, abababa, a], [aa, b, a, b, a, b, a, a], [aa, b, a, b, a, b, aa], [aa, b, a, b, aba, a], [aa, b, a, bab, a, a], [aa, b, a, bab, aa], [aa, b, aba, b, a, a], [aa, b, aba, b, aa], [aa, b, ababa, a], [aa, bab, a, b, a, a], [aa, bab, a, b, aa], [aa, bab, aba, a], [aa, babab, a, a], [aa, babab, aa], [aabababaa]]

[[a, a, b, a, b, a, b], [a, a, b, a, bab], [a, a, b, aba, b], [a, a, bab, a, b], [a, a, babab], [a, aba, b, a, b], [a, aba, bab], [a, ababa, b], [aa, b, a, b, a, b], [aa, b, a, bab], [aa, b, aba, b], [aa, bab, a, b], [aa, babab]]

[[a, a, b, a, b, b, a, a, b, a, b], [a, a, b, a, b, b, a, a, bab], [a, a, b, a, b, b, a, aba, b], [a, a, b, a, b, b, aa, b, a, b], [a, a, b, a, b, b, aa, bab], [a, a, b, a, b, baab, a, b], [a, a, b, a, bb, a, a, b, a, b], [a, a, b, a, bb, a, a, bab], [a, a, b, a, bb, a, aba, b], [a, a, b, a, bb, aa, b, a, b], [a, a, b, a, bb, aa, bab], [a, a, b, abba, a, b, a, b], [a, a, b, abba, a, bab], [a, a, b, abba, aba, b], [a, a, bab, b, a, a, b, a, b], [a, a, bab, b, a, a, bab], [a, a, bab, b, a, aba, b], [a, a, bab, b, aa, b, a, b], [a, a, bab, b, aa, bab], [a, a, bab, baab, a, b], [a, aba, b, b, a, a, b, a, b], [a, aba, b, b, a, a, bab], [a, aba, b, b, a, aba, b], [a, aba, b, b, aa, b, a, b], [a, aba, b, b, aa, bab], [a, aba, b, baab, a, b], [a, aba, bb, a, a, b, a, b], [a, aba, bb, a, a, bab], [a, aba, bb, a, aba, b], [a, aba, bb, aa, b, a, b], [a, aba, bb, aa, bab], [aa, b, a, b, b, a, a, b, a, b], [aa, b, a, b, b, a, a, bab], [aa, b, a, b, b, a, aba, b], [aa, b, a, b, b, aa, b, a, b], [aa, b, a, b, b, aa, bab], [aa, b, a, b, baab, a, b], [aa, b, a, bb, a, a, b, a, b], [aa, b, a, bb, a, a, bab], [aa, b, a, bb, a, aba, b], [aa, b, a, bb, aa, b, a, b], [aa, b, a, bb, aa, bab], [aa, b, abba, a, b, a, b], [aa, b, abba, a, bab], [aa, b, abba, aba, b], [aa, bab, b, a, a, b, a, b], [aa, bab, b, a, a, bab], [aa, bab, b, a, aba, b], [aa, bab, b, aa, b, a, b], [aa, bab, b, aa, bab], [aa, bab, baab, a, b]]

[[a, a, b, a, b, b, a, a, b, b], [a, a, b, a, b, b, a, a, bb], [a, a, b, a, b, b, aa, b, b], [a, a, b, a, b, b, aa, bb], [a, a, b, a, b, baab, b], [a, a, b, a, bb, a, a, b, b], [a, a, b, a, bb, a, a, bb], [a, a, b, a, bb, aa, b, b], [a, a, b, a, bb, aa, bb], [a, a, b, a, bbaabb], [a, a, b, abba, a, b, b], [a, a, b, abba, a, bb], [a, a, bab, b, a, a, b, b], [a, a, bab, b, a, a, bb], [a, a, bab, b, aa, b, b], [a, a, bab, b, aa, bb], [a, a, bab, baab, b], [a, aba, b, b, a, a, b, b], [a, aba, b, b, a, a, bb], [a, aba, b, b, aa, b, b], [a, aba, b, b, aa, bb], [a, aba, b, baab, b], [a, aba, bb, a, a, b, b], [a, aba, bb, a, a, bb], [a, aba, bb, aa, b, b], [a, aba, bb, aa, bb], [a, aba, bbaabb], [aa, b, a, b, b, a, a, b, b], [aa, b, a, b, b, a, a, bb], [aa, b, a, b, b, aa, b, b], [aa, b, a, b, b, aa, bb], [aa, b, a, b, baab, b], [aa, b, a, bb, a, a, b, b], [aa, b, a, bb, a, a, bb], [aa, b, a, bb, aa, b, b], [aa, b, a, bb, aa, bb], [aa, b, a, bbaabb], [aa, b, abba, a, b, b], [aa, b, abba, a, bb], [aa, bab, b, a, a, b, b], [aa, bab, b, a, a, bb], [aa, bab, b, aa, b, b], [aa, bab, b, aa, bb], [aa, bab, baab, b]]

[[a, a, b, b, a, a, a, b, a], [a, a, b, b, a, a, aba], [a, a, b, b, a, aa, b, a], [a, a, b, b, aa, a, b, a], [a, a, b, b, aa, aba], [a, a, b, b, aaa, b, a], [a, a, b, baaab, a], [a, a, bb, a, a, a, b, a], [a, a, bb, a, a, aba], [a, a, bb, a, aa, b, a], [a, a, bb, aa, a, b, a], [a, a, bb, aa, aba], [a, a, bb, aaa, b, a], [a, abba, a, a, b, a], [a, abba, a, aba], [a, abba, aa, b, a], [aa, b, b, a, a, a, b, a], [aa, b, b, a, a, aba], [aa, b, b, a, aa, b, a], [aa, b, b, aa, a, b, a], [aa, b, b, aa, aba], [aa, b, b, aaa, b, a], [aa, b, baaab, a], [aa, bb, a, a, a, b, a], [aa, bb, a, a, aba], [aa, bb, a, aa, b, a], [aa, bb, aa, a, b, a], [aa, bb, aa, aba], [aa, bb, aaa, b, a], [aabbaa, a, b, a], [aabbaa, aba]]

[[a, a, b, a, a, b, a], [a, a, b, a, aba], [a, a, b, aa, b, a], [a, a, baab, a], [a, aba, a, b, a], [a, aba, aba], [a, abaaba], [aa, b, a, a, b, a], [aa, b, a, aba], [aa, b, aa, b, a], [aa, baab, a], [aabaa, b, a]]

[[a, a, b, a, b, a, a, b, a, b, b, a], [a, a, b, a, b, a, a, b, a, bb, a], [a, a, b, a, b, a, a, b, abba], [a, a, b, a, b, a, a, bab, b, a], [a, a, b, a, b, a, aba, b, b, a], [a, a, b, a, b, a, aba, bb, a], [a, a, b, a, b, aa, b, a, b, b, a], [a, a, b, a, b, aa, b, a, bb, a], [a, a, b, a, b, aa, b, abba], [a, a, b, a, b, aa, bab, b, a], [a, a, b, a, baab, a, b, b, a], [a, a, b, a, baab, a, bb, a], [a, a, b, a, baab, abba], [a, a, b, aba, a, b, a, b, b, a], [a, a, b, aba, a, b, a, bb, a], [a, a, b, aba, a, b, abba], [a, a, b, aba, a, bab, b, a], [a, a, b, aba, aba, b, b, a], [a, a, b, aba, aba, bb, a], [a, a, b, abaaba, b, b, a], [a, a, b, abaaba, bb, a], [a, a, bab, a, a, b, a, b, b, a], [a, a, bab, a, a, b, a, bb, a], [a, a, bab, a, a, b, abba], [a, a, bab, a, a, bab, b, a], [a, a, bab, a, aba, b, b, a], [a, a, bab, a, aba, bb, a], [a, a, bab, aa, b, a, b, b, a], [a, a, bab, aa, b, a, bb, a], [a, a, bab, aa, b, abba], [a, a, bab, aa, bab, b, a], [a, a, babaabab, b, a], [a, aba, b, a, a, b, a, b, b, a], [a, aba, b, a, a, b, a, bb, a], [a, aba, b, a, a, b, abba], [a, aba, b, a, a, bab, b, a], [a, aba, b, a, aba, b, b, a], [a, aba, b, a, aba, bb, a], [a, aba, b, aa, b, a, b, b, a], [a, aba, b, aa, b, a, bb, a], [a, aba, b, aa, b, abba], [a, aba, b, aa, bab, b, a], [a, aba, baab, a, b, b, a], [a, aba, baab, a, bb, a], [a, aba, baab, abba], [a, ababa, a, b, a, b, b, a], [a, ababa, a, b, a, bb, a], [a, ababa, a, b, abba], [a, ababa, a, bab, b, a], [a, ababa, aba, b, b, a], [a, ababa, aba, bb, a], [aa, b, a, b, a, a, b, a, b, b, a], [aa, b, a, b, a, a, b, a, bb, a], [aa, b, a, b, a, a, b, abba], [aa, b, a, b, a, a, bab, b, a], [aa, b, a, b, a, aba, b, b, a], [aa, b, a, b, a, aba, bb, a], [aa, b, a, b, aa, b, a, b, b, a], [aa, b, a, b, aa, b, a, bb, a], [aa, b, a, b, aa, b, abba], [aa, b, a, b, aa, bab, b, a], [aa, b, a, baab, a, b, b, a], [aa, b, a, baab, a, bb, a], [aa, b, a, baab, abba], [aa, b, aba, a, b, a, b, b, a], [aa, b, aba, a, b, a, bb, a], [aa, b, aba, a, b, abba], [aa, b, aba, a, bab, b, a], [aa, b, aba, aba, b, b, a], [aa, b, aba, aba, bb, a], [aa, b, abaaba, b, b, a], [aa, b, abaaba, bb, a], [aa, bab, a, a, b, a, b, b, a], [aa, bab, a, a, b, a, bb, a], [aa, bab, a, a, b, abba], [aa, bab, a, a, bab, b, a], [aa, bab, a, aba, b, b, a], [aa, bab, a, aba, bb, a], [aa, bab, aa, b, a, b, b, a], [aa, bab, aa, b, a, bb, a], [aa, bab, aa, b, abba], [aa, bab, aa, bab, b, a], [aa, babaabab, b, a], [aababaa, b, a, b, b, a], [aababaa, b, a, bb, a], [aababaa, b, abba], [aababaa, bab, b, a]]

[[a, a, b, a, b, a, b, a, b, a, a], [a, a, b, a, b, a, b, a, b, aa], [a, a, b, a, b, a, b, aba, a], [a, a, b, a, b, a, bab, a, a], [a, a, b, a, b, a, bab, aa], [a, a, b, a, b, aba, b, a, a], [a, a, b, a, b, aba, b, aa], [a, a, b, a, b, ababa, a], [a, a, b, a, bab, a, b, a, a], [a, a, b, a, bab, a, b, aa], [a, a, b, a, bab, aba, a], [a, a, b, a, babab, a, a], [a, a, b, a, babab, aa], [a, a, b, aba, b, a, b, a, a], [a, a, b, aba, b, a, b, aa], [a, a, b, aba, b, aba, a], [a, a, b, aba, bab, a, a], [a, a, b, aba, bab, aa], [a, a, b, ababa, b, a, a], [a, a, b, ababa, b, aa], [a, a, b, abababa, a], [a, a, bab, a, b, a, b, a, a], [a, a, bab, a, b, a, b, aa], [a, a, bab, a, b, aba, a], [a, a, bab, a, bab, a, a], [a, a, bab, a, bab, aa], [a, a, bab, aba, b, a, a], [a, a, bab, aba, b, aa], [a, a, bab, ababa, a], [a, a, babab, a, b, a, a], [a, a, babab, a, b, aa], [a, a, babab, aba, a], [a, a, bababab, a, a], [a, a, bababab, aa], [a, aba, b, a, b, a, b, a, a], [a, aba, b, a, b, a, b, aa], [a, aba, b, a, b, aba, a], [a, aba, b, a, bab, a, a], [a, aba, b, a, bab, aa], [a, aba, b, aba, b, a, a], [a, aba, b, aba, b, aa], [a, aba, b, ababa, a], [a, aba, bab, a, b, a, a], [a, aba, bab, a, b, aa], [a, aba, bab, aba, a], [a, aba, babab, a, a], [a, aba, babab, aa], [a, ababa, b, a, b, a, a], [a, ababa, b, a, b, aa], [a, ababa, b, aba, a], [a, ababa, bab, a, a], [a, ababa, bab, aa], [a, abababa, b, a, a], [a, abababa, b, aa], [a, ababababa, a], [aa, b, a, b, a, b, a, b, a, a], [aa, b, a, b, a, b, a, b, aa], [aa, b, a, b, a, b, aba, a], [aa, b, a, b, a, bab, a, a], [aa, b, a, b, a, bab, aa], [aa, b, a, b, aba, b, a, a], [aa, b, a, b, aba, b, aa], [aa, b, a, b, ababa, a], [aa, b, a, bab, a, b, a, a], [aa, b, a, bab, a, b, aa], [aa, b, a, bab, aba, a], [aa, b, a, babab, a, a], [aa, b, a, babab, aa], [aa, b, aba, b, a, b, a, a], [aa, b, aba, b, a, b, aa], [aa, b, aba, b, aba, a], [aa, b, aba, bab, a, a], [aa, b, aba, bab, aa], [aa, b, ababa, b, a, a], [aa, b, ababa, b, aa], [aa, b, abababa, a], [aa, bab, a, b, a, b, a, a], [aa, bab, a, b, a, b, aa], [aa, bab, a, b, aba, a], [aa, bab, a, bab, a, a], [aa, bab, a, bab, aa], [aa, bab, aba, b, a, a], [aa, bab, aba, b, aa], [aa, bab, ababa, a], [aa, babab, a, b, a, a], [aa, babab, a, b, aa], [aa, babab, aba, a], [aa, bababab, a, a], [aa, bababab, aa], [aababababaa]]

[[a, a, b, a, a, a, b], [a, a, b, a, aa, b], [a, a, b, aa, a, b], [a, a, b, aaa, b], [a, a, baaab], [a, aba, a, a, b], [a, aba, aa, b], [aa, b, a, a, a, b], [aa, b, a, aa, b], [aa, b, aa, a, b], [aa, b, aaa, b], [aa, baaab], [aabaa, a, b]]

[[a, a, b, a, b, a, a, b, b, a, a], [a, a, b, a, b, a, a, b, b, aa], [a, a, b, a, b, a, a, bb, a, a], [a, a, b, a, b, a, a, bb, aa], [a, a, b, a, b, a, abba, a], [a, a, b, a, b, aa, b, b, a, a], [a, a, b, a, b, aa, b, b, aa], [a, a, b, a, b, aa, bb, a, a], [a, a, b, a, b, aa, bb, aa], [a, a, b, a, b, aabbaa], [a, a, b, a, baab, b, a, a], [a, a, b, a, baab, b, aa], [a, a, b, aba, a, b, b, a, a], [a, a, b, aba, a, b, b, aa], [a, a, b, aba, a, bb, a, a], [a, a, b, aba, a, bb, aa], [a, a, b, aba, abba, a], [a, a, bab, a, a, b, b, a, a], [a, a, bab, a, a, b, b, aa], [a, a, bab, a, a, bb, a, a], [a, a, bab, a, a, bb, aa], [a, a, bab, a, abba, a], [a, a, bab, aa, b, b, a, a], [a, a, bab, aa, b, b, aa], [a, a, bab, aa, bb, a, a], [a, a, bab, aa, bb, aa], [a, a, bab, aabbaa], [a, aba, b, a, a, b, b, a, a], [a, aba, b, a, a, b, b, aa], [a, aba, b, a, a, bb, a, a], [a, aba, b, a, a, bb, aa], [a, aba, b, a, abba, a], [a, aba, b, aa, b, b, a, a], [a, aba, b, aa, b, b, aa], [a, aba, b, aa, bb, a, a], [a, aba, b, aa, bb, aa], [a, aba, b, aabbaa], [a, aba, baab, b, a, a], [a, aba, baab, b, aa], [a, ababa, a, b, b, a, a], [a, ababa, a, b, b, aa], [a, ababa, a, bb, a, a], [a, ababa, a, bb, aa], [a, ababa, abba, a], [aa, b, a, b, a, a, b, b, a, a], [aa, b, a, b, a, a, b, b, aa], [aa, b, a, b, a, a, bb, a, a], [aa, b, a, b, a, a, bb, aa], [aa, b, a, b, a, abba, a], [aa, b, a, b, aa, b, b, a, a], [aa, b, a, b, aa, b, b, aa], [aa, b, a, b, aa, bb, a, a], [aa, b, a, b, aa, bb, aa], [aa, b, a, b, aabbaa], [aa, b, a, baab, b, a, a], [aa, b, a, baab, b, aa], [aa, b, aba, a, b, b, a, a], [aa, b, aba, a, b, b, aa], [aa, b, aba, a, bb, a, a], [aa, b, aba, a, bb, aa], [aa, b, aba, abba, a], [aa, bab, a, a, b, b, a, a], [aa, bab, a, a, b, b, aa], [aa, bab, a, a, bb, a, a], [aa, bab, a, a, bb, aa], [aa, bab, a, abba, a], [aa, bab, aa, b, b, a, a], [aa, bab, aa, b, b, aa], [aa, bab, aa, bb, a, a], [aa, bab, aa, bb, aa], [aa, bab, aabbaa], [aababaa, b, b, a, a], [aababaa, b, b, aa], [aababaa, bb, a, a], [aababaa, bb, aa]]

[[b, a, a, b, a, a], [b, a, a, b, aa], [b, a, aba, a], [b, aa, b, a, a], [b, aa, b, aa], [b, aabaa], [baab, a, a], [baab, aa]]

[[a, a, b, b, a, a, a], [a, a, b, b, a, aa], [a, a, b, b, aa, a], [a, a, b, b, aaa], [a, a, bb, a, a, a], [a, a, bb, a, aa], [a, a, bb, aa, a], [a, a, bb, aaa], [a, abba, a, a], [a, abba, aa], [aa, b, b, a, a, a], [aa, b, b, a, aa], [aa, b, b, aa, a], [aa, b, b, aaa], [aa, bb, a, a, a], [aa, bb, a, aa], [aa, bb, aa, a], [aa, bb, aaa], [aabbaa, a]]

[[a, a, b, a, a, a, b, a], [a, a, b, a, a, aba], [a, a, b, a, aa, b, a], [a, a, b, aa, a, b, a], [a, a, b, aa, aba], [a, a, b, aaa, b, a], [a, a, baaab, a], [a, aba, a, a, b, a], [a, aba, a, aba], [a, aba, aa, b, a], [a, abaaaba], [aa, b, a, a, a, b, a], [aa, b, a, a, aba], [aa, b, a, aa, b, a], [aa, b, aa, a, b, a], [aa, b, aa, aba], [aa, b, aaa, b, a], [aa, baaab, a], [aabaa, a, b, a], [aabaa, aba]]

[[a, a, b, a, b, a, b, b, a, a, b], [a, a, b, a, b, a, b, b, aa, b], [a, a, b, a, b, a, b, baab], [a, a, b, a, b, a, bb, a, a, b], [a, a, b, a, b, a, bb, aa, b], [a, a, b, a, b, abba, a, b], [a, a, b, a, bab, b, a, a, b], [a, a, b, a, bab, b, aa, b], [a, a, b, a, bab, baab], [a, a, b, aba, b, b, a, a, b], [a, a, b, aba, b, b, aa, b], [a, a, b, aba, b, baab], [a, a, b, aba, bb, a, a, b], [a, a, b, aba, bb, aa, b], [a, a, bab, a, b, b, a, a, b], [a, a, bab, a, b, b, aa, b], [a, a, bab, a, b, baab], [a, a, bab, a, bb, a, a, b], [a, a, bab, a, bb, aa, b], [a, a, bab, abba, a, b], [a, a, babab, b, a, a, b], [a, a, babab, b, aa, b], [a, a, babab, baab], [a, aba, b, a, b, b, a, a, b], [a, aba, b, a, b, b, aa, b], [a, aba, b, a, b, baab], [a, aba, b, a, bb, a, a, b], [a, aba, b, a, bb, aa, b], [a, aba, b, abba, a, b], [a, aba, bab, b, a, a, b], [a, aba, bab, b, aa, b], [a, aba, bab, baab], [a, ababa, b, b, a, a, b], [a, ababa, b, b, aa, b], [a, ababa, b, baab], [a, ababa, bb, a, a, b], [a, ababa, bb, aa, b], [aa, b, a, b, a, b, b, a, a, b], [aa, b, a, b, a, b, b, aa, b], [aa, b, a, b, a, b, baab], [aa, b, a, b, a, bb, a, a, b], [aa, b, a, b, a, bb, aa, b], [aa, b, a, b, abba, a, b], [aa, b, a, bab, b, a, a, b], [aa, b, a, bab, b, aa, b], [aa, b, a, bab, baab], [aa, b, aba, b, b, a, a, b], [aa, b, aba, b, b, aa, b], [aa, b, aba, b, baab], [aa, b, aba, bb, a, a, b], [aa, b, aba, bb, aa, b], [aa, bab, a, b, b, a, a, b], [aa, bab, a, b, b, aa, b], [aa, bab, a, b, baab], [aa, bab, a, bb, a, a, b], [aa, bab, a, bb, aa, b], [aa, bab, abba, a, b], [aa, babab, b, a, a, b], [aa, babab, b, aa, b], [aa, babab, baab]]

[[m, a, n, a, m, a, p, l, a, n, a, c, a, n, a, l, p, a, n, a, m, a], [m, a, n, a, m, a, p, l, a, n, a, c, a, n, a, l, p, a, n, ama], [m, a, n, a, m, a, p, l, a, n, a, c, a, n, a, l, p, ana, m, a], [m, a, n, a, m, a, p, l, a, n, a, c, ana, l, p, a, n, a, m, a], [m, a, n, a, m, a, p, l, a, n, a, c, ana, l, p, a, n, ama], [m, a, n, a, m, a, p, l, a, n, a, c, ana, l, p, ana, m, a], [m, a, n, a, m, a, p, l, a, n, aca, n, a, l, p, a, n, a, m, a], [m, a, n, a, m, a, p, l, a, n, aca, n, a, l, p, a, n, ama], [m, a, n, a, m, a, p, l, a, n, aca, n, a, l, p, ana, m, a], [m, a, n, a, m, a, p, l, a, nacan, a, l, p, a, n, a, m, a], [m, a, n, a, m, a, p, l, a, nacan, a, l, p, a, n, ama], [m, a, n, a, m, a, p, l, a, nacan, a, l, p, ana, m, a], [m, a, n, a, m, a, p, l, ana, c, a, n, a, l, p, a, n, a, m, a], [m, a, n, a, m, a, p, l, ana, c, a, n, a, l, p, a, n, ama], [m, a, n, a, m, a, p, l, ana, c, a, n, a, l, p, ana, m, a], [m, a, n, a, m, a, p, l, ana, c, ana, l, p, a, n, a, m, a], [m, a, n, a, m, a, p, l, ana, c, ana, l, p, a, n, ama], [m, a, n, a, m, a, p, l, ana, c, ana, l, p, ana, m, a], [m, a, n, a, m, a, p, l, anacana, l, p, a, n, a, m, a], [m, a, n, a, m, a, p, l, anacana, l, p, a, n, ama], [m, a, n, a, m, a, p, l, anacana, l, p, ana, m, a], [m, a, n, a, m, a, p, lanacanal, p, a, n, a, m, a], [m, a, n, a, m, a, p, lanacanal, p, a, n, ama], [m, a, n, a, m, a, p, lanacanal, p, ana, m, a], [m, a, n, a, m, a, planacanalp, a, n, a, m, a], [m, a, n, a, m, a, planacanalp, a, n, ama], [m, a, n, a, m, a, planacanalp, ana, m, a], [m, a, n, a, m, aplanacanalpa, n, a, m, a], [m, a, n, a, m, aplanacanalpa, n, ama], [m, a, n, ama, p, l, a, n, a, c, a, n, a, l, p, a, n, a, m, a], [m, a, n, ama, p, l, a, n, a, c, a, n, a, l, p, a, n, ama], [m, a, n, ama, p, l, a, n, a, c, a, n, a, l, p, ana, m, a], [m, a, n, ama, p, l, a, n, a, c, ana, l, p, a, n, a, m, a], [m, a, n, ama, p, l, a, n, a, c, ana, l, p, a, n, ama], [m, a, n, ama, p, l, a, n, a, c, ana, l, p, ana, m, a], [m, a, n, ama, p, l, a, n, aca, n, a, l, p, a, n, a, m, a], [m, a, n, ama, p, l, a, n, aca, n, a, l, p, a, n, ama], [m, a, n, ama, p, l, a, n, aca, n, a, l, p, ana, m, a], [m, a, n, ama, p, l, a, nacan, a, l, p, a, n, a, m, a], [m, a, n, ama, p, l, a, nacan, a, l, p, a, n, ama], [m, a, n, ama, p, l, a, nacan, a, l, p, ana, m, a], [m, a, n, ama, p, l, ana, c, a, n, a, l, p, a, n, a, m, a], [m, a, n, ama, p, l, ana, c, a, n, a, l, p, a, n, ama], [m, a, n, ama, p, l, ana, c, a, n, a, l, p, ana, m, a], [m, a, n, ama, p, l, ana, c, ana, l, p, a, n, a, m, a], [m, a, n, ama, p, l, ana, c, ana, l, p, a, n, ama], [m, a, n, ama, p, l, ana, c, ana, l, p, ana, m, a], [m, a, n, ama, p, l, anacana, l, p, a, n, a, m, a], [m, a, n, ama, p, l, anacana, l, p, a, n, ama], [m, a, n, ama, p, l, anacana, l, p, ana, m, a], [m, a, n, ama, p, lanacanal, p, a, n, a, m, a], [m, a, n, ama, p, lanacanal, p, a, n, ama], [m, a, n, ama, p, lanacanal, p, ana, m, a], [m, a, n, ama, planacanalp, a, n, a, m, a], [m, a, n, ama, planacanalp, a, n, ama], [m, a, n, ama, planacanalp, ana, m, a], [m, ana, m, a, p, l, a, n, a, c, a, n, a, l, p, a, n, a, m, a], [m, ana, m, a, p, l, a, n, a, c, a, n, a, l, p, a, n, ama], [m, ana, m, a, p, l, a, n, a, c, a, n, a, l, p, ana, m, a], [m, ana, m, a, p, l, a, n, a, c, ana, l, p, a, n, a, m, a], [m, ana, m, a, p, l, a, n, a, c, ana, l, p, a, n, ama], [m, ana, m, a, p, l, a, n, a, c, ana, l, p, ana, m, a], [m, ana, m, a, p, l, a, n, aca, n, a, l, p, a, n, a, m, a], [m, ana, m, a, p, l, a, n, aca, n, a, l, p, a, n, ama], [m, ana, m, a, p, l, a, n, aca, n, a, l, p, ana, m, a], [m, ana, m, a, p, l, a, nacan, a, l, p, a, n, a, m, a], [m, ana, m, a, p, l, a, nacan, a, l, p, a, n, ama], [m, ana, m, a, p, l, a, nacan, a, l, p, ana, m, a], [m, ana, m, a, p, l, ana, c, a, n, a, l, p, a, n, a, m, a], [m, ana, m, a, p, l, ana, c, a, n, a, l, p, a, n, ama], [m, ana, m, a, p, l, ana, c, a, n, a, l, p, ana, m, a], [m, ana, m, a, p, l, ana, c, ana, l, p, a, n, a, m, a], [m, ana, m, a, p, l, ana, c, ana, l, p, a, n, ama], [m, ana, m, a, p, l, ana, c, ana, l, p, ana, m, a], [m, ana, m, a, p, l, anacana, l, p, a, n, a, m, a], [m, ana, m, a, p, l, anacana, l, p, a, n, ama], [m, ana, m, a, p, l, anacana, l, p, ana, m, a], [m, ana, m, a, p, lanacanal, p, a, n, a, m, a], [m, ana, m, a, p, lanacanal, p, a, n, ama], [m, ana, m, a, p, lanacanal, p, ana, m, a], [m, ana, m, a, planacanalp, a, n, a, m, a], [m, ana, m, a, planacanalp, a, n, ama], [m, ana, m, a, planacanalp, ana, m, a], [m, ana, m, aplanacanalpa, n, a, m, a], [m, ana, m, aplanacanalpa, n, ama], [manam, a, p, l, a, n, a, c, a, n, a, l, p, a, n, a, m, a], [manam, a, p, l, a, n, a, c, a, n, a, l, p, a, n, ama], [manam, a, p, l, a, n, a, c, a, n, a, l, p, ana, m, a], [manam, a, p, l, a, n, a, c, ana, l, p, a, n, a, m, a], [manam, a, p, l, a, n, a, c, ana, l, p, a, n, ama], [manam, a, p, l, a, n, a, c, ana, l, p, ana, m, a], [manam, a, p, l, a, n, aca, n, a, l, p, a, n, a, m, a], [manam, a, p, l, a, n, aca, n, a, l, p, a, n, ama], [manam, a, p, l, a, n, aca, n, a, l, p, ana, m, a], [manam, a, p, l, a, nacan, a, l, p, a, n, a, m, a], [manam, a, p, l, a, nacan, a, l, p, a, n, ama], [manam, a, p, l, a, nacan, a, l, p, ana, m, a], [manam, a, p, l, ana, c, a, n, a, l, p, a, n, a, m, a], [manam, a, p, l, ana, c, a, n, a, l, p, a, n, ama], [manam, a, p, l, ana, c, a, n, a, l, p, ana, m, a], [manam, a, p, l, ana, c, ana, l, p, a, n, a, m, a], [manam, a, p, l, ana, c, ana, l, p, a, n, ama], [manam, a, p, l, ana, c, ana, l, p, ana, m, a], [manam, a, p, l, anacana, l, p, a, n, a, m, a], [manam, a, p, l, anacana, l, p, a, n, ama], [manam, a, p, l, anacana, l, p, ana, m, a], [manam, a, p, lanacanal, p, a, n, a, m, a], [manam, a, p, lanacanal, p, a, n, ama], [manam, a, p, lanacanal, p, ana, m, a], [manam, a, planacanalp, a, n, a, m, a], [manam, a, planacanalp, a, n, ama], [manam, a, planacanalp, ana, m, a], [manam, aplanacanalpa, n, a, m, a], [manam, aplanacanalpa, n, ama]]

[[a, a, b, a, b, a, a, b, a, b], [a, a, b, a, b, a, a, bab], [a, a, b, a, b, a, aba, b], [a, a, b, a, b, aa, b, a, b], [a, a, b, a, b, aa, bab], [a, a, b, a, baab, a, b], [a, a, b, aba, a, b, a, b], [a, a, b, aba, a, bab], [a, a, b, aba, aba, b], [a, a, b, abaaba, b], [a, a, bab, a, a, b, a, b], [a, a, bab, a, a, bab], [a, a, bab, a, aba, b], [a, a, bab, aa, b, a, b], [a, a, bab, aa, bab], [a, a, babaabab], [a, aba, b, a, a, b, a, b], [a, aba, b, a, a, bab], [a, aba, b, a, aba, b], [a, aba, b, aa, b, a, b], [a, aba, b, aa, bab], [a, aba, baab, a, b], [a, ababa, a, b, a, b], [a, ababa, a, bab], [a, ababa, aba, b], [aa, b, a, b, a, a, b, a, b], [aa, b, a, b, a, a, bab], [aa, b, a, b, a, aba, b], [aa, b, a, b, aa, b, a, b], [aa, b, a, b, aa, bab], [aa, b, a, baab, a, b], [aa, b, aba, a, b, a, b], [aa, b, aba, a, bab], [aa, b, aba, aba, b], [aa, b, abaaba, b], [aa, bab, a, a, b, a, b], [aa, bab, a, a, bab], [aa, bab, a, aba, b], [aa, bab, aa, b, a, b], [aa, bab, aa, bab], [aa, babaabab], [aababaa, b, a, b], [aababaa, bab]]

[[a, a, b, a, b, a, b, b, a, a], [a, a, b, a, b, a, b, b, aa], [a, a, b, a, b, a, bb, a, a], [a, a, b, a, b, a, bb, aa], [a, a, b, a, b, abba, a], [a, a, b, a, bab, b, a, a], [a, a, b, a, bab, b, aa], [a, a, b, aba, b, b, a, a], [a, a, b, aba, b, b, aa], [a, a, b, aba, bb, a, a], [a, a, b, aba, bb, aa], [a, a, bab, a, b, b, a, a], [a, a, bab, a, b, b, aa], [a, a, bab, a, bb, a, a], [a, a, bab, a, bb, aa], [a, a, bab, abba, a], [a, a, babab, b, a, a], [a, a, babab, b, aa], [a, aba, b, a, b, b, a, a], [a, aba, b, a, b, b, aa], [a, aba, b, a, bb, a, a], [a, aba, b, a, bb, aa], [a, aba, b, abba, a], [a, aba, bab, b, a, a], [a, aba, bab, b, aa], [a, ababa, b, b, a, a], [a, ababa, b, b, aa], [a, ababa, bb, a, a], [a, ababa, bb, aa], [aa, b, a, b, a, b, b, a, a], [aa, b, a, b, a, b, b, aa], [aa, b, a, b, a, bb, a, a], [aa, b, a, b, a, bb, aa], [aa, b, a, b, abba, a], [aa, b, a, bab, b, a, a], [aa, b, a, bab, b, aa], [aa, b, aba, b, b, a, a], [aa, b, aba, b, b, aa], [aa, b, aba, bb, a, a], [aa, b, aba, bb, aa], [aa, bab, a, b, b, a, a], [aa, bab, a, b, b, aa], [aa, bab, a, bb, a, a], [aa, bab, a, bb, aa], [aa, bab, abba, a], [aa, babab, b, a, a], [aa, babab, b, aa]]

[[a, a, b, b, a, a, a, b], [a, a, b, b, a, aa, b], [a, a, b, b, aa, a, b], [a, a, b, b, aaa, b], [a, a, b, baaab], [a, a, bb, a, a, a, b], [a, a, bb, a, aa, b], [a, a, bb, aa, a, b], [a, a, bb, aaa, b], [a, abba, a, a, b], [a, abba, aa, b], [aa, b, b, a, a, a, b], [aa, b, b, a, aa, b], [aa, b, b, aa, a, b], [aa, b, b, aaa, b], [aa, b, baaab], [aa, bb, a, a, a, b], [aa, bb, a, aa, b], [aa, bb, aa, a, b], [aa, bb, aaa, b], [aabbaa, a, b]]

[[a, a, b, a, b, a, b, a, b, a, b, a], [a, a, b, a, b, a, b, a, b, aba], [a, a, b, a, b, a, b, a, bab, a], [a, a, b, a, b, a, b, aba, b, a], [a, a, b, a, b, a, b, ababa], [a, a, b, a, b, a, bab, a, b, a], [a, a, b, a, b, a, bab, aba], [a, a, b, a, b, a, babab, a], [a, a, b, a, b, aba, b, a, b, a], [a, a, b, a, b, aba, b, aba], [a, a, b, a, b, aba, bab, a], [a, a, b, a, b, ababa, b, a], [a, a, b, a, b, abababa], [a, a, b, a, bab, a, b, a, b, a], [a, a, b, a, bab, a, b, aba], [a, a, b, a, bab, a, bab, a], [a, a, b, a, bab, aba, b, a], [a, a, b, a, bab, ababa], [a, a, b, a, babab, a, b, a], [a, a, b, a, babab, aba], [a, a, b, a, bababab, a], [a, a, b, aba, b, a, b, a, b, a], [a, a, b, aba, b, a, b, aba], [a, a, b, aba, b, a, bab, a], [a, a, b, aba, b, aba, b, a], [a, a, b, aba, b, ababa], [a, a, b, aba, bab, a, b, a], [a, a, b, aba, bab, aba], [a, a, b, aba, babab, a], [a, a, b, ababa, b, a, b, a], [a, a, b, ababa, b, aba], [a, a, b, ababa, bab, a], [a, a, b, abababa, b, a], [a, a, b, ababababa], [a, a, bab, a, b, a, b, a, b, a], [a, a, bab, a, b, a, b, aba], [a, a, bab, a, b, a, bab, a], [a, a, bab, a, b, aba, b, a], [a, a, bab, a, b, ababa], [a, a, bab, a, bab, a, b, a], [a, a, bab, a, bab, aba], [a, a, bab, a, babab, a], [a, a, bab, aba, b, a, b, a], [a, a, bab, aba, b, aba], [a, a, bab, aba, bab, a], [a, a, bab, ababa, b, a], [a, a, bab, abababa], [a, a, babab, a, b, a, b, a], [a, a, babab, a, b, aba], [a, a, babab, a, bab, a], [a, a, babab, aba, b, a], [a, a, babab, ababa], [a, a, bababab, a, b, a], [a, a, bababab, aba], [a, a, babababab, a], [a, aba, b, a, b, a, b, a, b, a], [a, aba, b, a, b, a, b, aba], [a, aba, b, a, b, a, bab, a], [a, aba, b, a, b, aba, b, a], [a, aba, b, a, b, ababa], [a, aba, b, a, bab, a, b, a], [a, aba, b, a, bab, aba], [a, aba, b, a, babab, a], [a, aba, b, aba, b, a, b, a], [a, aba, b, aba, b, aba], [a, aba, b, aba, bab, a], [a, aba, b, ababa, b, a], [a, aba, b, abababa], [a, aba, bab, a, b, a, b, a], [a, aba, bab, a, b, aba], [a, aba, bab, a, bab, a], [a, aba, bab, aba, b, a], [a, aba, bab, ababa], [a, aba, babab, a, b, a], [a, aba, babab, aba], [a, aba, bababab, a], [a, ababa, b, a, b, a, b, a], [a, ababa, b, a, b, aba], [a, ababa, b, a, bab, a], [a, ababa, b, aba, b, a], [a, ababa, b, ababa], [a, ababa, bab, a, b, a], [a, ababa, bab, aba], [a, ababa, babab, a], [a, abababa, b, a, b, a], [a, abababa, b, aba], [a, abababa, bab, a], [a, ababababa, b, a], [a, abababababa], [aa, b, a, b, a, b, a, b, a, b, a], [aa, b, a, b, a, b, a, b, aba], [aa, b, a, b, a, b, a, bab, a], [aa, b, a, b, a, b, aba, b, a], [aa, b, a, b, a, b, ababa], [aa, b, a, b, a, bab, a, b, a], [aa, b, a, b, a, bab, aba], [aa, b, a, b, a, babab, a], [aa, b, a, b, aba, b, a, b, a], [aa, b, a, b, aba, b, aba], [aa, b, a, b, aba, bab, a], [aa, b, a, b, ababa, b, a], [aa, b, a, b, abababa], [aa, b, a, bab, a, b, a, b, a], [aa, b, a, bab, a, b, aba], [aa, b, a, bab, a, bab, a], [aa, b, a, bab, aba, b, a], [aa, b, a, bab, ababa], [aa, b, a, babab, a, b, a], [aa, b, a, babab, aba], [aa, b, a, bababab, a], [aa, b, aba, b, a, b, a, b, a], [aa, b, aba, b, a, b, aba], [aa, b, aba, b, a, bab, a], [aa, b, aba, b, aba, b, a], [aa, b, aba, b, ababa], [aa, b, aba, bab, a, b, a], [aa, b, aba, bab, aba], [aa, b, aba, babab, a], [aa, b, ababa, b, a, b, a], [aa, b, ababa, b, aba], [aa, b, ababa, bab, a], [aa, b, abababa, b, a], [aa, b, ababababa], [aa, bab, a, b, a, b, a, b, a], [aa, bab, a, b, a, b, aba], [aa, bab, a, b, a, bab, a], [aa, bab, a, b, aba, b, a], [aa, bab, a, b, ababa], [aa, bab, a, bab, a, b, a], [aa, bab, a, bab, aba], [aa, bab, a, babab, a], [aa, bab, aba, b, a, b, a], [aa, bab, aba, b, aba], [aa, bab, aba, bab, a], [aa, bab, ababa, b, a], [aa, bab, abababa], [aa, babab, a, b, a, b, a], [aa, babab, a, b, aba], [aa, babab, a, bab, a], [aa, babab, aba, b, a], [aa, babab, ababa], [aa, bababab, a, b, a], [aa, bababab, aba], [aa, babababab, a]]

[[a, a, b, a, b, a, b, a, b, a, b, a, a], [a, a, b, a, b, a, b, a, b, a, b, aa], [a, a, b, a, b, a, b, a, b, aba, a], [a, a, b, a, b, a, b, a, bab, a, a], [a, a, b, a, b, a, b, a, bab, aa], [a, a, b, a, b, a, b, aba, b, a, a], [a, a, b, a, b, a, b, aba, b, aa], [a, a, b, a, b, a, b, ababa, a], [a, a, b, a, b, a, bab, a, b, a, a], [a, a, b, a, b, a, bab, a, b, aa], [a, a, b, a, b, a, bab, aba, a], [a, a, b, a, b, a, babab, a, a], [a, a, b, a, b, a, babab, aa], [a, a, b, a, b, aba, b, a, b, a, a], [a, a, b, a, b, aba, b, a, b, aa], [a, a, b, a, b, aba, b, aba, a], [a, a, b, a, b, aba, bab, a, a], [a, a, b, a, b, aba, bab, aa], [a, a, b, a, b, ababa, b, a, a], [a, a, b, a, b, ababa, b, aa], [a, a, b, a, b, abababa, a], [a, a, b, a, bab, a, b, a, b, a, a], [a, a, b, a, bab, a, b, a, b, aa], [a, a, b, a, bab, a, b, aba, a], [a, a, b, a, bab, a, bab, a, a], [a, a, b, a, bab, a, bab, aa], [a, a, b, a, bab, aba, b, a, a], [a, a, b, a, bab, aba, b, aa], [a, a, b, a, bab, ababa, a], [a, a, b, a, babab, a, b, a, a], [a, a, b, a, babab, a, b, aa], [a, a, b, a, babab, aba, a], [a, a, b, a, bababab, a, a], [a, a, b, a, bababab, aa], [a, a, b, aba, b, a, b, a, b, a, a], [a, a, b, aba, b, a, b, a, b, aa], [a, a, b, aba, b, a, b, aba, a], [a, a, b, aba, b, a, bab, a, a], [a, a, b, aba, b, a, bab, aa], [a, a, b, aba, b, aba, b, a, a], [a, a, b, aba, b, aba, b, aa], [a, a, b, aba, b, ababa, a], [a, a, b, aba, bab, a, b, a, a], [a, a, b, aba, bab, a, b, aa], [a, a, b, aba, bab, aba, a], [a, a, b, aba, babab, a, a], [a, a, b, aba, babab, aa], [a, a, b, ababa, b, a, b, a, a], [a, a, b, ababa, b, a, b, aa], [a, a, b, ababa, b, aba, a], [a, a, b, ababa, bab, a, a], [a, a, b, ababa, bab, aa], [a, a, b, abababa, b, a, a], [a, a, b, abababa, b, aa], [a, a, b, ababababa, a], [a, a, bab, a, b, a, b, a, b, a, a], [a, a, bab, a, b, a, b, a, b, aa], [a, a, bab, a, b, a, b, aba, a], [a, a, bab, a, b, a, bab, a, a], [a, a, bab, a, b, a, bab, aa], [a, a, bab, a, b, aba, b, a, a], [a, a, bab, a, b, aba, b, aa], [a, a, bab, a, b, ababa, a], [a, a, bab, a, bab, a, b, a, a], [a, a, bab, a, bab, a, b, aa], [a, a, bab, a, bab, aba, a], [a, a, bab, a, babab, a, a], [a, a, bab, a, babab, aa], [a, a, bab, aba, b, a, b, a, a], [a, a, bab, aba, b, a, b, aa], [a, a, bab, aba, b, aba, a], [a, a, bab, aba, bab, a, a], [a, a, bab, aba, bab, aa], [a, a, bab, ababa, b, a, a], [a, a, bab, ababa, b, aa], [a, a, bab, abababa, a], [a, a, babab, a, b, a, b, a, a], [a, a, babab, a, b, a, b, aa], [a, a, babab, a, b, aba, a], [a, a, babab, a, bab, a, a], [a, a, babab, a, bab, aa], [a, a, babab, aba, b, a, a], [a, a, babab, aba, b, aa], [a, a, babab, ababa, a], [a, a, bababab, a, b, a, a], [a, a, bababab, a, b, aa], [a, a, bababab, aba, a], [a, a, babababab, a, a], [a, a, babababab, aa], [a, aba, b, a, b, a, b, a, b, a, a], [a, aba, b, a, b, a, b, a, b, aa], [a, aba, b, a, b, a, b, aba, a], [a, aba, b, a, b, a, bab, a, a], [a, aba, b, a, b, a, bab, aa], [a, aba, b, a, b, aba, b, a, a], [a, aba, b, a, b, aba, b, aa], [a, aba, b, a, b, ababa, a], [a, aba, b, a, bab, a, b, a, a], [a, aba, b, a, bab, a, b, aa], [a, aba, b, a, bab, aba, a], [a, aba, b, a, babab, a, a], [a, aba, b, a, babab, aa], [a, aba, b, aba, b, a, b, a, a], [a, aba, b, aba, b, a, b, aa], [a, aba, b, aba, b, aba, a], [a, aba, b, aba, bab, a, a], [a, aba, b, aba, bab, aa], [a, aba, b, ababa, b, a, a], [a, aba, b, ababa, b, aa], [a, aba, b, abababa, a], [a, aba, bab, a, b, a, b, a, a], [a, aba, bab, a, b, a, b, aa], [a, aba, bab, a, b, aba, a], [a, aba, bab, a, bab, a, a], [a, aba, bab, a, bab, aa], [a, aba, bab, aba, b, a, a], [a, aba, bab, aba, b, aa], [a, aba, bab, ababa, a], [a, aba, babab, a, b, a, a], [a, aba, babab, a, b, aa], [a, aba, babab, aba, a], [a, aba, bababab, a, a], [a, aba, bababab, aa], [a, ababa, b, a, b, a, b, a, a], [a, ababa, b, a, b, a, b, aa], [a, ababa, b, a, b, aba, a], [a, ababa, b, a, bab, a, a], [a, ababa, b, a, bab, aa], [a, ababa, b, aba, b, a, a], [a, ababa, b, aba, b, aa], [a, ababa, b, ababa, a], [a, ababa, bab, a, b, a, a], [a, ababa, bab, a, b, aa], [a, ababa, bab, aba, a], [a, ababa, babab, a, a], [a, ababa, babab, aa], [a, abababa, b, a, b, a, a], [a, abababa, b, a, b, aa], [a, abababa, b, aba, a], [a, abababa, bab, a, a], [a, abababa, bab, aa], [a, ababababa, b, a, a], [a, ababababa, b, aa], [a, abababababa, a], [aa, b, a, b, a, b, a, b, a, b, a, a], [aa, b, a, b, a, b, a, b, a, b, aa], [aa, b, a, b, a, b, a, b, aba, a], [aa, b, a, b, a, b, a, bab, a, a], [aa, b, a, b, a, b, a, bab, aa], [aa, b, a, b, a, b, aba, b, a, a], [aa, b, a, b, a, b, aba, b, aa], [aa, b, a, b, a, b, ababa, a], [aa, b, a, b, a, bab, a, b, a, a], [aa, b, a, b, a, bab, a, b, aa], [aa, b, a, b, a, bab, aba, a], [aa, b, a, b, a, babab, a, a], [aa, b, a, b, a, babab, aa], [aa, b, a, b, aba, b, a, b, a, a], [aa, b, a, b, aba, b, a, b, aa], [aa, b, a, b, aba, b, aba, a], [aa, b, a, b, aba, bab, a, a], [aa, b, a, b, aba, bab, aa], [aa, b, a, b, ababa, b, a, a], [aa, b, a, b, ababa, b, aa], [aa, b, a, b, abababa, a], [aa, b, a, bab, a, b, a, b, a, a], [aa, b, a, bab, a, b, a, b, aa], [aa, b, a, bab, a, b, aba, a], [aa, b, a, bab, a, bab, a, a], [aa, b, a, bab, a, bab, aa], [aa, b, a, bab, aba, b, a, a], [aa, b, a, bab, aba, b, aa], [aa, b, a, bab, ababa, a], [aa, b, a, babab, a, b, a, a], [aa, b, a, babab, a, b, aa], [aa, b, a, babab, aba, a], [aa, b, a, bababab, a, a], [aa, b, a, bababab, aa], [aa, b, aba, b, a, b, a, b, a, a], [aa, b, aba, b, a, b, a, b, aa], [aa, b, aba, b, a, b, aba, a], [aa, b, aba, b, a, bab, a, a], [aa, b, aba, b, a, bab, aa], [aa, b, aba, b, aba, b, a, a], [aa, b, aba, b, aba, b, aa], [aa, b, aba, b, ababa, a], [aa, b, aba, bab, a, b, a, a], [aa, b, aba, bab, a, b, aa], [aa, b, aba, bab, aba, a], [aa, b, aba, babab, a, a], [aa, b, aba, babab, aa], [aa, b, ababa, b, a, b, a, a], [aa, b, ababa, b, a, b, aa], [aa, b, ababa, b, aba, a], [aa, b, ababa, bab, a, a], [aa, b, ababa, bab, aa], [aa, b, abababa, b, a, a], [aa, b, abababa, b, aa], [aa, b, ababababa, a], [aa, bab, a, b, a, b, a, b, a, a], [aa, bab, a, b, a, b, a, b, aa], [aa, bab, a, b, a, b, aba, a], [aa, bab, a, b, a, bab, a, a], [aa, bab, a, b, a, bab, aa], [aa, bab, a, b, aba, b, a, a], [aa, bab, a, b, aba, b, aa], [aa, bab, a, b, ababa, a], [aa, bab, a, bab, a, b, a, a], [aa, bab, a, bab, a, b, aa], [aa, bab, a, bab, aba, a], [aa, bab, a, babab, a, a], [aa, bab, a, babab, aa], [aa, bab, aba, b, a, b, a, a], [aa, bab, aba, b, a, b, aa], [aa, bab, aba, b, aba, a], [aa, bab, aba, bab, a, a], [aa, bab, aba, bab, aa], [aa, bab, ababa, b, a, a], [aa, bab, ababa, b, aa], [aa, bab, abababa, a], [aa, babab, a, b, a, b, a, a], [aa, babab, a, b, a, b, aa], [aa, babab, a, b, aba, a], [aa, babab, a, bab, a, a], [aa, babab, a, bab, aa], [aa, babab, aba, b, a, a], [aa, babab, aba, b, aa], [aa, babab, ababa, a], [aa, bababab, a, b, a, a], [aa, bababab, a, b, aa], [aa, bababab, aba, a], [aa, babababab, a, a], [aa, babababab, aa], [aabababababaa]]

[[a, a, b, a, a, b], [a, a, b, aa, b], [a, a, baab], [a, aba, a, b], [aa, b, a, a, b], [aa, b, aa, b], [aa, baab], [aabaa, b]]

[[a, a, b, a, b, a, a, b, a, b, b], [a, a, b, a, b, a, a, b, a, bb], [a, a, b, a, b, a, a, bab, b], [a, a, b, a, b, a, aba, b, b], [a, a, b, a, b, a, aba, bb], [a, a, b, a, b, aa, b, a, b, b], [a, a, b, a, b, aa, b, a, bb], [a, a, b, a, b, aa, bab, b], [a, a, b, a, baab, a, b, b], [a, a, b, a, baab, a, bb], [a, a, b, aba, a, b, a, b, b], [a, a, b, aba, a, b, a, bb], [a, a, b, aba, a, bab, b], [a, a, b, aba, aba, b, b], [a, a, b, aba, aba, bb], [a, a, b, abaaba, b, b], [a, a, b, abaaba, bb], [a, a, bab, a, a, b, a, b, b], [a, a, bab, a, a, b, a, bb], [a, a, bab, a, a, bab, b], [a, a, bab, a, aba, b, b], [a, a, bab, a, aba, bb], [a, a, bab, aa, b, a, b, b], [a, a, bab, aa, b, a, bb], [a, a, bab, aa, bab, b], [a, a, babaabab, b], [a, aba, b, a, a, b, a, b, b], [a, aba, b, a, a, b, a, bb], [a, aba, b, a, a, bab, b], [a, aba, b, a, aba, b, b], [a, aba, b, a, aba, bb], [a, aba, b, aa, b, a, b, b], [a, aba, b, aa, b, a, bb], [a, aba, b, aa, bab, b], [a, aba, baab, a, b, b], [a, aba, baab, a, bb], [a, ababa, a, b, a, b, b], [a, ababa, a, b, a, bb], [a, ababa, a, bab, b], [a, ababa, aba, b, b], [a, ababa, aba, bb], [aa, b, a, b, a, a, b, a, b, b], [aa, b, a, b, a, a, b, a, bb], [aa, b, a, b, a, a, bab, b], [aa, b, a, b, a, aba, b, b], [aa, b, a, b, a, aba, bb], [aa, b, a, b, aa, b, a, b, b], [aa, b, a, b, aa, b, a, bb], [aa, b, a, b, aa, bab, b], [aa, b, a, baab, a, b, b], [aa, b, a, baab, a, bb], [aa, b, aba, a, b, a, b, b], [aa, b, aba, a, b, a, bb], [aa, b, aba, a, bab, b], [aa, b, aba, aba, b, b], [aa, b, aba, aba, bb], [aa, b, abaaba, b, b], [aa, b, abaaba, bb], [aa, bab, a, a, b, a, b, b], [aa, bab, a, a, b, a, bb], [aa, bab, a, a, bab, b], [aa, bab, a, aba, b, b], [aa, bab, a, aba, bb], [aa, bab, aa, b, a, b, b], [aa, bab, aa, b, a, bb], [aa, bab, aa, bab, b], [aa, babaabab, b], [aababaa, b, a, b, b], [aababaa, b, a, bb], [aababaa, bab, b]]

[[a, a, b, a, b, a, a], [a, a, b, a, b, aa], [a, a, b, aba, a], [a, a, bab, a, a], [a, a, bab, aa], [a, aba, b, a, a], [a, aba, b, aa], [a, ababa, a], [aa, b, a, b, a, a], [aa, b, a, b, aa], [aa, b, aba, a], [aa, bab, a, a], [aa, bab, aa], [aababaa]]

[[a, a, b, a, b, a, a, b, a], [a, a, b, a, b, a, aba], [a, a, b, a, b, aa, b, a], [a, a, b, a, baab, a], [a, a, b, aba, a, b, a], [a, a, b, aba, aba], [a, a, b, abaaba], [a, a, bab, a, a, b, a], [a, a, bab, a, aba], [a, a, bab, aa, b, a], [a, aba, b, a, a, b, a], [a, aba, b, a, aba], [a, aba, b, aa, b, a], [a, aba, baab, a], [a, ababa, a, b, a], [a, ababa, aba], [aa, b, a, b, a, a, b, a], [aa, b, a, b, a, aba], [aa, b, a, b, aa, b, a], [aa, b, a, baab, a], [aa, b, aba, a, b, a], [aa, b, aba, aba], [aa, b, abaaba], [aa, bab, a, a, b, a], [aa, bab, a, aba], [aa, bab, aa, b, a], [aababaa, b, a]]

[[a, a, b, a, b, a, b, a, b, b, a], [a, a, b, a, b, a, b, a, bb, a], [a, a, b, a, b, a, b, abba], [a, a, b, a, b, a, bab, b, a], [a, a, b, a, b, aba, b, b, a], [a, a, b, a, b, aba, bb, a], [a, a, b, a, bab, a, b, b, a], [a, a, b, a, bab, a, bb, a], [a, a, b, a, bab, abba], [a, a, b, a, babab, b, a], [a, a, b, aba, b, a, b, b, a], [a, a, b, aba, b, a, bb, a], [a, a, b, aba, b, abba], [a, a, b, aba, bab, b, a], [a, a, b, ababa, b, b, a], [a, a, b, ababa, bb, a], [a, a, bab, a, b, a, b, b, a], [a, a, bab, a, b, a, bb, a], [a, a, bab, a, b, abba], [a, a, bab, a, bab, b, a], [a, a, bab, aba, b, b, a], [a, a, bab, aba, bb, a], [a, a, babab, a, b, b, a], [a, a, babab, a, bb, a], [a, a, babab, abba], [a, a, bababab, b, a], [a, aba, b, a, b, a, b, b, a], [a, aba, b, a, b, a, bb, a], [a, aba, b, a, b, abba], [a, aba, b, a, bab, b, a], [a, aba, b, aba, b, b, a], [a, aba, b, aba, bb, a], [a, aba, bab, a, b, b, a], [a, aba, bab, a, bb, a], [a, aba, bab, abba], [a, aba, babab, b, a], [a, ababa, b, a, b, b, a], [a, ababa, b, a, bb, a], [a, ababa, b, abba], [a, ababa, bab, b, a], [a, abababa, b, b, a], [a, abababa, bb, a], [aa, b, a, b, a, b, a, b, b, a], [aa, b, a, b, a, b, a, bb, a], [aa, b, a, b, a, b, abba], [aa, b, a, b, a, bab, b, a], [aa, b, a, b, aba, b, b, a], [aa, b, a, b, aba, bb, a], [aa, b, a, bab, a, b, b, a], [aa, b, a, bab, a, bb, a], [aa, b, a, bab, abba], [aa, b, a, babab, b, a], [aa, b, aba, b, a, b, b, a], [aa, b, aba, b, a, bb, a], [aa, b, aba, b, abba], [aa, b, aba, bab, b, a], [aa, b, ababa, b, b, a], [aa, b, ababa, bb, a], [aa, bab, a, b, a, b, b, a], [aa, bab, a, b, a, bb, a], [aa, bab, a, b, abba], [aa, bab, a, bab, b, a], [aa, bab, aba, b, b, a], [aa, bab, aba, bb, a], [aa, babab, a, b, b, a], [aa, babab, a, bb, a], [aa, babab, abba], [aa, bababab, b, a]]

[[a, a, b, a, b, a, a, b], [a, a, b, a, b, aa, b], [a, a, b, a, baab], [a, a, b, aba, a, b], [a, a, bab, a, a, b], [a, a, bab, aa, b], [a, aba, b, a, a, b], [a, aba, b, aa, b], [a, aba, baab], [a, ababa, a, b], [aa, b, a, b, a, a, b], [aa, b, a, b, aa, b], [aa, b, a, baab], [aa, b, aba, a, b], [aa, bab, a, a, b], [aa, bab, aa, b], [aababaa, b]]

[[a, a, b, a, b, b, a, a, b, b, a, a], [a, a, b, a, b, b, a, a, b, b, aa], [a, a, b, a, b, b, a, a, bb, a, a], [a, a, b, a, b, b, a, a, bb, aa], [a, a, b, a, b, b, a, abba, a], [a, a, b, a, b, b, aa, b, b, a, a], [a, a, b, a, b, b, aa, b, b, aa], [a, a, b, a, b, b, aa, bb, a, a], [a, a, b, a, b, b, aa, bb, aa], [a, a, b, a, b, b, aabbaa], [a, a, b, a, b, baab, b, a, a], [a, a, b, a, b, baab, b, aa], [a, a, b, a, bb, a, a, b, b, a, a], [a, a, b, a, bb, a, a, b, b, aa], [a, a, b, a, bb, a, a, bb, a, a], [a, a, b, a, bb, a, a, bb, aa], [a, a, b, a, bb, a, abba, a], [a, a, b, a, bb, aa, b, b, a, a], [a, a, b, a, bb, aa, b, b, aa], [a, a, b, a, bb, aa, bb, a, a], [a, a, b, a, bb, aa, bb, aa], [a, a, b, a, bb, aabbaa], [a, a, b, a, bbaabb, a, a], [a, a, b, a, bbaabb, aa], [a, a, b, abba, a, b, b, a, a], [a, a, b, abba, a, b, b, aa], [a, a, b, abba, a, bb, a, a], [a, a, b, abba, a, bb, aa], [a, a, b, abba, abba, a], [a, a, b, abbaabba, a], [a, a, bab, b, a, a, b, b, a, a], [a, a, bab, b, a, a, b, b, aa], [a, a, bab, b, a, a, bb, a, a], [a, a, bab, b, a, a, bb, aa], [a, a, bab, b, a, abba, a], [a, a, bab, b, aa, b, b, a, a], [a, a, bab, b, aa, b, b, aa], [a, a, bab, b, aa, bb, a, a], [a, a, bab, b, aa, bb, aa], [a, a, bab, b, aabbaa], [a, a, bab, baab, b, a, a], [a, a, bab, baab, b, aa], [a, aba, b, b, a, a, b, b, a, a], [a, aba, b, b, a, a, b, b, aa], [a, aba, b, b, a, a, bb, a, a], [a, aba, b, b, a, a, bb, aa], [a, aba, b, b, a, abba, a], [a, aba, b, b, aa, b, b, a, a], [a, aba, b, b, aa, b, b, aa], [a, aba, b, b, aa, bb, a, a], [a, aba, b, b, aa, bb, aa], [a, aba, b, b, aabbaa], [a, aba, b, baab, b, a, a], [a, aba, b, baab, b, aa], [a, aba, bb, a, a, b, b, a, a], [a, aba, bb, a, a, b, b, aa], [a, aba, bb, a, a, bb, a, a], [a, aba, bb, a, a, bb, aa], [a, aba, bb, a, abba, a], [a, aba, bb, aa, b, b, a, a], [a, aba, bb, aa, b, b, aa], [a, aba, bb, aa, bb, a, a], [a, aba, bb, aa, bb, aa], [a, aba, bb, aabbaa], [a, aba, bbaabb, a, a], [a, aba, bbaabb, aa], [aa, b, a, b, b, a, a, b, b, a, a], [aa, b, a, b, b, a, a, b, b, aa], [aa, b, a, b, b, a, a, bb, a, a], [aa, b, a, b, b, a, a, bb, aa], [aa, b, a, b, b, a, abba, a], [aa, b, a, b, b, aa, b, b, a, a], [aa, b, a, b, b, aa, b, b, aa], [aa, b, a, b, b, aa, bb, a, a], [aa, b, a, b, b, aa, bb, aa], [aa, b, a, b, b, aabbaa], [aa, b, a, b, baab, b, a, a], [aa, b, a, b, baab, b, aa], [aa, b, a, bb, a, a, b, b, a, a], [aa, b, a, bb, a, a, b, b, aa], [aa, b, a, bb, a, a, bb, a, a], [aa, b, a, bb, a, a, bb, aa], [aa, b, a, bb, a, abba, a], [aa, b, a, bb, aa, b, b, a, a], [aa, b, a, bb, aa, b, b, aa], [aa, b, a, bb, aa, bb, a, a], [aa, b, a, bb, aa, bb, aa], [aa, b, a, bb, aabbaa], [aa, b, a, bbaabb, a, a], [aa, b, a, bbaabb, aa], [aa, b, abba, a, b, b, a, a], [aa, b, abba, a, b, b, aa], [aa, b, abba, a, bb, a, a], [aa, b, abba, a, bb, aa], [aa, b, abba, abba, a], [aa, b, abbaabba, a], [aa, bab, b, a, a, b, b, a, a], [aa, bab, b, a, a, b, b, aa], [aa, bab, b, a, a, bb, a, a], [aa, bab, b, a, a, bb, aa], [aa, bab, b, a, abba, a], [aa, bab, b, aa, b, b, a, a], [aa, bab, b, aa, b, b, aa], [aa, bab, b, aa, bb, a, a], [aa, bab, b, aa, bb, aa], [aa, bab, b, aabbaa], [aa, bab, baab, b, a, a], [aa, bab, baab, b, aa]]

[[a, a, b, b, a, a, b, a, b], [a, a, b, b, a, a, bab], [a, a, b, b, a, aba, b], [a, a, b, b, aa, b, a, b], [a, a, b, b, aa, bab], [a, a, b, baab, a, b], [a, a, bb, a, a, b, a, b], [a, a, bb, a, a, bab], [a, a, bb, a, aba, b], [a, a, bb, aa, b, a, b], [a, a, bb, aa, bab], [a, abba, a, b, a, b], [a, abba, a, bab], [a, abba, aba, b], [aa, b, b, a, a, b, a, b], [aa, b, b, a, a, bab], [aa, b, b, a, aba, b], [aa, b, b, aa, b, a, b], [aa, b, b, aa, bab], [aa, b, baab, a, b], [aa, bb, a, a, b, a, b], [aa, bb, a, a, bab], [aa, bb, a, aba, b], [aa, bb, aa, b, a, b], [aa, bb, aa, bab], [aabbaa, b, a, b], [aabbaa, bab]]

```java
import java.util.ArrayList;
import java.util.List;

public class Solution {
    private boolean isPalindrome(String s, int start, int end) {
        while (start < end) {
            if (s.charAt(start++) != s.charAt(end--)) return false;
        }
        return true;
    }

    private void dfs(String s, int start, List<List<String>> results, List<String> current) {
        if (start == s.length()) {
            results.add(new ArrayList<>(current));
            return;
        }

        for (int end = start; end < s.length(); end++) {
            if (isPalindrome(s, start, end)) {
                current.add(s.substring(start, end + 1));
                dfs(s, end + 1, results, current);
                current.remove(current.size() - 1);
            }
        }
    }

    public List<List<String>> partition(String s) {
        List<List<String>> results = new ArrayList<>();
        List<String> current = new ArrayList<>();
        dfs(s, 0, results, current);
        return results;
    }
}
```


```cpp
#include <vector>
#include <string>

int minCut(std::string s) {
    int n = s.size();
    std::vector<int> dp(n + 1, 0);
    std::vector<std::vector<bool>> isPalindrome(n, std::vector<bool>(n, false));

    for (int i = 0; i <= n; i++) {
        dp[i] = i - 1;
    }

    for (int j = 1; j < n; j++) {
        for (int i = j; i >= 0; i--) {
            if (s[i] == s[j] && (j - i < 2 || isPalindrome[i + 1][j - 1])) {
                isPalindrome[i][j] = true;
                dp[j + 1] = std::min(dp[j + 1], dp[i] + 1);
            }
        }
    }

    return dp[n];
}
```

aabbccdd abc aabbccdd aabbccdd aabbccdd a aabbccdd a aabbccdd ab abcbcb aabbccdd ab aabbccdd aabbccdd aab abcddcba aabbccdd aba aabbccdd aabbccdd madamimadam aabbccdd aabbccdd aabbccdd aabbccdd aab aabbccdd aabbccdd aabbccdd aabbccdd abba aabbccdd aabbccdd aaab aabbcc racecar aabbccdd aabbccdd aabbccdd abcba aba aabcba aabbccdd aab abba aabbccdd aabbccdd

```python
def minCut(s):
    n = len(s)
    dp = [i - 1 for i in range(n + 1)]
    is_palindrome = [[False] * n for _ in range(n)]

    for j in range(1, n):
        for i in range(j, -1, -1):
            if s[i] == s[j] and (j - i < 2 or is_palindrome[i + 1][j - 1]):
                is_palindrome[i][j] = True
                dp[j + 1] = min(dp[j + 1], dp[i] + 1)

    return dp[n]
```


```python
def min_candies(ratings):
    n = len(ratings)
    candies = [1] * n

    for i in range(1, n):
        if ratings[i] > ratings[i - 1]:
            candies[i] = candies[i - 1] + 1

    for i in range(n - 2, -1, -1):
        if ratings[i] > ratings[i + 1]:
            candies[i] = max(candies[i], candies[i + 1] + 1)

    return sum(candies)
```

```cpp
#include <vector>
using namespace std;

int minCandies(vector<int>& ratings) {
    int n = ratings.size();
    vector<int> candies(n, 1);

    for(int i = 1; i < n; i++) {
        if(ratings[i] > ratings[i-1]) candies[i] = candies[i-1] + 1;
    }
    for(int i = n - 2; i >= 0; i--) {
        if(ratings[i] > ratings[i+1]) candies[i] = max(candies[i], candies[i+1] + 1);
    }

    int sum = 0;
    for(int candy : candies) sum += candy;

    return sum;
}
```


```python
def word_break(s, word_dict):
    word_set = set(word_dict)
    dp = [False] * (len(s) + 1)
    dp[0] = True
    for i in range(1, len(s) + 1):
        for j in range(i):
            if dp[j] and s[j:i] in word_set:
                dp[i] = True
                break
    return dp[len(s)]
```

s =  "leetcode ", wordDict = \[ "leet ", "code "\]

applepenappleisdelicious
["apple", "pen", "apple", "is", "delicious"]

applepiecatdogiscool
["apple", "pie", "cat", "dog", "is", "cool"]

catsanddog
["cats", "dog", "sand", "and"]

applepieiscool
["apple", "pie", "is", "cool"]

leetcodewowapplepie
["leet", "code", "wow", "apple", "pie"]

catsandog
["cats", "dog", "sand", "and", "cat"]

leetcodewowapplepieisdelicious
["leet", "code", "wow", "apple", "pie", "is", "delicious"]

leetcodewowisawesome
["leet", "code", "wow", "is", "awesome"]

applepieapplepenisdelicious
["apple", "pie", "apple", "pen", "is", "delicious"]

leetcodewowleetcode
["leet", "code", "wow", "leetcode"]

catdogiscool
["cat", "dog", "is", "cool"]

leetcodeiscool
["leetcode", "is", "cool"]

applepenapplepie
["apple", "pen", "applepie"]

leetcodewowapplepieiscool
["leet", "code", "wow", "apple", "pie", "is", "cool"]

catdogapplepen
["cat", "dog", "apple", "pen"]

catdogapplepieiscool
["cat", "dog", "apple", "pie", "is", "cool"]

applepenapplepieiscool
["apple", "pen", "apple", "pie", "is", "cool"]

leetcodewowappleisdelicious
["leet", "code", "wow", "apple", "is", "delicious"]

leetcodewowapple
["leet", "code", "wow", "apple"]

leetcodewowisdelicious
["leet", "code", "wow", "is", "delicious"]

applepieisdelicious
["apple", "pie", "is", "delicious"]

applepieapplepeniscool
["apple", "pie", "apple", "pen", "is", "cool"]

applepiecatdogisdelicious
["apple", "pie", "cat", "dog", "is", "delicious"]

leetcodeisawesome
["leetcode", "is", "awesome"]

applepenapplepieisdelicious
["apple", "pen", "apple", "pie", "is", "delicious"]

catdogapplepieisdelicious
["cat", "dog", "apple", "pie", "is", "delicious"]

catdogapplepenisdelicious
["cat", "dog", "apple", "pen", "is", "delicious"]

false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false

```cpp
#include <vector>
#include <string>
#include <unordered_set>

bool wordBreak(std::string s, std::vector<std::string>& wordDict) {
    std::unordered_set<std::string> dict(wordDict.begin(), wordDict.end());
    std::vector<bool> dp(s.size() + 1, false);
    dp[0] = true;
    for (size_t i = 1; i <= s.size(); ++i) {
        for (size_t j = 0; j < i; ++j) {
            if (dp[j] && dict.find(s.substr(j, i - j)) != dict.end()) {
                dp[i] = true;
                break;
            }
        }
    }
    return dp[s.size()];
}
```


```python
def word_break(s, word_dict):
    def helper(s, dict, memo):
        if s in memo:
            return memo[s]

        res = []
        if s in dict:
            res.append(s)

        for i in range(1, len(s)):
            prefix = s[:i]
            if prefix not in dict:
                continue
            suffix = s[i:]
            temp = helper(suffix, dict, memo)
            for t in temp:
                res.append(prefix + " " + t)

        memo[s] = res
        return res

    word_set = set(word_dict)
    memo = {}
    return helper(s, word_set, memo)
```

s =  "catsanddog ", wordDict = \[ "cat ", "cats ", "and ", "sand ", "dog "\]

pineapplepenapple
["apple", "pen", "applepen", "pine", "pineapple"]

catsandog
["cats", "dog", "sand", "and", "cat"]

emptystring
["empty", "string", "estring"]

catsanddog
["cat", "cats", "and", "sand", "dog"]

entertainment
["enter", "tain", "ment", "entertainment"]

catsanddog
[ "cat ", "cats ", "and ", "sand ", "dog "]

[pine apple pen apple, pine applepen apple, pineapple pen apple]

```java
import java.util.*;

public List<String> wordBreak(String s, List<String> wordDict) {
    HashSet<String> dict = new HashSet<>(wordDict);
    HashMap<String, List<String>> memo = new HashMap<>();
    return helper(s, dict, memo);
}

private List<String> helper(String s, HashSet<String> dict, HashMap<String, List<String>> memo) {
    if (memo.containsKey(s)) {
        return memo.get(s);
    }

    List<String> res = new ArrayList<>();
    if (dict.contains(s)) {
        res.add(s);
    }

    for (int i = 1; i < s.length(); ++i) {
        String prefix = s.substring(0, i);
        if (!dict.contains(prefix)) continue;
        String suffix = s.substring(i);
        List<String> temp = helper(suffix, dict, memo);
        for (String t : temp) {
            res.add(prefix + " " + t);
        }
    }

    memo.put(s, res);
    return res;
}
```


```python
def hasCycle(head):
    slow = fast = head
    while fast is not None and fast.next is not None:
        slow = slow.next
        fast = fast.next.next
        if slow == fast:
            return True
    return False
```

false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false

```java
public boolean hasCycle(ListNode head) {
    ListNode slow = head, fast = head;
    while (fast != null && fast.next != null) {
        slow = slow.next;
        fast = fast.next.next;
        if (slow == fast) {
            return true;
        }
    }
    return false;
}
```


```cpp
class ListNode {
public:
    int val;
    ListNode* next;
};

ListNode* detectCycle(ListNode* head) {
    ListNode* slow = head;
    ListNode* fast = head;

    while (fast != nullptr && fast->next != nullptr) {
        slow = slow->next;
        fast = fast->next->next;

        if (slow == fast) {
            ListNode* start = head;
            while (start != slow) {
                start = start->next;
                slow = slow->next;
            }
            return start;
        }
    }

    return nullptr;
}
```

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

def detectCycle(head):
    slow, fast = head, head

    while fast and fast.next:
        slow = slow.next
        fast = fast.next.next

        if slow == fast:
            start = head
            while start != slow:
                start = start.next
                slow = slow.next
            return start

    return None
```


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

def reorderList(head):
    if not head or not head.next or not head.next.next:
        return

    # Find the middle node
    slow = head
    fast = head
    while fast.next and fast.next.next:
        slow = slow.next
        fast = fast.next.next

    # Reverse the second half
    prev = None
    curr = slow.next
    while curr:
        next = curr.next
        curr.next = prev
        prev = curr
        curr = next
    slow.next = None

    # Merge two halves
    first = head
    second = prev
    while second:
        next = first.next
        first.next = second
        first = second
        second = next
```

```cpp
class ListNode {
public:
    int val;
    ListNode* next;
    ListNode(int x) : val(x), next(NULL) {}
};

void reorderList(ListNode* head) {
    if (!head || !head->next || !head->next->next) return;

    // Find the middle node
    ListNode* slow = head;
    ListNode* fast = head;
    while (fast->next && fast->next->next) {
        slow = slow->next;
        fast = fast->next->next;
    }

    // Reverse the second half
    ListNode* prev = nullptr;
    ListNode* curr = slow->next;
    ListNode* next;
    while (curr) {
        next = curr->next;
        curr->next = prev;
        prev = curr;
        curr = next;
    }
    slow->next = nullptr;

    // Merge two halves
    ListNode* first = head;
    ListNode* second = prev;
    while (second) {
        next = first->next;
        first = first->next = second;
        second = next;
    }
}
```


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

def preorderTraversal(root):
    if root is None:
        return []

    return [root.val] + preorderTraversal(root.left) + preorderTraversal(root.right)
```

```java
import java.util.ArrayList;
import java.util.List;

public class TreeNode {
    int val;
    TreeNode left;
    TreeNode right;
    TreeNode() {}
    TreeNode(int val) { this.val = val; }
    TreeNode(int val, TreeNode left, TreeNode right) {
        this.val = val;
        this.left = left;
        this.right = right;
    }
}

public List<Integer> preorderTraversal(TreeNode root) {
    List<Integer> result = new ArrayList<>();

    if (root == null) {
        return result;
    }

    result.add(root.val);
    result.addAll(preorderTraversal(root.left));
    result.addAll(preorderTraversal(root.right));

    return result;
}
```


```java
import java.util.ArrayList;
import java.util.List;
import java.util.Stack;

public class TreeNode {
    int val;
    TreeNode left;
    TreeNode right;
    TreeNode(int x) { val = x; }
}

public List<Integer> postorderTraversal(TreeNode root) {
    List<Integer> result = new ArrayList<>();
    Stack<TreeNode> s = new Stack<>();

    if (root == null) return result;

    s.push(root);
    while (!s.isEmpty()) {
        TreeNode current = s.pop();
        result.add(0, current.val);
        if (current.left != null) s.push(current.left);
        if (current.right != null) s.push(current.right);
    }

    return result;
}
```

```cpp
#include <vector>
#include <stack>
using namespace std;

struct TreeNode {
    int val;
    TreeNode *left;
    TreeNode *right;
    TreeNode(int x) : val(x), left(NULL), right(NULL) {}
};

vector<int> postorderTraversal(TreeNode* root) {
    vector<int> result;
    stack<TreeNode*> s;

    if (!root) return result;

    s.push(root);
    while (!s.empty()) {
        TreeNode *current = s.top();
        s.pop();
        result.insert(result.begin(), current->val);
        if (current->left) s.push(current->left);
        if (current->right) s.push(current->right);
    }

    return result;
}
```


```java
class ListNode {
    int val;
    ListNode next;
}

public ListNode insertionSortList(ListNode head) {
    ListNode dummy = new ListNode(0);
    ListNode cur;

    while (head != null) {
        cur = dummy;
        while (cur.next != null && cur.next.val < head.val) {
            cur = cur.next;
        }

        ListNode temp = head.next;
        head.next = cur.next;
        cur.next = head;
        head = temp;
    }

    return dummy.next;
}
```

```cpp
class ListNode {
public:
    int val;
    ListNode *next;
};

ListNode* insertionSortList(ListNode* head) {
    ListNode dummy(0);
    ListNode *cur;

    while (head) {
        cur = &dummy;
        while (cur->next && cur->next->val < head->val)
            cur = cur->next;

        ListNode* temp = head->next;
        head->next = cur->next;
        cur->next = head;
        head = temp;
    }

    return dummy.next;
}
```


```python
from math import gcd
from collections import defaultdict

def maxPoints(points):
    n = len(points)
    if n <= 2:
        return n

    max_count = 0

    for i in range(n):
        slope_map = defaultdict(int)
        duplicates = 0
        local_max = 0

        for j in range(i+1, n):
            deltaX = points[j][0] - points[i][0]
            deltaY = points[j][1] - points[i][1]

            if deltaX == 0 and deltaY == 0:
                duplicates += 1
                continue

            g = gcd(deltaX, deltaY)
            deltaX = deltaX // g
            deltaY = deltaY // g

            key = f"{deltaX}_{deltaY}"
            slope_map[key] += 1
            local_max = max(local_max, slope_map[key])

        max_count = max(max_count, local_max + duplicates + 1)

    return max_count
```

```java
import java.util.HashMap;

public int maxPoints(int[][] points) {
    int n = points.length;
    if (n <= 2) return n;
    int maxCount = 0;

    for (int i = 0; i < n-1; i++) {
        HashMap<String, Integer> slopeMap = new HashMap<>();
        int duplicates = 0, localMax = 0;

        for (int j = i+1; j < n; j++) {
            int deltaX = points[j][0] - points[i][0];
            int deltaY = points[j][1] - points[i][1];

            if (deltaX == 0 && deltaY == 0) {
                duplicates++;
                continue;
            }

            int gcd = gcd(deltaX, deltaY);
            deltaX /= gcd;
            deltaY /= gcd;

            String key = deltaX + "_" + deltaY;
            slopeMap.put(key, slopeMap.getOrDefault(key, 0) + 1);
            localMax = Math.max(localMax, slopeMap.get(key));
        }
        maxCount = Math.max(maxCount, localMax + duplicates + 1);
    }

    return maxCount;
}

private int gcd(int a, int b) {
    if(b == 0) return a;
    return gcd(b, a % b);
}
```


```cpp
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>

std::string reverseWords(std::string s) {
    std::stringstream ss(s);
    std::vector<std::string> words;
    std::string temp;

    while (ss >> temp) {
        words.push_back(temp);
    }

    std::reverse(words.begin(), words.end());

    std::string result;
    for (size_t i = 0; i < words.size(); ++i) {
        result += words[i] + (i < words.size() - 1 ? " " : "");
    }

    return result;
}
```

the lazy brown dog jumps over the quick brown fox

the lazy brown cat jumps over the quick brown fox

the quick brown fox jumps over the lazy brown cat

the lazy brown dog jumps over the quick brown cat

the lazy brown fox jumps over the quick brown dog

the quick brown cat jumps over the lazy brown dog

the quick brown dog jumps over the lazy brown fox

the quick brown fox jumps over the lazy dog

example   of   a   very   long   sentence

the quick brown fox jumps over the lazy brown dog

the quick red fox jumps over the lazy brown dog

cat brown quick the over jumps dog brown lazy the

fox brown quick the over jumps cat brown lazy the

cat brown lazy the over jumps fox brown quick the

dog brown quick the over jumps fox brown lazy the

dog brown lazy the over jumps cat brown quick the

fox brown lazy the over jumps dog brown quick the

dog brown lazy the over jumps fox red quick the

fox brown quick the over jumps dog brown lazy the

dog lazy the over jumps fox brown quick the

dog brown lazy the over jumps fox brown quick the

```python
def reverseWords(s):
    words = s.split()
    words.reverse()
    return ' '.join(words)
```


```java
public int maxProduct(int[] nums) {
    int max_so_far = nums[0];
    int min_so_far = nums[0];
    int result = nums[0];

    for (int i = 1; i < nums.length; i++) {
        if (nums[i] < 0) {
            int temp = max_so_far;
            max_so_far = min_so_far;
            min_so_far = temp;
        }

        max_so_far = Math.max(nums[i], max_so_far * nums[i]);
        min_so_far = Math.min(nums[i], min_so_far * nums[i]);
        result = Math.max(result, max_so_far);
    }
    return result;
}
```

```cpp
int maxProduct(vector<int>& nums) {
    int max_so_far = nums[0];
    int min_so_far = nums[0];
    int result = nums[0];

    for (int i = 1; i < nums.size(); i++) {
        if (nums[i] < 0)
            swap(max_so_far, min_so_far);

        max_so_far = max(nums[i], max_so_far * nums[i]);
        min_so_far = min(nums[i], min_so_far * nums[i]);
        result = max(result, max_so_far);
    }
    return result;
}
```


```java
public int findMin(int[] nums) {
    int low = 0, high = nums.length - 1;

    while (low < high) {
        int mid = low + (high - low) / 2;
        if (nums[mid] > nums[high]) {
            low = mid + 1;
        } else if (nums[mid] < nums[high]) {
            high = mid;
        } else {
            high--;
        }
    }
    return nums[low];
}
```

```cpp
int findMin(vector<int>& nums) {
    int low = 0, high = nums.size() - 1;

    while (low < high) {
        int mid = low + (high - low) / 2;
        if (nums[mid] > nums[high]) {
            low = mid + 1;
        } else if (nums[mid] < nums[high]) {
            high = mid;
        } else {
            high--;
        }
    }
    return nums[low];
}
```


```python
class TreeNode:
    def __init__(self, x):
        self.val = x
        self.left = None
        self.right = None

def upside_down_binary_tree(root):
    if not root or not root.left:
        return root
    new_root = upside_down_binary_tree(root.left)
    root.left.right = root
    root.left.left = root.right
    root.left = None
    root.right = None
    return new_root
```

```cpp
class TreeNode {
public:
    int val;
    TreeNode *left;
    TreeNode *right;
    TreeNode(int x) : val(x), left(NULL), right(NULL) {}
};

TreeNode* upsideDownBinaryTree(TreeNode* root) {
    if (root == nullptr || root->left == nullptr) {
        return root;
    }
    TreeNode* new_root = upsideDownBinaryTree(root->left);
    root->left->right = root;
    root->left->left = root->right;
    root->left = nullptr;
    root->right = nullptr;
    return new_root;
}
```


```cpp
int lengthOfLongestSubstringTwoDistinct(string s) {
    int l = 0, r = 0, max_len = 0, cur_len = 0;
    unordered_map<char, int> char_count;

    while (r < s.length()) {
        char_count[s[r]]++;
        if (char_count.size() <= 2) {
            cur_len++;
        } else {
            while (char_count.size() > 2 && l <= r) {
                char_count[s[l]]--;
                if (char_count[s[l]] == 0) {
                    char_count.erase(s[l]);
                }
                l++;
                cur_len--;
            }
            cur_len++;
        }
        max_len = max(max_len, cur_len);
        r++;
    }
    return max_len;
}
```

abac aaabbb abcabc eceba aaabcaa abcde 12345 aaaaa eceba

```java
public int lengthOfLongestSubstringTwoDistinct(String s) {
    int l = 0, r = 0, max_len = 0, cur_len = 0;
    HashMap<Character, Integer> char_count = new HashMap<>();

    while (r < s.length()) {
        char_count.put(s.charAt(r), char_count.getOrDefault(s.charAt(r), 0) + 1);
        if (char_count.size() <= 2) {
            cur_len++;
        } else {
            while (char_count.size() > 2 && l <= r) {
                char_count.put(s.charAt(l), char_count.get(s.charAt(l)) - 1);
                if (char_count.get(s.charAt(l)) == 0) {
                    char_count.remove(s.charAt(l));
                }
                l++;
                cur_len--;
            }
            cur_len++;
        }
        max_len = Math.max(max_len, cur_len);
        r++;
    }
    return max_len;
}
```


```python
def findPeakElement(nums):
    left, right = 0, len(nums) - 1
    while left < right:
        mid = left + (right - left) // 2
        if nums[mid] < nums[mid + 1]:
            left = mid + 1
        else:
            right = mid
    return left
```

```cpp
int findPeakElement(vector<int>& nums) {
    int left = 0, right = nums.size() - 1;
    while (left < right) {
        int mid = left + (right - left) / 2;
        if (nums[mid] < nums[mid + 1]) {
            left = mid + 1;
        } else {
            right = mid;
        }
    }
    return left;
}
```


```cpp
#include <vector>
#include <string>

std::vector<std::string> findMissingRanges(std::vector<int>& nums, int lower, int upper) {
    std::vector<std::string> result;
    long prev = (long)lower - 1;

    for (int i = 0; i <= nums.size(); ++i) {
        long cur = (i == nums.size()) ? (long)upper + 1 : nums[i];
        if (cur - prev >= 2) {
            result.push_back(std::to_string(prev + 1) + (cur - prev == 2 ? "" : "->") + std::to_string(cur - 1));
        }
        prev = cur;
    }

    return result;
}
```

```java
import java.util.ArrayList;
import java.util.List;

public List<String> findMissingRanges(int[] nums, int lower, int upper) {
    List<String> result = new ArrayList<>();
    long prev = (long) lower - 1;

    for (int i = 0; i <= nums.length; ++i) {
        long cur = (i == nums.length) ? (long) upper + 1 : nums[i];
        if (cur - prev >= 2) {
            result.add(Long.toString(prev + 1) + (cur - prev == 2 ? "" : "->") + Long.toString(cur - 1));
        }
        prev = cur;
    }

    return result;
}
```


```cpp
int maximumGap(vector<int>& nums) {
    if (nums.size() < 2) return 0;

    int min_val = *min_element(nums.begin(), nums.end());
    int max_val = *max_element(nums.begin(), nums.end());
    int len = nums.size();
    int bucket_size = max(1, (max_val - min_val) / (len - 1));
    int bucket_num = (max_val - min_val) / bucket_size + 1;
    vector<pair<int, int>> buckets(bucket_num, {INT_MAX, INT_MIN});

    for (int num : nums) {
        int idx = (num - min_val) / bucket_size;
        buckets[idx].first = min(buckets[idx].first, num);
        buckets[idx].second = max(buckets[idx].second, num);
    }

    int max_gap = 0, prev_max = min_val;
    for (auto& bucket : buckets) {
        if (bucket.first == INT_MAX) continue;
        max_gap = max(max_gap, bucket.first - prev_max);
        prev_max = bucket.second;
    }
    return max_gap;
}
```

```python
def maximumGap(nums):
    if len(nums) < 2:
        return 0

    min_val = min(nums)
    max_val = max(nums)
    length = len(nums)
    bucket_size = max(1, (max_val - min_val) // (length - 1))
    bucket_num = (max_val - min_val) // bucket_size + 1
    buckets = [[float("inf"), float("-inf")] for _ in range(bucket_num)]

    for num in nums:
        idx = (num - min_val) // bucket_size
        buckets[idx][0] = min(buckets[idx][0], num)
        buckets[idx][1] = max(buckets[idx][1], num)

    max_gap = 0
    prev_max = min_val
    for bucket in buckets:
        if bucket[0] == float("inf"):
            continue
        max_gap = max(max_gap, bucket[0] - prev_max)
        prev_max = bucket[1]
    return max_gap
```


```python
def compare_version(version1, version2):
    v1 = version1.split('.')
    v2 = version2.split('.')

    while v1 or v2:
        num1 = int(v1.pop(0)) if v1 else 0
        num2 = int(v2.pop(0)) if v2 else 0

        if num1 < num2:
            return -1
        if num1 > num2:
            return 1
    return 0
```

```java
public int compareVersion(String version1, String version2) {
    int i = 0, j = 0;
    while (i < version1.length() || j < version2.length()) {
        int num1 = 0, num2 = 0;
        while (i < version1.length() && version1.charAt(i) != '.') {
            num1 = num1 * 10 + (version1.charAt(i++) - '0');
        }
        while (j < version2.length() && version2.charAt(j) != '.') {
            num2 = num2 * 10 + (version2.charAt(j++) - '0');
        }
        if (num1 < num2) return -1;
        if (num1 > num2) return 1;
        i++; j++;
    }
    return 0;
}
```


```java
import java.util.HashMap;

public String fractionToDecimal(int numerator, int denominator) {
    if (numerator == 0) return "0";
    StringBuilder res = new StringBuilder();
    if ((numerator > 0) ^ (denominator > 0)) res.append('-');
    long num = Math.abs((long)numerator), den = Math.abs((long)denominator);
    res.append(num / den);
    num %= den;
    if (num == 0) return res.toString();
    res.append('.');
    HashMap<Long, Integer> map = new HashMap<>();
    while (num != 0) {
        if (map.containsKey(num)) {
            res.insert(map.get(num), "(");
            res.append(")");
            break;
        }
        map.put(num, res.length());
        num *= 10;
        res.append(num / den);
        num %= den;
    }
    return res.toString();
}
```

```python
def fraction_to_decimal(numerator, denominator):
    if numerator == 0:
        return "0"
    res = []
    if (numerator > 0) ^ (denominator > 0):
        res.append("-")
    num = abs(numerator)
    den = abs(denominator)
    res.append(str(num // den))
    num %= den
    if num == 0:
        return "".join(res)
    res.append(".")
    map = {}
    while num:
        if num in map:
            res.insert(map[num], "(")
            res.append(")")
            break
        map[num] = len(res)
        num *= 10
        res.append(str(num // den))
        num %= den
    return "".join(res)
```


```cpp
#include <vector>
using namespace std;

vector<int> twoSum(vector<int>& numbers, int target) {
    int left = 0, right = numbers.size() - 1;
    while (left < right) {
        int current_sum = numbers[left] + numbers[right];
        if (current_sum == target) {
            return {left + 1, right + 1};
        } else if (current_sum < target) {
            left++;
        } else {
            right--;
        }
    }
    return {};
}
```

```python
def twoSum(numbers, target):
    left, right = 0, len(numbers) - 1
    while left < right:
        current_sum = numbers[left] + numbers[right]
        if current_sum == target:
            return [left + 1, right + 1]
        elif current_sum < target:
            left += 1
        else:
            right -= 1
    return []
```


```java
public String convertToTitle(int columnNumber) {
    StringBuilder result = new StringBuilder();
    while (columnNumber > 0) {
        columnNumber--;
        result.insert(0, (char) ('A' + columnNumber % 26));
        columnNumber /= 26;
    }
    return result.toString();
}
```

```cpp
#include <string>

std::string convertToTitle(int columnNumber) {
    std::string result = "";
    while (columnNumber) {
        columnNumber--;
        result = (char)(columnNumber % 26 + 'A') + result;
        columnNumber /= 26;
    }
    return result;
}
```


```python
def majority_element(nums):
    count = 0
    candidate = None

    for num in nums:
        if count == 0:
            candidate = num
        count += (num == candidate) - (num != candidate)

    return candidate
```

```cpp
int majorityElement(vector<int>& nums) {
    int count = 0;
    int candidate;

    for (int num : nums) {
        if (count == 0) {
            candidate = num;
        }
        count += (num == candidate) ? 1 : -1;
    }

    return candidate;
}
```


```java
public int trailingZeroes(int n) {
    int count = 0;
    while (n > 0) {
        n = n / 5;
        count += n;
    }
    return count;
}
```

```cpp
int trailingZeroes(int n) {
    int count = 0;
    while (n > 0) {
        n /= 5;
        count += n;
    }
    return count;
}
```


```cpp
#include<vector>
using namespace std;

int calculateMinimumHP(vector<vector<int>>& dungeon) {
    int m = dungeon.size(), n = dungeon[0].size();
    vector<vector<int>> dp(m, vector<int>(n));

    for (int i = m - 1; i >= 0; i--) {
        for (int j = n - 1; j >= 0; j--) {
            if(i == m-1 && j == n-1){
                dp[i][j] = min(0, dungeon[i][j]);
            }
            else if (i == m - 1) {
                dp[i][j] = min(0, dp[i][j + 1] + dungeon[i][j]);
            }
            else if (j == n - 1) {
                dp[i][j] = min(0, dp[i + 1][j] + dungeon[i][j]);
            }
            else {
                dp[i][j] = min(0, max(dp[i + 1][j], dp[i][j + 1]) + dungeon[i][j]);
            }
        }
    }

    return abs(dp[0][0]) + 1;
}
```

```java
public int calculateMinimumHP(int[][] dungeon) {
    int m = dungeon.length, n = dungeon[0].length;
    int[][] dp = new int[m][n];

    for (int i = m - 1; i >= 0; i--) {
        for (int j = n - 1; j >= 0; j--) {
            if(i == m-1 && j == n-1)
                dp[i][j] = Math.min(0, dungeon[i][j]);
            else if (i == m - 1)
                dp[i][j] = Math.min(0, dp[i][j + 1] + dungeon[i][j]);
            else if (j == n - 1)
                dp[i][j] = Math.min(0, dp[i + 1][j] + dungeon[i][j]);
            else
                dp[i][j] = Math.min(0, Math.max(dp[i + 1][j], dp[i][j + 1]) + dungeon[i][j]);
        }
    }

    return Math.abs(dp[0][0]) + 1;
}
```


```java
import java.util.Arrays;
import java.util.Comparator;

public class Solution {
    public String largestNumber(int[] nums) {
        String[] strNums = new String[nums.length];
        for (int i = 0; i < nums.length; i++) {
            strNums[i] = String.valueOf(nums[i]);
        }
        Arrays.sort(strNums, (a, b) -> (b + a).compareTo(a + b));
        if (strNums[0].equals("0")) {
            return "0";
        }
        StringBuilder sb = new StringBuilder();
        for (String str : strNums) sb.append(str);
        return sb.toString();
    }
}
```

```python
from functools import cmp_to_key

def largestNumber(nums):
    def comparator(a, b):
        return -1 if a + b > b + a else int(a + b < b + a)

    nums_as_str = list(map(str, nums))
    nums_as_str.sort(key=cmp_to_key(comparator))
    return '0' if nums_as_str[0] == "0" else "".join(nums_as_str)
```


```cpp
#include <vector>
#include <algorithm>
int maxProfit(int k, std::vector<int>& prices) {
    int n = prices.size();
    if (k > n / 2) {
        int max_profit = 0;
        for (int i = 1; i < n; ++i)
            max_profit += std::max(prices[i] - prices[i - 1], 0);
        return max_profit;
    }

    std::vector<std::vector<int>> dp(k + 1, std::vector<int>(n, 0));
    for (int i = 1; i <= k; ++i) {
        int max_diff = -prices[0];
        for (int j = 1; j < n; ++j) {
            dp[i][j] = std::max(dp[i][j - 1], prices[j] + max_diff);
            max_diff = std::max(max_diff, dp[i - 1][j] - prices[j]);
        }
    }
    return dp[k][n - 1];
}
```

```python
def maxProfit(k, prices):
    n = len(prices)
    if k > n // 2:
        return sum(max(prices[i] - prices[i - 1], 0) for i in range(1, n))

    dp = [[0] * n for _ in range(k + 1)]
    for i in range(1, k + 1):
        max_diff = -prices[0]
        for j in range(1, n):
            dp[i][j] = max(dp[i][j - 1], prices[j] + max_diff)
            max_diff = max(max_diff, dp[i - 1][j] - prices[j])
    return dp[k][n - 1]
```


```cpp
#include <vector>
using namespace std;

void rotate(vector<int>& nums, int k) {
    int n = nums.size();
    k %= n;
    reverse(nums.begin(), nums.end());
    reverse(nums.begin(), nums.begin() + k);
    reverse(nums.begin() + k, nums.end());
}
```

```java
public void rotate(int[] nums, int k) {
    int n = nums.length;
    k %= n;
    reverse(nums, 0, n - 1);
    reverse(nums, 0, k - 1);
    reverse(nums, k, n - 1);
}

private void reverse(int[] nums, int start, int end) {
    while (start < end) {
        int temp = nums[start];
        nums[start++] = nums[end];
        nums[end--] = temp;
    }
}
```


```java
public int reverseBits(int n) {
    int res = 0;
    for (int i = 0; i < 32; ++i) {
        res <<= 1;
        res |= n & 1;
        n >>= 1;
    }
    return res;
}
```

```python
def reverse_bits(n: int) -> int:
    res = 0
    for _ in range(32):
        res <<= 1
        res |= n & 1
        n >>= 1
    return res
```


```python
def hamming_weight(n):
    count = 0
    while n:
        count += n & 1
        n >>= 1
    return count
```

```java
public int hammingWeight(int n) {
    int count = 0;
    while (n != 0) {
        count += n & 1;
        n >>>= 1;
    }
    return count;
}
```


```cpp
int rob(vector<int>& nums) {
    int prev1 = 0, prev2 = 0;
    for (const auto& num : nums) {
        int tmp = prev1;
        prev1 = max(prev2 + num, prev1);
        prev2 = tmp;
    }
    return prev1;
}
```

```python
def rob(nums):
    prev1, prev2 = 0, 0
    for num in nums:
        prev1, prev2 = max(prev2 + num, prev1), prev1
    return prev1
```


```cpp
#include <vector>
#include <queue>

using namespace std;

struct TreeNode {
    int val;
    TreeNode *left;
    TreeNode *right;
    TreeNode(int _val) : val(_val), left(nullptr), right(nullptr) {}
};

vector<int> rightSideView(TreeNode* root) {
    if (!root) return {};

    vector<int> result;
    queue<TreeNode*> q;
    q.push(root);

    while (!q.empty()) {
        int level_size = q.size();

        for (int i = 0; i < level_size; ++i) {
            TreeNode* current = q.front();
            q.pop();

            if (i == level_size - 1) result.push_back(current->val);
            if (current->left) q.push(current->left);
            if (current->right) q.push(current->right);
        }
    }

    return result;
}
```

```java
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;

class TreeNode {
    int val;
    TreeNode left;
    TreeNode right;
    TreeNode(int _val) { val = _val; }
}

public List<Integer> rightSideView(TreeNode root) {
    if (root == null) return new ArrayList<>();

    List<Integer> result = new ArrayList<>();
    Queue<TreeNode> queue = new LinkedList<>();
    queue.offer(root);

    while (!queue.isEmpty()) {
        int level_size = queue.size();

        for (int i = 0; i < level_size; i++) {
            TreeNode current = queue.poll();

            if (i == level_size - 1) result.add(current.val);
            if (current.left != null) queue.offer(current.left);
            if (current.right != null) queue.offer(current.right);
        }
    }

    return result;
}
```


```python
def dfs(grid, i, j):
    if i < 0 or i >= len(grid) or j < 0 or j >= len(grid[0]) or grid[i][j] == '0':
        return

    grid[i][j] = '0'
    dfs(grid, i + 1, j)
    dfs(grid, i - 1, j)
    dfs(grid, i, j + 1)
    dfs(grid, i, j - 1)

def numIslands(grid):
    count = 0
    for i in range(len(grid)):
        for j in range(len(grid[0])):
            if grid[i][j] == '1':
                count += 1
                dfs(grid, i, j)
    return count
```

```cpp
void dfs(vector<vector<char>>& grid, int i, int j) {
    if(i < 0 || i >= grid.size() || j < 0 || j >= grid[0].size() || grid[i][j] == '0')
        return;

    grid[i][j] = '0';
    dfs(grid, i + 1, j);
    dfs(grid, i - 1, j);
    dfs(grid, i, j + 1);
    dfs(grid, i, j - 1);
}

int numIslands(vector<vector<char>>& grid) {
    int count = 0;
    for(int i = 0; i < grid.size(); i++) {
        for(int j = 0; j < grid[0].size(); j++) {
            if(grid[i][j] == '1') {
                count++;
                dfs(grid, i, j);
            }
        }
    }
    return count;
}
```


```java
public int rangeBitwiseAnd(int left, int right) {
    int shift = 0;
    while (left != right) {
        left >>= 1;
        right >>= 1;
        shift++;
    }
    return left << shift;
}
```

```python
def range_bitwise_and(left: int, right: int) -> int:
    shift = 0
    while left != right:
        left >>= 1
        right >>= 1
        shift += 1
    return left << shift
```


```java
public int getNext(int n) {
    int sum = 0;
    while (n > 0) {
        int digit = n % 10;
        sum += digit * digit;
        n /= 10;
    }
    return sum;
}

public boolean isHappy(int n) {
    int slow = n, fast = getNext(n);
    while (fast != 1 && slow != fast) {
        slow = getNext(slow);
        fast = getNext(getNext(fast));
    }
    return fast == 1;
}
```

false true true false true true false false false false true false false true true true true true false true false true false true true false false true true false true true false true true true false true true true false true false true true false

```cpp
int getNext(int n) {
    int sum = 0;
    while (n > 0) {
        int digit = n % 10;
        sum += digit * digit;
        n /= 10;
    }
    return sum;
}

bool isHappy(int n) {
    int slow = n, fast = getNext(n);
    while (fast != 1 && slow != fast) {
        slow = getNext(slow);
        fast = getNext(getNext(fast));
    }
    return fast == 1;
}
```


```java
public class ListNode {
    int val;
    ListNode next;
    ListNode(int x) { val = x; }
}

public ListNode removeElements(ListNode head, int val) {
    ListNode sentinel = new ListNode(0);
    sentinel.next = head;
    ListNode prev = sentinel, curr = head;

    while (curr != null) {
        if (curr.val == val) {
            prev.next = curr.next;
        } else {
            prev = curr;
        }
        curr = curr.next;
    }

    return sentinel.next;
}
```

```cpp
class ListNode {
public:
    int val;
    ListNode* next;
    ListNode(int x) : val(x), next(NULL) {}
};

ListNode* removeElements(ListNode* head, int val) {
    ListNode** current = &head;

    while (*current != NULL) {
        if ((*current)->val == val) {
            ListNode* next = (*current)->next;
            delete *current;
            *current = next;
        } else {
            current = &(*current)->next;
        }
    }

    return head;
}
```


```cpp
int countPrimes(int n) {
    if (n <= 2) return 0;
    vector<bool> isPrime(n, true);
    isPrime[0] = isPrime[1] = false;
    for (int i = 2; i * i < n; ++i) {
        if (isPrime[i]) {
            for (int j = i * i; j < n; j += i) {
                isPrime[j] = false;
            }
        }
    }
    return count(isPrime.begin(), isPrime.end(), true);
}
```

```java
public int countPrimes(int n) {
    if (n <= 2) return 0;
    boolean[] isPrime = new boolean[n];
    Arrays.fill(isPrime, true);
    isPrime[0] = isPrime[1] = false;
    for (int i = 2; i * i < n; i++) {
        if (isPrime[i]) {
            for (int j = i * i; j < n; j += i) {
                isPrime[j] = false;
            }
        }
    }
    int count = 0;
    for (boolean prime : isPrime) {
        if (prime) count++;
    }
    return count;
}
```


```java
import java.util.HashMap;

public boolean isIsomorphic(String s, String t) {
    HashMap<Character, Character> map1 = new HashMap<>();
    HashMap<Character, Character> map2 = new HashMap<>();

    for (int i = 0; i < s.length(); i++) {
        char sChar = s.charAt(i);
        char tChar = t.charAt(i);

        if (!map1.containsKey(sChar)) {
            map1.put(sChar, tChar);
        }
        if (!map2.containsKey(tChar)) {
            map2.put(tChar, sChar);
        }

        if (map1.get(sChar) != tChar || map2.get(tChar) != sChar) {
           return false;
        }
    }
    return true;
}
```

True True True True True True False True True True True True True True True True True True True False True True True True True True True True False True True False True True False False True True True True True True True True False True True False False True True

```python
def is_isomorphic(s: str, t: str) -> bool:
    map1, map2 = {}, {}
    for char_s, char_t in zip(s, t):
        if char_s not in map1:
            map1[char_s] = char_t
        if char_t not in map2:
            map2[char_t] = char_s
        if map1[char_s] != char_t or map2[char_t] != char_s:
            return False
    return True
```


```cpp
class ListNode {
public:
    int val;
    ListNode *next;
};

ListNode* reverseList(ListNode* head) {
    ListNode* prev = nullptr;
    ListNode* current = head;
    ListNode* next = nullptr;
    while (current != nullptr) {
        next = current->next;
        current->next = prev;
        prev = current;
        current = next;
    }
    return prev;
}
```

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

def reverse_list(head):
    prev = None
    current = head
    while current is not None:
        next = current.next
        current.next = prev
        prev = current
        current = next
    return prev
```


```cpp
#include <vector>
#include <queue>

bool canFinish(int numCourses, std::vector<std::vector<int>>& prerequisites) {
    std::vector<std::vector<int>> adj(numCourses);
    std::vector<int> inDegree(numCourses, 0);

    for (auto& p : prerequisites) {
        adj[p[1]].push_back(p[0]);
        inDegree[p[0]]++;
    }

    std::queue<int> q;
    for (int i = 0; i < numCourses; i++) {
        if (inDegree[i] == 0) q.push(i);
    }

    while (!q.empty()) {
        int currCourse = q.front();
        q.pop();
        numCourses--;

        for (int nextCourse : adj[currCourse]) {
            inDegree[nextCourse]--;
            if (inDegree[nextCourse] == 0) q.push(nextCourse);
        }
    }

    return numCourses == 0;
}
```

numCourses = 2, prerequisites = \[\[1,0\]\]

true true true true true true true true true true true true true true false true true true true true true true true true true true true true true true true false true false false true true true true true true true true true true

```java
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;

public boolean canFinish(int numCourses, int[][] prerequisites) {
    List<List<Integer>> adj = new ArrayList<>(numCourses);
    int[] inDegree = new int[numCourses];

    for (int i = 0; i < numCourses; i++)
        adj.add(new ArrayList<>());

    for (int[] p : prerequisites) {
        adj.get(p[1]).add(p[0]);
        inDegree[p[0]]++;
    }

    Queue<Integer> q = new LinkedList<>();
    for (int i = 0; i < numCourses; i++) {
        if (inDegree[i] == 0) q.add(i);
    }

    while (!q.isEmpty()) {
        int currCourse = q.poll();
        numCourses--;

        for (int nextCourse : adj.get(currCourse)) {
            inDegree[nextCourse]--;
            if (inDegree[nextCourse] == 0) q.add(nextCourse);
        }
    }

    return numCourses == 0;
}
```


```java
public int minSubArrayLen(int target, int[] nums) {
    int left = 0, cur_sum = 0, min_len = Integer.MAX_VALUE;
    for (int right = 0; right < nums.length; right++) {
        cur_sum += nums[right];
        while (cur_sum >= target) {
            min_len = Math.min(min_len, right - left + 1);
            cur_sum -= nums[left++];
        }
    }
    return min_len == Integer.MAX_VALUE ? 0 : min_len;
}
```

```cpp
#include <climits>
int minSubArrayLen(int target, vector<int>& nums) {
    int left = 0, cur_sum = 0, min_len = INT_MAX;
    for (int right = 0; right < nums.size(); right++) {
        cur_sum += nums[right];
        while (cur_sum >= target) {
            min_len = min(min_len, right - left + 1);
            cur_sum -= nums[left++];
        }
    }
    return min_len == INT_MAX ? 0 : min_len;
}
```


```cpp
int rob(vector<int>& nums) {
    if (nums.size() == 1) return nums[0];
    int prev = 0, curr = 0;
    for (int i = 0; i < nums.size() - 1; i++) {
        int temp = max(curr, prev + nums[i]);
        prev = curr;
        curr = temp;
    }
    int res = curr;
    prev = 0;
    curr = 0;
    for (int i = 1; i < nums.size(); i++) {
        int temp = max(curr, prev + nums[i]);
        prev = curr;
        curr = temp;
    }
    return max(res, curr);
}
```

```java
public int rob(int[] nums) {
    if (nums.length == 1) return nums[0];
    int prev = 0, curr = 0;
    for (int i = 0; i < nums.length - 1; i++) {
        int temp = Math.max(curr, prev + nums[i]);
        prev = curr;
        curr = temp;
    }
    int res = curr;
    prev = 0;
    curr = 0;
    for (int i = 1; i < nums.length; i++) {
        int temp = Math.max(curr, prev + nums[i]);
        prev = curr;
        curr = temp;
    }
    return Math.max(res, curr);
}
```


```java
public String shortestPalindrome(String s) {
    int n = s.length();
    String rev_s = new StringBuilder(s).reverse().toString();

    for (int i = 0; i < n; ++i) {
        if(s.substring(0, n - i).equals(rev_s.substring(i)))
            return rev_s.substring(0, i) + s;
    }
    return "";
}
```

aaaa racecar a abac abcba abbaab aacecaaa

racecar a aaaa cabac aaacecaaa abcba baabbaab

```python
def shortest_palindrome(s: str) -> str:
    n = len(s)
    rev_s = s[::-1]

    for i in range(n):
        if s[:n - i] == rev_s[i:]:
            return rev_s[:i] + s
    return ""
```