Prompt:
from typing import List
def maximumEnergy(energy: List[int], k: int) -> int:
    """
    In a mystic dungeon, n magicians are standing in a line. Each magician has an attribute that gives you energy. Some magicians can give you negative energy, which means taking energy from you.
    You have been cursed in such a way that after absorbing energy from magician i, you will be instantly transported to magician (i + k). This process will be repeated until you reach the magician where (i + k) does not exist.
    In other words, you will choose a starting point and then teleport with k jumps until you reach the end of the magicians' sequence, absorbing all the energy during the journey.
    You are given an array energy and an integer k. Return the maximum possible energy you can gain.
    Note that when you are reach a magician, you must take energy from them, whether it is negative or positive energy.

    Example 1:

    >>> maximumEnergy(energy = [5,2,-10,-5,1], k = 3)
    >>> 3
    Explanation: We can gain a total energy of 3 by starting from magician 1 absorbing 2 + 1 = 3.

    Example 2:

    >>> maximumEnergy(energy = [-2,-3,-1], k = 2)
    >>> -1
    Explanation: We can gain a total energy of -1 by starting from magician 2.
    """


Prompt:
from typing import List
def maxScore(grid: List[List[int]]) -> int:
    """
    You are given an m x n matrix grid consisting of positive integers. You can move from a cell in the matrix to any other cell that is either to the bottom or to the right (not necessarily adjacent). The score of a move from a cell with the value c1 to a cell with the value c2 is c2 - c1.
    You can start at any cell, and you have to make at least one move.
    Return the maximum total score you can achieve.

    Example 1:

    >>> maxScore(grid = [[9,5,7,3],[8,9,6,1],[6,7,14,3],[2,5,3,1]])
    >>> 9
    Explanation: We start at the cell (0, 1), and we perform the following moves:
    - Move from the cell (0, 1) to (2, 1) with a score of 7 - 5 = 2.
    - Move from the cell (2, 1) to (2, 2) with a score of 14 - 7 = 7.
    The total score is 2 + 7 = 9.

    Example 2:

    >>> maxScore(grid = [[4,3,2],[3,2,1]])
    >>> -1
    Explanation: We start at the cell (0, 0), and we perform one move: (0, 0) to (0, 1). The score is 3 - 4 = -1.
    """


Prompt:
from typing import List
def findPermutation(nums: List[int]) -> List[int]:
    """
    You are given an array nums which is a permutation of [0, 1, 2, ..., n - 1]. The score of any permutation of [0, 1, 2, ..., n - 1] named perm is defined as:
    score(perm) = |perm[0] - nums[perm[1]]| + |perm[1] - nums[perm[2]]| + ... + |perm[n - 1] - nums[perm[0]]|
    Return the permutation perm which has the minimum possible score. If multiple permutations exist with this score, return the one that is lexicographically smallest among them.

    Example 1:

    >>> findPermutation(nums = [1,0,2])
    >>> [0,1,2]
    Explanation:

    The lexicographically smallest permutation with minimum cost is [0,1,2]. The cost of this permutation is |0 - 0| + |1 - 2| + |2 - 1| = 2.

    Example 2:

    >>> findPermutation(nums = [0,2,1])
    >>> [0,2,1]
    Explanation:

    The lexicographically smallest permutation with minimum cost is [0,2,1]. The cost of this permutation is |0 - 1| + |2 - 2| + |1 - 0| = 2.
    """


Prompt:
from typing import List
def isArraySpecial(nums: List[int]) -> bool:
    """
    An array is considered special if the parity of every pair of adjacent elements is different. In other words, one element in each pair must be even, and the other must be odd.
    You are given an array of integers nums. Return true if nums is a special array, otherwise, return false.

    Example 1:

    >>> isArraySpecial(nums = [1])
    >>> true
    Explanation:
    There is only one element. So the answer is true.

    Example 2:

    >>> isArraySpecial(nums = [2,1,4])
    >>> true
    Explanation:
    There is only two pairs: (2,1) and (1,4), and both of them contain numbers with different parity. So the answer is true.

    Example 3:

    >>> isArraySpecial(nums = [4,3,1,6])
    >>> false
    Explanation:
    nums[1] and nums[2] are both odd. So the answer is false.
    """


Prompt:
from typing import List
def isArraySpecial(nums: List[int], queries: List[List[int]]) -> List[bool]:
    """
    An array is considered special if every pair of its adjacent elements contains two numbers with different parity.
    You are given an array of integer nums and a 2D integer matrix queries, where for queries[i] = [fromi, toi] your task is to check that subarray nums[fromi..toi] is special or not.
    Return an array of booleans answer such that answer[i] is true if nums[fromi..toi] is special.

    Example 1:

    >>> isArraySpecial(nums = [3,4,1,2,6], queries = [[0,4]])
    >>> [false]
    Explanation:
    The subarray is [3,4,1,2,6]. 2 and 6 are both even.

    Example 2:

    >>> isArraySpecial(nums = [4,3,1,6], queries = [[0,2],[2,3]])
    >>> [false,true]
    Explanation:

    The subarray is [4,3,1]. 3 and 1 are both odd. So the answer to this query is false.
    The subarray is [1,6]. There is only one pair: (1,6) and it contains numbers with different parity. So the answer to this query is true.
    """


Prompt:
from typing import List
def sumDigitDifferences(nums: List[int]) -> int:
    """
    You are given an array nums consisting of positive integers where all integers have the same number of digits.
    The digit difference between two integers is the count of different digits that are in the same position in the two integers.
    Return the sum of the digit differences between all pairs of integers in nums.

    Example 1:

    >>> sumDigitDifferences(nums = [13,23,12])
    >>> 4
    Explanation:
    We have the following:
    - The digit difference between 13 and 23 is 1.
    - The digit difference between 13 and 12 is 1.
    - The digit difference between 23 and 12 is 2.
    So the total sum of digit differences between all pairs of integers is 1 + 1 + 2 = 4.

    Example 2:

    >>> sumDigitDifferences(nums = [10,10,10,10])
    >>> 0
    Explanation:
    All the integers in the array are the same. So the total sum of digit differences between all pairs of integers will be 0.
    """


Prompt:
def waysToReachStair(k: int) -> int:
    """
    You are given a non-negative integer k. There exists a staircase with an infinite number of stairs, with the lowest stair numbered 0.
    Alice has an integer jump, with an initial value of 0. She starts on stair 1 and wants to reach stair k using any number of operations. If she is on stair i, in one operation she can:

    Go down to stair i - 1. This operation cannot be used consecutively or on stair 0.
    Go up to stair i + 2jump. And then, jump becomes jump + 1.

    Return the total number of ways Alice can reach stair k.
    Note that it is possible that Alice reaches the stair k, and performs some operations to reach the stair k again.

    Example 1:

    >>> waysToReachStair(k = 0)
    >>> 2
    Explanation:
    The 2 possible ways of reaching stair 0 are:

    Alice starts at stair 1.

    Using an operation of the first type, she goes down 1 stair to reach stair 0.

    Alice starts at stair 1.

    Using an operation of the first type, she goes down 1 stair to reach stair 0.
    Using an operation of the second type, she goes up 20 stairs to reach stair 1.
    Using an operation of the first type, she goes down 1 stair to reach stair 0.

    Example 2:

    >>> waysToReachStair(k = 1)
    >>> 4
    Explanation:
    The 4 possible ways of reaching stair 1 are:

    Alice starts at stair 1. Alice is at stair 1.
    Alice starts at stair 1.

    Using an operation of the first type, she goes down 1 stair to reach stair 0.
    Using an operation of the second type, she goes up 20 stairs to reach stair 1.

    Alice starts at stair 1.

    Using an operation of the second type, she goes up 20 stairs to reach stair 2.
    Using an operation of the first type, she goes down 1 stair to reach stair 1.

    Alice starts at stair 1.

    Using an operation of the first type, she goes down 1 stair to reach stair 0.
    Using an operation of the second type, she goes up 20 stairs to reach stair 1.
    Using an operation of the first type, she goes down 1 stair to reach stair 0.
    Using an operation of the second type, she goes up 21 stairs to reach stair 2.
    Using an operation of the first type, she goes down 1 stair to reach stair 1.
    """


Prompt:
from typing import List
def maxUpgrades(count: List[int], upgrade: List[int], sell: List[int], money: List[int]) -> List[int]:
    """
    You have n data centers and need to upgrade their servers.
    You are given four arrays count, upgrade, sell, and money of length n, which show:

    The number of servers
    The cost of upgrading a single server
    The money you get by selling a server
    The money you initially have

    for each data center respectively.
    Return an array answer, where for each data center, the corresponding element in answer represents the maximum number of servers that can be upgraded.
    Note that the money from one data center cannot be used for another data center.

    Example 1:

    >>> maxUpgrades(count = [4,3], upgrade = [3,5], sell = [4,2], money = [8,9])
    >>> [3,2]
    Explanation:
    For the first data center, if we sell one server, we'll have 8 + 4 = 12 units of money and we can upgrade the remaining 3 servers.
    For the second data center, if we sell one server, we'll have 9 + 2 = 11 units of money and we can upgrade the remaining 2 servers.

    Example 2:

    >>> maxUpgrades(count = [1], upgrade = [2], sell = [1], money = [1])
    >>> [0]
    """


Prompt:
from typing import Optional
class TreeNode:
    def __init__(val=0, left=None, right=None):
        self.val = val
        self.left = left
        self.right = right
def minimumLevel(root: Optional[TreeNode]) -> int:
"""
Given the root of a binary tree root where each node has a value, return the level of the tree that has the minimum sum of values among all the levels (in case of a tie, return the lowest level).
Note that the root of the tree is at level 1 and the level of any other node is its distance from the root + 1.

Example 1:

>>> minimumLevel(root = [50,6,2,30,80,7])
>>> 2
Explanation:

Example 2:

>>> minimumLevel(root = [36,17,10,null,null,24])
>>> 3
Explanation:

Example 3:

>>> minimumLevel(root = [5,null,5,null,5])
>>> 1
Explanation:
"""


Prompt:
from typing import List
def duplicateNumbersXOR(nums: List[int]) -> int:
    """
    You are given an array nums, where each number in the array appears either once or twice.
    Return the bitwise XOR of all the numbers that appear twice in the array, or 0 if no number appears twice.

    Example 1:

    >>> duplicateNumbersXOR(nums = [1,2,1,3])
    >>> 1
    Explanation:
    The only number that appears twice in nums is 1.

    Example 2:

    >>> duplicateNumbersXOR(nums = [1,2,3])
    >>> 0
    Explanation:
    No number appears twice in nums.

    Example 3:

    >>> duplicateNumbersXOR(nums = [1,2,2,1])
    >>> 3
    Explanation:
    Numbers 1 and 2 appeared twice. 1 XOR 2 == 3.
    """


Prompt:
from typing import List
def occurrencesOfElement(nums: List[int], queries: List[int], x: int) -> List[int]:
    """
    You are given an integer array nums, an integer array queries, and an integer x.
    For each queries[i], you need to find the index of the queries[i]th occurrence of x in the nums array. If there are fewer than queries[i] occurrences of x, the answer should be -1 for that query.
    Return an integer array answer containing the answers to all queries.

    Example 1:

    >>> occurrencesOfElement(nums = [1,3,1,7], queries = [1,3,2,4], x = 1)
    >>> [0,-1,2,-1]
    Explanation:

    For the 1st query, the first occurrence of 1 is at index 0.
    For the 2nd query, there are only two occurrences of 1 in nums, so the answer is -1.
    For the 3rd query, the second occurrence of 1 is at index 2.
    For the 4th query, there are only two occurrences of 1 in nums, so the answer is -1.

    Example 2:

    >>> occurrencesOfElement(nums = [1,2,3], queries = [10], x = 5)
    >>> [-1]
    Explanation:

    For the 1st query, 5 doesn't exist in nums, so the answer is -1.
    """


Prompt:
from typing import List
def queryResults(limit: int, queries: List[List[int]]) -> List[int]:
    """
    You are given an integer limit and a 2D array queries of size n x 2.
    There are limit + 1 balls with distinct labels in the range [0, limit]. Initially, all balls are uncolored. For every query in queries that is of the form [x, y], you mark ball x with the color y. After each query, you need to find the number of colors among the balls.
    Return an array result of length n, where result[i] denotes the number of colors after ith query.
    Note that when answering a query, lack of a color will not be considered as a color.

    Example 1:

    >>> queryResults(limit = 4, queries = [[1,4],[2,5],[1,3],[3,4]])
    >>> [1,2,2,3]
    Explanation:

    After query 0, ball 1 has color 4.
    After query 1, ball 1 has color 4, and ball 2 has color 5.
    After query 2, ball 1 has color 3, and ball 2 has color 5.
    After query 3, ball 1 has color 3, ball 2 has color 5, and ball 3 has color 4.

    Example 2:

    >>> queryResults(limit = 4, queries = [[0,1],[1,2],[2,2],[3,4],[4,5]])
    >>> [1,2,2,3,4]
    Explanation:

    After query 0, ball 0 has color 1.
    After query 1, ball 0 has color 1, and ball 1 has color 2.
    After query 2, ball 0 has color 1, and balls 1 and 2 have color 2.
    After query 3, ball 0 has color 1, balls 1 and 2 have color 2, and ball 3 has color 4.
    After query 4, ball 0 has color 1, balls 1 and 2 have color 2, ball 3 has color 4, and ball 4 has color 5.
    """


Prompt:
from typing import List
def getResults(queries: List[List[int]]) -> List[bool]:
    """
    There exists an infinite number line, with its origin at 0 and extending towards the positive x-axis.
    You are given a 2D array queries, which contains two types of queries:

    For a query of type 1, queries[i] = [1, x]. Build an obstacle at distance x from the origin. It is guaranteed that there is no obstacle at distance x when the query is asked.
    For a query of type 2, queries[i] = [2, x, sz]. Check if it is possible to place a block of size sz anywhere in the range [0, x] on the line, such that the block entirely lies in the range [0, x]. A block cannot be placed if it intersects with any obstacle, but it may touch it. Note that you do not actually place the block. Queries are separate.

    Return a boolean array results, where results[i] is true if you can place the block specified in the ith query of type 2, and false otherwise.

    Example 1:

    >>> getResults(queries = [[1,2],[2,3,3],[2,3,1],[2,2,2]])
    >>> [false,true,true]
    Explanation:

    For query 0, place an obstacle at x = 2. A block of size at most 2 can be placed before x = 3.

    Example 2:

    >>> getResults(queries = [[1,7],[2,7,6],[1,2],[2,7,5],[2,7,6]])
    >>> [true,true,false]
    Explanation:

    Place an obstacle at x = 7 for query 0. A block of size at most 7 can be placed before x = 7.
    Place an obstacle at x = 2 for query 2. Now, a block of size at most 5 can be placed before x = 7, and a block of size at most 2 before x = 2.
    """


Prompt:
from typing import List
def numberOfPairs(nums1: List[int], nums2: List[int], k: int) -> int:
    """
    You are given 2 integer arrays nums1 and nums2 of lengths n and m respectively. You are also given a positive integer k.
    A pair (i, j) is called good if nums1[i] is divisible by nums2[j] * k (0 <= i <= n - 1, 0 <= j <= m - 1).
    Return the total number of good pairs.

    Example 1:

    >>> numberOfPairs(nums1 = [1,3,4], nums2 = [1,3,4], k = 1)
    >>> 5
    Explanation:
    The 5 good pairs are (0, 0), (1, 0), (1, 1), (2, 0), and (2, 2).
    Example 2:

    >>> numberOfPairs(nums1 = [1,2,4,12], nums2 = [2,4], k = 3)
    >>> 2
    Explanation:
    The 2 good pairs are (3, 0) and (3, 1).
    """


Prompt:
def compressedString(word: str) -> str:
    """
    Given a string word, compress it using the following algorithm:

    Begin with an empty string comp. While word is not empty, use the following operation:

    Remove a maximum length prefix of word made of a single character c repeating at most 9 times.
    Append the length of the prefix followed by c to comp.

    Return the string comp.

    Example 1:

    >>> compressedString(word = "abcde")
    >>> "1a1b1c1d1e"
    Explanation:
    Initially, comp = "". Apply the operation 5 times, choosing "a", "b", "c", "d", and "e" as the prefix in each operation.
    For each prefix, append "1" followed by the character to comp.

    Example 2:

    >>> compressedString(word = "aaaaaaaaaaaaaabb")
    >>> "9a5a2b"
    Explanation:
    Initially, comp = "". Apply the operation 3 times, choosing "aaaaaaaaa", "aaaaa", and "bb" as the prefix in each operation.

    For prefix "aaaaaaaaa", append "9" followed by "a" to comp.
    For prefix "aaaaa", append "5" followed by "a" to comp.
    For prefix "bb", append "2" followed by "b" to comp.
    """


Prompt:
from typing import List
def numberOfPairs(nums1: List[int], nums2: List[int], k: int) -> int:
    """
    You are given 2 integer arrays nums1 and nums2 of lengths n and m respectively. You are also given a positive integer k.
    A pair (i, j) is called good if nums1[i] is divisible by nums2[j] * k (0 <= i <= n - 1, 0 <= j <= m - 1).
    Return the total number of good pairs.

    Example 1:

    >>> numberOfPairs(nums1 = [1,3,4], nums2 = [1,3,4], k = 1)
    >>> 5
    Explanation:
    The 5 good pairs are (0, 0), (1, 0), (1, 1), (2, 0), and (2, 2).
    Example 2:

    >>> numberOfPairs(nums1 = [1,2,4,12], nums2 = [2,4], k = 3)
    >>> 2
    Explanation:
    The 2 good pairs are (3, 0) and (3, 1).
    """


Prompt:
from typing import List
def maximumSumSubsequence(nums: List[int], queries: List[List[int]]) -> int:
    """
    You are given an array nums consisting of integers. You are also given a 2D array queries, where queries[i] = [posi, xi].
    For query i, we first set nums[posi] equal to xi, then we calculate the answer to query i which is the maximum sum of a subsequence of nums where no two adjacent elements are selected.
    Return the sum of the answers to all queries.
    Since the final answer may be very large, return it modulo 109 + 7.
    A subsequence is an array that can be derived from another array by deleting some or no elements without changing the order of the remaining elements.

    Example 1:

    >>> maximumSumSubsequence(nums = [3,5,9], queries = [[1,-2],[0,-3]])
    >>> 21
    Explanation:
    After the 1st query, nums = [3,-2,9] and the maximum sum of a subsequence with non-adjacent elements is 3 + 9 = 12.
    After the 2nd query, nums = [-3,-2,9] and the maximum sum of a subsequence with non-adjacent elements is 9.

    Example 2:

    >>> maximumSumSubsequence(nums = [0,-1], queries = [[0,-5]])
    >>> 0
    Explanation:
    After the 1st query, nums = [-5,-1] and the maximum sum of a subsequence with non-adjacent elements is 0 (choosing an empty subsequence).
    """


Prompt:
def betterCompression(compressed: str) -> str:
    """
    You are given a string compressed representing a compressed version of a string. The format is a character followed by its frequency. For example, "a3b1a1c2" is a compressed version of the string "aaabacc".
    We seek a better compression with the following conditions:

    Each character should appear only once in the compressed version.
    The characters should be in alphabetical order.

    Return the better compression of compressed.
    Note: In the better version of compression, the order of letters may change, which is acceptable.

    Example 1:

    >>> betterCompression(compressed = "a3c9b2c1")
    >>> "a3b2c10"
    Explanation:
    Characters "a" and "b" appear only once in the input, but "c" appears twice, once with a size of 9 and once with a size of 1.
    Hence, in the resulting string, it should have a size of 10.

    Example 2:

    >>> betterCompression(compressed = "c2b3a1")
    >>> "a1b3c2"

    Example 3:

    >>> betterCompression(compressed = "a2b4c1")
    >>> "a2b4c1"
    """


Prompt:
def minimumChairs(s: str) -> int:
    """
    You are given a string s. Simulate events at each second i:

    If s[i] == 'E', a person enters the waiting room and takes one of the chairs in it.
    If s[i] == 'L', a person leaves the waiting room, freeing up a chair.

    Return the minimum number of chairs needed so that a chair is available for every person who enters the waiting room given that it is initially empty.

    Example 1:

    >>> minimumChairs(s = "EEEEEEE")
    >>> 7
    Explanation:
    After each second, a person enters the waiting room and no person leaves it. Therefore, a minimum of 7 chairs is needed.

    Example 2:

    >>> minimumChairs(s = "ELELEEL")
    >>> 2
    Explanation:
    Let's consider that there are 2 chairs in the waiting room. The table below shows the state of the waiting room at each second.

    Second
    Event
    People in the Waiting Room
    Available Chairs

    0
    Enter
    1
    1

    1
    Leave
    0
    2

    2
    Enter
    1
    1

    3
    Leave
    0
    2

    4
    Enter
    1
    1

    5
    Enter
    2
    0

    6
    Leave
    1
    1

    Example 3:

    >>> minimumChairs(s = "ELEELEELLL")
    >>> 3
    Explanation:
    Let's consider that there are 3 chairs in the waiting room. The table below shows the state of the waiting room at each second.

    Second
    Event
    People in the Waiting Room
    Available Chairs

    0
    Enter
    1
    2

    1
    Leave
    0
    3

    2
    Enter
    1
    2

    3
    Enter
    2
    1

    4
    Leave
    1
    2

    5
    Enter
    2
    1

    6
    Enter
    3
    0

    7
    Leave
    2
    1

    8
    Leave
    1
    2

    9
    Leave
    0
    3
    """


Prompt:
from typing import List
def countDays(days: int, meetings: List[List[int]]) -> int:
    """
    You are given a positive integer days representing the total number of days an employee is available for work (starting from day 1). You are also given a 2D array meetings of size n where, meetings[i] = [start_i, end_i] represents the starting and ending days of meeting i (inclusive).
    Return the count of days when the employee is available for work but no meetings are scheduled.
    Note: The meetings may overlap.

    Example 1:

    >>> countDays(days = 10, meetings = [[5,7],[1,3],[9,10]])
    >>> 2
    Explanation:
    There is no meeting scheduled on the 4th and 8th days.

    Example 2:

    >>> countDays(days = 5, meetings = [[2,4],[1,3]])
    >>> 1
    Explanation:
    There is no meeting scheduled on the 5th day.

    Example 3:

    >>> countDays(days = 6, meetings = [[1,6]])
    >>> 0
    Explanation:
    Meetings are scheduled for all working days.
    """


Prompt:
def clearStars(s: str) -> str:
    """
    You are given a string s. It may contain any number of '*' characters. Your task is to remove all '*' characters.
    While there is a '*', do the following operation:

    Delete the leftmost '*' and the smallest non-'*' character to its left. If there are several smallest characters, you can delete any of them.

    Return the lexicographically smallest resulting string after removing all '*' characters.

    Example 1:

    >>> clearStars(s = "aaba*")
    >>> "aab"
    Explanation:
    We should delete one of the 'a' characters with '*'. If we choose s[3], s becomes the lexicographically smallest.

    Example 2:

    >>> clearStars(s = "abc")
    >>> "abc"
    Explanation:
    There is no '*' in the string.
    """


Prompt:
from typing import List
def minimumDifference(nums: List[int], k: int) -> int:
    """
    You are given an array nums and an integer k. You need to find a subarray of nums such that the absolute difference between k and the bitwise OR of the subarray elements is as small as possible. In other words, select a subarray nums[l..r] such that |k - (nums[l] OR nums[l + 1] ... OR nums[r])| is minimum.
    Return the minimum possible value of the absolute difference.
    A subarray is a contiguous non-empty sequence of elements within an array.

    Example 1:

    >>> minimumDifference(nums = [1,2,4,5], k = 3)
    >>> 0
    Explanation:
    The subarray nums[0..1] has OR value 3, which gives the minimum absolute difference |3 - 3| = 0.

    Example 2:

    >>> minimumDifference(nums = [1,3,1,3], k = 2)
    >>> 1
    Explanation:
    The subarray nums[1..1] has OR value 3, which gives the minimum absolute difference |3 - 2| = 1.

    Example 3:

    >>> minimumDifference(nums = [1], k = 10)
    >>> 9
    Explanation:
    There is a single subarray with OR value 1, which gives the minimum absolute difference |10 - 1| = 9.
    """


Prompt:
from typing import List
def orArray(nums: List[int]) -> List[int]:
    """
    Given an array nums of length n, return an array answer of length n - 1 such that answer[i] = nums[i] | nums[i + 1] where | is the bitwise OR operation.

    Example 1:

    >>> orArray(nums = [1,3,7,15])
    >>> [3,7,15]

    Example 2:

    >>> orArray(nums = [8,4,2])
    >>> [12,6]

    Example 3:

    >>> orArray(nums = [5,4,9,11])
    >>> [5,13,11]
    """


Prompt:
def clearDigits(s: str) -> str:
    """
    You are given a string s.
    Your task is to remove all digits by doing this operation repeatedly:

    Delete the first digit and the closest non-digit character to its left.

    Return the resulting string after removing all digits.
    Note that the operation cannot be performed on a digit that does not have any non-digit character to its left.

    Example 1:

    >>> clearDigits(s = "abc")
    >>> "abc"
    Explanation:
    There is no digit in the string.

    Example 2:

    >>> clearDigits(s = "cb34")
    >>> ""
    Explanation:
    First, we apply the operation on s[2], and s becomes "c4".
    Then we apply the operation on s[1], and s becomes "".
    """


Prompt:
from typing import List
def findWinningPlayer(skills: List[int], k: int) -> int:
    """
    A competition consists of n players numbered from 0 to n - 1.
    You are given an integer array skills of size n and a positive integer k, where skills[i] is the skill level of player i. All integers in skills are unique.
    All players are standing in a queue in order from player 0 to player n - 1.
    The competition process is as follows:

    The first two players in the queue play a game, and the player with the higher skill level wins.
    After the game, the winner stays at the beginning of the queue, and the loser goes to the end of it.

    The winner of the competition is the first player who wins k games in a row.
    Return the initial index of the winning player.

    Example 1:

    >>> findWinningPlayer(skills = [4,2,6,3,9], k = 2)
    >>> 2
    Explanation:
    Initially, the queue of players is [0,1,2,3,4]. The following process happens:

    Players 0 and 1 play a game, since the skill of player 0 is higher than that of player 1, player 0 wins. The resulting queue is [0,2,3,4,1].
    Players 0 and 2 play a game, since the skill of player 2 is higher than that of player 0, player 2 wins. The resulting queue is [2,3,4,1,0].
    Players 2 and 3 play a game, since the skill of player 2 is higher than that of player 3, player 2 wins. The resulting queue is [2,4,1,0,3].

    Player 2 won k = 2 games in a row, so the winner is player 2.

    Example 2:

    >>> findWinningPlayer(skills = [2,5,4], k = 3)
    >>> 1
    Explanation:
    Initially, the queue of players is [0,1,2]. The following process happens:

    Players 0 and 1 play a game, since the skill of player 1 is higher than that of player 0, player 1 wins. The resulting queue is [1,2,0].
    Players 1 and 2 play a game, since the skill of player 1 is higher than that of player 2, player 1 wins. The resulting queue is [1,0,2].
    Players 1 and 0 play a game, since the skill of player 1 is higher than that of player 0, player 1 wins. The resulting queue is [1,2,0].

    Player 1 won k = 3 games in a row, so the winner is player 1.
    """


Prompt:
from typing import List
def maximumLength(nums: List[int], k: int) -> int:
    """
    You are given an integer array nums and a non-negative integer k. A sequence of integers seq is called good if there are at most k indices i in the range [0, seq.length - 2] such that seq[i] != seq[i + 1].
    Return the maximum possible length of a good subsequence of nums.

    Example 1:

    >>> maximumLength(nums = [1,2,1,1,3], k = 2)
    >>> 4
    Explanation:
    The maximum length subsequence is [1,2,1,1,3].

    Example 2:

    >>> maximumLength(nums = [1,2,3,4,5,1], k = 0)
    >>> 2
    Explanation:
    The maximum length subsequence is [1,2,3,4,5,1].
    """


Prompt:
from typing import List
def maximumLength(nums: List[int], k: int) -> int:
    """
    You are given an integer array nums and a non-negative integer k. A sequence of integers seq is called good if there are at most k indices i in the range [0, seq.length - 2] such that seq[i] != seq[i + 1].
    Return the maximum possible length of a good subsequence of nums.

    Example 1:

    >>> maximumLength(nums = [1,2,1,1,3], k = 2)
    >>> 4
    Explanation:
    The maximum length subsequence is [1,2,1,1,3].

    Example 2:

    >>> maximumLength(nums = [1,2,3,4,5,1], k = 0)
    >>> 2
    Explanation:
    The maximum length subsequence is [1,2,3,4,5,1].
    """


Prompt:
def numberOfChild(n: int, k: int) -> int:
    """
    You are given two positive integers n and k. There are n children numbered from 0 to n - 1 standing in a queue in order from left to right.
    Initially, child 0 holds a ball and the direction of passing the ball is towards the right direction. After each second, the child holding the ball passes it to the child next to them. Once the ball reaches either end of the line, i.e. child 0 or child n - 1, the direction of passing is reversed.
    Return the number of the child who receives the ball after k seconds.

    Example 1:

    >>> numberOfChild(n = 3, k = 5)
    >>> 1
    Explanation:

    Time elapsed
    Children

    0
    [0, 1, 2]

    1
    [0, 1, 2]

    2
    [0, 1, 2]

    3
    [0, 1, 2]

    4
    [0, 1, 2]

    5
    [0, 1, 2]

    Example 2:

    >>> numberOfChild(n = 5, k = 6)
    >>> 2
    Explanation:

    Time elapsed
    Children

    0
    [0, 1, 2, 3, 4]

    1
    [0, 1, 2, 3, 4]

    2
    [0, 1, 2, 3, 4]

    3
    [0, 1, 2, 3, 4]

    4
    [0, 1, 2, 3, 4]

    5
    [0, 1, 2, 3, 4]

    6
    [0, 1, 2, 3, 4]

    Example 3:

    >>> numberOfChild(n = 4, k = 2)
    >>> 2
    Explanation:

    Time elapsed
    Children

    0
    [0, 1, 2, 3]

    1
    [0, 1, 2, 3]

    2
    [0, 1, 2, 3]
    """


Prompt:
def valueAfterKSeconds(n: int, k: int) -> int:
    """
    You are given two integers n and k.
    Initially, you start with an array a of n integers where a[i] = 1 for all 0 <= i <= n - 1. After each second, you simultaneously update each element to be the sum of all its preceding elements plus the element itself. For example, after one second, a[0] remains the same, a[1] becomes a[0] + a[1], a[2] becomes a[0] + a[1] + a[2], and so on.
    Return the value of a[n - 1] after k seconds.
    Since the answer may be very large, return it modulo 109 + 7.

    Example 1:

    >>> valueAfterKSeconds(n = 4, k = 5)
    >>> 56
    Explanation:

    Second
    State After

    0
    [1,1,1,1]

    1
    [1,2,3,4]

    2
    [1,3,6,10]

    3
    [1,4,10,20]

    4
    [1,5,15,35]

    5
    [1,6,21,56]

    Example 2:

    >>> valueAfterKSeconds(n = 5, k = 3)
    >>> 35
    Explanation:

    Second
    State After

    0
    [1,1,1,1,1]

    1
    [1,2,3,4,5]

    2
    [1,3,6,10,15]

    3
    [1,4,10,20,35]
    """


Prompt:
from typing import List
def maxTotalReward(rewardValues: List[int]) -> int:
    """
    You are given an integer array rewardValues of length n, representing the values of rewards.
    Initially, your total reward x is 0, and all indices are unmarked. You are allowed to perform the following operation any number of times:

    Choose an unmarked index i from the range [0, n - 1].
    If rewardValues[i] is greater than your current total reward x, then add rewardValues[i] to x (i.e., x = x + rewardValues[i]), and mark the index i.

    Return an integer denoting the maximum total reward you can collect by performing the operations optimally.

    Example 1:

    >>> maxTotalReward(rewardValues = [1,1,3,3])
    >>> 4
    Explanation:
    During the operations, we can choose to mark the indices 0 and 2 in order, and the total reward will be 4, which is the maximum.

    Example 2:

    >>> maxTotalReward(rewardValues = [1,6,4,3,2])
    >>> 11
    Explanation:
    Mark the indices 0, 2, and 1 in order. The total reward will then be 11, which is the maximum.
    """


Prompt:
from typing import List
def maxTotalReward(rewardValues: List[int]) -> int:
    """
    You are given an integer array rewardValues of length n, representing the values of rewards.
    Initially, your total reward x is 0, and all indices are unmarked. You are allowed to perform the following operation any number of times:

    Choose an unmarked index i from the range [0, n - 1].
    If rewardValues[i] is greater than your current total reward x, then add rewardValues[i] to x (i.e., x = x + rewardValues[i]), and mark the index i.

    Return an integer denoting the maximum total reward you can collect by performing the operations optimally.

    Example 1:

    >>> maxTotalReward(rewardValues = [1,1,3,3])
    >>> 4
    Explanation:
    During the operations, we can choose to mark the indices 0 and 2 in order, and the total reward will be 4, which is the maximum.

    Example 2:

    >>> maxTotalReward(rewardValues = [1,6,4,3,2])
    >>> 11
    Explanation:
    Mark the indices 0, 2, and 1 in order. The total reward will then be 11, which is the maximum.
    """


Prompt:
def numberOfWays(n: int) -> int:
    """
    You have an infinite number of coins with values 1, 2, and 6, and only 2 coins with value 4.
    Given an integer n, return the number of ways to make the sum of n with the coins you have.
    Since the answer may be very large, return it modulo 109 + 7.
    Note that the order of the coins doesn't matter and [2, 2, 3] is the same as [2, 3, 2].

    Example 1:

    >>> numberOfWays(n = 4)
    >>> 4
    Explanation:
    Here are the four combinations: [1, 1, 1, 1], [1, 1, 2], [2, 2], [4].

    Example 2:

    >>> numberOfWays(n = 12)
    >>> 22
    Explanation:
    Note that [4, 4, 4] is not a valid combination since we cannot use 4 three times.

    Example 3:

    >>> numberOfWays(n = 5)
    >>> 4
    Explanation:
    Here are the four combinations: [1, 1, 1, 1, 1], [1, 1, 1, 2], [1, 2, 2], [1, 4].
    """


Prompt:
from typing import List
def countCompleteDayPairs(hours: List[int]) -> int:
    """
    Given an integer array hours representing times in hours, return an integer denoting the number of pairs i, j where i < j and hours[i] + hours[j] forms a complete day.
    A complete day is defined as a time duration that is an exact multiple of 24 hours.
    For example, 1 day is 24 hours, 2 days is 48 hours, 3 days is 72 hours, and so on.

    Example 1:

    >>> countCompleteDayPairs(hours = [12,12,30,24,24])
    >>> 2
    Explanation:
    The pairs of indices that form a complete day are (0, 1) and (3, 4).

    Example 2:

    >>> countCompleteDayPairs(hours = [72,48,24,3])
    >>> 3
    Explanation:
    The pairs of indices that form a complete day are (0, 1), (0, 2), and (1, 2).
    """


Prompt:
from typing import List
def countCompleteDayPairs(hours: List[int]) -> int:
    """
    Given an integer array hours representing times in hours, return an integer denoting the number of pairs i, j where i < j and hours[i] + hours[j] forms a complete day.
    A complete day is defined as a time duration that is an exact multiple of 24 hours.
    For example, 1 day is 24 hours, 2 days is 48 hours, 3 days is 72 hours, and so on.

    Example 1:

    >>> countCompleteDayPairs(hours = [12,12,30,24,24])
    >>> 2
    Explanation: The pairs of indices that form a complete day are (0, 1) and (3, 4).

    Example 2:

    >>> countCompleteDayPairs(hours = [72,48,24,3])
    >>> 3
    Explanation: The pairs of indices that form a complete day are (0, 1), (0, 2), and (1, 2).
    """


Prompt:
from typing import List
def maximumTotalDamage(power: List[int]) -> int:
    """
    A magician has various spells.
    You are given an array power, where each element represents the damage of a spell. Multiple spells can have the same damage value.
    It is a known fact that if a magician decides to cast a spell with a damage of power[i], they cannot cast any spell with a damage of power[i] - 2, power[i] - 1, power[i] + 1, or power[i] + 2.
    Each spell can be cast only once.
    Return the maximum possible total damage that a magician can cast.

    Example 1:

    >>> maximumTotalDamage(power = [1,1,3,4])
    >>> 6
    Explanation:
    The maximum possible damage of 6 is produced by casting spells 0, 1, 3 with damage 1, 1, 4.

    Example 2:

    >>> maximumTotalDamage(power = [7,1,6,6])
    >>> 13
    Explanation:
    The maximum possible damage of 13 is produced by casting spells 1, 2, 3 with damage 1, 6, 6.
    """


Prompt:
from typing import List
def countOfPeaks(nums: List[int], queries: List[List[int]]) -> List[int]:
    """
    A peak in an array arr is an element that is greater than its previous and next element in arr.
    You are given an integer array nums and a 2D integer array queries.
    You have to process queries of two types:

    queries[i] = [1, li, ri], determine the count of peak elements in the subarray nums[li..ri].
    queries[i] = [2, indexi, vali], change nums[indexi] to vali.

    Return an array answer containing the results of the queries of the first type in order.
    Notes:

    The first and the last element of an array or a subarray cannot be a peak.

    Example 1:

    >>> countOfPeaks(nums = [3,1,4,2,5], queries = [[2,3,4],[1,0,4]])
    >>> [0]
    Explanation:
    First query: We change nums[3] to 4 and nums becomes [3,1,4,4,5].
    Second query: The number of peaks in the [3,1,4,4,5] is 0.

    Example 2:

    >>> countOfPeaks(nums = [4,1,4,2,1,5], queries = [[2,2,4],[1,0,2],[1,0,4]])
    >>> [0,1]
    Explanation:
    First query: nums[2] should become 4, but it is already set to 4.
    Second query: The number of peaks in the [4,1,4] is 0.
    Third query: The second 4 is a peak in the [4,1,4,2,1].
    """


Prompt:
from typing import List
def minMoves(rooks: List[List[int]]) -> int:
    """
    Given a 2D array rooks of length n, where rooks[i] = [xi, yi] indicates the position of a rook on an n x n chess board. Your task is to move the rooks 1 cell at a time vertically or horizontally (to an adjacent cell) such that the board becomes peaceful.
    A board is peaceful if there is exactly one rook in each row and each column.
    Return the minimum number of moves required to get a peaceful board.
    Note that at no point can there be two rooks in the same cell.

    Example 1:

    >>> minMoves(rooks = [[0,0],[1,0],[1,1]])
    >>> 3
    Explanation:

    Example 2:

    >>> minMoves(rooks = [[0,0],[0,1],[0,2],[0,3]])
    >>> 6
    Explanation:
    """


Prompt:
from typing import List
def minimumOperations(nums: List[int]) -> int:
    """
    You are given an integer array nums. In one operation, you can add or subtract 1 from any element of nums.
    Return the minimum number of operations to make all elements of nums divisible by 3.

    Example 1:

    >>> minimumOperations(nums = [1,2,3,4])
    >>> 3
    Explanation:
    All array elements can be made divisible by 3 using 3 operations:

    Subtract 1 from 1.
    Add 1 to 2.
    Subtract 1 from 4.

    Example 2:

    >>> minimumOperations(nums = [3,6,9])
    >>> 0
    """


Prompt:
from typing import List
def minOperations(nums: List[int]) -> int:
    """
    You are given a binary array nums.
    You can do the following operation on the array any number of times (possibly zero):

    Choose any 3 consecutive elements from the array and flip all of them.

    Flipping an element means changing its value from 0 to 1, and from 1 to 0.
    Return the minimum number of operations required to make all elements in nums equal to 1. If it is impossible, return -1.

    Example 1:

    >>> minOperations(nums = [0,1,1,1,0,0])
    >>> 3
    Explanation:
    We can do the following operations:

    Choose the elements at indices 0, 1 and 2. The resulting array is nums = [1,0,0,1,0,0].
    Choose the elements at indices 1, 2 and 3. The resulting array is nums = [1,1,1,0,0,0].
    Choose the elements at indices 3, 4 and 5. The resulting array is nums = [1,1,1,1,1,1].

    Example 2:

    >>> minOperations(nums = [0,1,1,1])
    >>> -1
    Explanation:
    It is impossible to make all elements equal to 1.
    """


Prompt:
from typing import List
def minOperations(nums: List[int]) -> int:
    """
    You are given a binary array nums.
    You can do the following operation on the array any number of times (possibly zero):

    Choose any index i from the array and flip all the elements from index i to the end of the array.

    Flipping an element means changing its value from 0 to 1, and from 1 to 0.
    Return the minimum number of operations required to make all elements in nums equal to 1.

    Example 1:

    >>> minOperations(nums = [0,1,1,0,1])
    >>> 4
    Explanation:
    We can do the following operations:

    Choose the index i = 1. The resulting array will be nums = [0,0,0,1,0].
    Choose the index i = 0. The resulting array will be nums = [1,1,1,0,1].
    Choose the index i = 4. The resulting array will be nums = [1,1,1,0,0].
    Choose the index i = 3. The resulting array will be nums = [1,1,1,1,1].

    Example 2:

    >>> minOperations(nums = [1,0,0,0])
    >>> 1
    Explanation:
    We can do the following operation:

    Choose the index i = 1. The resulting array will be nums = [1,1,1,1].
    """


Prompt:
from typing import List
def numberOfPermutations(n: int, requirements: List[List[int]]) -> int:
    """
    You are given an integer n and a 2D array requirements, where requirements[i] = [endi, cnti] represents the end index and the inversion count of each requirement.
    A pair of indices (i, j) from an integer array nums is called an inversion if:

    i < j and nums[i] > nums[j]

    Return the number of permutations perm of [0, 1, 2, ..., n - 1] such that for all requirements[i], perm[0..endi] has exactly cnti inversions.
    Since the answer may be very large, return it modulo 109 + 7.

    Example 1:

    >>> numberOfPermutations(n = 3, requirements = [[2,2],[0,0]])
    >>> 2
    Explanation:
    The two permutations are:

    [2, 0, 1]

    Prefix [2, 0, 1] has inversions (0, 1) and (0, 2).
    Prefix [2] has 0 inversions.

    [1, 2, 0]

    Prefix [1, 2, 0] has inversions (0, 2) and (1, 2).
    Prefix [1] has 0 inversions.

    Example 2:

    >>> numberOfPermutations(n = 3, requirements = [[2,2],[1,1],[0,0]])
    >>> 1
    Explanation:
    The only satisfying permutation is [2, 0, 1]:

    Prefix [2, 0, 1] has inversions (0, 1) and (0, 2).
    Prefix [2, 0] has an inversion (0, 1).
    Prefix [2] has 0 inversions.

    Example 3:

    >>> numberOfPermutations(n = 2, requirements = [[0,0],[1,0]])
    >>> 1
    Explanation:
    The only satisfying permutation is [0, 1]:

    Prefix [0] has 0 inversions.
    Prefix [0, 1] has an inversion (0, 1).
    """


Prompt:
from typing import List
def minimumAverage(nums: List[int]) -> float:
    """
    You have an array of floating point numbers averages which is initially empty. You are given an array nums of n integers where n is even.
    You repeat the following procedure n / 2 times:

    Remove the smallest element, minElement, and the largest element maxElement, from nums.
    Add (minElement + maxElement) / 2 to averages.

    Return the minimum element in averages.

    Example 1:

    >>> minimumAverage(nums = [7,8,3,4,15,13,4,1])
    >>> 5.5
    Explanation:

    step
    nums
    averages

    0
    [7,8,3,4,15,13,4,1]
    []

    1
    [7,8,3,4,13,4]
    [8]

    2
    [7,8,4,4]
    [8,8]

    3
    [7,4]
    [8,8,6]

    4
    []
    [8,8,6,5.5]

    The smallest element of averages, 5.5, is returned.
    Example 2:

    >>> minimumAverage(nums = [1,9,8,3,10,5])
    >>> 5.5
    Explanation:

    step
    nums
    averages

    0
    [1,9,8,3,10,5]
    []

    1
    [9,8,3,5]
    [5.5]

    2
    [8,5]
    [5.5,6]

    3
    []
    [5.5,6,6.5]

    Example 3:

    >>> minimumAverage(nums = [1,2,3,7,8,9])
    >>> 5.0
    Explanation:

    step
    nums
    averages

    0
    [1,2,3,7,8,9]
    []

    1
    [2,3,7,8]
    [5]

    2
    [3,7]
    [5,5]

    3
    []
    [5,5,5]
    """


Prompt:
from typing import List
def minimumArea(grid: List[List[int]]) -> int:
    """
    You are given a 2D binary array grid. Find a rectangle with horizontal and vertical sides with the smallest area, such that all the 1's in grid lie inside this rectangle.
    Return the minimum possible area of the rectangle.

    Example 1:

    >>> minimumArea(grid = [[0,1,0],[1,0,1]])
    >>> 6
    Explanation:

    The smallest rectangle has a height of 2 and a width of 3, so it has an area of 2 * 3 = 6.

    Example 2:

    >>> minimumArea(grid = [[1,0],[0,0]])
    >>> 1
    Explanation:

    The smallest rectangle has both height and width 1, so its area is 1 * 1 = 1.
    """


Prompt:
from typing import List
def maximumTotalCost(nums: List[int]) -> int:
    """
    You are given an integer array nums with length n.
    The cost of a subarray nums[l..r], where 0 <= l <= r < n, is defined as:
    cost(l, r) = nums[l] - nums[l + 1] + ... + nums[r] * (−1)r − l
    Your task is to split nums into subarrays such that the total cost of the subarrays is maximized, ensuring each element belongs to exactly one subarray.
    Formally, if nums is split into k subarrays, where k > 1, at indices i1, i2, ..., ik − 1, where 0 <= i1 < i2 < ... < ik - 1 < n - 1, then the total cost will be:
    cost(0, i1) + cost(i1 + 1, i2) + ... + cost(ik − 1 + 1, n − 1)
    Return an integer denoting the maximum total cost of the subarrays after splitting the array optimally.
    Note: If nums is not split into subarrays, i.e. k = 1, the total cost is simply cost(0, n - 1).

    Example 1:

    >>> maximumTotalCost(nums = [1,-2,3,4])
    >>> 10
    Explanation:
    One way to maximize the total cost is by splitting [1, -2, 3, 4] into subarrays [1, -2, 3] and [4]. The total cost will be (1 + 2 + 3) + 4 = 10.

    Example 2:

    >>> maximumTotalCost(nums = [1,-1,1,-1])
    >>> 4
    Explanation:
    One way to maximize the total cost is by splitting [1, -1, 1, -1] into subarrays [1, -1] and [1, -1]. The total cost will be (1 + 1) + (1 + 1) = 4.

    Example 3:

    >>> maximumTotalCost(nums = [0])
    >>> 0
    Explanation:
    We cannot split the array further, so the answer is 0.

    Example 4:

    >>> maximumTotalCost(nums = [1,-1])
    >>> 2
    Explanation:
    Selecting the whole array gives a total cost of 1 + 1 = 2, which is the maximum.
    """


Prompt:
from typing import List
def minimumSum(grid: List[List[int]]) -> int:
    """
    You are given a 2D binary array grid. You need to find 3 non-overlapping rectangles having non-zero areas with horizontal and vertical sides such that all the 1's in grid lie inside these rectangles.
    Return the minimum possible sum of the area of these rectangles.
    Note that the rectangles are allowed to touch.

    Example 1:

    >>> minimumSum(grid = [[1,0,1],[1,1,1]])
    >>> 5
    Explanation:

    The 1's at (0, 0) and (1, 0) are covered by a rectangle of area 2.
    The 1's at (0, 2) and (1, 2) are covered by a rectangle of area 2.
    The 1 at (1, 1) is covered by a rectangle of area 1.

    Example 2:

    >>> minimumSum(grid = [[1,0,1,0],[0,1,0,1]])
    >>> 5
    Explanation:

    The 1's at (0, 0) and (0, 2) are covered by a rectangle of area 3.
    The 1 at (1, 1) is covered by a rectangle of area 1.
    The 1 at (1, 3) is covered by a rectangle of area 1.
    """


Prompt:
from typing import List
def tripletCount(a: List[int], b: List[int], c: List[int]) -> int:
    """
    Given three integer arrays a, b, and c, return the number of triplets (a[i], b[j], c[k]), such that the bitwise XOR of the elements of each triplet has an even number of set bits.

    Example 1:

    >>> tripletCount(a = [1], b = [2], c = [3])
    >>> 1
    Explanation:
    The only triplet is (a[0], b[0], c[0]) and their XOR is: 1 XOR 2 XOR 3 = 002.

    Example 2:

    >>> tripletCount(a = [1,1], b = [2,3], c = [1,5])
    >>> 4
    Explanation:
    Consider these four triplets:

    (a[0], b[1], c[0]): 1 XOR 3 XOR 1 = 0112
    (a[1], b[1], c[0]): 1 XOR 3 XOR 1 = 0112
    (a[0], b[0], c[1]): 1 XOR 2 XOR 5 = 1102
    (a[1], b[0], c[1]): 1 XOR 2 XOR 5 = 1102
    """


Prompt:
def maxHeightOfTriangle(red: int, blue: int) -> int:
    """
    You are given two integers red and blue representing the count of red and blue colored balls. You have to arrange these balls to form a triangle such that the 1st row will have 1 ball, the 2nd row will have 2 balls, the 3rd row will have 3 balls, and so on.
    All the balls in a particular row should be the same color, and adjacent rows should have different colors.
    Return the maximum height of the triangle that can be achieved.

    Example 1:

    >>> maxHeightOfTriangle(red = 2, blue = 4)
    >>> 3
    Explanation:

    The only possible arrangement is shown above.

    Example 2:

    >>> maxHeightOfTriangle(red = 2, blue = 1)
    >>> 2
    Explanation:

    The only possible arrangement is shown above.

    Example 3:

    >>> maxHeightOfTriangle(red = 1, blue = 1)
    >>> 1

    Example 4:

    >>> maxHeightOfTriangle(red = 10, blue = 1)
    >>> 2
    Explanation:

    The only possible arrangement is shown above.
    """


Prompt:
from typing import List
def maximumLength(nums: List[int]) -> int:
    """
    You are given an integer array nums.
    A subsequence sub of nums with length x is called valid if it satisfies:

    (sub[0] + sub[1]) % 2 == (sub[1] + sub[2]) % 2 == ... == (sub[x - 2] + sub[x - 1]) % 2.

    Return the length of the longest valid subsequence of nums.
    A subsequence is an array that can be derived from another array by deleting some or no elements without changing the order of the remaining elements.

    Example 1:

    >>> maximumLength(nums = [1,2,3,4])
    >>> 4
    Explanation:
    The longest valid subsequence is [1, 2, 3, 4].

    Example 2:

    >>> maximumLength(nums = [1,2,1,1,2,1,2])
    >>> 6
    Explanation:
    The longest valid subsequence is [1, 2, 1, 2, 1, 2].

    Example 3:

    >>> maximumLength(nums = [1,3])
    >>> 2
    Explanation:
    The longest valid subsequence is [1, 3].
    """


Prompt:
from typing import List
def maximumLength(nums: List[int], k: int) -> int:
    """
    You are given an integer array nums and a positive integer k.
    A subsequence sub of nums with length x is called valid if it satisfies:

    (sub[0] + sub[1]) % k == (sub[1] + sub[2]) % k == ... == (sub[x - 2] + sub[x - 1]) % k.

    Return the length of the longest valid subsequence of nums.

    Example 1:

    >>> maximumLength(nums = [1,2,3,4,5], k = 2)
    >>> 5
    Explanation:
    The longest valid subsequence is [1, 2, 3, 4, 5].

    Example 2:

    >>> maximumLength(nums = [1,4,2,3,1,4], k = 3)
    >>> 4
    Explanation:
    The longest valid subsequence is [1, 4, 1, 4].
    """


Prompt:
from typing import List
def minimumDiameterAfterMerge(edges1: List[List[int]], edges2: List[List[int]]) -> int:
    """
    There exist two undirected trees with n and m nodes, numbered from 0 to n - 1 and from 0 to m - 1, respectively. You are given two 2D integer arrays edges1 and edges2 of lengths n - 1 and m - 1, respectively, where edges1[i] = [ai, bi] indicates that there is an edge between nodes ai and bi in the first tree and edges2[i] = [ui, vi] indicates that there is an edge between nodes ui and vi in the second tree.
    You must connect one node from the first tree with another node from the second tree with an edge.
    Return the minimum possible diameter of the resulting tree.
    The diameter of a tree is the length of the longest path between any two nodes in the tree.

    Example 1:

    >>> minimumDiameterAfterMerge(edges1 = [[0,1],[0,2],[0,3]], edges2 = [[0,1]])
    >>> 3
    Explanation:
    We can obtain a tree of diameter 3 by connecting node 0 from the first tree with any node from the second tree.

    Example 2:

    >>> minimumDiameterAfterMerge(edges1 = [[0,1],[0,2],[0,3],[2,4],[2,5],[3,6],[2,7]], edges2 = [[0,1],[0,2],[0,3],[2,4],[2,5],[3,6],[2,7]])
    >>> 5
    Explanation:
    We can obtain a tree of diameter 5 by connecting node 0 from the first tree with node 0 from the second tree.
    """


Prompt:
from typing import List
def maxScore(nums: List[int]) -> int:
    """
    Given an array nums, you have to get the maximum score starting from index 0 and hopping until you reach the last element of the array.
    In each hop, you can jump from index i to an index j > i, and you get a score of (j - i) * nums[j].
    Return the maximum score you can get.

    Example 1:

    >>> maxScore(nums = [1,5,8])
    >>> 16
    Explanation:
    There are two possible ways to reach the last element:

    0 -> 1 -> 2 with a score of (1 - 0) * 5 + (2 - 1) * 8 = 13.
    0 -> 2 with a score of (2 - 0) * 8 = 16.

    Example 2:

    >>> maxScore(nums = [4,5,2,8,9,1,3])
    >>> 42
    Explanation:
    We can do the hopping 0 -> 4 -> 6 with a score of (4 - 0) * 9 + (6 - 4) * 3 = 42.
    """


Prompt:
from typing import List
def numberOfAlternatingGroups(colors: List[int]) -> int:
    """
    There is a circle of red and blue tiles. You are given an array of integers colors. The color of tile i is represented by colors[i]:

    colors[i] == 0 means that tile i is red.
    colors[i] == 1 means that tile i is blue.

    Every 3 contiguous tiles in the circle with alternating colors (the middle tile has a different color from its left and right tiles) is called an alternating group.
    Return the number of alternating groups.
    Note that since colors represents a circle, the first and the last tiles are considered to be next to each other.

    Example 1:

    >>> numberOfAlternatingGroups(colors = [1,1,1])
    >>> 0
    Explanation:

    Example 2:

    >>> numberOfAlternatingGroups(colors = [0,1,0,0,1])
    >>> 3
    Explanation:

    Alternating groups:
    """


Prompt:
from typing import List
def maximumPoints(enemyEnergies: List[int], currentEnergy: int) -> int:
    """
    You are given an integer array enemyEnergies denoting the energy values of various enemies.
    You are also given an integer currentEnergy denoting the amount of energy you have initially.
    You start with 0 points, and all the enemies are unmarked initially.
    You can perform either of the following operations zero or multiple times to gain points:

    Choose an unmarked enemy, i, such that currentEnergy >= enemyEnergies[i]. By choosing this option:

    You gain 1 point.
    Your energy is reduced by the enemy's energy, i.e. currentEnergy = currentEnergy - enemyEnergies[i].

    If you have at least 1 point, you can choose an unmarked enemy, i. By choosing this option:

    Your energy increases by the enemy's energy, i.e. currentEnergy = currentEnergy + enemyEnergies[i].
    The enemy i is marked.

    Return an integer denoting the maximum points you can get in the end by optimally performing operations.

    Example 1:

    >>> maximumPoints(enemyEnergies = [3,2,2], currentEnergy = 2)
    >>> 3
    Explanation:
    The following operations can be performed to get 3 points, which is the maximum:

    First operation on enemy 1: points increases by 1, and currentEnergy decreases by 2. So, points = 1, and currentEnergy = 0.
    Second operation on enemy 0: currentEnergy increases by 3, and enemy 0 is marked. So, points = 1, currentEnergy = 3, and marked enemies = [0].
    First operation on enemy 2: points increases by 1, and currentEnergy decreases by 2. So, points = 2, currentEnergy = 1, and marked enemies = [0].
    Second operation on enemy 2: currentEnergy increases by 2, and enemy 2 is marked. So, points = 2, currentEnergy = 3, and marked enemies = [0, 2].
    First operation on enemy 1: points increases by 1, and currentEnergy decreases by 2. So, points = 3, currentEnergy = 1, and marked enemies = [0, 2].

    Example 2:

    >>> maximumPoints(enemyEnergies = [2], currentEnergy = 10)
    >>> 5
    Explanation:
    Performing the first operation 5 times on enemy 0 results in the maximum number of points.
    """


Prompt:
from typing import List
def numberOfAlternatingGroups(colors: List[int], k: int) -> int:
    """
    There is a circle of red and blue tiles. You are given an array of integers colors and an integer k. The color of tile i is represented by colors[i]:

    colors[i] == 0 means that tile i is red.
    colors[i] == 1 means that tile i is blue.

    An alternating group is every k contiguous tiles in the circle with alternating colors (each tile in the group except the first and last one has a different color from its left and right tiles).
    Return the number of alternating groups.
    Note that since colors represents a circle, the first and the last tiles are considered to be next to each other.

    Example 1:

    >>> numberOfAlternatingGroups(colors = [0,1,0,1,0], k = 3)
    >>> 3
    Explanation:

    Alternating groups:

    Example 2:

    >>> numberOfAlternatingGroups(colors = [0,1,0,0,1,0,1], k = 6)
    >>> 2
    Explanation:

    Alternating groups:

    Example 3:

    >>> numberOfAlternatingGroups(colors = [1,1,0,1], k = 4)
    >>> 0
    Explanation:
    """


Prompt:
from typing import List
def countSubarrays(nums: List[int], k: int) -> int:
    """
    Given an array of integers nums and an integer k, return the number of subarrays of nums where the bitwise AND of the elements of the subarray equals k.

    Example 1:

    >>> countSubarrays(nums = [1,1,1], k = 1)
    >>> 6
    Explanation:
    All subarrays contain only 1's.

    Example 2:

    >>> countSubarrays(nums = [1,1,2], k = 1)
    >>> 3
    Explanation:
    Subarrays having an AND value of 1 are: [1,1,2], [1,1,2], [1,1,2].

    Example 3:

    >>> countSubarrays(nums = [1,2,3], k = 2)
    >>> 2
    Explanation:
    Subarrays having an AND value of 2 are: [1,2,3], [1,2,3].
    """


Prompt:
def getEncryptedString(s: str, k: int) -> str:
    """
    You are given a string s and an integer k. Encrypt the string using the following algorithm:

    For each character c in s, replace c with the kth character after c in the string (in a cyclic manner).

    Return the encrypted string.

    Example 1:

    >>> getEncryptedString(s = "dart", k = 3)
    >>> "tdar"
    Explanation:

    For i = 0, the 3rd character after 'd' is 't'.
    For i = 1, the 3rd character after 'a' is 'd'.
    For i = 2, the 3rd character after 'r' is 'a'.
    For i = 3, the 3rd character after 't' is 'r'.

    Example 2:

    >>> getEncryptedString(s = "aaa", k = 1)
    >>> "aaa"
    Explanation:
    As all the characters are the same, the encrypted string will also be the same.
    """


Prompt:
from typing import List
def validStrings(n: int) -> List[str]:
    """
    You are given a positive integer n.
    A binary string x is valid if all substrings of x of length 2 contain at least one "1".
    Return all valid strings with length n, in any order.

    Example 1:

    >>> validStrings(n = 3)
    >>> ["010","011","101","110","111"]
    Explanation:
    The valid strings of length 3 are: "010", "011", "101", "110", and "111".

    Example 2:

    >>> validStrings(n = 1)
    >>> ["0","1"]
    Explanation:
    The valid strings of length 1 are: "0" and "1".
    """


Prompt:
from typing import List
def numberOfSubmatrices(grid: List[List[str]]) -> int:
    """
    Given a 2D character matrix grid, where grid[i][j] is either 'X', 'Y', or '.', return the number of submatrices that contain:

    grid[0][0]
    an equal frequency of 'X' and 'Y'.
    at least one 'X'.

    Example 1:

    >>> numberOfSubmatrices(grid = [["X","Y","."],["Y",".","."]])
    >>> 3
    Explanation:

    Example 2:

    >>> numberOfSubmatrices(grid = [["X","X"],["X","Y"]])
    >>> 0
    Explanation:
    No submatrix has an equal frequency of 'X' and 'Y'.

    Example 3:

    >>> numberOfSubmatrices(grid = [[".","."],[".","."]])
    >>> 0
    Explanation:
    No submatrix has at least one 'X'.
    """


Prompt:
from typing import List
def minimumCost(target: str, words: List[str], costs: List[int]) -> int:
    """
    You are given a string target, an array of strings words, and an integer array costs, both arrays of the same length.
    Imagine an empty string s.
    You can perform the following operation any number of times (including zero):

    Choose an index i in the range [0, words.length - 1].
    Append words[i] to s.
    The cost of operation is costs[i].

    Return the minimum cost to make s equal to target. If it's not possible, return -1.

    Example 1:

    >>> minimumCost(target = "abcdef", words = ["abdef","abc","d","def","ef"], costs = [100,1,1,10,5])
    >>> 7
    Explanation:
    The minimum cost can be achieved by performing the following operations:

    Select index 1 and append "abc" to s at a cost of 1, resulting in s = "abc".
    Select index 2 and append "d" to s at a cost of 1, resulting in s = "abcd".
    Select index 4 and append "ef" to s at a cost of 5, resulting in s = "abcdef".

    Example 2:

    >>> minimumCost(target = "aaaa", words = ["z","zz","zzz"], costs = [1,10,100])
    >>> -1
    Explanation:
    It is impossible to make s equal to target, so we return -1.
    """


Prompt:
from typing import List
def tripletCount(a: List[int], b: List[int], c: List[int]) -> int:
    """
    Given three integer arrays a, b, and c, return the number of triplets (a[i], b[j], c[k]), such that the bitwise XOR between the elements of each triplet has an even number of set bits.

    Example 1:

    >>> tripletCount(a = [1], b = [2], c = [3])
    >>> 1
    Explanation:
    The only triplet is (a[0], b[0], c[0]) and their XOR is: 1 XOR 2 XOR 3 = 002.

    Example 2:

    >>> tripletCount(a = [1,1], b = [2,3], c = [1,5])
    >>> 4
    Explanation:
    Consider these four triplets:

    (a[0], b[1], c[0]): 1 XOR 3 XOR 1 = 0112
    (a[1], b[1], c[0]): 1 XOR 3 XOR 1 = 0112
    (a[0], b[0], c[1]): 1 XOR 2 XOR 5 = 1102
    (a[1], b[0], c[1]): 1 XOR 2 XOR 5 = 1102
    """


Prompt:
def getSmallestString(s: str) -> str:
    """
    Given a string s containing only digits, return the lexicographically smallest string that can be obtained after swapping adjacent digits in s with the same parity at most once.
    Digits have the same parity if both are odd or both are even. For example, 5 and 9, as well as 2 and 4, have the same parity, while 6 and 9 do not.

    Example 1:

    >>> getSmallestString(s = "45320")
    >>> "43520"
    Explanation:
    s[1] == '5' and s[2] == '3' both have the same parity, and swapping them results in the lexicographically smallest string.

    Example 2:

    >>> getSmallestString(s = "001")
    >>> "001"
    Explanation:
    There is no need to perform a swap because s is already the lexicographically smallest.
    """


Prompt:
from typing import List, Optional
class ListNode:
    def __init__(val=0, next=None):
        self.val = val
        self.next = next
def modifiedList(nums: List[int], head: Optional[ListNode]) -> Optional[ListNode]:
"""
You are given an array of integers nums and the head of a linked list. Return the head of the modified linked list after removing all nodes from the linked list that have a value that exists in nums.

Example 1:

>>> modifiedList(nums = [1,2,3], head = [1,2,3,4,5])
>>> [4,5]
Explanation:

Remove the nodes with values 1, 2, and 3.

Example 2:

>>> modifiedList(nums = [1], head = [1,2,1,2,1,2])
>>> [2,2,2]
Explanation:

Remove the nodes with value 1.

Example 3:

>>> modifiedList(nums = [5], head = [1,2,3,4])
>>> [1,2,3,4]
Explanation:

No node has value 5.
"""


Prompt:
from typing import List
def minimumCost(m: int, n: int, horizontalCut: List[int], verticalCut: List[int]) -> int:
    """
    There is an m x n cake that needs to be cut into 1 x 1 pieces.
    You are given integers m, n, and two arrays:

    horizontalCut of size m - 1, where horizontalCut[i] represents the cost to cut along the horizontal line i.
    verticalCut of size n - 1, where verticalCut[j] represents the cost to cut along the vertical line j.

    In one operation, you can choose any piece of cake that is not yet a 1 x 1 square and perform one of the following cuts:

    Cut along a horizontal line i at a cost of horizontalCut[i].
    Cut along a vertical line j at a cost of verticalCut[j].

    After the cut, the piece of cake is divided into two distinct pieces.
    The cost of a cut depends only on the initial cost of the line and does not change.
    Return the minimum total cost to cut the entire cake into 1 x 1 pieces.

    Example 1:

    >>> minimumCost(m = 3, n = 2, horizontalCut = [1,3], verticalCut = [5])
    >>> 13
    Explanation:

    Perform a cut on the vertical line 0 with cost 5, current total cost is 5.
    Perform a cut on the horizontal line 0 on 3 x 1 subgrid with cost 1.
    Perform a cut on the horizontal line 0 on 3 x 1 subgrid with cost 1.
    Perform a cut on the horizontal line 1 on 2 x 1 subgrid with cost 3.
    Perform a cut on the horizontal line 1 on 2 x 1 subgrid with cost 3.

    The total cost is 5 + 1 + 1 + 3 + 3 = 13.

    Example 2:

    >>> minimumCost(m = 2, n = 2, horizontalCut = [7], verticalCut = [4])
    >>> 15
    Explanation:

    Perform a cut on the horizontal line 0 with cost 7.
    Perform a cut on the vertical line 0 on 1 x 2 subgrid with cost 4.
    Perform a cut on the vertical line 0 on 1 x 2 subgrid with cost 4.

    The total cost is 7 + 4 + 4 = 15.
    """


Prompt:
from typing import List
def minimumCost(m: int, n: int, horizontalCut: List[int], verticalCut: List[int]) -> int:
    """
    There is an m x n cake that needs to be cut into 1 x 1 pieces.
    You are given integers m, n, and two arrays:

    horizontalCut of size m - 1, where horizontalCut[i] represents the cost to cut along the horizontal line i.
    verticalCut of size n - 1, where verticalCut[j] represents the cost to cut along the vertical line j.

    In one operation, you can choose any piece of cake that is not yet a 1 x 1 square and perform one of the following cuts:

    Cut along a horizontal line i at a cost of horizontalCut[i].
    Cut along a vertical line j at a cost of verticalCut[j].

    After the cut, the piece of cake is divided into two distinct pieces.
    The cost of a cut depends only on the initial cost of the line and does not change.
    Return the minimum total cost to cut the entire cake into 1 x 1 pieces.

    Example 1:

    >>> minimumCost(m = 3, n = 2, horizontalCut = [1,3], verticalCut = [5])
    >>> 13
    Explanation:

    Perform a cut on the vertical line 0 with cost 5, current total cost is 5.
    Perform a cut on the horizontal line 0 on 3 x 1 subgrid with cost 1.
    Perform a cut on the horizontal line 0 on 3 x 1 subgrid with cost 1.
    Perform a cut on the horizontal line 1 on 2 x 1 subgrid with cost 3.
    Perform a cut on the horizontal line 1 on 2 x 1 subgrid with cost 3.

    The total cost is 5 + 1 + 1 + 3 + 3 = 13.

    Example 2:

    >>> minimumCost(m = 2, n = 2, horizontalCut = [7], verticalCut = [4])
    >>> 15
    Explanation:

    Perform a cut on the horizontal line 0 with cost 7.
    Perform a cut on the vertical line 0 on 1 x 2 subgrid with cost 4.
    Perform a cut on the vertical line 0 on 1 x 2 subgrid with cost 4.

    The total cost is 7 + 4 + 4 = 15.
    """


Prompt:
from typing import List
def maxScore(nums: List[int]) -> int:
    """
    Given an array nums, you have to get the maximum score starting from index 0 and hopping until you reach the last element of the array.
    In each hop, you can jump from index i to an index j > i, and you get a score of (j - i) * nums[j].
    Return the maximum score you can get.

    Example 1:

    >>> maxScore(nums = [1,5,8])
    >>> 16
    Explanation:
    There are two possible ways to reach the last element:

    0 -> 1 -> 2 with a score of (1 - 0) * 5 + (2 - 1) * 8 = 13.
    0 -> 2 with a score of (2 - 0) * 8 = 16.

    Example 2:

    >>> maxScore(nums = [4,5,2,8,9,1,3])
    >>> 42
    Explanation:
    We can do the hopping 0 -> 4 -> 6 with a score of (4 - 0) * 9 + (6 - 4) * 3 = 42.
    """


Prompt:
def winningPlayer(x: int, y: int) -> str:
    """
    You are given two positive integers x and y, denoting the number of coins with values 75 and 10 respectively.
    Alice and Bob are playing a game. Each turn, starting with Alice, the player must pick up coins with a total value 115. If the player is unable to do so, they lose the game.
    Return the name of the player who wins the game if both players play optimally.

    Example 1:

    >>> winningPlayer(x = 2, y = 7)
    >>> "Alice"
    Explanation:
    The game ends in a single turn:

    Alice picks 1 coin with a value of 75 and 4 coins with a value of 10.

    Example 2:

    >>> winningPlayer(x = 4, y = 11)
    >>> "Bob"
    Explanation:
    The game ends in 2 turns:

    Alice picks 1 coin with a value of 75 and 4 coins with a value of 10.
    Bob picks 1 coin with a value of 75 and 4 coins with a value of 10.
    """


Prompt:
def minimumLength(s: str) -> int:
    """
    You are given a string s.
    You can perform the following process on s any number of times:

    Choose an index i in the string such that there is at least one character to the left of index i that is equal to s[i], and at least one character to the right that is also equal to s[i].
    Delete the closest occurrence of s[i] located to the left of i.
    Delete the closest occurrence of s[i] located to the right of i.

    Return the minimum length of the final string s that you can achieve.

    Example 1:

    >>> minimumLength(s = "abaacbcbb")
    >>> 5
    Explanation:
    We do the following operations:

    Choose index 2, then remove the characters at indices 0 and 3. The resulting string is s = "bacbcbb".
    Choose index 3, then remove the characters at indices 0 and 5. The resulting string is s = "acbcb".

    Example 2:

    >>> minimumLength(s = "aa")
    >>> 2
    Explanation:
    We cannot perform any operations, so we return the length of the original string.
    """


Prompt:
from typing import List
def minChanges(nums: List[int], k: int) -> int:
    """
    You are given an integer array nums of size n where n is even, and an integer k.
    You can perform some changes on the array, where in one change you can replace any element in the array with any integer in the range from 0 to k.
    You need to perform some changes (possibly none) such that the final array satisfies the following condition:

    There exists an integer X such that abs(a[i] - a[n - i - 1]) = X for all (0 <= i < n).

    Return the minimum number of changes required to satisfy the above condition.

    Example 1:

    >>> minChanges(nums = [1,0,1,2,4,3], k = 4)
    >>> 2
    Explanation:
    We can perform the following changes:

    Replace nums[1] by 2. The resulting array is nums = [1,2,1,2,4,3].
    Replace nums[3] by 3. The resulting array is nums = [1,2,1,3,4,3].

    The integer X will be 2.

    Example 2:

    >>> minChanges(nums = [0,1,2,3,3,6,5,4], k = 6)
    >>> 2
    Explanation:
    We can perform the following operations:

    Replace nums[3] by 0. The resulting array is nums = [0,1,2,0,3,6,5,4].
    Replace nums[4] by 4. The resulting array is nums = [0,1,2,0,4,6,5,4].

    The integer X will be 4.
    """


Prompt:
from typing import List
def maximumScore(grid: List[List[int]]) -> int:
    """
    You are given a 2D matrix grid of size n x n. Initially, all cells of the grid are colored white. In one operation, you can select any cell of indices (i, j), and color black all the cells of the jth column starting from the top row down to the ith row.
    The grid score is the sum of all grid[i][j] such that cell (i, j) is white and it has a horizontally adjacent black cell.
    Return the maximum score that can be achieved after some number of operations.

    Example 1:

    >>> maximumScore(grid = [[0,0,0,0,0],[0,0,3,0,0],[0,1,0,0,0],[5,0,0,3,0],[0,0,0,0,2]])
    >>> 11
    Explanation:

    In the first operation, we color all cells in column 1 down to row 3, and in the second operation, we color all cells in column 4 down to the last row. The score of the resulting grid is grid[3][0] + grid[1][2] + grid[3][3] which is equal to 11.

    Example 2:

    >>> maximumScore(grid = [[10,9,0,0,15],[7,1,0,8,0],[5,20,0,11,0],[0,0,0,1,2],[8,12,1,10,3]])
    >>> 94
    Explanation:

    We perform operations on 1, 2, and 3 down to rows 1, 4, and 0, respectively. The score of the resulting grid is grid[0][0] + grid[1][0] + grid[2][1] + grid[4][1] + grid[1][3] + grid[2][3] + grid[3][3] + grid[4][3] + grid[0][4] which is equal to 94.
    """


Prompt:
def minChanges(n: int, k: int) -> int:
    """
    You are given two positive integers n and k.
    You can choose any bit in the binary representation of n that is equal to 1 and change it to 0.
    Return the number of changes needed to make n equal to k. If it is impossible, return -1.

    Example 1:

    >>> minChanges(n = 13, k = 4)
    >>> 2
    Explanation:
    Initially, the binary representations of n and k are n = (1101)2 and k = (0100)2.
    We can change the first and fourth bits of n. The resulting integer is n = (0100)2 = k.

    Example 2:

    >>> minChanges(n = 21, k = 21)
    >>> 0
    Explanation:
    n and k are already equal, so no changes are needed.

    Example 3:

    >>> minChanges(n = 14, k = 13)
    >>> -1
    Explanation:
    It is not possible to make n equal to k.
    """


Prompt:
def doesAliceWin(s: str) -> bool:
    """
    Alice and Bob are playing a game on a string.
    You are given a string s, Alice and Bob will take turns playing the following game where Alice starts first:

    On Alice's turn, she has to remove any non-empty substring from s that contains an odd number of vowels.
    On Bob's turn, he has to remove any non-empty substring from s that contains an even number of vowels.

    The first player who cannot make a move on their turn loses the game. We assume that both Alice and Bob play optimally.
    Return true if Alice wins the game, and false otherwise.
    The English vowels are: a, e, i, o, and u.

    Example 1:

    >>> doesAliceWin(s = "leetcoder")
    >>> true
    Explanation:
    Alice can win the game as follows:

    Alice plays first, she can delete the underlined substring in s = "leetcoder" which contains 3 vowels. The resulting string is s = "der".
    Bob plays second, he can delete the underlined substring in s = "der" which contains 0 vowels. The resulting string is s = "er".
    Alice plays third, she can delete the whole string s = "er" which contains 1 vowel.
    Bob plays fourth, since the string is empty, there is no valid play for Bob. So Alice wins the game.

    Example 2:

    >>> doesAliceWin(s = "bbcd")
    >>> false
    Explanation:
    There is no valid play for Alice in her first turn, so Alice loses the game.
    """


Prompt:
def maxOperations(s: str) -> int:
    """
    You are given a binary string s.
    You can perform the following operation on the string any number of times:

    Choose any index i from the string where i + 1 < s.length such that s[i] == '1' and s[i + 1] == '0'.
    Move the character s[i] to the right until it reaches the end of the string or another '1'. For example, for s = "010010", if we choose i = 1, the resulting string will be s = "000110".

    Return the maximum number of operations that you can perform.

    Example 1:

    >>> maxOperations(s = "1001101")
    >>> 4
    Explanation:
    We can perform the following operations:

    Choose index i = 0. The resulting string is s = "0011101".
    Choose index i = 4. The resulting string is s = "0011011".
    Choose index i = 3. The resulting string is s = "0010111".
    Choose index i = 2. The resulting string is s = "0001111".

    Example 2:

    >>> maxOperations(s = "00111")
    >>> 0
    """


Prompt:
from typing import List
def minimumOperations(nums: List[int], target: List[int]) -> int:
    """
    You are given two positive integer arrays nums and target, of the same length.
    In a single operation, you can select any subarray of nums and increment each element within that subarray by 1 or decrement each element within that subarray by 1.
    Return the minimum number of operations required to make nums equal to the array target.

    Example 1:

    >>> minimumOperations(nums = [3,5,1,2], target = [4,6,2,4])
    >>> 2
    Explanation:
    We will perform the following operations to make nums equal to target:
    - Increment nums[0..3] by 1, nums = [4,6,2,3].
    - Increment nums[3..3] by 1, nums = [4,6,2,4].

    Example 2:

    >>> minimumOperations(nums = [1,3,2], target = [2,1,4])
    >>> 5
    Explanation:
    We will perform the following operations to make nums equal to target:
    - Increment nums[0..0] by 1, nums = [2,3,2].
    - Decrement nums[1..1] by 1, nums = [2,2,2].
    - Decrement nums[1..1] by 1, nums = [2,1,2].
    - Increment nums[2..2] by 1, nums = [2,1,3].
    - Increment nums[2..2] by 1, nums = [2,1,4].
    """


Prompt:
from typing import List
def minOperations(nums: List[int]) -> int:
    """
    Given an array of integers nums, you are allowed to perform the following operation any number of times:

    Remove a strictly increasing subsequence from the array.

    Your task is to find the minimum number of operations required to make the array empty.

    Example 1:

    >>> minOperations(nums = [5,3,1,4,2])
    >>> 3
    Explanation:
    We remove subsequences [1, 2], [3, 4], [5].

    Example 2:

    >>> minOperations(nums = [1,2,3,4,5])
    >>> 1

    Example 3:

    >>> minOperations(nums = [5,4,3,2,1])
    >>> 5
    """


Prompt:
from typing import List
def canAliceWin(nums: List[int]) -> bool:
    """
    You are given an array of positive integers nums.
    Alice and Bob are playing a game. In the game, Alice can choose either all single-digit numbers or all double-digit numbers from nums, and the rest of the numbers are given to Bob. Alice wins if the sum of her numbers is strictly greater than the sum of Bob's numbers.
    Return true if Alice can win this game, otherwise, return false.

    Example 1:

    >>> canAliceWin(nums = [1,2,3,4,10])
    >>> false
    Explanation:
    Alice cannot win by choosing either single-digit or double-digit numbers.

    Example 2:

    >>> canAliceWin(nums = [1,2,3,4,5,14])
    >>> true
    Explanation:
    Alice can win by choosing single-digit numbers which have a sum equal to 15.

    Example 3:

    >>> canAliceWin(nums = [5,5,5,25])
    >>> true
    Explanation:
    Alice can win by choosing double-digit numbers which have a sum equal to 25.
    """


Prompt:
def nonSpecialCount(l: int, r: int) -> int:
    """
    You are given 2 positive integers l and r. For any number x, all positive divisors of x except x are called the proper divisors of x.
    A number is called special if it has exactly 2 proper divisors. For example:

    The number 4 is special because it has proper divisors 1 and 2.
    The number 6 is not special because it has proper divisors 1, 2, and 3.

    Return the count of numbers in the range [l, r] that are not special.

    Example 1:

    >>> nonSpecialCount(l = 5, r = 7)
    >>> 3
    Explanation:
    There are no special numbers in the range [5, 7].

    Example 2:

    >>> nonSpecialCount(l = 4, r = 16)
    >>> 11
    Explanation:
    The special numbers in the range [4, 16] are 4 and 9.
    """


Prompt:
def numberOfSubstrings(s: str) -> int:
    """
    You are given a binary string s.
    Return the number of substrings with dominant ones.
    A string has dominant ones if the number of ones in the string is greater than or equal to the square of the number of zeros in the string.

    Example 1:

    >>> numberOfSubstrings(s = "00011")
    >>> 5
    Explanation:
    The substrings with dominant ones are shown in the table below.

    i
    j
    s[i..j]
    Number of Zeros
    Number of Ones

    3
    3
    1
    0
    1

    4
    4
    1
    0
    1

    2
    3
    01
    1
    1

    3
    4
    11
    0
    2

    2
    4
    011
    1
    2

    Example 2:

    >>> numberOfSubstrings(s = "101101")
    >>> 16
    Explanation:
    The substrings with non-dominant ones are shown in the table below.
    Since there are 21 substrings total and 5 of them have non-dominant ones, it follows that there are 16 substrings with dominant ones.

    i
    j
    s[i..j]
    Number of Zeros
    Number of Ones

    1
    1
    0
    1
    0

    4
    4
    0
    1
    0

    1
    4
    0110
    2
    2

    0
    4
    10110
    2
    3

    1
    5
    01101
    2
    3
    """


Prompt:
from typing import List
def canReachCorner(xCorner: int, yCorner: int, circles: List[List[int]]) -> bool:
    """
    You are given two positive integers xCorner and yCorner, and a 2D array circles, where circles[i] = [xi, yi, ri] denotes a circle with center at (xi, yi) and radius ri.
    There is a rectangle in the coordinate plane with its bottom left corner at the origin and top right corner at the coordinate (xCorner, yCorner). You need to check whether there is a path from the bottom left corner to the top right corner such that the entire path lies inside the rectangle, does not touch or lie inside any circle, and touches the rectangle only at the two corners.
    Return true if such a path exists, and false otherwise.

    Example 1:

    >>> canReachCorner(xCorner = 3, yCorner = 4, circles = [[2,1,1]])
    >>> true
    Explanation:

    The black curve shows a possible path between (0, 0) and (3, 4).

    Example 2:

    >>> canReachCorner(xCorner = 3, yCorner = 3, circles = [[1,1,2]])
    >>> false
    Explanation:

    No path exists from (0, 0) to (3, 3).

    Example 3:

    >>> canReachCorner(xCorner = 3, yCorner = 3, circles = [[2,1,1],[1,2,1]])
    >>> false
    Explanation:

    No path exists from (0, 0) to (3, 3).

    Example 4:

    >>> canReachCorner(xCorner = 4, yCorner = 4, circles = [[5,5,1]])
    >>> true
    Explanation:
    """


Prompt:
from typing import List
def simulationResult(windows: List[int], queries: List[int]) -> List[int]:
    """
    There are n windows open numbered from 1 to n, we want to simulate using alt + tab to navigate between the windows.
    You are given an array windows which contains the initial order of the windows (the first element is at the top and the last one is at the bottom).
    You are also given an array queries where for each query, the window queries[i] is brought to the top.
    Return the final state of the array windows.

    Example 1:

    >>> simulationResult(windows = [1,2,3], queries = [3,3,2])
    >>> [2,3,1]
    Explanation:
    Here is the window array after each query:

    Initial order: [1,2,3]
    After the first query: [3,1,2]
    After the second query: [3,1,2]
    After the last query: [2,3,1]

    Example 2:

    >>> simulationResult(windows = [1,4,2,3], queries = [4,1,3])
    >>> [3,1,4,2]
    Explanation:
    Here is the window array after each query:

    Initial order: [1,4,2,3]
    After the first query: [4,1,2,3]
    After the second query: [1,4,2,3]
    After the last query: [3,1,4,2]
    """


Prompt:
from typing import List
def winningPlayerCount(n: int, pick: List[List[int]]) -> int:
    """
    You are given an integer n representing the number of players in a game and a 2D array pick where pick[i] = [xi, yi] represents that the player xi picked a ball of color yi.
    Player i wins the game if they pick strictly more than i balls of the same color. In other words,

    Player 0 wins if they pick any ball.
    Player 1 wins if they pick at least two balls of the same color.
    ...
    Player i wins if they pick at leasti + 1 balls of the same color.

    Return the number of players who win the game.
    Note that multiple players can win the game.

    Example 1:

    >>> winningPlayerCount(n = 4, pick = [[0,0],[1,0],[1,0],[2,1],[2,1],[2,0]])
    >>> 2
    Explanation:
    Player 0 and player 1 win the game, while players 2 and 3 do not win.

    Example 2:

    >>> winningPlayerCount(n = 5, pick = [[1,1],[1,2],[1,3],[1,4]])
    >>> 0
    Explanation:
    No player wins the game.

    Example 3:

    >>> winningPlayerCount(n = 5, pick = [[1,1],[2,4],[2,4],[2,4]])
    >>> 1
    Explanation:
    Player 2 wins the game by picking 3 balls with color 4.
    """


Prompt:
from typing import List
def minFlips(grid: List[List[int]]) -> int:
    """
    You are given an m x n binary matrix grid.
    A row or column is considered palindromic if its values read the same forward and backward.
    You can flip any number of cells in grid from 0 to 1, or from 1 to 0.
    Return the minimum number of cells that need to be flipped to make either all rows palindromic or all columns palindromic.

    Example 1:

    >>> minFlips(grid = [[1,0,0],[0,0,0],[0,0,1]])
    >>> 2
    Explanation:

    Flipping the highlighted cells makes all the rows palindromic.

    Example 2:

    >>> minFlips(grid = [[0,1],[0,1],[0,0]])
    >>> 1
    Explanation:

    Flipping the highlighted cell makes all the columns palindromic.

    Example 3:

    >>> minFlips(grid = [[1],[0]])
    >>> 0
    Explanation:
    All rows are already palindromic.
    """


Prompt:
from typing import List
def minFlips(grid: List[List[int]]) -> int:
    """
    You are given an m x n binary matrix grid.
    A row or column is considered palindromic if its values read the same forward and backward.
    You can flip any number of cells in grid from 0 to 1, or from 1 to 0.
    Return the minimum number of cells that need to be flipped to make all rows and columns palindromic, and the total number of 1's in grid divisible by 4.

    Example 1:

    >>> minFlips(grid = [[1,0,0],[0,1,0],[0,0,1]])
    >>> 3
    Explanation:

    Example 2:

    >>> minFlips(grid = [[0,1],[0,1],[0,0]])
    >>> 2
    Explanation:

    Example 3:

    >>> minFlips(grid = [[1],[1]])
    >>> 2
    Explanation:
    """


Prompt:
from typing import List
def timeTaken(edges: List[List[int]]) -> List[int]:
    """
    There exists an undirected tree with n nodes numbered 0 to n - 1. You are given a 2D integer array edges of length n - 1, where edges[i] = [ui, vi] indicates that there is an edge between nodes ui and vi in the tree.
    Initially, all nodes are unmarked. For each node i:

    If i is odd, the node will get marked at time x if there is at least one node adjacent to it which was marked at time x - 1.
    If i is even, the node will get marked at time x if there is at least one node adjacent to it which was marked at time x - 2.

    Return an array times where times[i] is the time when all nodes get marked in the tree, if you mark node i at time t = 0.
    Note that the answer for each times[i] is independent, i.e. when you mark node i all other nodes are unmarked.

    Example 1:

    >>> timeTaken(edges = [[0,1],[0,2]])
    >>> [2,4,3]
    Explanation:

    For i = 0:

    Node 1 is marked at t = 1, and Node 2 at t = 2.

    For i = 1:

    Node 0 is marked at t = 2, and Node 2 at t = 4.

    For i = 2:

    Node 0 is marked at t = 2, and Node 1 at t = 3.

    Example 2:

    >>> timeTaken(edges = [[0,1]])
    >>> [1,2]
    Explanation:

    For i = 0:

    Node 1 is marked at t = 1.

    For i = 1:

    Node 0 is marked at t = 2.

    Example 3:

    >>> timeTaken(edges = [[2,4],[0,1],[2,3],[0,2]])
    >>> [4,6,3,5,5]
    Explanation:
    """