Prompt:
from typing import List
def longestObstacleCourseAtEachPosition(obstacles: List[int]) -> List[int]:
    """
    You want to build some obstacle courses. You are given a 0-indexed integer array obstacles of length n, where obstacles[i] describes the height of the ith obstacle.
    For every index i between 0 and n - 1 (inclusive), find the length of the longest obstacle course in obstacles such that:

    You choose any number of obstacles between 0 and i inclusive.
    You must include the ith obstacle in the course.
    You must put the chosen obstacles in the same order as they appear in obstacles.
    Every obstacle (except the first) is taller than or the same height as the obstacle immediately before it.

    Return an array ans of length n, where ans[i] is the length of the longest obstacle course for index i as described above.

    Example 1:

    >>> longestObstacleCourseAtEachPosition(obstacles = [1,2,3,2])
    >>> [1,2,3,3]
    Explanation: The longest valid obstacle course at each position is:
    - i = 0: [1], [1] has length 1.
    - i = 1: [1,2], [1,2] has length 2.
    - i = 2: [1,2,3], [1,2,3] has length 3.
    - i = 3: [1,2,3,2], [1,2,2] has length 3.

    Example 2:

    >>> longestObstacleCourseAtEachPosition(obstacles = [2,2,1])
    >>> [1,2,1]
    Explanation: The longest valid obstacle course at each position is:
    - i = 0: [2], [2] has length 1.
    - i = 1: [2,2], [2,2] has length 2.
    - i = 2: [2,2,1], [1] has length 1.

    Example 3:

    >>> longestObstacleCourseAtEachPosition(obstacles = [3,1,5,6,4,2])
    >>> [1,1,2,3,2,2]
    Explanation: The longest valid obstacle course at each position is:
    - i = 0: [3], [3] has length 1.
    - i = 1: [3,1], [1] has length 1.
    - i = 2: [3,1,5], [3,5] has length 2. [1,5] is also valid.
    - i = 3: [3,1,5,6], [3,5,6] has length 3. [1,5,6] is also valid.
    - i = 4: [3,1,5,6,4], [3,4] has length 2. [1,4] is also valid.
    - i = 5: [3,1,5,6,4,2], [1,2] has length 2.
    """


Prompt:
from typing import List
def binarySearchableNumbers(nums: List[int]) -> int:
    """
    Consider a function that implements an algorithm similar to Binary Search. The function has two input parameters: sequence is a sequence of integers, and target is an integer value. The purpose of the function is to find if the target exists in the sequence.
    The pseudocode of the function is as follows:

    func(sequence, target)
      while sequence is not empty
        randomly choose an element from sequence as the pivot
        if pivot = target, return true
        else if pivot < target, remove pivot and all elements to its left from the sequence
        else, remove pivot and all elements to its right from the sequence
      end while
      return false

    When the sequence is sorted, the function works correctly for all values. When the sequence is not sorted, the function does not work for all values, but may still work for some values.
    Given an integer array nums, representing the sequence, that contains unique numbers and may or may not be sorted, return the number of values that are guaranteed to be found using the function, for every possible pivot selection.

    Example 1:

    >>> binarySearchableNumbers(nums = [7])
    >>> 1
    Explanation:
    Searching for value 7 is guaranteed to be found.
    Since the sequence has only one element, 7 will be chosen as the pivot. Because the pivot equals the target, the function will return true.

    Example 2:

    >>> binarySearchableNumbers(nums = [-1,5,2])
    >>> 1
    Explanation:
    Searching for value -1 is guaranteed to be found.
    If -1 was chosen as the pivot, the function would return true.
    If 5 was chosen as the pivot, 5 and 2 would be removed. In the next loop, the sequence would have only -1 and the function would return true.
    If 2 was chosen as the pivot, 2 would be removed. In the next loop, the sequence would have -1 and 5. No matter which number was chosen as the next pivot, the function would find -1 and return true.

    Searching for value 5 is NOT guaranteed to be found.
    If 2 was chosen as the pivot, -1, 5 and 2 would be removed. The sequence would be empty and the function would return false.

    Searching for value 2 is NOT guaranteed to be found.
    If 5 was chosen as the pivot, 5 and 2 would be removed. In the next loop, the sequence would have only -1 and the function would return false.

    Because only -1 is guaranteed to be found, you should return 1.
    """


Prompt:
from typing import List
def numOfStrings(patterns: List[str], word: str) -> int:
    """
    Given an array of strings patterns and a string word, return the number of strings in patterns that exist as a substring in word.
    A substring is a contiguous sequence of characters within a string.

    Example 1:

    >>> numOfStrings(patterns = ["a","abc","bc","d"], word = "abc")
    >>> 3
    Explanation:
    - "a" appears as a substring in "abc".
    - "abc" appears as a substring in "abc".
    - "bc" appears as a substring in "abc".
    - "d" does not appear as a substring in "abc".
    3 of the strings in patterns appear as a substring in word.

    Example 2:

    >>> numOfStrings(patterns = ["a","b","c"], word = "aaaaabbbbb")
    >>> 2
    Explanation:
    - "a" appears as a substring in "aaaaabbbbb".
    - "b" appears as a substring in "aaaaabbbbb".
    - "c" does not appear as a substring in "aaaaabbbbb".
    2 of the strings in patterns appear as a substring in word.

    Example 3:

    >>> numOfStrings(patterns = ["a","a","a"], word = "ab")
    >>> 3
    Explanation: Each of the patterns appears as a substring in word "ab".
    """


Prompt:
from typing import List
def rearrangeArray(nums: List[int]) -> List[int]:
    """
    You are given a 0-indexed array nums of distinct integers. You want to rearrange the elements in the array such that every element in the rearranged array is not equal to the average of its neighbors.
    More formally, the rearranged array should have the property such that for every i in the range 1 <= i < nums.length - 1, (nums[i-1] + nums[i+1]) / 2 is not equal to nums[i].
    Return any rearrangement of nums that meets the requirements.

    Example 1:

    >>> rearrangeArray(nums = [1,2,3,4,5])
    >>> [1,2,4,5,3]
    Explanation:
    When i=1, nums[i] = 2, and the average of its neighbors is (1+4) / 2 = 2.5.
    When i=2, nums[i] = 4, and the average of its neighbors is (2+5) / 2 = 3.5.
    When i=3, nums[i] = 5, and the average of its neighbors is (4+3) / 2 = 3.5.

    Example 2:

    >>> rearrangeArray(nums = [6,2,0,9,7])
    >>> [9,7,6,2,0]
    Explanation:
    When i=1, nums[i] = 7, and the average of its neighbors is (9+6) / 2 = 7.5.
    When i=2, nums[i] = 6, and the average of its neighbors is (7+2) / 2 = 4.5.
    When i=3, nums[i] = 2, and the average of its neighbors is (6+0) / 2 = 3.
    Note that the original array [6,2,0,9,7] also satisfies the conditions.
    """


Prompt:
from typing import List
def latestDayToCross(row: int, col: int, cells: List[List[int]]) -> int:
    """
    There is a 1-based binary matrix where 0 represents land and 1 represents water. You are given integers row and col representing the number of rows and columns in the matrix, respectively.
    Initially on day 0, the entire matrix is land. However, each day a new cell becomes flooded with water. You are given a 1-based 2D array cells, where cells[i] = [ri, ci] represents that on the ith day, the cell on the rith row and cith column (1-based coordinates) will be covered with water (i.e., changed to 1).
    You want to find the last day that it is possible to walk from the top to the bottom by only walking on land cells. You can start from any cell in the top row and end at any cell in the bottom row. You can only travel in the four cardinal directions (left, right, up, and down).
    Return the last day where it is possible to walk from the top to the bottom by only walking on land cells.

    Example 1:

    >>> latestDayToCross(row = 2, col = 2, cells = [[1,1],[2,1],[1,2],[2,2]])
    >>> 2
    Explanation: The above image depicts how the matrix changes each day starting from day 0.
    The last day where it is possible to cross from top to bottom is on day 2.

    Example 2:

    >>> latestDayToCross(row = 2, col = 2, cells = [[1,1],[1,2],[2,1],[2,2]])
    >>> 1
    Explanation: The above image depicts how the matrix changes each day starting from day 0.
    The last day where it is possible to cross from top to bottom is on day 1.

    Example 3:

    >>> latestDayToCross(row = 3, col = 3, cells = [[1,2],[2,1],[3,3],[2,2],[1,1],[1,3],[2,3],[3,2],[3,1]])
    >>> 3
    Explanation: The above image depicts how the matrix changes each day starting from day 0.
    The last day where it is possible to cross from top to bottom is on day 3.
    """


Prompt:
from typing import List
def validPath(n: int, edges: List[List[int]], source: int, destination: int) -> bool:
    """
    There is a bi-directional graph with n vertices, where each vertex is labeled from 0 to n - 1 (inclusive). The edges in the graph are represented as a 2D integer array edges, where each edges[i] = [ui, vi] denotes a bi-directional edge between vertex ui and vertex vi. Every vertex pair is connected by at most one edge, and no vertex has an edge to itself.
    You want to determine if there is a valid path that exists from vertex source to vertex destination.
    Given edges and the integers n, source, and destination, return true if there is a valid path from source to destination, or false otherwise.

    Example 1:

    >>> validPath(n = 3, edges = [[0,1],[1,2],[2,0]], source = 0, destination = 2)
    >>> true
    Explanation: There are two paths from vertex 0 to vertex 2:
    - 0 → 1 → 2
    - 0 → 2

    Example 2:

    >>> validPath(n = 6, edges = [[0,1],[0,2],[3,5],[5,4],[4,3]], source = 0, destination = 5)
    >>> false
    Explanation: There is no path from vertex 0 to vertex 5.
    """


Prompt:
from typing import Optional
class TreeNode:
    def __init__(val=0, left=None, right=None):
        self.val = val
        self.left = left
        self.right = right
def equalToDescendants(root: Optional[TreeNode]) -> int:
"""
Given the root of a binary tree, return the number of nodes where the value of the node is equal to the sum of the values of its descendants.
A descendant of a node x is any node that is on the path from node x to some leaf node. The sum is considered to be 0 if the node has no descendants.

Example 1:

>>> equalToDescendants(root = [10,3,4,2,1])
>>> 2
Explanation:
For the node with value 10: The sum of its descendants is 3+4+2+1 = 10.
For the node with value 3: The sum of its descendants is 2+1 = 3.

Example 2:

>>> equalToDescendants(root = [2,3,null,2,null])
>>> 0
Explanation:
No node has a value that is equal to the sum of its descendants.

Example 3:

>>> equalToDescendants(root = [0])
>>> 1
For the node with value 0: The sum of its descendants is 0 since it has no descendants.
"""


Prompt:
def minTimeToType(word: str) -> int:
    """
    There is a special typewriter with lowercase English letters 'a' to 'z' arranged in a circle with a pointer. A character can only be typed if the pointer is pointing to that character. The pointer is initially pointing to the character 'a'.

    Each second, you may perform one of the following operations:

    Move the pointer one character counterclockwise or clockwise.
    Type the character the pointer is currently on.

    Given a string word, return the minimum number of seconds to type out the characters in word.

    Example 1:

    >>> minTimeToType(word = "abc")
    >>> 5
    Explanation:
    The characters are printed as follows:
    - Type the character 'a' in 1 second since the pointer is initially on 'a'.
    - Move the pointer clockwise to 'b' in 1 second.
    - Type the character 'b' in 1 second.
    - Move the pointer clockwise to 'c' in 1 second.
    - Type the character 'c' in 1 second.

    Example 2:

    >>> minTimeToType(word = "bza")
    >>> 7
    Explanation:
    The characters are printed as follows:
    - Move the pointer clockwise to 'b' in 1 second.
    - Type the character 'b' in 1 second.
    - Move the pointer counterclockwise to 'z' in 2 seconds.
    - Type the character 'z' in 1 second.
    - Move the pointer clockwise to 'a' in 1 second.
    - Type the character 'a' in 1 second.

    Example 3:

    >>> minTimeToType(word = "zjpc")
    >>> 34
    Explanation:
    The characters are printed as follows:
    - Move the pointer counterclockwise to 'z' in 1 second.
    - Type the character 'z' in 1 second.
    - Move the pointer clockwise to 'j' in 10 seconds.
    - Type the character 'j' in 1 second.
    - Move the pointer clockwise to 'p' in 6 seconds.
    - Type the character 'p' in 1 second.
    - Move the pointer counterclockwise to 'c' in 13 seconds.
    - Type the character 'c' in 1 second.
    """


Prompt:
from typing import List
def maxMatrixSum(matrix: List[List[int]]) -> int:
    """
    You are given an n x n integer matrix. You can do the following operation any number of times:

    Choose any two adjacent elements of matrix and multiply each of them by -1.

    Two elements are considered adjacent if and only if they share a border.
    Your goal is to maximize the summation of the matrix's elements. Return the maximum sum of the matrix's elements using the operation mentioned above.

    Example 1:

    >>> maxMatrixSum(matrix = [[1,-1],[-1,1]])
    >>> 4
    Explanation: We can follow the following steps to reach sum equals 4:
    - Multiply the 2 elements in the first row by -1.
    - Multiply the 2 elements in the first column by -1.

    Example 2:

    >>> maxMatrixSum(matrix = [[1,2,3],[-1,-2,-3],[1,2,3]])
    >>> 16
    Explanation: We can follow the following step to reach sum equals 16:
    - Multiply the 2 last elements in the second row by -1.
    """


Prompt:
from typing import List
def countPaths(n: int, roads: List[List[int]]) -> int:
    """
    You are in a city that consists of n intersections numbered from 0 to n - 1 with bi-directional roads between some intersections. The inputs are generated such that you can reach any intersection from any other intersection and that there is at most one road between any two intersections.
    You are given an integer n and a 2D integer array roads where roads[i] = [ui, vi, timei] means that there is a road between intersections ui and vi that takes timei minutes to travel. You want to know in how many ways you can travel from intersection 0 to intersection n - 1 in the shortest amount of time.
    Return the number of ways you can arrive at your destination in the shortest amount of time. Since the answer may be large, return it modulo 109 + 7.

    Example 1:

    >>> countPaths(n = 7, roads = [[0,6,7],[0,1,2],[1,2,3],[1,3,3],[6,3,3],[3,5,1],[6,5,1],[2,5,1],[0,4,5],[4,6,2]])
    >>> 4
    Explanation: The shortest amount of time it takes to go from intersection 0 to intersection 6 is 7 minutes.
    The four ways to get there in 7 minutes are:
    - 0 ➝ 6
    - 0 ➝ 4 ➝ 6
    - 0 ➝ 1 ➝ 2 ➝ 5 ➝ 6
    - 0 ➝ 1 ➝ 3 ➝ 5 ➝ 6

    Example 2:

    >>> countPaths(n = 2, roads = [[1,0,10]])
    >>> 1
    Explanation: There is only one way to go from intersection 0 to intersection 1, and it takes 10 minutes.
    """


Prompt:
def numberOfCombinations(num: str) -> int:
    """
    You wrote down many positive integers in a string called num. However, you realized that you forgot to add commas to seperate the different numbers. You remember that the list of integers was non-decreasing and that no integer had leading zeros.
    Return the number of possible lists of integers that you could have written down to get the string num. Since the answer may be large, return it modulo 109 + 7.

    Example 1:

    >>> numberOfCombinations(num = "327")
    >>> 2
    Explanation: You could have written down the numbers:
    3, 27
    327

    Example 2:

    >>> numberOfCombinations(num = "094")
    >>> 0
    Explanation: No numbers can have leading zeros and all numbers must be positive.

    Example 3:

    >>> numberOfCombinations(num = "0")
    >>> 0
    Explanation: No numbers can have leading zeros and all numbers must be positive.
    """


Prompt:
from typing import List
def findGCD(nums: List[int]) -> int:
    """
    Given an integer array nums, return the greatest common divisor of the smallest number and largest number in nums.
    The greatest common divisor of two numbers is the largest positive integer that evenly divides both numbers.

    Example 1:

    >>> findGCD(nums = [2,5,6,9,10])
    >>> 2
    Explanation:
    The smallest number in nums is 2.
    The largest number in nums is 10.
    The greatest common divisor of 2 and 10 is 2.

    Example 2:

    >>> findGCD(nums = [7,5,6,8,3])
    >>> 1
    Explanation:
    The smallest number in nums is 3.
    The largest number in nums is 8.
    The greatest common divisor of 3 and 8 is 1.

    Example 3:

    >>> findGCD(nums = [3,3])
    >>> 3
    Explanation:
    The smallest number in nums is 3.
    The largest number in nums is 3.
    The greatest common divisor of 3 and 3 is 3.
    """


Prompt:
from typing import List
def findDifferentBinaryString(nums: List[str]) -> str:
    """
    Given an array of strings nums containing n unique binary strings each of length n, return a binary string of length n that does not appear in nums. If there are multiple answers, you may return any of them.

    Example 1:

    >>> findDifferentBinaryString(nums = ["01","10"])
    >>> "11"
    Explanation: "11" does not appear in nums. "00" would also be correct.

    Example 2:

    >>> findDifferentBinaryString(nums = ["00","01"])
    >>> "11"
    Explanation: "11" does not appear in nums. "10" would also be correct.

    Example 3:

    >>> findDifferentBinaryString(nums = ["111","011","001"])
    >>> "101"
    Explanation: "101" does not appear in nums. "000", "010", "100", and "110" would also be correct.
    """


Prompt:
from typing import List
def minimizeTheDifference(mat: List[List[int]], target: int) -> int:
    """
    You are given an m x n integer matrix mat and an integer target.
    Choose one integer from each row in the matrix such that the absolute difference between target and the sum of the chosen elements is minimized.
    Return the minimum absolute difference.
    The absolute difference between two numbers a and b is the absolute value of a - b.

    Example 1:

    >>> minimizeTheDifference(mat = [[1,2,3],[4,5,6],[7,8,9]], target = 13)
    >>> 0
    Explanation: One possible choice is to:
    - Choose 1 from the first row.
    - Choose 5 from the second row.
    - Choose 7 from the third row.
    The sum of the chosen elements is 13, which equals the target, so the absolute difference is 0.

    Example 2:

    >>> minimizeTheDifference(mat = [[1],[2],[3]], target = 100)
    >>> 94
    Explanation: The best possible choice is to:
    - Choose 1 from the first row.
    - Choose 2 from the second row.
    - Choose 3 from the third row.
    The sum of the chosen elements is 6, and the absolute difference is 94.

    Example 3:

    >>> minimizeTheDifference(mat = [[1,2,9,8,7]], target = 6)
    >>> 1
    Explanation: The best choice is to choose 7 from the first row.
    The absolute difference is 1.
    """


Prompt:
from typing import List
def recoverArray(n: int, sums: List[int]) -> List[int]:
    """
    You are given an integer n representing the length of an unknown array that you are trying to recover. You are also given an array sums containing the values of all 2n subset sums of the unknown array (in no particular order).
    Return the array ans of length n representing the unknown array. If multiple answers exist, return any of them.
    An array sub is a subset of an array arr if sub can be obtained from arr by deleting some (possibly zero or all) elements of arr. The sum of the elements in sub is one possible subset sum of arr. The sum of an empty array is considered to be 0.
    Note: Test cases are generated such that there will always be at least one correct answer.

    Example 1:

    >>> recoverArray(n = 3, sums = [-3,-2,-1,0,0,1,2,3])
    >>> [1,2,-3]
    Explanation: [1,2,-3] is able to achieve the given subset sums:
    - []: sum is 0
    - [1]: sum is 1
    - [2]: sum is 2
    - [1,2]: sum is 3
    - [-3]: sum is -3
    - [1,-3]: sum is -2
    - [2,-3]: sum is -1
    - [1,2,-3]: sum is 0
    Note that any permutation of [1,2,-3] and also any permutation of [-1,-2,3] will also be accepted.

    Example 2:

    >>> recoverArray(n = 2, sums = [0,0,0,0])
    >>> [0,0]
    Explanation: The only correct answer is [0,0].

    Example 3:

    >>> recoverArray(n = 4, sums = [0,0,5,5,4,-1,4,9,9,-1,4,3,4,8,3,8])
    >>> [0,-1,4,5]
    Explanation: [0,-1,4,5] is able to achieve the given subset sums.
    """


Prompt:
from typing import List
def widestPairOfIndices(nums1: List[int], nums2: List[int]) -> int:
    """
    You are given two 0-indexed binary arrays nums1 and nums2. Find the widest pair of indices (i, j) such that i <= j and nums1[i] + nums1[i+1] + ... + nums1[j] == nums2[i] + nums2[i+1] + ... + nums2[j].
    The widest pair of indices is the pair with the largest distance between i and j. The distance between a pair of indices is defined as j - i + 1.
    Return the distance of the widest pair of indices. If no pair of indices meets the conditions, return 0.

    Example 1:

    >>> widestPairOfIndices(nums1 = [1,1,0,1], nums2 = [0,1,1,0])
    >>> 3
    Explanation:
    If i = 1 and j = 3:
    nums1[1] + nums1[2] + nums1[3] = 1 + 0 + 1 = 2.
    nums2[1] + nums2[2] + nums2[3] = 1 + 1 + 0 = 2.
    The distance between i and j is j - i + 1 = 3 - 1 + 1 = 3.

    Example 2:

    >>> widestPairOfIndices(nums1 = [0,1], nums2 = [1,1])
    >>> 1
    Explanation:
    If i = 1 and j = 1:
    nums1[1] = 1.
    nums2[1] = 1.
    The distance between i and j is j - i + 1 = 1 - 1 + 1 = 1.

    Example 3:

    >>> widestPairOfIndices(nums1 = [0], nums2 = [1])
    >>> 0
    Explanation:
    There are no pairs of indices that meet the requirements.
    """


Prompt:
from typing import List
def minimumDifference(nums: List[int], k: int) -> int:
    """
    You are given a 0-indexed integer array nums, where nums[i] represents the score of the ith student. You are also given an integer k.
    Pick the scores of any k students from the array so that the difference between the highest and the lowest of the k scores is minimized.
    Return the minimum possible difference.

    Example 1:

    >>> minimumDifference(nums = [90], k = 1)
    >>> 0
    Explanation: There is one way to pick score(s) of one student:
    - [90]. The difference between the highest and lowest score is 90 - 90 = 0.
    The minimum possible difference is 0.

    Example 2:

    >>> minimumDifference(nums = [9,4,1,7], k = 2)
    >>> 2
    Explanation: There are six ways to pick score(s) of two students:
    - [9,4,1,7]. The difference between the highest and lowest score is 9 - 4 = 5.
    - [9,4,1,7]. The difference between the highest and lowest score is 9 - 1 = 8.
    - [9,4,1,7]. The difference between the highest and lowest score is 9 - 7 = 2.
    - [9,4,1,7]. The difference between the highest and lowest score is 4 - 1 = 3.
    - [9,4,1,7]. The difference between the highest and lowest score is 7 - 4 = 3.
    - [9,4,1,7]. The difference between the highest and lowest score is 7 - 1 = 6.
    The minimum possible difference is 2.
    """


Prompt:
from typing import List
def kthLargestNumber(nums: List[str], k: int) -> str:
    """
    You are given an array of strings nums and an integer k. Each string in nums represents an integer without leading zeros.
    Return the string that represents the kth largest integer in nums.
    Note: Duplicate numbers should be counted distinctly. For example, if nums is ["1","2","2"], "2" is the first largest integer, "2" is the second-largest integer, and "1" is the third-largest integer.

    Example 1:

    >>> kthLargestNumber(nums = ["3","6","7","10"], k = 4)
    >>> "3"
    Explanation:
    The numbers in nums sorted in non-decreasing order are ["3","6","7","10"].
    The 4th largest integer in nums is "3".

    Example 2:

    >>> kthLargestNumber(nums = ["2","21","12","1"], k = 3)
    >>> "2"
    Explanation:
    The numbers in nums sorted in non-decreasing order are ["1","2","12","21"].
    The 3rd largest integer in nums is "2".

    Example 3:

    >>> kthLargestNumber(nums = ["0","0"], k = 2)
    >>> "0"
    Explanation:
    The numbers in nums sorted in non-decreasing order are ["0","0"].
    The 2nd largest integer in nums is "0".
    """


Prompt:
from typing import List
def minSessions(tasks: List[int], sessionTime: int) -> int:
    """
    There are n tasks assigned to you. The task times are represented as an integer array tasks of length n, where the ith task takes tasks[i] hours to finish. A work session is when you work for at most sessionTime consecutive hours and then take a break.
    You should finish the given tasks in a way that satisfies the following conditions:

    If you start a task in a work session, you must complete it in the same work session.
    You can start a new task immediately after finishing the previous one.
    You may complete the tasks in any order.

    Given tasks and sessionTime, return the minimum number of work sessions needed to finish all the tasks following the conditions above.
    The tests are generated such that sessionTime is greater than or equal to the maximum element in tasks[i].

    Example 1:

    >>> minSessions(tasks = [1,2,3], sessionTime = 3)
    >>> 2
    Explanation: You can finish the tasks in two work sessions.
    - First work session: finish the first and the second tasks in 1 + 2 = 3 hours.
    - Second work session: finish the third task in 3 hours.

    Example 2:

    >>> minSessions(tasks = [3,1,3,1,1], sessionTime = 8)
    >>> 2
    Explanation: You can finish the tasks in two work sessions.
    - First work session: finish all the tasks except the last one in 3 + 1 + 3 + 1 = 8 hours.
    - Second work session: finish the last task in 1 hour.

    Example 3:

    >>> minSessions(tasks = [1,2,3,4,5], sessionTime = 15)
    >>> 1
    Explanation: You can finish all the tasks in one work session.
    """


Prompt:
def numberOfUniqueGoodSubsequences(binary: str) -> int:
    """
    You are given a binary string binary. A subsequence of binary is considered good if it is not empty and has no leading zeros (with the exception of "0").
    Find the number of unique good subsequences of binary.

    For example, if binary = "001", then all the good subsequences are ["0", "0", "1"], so the unique good subsequences are "0" and "1". Note that subsequences "00", "01", and "001" are not good because they have leading zeros.

    Return the number of unique good subsequences of binary. Since the answer may be very large, return it modulo 109 + 7.
    A subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements.

    Example 1:

    >>> numberOfUniqueGoodSubsequences(binary = "001")
    >>> 2
    Explanation: The good subsequences of binary are ["0", "0", "1"].
    The unique good subsequences are "0" and "1".

    Example 2:

    >>> numberOfUniqueGoodSubsequences(binary = "11")
    >>> 2
    Explanation: The good subsequences of binary are ["1", "1", "11"].
    The unique good subsequences are "1" and "11".
    Example 3:

    >>> numberOfUniqueGoodSubsequences(binary = "101")
    >>> 5
    Explanation: The good subsequences of binary are ["1", "0", "1", "10", "11", "101"].
    The unique good subsequences are "0", "1", "10", "11", and "101".
    """


Prompt:
from typing import List
def catchMaximumAmountofPeople(team: List[int], dist: int) -> int:
    """
    You are playing a game of tag with your friends. In tag, people are divided into two teams: people who are "it", and people who are not "it". The people who are "it" want to catch as many people as possible who are not "it".
    You are given a 0-indexed integer array team containing only zeros (denoting people who are not "it") and ones (denoting people who are "it"), and an integer dist. A person who is "it" at index i can catch any one person whose index is in the range [i - dist, i + dist] (inclusive) and is not "it".
    Return the maximum number of people that the people who are "it" can catch.

    Example 1:

    >>> catchMaximumAmountofPeople(team = [0,1,0,1,0], dist = 3)
    >>> 2
    Explanation:
    The person who is "it" at index 1 can catch people in the range [i-dist, i+dist] = [1-3, 1+3] = [-2, 4].
    They can catch the person who is not "it" at index 2.
    The person who is "it" at index 3 can catch people in the range [i-dist, i+dist] = [3-3, 3+3] = [0, 6].
    They can catch the person who is not "it" at index 0.
    The person who is not "it" at index 4 will not be caught because the people at indices 1 and 3 are already catching one person.
    Example 2:

    >>> catchMaximumAmountofPeople(team = [1], dist = 1)
    >>> 0
    Explanation:
    There are no people who are not "it" to catch.

    Example 3:

    >>> catchMaximumAmountofPeople(team = [0], dist = 1)
    >>> 0
    Explanation:
    There are no people who are "it" to catch people.
    """


Prompt:
from typing import List
def findMiddleIndex(nums: List[int]) -> int:
    """
    Given a 0-indexed integer array nums, find the leftmost middleIndex (i.e., the smallest amongst all the possible ones).
    A middleIndex is an index where nums[0] + nums[1] + ... + nums[middleIndex-1] == nums[middleIndex+1] + nums[middleIndex+2] + ... + nums[nums.length-1].
    If middleIndex == 0, the left side sum is considered to be 0. Similarly, if middleIndex == nums.length - 1, the right side sum is considered to be 0.
    Return the leftmost middleIndex that satisfies the condition, or -1 if there is no such index.

    Example 1:

    >>> findMiddleIndex(nums = [2,3,-1,8,4])
    >>> 3
    Explanation: The sum of the numbers before index 3 is: 2 + 3 + -1 = 4
    The sum of the numbers after index 3 is: 4 = 4

    Example 2:

    >>> findMiddleIndex(nums = [1,-1,4])
    >>> 2
    Explanation: The sum of the numbers before index 2 is: 1 + -1 = 0
    The sum of the numbers after index 2 is: 0

    Example 3:

    >>> findMiddleIndex(nums = [2,5])
    >>> -1
    Explanation: There is no valid middleIndex.
    """


Prompt:
from typing import List
def findFarmland(land: List[List[int]]) -> List[List[int]]:
    """
    You are given a 0-indexed m x n binary matrix land where a 0 represents a hectare of forested land and a 1 represents a hectare of farmland.
    To keep the land organized, there are designated rectangular areas of hectares that consist entirely of farmland. These rectangular areas are called groups. No two groups are adjacent, meaning farmland in one group is not four-directionally adjacent to another farmland in a different group.
    land can be represented by a coordinate system where the top left corner of land is (0, 0) and the bottom right corner of land is (m-1, n-1). Find the coordinates of the top left and bottom right corner of each group of farmland. A group of farmland with a top left corner at (r1, c1) and a bottom right corner at (r2, c2) is represented by the 4-length array [r1, c1, r2, c2].
    Return a 2D array containing the 4-length arrays described above for each group of farmland in land. If there are no groups of farmland, return an empty array. You may return the answer in any order.

    Example 1:

    >>> findFarmland(land = [[1,0,0],[0,1,1],[0,1,1]])
    >>> [[0,0,0,0],[1,1,2,2]]
    Explanation:
    The first group has a top left corner at land[0][0] and a bottom right corner at land[0][0].
    The second group has a top left corner at land[1][1] and a bottom right corner at land[2][2].

    Example 2:

    >>> findFarmland(land = [[1,1],[1,1]])
    >>> [[0,0,1,1]]
    Explanation:
    The first group has a top left corner at land[0][0] and a bottom right corner at land[1][1].

    Example 3:

    >>> findFarmland(land = [[0]])
    >>> []
    Explanation:
    There are no groups of farmland.
    """


Prompt:
from typing import List
def numberOfGoodSubsets(nums: List[int]) -> int:
    """
    You are given an integer array nums. We call a subset of nums good if its product can be represented as a product of one or more distinct prime numbers.

    For example, if nums = [1, 2, 3, 4]:

    [2, 3], [1, 2, 3], and [1, 3] are good subsets with products 6 = 2*3, 6 = 2*3, and 3 = 3 respectively.
    [1, 4] and [4] are not good subsets with products 4 = 2*2 and 4 = 2*2 respectively.

    Return the number of different good subsets in nums modulo 109 + 7.
    A subset of nums is any array that can be obtained by deleting some (possibly none or all) elements from nums. Two subsets are different if and only if the chosen indices to delete are different.

    Example 1:

    >>> numberOfGoodSubsets(nums = [1,2,3,4])
    >>> 6
    Explanation: The good subsets are:
    - [1,2]: product is 2, which is the product of distinct prime 2.
    - [1,2,3]: product is 6, which is the product of distinct primes 2 and 3.
    - [1,3]: product is 3, which is the product of distinct prime 3.
    - [2]: product is 2, which is the product of distinct prime 2.
    - [2,3]: product is 6, which is the product of distinct primes 2 and 3.
    - [3]: product is 3, which is the product of distinct prime 3.

    Example 2:

    >>> numberOfGoodSubsets(nums = [4,2,3,15])
    >>> 5
    Explanation: The good subsets are:
    - [2]: product is 2, which is the product of distinct prime 2.
    - [2,3]: product is 6, which is the product of distinct primes 2 and 3.
    - [2,15]: product is 30, which is the product of distinct primes 2, 3, and 5.
    - [3]: product is 3, which is the product of distinct prime 3.
    - [15]: product is 15, which is the product of distinct primes 3 and 5.
    """


Prompt:
from typing import List
def countQuadruplets(nums: List[int]) -> int:
    """
    Given a 0-indexed integer array nums, return the number of distinct quadruplets (a, b, c, d) such that:

    nums[a] + nums[b] + nums[c] == nums[d], and
    a < b < c < d

    Example 1:

    >>> countQuadruplets(nums = [1,2,3,6])
    >>> 1
    Explanation: The only quadruplet that satisfies the requirement is (0, 1, 2, 3) because 1 + 2 + 3 == 6.

    Example 2:

    >>> countQuadruplets(nums = [3,3,6,4,5])
    >>> 0
    Explanation: There are no such quadruplets in [3,3,6,4,5].

    Example 3:

    >>> countQuadruplets(nums = [1,1,1,3,5])
    >>> 4
    Explanation: The 4 quadruplets that satisfy the requirement are:
    - (0, 1, 2, 3): 1 + 1 + 1 == 3
    - (0, 1, 3, 4): 1 + 1 + 3 == 5
    - (0, 2, 3, 4): 1 + 1 + 3 == 5
    - (1, 2, 3, 4): 1 + 1 + 3 == 5
    """


Prompt:
from typing import List
def numberOfWeakCharacters(properties: List[List[int]]) -> int:
    """
    You are playing a game that contains multiple characters, and each of the characters has two main properties: attack and defense. You are given a 2D integer array properties where properties[i] = [attacki, defensei] represents the properties of the ith character in the game.
    A character is said to be weak if any other character has both attack and defense levels strictly greater than this character's attack and defense levels. More formally, a character i is said to be weak if there exists another character j where attackj > attacki and defensej > defensei.
    Return the number of weak characters.

    Example 1:

    >>> numberOfWeakCharacters(properties = [[5,5],[6,3],[3,6]])
    >>> 0
    Explanation: No character has strictly greater attack and defense than the other.

    Example 2:

    >>> numberOfWeakCharacters(properties = [[2,2],[3,3]])
    >>> 1
    Explanation: The first character is weak because the second character has a strictly greater attack and defense.

    Example 3:

    >>> numberOfWeakCharacters(properties = [[1,5],[10,4],[4,3]])
    >>> 1
    Explanation: The third character is weak because the second character has a strictly greater attack and defense.
    """


Prompt:
from typing import List
def firstDayBeenInAllRooms(nextVisit: List[int]) -> int:
    """
    There are n rooms you need to visit, labeled from 0 to n - 1. Each day is labeled, starting from 0. You will go in and visit one room a day.
    Initially on day 0, you visit room 0. The order you visit the rooms for the coming days is determined by the following rules and a given 0-indexed array nextVisit of length n:

    Assuming that on a day, you visit room i,
    if you have been in room i an odd number of times (including the current visit), on the next day you will visit a room with a lower or equal room number specified by nextVisit[i] where 0 <= nextVisit[i] <= i;
    if you have been in room i an even number of times (including the current visit), on the next day you will visit room (i + 1) mod n.

    Return the label of the first day where you have been in all the rooms. It can be shown that such a day exists. Since the answer may be very large, return it modulo 109 + 7.

    Example 1:

    >>> firstDayBeenInAllRooms(nextVisit = [0,0])
    >>> 2
    Explanation:
    - On day 0, you visit room 0. The total times you have been in room 0 is 1, which is odd.
      On the next day you will visit room nextVisit[0] = 0
    - On day 1, you visit room 0, The total times you have been in room 0 is 2, which is even.
      On the next day you will visit room (0 + 1) mod 2 = 1
    - On day 2, you visit room 1. This is the first day where you have been in all the rooms.

    Example 2:

    >>> firstDayBeenInAllRooms(nextVisit = [0,0,2])
    >>> 6
    Explanation:
    Your room visiting order for each day is: [0,0,1,0,0,1,2,...].
    Day 6 is the first day where you have been in all the rooms.

    Example 3:

    >>> firstDayBeenInAllRooms(nextVisit = [0,1,2,0])
    >>> 6
    Explanation:
    Your room visiting order for each day is: [0,0,1,1,2,2,3,...].
    Day 6 is the first day where you have been in all the rooms.
    """


Prompt:
from typing import List
def gcdSort(nums: List[int]) -> bool:
    """
    You are given an integer array nums, and you can perform the following operation any number of times on nums:

    Swap the positions of two elements nums[i] and nums[j] if gcd(nums[i], nums[j]) > 1 where gcd(nums[i], nums[j]) is the greatest common divisor of nums[i] and nums[j].

    Return true if it is possible to sort nums in non-decreasing order using the above swap method, or false otherwise.

    Example 1:

    >>> gcdSort(nums = [7,21,3])
    >>> true
    Explanation: We can sort [7,21,3] by performing the following operations:
    - Swap 7 and 21 because gcd(7,21) = 7. nums = [21,7,3]
    - Swap 21 and 3 because gcd(21,3) = 3. nums = [3,7,21]

    Example 2:

    >>> gcdSort(nums = [5,2,6,2])
    >>> false
    Explanation: It is impossible to sort the array because 5 cannot be swapped with any other element.

    Example 3:

    >>> gcdSort(nums = [10,5,9,3,15])
    >>> true
    We can sort [10,5,9,3,15] by performing the following operations:
    - Swap 10 and 15 because gcd(10,15) = 5. nums = [15,5,9,3,10]
    - Swap 15 and 3 because gcd(15,3) = 3. nums = [3,5,9,15,10]
    - Swap 10 and 15 because gcd(10,15) = 5. nums = [3,5,9,10,15]
    """


Prompt:
def findInteger(k: int, digit1: int, digit2: int) -> int:
    """
    Given three integers, k, digit1, and digit2, you want to find the smallest integer that is:

    Larger than k,
    A multiple of k, and
    Comprised of only the digits digit1 and/or digit2.

    Return the smallest such integer. If no such integer exists or the integer exceeds the limit of a signed 32-bit integer (231 - 1), return -1.

    Example 1:

    >>> findInteger(k = 2, digit1 = 0, digit2 = 2)
    >>> 20
    Explanation:
    20 is the first integer larger than 2, a multiple of 2, and comprised of only the digits 0 and/or 2.

    Example 2:

    >>> findInteger(k = 3, digit1 = 4, digit2 = 2)
    >>> 24
    Explanation:
    24 is the first integer larger than 3, a multiple of 3, and comprised of only the digits 4 and/or 2.

    Example 3:

    >>> findInteger(k = 2, digit1 = 0, digit2 = 0)
    >>> -1
    Explanation:
    No integer meets the requirements so return -1.
    """


Prompt:
def reversePrefix(word: str, ch: str) -> str:
    """
    Given a 0-indexed string word and a character ch, reverse the segment of word that starts at index 0 and ends at the index of the first occurrence of ch (inclusive). If the character ch does not exist in word, do nothing.

    For example, if word = "abcdefd" and ch = "d", then you should reverse the segment that starts at 0 and ends at 3 (inclusive). The resulting string will be "dcbaefd".

    Return the resulting string.

    Example 1:

    >>> reversePrefix(word = "abcdefd", ch = "d")
    >>> "dcbaefd"
    Explanation: The first occurrence of "d" is at index 3.
    Reverse the part of word from 0 to 3 (inclusive), the resulting string is "dcbaefd".

    Example 2:

    >>> reversePrefix(word = "xyxzxe", ch = "z")
    >>> "zxyxxe"
    Explanation: The first and only occurrence of "z" is at index 3.
    Reverse the part of word from 0 to 3 (inclusive), the resulting string is "zxyxxe".

    Example 3:

    >>> reversePrefix(word = "abcd", ch = "z")
    >>> "abcd"
    Explanation: "z" does not exist in word.
    You should not do any reverse operation, the resulting string is "abcd".
    """


Prompt:
from typing import List
def interchangeableRectangles(rectangles: List[List[int]]) -> int:
    """
    You are given n rectangles represented by a 0-indexed 2D integer array rectangles, where rectangles[i] = [widthi, heighti] denotes the width and height of the ith rectangle.
    Two rectangles i and j (i < j) are considered interchangeable if they have the same width-to-height ratio. More formally, two rectangles are interchangeable if widthi/heighti == widthj/heightj (using decimal division, not integer division).
    Return the number of pairs of interchangeable rectangles in rectangles.

    Example 1:

    >>> interchangeableRectangles(rectangles = [[4,8],[3,6],[10,20],[15,30]])
    >>> 6
    Explanation: The following are the interchangeable pairs of rectangles by index (0-indexed):
    - Rectangle 0 with rectangle 1: 4/8 == 3/6.
    - Rectangle 0 with rectangle 2: 4/8 == 10/20.
    - Rectangle 0 with rectangle 3: 4/8 == 15/30.
    - Rectangle 1 with rectangle 2: 3/6 == 10/20.
    - Rectangle 1 with rectangle 3: 3/6 == 15/30.
    - Rectangle 2 with rectangle 3: 10/20 == 15/30.

    Example 2:

    >>> interchangeableRectangles(rectangles = [[4,5],[7,8]])
    >>> 0
    Explanation: There are no interchangeable pairs of rectangles.
    """


Prompt:
def maxProduct(s: str) -> int:
    """
    Given a string s, find two disjoint palindromic subsequences of s such that the product of their lengths is maximized. The two subsequences are disjoint if they do not both pick a character at the same index.
    Return the maximum possible product of the lengths of the two palindromic subsequences.
    A subsequence is a string that can be derived from another string by deleting some or no characters without changing the order of the remaining characters. A string is palindromic if it reads the same forward and backward.

    Example 1:

    >>> maxProduct(s = "leetcodecom")
    >>> 9
    Explanation: An optimal solution is to choose "ete" for the 1st subsequence and "cdc" for the 2nd subsequence.
    The product of their lengths is: 3 * 3 = 9.

    Example 2:

    >>> maxProduct(s = "bb")
    >>> 1
    Explanation: An optimal solution is to choose "b" (the first character) for the 1st subsequence and "b" (the second character) for the 2nd subsequence.
    The product of their lengths is: 1 * 1 = 1.

    Example 3:

    >>> maxProduct(s = "accbcaxxcxx")
    >>> 25
    Explanation: An optimal solution is to choose "accca" for the 1st subsequence and "xxcxx" for the 2nd subsequence.
    The product of their lengths is: 5 * 5 = 25.
    """


Prompt:
from typing import List
def smallestMissingValueSubtree(parents: List[int], nums: List[int]) -> List[int]:
    """
    There is a family tree rooted at 0 consisting of n nodes numbered 0 to n - 1. You are given a 0-indexed integer array parents, where parents[i] is the parent for node i. Since node 0 is the root, parents[0] == -1.
    There are 105 genetic values, each represented by an integer in the inclusive range [1, 105]. You are given a 0-indexed integer array nums, where nums[i] is a distinct genetic value for node i.
    Return an array ans of length n where ans[i] is the smallest genetic value that is missing from the subtree rooted at node i.
    The subtree rooted at a node x contains node x and all of its descendant nodes.

    Example 1:

    >>> smallestMissingValueSubtree(parents = [-1,0,0,2], nums = [1,2,3,4])
    >>> [5,1,1,1]
    Explanation: The answer for each subtree is calculated as follows:
    - 0: The subtree contains nodes [0,1,2,3] with values [1,2,3,4]. 5 is the smallest missing value.
    - 1: The subtree contains only node 1 with value 2. 1 is the smallest missing value.
    - 2: The subtree contains nodes [2,3] with values [3,4]. 1 is the smallest missing value.
    - 3: The subtree contains only node 3 with value 4. 1 is the smallest missing value.

    Example 2:

    >>> smallestMissingValueSubtree(parents = [-1,0,1,0,3,3], nums = [5,4,6,2,1,3])
    >>> [7,1,1,4,2,1]
    Explanation: The answer for each subtree is calculated as follows:
    - 0: The subtree contains nodes [0,1,2,3,4,5] with values [5,4,6,2,1,3]. 7 is the smallest missing value.
    - 1: The subtree contains nodes [1,2] with values [4,6]. 1 is the smallest missing value.
    - 2: The subtree contains only node 2 with value 6. 1 is the smallest missing value.
    - 3: The subtree contains nodes [3,4,5] with values [2,1,3]. 4 is the smallest missing value.
    - 4: The subtree contains only node 4 with value 1. 2 is the smallest missing value.
    - 5: The subtree contains only node 5 with value 3. 1 is the smallest missing value.

    Example 3:

    >>> smallestMissingValueSubtree(parents = [-1,2,3,0,2,4,1], nums = [2,3,4,5,6,7,8])
    >>> [1,1,1,1,1,1,1]
    Explanation: The value 1 is missing from all the subtrees.
    """


Prompt:
def findGameWinner(n: int) -> bool:
    """
    A Fibonacci tree is a binary tree created using the order function order(n):

    order(0) is the empty tree.
    order(1) is a binary tree with only one node.
    order(n) is a binary tree that consists of a root node with the left subtree as order(n - 2) and the right subtree as order(n - 1).

    Alice and Bob are playing a game with a Fibonacci tree with Alice staring first. On each turn, a player selects a node and removes that node and its subtree. The player that is forced to delete root loses.
    Given the integer n, return true if Alice wins the game or false if Bob wins, assuming both players play optimally.
    A subtree of a binary tree tree is a tree that consists of a node in tree and all of this node's descendants. The tree tree could also be considered as a subtree of itself.

    Example 1:

    >>> findGameWinner(n = 3)
    >>> true
    Explanation:
    Alice takes the node 1 in the right subtree.
    Bob takes either the 1 in the left subtree or the 2 in the right subtree.
    Alice takes whichever node Bob doesn't take.
    Bob is forced to take the root node 3, so Bob will lose.
    Return true because Alice wins.

    Example 2:

    >>> findGameWinner(n = 1)
    >>> false
    Explanation:
    Alice is forced to take the root node 1, so Alice will lose.
    Return false because Alice loses.

    Example 3:

    >>> findGameWinner(n = 2)
    >>> true
    Explanation:
    Alice takes the node 1.
    Bob is forced to take the root node 2, so Bob will lose.
    Return true because Alice wins.
    """


Prompt:
from typing import List
def countKDifference(nums: List[int], k: int) -> int:
    """
    Given an integer array nums and an integer k, return the number of pairs (i, j) where i < j such that |nums[i] - nums[j]| == k.
    The value of |x| is defined as:

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

    Example 1:

    >>> countKDifference(nums = [1,2,2,1], k = 1)
    >>> 4
    Explanation: The pairs with an absolute difference of 1 are:
    - [1,2,2,1]
    - [1,2,2,1]
    - [1,2,2,1]
    - [1,2,2,1]

    Example 2:

    >>> countKDifference(nums = [1,3], k = 3)
    >>> 0
    Explanation: There are no pairs with an absolute difference of 3.

    Example 3:

    >>> countKDifference(nums = [3,2,1,5,4], k = 2)
    >>> 3
    Explanation: The pairs with an absolute difference of 2 are:
    - [3,2,1,5,4]
    - [3,2,1,5,4]
    - [3,2,1,5,4]
    """


Prompt:
from typing import List
def findOriginalArray(changed: List[int]) -> List[int]:
    """
    An integer array original is transformed into a doubled array changed by appending twice the value of every element in original, and then randomly shuffling the resulting array.
    Given an array changed, return original if changed is a doubled array. If changed is not a doubled array, return an empty array. The elements in original may be returned in any order.

    Example 1:

    >>> findOriginalArray(changed = [1,3,4,2,6,8])
    >>> [1,3,4]
    Explanation: One possible original array could be [1,3,4]:
    - Twice the value of 1 is 1 * 2 = 2.
    - Twice the value of 3 is 3 * 2 = 6.
    - Twice the value of 4 is 4 * 2 = 8.
    Other original arrays could be [4,3,1] or [3,1,4].

    Example 2:

    >>> findOriginalArray(changed = [6,3,0,1])
    >>> []
    Explanation: changed is not a doubled array.

    Example 3:

    >>> findOriginalArray(changed = [1])
    >>> []
    Explanation: changed is not a doubled array.
    """


Prompt:
from typing import List
def maxTaxiEarnings(n: int, rides: List[List[int]]) -> int:
    """
    There are n points on a road you are driving your taxi on. The n points on the road are labeled from 1 to n in the direction you are going, and you want to drive from point 1 to point n to make money by picking up passengers. You cannot change the direction of the taxi.
    The passengers are represented by a 0-indexed 2D integer array rides, where rides[i] = [starti, endi, tipi] denotes the ith passenger requesting a ride from point starti to point endi who is willing to give a tipi dollar tip.
    For each passenger i you pick up, you earn endi - starti + tipi dollars. You may only drive at most one passenger at a time.
    Given n and rides, return the maximum number of dollars you can earn by picking up the passengers optimally.
    Note: You may drop off a passenger and pick up a different passenger at the same point.

    Example 1:

    >>> maxTaxiEarnings(n = 5, rides = [[2,5,4],[1,5,1]])
    >>> 7
    Explanation: We can pick up passenger 0 to earn 5 - 2 + 4 = 7 dollars.

    Example 2:

    >>> maxTaxiEarnings(n = 20, rides = [[1,6,1],[3,10,2],[10,12,3],[11,12,2],[12,15,2],[13,18,1]])
    >>> 20
    Explanation: We will pick up the following passengers:
    - Drive passenger 1 from point 3 to point 10 for a profit of 10 - 3 + 2 = 9 dollars.
    - Drive passenger 2 from point 10 to point 12 for a profit of 12 - 10 + 3 = 5 dollars.
    - Drive passenger 5 from point 13 to point 18 for a profit of 18 - 13 + 1 = 6 dollars.
    We earn 9 + 5 + 6 = 20 dollars in total.
    """


Prompt:
from typing import List
def minOperations(nums: List[int]) -> int:
    """
    You are given an integer array nums. In one operation, you can replace any element in nums with any integer.
    nums is considered continuous if both of the following conditions are fulfilled:

    All elements in nums are unique.
    The difference between the maximum element and the minimum element in nums equals nums.length - 1.

    For example, nums = [4, 2, 5, 3] is continuous, but nums = [1, 2, 3, 5, 6] is not continuous.
    Return the minimum number of operations to make nums continuous.

    Example 1:

    >>> minOperations(nums = [4,2,5,3])
    >>> 0
    Explanation: nums is already continuous.

    Example 2:

    >>> minOperations(nums = [1,2,3,5,6])
    >>> 1
    Explanation: One possible solution is to change the last element to 4.
    The resulting array is [1,2,3,5,4], which is continuous.

    Example 3:

    >>> minOperations(nums = [1,10,100,1000])
    >>> 3
    Explanation: One possible solution is to:
    - Change the second element to 2.
    - Change the third element to 3.
    - Change the fourth element to 4.
    The resulting array is [1,2,3,4], which is continuous.
    """


Prompt:
from typing import List
def finalValueAfterOperations(operations: List[str]) -> int:
    """
    There is a programming language with only four operations and one variable X:

    ++X and X++ increments the value of the variable X by 1.
    --X and X-- decrements the value of the variable X by 1.

    Initially, the value of X is 0.
    Given an array of strings operations containing a list of operations, return the final value of X after performing all the operations.

    Example 1:

    >>> finalValueAfterOperations(operations = ["--X","X++","X++"])
    >>> 1
    Explanation: The operations are performed as follows:
    Initially, X = 0.
    --X: X is decremented by 1, X =  0 - 1 = -1.
    X++: X is incremented by 1, X = -1 + 1 =  0.
    X++: X is incremented by 1, X =  0 + 1 =  1.

    Example 2:

    >>> finalValueAfterOperations(operations = ["++X","++X","X++"])
    >>> 3
    Explanation: The operations are performed as follows:
    Initially, X = 0.
    ++X: X is incremented by 1, X = 0 + 1 = 1.
    ++X: X is incremented by 1, X = 1 + 1 = 2.
    X++: X is incremented by 1, X = 2 + 1 = 3.

    Example 3:

    >>> finalValueAfterOperations(operations = ["X++","++X","--X","X--"])
    >>> 0
    Explanation: The operations are performed as follows:
    Initially, X = 0.
    X++: X is incremented by 1, X = 0 + 1 = 1.
    ++X: X is incremented by 1, X = 1 + 1 = 2.
    --X: X is decremented by 1, X = 2 - 1 = 1.
    X--: X is decremented by 1, X = 1 - 1 = 0.
    """


Prompt:
from typing import List
def sumOfBeauties(nums: List[int]) -> int:
    """
    You are given a 0-indexed integer array nums. For each index i (1 <= i <= nums.length - 2) the beauty of nums[i] equals:

    2, if nums[j] < nums[i] < nums[k], for all 0 <= j < i and for all i < k <= nums.length - 1.
    1, if nums[i - 1] < nums[i] < nums[i + 1], and the previous condition is not satisfied.
    0, if none of the previous conditions holds.

    Return the sum of beauty of all nums[i] where 1 <= i <= nums.length - 2.

    Example 1:

    >>> sumOfBeauties(nums = [1,2,3])
    >>> 2
    Explanation: For each index i in the range 1 <= i <= 1:
    - The beauty of nums[1] equals 2.

    Example 2:

    >>> sumOfBeauties(nums = [2,4,6,4])
    >>> 1
    Explanation: For each index i in the range 1 <= i <= 2:
    - The beauty of nums[1] equals 1.
    - The beauty of nums[2] equals 0.

    Example 3:

    >>> sumOfBeauties(nums = [3,2,1])
    >>> 0
    Explanation: For each index i in the range 1 <= i <= 1:
    - The beauty of nums[1] equals 0.
    """


Prompt:
def longestSubsequenceRepeatedK(s: str, k: int) -> str:
    """
    You are given a string s of length n, and an integer k. You are tasked to find the longest subsequence repeated k times in string s.
    A subsequence is a string that can be derived from another string by deleting some or no characters without changing the order of the remaining characters.
    A subsequence seq is repeated k times in the string s if seq * k is a subsequence of s, where seq * k represents a string constructed by concatenating seq k times.

    For example, "bba" is repeated 2 times in the string "bababcba", because the string "bbabba", constructed by concatenating "bba" 2 times, is a subsequence of the string "bababcba".

    Return the longest subsequence repeated k times in string s. If multiple such subsequences are found, return the lexicographically largest one. If there is no such subsequence, return an empty string.

    Example 1:

    >>> longestSubsequenceRepeatedK(s = "letsleetcode", k = 2)
    >>> "let"
    Explanation: There are two longest subsequences repeated 2 times: "let" and "ete".
    "let" is the lexicographically largest one.

    Example 2:

    >>> longestSubsequenceRepeatedK(s = "bb", k = 2)
    >>> "b"
    Explanation: The longest subsequence repeated 2 times is "b".

    Example 3:

    >>> longestSubsequenceRepeatedK(s = "ab", k = 2)
    >>> ""
    Explanation: There is no subsequence repeated 2 times. Empty string is returned.
    """


Prompt:
from typing import List
def averageHeightOfBuildings(buildings: List[List[int]]) -> List[List[int]]:
    """
    A perfectly straight street is represented by a number line. The street has building(s) on it and is represented by a 2D integer array buildings, where buildings[i] = [starti, endi, heighti]. This means that there is a building with heighti in the half-closed segment [starti, endi).
    You want to describe the heights of the buildings on the street with the minimum number of non-overlapping segments. The street can be represented by the 2D integer array street where street[j] = [leftj, rightj, averagej] describes a half-closed segment [leftj, rightj) of the road where the average heights of the buildings in the segment is averagej.

    For example, if buildings = [[1,5,2],[3,10,4]], the street could be represented by street = [[1,3,2],[3,5,3],[5,10,4]] because:

    From 1 to 3, there is only the first building with an average height of 2 / 1 = 2.
    From 3 to 5, both the first and the second building are there with an average height of (2+4) / 2 = 3.
    From 5 to 10, there is only the second building with an average height of 4 / 1 = 4.

    Given buildings, return the 2D integer array street as described above (excluding any areas of the street where there are no buldings). You may return the array in any order.
    The average of n elements is the sum of the n elements divided (integer division) by n.
    A half-closed segment [a, b) is the section of the number line between points a and b including point a and not including point b.

    Example 1:

    >>> averageHeightOfBuildings(buildings = [[1,4,2],[3,9,4]])
    >>> [[1,3,2],[3,4,3],[4,9,4]]
    Explanation:
    From 1 to 3, there is only the first building with an average height of 2 / 1 = 2.
    From 3 to 4, both the first and the second building are there with an average height of (2+4) / 2 = 3.
    From 4 to 9, there is only the second building with an average height of 4 / 1 = 4.

    Example 2:

    >>> averageHeightOfBuildings(buildings = [[1,3,2],[2,5,3],[2,8,3]])
    >>> [[1,3,2],[3,8,3]]
    Explanation:
    From 1 to 2, there is only the first building with an average height of 2 / 1 = 2.
    From 2 to 3, all three buildings are there with an average height of (2+3+3) / 3 = 2.
    From 3 to 5, both the second and the third building are there with an average height of (3+3) / 2 = 3.
    From 5 to 8, there is only the last building with an average height of 3 / 1 = 3.
    The average height from 1 to 3 is the same so we can group them into one segment.
    The average height from 3 to 8 is the same so we can group them into one segment.

    Example 3:

    >>> averageHeightOfBuildings(buildings = [[1,2,1],[5,6,1]])
    >>> [[1,2,1],[5,6,1]]
    Explanation:
    From 1 to 2, there is only the first building with an average height of 1 / 1 = 1.
    From 2 to 5, there are no buildings, so it is not included in the output.
    From 5 to 6, there is only the second building with an average height of 1 / 1 = 1.
    We cannot group the segments together because an empty space with no buildings seperates the segments.
    """


Prompt:
from typing import List
def maximumDifference(nums: List[int]) -> int:
    """
    Given a 0-indexed integer array nums of size n, find the maximum difference between nums[i] and nums[j] (i.e., nums[j] - nums[i]), such that 0 <= i < j < n and nums[i] < nums[j].
    Return the maximum difference. If no such i and j exists, return -1.

    Example 1:

    >>> maximumDifference(nums = [7,1,5,4])
    >>> 4
    Explanation:
    The maximum difference occurs with i = 1 and j = 2, nums[j] - nums[i] = 5 - 1 = 4.
    Note that with i = 1 and j = 0, the difference nums[j] - nums[i] = 7 - 1 = 6, but i > j, so it is not valid.

    Example 2:

    >>> maximumDifference(nums = [9,4,3,2])
    >>> -1
    Explanation:
    There is no i and j such that i < j and nums[i] < nums[j].

    Example 3:

    >>> maximumDifference(nums = [1,5,2,10])
    >>> 9
    Explanation:
    The maximum difference occurs with i = 0 and j = 3, nums[j] - nums[i] = 10 - 1 = 9.
    """


Prompt:
from typing import List
def gridGame(grid: List[List[int]]) -> int:
    """
    You are given a 0-indexed 2D array grid of size 2 x n, where grid[r][c] represents the number of points at position (r, c) on the matrix. Two robots are playing a game on this matrix.
    Both robots initially start at (0, 0) and want to reach (1, n-1). Each robot may only move to the right ((r, c) to (r, c + 1)) or down ((r, c) to (r + 1, c)).
    At the start of the game, the first robot moves from (0, 0) to (1, n-1), collecting all the points from the cells on its path. For all cells (r, c) traversed on the path, grid[r][c] is set to 0. Then, the second robot moves from (0, 0) to (1, n-1), collecting the points on its path. Note that their paths may intersect with one another.
    The first robot wants to minimize the number of points collected by the second robot. In contrast, the second robot wants to maximize the number of points it collects. If both robots play optimally, return the number of points collected by the second robot.

    Example 1:

    >>> gridGame(grid = [[2,5,4],[1,5,1]])
    >>> 4
    Explanation: The optimal path taken by the first robot is shown in red, and the optimal path taken by the second robot is shown in blue.
    The cells visited by the first robot are set to 0.
    The second robot will collect 0 + 0 + 4 + 0 = 4 points.

    Example 2:

    >>> gridGame(grid = [[3,3,1],[8,5,2]])
    >>> 4
    Explanation: The optimal path taken by the first robot is shown in red, and the optimal path taken by the second robot is shown in blue.
    The cells visited by the first robot are set to 0.
    The second robot will collect 0 + 3 + 1 + 0 = 4 points.

    Example 3:

    >>> gridGame(grid = [[1,3,1,15],[1,3,3,1]])
    >>> 7
    Explanation: The optimal path taken by the first robot is shown in red, and the optimal path taken by the second robot is shown in blue.
    The cells visited by the first robot are set to 0.
    The second robot will collect 0 + 1 + 3 + 3 + 0 = 7 points.
    """


Prompt:
from typing import List
def placeWordInCrossword(board: List[List[str]], word: str) -> bool:
    """
    You are given an m x n matrix board, representing the current state of a crossword puzzle. The crossword contains lowercase English letters (from solved words), ' ' to represent any empty cells, and '#' to represent any blocked cells.
    A word can be placed horizontally (left to right or right to left) or vertically (top to bottom or bottom to top) in the board if:

    It does not occupy a cell containing the character '#'.
    The cell each letter is placed in must either be ' ' (empty) or match the letter already on the board.
    There must not be any empty cells ' ' or other lowercase letters directly left or right of the word if the word was placed horizontally.
    There must not be any empty cells ' ' or other lowercase letters directly above or below the word if the word was placed vertically.

    Given a string word, return true if word can be placed in board, or false otherwise.

    Example 1:

    >>> placeWordInCrossword(board = [["#", " ", "#"], [" ", " ", "#"], ["#", "c", " "]], word = "abc")
    >>> true
    Explanation: The word "abc" can be placed as shown above (top to bottom).

    Example 2:

    >>> placeWordInCrossword(board = [[" ", "#", "a"], [" ", "#", "c"], [" ", "#", "a"]], word = "ac")
    >>> false
    Explanation: It is impossible to place the word because there will always be a space/letter above or below it.
    Example 3:

    >>> placeWordInCrossword(board = [["#", " ", "#"], [" ", " ", "#"], ["#", " ", "c"]], word = "ca")
    >>> true
    Explanation: The word "ca" can be placed as shown above (right to left).
    """


Prompt:
from typing import List
def scoreOfStudents(s: str, answers: List[int]) -> int:
    """
    You are given a string s that contains digits 0-9, addition symbols '+', and multiplication symbols '*' only, representing a valid math expression of single digit numbers (e.g., 3+5*2). This expression was given to n elementary school students. The students were instructed to get the answer of the expression by following this order of operations:

    Compute multiplication, reading from left to right; Then,
    Compute addition, reading from left to right.

    You are given an integer array answers of length n, which are the submitted answers of the students in no particular order. You are asked to grade the answers, by following these rules:

    If an answer equals the correct answer of the expression, this student will be rewarded 5 points;
    Otherwise, if the answer could be interpreted as if the student applied the operators in the wrong order but had correct arithmetic, this student will be rewarded 2 points;
    Otherwise, this student will be rewarded 0 points.

    Return the sum of the points of the students.

    Example 1:

    >>> scoreOfStudents(s = "7+3*1*2", answers = [20,13,42])
    >>> 7
    Explanation: As illustrated above, the correct answer of the expression is 13, therefore one student is rewarded 5 points: [20,13,42]
    A student might have applied the operators in this wrong order: ((7+3)*1)*2 = 20. Therefore one student is rewarded 2 points: [20,13,42]
    The points for the students are: [2,5,0]. The sum of the points is 2+5+0=7.

    Example 2:

    >>> scoreOfStudents(s = "3+5*2", answers = [13,0,10,13,13,16,16])
    >>> 19
    Explanation: The correct answer of the expression is 13, therefore three students are rewarded 5 points each: [13,0,10,13,13,16,16]
    A student might have applied the operators in this wrong order: ((3+5)*2 = 16. Therefore two students are rewarded 2 points: [13,0,10,13,13,16,16]
    The points for the students are: [5,0,0,5,5,2,2]. The sum of the points is 5+0+0+5+5+2+2=19.

    Example 3:

    >>> scoreOfStudents(s = "6+0*1", answers = [12,9,6,4,8,6])
    >>> 10
    Explanation: The correct answer of the expression is 6.
    If a student had incorrectly done (6+0)*1, the answer would also be 6.
    By the rules of grading, the students will still be rewarded 5 points (as they got the correct answer), not 2 points.
    The points for the students are: [0,0,5,0,0,5]. The sum of the points is 10.
    """


Prompt:
from typing import List
def brightestPosition(lights: List[List[int]]) -> int:
    """
    A perfectly straight street is represented by a number line. The street has street lamp(s) on it and is represented by a 2D integer array lights. Each lights[i] = [positioni, rangei] indicates that there is a street lamp at position positioni that lights up the area from [positioni - rangei, positioni + rangei] (inclusive).
    The brightness of a position p is defined as the number of street lamp that light up the position p.
    Given lights, return the brightest position on the street. If there are multiple brightest positions, return the smallest one.

    Example 1:

    >>> brightestPosition(lights = [[-3,2],[1,2],[3,3]])
    >>> -1
    Explanation:
    The first street lamp lights up the area from [(-3) - 2, (-3) + 2] = [-5, -1].
    The second street lamp lights up the area from [1 - 2, 1 + 2] = [-1, 3].
    The third street lamp lights up the area from [3 - 3, 3 + 3] = [0, 6].

    Position -1 has a brightness of 2, illuminated by the first and second street light.
    Positions 0, 1, 2, and 3 have a brightness of 2, illuminated by the second and third street light.
    Out of all these positions, -1 is the smallest, so return it.

    Example 2:

    >>> brightestPosition(lights = [[1,0],[0,1]])
    >>> 1
    Explanation:
    The first street lamp lights up the area from [1 - 0, 1 + 0] = [1, 1].
    The second street lamp lights up the area from [0 - 1, 0 + 1] = [-1, 1].

    Position 1 has a brightness of 2, illuminated by the first and second street light.
    Return 1 because it is the brightest position on the street.

    Example 3:

    >>> brightestPosition(lights = [[1,2]])
    >>> -1
    Explanation:
    The first street lamp lights up the area from [1 - 2, 1 + 2] = [-1, 3].

    Positions -1, 0, 1, 2, and 3 have a brightness of 1, illuminated by the first street light.
    Out of all these positions, -1 is the smallest, so return it.
    """


Prompt:
from typing import List
def construct2DArray(original: List[int], m: int, n: int) -> List[List[int]]:
    """
    You are given a 0-indexed 1-dimensional (1D) integer array original, and two integers, m and n. You are tasked with creating a 2-dimensional (2D) array with  m rows and n columns using all the elements from original.
    The elements from indices 0 to n - 1 (inclusive) of original should form the first row of the constructed 2D array, the elements from indices n to 2 * n - 1 (inclusive) should form the second row of the constructed 2D array, and so on.
    Return an m x n 2D array constructed according to the above procedure, or an empty 2D array if it is impossible.

    Example 1:

    >>> construct2DArray(original = [1,2,3,4], m = 2, n = 2)
    >>> [[1,2],[3,4]]
    Explanation: The constructed 2D array should contain 2 rows and 2 columns.
    The first group of n=2 elements in original, [1,2], becomes the first row in the constructed 2D array.
    The second group of n=2 elements in original, [3,4], becomes the second row in the constructed 2D array.

    Example 2:

    >>> construct2DArray(original = [1,2,3], m = 1, n = 3)
    >>> [[1,2,3]]
    Explanation: The constructed 2D array should contain 1 row and 3 columns.
    Put all three elements in original into the first row of the constructed 2D array.

    Example 3:

    >>> construct2DArray(original = [1,2], m = 1, n = 1)
    >>> []
    Explanation: There are 2 elements in original.
    It is impossible to fit 2 elements in a 1x1 2D array, so return an empty 2D array.
    """


Prompt:
from typing import List
def numOfPairs(nums: List[str], target: str) -> int:
    """
    Given an array of digit strings nums and a digit string target, return the number of pairs of indices (i, j) (where i != j) such that the concatenation of nums[i] + nums[j] equals target.

    Example 1:

    >>> numOfPairs(nums = ["777","7","77","77"], target = "7777")
    >>> 4
    Explanation: Valid pairs are:
    - (0, 1): "777" + "7"
    - (1, 0): "7" + "777"
    - (2, 3): "77" + "77"
    - (3, 2): "77" + "77"

    Example 2:

    >>> numOfPairs(nums = ["123","4","12","34"], target = "1234")
    >>> 2
    Explanation: Valid pairs are:
    - (0, 1): "123" + "4"
    - (2, 3): "12" + "34"

    Example 3:

    >>> numOfPairs(nums = ["1","1","1"], target = "11")
    >>> 6
    Explanation: Valid pairs are:
    - (0, 1): "1" + "1"
    - (1, 0): "1" + "1"
    - (0, 2): "1" + "1"
    - (2, 0): "1" + "1"
    - (1, 2): "1" + "1"
    - (2, 1): "1" + "1"
    """


Prompt:
def maxConsecutiveAnswers(answerKey: str, k: int) -> int:
    """
    A teacher is writing a test with n true/false questions, with 'T' denoting true and 'F' denoting false. He wants to confuse the students by maximizing the number of consecutive questions with the same answer (multiple trues or multiple falses in a row).
    You are given a string answerKey, where answerKey[i] is the original answer to the ith question. In addition, you are given an integer k, the maximum number of times you may perform the following operation:

    Change the answer key for any question to 'T' or 'F' (i.e., set answerKey[i] to 'T' or 'F').

    Return the maximum number of consecutive 'T's or 'F's in the answer key after performing the operation at most k times.

    Example 1:

    >>> maxConsecutiveAnswers(answerKey = "TTFF", k = 2)
    >>> 4
    Explanation: We can replace both the 'F's with 'T's to make answerKey = "TTTT".
    There are four consecutive 'T's.

    Example 2:

    >>> maxConsecutiveAnswers(answerKey = "TFFT", k = 1)
    >>> 3
    Explanation: We can replace the first 'T' with an 'F' to make answerKey = "FFFT".
    Alternatively, we can replace the second 'T' with an 'F' to make answerKey = "TFFF".
    In both cases, there are three consecutive 'F's.

    Example 3:

    >>> maxConsecutiveAnswers(answerKey = "TTFTTFTT", k = 1)
    >>> 5
    Explanation: We can replace the first 'F' to make answerKey = "TTTTTFTT"
    Alternatively, we can replace the second 'F' to make answerKey = "TTFTTTTT".
    In both cases, there are five consecutive 'T's.
    """


Prompt:
from typing import List
def waysToPartition(nums: List[int], k: int) -> int:
    """
    You are given a 0-indexed integer array nums of length n. The number of ways to partition nums is the number of pivot indices that satisfy both conditions:

    1 <= pivot < n
    nums[0] + nums[1] + ... + nums[pivot - 1] == nums[pivot] + nums[pivot + 1] + ... + nums[n - 1]

    You are also given an integer k. You can choose to change the value of one element of nums to k, or to leave the array unchanged.
    Return the maximum possible number of ways to partition nums to satisfy both conditions after changing at most one element.

    Example 1:

    >>> waysToPartition(nums = [2,-1,2], k = 3)
    >>> 1
    Explanation: One optimal approach is to change nums[0] to k. The array becomes [3,-1,2].
    There is one way to partition the array:
    - For pivot = 2, we have the partition [3,-1 | 2]: 3 + -1 == 2.

    Example 2:

    >>> waysToPartition(nums = [0,0,0], k = 1)
    >>> 2
    Explanation: The optimal approach is to leave the array unchanged.
    There are two ways to partition the array:
    - For pivot = 1, we have the partition [0 | 0,0]: 0 == 0 + 0.
    - For pivot = 2, we have the partition [0,0 | 0]: 0 + 0 == 0.

    Example 3:

    >>> waysToPartition(nums = [22,4,-25,-20,-15,15,-16,7,19,-10,0,-13,-14], k = -33)
    >>> 4
    Explanation: One optimal approach is to change nums[2] to k. The array becomes [22,4,-33,-20,-15,15,-16,7,19,-10,0,-13,-14].
    There are four ways to partition the array.
    """


Prompt:
def minimumMoves(s: str) -> int:
    """
    You are given a string s consisting of n characters which are either 'X' or 'O'.
    A move is defined as selecting three consecutive characters of s and converting them to 'O'. Note that if a move is applied to the character 'O', it will stay the same.
    Return the minimum number of moves required so that all the characters of s are converted to 'O'.

    Example 1:

    >>> minimumMoves(s = "XXX")
    >>> 1
    Explanation: XXX -> OOO
    We select all the 3 characters and convert them in one move.

    Example 2:

    >>> minimumMoves(s = "XXOX")
    >>> 2
    Explanation: XXOX -> OOOX -> OOOO
    We select the first 3 characters in the first move, and convert them to 'O'.
    Then we select the last 3 characters and convert them so that the final string contains all 'O's.
    Example 3:

    >>> minimumMoves(s = "OOOO")
    >>> 0
    Explanation: There are no 'X's in s to convert.
    """


Prompt:
from typing import List
def missingRolls(rolls: List[int], mean: int, n: int) -> List[int]:
    """
    You have observations of n + m 6-sided dice rolls with each face numbered from 1 to 6. n of the observations went missing, and you only have the observations of m rolls. Fortunately, you have also calculated the average value of the n + m rolls.
    You are given an integer array rolls of length m where rolls[i] is the value of the ith observation. You are also given the two integers mean and n.
    Return an array of length n containing the missing observations such that the average value of the n + m rolls is exactly mean. If there are multiple valid answers, return any of them. If no such array exists, return an empty array.
    The average value of a set of k numbers is the sum of the numbers divided by k.
    Note that mean is an integer, so the sum of the n + m rolls should be divisible by n + m.

    Example 1:

    >>> missingRolls(rolls = [3,2,4,3], mean = 4, n = 2)
    >>> [6,6]
    Explanation: The mean of all n + m rolls is (3 + 2 + 4 + 3 + 6 + 6) / 6 = 4.

    Example 2:

    >>> missingRolls(rolls = [1,5,6], mean = 3, n = 4)
    >>> [2,3,2,2]
    Explanation: The mean of all n + m rolls is (1 + 5 + 6 + 2 + 3 + 2 + 2) / 7 = 3.

    Example 3:

    >>> missingRolls(rolls = [1,2,3,4], mean = 6, n = 4)
    >>> []
    Explanation: It is impossible for the mean to be 6 no matter what the 4 missing rolls are.
    """


Prompt:
from typing import List
def stoneGameIX(stones: List[int]) -> bool:
    """
    Alice and Bob continue their games with stones. There is a row of n stones, and each stone has an associated value. You are given an integer array stones, where stones[i] is the value of the ith stone.
    Alice and Bob take turns, with Alice starting first. On each turn, the player may remove any stone from stones. The player who removes a stone loses if the sum of the values of all removed stones is divisible by 3. Bob will win automatically if there are no remaining stones (even if it is Alice's turn).
    Assuming both players play optimally, return true if Alice wins and false if Bob wins.

    Example 1:

    >>> stoneGameIX(stones = [2,1])
    >>> true
    Explanation: The game will be played as follows:
    - Turn 1: Alice can remove either stone.
    - Turn 2: Bob removes the remaining stone.
    The sum of the removed stones is 1 + 2 = 3 and is divisible by 3. Therefore, Bob loses and Alice wins the game.

    Example 2:

    >>> stoneGameIX(stones = [2])
    >>> false
    Explanation: Alice will remove the only stone, and the sum of the values on the removed stones is 2.
    Since all the stones are removed and the sum of values is not divisible by 3, Bob wins the game.

    Example 3:

    >>> stoneGameIX(stones = [5,1,2,4,3])
    >>> false
    Explanation: Bob will always win. One possible way for Bob to win is shown below:
    - Turn 1: Alice can remove the second stone with value 1. Sum of removed stones = 1.
    - Turn 2: Bob removes the fifth stone with value 3. Sum of removed stones = 1 + 3 = 4.
    - Turn 3: Alices removes the fourth stone with value 4. Sum of removed stones = 1 + 3 + 4 = 8.
    - Turn 4: Bob removes the third stone with value 2. Sum of removed stones = 1 + 3 + 4 + 2 = 10.
    - Turn 5: Alice removes the first stone with value 5. Sum of removed stones = 1 + 3 + 4 + 2 + 5 = 15.
    Alice loses the game because the sum of the removed stones (15) is divisible by 3. Bob wins the game.
    """


Prompt:
def smallestSubsequence(s: str, k: int, letter: str, repetition: int) -> str:
    """
    You are given a string s, an integer k, a letter letter, and an integer repetition.
    Return the lexicographically smallest subsequence of s of length k that has the letter letter appear at least repetition times. The test cases are generated so that the letter appears in s at least repetition times.
    A subsequence is a string that can be derived from another string by deleting some or no characters without changing the order of the remaining characters.
    A string a is lexicographically smaller than a string b if in the first position where a and b differ, string a has a letter that appears earlier in the alphabet than the corresponding letter in b.

    Example 1:

    >>> smallestSubsequence(s = "leet", k = 3, letter = "e", repetition = 1)
    >>> "eet"
    Explanation: There are four subsequences of length 3 that have the letter 'e' appear at least 1 time:
    - "lee" (from "leet")
    - "let" (from "leet")
    - "let" (from "leet")
    - "eet" (from "leet")
    The lexicographically smallest subsequence among them is "eet".

    Example 2:

    >>> smallestSubsequence(s = "leetcode", k = 4, letter = "e", repetition = 2)
    >>> "ecde"
    Explanation: "ecde" is the lexicographically smallest subsequence of length 4 that has the letter "e" appear at least 2 times.

    Example 3:

    >>> smallestSubsequence(s = "bb", k = 2, letter = "b", repetition = 2)
    >>> "bb"
    Explanation: "bb" is the only subsequence of length 2 that has the letter "b" appear at least 2 times.
    """


Prompt:
from typing import List
def subarraysWithMoreZerosThanOnes(nums: List[int]) -> int:
    """
    You are given a binary array nums containing only the integers 0 and 1. Return the number of subarrays in nums that have more 1's than 0's. Since the answer may be very large, return it modulo 109 + 7.
    A subarray is a contiguous sequence of elements within an array.

    Example 1:

    >>> subarraysWithMoreZerosThanOnes(nums = [0,1,1,0,1])
    >>> 9
    Explanation:
    The subarrays of size 1 that have more ones than zeros are: [1], [1], [1]
    The subarrays of size 2 that have more ones than zeros are: [1,1]
    The subarrays of size 3 that have more ones than zeros are: [0,1,1], [1,1,0], [1,0,1]
    The subarrays of size 4 that have more ones than zeros are: [1,1,0,1]
    The subarrays of size 5 that have more ones than zeros are: [0,1,1,0,1]

    Example 2:

    >>> subarraysWithMoreZerosThanOnes(nums = [0])
    >>> 0
    Explanation:
    No subarrays have more ones than zeros.

    Example 3:

    >>> subarraysWithMoreZerosThanOnes(nums = [1])
    >>> 1
    Explanation:
    The subarrays of size 1 that have more ones than zeros are: [1]
    """


Prompt:
from typing import List
def twoOutOfThree(nums1: List[int], nums2: List[int], nums3: List[int]) -> List[int]:
    """
    Given three integer arrays nums1, nums2, and nums3, return a distinct array containing all the values that are present in at least two out of the three arrays. You may return the values in any order.

    Example 1:

    >>> twoOutOfThree(nums1 = [1,1,3,2], nums2 = [2,3], nums3 = [3])
    >>> [3,2]
    Explanation: The values that are present in at least two arrays are:
    - 3, in all three arrays.
    - 2, in nums1 and nums2.

    Example 2:

    >>> twoOutOfThree(nums1 = [3,1], nums2 = [2,3], nums3 = [1,2])
    >>> [2,3,1]
    Explanation: The values that are present in at least two arrays are:
    - 2, in nums2 and nums3.
    - 3, in nums1 and nums2.
    - 1, in nums1 and nums3.

    Example 3:

    >>> twoOutOfThree(nums1 = [1,2,2], nums2 = [4,3,3], nums3 = [5])
    >>> []
    Explanation: No value is present in at least two arrays.
    """


Prompt:
from typing import List
def minOperations(grid: List[List[int]], x: int) -> int:
    """
    You are given a 2D integer grid of size m x n and an integer x. In one operation, you can add x to or subtract x from any element in the grid.
    A uni-value grid is a grid where all the elements of it are equal.
    Return the minimum number of operations to make the grid uni-value. If it is not possible, return -1.

    Example 1:

    >>> minOperations(grid = [[2,4],[6,8]], x = 2)
    >>> 4
    Explanation: We can make every element equal to 4 by doing the following:
    - Add x to 2 once.
    - Subtract x from 6 once.
    - Subtract x from 8 twice.
    A total of 4 operations were used.

    Example 2:

    >>> minOperations(grid = [[1,5],[2,3]], x = 1)
    >>> 5
    Explanation: We can make every element equal to 3.

    Example 3:

    >>> minOperations(grid = [[1,2],[3,4]], x = 2)
    >>> -1
    Explanation: It is impossible to make every element equal.
    """


Prompt:
from typing import List
def minimumDifference(nums: List[int]) -> int:
    """
    You are given an integer array nums of 2 * n integers. You need to partition nums into two arrays of length n to minimize the absolute difference of the sums of the arrays. To partition nums, put each element of nums into one of the two arrays.
    Return the minimum possible absolute difference.

    Example 1:

    >>> minimumDifference(nums = [3,9,7,3])
    >>> 2
    Explanation: One optimal partition is: [3,9] and [7,3].
    The absolute difference between the sums of the arrays is abs((3 + 9) - (7 + 3)) = 2.

    Example 2:

    >>> minimumDifference(nums = [-36,36])
    >>> 72
    Explanation: One optimal partition is: [-36] and [36].
    The absolute difference between the sums of the arrays is abs((-36) - (36)) = 72.

    Example 3:

    >>> minimumDifference(nums = [2,-1,0,4,-2,-9])
    >>> 0
    Explanation: One optimal partition is: [2,4,-9] and [-1,0,-2].
    The absolute difference between the sums of the arrays is abs((2 + 4 + -9) - (-1 + 0 + -2)) = 0.
    """


Prompt:
from typing import List
def maximumAlternatingSubarraySum(nums: List[int]) -> int:
    """
    A subarray of a 0-indexed integer array is a contiguous non-empty sequence of elements within an array.
    The alternating subarray sum of a subarray that ranges from index i to j (inclusive, 0 <= i <= j < nums.length) is nums[i] - nums[i+1] + nums[i+2] - ... +/- nums[j].
    Given a 0-indexed integer array nums, return the maximum alternating subarray sum of any subarray of nums.

    Example 1:

    >>> maximumAlternatingSubarraySum(nums = [3,-1,1,2])
    >>> 5
    Explanation:
    The subarray [3,-1,1] has the largest alternating subarray sum.
    The alternating subarray sum is 3 - (-1) + 1 = 5.

    Example 2:

    >>> maximumAlternatingSubarraySum(nums = [2,2,2,2,2])
    >>> 2
    Explanation:
    The subarrays [2], [2,2,2], and [2,2,2,2,2] have the largest alternating subarray sum.
    The alternating subarray sum of [2] is 2.
    The alternating subarray sum of [2,2,2] is 2 - 2 + 2 = 2.
    The alternating subarray sum of [2,2,2,2,2] is 2 - 2 + 2 - 2 + 2 = 2.

    Example 3:

    >>> maximumAlternatingSubarraySum(nums = [1])
    >>> 1
    Explanation:
    There is only one non-empty subarray, which is [1].
    The alternating subarray sum is 1.
    """


Prompt:
from typing import List
def minMovesToSeat(seats: List[int], students: List[int]) -> int:
    """
    There are n availabe seats and n students standing in a room. You are given an array seats of length n, where seats[i] is the position of the ith seat. You are also given the array students of length n, where students[j] is the position of the jth student.
    You may perform the following move any number of times:

    Increase or decrease the position of the ith student by 1 (i.e., moving the ith student from position x to x + 1 or x - 1)

    Return the minimum number of moves required to move each student to a seat such that no two students are in the same seat.
    Note that there may be multiple seats or students in the same position at the beginning.

    Example 1:

    >>> minMovesToSeat(seats = [3,1,5], students = [2,7,4])
    >>> 4
    Explanation: The students are moved as follows:
    - The first student is moved from position 2 to position 1 using 1 move.
    - The second student is moved from position 7 to position 5 using 2 moves.
    - The third student is moved from position 4 to position 3 using 1 move.
    In total, 1 + 2 + 1 = 4 moves were used.

    Example 2:

    >>> minMovesToSeat(seats = [4,1,5,9], students = [1,3,2,6])
    >>> 7
    Explanation: The students are moved as follows:
    - The first student is not moved.
    - The second student is moved from position 3 to position 4 using 1 move.
    - The third student is moved from position 2 to position 5 using 3 moves.
    - The fourth student is moved from position 6 to position 9 using 3 moves.
    In total, 0 + 1 + 3 + 3 = 7 moves were used.

    Example 3:

    >>> minMovesToSeat(seats = [2,2,6,6], students = [1,3,2,6])
    >>> 4
    Explanation: Note that there are two seats at position 2 and two seats at position 6.
    The students are moved as follows:
    - The first student is moved from position 1 to position 2 using 1 move.
    - The second student is moved from position 3 to position 6 using 3 moves.
    - The third student is not moved.
    - The fourth student is not moved.
    In total, 1 + 3 + 0 + 0 = 4 moves were used.
    """


Prompt:
def winnerOfGame(colors: str) -> bool:
    """
    There are n pieces arranged in a line, and each piece is colored either by 'A' or by 'B'. You are given a string colors of length n where colors[i] is the color of the ith piece.
    Alice and Bob are playing a game where they take alternating turns removing pieces from the line. In this game, Alice moves first.

    Alice is only allowed to remove a piece colored 'A' if both its neighbors are also colored 'A'. She is not allowed to remove pieces that are colored 'B'.
    Bob is only allowed to remove a piece colored 'B' if both its neighbors are also colored 'B'. He is not allowed to remove pieces that are colored 'A'.
    Alice and Bob cannot remove pieces from the edge of the line.
    If a player cannot make a move on their turn, that player loses and the other player wins.

    Assuming Alice and Bob play optimally, return true if Alice wins, or return false if Bob wins.

    Example 1:

    >>> winnerOfGame(colors = "AAABABB")
    >>> true
    Explanation:
    AAABABB -> AABABB
    Alice moves first.
    She removes the second 'A' from the left since that is the only 'A' whose neighbors are both 'A'.

    Now it's Bob's turn.
    Bob cannot make a move on his turn since there are no 'B's whose neighbors are both 'B'.
    Thus, Alice wins, so return true.

    Example 2:

    >>> winnerOfGame(colors = "AA")
    >>> false
    Explanation:
    Alice has her turn first.
    There are only two 'A's and both are on the edge of the line, so she cannot move on her turn.
    Thus, Bob wins, so return false.

    Example 3:

    >>> winnerOfGame(colors = "ABBBBBBBAAA")
    >>> false
    Explanation:
    ABBBBBBBAAA -> ABBBBBBBAA
    Alice moves first.
    Her only option is to remove the second to last 'A' from the right.

    ABBBBBBBAA -> ABBBBBBAA
    Next is Bob's turn.
    He has many options for which 'B' piece to remove. He can pick any.

    On Alice's second turn, she has no more pieces that she can remove.
    Thus, Bob wins, so return false.
    """


Prompt:
from typing import List
def networkBecomesIdle(edges: List[List[int]], patience: List[int]) -> int:
    """
    There is a network of n servers, labeled from 0 to n - 1. You are given a 2D integer array edges, where edges[i] = [ui, vi] indicates there is a message channel between servers ui and vi, and they can pass any number of messages to each other directly in one second. You are also given a 0-indexed integer array patience of length n.
    All servers are connected, i.e., a message can be passed from one server to any other server(s) directly or indirectly through the message channels.
    The server labeled 0 is the master server. The rest are data servers. Each data server needs to send its message to the master server for processing and wait for a reply. Messages move between servers optimally, so every message takes the least amount of time to arrive at the master server. The master server will process all newly arrived messages instantly and send a reply to the originating server via the reversed path the message had gone through.
    At the beginning of second 0, each data server sends its message to be processed. Starting from second 1, at the beginning of every second, each data server will check if it has received a reply to the message it sent (including any newly arrived replies) from the master server:

    If it has not, it will resend the message periodically. The data server i will resend the message every patience[i] second(s), i.e., the data server i will resend the message if patience[i] second(s) have elapsed since the last time the message was sent from this server.
    Otherwise, no more resending will occur from this server.

    The network becomes idle when there are no messages passing between servers or arriving at servers.
    Return the earliest second starting from which the network becomes idle.

    Example 1:

    >>> networkBecomesIdle(edges = [[0,1],[1,2]], patience = [0,2,1])
    >>> 8
    Explanation:
    At (the beginning of) second 0,
    - Data server 1 sends its message (denoted 1A) to the master server.
    - Data server 2 sends its message (denoted 2A) to the master server.

    At second 1,
    - Message 1A arrives at the master server. Master server processes message 1A instantly and sends a reply 1A back.
    - Server 1 has not received any reply. 1 second (1 < patience[1] = 2) elapsed since this server has sent the message, therefore it does not resend the message.
    - Server 2 has not received any reply. 1 second (1 == patience[2] = 1) elapsed since this server has sent the message, therefore it resends the message (denoted 2B).

    At second 2,
    - The reply 1A arrives at server 1. No more resending will occur from server 1.
    - Message 2A arrives at the master server. Master server processes message 2A instantly and sends a reply 2A back.
    - Server 2 resends the message (denoted 2C).
    ...
    At second 4,
    - The reply 2A arrives at server 2. No more resending will occur from server 2.
    ...
    At second 7, reply 2D arrives at server 2.

    Starting from the beginning of the second 8, there are no messages passing between servers or arriving at servers.
    This is the time when the network becomes idle.

    Example 2:

    >>> networkBecomesIdle(edges = [[0,1],[0,2],[1,2]], patience = [0,10,10])
    >>> 3
    Explanation: Data servers 1 and 2 receive a reply back at the beginning of second 2.
    From the beginning of the second 3, the network becomes idle.
    """


Prompt:
from typing import List
def kthSmallestProduct(nums1: List[int], nums2: List[int], k: int) -> int:
    """
    Given two sorted 0-indexed integer arrays nums1 and nums2 as well as an integer k, return the kth (1-based) smallest product of nums1[i] * nums2[j] where 0 <= i < nums1.length and 0 <= j < nums2.length.

    Example 1:

    >>> kthSmallestProduct(nums1 = [2,5], nums2 = [3,4], k = 2)
    >>> 8
    Explanation: The 2 smallest products are:
    - nums1[0] * nums2[0] = 2 * 3 = 6
    - nums1[0] * nums2[1] = 2 * 4 = 8
    The 2nd smallest product is 8.

    Example 2:

    >>> kthSmallestProduct(nums1 = [-4,-2,0,3], nums2 = [2,4], k = 6)
    >>> 0
    Explanation: The 6 smallest products are:
    - nums1[0] * nums2[1] = (-4) * 4 = -16
    - nums1[0] * nums2[0] = (-4) * 2 = -8
    - nums1[1] * nums2[1] = (-2) * 4 = -8
    - nums1[1] * nums2[0] = (-2) * 2 = -4
    - nums1[2] * nums2[0] = 0 * 2 = 0
    - nums1[2] * nums2[1] = 0 * 4 = 0
    The 6th smallest product is 0.

    Example 3:

    >>> kthSmallestProduct(nums1 = [-2,-1,0,1,2], nums2 = [-3,-1,2,4,5], k = 3)
    >>> -6
    Explanation: The 3 smallest products are:
    - nums1[0] * nums2[4] = (-2) * 5 = -10
    - nums1[0] * nums2[3] = (-2) * 4 = -8
    - nums1[4] * nums2[0] = 2 * (-3) = -6
    The 3rd smallest product is -6.
    """


Prompt:
def areNumbersAscending(s: str) -> bool:
    """
    A sentence is a list of tokens separated by a single space with no leading or trailing spaces. Every token is either a positive number consisting of digits 0-9 with no leading zeros, or a word consisting of lowercase English letters.

    For example, "a puppy has 2 eyes 4 legs" is a sentence with seven tokens: "2" and "4" are numbers and the other tokens such as "puppy" are words.

    Given a string s representing a sentence, you need to check if all the numbers in s are strictly increasing from left to right (i.e., other than the last number, each number is strictly smaller than the number on its right in s).
    Return true if so, or false otherwise.

    Example 1:

    >>> areNumbersAscending(s = "1 box has 3 blue 4 red 6 green and 12 yellow marbles")
    >>> true
    Explanation: The numbers in s are: 1, 3, 4, 6, 12.
    They are strictly increasing from left to right: 1 < 3 < 4 < 6 < 12.

    Example 2:

    >>> areNumbersAscending(s = "hello world 5 x 5")
    >>> false
    Explanation: The numbers in s are: 5, 5. They are not strictly increasing.

    Example 3:

    >>> areNumbersAscending(s = "sunset is at 7 51 pm overnight lows will be in the low 50 and 60 s")
    >>> false
    Explanation: The numbers in s are: 7, 51, 50, 60. They are not strictly increasing.
    """


Prompt:
from typing import List
def countMaxOrSubsets(nums: List[int]) -> int:
    """
    Given an integer array nums, find the maximum possible bitwise OR of a subset of nums and return the number of different non-empty subsets with the maximum bitwise OR.
    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. Two subsets are considered different if the indices of the elements chosen are different.
    The bitwise OR of an array a is equal to a[0] OR a[1] OR ... OR a[a.length - 1] (0-indexed).

    Example 1:

    >>> countMaxOrSubsets(nums = [3,1])
    >>> 2
    Explanation: The maximum possible bitwise OR of a subset is 3. There are 2 subsets with a bitwise OR of 3:
    - [3]
    - [3,1]

    Example 2:

    >>> countMaxOrSubsets(nums = [2,2,2])
    >>> 7
    Explanation: All non-empty subsets of [2,2,2] have a bitwise OR of 2. There are 23 - 1 = 7 total subsets.

    Example 3:

    >>> countMaxOrSubsets(nums = [3,2,1,5])
    >>> 6
    Explanation: The maximum possible bitwise OR of a subset is 7. There are 6 subsets with a bitwise OR of 7:
    - [3,5]
    - [3,1,5]
    - [3,2,5]
    - [3,2,1,5]
    - [2,5]
    - [2,1,5]
    """