Prompt:
def mergeTriplets(triplets: List[List[int]], target: List[int]) -> bool:
    """
    A triplet is an array of three integers. You are given a 2D integer array triplets, where triplets[i] = [ai, bi, ci] describes the ith triplet. You are also given an integer array target = [x, y, z] that describes the triplet you want to obtain.
    To obtain target, you may apply the following operation on triplets any number of times (possibly zero):

    Choose two indices (0-indexed) i and j (i != j) and update triplets[j] to become [max(ai, aj), max(bi, bj), max(ci, cj)].

    For example, if triplets[i] = [2, 5, 3] and triplets[j] = [1, 7, 5], triplets[j] will be updated to [max(2, 1), max(5, 7), max(3, 5)] = [2, 7, 5].

    Return true if it is possible to obtain the target triplet [x, y, z] as an element of triplets, or false otherwise.

    Example 1:

    >>> mergeTriplets(triplets = [[2,5,3],[1,8,4],[1,7,5]], target = [2,7,5])
    >>> true
    Explanation: Perform the following operations:
    - Choose the first and last triplets [[2,5,3],[1,8,4],[1,7,5]]. Update the last triplet to be [max(2,1), max(5,7), max(3,5)] = [2,7,5]. triplets = [[2,5,3],[1,8,4],[2,7,5]]
    The target triplet [2,7,5] is now an element of triplets.

    Example 2:

    >>> mergeTriplets(triplets = [[3,4,5],[4,5,6]], target = [3,2,5])
    >>> false
    Explanation: It is impossible to have [3,2,5] as an element because there is no 2 in any of the triplets.

    Example 3:

    >>> mergeTriplets(triplets = [[2,5,3],[2,3,4],[1,2,5],[5,2,3]], target = [5,5,5])
    >>> true
    Explanation: Perform the following operations:
    - Choose the first and third triplets [[2,5,3],[2,3,4],[1,2,5],[5,2,3]]. Update the third triplet to be [max(2,1), max(5,2), max(3,5)] = [2,5,5]. triplets = [[2,5,3],[2,3,4],[2,5,5],[5,2,3]].
    - Choose the third and fourth triplets [[2,5,3],[2,3,4],[2,5,5],[5,2,3]]. Update the fourth triplet to be [max(2,5), max(5,2), max(5,3)] = [5,5,5]. triplets = [[2,5,3],[2,3,4],[2,5,5],[5,5,5]].
    The target triplet [5,5,5] is now an element of triplets.
    """


Prompt:
def earliestAndLatest(n: int, firstPlayer: int, secondPlayer: int) -> List[int]:
    """
    There is a tournament where n players are participating. The players are standing in a single row and are numbered from 1 to n based on their initial standing position (player 1 is the first player in the row, player 2 is the second player in the row, etc.).
    The tournament consists of multiple rounds (starting from round number 1). In each round, the ith player from the front of the row competes against the ith player from the end of the row, and the winner advances to the next round. When the number of players is odd for the current round, the player in the middle automatically advances to the next round.

    For example, if the row consists of players 1, 2, 4, 6, 7

    Player 1 competes against player 7.
    Player 2 competes against player 6.
    Player 4 automatically advances to the next round.

    After each round is over, the winners are lined back up in the row based on the original ordering assigned to them initially (ascending order).
    The players numbered firstPlayer and secondPlayer are the best in the tournament. They can win against any other player before they compete against each other. If any two other players compete against each other, either of them might win, and thus you may choose the outcome of this round.
    Given the integers n, firstPlayer, and secondPlayer, return an integer array containing two values, the earliest possible round number and the latest possible round number in which these two players will compete against each other, respectively.

    Example 1:

    >>> earliestAndLatest(n = 11, firstPlayer = 2, secondPlayer = 4)
    >>> [3,4]
    Explanation:
    One possible scenario which leads to the earliest round number:
    First round: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
    Second round: 2, 3, 4, 5, 6, 11
    Third round: 2, 3, 4
    One possible scenario which leads to the latest round number:
    First round: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
    Second round: 1, 2, 3, 4, 5, 6
    Third round: 1, 2, 4
    Fourth round: 2, 4

    Example 2:

    >>> earliestAndLatest(n = 5, firstPlayer = 1, secondPlayer = 5)
    >>> [1,1]
    Explanation: The players numbered 1 and 5 compete in the first round.
    There is no way to make them compete in any other round.
    """


Prompt:
def findPeakGrid(mat: List[List[int]]) -> List[int]:
    """
    A peak element in a 2D grid is an element that is strictly greater than all of its adjacent neighbors to the left, right, top, and bottom.
    Given a 0-indexed m x n matrix mat where no two adjacent cells are equal, find any peak element mat[i][j] and return the length 2 array [i,j].
    You may assume that the entire matrix is surrounded by an outer perimeter with the value -1 in each cell.
    You must write an algorithm that runs in O(m log(n)) or O(n log(m)) time.

    Example 1:

    >>> findPeakGrid(mat = [[1,4],[3,2]])
    >>> [0,1]
    Explanation: Both 3 and 4 are peak elements so [1,0] and [0,1] are both acceptable answers.

    Example 2:

    >>> findPeakGrid(mat = [[10,20,15],[21,30,14],[7,16,32]])
    >>> [1,1]
    Explanation: Both 30 and 32 are peak elements so [1,1] and [2,2] are both acceptable answers.
    """


Prompt:
def maxDepthBST(order: List[int]) -> int:
    """
    You are given a 0-indexed integer array order of length n, a permutation of integers from 1 to n representing the order of insertion into a binary search tree.
    A binary search tree is defined as follows:

    The left subtree of a node contains only nodes with keys less than the node's key.
    The right subtree of a node contains only nodes with keys greater than the node's key.
    Both the left and right subtrees must also be binary search trees.

    The binary search tree is constructed as follows:

    order[0] will be the root of the binary search tree.
    All subsequent elements are inserted as the child of any existing node such that the binary search tree properties hold.

    Return the depth of the binary search tree.
    A binary tree's depth is the number of nodes along the longest path from the root node down to the farthest leaf node.

    Example 1:

    >>> maxDepthBST(order = [2,1,4,3])
    >>> 3
    Explanation: The binary search tree has a depth of 3 with path 2->3->4.

    Example 2:

    >>> maxDepthBST(order = [2,1,3,4])
    >>> 3
    Explanation: The binary search tree has a depth of 3 with path 2->3->4.

    Example 3:

    >>> maxDepthBST(order = [1,2,3,4])
    >>> 4
    Explanation: The binary search tree has a depth of 4 with path 1->2->3->4.
    """


Prompt:
def largestOddNumber(num: str) -> str:
    """
    You are given a string num, representing a large integer. Return the largest-valued odd integer (as a string) that is a non-empty substring of num, or an empty string "" if no odd integer exists.
    A substring is a contiguous sequence of characters within a string.

    Example 1:

    >>> largestOddNumber(num = "52")
    >>> "5"
    Explanation: The only non-empty substrings are "5", "2", and "52". "5" is the only odd number.

    Example 2:

    >>> largestOddNumber(num = "4206")
    >>> ""
    Explanation: There are no odd numbers in "4206".

    Example 3:

    >>> largestOddNumber(num = "35427")
    >>> "35427"
    Explanation: "35427" is already an odd number.
    """


Prompt:
def numberOfRounds(loginTime: str, logoutTime: str) -> int:
    """
    You are participating in an online chess tournament. There is a chess round that starts every 15 minutes. The first round of the day starts at 00:00, and after every 15 minutes, a new round starts.

    For example, the second round starts at 00:15, the fourth round starts at 00:45, and the seventh round starts at 01:30.

    You are given two strings loginTime and logoutTime where:

    loginTime is the time you will login to the game, and
    logoutTime is the time you will logout from the game.

    If logoutTime is earlier than loginTime, this means you have played from loginTime to midnight and from midnight to logoutTime.
    Return the number of full chess rounds you have played in the tournament.
    Note: All the given times follow the 24-hour clock. That means the first round of the day starts at 00:00 and the last round of the day starts at 23:45.

    Example 1:

    >>> numberOfRounds(loginTime = "09:31", logoutTime = "10:14")
    >>> 1
    Explanation: You played one full round from 09:45 to 10:00.
    You did not play the full round from 09:30 to 09:45 because you logged in at 09:31 after it began.
    You did not play the full round from 10:00 to 10:15 because you logged out at 10:14 before it ended.

    Example 2:

    >>> numberOfRounds(loginTime = "21:30", logoutTime = "03:00")
    >>> 22
    Explanation: You played 10 full rounds from 21:30 to 00:00 and 12 full rounds from 00:00 to 03:00.
    10 + 12 = 22.
    """


Prompt:
def countSubIslands(grid1: List[List[int]], grid2: List[List[int]]) -> int:
    """
    You are given two m x n binary matrices grid1 and grid2 containing only 0's (representing water) and 1's (representing land). An island is a group of 1's connected 4-directionally (horizontal or vertical). Any cells outside of the grid are considered water cells.
    An island in grid2 is considered a sub-island if there is an island in grid1 that contains all the cells that make up this island in grid2.
    Return the number of islands in grid2 that are considered sub-islands.

    Example 1:

    >>> countSubIslands(grid1 = [[1,1,1,0,0],[0,1,1,1,1],[0,0,0,0,0],[1,0,0,0,0],[1,1,0,1,1]], grid2 = [[1,1,1,0,0],[0,0,1,1,1],[0,1,0,0,0],[1,0,1,1,0],[0,1,0,1,0]])
    >>> 3
    Explanation: In the picture above, the grid on the left is grid1 and the grid on the right is grid2.
    The 1s colored red in grid2 are those considered to be part of a sub-island. There are three sub-islands.

    Example 2:

    >>> countSubIslands(grid1 = [[1,0,1,0,1],[1,1,1,1,1],[0,0,0,0,0],[1,1,1,1,1],[1,0,1,0,1]], grid2 = [[0,0,0,0,0],[1,1,1,1,1],[0,1,0,1,0],[0,1,0,1,0],[1,0,0,0,1]])
    >>> 2
    Explanation: In the picture above, the grid on the left is grid1 and the grid on the right is grid2.
    The 1s colored red in grid2 are those considered to be part of a sub-island. There are two sub-islands.
    """


Prompt:
def minDifference(nums: List[int], queries: List[List[int]]) -> List[int]:
    """
    The minimum absolute difference of an array a is defined as the minimum value of |a[i] - a[j]|, where 0 <= i < j < a.length and a[i] != a[j]. If all elements of a are the same, the minimum absolute difference is -1.

    For example, the minimum absolute difference of the array [5,2,3,7,2] is |2 - 3| = 1. Note that it is not 0 because a[i] and a[j] must be different.

    You are given an integer array nums and the array queries where queries[i] = [li, ri]. For each query i, compute the minimum absolute difference of the subarray nums[li...ri] containing the elements of nums between the 0-based indices li and ri (inclusive).
    Return an array ans where ans[i] is the answer to the ith query.
    A subarray is a contiguous sequence of elements in an array.
    The value of |x| is defined as:

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

    Example 1:

    >>> minDifference(nums = [1,3,4,8], queries = [[0,1],[1,2],[2,3],[0,3]])
    >>> [2,1,4,1]
    Explanation: The queries are processed as follows:
    - queries[0] = [0,1]: The subarray is [1,3] and the minimum absolute difference is |1-3| = 2.
    - queries[1] = [1,2]: The subarray is [3,4] and the minimum absolute difference is |3-4| = 1.
    - queries[2] = [2,3]: The subarray is [4,8] and the minimum absolute difference is |4-8| = 4.
    - queries[3] = [0,3]: The subarray is [1,3,4,8] and the minimum absolute difference is |3-4| = 1.

    Example 2:

    >>> minDifference(nums = [4,5,2,2,7,10], queries = [[2,3],[0,2],[0,5],[3,5]])
    >>> [-1,1,1,3]
    Explanation: The queries are processed as follows:
    - queries[0] = [2,3]: The subarray is [2,2] and the minimum absolute difference is -1 because all the
      elements are the same.
    - queries[1] = [0,2]: The subarray is [4,5,2] and the minimum absolute difference is |4-5| = 1.
    - queries[2] = [0,5]: The subarray is [4,5,2,2,7,10] and the minimum absolute difference is |4-5| = 1.
    - queries[3] = [3,5]: The subarray is [2,7,10] and the minimum absolute difference is |7-10| = 3.
    """


Prompt:
def nimGame(piles: List[int]) -> bool:
    """
    Alice and Bob take turns playing a game with Alice starting first.
    In this game, there are n piles of stones. On each player's turn, the player should remove any positive number of stones from a non-empty pile of his or her choice. The first player who cannot make a move loses, and the other player wins.
    Given an integer array piles, where piles[i] is the number of stones in the ith pile, return true if Alice wins, or false if Bob wins.
    Both Alice and Bob play optimally.

    Example 1:

    >>> nimGame(piles = [1])
    >>> true
    Explanation: There is only one possible scenario:
    - On the first turn, Alice removes one stone from the first pile. piles = [0].
    - On the second turn, there are no stones left for Bob to remove. Alice wins.

    Example 2:

    >>> nimGame(piles = [1,1])
    >>> false
    Explanation: It can be proven that Bob will always win. One possible scenario is:
    - On the first turn, Alice removes one stone from the first pile. piles = [0,1].
    - On the second turn, Bob removes one stone from the second pile. piles = [0,0].
    - On the third turn, there are no stones left for Alice to remove. Bob wins.

    Example 3:

    >>> nimGame(piles = [1,2,3])
    >>> false
    Explanation: It can be proven that Bob will always win. One possible scenario is:
    - On the first turn, Alice removes three stones from the third pile. piles = [1,2,0].
    - On the second turn, Bob removes one stone from the second pile. piles = [1,1,0].
    - On the third turn, Alice removes one stone from the first pile. piles = [0,1,0].
    - On the fourth turn, Bob removes one stone from the second pile. piles = [0,0,0].
    - On the fifth turn, there are no stones left for Alice to remove. Bob wins.
    """


Prompt:
def canBeIncreasing(nums: List[int]) -> bool:
    """
    Given a 0-indexed integer array nums, return true if it can be made strictly increasing after removing exactly one element, or false otherwise. If the array is already strictly increasing, return true.
    The array nums is strictly increasing if nums[i - 1] < nums[i] for each index (1 <= i < nums.length).

    Example 1:

    >>> canBeIncreasing(nums = [1,2,10,5,7])
    >>> true
    Explanation: By removing 10 at index 2 from nums, it becomes [1,2,5,7].
    [1,2,5,7] is strictly increasing, so return true.

    Example 2:

    >>> canBeIncreasing(nums = [2,3,1,2])
    >>> false
    Explanation:
    [3,1,2] is the result of removing the element at index 0.
    [2,1,2] is the result of removing the element at index 1.
    [2,3,2] is the result of removing the element at index 2.
    [2,3,1] is the result of removing the element at index 3.
    No resulting array is strictly increasing, so return false.
    Example 3:

    >>> canBeIncreasing(nums = [1,1,1])
    >>> false
    Explanation: The result of removing any element is [1,1].
    [1,1] is not strictly increasing, so return false.
    """


Prompt:
def removeOccurrences(s: str, part: str) -> str:
    """
    Given two strings s and part, perform the following operation on s until all occurrences of the substring part are removed:

    Find the leftmost occurrence of the substring part and remove it from s.

    Return s after removing all occurrences of part.
    A substring is a contiguous sequence of characters in a string.

    Example 1:

    >>> removeOccurrences(s = "daabcbaabcbc", part = "abc")
    >>> "dab"
    Explanation: The following operations are done:
    - s = "daabcbaabcbc", remove "abc" starting at index 2, so s = "dabaabcbc".
    - s = "dabaabcbc", remove "abc" starting at index 4, so s = "dababc".
    - s = "dababc", remove "abc" starting at index 3, so s = "dab".
    Now s has no occurrences of "abc".

    Example 2:

    >>> removeOccurrences(s = "axxxxyyyyb", part = "xy")
    >>> "ab"
    Explanation: The following operations are done:
    - s = "axxxxyyyyb", remove "xy" starting at index 4 so s = "axxxyyyb".
    - s = "axxxyyyb", remove "xy" starting at index 3 so s = "axxyyb".
    - s = "axxyyb", remove "xy" starting at index 2 so s = "axyb".
    - s = "axyb", remove "xy" starting at index 1 so s = "ab".
    Now s has no occurrences of "xy".
    """


Prompt:
def maxAlternatingSum(nums: List[int]) -> int:
    """
    The alternating sum of a 0-indexed array is defined as the sum of the elements at even indices minus the sum of the elements at odd indices.\r
    \r
    \r
    	For example, the alternating sum of [4,2,5,3] is (4 + 5) - (2 + 3) = 4.\r
    \r
    \r
    Given an array nums, return the maximum alternating sum of any subsequence of nums (after reindexing the elements of the subsequence).\r
    \r
    \r
    \r
    \r
    A subsequence of an array is a new array generated from the original array by deleting some elements (possibly none) without changing the remaining elements' relative order. For example, [2,7,4] is a subsequence of [4,2,3,7,2,1,4] (the underlined elements), while [2,4,2] is not.\r
    \r
     \r
    Example 1:\r
    \r
    \r
    >>> maxAlternatingSum(nums = [4,2,5,3]\r)
    >>> 7\r
    Explanation: It is optimal to choose the subsequence [4,2,5] with alternating sum (4 + 5) - 2 = 7.\r
    \r
    \r
    Example 2:\r
    \r
    \r
    >>> maxAlternatingSum(nums = [5,6,7,8]\r)
    >>> 8\r
    Explanation: It is optimal to choose the subsequence [8] with alternating sum 8.\r
    \r
    \r
    Example 3:\r
    \r
    \r
    >>> maxAlternatingSum(nums = [6,2,1,2,4,5]\r)
    >>> 10\r
    Explanation: It is optimal to choose the subsequence [6,1,5] with alternating sum (6 + 5) - 1 = 10.\r
    \r
    \r
     \r
    """


Prompt:
def maxProductDifference(nums: List[int]) -> int:
    """
    The product difference between two pairs (a, b) and (c, d) is defined as (a * b) - (c * d).\r
    \r
    \r
    	For example, the product difference between (5, 6) and (2, 7) is (5 * 6) - (2 * 7) = 16.\r
    \r
    \r
    Given an integer array nums, choose four distinct indices w, x, y, and z such that the product difference between pairs (nums[w], nums[x]) and (nums[y], nums[z]) is maximized.\r
    \r
    Return the maximum such product difference.\r
    \r
     \r
    Example 1:\r
    \r
    \r
    >>> maxProductDifference(nums = [5,6,2,7,4]\r)
    >>> 34\r
    Explanation: We can choose indices 1 and 3 for the first pair (6, 7) and indices 2 and 4 for the second pair (2, 4).\r
    The product difference is (6 * 7) - (2 * 4) = 34.\r
    \r
    \r
    Example 2:\r
    \r
    \r
    >>> maxProductDifference(nums = [4,2,5,9,7,4,8]\r)
    >>> 64\r
    Explanation: We can choose indices 3 and 6 for the first pair (9, 8) and indices 1 and 5 for the second pair (2, 4).\r
    The product difference is (9 * 8) - (2 * 4) = 64.\r
    \r
    \r
     \r
    """


Prompt:
def rotateGrid(grid: List[List[int]], k: int) -> List[List[int]]:
    """
    You are given an m x n integer matrix grid, where m and n are both even integers, and an integer k.\r
    \r
    The matrix is composed of several layers, which is shown in the below image, where each color is its own layer:\r
    \r
    \r
    \r
    A cyclic rotation of the matrix is done by cyclically rotating each layer in the matrix. To cyclically rotate a layer once, each element in the layer will take the place of the adjacent element in the counter-clockwise direction. An example rotation is shown below:\r
    \r
    Return the matrix after applying k cyclic rotations to it.\r
    \r
     \r
    Example 1:\r
    \r
    \r
    >>> rotateGrid(grid = [[40,10],[30,20]], k = 1\r)
    >>> [[10,20],[40,30]]\r
    Explanation: The figures above represent the grid at every state.\r
    \r
    \r
    Example 2:\r
      \r
    \r
    \r
    >>> rotateGrid(grid = [[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,16]], k = 2\r)
    >>> [[3,4,8,12],[2,11,10,16],[1,7,6,15],[5,9,13,14]]\r
    Explanation: The figures above represent the grid at every state.\r
    \r
    \r
     \r
    """


Prompt:
def wonderfulSubstrings(word: str) -> int:
    """
    A wonderful string is a string where at most one letter appears an odd number of times.\r
    \r
    \r
    	For example, "ccjjc" and "abab" are wonderful, but "ab" is not.\r
    \r
    \r
    Given a string word that consists of the first ten lowercase English letters ('a' through 'j'), return the number of wonderful non-empty substrings in word. If the same substring appears multiple times in word, then count each occurrence separately.\r
    \r
    A substring is a contiguous sequence of characters in a string.\r
    \r
     \r
    Example 1:\r
    \r
    \r
    >>> wonderfulSubstrings(word = "aba"\r)
    >>> 4\r
    Explanation: The four wonderful substrings are underlined below:\r
    - "aba" -> "a"\r
    - "aba" -> "b"\r
    - "aba" -> "a"\r
    - "aba" -> "aba"\r
    \r
    \r
    Example 2:\r
    \r
    \r
    >>> wonderfulSubstrings(word = "aabb"\r)
    >>> 9\r
    Explanation: The nine wonderful substrings are underlined below:\r
    - "aabb" -> "a"\r
    - "aabb" -> "aa"\r
    - "aabb" -> "aab"\r
    - "aabb" -> "aabb"\r
    - "aabb" -> "a"\r
    - "aabb" -> "abb"\r
    - "aabb" -> "b"\r
    - "aabb" -> "bb"\r
    - "aabb" -> "b"\r
    \r
    \r
    Example 3:\r
    \r
    \r
    >>> wonderfulSubstrings(word = "he"\r)
    >>> 2\r
    Explanation: The two wonderful substrings are underlined below:\r
    - "he" -> "h"\r
    - "he" -> "e"\r
    \r
    \r
     \r
    """


Prompt:
def waysToBuildRooms(prevRoom: List[int]) -> int:
    """
    You are an ant tasked with adding n new rooms numbered 0 to n-1 to your colony. You are given the expansion plan as a 0-indexed integer array of length n, prevRoom, where prevRoom[i] indicates that you must build room prevRoom[i] before building room i, and these two rooms must be connected directly. Room 0 is already built, so prevRoom[0] = -1. The expansion plan is given such that once all the rooms are built, every room will be reachable from room 0.\r
    \r
    You can only build one room at a time, and you can travel freely between rooms you have already built only if they are connected. You can choose to build any room as long as its previous room is already built.\r
    \r
    Return the number of different orders you can build all the rooms in. Since the answer may be large, return it modulo 109 + 7.\r
    \r
     \r
    Example 1:\r
    \r
    \r
    >>> waysToBuildRooms(prevRoom = [-1,0,1]\r)
    >>> 1\r
    Explanation: There is only one way to build the additional rooms: 0 → 1 → 2\r
    \r
    \r
    Example 2:\r
    \r
    \r
    \r
    >>> waysToBuildRooms(prevRoom = [-1,0,0,1,2]\r)
    >>> 6\r
    Explanation:\r
    The 6 ways are:\r
    0 → 1 → 3 → 2 → 4\r
    0 → 2 → 4 → 1 → 3\r
    0 → 1 → 2 → 3 → 4\r
    0 → 1 → 2 → 4 → 3\r
    0 → 2 → 1 → 3 → 4\r
    0 → 2 → 1 → 4 → 3\r
    \r
    \r
     \r
    """


Prompt:
def kthSmallestSubarraySum(nums: List[int], k: int) -> int:
    """
    Given an integer array nums of length n and an integer k, return the kth smallest subarray sum.
    A subarray is defined as a non-empty contiguous sequence of elements in an array. A subarray sum is the sum of all elements in the subarray.

    Example 1:

    >>> kthSmallestSubarraySum(nums = [2,1,3], k = 4)
    >>> 3
    Explanation: The subarrays of [2,1,3] are:
    - [2] with sum 2
    - [1] with sum 1
    - [3] with sum 3
    - [2,1] with sum 3
    - [1,3] with sum 4
    - [2,1,3] with sum 6
    Ordering the sums from smallest to largest gives 1, 2, 3, 3, 4, 6. The 4th smallest is 3.

    Example 2:

    >>> kthSmallestSubarraySum(nums = [3,3,5,5], k = 7)
    >>> 10
    Explanation: The subarrays of [3,3,5,5] are:
    - [3] with sum 3
    - [3] with sum 3
    - [5] with sum 5
    - [5] with sum 5
    - [3,3] with sum 6
    - [3,5] with sum 8
    - [5,5] with sum 10
    - [3,3,5], with sum 11
    - [3,5,5] with sum 13
    - [3,3,5,5] with sum 16
    Ordering the sums from smallest to largest gives 3, 3, 5, 5, 6, 8, 10, 11, 13, 16. The 7th smallest is 10.
    """


Prompt:
def buildArray(nums: List[int]) -> List[int]:
    """
    Given a zero-based permutation nums (0-indexed), build an array ans of the same length where ans[i] = nums[nums[i]] for each 0 <= i < nums.length and return it.
    A zero-based permutation nums is an array of distinct integers from 0 to nums.length - 1 (inclusive).

    Example 1:

    >>> buildArray(nums = [0,2,1,5,3,4])
    >>> [0,1,2,4,5,3]
    Explanation: The array ans is built as follows:
    ans = [nums[nums[0]], nums[nums[1]], nums[nums[2]], nums[nums[3]], nums[nums[4]], nums[nums[5]]]
        = [nums[0], nums[2], nums[1], nums[5], nums[3], nums[4]]
        = [0,1,2,4,5,3]
    Example 2:

    >>> buildArray(nums = [5,0,1,2,3,4])
    >>> [4,5,0,1,2,3]
    Explanation: The array ans is built as follows:
    ans = [nums[nums[0]], nums[nums[1]], nums[nums[2]], nums[nums[3]], nums[nums[4]], nums[nums[5]]]
        = [nums[5], nums[0], nums[1], nums[2], nums[3], nums[4]]
        = [4,5,0,1,2,3]
    """


Prompt:
def eliminateMaximum(dist: List[int], speed: List[int]) -> int:
    """
    You are playing a video game where you are defending your city from a group of n monsters. You are given a 0-indexed integer array dist of size n, where dist[i] is the initial distance in kilometers of the ith monster from the city.
    The monsters walk toward the city at a constant speed. The speed of each monster is given to you in an integer array speed of size n, where speed[i] is the speed of the ith monster in kilometers per minute.
    You have a weapon that, once fully charged, can eliminate a single monster. However, the weapon takes one minute to charge. The weapon is fully charged at the very start.
    You lose when any monster reaches your city. If a monster reaches the city at the exact moment the weapon is fully charged, it counts as a loss, and the game ends before you can use your weapon.
    Return the maximum number of monsters that you can eliminate before you lose, or n if you can eliminate all the monsters before they reach the city.

    Example 1:

    >>> eliminateMaximum(dist = [1,3,4], speed = [1,1,1])
    >>> 3
    Explanation:
    In the beginning, the distances of the monsters are [1,3,4]. You eliminate the first monster.
    After a minute, the distances of the monsters are [X,2,3]. You eliminate the second monster.
    After a minute, the distances of the monsters are [X,X,2]. You eliminate the third monster.
    All 3 monsters can be eliminated.
    Example 2:

    >>> eliminateMaximum(dist = [1,1,2,3], speed = [1,1,1,1])
    >>> 1
    Explanation:
    In the beginning, the distances of the monsters are [1,1,2,3]. You eliminate the first monster.
    After a minute, the distances of the monsters are [X,0,1,2], so you lose.
    You can only eliminate 1 monster.

    Example 3:

    >>> eliminateMaximum(dist = [3,2,4], speed = [5,3,2])
    >>> 1
    Explanation:
    In the beginning, the distances of the monsters are [3,2,4]. You eliminate the first monster.
    After a minute, the distances of the monsters are [X,0,2], so you lose.
    You can only eliminate 1 monster.
    """


Prompt:
def countGoodNumbers(n: int) -> int:
    """
    A digit string is good if the digits (0-indexed) at even indices are even and the digits at odd indices are prime (2, 3, 5, or 7).

    For example, "2582" is good because the digits (2 and 8) at even positions are even and the digits (5 and 2) at odd positions are prime. However, "3245" is not good because 3 is at an even index but is not even.

    Given an integer n, return the total number of good digit strings of length n. Since the answer may be large, return it modulo 109 + 7.
    A digit string is a string consisting of digits 0 through 9 that may contain leading zeros.

    Example 1:

    >>> countGoodNumbers(n = 1)
    >>> 5
    Explanation: The good numbers of length 1 are "0", "2", "4", "6", "8".

    Example 2:

    >>> countGoodNumbers(n = 4)
    >>> 400

    Example 3:

    >>> countGoodNumbers(n = 50)
    >>> 564908303
    """


Prompt:
def longestCommonSubpath(n: int, paths: List[List[int]]) -> int:
    """
    There is a country of n cities numbered from 0 to n - 1. In this country, there is a road connecting every pair of cities.
    There are m friends numbered from 0 to m - 1 who are traveling through the country. Each one of them will take a path consisting of some cities. Each path is represented by an integer array that contains the visited cities in order. The path may contain a city more than once, but the same city will not be listed consecutively.
    Given an integer n and a 2D integer array paths where paths[i] is an integer array representing the path of the ith friend, return the length of the longest common subpath that is shared by every friend's path, or 0 if there is no common subpath at all.
    A subpath of a path is a contiguous sequence of cities within that path.

    Example 1:

                           [2,3,4],
                           [4,0,1,2,3]]
    >>> longestCommonSubpath(n = 5, paths = [[0,1,2,3,4],)
    >>> 2
    Explanation: The longest common subpath is [2,3].

    Example 2:

    >>> longestCommonSubpath(n = 3, paths = [[0],[1],[2]])
    >>> 0
    Explanation: There is no common subpath shared by the three paths.

    Example 3:

                           [4,3,2,1,0]]
    >>> longestCommonSubpath(n = 5, paths = [[0,1,2,3,4],)
    >>> 1
    Explanation: The possible longest common subpaths are [0], [1], [2], [3], and [4]. All have a length of 1.
    """


Prompt:
def outerTrees(trees: List[List[int]]) -> List[float]:
    """
    You are given a 2D integer array trees where trees[i] = [xi, yi] represents the location of the ith tree in the garden.
    You are asked to fence the entire garden using the minimum length of rope possible. The garden is well-fenced only if all the trees are enclosed and the rope used forms a perfect circle. A tree is considered enclosed if it is inside or on the border of the circle.
    More formally, you must form a circle using the rope with a center (x, y) and radius r where all trees lie inside or on the circle and r is minimum.
    Return the center and radius of the circle as a length 3 array [x, y, r]. Answers within 10-5 of the actual answer will be accepted.

    Example 1:

    >>> outerTrees(trees = [[1,1],[2,2],[2,0],[2,4],[3,3],[4,2]])
    >>> [2.00000,2.00000,2.00000]
    Explanation: The fence will have center = (2, 2) and radius = 2

    Example 2:

    >>> outerTrees(trees = [[1,2],[2,2],[4,2]])
    >>> [2.50000,2.00000,1.50000]
    Explanation: The fence will have center = (2.5, 2) and radius = 1.5
    """


Prompt:
def countTriples(n: int) -> int:
    """
    A square triple (a,b,c) is a triple where a, b, and c are integers and a2 + b2 = c2.
    Given an integer n, return the number of square triples such that 1 <= a, b, c <= n.

    Example 1:

    >>> countTriples(n = 5)
    >>> 2
    Explanation: The square triples are (3,4,5) and (4,3,5).

    Example 2:

    >>> countTriples(n = 10)
    >>> 4
    Explanation: The square triples are (3,4,5), (4,3,5), (6,8,10), and (8,6,10).
    """


Prompt:
def nearestExit(maze: List[List[str]], entrance: List[int]) -> int:
    """
    You are given an m x n matrix maze (0-indexed) with empty cells (represented as '.') and walls (represented as '+'). You are also given the entrance of the maze, where entrance = [entrancerow, entrancecol] denotes the row and column of the cell you are initially standing at.
    In one step, you can move one cell up, down, left, or right. You cannot step into a cell with a wall, and you cannot step outside the maze. Your goal is to find the nearest exit from the entrance. An exit is defined as an empty cell that is at the border of the maze. The entrance does not count as an exit.
    Return the number of steps in the shortest path from the entrance to the nearest exit, or -1 if no such path exists.

    Example 1:

    >>> nearestExit(maze = [["+","+",".","+"],[".",".",".","+"],["+","+","+","."]], entrance = [1,2])
    >>> 1
    Explanation: There are 3 exits in this maze at [1,0], [0,2], and [2,3].
    Initially, you are at the entrance cell [1,2].
    - You can reach [1,0] by moving 2 steps left.
    - You can reach [0,2] by moving 1 step up.
    It is impossible to reach [2,3] from the entrance.
    Thus, the nearest exit is [0,2], which is 1 step away.

    Example 2:

    >>> nearestExit(maze = [["+","+","+"],[".",".","."],["+","+","+"]], entrance = [1,0])
    >>> 2
    Explanation: There is 1 exit in this maze at [1,2].
    [1,0] does not count as an exit since it is the entrance cell.
    Initially, you are at the entrance cell [1,0].
    - You can reach [1,2] by moving 2 steps right.
    Thus, the nearest exit is [1,2], which is 2 steps away.

    Example 3:

    >>> nearestExit(maze = [[".","+"]], entrance = [0,0])
    >>> -1
    Explanation: There are no exits in this maze.
    """


Prompt:
def sumGame(num: str) -> bool:
    """
    Alice and Bob take turns playing a game, with Alice starting first.
    You are given a string num of even length consisting of digits and '?' characters. On each turn, a player will do the following if there is still at least one '?' in num:

    Choose an index i where num[i] == '?'.
    Replace num[i] with any digit between '0' and '9'.

    The game ends when there are no more '?' characters in num.
    For Bob to win, the sum of the digits in the first half of num must be equal to the sum of the digits in the second half. For Alice to win, the sums must not be equal.

    For example, if the game ended with num = "243801", then Bob wins because 2+4+3 = 8+0+1. If the game ended with num = "243803", then Alice wins because 2+4+3 != 8+0+3.

    Assuming Alice and Bob play optimally, return true if Alice will win and false if Bob will win.

    Example 1:

    >>> sumGame(num = "5023")
    >>> false
    Explanation: There are no moves to be made.
    The sum of the first half is equal to the sum of the second half: 5 + 0 = 2 + 3.

    Example 2:

    >>> sumGame(num = "25??")
    >>> true
    Explanation: Alice can replace one of the '?'s with '9' and it will be impossible for Bob to make the sums equal.

    Example 3:

    >>> sumGame(num = "?3295???")
    >>> false
    Explanation: It can be proven that Bob will always win. One possible outcome is:
    - Alice replaces the first '?' with '9'. num = "93295???".
    - Bob replaces one of the '?' in the right half with '9'. num = "932959??".
    - Alice replaces one of the '?' in the right half with '2'. num = "9329592?".
    - Bob replaces the last '?' in the right half with '7'. num = "93295927".
    Bob wins because 9 + 3 + 2 + 9 = 5 + 9 + 2 + 7.
    """


Prompt:
def minCost(maxTime: int, edges: List[List[int]], passingFees: List[int]) -> int:
    """
    There is a country of n cities numbered from 0 to n - 1 where all the cities are connected by bi-directional roads. The roads are represented as a 2D integer array edges where edges[i] = [xi, yi, timei] denotes a road between cities xi and yi that takes timei minutes to travel. There may be multiple roads of differing travel times connecting the same two cities, but no road connects a city to itself.
    Each time you pass through a city, you must pay a passing fee. This is represented as a 0-indexed integer array passingFees of length n where passingFees[j] is the amount of dollars you must pay when you pass through city j.
    In the beginning, you are at city 0 and want to reach city n - 1 in maxTime minutes or less. The cost of your journey is the summation of passing fees for each city that you passed through at some moment of your journey (including the source and destination cities).
    Given maxTime, edges, and passingFees, return the minimum cost to complete your journey, or -1 if you cannot complete it within maxTime minutes.

    Example 1:

    >>> minCost(maxTime = 30, edges = [[0,1,10],[1,2,10],[2,5,10],[0,3,1],[3,4,10],[4,5,15]], passingFees = [5,1,2,20,20,3])
    >>> 11
    Explanation: The path to take is 0 -> 1 -> 2 -> 5, which takes 30 minutes and has $11 worth of passing fees.

    Example 2:

    >>> minCost(maxTime = 29, edges = [[0,1,10],[1,2,10],[2,5,10],[0,3,1],[3,4,10],[4,5,15]], passingFees = [5,1,2,20,20,3])
    >>> 48
    Explanation: The path to take is 0 -> 3 -> 4 -> 5, which takes 26 minutes and has $48 worth of passing fees.
    You cannot take path 0 -> 1 -> 2 -> 5 since it would take too long.

    Example 3:

    >>> minCost(maxTime = 25, edges = [[0,1,10],[1,2,10],[2,5,10],[0,3,1],[3,4,10],[4,5,15]], passingFees = [5,1,2,20,20,3])
    >>> -1
    Explanation: There is no way to reach city 5 from city 0 within 25 minutes.
    """


Prompt:
def getConcatenation(nums: List[int]) -> List[int]:
    """
    Given an integer array nums of length n, you want to create an array ans of length 2n where ans[i] == nums[i] and ans[i + n] == nums[i] for 0 <= i < n (0-indexed).
    Specifically, ans is the concatenation of two nums arrays.
    Return the array ans.

    Example 1:

    >>> getConcatenation(nums = [1,2,1])
    >>> [1,2,1,1,2,1]
    Explanation: The array ans is formed as follows:
    - ans = [nums[0],nums[1],nums[2],nums[0],nums[1],nums[2]]
    - ans = [1,2,1,1,2,1]
    Example 2:

    >>> getConcatenation(nums = [1,3,2,1])
    >>> [1,3,2,1,1,3,2,1]
    Explanation: The array ans is formed as follows:
    - ans = [nums[0],nums[1],nums[2],nums[3],nums[0],nums[1],nums[2],nums[3]]
    - ans = [1,3,2,1,1,3,2,1]
    """


Prompt:
def countPalindromicSubsequence(s: str) -> int:
    """
    Given a string s, return the number of unique palindromes of length three that are a subsequence of s.
    Note that even if there are multiple ways to obtain the same subsequence, it is still only counted once.
    A palindrome is a string that reads the same forwards and backwards.
    A subsequence of a string is a new string generated from the original string with some characters (can be none) deleted without changing the relative order of the remaining characters.

    For example, "ace" is a subsequence of "abcde".

    Example 1:

    >>> countPalindromicSubsequence(s = "aabca")
    >>> 3
    Explanation: The 3 palindromic subsequences of length 3 are:
    - "aba" (subsequence of "aabca")
    - "aaa" (subsequence of "aabca")
    - "aca" (subsequence of "aabca")

    Example 2:

    >>> countPalindromicSubsequence(s = "adc")
    >>> 0
    Explanation: There are no palindromic subsequences of length 3 in "adc".

    Example 3:

    >>> countPalindromicSubsequence(s = "bbcbaba")
    >>> 4
    Explanation: The 4 palindromic subsequences of length 3 are:
    - "bbb" (subsequence of "bbcbaba")
    - "bcb" (subsequence of "bbcbaba")
    - "bab" (subsequence of "bbcbaba")
    - "aba" (subsequence of "bbcbaba")
    """


Prompt:
def colorTheGrid(m: int, n: int) -> int:
    """
    You are given two integers m and n. Consider an m x n grid where each cell is initially white. You can paint each cell red, green, or blue. All cells must be painted.
    Return the number of ways to color the grid with no two adjacent cells having the same color. Since the answer can be very large, return it modulo 109 + 7.

    Example 1:

    >>> colorTheGrid(m = 1, n = 1)
    >>> 3
    Explanation: The three possible colorings are shown in the image above.

    Example 2:

    >>> colorTheGrid(m = 1, n = 2)
    >>> 6
    Explanation: The six possible colorings are shown in the image above.

    Example 3:

    >>> colorTheGrid(m = 5, n = 5)
    >>> 580986
    """


Prompt:
def isDecomposable(s: str) -> bool:
    """
    A value-equal string is a string where all characters are the same.

    For example, "1111" and "33" are value-equal strings.
    In contrast, "123" is not a value-equal string.

    Given a digit string s, decompose the string into some number of consecutive value-equal substrings where exactly one substring has a length of 2 and the remaining substrings have a length of 3.
    Return true if you can decompose s according to the above rules. Otherwise, return false.
    A substring is a contiguous sequence of characters in a string.

    Example 1:

    >>> isDecomposable(s = "000111000")
    >>> false
    Explanation: s cannot be decomposed according to the rules because ["000", "111", "000"] does not have a substring of length 2.

    Example 2:

    >>> isDecomposable(s = "00011111222")
    >>> true
    Explanation: s can be decomposed into ["000", "111", "11", "222"].

    Example 3:

    >>> isDecomposable(s = "011100022233")
    >>> false
    Explanation: s cannot be decomposed according to the rules because of the first '0'.
    """


Prompt:
def canBeTypedWords(text: str, brokenLetters: str) -> int:
    """
    There is a malfunctioning keyboard where some letter keys do not work. All other keys on the keyboard work properly.
    Given a string text of words separated by a single space (no leading or trailing spaces) and a string brokenLetters of all distinct letter keys that are broken, return the number of words in text you can fully type using this keyboard.

    Example 1:

    >>> canBeTypedWords(text = "hello world", brokenLetters = "ad")
    >>> 1
    Explanation: We cannot type "world" because the 'd' key is broken.

    Example 2:

    >>> canBeTypedWords(text = "leet code", brokenLetters = "lt")
    >>> 1
    Explanation: We cannot type "leet" because the 'l' and 't' keys are broken.

    Example 3:

    >>> canBeTypedWords(text = "leet code", brokenLetters = "e")
    >>> 0
    Explanation: We cannot type either word because the 'e' key is broken.
    """


Prompt:
def addRungs(rungs: List[int], dist: int) -> int:
    """
    You are given a strictly increasing integer array rungs that represents the height of rungs on a ladder. You are currently on the floor at height 0, and you want to reach the last rung.
    You are also given an integer dist. You can only climb to the next highest rung if the distance between where you are currently at (the floor or on a rung) and the next rung is at most dist. You are able to insert rungs at any positive integer height if a rung is not already there.
    Return the minimum number of rungs that must be added to the ladder in order for you to climb to the last rung.

    Example 1:

    >>> addRungs(rungs = [1,3,5,10], dist = 2)
    >>> 2
    Explanation:
    You currently cannot reach the last rung.
    Add rungs at heights 7 and 8 to climb this ladder.
    The ladder will now have rungs at [1,3,5,7,8,10].

    Example 2:

    >>> addRungs(rungs = [3,6,8,10], dist = 3)
    >>> 0
    Explanation:
    This ladder can be climbed without adding additional rungs.

    Example 3:

    >>> addRungs(rungs = [3,4,6,7], dist = 2)
    >>> 1
    Explanation:
    You currently cannot reach the first rung from the ground.
    Add a rung at height 1 to climb this ladder.
    The ladder will now have rungs at [1,3,4,6,7].
    """


Prompt:
def maxPoints(points: List[List[int]]) -> int:
    """
    You are given an m x n integer matrix points (0-indexed). Starting with 0 points, you want to maximize the number of points you can get from the matrix.
    To gain points, you must pick one cell in each row. Picking the cell at coordinates (r, c) will add points[r][c] to your score.
    However, you will lose points if you pick a cell too far from the cell that you picked in the previous row. For every two adjacent rows r and r + 1 (where 0 <= r < m - 1), picking cells at coordinates (r, c1) and (r + 1, c2) will subtract abs(c1 - c2) from your score.
    Return the maximum number of points you can achieve.
    abs(x) is defined as:

    x for x >= 0.
    -x for x < 0.

    Example 1:

    >>> maxPoints(points = [[1,2,3],[1,5,1],[3,1,1]])
    >>> 9
    Explanation:
    The blue cells denote the optimal cells to pick, which have coordinates (0, 2), (1, 1), and (2, 0).
    You add 3 + 5 + 3 = 11 to your score.
    However, you must subtract abs(2 - 1) + abs(1 - 0) = 2 from your score.
    Your final score is 11 - 2 = 9.

    Example 2:

    >>> maxPoints(points = [[1,5],[2,3],[4,2]])
    >>> 11
    Explanation:
    The blue cells denote the optimal cells to pick, which have coordinates (0, 1), (1, 1), and (2, 0).
    You add 5 + 3 + 4 = 12 to your score.
    However, you must subtract abs(1 - 1) + abs(1 - 0) = 1 from your score.
    Your final score is 12 - 1 = 11.
    """


Prompt:
def maxGeneticDifference(parents: List[int], queries: List[List[int]]) -> List[int]:
    """
    There is a rooted tree consisting of n nodes numbered 0 to n - 1. Each node's number denotes its unique genetic value (i.e. the genetic value of node x is x). The genetic difference between two genetic values is defined as the bitwise-XOR of their values. You are given the integer array parents, where parents[i] is the parent for node i. If node x is the root of the tree, then parents[x] == -1.
    You are also given the array queries where queries[i] = [nodei, vali]. For each query i, find the maximum genetic difference between vali and pi, where pi is the genetic value of any node that is on the path between nodei and the root (including nodei and the root). More formally, you want to maximize vali XOR pi.
    Return an array ans where ans[i] is the answer to the ith query.

    Example 1:

    >>> maxGeneticDifference(parents = [-1,0,1,1], queries = [[0,2],[3,2],[2,5]])
    >>> [2,3,7]
    Explanation: The queries are processed as follows:
    - [0,2]: The node with the maximum genetic difference is 0, with a difference of 2 XOR 0 = 2.
    - [3,2]: The node with the maximum genetic difference is 1, with a difference of 2 XOR 1 = 3.
    - [2,5]: The node with the maximum genetic difference is 2, with a difference of 5 XOR 2 = 7.

    Example 2:

    >>> maxGeneticDifference(parents = [3,7,-1,2,0,7,0,2], queries = [[4,6],[1,15],[0,5]])
    >>> [6,14,7]
    Explanation: The queries are processed as follows:
    - [4,6]: The node with the maximum genetic difference is 0, with a difference of 6 XOR 0 = 6.
    - [1,15]: The node with the maximum genetic difference is 1, with a difference of 15 XOR 1 = 14.
    - [0,5]: The node with the maximum genetic difference is 2, with a difference of 5 XOR 2 = 7.
    """


Prompt:
def longestCommonSubsequence(arrays: List[List[int]]) -> List[int]:
    """
    Given an array of integer arrays arrays where each arrays[i] is sorted in strictly increasing order, return an integer array representing the longest common subsequence among all the arrays.
    A subsequence is a sequence that can be derived from another sequence by deleting some elements (possibly none) without changing the order of the remaining elements.

    Example 1:

                     [1,4,7,9]]
    >>> longestCommonSubsequence(arrays = [[1,3,4],)
    >>> [1,4]
    Explanation: The longest common subsequence in the two arrays is [1,4].

    Example 2:

                     [1,2,3,5,6,7,10],
                     [2,3,4,6,9]]
    >>> longestCommonSubsequence(arrays = [[2,3,6,8],)
    >>> [2,3,6]
    Explanation: The longest common subsequence in all three arrays is [2,3,6].

    Example 3:

                     [6,7,8]]
    >>> longestCommonSubsequence(arrays = [[1,2,3,4,5],)
    >>> []
    Explanation: There is no common subsequence between the two arrays.
    """


Prompt:
def areOccurrencesEqual(s: str) -> bool:
    """
    Given a string s, return true if s is a good string, or false otherwise.
    A string s is good if all the characters that appear in s have the same number of occurrences (i.e., the same frequency).

    Example 1:

    >>> areOccurrencesEqual(s = "abacbc")
    >>> true
    Explanation: The characters that appear in s are 'a', 'b', and 'c'. All characters occur 2 times in s.

    Example 2:

    >>> areOccurrencesEqual(s = "aaabb")
    >>> false
    Explanation: The characters that appear in s are 'a' and 'b'.
    'a' occurs 3 times while 'b' occurs 2 times, which is not the same number of times.
    """


Prompt:
def smallestChair(times: List[List[int]], targetFriend: int) -> int:
    """
    There is a party where n friends numbered from 0 to n - 1 are attending. There is an infinite number of chairs in this party that are numbered from 0 to infinity. When a friend arrives at the party, they sit on the unoccupied chair with the smallest number.

    For example, if chairs 0, 1, and 5 are occupied when a friend comes, they will sit on chair number 2.

    When a friend leaves the party, their chair becomes unoccupied at the moment they leave. If another friend arrives at that same moment, they can sit in that chair.
    You are given a 0-indexed 2D integer array times where times[i] = [arrivali, leavingi], indicating the arrival and leaving times of the ith friend respectively, and an integer targetFriend. All arrival times are distinct.
    Return the chair number that the friend numbered targetFriend will sit on.

    Example 1:

    >>> smallestChair(times = [[1,4],[2,3],[4,6]], targetFriend = 1)
    >>> 1
    Explanation:
    - Friend 0 arrives at time 1 and sits on chair 0.
    - Friend 1 arrives at time 2 and sits on chair 1.
    - Friend 1 leaves at time 3 and chair 1 becomes empty.
    - Friend 0 leaves at time 4 and chair 0 becomes empty.
    - Friend 2 arrives at time 4 and sits on chair 0.
    Since friend 1 sat on chair 1, we return 1.

    Example 2:

    >>> smallestChair(times = [[3,10],[1,5],[2,6]], targetFriend = 0)
    >>> 2
    Explanation:
    - Friend 1 arrives at time 1 and sits on chair 0.
    - Friend 2 arrives at time 2 and sits on chair 1.
    - Friend 0 arrives at time 3 and sits on chair 2.
    - Friend 1 leaves at time 5 and chair 0 becomes empty.
    - Friend 2 leaves at time 6 and chair 1 becomes empty.
    - Friend 0 leaves at time 10 and chair 2 becomes empty.
    Since friend 0 sat on chair 2, we return 2.
    """


Prompt:
def splitPainting(segments: List[List[int]]) -> List[List[int]]:
    """
    There is a long and thin painting that can be represented by a number line. The painting was painted with multiple overlapping segments where each segment was painted with a unique color. You are given a 2D integer array segments, where segments[i] = [starti, endi, colori] represents the half-closed segment [starti, endi) with colori as the color.
    The colors in the overlapping segments of the painting were mixed when it was painted. When two or more colors mix, they form a new color that can be represented as a set of mixed colors.

    For example, if colors 2, 4, and 6 are mixed, then the resulting mixed color is {2,4,6}.

    For the sake of simplicity, you should only output the sum of the elements in the set rather than the full set.
    You want to describe the painting with the minimum number of non-overlapping half-closed segments of these mixed colors. These segments can be represented by the 2D array painting where painting[j] = [leftj, rightj, mixj] describes a half-closed segment [leftj, rightj) with the mixed color sum of mixj.

    For example, the painting created with segments = [[1,4,5],[1,7,7]] can be described by painting = [[1,4,12],[4,7,7]] because:

    [1,4) is colored {5,7} (with a sum of 12) from both the first and second segments.
    [4,7) is colored {7} from only the second segment.

    Return the 2D array painting describing the finished painting (excluding any parts that are not painted). You may return the segments in any order.
    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:

    >>> splitPainting(segments = [[1,4,5],[4,7,7],[1,7,9]])
    >>> [[1,4,14],[4,7,16]]
    Explanation: The painting can be described as follows:
    - [1,4) is colored {5,9} (with a sum of 14) from the first and third segments.
    - [4,7) is colored {7,9} (with a sum of 16) from the second and third segments.

    Example 2:

    >>> splitPainting(segments = [[1,7,9],[6,8,15],[8,10,7]])
    >>> [[1,6,9],[6,7,24],[7,8,15],[8,10,7]]
    Explanation: The painting can be described as follows:
    - [1,6) is colored 9 from the first segment.
    - [6,7) is colored {9,15} (with a sum of 24) from the first and second segments.
    - [7,8) is colored 15 from the second segment.
    - [8,10) is colored 7 from the third segment.

    Example 3:

    >>> splitPainting(segments = [[1,4,5],[1,4,7],[4,7,1],[4,7,11]])
    >>> [[1,4,12],[4,7,12]]
    Explanation: The painting can be described as follows:
    - [1,4) is colored {5,7} (with a sum of 12) from the first and second segments.
    - [4,7) is colored {1,11} (with a sum of 12) from the third and fourth segments.
    Note that returning a single segment [1,7) is incorrect because the mixed color sets are different.
    """


Prompt:
def canSeePersonsCount(heights: List[int]) -> List[int]:
    """
    There are n people standing in a queue, and they numbered from 0 to n - 1 in left to right order. You are given an array heights of distinct integers where heights[i] represents the height of the ith person.
    A person can see another person to their right in the queue if everybody in between is shorter than both of them. More formally, the ith person can see the jth person if i < j and min(heights[i], heights[j]) > max(heights[i+1], heights[i+2], ..., heights[j-1]).
    Return an array answer of length n where answer[i] is the number of people the ith person can see to their right in the queue.

    Example 1:

    >>> canSeePersonsCount(heights = [10,6,8,5,11,9])
    >>> [3,1,2,1,1,0]
    Explanation:
    Person 0 can see person 1, 2, and 4.
    Person 1 can see person 2.
    Person 2 can see person 3 and 4.
    Person 3 can see person 4.
    Person 4 can see person 5.
    Person 5 can see no one since nobody is to the right of them.

    Example 2:

    >>> canSeePersonsCount(heights = [5,1,2,3,10])
    >>> [4,1,1,1,0]
    """


Prompt:
def getLucky(s: str, k: int) -> int:
    """
    You are given a string s consisting of lowercase English letters, and an integer k. Your task is to convert the string into an integer by a special process, and then transform it by summing its digits repeatedly k times. More specifically, perform the following steps:

    Convert s into an integer by replacing each letter with its position in the alphabet (i.e. replace 'a' with 1, 'b' with 2, ..., 'z' with 26).
    Transform the integer by replacing it with the sum of its digits.
    Repeat the transform operation (step 2) k times in total.

    For example, if s = "zbax" and k = 2, then the resulting integer would be 8 by the following operations:

    Convert: "zbax" ➝ "(26)(2)(1)(24)" ➝ "262124" ➝ 262124
    Transform #1: 262124 ➝ 2 + 6 + 2 + 1 + 2 + 4 ➝ 17
    Transform #2: 17 ➝ 1 + 7 ➝ 8

    Return the resulting integer after performing the operations described above.

    Example 1:

    >>> getLucky(s = "iiii", k = 1)
    >>> 36
    Explanation:
    The operations are as follows:
    - Convert: "iiii" ➝ "(9)(9)(9)(9)" ➝ "9999" ➝ 9999
    - Transform #1: 9999 ➝ 9 + 9 + 9 + 9 ➝ 36
    Thus the resulting integer is 36.

    Example 2:

    >>> getLucky(s = "leetcode", k = 2)
    >>> 6
    Explanation:
    The operations are as follows:
    - Convert: "leetcode" ➝ "(12)(5)(5)(20)(3)(15)(4)(5)" ➝ "12552031545" ➝ 12552031545
    - Transform #1: 12552031545 ➝ 1 + 2 + 5 + 5 + 2 + 0 + 3 + 1 + 5 + 4 + 5 ➝ 33
    - Transform #2: 33 ➝ 3 + 3 ➝ 6
    Thus the resulting integer is 6.

    Example 3:

    >>> getLucky(s = "zbax", k = 2)
    >>> 8
    """


Prompt:
def maximumNumber(num: str, change: List[int]) -> str:
    """
    You are given a string num, which represents a large integer. You are also given a 0-indexed integer array change of length 10 that maps each digit 0-9 to another digit. More formally, digit d maps to digit change[d].
    You may choose to mutate a single substring of num. To mutate a substring, replace each digit num[i] with the digit it maps to in change (i.e. replace num[i] with change[num[i]]).
    Return a string representing the largest possible integer after mutating (or choosing not to) a single substring of num.
    A substring is a contiguous sequence of characters within the string.

    Example 1:

    >>> maximumNumber(num = "132", change = [9,8,5,0,3,6,4,2,6,8])
    >>> "832"
    Explanation: Replace the substring "1":
    - 1 maps to change[1] = 8.
    Thus, "132" becomes "832".
    "832" is the largest number that can be created, so return it.

    Example 2:

    >>> maximumNumber(num = "021", change = [9,4,3,5,7,2,1,9,0,6])
    >>> "934"
    Explanation: Replace the substring "021":
    - 0 maps to change[0] = 9.
    - 2 maps to change[2] = 3.
    - 1 maps to change[1] = 4.
    Thus, "021" becomes "934".
    "934" is the largest number that can be created, so return it.

    Example 3:

    >>> maximumNumber(num = "5", change = [1,4,7,5,3,2,5,6,9,4])
    >>> "5"
    Explanation: "5" is already the largest number that can be created, so return it.
    """


Prompt:
def maxCompatibilitySum(students: List[List[int]], mentors: List[List[int]]) -> int:
    """
    There is a survey that consists of n questions where each question's answer is either 0 (no) or 1 (yes).
    The survey was given to m students numbered from 0 to m - 1 and m mentors numbered from 0 to m - 1. The answers of the students are represented by a 2D integer array students where students[i] is an integer array that contains the answers of the ith student (0-indexed). The answers of the mentors are represented by a 2D integer array mentors where mentors[j] is an integer array that contains the answers of the jth mentor (0-indexed).
    Each student will be assigned to one mentor, and each mentor will have one student assigned to them. The compatibility score of a student-mentor pair is the number of answers that are the same for both the student and the mentor.

    For example, if the student's answers were [1, 0, 1] and the mentor's answers were [0, 0, 1], then their compatibility score is 2 because only the second and the third answers are the same.

    You are tasked with finding the optimal student-mentor pairings to maximize the sum of the compatibility scores.
    Given students and mentors, return the maximum compatibility score sum that can be achieved.

    Example 1:

    >>> maxCompatibilitySum(students = [[1,1,0],[1,0,1],[0,0,1]], mentors = [[1,0,0],[0,0,1],[1,1,0]])
    >>> 8
    Explanation: We assign students to mentors in the following way:
    - student 0 to mentor 2 with a compatibility score of 3.
    - student 1 to mentor 0 with a compatibility score of 2.
    - student 2 to mentor 1 with a compatibility score of 3.
    The compatibility score sum is 3 + 2 + 3 = 8.

    Example 2:

    >>> maxCompatibilitySum(students = [[0,0],[0,0],[0,0]], mentors = [[1,1],[1,1],[1,1]])
    >>> 0
    Explanation: The compatibility score of any student-mentor pair is 0.
    """


Prompt:
def deleteDuplicateFolder(paths: List[List[str]]) -> List[List[str]]:
    """
    Due to a bug, there are many duplicate folders in a file system. You are given a 2D array paths, where paths[i] is an array representing an absolute path to the ith folder in the file system.

    For example, ["one", "two", "three"] represents the path "/one/two/three".

    Two folders (not necessarily on the same level) are identical if they contain the same non-empty set of identical subfolders and underlying subfolder structure. The folders do not need to be at the root level to be identical. If two or more folders are identical, then mark the folders as well as all their subfolders.

    For example, folders "/a" and "/b" in the file structure below are identical. They (as well as their subfolders) should all be marked:

    /a
    /a/x
    /a/x/y
    /a/z
    /b
    /b/x
    /b/x/y
    /b/z

    However, if the file structure also included the path "/b/w", then the folders "/a" and "/b" would not be identical. Note that "/a/x" and "/b/x" would still be considered identical even with the added folder.

    Once all the identical folders and their subfolders have been marked, the file system will delete all of them. The file system only runs the deletion once, so any folders that become identical after the initial deletion are not deleted.
    Return the 2D array ans containing the paths of the remaining folders after deleting all the marked folders. The paths may be returned in any order.

    Example 1:

    >>> deleteDuplicateFolder(paths = [["a"],["c"],["d"],["a","b"],["c","b"],["d","a"]])
    >>> [["d"],["d","a"]]
    Explanation: The file structure is as shown.
    Folders "/a" and "/c" (and their subfolders) are marked for deletion because they both contain an empty
    folder named "b".

    Example 2:

    >>> deleteDuplicateFolder(paths = [["a"],["c"],["a","b"],["c","b"],["a","b","x"],["a","b","x","y"],["w"],["w","y"]])
    >>> [["c"],["c","b"],["a"],["a","b"]]
    Explanation: The file structure is as shown.
    Folders "/a/b/x" and "/w" (and their subfolders) are marked for deletion because they both contain an empty folder named "y".
    Note that folders "/a" and "/c" are identical after the deletion, but they are not deleted because they were not marked beforehand.

    Example 3:

    >>> deleteDuplicateFolder(paths = [["a","b"],["c","d"],["c"],["a"]])
    >>> [["c"],["c","d"],["a"],["a","b"]]
    Explanation: All folders are unique in the file system.
    Note that the returned array can be in a different order as the order does not matter.
    """


Prompt:
def findMaximums(nums: List[int]) -> List[int]:
    """
    You are given an integer array nums of size n. You are asked to solve n queries for each integer i in the range 0 <= i < n.
    To solve the ith query:

    Find the minimum value in each possible subarray of size i + 1 of the array nums.
    Find the maximum of those minimum values. This maximum is the answer to the query.

    Return a 0-indexed integer array ans of size n such that ans[i] is the answer to the ith query.
    A subarray is a contiguous sequence of elements in an array.

    Example 1:

    >>> findMaximums(nums = [0,1,2,4])
    >>> [4,2,1,0]
    Explanation:
    i=0:
    - The subarrays of size 1 are [0], [1], [2], [4]. The minimum values are 0, 1, 2, 4.
    - The maximum of the minimum values is 4.
    i=1:
    - The subarrays of size 2 are [0,1], [1,2], [2,4]. The minimum values are 0, 1, 2.
    - The maximum of the minimum values is 2.
    i=2:
    - The subarrays of size 3 are [0,1,2], [1,2,4]. The minimum values are 0, 1.
    - The maximum of the minimum values is 1.
    i=3:
    - There is one subarray of size 4, which is [0,1,2,4]. The minimum value is 0.
    - There is only one value, so the maximum is 0.

    Example 2:

    >>> findMaximums(nums = [10,20,50,10])
    >>> [50,20,10,10]
    Explanation:
    i=0:
    - The subarrays of size 1 are [10], [20], [50], [10]. The minimum values are 10, 20, 50, 10.
    - The maximum of the minimum values is 50.
    i=1:
    - The subarrays of size 2 are [10,20], [20,50], [50,10]. The minimum values are 10, 20, 10.
    - The maximum of the minimum values is 20.
    i=2:
    - The subarrays of size 3 are [10,20,50], [20,50,10]. The minimum values are 10, 10.
    - The maximum of the minimum values is 10.
    i=3:
    - There is one subarray of size 4, which is [10,20,50,10]. The minimum value is 10.
    - There is only one value, so the maximum is 10.
    """


Prompt:
def isThree(n: int) -> bool:
    """
    Given an integer n, return true if n has exactly three positive divisors. Otherwise, return false.
    An integer m is a divisor of n if there exists an integer k such that n = k * m.

    Example 1:

    >>> isThree(n = 2)
    >>> false
    Explantion: 2 has only two divisors: 1 and 2.

    Example 2:

    >>> isThree(n = 4)
    >>> true
    Explantion: 4 has three divisors: 1, 2, and 4.
    """


Prompt:
def numberOfWeeks(milestones: List[int]) -> int:
    """
    There are n projects numbered from 0 to n - 1. You are given an integer array milestones where each milestones[i] denotes the number of milestones the ith project has.
    You can work on the projects following these two rules:

    Every week, you will finish exactly one milestone of one project. You must work every week.
    You cannot work on two milestones from the same project for two consecutive weeks.

    Once all the milestones of all the projects are finished, or if the only milestones that you can work on will cause you to violate the above rules, you will stop working. Note that you may not be able to finish every project's milestones due to these constraints.
    Return the maximum number of weeks you would be able to work on the projects without violating the rules mentioned above.

    Example 1:

    >>> numberOfWeeks(milestones = [1,2,3])
    >>> 6
    Explanation: One possible scenario is:
    - During the 1st week, you will work on a milestone of project 0.
    - During the 2nd week, you will work on a milestone of project 2.
    - During the 3rd week, you will work on a milestone of project 1.
    - During the 4th week, you will work on a milestone of project 2.
    - During the 5th week, you will work on a milestone of project 1.
    - During the 6th week, you will work on a milestone of project 2.
    The total number of weeks is 6.

    Example 2:

    >>> numberOfWeeks(milestones = [5,2,1])
    >>> 7
    Explanation: One possible scenario is:
    - During the 1st week, you will work on a milestone of project 0.
    - During the 2nd week, you will work on a milestone of project 1.
    - During the 3rd week, you will work on a milestone of project 0.
    - During the 4th week, you will work on a milestone of project 1.
    - During the 5th week, you will work on a milestone of project 0.
    - During the 6th week, you will work on a milestone of project 2.
    - During the 7th week, you will work on a milestone of project 0.
    The total number of weeks is 7.
    Note that you cannot work on the last milestone of project 0 on 8th week because it would violate the rules.
    Thus, one milestone in project 0 will remain unfinished.
    """


Prompt:
def minimumPerimeter(neededApples: int) -> int:
    """
    In a garden represented as an infinite 2D grid, there is an apple tree planted at every integer coordinate. The apple tree planted at an integer coordinate (i, j) has |i| + |j| apples growing on it.
    You will buy an axis-aligned square plot of land that is centered at (0, 0).
    Given an integer neededApples, return the minimum perimeter of a plot such that at least neededApples apples are inside or on the perimeter of that plot.
    The value of |x| is defined as:

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

    Example 1:

    >>> minimumPerimeter(neededApples = 1)
    >>> 8
    Explanation: A square plot of side length 1 does not contain any apples.
    However, a square plot of side length 2 has 12 apples inside (as depicted in the image above).
    The perimeter is 2 * 4 = 8.

    Example 2:

    >>> minimumPerimeter(neededApples = 13)
    >>> 16

    Example 3:

    >>> minimumPerimeter(neededApples = 1000000000)
    >>> 5040
    """


Prompt:
def countSpecialSubsequences(nums: List[int]) -> int:
    """
    A sequence is special if it consists of a positive number of 0s, followed by a positive number of 1s, then a positive number of 2s.

    For example, [0,1,2] and [0,0,1,1,1,2] are special.
    In contrast, [2,1,0], [1], and [0,1,2,0] are not special.

    Given an array nums (consisting of only integers 0, 1, and 2), return the number of different subsequences that are special. Since the answer may be very large, return it modulo 109 + 7.
    A subsequence of an array is a sequence that can be derived from the array by deleting some or no elements without changing the order of the remaining elements. Two subsequences are different if the set of indices chosen are different.

    Example 1:

    >>> countSpecialSubsequences(nums = [0,1,2,2])
    >>> 3
    Explanation: The special subsequences are bolded [0,1,2,2], [0,1,2,2], and [0,1,2,2].

    Example 2:

    >>> countSpecialSubsequences(nums = [2,2,0,0])
    >>> 0
    Explanation: There are no special subsequences in [2,2,0,0].

    Example 3:

    >>> countSpecialSubsequences(nums = [0,1,2,0,1,2])
    >>> 7
    Explanation: The special subsequences are bolded:
    - [0,1,2,0,1,2]
    - [0,1,2,0,1,2]
    - [0,1,2,0,1,2]
    - [0,1,2,0,1,2]
    - [0,1,2,0,1,2]
    - [0,1,2,0,1,2]
    - [0,1,2,0,1,2]
    """


Prompt:
def minDayskVariants(points: List[List[int]], k: int) -> int:
    """
    There are n unique virus variants in an infinite 2D grid. You are given a 2D array points, where points[i] = [xi, yi] represents a virus originating at (xi, yi) on day 0. Note that it is possible for multiple virus variants to originate at the same point.
    Every day, each cell infected with a virus variant will spread the virus to all neighboring points in the four cardinal directions (i.e. up, down, left, and right). If a cell has multiple variants, all the variants will spread without interfering with each other.
    Given an integer k, return the minimum integer number of days for any point to contain at least k of the unique virus variants.

    Example 1:

    >>> minDayskVariants(points = [[1,1],[6,1]], k = 2)
    >>> 3
    Explanation: On day 3, points (3,1) and (4,1) will contain both virus variants. Note that these are not the only points that will contain both virus variants.

    Example 2:

    >>> minDayskVariants(points = [[3,3],[1,2],[9,2]], k = 2)
    >>> 2
    Explanation: On day 2, points (1,3), (2,3), (2,2), and (3,2) will contain the first two viruses. Note that these are not the only points that will contain both virus variants.

    Example 3:

    >>> minDayskVariants(points = [[3,3],[1,2],[9,2]], k = 3)
    >>> 4
    Explanation: On day 4, the point (5,2) will contain all 3 viruses. Note that this is not the only point that will contain all 3 virus variants.
    """


Prompt:
def makeFancyString(s: str) -> str:
    """
    A fancy string is a string where no three consecutive characters are equal.
    Given a string s, delete the minimum possible number of characters from s to make it fancy.
    Return the final string after the deletion. It can be shown that the answer will always be unique.

    Example 1:

    >>> makeFancyString(s = "leeetcode")
    >>> "leetcode"
    Explanation:
    Remove an 'e' from the first group of 'e's to create "leetcode".
    No three consecutive characters are equal, so return "leetcode".

    Example 2:

    >>> makeFancyString(s = "aaabaaaa")
    >>> "aabaa"
    Explanation:
    Remove an 'a' from the first group of 'a's to create "aabaaaa".
    Remove two 'a's from the second group of 'a's to create "aabaa".
    No three consecutive characters are equal, so return "aabaa".

    Example 3:

    >>> makeFancyString(s = "aab")
    >>> "aab"
    Explanation: No three consecutive characters are equal, so return "aab".
    """


Prompt:
def checkMove(board: List[List[str]], rMove: int, cMove: int, color: str) -> bool:
    """
    You are given a 0-indexed 8 x 8 grid board, where board[r][c] represents the cell (r, c) on a game board. On the board, free cells are represented by '.', white cells are represented by 'W', and black cells are represented by 'B'.
    Each move in this game consists of choosing a free cell and changing it to the color you are playing as (either white or black). However, a move is only legal if, after changing it, the cell becomes the endpoint of a good line (horizontal, vertical, or diagonal).
    A good line is a line of three or more cells (including the endpoints) where the endpoints of the line are one color, and the remaining cells in the middle are the opposite color (no cells in the line are free). You can find examples for good lines in the figure below:

    Given two integers rMove and cMove and a character color representing the color you are playing as (white or black), return true if changing cell (rMove, cMove) to color color is a legal move, or false if it is not legal.

    Example 1:

    >>> checkMove(board = [[".",".",".","B",".",".",".","."],[".",".",".","W",".",".",".","."],[".",".",".","W",".",".",".","."],[".",".",".","W",".",".",".","."],["W","B","B",".","W","W","W","B"],[".",".",".","B",".",".",".","."],[".",".",".","B",".",".",".","."],[".",".",".","W",".",".",".","."]], rMove = 4, cMove = 3, color = "B")
    >>> true
    Explanation: '.', 'W', and 'B' are represented by the colors blue, white, and black respectively, and cell (rMove, cMove) is marked with an 'X'.
    The two good lines with the chosen cell as an endpoint are annotated above with the red rectangles.

    Example 2:

    >>> checkMove(board = [[".",".",".",".",".",".",".","."],[".","B",".",".","W",".",".","."],[".",".","W",".",".",".",".","."],[".",".",".","W","B",".",".","."],[".",".",".",".",".",".",".","."],[".",".",".",".","B","W",".","."],[".",".",".",".",".",".","W","."],[".",".",".",".",".",".",".","B"]], rMove = 4, cMove = 4, color = "W")
    >>> false
    Explanation: While there are good lines with the chosen cell as a middle cell, there are no good lines with the chosen cell as an endpoint.
    """


Prompt:
def minSpaceWastedKResizing(nums: List[int], k: int) -> int:
    """
    You are currently designing a dynamic array. You are given a 0-indexed integer array nums, where nums[i] is the number of elements that will be in the array at time i. In addition, you are given an integer k, the maximum number of times you can resize the array (to any size).
    The size of the array at time t, sizet, must be at least nums[t] because there needs to be enough space in the array to hold all the elements. The space wasted at time t is defined as sizet - nums[t], and the total space wasted is the sum of the space wasted across every time t where 0 <= t < nums.length.
    Return the minimum total space wasted if you can resize the array at most k times.
    Note: The array can have any size at the start and does not count towards the number of resizing operations.

    Example 1:

    >>> minSpaceWastedKResizing(nums = [10,20], k = 0)
    >>> 10
    Explanation: size = [20,20].
    We can set the initial size to be 20.
    The total wasted space is (20 - 10) + (20 - 20) = 10.

    Example 2:

    >>> minSpaceWastedKResizing(nums = [10,20,30], k = 1)
    >>> 10
    Explanation: size = [20,20,30].
    We can set the initial size to be 20 and resize to 30 at time 2.
    The total wasted space is (20 - 10) + (20 - 20) + (30 - 30) = 10.

    Example 3:

    >>> minSpaceWastedKResizing(nums = [10,20,15,30,20], k = 2)
    >>> 15
    Explanation: size = [10,20,20,30,30].
    We can set the initial size to 10, resize to 20 at time 1, and resize to 30 at time 3.
    The total wasted space is (10 - 10) + (20 - 20) + (20 - 15) + (30 - 30) + (30 - 20) = 15.
    """


Prompt:
def maxProduct(s: str) -> int:
    """
    You are given a 0-indexed string s and are tasked with finding two non-intersecting palindromic substrings of odd length such that the product of their lengths is maximized.
    More formally, you want to choose four integers i, j, k, l such that 0 <= i <= j < k <= l < s.length and both the substrings s[i...j] and s[k...l] are palindromes and have odd lengths. s[i...j] denotes a substring from index i to index j inclusive.
    Return the maximum possible product of the lengths of the two non-intersecting palindromic substrings.
    A palindrome is a string that is the same forward and backward. A substring is a contiguous sequence of characters in a string.

    Example 1:

    >>> maxProduct(s = "ababbb")
    >>> 9
    Explanation: Substrings "aba" and "bbb" are palindromes with odd length. product = 3 * 3 = 9.

    Example 2:

    >>> maxProduct(s = "zaaaxbbby")
    >>> 9
    Explanation: Substrings "aaa" and "bbb" are palindromes with odd length. product = 3 * 3 = 9.
    """


Prompt:
def isPrefixString(s: str, words: List[str]) -> bool:
    """
    Given a string s and an array of strings words, determine whether s is a prefix string of words.
    A string s is a prefix string of words if s can be made by concatenating the first k strings in words for some positive k no larger than words.length.
    Return true if s is a prefix string of words, or false otherwise.

    Example 1:

    >>> isPrefixString(s = "iloveleetcode", words = ["i","love","leetcode","apples"])
    >>> true
    Explanation:
    s can be made by concatenating "i", "love", and "leetcode" together.

    Example 2:

    >>> isPrefixString(s = "iloveleetcode", words = ["apples","i","love","leetcode"])
    >>> false
    Explanation:
    It is impossible to make s using a prefix of arr.
    """


Prompt:
def minStoneSum(piles: List[int], k: int) -> int:
    """
    You are given a 0-indexed integer array piles, where piles[i] represents the number of stones in the ith pile, and an integer k. You should apply the following operation exactly k times:

    Choose any piles[i] and remove floor(piles[i] / 2) stones from it.

    Notice that you can apply the operation on the same pile more than once.
    Return the minimum possible total number of stones remaining after applying the k operations.
    floor(x) is the greatest integer that is smaller than or equal to x (i.e., rounds x down).

    Example 1:

    >>> minStoneSum(piles = [5,4,9], k = 2)
    >>> 12
    Explanation: Steps of a possible scenario are:
    - Apply the operation on pile 2. The resulting piles are [5,4,5].
    - Apply the operation on pile 0. The resulting piles are [3,4,5].
    The total number of stones in [3,4,5] is 12.

    Example 2:

    >>> minStoneSum(piles = [4,3,6,7], k = 3)
    >>> 12
    Explanation: Steps of a possible scenario are:
    - Apply the operation on pile 2. The resulting piles are [4,3,3,7].
    - Apply the operation on pile 3. The resulting piles are [4,3,3,4].
    - Apply the operation on pile 0. The resulting piles are [2,3,3,4].
    The total number of stones in [2,3,3,4] is 12.
    """


Prompt:
def minSwaps(s: str) -> int:
    """
    You are given a 0-indexed string s of even length n. The string consists of exactly n / 2 opening brackets '[' and n / 2 closing brackets ']'.
    A string is called balanced if and only if:

    It is the empty string, or
    It can be written as AB, where both A and B are balanced strings, or
    It can be written as [C], where C is a balanced string.

    You may swap the brackets at any two indices any number of times.
    Return the minimum number of swaps to make s balanced.

    Example 1:

    >>> minSwaps(s = "][][")
    >>> 1
    Explanation: You can make the string balanced by swapping index 0 with index 3.
    The resulting string is "[[]]".

    Example 2:

    >>> minSwaps(s = "]]][[[")
    >>> 2
    Explanation: You can do the following to make the string balanced:
    - Swap index 0 with index 4. s = "[]][][".
    - Swap index 1 with index 5. s = "[[][]]".
    The resulting string is "[[][]]".

    Example 3:

    >>> minSwaps(s = "[]")
    >>> 0
    Explanation: The string is already balanced.
    """


Prompt:
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:
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:
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:
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:
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:
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:
# class TreeNode:
#     def __init__(val=0, left=None, right=None):
#         self.val = val
#         self.left = left
#         self.right = right
class Solution:
    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:

    >>> __init__(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:

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

    Example 3:

    >>> __init__(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:
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:
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:
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:
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:
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.
    """