ShwStone/humaneval-leetcode huggingface dataset:
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"]]
    """
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"].
    """
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]]
    """
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
    """
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}.
    """
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")
    >>> ""
    """
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]
    """
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.
    """
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.
    """
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.
    """
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.
    """
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.
    """
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".
    """
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
    """
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]
    """
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.
    """