Prompt:
def maxSpending(values: List[List[int]]) -> int:
    """
    You are given a 0-indexed m * n integer matrix values, representing the values of m * n different items in m different shops. Each shop has n items where the jth item in the ith shop has a value of values[i][j]. Additionally, the items in the ith shop are sorted in non-increasing order of value. That is, values[i][j] >= values[i][j + 1] for all 0 <= j < n - 1.
    On each day, you would like to buy a single item from one of the shops. Specifically, On the dth day you can:

    Pick any shop i.
    Buy the rightmost available item j for the price of values[i][j] * d. That is, find the greatest index j such that item j was never bought before, and buy it for the price of values[i][j] * d.

    Note that all items are pairwise different. For example, if you have bought item 0 from shop 1, you can still buy item 0 from any other shop.
    Return the maximum amount of money that can be spent on buying all  m * n products.

    Example 1:

    >>> maxSpending(values = [[8,5,2],[6,4,1],[9,7,3]])
    >>> 285
    Explanation: On the first day, we buy product 2 from shop 1 for a price of values[1][2] * 1 = 1.
    On the second day, we buy product 2 from shop 0 for a price of values[0][2] * 2 = 4.
    On the third day, we buy product 2 from shop 2 for a price of values[2][2] * 3 = 9.
    On the fourth day, we buy product 1 from shop 1 for a price of values[1][1] * 4 = 16.
    On the fifth day, we buy product 1 from shop 0 for a price of values[0][1] * 5 = 25.
    On the sixth day, we buy product 0 from shop 1 for a price of values[1][0] * 6 = 36.
    On the seventh day, we buy product 1 from shop 2 for a price of values[2][1] * 7 = 49.
    On the eighth day, we buy product 0 from shop 0 for a price of values[0][0] * 8 = 64.
    On the ninth day, we buy product 0 from shop 2 for a price of values[2][0] * 9 = 81.
    Hence, our total spending is equal to 285.
    It can be shown that 285 is the maximum amount of money that can be spent buying all m * n products.

    Example 2:

    >>> maxSpending(values = [[10,8,6,4,2],[9,7,5,3,2]])
    >>> 386
    Explanation: On the first day, we buy product 4 from shop 0 for a price of values[0][4] * 1 = 2.
    On the second day, we buy product 4 from shop 1 for a price of values[1][4] * 2 = 4.
    On the third day, we buy product 3 from shop 1 for a price of values[1][3] * 3 = 9.
    On the fourth day, we buy product 3 from shop 0 for a price of values[0][3] * 4 = 16.
    On the fifth day, we buy product 2 from shop 1 for a price of values[1][2] * 5 = 25.
    On the sixth day, we buy product 2 from shop 0 for a price of values[0][2] * 6 = 36.
    On the seventh day, we buy product 1 from shop 1 for a price of values[1][1] * 7 = 49.
    On the eighth day, we buy product 1 from shop 0 for a price of values[0][1] * 8 = 64
    On the ninth day, we buy product 0 from shop 1 for a price of values[1][0] * 9 = 81.
    On the tenth day, we buy product 0 from shop 0 for a price of values[0][0] * 10 = 100.
    Hence, our total spending is equal to 386.
    It can be shown that 386 is the maximum amount of money that can be spent buying all m * n products.
    """


Prompt:
def maximumStrongPairXor(nums: List[int]) -> int:
    """
    You are given a 0-indexed integer array nums. A pair of integers x and y is called a strong pair if it satisfies the condition:

    |x - y| <= min(x, y)

    You need to select two integers from nums such that they form a strong pair and their bitwise XOR is the maximum among all strong pairs in the array.
    Return the maximum XOR value out of all possible strong pairs in the array nums.
    Note that you can pick the same integer twice to form a pair.

    Example 1:

    >>> maximumStrongPairXor(nums = [1,2,3,4,5])
    >>> 7
    Explanation: There are 11 strong pairs in the array nums: (1, 1), (1, 2), (2, 2), (2, 3), (2, 4), (3, 3), (3, 4), (3, 5), (4, 4), (4, 5) and (5, 5).
    The maximum XOR possible from these pairs is 3 XOR 4 = 7.

    Example 2:

    >>> maximumStrongPairXor(nums = [10,100])
    >>> 0
    Explanation: There are 2 strong pairs in the array nums: (10, 10) and (100, 100).
    The maximum XOR possible from these pairs is 10 XOR 10 = 0 since the pair (100, 100) also gives 100 XOR 100 = 0.

    Example 3:

    >>> maximumStrongPairXor(nums = [5,6,25,30])
    >>> 7
    Explanation: There are 6 strong pairs in the array nums: (5, 5), (5, 6), (6, 6), (25, 25), (25, 30) and (30, 30).
    The maximum XOR possible from these pairs is 25 XOR 30 = 7 since the only other non-zero XOR value is 5 XOR 6 = 3.
    """


Prompt:
def findHighAccessEmployees(access_times: List[List[str]]) -> List[str]:
    """
    You are given a 2D 0-indexed array of strings, access_times, with size n. For each i where 0 <= i <= n - 1, access_times[i][0] represents the name of an employee, and access_times[i][1] represents the access time of that employee. All entries in access_times are within the same day.
    The access time is represented as four digits using a 24-hour time format, for example, "0800" or "2250".
    An employee is said to be high-access if he has accessed the system three or more times within a one-hour period.
    Times with exactly one hour of difference are not considered part of the same one-hour period. For example, "0815" and "0915" are not part of the same one-hour period.
    Access times at the start and end of the day are not counted within the same one-hour period. For example, "0005" and "2350" are not part of the same one-hour period.
    Return a list that contains the names of high-access employees with any order you want.

    Example 1:

    >>> findHighAccessEmployees(access_times = [["a","0549"],["b","0457"],["a","0532"],["a","0621"],["b","0540"]])
    >>> ["a"]
    Explanation: "a" has three access times in the one-hour period of [05:32, 06:31] which are 05:32, 05:49, and 06:21.
    But "b" does not have more than two access times at all.
    So the answer is ["a"].
    Example 2:

    >>> findHighAccessEmployees(access_times = [["d","0002"],["c","0808"],["c","0829"],["e","0215"],["d","1508"],["d","1444"],["d","1410"],["c","0809"]])
    >>> ["c","d"]
    Explanation: "c" has three access times in the one-hour period of [08:08, 09:07] which are 08:08, 08:09, and 08:29.
    "d" has also three access times in the one-hour period of [14:10, 15:09] which are 14:10, 14:44, and 15:08.
    However, "e" has just one access time, so it can not be in the answer and the final answer is ["c","d"].
    Example 3:

    >>> findHighAccessEmployees(access_times = [["cd","1025"],["ab","1025"],["cd","1046"],["cd","1055"],["ab","1124"],["ab","1120"]])
    >>> ["ab","cd"]
    Explanation: "ab" has three access times in the one-hour period of [10:25, 11:24] which are 10:25, 11:20, and 11:24.
    "cd" has also three access times in the one-hour period of [10:25, 11:24] which are 10:25, 10:46, and 10:55.
    So the answer is ["ab","cd"].
    """


Prompt:
def minOperations(nums1: List[int], nums2: List[int]) -> int:
    """
    You are given two 0-indexed integer arrays, nums1 and nums2, both having length n.
    You are allowed to perform a series of operations (possibly none).
    In an operation, you select an index i in the range [0, n - 1] and swap the values of nums1[i] and nums2[i].
    Your task is to find the minimum number of operations required to satisfy the following conditions:

    nums1[n - 1] is equal to the maximum value among all elements of nums1, i.e., nums1[n - 1] = max(nums1[0], nums1[1], ..., nums1[n - 1]).
    nums2[n - 1] is equal to the maximum value among all elements of nums2, i.e., nums2[n - 1] = max(nums2[0], nums2[1], ..., nums2[n - 1]).

    Return an integer denoting the minimum number of operations needed to meet both conditions, or -1 if it is impossible to satisfy both conditions.

    Example 1:

    >>> minOperations(nums1 = [1,2,7], nums2 = [4,5,3])
    >>> 1
    Explanation: In this example, an operation can be performed using index i = 2.
    When nums1[2] and nums2[2] are swapped, nums1 becomes [1,2,3] and nums2 becomes [4,5,7].
    Both conditions are now satisfied.
    It can be shown that the minimum number of operations needed to be performed is 1.
    So, the answer is 1.

    Example 2:

    >>> minOperations(nums1 = [2,3,4,5,9], nums2 = [8,8,4,4,4])
    >>> 2
    Explanation: In this example, the following operations can be performed:
    First operation using index i = 4.
    When nums1[4] and nums2[4] are swapped, nums1 becomes [2,3,4,5,4], and nums2 becomes [8,8,4,4,9].
    Another operation using index i = 3.
    When nums1[3] and nums2[3] are swapped, nums1 becomes [2,3,4,4,4], and nums2 becomes [8,8,4,5,9].
    Both conditions are now satisfied.
    It can be shown that the minimum number of operations needed to be performed is 2.
    So, the answer is 2.

    Example 3:

    >>> minOperations(nums1 = [1,5,4], nums2 = [2,5,3])
    >>> -1
    Explanation: In this example, it is not possible to satisfy both conditions.
    So, the answer is -1.
    """


Prompt:
def maximumStrongPairXor(nums: List[int]) -> int:
    """
    You are given a 0-indexed integer array nums. A pair of integers x and y is called a strong pair if it satisfies the condition:

    |x - y| <= min(x, y)

    You need to select two integers from nums such that they form a strong pair and their bitwise XOR is the maximum among all strong pairs in the array.
    Return the maximum XOR value out of all possible strong pairs in the array nums.
    Note that you can pick the same integer twice to form a pair.

    Example 1:

    >>> maximumStrongPairXor(nums = [1,2,3,4,5])
    >>> 7
    Explanation: There are 11 strong pairs in the array nums: (1, 1), (1, 2), (2, 2), (2, 3), (2, 4), (3, 3), (3, 4), (3, 5), (4, 4), (4, 5) and (5, 5).
    The maximum XOR possible from these pairs is 3 XOR 4 = 7.

    Example 2:

    >>> maximumStrongPairXor(nums = [10,100])
    >>> 0
    Explanation: There are 2 strong pairs in the array nums: (10, 10) and (100, 100).
    The maximum XOR possible from these pairs is 10 XOR 10 = 0 since the pair (100, 100) also gives 100 XOR 100 = 0.

    Example 3:

    >>> maximumStrongPairXor(nums = [500,520,2500,3000])
    >>> 1020
    Explanation: There are 6 strong pairs in the array nums: (500, 500), (500, 520), (520, 520), (2500, 2500), (2500, 3000) and (3000, 3000).
    The maximum XOR possible from these pairs is 500 XOR 520 = 1020 since the only other non-zero XOR value is 2500 XOR 3000 = 636.
    """


Prompt:
def findMinimumOperations(s1: str, s2: str, s3: str) -> int:
    """
    You are given three strings: s1, s2, and s3. In one operation you can choose one of these strings and delete its rightmost character. Note that you cannot completely empty a string.
    Return the minimum number of operations required to make the strings equal. If it is impossible to make them equal, return -1.

    Example 1:

    >>> findMinimumOperations(s1 = "abc", s2 = "abb", s3 = "ab")
    >>> 2
    Explanation: Deleting the rightmost character from both s1 and s2 will result in three equal strings.

    Example 2:

    >>> findMinimumOperations(s1 = "dac", s2 = "bac", s3 = "cac")
    >>> -1
    Explanation: Since the first letters of s1 and s2 differ, they cannot be made equal.
    """


Prompt:
def minimumSteps(s: str) -> int:
    """
    There are n balls on a table, each ball has a color black or white.
    You are given a 0-indexed binary string s of length n, where 1 and 0 represent black and white balls, respectively.
    In each step, you can choose two adjacent balls and swap them.
    Return the minimum number of steps to group all the black balls to the right and all the white balls to the left.

    Example 1:

    >>> minimumSteps(s = "101")
    >>> 1
    Explanation: We can group all the black balls to the right in the following way:
    - Swap s[0] and s[1], s = "011".
    Initially, 1s are not grouped together, requiring at least 1 step to group them to the right.
    Example 2:

    >>> minimumSteps(s = "100")
    >>> 2
    Explanation: We can group all the black balls to the right in the following way:
    - Swap s[0] and s[1], s = "010".
    - Swap s[1] and s[2], s = "001".
    It can be proven that the minimum number of steps needed is 2.

    Example 3:

    >>> minimumSteps(s = "0111")
    >>> 0
    Explanation: All the black balls are already grouped to the right.
    """


Prompt:
def maximumXorProduct(a: int, b: int, n: int) -> int:
    """
    Given three integers a, b, and n, return the maximum value of (a XOR x) * (b XOR x) where 0 <= x < 2n.
    Since the answer may be too large, return it modulo 109 + 7.
    Note that XOR is the bitwise XOR operation.

    Example 1:

    >>> maximumXorProduct(a = 12, b = 5, n = 4)
    >>> 98
    Explanation: For x = 2, (a XOR x) = 14 and (b XOR x) = 7. Hence, (a XOR x) * (b XOR x) = 98.
    It can be shown that 98 is the maximum value of (a XOR x) * (b XOR x) for all 0 <= x < 2n.

    Example 2:

    >>> maximumXorProduct(a = 6, b = 7 , n = 5)
    >>> 930
    Explanation: For x = 25, (a XOR x) = 31 and (b XOR x) = 30. Hence, (a XOR x) * (b XOR x) = 930.
    It can be shown that 930 is the maximum value of (a XOR x) * (b XOR x) for all 0 <= x < 2n.
    Example 3:

    >>> maximumXorProduct(a = 1, b = 6, n = 3)
    >>> 12
    Explanation: For x = 5, (a XOR x) = 4 and (b XOR x) = 3. Hence, (a XOR x) * (b XOR x) = 12.
    It can be shown that 12 is the maximum value of (a XOR x) * (b XOR x) for all 0 <= x < 2n.
    """


Prompt:
def leftmostBuildingQueries(heights: List[int], queries: List[List[int]]) -> List[int]:
    """
    You are given a 0-indexed array heights of positive integers, where heights[i] represents the height of the ith building.
    If a person is in building i, they can move to any other building j if and only if i < j and heights[i] < heights[j].
    You are also given another array queries where queries[i] = [ai, bi]. On the ith query, Alice is in building ai while Bob is in building bi.
    Return an array ans where ans[i] is the index of the leftmost building where Alice and Bob can meet on the ith query. If Alice and Bob cannot move to a common building on query i, set ans[i] to -1.

    Example 1:

    >>> leftmostBuildingQueries(heights = [6,4,8,5,2,7], queries = [[0,1],[0,3],[2,4],[3,4],[2,2]])
    >>> [2,5,-1,5,2]
    Explanation: In the first query, Alice and Bob can move to building 2 since heights[0] < heights[2] and heights[1] < heights[2].
    In the second query, Alice and Bob can move to building 5 since heights[0] < heights[5] and heights[3] < heights[5].
    In the third query, Alice cannot meet Bob since Alice cannot move to any other building.
    In the fourth query, Alice and Bob can move to building 5 since heights[3] < heights[5] and heights[4] < heights[5].
    In the fifth query, Alice and Bob are already in the same building.
    For ans[i] != -1, It can be shown that ans[i] is the leftmost building where Alice and Bob can meet.
    For ans[i] == -1, It can be shown that there is no building where Alice and Bob can meet.

    Example 2:

    >>> leftmostBuildingQueries(heights = [5,3,8,2,6,1,4,6], queries = [[0,7],[3,5],[5,2],[3,0],[1,6]])
    >>> [7,6,-1,4,6]
    Explanation: In the first query, Alice can directly move to Bob's building since heights[0] < heights[7].
    In the second query, Alice and Bob can move to building 6 since heights[3] < heights[6] and heights[5] < heights[6].
    In the third query, Alice cannot meet Bob since Bob cannot move to any other building.
    In the fourth query, Alice and Bob can move to building 4 since heights[3] < heights[4] and heights[0] < heights[4].
    In the fifth query, Alice can directly move to Bob's building since heights[1] < heights[6].
    For ans[i] != -1, It can be shown that ans[i] is the leftmost building where Alice and Bob can meet.
    For ans[i] == -1, It can be shown that there is no building where Alice and Bob can meet.
    """


Prompt:
def maxGcdSum(nums: List[int], k: int) -> int:
    """
    You are given an array of integers nums and an integer k.
    The gcd-sum of an array a is calculated as follows:

    Let s be the sum of all the elements of a.
    Let g be the greatest common divisor of all the elements of a.
    The gcd-sum of a is equal to s * g.

    Return the maximum gcd-sum of a subarray of nums with at least k elements.

    Example 1:

    >>> maxGcdSum(nums = [2,1,4,4,4,2], k = 2)
    >>> 48
    Explanation: We take the subarray [4,4,4], the gcd-sum of this array is 4 * (4 + 4 + 4) = 48.
    It can be shown that we can not select any other subarray with a gcd-sum greater than 48.
    Example 2:

    >>> maxGcdSum(nums = [7,3,9,4], k = 1)
    >>> 81
    Explanation: We take the subarray [9], the gcd-sum of this array is 9 * 9 = 81.
    It can be shown that we can not select any other subarray with a gcd-sum greater than 81.
    """


Prompt:
def findWordsContaining(words: List[str], x: str) -> List[int]:
    """
    You are given a 0-indexed array of strings words and a character x.
    Return an array of indices representing the words that contain the character x.
    Note that the returned array may be in any order.

    Example 1:

    >>> findWordsContaining(words = ["leet","code"], x = "e")
    >>> [0,1]
    Explanation: "e" occurs in both words: "leet", and "code". Hence, we return indices 0 and 1.

    Example 2:

    >>> findWordsContaining(words = ["abc","bcd","aaaa","cbc"], x = "a")
    >>> [0,2]
    Explanation: "a" occurs in "abc", and "aaaa". Hence, we return indices 0 and 2.

    Example 3:

    >>> findWordsContaining(words = ["abc","bcd","aaaa","cbc"], x = "z")
    >>> []
    Explanation: "z" does not occur in any of the words. Hence, we return an empty array.
    """


Prompt:
def maximizeSquareHoleArea(n: int, m: int, hBars: List[int], vBars: List[int]) -> int:
    """
    You are given the two integers, n and m and two integer arrays, hBars and vBars. The grid has n + 2 horizontal and m + 2 vertical bars, creating 1 x 1 unit cells. The bars are indexed starting from 1.
    You can remove some of the bars in hBars from horizontal bars and some of the bars in vBars from vertical bars. Note that other bars are fixed and cannot be removed.
    Return an integer denoting the maximum area of a square-shaped hole in the grid, after removing some bars (possibly none).

    Example 1:

    >>> maximizeSquareHoleArea(n = 2, m = 1, hBars = [2,3], vBars = [2])
    >>> 4
    Explanation:
    The left image shows the initial grid formed by the bars. The horizontal bars are [1,2,3,4], and the vertical bars are [1,2,3].
    One way to get the maximum square-shaped hole is by removing horizontal bar 2 and vertical bar 2.

    Example 2:

    >>> maximizeSquareHoleArea(n = 1, m = 1, hBars = [2], vBars = [2])
    >>> 4
    Explanation:
    To get the maximum square-shaped hole, we remove horizontal bar 2 and vertical bar 2.

    Example 3:

    >>> maximizeSquareHoleArea(n = 2, m = 3, hBars = [2,3], vBars = [2,4])
    >>> 4
    Explanation:
    One way to get the maximum square-shaped hole is by removing horizontal bar 3, and vertical bar 4.
    """


Prompt:
def minimumCoins(prices: List[int]) -> int:
    """
    You are given an 0-indexed integer array prices where prices[i] denotes the number of coins needed to purchase the (i + 1)th fruit.
    The fruit market has the following reward for each fruit:

    If you purchase the (i + 1)th fruit at prices[i] coins, you can get any number of the next i fruits for free.

    Note that even if you can take fruit j for free, you can still purchase it for prices[j - 1] coins to receive its reward.
    Return the minimum number of coins needed to acquire all the fruits.

    Example 1:

    >>> minimumCoins(prices = [3,1,2])
    >>> 4
    Explanation:

    Purchase the 1st fruit with prices[0] = 3 coins, you are allowed to take the 2nd fruit for free.
    Purchase the 2nd fruit with prices[1] = 1 coin, you are allowed to take the 3rd fruit for free.
    Take the 3rd fruit for free.

    Note that even though you could take the 2nd fruit for free as a reward of buying 1st fruit, you purchase it to receive its reward, which is more optimal.

    Example 2:

    >>> minimumCoins(prices = [1,10,1,1])
    >>> 2
    Explanation:

    Purchase the 1st fruit with prices[0] = 1 coin, you are allowed to take the 2nd fruit for free.
    Take the 2nd fruit for free.
    Purchase the 3rd fruit for prices[2] = 1 coin, you are allowed to take the 4th fruit for free.
    Take the 4th fruit for free.

    Example 3:

    >>> minimumCoins(prices = [26,18,6,12,49,7,45,45])
    >>> 39
    Explanation:

    Purchase the 1st fruit with prices[0] = 26 coin, you are allowed to take the 2nd fruit for free.
    Take the 2nd fruit for free.
    Purchase the 3rd fruit for prices[2] = 6 coin, you are allowed to take the 4th, 5th and 6th (the next three) fruits for free.
    Take the 4th fruit for free.
    Take the 5th fruit for free.
    Purchase the 6th fruit with prices[5] = 7 coin, you are allowed to take the 8th and 9th fruit for free.
    Take the 7th fruit for free.
    Take the 8th fruit for free.

    Note that even though you could take the 6th fruit for free as a reward of buying 3rd fruit, you purchase it to receive its reward, which is more optimal.
    """


Prompt:
def findMaximumLength(nums: List[int]) -> int:
    """
    You are given a 0-indexed integer array nums.
    You can perform any number of operations, where each operation involves selecting a subarray of the array and replacing it with the sum of its elements. For example, if the given array is [1,3,5,6] and you select subarray [3,5] the array will convert to [1,8,6].
    Return the maximum length of a non-decreasing array that can be made after applying operations.
    A subarray is a contiguous non-empty sequence of elements within an array.

    Example 1:

    >>> findMaximumLength(nums = [5,2,2])
    >>> 1
    Explanation: This array with length 3 is not non-decreasing.
    We have two ways to make the array length two.
    First, choosing subarray [2,2] converts the array to [5,4].
    Second, choosing subarray [5,2] converts the array to [7,2].
    In these two ways the array is not non-decreasing.
    And if we choose subarray [5,2,2] and replace it with [9] it becomes non-decreasing.
    So the answer is 1.

    Example 2:

    >>> findMaximumLength(nums = [1,2,3,4])
    >>> 4
    Explanation: The array is non-decreasing. So the answer is 4.

    Example 3:

    >>> findMaximumLength(nums = [4,3,2,6])
    >>> 3
    Explanation: Replacing [3,2] with [5] converts the given array to [4,5,6] that is non-decreasing.
    Because the given array is not non-decreasing, the maximum possible answer is 3.
    """


Prompt:
def areSimilar(mat: List[List[int]], k: int) -> bool:
    """
    You are given an m x n integer matrix mat and an integer k. The matrix rows are 0-indexed.
    The following proccess happens k times:

    Even-indexed rows (0, 2, 4, ...) are cyclically shifted to the left.

    Odd-indexed rows (1, 3, 5, ...) are cyclically shifted to the right.

    Return true if the final modified matrix after k steps is identical to the original matrix, and false otherwise.

    Example 1:

    >>> areSimilar(mat = [[1,2,3],[4,5,6],[7,8,9]], k = 4)
    >>> false
    Explanation:
    In each step left shift is applied to rows 0 and 2 (even indices), and right shift to row 1 (odd index).

    Example 2:

    >>> areSimilar(mat = [[1,2,1,2],[5,5,5,5],[6,3,6,3]], k = 2)
    >>> true
    Explanation:

    Example 3:

    >>> areSimilar(mat = [[2,2],[2,2]], k = 3)
    >>> true
    Explanation:
    As all the values are equal in the matrix, even after performing cyclic shifts the matrix will remain the same.
    """


Prompt:
def beautifulSubstrings(s: str, k: int) -> int:
    """
    You are given a string s and a positive integer k.
    Let vowels and consonants be the number of vowels and consonants in a string.
    A string is beautiful if:

    vowels == consonants.
    (vowels * consonants) % k == 0, in other terms the multiplication of vowels and consonants is divisible by k.

    Return the number of non-empty beautiful substrings in the given string s.
    A substring is a contiguous sequence of characters in a string.
    Vowel letters in English are 'a', 'e', 'i', 'o', and 'u'.
    Consonant letters in English are every letter except vowels.

    Example 1:

    >>> beautifulSubstrings(s = "baeyh", k = 2)
    >>> 2
    Explanation: There are 2 beautiful substrings in the given string.
    - Substring "baeyh", vowels = 2 (["a",e"]), consonants = 2 (["y","h"]).
    You can see that string "aeyh" is beautiful as vowels == consonants and vowels * consonants % k == 0.
    - Substring "baeyh", vowels = 2 (["a",e"]), consonants = 2 (["b","y"]).
    You can see that string "baey" is beautiful as vowels == consonants and vowels * consonants % k == 0.
    It can be shown that there are only 2 beautiful substrings in the given string.

    Example 2:

    >>> beautifulSubstrings(s = "abba", k = 1)
    >>> 3
    Explanation: There are 3 beautiful substrings in the given string.
    - Substring "abba", vowels = 1 (["a"]), consonants = 1 (["b"]).
    - Substring "abba", vowels = 1 (["a"]), consonants = 1 (["b"]).
    - Substring "abba", vowels = 2 (["a","a"]), consonants = 2 (["b","b"]).
    It can be shown that there are only 3 beautiful substrings in the given string.

    Example 3:

    >>> beautifulSubstrings(s = "bcdf", k = 1)
    >>> 0
    Explanation: There are no beautiful substrings in the given string.
    """


Prompt:
def lexicographicallySmallestArray(nums: List[int], limit: int) -> List[int]:
    """
    You are given a 0-indexed array of positive integers nums and a positive integer limit.
    In one operation, you can choose any two indices i and j and swap nums[i] and nums[j] if |nums[i] - nums[j]| <= limit.
    Return the lexicographically smallest array that can be obtained by performing the operation any number of times.
    An array a is lexicographically smaller than an array b if in the first position where a and b differ, array a has an element that is less than the corresponding element in b. For example, the array [2,10,3] is lexicographically smaller than the array [10,2,3] because they differ at index 0 and 2 < 10.

    Example 1:

    >>> lexicographicallySmallestArray(nums = [1,5,3,9,8], limit = 2)
    >>> [1,3,5,8,9]
    Explanation: Apply the operation 2 times:
    - Swap nums[1] with nums[2]. The array becomes [1,3,5,9,8]
    - Swap nums[3] with nums[4]. The array becomes [1,3,5,8,9]
    We cannot obtain a lexicographically smaller array by applying any more operations.
    Note that it may be possible to get the same result by doing different operations.

    Example 2:

    >>> lexicographicallySmallestArray(nums = [1,7,6,18,2,1], limit = 3)
    >>> [1,6,7,18,1,2]
    Explanation: Apply the operation 3 times:
    - Swap nums[1] with nums[2]. The array becomes [1,6,7,18,2,1]
    - Swap nums[0] with nums[4]. The array becomes [2,6,7,18,1,1]
    - Swap nums[0] with nums[5]. The array becomes [1,6,7,18,1,2]
    We cannot obtain a lexicographically smaller array by applying any more operations.

    Example 3:

    >>> lexicographicallySmallestArray(nums = [1,7,28,19,10], limit = 3)
    >>> [1,7,28,19,10]
    Explanation: [1,7,28,19,10] is the lexicographically smallest array we can obtain because we cannot apply the operation on any two indices.
    """


Prompt:
def beautifulSubstrings(s: str, k: int) -> int:
    """
    You are given a string s and a positive integer k.
    Let vowels and consonants be the number of vowels and consonants in a string.
    A string is beautiful if:

    vowels == consonants.
    (vowels * consonants) % k == 0, in other terms the multiplication of vowels and consonants is divisible by k.

    Return the number of non-empty beautiful substrings in the given string s.
    A substring is a contiguous sequence of characters in a string.
    Vowel letters in English are 'a', 'e', 'i', 'o', and 'u'.
    Consonant letters in English are every letter except vowels.

    Example 1:

    >>> beautifulSubstrings(s = "baeyh", k = 2)
    >>> 2
    Explanation: There are 2 beautiful substrings in the given string.
    - Substring "baeyh", vowels = 2 (["a",e"]), consonants = 2 (["y","h"]).
    You can see that string "aeyh" is beautiful as vowels == consonants and vowels * consonants % k == 0.
    - Substring "baeyh", vowels = 2 (["a",e"]), consonants = 2 (["b","y"]).
    You can see that string "baey" is beautiful as vowels == consonants and vowels * consonants % k == 0.
    It can be shown that there are only 2 beautiful substrings in the given string.

    Example 2:

    >>> beautifulSubstrings(s = "abba", k = 1)
    >>> 3
    Explanation: There are 3 beautiful substrings in the given string.
    - Substring "abba", vowels = 1 (["a"]), consonants = 1 (["b"]).
    - Substring "abba", vowels = 1 (["a"]), consonants = 1 (["b"]).
    - Substring "abba", vowels = 2 (["a","a"]), consonants = 2 (["b","b"]).
    It can be shown that there are only 3 beautiful substrings in the given string.

    Example 3:

    >>> beautifulSubstrings(s = "bcdf", k = 1)
    >>> 0
    Explanation: There are no beautiful substrings in the given string.
    """


Prompt:
def countDivisibleSubstrings(word: str) -> int:
    """
    Each character of the English alphabet has been mapped to a digit as shown below.

    A string is divisible if the sum of the mapped values of its characters is divisible by its length.
    Given a string s, return the number of divisible substrings of s.
    A substring is a contiguous non-empty sequence of characters within a string.

    Example 1:

    Substring
    Mapped
    Sum
    Length
    Divisible?

    a
    1
    1
    1
    Yes

    s
    7
    7
    1
    Yes

    d
    2
    2
    1
    Yes

    f
    3
    3
    1
    Yes

    as
    1, 7
    8
    2
    Yes

    sd
    7, 2
    9
    2
    No

    df
    2, 3
    5
    2
    No

    asd
    1, 7, 2
    10
    3
    No

    sdf
    7, 2, 3
    12
    3
    Yes

    asdf
    1, 7, 2, 3
    13
    4
    No

    >>> countDivisibleSubstrings(word = "asdf")
    >>> 6
    Explanation: The table above contains the details about every substring of word, and we can see that 6 of them are divisible.

    Example 2:

    >>> countDivisibleSubstrings(word = "bdh")
    >>> 4
    Explanation: The 4 divisible substrings are: "b", "d", "h", "bdh".
    It can be shown that there are no other substrings of word that are divisible.

    Example 3:

    >>> countDivisibleSubstrings(word = "abcd")
    >>> 6
    Explanation: The 6 divisible substrings are: "a", "b", "c", "d", "ab", "cd".
    It can be shown that there are no other substrings of word that are divisible.
    """


Prompt:
def findPeaks(mountain: List[int]) -> List[int]:
    """
    You are given a 0-indexed array mountain. Your task is to find all the peaks in the mountain array.
    Return an array that consists of indices of peaks in the given array in any order.
    Notes:

    A peak is defined as an element that is strictly greater than its neighboring elements.
    The first and last elements of the array are not a peak.

    Example 1:

    >>> findPeaks(mountain = [2,4,4])
    >>> []
    Explanation: mountain[0] and mountain[2] can not be a peak because they are first and last elements of the array.
    mountain[1] also can not be a peak because it is not strictly greater than mountain[2].
    So the answer is [].

    Example 2:

    >>> findPeaks(mountain = [1,4,3,8,5])
    >>> [1,3]
    Explanation: mountain[0] and mountain[4] can not be a peak because they are first and last elements of the array.
    mountain[2] also can not be a peak because it is not strictly greater than mountain[3] and mountain[1].
    But mountain [1] and mountain[3] are strictly greater than their neighboring elements.
    So the answer is [1,3].
    """


Prompt:
def minimumAddedCoins(coins: List[int], target: int) -> int:
    """
    You are given a 0-indexed integer array coins, representing the values of the coins available, and an integer target.
    An integer x is obtainable if there exists a subsequence of coins that sums to x.
    Return the minimum number of coins of any value that need to be added to the array so that every integer in the range [1, target] is obtainable.
    A subsequence of an array is a new non-empty array that is formed from the original array by deleting some (possibly none) of the elements without disturbing the relative positions of the remaining elements.

    Example 1:

    >>> minimumAddedCoins(coins = [1,4,10], target = 19)
    >>> 2
    Explanation: We need to add coins 2 and 8. The resulting array will be [1,2,4,8,10].
    It can be shown that all integers from 1 to 19 are obtainable from the resulting array, and that 2 is the minimum number of coins that need to be added to the array.

    Example 2:

    >>> minimumAddedCoins(coins = [1,4,10,5,7,19], target = 19)
    >>> 1
    Explanation: We only need to add the coin 2. The resulting array will be [1,2,4,5,7,10,19].
    It can be shown that all integers from 1 to 19 are obtainable from the resulting array, and that 1 is the minimum number of coins that need to be added to the array.

    Example 3:

    >>> minimumAddedCoins(coins = [1,1,1], target = 20)
    >>> 3
    Explanation: We need to add coins 4, 8, and 16. The resulting array will be [1,1,1,4,8,16].
    It can be shown that all integers from 1 to 20 are obtainable from the resulting array, and that 3 is the minimum number of coins that need to be added to the array.
    """


Prompt:
def countCompleteSubstrings(word: str, k: int) -> int:
    """
    You are given a string word and an integer k.
    A substring s of word is complete if:

    Each character in s occurs exactly k times.
    The difference between two adjacent characters is at most 2. That is, for any two adjacent characters c1 and c2 in s, the absolute difference in their positions in the alphabet is at most 2.

    Return the number of complete substrings of word.
    A substring is a non-empty contiguous sequence of characters in a string.

    Example 1:

    >>> countCompleteSubstrings(word = "igigee", k = 2)
    >>> 3
    Explanation: The complete substrings where each character appears exactly twice and the difference between adjacent characters is at most 2 are: igigee, igigee, igigee.

    Example 2:

    >>> countCompleteSubstrings(word = "aaabbbccc", k = 3)
    >>> 6
    Explanation: The complete substrings where each character appears exactly three times and the difference between adjacent characters is at most 2 are: aaabbbccc, aaabbbccc, aaabbbccc, aaabbbccc, aaabbbccc, aaabbbccc.
    """


Prompt:
def sameEndSubstringCount(s: str, queries: List[List[int]]) -> List[int]:
    """
    You are given a 0-indexed string s, and a 2D array of integers queries, where queries[i] = [li, ri] indicates a substring of s starting from the index li and ending at the index ri (both inclusive), i.e. s[li..ri].
    Return an array ans where ans[i] is the number of same-end substrings of queries[i].
    A 0-indexed string t of length n is called same-end if it has the same character at both of its ends, i.e., t[0] == t[n - 1].
    A substring is a contiguous non-empty sequence of characters within a string.

    Example 1:

    >>> sameEndSubstringCount(s = "abcaab", queries = [[0,0],[1,4],[2,5],[0,5]])
    >>> [1,5,5,10]
    Explanation: Here is the same-end substrings of each query:
    1st query: s[0..0] is "a" which has 1 same-end substring: "a".
    2nd query: s[1..4] is "bcaa" which has 5 same-end substrings: "bcaa", "bcaa", "bcaa", "bcaa", "bcaa".
    3rd query: s[2..5] is "caab" which has 5 same-end substrings: "caab", "caab", "caab", "caab", "caab".
    4th query: s[0..5] is "abcaab" which has 10 same-end substrings: "abcaab", "abcaab", "abcaab", "abcaab", "abcaab", "abcaab", "abcaab", "abcaab", "abcaab", "abcaab".

    Example 2:

    >>> sameEndSubstringCount(s = "abcd", queries = [[0,3]])
    >>> [4]
    Explanation: The only query is s[0..3] which is "abcd". It has 4 same-end substrings: "abcd", "abcd", "abcd", "abcd".
    """


Prompt:
def findIntersectionValues(nums1: List[int], nums2: List[int]) -> List[int]:
    """
    You are given two integer arrays nums1 and nums2 of sizes n and m, respectively. Calculate the following values:

    answer1 : the number of indices i such that nums1[i] exists in nums2.
    answer2 : the number of indices i such that nums2[i] exists in nums1.

    Return [answer1,answer2].

    Example 1:

    >>> findIntersectionValues(nums1 = [2,3,2], nums2 = [1,2])
    >>> [2,1]
    Explanation:

    Example 2:

    >>> findIntersectionValues(nums1 = [4,3,2,3,1], nums2 = [2,2,5,2,3,6])
    >>> [3,4]
    Explanation:
    The elements at indices 1, 2, and 3 in nums1 exist in nums2 as well. So answer1 is 3.
    The elements at indices 0, 1, 3, and 4 in nums2 exist in nums1. So answer2 is 4.

    Example 3:

    >>> findIntersectionValues(nums1 = [3,4,2,3], nums2 = [1,5])
    >>> [0,0]
    Explanation:
    No numbers are common between nums1 and nums2, so answer is [0,0].
    """


Prompt:
def removeAlmostEqualCharacters(word: str) -> int:
    """
    You are given a 0-indexed string word.
    In one operation, you can pick any index i of word and change word[i] to any lowercase English letter.
    Return the minimum number of operations needed to remove all adjacent almost-equal characters from word.
    Two characters a and b are almost-equal if a == b or a and b are adjacent in the alphabet.

    Example 1:

    >>> removeAlmostEqualCharacters(word = "aaaaa")
    >>> 2
    Explanation: We can change word into "acaca" which does not have any adjacent almost-equal characters.
    It can be shown that the minimum number of operations needed to remove all adjacent almost-equal characters from word is 2.

    Example 2:

    >>> removeAlmostEqualCharacters(word = "abddez")
    >>> 2
    Explanation: We can change word into "ybdoez" which does not have any adjacent almost-equal characters.
    It can be shown that the minimum number of operations needed to remove all adjacent almost-equal characters from word is 2.
    Example 3:

    >>> removeAlmostEqualCharacters(word = "zyxyxyz")
    >>> 3
    Explanation: We can change word into "zaxaxaz" which does not have any adjacent almost-equal characters.
    It can be shown that the minimum number of operations needed to remove all adjacent almost-equal characters from word is 3.
    """


Prompt:
def maxSubarrayLength(nums: List[int], k: int) -> int:
    """
    You are given an integer array nums and an integer k.
    The frequency of an element x is the number of times it occurs in an array.
    An array is called good if the frequency of each element in this array is less than or equal to k.
    Return the length of the longest good subarray of nums.
    A subarray is a contiguous non-empty sequence of elements within an array.

    Example 1:

    >>> maxSubarrayLength(nums = [1,2,3,1,2,3,1,2], k = 2)
    >>> 6
    Explanation: The longest possible good subarray is [1,2,3,1,2,3] since the values 1, 2, and 3 occur at most twice in this subarray. Note that the subarrays [2,3,1,2,3,1] and [3,1,2,3,1,2] are also good.
    It can be shown that there are no good subarrays with length more than 6.

    Example 2:

    >>> maxSubarrayLength(nums = [1,2,1,2,1,2,1,2], k = 1)
    >>> 2
    Explanation: The longest possible good subarray is [1,2] since the values 1 and 2 occur at most once in this subarray. Note that the subarray [2,1] is also good.
    It can be shown that there are no good subarrays with length more than 2.

    Example 3:

    >>> maxSubarrayLength(nums = [5,5,5,5,5,5,5], k = 4)
    >>> 4
    Explanation: The longest possible good subarray is [5,5,5,5] since the value 5 occurs 4 times in this subarray.
    It can be shown that there are no good subarrays with length more than 4.
    """


Prompt:
def numberOfSets(n: int, maxDistance: int, roads: List[List[int]]) -> int:
    """
    There is a company with n branches across the country, some of which are connected by roads. Initially, all branches are reachable from each other by traveling some roads.
    The company has realized that they are spending an excessive amount of time traveling between their branches. As a result, they have decided to close down some of these branches (possibly none). However, they want to ensure that the remaining branches have a distance of at most maxDistance from each other.
    The distance between two branches is the minimum total traveled length needed to reach one branch from another.
    You are given integers n, maxDistance, and a 0-indexed 2D array roads, where roads[i] = [ui, vi, wi] represents the undirected road between branches ui and vi with length wi.
    Return the number of possible sets of closing branches, so that any branch has a distance of at most maxDistance from any other.
    Note that, after closing a branch, the company will no longer have access to any roads connected to it.
    Note that, multiple roads are allowed.

    Example 1:

    >>> numberOfSets(n = 3, maxDistance = 5, roads = [[0,1,2],[1,2,10],[0,2,10]])
    >>> 5
    Explanation: The possible sets of closing branches are:
    - The set [2], after closing, active branches are [0,1] and they are reachable to each other within distance 2.
    - The set [0,1], after closing, the active branch is [2].
    - The set [1,2], after closing, the active branch is [0].
    - The set [0,2], after closing, the active branch is [1].
    - The set [0,1,2], after closing, there are no active branches.
    It can be proven, that there are only 5 possible sets of closing branches.

    Example 2:

    >>> numberOfSets(n = 3, maxDistance = 5, roads = [[0,1,20],[0,1,10],[1,2,2],[0,2,2]])
    >>> 7
    Explanation: The possible sets of closing branches are:
    - The set [], after closing, active branches are [0,1,2] and they are reachable to each other within distance 4.
    - The set [0], after closing, active branches are [1,2] and they are reachable to each other within distance 2.
    - The set [1], after closing, active branches are [0,2] and they are reachable to each other within distance 2.
    - The set [0,1], after closing, the active branch is [2].
    - The set [1,2], after closing, the active branch is [0].
    - The set [0,2], after closing, the active branch is [1].
    - The set [0,1,2], after closing, there are no active branches.
    It can be proven, that there are only 7 possible sets of closing branches.

    Example 3:

    >>> numberOfSets(n = 1, maxDistance = 10, roads = [])
    >>> 2
    Explanation: The possible sets of closing branches are:
    - The set [], after closing, the active branch is [0].
    - The set [0], after closing, there are no active branches.
    It can be proven, that there are only 2 possible sets of closing branches.
    """


Prompt:
def countTestedDevices(batteryPercentages: List[int]) -> int:
    """
    You are given a 0-indexed integer array batteryPercentages having length n, denoting the battery percentages of n 0-indexed devices.
    Your task is to test each device i in order from 0 to n - 1, by performing the following test operations:

    If batteryPercentages[i] is greater than 0:

    Increment the count of tested devices.
    Decrease the battery percentage of all devices with indices j in the range [i + 1, n - 1] by 1, ensuring their battery percentage never goes below 0, i.e, batteryPercentages[j] = max(0, batteryPercentages[j] - 1).
    Move to the next device.

    Otherwise, move to the next device without performing any test.

    Return an integer denoting the number of devices that will be tested after performing the test operations in order.

    Example 1:

    >>> countTestedDevices(batteryPercentages = [1,1,2,1,3])
    >>> 3
    Explanation: Performing the test operations in order starting from device 0:
    At device 0, batteryPercentages[0] > 0, so there is now 1 tested device, and batteryPercentages becomes [1,0,1,0,2].
    At device 1, batteryPercentages[1] == 0, so we move to the next device without testing.
    At device 2, batteryPercentages[2] > 0, so there are now 2 tested devices, and batteryPercentages becomes [1,0,1,0,1].
    At device 3, batteryPercentages[3] == 0, so we move to the next device without testing.
    At device 4, batteryPercentages[4] > 0, so there are now 3 tested devices, and batteryPercentages stays the same.
    So, the answer is 3.

    Example 2:

    >>> countTestedDevices(batteryPercentages = [0,1,2])
    >>> 2
    Explanation: Performing the test operations in order starting from device 0:
    At device 0, batteryPercentages[0] == 0, so we move to the next device without testing.
    At device 1, batteryPercentages[1] > 0, so there is now 1 tested device, and batteryPercentages becomes [0,1,1].
    At device 2, batteryPercentages[2] > 0, so there are now 2 tested devices, and batteryPercentages stays the same.
    So, the answer is 2.
    """


Prompt:
def countSubarrays(nums: List[int], k: int) -> int:
    """
    You are given an integer array nums and a positive integer k.
    Return the number of subarrays where the maximum element of nums appears at least k times in that subarray.
    A subarray is a contiguous sequence of elements within an array.

    Example 1:

    >>> countSubarrays(nums = [1,3,2,3,3], k = 2)
    >>> 6
    Explanation: The subarrays that contain the element 3 at least 2 times are: [1,3,2,3], [1,3,2,3,3], [3,2,3], [3,2,3,3], [2,3,3] and [3,3].

    Example 2:

    >>> countSubarrays(nums = [1,4,2,1], k = 3)
    >>> 0
    Explanation: No subarray contains the element 4 at least 3 times.
    """


Prompt:
def divisibleTripletCount(nums: List[int], d: int) -> int:
    """
    Given a 0-indexed integer array nums and an integer d, return the number of triplets (i, j, k) such that i < j < k and (nums[i] + nums[j] + nums[k]) % d == 0.

    Example 1:

    >>> divisibleTripletCount(nums = [3,3,4,7,8], d = 5)
    >>> 3
    Explanation: The triplets which are divisible by 5 are: (0, 1, 2), (0, 2, 4), (1, 2, 4).
    It can be shown that no other triplet is divisible by 5. Hence, the answer is 3.

    Example 2:

    >>> divisibleTripletCount(nums = [3,3,3,3], d = 3)
    >>> 4
    Explanation: Any triplet chosen here has a sum of 9, which is divisible by 3. Hence, the answer is the total number of triplets which is 4.

    Example 3:

    >>> divisibleTripletCount(nums = [3,3,3,3], d = 6)
    >>> 0
    Explanation: Any triplet chosen here has a sum of 9, which is not divisible by 6. Hence, the answer is 0.
    """


Prompt:
def findMissingAndRepeatedValues(grid: List[List[int]]) -> List[int]:
    """
    You are given a 0-indexed 2D integer matrix grid of size n * n with values in the range [1, n2]. Each integer appears exactly once except a which appears twice and b which is missing. The task is to find the repeating and missing numbers a and b.
    Return a 0-indexed integer array ans of size 2 where ans[0] equals to a and ans[1] equals to b.

    Example 1:

    >>> findMissingAndRepeatedValues(grid = [[1,3],[2,2]])
    >>> [2,4]
    Explanation: Number 2 is repeated and number 4 is missing so the answer is [2,4].

    Example 2:

    >>> findMissingAndRepeatedValues(grid = [[9,1,7],[8,9,2],[3,4,6]])
    >>> [9,5]
    Explanation: Number 9 is repeated and number 5 is missing so the answer is [9,5].
    """


Prompt:
def divideArray(nums: List[int], k: int) -> List[List[int]]:
    """
    You are given an integer array nums of size n where n is a multiple of 3 and a positive integer k.
    Divide the array nums into n / 3 arrays of size 3 satisfying the following condition:

    The difference between any two elements in one array is less than or equal to k.

    Return a 2D array containing the arrays. If it is impossible to satisfy the conditions, return an empty array. And if there are multiple answers, return any of them.

    Example 1:

    >>> divideArray(nums = [1,3,4,8,7,9,3,5,1], k = 2)
    >>> [[1,1,3],[3,4,5],[7,8,9]]
    Explanation:
    The difference between any two elements in each array is less than or equal to 2.

    Example 2:

    >>> divideArray(nums = [2,4,2,2,5,2], k = 2)
    >>> []
    Explanation:
    Different ways to divide nums into 2 arrays of size 3 are:

    [[2,2,2],[2,4,5]] (and its permutations)
    [[2,2,4],[2,2,5]] (and its permutations)

    Because there are four 2s there will be an array with the elements 2 and 5 no matter how we divide it. since 5 - 2 = 3 > k, the condition is not satisfied and so there is no valid division.

    Example 3:

    >>> divideArray(nums = [4,2,9,8,2,12,7,12,10,5,8,5,5,7,9,2,5,11], k = 14)
    >>> [[2,2,12],[4,8,5],[5,9,7],[7,8,5],[5,9,10],[11,12,2]]
    Explanation:
    The difference between any two elements in each array is less than or equal to 14.
    """


Prompt:
def minimumCost(nums: List[int]) -> int:
    """
    You are given a 0-indexed integer array nums having length n.
    You are allowed to perform a special move any number of times (including zero) on nums. In one special move you perform the following steps in order:

    Choose an index i in the range [0, n - 1], and a positive integer x.
    Add |nums[i] - x| to the total cost.
    Change the value of nums[i] to x.

    A palindromic number is a positive integer that remains the same when its digits are reversed. For example, 121, 2552 and 65756 are palindromic numbers whereas 24, 46, 235 are not palindromic numbers.
    An array is considered equalindromic if all the elements in the array are equal to an integer y, where y is a palindromic number less than 109.
    Return an integer denoting the minimum possible total cost to make nums equalindromic by performing any number of special moves.

    Example 1:

    >>> minimumCost(nums = [1,2,3,4,5])
    >>> 6
    Explanation: We can make the array equalindromic by changing all elements to 3 which is a palindromic number. The cost of changing the array to [3,3,3,3,3] using 4 special moves is given by |1 - 3| + |2 - 3| + |4 - 3| + |5 - 3| = 6.
    It can be shown that changing all elements to any palindromic number other than 3 cannot be achieved at a lower cost.

    Example 2:

    >>> minimumCost(nums = [10,12,13,14,15])
    >>> 11
    Explanation: We can make the array equalindromic by changing all elements to 11 which is a palindromic number. The cost of changing the array to [11,11,11,11,11] using 5 special moves is given by |10 - 11| + |12 - 11| + |13 - 11| + |14 - 11| + |15 - 11| = 11.
    It can be shown that changing all elements to any palindromic number other than 11 cannot be achieved at a lower cost.

    Example 3:

    >>> minimumCost(nums = [22,33,22,33,22])
    >>> 22
    Explanation: We can make the array equalindromic by changing all elements to 22 which is a palindromic number. The cost of changing the array to [22,22,22,22,22] using 2 special moves is given by |33 - 22| + |33 - 22| = 22.
    It can be shown that changing all elements to any palindromic number other than 22 cannot be achieved at a lower cost.
    """


Prompt:
def maxFrequencyScore(nums: List[int], k: int) -> int:
    """
    You are given a 0-indexed integer array nums and an integer k.
    You can perform the following operation on the array at most k times:

    Choose any index i from the array and increase or decrease nums[i] by 1.

    The score of the final array is the frequency of the most frequent element in the array.
    Return the maximum score you can achieve.
    The frequency of an element is the number of occurences of that element in the array.

    Example 1:

    >>> maxFrequencyScore(nums = [1,2,6,4], k = 3)
    >>> 3
    Explanation: We can do the following operations on the array:
    - Choose i = 0, and increase the value of nums[0] by 1. The resulting array is [2,2,6,4].
    - Choose i = 3, and decrease the value of nums[3] by 1. The resulting array is [2,2,6,3].
    - Choose i = 3, and decrease the value of nums[3] by 1. The resulting array is [2,2,6,2].
    The element 2 is the most frequent in the final array so our score is 3.
    It can be shown that we cannot achieve a better score.

    Example 2:

    >>> maxFrequencyScore(nums = [1,4,4,2,4], k = 0)
    >>> 3
    Explanation: We cannot apply any operations so our score will be the frequency of the most frequent element in the original array, which is 3.
    """


Prompt:
def minimumCoins(prices: List[int]) -> int:
    """
    You are at a fruit market with different types of exotic fruits on display.
    You are given a 1-indexed array prices, where prices[i] denotes the number of coins needed to purchase the ith fruit.
    The fruit market has the following offer:

    If you purchase the ith fruit at prices[i] coins, you can get the next i fruits for free.

    Note that even if you can take fruit j for free, you can still purchase it for prices[j] coins to receive a new offer.
    Return the minimum number of coins needed to acquire all the fruits.

    Example 1:

    >>> minimumCoins(prices = [3,1,2])
    >>> 4
    Explanation: You can acquire the fruits as follows:
    - Purchase the 1st fruit with 3 coins, and you are allowed to take the 2nd fruit for free.
    - Purchase the 2nd fruit with 1 coin, and you are allowed to take the 3rd fruit for free.
    - Take the 3rd fruit for free.
    Note that even though you were allowed to take the 2nd fruit for free, you purchased it because it is more optimal.
    It can be proven that 4 is the minimum number of coins needed to acquire all the fruits.

    Example 2:

    >>> minimumCoins(prices = [1,10,1,1])
    >>> 2
    Explanation: You can acquire the fruits as follows:
    - Purchase the 1st fruit with 1 coin, and you are allowed to take the 2nd fruit for free.
    - Take the 2nd fruit for free.
    - Purchase the 3rd fruit for 1 coin, and you are allowed to take the 4th fruit for free.
    - Take the 4th fruit for free.
    It can be proven that 2 is the minimum number of coins needed to acquire all the fruits.
    """


Prompt:
def incremovableSubarrayCount(nums: List[int]) -> int:
    """
    You are given a 0-indexed array of positive integers nums.
    A subarray of nums is called incremovable if nums becomes strictly increasing on removing the subarray. For example, the subarray [3, 4] is an incremovable subarray of [5, 3, 4, 6, 7] because removing this subarray changes the array [5, 3, 4, 6, 7] to [5, 6, 7] which is strictly increasing.
    Return the total number of incremovable subarrays of nums.
    Note that an empty array is considered strictly increasing.
    A subarray is a contiguous non-empty sequence of elements within an array.

    Example 1:

    >>> incremovableSubarrayCount(nums = [1,2,3,4])
    >>> 10
    Explanation: The 10 incremovable subarrays are: [1], [2], [3], [4], [1,2], [2,3], [3,4], [1,2,3], [2,3,4], and [1,2,3,4], because on removing any one of these subarrays nums becomes strictly increasing. Note that you cannot select an empty subarray.

    Example 2:

    >>> incremovableSubarrayCount(nums = [6,5,7,8])
    >>> 7
    Explanation: The 7 incremovable subarrays are: [5], [6], [5,7], [6,5], [5,7,8], [6,5,7] and [6,5,7,8].
    It can be shown that there are only 7 incremovable subarrays in nums.

    Example 3:

    >>> incremovableSubarrayCount(nums = [8,7,6,6])
    >>> 3
    Explanation: The 3 incremovable subarrays are: [8,7,6], [7,6,6], and [8,7,6,6]. Note that [8,7] is not an incremovable subarray because after removing [8,7] nums becomes [6,6], which is sorted in ascending order but not strictly increasing.
    """


Prompt:
def largestPerimeter(nums: List[int]) -> int:
    """
    You are given an array of positive integers nums of length n.
    A polygon is a closed plane figure that has at least 3 sides. The longest side of a polygon is smaller than the sum of its other sides.
    Conversely, if you have k (k >= 3) positive real numbers a1, a2, a3, ..., ak where a1 <= a2 <= a3 <= ... <= ak and a1 + a2 + a3 + ... + ak-1 > ak, then there always exists a polygon with k sides whose lengths are a1, a2, a3, ..., ak.
    The perimeter of a polygon is the sum of lengths of its sides.
    Return the largest possible perimeter of a polygon whose sides can be formed from nums, or -1 if it is not possible to create a polygon.

    Example 1:

    >>> largestPerimeter(nums = [5,5,5])
    >>> 15
    Explanation: The only possible polygon that can be made from nums has 3 sides: 5, 5, and 5. The perimeter is 5 + 5 + 5 = 15.

    Example 2:

    >>> largestPerimeter(nums = [1,12,1,2,5,50,3])
    >>> 12
    Explanation: The polygon with the largest perimeter which can be made from nums has 5 sides: 1, 1, 2, 3, and 5. The perimeter is 1 + 1 + 2 + 3 + 5 = 12.
    We cannot have a polygon with either 12 or 50 as the longest side because it is not possible to include 2 or more smaller sides that have a greater sum than either of them.
    It can be shown that the largest possible perimeter is 12.

    Example 3:

    >>> largestPerimeter(nums = [5,5,50])
    >>> -1
    Explanation: There is no possible way to form a polygon from nums, as a polygon has at least 3 sides and 50 > 5 + 5.
    """


Prompt:
def incremovableSubarrayCount(nums: List[int]) -> int:
    """
    You are given a 0-indexed array of positive integers nums.
    A subarray of nums is called incremovable if nums becomes strictly increasing on removing the subarray. For example, the subarray [3, 4] is an incremovable subarray of [5, 3, 4, 6, 7] because removing this subarray changes the array [5, 3, 4, 6, 7] to [5, 6, 7] which is strictly increasing.
    Return the total number of incremovable subarrays of nums.
    Note that an empty array is considered strictly increasing.
    A subarray is a contiguous non-empty sequence of elements within an array.

    Example 1:

    >>> incremovableSubarrayCount(nums = [1,2,3,4])
    >>> 10
    Explanation: The 10 incremovable subarrays are: [1], [2], [3], [4], [1,2], [2,3], [3,4], [1,2,3], [2,3,4], and [1,2,3,4], because on removing any one of these subarrays nums becomes strictly increasing. Note that you cannot select an empty subarray.

    Example 2:

    >>> incremovableSubarrayCount(nums = [6,5,7,8])
    >>> 7
    Explanation: The 7 incremovable subarrays are: [5], [6], [5,7], [6,5], [5,7,8], [6,5,7] and [6,5,7,8].
    It can be shown that there are only 7 incremovable subarrays in nums.

    Example 3:

    >>> incremovableSubarrayCount(nums = [8,7,6,6])
    >>> 3
    Explanation: The 3 incremovable subarrays are: [8,7,6], [7,6,6], and [8,7,6,6]. Note that [8,7] is not an incremovable subarray because after removing [8,7] nums becomes [6,6], which is sorted in ascending order but not strictly increasing.
    """


Prompt:
def placedCoins(edges: List[List[int]], cost: List[int]) -> List[int]:
    """
    You are given an undirected tree with n nodes labeled from 0 to n - 1, and rooted at node 0. You are given a 2D integer array edges of length n - 1, where edges[i] = [ai, bi] indicates that there is an edge between nodes ai and bi in the tree.
    You are also given a 0-indexed integer array cost of length n, where cost[i] is the cost assigned to the ith node.
    You need to place some coins on every node of the tree. The number of coins to be placed at node i can be calculated as:

    If size of the subtree of node i is less than 3, place 1 coin.
    Otherwise, place an amount of coins equal to the maximum product of cost values assigned to 3 distinct nodes in the subtree of node i. If this product is negative, place 0 coins.

    Return an array coin of size n such that coin[i] is the number of coins placed at node i.

    Example 1:

    >>> placedCoins(edges = [[0,1],[0,2],[0,3],[0,4],[0,5]], cost = [1,2,3,4,5,6])
    >>> [120,1,1,1,1,1]
    Explanation: For node 0 place 6 * 5 * 4 = 120 coins. All other nodes are leaves with subtree of size 1, place 1 coin on each of them.

    Example 2:

    >>> placedCoins(edges = [[0,1],[0,2],[1,3],[1,4],[1,5],[2,6],[2,7],[2,8]], cost = [1,4,2,3,5,7,8,-4,2])
    >>> [280,140,32,1,1,1,1,1,1]
    Explanation: The coins placed on each node are:
    - Place 8 * 7 * 5 = 280 coins on node 0.
    - Place 7 * 5 * 4 = 140 coins on node 1.
    - Place 8 * 2 * 2 = 32 coins on node 2.
    - All other nodes are leaves with subtree of size 1, place 1 coin on each of them.

    Example 3:

    >>> placedCoins(edges = [[0,1],[0,2]], cost = [1,2,-2])
    >>> [0,1,1]
    Explanation: Node 1 and 2 are leaves with subtree of size 1, place 1 coin on each of them. For node 0 the only possible product of cost is 2 * 1 * -2 = -4. Hence place 0 coins on node 0.
    """


Prompt:
def numberGame(nums: List[int]) -> List[int]:
    """
    You are given a 0-indexed integer array nums of even length and there is also an empty array arr. Alice and Bob decided to play a game where in every round Alice and Bob will do one move. The rules of the game are as follows:

    Every round, first Alice will remove the minimum element from nums, and then Bob does the same.
    Now, first Bob will append the removed element in the array arr, and then Alice does the same.
    The game continues until nums becomes empty.

    Return the resulting array arr.

    Example 1:

    >>> numberGame(nums = [5,4,2,3])
    >>> [3,2,5,4]
    Explanation: In round one, first Alice removes 2 and then Bob removes 3. Then in arr firstly Bob appends 3 and then Alice appends 2. So arr = [3,2].
    At the begining of round two, nums = [5,4]. Now, first Alice removes 4 and then Bob removes 5. Then both append in arr which becomes [3,2,5,4].

    Example 2:

    >>> numberGame(nums = [2,5])
    >>> [5,2]
    Explanation: In round one, first Alice removes 2 and then Bob removes 5. Then in arr firstly Bob appends and then Alice appends. So arr = [5,2].
    """


Prompt:
def maximizeSquareArea(m: int, n: int, hFences: List[int], vFences: List[int]) -> int:
    """
    There is a large (m - 1) x (n - 1) rectangular field with corners at (1, 1) and (m, n) containing some horizontal and vertical fences given in arrays hFences and vFences respectively.
    Horizontal fences are from the coordinates (hFences[i], 1) to (hFences[i], n) and vertical fences are from the coordinates (1, vFences[i]) to (m, vFences[i]).
    Return the maximum area of a square field that can be formed by removing some fences (possibly none) or -1 if it is impossible to make a square field.
    Since the answer may be large, return it modulo 109 + 7.
    Note: The field is surrounded by two horizontal fences from the coordinates (1, 1) to (1, n) and (m, 1) to (m, n) and two vertical fences from the coordinates (1, 1) to (m, 1) and (1, n) to (m, n). These fences cannot be removed.

    Example 1:

    >>> maximizeSquareArea(m = 4, n = 3, hFences = [2,3], vFences = [2])
    >>> 4
    Explanation: Removing the horizontal fence at 2 and the vertical fence at 2 will give a square field of area 4.

    Example 2:

    >>> maximizeSquareArea(m = 6, n = 7, hFences = [2], vFences = [4])
    >>> -1
    Explanation: It can be proved that there is no way to create a square field by removing fences.
    """


Prompt:
def minimumCost(source: str, target: str, original: List[str], changed: List[str], cost: List[int]) -> int:
    """
    You are given two 0-indexed strings source and target, both of length n and consisting of lowercase English letters. You are also given two 0-indexed character arrays original and changed, and an integer array cost, where cost[i] represents the cost of changing the character original[i] to the character changed[i].
    You start with the string source. In one operation, you can pick a character x from the string and change it to the character y at a cost of z if there exists any index j such that cost[j] == z, original[j] == x, and changed[j] == y.
    Return the minimum cost to convert the string source to the string target using any number of operations. If it is impossible to convert source to target, return -1.
    Note that there may exist indices i, j such that original[j] == original[i] and changed[j] == changed[i].

    Example 1:

    >>> minimumCost(source = "abcd", target = "acbe", original = ["a","b","c","c","e","d"], changed = ["b","c","b","e","b","e"], cost = [2,5,5,1,2,20])
    >>> 28
    Explanation: To convert the string "abcd" to string "acbe":
    - Change value at index 1 from 'b' to 'c' at a cost of 5.
    - Change value at index 2 from 'c' to 'e' at a cost of 1.
    - Change value at index 2 from 'e' to 'b' at a cost of 2.
    - Change value at index 3 from 'd' to 'e' at a cost of 20.
    The total cost incurred is 5 + 1 + 2 + 20 = 28.
    It can be shown that this is the minimum possible cost.

    Example 2:

    >>> minimumCost(source = "aaaa", target = "bbbb", original = ["a","c"], changed = ["c","b"], cost = [1,2])
    >>> 12
    Explanation: To change the character 'a' to 'b' change the character 'a' to 'c' at a cost of 1, followed by changing the character 'c' to 'b' at a cost of 2, for a total cost of 1 + 2 = 3. To change all occurrences of 'a' to 'b', a total cost of 3 * 4 = 12 is incurred.

    Example 3:

    >>> minimumCost(source = "abcd", target = "abce", original = ["a"], changed = ["e"], cost = [10000])
    >>> -1
    Explanation: It is impossible to convert source to target because the value at index 3 cannot be changed from 'd' to 'e'.
    """


Prompt:
def minimumCost(source: str, target: str, original: List[str], changed: List[str], cost: List[int]) -> int:
    """
    You are given two 0-indexed strings source and target, both of length n and consisting of lowercase English characters. You are also given two 0-indexed string arrays original and changed, and an integer array cost, where cost[i] represents the cost of converting the string original[i] to the string changed[i].
    You start with the string source. In one operation, you can pick a substring x from the string, and change it to y at a cost of z if there exists any index j such that cost[j] == z, original[j] == x, and changed[j] == y. You are allowed to do any number of operations, but any pair of operations must satisfy either of these two conditions:

    The substrings picked in the operations are source[a..b] and source[c..d] with either b < c or d < a. In other words, the indices picked in both operations are disjoint.
    The substrings picked in the operations are source[a..b] and source[c..d] with a == c and b == d. In other words, the indices picked in both operations are identical.

    Return the minimum cost to convert the string source to the string target using any number of operations. If it is impossible to convert source to target, return -1.
    Note that there may exist indices i, j such that original[j] == original[i] and changed[j] == changed[i].

    Example 1:

    >>> minimumCost(source = "abcd", target = "acbe", original = ["a","b","c","c","e","d"], changed = ["b","c","b","e","b","e"], cost = [2,5,5,1,2,20])
    >>> 28
    Explanation: To convert "abcd" to "acbe", do the following operations:
    - Change substring source[1..1] from "b" to "c" at a cost of 5.
    - Change substring source[2..2] from "c" to "e" at a cost of 1.
    - Change substring source[2..2] from "e" to "b" at a cost of 2.
    - Change substring source[3..3] from "d" to "e" at a cost of 20.
    The total cost incurred is 5 + 1 + 2 + 20 = 28.
    It can be shown that this is the minimum possible cost.

    Example 2:

    >>> minimumCost(source = "abcdefgh", target = "acdeeghh", original = ["bcd","fgh","thh"], changed = ["cde","thh","ghh"], cost = [1,3,5])
    >>> 9
    Explanation: To convert "abcdefgh" to "acdeeghh", do the following operations:
    - Change substring source[1..3] from "bcd" to "cde" at a cost of 1.
    - Change substring source[5..7] from "fgh" to "thh" at a cost of 3. We can do this operation because indices [5,7] are disjoint with indices picked in the first operation.
    - Change substring source[5..7] from "thh" to "ghh" at a cost of 5. We can do this operation because indices [5,7] are disjoint with indices picked in the first operation, and identical with indices picked in the second operation.
    The total cost incurred is 1 + 3 + 5 = 9.
    It can be shown that this is the minimum possible cost.

    Example 3:

    >>> minimumCost(source = "abcdefgh", target = "addddddd", original = ["bcd","defgh"], changed = ["ddd","ddddd"], cost = [100,1578])
    >>> -1
    Explanation: It is impossible to convert "abcdefgh" to "addddddd".
    If you select substring source[1..3] as the first operation to change "abcdefgh" to "adddefgh", you cannot select substring source[3..7] as the second operation because it has a common index, 3, with the first operation.
    If you select substring source[3..7] as the first operation to change "abcdefgh" to "abcddddd", you cannot select substring source[1..3] as the second operation because it has a common index, 3, with the first operation.
    """


Prompt:
def mostExpensiveItem(primeOne: int, primeTwo: int) -> int:
    """
    You are given two distinct prime numbers primeOne and primeTwo.
    Alice and Bob are visiting a market. The market has an infinite number of items, for any positive integer x there exists an item whose price is x. Alice wants to buy some items from the market to gift to Bob. She has an infinite number of coins in the denomination primeOne and primeTwo. She wants to know the most expensive item she can not buy to gift to Bob.
    Return the price of the most expensive item which Alice can not gift to Bob.

    Example 1:

    >>> mostExpensiveItem(primeOne = 2, primeTwo = 5)
    >>> 3
    Explanation: The prices of items which cannot be bought are [1,3]. It can be shown that all items with a price greater than 3 can be bought using a combination of coins of denominations 2 and 5.

    Example 2:

    >>> mostExpensiveItem(primeOne = 5, primeTwo = 7)
    >>> 23
    Explanation: The prices of items which cannot be bought are [1,2,3,4,6,8,9,11,13,16,18,23]. It can be shown that all items with a price greater than 23 can be bought.
    """


Prompt:
def hasTrailingZeros(nums: List[int]) -> bool:
    """
    You are given an array of positive integers nums.
    You have to check if it is possible to select two or more elements in the array such that the bitwise OR of the selected elements has at least one trailing zero in its binary representation.
    For example, the binary representation of 5, which is "101", does not have any trailing zeros, whereas the binary representation of 4, which is "100", has two trailing zeros.
    Return true if it is possible to select two or more elements whose bitwise OR has trailing zeros, return false otherwise.

    Example 1:

    >>> hasTrailingZeros(nums = [1,2,3,4,5])
    >>> true
    Explanation: If we select the elements 2 and 4, their bitwise OR is 6, which has the binary representation "110" with one trailing zero.

    Example 2:

    >>> hasTrailingZeros(nums = [2,4,8,16])
    >>> true
    Explanation: If we select the elements 2 and 4, their bitwise OR is 6, which has the binary representation "110" with one trailing zero.
    Other possible ways to select elements to have trailing zeroes in the binary representation of their bitwise OR are: (2, 8), (2, 16), (4, 8), (4, 16), (8, 16), (2, 4, 8), (2, 4, 16), (2, 8, 16), (4, 8, 16), and (2, 4, 8, 16).

    Example 3:

    >>> hasTrailingZeros(nums = [1,3,5,7,9])
    >>> false
    Explanation: There is no possible way to select two or more elements to have trailing zeros in the binary representation of their bitwise OR.
    """


Prompt:
def maximumLength(s: str) -> int:
    """
    You are given a string s that consists of lowercase English letters.
    A string is called special if it is made up of only a single character. For example, the string "abc" is not special, whereas the strings "ddd", "zz", and "f" are special.
    Return the length of the longest special substring of s which occurs at least thrice, or -1 if no special substring occurs at least thrice.
    A substring is a contiguous non-empty sequence of characters within a string.

    Example 1:

    >>> maximumLength(s = "aaaa")
    >>> 2
    Explanation: The longest special substring which occurs thrice is "aa": substrings "aaaa", "aaaa", and "aaaa".
    It can be shown that the maximum length achievable is 2.

    Example 2:

    >>> maximumLength(s = "abcdef")
    >>> -1
    Explanation: There exists no special substring which occurs at least thrice. Hence return -1.

    Example 3:

    >>> maximumLength(s = "abcaba")
    >>> 1
    Explanation: The longest special substring which occurs thrice is "a": substrings "abcaba", "abcaba", and "abcaba".
    It can be shown that the maximum length achievable is 1.
    """


Prompt:
def maximumLength(s: str) -> int:
    """
    You are given a string s that consists of lowercase English letters.
    A string is called special if it is made up of only a single character. For example, the string "abc" is not special, whereas the strings "ddd", "zz", and "f" are special.
    Return the length of the longest special substring of s which occurs at least thrice, or -1 if no special substring occurs at least thrice.
    A substring is a contiguous non-empty sequence of characters within a string.

    Example 1:

    >>> maximumLength(s = "aaaa")
    >>> 2
    Explanation: The longest special substring which occurs thrice is "aa": substrings "aaaa", "aaaa", and "aaaa".
    It can be shown that the maximum length achievable is 2.

    Example 2:

    >>> maximumLength(s = "abcdef")
    >>> -1
    Explanation: There exists no special substring which occurs at least thrice. Hence return -1.

    Example 3:

    >>> maximumLength(s = "abcaba")
    >>> 1
    Explanation: The longest special substring which occurs thrice is "a": substrings "abcaba", "abcaba", and "abcaba".
    It can be shown that the maximum length achievable is 1.
    """


Prompt:
def canMakePalindromeQueries(s: str, queries: List[List[int]]) -> List[bool]:
    """
    You are given a 0-indexed string s having an even length n.
    You are also given a 0-indexed 2D integer array, queries, where queries[i] = [ai, bi, ci, di].
    For each query i, you are allowed to perform the following operations:

    Rearrange the characters within the substring s[ai:bi], where 0 <= ai <= bi < n / 2.
    Rearrange the characters within the substring s[ci:di], where n / 2 <= ci <= di < n.

    For each query, your task is to determine whether it is possible to make s a palindrome by performing the operations.
    Each query is answered independently of the others.
    Return a 0-indexed array answer, where answer[i] == true if it is possible to make s a palindrome by performing operations specified by the ith query, and false otherwise.

    A substring is a contiguous sequence of characters within a string.
    s[x:y] represents the substring consisting of characters from the index x to index y in s, both inclusive.

    Example 1:

    >>> canMakePalindromeQueries(s = "abcabc", queries = [[1,1,3,5],[0,2,5,5]])
    >>> [true,true]
    Explanation: In this example, there are two queries:
    In the first query:
    - a0 = 1, b0 = 1, c0 = 3, d0 = 5.
    - So, you are allowed to rearrange s[1:1] => abcabc and s[3:5] => abcabc.
    - To make s a palindrome, s[3:5] can be rearranged to become => abccba.
    - Now, s is a palindrome. So, answer[0] = true.
    In the second query:
    - a1 = 0, b1 = 2, c1 = 5, d1 = 5.
    - So, you are allowed to rearrange s[0:2] => abcabc and s[5:5] => abcabc.
    - To make s a palindrome, s[0:2] can be rearranged to become => cbaabc.
    - Now, s is a palindrome. So, answer[1] = true.

    Example 2:

    >>> canMakePalindromeQueries(s = "abbcdecbba", queries = [[0,2,7,9]])
    >>> [false]
    Explanation: In this example, there is only one query.
    a0 = 0, b0 = 2, c0 = 7, d0 = 9.
    So, you are allowed to rearrange s[0:2] => abbcdecbba and s[7:9] => abbcdecbba.
    It is not possible to make s a palindrome by rearranging these substrings because s[3:6] is not a palindrome.
    So, answer[0] = false.
    Example 3:

    >>> canMakePalindromeQueries(s = "acbcab", queries = [[1,2,4,5]])
    >>> [true]
    Explanation: In this example, there is only one query.
    a0 = 1, b0 = 2, c0 = 4, d0 = 5.
    So, you are allowed to rearrange s[1:2] => acbcab and s[4:5] => acbcab.
    To make s a palindrome s[1:2] can be rearranged to become abccab.
    Then, s[4:5] can be rearranged to become abccba.
    Now, s is a palindrome. So, answer[0] = true.
    """


Prompt:
def selfDivisiblePermutationCount(n: int) -> int:
    """
    Given an integer n, return the number of permutations of the 1-indexed array nums = [1, 2, ..., n], such that it's self-divisible.
    A 1-indexed array a of length n is self-divisible if for every 1 <= i <= n, gcd(a[i], i) == 1.
    A permutation of an array is a rearrangement of the elements of that array, for example here are all of the permutations of the array [1, 2, 3]:

    [1, 2, 3]
    [1, 3, 2]
    [2, 1, 3]
    [2, 3, 1]
    [3, 1, 2]
    [3, 2, 1]

    Example 1:

    >>> selfDivisiblePermutationCount(n = 1)
    >>> 1
    Explanation: The array [1] has only 1 permutation which is self-divisible.

    Example 2:

    >>> selfDivisiblePermutationCount(n = 2)
    >>> 1
    Explanation: The array [1,2] has 2 permutations and only one of them is self-divisible:
    nums = [1,2]: This is not self-divisible since gcd(nums[2], 2) != 1.
    nums = [2,1]: This is self-divisible since gcd(nums[1], 1) == 1 and gcd(nums[2], 2) == 1.

    Example 3:

    >>> selfDivisiblePermutationCount(n = 3)
    >>> 3
    Explanation: The array [1,2,3] has 3 self-divisble permutations: [1,3,2], [3,1,2], [2,3,1].
    It can be shown that the other 3 permutations are not self-divisible. Hence the answer is 3.
    """


Prompt:
def missingInteger(nums: List[int]) -> int:
    """
    You are given a 0-indexed array of integers nums.
    A prefix nums[0..i] is sequential if, for all 1 <= j <= i, nums[j] = nums[j - 1] + 1. In particular, the prefix consisting only of nums[0] is sequential.
    Return the smallest integer x missing from nums such that x is greater than or equal to the sum of the longest sequential prefix.

    Example 1:

    >>> missingInteger(nums = [1,2,3,2,5])
    >>> 6
    Explanation: The longest sequential prefix of nums is [1,2,3] with a sum of 6. 6 is not in the array, therefore 6 is the smallest missing integer greater than or equal to the sum of the longest sequential prefix.

    Example 2:

    >>> missingInteger(nums = [3,4,5,1,12,14,13])
    >>> 15
    Explanation: The longest sequential prefix of nums is [3,4,5] with a sum of 12. 12, 13, and 14 belong to the array while 15 does not. Therefore 15 is the smallest missing integer greater than or equal to the sum of the longest sequential prefix.
    """


Prompt:
def minOperations(nums: List[int], k: int) -> int:
    """
    You are given a 0-indexed integer array nums and a positive integer k.
    You can apply the following operation on the array any number of times:

    Choose any element of the array and flip a bit in its binary representation. Flipping a bit means changing a 0 to 1 or vice versa.

    Return the minimum number of operations required to make the bitwise XOR of all elements of the final array equal to k.
    Note that you can flip leading zero bits in the binary representation of elements. For example, for the number (101)2 you can flip the fourth bit and obtain (1101)2.

    Example 1:

    >>> minOperations(nums = [2,1,3,4], k = 1)
    >>> 2
    Explanation: We can do the following operations:
    - Choose element 2 which is 3 == (011)2, we flip the first bit and we obtain (010)2 == 2. nums becomes [2,1,2,4].
    - Choose element 0 which is 2 == (010)2, we flip the third bit and we obtain (110)2 = 6. nums becomes [6,1,2,4].
    The XOR of elements of the final array is (6 XOR 1 XOR 2 XOR 4) == 1 == k.
    It can be shown that we cannot make the XOR equal to k in less than 2 operations.

    Example 2:

    >>> minOperations(nums = [2,0,2,0], k = 0)
    >>> 0
    Explanation: The XOR of elements of the array is (2 XOR 0 XOR 2 XOR 0) == 0 == k. So no operation is needed.
    """


Prompt:
def minimumOperationsToMakeEqual(x: int, y: int) -> int:
    """
    You are given two positive integers x and y.
    In one operation, you can do one of the four following operations:

    Divide x by 11 if x is a multiple of 11.
    Divide x by 5 if x is a multiple of 5.
    Decrement x by 1.
    Increment x by 1.

    Return the minimum number of operations required to make  x and y equal.

    Example 1:

    >>> minimumOperationsToMakeEqual(x = 26, y = 1)
    >>> 3
    Explanation: We can make 26 equal to 1 by applying the following operations:
    1. Decrement x by 1
    2. Divide x by 5
    3. Divide x by 5
    It can be shown that 3 is the minimum number of operations required to make 26 equal to 1.

    Example 2:

    >>> minimumOperationsToMakeEqual(x = 54, y = 2)
    >>> 4
    Explanation: We can make 54 equal to 2 by applying the following operations:
    1. Increment x by 1
    2. Divide x by 11
    3. Divide x by 5
    4. Increment x by 1
    It can be shown that 4 is the minimum number of operations required to make 54 equal to 2.

    Example 3:

    >>> minimumOperationsToMakeEqual(x = 25, y = 30)
    >>> 5
    Explanation: We can make 25 equal to 30 by applying the following operations:
    1. Increment x by 1
    2. Increment x by 1
    3. Increment x by 1
    4. Increment x by 1
    5. Increment x by 1
    It can be shown that 5 is the minimum number of operations required to make 25 equal to 30.
    """


Prompt:
def numberOfPowerfulInt(start: int, finish: int, limit: int, s: str) -> int:
    """
    You are given three integers start, finish, and limit. You are also given a 0-indexed string s representing a positive integer.
    A positive integer x is called powerful if it ends with s (in other words, s is a suffix of x) and each digit in x is at most limit.
    Return the total number of powerful integers in the range [start..finish].
    A string x is a suffix of a string y if and only if x is a substring of y that starts from some index (including 0) in y and extends to the index y.length - 1. For example, 25 is a suffix of 5125 whereas 512 is not.

    Example 1:

    >>> numberOfPowerfulInt(start = 1, finish = 6000, limit = 4, s = "124")
    >>> 5
    Explanation: The powerful integers in the range [1..6000] are 124, 1124, 2124, 3124, and, 4124. All these integers have each digit <= 4, and "124" as a suffix. Note that 5124 is not a powerful integer because the first digit is 5 which is greater than 4.
    It can be shown that there are only 5 powerful integers in this range.

    Example 2:

    >>> numberOfPowerfulInt(start = 15, finish = 215, limit = 6, s = "10")
    >>> 2
    Explanation: The powerful integers in the range [15..215] are 110 and 210. All these integers have each digit <= 6, and "10" as a suffix.
    It can be shown that there are only 2 powerful integers in this range.

    Example 3:

    >>> numberOfPowerfulInt(start = 1000, finish = 2000, limit = 4, s = "3000")
    >>> 0
    Explanation: All integers in the range [1000..2000] are smaller than 3000, hence "3000" cannot be a suffix of any integer in this range.
    """


Prompt:
def areaOfMaxDiagonal(dimensions: List[List[int]]) -> int:
    """
    You are given a 2D 0-indexed integer array dimensions.
    For all indices i, 0 <= i < dimensions.length, dimensions[i][0] represents the length and dimensions[i][1] represents the width of the rectangle i.
    Return the area of the rectangle having the longest diagonal. If there are multiple rectangles with the longest diagonal, return the area of the rectangle having the maximum area.

    Example 1:

    >>> areaOfMaxDiagonal(dimensions = [[9,3],[8,6]])
    >>> 48
    Explanation:
    For index = 0, length = 9 and width = 3. Diagonal length = sqrt(9 * 9 + 3 * 3) = sqrt(90) ≈ 9.487.
    For index = 1, length = 8 and width = 6. Diagonal length = sqrt(8 * 8 + 6 * 6) = sqrt(100) = 10.
    So, the rectangle at index 1 has a greater diagonal length therefore we return area = 8 * 6 = 48.

    Example 2:

    >>> areaOfMaxDiagonal(dimensions = [[3,4],[4,3]])
    >>> 12
    Explanation: Length of diagonal is the same for both which is 5, so maximum area = 12.
    """


Prompt:
def minMovesToCaptureTheQueen(a: int, b: int, c: int, d: int, e: int, f: int) -> int:
    """
    There is a 1-indexed 8 x 8 chessboard containing 3 pieces.
    You are given 6 integers a, b, c, d, e, and f where:

    (a, b) denotes the position of the white rook.
    (c, d) denotes the position of the white bishop.
    (e, f) denotes the position of the black queen.

    Given that you can only move the white pieces, return the minimum number of moves required to capture the black queen.
    Note that:

    Rooks can move any number of squares either vertically or horizontally, but cannot jump over other pieces.
    Bishops can move any number of squares diagonally, but cannot jump over other pieces.
    A rook or a bishop can capture the queen if it is located in a square that they can move to.
    The queen does not move.

    Example 1:

    >>> minMovesToCaptureTheQueen(a = 1, b = 1, c = 8, d = 8, e = 2, f = 3)
    >>> 2
    Explanation: We can capture the black queen in two moves by moving the white rook to (1, 3) then to (2, 3).
    It is impossible to capture the black queen in less than two moves since it is not being attacked by any of the pieces at the beginning.

    Example 2:

    >>> minMovesToCaptureTheQueen(a = 5, b = 3, c = 3, d = 4, e = 5, f = 2)
    >>> 1
    Explanation: We can capture the black queen in a single move by doing one of the following:
    - Move the white rook to (5, 2).
    - Move the white bishop to (5, 2).
    """


Prompt:
def maximumSetSize(nums1: List[int], nums2: List[int]) -> int:
    """
    You are given two 0-indexed integer arrays nums1 and nums2 of even length n.
    You must remove n / 2 elements from nums1 and n / 2 elements from nums2. After the removals, you insert the remaining elements of nums1 and nums2 into a set s.
    Return the maximum possible size of the set s.

    Example 1:

    >>> maximumSetSize(nums1 = [1,2,1,2], nums2 = [1,1,1,1])
    >>> 2
    Explanation: We remove two occurences of 1 from nums1 and nums2. After the removals, the arrays become equal to nums1 = [2,2] and nums2 = [1,1]. Therefore, s = {1,2}.
    It can be shown that 2 is the maximum possible size of the set s after the removals.

    Example 2:

    >>> maximumSetSize(nums1 = [1,2,3,4,5,6], nums2 = [2,3,2,3,2,3])
    >>> 5
    Explanation: We remove 2, 3, and 6 from nums1, as well as 2 and two occurrences of 3 from nums2. After the removals, the arrays become equal to nums1 = [1,4,5] and nums2 = [2,3,2]. Therefore, s = {1,2,3,4,5}.
    It can be shown that 5 is the maximum possible size of the set s after the removals.

    Example 3:

    >>> maximumSetSize(nums1 = [1,1,2,2,3,3], nums2 = [4,4,5,5,6,6])
    >>> 6
    Explanation: We remove 1, 2, and 3 from nums1, as well as 4, 5, and 6 from nums2. After the removals, the arrays become equal to nums1 = [1,2,3] and nums2 = [4,5,6]. Therefore, s = {1,2,3,4,5,6}.
    It can be shown that 6 is the maximum possible size of the set s after the removals.
    """


Prompt:
def maxPartitionsAfterOperations(s: str, k: int) -> int:
    """
    You are given a string s and an integer k.
    First, you are allowed to change at most one index in s to another lowercase English letter.
    After that, do the following partitioning operation until s is empty:

    Choose the longest prefix of s containing at most k distinct characters.
    Delete the prefix from s and increase the number of partitions by one. The remaining characters (if any) in s maintain their initial order.

    Return an integer denoting the maximum number of resulting partitions after the operations by optimally choosing at most one index to change.

    Example 1:

    >>> maxPartitionsAfterOperations(s = "accca", k = 2)
    >>> 3
    Explanation:
    The optimal way is to change s[2] to something other than a and c, for example, b. then it becomes "acbca".
    Then we perform the operations:

    The longest prefix containing at most 2 distinct characters is "ac", we remove it and s becomes "bca".
    Now The longest prefix containing at most 2 distinct characters is "bc", so we remove it and s becomes "a".
    Finally, we remove "a" and s becomes empty, so the procedure ends.

    Doing the operations, the string is divided into 3 partitions, so the answer is 3.

    Example 2:

    >>> maxPartitionsAfterOperations(s = "aabaab", k = 3)
    >>> 1
    Explanation:
    Initially s contains 2 distinct characters, so whichever character we change, it will contain at most 3 distinct characters, so the longest prefix with at most 3 distinct characters would always be all of it, therefore the answer is 1.

    Example 3:

    >>> maxPartitionsAfterOperations(s = "xxyz", k = 1)
    >>> 4
    Explanation:
    The optimal way is to change s[0] or s[1] to something other than characters in s, for example, to change s[0] to w.
    Then s becomes "wxyz", which consists of 4 distinct characters, so as k is 1, it will divide into 4 partitions.
    """


Prompt:
def maximumSubtreeSize(edges: List[List[int]], colors: List[int]) -> int:
    """
    You are given a 2D integer array edges representing a tree with n nodes, numbered from 0 to n - 1, rooted at node 0, where edges[i] = [ui, vi] means there is an edge between the nodes vi and ui.
    You are also given a 0-indexed integer array colors of size n, where colors[i] is the color assigned to node i.
    We want to find a node v such that every node in the subtree of v has the same color.
    Return the size of such subtree with the maximum number of nodes possible.

    Example 1:

    >>> maximumSubtreeSize(edges = [[0,1],[0,2],[0,3]], colors = [1,1,2,3])
    >>> 1
    Explanation: Each color is represented as: 1 -> Red, 2 -> Green, 3 -> Blue. We can see that the subtree rooted at node 0 has children with different colors. Any other subtree is of the same color and has a size of 1. Hence, we return 1.

    Example 2:

    >>> maximumSubtreeSize(edges = [[0,1],[0,2],[0,3]], colors = [1,1,1,1])
    >>> 4
    Explanation: The whole tree has the same color, and the subtree rooted at node 0 has the most number of nodes which is 4. Hence, we return 4.

    Example 3:

    >>> maximumSubtreeSize(edges = [[0,1],[0,2],[2,3],[2,4]], colors = [1,2,3,3,3])
    >>> 3
    Explanation: Each color is represented as: 1 -> Red, 2 -> Green, 3 -> Blue. We can see that the subtree rooted at node 0 has children with different colors. Any other subtree is of the same color, but the subtree rooted at node 2 has a size of 3 which is the maximum. Hence, we return 3.
    """


Prompt:
def maxFrequencyElements(nums: List[int]) -> int:
    """
    You are given an array nums consisting of positive integers.
    Return the total frequencies of elements in nums such that those elements all have the maximum frequency.
    The frequency of an element is the number of occurrences of that element in the array.

    Example 1:

    >>> maxFrequencyElements(nums = [1,2,2,3,1,4])
    >>> 4
    Explanation: The elements 1 and 2 have a frequency of 2 which is the maximum frequency in the array.
    So the number of elements in the array with maximum frequency is 4.

    Example 2:

    >>> maxFrequencyElements(nums = [1,2,3,4,5])
    >>> 5
    Explanation: All elements of the array have a frequency of 1 which is the maximum.
    So the number of elements in the array with maximum frequency is 5.
    """


Prompt:
def beautifulIndices(s: str, a: str, b: str, k: int) -> List[int]:
    """
    You are given a 0-indexed string s, a string a, a string b, and an integer k.
    An index i is beautiful if:

    0 <= i <= s.length - a.length
    s[i..(i + a.length - 1)] == a
    There exists an index j such that:

    0 <= j <= s.length - b.length
    s[j..(j + b.length - 1)] == b
    |j - i| <= k

    Return the array that contains beautiful indices in sorted order from smallest to largest.

    Example 1:

    >>> beautifulIndices(s = "isawsquirrelnearmysquirrelhouseohmy", a = "my", b = "squirrel", k = 15)
    >>> [16,33]
    Explanation: There are 2 beautiful indices: [16,33].
    - The index 16 is beautiful as s[16..17] == "my" and there exists an index 4 with s[4..11] == "squirrel" and |16 - 4| <= 15.
    - The index 33 is beautiful as s[33..34] == "my" and there exists an index 18 with s[18..25] == "squirrel" and |33 - 18| <= 15.
    Thus we return [16,33] as the result.

    Example 2:

    >>> beautifulIndices(s = "abcd", a = "a", b = "a", k = 4)
    >>> [0]
    Explanation: There is 1 beautiful index: [0].
    - The index 0 is beautiful as s[0..0] == "a" and there exists an index 0 with s[0..0] == "a" and |0 - 0| <= 4.
    Thus we return [0] as the result.
    """


Prompt:
def findMaximumNumber(k: int, x: int) -> int:
    """
    You are given an integer k and an integer x. The price of a number num is calculated by the count of set bits at positions x, 2x, 3x, etc., in its binary representation, starting from the least significant bit. The following table contains examples of how price is calculated.

    x
    num
    Binary Representation
    Price

    1
    13
    000001101
    3

    2
    13
    000001101
    1

    2
    233
    011101001
    3

    3
    13
    000001101
    1

    3
    362
    101101010
    2

    The accumulated price of num is the total price of numbers from 1 to num. num is considered cheap if its accumulated price is less than or equal to k.
    Return the greatest cheap number.

    Example 1:

    >>> findMaximumNumber(k = 9, x = 1)
    >>> 6
    Explanation:
    As shown in the table below, 6 is the greatest cheap number.

    x
    num
    Binary Representation
    Price
    Accumulated Price

    1
    1
    001
    1
    1

    1
    2
    010
    1
    2

    1
    3
    011
    2
    4

    1
    4
    100
    1
    5

    1
    5
    101
    2
    7

    1
    6
    110
    2
    9

    1
    7
    111
    3
    12

    Example 2:

    >>> findMaximumNumber(k = 7, x = 2)
    >>> 9
    Explanation:
    As shown in the table below, 9 is the greatest cheap number.

    x
    num
    Binary Representation
    Price
    Accumulated Price

    2
    1
    0001
    0
    0

    2
    2
    0010
    1
    1

    2
    3
    0011
    1
    2

    2
    4
    0100
    0
    2

    2
    5
    0101
    0
    2

    2
    6
    0110
    1
    3

    2
    7
    0111
    1
    4

    2
    8
    1000
    1
    5

    2
    9
    1001
    1
    6

    2
    10
    1010
    2
    8
    """


Prompt:
def beautifulIndices(s: str, a: str, b: str, k: int) -> List[int]:
    """
    You are given a 0-indexed string s, a string a, a string b, and an integer k.
    An index i is beautiful if:

    0 <= i <= s.length - a.length
    s[i..(i + a.length - 1)] == a
    There exists an index j such that:

    0 <= j <= s.length - b.length
    s[j..(j + b.length - 1)] == b
    |j - i| <= k

    Return the array that contains beautiful indices in sorted order from smallest to largest.

    Example 1:

    >>> beautifulIndices(s = "isawsquirrelnearmysquirrelhouseohmy", a = "my", b = "squirrel", k = 15)
    >>> [16,33]
    Explanation: There are 2 beautiful indices: [16,33].
    - The index 16 is beautiful as s[16..17] == "my" and there exists an index 4 with s[4..11] == "squirrel" and |16 - 4| <= 15.
    - The index 33 is beautiful as s[33..34] == "my" and there exists an index 18 with s[18..25] == "squirrel" and |33 - 18| <= 15.
    Thus we return [16,33] as the result.

    Example 2:

    >>> beautifulIndices(s = "abcd", a = "a", b = "a", k = 4)
    >>> [0]
    Explanation: There is 1 beautiful index: [0].
    - The index 0 is beautiful as s[0..0] == "a" and there exists an index 0 with s[0..0] == "a" and |0 - 0| <= 4.
    Thus we return [0] as the result.
    """


Prompt:
def maxIntersectionCount(y: List[int]) -> int:
    """
    There is a line chart consisting of n points connected by line segments. You are given a 1-indexed integer array y. The kth point has coordinates (k, y[k]). There are no horizontal lines; that is, no two consecutive points have the same y-coordinate.
    We can draw an infinitely long horizontal line. Return the maximum number of points of intersection of the line with the chart.

    Example 1:

    >>> maxIntersectionCount(y = [1,2,1,2,1,3,2])
    >>> 5
    Explanation: As you can see in the image above, the line y = 1.5 has 5 intersections with the chart (in red crosses). You can also see the line y = 2 which intersects the chart in 4 points (in red crosses). It can be shown that there is no horizontal line intersecting the chart at more than 5 points. So the answer would be 5.

    Example 2:

    >>> maxIntersectionCount(y = [2,1,3,4,5])
    >>> 2
    Explanation: As you can see in the image above, the line y = 1.5 has 2 intersections with the chart (in red crosses). You can also see the line y = 2 which intersects the chart in 2 points (in red crosses). It can be shown that there is no horizontal line intersecting the chart at more than 2 points. So the answer would be 2.
    """


Prompt:
def minimumCost(nums: List[int]) -> int:
    """
    You are given an array of integers nums of length n.
    The cost of an array is the value of its first element. For example, the cost of [1,2,3] is 1 while the cost of [3,4,1] is 3.
    You need to divide nums into 3 disjoint contiguous subarrays.
    Return the minimum possible sum of the cost of these subarrays.

    Example 1:

    >>> minimumCost(nums = [1,2,3,12])
    >>> 6
    Explanation: The best possible way to form 3 subarrays is: [1], [2], and [3,12] at a total cost of 1 + 2 + 3 = 6.
    The other possible ways to form 3 subarrays are:
    - [1], [2,3], and [12] at a total cost of 1 + 2 + 12 = 15.
    - [1,2], [3], and [12] at a total cost of 1 + 3 + 12 = 16.

    Example 2:

    >>> minimumCost(nums = [5,4,3])
    >>> 12
    Explanation: The best possible way to form 3 subarrays is: [5], [4], and [3] at a total cost of 5 + 4 + 3 = 12.
    It can be shown that 12 is the minimum cost achievable.

    Example 3:

    >>> minimumCost(nums = [10,3,1,1])
    >>> 12
    Explanation: The best possible way to form 3 subarrays is: [10,3], [1], and [1] at a total cost of 10 + 1 + 1 = 12.
    It can be shown that 12 is the minimum cost achievable.
    """