Prompt:
from typing import List
def fallingSquares(positions: List[List[int]]) -> List[int]:
    """
    There are several squares being dropped onto the X-axis of a 2D plane.
    You are given a 2D integer array positions where positions[i] = [lefti, sideLengthi] represents the ith square with a side length of sideLengthi that is dropped with its left edge aligned with X-coordinate lefti.
    Each square is dropped one at a time from a height above any landed squares. It then falls downward (negative Y direction) until it either lands on the top side of another square or on the X-axis. A square brushing the left/right side of another square does not count as landing on it. Once it lands, it freezes in place and cannot be moved.
    After each square is dropped, you must record the height of the current tallest stack of squares.
    Return an integer array ans where ans[i] represents the height described above after dropping the ith square.

    Example 1:

    >>> fallingSquares(positions = [[1,2],[2,3],[6,1]])
    >>> [2,5,5]
    Explanation:
    After the first drop, the tallest stack is square 1 with a height of 2.
    After the second drop, the tallest stack is squares 1 and 2 with a height of 5.
    After the third drop, the tallest stack is still squares 1 and 2 with a height of 5.
    Thus, we return an answer of [2, 5, 5].

    Example 2:

    >>> fallingSquares(positions = [[100,100],[200,100]])
    >>> [100,100]
    Explanation:
    After the first drop, the tallest stack is square 1 with a height of 100.
    After the second drop, the tallest stack is either square 1 or square 2, both with heights of 100.
    Thus, we return an answer of [100, 100].
    Note that square 2 only brushes the right side of square 1, which does not count as landing on it.
    """


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 searchBST(root: Optional[TreeNode], val: int) -> Optional[TreeNode]:
"""
You are given the root of a binary search tree (BST) and an integer val.
Find the node in the BST that the node's value equals val and return the subtree rooted with that node. If such a node does not exist, return null.

Example 1:

>>> searchBST(root = [4,2,7,1,3], val = 2)
>>> [2,1,3]

Example 2:

>>> searchBST(root = [4,2,7,1,3], val = 5)
>>> []
"""


Prompt:
from typing import Optional
class TreeNode:
    def __init__(val=0, left=None, right=None):
        self.val = val
        self.left = left
        self.right = right
def insertIntoBST(root: Optional[TreeNode], val: int) -> Optional[TreeNode]:
"""
You are given the root node of a binary search tree (BST) and a value to insert into the tree. Return the root node of the BST after the insertion. It is guaranteed that the new value does not exist in the original BST.
Notice that there may exist multiple valid ways for the insertion, as long as the tree remains a BST after insertion. You can return any of them.

Example 1:

>>> insertIntoBST(root = [4,2,7,1,3], val = 5)
>>> [4,2,7,1,3,5]
Explanation: Another accepted tree is:

Example 2:

>>> insertIntoBST(root = [40,20,60,10,30,50,70], val = 25)
>>> [40,20,60,10,30,50,70,null,null,25]

Example 3:

>>> insertIntoBST(root = [4,2,7,1,3,null,null,null,null,null,null], val = 5)
>>> [4,2,7,1,3,5]
"""


Prompt:
from typing import List
def search(nums: List[int], target: int) -> int:
    """
    Given an array of integers nums which is sorted in ascending order, and an integer target, write a function to search target in nums. If target exists, then return its index. Otherwise, return -1.
    You must write an algorithm with O(log n) runtime complexity.

    Example 1:

    >>> search(nums = [-1,0,3,5,9,12], target = 9)
    >>> 4
    Explanation: 9 exists in nums and its index is 4

    Example 2:

    >>> search(nums = [-1,0,3,5,9,12], target = 2)
    >>> -1
    Explanation: 2 does not exist in nums so return -1
    """


Prompt:
def toLowerCase(s: str) -> str:
    """
    Given a string s, return the string after replacing every uppercase letter with the same lowercase letter.

    Example 1:

    >>> toLowerCase(s = "Hello")
    >>> "hello"

    Example 2:

    >>> toLowerCase(s = "here")
    >>> "here"

    Example 3:

    >>> toLowerCase(s = "LOVELY")
    >>> "lovely"
    """


Prompt:
from typing import List
def numDistinctIslands2(grid: List[List[int]]) -> int:
    """
    You are given an m x n binary matrix grid. An island is a group of 1's (representing land) connected 4-directionally (horizontal or vertical.) You may assume all four edges of the grid are surrounded by water.
    An island is considered to be the same as another if they have the same shape, or have the same shape after rotation (90, 180, or 270 degrees only) or reflection (left/right direction or up/down direction).
    Return the number of distinct islands.

    Example 1:

    >>> numDistinctIslands2(grid = [[1,1,0,0,0],[1,0,0,0,0],[0,0,0,0,1],[0,0,0,1,1]])
    >>> 1
    Explanation: The two islands are considered the same because if we make a 180 degrees clockwise rotation on the first island, then two islands will have the same shapes.

    Example 2:

    >>> numDistinctIslands2(grid = [[1,1,0,0,0],[1,1,0,0,0],[0,0,0,1,1],[0,0,0,1,1]])
    >>> 1
    """


Prompt:
def minimumDeleteSum(s1: str, s2: str) -> int:
    """
    Given two strings s1 and s2, return the lowest ASCII sum of deleted characters to make two strings equal.

    Example 1:

    >>> minimumDeleteSum(s1 = "sea", s2 = "eat")
    >>> 231
    Explanation: Deleting "s" from "sea" adds the ASCII value of "s" (115) to the sum.
    Deleting "t" from "eat" adds 116 to the sum.
    At the end, both strings are equal, and 115 + 116 = 231 is the minimum sum possible to achieve this.

    Example 2:

    >>> minimumDeleteSum(s1 = "delete", s2 = "leet")
    >>> 403
    Explanation: Deleting "dee" from "delete" to turn the string into "let",
    adds 100[d] + 101[e] + 101[e] to the sum.
    Deleting "e" from "leet" adds 101[e] to the sum.
    At the end, both strings are equal to "let", and the answer is 100+101+101+101 = 403.
    If instead we turned both strings into "lee" or "eet", we would get answers of 433 or 417, which are higher.
    """


Prompt:
from typing import List
def numSubarrayProductLessThanK(nums: List[int], k: int) -> int:
    """
    Given an array of integers nums and an integer k, return the number of contiguous subarrays where the product of all the elements in the subarray is strictly less than k.

    Example 1:

    >>> numSubarrayProductLessThanK(nums = [10,5,2,6], k = 100)
    >>> 8
    Explanation: The 8 subarrays that have product less than 100 are:
    [10], [5], [2], [6], [10, 5], [5, 2], [2, 6], [5, 2, 6]
    Note that [10, 5, 2] is not included as the product of 100 is not strictly less than k.

    Example 2:

    >>> numSubarrayProductLessThanK(nums = [1,2,3], k = 0)
    >>> 0
    """


Prompt:
from typing import List
def maxProfit(prices: List[int], fee: int) -> int:
    """
    You are given an array prices where prices[i] is the price of a given stock on the ith day, and an integer fee representing a transaction fee.
    Find the maximum profit you can achieve. You may complete as many transactions as you like, but you need to pay the transaction fee for each transaction.
    Note:

    You may not engage in multiple transactions simultaneously (i.e., you must sell the stock before you buy again).
    The transaction fee is only charged once for each stock purchase and sale.

    Example 1:

    >>> maxProfit(prices = [1,3,2,8,4,9], fee = 2)
    >>> 8
    Explanation: The maximum profit can be achieved by:
    - Buying at prices[0] = 1
    - Selling at prices[3] = 8
    - Buying at prices[4] = 4
    - Selling at prices[5] = 9
    The total profit is ((8 - 1) - 2) + ((9 - 4) - 2) = 8.

    Example 2:

    >>> maxProfit(prices = [1,3,7,5,10,3], fee = 3)
    >>> 6
    """


Prompt:
from typing import List
def isOneBitCharacter(bits: List[int]) -> bool:
    """
    We have two special characters:

    The first character can be represented by one bit 0.
    The second character can be represented by two bits (10 or 11).

    Given a binary array bits that ends with 0, return true if the last character must be a one-bit character.

    Example 1:

    >>> isOneBitCharacter(bits = [1,0,0])
    >>> true
    Explanation: The only way to decode it is two-bit character and one-bit character.
    So the last character is one-bit character.

    Example 2:

    >>> isOneBitCharacter(bits = [1,1,1,0])
    >>> false
    Explanation: The only way to decode it is two-bit character and two-bit character.
    So the last character is not one-bit character.
    """


Prompt:
from typing import List
def findLength(nums1: List[int], nums2: List[int]) -> int:
    """
    Given two integer arrays nums1 and nums2, return the maximum length of a subarray that appears in both arrays.

    Example 1:

    >>> findLength(nums1 = [1,2,3,2,1], nums2 = [3,2,1,4,7])
    >>> 3
    Explanation: The repeated subarray with maximum length is [3,2,1].

    Example 2:

    >>> findLength(nums1 = [0,0,0,0,0], nums2 = [0,0,0,0,0])
    >>> 5
    Explanation: The repeated subarray with maximum length is [0,0,0,0,0].
    """


Prompt:
from typing import List
def smallestDistancePair(nums: List[int], k: int) -> int:
    """
    The distance of a pair of integers a and b is defined as the absolute difference between a and b.
    Given an integer array nums and an integer k, return the kth smallest distance among all the pairs nums[i] and nums[j] where 0 <= i < j < nums.length.

    Example 1:

    >>> smallestDistancePair(nums = [1,3,1], k = 1)
    >>> 0
    Explanation: Here are all the pairs:
    (1,3) -> 2
    (1,1) -> 0
    (3,1) -> 2
    Then the 1st smallest distance pair is (1,1), and its distance is 0.

    Example 2:

    >>> smallestDistancePair(nums = [1,1,1], k = 2)
    >>> 0

    Example 3:

    >>> smallestDistancePair(nums = [1,6,1], k = 3)
    >>> 5
    """


Prompt:
from typing import List
def longestWord(words: List[str]) -> str:
    """
    Given an array of strings words representing an English Dictionary, return the longest word in words that can be built one character at a time by other words in words.
    If there is more than one possible answer, return the longest word with the smallest lexicographical order. If there is no answer, return the empty string.
    Note that the word should be built from left to right with each additional character being added to the end of a previous word.

    Example 1:

    >>> longestWord(words = ["w","wo","wor","worl","world"])
    >>> "world"
    Explanation: The word "world" can be built one character at a time by "w", "wo", "wor", and "worl".

    Example 2:

    >>> longestWord(words = ["a","banana","app","appl","ap","apply","apple"])
    >>> "apple"
    Explanation: Both "apply" and "apple" can be built from other words in the dictionary. However, "apple" is lexicographically smaller than "apply".
    """


Prompt:
from typing import List
def accountsMerge(accounts: List[List[str]]) -> List[List[str]]:
    """
    Given a list of accounts where each element accounts[i] is a list of strings, where the first element accounts[i][0] is a name, and the rest of the elements are emails representing emails of the account.
    Now, we would like to merge these accounts. Two accounts definitely belong to the same person if there is some common email to both accounts. Note that even if two accounts have the same name, they may belong to different people as people could have the same name. A person can have any number of accounts initially, but all of their accounts definitely have the same name.
    After merging the accounts, return the accounts in the following format: the first element of each account is the name, and the rest of the elements are emails in sorted order. The accounts themselves can be returned in any order.

    Example 1:

    >>> accountsMerge(accounts = [["John","johnsmith@mail.com","john_newyork@mail.com"],["John","johnsmith@mail.com","john00@mail.com"],["Mary","mary@mail.com"],["John","johnnybravo@mail.com"]])
    >>> [["John","john00@mail.com","john_newyork@mail.com","johnsmith@mail.com"],["Mary","mary@mail.com"],["John","johnnybravo@mail.com"]]
    Explanation:
    The first and second John's are the same person as they have the common email "johnsmith@mail.com".
    The third John and Mary are different people as none of their email addresses are used by other accounts.
    We could return these lists in any order, for example the answer [['Mary', 'mary@mail.com'], ['John', 'johnnybravo@mail.com'],
    ['John', 'john00@mail.com', 'john_newyork@mail.com', 'johnsmith@mail.com']] would still be accepted.

    Example 2:

    >>> accountsMerge(accounts = [["Gabe","Gabe0@m.co","Gabe3@m.co","Gabe1@m.co"],["Kevin","Kevin3@m.co","Kevin5@m.co","Kevin0@m.co"],["Ethan","Ethan5@m.co","Ethan4@m.co","Ethan0@m.co"],["Hanzo","Hanzo3@m.co","Hanzo1@m.co","Hanzo0@m.co"],["Fern","Fern5@m.co","Fern1@m.co","Fern0@m.co"]])
    >>> [["Ethan","Ethan0@m.co","Ethan4@m.co","Ethan5@m.co"],["Gabe","Gabe0@m.co","Gabe1@m.co","Gabe3@m.co"],["Hanzo","Hanzo0@m.co","Hanzo1@m.co","Hanzo3@m.co"],["Kevin","Kevin0@m.co","Kevin3@m.co","Kevin5@m.co"],["Fern","Fern0@m.co","Fern1@m.co","Fern5@m.co"]]
    """


Prompt:
from typing import List
def removeComments(source: List[str]) -> List[str]:
    """
    Given a C++ program, remove comments from it. The program source is an array of strings source where source[i] is the ith line of the source code. This represents the result of splitting the original source code string by the newline character '\
    '.
    In C++, there are two types of comments, line comments, and block comments.

    The string "//" denotes a line comment, which represents that it and the rest of the characters to the right of it in the same line should be ignored.
    The string "/*" denotes a block comment, which represents that all characters until the next (non-overlapping) occurrence of "*/" should be ignored. (Here, occurrences happen in reading order: line by line from left to right.) To be clear, the string "/*/" does not yet end the block comment, as the ending would be overlapping the beginning.

    The first effective comment takes precedence over others.

    For example, if the string "//" occurs in a block comment, it is ignored.
    Similarly, if the string "/*" occurs in a line or block comment, it is also ignored.

    If a certain line of code is empty after removing comments, you must not output that line: each string in the answer list will be non-empty.
    There will be no control characters, single quote, or double quote characters.

    For example, source = "string s = "/* Not a comment. */";" will not be a test case.

    Also, nothing else such as defines or macros will interfere with the comments.
    It is guaranteed that every open block comment will eventually be closed, so "/*" outside of a line or block comment always starts a new comment.
    Finally, implicit newline characters can be deleted by block comments. Please see the examples below for details.
    After removing the comments from the source code, return the source code in the same format.

    Example 1:

    >>> removeComments(source = ["/*Test program */", "int main()", "{ ", "  // variable declaration ", "int a, b, c;", "/* This is a test", "   multiline  ", "   comment for ", "   testing */", "a = b + c;", "}"])
    >>> ["int main()","{ ","  ","int a, b, c;","a = b + c;","}"]
    Explanation: The line by line code is visualized as below:
    /*Test program */
    int main()
    {
      // variable declaration
    int a, b, c;
    /* This is a test
       multiline
       comment for
       testing */
    a = b + c;
    }
    The string /* denotes a block comment, including line 1 and lines 6-9. The string // denotes line 4 as comments.
    The line by line output code is visualized as below:
    int main()
    {

    int a, b, c;
    a = b + c;
    }

    Example 2:

    >>> removeComments(source = ["a/*comment", "line", "more_comment*/b"])
    >>> ["ab"]
    Explanation: The original source string is "a/*comment\
    line\
    more_comment*/b", where we have bolded the newline characters.  After deletion, the implicit newline characters are deleted, leaving the string "ab", which when delimited by newline characters becomes ["ab"].
    """


Prompt:
from typing import List
def candyCrush(board: List[List[int]]) -> List[List[int]]:
    """
    This question is about implementing a basic elimination algorithm for Candy Crush.
    Given an m x n integer array board representing the grid of candy where board[i][j] represents the type of candy. A value of board[i][j] == 0 represents that the cell is empty.
    The given board represents the state of the game following the player's move. Now, you need to restore the board to a stable state by crushing candies according to the following rules:

    If three or more candies of the same type are adjacent vertically or horizontally, crush them all at the same time - these positions become empty.
    After crushing all candies simultaneously, if an empty space on the board has candies on top of itself, then these candies will drop until they hit a candy or bottom at the same time. No new candies will drop outside the top boundary.
    After the above steps, there may exist more candies that can be crushed. If so, you need to repeat the above steps.
    If there does not exist more candies that can be crushed (i.e., the board is stable), then return the current board.

    You need to perform the above rules until the board becomes stable, then return the stable board.

    Example 1:

    >>> candyCrush(board = [[110,5,112,113,114],[210,211,5,213,214],[310,311,3,313,314],[410,411,412,5,414],[5,1,512,3,3],[610,4,1,613,614],[710,1,2,713,714],[810,1,2,1,1],[1,1,2,2,2],[4,1,4,4,1014]])
    >>> [[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0],[110,0,0,0,114],[210,0,0,0,214],[310,0,0,113,314],[410,0,0,213,414],[610,211,112,313,614],[710,311,412,613,714],[810,411,512,713,1014]]

    Example 2:

    >>> candyCrush(board = [[1,3,5,5,2],[3,4,3,3,1],[3,2,4,5,2],[2,4,4,5,5],[1,4,4,1,1]])
    >>> [[1,3,0,0,0],[3,4,0,5,2],[3,2,0,3,1],[2,4,0,5,2],[1,4,3,1,1]]
    """


Prompt:
from typing import List
def pivotIndex(nums: List[int]) -> int:
    """
    Given an array of integers nums, calculate the pivot index of this array.
    The pivot index is the index where the sum of all the numbers strictly to the left of the index is equal to the sum of all the numbers strictly to the index's right.
    If the index is on the left edge of the array, then the left sum is 0 because there are no elements to the left. This also applies to the right edge of the array.
    Return the leftmost pivot index. If no such index exists, return -1.

    Example 1:

    >>> pivotIndex(nums = [1,7,3,6,5,6])
    >>> 3
    Explanation:
    The pivot index is 3.
    Left sum = nums[0] + nums[1] + nums[2] = 1 + 7 + 3 = 11
    Right sum = nums[4] + nums[5] = 5 + 6 = 11

    Example 2:

    >>> pivotIndex(nums = [1,2,3])
    >>> -1
    Explanation:
    There is no index that satisfies the conditions in the problem statement.
    Example 3:

    >>> pivotIndex(nums = [2,1,-1])
    >>> 0
    Explanation:
    The pivot index is 0.
    Left sum = 0 (no elements to the left of index 0)
    Right sum = nums[1] + nums[2] = 1 + -1 = 0
    """


Prompt:
def countOfAtoms(formula: str) -> str:
    """
    Given a string formula representing a chemical formula, return the count of each atom.
    The atomic element always starts with an uppercase character, then zero or more lowercase letters, representing the name.
    One or more digits representing that element's count may follow if the count is greater than 1. If the count is 1, no digits will follow.

    For example, "H2O" and "H2O2" are possible, but "H1O2" is impossible.

    Two formulas are concatenated together to produce another formula.

    For example, "H2O2He3Mg4" is also a formula.

    A formula placed in parentheses, and a count (optionally added) is also a formula.

    For example, "(H2O2)" and "(H2O2)3" are formulas.

    Return the count of all elements as a string in the following form: the first name (in sorted order), followed by its count (if that count is more than 1), followed by the second name (in sorted order), followed by its count (if that count is more than 1), and so on.
    The test cases are generated so that all the values in the output fit in a 32-bit integer.

    Example 1:

    >>> countOfAtoms(formula = "H2O")
    >>> "H2O"
    Explanation: The count of elements are {'H': 2, 'O': 1}.

    Example 2:

    >>> countOfAtoms(formula = "Mg(OH)2")
    >>> "H2MgO2"
    Explanation: The count of elements are {'H': 2, 'Mg': 1, 'O': 2}.

    Example 3:

    >>> countOfAtoms(formula = "K4(ON(SO3)2)2")
    >>> "K4N2O14S4"
    Explanation: The count of elements are {'K': 4, 'N': 2, 'O': 14, 'S': 4}.
    """


Prompt:
def minWindow(s1: str, s2: str) -> str:
    """
    Given strings s1 and s2, return the minimum contiguous substring part of s1, so that s2 is a subsequence of the part.
    If there is no such window in s1 that covers all characters in s2, return the empty string "". If there are multiple such minimum-length windows, return the one with the left-most starting index.

    Example 1:

    >>> minWindow(s1 = "abcdebdde", s2 = "bde")
    >>> "bcde"
    Explanation:
    "bcde" is the answer because it occurs before "bdde" which has the same length.
    "deb" is not a smaller window because the elements of s2 in the window must occur in order.

    Example 2:

    >>> minWindow(s1 = "jmeqksfrsdcmsiwvaovztaqenprpvnbstl", s2 = "u")
    >>> ""
    """


Prompt:
from typing import List
def selfDividingNumbers(left: int, right: int) -> List[int]:
    """
    A self-dividing number is a number that is divisible by every digit it contains.

    For example, 128 is a self-dividing number because 128 % 1 == 0, 128 % 2 == 0, and 128 % 8 == 0.

    A self-dividing number is not allowed to contain the digit zero.
    Given two integers left and right, return a list of all the self-dividing numbers in the range [left, right] (both inclusive).

    Example 1:
    >>> selfDividingNumbers(left = 1, right = 22)
    >>> [1,2,3,4,5,6,7,8,9,11,12,15,22]
    Example 2:
    >>> selfDividingNumbers(left = 47, right = 85)
    >>> [48,55,66,77]
    """


Prompt:
def countPalindromicSubsequences(s: str) -> int:
    """
    Given a string s, return the number of different non-empty palindromic subsequences in s. Since the answer may be very large, return it modulo 109 + 7.
    A subsequence of a string is obtained by deleting zero or more characters from the string.
    A sequence is palindromic if it is equal to the sequence reversed.
    Two sequences a1, a2, ... and b1, b2, ... are different if there is some i for which ai != bi.

    Example 1:

    >>> countPalindromicSubsequences(s = "bccb")
    >>> 6
    Explanation: The 6 different non-empty palindromic subsequences are 'b', 'c', 'bb', 'cc', 'bcb', 'bccb'.
    Note that 'bcb' is counted only once, even though it occurs twice.

    Example 2:

    >>> countPalindromicSubsequences(s = "abcdabcdabcdabcdabcdabcdabcdabcddcbadcbadcbadcbadcbadcbadcbadcba")
    >>> 104860361
    Explanation: There are 3104860382 different non-empty palindromic subsequences, which is 104860361 modulo 109 + 7.
    """


Prompt:
from typing import List
def floodFill(image: List[List[int]], sr: int, sc: int, color: int) -> List[List[int]]:
    """
    You are given an image represented by an m x n grid of integers image, where image[i][j] represents the pixel value of the image. You are also given three integers sr, sc, and color. Your task is to perform a flood fill on the image starting from the pixel image[sr][sc].
    To perform a flood fill:

    Begin with the starting pixel and change its color to color.
    Perform the same process for each pixel that is directly adjacent (pixels that share a side with the original pixel, either horizontally or vertically) and shares the same color as the starting pixel.
    Keep repeating this process by checking neighboring pixels of the updated pixels and modifying their color if it matches the original color of the starting pixel.
    The process stops when there are no more adjacent pixels of the original color to update.

    Return the modified image after performing the flood fill.

    Example 1:

    >>> floodFill(image = [[1,1,1],[1,1,0],[1,0,1]], sr = 1, sc = 1, color = 2)
    >>> [[2,2,2],[2,2,0],[2,0,1]]
    Explanation:

    From the center of the image with position (sr, sc) = (1, 1) (i.e., the red pixel), all pixels connected by a path of the same color as the starting pixel (i.e., the blue pixels) are colored with the new color.
    Note the bottom corner is not colored 2, because it is not horizontally or vertically connected to the starting pixel.

    Example 2:

    >>> floodFill(image = [[0,0,0],[0,0,0]], sr = 0, sc = 0, color = 0)
    >>> [[0,0,0],[0,0,0]]
    Explanation:
    The starting pixel is already colored with 0, which is the same as the target color. Therefore, no changes are made to the image.
    """


Prompt:
from typing import List
def areSentencesSimilar(sentence1: List[str], sentence2: List[str], similarPairs: List[List[str]]) -> bool:
    """
    We can represent a sentence as an array of words, for example, the sentence "I am happy with leetcode" can be represented as arr = ["I","am",happy","with","leetcode"].
    Given two sentences sentence1 and sentence2 each represented as a string array and given an array of string pairs similarPairs where similarPairs[i] = [xi, yi] indicates that the two words xi and yi are similar.
    Return true if sentence1 and sentence2 are similar, or false if they are not similar.
    Two sentences are similar if:

    They have the same length (i.e., the same number of words)
    sentence1[i] and sentence2[i] are similar.

    Notice that a word is always similar to itself, also notice that the similarity relation is not transitive. For example, if the words a and b are similar, and the words b and c are similar, a and c are not necessarily similar.

    Example 1:

    >>> areSentencesSimilar(sentence1 = ["great","acting","skills"], sentence2 = ["fine","drama","talent"], similarPairs = [["great","fine"],["drama","acting"],["skills","talent"]])
    >>> true
    Explanation: The two sentences have the same length and each word i of sentence1 is also similar to the corresponding word in sentence2.

    Example 2:

    >>> areSentencesSimilar(sentence1 = ["great"], sentence2 = ["great"], similarPairs = [])
    >>> true
    Explanation: A word is similar to itself.

    Example 3:

    >>> areSentencesSimilar(sentence1 = ["great"], sentence2 = ["doubleplus","good"], similarPairs = [["great","doubleplus"]])
    >>> false
    Explanation: As they don't have the same length, we return false.
    """


Prompt:
from typing import List
def asteroidCollision(asteroids: List[int]) -> List[int]:
    """
    We are given an array asteroids of integers representing asteroids in a row. The indices of the asteriod in the array represent their relative position in space.
    For each asteroid, the absolute value represents its size, and the sign represents its direction (positive meaning right, negative meaning left). Each asteroid moves at the same speed.
    Find out the state of the asteroids after all collisions. If two asteroids meet, the smaller one will explode. If both are the same size, both will explode. Two asteroids moving in the same direction will never meet.

    Example 1:

    >>> asteroidCollision(asteroids = [5,10,-5])
    >>> [5,10]
    Explanation: The 10 and -5 collide resulting in 10. The 5 and 10 never collide.

    Example 2:

    >>> asteroidCollision(asteroids = [8,-8])
    >>> []
    Explanation: The 8 and -8 collide exploding each other.

    Example 3:

    >>> asteroidCollision(asteroids = [10,2,-5])
    >>> [10]
    Explanation: The 2 and -5 collide resulting in -5. The 10 and -5 collide resulting in 10.
    """


Prompt:
def evaluate(expression: str) -> int:
    """
    You are given a string expression representing a Lisp-like expression to return the integer value of.
    The syntax for these expressions is given as follows.

    An expression is either an integer, let expression, add expression, mult expression, or an assigned variable. Expressions always evaluate to a single integer.
    (An integer could be positive or negative.)
    A let expression takes the form "(let v1 e1 v2 e2 ... vn en expr)", where let is always the string "let", then there are one or more pairs of alternating variables and expressions, meaning that the first variable v1 is assigned the value of the expression e1, the second variable v2 is assigned the value of the expression e2, and so on sequentially; and then the value of this let expression is the value of the expression expr.
    An add expression takes the form "(add e1 e2)" where add is always the string "add", there are always two expressions e1, e2 and the result is the addition of the evaluation of e1 and the evaluation of e2.
    A mult expression takes the form "(mult e1 e2)" where mult is always the string "mult", there are always two expressions e1, e2 and the result is the multiplication of the evaluation of e1 and the evaluation of e2.
    For this question, we will use a smaller subset of variable names. A variable starts with a lowercase letter, then zero or more lowercase letters or digits. Additionally, for your convenience, the names "add", "let", and "mult" are protected and will never be used as variable names.
    Finally, there is the concept of scope. When an expression of a variable name is evaluated, within the context of that evaluation, the innermost scope (in terms of parentheses) is checked first for the value of that variable, and then outer scopes are checked sequentially. It is guaranteed that every expression is legal. Please see the examples for more details on the scope.

    Example 1:

    >>> evaluate(expression = "(let x 2 (mult x (let x 3 y 4 (add x y))))")
    >>> 14
    Explanation: In the expression (add x y), when checking for the value of the variable x,
    we check from the innermost scope to the outermost in the context of the variable we are trying to evaluate.
    Since x = 3 is found first, the value of x is 3.

    Example 2:

    >>> evaluate(expression = "(let x 3 x 2 x)")
    >>> 2
    Explanation: Assignment in let statements is processed sequentially.

    Example 3:

    >>> evaluate(expression = "(let x 1 y 2 x (add x y) (add x y))")
    >>> 5
    Explanation: The first (add x y) evaluates as 3, and is assigned to x.
    The second (add x y) evaluates as 3+2 = 5.
    """


Prompt:
from typing import List
def areSentencesSimilarTwo(sentence1: List[str], sentence2: List[str], similarPairs: List[List[str]]) -> bool:
    """
    We can represent a sentence as an array of words, for example, the sentence "I am happy with leetcode" can be represented as arr = ["I","am",happy","with","leetcode"].
    Given two sentences sentence1 and sentence2 each represented as a string array and given an array of string pairs similarPairs where similarPairs[i] = [xi, yi] indicates that the two words xi and yi are similar.
    Return true if sentence1 and sentence2 are similar, or false if they are not similar.
    Two sentences are similar if:

    They have the same length (i.e., the same number of words)
    sentence1[i] and sentence2[i] are similar.

    Notice that a word is always similar to itself, also notice that the similarity relation is transitive. For example, if the words a and b are similar, and the words b and c are similar, then a and c are similar.

    Example 1:

    >>> areSentencesSimilarTwo(sentence1 = ["great","acting","skills"], sentence2 = ["fine","drama","talent"], similarPairs = [["great","good"],["fine","good"],["drama","acting"],["skills","talent"]])
    >>> true
    Explanation: The two sentences have the same length and each word i of sentence1 is also similar to the corresponding word in sentence2.

    Example 2:

    >>> areSentencesSimilarTwo(sentence1 = ["I","love","leetcode"], sentence2 = ["I","love","onepiece"], similarPairs = [["manga","onepiece"],["platform","anime"],["leetcode","platform"],["anime","manga"]])
    >>> true
    Explanation: "leetcode" --> "platform" --> "anime" --> "manga" --> "onepiece".
    Since "leetcode is similar to "onepiece" and the first two words are the same, the two sentences are similar.
    Example 3:

    >>> areSentencesSimilarTwo(sentence1 = ["I","love","leetcode"], sentence2 = ["I","love","onepiece"], similarPairs = [["manga","hunterXhunter"],["platform","anime"],["leetcode","platform"],["anime","manga"]])
    >>> false
    Explanation: "leetcode" is not similar to "onepiece".
    """


Prompt:
def monotoneIncreasingDigits(n: int) -> int:
    """
    An integer has monotone increasing digits if and only if each pair of adjacent digits x and y satisfy x <= y.
    Given an integer n, return the largest number that is less than or equal to n with monotone increasing digits.

    Example 1:

    >>> monotoneIncreasingDigits(n = 10)
    >>> 9

    Example 2:

    >>> monotoneIncreasingDigits(n = 1234)
    >>> 1234

    Example 3:

    >>> monotoneIncreasingDigits(n = 332)
    >>> 299
    """


Prompt:
from typing import List
def dailyTemperatures(temperatures: List[int]) -> List[int]:
    """
    Given an array of integers temperatures represents the daily temperatures, return an array answer such that answer[i] is the number of days you have to wait after the ith day to get a warmer temperature. If there is no future day for which this is possible, keep answer[i] == 0 instead.

    Example 1:
    >>> dailyTemperatures(temperatures = [73,74,75,71,69,72,76,73])
    >>> [1,1,4,2,1,1,0,0]
    Example 2:
    >>> dailyTemperatures(temperatures = [30,40,50,60])
    >>> [1,1,1,0]
    Example 3:
    >>> dailyTemperatures(temperatures = [30,60,90])
    >>> [1,1,0]
    """


Prompt:
from typing import List
def deleteAndEarn(nums: List[int]) -> int:
    """
    You are given an integer array nums. You want to maximize the number of points you get by performing the following operation any number of times:

    Pick any nums[i] and delete it to earn nums[i] points. Afterwards, you must delete every element equal to nums[i] - 1 and every element equal to nums[i] + 1.

    Return the maximum number of points you can earn by applying the above operation some number of times.

    Example 1:

    >>> deleteAndEarn(nums = [3,4,2])
    >>> 6
    Explanation: You can perform the following operations:
    - Delete 4 to earn 4 points. Consequently, 3 is also deleted. nums = [2].
    - Delete 2 to earn 2 points. nums = [].
    You earn a total of 6 points.

    Example 2:

    >>> deleteAndEarn(nums = [2,2,3,3,3,4])
    >>> 9
    Explanation: You can perform the following operations:
    - Delete a 3 to earn 3 points. All 2's and 4's are also deleted. nums = [3,3].
    - Delete a 3 again to earn 3 points. nums = [3].
    - Delete a 3 once more to earn 3 points. nums = [].
    You earn a total of 9 points.
    """


Prompt:
from typing import List
def cherryPickup(grid: List[List[int]]) -> int:
    """
    You are given an n x n grid representing a field of cherries, each cell is one of three possible integers.

    0 means the cell is empty, so you can pass through,
    1 means the cell contains a cherry that you can pick up and pass through, or
    -1 means the cell contains a thorn that blocks your way.

    Return the maximum number of cherries you can collect by following the rules below:

    Starting at the position (0, 0) and reaching (n - 1, n - 1) by moving right or down through valid path cells (cells with value 0 or 1).
    After reaching (n - 1, n - 1), returning to (0, 0) by moving left or up through valid path cells.
    When passing through a path cell containing a cherry, you pick it up, and the cell becomes an empty cell 0.
    If there is no valid path between (0, 0) and (n - 1, n - 1), then no cherries can be collected.

    Example 1:

    >>> cherryPickup(grid = [[0,1,-1],[1,0,-1],[1,1,1]])
    >>> 5
    Explanation: The player started at (0, 0) and went down, down, right right to reach (2, 2).
    4 cherries were picked up during this single trip, and the matrix becomes [[0,1,-1],[0,0,-1],[0,0,0]].
    Then, the player went left, up, up, left to return home, picking up one more cherry.
    The total number of cherries picked up is 5, and this is the maximum possible.

    Example 2:

    >>> cherryPickup(grid = [[1,1,-1],[1,-1,1],[-1,1,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 findClosestLeaf(root: Optional[TreeNode], k: int) -> int:
"""
Given the root of a binary tree where every node has a unique value and a target integer k, return the value of the nearest leaf node to the target k in the tree.
Nearest to a leaf means the least number of edges traveled on the binary tree to reach any leaf of the tree. Also, a node is called a leaf if it has no children.

Example 1:

>>> findClosestLeaf(root = [1,3,2], k = 1)
>>> 2
Explanation: Either 2 or 3 is the nearest leaf node to the target of 1.

Example 2:

>>> findClosestLeaf(root = [1], k = 1)
>>> 1
Explanation: The nearest leaf node is the root node itself.

Example 3:

>>> findClosestLeaf(root = [1,2,3,4,null,null,null,5,null,6], k = 2)
>>> 3
Explanation: The leaf node with value 3 (and not the leaf node with value 6) is nearest to the node with value 2.
"""


Prompt:
from typing import List
def networkDelayTime(times: List[List[int]], n: int, k: int) -> int:
    """
    You are given a network of n nodes, labeled from 1 to n. You are also given times, a list of travel times as directed edges times[i] = (ui, vi, wi), where ui is the source node, vi is the target node, and wi is the time it takes for a signal to travel from source to target.
    We will send a signal from a given node k. Return the minimum time it takes for all the n nodes to receive the signal. If it is impossible for all the n nodes to receive the signal, return -1.

    Example 1:

    >>> networkDelayTime(times = [[2,1,1],[2,3,1],[3,4,1]], n = 4, k = 2)
    >>> 2

    Example 2:

    >>> networkDelayTime(times = [[1,2,1]], n = 2, k = 1)
    >>> 1

    Example 3:

    >>> networkDelayTime(times = [[1,2,1]], n = 2, k = 2)
    >>> -1
    """


Prompt:
from typing import List
def nextGreatestLetter(letters: List[str], target: str) -> str:
    """
    You are given an array of characters letters that is sorted in non-decreasing order, and a character target. There are at least two different characters in letters.
    Return the smallest character in letters that is lexicographically greater than target. If such a character does not exist, return the first character in letters.

    Example 1:

    >>> nextGreatestLetter(letters = ["c","f","j"], target = "a")
    >>> "c"
    Explanation: The smallest character that is lexicographically greater than 'a' in letters is 'c'.

    Example 2:

    >>> nextGreatestLetter(letters = ["c","f","j"], target = "c")
    >>> "f"
    Explanation: The smallest character that is lexicographically greater than 'c' in letters is 'f'.

    Example 3:

    >>> nextGreatestLetter(letters = ["x","x","y","y"], target = "z")
    >>> "x"
    Explanation: There are no characters in letters that is lexicographically greater than 'z' so we return letters[0].
    """


Prompt:
from typing import List
def minCostClimbingStairs(cost: List[int]) -> int:
    """
    You are given an integer array cost where cost[i] is the cost of ith step on a staircase. Once you pay the cost, you can either climb one or two steps.
    You can either start from the step with index 0, or the step with index 1.
    Return the minimum cost to reach the top of the floor.

    Example 1:

    >>> minCostClimbingStairs(cost = [10,15,20])
    >>> 15
    Explanation: You will start at index 1.
    - Pay 15 and climb two steps to reach the top.
    The total cost is 15.

    Example 2:

    >>> minCostClimbingStairs(cost = [1,100,1,1,1,100,1,1,100,1])
    >>> 6
    Explanation: You will start at index 0.
    - Pay 1 and climb two steps to reach index 2.
    - Pay 1 and climb two steps to reach index 4.
    - Pay 1 and climb two steps to reach index 6.
    - Pay 1 and climb one step to reach index 7.
    - Pay 1 and climb two steps to reach index 9.
    - Pay 1 and climb one step to reach the top.
    The total cost is 6.
    """


Prompt:
from typing import List
def dominantIndex(nums: List[int]) -> int:
    """
    You are given an integer array nums where the largest integer is unique.
    Determine whether the largest element in the array is at least twice as much as every other number in the array. If it is, return the index of the largest element, or return -1 otherwise.

    Example 1:

    >>> dominantIndex(nums = [3,6,1,0])
    >>> 1
    Explanation: 6 is the largest integer.
    For every other number in the array x, 6 is at least twice as big as x.
    The index of value 6 is 1, so we return 1.

    Example 2:

    >>> dominantIndex(nums = [1,2,3,4])
    >>> -1
    Explanation: 4 is less than twice the value of 3, so we return -1.
    """


Prompt:
from typing import List
def shortestCompletingWord(licensePlate: str, words: List[str]) -> str:
    """
    Given a string licensePlate and an array of strings words, find the shortest completing word in words.
    A completing word is a word that contains all the letters in licensePlate. Ignore numbers and spaces in licensePlate, and treat letters as case insensitive. If a letter appears more than once in licensePlate, then it must appear in the word the same number of times or more.
    For example, if licensePlate = "aBc 12c", then it contains letters 'a', 'b' (ignoring case), and 'c' twice. Possible completing words are "abccdef", "caaacab", and "cbca".
    Return the shortest completing word in words. It is guaranteed an answer exists. If there are multiple shortest completing words, return the first one that occurs in words.

    Example 1:

    >>> shortestCompletingWord(licensePlate = "1s3 PSt", words = ["step","steps","stripe","stepple"])
    >>> "steps"
    Explanation: licensePlate contains letters 's', 'p', 's' (ignoring case), and 't'.
    "step" contains 't' and 'p', but only contains 1 's'.
    "steps" contains 't', 'p', and both 's' characters.
    "stripe" is missing an 's'.
    "stepple" is missing an 's'.
    Since "steps" is the only word containing all the letters, that is the answer.

    Example 2:

    >>> shortestCompletingWord(licensePlate = "1s3 456", words = ["looks","pest","stew","show"])
    >>> "pest"
    Explanation: licensePlate only contains the letter 's'. All the words contain 's', but among these "pest", "stew", and "show" are shortest. The answer is "pest" because it is the word that appears earliest of the 3.
    """


Prompt:
from typing import List
def containVirus(isInfected: List[List[int]]) -> int:
    """
    A virus is spreading rapidly, and your task is to quarantine the infected area by installing walls.
    The world is modeled as an m x n binary grid isInfected, where isInfected[i][j] == 0 represents uninfected cells, and isInfected[i][j] == 1 represents cells contaminated with the virus. A wall (and only one wall) can be installed between any two 4-directionally adjacent cells, on the shared boundary.
    Every night, the virus spreads to all neighboring cells in all four directions unless blocked by a wall. Resources are limited. Each day, you can install walls around only one region (i.e., the affected area (continuous block of infected cells) that threatens the most uninfected cells the following night). There will never be a tie.
    Return the number of walls used to quarantine all the infected regions. If the world will become fully infected, return the number of walls used.

    Example 1:

    >>> containVirus(isInfected = [[0,1,0,0,0,0,0,1],[0,1,0,0,0,0,0,1],[0,0,0,0,0,0,0,1],[0,0,0,0,0,0,0,0]])
    >>> 10
    Explanation: There are 2 contaminated regions.
    On the first day, add 5 walls to quarantine the viral region on the left. The board after the virus spreads is:

    On the second day, add 5 walls to quarantine the viral region on the right. The virus is fully contained.

    Example 2:

    >>> containVirus(isInfected = [[1,1,1],[1,0,1],[1,1,1]])
    >>> 4
    Explanation: Even though there is only one cell saved, there are 4 walls built.
    Notice that walls are only built on the shared boundary of two different cells.

    Example 3:

    >>> containVirus(isInfected = [[1,1,1,0,0,0,0,0,0],[1,0,1,0,1,1,1,1,1],[1,1,1,0,0,0,0,0,0]])
    >>> 13
    Explanation: The region on the left only builds two new walls.
    """


Prompt:
from typing import List
def countCornerRectangles(grid: List[List[int]]) -> int:
    """
    Given an m x n integer matrix grid where each entry is only 0 or 1, return the number of corner rectangles.
    A corner rectangle is four distinct 1's on the grid that forms an axis-aligned rectangle. Note that only the corners need to have the value 1. Also, all four 1's used must be distinct.

    Example 1:

    >>> countCornerRectangles(grid = [[1,0,0,1,0],[0,0,1,0,1],[0,0,0,1,0],[1,0,1,0,1]])
    >>> 1
    Explanation: There is only one corner rectangle, with corners grid[1][2], grid[1][4], grid[3][2], grid[3][4].

    Example 2:

    >>> countCornerRectangles(grid = [[1,1,1],[1,1,1],[1,1,1]])
    >>> 9
    Explanation: There are four 2x2 rectangles, four 2x3 and 3x2 rectangles, and one 3x3 rectangle.

    Example 3:

    >>> countCornerRectangles(grid = [[1,1,1,1]])
    >>> 0
    Explanation: Rectangles must have four distinct corners.
    """


Prompt:
from typing import Any, List
def ipToCIDR(ip: str, n: int) -> List[str]:
    """
    An IP address is a formatted 32-bit unsigned integer where each group of 8 bits is printed as a decimal number and the dot character '.' splits the groups.

    For example, the binary number 00001111 10001000 11111111 01101011 (spaces added for clarity) formatted as an IP address would be "15.136.255.107".

    A CIDR block is a format used to denote a specific set of IP addresses. It is a string consisting of a base IP address, followed by a slash, followed by a prefix length k. The addresses it covers are all the IPs whose first k bits are the same as the base IP address.

    For example, "123.45.67.89/20" is a CIDR block with a prefix length of 20. Any IP address whose binary representation matches 01111011 00101101 0100xxxx xxxxxxxx, where x can be either 0 or 1, is in the set covered by the CIDR block.

    You are given a start IP address ip and the number of IP addresses we need to cover n. Your goal is to use as few CIDR blocks as possible to cover all the IP addresses in the inclusive range [ip, ip + n - 1] exactly. No other IP addresses outside of the range should be covered.
    Return the shortest list of CIDR blocks that covers the range of IP addresses. If there are multiple answers, return any of them.

    Example 1:

    >>> ipToCIDR(ip = "255.0.0.7", n = 10)
    >>> ["255.0.0.7/32","255.0.0.8/29","255.0.0.16/32"]
    Explanation:
    The IP addresses that need to be covered are:
    - 255.0.0.7  -> 11111111 00000000 00000000 00000111
    - 255.0.0.8  -> 11111111 00000000 00000000 00001000
    - 255.0.0.9  -> 11111111 00000000 00000000 00001001
    - 255.0.0.10 -> 11111111 00000000 00000000 00001010
    - 255.0.0.11 -> 11111111 00000000 00000000 00001011
    - 255.0.0.12 -> 11111111 00000000 00000000 00001100
    - 255.0.0.13 -> 11111111 00000000 00000000 00001101
    - 255.0.0.14 -> 11111111 00000000 00000000 00001110
    - 255.0.0.15 -> 11111111 00000000 00000000 00001111
    - 255.0.0.16 -> 11111111 00000000 00000000 00010000
    The CIDR block "255.0.0.7/32" covers the first address.
    The CIDR block "255.0.0.8/29" covers the middle 8 addresses (binary format of 11111111 00000000 00000000 00001xxx).
    The CIDR block "255.0.0.16/32" covers the last address.
    Note that while the CIDR block "255.0.0.0/28" does cover all the addresses, it also includes addresses outside of the range, so we cannot use it.

    Example 2:

    >>> ipToCIDR(ip = "117.145.102.62", n = 8)
    >>> ["117.145.102.62/31","117.145.102.64/30","117.145.102.68/31"]
    """


Prompt:
from typing import List
def openLock(deadends: List[str], target: str) -> int:
    """
    You have a lock in front of you with 4 circular wheels. Each wheel has 10 slots: '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'. The wheels can rotate freely and wrap around: for example we can turn '9' to be '0', or '0' to be '9'. Each move consists of turning one wheel one slot.
    The lock initially starts at '0000', a string representing the state of the 4 wheels.
    You are given a list of deadends dead ends, meaning if the lock displays any of these codes, the wheels of the lock will stop turning and you will be unable to open it.
    Given a target representing the value of the wheels that will unlock the lock, return the minimum total number of turns required to open the lock, or -1 if it is impossible.

    Example 1:

    >>> openLock(deadends = ["0201","0101","0102","1212","2002"], target = "0202")
    >>> 6
    Explanation:
    A sequence of valid moves would be "0000" -> "1000" -> "1100" -> "1200" -> "1201" -> "1202" -> "0202".
    Note that a sequence like "0000" -> "0001" -> "0002" -> "0102" -> "0202" would be invalid,
    because the wheels of the lock become stuck after the display becomes the dead end "0102".

    Example 2:

    >>> openLock(deadends = ["8888"], target = "0009")
    >>> 1
    Explanation: We can turn the last wheel in reverse to move from "0000" -> "0009".

    Example 3:

    >>> openLock(deadends = ["8887","8889","8878","8898","8788","8988","7888","9888"], target = "8888")
    >>> -1
    Explanation: We cannot reach the target without getting stuck.
    """


Prompt:
def crackSafe(n: int, k: int) -> str:
    """
    There is a safe protected by a password. The password is a sequence of n digits where each digit can be in the range [0, k - 1].
    The safe has a peculiar way of checking the password. When you enter in a sequence, it checks the most recent n digits that were entered each time you type a digit.

    For example, the correct password is "345" and you enter in "012345":

    After typing 0, the most recent 3 digits is "0", which is incorrect.
    After typing 1, the most recent 3 digits is "01", which is incorrect.
    After typing 2, the most recent 3 digits is "012", which is incorrect.
    After typing 3, the most recent 3 digits is "123", which is incorrect.
    After typing 4, the most recent 3 digits is "234", which is incorrect.
    After typing 5, the most recent 3 digits is "345", which is correct and the safe unlocks.

    Return any string of minimum length that will unlock the safe at some point of entering it.

    Example 1:

    >>> crackSafe(n = 1, k = 2)
    >>> "10"
    Explanation: The password is a single digit, so enter each digit. "01" would also unlock the safe.

    Example 2:

    >>> crackSafe(n = 2, k = 2)
    >>> "01100"
    Explanation: For each possible password:
    - "00" is typed in starting from the 4th digit.
    - "01" is typed in starting from the 1st digit.
    - "10" is typed in starting from the 3rd digit.
    - "11" is typed in starting from the 2nd digit.
    Thus "01100" will unlock the safe. "10011", and "11001" would also unlock the safe.
    """


Prompt:
def reachNumber(target: int) -> int:
    """
    You are standing at position 0 on an infinite number line. There is a destination at position target.
    You can make some number of moves numMoves so that:

    On each move, you can either go left or right.
    During the ith move (starting from i == 1 to i == numMoves), you take i steps in the chosen direction.

    Given the integer target, return the minimum number of moves required (i.e., the minimum numMoves) to reach the destination.

    Example 1:

    >>> reachNumber(target = 2)
    >>> 3
    Explanation:
    On the 1st move, we step from 0 to 1 (1 step).
    On the 2nd move, we step from 1 to -1 (2 steps).
    On the 3rd move, we step from -1 to 2 (3 steps).

    Example 2:

    >>> reachNumber(target = 3)
    >>> 2
    Explanation:
    On the 1st move, we step from 0 to 1 (1 step).
    On the 2nd move, we step from 1 to 3 (2 steps).
    """


Prompt:
from typing import List
def pourWater(heights: List[int], volume: int, k: int) -> List[int]:
    """
    You are given an elevation map represents as an integer array heights where heights[i] representing the height of the terrain at index i. The width at each index is 1. You are also given two integers volume and k. volume units of water will fall at index k.
    Water first drops at the index k and rests on top of the highest terrain or water at that index. Then, it flows according to the following rules:

    If the droplet would eventually fall by moving left, then move left.
    Otherwise, if the droplet would eventually fall by moving right, then move right.
    Otherwise, rise to its current position.

    Here, "eventually fall" means that the droplet will eventually be at a lower level if it moves in that direction. Also, level means the height of the terrain plus any water in that column.
    We can assume there is infinitely high terrain on the two sides out of bounds of the array. Also, there could not be partial water being spread out evenly on more than one grid block, and each unit of water has to be in exactly one block.

    Example 1:

    >>> pourWater(heights = [2,1,1,2,1,2,2], volume = 4, k = 3)
    >>> [2,2,2,3,2,2,2]
    Explanation:
    The first drop of water lands at index k = 3. When moving left or right, the water can only move to the same level or a lower level. (By level, we mean the total height of the terrain plus any water in that column.)
    Since moving left will eventually make it fall, it moves left. (A droplet "made to fall" means go to a lower height than it was at previously.) Since moving left will not make it fall, it stays in place.

    The next droplet falls at index k = 3. Since the new droplet moving left will eventually make it fall, it moves left. Notice that the droplet still preferred to move left, even though it could move right (and moving right makes it fall quicker.)

    The third droplet falls at index k = 3. Since moving left would not eventually make it fall, it tries to move right. Since moving right would eventually make it fall, it moves right.

    Finally, the fourth droplet falls at index k = 3. Since moving left would not eventually make it fall, it tries to move right. Since moving right would not eventually make it fall, it stays in place.

    Example 2:

    >>> pourWater(heights = [1,2,3,4], volume = 2, k = 2)
    >>> [2,3,3,4]
    Explanation: The last droplet settles at index 1, since moving further left would not cause it to eventually fall to a lower height.

    Example 3:

    >>> pourWater(heights = [3,1,3], volume = 5, k = 1)
    >>> [4,4,4]
    """


Prompt:
from typing import List
def pyramidTransition(bottom: str, allowed: List[str]) -> bool:
    """
    You are stacking blocks to form a pyramid. Each block has a color, which is represented by a single letter. Each row of blocks contains one less block than the row beneath it and is centered on top.
    To make the pyramid aesthetically pleasing, there are only specific triangular patterns that are allowed. A triangular pattern consists of a single block stacked on top of two blocks. The patterns are given as a list of three-letter strings allowed, where the first two characters of a pattern represent the left and right bottom blocks respectively, and the third character is the top block.

    For example, "ABC" represents a triangular pattern with a 'C' block stacked on top of an 'A' (left) and 'B' (right) block. Note that this is different from "BAC" where 'B' is on the left bottom and 'A' is on the right bottom.

    You start with a bottom row of blocks bottom, given as a single string, that you must use as the base of the pyramid.
    Given bottom and allowed, return true if you can build the pyramid all the way to the top such that every triangular pattern in the pyramid is in allowed, or false otherwise.

    Example 1:

    >>> pyramidTransition(bottom = "BCD", allowed = ["BCC","CDE","CEA","FFF"])
    >>> true
    Explanation: The allowed triangular patterns are shown on the right.
    Starting from the bottom (level 3), we can build "CE" on level 2 and then build "A" on level 1.
    There are three triangular patterns in the pyramid, which are "BCC", "CDE", and "CEA". All are allowed.

    Example 2:

    >>> pyramidTransition(bottom = "AAAA", allowed = ["AAB","AAC","BCD","BBE","DEF"])
    >>> false
    Explanation: The allowed triangular patterns are shown on the right.
    Starting from the bottom (level 4), there are multiple ways to build level 3, but trying all the possibilites, you will get always stuck before building level 1.
    """


Prompt:
from typing import List
def intersectionSizeTwo(intervals: List[List[int]]) -> int:
    """
    You are given a 2D integer array intervals where intervals[i] = [starti, endi] represents all the integers from starti to endi inclusively.
    A containing set is an array nums where each interval from intervals has at least two integers in nums.

    For example, if intervals = [[1,3], [3,7], [8,9]], then [1,2,4,7,8,9] and [2,3,4,8,9] are containing sets.

    Return the minimum possible size of a containing set.

    Example 1:

    >>> intersectionSizeTwo(intervals = [[1,3],[3,7],[8,9]])
    >>> 5
    Explanation: let nums = [2, 3, 4, 8, 9].
    It can be shown that there cannot be any containing array of size 4.

    Example 2:

    >>> intersectionSizeTwo(intervals = [[1,3],[1,4],[2,5],[3,5]])
    >>> 3
    Explanation: let nums = [2, 3, 4].
    It can be shown that there cannot be any containing array of size 2.

    Example 3:

    >>> intersectionSizeTwo(intervals = [[1,2],[2,3],[2,4],[4,5]])
    >>> 5
    Explanation: let nums = [1, 2, 3, 4, 5].
    It can be shown that there cannot be any containing array of size 4.
    """


Prompt:
from typing import Any, List
def boldWords(words: List[str], s: str) -> str:
    """
    Given an array of keywords words and a string s, make all appearances of all keywords words[i] in s bold. Any letters between  and  tags become bold.
    Return s after adding the bold tags. The returned string should use the least number of tags possible, and the tags should form a valid combination.

    Example 1:

    >>> boldWords(words = ["ab","bc"], s = "aabcd")
    >>> "aabcd"
    Explanation: Note that returning "aabcd" would use more tags, so it is incorrect.

    Example 2:

    >>> boldWords(words = ["ab","cb"], s = "aabcd")
    >>> "aabcd"
    """


Prompt:
from typing import List
def anagramMappings(nums1: List[int], nums2: List[int]) -> List[int]:
    """
    You are given two integer arrays nums1 and nums2 where nums2 is an anagram of nums1. Both arrays may contain duplicates.
    Return an index mapping array mapping from nums1 to nums2 where mapping[i] = j means the ith element in nums1 appears in nums2 at index j. If there are multiple answers, return any of them.
    An array a is an anagram of an array b means b is made by randomizing the order of the elements in a.

    Example 1:

    >>> anagramMappings(nums1 = [12,28,46,32,50], nums2 = [50,12,32,46,28])
    >>> [1,4,3,2,0]
    Explanation: As mapping[0] = 1 because the 0th element of nums1 appears at nums2[1], and mapping[1] = 4 because the 1st element of nums1 appears at nums2[4], and so on.

    Example 2:

    >>> anagramMappings(nums1 = [84,46], nums2 = [84,46])
    >>> [0,1]
    """


Prompt:
def makeLargestSpecial(s: str) -> str:
    """
    Special binary strings are binary strings with the following two properties:

    The number of 0's is equal to the number of 1's.
    Every prefix of the binary string has at least as many 1's as 0's.

    You are given a special binary string s.
    A move consists of choosing two consecutive, non-empty, special substrings of s, and swapping them. Two strings are consecutive if the last character of the first string is exactly one index before the first character of the second string.
    Return the lexicographically largest resulting string possible after applying the mentioned operations on the string.

    Example 1:

    >>> makeLargestSpecial(s = "11011000")
    >>> "11100100"
    Explanation: The strings "10" [occuring at s[1]] and "1100" [at s[3]] are swapped.
    This is the lexicographically largest string possible after some number of swaps.

    Example 2:

    >>> makeLargestSpecial(s = "10")
    >>> "10"
    """


Prompt:
def countPrimeSetBits(left: int, right: int) -> int:
    """
    Given two integers left and right, return the count of numbers in the inclusive range [left, right] having a prime number of set bits in their binary representation.
    Recall that the number of set bits an integer has is the number of 1's present when written in binary.

    For example, 21 written in binary is 10101, which has 3 set bits.

    Example 1:

    >>> countPrimeSetBits(left = 6, right = 10)
    >>> 4
    Explanation:
    6  -> 110 (2 set bits, 2 is prime)
    7  -> 111 (3 set bits, 3 is prime)
    8  -> 1000 (1 set bit, 1 is not prime)
    9  -> 1001 (2 set bits, 2 is prime)
    10 -> 1010 (2 set bits, 2 is prime)
    4 numbers have a prime number of set bits.

    Example 2:

    >>> countPrimeSetBits(left = 10, right = 15)
    >>> 5
    Explanation:
    10 -> 1010 (2 set bits, 2 is prime)
    11 -> 1011 (3 set bits, 3 is prime)
    12 -> 1100 (2 set bits, 2 is prime)
    13 -> 1101 (3 set bits, 3 is prime)
    14 -> 1110 (3 set bits, 3 is prime)
    15 -> 1111 (4 set bits, 4 is not prime)
    5 numbers have a prime number of set bits.
    """


Prompt:
from typing import List
def partitionLabels(s: str) -> List[int]:
    """
    You are given a string s. We want to partition the string into as many parts as possible so that each letter appears in at most one part. For example, the string "ababcc" can be partitioned into ["abab", "cc"], but partitions such as ["aba", "bcc"] or ["ab", "ab", "cc"] are invalid.
    Note that the partition is done so that after concatenating all the parts in order, the resultant string should be s.
    Return a list of integers representing the size of these parts.

    Example 1:

    >>> partitionLabels(s = "ababcbacadefegdehijhklij")
    >>> [9,7,8]
    Explanation:
    The partition is "ababcbaca", "defegde", "hijhklij".
    This is a partition so that each letter appears in at most one part.
    A partition like "ababcbacadefegde", "hijhklij" is incorrect, because it splits s into less parts.

    Example 2:

    >>> partitionLabels(s = "eccbbbbdec")
    >>> [10]
    """


Prompt:
from typing import List
def orderOfLargestPlusSign(n: int, mines: List[List[int]]) -> int:
    """
    You are given an integer n. You have an n x n binary grid grid with all values initially 1's except for some indices given in the array mines. The ith element of the array mines is defined as mines[i] = [xi, yi] where grid[xi][yi] == 0.
    Return the order of the largest axis-aligned plus sign of 1's contained in grid. If there is none, return 0.
    An axis-aligned plus sign of 1's of order k has some center grid[r][c] == 1 along with four arms of length k - 1 going up, down, left, and right, and made of 1's. Note that there could be 0's or 1's beyond the arms of the plus sign, only the relevant area of the plus sign is checked for 1's.

    Example 1:

    >>> orderOfLargestPlusSign(n = 5, mines = [[4,2]])
    >>> 2
    Explanation: In the above grid, the largest plus sign can only be of order 2. One of them is shown.

    Example 2:

    >>> orderOfLargestPlusSign(n = 1, mines = [[0,0]])
    >>> 0
    Explanation: There is no plus sign, so return 0.
    """


Prompt:
from typing import List
def minSwapsCouples(row: List[int]) -> int:
    """
    There are n couples sitting in 2n seats arranged in a row and want to hold hands.
    The people and seats are represented by an integer array row where row[i] is the ID of the person sitting in the ith seat. The couples are numbered in order, the first couple being (0, 1), the second couple being (2, 3), and so on with the last couple being (2n - 2, 2n - 1).
    Return the minimum number of swaps so that every couple is sitting side by side. A swap consists of choosing any two people, then they stand up and switch seats.

    Example 1:

    >>> minSwapsCouples(row = [0,2,1,3])
    >>> 1
    Explanation: We only need to swap the second (row[1]) and third (row[2]) person.

    Example 2:

    >>> minSwapsCouples(row = [3,2,0,1])
    >>> 0
    Explanation: All couples are already seated side by side.
    """


Prompt:
from typing import List
def isToeplitzMatrix(matrix: List[List[int]]) -> bool:
    """
    Given an m x n matrix, return true if the matrix is Toeplitz. Otherwise, return false.
    A matrix is Toeplitz if every diagonal from top-left to bottom-right has the same elements.

    Example 1:

    >>> isToeplitzMatrix(matrix = [[1,2,3,4],[5,1,2,3],[9,5,1,2]])
    >>> true
    Explanation:
    In the above grid, the diagonals are:
    "[9]", "[5, 5]", "[1, 1, 1]", "[2, 2, 2]", "[3, 3]", "[4]".
    In each diagonal all elements are the same, so the answer is True.

    Example 2:

    >>> isToeplitzMatrix(matrix = [[1,2],[2,2]])
    >>> false
    Explanation:
    The diagonal "[1, 2]" has different elements.
    """


Prompt:
def reorganizeString(s: str) -> str:
    """
    Given a string s, rearrange the characters of s so that any two adjacent characters are not the same.
    Return any possible rearrangement of s or return "" if not possible.

    Example 1:
    >>> reorganizeString(s = "aab")
    >>> "aba"
    Example 2:
    >>> reorganizeString(s = "aaab")
    >>> ""
    """


Prompt:
from typing import List
def maxChunksToSorted(arr: List[int]) -> int:
    """
    You are given an integer array arr.
    We split arr into some number of chunks (i.e., partitions), and individually sort each chunk. After concatenating them, the result should equal the sorted array.
    Return the largest number of chunks we can make to sort the array.

    Example 1:

    >>> maxChunksToSorted(arr = [5,4,3,2,1])
    >>> 1
    Explanation:
    Splitting into two or more chunks will not return the required result.
    For example, splitting into [5, 4], [3, 2, 1] will result in [4, 5, 1, 2, 3], which isn't sorted.

    Example 2:

    >>> maxChunksToSorted(arr = [2,1,3,4,4])
    >>> 4
    Explanation:
    We can split into two chunks, such as [2, 1], [3, 4, 4].
    However, splitting into [2, 1], [3], [4], [4] is the highest number of chunks possible.
    """


Prompt:
from typing import List
def maxChunksToSorted(arr: List[int]) -> int:
    """
    You are given an integer array arr of length n that represents a permutation of the integers in the range [0, n - 1].
    We split arr into some number of chunks (i.e., partitions), and individually sort each chunk. After concatenating them, the result should equal the sorted array.
    Return the largest number of chunks we can make to sort the array.

    Example 1:

    >>> maxChunksToSorted(arr = [4,3,2,1,0])
    >>> 1
    Explanation:
    Splitting into two or more chunks will not return the required result.
    For example, splitting into [4, 3], [2, 1, 0] will result in [3, 4, 0, 1, 2], which isn't sorted.

    Example 2:

    >>> maxChunksToSorted(arr = [1,0,2,3,4])
    >>> 4
    Explanation:
    We can split into two chunks, such as [1, 0], [2, 3, 4].
    However, splitting into [1, 0], [2], [3], [4] is the highest number of chunks possible.
    """


Prompt:
from typing import List
def basicCalculatorIV(expression: str, evalvars: List[str], evalints: List[int]) -> List[str]:
    """
    Given an expression such as expression = "e + 8 - a + 5" and an evaluation map such as {"e": 1} (given in terms of evalvars = ["e"] and evalints = [1]), return a list of tokens representing the simplified expression, such as ["-1*a","14"]

    An expression alternates chunks and symbols, with a space separating each chunk and symbol.
    A chunk is either an expression in parentheses, a variable, or a non-negative integer.
    A variable is a string of lowercase letters (not including digits.) Note that variables can be multiple letters, and note that variables never have a leading coefficient or unary operator like "2x" or "-x".

    Expressions are evaluated in the usual order: brackets first, then multiplication, then addition and subtraction.

    For example, expression = "1 + 2 * 3" has an answer of ["7"].

    The format of the output is as follows:

    For each term of free variables with a non-zero coefficient, we write the free variables within a term in sorted order lexicographically.

    For example, we would never write a term like "b*a*c", only "a*b*c".

    Terms have degrees equal to the number of free variables being multiplied, counting multiplicity. We write the largest degree terms of our answer first, breaking ties by lexicographic order ignoring the leading coefficient of the term.

    For example, "a*a*b*c" has degree 4.

    The leading coefficient of the term is placed directly to the left with an asterisk separating it from the variables (if they exist.) A leading coefficient of 1 is still printed.
    An example of a well-formatted answer is ["-2*a*a*a", "3*a*a*b", "3*b*b", "4*a", "5*c", "-6"].
    Terms (including constant terms) with coefficient 0 are not included.

    For example, an expression of "0" has an output of [].

    Note: You may assume that the given expression is always valid. All intermediate results will be in the range of [-231, 231 - 1].

    Example 1:

    >>> basicCalculatorIV(expression = "e + 8 - a + 5", evalvars = ["e"], evalints = [1])
    >>> ["-1*a","14"]

    Example 2:

    >>> basicCalculatorIV(expression = "e - 8 + temperature - pressure", evalvars = ["e", "temperature"], evalints = [1, 12])
    >>> ["-1*pressure","5"]

    Example 3:

    >>> basicCalculatorIV(expression = "(e + 8) * (e - 8)", evalvars = [], evalints = [])
    >>> ["1*e*e","-64"]
    """


Prompt:
def numJewelsInStones(jewels: str, stones: str) -> int:
    """
    You're given strings jewels representing the types of stones that are jewels, and stones representing the stones you have. Each character in stones is a type of stone you have. You want to know how many of the stones you have are also jewels.
    Letters are case sensitive, so "a" is considered a different type of stone from "A".

    Example 1:
    >>> numJewelsInStones(jewels = "aA", stones = "aAAbbbb")
    >>> 3
    Example 2:
    >>> numJewelsInStones(jewels = "z", stones = "ZZ")
    >>> 0
    """


Prompt:
def calculate(s: str) -> int:
    """
    Implement a basic calculator to evaluate a simple expression string.
    The expression string contains only non-negative integers, '+', '-', '*', '/' operators, and open '(' and closing parentheses ')'. The integer division should truncate toward zero.
    You may assume that the given expression is always valid. All intermediate results will be in the range of [-231, 231 - 1].
    Note: You are not allowed to use any built-in function which evaluates strings as mathematical expressions, such as eval().

    Example 1:

    >>> calculate(s = "1+1")
    >>> 2

    Example 2:

    >>> calculate(s = "6-4/2")
    >>> 4

    Example 3:

    >>> calculate(s = "2*(5+5*2)/3+(6/2+8)")
    >>> 21
    """


Prompt:
from typing import List
def slidingPuzzle(board: List[List[int]]) -> int:
    """
    On an 2 x 3 board, there are five tiles labeled from 1 to 5, and an empty square represented by 0. A move consists of choosing 0 and a 4-directionally adjacent number and swapping it.
    The state of the board is solved if and only if the board is [[1,2,3],[4,5,0]].
    Given the puzzle board board, return the least number of moves required so that the state of the board is solved. If it is impossible for the state of the board to be solved, return -1.

    Example 1:

    >>> slidingPuzzle(board = [[1,2,3],[4,0,5]])
    >>> 1
    Explanation: Swap the 0 and the 5 in one move.

    Example 2:

    >>> slidingPuzzle(board = [[1,2,3],[5,4,0]])
    >>> -1
    Explanation: No number of moves will make the board solved.

    Example 3:

    >>> slidingPuzzle(board = [[4,1,2],[5,0,3]])
    >>> 5
    Explanation: 5 is the smallest number of moves that solves the board.
    An example path:
    After move 0: [[4,1,2],[5,0,3]]
    After move 1: [[4,1,2],[0,5,3]]
    After move 2: [[0,1,2],[4,5,3]]
    After move 3: [[1,0,2],[4,5,3]]
    After move 4: [[1,2,0],[4,5,3]]
    After move 5: [[1,2,3],[4,5,0]]
    """


Prompt:
from typing import List
def minmaxGasDist(stations: List[int], k: int) -> float:
    """
    You are given an integer array stations that represents the positions of the gas stations on the x-axis. You are also given an integer k.
    You should add k new gas stations. You can add the stations anywhere on the x-axis, and not necessarily on an integer position.
    Let penalty() be the maximum distance between adjacent gas stations after adding the k new stations.
    Return the smallest possible value of penalty(). Answers within 10-6 of the actual answer will be accepted.

    Example 1:
    >>> minmaxGasDist(stations = [1,2,3,4,5,6,7,8,9,10], k = 9)
    >>> 0.50000
    Example 2:
    >>> minmaxGasDist(stations = [23,24,36,39,46,56,57,65,84,98], k = 1)
    >>> 14.00000
    """


Prompt:
from typing import List
def isIdealPermutation(nums: List[int]) -> bool:
    """
    You are given an integer array nums of length n which represents a permutation of all the integers in the range [0, n - 1].
    The number of global inversions is the number of the different pairs (i, j) where:

    0 <= i < j < n
    nums[i] > nums[j]

    The number of local inversions is the number of indices i where:

    0 <= i < n - 1
    nums[i] > nums[i + 1]

    Return true if the number of global inversions is equal to the number of local inversions.

    Example 1:

    >>> isIdealPermutation(nums = [1,0,2])
    >>> true
    Explanation: There is 1 global inversion and 1 local inversion.

    Example 2:

    >>> isIdealPermutation(nums = [1,2,0])
    >>> false
    Explanation: There are 2 global inversions and 1 local inversion.
    """


Prompt:
def canTransform(start: str, result: str) -> bool:
    """
    In a string composed of 'L', 'R', and 'X' characters, like "RXXLRXRXL", a move consists of either replacing one occurrence of "XL" with "LX", or replacing one occurrence of "RX" with "XR". Given the starting string start and the ending string result, return True if and only if there exists a sequence of moves to transform start to result.

    Example 1:

    >>> canTransform(start = "RXXLRXRXL", result = "XRLXXRRLX")
    >>> true
    Explanation: We can transform start to result following these steps:
    RXXLRXRXL ->
    XRXLRXRXL ->
    XRLXRXRXL ->
    XRLXXRRXL ->
    XRLXXRRLX

    Example 2:

    >>> canTransform(start = "X", result = "L")
    >>> false
    """


Prompt:
from typing import List
def swimInWater(grid: List[List[int]]) -> int:
    """
    You are given an n x n integer matrix grid where each value grid[i][j] represents the elevation at that point (i, j).
    The rain starts to fall. At time t, the depth of the water everywhere is t. You can swim from a square to another 4-directionally adjacent square if and only if the elevation of both squares individually are at most t. You can swim infinite distances in zero time. Of course, you must stay within the boundaries of the grid during your swim.
    Return the least time until you can reach the bottom right square (n - 1, n - 1) if you start at the top left square (0, 0).

    Example 1:

    >>> swimInWater(grid = [[0,2],[1,3]])
    >>> 3
    Explanation:
    At time 0, you are in grid location (0, 0).
    You cannot go anywhere else because 4-directionally adjacent neighbors have a higher elevation than t = 0.
    You cannot reach point (1, 1) until time 3.
    When the depth of water is 3, we can swim anywhere inside the grid.

    Example 2:

    >>> swimInWater(grid = [[0,1,2,3,4],[24,23,22,21,5],[12,13,14,15,16],[11,17,18,19,20],[10,9,8,7,6]])
    >>> 16
    Explanation: The final route is shown.
    We need to wait until time 16 so that (0, 0) and (4, 4) are connected.
    """


Prompt:
def kthGrammar(n: int, k: int) -> int:
    """
    We build a table of n rows (1-indexed). We start by writing 0 in the 1st row. Now in every subsequent row, we look at the previous row and replace each occurrence of 0 with 01, and each occurrence of 1 with 10.

    For example, for n = 3, the 1st row is 0, the 2nd row is 01, and the 3rd row is 0110.

    Given two integer n and k, return the kth (1-indexed) symbol in the nth row of a table of n rows.

    Example 1:

    >>> kthGrammar(n = 1, k = 1)
    >>> 0
    Explanation: row 1: 0

    Example 2:

    >>> kthGrammar(n = 2, k = 1)
    >>> 0
    Explanation:
    row 1: 0
    row 2: 01

    Example 3:

    >>> kthGrammar(n = 2, k = 2)
    >>> 1
    Explanation:
    row 1: 0
    row 2: 01
    """


Prompt:
def reachingPoints(sx: int, sy: int, tx: int, ty: int) -> bool:
    """
    Given four integers sx, sy, tx, and ty, return true if it is possible to convert the point (sx, sy) to the point (tx, ty) through some operations, or false otherwise.
    The allowed operation on some point (x, y) is to convert it to either (x, x + y) or (x + y, y).

    Example 1:

    >>> reachingPoints(sx = 1, sy = 1, tx = 3, ty = 5)
    >>> true
    Explanation:
    One series of moves that transforms the starting point to the target is:
    (1, 1) -> (1, 2)
    (1, 2) -> (3, 2)
    (3, 2) -> (3, 5)

    Example 2:

    >>> reachingPoints(sx = 1, sy = 1, tx = 2, ty = 2)
    >>> false

    Example 3:

    >>> reachingPoints(sx = 1, sy = 1, tx = 1, ty = 1)
    >>> true
    """


Prompt:
from typing import List
def numRabbits(answers: List[int]) -> int:
    """
    There is a forest with an unknown number of rabbits. We asked n rabbits "How many rabbits have the same color as you?" and collected the answers in an integer array answers where answers[i] is the answer of the ith rabbit.
    Given the array answers, return the minimum number of rabbits that could be in the forest.

    Example 1:

    >>> numRabbits(answers = [1,1,2])
    >>> 5
    Explanation:
    The two rabbits that answered "1" could both be the same color, say red.
    The rabbit that answered "2" can't be red or the answers would be inconsistent.
    Say the rabbit that answered "2" was blue.
    Then there should be 2 other blue rabbits in the forest that didn't answer into the array.
    The smallest possible number of rabbits in the forest is therefore 5: 3 that answered plus 2 that didn't.

    Example 2:

    >>> numRabbits(answers = [10,10,10])
    >>> 11
    """


Prompt:
from typing import List
def movesToChessboard(board: List[List[int]]) -> int:
    """
    You are given an n x n binary grid board. In each move, you can swap any two rows with each other, or any two columns with each other.
    Return the minimum number of moves to transform the board into a chessboard board. If the task is impossible, return -1.
    A chessboard board is a board where no 0's and no 1's are 4-directionally adjacent.

    Example 1:

    >>> movesToChessboard(board = [[0,1,1,0],[0,1,1,0],[1,0,0,1],[1,0,0,1]])
    >>> 2
    Explanation: One potential sequence of moves is shown.
    The first move swaps the first and second column.
    The second move swaps the second and third row.

    Example 2:

    >>> movesToChessboard(board = [[0,1],[1,0]])
    >>> 0
    Explanation: Also note that the board with 0 in the top left corner, is also a valid chessboard.

    Example 3:

    >>> movesToChessboard(board = [[1,0],[1,0]])
    >>> -1
    Explanation: No matter what sequence of moves you make, you cannot end with a valid chessboard.
    """


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 minDiffInBST(root: Optional[TreeNode]) -> int:
"""
Given the root of a Binary Search Tree (BST), return the minimum difference between the values of any two different nodes in the tree.

Example 1:

>>> minDiffInBST(root = [4,2,6,1,3])
>>> 1

Example 2:

>>> minDiffInBST(root = [1,0,48,null,null,12,49])
>>> 1
"""


Prompt:
from typing import List
def letterCasePermutation(s: str) -> List[str]:
    """
    Given a string s, you can transform every letter individually to be lowercase or uppercase to create another string.
    Return a list of all possible strings we could create. Return the output in any order.

    Example 1:

    >>> letterCasePermutation(s = "a1b2")
    >>> ["a1b2","a1B2","A1b2","A1B2"]

    Example 2:

    >>> letterCasePermutation(s = "3z4")
    >>> ["3z4","3Z4"]
    """


Prompt:
from typing import List
def isBipartite(graph: List[List[int]]) -> bool:
    """
    There is an undirected graph with n nodes, where each node is numbered between 0 and n - 1. You are given a 2D array graph, where graph[u] is an array of nodes that node u is adjacent to. More formally, for each v in graph[u], there is an undirected edge between node u and node v. The graph has the following properties:

    There are no self-edges (graph[u] does not contain u).
    There are no parallel edges (graph[u] does not contain duplicate values).
    If v is in graph[u], then u is in graph[v] (the graph is undirected).
    The graph may not be connected, meaning there may be two nodes u and v such that there is no path between them.

    A graph is bipartite if the nodes can be partitioned into two independent sets A and B such that every edge in the graph connects a node in set A and a node in set B.
    Return true if and only if it is bipartite.

    Example 1:

    >>> isBipartite(graph = [[1,2,3],[0,2],[0,1,3],[0,2]])
    >>> false
    Explanation: There is no way to partition the nodes into two independent sets such that every edge connects a node in one and a node in the other.
    Example 2:

    >>> isBipartite(graph = [[1,3],[0,2],[1,3],[0,2]])
    >>> true
    Explanation: We can partition the nodes into two sets: {0, 2} and {1, 3}.
    """


Prompt:
from typing import List
def kthSmallestPrimeFraction(arr: List[int], k: int) -> List[int]:
    """
    You are given a sorted integer array arr containing 1 and prime numbers, where all the integers of arr are unique. You are also given an integer k.
    For every i and j where 0 <= i < j < arr.length, we consider the fraction arr[i] / arr[j].
    Return the kth smallest fraction considered. Return your answer as an array of integers of size 2, where answer[0] == arr[i] and answer[1] == arr[j].

    Example 1:

    >>> kthSmallestPrimeFraction(arr = [1,2,3,5], k = 3)
    >>> [2,5]
    Explanation: The fractions to be considered in sorted order are:
    1/5, 1/3, 2/5, 1/2, 3/5, and 2/3.
    The third fraction is 2/5.

    Example 2:

    >>> kthSmallestPrimeFraction(arr = [1,7], k = 1)
    >>> [1,7]
    """


Prompt:
from typing import List
def findCheapestPrice(n: int, flights: List[List[int]], src: int, dst: int, k: int) -> int:
    """
    There are n cities connected by some number of flights. You are given an array flights where flights[i] = [fromi, toi, pricei] indicates that there is a flight from city fromi to city toi with cost pricei.
    You are also given three integers src, dst, and k, return the cheapest price from src to dst with at most k stops. If there is no such route, return -1.

    Example 1:

    >>> findCheapestPrice(n = 4, flights = [[0,1,100],[1,2,100],[2,0,100],[1,3,600],[2,3,200]], src = 0, dst = 3, k = 1)
    >>> 700
    Explanation:
    The graph is shown above.
    The optimal path with at most 1 stop from city 0 to 3 is marked in red and has cost 100 + 600 = 700.
    Note that the path through cities [0,1,2,3] is cheaper but is invalid because it uses 2 stops.

    Example 2:

    >>> findCheapestPrice(n = 3, flights = [[0,1,100],[1,2,100],[0,2,500]], src = 0, dst = 2, k = 1)
    >>> 200
    Explanation:
    The graph is shown above.
    The optimal path with at most 1 stop from city 0 to 2 is marked in red and has cost 100 + 100 = 200.

    Example 3:

    >>> findCheapestPrice(n = 3, flights = [[0,1,100],[1,2,100],[0,2,500]], src = 0, dst = 2, k = 0)
    >>> 500
    Explanation:
    The graph is shown above.
    The optimal path with no stops from city 0 to 2 is marked in red and has cost 500.
    """


Prompt:
def rotatedDigits(n: int) -> int:
    """
    An integer x is a good if after rotating each digit individually by 180 degrees, we get a valid number that is different from x. Each digit must be rotated - we cannot choose to leave it alone.
    A number is valid if each digit remains a digit after rotation. For example:

    0, 1, and 8 rotate to themselves,
    2 and 5 rotate to each other (in this case they are rotated in a different direction, in other words, 2 or 5 gets mirrored),
    6 and 9 rotate to each other, and
    the rest of the numbers do not rotate to any other number and become invalid.

    Given an integer n, return the number of good integers in the range [1, n].

    Example 1:

    >>> rotatedDigits(n = 10)
    >>> 4
    Explanation: There are four good numbers in the range [1, 10] : 2, 5, 6, 9.
    Note that 1 and 10 are not good numbers, since they remain unchanged after rotating.

    Example 2:

    >>> rotatedDigits(n = 1)
    >>> 0

    Example 3:

    >>> rotatedDigits(n = 2)
    >>> 1
    """


Prompt:
from typing import List
def escapeGhosts(ghosts: List[List[int]], target: List[int]) -> bool:
    """
    You are playing a simplified PAC-MAN game on an infinite 2-D grid. You start at the point [0, 0], and you are given a destination point target = [xtarget, ytarget] that you are trying to get to. There are several ghosts on the map with their starting positions given as a 2D array ghosts, where ghosts[i] = [xi, yi] represents the starting position of the ith ghost. All inputs are integral coordinates.
    Each turn, you and all the ghosts may independently choose to either move 1 unit in any of the four cardinal directions: north, east, south, or west, or stay still. All actions happen simultaneously.
    You escape if and only if you can reach the target before any ghost reaches you. If you reach any square (including the target) at the same time as a ghost, it does not count as an escape.
    Return true if it is possible to escape regardless of how the ghosts move, otherwise return false.

    Example 1:

    >>> escapeGhosts(ghosts = [[1,0],[0,3]], target = [0,1])
    >>> true
    Explanation: You can reach the destination (0, 1) after 1 turn, while the ghosts located at (1, 0) and (0, 3) cannot catch up with you.

    Example 2:

    >>> escapeGhosts(ghosts = [[1,0]], target = [2,0])
    >>> false
    Explanation: You need to reach the destination (2, 0), but the ghost at (1, 0) lies between you and the destination.

    Example 3:

    >>> escapeGhosts(ghosts = [[2,0]], target = [1,0])
    >>> false
    Explanation: The ghost can reach the target at the same time as you.
    """


Prompt:
def numTilings(n: int) -> int:
    """
    You have two types of tiles: a 2 x 1 domino shape and a tromino shape. You may rotate these shapes.

    Given an integer n, return the number of ways to tile an 2 x n board. Since the answer may be very large, return it modulo 109 + 7.
    In a tiling, every square must be covered by a tile. Two tilings are different if and only if there are two 4-directionally adjacent cells on the board such that exactly one of the tilings has both squares occupied by a tile.

    Example 1:

    >>> numTilings(n = 3)
    >>> 5
    Explanation: The five different ways are show above.

    Example 2:

    >>> numTilings(n = 1)
    >>> 1
    """


Prompt:
def customSortString(order: str, s: str) -> str:
    """
    You are given two strings order and s. All the characters of order are unique and were sorted in some custom order previously.
    Permute the characters of s so that they match the order that order was sorted. More specifically, if a character x occurs before a character y in order, then x should occur before y in the permuted string.
    Return any permutation of s that satisfies this property.

    Example 1:

    >>> customSortString(order = "cba", s = "abcd")
    >>> "cbad"
    Explanation:  "a", "b", "c" appear in order, so the order of "a", "b", "c" should be "c", "b", and "a".
    Since "d" does not appear in order, it can be at any position in the returned string. "dcba", "cdba", "cbda" are also valid outputs.

    Example 2:

    >>> customSortString(order = "bcafg", s = "abcd")
    >>> "bcad"
    Explanation:  The characters "b", "c", and "a" from order dictate the order for the characters in s. The character "d" in s does not appear in order, so its position is flexible.
    Following the order of appearance in order, "b", "c", and "a" from s should be arranged as "b", "c", "a". "d" can be placed at any position since it's not in order. The output "bcad" correctly follows this rule. Other arrangements like "dbca" or "bcda" would also be valid, as long as "b", "c", "a" maintain their order.
    """


Prompt:
from typing import List
def numMatchingSubseq(s: str, words: List[str]) -> int:
    """
    Given a string s and an array of strings words, return the number of words[i] that is a subsequence of s.
    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:

    >>> numMatchingSubseq(s = "abcde", words = ["a","bb","acd","ace"])
    >>> 3
    Explanation: There are three strings in words that are a subsequence of s: "a", "acd", "ace".

    Example 2:

    >>> numMatchingSubseq(s = "dsahjpjauf", words = ["ahjpjau","ja","ahbwzgqnuk","tnmlanowax"])
    >>> 2
    """


Prompt:
def preimageSizeFZF(k: int) -> int:
    """
    Let f(x) be the number of zeroes at the end of x!. Recall that x! = 1 * 2 * 3 * ... * x and by convention, 0! = 1.

    For example, f(3) = 0 because 3! = 6 has no zeroes at the end, while f(11) = 2 because 11! = 39916800 has two zeroes at the end.

    Given an integer k, return the number of non-negative integers x have the property that f(x) = k.

    Example 1:

    >>> preimageSizeFZF(k = 0)
    >>> 5
    Explanation: 0!, 1!, 2!, 3!, and 4! end with k = 0 zeroes.

    Example 2:

    >>> preimageSizeFZF(k = 5)
    >>> 0
    Explanation: There is no x such that x! ends in k = 5 zeroes.

    Example 3:

    >>> preimageSizeFZF(k = 3)
    >>> 5
    """


Prompt:
from typing import List
def validTicTacToe(board: List[str]) -> bool:
    """
    Given a Tic-Tac-Toe board as a string array board, return true if and only if it is possible to reach this board position during the course of a valid tic-tac-toe game.
    The board is a 3 x 3 array that consists of characters ' ', 'X', and 'O'. The ' ' character represents an empty square.
    Here are the rules of Tic-Tac-Toe:

    Players take turns placing characters into empty squares ' '.
    The first player always places 'X' characters, while the second player always places 'O' characters.
    'X' and 'O' characters are always placed into empty squares, never filled ones.
    The game ends when there are three of the same (non-empty) character filling any row, column, or diagonal.
    The game also ends if all squares are non-empty.
    No more moves can be played if the game is over.

    Example 1:

    >>> validTicTacToe(board = ["O  ","   ","   "])
    >>> false
    Explanation: The first player always plays "X".

    Example 2:

    >>> validTicTacToe(board = ["XOX"," X ","   "])
    >>> false
    Explanation: Players take turns making moves.

    Example 3:

    >>> validTicTacToe(board = ["XOX","O O","XOX"])
    >>> true
    """


Prompt:
from typing import List
def numSubarrayBoundedMax(nums: List[int], left: int, right: int) -> int:
    """
    Given an integer array nums and two integers left and right, return the number of contiguous non-empty subarrays such that the value of the maximum array element in that subarray is in the range [left, right].
    The test cases are generated so that the answer will fit in a 32-bit integer.

    Example 1:

    >>> numSubarrayBoundedMax(nums = [2,1,4,3], left = 2, right = 3)
    >>> 3
    Explanation: There are three subarrays that meet the requirements: [2], [2, 1], [3].

    Example 2:

    >>> numSubarrayBoundedMax(nums = [2,9,2,5,6], left = 2, right = 8)
    >>> 7
    """


Prompt:
def rotateString(s: str, goal: str) -> bool:
    """
    Given two strings s and goal, return true if and only if s can become goal after some number of shifts on s.
    A shift on s consists of moving the leftmost character of s to the rightmost position.

    For example, if s = "abcde", then it will be "bcdea" after one shift.

    Example 1:
    >>> rotateString(s = "abcde", goal = "cdeab")
    >>> true
    Example 2:
    >>> rotateString(s = "abcde", goal = "abced")
    >>> false
    """


Prompt:
from typing import List
def allPathsSourceTarget(graph: List[List[int]]) -> List[List[int]]:
    """
    Given a directed acyclic graph (DAG) of n nodes labeled from 0 to n - 1, find all possible paths from node 0 to node n - 1 and return them in any order.
    The graph is given as follows: graph[i] is a list of all nodes you can visit from node i (i.e., there is a directed edge from node i to node graph[i][j]).

    Example 1:

    >>> allPathsSourceTarget(graph = [[1,2],[3],[3],[]])
    >>> [[0,1,3],[0,2,3]]
    Explanation: There are two paths: 0 -> 1 -> 3 and 0 -> 2 -> 3.

    Example 2:

    >>> allPathsSourceTarget(graph = [[4,3,1],[3,2,4],[3],[4],[]])
    >>> [[0,4],[0,3,4],[0,1,3,4],[0,1,2,3,4],[0,1,4]]
    """


Prompt:
from typing import List
def bestRotation(nums: List[int]) -> int:
    """
    You are given an array nums. You can rotate it by a non-negative integer k so that the array becomes [nums[k], nums[k + 1], ... nums[nums.length - 1], nums[0], nums[1], ..., nums[k-1]]. Afterward, any entries that are less than or equal to their index are worth one point.

    For example, if we have nums = [2,4,1,3,0], and we rotate by k = 2, it becomes [1,3,0,2,4]. This is worth 3 points because 1 > 0 [no points], 3 > 1 [no points], 0 <= 2 [one point], 2 <= 3 [one point], 4 <= 4 [one point].

    Return the rotation index k that corresponds to the highest score we can achieve if we rotated nums by it. If there are multiple answers, return the smallest such index k.

    Example 1:

    >>> bestRotation(nums = [2,3,1,4,0])
    >>> 3
    Explanation: Scores for each k are listed below:
    k = 0,  nums = [2,3,1,4,0],    score 2
    k = 1,  nums = [3,1,4,0,2],    score 3
    k = 2,  nums = [1,4,0,2,3],    score 3
    k = 3,  nums = [4,0,2,3,1],    score 4
    k = 4,  nums = [0,2,3,1,4],    score 3
    So we should choose k = 3, which has the highest score.

    Example 2:

    >>> bestRotation(nums = [1,3,0,2,4])
    >>> 0
    Explanation: nums will always have 3 points no matter how it shifts.
    So we will choose the smallest k, which is 0.
    """


Prompt:
def champagneTower(poured: int, query_row: int, query_glass: int) -> float:
    """
    We stack glasses in a pyramid, where the first row has 1 glass, the second row has 2 glasses, and so on until the 100th row.  Each glass holds one cup of champagne.\r
    \r
    Then, some champagne is poured into the first glass at the top.  When the topmost glass is full, any excess liquid poured will fall equally to the glass immediately to the left and right of it.  When those glasses become full, any excess champagne will fall equally to the left and right of those glasses, and so on.  (A glass at the bottom row has its excess champagne fall on the floor.)\r
    \r
    For example, after one cup of champagne is poured, the top most glass is full.  After two cups of champagne are poured, the two glasses on the second row are half full.  After three cups of champagne are poured, those two cups become full - there are 3 full glasses total now.  After four cups of champagne are poured, the third row has the middle glass half full, and the two outside glasses are a quarter full, as pictured below.\r
    \r
    \r
    \r
    Now after pouring some non-negative integer cups of champagne, return how full the jth glass in the ith row is (both i and j are 0-indexed.)\r
    \r
     \r
    Example 1:\r
    \r
    \r
    >>> champagneTower(poured = 1, query_row = 1, query_glass = 1\r)
    >>> 0.00000\r
    Explanation: We poured 1 cup of champange to the top glass of the tower (which is indexed as (0, 0)). There will be no excess liquid so all the glasses under the top glass will remain empty.\r
    \r
    \r
    Example 2:\r
    \r
    \r
    >>> champagneTower(poured = 2, query_row = 1, query_glass = 1\r)
    >>> 0.50000\r
    Explanation: We poured 2 cups of champange to the top glass of the tower (which is indexed as (0, 0)). There is one cup of excess liquid. The glass indexed as (1, 0) and the glass indexed as (1, 1) will share the excess liquid equally, and each will get half cup of champange.\r
    \r
    \r
    Example 3:\r
    \r
    \r
    >>> champagneTower(poured = 100000009, query_row = 33, query_glass = 17\r)
    >>> 1.00000\r
    \r
    \r
     \r
    """


Prompt:
from typing import Any
def similarRGB(color: str) -> str:
    """
    The red-green-blue color "#AABBCC" can be written as "#ABC" in shorthand.

    For example, "#15c" is shorthand for the color "#1155cc".

    The similarity between the two colors "#ABCDEF" and "#UVWXYZ" is -(AB - UV)2 - (CD - WX)2 - (EF - YZ)2.
    Given a string color that follows the format "#ABCDEF", return a string represents the color that is most similar to the given color and has a shorthand (i.e., it can be represented as some "#XYZ").
    Any answer which has the same highest similarity as the best answer will be accepted.

    Example 1:

    >>> similarRGB(color = "#09f166")
    >>> "#11ee66"
    Explanation:
    The similarity is -(0x09 - 0x11)2 -(0xf1 - 0xee)2 - (0x66 - 0x66)2 = -64 -9 -0 = -73.
    This is the highest among any shorthand color.

    Example 2:

    >>> similarRGB(color = "#4e3fe1")
    >>> "#5544dd"
    """