Prompt:
from typing import List
def maximumScore(nums: List[int], k: int) -> int:
    """
    You are given an array of integers nums (0-indexed) and an integer k.
    The score of a subarray (i, j) is defined as min(nums[i], nums[i+1], ..., nums[j]) * (j - i + 1). A good subarray is a subarray where i <= k <= j.
    Return the maximum possible score of a good subarray.

    Example 1:

    >>> maximumScore(nums = [1,4,3,7,4,5], k = 3)
    >>> 15
    Explanation: The optimal subarray is (1, 5) with a score of min(4,3,7,4,5) * (5-1+1) = 3 * 5 = 15.

    Example 2:

    >>> maximumScore(nums = [5,5,4,5,4,1,1,1], k = 0)
    >>> 20
    Explanation: The optimal subarray is (0, 4) with a score of min(5,5,4,5,4) * (4-0+1) = 4 * 5 = 20.
    """


Prompt:
def countQuadruples(firstString: str, secondString: str) -> int:
    """
    You are given two strings firstString and secondString that are 0-indexed and consist only of lowercase English letters. Count the number of index quadruples (i,j,a,b) that satisfy the following conditions:

    0 <= i <= j < firstString.length
    0 <= a <= b < secondString.length
    The substring of firstString that starts at the ith character and ends at the jth character (inclusive) is equal to the substring of secondString that starts at the ath character and ends at the bth character (inclusive).
    j - a is the minimum possible value among all quadruples that satisfy the previous conditions.

    Return the number of such quadruples.

    Example 1:

    >>> countQuadruples(firstString = "abcd", secondString = "bccda")
    >>> 1
    Explanation: The quadruple (0,0,4,4) is the only one that satisfies all the conditions and minimizes j - a.

    Example 2:

    >>> countQuadruples(firstString = "ab", secondString = "cd")
    >>> 0
    Explanation: There are no quadruples satisfying all the conditions.
    """


Prompt:
def secondHighest(s: str) -> int:
    """
    Given an alphanumeric string s, return the second largest numerical digit that appears in s, or -1 if it does not exist.
    An alphanumeric string is a string consisting of lowercase English letters and digits.

    Example 1:

    >>> secondHighest(s = "dfa12321afd")
    >>> 2
    Explanation: The digits that appear in s are [1, 2, 3]. The second largest digit is 2.

    Example 2:

    >>> secondHighest(s = "abc1111")
    >>> -1
    Explanation: The digits that appear in s are [1]. There is no second largest digit.
    """


Prompt:
from typing import List
def getMaximumConsecutive(coins: List[int]) -> int:
    """
    You are given an integer array coins of length n which represents the n coins that you own. The value of the ith coin is coins[i]. You can make some value x if you can choose some of your n coins such that their values sum up to x.
    Return the maximum number of consecutive integer values that you can make with your coins starting from and including 0.
    Note that you may have multiple coins of the same value.

    Example 1:

    >>> getMaximumConsecutive(coins = [1,3])
    >>> 2
    Explanation: You can make the following values:
    - 0: take []
    - 1: take [1]
    You can make 2 consecutive integer values starting from 0.
    Example 2:

    >>> getMaximumConsecutive(coins = [1,1,1,4])
    >>> 8
    Explanation: You can make the following values:
    - 0: take []
    - 1: take [1]
    - 2: take [1,1]
    - 3: take [1,1,1]
    - 4: take [4]
    - 5: take [4,1]
    - 6: take [4,1,1]
    - 7: take [4,1,1,1]
    You can make 8 consecutive integer values starting from 0.
    Example 3:

    >>> getMaximumConsecutive(coins = [1,4,10,3,1])
    >>> 20
    """


Prompt:
from typing import List
def maxAscendingSum(nums: List[int]) -> int:
    """
    Given an array of positive integers nums, return the maximum possible sum of an strictly increasing subarray in nums.
    A subarray is defined as a contiguous sequence of numbers in an array.

    Example 1:

    >>> maxAscendingSum(nums = [10,20,30,5,10,50])
    >>> 65
    Explanation: [5,10,50] is the ascending subarray with the maximum sum of 65.

    Example 2:

    >>> maxAscendingSum(nums = [10,20,30,40,50])
    >>> 150
    Explanation: [10,20,30,40,50] is the ascending subarray with the maximum sum of 150.

    Example 3:

    >>> maxAscendingSum(nums = [12,17,15,13,10,11,12])
    >>> 33
    Explanation: [10,11,12] is the ascending subarray with the maximum sum of 33.
    """


Prompt:
from typing import List
def getNumberOfBacklogOrders(orders: List[List[int]]) -> int:
    """
    You are given a 2D integer array orders, where each orders[i] = [pricei, amounti, orderTypei] denotes that amounti orders have been placed of type orderTypei at the price pricei. The orderTypei is:\r
    \r
    \r
    	0 if it is a batch of buy orders, or\r
    	1 if it is a batch of sell orders.\r
    \r
    \r
    Note that orders[i] represents a batch of amounti independent orders with the same price and order type. All orders represented by orders[i] will be placed before all orders represented by orders[i+1] for all valid i.\r
    \r
    There is a backlog that consists of orders that have not been executed. The backlog is initially empty. When an order is placed, the following happens:\r
    \r
    \r
    	If the order is a buy order, you look at the sell order with the smallest price in the backlog. If that sell order's price is smaller than or equal to the current buy order's price, they will match and be executed, and that sell order will be removed from the backlog. Else, the buy order is added to the backlog.\r
    	Vice versa, if the order is a sell order, you look at the buy order with the largest price in the backlog. If that buy order's price is larger than or equal to the current sell order's price, they will match and be executed, and that buy order will be removed from the backlog. Else, the sell order is added to the backlog.\r
    \r
    \r
    Return the total amount of orders in the backlog after placing all the orders from the input. Since this number can be large, return it modulo 109 + 7.\r
    \r
     \r
    Example 1:\r
    \r
    \r
    >>> getNumberOfBacklogOrders(orders = [[10,5,0],[15,2,1],[25,1,1],[30,4,0]]\r)
    >>> 6\r
    Explanation: Here is what happens with the orders:\r
    - 5 orders of type buy with price 10 are placed. There are no sell orders, so the 5 orders are added to the backlog.\r
    - 2 orders of type sell with price 15 are placed. There are no buy orders with prices larger than or equal to 15, so the 2 orders are added to the backlog.\r
    - 1 order of type sell with price 25 is placed. There are no buy orders with prices larger than or equal to 25 in the backlog, so this order is added to the backlog.\r
    - 4 orders of type buy with price 30 are placed. The first 2 orders are matched with the 2 sell orders of the least price, which is 15 and these 2 sell orders are removed from the backlog. The 3rd order is matched with the sell order of the least price, which is 25 and this sell order is removed from the backlog. Then, there are no more sell orders in the backlog, so the 4th order is added to the backlog.\r
    Finally, the backlog has 5 buy orders with price 10, and 1 buy order with price 30. So the total number of orders in the backlog is 6.\r
    \r
    \r
    Example 2:\r
    \r
    \r
    >>> getNumberOfBacklogOrders(orders = [[7,1000000000,1],[15,3,0],[5,999999995,0],[5,1,1]]\r)
    >>> 999999984\r
    Explanation: Here is what happens with the orders:\r
    - 109 orders of type sell with price 7 are placed. There are no buy orders, so the 109 orders are added to the backlog.\r
    - 3 orders of type buy with price 15 are placed. They are matched with the 3 sell orders with the least price which is 7, and those 3 sell orders are removed from the backlog.\r
    - 999999995 orders of type buy with price 5 are placed. The least price of a sell order is 7, so the 999999995 orders are added to the backlog.\r
    - 1 order of type sell with price 5 is placed. It is matched with the buy order of the highest price, which is 5, and that buy order is removed from the backlog.\r
    Finally, the backlog has (1000000000-3) sell orders with price 7, and (999999995-1) buy orders with price 5. So the total number of orders = 1999999991, which is equal to 999999984 % (109 + 7).\r
    \r
    \r
     \r
    """


Prompt:
def maxValue(n: int, index: int, maxSum: int) -> int:
    """
    You are given three positive integers: n, index, and maxSum. You want to construct an array nums (0-indexed) that satisfies the following conditions:

    nums.length == n
    nums[i] is a positive integer where 0 <= i < n.
    abs(nums[i] - nums[i+1]) <= 1 where 0 <= i < n-1.
    The sum of all the elements of nums does not exceed maxSum.
    nums[index] is maximized.

    Return nums[index] of the constructed array.
    Note that abs(x) equals x if x >= 0, and -x otherwise.

    Example 1:

    >>> maxValue(n = 4, index = 2,  maxSum = 6)
    >>> 2
    Explanation: nums = [1,2,2,1] is one array that satisfies all the conditions.
    There are no arrays that satisfy all the conditions and have nums[2] == 3, so 2 is the maximum nums[2].

    Example 2:

    >>> maxValue(n = 6, index = 1,  maxSum = 10)
    >>> 3
    """


Prompt:
from typing import List
def countPairs(nums: List[int], low: int, high: int) -> int:
    """
    Given a (0-indexed) integer array nums and two integers low and high, return the number of nice pairs.\r
    \r
    A nice pair is a pair (i, j) where 0 <= i < j < nums.length and low <= (nums[i] XOR nums[j]) <= high.\r
    \r
     \r
    Example 1:\r
    \r
    \r
    >>> countPairs(nums = [1,4,2,7], low = 2, high = 6\r)
    >>> 6\r
    Explanation: All nice pairs (i, j) are as follows:\r
        - (0, 1): nums[0] XOR nums[1] = 5 \r
        - (0, 2): nums[0] XOR nums[2] = 3\r
        - (0, 3): nums[0] XOR nums[3] = 6\r
        - (1, 2): nums[1] XOR nums[2] = 6\r
        - (1, 3): nums[1] XOR nums[3] = 3\r
        - (2, 3): nums[2] XOR nums[3] = 5\r
    \r
    \r
    Example 2:\r
    \r
    \r
    >>> countPairs(nums = [9,8,4,2,1], low = 5, high = 14\r)
    >>> 8\r
    Explanation: All nice pairs (i, j) are as follows:\r
        - (0, 2): nums[0] XOR nums[2] = 13\r
        - (0, 3): nums[0] XOR nums[3] = 11\r
        - (0, 4): nums[0] XOR nums[4] = 8\r
        - (1, 2): nums[1] XOR nums[2] = 12\r
        - (1, 3): nums[1] XOR nums[3] = 10\r
        - (1, 4): nums[1] XOR nums[4] = 9\r
        - (2, 3): nums[2] XOR nums[3] = 6\r
        - (2, 4): nums[2] XOR nums[4] = 5\r
    \r
     \r
    """


Prompt:
def numDifferentIntegers(word: str) -> int:
    """
    You are given a string word that consists of digits and lowercase English letters.
    You will replace every non-digit character with a space. For example, "a123bc34d8ef34" will become " 123  34 8  34". Notice that you are left with some integers that are separated by at least one space: "123", "34", "8", and "34".
    Return the number of different integers after performing the replacement operations on word.
    Two integers are considered different if their decimal representations without any leading zeros are different.

    Example 1:

    >>> numDifferentIntegers(word = "a123bc34d8ef34")
    >>> 3
    Explanation: The three different integers are "123", "34", and "8". Notice that "34" is only counted once.

    Example 2:

    >>> numDifferentIntegers(word = "leet1234code234")
    >>> 2

    Example 3:

    >>> numDifferentIntegers(word = "a1b01c001")
    >>> 1
    Explanation: The three integers "1", "01", and "001" all represent the same integer because
    the leading zeros are ignored when comparing their decimal values.
    """


Prompt:
def reinitializePermutation(n: int) -> int:
    """
    You are given an even integer n. You initially have a permutation perm of size n where perm[i] == i (0-indexed).
    In one operation, you will create a new array arr, and for each i:

    If i % 2 == 0, then arr[i] = perm[i / 2].
    If i % 2 == 1, then arr[i] = perm[n / 2 + (i - 1) / 2].

    You will then assign arr to perm.
    Return the minimum non-zero number of operations you need to perform on perm to return the permutation to its initial value.

    Example 1:

    >>> reinitializePermutation(n = 2)
    >>> 1
    Explanation: perm = [0,1] initially.
    After the 1st operation, perm = [0,1]
    So it takes only 1 operation.

    Example 2:

    >>> reinitializePermutation(n = 4)
    >>> 2
    Explanation: perm = [0,1,2,3] initially.
    After the 1st operation, perm = [0,2,1,3]
    After the 2nd operation, perm = [0,1,2,3]
    So it takes only 2 operations.

    Example 3:

    >>> reinitializePermutation(n = 6)
    >>> 4
    """


Prompt:
from typing import List
def evaluate(s: str, knowledge: List[List[str]]) -> str:
    """
    You are given a string s that contains some bracket pairs, with each pair containing a non-empty key.

    For example, in the string "(name)is(age)yearsold", there are two bracket pairs that contain the keys "name" and "age".

    You know the values of a wide range of keys. This is represented by a 2D string array knowledge where each knowledge[i] = [keyi, valuei] indicates that key keyi has a value of valuei.
    You are tasked to evaluate all of the bracket pairs. When you evaluate a bracket pair that contains some key keyi, you will:

    Replace keyi and the bracket pair with the key's corresponding valuei.
    If you do not know the value of the key, you will replace keyi and the bracket pair with a question mark "?" (without the quotation marks).

    Each key will appear at most once in your knowledge. There will not be any nested brackets in s.
    Return the resulting string after evaluating all of the bracket pairs.

    Example 1:

    >>> evaluate(s = "(name)is(age)yearsold", knowledge = [["name","bob"],["age","two"]])
    >>> "bobistwoyearsold"
    Explanation:
    The key "name" has a value of "bob", so replace "(name)" with "bob".
    The key "age" has a value of "two", so replace "(age)" with "two".

    Example 2:

    >>> evaluate(s = "hi(name)", knowledge = [["a","b"]])
    >>> "hi?"
    Explanation: As you do not know the value of the key "name", replace "(name)" with "?".

    Example 3:

    >>> evaluate(s = "(a)(a)(a)aaa", knowledge = [["a","yes"]])
    >>> "yesyesyesaaa"
    Explanation: The same key can appear multiple times.
    The key "a" has a value of "yes", so replace all occurrences of "(a)" with "yes".
    Notice that the "a"s not in a bracket pair are not evaluated.
    """


Prompt:
def maxNiceDivisors(primeFactors: int) -> int:
    """
    You are given a positive integer primeFactors. You are asked to construct a positive integer n that satisfies the following conditions:\r
    \r
    \r
      The number of prime factors of n (not necessarily distinct) is at most primeFactors.\r
      The number of nice divisors of n is maximized. Note that a divisor of n is nice if it is divisible by every prime factor of n. For example, if n = 12, then its prime factors are [2,2,3], then 6 and 12 are nice divisors, while 3 and 4 are not.\r
    \r
    \r
    Return the number of nice divisors of n. Since that number can be too large, return it modulo 109 + 7.\r
    \r
    Note that a prime number is a natural number greater than 1 that is not a product of two smaller natural numbers. The prime factors of a number n is a list of prime numbers such that their product equals n.\r
    \r
     \r
    Example 1:\r
    \r
    \r
    >>> maxNiceDivisors(primeFactors = 5\r)
    >>> 6\r
    Explanation: 200 is a valid value of n.\r
    It has 5 prime factors: [2,2,2,5,5], and it has 6 nice divisors: [10,20,40,50,100,200].\r
    There is not other value of n that has at most 5 prime factors and more nice divisors.\r
    \r
    \r
    Example 2:\r
    \r
    \r
    >>> maxNiceDivisors(primeFactors = 8\r)
    >>> 18\r
    \r
    \r
     \r
    """


Prompt:
def squareIsWhite(coordinates: str) -> bool:
    """
    You are given coordinates, a string that represents the coordinates of a square of the chessboard. Below is a chessboard for your reference.

    Return true if the square is white, and false if the square is black.
    The coordinate will always represent a valid chessboard square. The coordinate will always have the letter first, and the number second.

    Example 1:

    >>> squareIsWhite(coordinates = "a1")
    >>> false
    Explanation: From the chessboard above, the square with coordinates "a1" is black, so return false.

    Example 2:

    >>> squareIsWhite(coordinates = "h3")
    >>> true
    Explanation: From the chessboard above, the square with coordinates "h3" is white, so return true.

    Example 3:

    >>> squareIsWhite(coordinates = "c7")
    >>> false
    """


Prompt:
def areSentencesSimilar(sentence1: str, sentence2: str) -> bool:
    """
    You are given two strings sentence1 and sentence2, each representing a sentence composed of words. A sentence is a list of words that are separated by a single space with no leading or trailing spaces. Each word consists of only uppercase and lowercase English characters.
    Two sentences s1 and s2 are considered similar if it is possible to insert an arbitrary sentence (possibly empty) inside one of these sentences such that the two sentences become equal. Note that the inserted sentence must be separated from existing words by spaces.
    For example,

    s1 = "Hello Jane" and s2 = "Hello my name is Jane" can be made equal by inserting "my name is" between "Hello" and "Jane" in s1.
    s1 = "Frog cool" and s2 = "Frogs are cool" are not similar, since although there is a sentence "s are" inserted into s1, it is not separated from "Frog" by a space.

    Given two sentences sentence1 and sentence2, return true if sentence1 and sentence2 are similar. Otherwise, return false.

    Example 1:

    >>> areSentencesSimilar(sentence1 = "My name is Haley", sentence2 = "My Haley")
    >>> true
    Explanation:
    sentence2 can be turned to sentence1 by inserting "name is" between "My" and "Haley".

    Example 2:

    >>> areSentencesSimilar(sentence1 = "of", sentence2 = "A lot of words")
    >>> false
    Explanation:
    No single sentence can be inserted inside one of the sentences to make it equal to the other.

    Example 3:

    >>> areSentencesSimilar(sentence1 = "Eating right now", sentence2 = "Eating")
    >>> true
    Explanation:
    sentence2 can be turned to sentence1 by inserting "right now" at the end of the sentence.
    """


Prompt:
from typing import List
def countNicePairs(nums: List[int]) -> int:
    """
    You are given an array nums that consists of non-negative integers. Let us define rev(x) as the reverse of the non-negative integer x. For example, rev(123) = 321, and rev(120) = 21. A pair of indices (i, j) is nice if it satisfies all of the following conditions:

    0 <= i < j < nums.length
    nums[i] + rev(nums[j]) == nums[j] + rev(nums[i])

    Return the number of nice pairs of indices. Since that number can be too large, return it modulo 109 + 7.

    Example 1:

    >>> countNicePairs(nums = [42,11,1,97])
    >>> 2
    Explanation: The two pairs are:
     - (0,3) : 42 + rev(97) = 42 + 79 = 121, 97 + rev(42) = 97 + 24 = 121.
     - (1,2) : 11 + rev(1) = 11 + 1 = 12, 1 + rev(11) = 1 + 11 = 12.

    Example 2:

    >>> countNicePairs(nums = [13,10,35,24,76])
    >>> 4
    """


Prompt:
from typing import List
def maxHappyGroups(batchSize: int, groups: List[int]) -> int:
    """
    There is a donuts shop that bakes donuts in batches of batchSize. They have a rule where they must serve all of the donuts of a batch before serving any donuts of the next batch. You are given an integer batchSize and an integer array groups, where groups[i] denotes that there is a group of groups[i] customers that will visit the shop. Each customer will get exactly one donut.
    When a group visits the shop, all customers of the group must be served before serving any of the following groups. A group will be happy if they all get fresh donuts. That is, the first customer of the group does not receive a donut that was left over from the previous group.
    You can freely rearrange the ordering of the groups. Return the maximum possible number of happy groups after rearranging the groups.

    Example 1:

    >>> maxHappyGroups(batchSize = 3, groups = [1,2,3,4,5,6])
    >>> 4
    Explanation: You can arrange the groups as [6,2,4,5,1,3]. Then the 1st, 2nd, 4th, and 6th groups will be happy.

    Example 2:

    >>> maxHappyGroups(batchSize = 4, groups = [1,3,2,5,2,2,1,6])
    >>> 4
    """


Prompt:
def truncateSentence(s: str, k: int) -> str:
    """
    A sentence is a list of words that are separated by a single space with no leading or trailing spaces. Each of the words consists of only uppercase and lowercase English letters (no punctuation).

    For example, "Hello World", "HELLO", and "hello world hello world" are all sentences.

    You are given a sentence s and an integer k. You want to truncate s such that it contains only the first k words. Return s after truncating it.

    Example 1:

    >>> truncateSentence(s = "Hello how are you Contestant", k = 4)
    >>> "Hello how are you"
    Explanation:
    The words in s are ["Hello", "how" "are", "you", "Contestant"].
    The first 4 words are ["Hello", "how", "are", "you"].
    Hence, you should return "Hello how are you".

    Example 2:

    >>> truncateSentence(s = "What is the solution to this problem", k = 4)
    >>> "What is the solution"
    Explanation:
    The words in s are ["What", "is" "the", "solution", "to", "this", "problem"].
    The first 4 words are ["What", "is", "the", "solution"].
    Hence, you should return "What is the solution".
    Example 3:

    >>> truncateSentence(s = "chopper is not a tanuki", k = 5)
    >>> "chopper is not a tanuki"
    """


Prompt:
from typing import List
def findingUsersActiveMinutes(logs: List[List[int]], k: int) -> List[int]:
    """
    You are given the logs for users' actions on LeetCode, and an integer k. The logs are represented by a 2D integer array logs where each logs[i] = [IDi, timei] indicates that the user with IDi performed an action at the minute timei.
    Multiple users can perform actions simultaneously, and a single user can perform multiple actions in the same minute.
    The user active minutes (UAM) for a given user is defined as the number of unique minutes in which the user performed an action on LeetCode. A minute can only be counted once, even if multiple actions occur during it.
    You are to calculate a 1-indexed array answer of size k such that, for each j (1 <= j <= k), answer[j] is the number of users whose UAM equals j.
    Return the array answer as described above.

    Example 1:

    >>> findingUsersActiveMinutes(logs = [[0,5],[1,2],[0,2],[0,5],[1,3]], k = 5)
    >>> [0,2,0,0,0]
    Explanation:
    The user with ID=0 performed actions at minutes 5, 2, and 5 again. Hence, they have a UAM of 2 (minute 5 is only counted once).
    The user with ID=1 performed actions at minutes 2 and 3. Hence, they have a UAM of 2.
    Since both users have a UAM of 2, answer[2] is 2, and the remaining answer[j] values are 0.

    Example 2:

    >>> findingUsersActiveMinutes(logs = [[1,1],[2,2],[2,3]], k = 4)
    >>> [1,1,0,0]
    Explanation:
    The user with ID=1 performed a single action at minute 1. Hence, they have a UAM of 1.
    The user with ID=2 performed actions at minutes 2 and 3. Hence, they have a UAM of 2.
    There is one user with a UAM of 1 and one with a UAM of 2.
    Hence, answer[1] = 1, answer[2] = 1, and the remaining values are 0.
    """


Prompt:
from typing import List
def minAbsoluteSumDiff(nums1: List[int], nums2: List[int]) -> int:
    """
    You are given two positive integer arrays nums1 and nums2, both of length n.
    The absolute sum difference of arrays nums1 and nums2 is defined as the sum of |nums1[i] - nums2[i]| for each 0 <= i < n (0-indexed).
    You can replace at most one element of nums1 with any other element in nums1 to minimize the absolute sum difference.
    Return the minimum absolute sum difference after replacing at most one element in the array nums1. Since the answer may be large, return it modulo 109 + 7.
    |x| is defined as:

    x if x >= 0, or
    -x if x < 0.

    Example 1:

    >>> minAbsoluteSumDiff(nums1 = [1,7,5], nums2 = [2,3,5])
    >>> 3
    Explanation: There are two possible optimal solutions:
    - Replace the second element with the first: [1,7,5] => [1,1,5], or
    - Replace the second element with the third: [1,7,5] => [1,5,5].
    Both will yield an absolute sum difference of |1-2| + (|1-3| or |5-3|) + |5-5| = 3.

    Example 2:

    >>> minAbsoluteSumDiff(nums1 = [2,4,6,8,10], nums2 = [2,4,6,8,10])
    >>> 0
    Explanation: nums1 is equal to nums2 so no replacement is needed. This will result in an
    absolute sum difference of 0.

    Example 3:

    >>> minAbsoluteSumDiff(nums1 = [1,10,4,4,2,7], nums2 = [9,3,5,1,7,4])
    >>> 20
    Explanation: Replace the first element with the second: [1,10,4,4,2,7] => [10,10,4,4,2,7].
    This yields an absolute sum difference of |10-9| + |10-3| + |4-5| + |4-1| + |2-7| + |7-4| = 20
    """


Prompt:
from typing import List
def countDifferentSubsequenceGCDs(nums: List[int]) -> int:
    """
    You are given an array nums that consists of positive integers.
    The GCD of a sequence of numbers is defined as the greatest integer that divides all the numbers in the sequence evenly.

    For example, the GCD of the sequence [4,6,16] is 2.

    A subsequence of an array is a sequence that can be formed by removing some elements (possibly none) of the array.

    For example, [2,5,10] is a subsequence of [1,2,1,2,4,1,5,10].

    Return the number of different GCDs among all non-empty subsequences of nums.

    Example 1:

    >>> countDifferentSubsequenceGCDs(nums = [6,10,3])
    >>> 5
    Explanation: The figure shows all the non-empty subsequences and their GCDs.
    The different GCDs are 6, 10, 3, 2, and 1.

    Example 2:

    >>> countDifferentSubsequenceGCDs(nums = [5,15,40,5,6])
    >>> 7
    """


Prompt:
from typing import List
def maximumInvitations(grid: List[List[int]]) -> int:
    """
    There are m boys and n girls in a class attending an upcoming party.
    You are given an m x n integer matrix grid, where grid[i][j] equals 0 or 1. If grid[i][j] == 1, then that means the ith boy can invite the jth girl to the party. A boy can invite at most one girl, and a girl can accept at most one invitation from a boy.
    Return the maximum possible number of accepted invitations.

    Example 1:

                   [1,0,1],
                   [0,0,1]]
    >>> maximumInvitations(grid = [[1,1,1],)
    >>> 3
    Explanation: The invitations are sent as follows:
    - The 1st boy invites the 2nd girl.
    - The 2nd boy invites the 1st girl.
    - The 3rd boy invites the 3rd girl.
    Example 2:

                   [1,0,0,0],
                   [0,0,1,0],
                   [1,1,1,0]]
    >>> maximumInvitations(grid = [[1,0,1,0],)
    >>> 3
    Explanation: The invitations are sent as follows:
    -The 1st boy invites the 3rd girl.
    -The 2nd boy invites the 1st girl.
    -The 3rd boy invites no one.
    -The 4th boy invites the 2nd girl.
    """


Prompt:
from typing import List
def arraySign(nums: List[int]) -> int:
    """
    Implement a function signFunc(x) that returns:

    1 if x is positive.
    -1 if x is negative.
    0 if x is equal to 0.

    You are given an integer array nums. Let product be the product of all values in the array nums.
    Return signFunc(product).

    Example 1:

    >>> arraySign(nums = [-1,-2,-3,-4,3,2,1])
    >>> 1
    Explanation: The product of all values in the array is 144, and signFunc(144) = 1

    Example 2:

    >>> arraySign(nums = [1,5,0,2,-3])
    >>> 0
    Explanation: The product of all values in the array is 0, and signFunc(0) = 0

    Example 3:

    >>> arraySign(nums = [-1,1,-1,1,-1])
    >>> -1
    Explanation: The product of all values in the array is -1, and signFunc(-1) = -1
    """


Prompt:
def findTheWinner(n: int, k: int) -> int:
    """
    There are n friends that are playing a game. The friends are sitting in a circle and are numbered from 1 to n in clockwise order. More formally, moving clockwise from the ith friend brings you to the (i+1)th friend for 1 <= i < n, and moving clockwise from the nth friend brings you to the 1st friend.
    The rules of the game are as follows:

    Start at the 1st friend.
    Count the next k friends in the clockwise direction including the friend you started at. The counting wraps around the circle and may count some friends more than once.
    The last friend you counted leaves the circle and loses the game.
    If there is still more than one friend in the circle, go back to step 2 starting from the friend immediately clockwise of the friend who just lost and repeat.
    Else, the last friend in the circle wins the game.

    Given the number of friends, n, and an integer k, return the winner of the game.

    Example 1:

    >>> findTheWinner(n = 5, k = 2)
    >>> 3
    Explanation: Here are the steps of the game:
    1) Start at friend 1.
    2) Count 2 friends clockwise, which are friends 1 and 2.
    3) Friend 2 leaves the circle. Next start is friend 3.
    4) Count 2 friends clockwise, which are friends 3 and 4.
    5) Friend 4 leaves the circle. Next start is friend 5.
    6) Count 2 friends clockwise, which are friends 5 and 1.
    7) Friend 1 leaves the circle. Next start is friend 3.
    8) Count 2 friends clockwise, which are friends 3 and 5.
    9) Friend 5 leaves the circle. Only friend 3 is left, so they are the winner.
    Example 2:

    >>> findTheWinner(n = 6, k = 5)
    >>> 1
    Explanation: The friends leave in this order: 5, 4, 6, 2, 3. The winner is friend 1.
    """


Prompt:
from typing import List
def minSideJumps(obstacles: List[int]) -> int:
    """
    There is a 3 lane road of length n that consists of n + 1 points labeled from 0 to n. A frog starts at point 0 in the second lane and wants to jump to point n. However, there could be obstacles along the way.
    You are given an array obstacles of length n + 1 where each obstacles[i] (ranging from 0 to 3) describes an obstacle on the lane obstacles[i] at point i. If obstacles[i] == 0, there are no obstacles at point i. There will be at most one obstacle in the 3 lanes at each point.

    For example, if obstacles[2] == 1, then there is an obstacle on lane 1 at point 2.

    The frog can only travel from point i to point i + 1 on the same lane if there is not an obstacle on the lane at point i + 1. To avoid obstacles, the frog can also perform a side jump to jump to another lane (even if they are not adjacent) at the same point if there is no obstacle on the new lane.

    For example, the frog can jump from lane 3 at point 3 to lane 1 at point 3.

    Return the minimum number of side jumps the frog needs to reach any lane at point n starting from lane 2 at point 0.
    Note: There will be no obstacles on points 0 and n.

    Example 1:

    >>> minSideJumps(obstacles = [0,1,2,3,0])
    >>> 2
    Explanation: The optimal solution is shown by the arrows above. There are 2 side jumps (red arrows).
    Note that the frog can jump over obstacles only when making side jumps (as shown at point 2).

    Example 2:

    >>> minSideJumps(obstacles = [0,1,1,3,3,0])
    >>> 0
    Explanation: There are no obstacles on lane 2. No side jumps are required.

    Example 3:

    >>> minSideJumps(obstacles = [0,2,1,0,3,0])
    >>> 2
    Explanation: The optimal solution is shown by the arrows above. There are 2 side jumps.
    """


Prompt:
from typing import List
def badSensor(sensor1: List[int], sensor2: List[int]) -> int:
    """
    An experiment is being conducted in a lab. To ensure accuracy, there are two sensors collecting data simultaneously. You are given two arrays sensor1 and sensor2, where sensor1[i] and sensor2[i] are the ith data points collected by the two sensors.
    However, this type of sensor has a chance of being defective, which causes exactly one data point to be dropped. After the data is dropped, all the data points to the right of the dropped data are shifted one place to the left, and the last data point is replaced with some random value. It is guaranteed that this random value will not be equal to the dropped value.

    For example, if the correct data is [1,2,3,4,5] and 3 is dropped, the sensor could return [1,2,4,5,7] (the last position can be any value, not just 7).

    We know that there is a defect in at most one of the sensors. Return the sensor number (1 or 2) with the defect. If there is no defect in either sensor or if it is impossible to determine the defective sensor, return -1.

    Example 1:

    >>> badSensor(sensor1 = [2,3,4,5], sensor2 = [2,1,3,4])
    >>> 1
    Explanation: Sensor 2 has the correct values.
    The second data point from sensor 2 is dropped, and the last value of sensor 1 is replaced by a 5.

    Example 2:

    >>> badSensor(sensor1 = [2,2,2,2,2], sensor2 = [2,2,2,2,5])
    >>> -1
    Explanation: It is impossible to determine which sensor has a defect.
    Dropping the last value for either sensor could produce the output for the other sensor.

    Example 3:

    >>> badSensor(sensor1 = [2,3,2,2,3,2], sensor2 = [2,3,2,3,2,7])
    >>> 2
    Explanation: Sensor 1 has the correct values.
    The fourth data point from sensor 1 is dropped, and the last value of sensor 1 is replaced by a 7.
    """


Prompt:
from typing import List
def minOperations(nums: List[int]) -> int:
    """
    You are given an integer array nums (0-indexed). In one operation, you can choose an element of the array and increment it by 1.\r
    \r
    \r
    	For example, if nums = [1,2,3], you can choose to increment nums[1] to make nums = [1,3,3].\r
    \r
    \r
    Return the minimum number of operations needed to make nums strictly increasing.\r
    \r
    An array nums is strictly increasing if nums[i] < nums[i+1] for all 0 <= i < nums.length - 1. An array of length 1 is trivially strictly increasing.\r
    \r
     \r
    Example 1:\r
    \r
    \r
    >>> minOperations(nums = [1,1,1]\r)
    >>> 3\r
    Explanation: You can do the following operations:\r
    1) Increment nums[2], so nums becomes [1,1,2].\r
    2) Increment nums[1], so nums becomes [1,2,2].\r
    3) Increment nums[2], so nums becomes [1,2,3].\r
    \r
    \r
    Example 2:\r
    \r
    \r
    >>> minOperations(nums = [1,5,2,4,1]\r)
    >>> 14\r
    \r
    \r
    Example 3:\r
    \r
    \r
    >>> minOperations(nums = [8]\r)
    >>> 0\r
    \r
    \r
     \r
    """


Prompt:
from typing import List
def countPoints(points: List[List[int]], queries: List[List[int]]) -> List[int]:
    """
    You are given an array points where points[i] = [xi, yi] is the coordinates of the ith point on a 2D plane. Multiple points can have the same coordinates.
    You are also given an array queries where queries[j] = [xj, yj, rj] describes a circle centered at (xj, yj) with a radius of rj.
    For each query queries[j], compute the number of points inside the jth circle. Points on the border of the circle are considered inside.
    Return an array answer, where answer[j] is the answer to the jth query.

    Example 1:

    >>> countPoints(points = [[1,3],[3,3],[5,3],[2,2]], queries = [[2,3,1],[4,3,1],[1,1,2]])
    >>> [3,2,2]
    Explanation: The points and circles are shown above.
    queries[0] is the green circle, queries[1] is the red circle, and queries[2] is the blue circle.

    Example 2:

    >>> countPoints(points = [[1,1],[2,2],[3,3],[4,4],[5,5]], queries = [[1,2,2],[2,2,2],[4,3,2],[4,3,3]])
    >>> [2,3,2,4]
    Explanation: The points and circles are shown above.
    queries[0] is green, queries[1] is red, queries[2] is blue, and queries[3] is purple.
    """


Prompt:
from typing import List
def getMaximumXor(nums: List[int], maximumBit: int) -> List[int]:
    """
    You are given a sorted array nums of n non-negative integers and an integer maximumBit. You want to perform the following query n times:

    Find a non-negative integer k < 2maximumBit such that nums[0] XOR nums[1] XOR ... XOR nums[nums.length-1] XOR k is maximized. k is the answer to the ith query.
    Remove the last element from the current array nums.

    Return an array answer, where answer[i] is the answer to the ith query.

    Example 1:

    >>> getMaximumXor(nums = [0,1,1,3], maximumBit = 2)
    >>> [0,3,2,3]
    Explanation: The queries are answered as follows:
    1st query: nums = [0,1,1,3], k = 0 since 0 XOR 1 XOR 1 XOR 3 XOR 0 = 3.
    2nd query: nums = [0,1,1], k = 3 since 0 XOR 1 XOR 1 XOR 3 = 3.
    3rd query: nums = [0,1], k = 2 since 0 XOR 1 XOR 2 = 3.
    4th query: nums = [0], k = 3 since 0 XOR 3 = 3.

    Example 2:

    >>> getMaximumXor(nums = [2,3,4,7], maximumBit = 3)
    >>> [5,2,6,5]
    Explanation: The queries are answered as follows:
    1st query: nums = [2,3,4,7], k = 5 since 2 XOR 3 XOR 4 XOR 7 XOR 5 = 7.
    2nd query: nums = [2,3,4], k = 2 since 2 XOR 3 XOR 4 XOR 2 = 7.
    3rd query: nums = [2,3], k = 6 since 2 XOR 3 XOR 6 = 7.
    4th query: nums = [2], k = 5 since 2 XOR 5 = 7.

    Example 3:

    >>> getMaximumXor(nums = [0,1,2,2,5,7], maximumBit = 3)
    >>> [4,3,6,4,6,7]
    """


Prompt:
def checkIfPangram(sentence: str) -> bool:
    """
    A pangram is a sentence where every letter of the English alphabet appears at least once.
    Given a string sentence containing only lowercase English letters, return true if sentence is a pangram, or false otherwise.

    Example 1:

    >>> checkIfPangram(sentence = "thequickbrownfoxjumpsoverthelazydog")
    >>> true
    Explanation: sentence contains at least one of every letter of the English alphabet.

    Example 2:

    >>> checkIfPangram(sentence = "leetcode")
    >>> false
    """


Prompt:
from typing import List
def maxIceCream(costs: List[int], coins: int) -> int:
    """
    It is a sweltering summer day, and a boy wants to buy some ice cream bars.
    At the store, there are n ice cream bars. You are given an array costs of length n, where costs[i] is the price of the ith ice cream bar in coins. The boy initially has coins coins to spend, and he wants to buy as many ice cream bars as possible.
    Note: The boy can buy the ice cream bars in any order.
    Return the maximum number of ice cream bars the boy can buy with coins coins.
    You must solve the problem by counting sort.

    Example 1:

    >>> maxIceCream(costs = [1,3,2,4,1], coins = 7)
    >>> 4
    Explanation: The boy can buy ice cream bars at indices 0,1,2,4 for a total price of 1 + 3 + 2 + 1 = 7.

    Example 2:

    >>> maxIceCream(costs = [10,6,8,7,7,8], coins = 5)
    >>> 0
    Explanation: The boy cannot afford any of the ice cream bars.

    Example 3:

    >>> maxIceCream(costs = [1,6,3,1,2,5], coins = 20)
    >>> 6
    Explanation: The boy can buy all the ice cream bars for a total price of 1 + 6 + 3 + 1 + 2 + 5 = 18.
    """


Prompt:
from typing import List
def getOrder(tasks: List[List[int]]) -> List[int]:
    """
    You are given n tasks labeled from 0 to n - 1 represented by a 2D integer array tasks, where tasks[i] = [enqueueTimei, processingTimei] means that the ith task will be available to process at enqueueTimei and will take processingTimei to finish processing.
    You have a single-threaded CPU that can process at most one task at a time and will act in the following way:

    If the CPU is idle and there are no available tasks to process, the CPU remains idle.
    If the CPU is idle and there are available tasks, the CPU will choose the one with the shortest processing time. If multiple tasks have the same shortest processing time, it will choose the task with the smallest index.
    Once a task is started, the CPU will process the entire task without stopping.
    The CPU can finish a task then start a new one instantly.

    Return the order in which the CPU will process the tasks.

    Example 1:

    >>> getOrder(tasks = [[1,2],[2,4],[3,2],[4,1]])
    >>> [0,2,3,1]
    Explanation: The events go as follows:
    - At time = 1, task 0 is available to process. Available tasks = {0}.
    - Also at time = 1, the idle CPU starts processing task 0. Available tasks = {}.
    - At time = 2, task 1 is available to process. Available tasks = {1}.
    - At time = 3, task 2 is available to process. Available tasks = {1, 2}.
    - Also at time = 3, the CPU finishes task 0 and starts processing task 2 as it is the shortest. Available tasks = {1}.
    - At time = 4, task 3 is available to process. Available tasks = {1, 3}.
    - At time = 5, the CPU finishes task 2 and starts processing task 3 as it is the shortest. Available tasks = {1}.
    - At time = 6, the CPU finishes task 3 and starts processing task 1. Available tasks = {}.
    - At time = 10, the CPU finishes task 1 and becomes idle.

    Example 2:

    >>> getOrder(tasks = [[7,10],[7,12],[7,5],[7,4],[7,2]])
    >>> [4,3,2,0,1]
    Explanation: The events go as follows:
    - At time = 7, all the tasks become available. Available tasks = {0,1,2,3,4}.
    - Also at time = 7, the idle CPU starts processing task 4. Available tasks = {0,1,2,3}.
    - At time = 9, the CPU finishes task 4 and starts processing task 3. Available tasks = {0,1,2}.
    - At time = 13, the CPU finishes task 3 and starts processing task 2. Available tasks = {0,1}.
    - At time = 18, the CPU finishes task 2 and starts processing task 0. Available tasks = {1}.
    - At time = 28, the CPU finishes task 0 and starts processing task 1. Available tasks = {}.
    - At time = 40, the CPU finishes task 1 and becomes idle.
    """


Prompt:
from typing import List
def getXORSum(arr1: List[int], arr2: List[int]) -> int:
    """
    The XOR sum of a list is the bitwise XOR of all its elements. If the list only contains one element, then its XOR sum will be equal to this element.

    For example, the XOR sum of [1,2,3,4] is equal to 1 XOR 2 XOR 3 XOR 4 = 4, and the XOR sum of [3] is equal to 3.

    You are given two 0-indexed arrays arr1 and arr2 that consist only of non-negative integers.
    Consider the list containing the result of arr1[i] AND arr2[j] (bitwise AND) for every (i, j) pair where 0 <= i < arr1.length and 0 <= j < arr2.length.
    Return the XOR sum of the aforementioned list.

    Example 1:

    >>> getXORSum(arr1 = [1,2,3], arr2 = [6,5])
    >>> 0
    Explanation: The list = [1 AND 6, 1 AND 5, 2 AND 6, 2 AND 5, 3 AND 6, 3 AND 5] = [0,1,2,0,2,1].
    The XOR sum = 0 XOR 1 XOR 2 XOR 0 XOR 2 XOR 1 = 0.

    Example 2:

    >>> getXORSum(arr1 = [12], arr2 = [4])
    >>> 4
    Explanation: The list = [12 AND 4] = [4]. The XOR sum = 4.
    """


Prompt:
from typing import Optional
class ListNode:
    def __init__(val=0, next=None):
        self.val = val
        self.next = next
def deleteDuplicatesUnsorted(head: Optional[ListNode]) -> Optional[ListNode]:
"""
Given the head of a linked list, find all the values that appear more than once in the list and delete the nodes that have any of those values.\r
\r
Return the linked list after the deletions.\r
\r
 \r
Example 1:\r
\r
\r
>>> deleteDuplicatesUnsorted(head = [1,2,3,2]\r)
>>> [1,3]\r
Explanation: 2 appears twice in the linked list, so all 2's should be deleted. After deleting all 2's, we are left with [1,3].\r
\r
\r
Example 2:\r
\r
\r
>>> deleteDuplicatesUnsorted(head = [2,1,1,2]\r)
>>> []\r
Explanation: 2 and 1 both appear twice. All the elements should be deleted.\r
\r
\r
Example 3:\r
\r
\r
>>> deleteDuplicatesUnsorted(head = [3,2,2,1,3,2,4]\r)
>>> [1,4]\r
Explanation: 3 appears twice and 2 appears three times. After deleting all 3's and 2's, we are left with [1,4].\r
\r
\r
 \r
"""


Prompt:
def sumBase(n: int, k: int) -> int:
    """
    Given an integer n (in base 10) and a base k, return the sum of the digits of n after converting n from base 10 to base k.
    After converting, each digit should be interpreted as a base 10 number, and the sum should be returned in base 10.

    Example 1:

    >>> sumBase(n = 34, k = 6)
    >>> 9
    Explanation: 34 (base 10) expressed in base 6 is 54. 5 + 4 = 9.

    Example 2:

    >>> sumBase(n = 10, k = 10)
    >>> 1
    Explanation: n is already in base 10. 1 + 0 = 1.
    """


Prompt:
from typing import List
def maxFrequency(nums: List[int], k: int) -> int:
    """
    The frequency of an element is the number of times it occurs in an array.
    You are given an integer array nums and an integer k. In one operation, you can choose an index of nums and increment the element at that index by 1.
    Return the maximum possible frequency of an element after performing at most k operations.

    Example 1:

    >>> maxFrequency(nums = [1,2,4], k = 5)
    >>> 3
    Explanation: Increment the first element three times and the second element two times to make nums = [4,4,4].
    4 has a frequency of 3.
    Example 2:

    >>> maxFrequency(nums = [1,4,8,13], k = 5)
    >>> 2
    Explanation: There are multiple optimal solutions:
    - Increment the first element three times to make nums = [4,4,8,13]. 4 has a frequency of 2.
    - Increment the second element four times to make nums = [1,8,8,13]. 8 has a frequency of 2.
    - Increment the third element five times to make nums = [1,4,13,13]. 13 has a frequency of 2.

    Example 3:

    >>> maxFrequency(nums = [3,9,6], k = 2)
    >>> 1
    """


Prompt:
def longestBeautifulSubstring(word: str) -> int:
    """
    A string is considered beautiful if it satisfies the following conditions:

    Each of the 5 English vowels ('a', 'e', 'i', 'o', 'u') must appear at least once in it.
    The letters must be sorted in alphabetical order (i.e. all 'a's before 'e's, all 'e's before 'i's, etc.).

    For example, strings "aeiou" and "aaaaaaeiiiioou" are considered beautiful, but "uaeio", "aeoiu", and "aaaeeeooo" are not beautiful.
    Given a string word consisting of English vowels, return the length of the longest beautiful substring of word. If no such substring exists, return 0.
    A substring is a contiguous sequence of characters in a string.

    Example 1:

    >>> longestBeautifulSubstring(word = "aeiaaioaaaaeiiiiouuuooaauuaeiu")
    >>> 13
    Explanation: The longest beautiful substring in word is "aaaaeiiiiouuu" of length 13.
    Example 2:

    >>> longestBeautifulSubstring(word = "aeeeiiiioooauuuaeiou")
    >>> 5
    Explanation: The longest beautiful substring in word is "aeiou" of length 5.

    Example 3:

    >>> longestBeautifulSubstring(word = "a")
    >>> 0
    Explanation: There is no beautiful substring, so return 0.
    """


Prompt:
from typing import List
def maxBuilding(n: int, restrictions: List[List[int]]) -> int:
    """
    You want to build n new buildings in a city. The new buildings will be built in a line and are labeled from 1 to n.
    However, there are city restrictions on the heights of the new buildings:

    The height of each building must be a non-negative integer.
    The height of the first building must be 0.
    The height difference between any two adjacent buildings cannot exceed 1.

    Additionally, there are city restrictions on the maximum height of specific buildings. These restrictions are given as a 2D integer array restrictions where restrictions[i] = [idi, maxHeighti] indicates that building idi must have a height less than or equal to maxHeighti.
    It is guaranteed that each building will appear at most once in restrictions, and building 1 will not be in restrictions.
    Return the maximum possible height of the tallest building.

    Example 1:

    >>> maxBuilding(n = 5, restrictions = [[2,1],[4,1]])
    >>> 2
    Explanation: The green area in the image indicates the maximum allowed height for each building.
    We can build the buildings with heights [0,1,2,1,2], and the tallest building has a height of 2.
    Example 2:

    >>> maxBuilding(n = 6, restrictions = [])
    >>> 5
    Explanation: The green area in the image indicates the maximum allowed height for each building.
    We can build the buildings with heights [0,1,2,3,4,5], and the tallest building has a height of 5.

    Example 3:

    >>> maxBuilding(n = 10, restrictions = [[5,3],[2,5],[7,4],[10,3]])
    >>> 5
    Explanation: The green area in the image indicates the maximum allowed height for each building.
    We can build the buildings with heights [0,1,2,3,3,4,4,5,4,3], and the tallest building has a height of 5.
    """


Prompt:
def nextPalindrome(num: str) -> str:
    """
    You are given a numeric string num, representing a very large palindrome.
    Return the smallest palindrome larger than num that can be created by rearranging its digits. If no such palindrome exists, return an empty string "".
    A palindrome is a number that reads the same backward as forward.

    Example 1:

    >>> nextPalindrome(num = "1221")
    >>> "2112"
    Explanation: The next palindrome larger than "1221" is "2112".

    Example 2:

    >>> nextPalindrome(num = "32123")
    >>> ""
    Explanation: No palindromes larger than "32123" can be made by rearranging the digits.

    Example 3:

    >>> nextPalindrome(num = "45544554")
    >>> "54455445"
    Explanation: The next palindrome larger than "45544554" is "54455445".
    """


Prompt:
def replaceDigits(s: str) -> str:
    """
    You are given a 0-indexed string s that has lowercase English letters in its even indices and digits in its odd indices.
    You must perform an operation shift(c, x), where c is a character and x is a digit, that returns the xth character after c.

    For example, shift('a', 5) = 'f' and shift('x', 0) = 'x'.

    For every odd index i, you want to replace the digit s[i] with the result of the shift(s[i-1], s[i]) operation.
    Return s after replacing all digits. It is guaranteed that shift(s[i-1], s[i]) will never exceed 'z'.
    Note that shift(c, x) is not a preloaded function, but an operation to be implemented as part of the solution.

    Example 1:

    >>> replaceDigits(s = "a1c1e1")
    >>> "abcdef"
    Explanation: The digits are replaced as follows:
    - s[1] -> shift('a',1) = 'b'
    - s[3] -> shift('c',1) = 'd'
    - s[5] -> shift('e',1) = 'f'
    Example 2:

    >>> replaceDigits(s = "a1b2c3d4e")
    >>> "abbdcfdhe"
    Explanation: The digits are replaced as follows:
    - s[1] -> shift('a',1) = 'b'
    - s[3] -> shift('b',2) = 'd'
    - s[5] -> shift('c',3) = 'f'
    - s[7] -> shift('d',4) = 'h'
    """


Prompt:
from typing import List
def maximumElementAfterDecrementingAndRearranging(arr: List[int]) -> int:
    """
    You are given an array of positive integers arr. Perform some operations (possibly none) on arr so that it satisfies these conditions:

    The value of the first element in arr must be 1.
    The absolute difference between any 2 adjacent elements must be less than or equal to 1. In other words, abs(arr[i] - arr[i - 1]) <= 1 for each i where 1 <= i < arr.length (0-indexed). abs(x) is the absolute value of x.

    There are 2 types of operations that you can perform any number of times:

    Decrease the value of any element of arr to a smaller positive integer.
    Rearrange the elements of arr to be in any order.

    Return the maximum possible value of an element in arr after performing the operations to satisfy the conditions.

    Example 1:

    >>> maximumElementAfterDecrementingAndRearranging(arr = [2,2,1,2,1])
    >>> 2
    Explanation:
    We can satisfy the conditions by rearranging arr so it becomes [1,2,2,2,1].
    The largest element in arr is 2.

    Example 2:

    >>> maximumElementAfterDecrementingAndRearranging(arr = [100,1,1000])
    >>> 3
    Explanation:
    One possible way to satisfy the conditions is by doing the following:
    1. Rearrange arr so it becomes [1,100,1000].
    2. Decrease the value of the second element to 2.
    3. Decrease the value of the third element to 3.
    Now arr = [1,2,3], which satisfies the conditions.
    The largest element in arr is 3.

    Example 3:

    >>> maximumElementAfterDecrementingAndRearranging(arr = [1,2,3,4,5])
    >>> 5
    Explanation: The array already satisfies the conditions, and the largest element is 5.
    """


Prompt:
from typing import List
def closestRoom(rooms: List[List[int]], queries: List[List[int]]) -> List[int]:
    """
    There is a hotel with n rooms. The rooms are represented by a 2D integer array rooms where rooms[i] = [roomIdi, sizei] denotes that there is a room with room number roomIdi and size equal to sizei. Each roomIdi is guaranteed to be unique.
    You are also given k queries in a 2D array queries where queries[j] = [preferredj, minSizej]. The answer to the jth query is the room number id of a room such that:

    The room has a size of at least minSizej, and
    abs(id - preferredj) is minimized, where abs(x) is the absolute value of x.

    If there is a tie in the absolute difference, then use the room with the smallest such id. If there is no such room, the answer is -1.
    Return an array answer of length k where answer[j] contains the answer to the jth query.

    Example 1:

    >>> closestRoom(rooms = [[2,2],[1,2],[3,2]], queries = [[3,1],[3,3],[5,2]])
    >>> [3,-1,3]
    Explanation: The answers to the queries are as follows:
    Query = [3,1]: Room number 3 is the closest as abs(3 - 3) = 0, and its size of 2 is at least 1. The answer is 3.
    Query = [3,3]: There are no rooms with a size of at least 3, so the answer is -1.
    Query = [5,2]: Room number 3 is the closest as abs(3 - 5) = 2, and its size of 2 is at least 2. The answer is 3.
    Example 2:

    >>> closestRoom(rooms = [[1,4],[2,3],[3,5],[4,1],[5,2]], queries = [[2,3],[2,4],[2,5]])
    >>> [2,1,3]
    Explanation: The answers to the queries are as follows:
    Query = [2,3]: Room number 2 is the closest as abs(2 - 2) = 0, and its size of 3 is at least 3. The answer is 2.
    Query = [2,4]: Room numbers 1 and 3 both have sizes of at least 4. The answer is 1 since it is smaller.
    Query = [2,5]: Room number 3 is the only room with a size of at least 5. The answer is 3.
    """


Prompt:
from typing import List
def getMinDistance(nums: List[int], target: int, start: int) -> int:
    """
    Given an integer array nums (0-indexed) and two integers target and start, find an index i such that nums[i] == target and abs(i - start) is minimized. Note that abs(x) is the absolute value of x.
    Return abs(i - start).
    It is guaranteed that target exists in nums.

    Example 1:

    >>> getMinDistance(nums = [1,2,3,4,5], target = 5, start = 3)
    >>> 1
    Explanation: nums[4] = 5 is the only value equal to target, so the answer is abs(4 - 3) = 1.

    Example 2:

    >>> getMinDistance(nums = [1], target = 1, start = 0)
    >>> 0
    Explanation: nums[0] = 1 is the only value equal to target, so the answer is abs(0 - 0) = 0.

    Example 3:

    >>> getMinDistance(nums = [1,1,1,1,1,1,1,1,1,1], target = 1, start = 0)
    >>> 0
    Explanation: Every value of nums is 1, but nums[0] minimizes abs(i - start), which is abs(0 - 0) = 0.
    """


Prompt:
def splitString(s: str) -> bool:
    """
    You are given a string s that consists of only digits.
    Check if we can split s into two or more non-empty substrings such that the numerical values of the substrings are in descending order and the difference between numerical values of every two adjacent substrings is equal to 1.

    For example, the string s = "0090089" can be split into ["0090", "089"] with numerical values [90,89]. The values are in descending order and adjacent values differ by 1, so this way is valid.
    Another example, the string s = "001" can be split into ["0", "01"], ["00", "1"], or ["0", "0", "1"]. However all the ways are invalid because they have numerical values [0,1], [0,1], and [0,0,1] respectively, all of which are not in descending order.

    Return true if it is possible to split s as described above, or false otherwise.
    A substring is a contiguous sequence of characters in a string.

    Example 1:

    >>> splitString(s = "1234")
    >>> false
    Explanation: There is no valid way to split s.

    Example 2:

    >>> splitString(s = "050043")
    >>> true
    Explanation: s can be split into ["05", "004", "3"] with numerical values [5,4,3].
    The values are in descending order with adjacent values differing by 1.

    Example 3:

    >>> splitString(s = "9080701")
    >>> false
    Explanation: There is no valid way to split s.
    """


Prompt:
def getMinSwaps(num: str, k: int) -> int:
    """
    You are given a string num, representing a large integer, and an integer k.
    We call some integer wonderful if it is a permutation of the digits in num and is greater in value than num. There can be many wonderful integers. However, we only care about the smallest-valued ones.

    For example, when num = "5489355142":

    The 1st smallest wonderful integer is "5489355214".
    The 2nd smallest wonderful integer is "5489355241".
    The 3rd smallest wonderful integer is "5489355412".
    The 4th smallest wonderful integer is "5489355421".

    Return the minimum number of adjacent digit swaps that needs to be applied to num to reach the kth smallest wonderful integer.
    The tests are generated in such a way that kth smallest wonderful integer exists.

    Example 1:

    >>> getMinSwaps(num = "5489355142", k = 4)
    >>> 2
    Explanation: The 4th smallest wonderful number is "5489355421". To get this number:
    - Swap index 7 with index 8: "5489355142" -> "5489355412"
    - Swap index 8 with index 9: "5489355412" -> "5489355421"

    Example 2:

    >>> getMinSwaps(num = "11112", k = 4)
    >>> 4
    Explanation: The 4th smallest wonderful number is "21111". To get this number:
    - Swap index 3 with index 4: "11112" -> "11121"
    - Swap index 2 with index 3: "11121" -> "11211"
    - Swap index 1 with index 2: "11211" -> "12111"
    - Swap index 0 with index 1: "12111" -> "21111"

    Example 3:

    >>> getMinSwaps(num = "00123", k = 1)
    >>> 1
    Explanation: The 1st smallest wonderful number is "00132". To get this number:
    - Swap index 3 with index 4: "00123" -> "00132"
    """


Prompt:
from typing import List
def minInterval(intervals: List[List[int]], queries: List[int]) -> List[int]:
    """
    You are given a 2D integer array intervals, where intervals[i] = [lefti, righti] describes the ith interval starting at lefti and ending at righti (inclusive). The size of an interval is defined as the number of integers it contains, or more formally righti - lefti + 1.
    You are also given an integer array queries. The answer to the jth query is the size of the smallest interval i such that lefti <= queries[j] <= righti. If no such interval exists, the answer is -1.
    Return an array containing the answers to the queries.

    Example 1:

    >>> minInterval(intervals = [[1,4],[2,4],[3,6],[4,4]], queries = [2,3,4,5])
    >>> [3,3,1,4]
    Explanation: The queries are processed as follows:
    - Query = 2: The interval [2,4] is the smallest interval containing 2. The answer is 4 - 2 + 1 = 3.
    - Query = 3: The interval [2,4] is the smallest interval containing 3. The answer is 4 - 2 + 1 = 3.
    - Query = 4: The interval [4,4] is the smallest interval containing 4. The answer is 4 - 4 + 1 = 1.
    - Query = 5: The interval [3,6] is the smallest interval containing 5. The answer is 6 - 3 + 1 = 4.

    Example 2:

    >>> minInterval(intervals = [[2,3],[2,5],[1,8],[20,25]], queries = [2,19,5,22])
    >>> [2,-1,4,6]
    Explanation: The queries are processed as follows:
    - Query = 2: The interval [2,3] is the smallest interval containing 2. The answer is 3 - 2 + 1 = 2.
    - Query = 19: None of the intervals contain 19. The answer is -1.
    - Query = 5: The interval [2,5] is the smallest interval containing 5. The answer is 5 - 2 + 1 = 4.
    - Query = 22: The interval [20,25] is the smallest interval containing 22. The answer is 25 - 20 + 1 = 6.
    """


Prompt:
from typing import List
def distinctNumbers(nums: List[int], k: int) -> List[int]:
    """
    You are given an integer array nums of length n and an integer k. Your task is to find the number of distinct elements in every subarray of size k within nums.
    Return an array ans such that ans[i] is the count of distinct elements in nums[i..(i + k - 1)] for each index 0 <= i < n - k.

    Example 1:

    >>> distinctNumbers(nums = [1,2,3,2,2,1,3], k = 3)
    >>> [3,2,2,2,3]
    Explanation: The number of distinct elements in each subarray goes as follows:
    - nums[0..2] = [1,2,3] so ans[0] = 3
    - nums[1..3] = [2,3,2] so ans[1] = 2
    - nums[2..4] = [3,2,2] so ans[2] = 2
    - nums[3..5] = [2,2,1] so ans[3] = 2
    - nums[4..6] = [2,1,3] so ans[4] = 3

    Example 2:

    >>> distinctNumbers(nums = [1,1,1,1,2,3,4], k = 4)
    >>> [1,2,3,4]
    Explanation: The number of distinct elements in each subarray goes as follows:
    - nums[0..3] = [1,1,1,1] so ans[0] = 1
    - nums[1..4] = [1,1,1,2] so ans[1] = 2
    - nums[2..5] = [1,1,2,3] so ans[2] = 3
    - nums[3..6] = [1,2,3,4] so ans[3] = 4
    """


Prompt:
from typing import List
def maximumPopulation(logs: List[List[int]]) -> int:
    """
    You are given a 2D integer array logs where each logs[i] = [birthi, deathi] indicates the birth and death years of the ith person.
    The population of some year x is the number of people alive during that year. The ith person is counted in year x's population if x is in the inclusive range [birthi, deathi - 1]. Note that the person is not counted in the year that they die.
    Return the earliest year with the maximum population.

    Example 1:

    >>> maximumPopulation(logs = [[1993,1999],[2000,2010]])
    >>> 1993
    Explanation: The maximum population is 1, and 1993 is the earliest year with this population.

    Example 2:

    >>> maximumPopulation(logs = [[1950,1961],[1960,1971],[1970,1981]])
    >>> 1960
    Explanation:
    The maximum population is 2, and it had happened in years 1960 and 1970.
    The earlier year between them is 1960.
    """


Prompt:
from typing import List
def maxDistance(nums1: List[int], nums2: List[int]) -> int:
    """
    You are given two non-increasing 0-indexed integer arrays nums1 and nums2.
    A pair of indices (i, j), where 0 <= i < nums1.length and 0 <= j < nums2.length, is valid if both i <= j and nums1[i] <= nums2[j]. The distance of the pair is j - i.
    Return the maximum distance of any valid pair (i, j). If there are no valid pairs, return 0.
    An array arr is non-increasing if arr[i-1] >= arr[i] for every 1 <= i < arr.length.

    Example 1:

    >>> maxDistance(nums1 = [55,30,5,4,2], nums2 = [100,20,10,10,5])
    >>> 2
    Explanation: The valid pairs are (0,0), (2,2), (2,3), (2,4), (3,3), (3,4), and (4,4).
    The maximum distance is 2 with pair (2,4).

    Example 2:

    >>> maxDistance(nums1 = [2,2,2], nums2 = [10,10,1])
    >>> 1
    Explanation: The valid pairs are (0,0), (0,1), and (1,1).
    The maximum distance is 1 with pair (0,1).

    Example 3:

    >>> maxDistance(nums1 = [30,29,19,5], nums2 = [25,25,25,25,25])
    >>> 2
    Explanation: The valid pairs are (2,2), (2,3), (2,4), (3,3), and (3,4).
    The maximum distance is 2 with pair (2,4).
    """


Prompt:
from typing import List
def maxSumMinProduct(nums: List[int]) -> int:
    """
    The min-product of an array is equal to the minimum value in the array multiplied by the array's sum.

    For example, the array [3,2,5] (minimum value is 2) has a min-product of 2 * (3+2+5) = 2 * 10 = 20.

    Given an array of integers nums, return the maximum min-product of any non-empty subarray of nums. Since the answer may be large, return it modulo 109 + 7.
    Note that the min-product should be maximized before performing the modulo operation. Testcases are generated such that the maximum min-product without modulo will fit in a 64-bit signed integer.
    A subarray is a contiguous part of an array.

    Example 1:

    >>> maxSumMinProduct(nums = [1,2,3,2])
    >>> 14
    Explanation: The maximum min-product is achieved with the subarray [2,3,2] (minimum value is 2).
    2 * (2+3+2) = 2 * 7 = 14.

    Example 2:

    >>> maxSumMinProduct(nums = [2,3,3,1,2])
    >>> 18
    Explanation: The maximum min-product is achieved with the subarray [3,3] (minimum value is 3).
    3 * (3+3) = 3 * 6 = 18.

    Example 3:

    >>> maxSumMinProduct(nums = [3,1,5,6,4,2])
    >>> 60
    Explanation: The maximum min-product is achieved with the subarray [5,6,4] (minimum value is 4).
    4 * (5+6+4) = 4 * 15 = 60.
    """


Prompt:
from typing import List
def largestPathValue(colors: str, edges: List[List[int]]) -> int:
    """
    There is a directed graph of n colored nodes and m edges. The nodes are numbered from 0 to n - 1.\r
    \r
    You are given a string colors where colors[i] is a lowercase English letter representing the color of the ith node in this graph (0-indexed). You are also given a 2D array edges where edges[j] = [aj, bj] indicates that there is a directed edge from node aj to node bj.\r
    \r
    A valid path in the graph is a sequence of nodes x1 -> x2 -> x3 -> ... -> xk such that there is a directed edge from xi to xi+1 for every 1 <= i < k. The color value of the path is the number of nodes that are colored the most frequently occurring color along that path.\r
    \r
    Return the largest color value of any valid path in the given graph, or -1 if the graph contains a cycle.\r
    \r
     \r
    Example 1:\r
    \r
    \r
    \r
    \r
    >>> largestPathValue(colors = "abaca", edges = [[0,1],[0,2],[2,3],[3,4]]\r)
    >>> 3\r
    Explanation: The path 0 -> 2 -> 3 -> 4 contains 3 nodes that are colored "a" (red in the above image).\r
    \r
    \r
    Example 2:\r
    \r
    \r
    \r
    \r
    >>> largestPathValue(colors = "a", edges = [[0,0]]\r)
    >>> -1\r
    Explanation: There is a cycle from 0 to 0.\r
    \r
    \r
     \r
    """


Prompt:
from typing import List
def longestWord(words: List[str]) -> str:
    """
    Given an array of strings words, find the longest string in words such that every prefix of it is also in words.

    For example, let words = ["a", "app", "ap"]. The string "app" has prefixes "ap" and "a", all of which are in words.

    Return the string described above. If there is more than one string with the same length, return the lexicographically smallest one, and if no string exists, return "".

    Example 1:

    >>> longestWord(words = ["k","ki","kir","kira", "kiran"])
    >>> "kiran"
    Explanation: "kiran" has prefixes "kira", "kir", "ki", and "k", and all of them appear in words.

    Example 2:

    >>> longestWord(words = ["a", "banana", "app", "appl", "ap", "apply", "apple"])
    >>> "apple"
    Explanation: Both "apple" and "apply" have all their prefixes in words.
    However, "apple" is lexicographically smaller, so we return that.

    Example 3:

    >>> longestWord(words = ["abc", "bc", "ab", "qwe"])
    >>> ""
    """


Prompt:
def sortSentence(s: str) -> str:
    """
    A sentence is a list of words that are separated by a single space with no leading or trailing spaces. Each word consists of lowercase and uppercase English letters.
    A sentence can be shuffled by appending the 1-indexed word position to each word then rearranging the words in the sentence.

    For example, the sentence "This is a sentence" can be shuffled as "sentence4 a3 is2 This1" or "is2 sentence4 This1 a3".

    Given a shuffled sentence s containing no more than 9 words, reconstruct and return the original sentence.

    Example 1:

    >>> sortSentence(s = "is2 sentence4 This1 a3")
    >>> "This is a sentence"
    Explanation: Sort the words in s to their original positions "This1 is2 a3 sentence4", then remove the numbers.

    Example 2:

    >>> sortSentence(s = "Myself2 Me1 I4 and3")
    >>> "Me Myself and I"
    Explanation: Sort the words in s to their original positions "Me1 Myself2 and3 I4", then remove the numbers.
    """


Prompt:
from typing import List
def memLeak(memory1: int, memory2: int) -> List[int]:
    """
    You are given two integers memory1 and memory2 representing the available memory in bits on two memory sticks. There is currently a faulty program running that consumes an increasing amount of memory every second.
    At the ith second (starting from 1), i bits of memory are allocated to the stick with more available memory (or from the first memory stick if both have the same available memory). If neither stick has at least i bits of available memory, the program crashes.
    Return an array containing [crashTime, memory1crash, memory2crash], where crashTime is the time (in seconds) when the program crashed and memory1crash and memory2crash are the available bits of memory in the first and second sticks respectively.

    Example 1:

    >>> memLeak(memory1 = 2, memory2 = 2)
    >>> [3,1,0]
    Explanation: The memory is allocated as follows:
    - At the 1st second, 1 bit of memory is allocated to stick 1. The first stick now has 1 bit of available memory.
    - At the 2nd second, 2 bits of memory are allocated to stick 2. The second stick now has 0 bits of available memory.
    - At the 3rd second, the program crashes. The sticks have 1 and 0 bits available respectively.

    Example 2:

    >>> memLeak(memory1 = 8, memory2 = 11)
    >>> [6,0,4]
    Explanation: The memory is allocated as follows:
    - At the 1st second, 1 bit of memory is allocated to stick 2. The second stick now has 10 bit of available memory.
    - At the 2nd second, 2 bits of memory are allocated to stick 2. The second stick now has 8 bits of available memory.
    - At the 3rd second, 3 bits of memory are allocated to stick 1. The first stick now has 5 bits of available memory.
    - At the 4th second, 4 bits of memory are allocated to stick 2. The second stick now has 4 bits of available memory.
    - At the 5th second, 5 bits of memory are allocated to stick 1. The first stick now has 0 bits of available memory.
    - At the 6th second, the program crashes. The sticks have 0 and 4 bits available respectively.
    """


Prompt:
from typing import List
def rotateTheBox(boxGrid: List[List[str]]) -> List[List[str]]:
    """
    You are given an m x n matrix of characters boxGrid representing a side-view of a box. Each cell of the box is one of the following:

    A stone '#'
    A stationary obstacle '*'
    Empty '.'

    The box is rotated 90 degrees clockwise, causing some of the stones to fall due to gravity. Each stone falls down until it lands on an obstacle, another stone, or the bottom of the box. Gravity does not affect the obstacles' positions, and the inertia from the box's rotation does not affect the stones' horizontal positions.
    It is guaranteed that each stone in boxGrid rests on an obstacle, another stone, or the bottom of the box.
    Return an n x m matrix representing the box after the rotation described above.

    Example 1:

    >>> rotateTheBox(boxGrid = [["#",".","#"]])
    >>> [["."],
             ["#"],
             ["#"]]

    Example 2:

                  ["#","#","*","."]]
    >>> rotateTheBox(boxGrid = [["#",".","*","."],)
    >>> [["#","."],
             ["#","#"],
             ["*","*"],
             [".","."]]

    Example 3:

                  ["#","#","#","*",".","."],
                  ["#","#","#",".","#","."]]
    >>> rotateTheBox(boxGrid = [["#","#","*",".","*","."],)
    >>> [[".","#","#"],
             [".","#","#"],
             ["#","#","*"],
             ["#","*","."],
             ["#",".","*"],
             ["#",".","."]]
    """


Prompt:
from typing import List
def sumOfFlooredPairs(nums: List[int]) -> int:
    """
    Given an integer array nums, return the sum of floor(nums[i] / nums[j]) for all pairs of indices 0 <= i, j < nums.length in the array. Since the answer may be too large, return it modulo 109 + 7.
    The floor() function returns the integer part of the division.

    Example 1:

    >>> sumOfFlooredPairs(nums = [2,5,9])
    >>> 10
    Explanation:
    floor(2 / 5) = floor(2 / 9) = floor(5 / 9) = 0
    floor(2 / 2) = floor(5 / 5) = floor(9 / 9) = 1
    floor(5 / 2) = 2
    floor(9 / 2) = 4
    floor(9 / 5) = 1
    We calculate the floor of the division for every pair of indices in the array then sum them up.

    Example 2:

    >>> sumOfFlooredPairs(nums = [7,7,7,7,7,7,7])
    >>> 49
    """


Prompt:
from typing import List
def subsetXORSum(nums: List[int]) -> int:
    """
    The XOR total of an array is defined as the bitwise XOR of all its elements, or 0 if the array is empty.

    For example, the XOR total of the array [2,5,6] is 2 XOR 5 XOR 6 = 1.

    Given an array nums, return the sum of all XOR totals for every subset of nums.
    Note: Subsets with the same elements should be counted multiple times.
    An array a is a subset of an array b if a can be obtained from b by deleting some (possibly zero) elements of b.

    Example 1:

    >>> subsetXORSum(nums = [1,3])
    >>> 6
    Explanation: The 4 subsets of [1,3] are:
    - The empty subset has an XOR total of 0.
    - [1] has an XOR total of 1.
    - [3] has an XOR total of 3.
    - [1,3] has an XOR total of 1 XOR 3 = 2.
    0 + 1 + 3 + 2 = 6

    Example 2:

    >>> subsetXORSum(nums = [5,1,6])
    >>> 28
    Explanation: The 8 subsets of [5,1,6] are:
    - The empty subset has an XOR total of 0.
    - [5] has an XOR total of 5.
    - [1] has an XOR total of 1.
    - [6] has an XOR total of 6.
    - [5,1] has an XOR total of 5 XOR 1 = 4.
    - [5,6] has an XOR total of 5 XOR 6 = 3.
    - [1,6] has an XOR total of 1 XOR 6 = 7.
    - [5,1,6] has an XOR total of 5 XOR 1 XOR 6 = 2.
    0 + 5 + 1 + 6 + 4 + 3 + 7 + 2 = 28

    Example 3:

    >>> subsetXORSum(nums = [3,4,5,6,7,8])
    >>> 480
    Explanation: The sum of all XOR totals for every subset is 480.
    """


Prompt:
from typing import Any
def minSwaps(s: str) -> int:
    """
    Given a binary string s, return the minimum number of character swaps to make it alternating, or -1 if it is impossible.
    The string is called alternating if no two adjacent characters are equal. For example, the strings "010" and "1010" are alternating, while the string "0100" is not.
    Any two characters may be swapped, even if they are not adjacent.

    Example 1:

    >>> minSwaps(s = "111000")
    >>> 1
    Explanation: Swap positions 1 and 4: "111000" -> "101010"
    The string is now alternating.

    Example 2:

    >>> minSwaps(s = "010")
    >>> 0
    Explanation: The string is already alternating, no swaps are needed.

    Example 3:

    >>> minSwaps(s = "1110")
    >>> -1
    """


Prompt:
def rearrangeSticks(n: int, k: int) -> int:
    """
    There are n uniquely-sized sticks whose lengths are integers from 1 to n. You want to arrange the sticks such that exactly k sticks are visible from the left. A stick is visible from the left if there are no longer sticks to the left of it.

    For example, if the sticks are arranged [1,3,2,5,4], then the sticks with lengths 1, 3, and 5 are visible from the left.

    Given n and k, return the number of such arrangements. Since the answer may be large, return it modulo 109 + 7.

    Example 1:

    >>> rearrangeSticks(n = 3, k = 2)
    >>> 3
    Explanation: [1,3,2], [2,3,1], and [2,1,3] are the only arrangements such that exactly 2 sticks are visible.
    The visible sticks are underlined.

    Example 2:

    >>> rearrangeSticks(n = 5, k = 5)
    >>> 1
    Explanation: [1,2,3,4,5] is the only arrangement such that all 5 sticks are visible.
    The visible sticks are underlined.

    Example 3:

    >>> rearrangeSticks(n = 20, k = 11)
    >>> 647427950
    Explanation: There are 647427950 (mod 109 + 7) ways to rearrange the sticks such that exactly 11 sticks are visible.
    """


Prompt:
from typing import List
def findRLEArray(encoded1: List[List[int]], encoded2: List[List[int]]) -> List[List[int]]:
    """
    Run-length encoding is a compression algorithm that allows for an integer array nums with many segments of consecutive repeated numbers to be represented by a (generally smaller) 2D array encoded. Each encoded[i] = [vali, freqi] describes the ith segment of repeated numbers in nums where vali is the value that is repeated freqi times.

    For example, nums = [1,1,1,2,2,2,2,2] is represented by the run-length encoded array encoded = [[1,3],[2,5]]. Another way to read this is "three 1's followed by five 2's".

    The product of two run-length encoded arrays encoded1 and encoded2 can be calculated using the following steps:

    Expand both encoded1 and encoded2 into the full arrays nums1 and nums2 respectively.
    Create a new array prodNums of length nums1.length and set prodNums[i] = nums1[i] * nums2[i].
    Compress prodNums into a run-length encoded array and return it.

    You are given two run-length encoded arrays encoded1 and encoded2 representing full arrays nums1 and nums2 respectively. Both nums1 and nums2 have the same length. Each encoded1[i] = [vali, freqi] describes the ith segment of nums1, and each encoded2[j] = [valj, freqj] describes the jth segment of nums2.
    Return the product of encoded1 and encoded2.
    Note: Compression should be done such that the run-length encoded array has the minimum possible length.

    Example 1:

    >>> findRLEArray(encoded1 = [[1,3],[2,3]], encoded2 = [[6,3],[3,3]])
    >>> [[6,6]]
    Explanation: encoded1 expands to [1,1,1,2,2,2] and encoded2 expands to [6,6,6,3,3,3].
    prodNums = [6,6,6,6,6,6], which is compressed into the run-length encoded array [[6,6]].

    Example 2:

    >>> findRLEArray(encoded1 = [[1,3],[2,1],[3,2]], encoded2 = [[2,3],[3,3]])
    >>> [[2,3],[6,1],[9,2]]
    Explanation: encoded1 expands to [1,1,1,2,3,3] and encoded2 expands to [2,2,2,3,3,3].
    prodNums = [2,2,2,6,9,9], which is compressed into the run-length encoded array [[2,3],[6,1],[9,2]].
    """


Prompt:
def checkZeroOnes(s: str) -> bool:
    """
    Given a binary string s, return true if the longest contiguous segment of 1's is strictly longer than the longest contiguous segment of 0's in s, or return false otherwise.

    For example, in s = "110100010" the longest continuous segment of 1s has length 2, and the longest continuous segment of 0s has length 3.

    Note that if there are no 0's, then the longest continuous segment of 0's is considered to have a length 0. The same applies if there is no 1's.

    Example 1:

    >>> checkZeroOnes(s = "1101")
    >>> true
    Explanation:
    The longest contiguous segment of 1s has length 2: "1101"
    The longest contiguous segment of 0s has length 1: "1101"
    The segment of 1s is longer, so return true.

    Example 2:

    >>> checkZeroOnes(s = "111000")
    >>> false
    Explanation:
    The longest contiguous segment of 1s has length 3: "111000"
    The longest contiguous segment of 0s has length 3: "111000"
    The segment of 1s is not longer, so return false.

    Example 3:

    >>> checkZeroOnes(s = "110100010")
    >>> false
    Explanation:
    The longest contiguous segment of 1s has length 2: "110100010"
    The longest contiguous segment of 0s has length 3: "110100010"
    The segment of 1s is not longer, so return false.
    """


Prompt:
from typing import List
def minSpeedOnTime(dist: List[int], hour: float) -> int:
    """
    You are given a floating-point number hour, representing the amount of time you have to reach the office. To commute to the office, you must take n trains in sequential order. You are also given an integer array dist of length n, where dist[i] describes the distance (in kilometers) of the ith train ride.
    Each train can only depart at an integer hour, so you may need to wait in between each train ride.

    For example, if the 1st train ride takes 1.5 hours, you must wait for an additional 0.5 hours before you can depart on the 2nd train ride at the 2 hour mark.

    Return the minimum positive integer speed (in kilometers per hour) that all the trains must travel at for you to reach the office on time, or -1 if it is impossible to be on time.
    Tests are generated such that the answer will not exceed 107 and hour will have at most two digits after the decimal point.

    Example 1:

    >>> minSpeedOnTime(dist = [1,3,2], hour = 6)
    >>> 1
    Explanation: At speed 1:
    - The first train ride takes 1/1 = 1 hour.
    - Since we are already at an integer hour, we depart immediately at the 1 hour mark. The second train takes 3/1 = 3 hours.
    - Since we are already at an integer hour, we depart immediately at the 4 hour mark. The third train takes 2/1 = 2 hours.
    - You will arrive at exactly the 6 hour mark.

    Example 2:

    >>> minSpeedOnTime(dist = [1,3,2], hour = 2.7)
    >>> 3
    Explanation: At speed 3:
    - The first train ride takes 1/3 = 0.33333 hours.
    - Since we are not at an integer hour, we wait until the 1 hour mark to depart. The second train ride takes 3/3 = 1 hour.
    - Since we are already at an integer hour, we depart immediately at the 2 hour mark. The third train takes 2/3 = 0.66667 hours.
    - You will arrive at the 2.66667 hour mark.

    Example 3:

    >>> minSpeedOnTime(dist = [1,3,2], hour = 1.9)
    >>> -1
    Explanation: It is impossible because the earliest the third train can depart is at the 2 hour mark.
    """


Prompt:
def canReach(s: str, minJump: int, maxJump: int) -> bool:
    """
    You are given a 0-indexed binary string s and two integers minJump and maxJump. In the beginning, you are standing at index 0, which is equal to '0'. You can move from index i to index j if the following conditions are fulfilled:

    i + minJump <= j <= min(i + maxJump, s.length - 1), and
    s[j] == '0'.

    Return true if you can reach index s.length - 1 in s, or false otherwise.

    Example 1:

    >>> canReach(s = "011010", minJump = 2, maxJump = 3)
    >>> true
    Explanation:
    In the first step, move from index 0 to index 3.
    In the second step, move from index 3 to index 5.

    Example 2:

    >>> canReach(s = "01101110", minJump = 2, maxJump = 3)
    >>> false
    """


Prompt:
from typing import List
def stoneGameVIII(stones: List[int]) -> int:
    """
    Alice and Bob take turns playing a game, with Alice starting first.\r
    \r
    There are n stones arranged in a row. On each player's turn, while the number of stones is more than one, they will do the following:\r
    \r
    \r
    	Choose an integer x > 1, and remove the leftmost x stones from the row.\r
    	Add the sum of the removed stones' values to the player's score.\r
    	Place a new stone, whose value is equal to that sum, on the left side of the row.\r
    \r
    \r
    The game stops when only one stone is left in the row.\r
    \r
    The score difference between Alice and Bob is (Alice's score - Bob's score). Alice's goal is to maximize the score difference, and Bob's goal is the minimize the score difference.\r
    \r
    Given an integer array stones of length n where stones[i] represents the value of the ith stone from the left, return the score difference between Alice and Bob if they both play optimally.\r
    \r
     \r
    Example 1:\r
    \r
    \r
    >>> stoneGameVIII(stones = [-1,2,-3,4,-5]\r)
    >>> 5\r
    Explanation:\r
    - Alice removes the first 4 stones, adds (-1) + 2 + (-3) + 4 = 2 to her score, and places a stone of\r
      value 2 on the left. stones = [2,-5].\r
    - Bob removes the first 2 stones, adds 2 + (-5) = -3 to his score, and places a stone of value -3 on\r
      the left. stones = [-3].\r
    The difference between their scores is 2 - (-3) = 5.\r
    \r
    \r
    Example 2:\r
    \r
    \r
    >>> stoneGameVIII(stones = [7,-6,5,10,5,-2,-6]\r)
    >>> 13\r
    Explanation:\r
    - Alice removes all stones, adds 7 + (-6) + 5 + 10 + 5 + (-2) + (-6) = 13 to her score, and places a\r
      stone of value 13 on the left. stones = [13].\r
    The difference between their scores is 13 - 0 = 13.\r
    \r
    \r
    Example 3:\r
    \r
    \r
    >>> stoneGameVIII(stones = [-10,-12]\r)
    >>> -22\r
    Explanation:\r
    - Alice can only make one move, which is to remove both stones. She adds (-10) + (-12) = -22 to her\r
      score and places a stone of value -22 on the left. stones = [-22].\r
    The difference between their scores is (-22) - 0 = -22.\r
    \r
    \r
     \r
    """


Prompt:
from typing import List
def minProductSum(nums1: List[int], nums2: List[int]) -> int:
    """
    The product sum of two equal-length arrays a and b is equal to the sum of a[i] * b[i] for all 0 <= i < a.length (0-indexed).\r
    \r
    \r
    	For example, if a = [1,2,3,4] and b = [5,2,3,1], the product sum would be 1*5 + 2*2 + 3*3 + 4*1 = 22.\r
    \r
    \r
    Given two arrays nums1 and nums2 of length n, return the minimum product sum if you are allowed to rearrange the order of the elements in nums1. \r
    \r
     \r
    Example 1:\r
    \r
    \r
    >>> minProductSum(nums1 = [5,3,4,2], nums2 = [4,2,2,5]\r)
    >>> 40\r
    Explanation: We can rearrange nums1 to become [3,5,4,2]. The product sum of [3,5,4,2] and [4,2,2,5] is 3*4 + 5*2 + 4*2 + 2*5 = 40.\r
    \r
    \r
    Example 2:\r
    \r
    \r
    >>> minProductSum(nums1 = [2,1,4,5,7], nums2 = [3,2,4,8,6]\r)
    >>> 65\r
    Explanation: We can rearrange nums1 to become [5,7,4,1,2]. The product sum of [5,7,4,1,2] and [3,2,4,8,6] is 5*3 + 7*2 + 4*4 + 1*8 + 2*6 = 65.\r
    \r
    \r
     \r
    """


Prompt:
def countGoodSubstrings(s: str) -> int:
    """
    A string is good if there are no repeated characters.
    Given a string s, return the number of good substrings of length three in s.
    Note that if there are multiple occurrences of the same substring, every occurrence should be counted.
    A substring is a contiguous sequence of characters in a string.

    Example 1:

    >>> countGoodSubstrings(s = "xyzzaz")
    >>> 1
    Explanation: There are 4 substrings of size 3: "xyz", "yzz", "zza", and "zaz".
    The only good substring of length 3 is "xyz".

    Example 2:

    >>> countGoodSubstrings(s = "aababcabc")
    >>> 4
    Explanation: There are 7 substrings of size 3: "aab", "aba", "bab", "abc", "bca", "cab", and "abc".
    The good substrings are "abc", "bca", "cab", and "abc".
    """


Prompt:
from typing import List
def minPairSum(nums: List[int]) -> int:
    """
    The pair sum of a pair (a,b) is equal to a + b. The maximum pair sum is the largest pair sum in a list of pairs.\r
    \r
    \r
    	For example, if we have pairs (1,5), (2,3), and (4,4), the maximum pair sum would be max(1+5, 2+3, 4+4) = max(6, 5, 8) = 8.\r
    \r
    \r
    Given an array nums of even length n, pair up the elements of nums into n / 2 pairs such that:\r
    \r
    \r
    	Each element of nums is in exactly one pair, and\r
    	The maximum pair sum is minimized.\r
    \r
    \r
    Return the minimized maximum pair sum after optimally pairing up the elements.\r
    \r
     \r
    Example 1:\r
    \r
    \r
    >>> minPairSum(nums = [3,5,2,3]\r)
    >>> 7\r
    Explanation: The elements can be paired up into pairs (3,3) and (5,2).\r
    The maximum pair sum is max(3+3, 5+2) = max(6, 7) = 7.\r
    \r
    \r
    Example 2:\r
    \r
    \r
    >>> minPairSum(nums = [3,5,4,2,4,6]\r)
    >>> 8\r
    Explanation: The elements can be paired up into pairs (3,5), (4,4), and (6,2).\r
    The maximum pair sum is max(3+5, 4+4, 6+2) = max(8, 8, 8) = 8.\r
    \r
    \r
     \r
    """


Prompt:
from typing import List
def getBiggestThree(grid: List[List[int]]) -> List[int]:
    """
    You are given an m x n integer matrix grid.
    A rhombus sum is the sum of the elements that form the border of a regular rhombus shape in grid. The rhombus must have the shape of a square rotated 45 degrees with each of the corners centered in a grid cell. Below is an image of four valid rhombus shapes with the corresponding colored cells that should be included in each rhombus sum:

    Note that the rhombus can have an area of 0, which is depicted by the purple rhombus in the bottom right corner.
    Return the biggest three distinct rhombus sums in the grid in descending order. If there are less than three distinct values, return all of them.

    Example 1:

    >>> getBiggestThree(grid = [[3,4,5,1,3],[3,3,4,2,3],[20,30,200,40,10],[1,5,5,4,1],[4,3,2,2,5]])
    >>> [228,216,211]
    Explanation: The rhombus shapes for the three biggest distinct rhombus sums are depicted above.
    - Blue: 20 + 3 + 200 + 5 = 228
    - Red: 200 + 2 + 10 + 4 = 216
    - Green: 5 + 200 + 4 + 2 = 211

    Example 2:

    >>> getBiggestThree(grid = [[1,2,3],[4,5,6],[7,8,9]])
    >>> [20,9,8]
    Explanation: The rhombus shapes for the three biggest distinct rhombus sums are depicted above.
    - Blue: 4 + 2 + 6 + 8 = 20
    - Red: 9 (area 0 rhombus in the bottom right corner)
    - Green: 8 (area 0 rhombus in the bottom middle)

    Example 3:

    >>> getBiggestThree(grid = [[7,7,7]])
    >>> [7]
    Explanation: All three possible rhombus sums are the same, so return [7].
    """


Prompt:
from typing import List
def minimumXORSum(nums1: List[int], nums2: List[int]) -> int:
    """
    You are given two integer arrays nums1 and nums2 of length n.
    The XOR sum of the two integer arrays is (nums1[0] XOR nums2[0]) + (nums1[1] XOR nums2[1]) + ... + (nums1[n - 1] XOR nums2[n - 1]) (0-indexed).

    For example, the XOR sum of [1,2,3] and [3,2,1] is equal to (1 XOR 3) + (2 XOR 2) + (3 XOR 1) = 2 + 0 + 2 = 4.

    Rearrange the elements of nums2 such that the resulting XOR sum is minimized.
    Return the XOR sum after the rearrangement.

    Example 1:

    >>> minimumXORSum(nums1 = [1,2], nums2 = [2,3])
    >>> 2
    Explanation: Rearrange nums2 so that it becomes [3,2].
    The XOR sum is (1 XOR 3) + (2 XOR 2) = 2 + 0 = 2.
    Example 2:

    >>> minimumXORSum(nums1 = [1,0,3], nums2 = [5,3,4])
    >>> 8
    Explanation: Rearrange nums2 so that it becomes [5,4,3].
    The XOR sum is (1 XOR 5) + (0 XOR 4) + (3 XOR 3) = 4 + 4 + 0 = 8.
    """


Prompt:
def isSumEqual(firstWord: str, secondWord: str, targetWord: str) -> bool:
    """
    The letter value of a letter is its position in the alphabet starting from 0 (i.e. 'a' -> 0, 'b' -> 1, 'c' -> 2, etc.).
    The numerical value of some string of lowercase English letters s is the concatenation of the letter values of each letter in s, which is then converted into an integer.

    For example, if s = "acb", we concatenate each letter's letter value, resulting in "021". After converting it, we get 21.

    You are given three strings firstWord, secondWord, and targetWord, each consisting of lowercase English letters 'a' through 'j' inclusive.
    Return true if the summation of the numerical values of firstWord and secondWord equals the numerical value of targetWord, or false otherwise.

    Example 1:

    >>> isSumEqual(firstWord = "acb", secondWord = "cba", targetWord = "cdb")
    >>> true
    Explanation:
    The numerical value of firstWord is "acb" -> "021" -> 21.
    The numerical value of secondWord is "cba" -> "210" -> 210.
    The numerical value of targetWord is "cdb" -> "231" -> 231.
    We return true because 21 + 210 == 231.

    Example 2:

    >>> isSumEqual(firstWord = "aaa", secondWord = "a", targetWord = "aab")
    >>> false
    Explanation:
    The numerical value of firstWord is "aaa" -> "000" -> 0.
    The numerical value of secondWord is "a" -> "0" -> 0.
    The numerical value of targetWord is "aab" -> "001" -> 1.
    We return false because 0 + 0 != 1.

    Example 3:

    >>> isSumEqual(firstWord = "aaa", secondWord = "a", targetWord = "aaaa")
    >>> true
    Explanation:
    The numerical value of firstWord is "aaa" -> "000" -> 0.
    The numerical value of secondWord is "a" -> "0" -> 0.
    The numerical value of targetWord is "aaaa" -> "0000" -> 0.
    We return true because 0 + 0 == 0.
    """


Prompt:
def maxValue(n: str, x: int) -> str:
    """
    You are given a very large integer n, represented as a string, and an integer digit x. The digits in n and the digit x are in the inclusive range [1, 9], and n may represent a negative number.
    You want to maximize n's numerical value by inserting x anywhere in the decimal representation of n. You cannot insert x to the left of the negative sign.

    For example, if n = 73 and x = 6, it would be best to insert it between 7 and 3, making n = 763.
    If n = -55 and x = 2, it would be best to insert it before the first 5, making n = -255.

    Return a string representing the maximum value of n after the insertion.

    Example 1:

    >>> maxValue(n = "99", x = 9)
    >>> "999"
    Explanation: The result is the same regardless of where you insert 9.

    Example 2:

    >>> maxValue(n = "-13", x = 2)
    >>> "-123"
    Explanation: You can make n one of {-213, -123, -132}, and the largest of those three is -123.
    """


Prompt:
from typing import List
def assignTasks(servers: List[int], tasks: List[int]) -> List[int]:
    """
    You are given two 0-indexed integer arrays servers and tasks of lengths n and m respectively. servers[i] is the weight of the ith server, and tasks[j] is the time needed to process the jth task in seconds.
    Tasks are assigned to the servers using a task queue. Initially, all servers are free, and the queue is empty.
    At second j, the jth task is inserted into the queue (starting with the 0th task being inserted at second 0). As long as there are free servers and the queue is not empty, the task in the front of the queue will be assigned to a free server with the smallest weight, and in case of a tie, it is assigned to a free server with the smallest index.
    If there are no free servers and the queue is not empty, we wait until a server becomes free and immediately assign the next task. If multiple servers become free at the same time, then multiple tasks from the queue will be assigned in order of insertion following the weight and index priorities above.
    A server that is assigned task j at second t will be free again at second t + tasks[j].
    Build an array ans of length m, where ans[j] is the index of the server the jth task will be assigned to.
    Return the array ans.

    Example 1:

    >>> assignTasks(servers = [3,3,2], tasks = [1,2,3,2,1,2])
    >>> [2,2,0,2,1,2]
    Explanation: Events in chronological order go as follows:
    - At second 0, task 0 is added and processed using server 2 until second 1.
    - At second 1, server 2 becomes free. Task 1 is added and processed using server 2 until second 3.
    - At second 2, task 2 is added and processed using server 0 until second 5.
    - At second 3, server 2 becomes free. Task 3 is added and processed using server 2 until second 5.
    - At second 4, task 4 is added and processed using server 1 until second 5.
    - At second 5, all servers become free. Task 5 is added and processed using server 2 until second 7.
    Example 2:

    >>> assignTasks(servers = [5,1,4,3,2], tasks = [2,1,2,4,5,2,1])
    >>> [1,4,1,4,1,3,2]
    Explanation: Events in chronological order go as follows:
    - At second 0, task 0 is added and processed using server 1 until second 2.
    - At second 1, task 1 is added and processed using server 4 until second 2.
    - At second 2, servers 1 and 4 become free. Task 2 is added and processed using server 1 until second 4.
    - At second 3, task 3 is added and processed using server 4 until second 7.
    - At second 4, server 1 becomes free. Task 4 is added and processed using server 1 until second 9.
    - At second 5, task 5 is added and processed using server 3 until second 7.
    - At second 6, task 6 is added and processed using server 2 until second 7.
    """


Prompt:
from typing import List
def minSkips(dist: List[int], speed: int, hoursBefore: int) -> int:
    """
    You are given an integer hoursBefore, the number of hours you have to travel to your meeting. To arrive at your meeting, you have to travel through n roads. The road lengths are given as an integer array dist of length n, where dist[i] describes the length of the ith road in kilometers. In addition, you are given an integer speed, which is the speed (in km/h) you will travel at.
    After you travel road i, you must rest and wait for the next integer hour before you can begin traveling on the next road. Note that you do not have to rest after traveling the last road because you are already at the meeting.

    For example, if traveling a road takes 1.4 hours, you must wait until the 2 hour mark before traveling the next road. If traveling a road takes exactly 2 hours, you do not need to wait.

    However, you are allowed to skip some rests to be able to arrive on time, meaning you do not need to wait for the next integer hour. Note that this means you may finish traveling future roads at different hour marks.

    For example, suppose traveling the first road takes 1.4 hours and traveling the second road takes 0.6 hours. Skipping the rest after the first road will mean you finish traveling the second road right at the 2 hour mark, letting you start traveling the third road immediately.

    Return the minimum number of skips required to arrive at the meeting on time, or -1 if it is impossible.

    Example 1:

    >>> minSkips(dist = [1,3,2], speed = 4, hoursBefore = 2)
    >>> 1
    Explanation:
    Without skipping any rests, you will arrive in (1/4 + 3/4) + (3/4 + 1/4) + (2/4) = 2.5 hours.
    You can skip the first rest to arrive in ((1/4 + 0) + (3/4 + 0)) + (2/4) = 1.5 hours.
    Note that the second rest is shortened because you finish traveling the second road at an integer hour due to skipping the first rest.

    Example 2:

    >>> minSkips(dist = [7,3,5,5], speed = 2, hoursBefore = 10)
    >>> 2
    Explanation:
    Without skipping any rests, you will arrive in (7/2 + 1/2) + (3/2 + 1/2) + (5/2 + 1/2) + (5/2) = 11.5 hours.
    You can skip the first and third rest to arrive in ((7/2 + 0) + (3/2 + 0)) + ((5/2 + 0) + (5/2)) = 10 hours.

    Example 3:

    >>> minSkips(dist = [7,3,5,5], speed = 1, hoursBefore = 10)
    >>> -1
    Explanation: It is impossible to arrive at the meeting on time even if you skip all the rests.
    """