ShwStone/humaneval-leetcode huggingface dataset:
def canConstruct(s: str, k: int) -> bool:
    """
    Given a string s and an integer k, return true if you can use all the characters in s to construct non-empty k palindrome strings or false otherwise.
    
    Example 1:
    
    >>> canConstruct(s = "annabelle", k = 2)
    >>> true
    Explanation: You can construct two palindromes using all characters in s.
    Some possible constructions "anna" + "elble", "anbna" + "elle", "anellena" + "b"
    
    Example 2:
    
    >>> canConstruct(s = "leetcode", k = 3)
    >>> false
    Explanation: It is impossible to construct 3 palindromes using all the characters of s.
    
    Example 3:
    
    >>> canConstruct(s = "true", k = 4)
    >>> true
    Explanation: The only possible solution is to put each character in a separate string.
    """
def checkOverlap(radius: int, xCenter: int, yCenter: int, x1: int, y1: int, x2: int, y2: int) -> bool:
    """
    You are given a circle represented as (radius, xCenter, yCenter) and an axis-aligned rectangle represented as (x1, y1, x2, y2), where (x1, y1) are the coordinates of the bottom-left corner, and (x2, y2) are the coordinates of the top-right corner of the rectangle.
    Return true if the circle and rectangle are overlapped otherwise return false. In other words, check if there is any point (xi, yi) that belongs to the circle and the rectangle at the same time.
    
    Example 1:
    
    
    >>> checkOverlap(radius = 1, xCenter = 0, yCenter = 0, x1 = 1, y1 = -1, x2 = 3, y2 = 1)
    >>> true
    Explanation: Circle and rectangle share the point (1,0).
    
    Example 2:
    
    >>> checkOverlap(radius = 1, xCenter = 1, yCenter = 1, x1 = 1, y1 = -3, x2 = 2, y2 = -1)
    >>> false
    
    Example 3:
    
    
    >>> checkOverlap(radius = 1, xCenter = 0, yCenter = 0, x1 = -1, y1 = 0, x2 = 0, y2 = 1)
    >>> true
    """
def maxSatisfaction(satisfaction: List[int]) -> int:
    """
    A chef has collected data on the satisfaction level of his n dishes. Chef can cook any dish in 1 unit of time.
    Like-time coefficient of a dish is defined as the time taken to cook that dish including previous dishes multiplied by its satisfaction level i.e. time[i] * satisfaction[i].
    Return the maximum sum of like-time coefficient that the chef can obtain after preparing some amount of dishes.
    Dishes can be prepared in any order and the chef can discard some dishes to get this maximum value.
    
    Example 1:
    
    >>> maxSatisfaction(satisfaction = [-1,-8,0,5,-9])
    >>> 14
    Explanation: After Removing the second and last dish, the maximum total like-time coefficient will be equal to (-1*1 + 0*2 + 5*3 = 14).
    Each dish is prepared in one unit of time.
    Example 2:
    
    >>> maxSatisfaction(satisfaction = [4,3,2])
    >>> 20
    Explanation: Dishes can be prepared in any order, (2*1 + 3*2 + 4*3 = 20)
    
    Example 3:
    
    >>> maxSatisfaction(satisfaction = [-1,-4,-5])
    >>> 0
    Explanation: People do not like the dishes. No dish is prepared.
    """
def minSubsequence(nums: List[int]) -> List[int]:
    """
    Given the array nums, obtain a subsequence of the array whose sum of elements is strictly greater than the sum of the non included elements in such subsequence.
    If there are multiple solutions, return the subsequence with minimum size and if there still exist multiple solutions, return the subsequence with the maximum total sum of all its elements. A subsequence of an array can be obtained by erasing some (possibly zero) elements from the array.
    Note that the solution with the given constraints is guaranteed to be unique. Also return the answer sorted in non-increasing order.
    
    Example 1:
    
    >>> minSubsequence(nums = [4,3,10,9,8])
    >>> [10,9]
    Explanation: The subsequences [10,9] and [10,8] are minimal such that the sum of their elements is strictly greater than the sum of elements not included. However, the subsequence [10,9] has the maximum total sum of its elements.
    
    Example 2:
    
    >>> minSubsequence(nums = [4,4,7,6,7])
    >>> [7,7,6]
    Explanation: The subsequence [7,7] has the sum of its elements equal to 14 which is not strictly greater than the sum of elements not included (14 = 4 + 4 + 6). Therefore, the subsequence [7,6,7] is the minimal satisfying the conditions. Note the subsequence has to be returned in non-increasing order.
    """
def numSteps(s: str) -> int:
    """
    Given the binary representation of an integer as a string s, return the number of steps to reduce it to 1 under the following rules:
    
    
    If the current number is even, you have to divide it by 2.
    
    
    If the current number is odd, you have to add 1 to it.
    
    
    It is guaranteed that you can always reach one for all test cases.
    
    Example 1:
    
    >>> numSteps(s = "1101")
    >>> 6
    Explanation: "1101" corressponds to number 13 in their decimal representation.
    Step 1) 13 is odd, add 1 and obtain 14.
    Step 2) 14 is even, divide by 2 and obtain 7.
    Step 3) 7 is odd, add 1 and obtain 8.
    Step 4) 8 is even, divide by 2 and obtain 4.
    Step 5) 4 is even, divide by 2 and obtain 2.
    Step 6) 2 is even, divide by 2 and obtain 1.
    
    Example 2:
    
    >>> numSteps(s = "10")
    >>> 1
    Explanation: "10" corresponds to number 2 in their decimal representation.
    Step 1) 2 is even, divide by 2 and obtain 1.
    
    Example 3:
    
    >>> numSteps(s = "1")
    >>> 0
    """
def longestDiverseString(a: int, b: int, c: int) -> str:
    """
    A string s is called happy if it satisfies the following conditions:
    
    s only contains the letters 'a', 'b', and 'c'.
    s does not contain any of "aaa", "bbb", or "ccc" as a substring.
    s contains at most a occurrences of the letter 'a'.
    s contains at most b occurrences of the letter 'b'.
    s contains at most c occurrences of the letter 'c'.
    
    Given three integers a, b, and c, return the longest possible happy string. If there are multiple longest happy strings, return any of them. If there is no such string, return the empty string "".
    A substring is a contiguous sequence of characters within a string.
    
    Example 1:
    
    >>> longestDiverseString(a = 1, b = 1, c = 7)
    >>> "ccaccbcc"
    Explanation: "ccbccacc" would also be a correct answer.
    
    Example 2:
    
    >>> longestDiverseString(a = 7, b = 1, c = 0)
    >>> "aabaa"
    Explanation: It is the only correct answer in this case.
    """
def stoneGameIII(stoneValue: List[int]) -> str:
    """
    Alice and Bob continue their games with piles of stones. There are several stones arranged in a row, and each stone has an associated value which is an integer given in the array stoneValue.
    Alice and Bob take turns, with Alice starting first. On each player's turn, that player can take 1, 2, or 3 stones from the first remaining stones in the row.
    The score of each player is the sum of the values of the stones taken. The score of each player is 0 initially.
    The objective of the game is to end with the highest score, and the winner is the player with the highest score and there could be a tie. The game continues until all the stones have been taken.
    Assume Alice and Bob play optimally.
    Return "Alice" if Alice will win, "Bob" if Bob will win, or "Tie" if they will end the game with the same score.
    
    Example 1:
    
    >>> stoneGameIII(stoneValue = [1,2,3,7])
    >>> "Bob"
    Explanation: Alice will always lose. Her best move will be to take three piles and the score become 6. Now the score of Bob is 7 and Bob wins.
    
    Example 2:
    
    >>> stoneGameIII(stoneValue = [1,2,3,-9])
    >>> "Alice"
    Explanation: Alice must choose all the three piles at the first move to win and leave Bob with negative score.
    If Alice chooses one pile her score will be 1 and the next move Bob's score becomes 5. In the next move, Alice will take the pile with value = -9 and lose.
    If Alice chooses two piles her score will be 3 and the next move Bob's score becomes 3. In the next move, Alice will take the pile with value = -9 and also lose.
    Remember that both play optimally so here Alice will choose the scenario that makes her win.
    
    Example 3:
    
    >>> stoneGameIII(stoneValue = [1,2,3,6])
    >>> "Tie"
    Explanation: Alice cannot win this game. She can end the game in a draw if she decided to choose all the first three piles, otherwise she will lose.
    """
def stringMatching(words: List[str]) -> List[str]:
    """
    Given an array of string words, return all strings in words that are a substring of another word. You can return the answer in any order.
    
    Example 1:
    
    >>> stringMatching(words = ["mass","as","hero","superhero"])
    >>> ["as","hero"]
    Explanation: "as" is substring of "mass" and "hero" is substring of "superhero".
    ["hero","as"] is also a valid answer.
    
    Example 2:
    
    >>> stringMatching(words = ["leetcode","et","code"])
    >>> ["et","code"]
    Explanation: "et", "code" are substring of "leetcode".
    
    Example 3:
    
    >>> stringMatching(words = ["blue","green","bu"])
    >>> []
    Explanation: No string of words is substring of another string.
    """
def processQueries(queries: List[int], m: int) -> List[int]:
    """
    Given the array queries of positive integers between 1 and m, you have to process all queries[i] (from i=0 to i=queries.length-1) according to the following rules:
    
    In the beginning, you have the permutation P=[1,2,3,...,m].
    For the current i, find the position of queries[i] in the permutation P (indexing from 0) and then move this at the beginning of the permutation P. Notice that the position of queries[i] in P is the result for queries[i].
    
    Return an array containing the result for the given queries.
    
    Example 1:
    
    >>> processQueries(queries = [3,1,2,1], m = 5)
    >>> [2,1,2,1]
    Explanation: The queries are processed as follow:
    For i=0: queries[i]=3, P=[1,2,3,4,5], position of 3 in P is 2, then we move 3 to the beginning of P resulting in P=[3,1,2,4,5].
    For i=1: queries[i]=1, P=[3,1,2,4,5], position of 1 in P is 1, then we move 1 to the beginning of P resulting in P=[1,3,2,4,5].
    For i=2: queries[i]=2, P=[1,3,2,4,5], position of 2 in P is 2, then we move 2 to the beginning of P resulting in P=[2,1,3,4,5].
    For i=3: queries[i]=1, P=[2,1,3,4,5], position of 1 in P is 1, then we move 1 to the beginning of P resulting in P=[1,2,3,4,5].
    Therefore, the array containing the result is [2,1,2,1].
    
    Example 2:
    
    >>> processQueries(queries = [4,1,2,2], m = 4)
    >>> [3,1,2,0]
    
    Example 3:
    
    >>> processQueries(queries = [7,5,5,8,3], m = 8)
    >>> [6,5,0,7,5]
    """
def entityParser(text: str) -> str:
    """
    HTML entity parser is the parser that takes HTML code as input and replace all the entities of the special characters by the characters itself.
    The special characters and their entities for HTML are:
    
    Quotation Mark: the entity is &quot; and symbol character is ".
    Single Quote Mark: the entity is &apos; and symbol character is '.
    Ampersand: the entity is &amp; and symbol character is &.
    Greater Than Sign: the entity is &gt; and symbol character is >.
    Less Than Sign: the entity is &lt; and symbol character is <.
    Slash: the entity is &frasl; and symbol character is /.
    
    Given the input text string to the HTML parser, you have to implement the entity parser.
    Return the text after replacing the entities by the special characters.
    
    Example 1:
    
    >>> entityParser(text = "&amp; is an HTML entity but &ambassador; is not.")
    >>> "& is an HTML entity but &ambassador; is not."
    Explanation: The parser will replace the &amp; entity by &
    
    Example 2:
    
    >>> entityParser(text = "and I quote: &quot;...&quot;")
    >>> "and I quote: \"...\""
    """
def numOfWays(n: int) -> int:
    """
    You have a grid of size n x 3 and you want to paint each cell of the grid with exactly one of the three colors: Red, Yellow, or Green while making sure that no two adjacent cells have the same color (i.e., no two cells that share vertical or horizontal sides have the same color).
    Given n the number of rows of the grid, return the number of ways you can paint this grid. As the answer may grow large, the answer must be computed modulo 109 + 7.
    
    Example 1:
    
    
    >>> numOfWays(n = 1)
    >>> 12
    Explanation: There are 12 possible way to paint the grid as shown.
    
    Example 2:
    
    >>> numOfWays(n = 5000)
    >>> 30228214
    """
def minStartValue(nums: List[int]) -> int:
    """
    Given an array of integers nums, you start with an initial positive value startValue.
    In each iteration, you calculate the step by step sum of startValue plus elements in nums (from left to right).
    Return the minimum positive value of startValue such that the step by step sum is never less than 1.
    
    Example 1:
    
    >>> minStartValue(nums = [-3,2,-3,4,2])
    >>> 5
    Explanation: If you choose startValue = 4, in the third iteration your step by step sum is less than 1.
    step by step sum
    startValue = 4 | startValue = 5 | nums
      (4 -3 ) = 1  | (5 -3 ) = 2    |  -3
      (1 +2 ) = 3  | (2 +2 ) = 4    |   2
      (3 -3 ) = 0  | (4 -3 ) = 1    |  -3
      (0 +4 ) = 4  | (1 +4 ) = 5    |   4
      (4 +2 ) = 6  | (5 +2 ) = 7    |   2
    
    Example 2:
    
    >>> minStartValue(nums = [1,2])
    >>> 1
    Explanation: Minimum start value should be positive.
    
    Example 3:
    
    >>> minStartValue(nums = [1,-2,-3])
    >>> 5
    """
def findMinFibonacciNumbers(k: int) -> int:
    """
    Given an integer k, return the minimum number of Fibonacci numbers whose sum is equal to k. The same Fibonacci number can be used multiple times.
    The Fibonacci numbers are defined as:
    
    F1 = 1
    F2 = 1
    Fn = Fn-1 + Fn-2 for n > 2.
    
    It is guaranteed that for the given constraints we can always find such Fibonacci numbers that sum up to k.
    
    Example 1:
    
    >>> findMinFibonacciNumbers(k = 7)
    >>> 2
    Explanation: The Fibonacci numbers are: 1, 1, 2, 3, 5, 8, 13, ...
    For k = 7 we can use 2 + 5 = 7.
    Example 2:
    
    >>> findMinFibonacciNumbers(k = 10)
    >>> 2
    Explanation: For k = 10 we can use 2 + 8 = 10.
    
    Example 3:
    
    >>> findMinFibonacciNumbers(k = 19)
    >>> 3
    Explanation: For k = 19 we can use 1 + 5 + 13 = 19.
    """
def getHappyString(n: int, k: int) -> str:
    """
    A happy string is a string that:
    
    consists only of letters of the set ['a', 'b', 'c'].
    s[i] != s[i + 1] for all values of i from 1 to s.length - 1 (string is 1-indexed).
    
    For example, strings "abc", "ac", "b" and "abcbabcbcb" are all happy strings and strings "aa", "baa" and "ababbc" are not happy strings.
    Given two integers n and k, consider a list of all happy strings of length n sorted in lexicographical order.
    Return the kth string of this list or return an empty string if there are less than k happy strings of length n.
    
    Example 1:
    
    >>> getHappyString(n = 1, k = 3)
    >>> "c"
    Explanation: The list ["a", "b", "c"] contains all happy strings of length 1. The third string is "c".
    
    Example 2:
    
    >>> getHappyString(n = 1, k = 4)
    >>> ""
    Explanation: There are only 3 happy strings of length 1.
    
    Example 3:
    
    >>> getHappyString(n = 3, k = 9)
    >>> "cab"
    Explanation: There are 12 different happy string of length 3 ["aba", "abc", "aca", "acb", "bab", "bac", "bca", "bcb", "cab", "cac", "cba", "cbc"]. You will find the 9th string = "cab"
    """
def numberOfArrays(s: str, k: int) -> int:
    """
    A program was supposed to print an array of integers. The program forgot to print whitespaces and the array is printed as a string of digits s and all we know is that all integers in the array were in the range [1, k] and there are no leading zeros in the array.
    Given the string s and the integer k, return the number of the possible arrays that can be printed as s using the mentioned program. Since the answer may be very large, return it modulo 109 + 7.
    
    Example 1:
    
    >>> numberOfArrays(s = "1000", k = 10000)
    >>> 1
    Explanation: The only possible array is [1000]
    
    Example 2:
    
    >>> numberOfArrays(s = "1000", k = 10)
    >>> 0
    Explanation: There cannot be an array that was printed this way and has all integer >= 1 and <= 10.
    
    Example 3:
    
    >>> numberOfArrays(s = "1317", k = 2000)
    >>> 8
    Explanation: Possible arrays are [1317],[131,7],[13,17],[1,317],[13,1,7],[1,31,7],[1,3,17],[1,3,1,7]
    """
def reformat(s: str) -> str:
    """
    You are given an alphanumeric string s. (Alphanumeric string is a string consisting of lowercase English letters and digits).
    You have to find a permutation of the string where no letter is followed by another letter and no digit is followed by another digit. That is, no two adjacent characters have the same type.
    Return the reformatted string or return an empty string if it is impossible to reformat the string.
    
    Example 1:
    
    >>> reformat(s = "a0b1c2")
    >>> "0a1b2c"
    Explanation: No two adjacent characters have the same type in "0a1b2c". "a0b1c2", "0a1b2c", "0c2a1b" are also valid permutations.
    
    Example 2:
    
    >>> reformat(s = "leetcode")
    >>> ""
    Explanation: "leetcode" has only characters so we cannot separate them by digits.
    
    Example 3:
    
    >>> reformat(s = "1229857369")
    >>> ""
    Explanation: "1229857369" has only digits so we cannot separate them by characters.
    """
def displayTable(orders: List[List[str]]) -> List[List[str]]:
    """
    Given the array orders, which represents the orders that customers have done in a restaurant. More specifically orders[i]=[customerNamei,tableNumberi,foodItemi] where customerNamei is the name of the customer, tableNumberi is the table customer sit at, and foodItemi is the item customer orders.\r
    \r
    Return the restaurant's “display table”. The “display table” is a table whose row entries denote how many of each food item each table ordered. The first column is the table number and the remaining columns correspond to each food item in alphabetical order. The first row should be a header whose first column is “Table”, followed by the names of the food items. Note that the customer names are not part of the table. Additionally, the rows should be sorted in numerically increasing order.\r
    \r
     \r
    Example 1:\r
    \r
    \r
    >>> displayTable(orders = [["David","3","Ceviche"],["Corina","10","Beef Burrito"],["David","3","Fried Chicken"],["Carla","5","Water"],["Carla","5","Ceviche"],["Rous","3","Ceviche"]]\r)
    >>> [["Table","Beef Burrito","Ceviche","Fried Chicken","Water"],["3","0","2","1","0"],["5","0","1","0","1"],["10","1","0","0","0"]] \r
    Explanation:\r
    The displaying table looks like:\r
    Table,Beef Burrito,Ceviche,Fried Chicken,Water\r
    3    ,0           ,2      ,1            ,0\r
    5    ,0           ,1      ,0            ,1\r
    10   ,1           ,0      ,0            ,0\r
    For the table 3: David orders "Ceviche" and "Fried Chicken", and Rous orders "Ceviche".\r
    For the table 5: Carla orders "Water" and "Ceviche".\r
    For the table 10: Corina orders "Beef Burrito". \r
    \r
    \r
    Example 2:\r
    \r
    \r
    >>> displayTable(orders = [["James","12","Fried Chicken"],["Ratesh","12","Fried Chicken"],["Amadeus","12","Fried Chicken"],["Adam","1","Canadian Waffles"],["Brianna","1","Canadian Waffles"]]\r)
    >>> [["Table","Canadian Waffles","Fried Chicken"],["1","2","0"],["12","0","3"]] \r
    Explanation: \r
    For the table 1: Adam and Brianna order "Canadian Waffles".\r
    For the table 12: James, Ratesh and Amadeus order "Fried Chicken".\r
    \r
    \r
    Example 3:\r
    \r
    \r
    >>> displayTable(orders = [["Laura","2","Bean Burrito"],["Jhon","2","Beef Burrito"],["Melissa","2","Soda"]]\r)
    >>> [["Table","Bean Burrito","Beef Burrito","Soda"],["2","1","1","1"]]\r
    \r
    \r
     \r
    """
def minNumberOfFrogs(croakOfFrogs: str) -> int:
    """
    You are given the string croakOfFrogs, which represents a combination of the string "croak" from different frogs, that is, multiple frogs can croak at the same time, so multiple "croak" are mixed.
    Return the minimum number of different frogs to finish all the croaks in the given string.
    A valid "croak" means a frog is printing five letters 'c', 'r', 'o', 'a', and 'k' sequentially. The frogs have to print all five letters to finish a croak. If the given string is not a combination of a valid "croak" return -1.
    
    Example 1:
    
    >>> minNumberOfFrogs(croakOfFrogs = "croakcroak")
    >>> 1
    Explanation: One frog yelling "croak" twice.
    
    Example 2:
    
    >>> minNumberOfFrogs(croakOfFrogs = "crcoakroak")
    >>> 2
    Explanation: The minimum number of frogs is two.
    The first frog could yell "crcoakroak".
    The second frog could yell later "crcoakroak".
    
    Example 3:
    
    >>> minNumberOfFrogs(croakOfFrogs = "croakcrook")
    >>> -1
    Explanation: The given string is an invalid combination of "croak" from different frogs.
    """
def numOfArrays(n: int, m: int, k: int) -> int:
    """
    You are given three integers n, m and k. Consider the following algorithm to find the maximum element of an array of positive integers:
    
    You should build the array arr which has the following properties:
    
    arr has exactly n integers.
    1 <= arr[i] <= m where (0 <= i < n).
    After applying the mentioned algorithm to arr, the value search_cost is equal to k.
    
    Return the number of ways to build the array arr under the mentioned conditions. As the answer may grow large, the answer must be computed modulo 109 + 7.
    
    Example 1:
    
    >>> numOfArrays(n = 2, m = 3, k = 1)
    >>> 6
    Explanation: The possible arrays are [1, 1], [2, 1], [2, 2], [3, 1], [3, 2] [3, 3]
    
    Example 2:
    
    >>> numOfArrays(n = 5, m = 2, k = 3)
    >>> 0
    Explanation: There are no possible arrays that satisfy the mentioned conditions.
    
    Example 3:
    
    >>> numOfArrays(n = 9, m = 1, k = 1)
    >>> 1
    Explanation: The only possible array is [1, 1, 1, 1, 1, 1, 1, 1, 1]
    """
def maxScore(s: str) -> int:
    """
    Given a string s of zeros and ones, return the maximum score after splitting the string into two non-empty substrings (i.e. left substring and right substring).
    The score after splitting a string is the number of zeros in the left substring plus the number of ones in the right substring.
    
    Example 1:
    
    >>> maxScore(s = "011101")
    >>> 5
    Explanation:
    All possible ways of splitting s into two non-empty substrings are:
    left = "0" and right = "11101", score = 1 + 4 = 5
    left = "01" and right = "1101", score = 1 + 3 = 4
    left = "011" and right = "101", score = 1 + 2 = 3
    left = "0111" and right = "01", score = 1 + 1 = 2
    left = "01110" and right = "1", score = 2 + 1 = 3
    
    Example 2:
    
    >>> maxScore(s = "00111")
    >>> 5
    Explanation: When left = "00" and right = "111", we get the maximum score = 2 + 3 = 5
    
    Example 3:
    
    >>> maxScore(s = "1111")
    >>> 3
    """