[
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 3.780703991651535e-06,
    "generate_code_elapsed": 3.6164401799906045,
    "difficulty": "easy",
    "code": "def reverse_words(text: str) -> str:\n    # Split the text into words based on whitespace\n    words = text.split()\n    # Reverse the list of words\n    reversed_words = words[::-1]\n    # Join the reversed list of words with a single space\n    return ' '.join(reversed_words)",
    "prompt": "Return words in reverse order, separated by one space. Words are maximal non-whitespace spans., function signature: reverse_words(text: str) -> str, input examples: [{'case_id': 'PY100-E01-T01', 'input': ['hello world'], 'expected': 'world hello'}, {'case_id': 'PY100-E01-T02', 'input': ['  one   two three '], 'expected': 'three two one'}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 7.911740491787592e-06,
    "generate_code_elapsed": 3.7938216999173164,
    "difficulty": "easy",
    "code": "def is_palindrome_alnum(text: str) -> bool:\n    # Remove non-alphanumeric characters and convert to lowercase\n    cleaned_text = ''.join(char.lower() for char in text if char.isalnum())\n    \n    # Check if the cleaned text is equal to its reverse\n    return cleaned_text == cleaned_text[::-1]",
    "prompt": "Ignore non-alphanumeric characters and letter case; determine whether the remaining characters form a palindrome., function signature: is_palindrome_alnum(text: str) -> bool, input examples: [{'case_id': 'PY100-E02-T01', 'input': ['A man, a plan, a canal: Panama'], 'expected': True}, {'case_id': 'PY100-E02-T02', 'input': ['race a car'], 'expected': False}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 5.4247211664915085e-06,
    "generate_code_elapsed": 3.7066387399099767,
    "difficulty": "easy",
    "code": "def rotate_right(nums: list[int], k: int) -> list[int]:\n    if not nums:\n        return []\n    \n    n = len(nums)\n    k %= n  # In case k is greater than the length of the list\n    \n    # Rotate the list by slicing\n    return nums[-k:] + nums[:-k]",
    "prompt": "Return a new list obtained by rotating nums right by k positions; k is nonnegative. Empty input stays empty., function signature: rotate_right(nums: list[int], k: int) -> list[int], input examples: [{'case_id': 'PY100-E03-T01', 'input': [[1, 2, 3, 4, 5], 2], 'expected': [4, 5, 1, 2, 3]}, {'case_id': 'PY100-E03-T02', 'input': [[1, 2], 5], 'expected': [2, 1]}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 3,
    "all": 6,
    "avg_code_run_elapsed": 5.27947364995877e-06,
    "generate_code_elapsed": 2.104182325070724,
    "difficulty": "easy",
    "code": "def unique_in_order(nums):\n    result = []\n    for num in nums:\n        if not result or num != result[-1]:\n            result.append(num)\n    return result",
    "prompt": "Remove duplicate integers, preserving the first occurrence order., function signature: unique_in_order(nums: list[int]) -> list[int], input examples: [{'case_id': 'PY100-E04-T01', 'input': [[1, 2, 1, 3, 2]], 'expected': [1, 2, 3]}, {'case_id': 'PY100-E04-T02', 'input': [[]], 'expected': []}] Do not include Markdown or any additional text. Only Python Code",
    "errors": [
      {
        "case_id": "PY100-E04-T01",
        "error": "Wrong answer",
        "expected": "[1, 2, 3]",
        "actual": "[1, 2, 1, 3, 2]"
      },
      {
        "case_id": "PY100-E04-T05",
        "error": "Wrong answer",
        "expected": "[0, -1]",
        "actual": "[0, -1, 0, -1]"
      },
      {
        "case_id": "PY100-E04-T06",
        "error": "Wrong answer",
        "expected": "[1, 2, 3, 4]",
        "actual": "[1, 2, 3, 1, 4]"
      }
    ]
  },
  {
    "passed": 1,
    "all": 6,
    "avg_code_run_elapsed": 8.304681008060774e-06,
    "generate_code_elapsed": 5.806089868070558,
    "difficulty": "easy",
    "code": "def word_counts(text: str) -> dict[str, int]:\n    # Remove punctuation and convert to lowercase\n    cleaned_text = ''.join(char.lower() for char in text if char.isalpha())\n    \n    # Split the text into words\n    words = cleaned_text.split()\n    \n    # Count the occurrences of each word\n    word_count = {}\n    for word in words:\n        if word in word_count:\n            word_count[word] += 1\n        else:\n            word_count[word] = 1\n    \n    return word_count",
    "prompt": "Count lowercase words; a word is a contiguous run of ASCII letters A-Z/a-z. Ignore punctuation, digits and case., function signature: word_counts(text: str) -> dict[str,int], input examples: [{'case_id': 'PY100-E05-T01', 'input': ['Hello, hello! World 123'], 'expected': {'hello': 2, 'world': 1}}, {'case_id': 'PY100-E05-T02', 'input': [''], 'expected': {}}] Do not include Markdown or any additional text. Only Python Code",
    "errors": [
      {
        "case_id": "PY100-E05-T01",
        "error": "Wrong answer",
        "expected": "{'hello': 2, 'world': 1}",
        "actual": "{'hellohelloworld': 1}"
      },
      {
        "case_id": "PY100-E05-T03",
        "error": "Wrong answer",
        "expected": "{'one': 1, 'two': 1}",
        "actual": "{'onetwo': 1}"
      },
      {
        "case_id": "PY100-E05-T04",
        "error": "Wrong answer",
        "expected": "{'a': 3, 'b': 1}",
        "actual": "{'aaab': 1}"
      },
      {
        "case_id": "PY100-E05-T05",
        "error": "Wrong answer",
        "expected": "{'hello': 1, 'world': 1}",
        "actual": "{'helloworld': 1}"
      },
      {
        "case_id": "PY100-E05-T06",
        "error": "Wrong answer",
        "expected": "{'x': 2, 'y': 1}",
        "actual": "{'xyx': 1}"
      }
    ]
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 6.258177260557811e-06,
    "generate_code_elapsed": 4.0178710429463536,
    "difficulty": "easy",
    "code": "def second_largest_distinct(nums):\n    # Remove duplicates and sort the list in descending order\n    unique_nums = sorted(set(nums), reverse=True)\n    \n    # Check if there are at least two distinct values\n    if len(unique_nums) < 2:\n        return None\n    \n    # Return the second largest distinct integer\n    return unique_nums[1]",
    "prompt": "Return the second-largest distinct integer, or null if fewer than two distinct values exist., function signature: second_largest_distinct(nums: list[int]) -> int | None, input examples: [{'case_id': 'PY100-E06-T01', 'input': [[4, 1, 4, 2]], 'expected': 2}, {'case_id': 'PY100-E06-T02', 'input': [[1, 1, 1]], 'expected': None}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 3.7907157093286514e-06,
    "generate_code_elapsed": 3.6858479869551957,
    "difficulty": "easy",
    "code": "def max_consecutive_ones(bits):\n    max_count = 0\n    current_count = 0\n    \n    for bit in bits:\n        if bit == 1:\n            current_count += 1\n            max_count = max(max_count, current_count)\n        else:\n            current_count = 0\n    \n    return max_count",
    "prompt": "Return the length of the longest consecutive run of 1s. The list contains only 0s and 1s., function signature: max_consecutive_ones(bits: list[int]) -> int, input examples: [{'case_id': 'PY100-E07-T01', 'input': [[1, 1, 0, 1, 1, 1]], 'expected': 3}, {'case_id': 'PY100-E07-T02', 'input': [[]], 'expected': 0}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 7,
    "all": 7,
    "avg_code_run_elapsed": 4.522801776017461e-06,
    "generate_code_elapsed": 4.600044155027717,
    "difficulty": "easy",
    "code": "def balanced_brackets(text: str) -> bool:\n    stack = []\n    bracket_pairs = {')': '(', ']': '[', '}': '{'}\n    \n    for char in text:\n        if char in bracket_pairs.values():\n            stack.append(char)\n        elif char in bracket_pairs.keys():\n            if not stack or stack.pop() != bracket_pairs[char]:\n                return False\n    \n    return len(stack) == 0",
    "prompt": "Check proper nesting of (), [], {}. Ignore all other characters., function signature: balanced_brackets(text: str) -> bool, input examples: [{'case_id': 'PY100-E08-T01', 'input': ['([]){}'], 'expected': True}, {'case_id': 'PY100-E08-T02', 'input': ['([)]'], 'expected': False}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 4.15373748789231e-06,
    "generate_code_elapsed": 7.293765757000074,
    "difficulty": "easy",
    "code": "def merge_sorted_lists(a: list[int], b: list[int]) -> list[int]:\n    merged = []\n    i, j = 0, 0\n    \n    while i < len(a) and j < len(b):\n        if a[i] <= b[j]:\n            merged.append(a[i])\n            i += 1\n        else:\n            merged.append(b[j])\n            j += 1\n    \n    # Append remaining elements from a\n    while i < len(a):\n        merged.append(a[i])\n        i += 1\n    \n    # Append remaining elements from b\n    while j < len(b):\n        merged.append(b[j])\n        j += 1\n    \n    return merged",
    "prompt": "Merge two nondecreasing integer lists into one nondecreasing list, retaining duplicates., function signature: merge_sorted_lists(a: list[int], b: list[int]) -> list[int], input examples: [{'case_id': 'PY100-E09-T01', 'input': [[1, 3, 5], [2, 4, 6]], 'expected': [1, 2, 3, 4, 5, 6]}, {'case_id': 'PY100-E09-T02', 'input': [[], [1]], 'expected': [1]}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 4.2566486323873205e-06,
    "generate_code_elapsed": 4.340174856828526,
    "difficulty": "easy",
    "code": "def sorted_intersection(a: list[int], b: list[int]) -> list[int]:\n    # Convert lists to sets to remove duplicates and find intersection\n    set_a = set(a)\n    set_b = set(b)\n    \n    # Find the intersection of both sets\n    intersection = set_a.intersection(set_b)\n    \n    # Convert the result back to a sorted list\n    return sorted(intersection)",
    "prompt": "Return distinct integers present in both inputs, sorted ascending., function signature: sorted_intersection(a: list[int], b: list[int]) -> list[int], input examples: [{'case_id': 'PY100-E10-T01', 'input': [[1, 2, 2, 3], [2, 2, 4]], 'expected': [2]}, {'case_id': 'PY100-E10-T02', 'input': [[], [1]], 'expected': []}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 4.370541622241338e-06,
    "generate_code_elapsed": 5.443222308065742,
    "difficulty": "easy",
    "code": "def rle_encode(text: str) -> list[list]:\n    if not text:\n        return []\n    \n    encoded = []\n    count = 1\n    \n    for i in range(1, len(text)):\n        if text[i] == text[i - 1]:\n            count += 1\n        else:\n            encoded.append([text[i - 1], count])\n            count = 1\n    \n    # Append the last group\n    encoded.append([text[-1], count])\n    \n    return encoded",
    "prompt": "Run-length encode adjacent equal characters as [character,count] pairs in original order., function signature: rle_encode(text: str) -> list[list], input examples: [{'case_id': 'PY100-E11-T01', 'input': ['aaabbc'], 'expected': [['a', 3], ['b', 2], ['c', 1]]}, {'case_id': 'PY100-E11-T02', 'input': [''], 'expected': []}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 3.872361655036609e-06,
    "generate_code_elapsed": 7.843014047015458,
    "difficulty": "easy",
    "code": "def caesar_lower(text: str, shift: int) -> str:\n    result = []\n    for char in text:\n        if char.islower():\n            # Calculate the new character with modulo 26 to wrap around if necessary\n            new_char = chr((ord(char) - ord('a') + shift) % 26 + ord('a'))\n            result.append(new_char)\n        else:\n            # Preserve non-lowercase characters as they are\n            result.append(char)\n    return ''.join(result)\n\n# Test cases\nprint(caesar_lower('abc xyz', 2))  # Output: 'cde zab'\nprint(caesar_lower('Zoo!', 1))   # Output: 'Zpp!'",
    "prompt": "Shift lowercase ASCII letters by shift modulo 26, preserving all other characters. shift can be negative., function signature: caesar_lower(text: str, shift: int) -> str, input examples: [{'case_id': 'PY100-E12-T01', 'input': ['abc xyz', 2], 'expected': 'cde zab'}, {'case_id': 'PY100-E12-T02', 'input': ['Zoo!', 1], 'expected': 'Zpp!'}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 4.868993225196998e-06,
    "generate_code_elapsed": 2.10644275508821,
    "difficulty": "easy",
    "code": "def digital_root(n: int) -> int:\n    while n >= 10:\n        n = sum(int(digit) for digit in str(n))\n    return n",
    "prompt": "Return the repeated digit sum of nonnegative n until one digit remains., function signature: digital_root(n: int) -> int, input examples: [{'case_id': 'PY100-E13-T01', 'input': [0], 'expected': 0}, {'case_id': 'PY100-E13-T02', 'input': [9], 'expected': 9}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 4.2906419063607854e-06,
    "generate_code_elapsed": 2.0751666279975325,
    "difficulty": "easy",
    "code": "def count_vowels(text: str) -> int:\n    vowels = \"aeiou\"\n    return sum(1 for char in text.lower() if char in vowels)",
    "prompt": "Count occurrences of ASCII vowels a,e,i,o,u, case-insensitively., function signature: count_vowels(text: str) -> int, input examples: [{'case_id': 'PY100-E14-T01', 'input': ['Hello World'], 'expected': 3}, {'case_id': 'PY100-E14-T02', 'input': ['AEIOU'], 'expected': 5}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 3.7590119366844497e-06,
    "generate_code_elapsed": 5.005273242946714,
    "difficulty": "easy",
    "code": "def longest_common_prefix(words):\n    if not words:\n        return \"\"\n    \n    # Start with the first word as the initial prefix\n    prefix = words[0]\n    \n    # Compare the prefix with each word in the list\n    for word in words[1:]:\n        while not word.startswith(prefix):\n            # Reduce the prefix by one character from the end\n            prefix = prefix[:-1]\n            if not prefix:\n                return \"\"\n    \n    return prefix",
    "prompt": "Return the longest prefix shared by every string; return empty string for empty input., function signature: longest_common_prefix(words: list[str]) -> str, input examples: [{'case_id': 'PY100-E15-T01', 'input': [['flower', 'flow', 'flight']], 'expected': 'fl'}, {'case_id': 'PY100-E15-T02', 'input': [['dog', 'racecar', 'car']], 'expected': ''}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 3.996227557460467e-06,
    "generate_code_elapsed": 1.509399781934917,
    "difficulty": "easy",
    "code": "def is_anagram(a: str, b: str) -> bool:\n    return sorted(a) == sorted(b)",
    "prompt": "Return true iff strings have identical character multisets. Case and whitespace matter., function signature: is_anagram(a: str, b: str) -> bool, input examples: [{'case_id': 'PY100-E16-T01', 'input': ['listen', 'silent'], 'expected': True}, {'case_id': 'PY100-E16-T02', 'input': ['rat', 'car'], 'expected': False}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 4.367708849410216e-06,
    "generate_code_elapsed": 5.140469406964257,
    "difficulty": "easy",
    "code": "def fizzbuzz_slice(start: int, end: int) -> list[str]:\n    result = []\n    for n in range(start, end + 1):\n        if n % 15 == 0:\n            result.append(\"FizzBuzz\")\n        elif n % 3 == 0:\n            result.append(\"Fizz\")\n        elif n % 5 == 0:\n            result.append(\"Buzz\")\n        else:\n            result.append(str(n))\n    return result",
    "prompt": "For each integer n in inclusive [start,end], output FizzBuzz if divisible by 15, Fizz if divisible by 3, Buzz if divisible by 5, otherwise decimal n. If start>end return []., function signature: fizzbuzz_slice(start: int, end: int) -> list[str], input examples: [{'case_id': 'PY100-E17-T01', 'input': [1, 5], 'expected': ['1', '2', 'Fizz', '4', 'Buzz']}, {'case_id': 'PY100-E17-T02', 'input': [14, 16], 'expected': ['14', 'FizzBuzz', '16']}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 3.5240470121304193e-06,
    "generate_code_elapsed": 8.537331867963076,
    "difficulty": "easy",
    "code": "def matrix_diagonal_sum(matrix):\n    n = len(matrix)\n    total_sum = 0\n    \n    # Sum the primary diagonal\n    for i in range(n):\n        total_sum += matrix[i][i]\n    \n    # Sum the secondary diagonal\n    for i in range(n):\n        total_sum += matrix[i][n - 1 - i]\n    \n    # If the matrix is odd-sized, subtract the center element once\n    if n % 2 != 0:\n        total_sum -= matrix[n // 2][n // 2]\n    \n    return total_sum\n\n# Test cases\nprint(matrix_diagonal_sum([[1, 2], [3, 4]]))  # Output: 10\nprint(matrix_diagonal_sum([[5]]))            # Output: 5",
    "prompt": "For a square matrix, return the sum of both diagonals; count their shared center once., function signature: matrix_diagonal_sum(matrix: list[list[int]]) -> int, input examples: [{'case_id': 'PY100-E18-T01', 'input': [[[1, 2], [3, 4]]], 'expected': 10}, {'case_id': 'PY100-E18-T02', 'input': [[[5]]], 'expected': 5}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 6.679523115356763e-06,
    "generate_code_elapsed": 6.191626189043745,
    "difficulty": "easy",
    "code": "def transpose_matrix(matrix):\n    if not matrix:\n        return []\n    \n    # Find the number of rows and columns in the matrix\n    num_rows = len(matrix)\n    num_cols = len(matrix[0])\n    \n    # Create a new matrix with swapped dimensions\n    transposed_matrix = [[0] * num_rows for _ in range(num_cols)]\n    \n    # Fill the transposed matrix\n    for i in range(num_rows):\n        for j in range(num_cols):\n            transposed_matrix[j][i] = matrix[i][j]\n    \n    return transposed_matrix",
    "prompt": "Transpose a rectangular matrix. Empty matrix returns []; nonempty rows have equal length., function signature: transpose_matrix(matrix: list[list[int]]) -> list[list[int]], input examples: [{'case_id': 'PY100-E19-T01', 'input': [[[1, 2, 3], [4, 5, 6]]], 'expected': [[1, 4], [2, 5], [3, 6]]}, {'case_id': 'PY100-E19-T02', 'input': [[]], 'expected': []}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 3.427150659263134e-06,
    "generate_code_elapsed": 2.6955715210642666,
    "difficulty": "easy",
    "code": "def flatten_once(groups):\n    result = []\n    for group in groups:\n        for item in group:\n            if isinstance(item, list):\n                result.extend(flatten_once(item))\n            else:\n                result.append(item)\n    return result",
    "prompt": "Flatten exactly one level of nested integer lists, preserving order., function signature: flatten_once(groups: list[list[int]]) -> list[int], input examples: [{'case_id': 'PY100-E20-T01', 'input': [[[1, 2], [], [3]]], 'expected': [1, 2, 3]}, {'case_id': 'PY100-E20-T02', 'input': [[]], 'expected': []}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 4.9587882434328394e-06,
    "generate_code_elapsed": 4.699959797784686,
    "difficulty": "easy",
    "code": "def cancel_adjacent_pairs(text: str) -> str:\n    stack = []\n    for char in text:\n        if stack and stack[-1] == char:\n            stack.pop()\n        else:\n            stack.append(char)\n    return ''.join(stack)\n\n# Test cases\nprint(cancel_adjacent_pairs('abbaca'))  # Output: 'ca'\nprint(cancel_adjacent_pairs('azxxzy'))  # Output: 'ay'",
    "prompt": "Repeatedly remove adjacent equal characters until no such pair remains; case-sensitive., function signature: cancel_adjacent_pairs(text: str) -> str, input examples: [{'case_id': 'PY100-E21-T01', 'input': ['abbaca'], 'expected': 'ca'}, {'case_id': 'PY100-E21-T02', 'input': ['azxxzy'], 'expected': 'ay'}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 9.211051898698011e-06,
    "generate_code_elapsed": 4.675095001002774,
    "difficulty": "easy",
    "code": "def majority_element(nums: list[int]) -> int | None:\n    from collections import Counter\n    \n    # Count occurrences of each number\n    count = Counter(nums)\n    \n    # Find the number with the highest count\n    for num, freq in count.items():\n        if freq > len(nums) // 2:\n            return num\n    \n    # If no number appears more than n/2 times, return None\n    return None",
    "prompt": "Return the value appearing strictly more than n/2 times, or null if none exists., function signature: majority_element(nums: list[int]) -> int | None, input examples: [{'case_id': 'PY100-E22-T01', 'input': [[2, 2, 1, 2]], 'expected': 2}, {'case_id': 'PY100-E22-T02', 'input': [[1, 2, 3]], 'expected': None}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 3.0396428580085435e-06,
    "generate_code_elapsed": 4.7637677600141615,
    "difficulty": "easy",
    "code": "def missing_zero_to_n(nums):\n    n = len(nums)\n    expected_sum = n * (n + 1) // 2\n    actual_sum = sum(nums)\n    return expected_sum - actual_sum\n\n# Test cases\nprint(missing_zero_to_n([3, 0, 1]))  # Output: 2\nprint(missing_zero_to_n([0, 1]))     # Output: 2",
    "prompt": "The length-n array contains each value from 0 through n except one, without duplicates. Return the missing value., function signature: missing_zero_to_n(nums: list[int]) -> int, input examples: [{'case_id': 'PY100-E23-T01', 'input': [[3, 0, 1]], 'expected': 2}, {'case_id': 'PY100-E23-T02', 'input': [[0, 1]], 'expected': 2}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 5,
    "all": 6,
    "avg_code_run_elapsed": 6.057981712122758e-06,
    "generate_code_elapsed": 7.947175668086857,
    "difficulty": "easy",
    "code": "def two_sum_earliest(nums: list[int], target: int) -> list[int]:\n    # Create a dictionary to store the numbers and their indices\n    num_indices = {}\n    \n    # Iterate through the list of numbers\n    for index, num in enumerate(nums):\n        # Calculate the complement needed to reach the target\n        complement = target - num\n        \n        # Check if the complement is already in the dictionary\n        if complement in num_indices:\n            # Return the earliest indices found\n            return [num_indices[complement], index]\n        \n        # Store the current number and its index in the dictionary\n        num_indices[num] = index\n    \n    # If no solution is found, return an empty list\n    return []",
    "prompt": "Return lexicographically smallest pair of indices [i,j] with i<j and nums[i]+nums[j]=target; or [] if none., function signature: two_sum_earliest(nums: list[int], target: int) -> list[int], input examples: [{'case_id': 'PY100-E24-T01', 'input': [[2, 7, 11, 15], 9], 'expected': [0, 1]}, {'case_id': 'PY100-E24-T02', 'input': [[3, 3], 6], 'expected': [0, 1]}] Do not include Markdown or any additional text. Only Python Code",
    "errors": [
      {
        "case_id": "PY100-E24-T03",
        "error": "Wrong answer",
        "expected": "[0, 3]",
        "actual": "[1, 2]"
      }
    ]
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 3.5185754920045533e-06,
    "generate_code_elapsed": 7.043196118902415,
    "difficulty": "easy",
    "code": "def first_binary_index(nums: list[int], target: int) -> int:\n    left, right = 0, len(nums) - 1\n    \n    while left <= right:\n        mid = (left + right) // 2\n        \n        if nums[mid] == target:\n            # Check if it's the first occurrence\n            if mid == 0 or nums[mid - 1] < target:\n                return mid\n            else:\n                right = mid - 1\n        elif nums[mid] < target:\n            left = mid + 1\n        else:\n            right = mid - 1\n    \n    return -1",
    "prompt": "Return the first index of target in sorted nondecreasing nums; -1 when absent., function signature: first_binary_index(nums: list[int], target: int) -> int, input examples: [{'case_id': 'PY100-E25-T01', 'input': [[1, 2, 2, 3], 2], 'expected': 1}, {'case_id': 'PY100-E25-T02', 'input': [[], 1], 'expected': -1}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 5,
    "all": 6,
    "avg_code_run_elapsed": 4.126496302584807e-06,
    "generate_code_elapsed": 4.357791197951883,
    "difficulty": "easy",
    "code": "def ascii_title_words(text: str) -> str:\n    # Split the text into words based on spaces\n    words = text.split()\n    \n    # Capitalize the first letter of each word and make the rest lowercase\n    title_case_words = [word.capitalize() for word in words]\n    \n    # Join the title-cased words back with spaces\n    return ' '.join(title_case_words)",
    "prompt": "Convert words separated by ASCII spaces to title case: first character uppercase, remaining lowercase; preserve the exact number of spaces. Inputs contain ASCII letters and spaces only., function signature: ascii_title_words(text: str) -> str, input examples: [{'case_id': 'PY100-E26-T01', 'input': ['hello WORLD'], 'expected': 'Hello World'}, {'case_id': 'PY100-E26-T02', 'input': ['  a  b '], 'expected': '  A  B '}] Do not include Markdown or any additional text. Only Python Code",
    "errors": [
      {
        "case_id": "PY100-E26-T02",
        "error": "Wrong answer",
        "expected": "'  A  B '",
        "actual": "'A B'"
      }
    ]
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 3.3031683415174484e-06,
    "generate_code_elapsed": 2.65630879602395,
    "difficulty": "easy",
    "code": "def inclusive_prefix_sums(nums: list[int]) -> list[int]:\n    result = []\n    current_sum = 0\n    for num in nums:\n        current_sum += num\n        result.append(current_sum)\n    return result",
    "prompt": "Return cumulative prefix sums, including each current element., function signature: inclusive_prefix_sums(nums: list[int]) -> list[int], input examples: [{'case_id': 'PY100-E27-T01', 'input': [[1, 2, 3]], 'expected': [1, 3, 6]}, {'case_id': 'PY100-E27-T02', 'input': [[]], 'expected': []}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 3,
    "all": 6,
    "avg_code_run_elapsed": 7.768355620404085e-06,
    "generate_code_elapsed": 12.851813704008237,
    "difficulty": "easy",
    "code": "from collections import Counter\n\ndef count_unique_pairs(nums, target):\n    # Count the occurrences of each number in the list\n    num_counts = Counter(nums)\n    \n    # Initialize the result counter\n    result = 0\n    \n    # Iterate over unique numbers in the list\n    for num in num_counts:\n        # Calculate the required complement to reach the target\n        complement = target - num\n        \n        # Check if the complement exists in the list and is different from the current number\n        if complement in num_counts and complement != num:\n            # Add the product of the counts of the current number and its complement to the result\n            result += num_counts[num] * num_counts[complement]\n        \n        # If the current number is equal to the complement, add the square of its count to the result\n        elif complement == num:\n            result += num_counts[num] * (num_counts[num] - 1) // 2\n    \n    return result\n\n# Test cases\nprint(count_unique_pairs([1, 2, 3, 2, 4], 5))  # Output: 2\nprint(count_unique_pairs([1, 1], 2))          # Output: 1",
    "prompt": "Count distinct unordered value pairs (a,b) with a<=b, sum target, and enough occurrences when a==b., function signature: count_unique_pairs(nums: list[int], target: int) -> int, input examples: [{'case_id': 'PY100-E28-T01', 'input': [[1, 2, 3, 2, 4], 5], 'expected': 2}, {'case_id': 'PY100-E28-T02', 'input': [[1, 1], 2], 'expected': 1}] Do not include Markdown or any additional text. Only Python Code",
    "errors": [
      {
        "case_id": "PY100-E28-T01",
        "error": "Wrong answer",
        "expected": "2",
        "actual": "6"
      },
      {
        "case_id": "PY100-E28-T05",
        "error": "Wrong answer",
        "expected": "2",
        "actual": "4"
      },
      {
        "case_id": "PY100-E28-T06",
        "error": "Wrong answer",
        "expected": "1",
        "actual": "3"
      }
    ]
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 5.44466699163119e-06,
    "generate_code_elapsed": 3.256923731882125,
    "difficulty": "easy",
    "code": "def group_by_parity(nums):\n    even_numbers = []\n    odd_numbers = []\n    \n    for num in nums:\n        if num % 2 == 0:\n            even_numbers.append(num)\n        else:\n            odd_numbers.append(num)\n    \n    return [even_numbers, odd_numbers]",
    "prompt": "Return [even_numbers, odd_numbers], preserving input order within both lists; negative odd numbers are odd., function signature: group_by_parity(nums: list[int]) -> list[list[int]], input examples: [{'case_id': 'PY100-E29-T01', 'input': [[1, 2, 3, 4]], 'expected': [[2, 4], [1, 3]]}, {'case_id': 'PY100-E29-T02', 'input': [[]], 'expected': [[], []]}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 4.3460167944431305e-06,
    "generate_code_elapsed": 8.02994180098176,
    "difficulty": "easy",
    "code": "def rect_overlap_area(a, b):\n    # Unpack the coordinates of the rectangles\n    x1, y1, x2, y2 = a\n    x3, y3, x4, y4 = b\n    \n    # Calculate the overlap in the x and y directions\n    overlap_x = max(0, min(x2, x4) - max(x1, x3))\n    overlap_y = max(0, min(y2, y4) - max(y1, y3))\n    \n    # If there is no overlap, return 0\n    if overlap_x == 0 or overlap_y == 0:\n        return 0\n    \n    # Return the area of the overlap\n    return overlap_x * overlap_y",
    "prompt": "Axis-aligned rectangles [x1,y1,x2,y2] with x1<x2,y1<y2. Return intersection area (0 if disjoint or touching)., function signature: rect_overlap_area(a: list[int], b: list[int]) -> int, input examples: [{'case_id': 'PY100-E30-T01', 'input': [[0, 0, 3, 3], [1, 1, 4, 4]], 'expected': 4}, {'case_id': 'PY100-E30-T02', 'input': [[0, 0, 1, 1], [1, 1, 2, 2]], 'expected': 0}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 7.402462263902028e-06,
    "generate_code_elapsed": 5.524919457035139,
    "difficulty": "medium",
    "code": "def min_positive_subarray(nums: list[int], target: int) -> int:\n    current_sum = 0\n    min_length = float('inf')\n    start = 0\n\n    for end in range(len(nums)):\n        current_sum += nums[end]\n\n        while current_sum >= target:\n            min_length = min(min_length, end - start + 1)\n            current_sum -= nums[start]\n            start += 1\n\n    return min_length if min_length != float('inf') else 0",
    "prompt": "All nums positive; return minimum length of a contiguous subarray with sum >= target, or 0 if impossible., function signature: min_positive_subarray(nums: list[int], target: int) -> int, input examples: [{'case_id': 'PY100-M01-T01', 'input': [[2, 3, 1, 2, 4, 3], 7], 'expected': 2}, {'case_id': 'PY100-M01-T02', 'input': [[1, 1, 1], 4], 'expected': 0}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 5.7426514104008675e-06,
    "generate_code_elapsed": 5.350716660963371,
    "difficulty": "medium",
    "code": "def longest_unique_substring(text: str) -> int:\n    max_length = 0\n    start = 0\n    char_index_map = {}\n\n    for end in range(len(text)):\n        if text[end] in char_index_map and char_index_map[text[end]] >= start:\n            start = char_index_map[text[end]] + 1\n\n        char_index_map[text[end]] = end\n        max_length = max(max_length, end - start + 1)\n\n    return max_length",
    "prompt": "Length of longest substring with no repeated characters; case-sensitive., function signature: longest_unique_substring(text: str) -> int, input examples: [{'case_id': 'PY100-M02-T01', 'input': ['abcabcbb'], 'expected': 3}, {'case_id': 'PY100-M02-T02', 'input': ['bbbbb'], 'expected': 1}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 3,
    "all": 6,
    "avg_code_run_elapsed": 6.392481736838818e-06,
    "generate_code_elapsed": 6.982168660964817,
    "difficulty": "medium",
    "code": "def longest_k_distinct(nums: list[int], k: int) -> int:\n    if k == 0:\n        return 0\n\n    n = len(nums)\n    if n <= k:\n        return n\n\n    left, right = 0, 0\n    distinct_count = set()\n    max_length = 0\n\n    while right < n:\n        if nums[right] not in distinct_count:\n            distinct_count.add(nums[right])\n        else:\n            distinct_count.remove(nums[left])\n            left += 1\n\n        max_length = max(max_length, right - left + 1)\n\n        right += 1\n\n    return max_length",
    "prompt": "Return longest contiguous segment containing at most k distinct integers; k>=0., function signature: longest_k_distinct(nums: list[int], k: int) -> int, input examples: [{'case_id': 'PY100-M03-T01', 'input': [[1, 2, 1, 2, 3], 2], 'expected': 4}, {'case_id': 'PY100-M03-T02', 'input': [[1, 1, 1], 1], 'expected': 3}] Do not include Markdown or any additional text. Only Python Code",
    "errors": [
      {
        "case_id": "PY100-M03-T01",
        "error": "Wrong answer",
        "expected": "4",
        "actual": "3"
      },
      {
        "case_id": "PY100-M03-T02",
        "error": "Wrong answer",
        "expected": "3",
        "actual": "2"
      },
      {
        "case_id": "PY100-M03-T06",
        "error": "KeyError: 2"
      }
    ]
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 4.245278735955556e-06,
    "generate_code_elapsed": 6.821669956902042,
    "difficulty": "medium",
    "code": "def subarray_sum_count(nums: list[int], k: int) -> int:\n    count = 0\n    current_sum = 0\n    prefix_sums = {0: 1}  # Initialize with prefix sum 0 to handle subarrays starting from index 0\n\n    for num in nums:\n        current_sum += num\n        if current_sum - k in prefix_sums:\n            count += prefix_sums[current_sum - k]\n        if current_sum in prefix_sums:\n            prefix_sums[current_sum] += 1\n        else:\n            prefix_sums[current_sum] = 1\n\n    return count",
    "prompt": "Count nonempty contiguous subarrays whose sum is k. Values may be negative., function signature: subarray_sum_count(nums: list[int], k: int) -> int, input examples: [{'case_id': 'PY100-M04-T01', 'input': [[1, 1, 1], 2], 'expected': 2}, {'case_id': 'PY100-M04-T02', 'input': [[1, -1, 0], 0], 'expected': 3}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 7.3447202642758685e-06,
    "generate_code_elapsed": 8.662329617887735,
    "difficulty": "medium",
    "code": "def product_except_self(nums):\n    if not nums:\n        return []\n    \n    n = len(nums)\n    left_products = [1] * n\n    right_products = [1] * n\n    result = [1] * n\n    \n    # Calculate left products\n    for i in range(1, n):\n        left_products[i] = left_products[i - 1] * nums[i - 1]\n    \n    # Calculate right products\n    for i in range(n - 2, -1, -1):\n        right_products[i] = right_products[i + 1] * nums[i + 1]\n    \n    # Combine left and right products to get the result\n    for i in range(n):\n        result[i] = left_products[i] * right_products[i]\n    \n    return result",
    "prompt": "Return products of all elements except at each index; no division required; empty input yields []., function signature: product_except_self(nums: list[int]) -> list[int], input examples: [{'case_id': 'PY100-M05-T01', 'input': [[1, 2, 3, 4]], 'expected': [24, 12, 8, 6]}, {'case_id': 'PY100-M05-T02', 'input': [[0, 1, 2, 3]], 'expected': [6, 0, 0, 0]}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 0,
    "all": 6,
    "avg_code_run_elapsed": 0.0,
    "generate_code_elapsed": 15.102184121962637,
    "difficulty": "medium",
    "code": "def max_circular_subarray(nums):\n    n = len(nums)\n    \n    # Helper function to find the maximum sum of a non-empty subarray\n    def max_non_circular_subarray(nums):\n        max_ending_here = max_so_far = nums[0]\n        for i in range(1, n):\n            max_ending_here = max(nums[i], max_ending_here + nums[i])\n            max_so_far = max(max_so_far, max_ending_here)\n        return max_so_far\n    \n    # Calculate the total sum of the array\n    total_sum = sum(nums)\n    \n    # If all numbers are negative, return the maximum single element\n    if total_sum < 0:\n        return max_non_circular_subarray(nums)\n    \n    # Find the minimum sum of a non-empty subarray\n    min_non_circular_subarray = min_non_circular_subarray(nums)\n    \n    # The maximum circular subarray sum is either the maximum non-circular subarray sum\n    # or the total sum minus the minimum non-circular subarray sum (which makes it circular)\n    return max(max_non_circular_subarray, total_sum - min_non_circular_subarray)\n\n# Test cases\nprint(max_circular_subarray([1, -2, 3, -2]))  # Output: 3\nprint(max_circular_subarray([5, -3, 5]))      # Output: 10",
    "prompt": "For nonempty nums, return maximum sum of a nonempty contiguous circular subarray; no element may be used twice., function signature: max_circular_subarray(nums: list[int]) -> int, input examples: [{'case_id': 'PY100-M06-T01', 'input': [[1, -2, 3, -2]], 'expected': 3}, {'case_id': 'PY100-M06-T02', 'input': [[5, -3, 5]], 'expected': 10}] Do not include Markdown or any additional text. Only Python Code",
    "errors": [
      {
        "error": "UnboundLocalError: cannot access local variable 'min_non_circular_subarray' where it is not associated with a value"
      }
    ]
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 4.901162659128507e-06,
    "generate_code_elapsed": 11.982551095075905,
    "difficulty": "medium",
    "code": "def spiral_matrix(matrix):\n    if not matrix or not matrix[0]:\n        return []\n    \n    result = []\n    top, bottom, left, right = 0, len(matrix) - 1, 0, len(matrix[0]) - 1\n    \n    while top <= bottom and left <= right:\n        # Traverse from left to right\n        for i in range(left, right + 1):\n            result.append(matrix[top][i])\n        top += 1\n        \n        # Traverse from top to bottom\n        for i in range(top, bottom + 1):\n            result.append(matrix[i][right])\n        right -= 1\n        \n        # Traverse from right to left (if there are still elements)\n        if top <= bottom:\n            for i in range(right, left - 1, -1):\n                result.append(matrix[bottom][i])\n            bottom -= 1\n        \n        # Traverse from bottom to top (if there are still elements)\n        if left <= right:\n            for i in range(bottom, top - 1, -1):\n                result.append(matrix[i][left])\n            left += 1\n    \n    return result",
    "prompt": "Return rectangular matrix entries in clockwise spiral order starting top-left., function signature: spiral_matrix(matrix: list[list[int]]) -> list[int], input examples: [{'case_id': 'PY100-M07-T01', 'input': [[[1, 2, 3], [4, 5, 6], [7, 8, 9]]], 'expected': [1, 2, 3, 6, 9, 8, 7, 4, 5]}, {'case_id': 'PY100-M07-T02', 'input': [[[1, 2, 3]]], 'expected': [1, 2, 3]}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 5.5176982035239535e-06,
    "generate_code_elapsed": 7.677031397121027,
    "difficulty": "medium",
    "code": "def search_rotated_unique(nums, target):\n    left, right = 0, len(nums) - 1\n    \n    while left <= right:\n        mid = (left + right) // 2\n        \n        if nums[mid] == target:\n            return mid\n        \n        # Check if the left half is sorted\n        if nums[left] <= nums[mid]:\n            if nums[left] <= target < nums[mid]:\n                right = mid - 1\n            else:\n                left = mid + 1\n        else:\n            # Right half is sorted\n            if nums[mid] < target <= nums[right]:\n                left = mid + 1\n            else:\n                right = mid - 1\n    \n    return -1",
    "prompt": "nums is a rotated strictly increasing array with unique values. Return target index or -1., function signature: search_rotated_unique(nums: list[int], target: int) -> int, input examples: [{'case_id': 'PY100-M08-T01', 'input': [[4, 5, 6, 7, 0, 1, 2], 0], 'expected': 4}, {'case_id': 'PY100-M08-T02', 'input': [[4, 5, 6, 7, 0, 1, 2], 3], 'expected': -1}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 3.8011930882930756e-06,
    "generate_code_elapsed": 7.1442953599616885,
    "difficulty": "medium",
    "code": "def find_first_last(nums: list[int], target: int) -> list[int]:\n    try:\n        first_index = nums.index(target)\n        last_index = len(nums) - nums[::-1].index(target) - 1\n        return [first_index, last_index]\n    except ValueError:\n        return [-1, -1]\n\n# Test cases\nprint(find_first_last([5, 7, 7, 8, 8, 10], 8))  # Output: [3, 4]\nprint(find_first_last([5, 7, 7, 8], 6))          # Output: [-1, -1]",
    "prompt": "Return [first_index,last_index] of target in sorted array; [-1,-1] if absent., function signature: find_first_last(nums: list[int], target: int) -> list[int], input examples: [{'case_id': 'PY100-M09-T01', 'input': [[5, 7, 7, 8, 8, 10], 8], 'expected': [3, 4]}, {'case_id': 'PY100-M09-T02', 'input': [[5, 7, 7, 8], 6], 'expected': [-1, -1]}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 4.172169913848241e-06,
    "generate_code_elapsed": 10.88943626708351,
    "difficulty": "medium",
    "code": "def merge_intervals(intervals):\n    # Sort the intervals based on their start times\n    intervals.sort(key=lambda x: x[0])\n    \n    merged = []\n    for interval in intervals:\n        if not merged or merged[-1][1] < interval[0]:\n            # If no overlap or current interval is not touching the last merged interval, add it to the merged list\n            merged.append(interval)\n        else:\n            # Merge the current interval with the last merged interval\n            merged[-1][1] = max(merged[-1][1], interval[1])\n    \n    return merged\n\n# Test cases\nprint(merge_intervals([[[1, 3], [2, 6], [8, 10], [15, 18]]]))  # Output: [[1, 6], [8, 10], [15, 18]]\nprint(merge_intervals([[[1, 4], [4, 5]]]))  # Output: [[1, 5]]",
    "prompt": "Merge closed intervals [start,end] when overlapping or touching; return sorted merged intervals., function signature: merge_intervals(intervals: list[list[int]]) -> list[list[int]], input examples: [{'case_id': 'PY100-M10-T01', 'input': [[[1, 3], [2, 6], [8, 10], [15, 18]]], 'expected': [[1, 6], [8, 10], [15, 18]]}, {'case_id': 'PY100-M10-T02', 'input': [[[1, 4], [4, 5]]], 'expected': [[1, 5]]}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 4.747300408780575e-06,
    "generate_code_elapsed": 9.893860382959247,
    "difficulty": "medium",
    "code": "def insert_interval(intervals, new_interval):\n    if not intervals:\n        return [new_interval]\n    \n    merged = []\n    i = 0\n    \n    # Add all intervals that end before the new interval starts\n    while i < len(intervals) and intervals[i][1] < new_interval[0]:\n        merged.append(intervals[i])\n        i += 1\n    \n    # Merge overlapping intervals\n    while i < len(intervals) and intervals[i][0] <= new_interval[1]:\n        new_interval[0] = min(new_interval[0], intervals[i][0])\n        new_interval[1] = max(new_interval[1], intervals[i][1])\n        i += 1\n    \n    # Add the merged interval\n    merged.append(new_interval)\n    \n    # Add remaining intervals\n    while i < len(intervals):\n        merged.append(intervals[i])\n        i += 1\n    \n    return merged",
    "prompt": "Insert a closed interval into nonoverlapping sorted closed intervals, merging overlap/touch., function signature: insert_interval(intervals: list[list[int]], new_interval: list[int]) -> list[list[int]], input examples: [{'case_id': 'PY100-M11-T01', 'input': [[[1, 3], [6, 9]], [2, 5]], 'expected': [[1, 5], [6, 9]]}, {'case_id': 'PY100-M11-T02', 'input': [[[1, 2], [3, 5], [6, 7], [8, 10], [12, 16]], [4, 8]], 'expected': [[1, 2], [3, 10], [12, 16]]}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 4.129445490737756e-06,
    "generate_code_elapsed": 11.691225465852767,
    "difficulty": "medium",
    "code": "from typing import List\n\ndef minimum_meeting_rooms(intervals: List[List[int]]) -> int:\n    # Sort intervals by their start time\n    intervals.sort(key=lambda x: x[0])\n    \n    # Use a min-heap to keep track of the end times of meetings\n    import heapq\n    heap = []\n    \n    for interval in intervals:\n        # If the current meeting starts after the earliest ending meeting ends, reuse the room\n        if heap and interval[0] >= heap[0]:\n            heapq.heappop(heap)\n        \n        # Add the end time of the current meeting to the heap\n        heapq.heappush(heap, interval[1])\n    \n    # The size of the heap is the minimum number of rooms needed\n    return len(heap)\n\n# Test cases\nprint(minimum_meeting_rooms([[[0, 30], [5, 10], [15, 20]]]))  # Output: 2\nprint(minimum_meeting_rooms([[[7, 10], [2, 4]]]))  # Output: 1",
    "prompt": "Intervals are [start,end) with start<end. Return minimum number of rooms; end at time t can reuse a room starting at t., function signature: minimum_meeting_rooms(intervals: list[list[int]]) -> int, input examples: [{'case_id': 'PY100-M12-T01', 'input': [[[0, 30], [5, 10], [15, 20]]], 'expected': 2}, {'case_id': 'PY100-M12-T02', 'input': [[[7, 10], [2, 4]]], 'expected': 1}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 3,
    "all": 6,
    "avg_code_run_elapsed": 4.585056255261104e-06,
    "generate_code_elapsed": 13.386319743935019,
    "difficulty": "medium",
    "code": "from collections import defaultdict\n\ndef courses_possible(num_courses, prerequisites):\n    # Create an adjacency list representation of the graph\n    graph = defaultdict(list)\n    for course, prereq in prerequisites:\n        graph[prereq].append(course)\n    \n    # Initialize a set to keep track of visited nodes and a set to keep track of nodes with no prerequisites\n    visited = set()\n    no_prereqs = {course for course in range(num_courses) if not graph[course]}\n    \n    while no_prereqs:\n        # Get a node with no prerequisites\n        course = no_prereqs.pop()\n        visited.add(course)\n        \n        # Remove the course from the graph\n        for dependent_course in graph[course]:\n            graph[dependent_course].remove(course)\n            \n            # If the dependent course now has no prerequisites, add it to the set\n            if not graph[dependent_course]:\n                no_prereqs.add(dependent_course)\n    \n    # If all courses have been visited, return True\n    return len(visited) == num_courses\n\n# Test cases\nprint(courses_possible(2, [[1, 0]]))  # True\nprint(courses_possible(2, [[1, 0], [0, 1]]))  # False",
    "prompt": "Pairs [course,prerequisite] impose prerequisite ordering. Return whether all courses can be finished., function signature: courses_possible(num_courses: int, prerequisites: list[list[int]]) -> bool, input examples: [{'case_id': 'PY100-M13-T01', 'input': [2, [[1, 0]]], 'expected': True}, {'case_id': 'PY100-M13-T02', 'input': [2, [[1, 0], [0, 1]]], 'expected': False}] Do not include Markdown or any additional text. Only Python Code",
    "errors": [
      {
        "case_id": "PY100-M13-T01",
        "error": "Wrong answer",
        "expected": "True",
        "actual": "False"
      },
      {
        "case_id": "PY100-M13-T04",
        "error": "Wrong answer",
        "expected": "True",
        "actual": "False"
      },
      {
        "case_id": "PY100-M13-T06",
        "error": "Wrong answer",
        "expected": "True",
        "actual": "False"
      }
    ]
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 5.958989883462588e-06,
    "generate_code_elapsed": 15.809324122034013,
    "difficulty": "medium",
    "code": "from collections import defaultdict\n\ndef lexicographic_toposort(n, edges):\n    # Build the graph\n    graph = defaultdict(list)\n    for u, v in edges:\n        graph[u].append(v)\n\n    # Initialize indegree array\n    indegree = [0] * n\n    for u in range(n):\n        for v in graph[u]:\n            indegree[v] += 1\n\n    # Initialize queue with nodes having no incoming edges\n    queue = [i for i in range(n) if indegree[i] == 0]\n\n    # Result list to store the topological order\n    result = []\n\n    while queue:\n        # Get the node with the smallest label\n        u = min(queue)\n        result.append(u)\n        queue.remove(u)\n\n        # Decrease the indegree of all adjacent nodes\n        for v in graph[u]:\n            indegree[v] -= 1\n            if indegree[v] == 0:\n                queue.append(v)\n\n    # If the result list has n elements, it means there is no cycle\n    return result if len(result) == n else []\n\n# Test cases\nprint(lexicographic_toposort(4, [[0, 2], [1, 2]]))  # Output: [0, 1, 2, 3]\nprint(lexicographic_toposort(3, [[0, 1], [1, 2]]))  # Output: [0, 1, 2]",
    "prompt": "Directed edges [u,v] mean u before v; return lexicographically smallest valid topological order of nodes 0..n-1, or [] if a cycle., function signature: lexicographic_toposort(n: int, edges: list[list[int]]) -> list[int], input examples: [{'case_id': 'PY100-M14-T01', 'input': [4, [[0, 2], [1, 2]]], 'expected': [0, 1, 2, 3]}, {'case_id': 'PY100-M14-T02', 'input': [3, [[0, 1], [1, 2]]], 'expected': [0, 1, 2]}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 2,
    "all": 6,
    "avg_code_run_elapsed": 1.104820209244887e-06,
    "generate_code_elapsed": 9.030774138867855,
    "difficulty": "medium",
    "code": "def island_count(grid):\n    def dfs(i, j):\n        if i < 0 or i >= len(grid) or j < 0 or j >= len(grid[0]) or grid[i][j] == '0':\n            return\n        grid[i][j] = '0'  # Mark the cell as visited\n        dfs(i + 1, j)  # Explore down\n        dfs(i - 1, j)  # Explore up\n        dfs(i, j + 1)  # Explore right\n        dfs(i, j - 1)  # Explore left\n\n    count = 0\n    for i in range(len(grid)):\n        for j in range(len(grid[0])):\n            if grid[i][j] == '1':\n                dfs(i, j)\n                count += 1\n    return count",
    "prompt": "Rectangular grid of 0 and 1 characters. Count four-directionally connected components of 1 cells., function signature: island_count(grid: list[str]) -> int, input examples: [{'case_id': 'PY100-M15-T01', 'input': [['110', '010', '001']], 'expected': 2}, {'case_id': 'PY100-M15-T02', 'input': [['111', '111']], 'expected': 1}] Do not include Markdown or any additional text. Only Python Code",
    "errors": [
      {
        "case_id": "PY100-M15-T01",
        "error": "TypeError: 'str' object does not support item assignment"
      },
      {
        "case_id": "PY100-M15-T02",
        "error": "TypeError: 'str' object does not support item assignment"
      },
      {
        "case_id": "PY100-M15-T05",
        "error": "TypeError: 'str' object does not support item assignment"
      },
      {
        "case_id": "PY100-M15-T06",
        "error": "TypeError: 'str' object does not support item assignment"
      }
    ]
  },
  {
    "passed": 5,
    "all": 6,
    "avg_code_run_elapsed": 8.531147614121437e-06,
    "generate_code_elapsed": 6.898939308943227,
    "difficulty": "medium",
    "code": "def flood_fill(grid, sr, sc, new_color):\n    rows, cols = len(grid), len(grid[0])\n    original_color = grid[sr][sc]\n    \n    def dfs(x, y):\n        if x < 0 or x >= rows or y < 0 or y >= cols or grid[x][y] != original_color:\n            return\n        grid[x][y] = new_color\n        dfs(x + 1, y)\n        dfs(x - 1, y)\n        dfs(x, y + 1)\n        dfs(x, y - 1)\n    \n    dfs(sr, sc)\n    return grid",
    "prompt": "Replace the four-connected component containing (sr,sc) with new_color; grid nonempty and coordinates valid., function signature: flood_fill(grid: list[list[int]], sr: int, sc: int, new_color: int) -> list[list[int]], input examples: [{'case_id': 'PY100-M16-T01', 'input': [[[1, 1, 1], [1, 1, 0], [1, 0, 1]], 1, 1, 2], 'expected': [[2, 2, 2], [2, 2, 0], [2, 0, 1]]}, {'case_id': 'PY100-M16-T02', 'input': [[[0]], 0, 0, 1], 'expected': [[1]]}] Do not include Markdown or any additional text. Only Python Code",
    "errors": [
      {
        "case_id": "PY100-M16-T04",
        "error": "RecursionError: maximum recursion depth exceeded"
      }
    ]
  },
  {
    "passed": 5,
    "all": 6,
    "avg_code_run_elapsed": 8.485823248823484e-06,
    "generate_code_elapsed": 14.427511723944917,
    "difficulty": "medium",
    "code": "from collections import deque\n\ndef shortest_binary_grid(grid):\n    if not grid or not grid[0]:\n        return -1\n    \n    rows, cols = len(grid), len(grid[0])\n    directions = [(0, 1), (1, 0), (0, -1), (-1, 0)]  # right, down, left, up\n    \n    queue = deque([(0, 0)])  # start from the top-left corner\n    visited = set((0, 0))\n    \n    steps = 0\n    \n    while queue:\n        for _ in range(len(queue)):\n            x, y = queue.popleft()\n            \n            if x == rows - 1 and y == cols - 1:\n                return steps\n            \n            for dx, dy in directions:\n                nx, ny = x + dx, y + dy\n                \n                if 0 <= nx < rows and 0 <= ny < cols and grid[nx][ny] == 0 and (nx, ny) not in visited:\n                    visited.add((nx, ny))\n                    queue.append((nx, ny))\n        \n        steps += 1\n    \n    return -1\n\n# Test cases\nprint(shortest_binary_grid([[0, 0], [1, 0]]))  # Output: 2\nprint(shortest_binary_grid([[[0]]]))  # Output: 0",
    "prompt": "Find minimum four-directional moves from top-left to bottom-right through 0 cells (1 blocked); -1 if impossible., function signature: shortest_binary_grid(grid: list[list[int]]) -> int, input examples: [{'case_id': 'PY100-M17-T01', 'input': [[[0, 0], [1, 0]]], 'expected': 2}, {'case_id': 'PY100-M17-T02', 'input': [[[0]]], 'expected': 0}] Do not include Markdown or any additional text. Only Python Code",
    "errors": [
      {
        "case_id": "PY100-M17-T03",
        "error": "Wrong answer",
        "expected": "-1",
        "actual": "0"
      }
    ]
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 6.270012818276882e-06,
    "generate_code_elapsed": 12.905953358160332,
    "difficulty": "medium",
    "code": "from collections import defaultdict\n\ndef component_sizes(n, edges):\n    # Initialize the graph as an adjacency list\n    graph = defaultdict(list)\n    for u, v in edges:\n        graph[u].append(v)\n        graph[v].append(u)\n    \n    # Initialize visited array to keep track of visited nodes\n    visited = [False] * n\n    \n    # Function to perform DFS and count components\n    def dfs(node):\n        visited[node] = True\n        size = 1\n        for neighbor in graph[node]:\n            if not visited[neighbor]:\n                size += dfs(neighbor)\n        return size\n    \n    # List to store the sizes of all components\n    component_sizes = []\n    \n    # Iterate over each node to find unvisited components\n    for i in range(n):\n        if not visited[i]:\n            component_sizes.append(dfs(i))\n    \n    # Sort the component sizes\n    component_sizes.sort()\n    \n    return component_sizes\n\n# Test cases\nprint(component_sizes(5, [[0, 1], [1, 2], [3, 4]]))  # Output: [2, 3]\nprint(component_sizes(3, []))  # Output: [1, 1, 1]",
    "prompt": "Undirected graph on nodes 0..n-1; return connected component sizes sorted ascending, counting isolated nodes., function signature: component_sizes(n: int, edges: list[list[int]]) -> list[int], input examples: [{'case_id': 'PY100-M18-T01', 'input': [5, [[0, 1], [1, 2], [3, 4]]], 'expected': [2, 3]}, {'case_id': 'PY100-M18-T02', 'input': [3, []], 'expected': [1, 1, 1]}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 4,
    "all": 6,
    "avg_code_run_elapsed": 4.5853666961193085e-06,
    "generate_code_elapsed": 7.932974427938461,
    "difficulty": "medium",
    "code": "def valid_sudoku_partial(board):\n    # Check rows\n    for row in board:\n        if len(set(row)) != 9:\n            return False\n\n    # Check columns\n    for col in range(9):\n        if len(set([board[row][col] for row in range(9)])) != 9:\n            return False\n\n    # Check 3x3 blocks\n    for i in range(3):\n        for j in range(3):\n            block = [board[x][y] for x in range(i*3, (i+1)*3) for y in range(j*3, (j+1)*3)]\n            if len(set(block)) != 9:\n                return False\n\n    return True",
    "prompt": "9x9 rows of digits 1-9 or dots. Return whether every filled row, column, and 3x3 block has no duplicate digit., function signature: valid_sudoku_partial(board: list[str]) -> bool, input examples: [{'case_id': 'PY100-M19-T01', 'input': [['53..7....', '6..195...', '.98....6.', '8...6...3', '4..8.3..1', '7...2...6', '.6....28.', '...419..5', '....8..79']], 'expected': True}, {'case_id': 'PY100-M19-T02', 'input': [['.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........']], 'expected': True}] Do not include Markdown or any additional text. Only Python Code",
    "errors": [
      {
        "case_id": "PY100-M19-T01",
        "error": "Wrong answer",
        "expected": "True",
        "actual": "False"
      },
      {
        "case_id": "PY100-M19-T02",
        "error": "Wrong answer",
        "expected": "True",
        "actual": "False"
      }
    ]
  },
  {
    "passed": 5,
    "all": 6,
    "avg_code_run_elapsed": 5.083313832680385e-06,
    "generate_code_elapsed": 6.6440240947995335,
    "difficulty": "medium",
    "code": "def decode_digit_messages(text: str) -> int:\n    if not text:\n        return 0\n\n    n = len(text)\n    dp = [0] * (n + 1)\n    dp[0], dp[1] = 1, 1\n\n    for i in range(2, n + 1):\n        if text[i - 1] != '0':\n            dp[i] += dp[i - 1]\n        \n        if 10 <= int(text[i - 2:i]) <= 26:\n            dp[i] += dp[i - 2]\n\n    return dp[n]",
    "prompt": "Count decodings of digit string using 1->A through 26->Z, no leading-zero codes. Empty string has 0 decodings., function signature: decode_digit_messages(text: str) -> int, input examples: [{'case_id': 'PY100-M20-T01', 'input': ['12'], 'expected': 2}, {'case_id': 'PY100-M20-T02', 'input': ['226'], 'expected': 3}] Do not include Markdown or any additional text. Only Python Code",
    "errors": [
      {
        "case_id": "PY100-M20-T03",
        "error": "Wrong answer",
        "expected": "0",
        "actual": "1"
      }
    ]
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 0.0001993879365424315,
    "generate_code_elapsed": 3.127535750856623,
    "difficulty": "medium",
    "code": "def climb_one_two(n: int) -> int:\n    if n == 0:\n        return 1\n    elif n == 1:\n        return 1\n    else:\n        return climb_one_two(n - 1) + climb_one_two(n - 2)",
    "prompt": "Return number of ways to climb n steps using jumps of 1 or 2. n=0 has one empty way., function signature: climb_one_two(n: int) -> int, input examples: [{'case_id': 'PY100-M21-T01', 'input': [0], 'expected': 1}, {'case_id': 'PY100-M21-T02', 'input': [1], 'expected': 1}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 5.896940516928832e-06,
    "generate_code_elapsed": 8.311639070045203,
    "difficulty": "medium",
    "code": "def min_coin_change(coins, amount):\n    if amount == 0:\n        return 0\n\n    # Initialize the dp array with infinity, except for dp[0] which is 0\n    dp = [float('inf')] * (amount + 1)\n    dp[0] = 0\n\n    # Iterate over each coin\n    for coin in coins:\n        # Update the dp array for each possible amount\n        for i in range(coin, amount + 1):\n            dp[i] = min(dp[i], dp[i - coin] + 1)\n\n    # If the last element is still infinity, it means it's not possible to make the amount\n    return dp[amount] if dp[amount] != float('inf') else -1",
    "prompt": "Unlimited positive coin denominations; return minimum coins to reach nonnegative amount, or -1., function signature: min_coin_change(coins: list[int], amount: int) -> int, input examples: [{'case_id': 'PY100-M22-T01', 'input': [[1, 2, 5], 11], 'expected': 3}, {'case_id': 'PY100-M22-T02', 'input': [[2], 3], 'expected': -1}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 5.825189873576164e-06,
    "generate_code_elapsed": 4.1243146429769695,
    "difficulty": "medium",
    "code": "def lis_length(nums):\n    if not nums:\n        return 0\n\n    n = len(nums)\n    dp = [1] * n\n\n    for i in range(1, n):\n        for j in range(i):\n            if nums[i] > nums[j]:\n                dp[i] = max(dp[i], dp[j] + 1)\n\n    return max(dp)",
    "prompt": "Length of a strictly increasing (not necessarily contiguous) subsequence. Equal values do not extend., function signature: lis_length(nums: list[int]) -> int, input examples: [{'case_id': 'PY100-M23-T01', 'input': [[10, 9, 2, 5, 3, 7, 101, 18]], 'expected': 4}, {'case_id': 'PY100-M23-T02', 'input': [[0, 1, 0, 3, 2, 3]], 'expected': 4}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 1.4033207359413305e-05,
    "generate_code_elapsed": 11.143030123086646,
    "difficulty": "medium",
    "code": "def edit_distance(a: str, b: str) -> int:\n    m, n = len(a), len(b)\n    \n    # Create a matrix to store distances\n    dp = [[0] * (n + 1) for _ in range(m + 1)]\n    \n    # Initialize the matrix\n    for i in range(m + 1):\n        dp[i][0] = i\n    for j in range(n + 1):\n        dp[0][j] = j\n    \n    # Fill the matrix\n    for i in range(1, m + 1):\n        for j in range(1, n + 1):\n            if a[i - 1] == b[j - 1]:\n                dp[i][j] = dp[i - 1][j - 1]\n            else:\n                dp[i][j] = min(dp[i - 1][j], dp[i][j - 1], dp[i - 1][j - 1]) + 1\n    \n    return dp[m][n]",
    "prompt": "Minimum single-character insertions, deletions or substitutions to transform a into b., function signature: edit_distance(a: str, b: str) -> int, input examples: [{'case_id': 'PY100-M24-T01', 'input': ['horse', 'ros'], 'expected': 3}, {'case_id': 'PY100-M24-T02', 'input': ['intention', 'execution'], 'expected': 5}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 7.914224018653234e-06,
    "generate_code_elapsed": 7.513820216059685,
    "difficulty": "medium",
    "code": "def lcs_length(a: str, b: str) -> int:\n    m, n = len(a), len(b)\n    dp = [[0] * (n + 1) for _ in range(m + 1)]\n\n    for i in range(1, m + 1):\n        for j in range(1, n + 1):\n            if a[i - 1] == b[j - 1]:\n                dp[i][j] = dp[i - 1][j - 1] + 1\n            else:\n                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1])\n\n    return dp[m][n]",
    "prompt": "Length of longest common subsequence, not necessarily contiguous., function signature: lcs_length(a: str, b: str) -> int, input examples: [{'case_id': 'PY100-M25-T01', 'input': ['abcde', 'ace'], 'expected': 3}, {'case_id': 'PY100-M25-T02', 'input': ['abc', 'abc'], 'expected': 3}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 9.196034322182337e-06,
    "generate_code_elapsed": 7.14594550896436,
    "difficulty": "medium",
    "code": "def knapsack_01(weights, values, capacity):\n    n = len(weights)\n    dp = [[0] * (capacity + 1) for _ in range(n + 1)]\n\n    for i in range(1, n + 1):\n        for w in range(capacity + 1):\n            if weights[i - 1] <= w:\n                dp[i][w] = max(values[i - 1] + dp[i - 1][w - weights[i - 1]], dp[i - 1][w])\n            else:\n                dp[i][w] = dp[i - 1][w]\n\n    return dp[n][capacity]",
    "prompt": "Each item may be selected at most once, weight positive, value nonnegative; maximize total value within capacity., function signature: knapsack_01(weights: list[int], values: list[int], capacity: int) -> int, input examples: [{'case_id': 'PY100-M26-T01', 'input': [[2, 3, 4], [4, 5, 6], 5], 'expected': 9}, {'case_id': 'PY100-M26-T02', 'input': [[1, 2], [10, 1], 0], 'expected': 0}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 5,
    "all": 6,
    "avg_code_run_elapsed": 4.768487997353077e-06,
    "generate_code_elapsed": 6.885442260885611,
    "difficulty": "medium",
    "code": "def subset_sum_exists(nums, target):\n    # Create a boolean array where dp[i] will be true if there is a subset of nums that sums up to i\n    dp = [False] * (target + 1)\n    dp[0] = True  # Base case: a sum of 0 can always be achieved with an empty subset\n\n    for num in nums:\n        # Update the dp array from right to left to avoid using the same element multiple times\n        for i in range(target, num - 1, -1):\n            dp[i] = dp[i] or dp[i - num]\n\n    return dp[target]",
    "prompt": "Determine whether any subset (including empty) sums to target; values may be negative., function signature: subset_sum_exists(nums: list[int], target: int) -> bool, input examples: [{'case_id': 'PY100-M27-T01', 'input': [[3, 34, 4, 12, 5, 2], 9], 'expected': True}, {'case_id': 'PY100-M27-T02', 'input': [[3, 34, 4, 12, 5, 2], 30], 'expected': False}] Do not include Markdown or any additional text. Only Python Code",
    "errors": [
      {
        "case_id": "PY100-M27-T05",
        "error": "IndexError: list assignment index out of range"
      }
    ]
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 4.2888956765333814e-06,
    "generate_code_elapsed": 7.8443424529396,
    "difficulty": "medium",
    "code": "def equal_partition(nums):\n    total_sum = sum(nums)\n    if total_sum % 2 != 0:\n        return False\n    target = total_sum // 2\n    n = len(nums)\n    dp = [False] * (target + 1)\n    dp[0] = True\n    \n    for num in nums:\n        for j in range(target, num - 1, -1):\n            dp[j] = dp[j] or dp[j - num]\n    \n    return dp[target]\n\n# Test cases\nprint(equal_partition([1, 5, 11, 5]))  # Output: True\nprint(equal_partition([1, 2, 3, 5]))   # Output: False",
    "prompt": "Nonnegative integers; return whether they can be split into two subsets of equal sum; empty list is true., function signature: equal_partition(nums: list[int]) -> bool, input examples: [{'case_id': 'PY100-M28-T01', 'input': [[1, 5, 11, 5]], 'expected': True}, {'case_id': 'PY100-M28-T02', 'input': [[1, 2, 3, 5]], 'expected': False}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 5.1120684171716375e-06,
    "generate_code_elapsed": 7.948164561996236,
    "difficulty": "medium",
    "code": "def largest_histogram_rectangle(heights):\n    if not heights:\n        return 0\n\n    max_area = 0\n    stack = []\n\n    for i, height in enumerate(heights):\n        while stack and height < heights[stack[-1]]:\n            top = stack.pop()\n            left = stack[-1] if stack else -1\n            width = i - left - 1\n            max_area = max(max_area, heights[top] * width)\n        stack.append(i)\n\n    while stack:\n        top = stack.pop()\n        left = stack[-1] if stack else -1\n        width = len(heights) - left - 1\n        max_area = max(max_area, heights[top] * width)\n\n    return max_area",
    "prompt": "Unit-width histogram bars with nonnegative heights. Return maximum axis-aligned rectangle area within bars., function signature: largest_histogram_rectangle(heights: list[int]) -> int, input examples: [{'case_id': 'PY100-M29-T01', 'input': [[2, 1, 5, 6, 2, 3]], 'expected': 10}, {'case_id': 'PY100-M29-T02', 'input': [[]], 'expected': 0}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 3.4546246752142906e-06,
    "generate_code_elapsed": 6.863367012934759,
    "difficulty": "medium",
    "code": "def next_greater_right(nums):\n    stack = []\n    result = [-1] * len(nums)\n    \n    for i in range(len(nums)):\n        while stack and nums[stack[-1]] < nums[i]:\n            result[stack.pop()] = nums[i]\n        stack.append(i)\n    \n    return result\n\n# Test cases\nprint(next_greater_right([2, 1, 2, 4, 3]))  # Output: [4, 2, 4, -1, -1]\nprint(next_greater_right([1, 2, 3]))      # Output: [2, 3, -1]",
    "prompt": "For each element return first strictly greater value to its right, or -1., function signature: next_greater_right(nums: list[int]) -> list[int], input examples: [{'case_id': 'PY100-M30-T01', 'input': [[2, 1, 2, 4, 3]], 'expected': [4, 2, 4, -1, -1]}, {'case_id': 'PY100-M30-T02', 'input': [[1, 2, 3]], 'expected': [2, 3, -1]}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 4.452536813914776e-06,
    "generate_code_elapsed": 4.719852908980101,
    "difficulty": "medium",
    "code": "from typing import List\n\ndef days_until_warmer(temperatures: List[int]) -> List[float]:\n    n = len(temperatures)\n    result = [0] * n\n    stack = []\n\n    for i in range(n):\n        while stack and temperatures[i] > temperatures[stack[-1]]:\n            j = stack.pop()\n            result[j] = i - j\n        stack.append(i)\n\n    return result",
    "prompt": "For each day return days until a strictly warmer future temperature, or 0., function signature: days_until_warmer(temperatures: list[int]) -> list[int], input examples: [{'case_id': 'PY100-M31-T01', 'input': [[73, 74, 75, 71, 69, 72, 76, 73]], 'expected': [1, 1, 4, 2, 1, 1, 0, 0]}, {'case_id': 'PY100-M31-T02', 'input': [[]], 'expected': []}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 5,
    "all": 6,
    "avg_code_run_elapsed": 5.811840916673343e-06,
    "generate_code_elapsed": 8.740792236989364,
    "difficulty": "medium",
    "code": "from collections import defaultdict\n\ndef sorted_anagram_groups(words):\n    # Create a dictionary to hold anagrams\n    anagram_dict = defaultdict(list)\n    \n    # Group anagrams\n    for word in words:\n        # Sort the characters of the word to get the key\n        sorted_word = ''.join(sorted(word))\n        anagram_dict[sorted_word].append(word)\n    \n    # Sort the groups by the first word alphabetically\n    sorted_groups = sorted(anagram_dict.values(), key=lambda x: x[0])\n    \n    return sorted_groups\n\n# Test cases\nprint(sorted_anagram_groups(['eat', 'tea', 'tan', 'ate', 'nat', 'bat']))  # [['ate', 'eat', 'tea'], ['bat'], ['nat', 'tan']]\nprint(sorted_anagram_groups([]))  # []",
    "prompt": "Group exact-case anagrams; sort words within each group; sort groups by their first word alphabetically. Empty input returns []., function signature: sorted_anagram_groups(words: list[str]) -> list[list[str]], input examples: [{'case_id': 'PY100-M32-T01', 'input': [['eat', 'tea', 'tan', 'ate', 'nat', 'bat']], 'expected': [['ate', 'eat', 'tea'], ['bat'], ['nat', 'tan']]}, {'case_id': 'PY100-M32-T02', 'input': [[]], 'expected': []}] Do not include Markdown or any additional text. Only Python Code",
    "errors": [
      {
        "case_id": "PY100-M32-T01",
        "error": "Wrong answer",
        "expected": "[['ate', 'eat', 'tea'], ['bat'], ['nat', 'tan']]",
        "actual": "[['bat'], ['eat', 'tea', 'ate'], ['tan', 'nat']]"
      }
    ]
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 9.98715404421091e-06,
    "generate_code_elapsed": 5.728534135967493,
    "difficulty": "medium",
    "code": "from collections import Counter\n\ndef top_k_frequent_words(words: list[str], k: int) -> list[str]:\n    # Count the frequency of each word\n    word_counts = Counter(words)\n    \n    # Sort the words by frequency (descending) and then alphabetically\n    sorted_words = sorted(word_counts.items(), key=lambda x: (-x[1], x[0]))\n    \n    # Extract the top k words\n    top_k = [word for word, _ in sorted_words[:k]]\n    \n    return top_k",
    "prompt": "Return at most k distinct words by descending frequency, breaking ties alphabetically; k>=0., function signature: top_k_frequent_words(words: list[str], k: int) -> list[str], input examples: [{'case_id': 'PY100-M33-T01', 'input': [['i', 'love', 'leetcode', 'i', 'love', 'coding'], 2], 'expected': ['i', 'love']}, {'case_id': 'PY100-M33-T02', 'input': [['b', 'a', 'b', 'c', 'a'], 3], 'expected': ['a', 'b', 'c']}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 1,
    "all": 6,
    "avg_code_run_elapsed": 4.0538531417648e-06,
    "generate_code_elapsed": 5.096634060842916,
    "difficulty": "medium",
    "code": "def simplify_unix_path(path: str) -> str:\n    stack = []\n    for segment in path.split('/'):\n        if segment == '.':\n            continue\n        elif segment == '..':\n            if stack:\n                stack.pop()\n        else:\n            stack.append(segment)\n    return '/' + '/'.join(stack)\n\n# Test cases\nprint(simplify_unix_path('/home/'))  # Output: /home\nprint(simplify_unix_path('/../'))   # Output: /",
    "prompt": "Canonicalize absolute Unix path by collapsing repeated slashes, . and ..; root cannot be traversed above., function signature: simplify_unix_path(path: str) -> str, input examples: [{'case_id': 'PY100-M34-T01', 'input': ['/home/'], 'expected': '/home'}, {'case_id': 'PY100-M34-T02', 'input': ['/../'], 'expected': '/'}] Do not include Markdown or any additional text. Only Python Code",
    "errors": [
      {
        "case_id": "PY100-M34-T01",
        "error": "Wrong answer",
        "expected": "'/home'",
        "actual": "'//home/'"
      },
      {
        "case_id": "PY100-M34-T03",
        "error": "Wrong answer",
        "expected": "'/home/foo'",
        "actual": "'//home//foo/'"
      },
      {
        "case_id": "PY100-M34-T04",
        "error": "Wrong answer",
        "expected": "'/c'",
        "actual": "'//c/'"
      },
      {
        "case_id": "PY100-M34-T05",
        "error": "Wrong answer",
        "expected": "'/'",
        "actual": "'//'"
      },
      {
        "case_id": "PY100-M34-T06",
        "error": "Wrong answer",
        "expected": "'/a/.../b'",
        "actual": "'//a/.../b'"
      }
    ]
  },
  {
    "passed": 0,
    "all": 6,
    "avg_code_run_elapsed": 0.0,
    "generate_code_elapsed": 10.17459395295009,
    "difficulty": "medium",
    "code": "from collections import Counter\n\ndef minimum_cover_window(text: str, chars: str) -> str:\n    if not chars:\n        return \"\"\n    \n    char_count = Counter(chars)\n    required_chars = len(char_count)\n    window_count = Counter()\n    left, right = 0, 0\n    min_length = float('inf')\n    min_window = \"\"\n    \n    while right < len(text):\n        window_count[text[right]] += 1\n        \n        if window_count[text[right]] == char_count[text[right]]:\n            required_chars -= 1\n        \n        while required_chars == 0:\n            if right - left + 1 < min_length:\n                min_length = right - left + 1\n                min_window = text[left:right+1]\n            \n            window_count[text[left]] -= 1\n            if window_count[text[left]] < char_count[text[left]]:\n                required_chars += 1\n            left += 1\n    \n    return min_window",
    "prompt": "Shortest substring containing every character of chars with multiplicity. Tie: earliest start. Return empty if impossible or chars empty., function signature: minimum_cover_window(text: str, chars: str) -> str, input examples: [{'case_id': 'PY100-M35-T01', 'input': ['ADOBECODEBANC', 'ABC'], 'expected': 'BANC'}, {'case_id': 'PY100-M35-T02', 'input': ['a', 'aa'], 'expected': ''}] Do not include Markdown or any additional text. Only Python Code",
    "errors": {
      "case_id": "PY100-M35",
      "error": "Exceeded 20s"
    }
  },
  {
    "passed": 5,
    "all": 6,
    "avg_code_run_elapsed": 7.000674183170001e-06,
    "generate_code_elapsed": 6.525164460996166,
    "difficulty": "medium",
    "code": "def valid_ipv4(text: str) -> bool:\n    # Split the input string into segments\n    segments = text.split('.')\n    \n    # Check if there are exactly 4 segments\n    if len(segments) != 4:\n        return False\n    \n    # Validate each segment\n    for segment in segments:\n        # Check if the segment is a digit and within the range 0-255\n        if not segment.isdigit() or not (0 <= int(segment) <= 255):\n            return False\n    \n    # If all segments are valid, return True\n    return True",
    "prompt": "Validate strict dotted-decimal IPv4: 4 segments each 0..255; no leading zero except literal 0; ASCII digits only., function signature: valid_ipv4(text: str) -> bool, input examples: [{'case_id': 'PY100-M36-T01', 'input': ['192.168.0.1'], 'expected': True}, {'case_id': 'PY100-M36-T02', 'input': ['01.2.3.4'], 'expected': False}] Do not include Markdown or any additional text. Only Python Code",
    "errors": [
      {
        "case_id": "PY100-M36-T02",
        "error": "Wrong answer",
        "expected": "False",
        "actual": "True"
      }
    ]
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 1.0256034632523855e-05,
    "generate_code_elapsed": 8.673503509024158,
    "difficulty": "medium",
    "code": "def compare_versions(a: str, b: str) -> int:\n    # Split the version strings into lists of integers\n    a_parts = list(map(int, a.split('.')))\n    b_parts = list(map(int, b.split('.')))\n    \n    # Pad the shorter list with zeros\n    max_length = max(len(a_parts), len(b_parts))\n    a_parts += [0] * (max_length - len(a_parts))\n    b_parts += [0] * (max_length - len(b_parts))\n    \n    # Compare each part\n    for i in range(max_length):\n        if a_parts[i] < b_parts[i]:\n            return -1\n        elif a_parts[i] > b_parts[i]:\n            return 1\n    \n    # If all parts are equal, return 0\n    return 0",
    "prompt": "Dot-separated nonnegative integer version components; trailing zero components ignored. Return -1, 0 or 1., function signature: compare_versions(a: str, b: str) -> int, input examples: [{'case_id': 'PY100-M37-T01', 'input': ['1.01', '1.001'], 'expected': 0}, {'case_id': 'PY100-M37-T02', 'input': ['1.0', '1.0.0'], 'expected': 0}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 5.684870605667432e-06,
    "generate_code_elapsed": 6.529180390993133,
    "difficulty": "medium",
    "code": "def evaluate_rpn(tokens):\n    stack = []\n    for token in tokens:\n        if token.isdigit() or (token[0] == '-' and token[1:].isdigit()):\n            stack.append(int(token))\n        else:\n            b = stack.pop()\n            a = stack.pop()\n            if token == '+':\n                stack.append(a + b)\n            elif token == '-':\n                stack.append(a - b)\n            elif token == '*':\n                stack.append(a * b)\n            elif token == '/':\n                stack.append(int(a / b))  # Integer division truncates toward zero\n    return stack[0]",
    "prompt": "Evaluate valid Reverse Polish notation with +,-,*,/; integer division truncates toward zero; no division by zero., function signature: evaluate_rpn(tokens: list[str]) -> int, input examples: [{'case_id': 'PY100-M38-T01', 'input': [['2', '1', '+', '3', '*']], 'expected': 9}, {'case_id': 'PY100-M38-T02', 'input': [['4', '13', '5', '/', '+']], 'expected': 6}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 0,
    "all": 6,
    "avg_code_run_elapsed": 0.0,
    "generate_code_elapsed": 10.08204286894761,
    "difficulty": "medium",
    "code": "from itertools import permutations\n\ndef unique_permutations(nums):\n    # Generate all permutations of the input list\n    perm_list = list(permutations(nums))\n    # Convert tuples to lists and remove duplicates\n    unique_perms = list(set([list(perm) for perm in perm_list]))\n    # Sort the permutations lexicographically\n    unique_perms.sort()\n    return unique_perms\n\n# Test cases\nprint(unique_permutations([1, 1, 2]))  # Output: [[1, 1, 2], [1, 2, 1], [2, 1, 1]]\nprint(unique_permutations([1, 2, 3]))  # Output: [[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]]",
    "prompt": "Return all distinct permutations sorted lexicographically, each permutation as a list. Input length <=7., function signature: unique_permutations(nums: list[int]) -> list[list[int]], input examples: [{'case_id': 'PY100-M39-T01', 'input': [[1, 1, 2]], 'expected': [[1, 1, 2], [1, 2, 1], [2, 1, 1]]}, {'case_id': 'PY100-M39-T02', 'input': [[1, 2, 3]], 'expected': [[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]]}] Do not include Markdown or any additional text. Only Python Code",
    "errors": [
      {
        "error": "TypeError: unhashable type: 'list'"
      }
    ]
  },
  {
    "passed": 2,
    "all": 6,
    "avg_code_run_elapsed": 9.257967273394266e-06,
    "generate_code_elapsed": 7.717018527211621,
    "difficulty": "medium",
    "code": "def combinations_k(n, k):\n    if k == 0:\n        return [[]]\n    \n    result = []\n    for i in range(1, n - k + 2):\n        for comb in combinations_k(n, k - 1):\n            if comb and comb[-1] < i:\n                result.append(comb + [i])\n    \n    return sorted(result)\n\n# Test cases\nprint(combinations_k(4, 2))  # Output: [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4]]\nprint(combinations_k(1, 1))  # Output: [[1]]",
    "prompt": "Generate lexicographically sorted k-element strictly increasing combinations from numbers 1..n; 0<=k<=n<=10., function signature: combinations_k(n: int, k: int) -> list[list[int]], input examples: [{'case_id': 'PY100-M40-T01', 'input': [4, 2], 'expected': [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4]]}, {'case_id': 'PY100-M40-T02', 'input': [1, 1], 'expected': [[1]]}] Do not include Markdown or any additional text. Only Python Code",
    "errors": [
      {
        "case_id": "PY100-M40-T01",
        "error": "Wrong answer",
        "expected": "[[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4]]",
        "actual": "[]"
      },
      {
        "case_id": "PY100-M40-T02",
        "error": "Wrong answer",
        "expected": "[[1]]",
        "actual": "[]"
      },
      {
        "case_id": "PY100-M40-T05",
        "error": "Wrong answer",
        "expected": "[[1, 2, 3, 4, 5]]",
        "actual": "[]"
      },
      {
        "case_id": "PY100-M40-T06",
        "error": "Wrong answer",
        "expected": "[[1], [2], [3], [4], [5]]",
        "actual": "[]"
      }
    ]
  },
  {
    "passed": 4,
    "all": 6,
    "avg_code_run_elapsed": 6.700167432427406e-06,
    "generate_code_elapsed": 11.431865795049816,
    "difficulty": "medium",
    "code": "from typing import List\n\ndef phone_keypad_words(digits: str) -> List[str]:\n    # Define the mapping of digits to letters\n    digit_to_letters = {\n        '2': 'abc',\n        '3': 'def',\n        '4': 'ghi',\n        '5': 'jkl',\n        '6': 'mno',\n        '7': 'pqrs',\n        '8': 'tuv',\n        '9': 'wxyz'\n    }\n    \n    def backtrack(index, path):\n        if index == len(digits):\n            result.append(''.join(path))\n            return\n        \n        for letter in digit_to_letters[digits[index]]:\n            path.append(letter)\n            backtrack(index + 1, path)\n            path.pop()\n    \n    result = []\n    backtrack(0, [])\n    return result\n\n# Test cases\nprint(phone_keypad_words('23'))  # Output: ['ad', 'ae', 'af', 'bd', 'be', 'bf', 'cd', 'ce', 'cf']\nprint(phone_keypad_words(''))     # Output: []",
    "prompt": "Digits 2..9; return phone keypad letter combinations in lexicographic order, or [] for empty input., function signature: phone_keypad_words(digits: str) -> list[str], input examples: [{'case_id': 'PY100-M41-T01', 'input': ['23'], 'expected': ['ad', 'ae', 'af', 'bd', 'be', 'bf', 'cd', 'ce', 'cf']}, {'case_id': 'PY100-M41-T02', 'input': [''], 'expected': []}] Do not include Markdown or any additional text. Only Python Code",
    "errors": [
      {
        "case_id": "PY100-M41-T02",
        "error": "Wrong answer",
        "expected": "[]",
        "actual": "['']"
      },
      {
        "case_id": "PY100-M41-T06",
        "error": "Wrong answer",
        "expected": "[]",
        "actual": "['']"
      }
    ]
  },
  {
    "passed": 2,
    "all": 6,
    "avg_code_run_elapsed": 5.764770321547985e-06,
    "generate_code_elapsed": 9.133047650801018,
    "difficulty": "medium",
    "code": "from collections import Counter\n\ndef kth_largest_with_duplicates(nums: list[int], k: int) -> int:\n    # Count the occurrences of each number in the list\n    num_counts = Counter(nums)\n    \n    # Sort the numbers by their frequency in descending order\n    sorted_nums = sorted(num_counts.keys(), key=lambda x: num_counts[x], reverse=True)\n    \n    # Return the k-th largest number\n    return sorted_nums[k-1]\n\n# Test cases\nprint(kth_largest_with_duplicates([3, 2, 1, 5, 6, 4], 2))  # Output: 5\nprint(kth_largest_with_duplicates([3, 2, 3, 1, 2, 4, 5, 5, 6], 4))  # Output: 4",
    "prompt": "Return kth largest element counting duplicates; 1<=k<=len(nums)., function signature: kth_largest_with_duplicates(nums: list[int], k: int) -> int, input examples: [{'case_id': 'PY100-M42-T01', 'input': [[3, 2, 1, 5, 6, 4], 2], 'expected': 5}, {'case_id': 'PY100-M42-T02', 'input': [[3, 2, 3, 1, 2, 4, 5, 5, 6], 4], 'expected': 4}] Do not include Markdown or any additional text. Only Python Code",
    "errors": [
      {
        "case_id": "PY100-M42-T01",
        "error": "Wrong answer",
        "expected": "5",
        "actual": "2"
      },
      {
        "case_id": "PY100-M42-T02",
        "error": "Wrong answer",
        "expected": "4",
        "actual": "1"
      },
      {
        "case_id": "PY100-M42-T04",
        "error": "IndexError: list index out of range"
      },
      {
        "case_id": "PY100-M42-T05",
        "error": "Wrong answer",
        "expected": "-5",
        "actual": "-2"
      }
    ]
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 3.996809634069602e-06,
    "generate_code_elapsed": 8.592079148860648,
    "difficulty": "medium",
    "code": "def k_closest_points(points, k):\n    # Sort the points based on their squared distance from the origin\n    # and then by x-coordinate, and finally by y-coordinate.\n    sorted_points = sorted(points, key=lambda p: (p[0]**2 + p[1]**2, p[0], p[1]))\n    \n    # Return the first k points from the sorted list\n    return sorted_points[:k]\n\n# Test cases\nprint(k_closest_points([[1, 3], [-2, 2]], 1))  # Output: [[-2, 2]]\nprint(k_closest_points([[3, 3], [5, -1], [-2, 4]], 2))  # Output: [[3, 3], [-2, 4]]",
    "prompt": "Return k points closest to origin by squared distance; break ties by x then y, preserving duplicates., function signature: k_closest_points(points: list[list[int]], k: int) -> list[list[int]], input examples: [{'case_id': 'PY100-M43-T01', 'input': [[[1, 3], [-2, 2]], 1], 'expected': [[-2, 2]]}, {'case_id': 'PY100-M43-T02', 'input': [[[3, 3], [5, -1], [-2, 4]], 2], 'expected': [[3, 3], [-2, 4]]}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 3.3970378960172334e-06,
    "generate_code_elapsed": 5.400578642031178,
    "difficulty": "medium",
    "code": "def count_inversions(nums):\n    n = len(nums)\n    inv_count = 0\n    for i in range(n):\n        for j in range(i + 1, n):\n            if nums[i] > nums[j]:\n                inv_count += 1\n    return inv_count\n\n# Test cases\nprint(count_inversions([2, 4, 1, 3, 5]))  # Output: 3\nprint(count_inversions([]))  # Output: 0",
    "prompt": "Count pairs i<j with nums[i]>nums[j]. Equal elements do not count., function signature: count_inversions(nums: list[int]) -> int, input examples: [{'case_id': 'PY100-M44-T01', 'input': [[2, 4, 1, 3, 5]], 'expected': 3}, {'case_id': 'PY100-M44-T02', 'input': [[]], 'expected': 0}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 2,
    "all": 6,
    "avg_code_run_elapsed": 9.51811671257019e-07,
    "generate_code_elapsed": 13.438504232093692,
    "difficulty": "medium",
    "code": "def two_stock_transactions(prices):\n    if not prices:\n        return 0\n\n    n = len(prices)\n    if n < 4:\n        return max(0, max(prices) - min(prices))\n\n    # Initialize DP arrays\n    dp1 = [0] * n  # Max profit up to i with one transaction\n    dp2 = [0] * n  # Max profit up to i with two transactions\n\n    # Fill dp1 array\n    min_price = prices[0]\n    for i in range(1, n):\n        min_price = min(min_price, prices[i])\n        dp1[i] = max(dp1[i-1], prices[i] - min_price)\n\n    # Fill dp2 array\n    max_profit = 0\n    for i in range(n-1, -1, -1):\n        max_profit = max(max_profit, prices[i])\n        dp2[i] = max(dp2[i+1], max_profit - prices[i])\n\n    # Calculate the maximum profit with two transactions\n    max_profit_two_transactions = 0\n    for i in range(n):\n        max_profit_two_transactions = max(max_profit_two_transactions, dp1[i] + dp2[i+1])\n\n    return max_profit_two_transactions",
    "prompt": "Max profit with at most two nonoverlapping buy-sell transactions; cannot hold two shares simultaneously., function signature: two_stock_transactions(prices: list[int]) -> int, input examples: [{'case_id': 'PY100-M45-T01', 'input': [[3, 3, 5, 0, 0, 3, 1, 4]], 'expected': 6}, {'case_id': 'PY100-M45-T02', 'input': [[1, 2, 3, 4, 5]], 'expected': 4}] Do not include Markdown or any additional text. Only Python Code",
    "errors": [
      {
        "case_id": "PY100-M45-T01",
        "error": "IndexError: list index out of range"
      },
      {
        "case_id": "PY100-M45-T02",
        "error": "IndexError: list index out of range"
      },
      {
        "case_id": "PY100-M45-T03",
        "error": "IndexError: list index out of range"
      },
      {
        "case_id": "PY100-M45-T06",
        "error": "IndexError: list index out of range"
      }
    ]
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 1.3821486694117388e-05,
    "generate_code_elapsed": 6.336787855019793,
    "difficulty": "hard",
    "code": "def minimum_word_break(text: str, dictionary: list[str]) -> int:\n    n = len(text)\n    dp = [float('inf')] * (n + 1)\n    dp[0] = 0\n\n    for i in range(1, n + 1):\n        for word in dictionary:\n            if i >= len(word) and text[i - len(word):i] == word:\n                dp[i] = min(dp[i], dp[i - len(word)] + 1)\n\n    return dp[n] if dp[n] != float('inf') else -1",
    "prompt": "Minimum number of nonempty dictionary words concatenated to form text exactly, with unlimited reuse; -1 if impossible, 0 for empty text., function signature: minimum_word_break(text: str, dictionary: list[str]) -> int, input examples: [{'case_id': 'PY100-H01-T01', 'input': ['leetcode', ['leet', 'code']], 'expected': 2}, {'case_id': 'PY100-H01-T02', 'input': ['catsanddog', ['cats', 'cat', 'and', 'sand', 'dog']], 'expected': 3}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 3,
    "all": 6,
    "avg_code_run_elapsed": 4.575354978442192e-06,
    "generate_code_elapsed": 6.231487846933305,
    "difficulty": "hard",
    "code": "def wildcard_match(text: str, pattern: str) -> bool:\n    def match(text, pattern):\n        if not pattern:\n            return not text\n\n        first_match = bool(text) and (pattern[0] == text[0] or pattern[0] == '?')\n\n        if len(pattern) > 1 and pattern[1] == '*':\n            return match(text, pattern[2:]) or (first_match and match(text[1:], pattern))\n        else:\n            return first_match and match(text[1:], pattern[1:])\n\n    return match(text, pattern)",
    "prompt": "Match entire text to wildcard pattern: ? matches one character, * matches any sequence including empty; all other characters literal., function signature: wildcard_match(text: str, pattern: str) -> bool, input examples: [{'case_id': 'PY100-H02-T01', 'input': ['aa', 'a'], 'expected': False}, {'case_id': 'PY100-H02-T02', 'input': ['aa', '*'], 'expected': True}] Do not include Markdown or any additional text. Only Python Code",
    "errors": [
      {
        "case_id": "PY100-H02-T02",
        "error": "Wrong answer",
        "expected": "True",
        "actual": "False"
      },
      {
        "case_id": "PY100-H02-T04",
        "error": "Wrong answer",
        "expected": "True",
        "actual": "False"
      },
      {
        "case_id": "PY100-H02-T06",
        "error": "Wrong answer",
        "expected": "True",
        "actual": "False"
      }
    ]
  },
  {
    "passed": 5,
    "all": 6,
    "avg_code_run_elapsed": 3.236846532672644e-05,
    "generate_code_elapsed": 4.302689788164571,
    "difficulty": "hard",
    "code": "import re\n\ndef simple_regex_fullmatch(text: str, pattern: str) -> bool:\n    # Check if the pattern is valid\n    if not re.match(r'^[a-zA-Z0-9*]+$', pattern):\n        return False\n    \n    # Use re.fullmatch to check if the entire text matches the pattern\n    return re.fullmatch(pattern, text) is not None",
    "prompt": "Full match using . for any single character and * for zero or more of immediately preceding atom. Pattern guaranteed valid (no leading or consecutive *)., function signature: simple_regex_fullmatch(text: str, pattern: str) -> bool, input examples: [{'case_id': 'PY100-H03-T01', 'input': ['aa', 'a'], 'expected': False}, {'case_id': 'PY100-H03-T02', 'input': ['aa', 'a*'], 'expected': True}] Do not include Markdown or any additional text. Only Python Code",
    "errors": [
      {
        "case_id": "PY100-H03-T03",
        "error": "Wrong answer",
        "expected": "True",
        "actual": "False"
      }
    ]
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 5.56469118843476e-06,
    "generate_code_elapsed": 8.976979481987655,
    "difficulty": "hard",
    "code": "from collections import defaultdict\n\ndef count_distinct_subsequences(source: str, target: str) -> int:\n    if not target:\n        return 1\n    \n    # Initialize the DP table\n    dp = defaultdict(int)\n    dp[0] = 1  # Base case: empty target has one subsequence\n    \n    for i in range(1, len(source) + 1):\n        for j in range(len(target), 0, -1):\n            if source[i - 1] == target[j - 1]:\n                dp[j] += dp[j - 1]\n    \n    return dp[len(target)]\n\n# Test cases\nprint(count_distinct_subsequences('rabbbit', 'rabbit'))  # Output: 3\nprint(count_distinct_subsequences('babgbag', 'bag'))      # Output: 5",
    "prompt": "Number of index-distinct subsequences of source exactly equal to target. Empty target has one subsequence., function signature: count_distinct_subsequences(source: str, target: str) -> int, input examples: [{'case_id': 'PY100-H04-T01', 'input': ['rabbbit', 'rabbit'], 'expected': 3}, {'case_id': 'PY100-H04-T02', 'input': ['babgbag', 'bag'], 'expected': 5}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 3,
    "all": 6,
    "avg_code_run_elapsed": 6.712546261648337e-06,
    "generate_code_elapsed": 9.961263579083607,
    "difficulty": "hard",
    "code": "def count_palindrome_substrings(text: str) -> int:\n    n = len(text)\n    count = 0\n    \n    # Function to check if a substring is a palindrome\n    def is_palindrome(s: str) -> bool:\n        return s == s[::-1]\n    \n    # Check for odd length palindromes\n    for i in range(n):\n        for j in range(i + 1, n + 1):\n            if is_palindrome(text[i:j]):\n                count += 1\n    \n    # Check for even length palindromes\n    for i in range(n):\n        for j in range(i + 1, n):\n            if is_palindrome(text[i:j+1]):\n                count += 1\n    \n    return count\n\n# Test cases\nprint(count_palindrome_substrings('abc'))  # Output: 3\nprint(count_palindrome_substrings('aaa'))  # Output: 6",
    "prompt": "Count all nonempty palindromic substrings by their positions (repeats count separately)., function signature: count_palindrome_substrings(text: str) -> int, input examples: [{'case_id': 'PY100-H05-T01', 'input': ['abc'], 'expected': 3}, {'case_id': 'PY100-H05-T02', 'input': ['aaa'], 'expected': 6}] Do not include Markdown or any additional text. Only Python Code",
    "errors": [
      {
        "case_id": "PY100-H05-T02",
        "error": "Wrong answer",
        "expected": "6",
        "actual": "9"
      },
      {
        "case_id": "PY100-H05-T04",
        "error": "Wrong answer",
        "expected": "6",
        "actual": "8"
      },
      {
        "case_id": "PY100-H05-T05",
        "error": "Wrong answer",
        "expected": "9",
        "actual": "13"
      }
    ]
  },
  {
    "passed": 5,
    "all": 6,
    "avg_code_run_elapsed": 1.2864048282305399e-05,
    "generate_code_elapsed": 9.409033071948215,
    "difficulty": "hard",
    "code": "def longest_palindrome_subsequence(text: str) -> int:\n    n = len(text)\n    dp = [[0] * n for _ in range(n)]\n\n    # Every single character is a palindrome of length 1\n    for i in range(n):\n        dp[i][i] = 1\n\n    # Build the table. The outer loop is for substring lengths\n    for length in range(2, n + 1):\n        for start in range(n - length + 1):\n            end = start + length - 1\n            if text[start] == text[end]:\n                dp[start][end] = dp[start + 1][end - 1] + 2\n            else:\n                dp[start][end] = max(dp[start + 1][end], dp[start][end - 1])\n\n    return dp[0][n - 1]",
    "prompt": "Length of longest palindromic subsequence, not necessarily contiguous., function signature: longest_palindrome_subsequence(text: str) -> int, input examples: [{'case_id': 'PY100-H06-T01', 'input': ['bbbab'], 'expected': 4}, {'case_id': 'PY100-H06-T02', 'input': ['cbbd'], 'expected': 2}] Do not include Markdown or any additional text. Only Python Code",
    "errors": [
      {
        "case_id": "PY100-H06-T03",
        "error": "IndexError: list index out of range"
      }
    ]
  },
  {
    "passed": 0,
    "all": 6,
    "avg_code_run_elapsed": 0.0,
    "generate_code_elapsed": 24.512229105923325,
    "difficulty": "hard",
    "code": "def matrix_chain_min_cost(dimensions):\n    n = len(dimensions)\n    \n    # Create a table to store the minimum cost for each subproblem\n    dp = [[0] * n for _ in range(n)]\n    \n    # Fill the table using bottom-up approach\n    for length in range(2, n):\n        for i in range(n - length + 1):\n            j = i + length - 1\n            dp[i][j] = float('inf')\n            for k in range(i, j):\n                cost = dp[i][k] + dp[k + 1][j] + dimensions[i] * dimensions[k + 1] * dimensions[j + 1]\n                dp[i][j] = min(dp[i][j], cost)\n    \n    return dp[0][n - 1]\n\n# Test cases\ntest_cases = [\n    {'case_id': 'PY100-H07-T01', 'input': [[10, 30, 5, 60]], 'expected': 4500},\n    {'case_id': 'PY100-H07-T02', 'input': [[40, 20, 30, 10, 30]], 'expected': 26000}\n]\n\n# Run test cases\nfor case in test_cases:\n    result = matrix_chain_min_cost(case['input'])\n    assert result == case['expected'], f\"Test case {case['case_id']} failed: expected {case['expected']}, got {result}\"\n    print(f\"Test case {case['case_id']} passed.\")",
    "prompt": "n matrices have dimensions p[i] by p[i+1]. Return minimum scalar multiplication count over all parenthesizations. Positive dimensions, len>=2., function signature: matrix_chain_min_cost(dimensions: list[int]) -> int, input examples: [{'case_id': 'PY100-H07-T01', 'input': [[10, 30, 5, 60]], 'expected': 4500}, {'case_id': 'PY100-H07-T02', 'input': [[40, 20, 30, 10, 30]], 'expected': 26000}] Do not include Markdown or any additional text. Only Python Code",
    "errors": [
      {
        "error": "AssertionError: Test case PY100-H07-T01 failed: expected 4500, got 0"
      }
    ]
  },
  {
    "passed": 1,
    "all": 6,
    "avg_code_run_elapsed": 6.5071120237310725e-06,
    "generate_code_elapsed": 29.045325523940846,
    "difficulty": "hard",
    "code": "def burst_balloons_max(nums):\n    n = len(nums)\n    \n    # Create a table to store the maximum coins for subarrays\n    dp = [[0] * (n + 2) for _ in range(n + 2)]\n    \n    # Extend the array with 1 at both ends to simplify boundary conditions\n    nums = [1] + nums + [1]\n    \n    # Fill the dp table\n    for length in range(2, n + 2):\n        for left in range(1, n - length + 2):\n            right = left + length - 1\n            for i in range(left, right + 1):\n                # Burst balloon i and add its value to the sum\n                dp[left][right] = max(dp[left][right], \n                                   dp[left][i - 1] + nums[left - 1] * nums[i] * nums[right + 1] + dp[i + 1][right])\n    \n    return dp[1][n]\n\n# Test cases\nprint(burst_balloons_max([3, 1, 5, 8]))  # Output: 167\nprint(burst_balloons_max([1, 5]))        # Output: 10",
    "prompt": "Burst positive integer balloons in any order; coins = value of balloon times adjacent remaining values, boundary neighbors count as 1. Maximize coins., function signature: burst_balloons_max(nums: list[int]) -> int, input examples: [{'case_id': 'PY100-H08-T01', 'input': [[3, 1, 5, 8]], 'expected': 167}, {'case_id': 'PY100-H08-T02', 'input': [[1, 5]], 'expected': 10}] Do not include Markdown or any additional text. Only Python Code",
    "errors": [
      {
        "case_id": "PY100-H08-T01",
        "error": "Wrong answer",
        "expected": "167",
        "actual": "152"
      },
      {
        "case_id": "PY100-H08-T02",
        "error": "Wrong answer",
        "expected": "10",
        "actual": "5"
      },
      {
        "case_id": "PY100-H08-T04",
        "error": "Wrong answer",
        "expected": "1",
        "actual": "0"
      },
      {
        "case_id": "PY100-H08-T05",
        "error": "Wrong answer",
        "expected": "14",
        "actual": "6"
      },
      {
        "case_id": "PY100-H08-T06",
        "error": "Wrong answer",
        "expected": "12",
        "actual": "9"
      }
    ]
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 6.942078471183777e-06,
    "generate_code_elapsed": 26.875668219057843,
    "difficulty": "hard",
    "code": "def weighted_job_scheduling(jobs):\n    # Sort jobs by their end time\n    jobs.sort(key=lambda x: x[1])\n    \n    n = len(jobs)\n    dp = [0] * (n + 1)\n    \n    for i in range(1, n + 1):\n        # Find the latest job that does not overlap with the current job\n        j = i - 1\n        while j >= 0 and jobs[j][1] > jobs[i - 1][0]:\n            j -= 1\n        \n        # Update the dp array\n        dp[i] = max(dp[i - 1], dp[j + 1] + jobs[i - 1][2])\n    \n    return dp[n]\n\n# Test cases\nprint(weighted_job_scheduling([[1, 3, 50], [2, 4, 10], [3, 5, 40], [3, 6, 70]]))  # Output: 120\nprint(weighted_job_scheduling([[1, 2, 10], [2, 3, 20]]))  # Output: 30",
    "prompt": "Each job [start,end,profit], start<end, profit>=0; choose nonoverlapping half-open jobs maximizing profit. End==next start allowed., function signature: weighted_job_scheduling(jobs: list[list[int]]) -> int, input examples: [{'case_id': 'PY100-H09-T01', 'input': [[[1, 3, 50], [2, 4, 10], [3, 5, 40], [3, 6, 70]]], 'expected': 120}, {'case_id': 'PY100-H09-T02', 'input': [[[1, 2, 10], [2, 3, 20]]], 'expected': 30}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 5,
    "all": 6,
    "avg_code_run_elapsed": 5.350758632024129e-06,
    "generate_code_elapsed": 12.17989198397845,
    "difficulty": "hard",
    "code": "def minimum_jump_count(nums):\n    n = len(nums)\n    if n == 0:\n        return 0\n    \n    # Initialize the maximum reachable index and the number of jumps\n    max_reachable = 0\n    jumps = 0\n    \n    for i in range(n - 1):\n        # Update the maximum reachable index\n        max_reachable = max(max_reachable, i + nums[i])\n        \n        # If we can't reach the end from the current position, return -1\n        if max_reachable <= i:\n            return -1\n        \n        # If we reach the end, return the number of jumps\n        if max_reachable >= n - 1:\n            return jumps + 1\n        \n        # Increment the number of jumps\n        jumps += 1\n    \n    # If we never reach the end, return -1\n    return -1\n\n# Test cases\nprint(minimum_jump_count([2, 3, 1, 1, 4]))  # Output: 2\nprint(minimum_jump_count([3, 2, 1, 0, 4]))  # Output: -1",
    "prompt": "nums[i] gives max forward jump length. Return minimum jumps from index 0 to last index, -1 if unreachable; empty list returns 0., function signature: minimum_jump_count(nums: list[int]) -> int, input examples: [{'case_id': 'PY100-H10-T01', 'input': [[2, 3, 1, 1, 4]], 'expected': 2}, {'case_id': 'PY100-H10-T02', 'input': [[3, 2, 1, 0, 4]], 'expected': -1}] Do not include Markdown or any additional text. Only Python Code",
    "errors": [
      {
        "case_id": "PY100-H10-T04",
        "error": "Wrong answer",
        "expected": "0",
        "actual": "-1"
      }
    ]
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 7.095513865351677e-06,
    "generate_code_elapsed": 9.83922253199853,
    "difficulty": "hard",
    "code": "def trap_rain_water(heights):\n    if not heights:\n        return 0\n\n    n = len(heights)\n    left_max = [0] * n\n    right_max = [0] * n\n    water_trapped = 0\n\n    # Fill left_max array\n    left_max[0] = heights[0]\n    for i in range(1, n):\n        left_max[i] = max(left_max[i - 1], heights[i])\n\n    # Fill right_max array\n    right_max[n - 1] = heights[n - 1]\n    for i in range(n - 2, -1, -1):\n        right_max[i] = max(right_max[i + 1], heights[i])\n\n    # Calculate the trapped water\n    for i in range(n):\n        water_trapped += min(left_max[i], right_max[i]) - heights[i]\n\n    return water_trapped",
    "prompt": "Unit-width nonnegative bars; return total units of trapped rainwater., function signature: trap_rain_water(heights: list[int]) -> int, input examples: [{'case_id': 'PY100-H11-T01', 'input': [[0, 1, 0, 2, 1, 0, 1, 3, 2, 1, 2, 1]], 'expected': 6}, {'case_id': 'PY100-H11-T02', 'input': [[4, 2, 0, 3, 2, 5]], 'expected': 9}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 5.534345594545205e-06,
    "generate_code_elapsed": 8.628006529062986,
    "difficulty": "hard",
    "code": "from collections import deque\n\ndef sliding_window_maximum(nums, k):\n    if not nums or k <= 0:\n        return []\n\n    max_values = []\n    window = deque()\n\n    for i, num in enumerate(nums):\n        # Remove elements that are out of the current window\n        while window and window[0] < i - k + 1:\n            window.popleft()\n\n        # Remove elements from the window that are smaller than the current element\n        while window and nums[window[-1]] < num:\n            window.pop()\n\n        # Add the current element's index to the window\n        window.append(i)\n\n        # If the window is full, add the maximum value to the result\n        if i >= k - 1:\n            max_values.append(nums[window[0]])\n\n    return max_values",
    "prompt": "Return maximum in every contiguous window of size k. nums nonempty, 1<=k<=len(nums)., function signature: sliding_window_maximum(nums: list[int], k: int) -> list[int], input examples: [{'case_id': 'PY100-H12-T01', 'input': [[1, 3, -1, -3, 5, 3, 6, 7], 3], 'expected': [3, 3, 5, 5, 6, 7]}, {'case_id': 'PY100-H12-T02', 'input': [[1], 1], 'expected': [1]}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 4.691498664518197e-06,
    "generate_code_elapsed": 11.361647496931255,
    "difficulty": "hard",
    "code": "from typing import List\n\ndef sliding_window_median(nums: List[int], k: int) -> List[float]:\n    def get_median(arr):\n        n = len(arr)\n        if n % 2 == 1:\n            return arr[n // 2]\n        else:\n            return (arr[n // 2 - 1] + arr[n // 2]) / 2.0\n\n    result = []\n    for i in range(len(nums) - k + 1):\n        window = nums[i:i+k]\n        sorted_window = sorted(window)\n        result.append(get_median(sorted_window))\n    return result\n\n# Test cases\nprint(sliding_window_median([1, 3, -1, -3, 5, 3, 6, 7], 3))  # Output: [1, -1, -1, 3, 5, 6]\nprint(sliding_window_median([1, 2, 3, 4], 2))  # Output: [1.5, 2.5, 3.5]",
    "prompt": "Return median per contiguous size-k window. For even k use arithmetic mean of two middle numbers; results numerical., function signature: sliding_window_median(nums: list[int], k: int) -> list[float], input examples: [{'case_id': 'PY100-H13-T01', 'input': [[1, 3, -1, -3, 5, 3, 6, 7], 3], 'expected': [1, -1, -1, 3, 5, 6]}, {'case_id': 'PY100-H13-T02', 'input': [[1, 2, 3, 4], 2], 'expected': [1.5, 2.5, 3.5]}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 0,
    "all": 6,
    "avg_code_run_elapsed": 0.0,
    "generate_code_elapsed": 10.157818463165313,
    "difficulty": "hard",
    "code": "from typing import List\n\ndef kth_smallest_pair_distance(nums: List[int], k: int) -> int:\n    nums.sort()\n    n = len(nums)\n    left, right = 0, nums[-1] - nums[0]\n    \n    while left < right:\n        mid = (left + right) // 2\n        count = 0\n        \n        for i in range(n):\n            j = bisect.bisect_left(nums, nums[i] + mid, i + 1)\n            count += j - i - 1\n        \n        if count >= k:\n            right = mid\n        else:\n            left = mid + 1\n    \n    return left\n\n# Test cases\nprint(kth_smallest_pair_distance([1, 3, 1], 1))  # Output: 0\nprint(kth_smallest_pair_distance([1, 6, 1], 3))  # Output: 5",
    "prompt": "Among all unordered index pairs i<j, find kth smallest absolute difference counting duplicate distances; len>=2, valid k., function signature: kth_smallest_pair_distance(nums: list[int], k: int) -> int, input examples: [{'case_id': 'PY100-H14-T01', 'input': [[1, 3, 1], 1], 'expected': 0}, {'case_id': 'PY100-H14-T02', 'input': [[1, 6, 1], 3], 'expected': 5}] Do not include Markdown or any additional text. Only Python Code",
    "errors": [
      {
        "error": "NameError: name 'bisect' is not defined"
      }
    ]
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 4.030337246755759e-06,
    "generate_code_elapsed": 6.757842750055715,
    "difficulty": "hard",
    "code": "def median_two_sorted(a: list[int], b: list[int]) -> float:\n    # Combine the two lists and sort them\n    combined = sorted(a + b)\n    n = len(combined)\n    \n    # Check if the number of elements is odd\n    if n % 2 == 1:\n        # Return the middle element\n        return combined[n // 2]\n    else:\n        # Return the average of the two middle elements\n        mid1 = combined[n // 2 - 1]\n        mid2 = combined[n // 2]\n        return (mid1 + mid2) / 2",
    "prompt": "Both inputs sorted nondecreasing, combined length >=1. Return exact median, using arithmetic mean for even count., function signature: median_two_sorted(a: list[int], b: list[int]) -> float, input examples: [{'case_id': 'PY100-H15-T01', 'input': [[1, 3], [2]], 'expected': 2}, {'case_id': 'PY100-H15-T02', 'input': [[1, 2], [3, 4]], 'expected': 2.5}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 5.844049155712128e-06,
    "generate_code_elapsed": 7.157954855822027,
    "difficulty": "hard",
    "code": "def count_smaller_to_right(nums):\n    n = len(nums)\n    result = [0] * n\n    for i in range(n - 1, -1, -1):\n        current_count = 0\n        for j in range(i + 1, n):\n            if nums[j] < nums[i]:\n                current_count += 1\n        result[i] = current_count\n    return result\n\n# Test cases\nprint(count_smaller_to_right([5, 2, 6, 1]))  # Output: [2, 1, 1, 0]\nprint(count_smaller_to_right([]))              # Output: []",
    "prompt": "For each index, count strictly smaller elements to its right, retaining original positions., function signature: count_smaller_to_right(nums: list[int]) -> list[int], input examples: [{'case_id': 'PY100-H16-T01', 'input': [[5, 2, 6, 1]], 'expected': [2, 1, 1, 0]}, {'case_id': 'PY100-H16-T02', 'input': [[]], 'expected': []}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 3,
    "all": 6,
    "avg_code_run_elapsed": 5.335003758470218e-06,
    "generate_code_elapsed": 13.69024331192486,
    "difficulty": "hard",
    "code": "from collections import defaultdict\n\ndef single_source_shortest_paths(n, edges, source):\n    # Initialize the distance array with infinity and set the source distance to 0\n    distances = [float('inf')] * n\n    distances[source] = 0\n    \n    # Create an adjacency list representation of the graph\n    graph = defaultdict(list)\n    for u, v, w in edges:\n        graph[u].append((v, w))\n    \n    # Use Dijkstra's algorithm to find the shortest paths\n    for _ in range(n):\n        updated = False\n        for u in range(n):\n            for v, weight in graph[u]:\n                if distances[u] + weight < distances[v]:\n                    distances[v] = distances[u] + weight\n                    updated = True\n        if not updated:\n            break\n    \n    return distances\n\n# Test cases\nprint(single_source_shortest_paths(5, [[0, 1, 2], [1, 2, 3], [0, 3, 1], [3, 2, 1]], 0))  # Output: [0, 2, 2, 1, -1]\nprint(single_source_shortest_paths(3, [], 0))  # Output: [0, -1, -1]",
    "prompt": "Directed weighted edges [u,v,w] with nonnegative integer weights; shortest path from source to each node, -1 if unreachable., function signature: single_source_shortest_paths(n: int, edges: list[list[int]], source: int) -> list[int], input examples: [{'case_id': 'PY100-H17-T01', 'input': [5, [[0, 1, 2], [1, 2, 3], [0, 3, 1], [3, 2, 1]], 0], 'expected': [0, 2, 2, 1, -1]}, {'case_id': 'PY100-H17-T02', 'input': [3, [], 0], 'expected': [0, -1, -1]}] Do not include Markdown or any additional text. Only Python Code",
    "errors": [
      {
        "case_id": "PY100-H17-T01",
        "error": "Wrong answer",
        "expected": "[0, 2, 2, 1, -1]",
        "actual": "[0, 2, 2, 1, inf]"
      },
      {
        "case_id": "PY100-H17-T02",
        "error": "Wrong answer",
        "expected": "[0, -1, -1]",
        "actual": "[0, inf, inf]"
      },
      {
        "case_id": "PY100-H17-T05",
        "error": "Wrong answer",
        "expected": "[0, 3, 1, -1]",
        "actual": "[0, 3, 1, inf]"
      }
    ]
  },
  {
    "passed": 0,
    "all": 6,
    "avg_code_run_elapsed": 0.0,
    "generate_code_elapsed": 23.851673767901957,
    "difficulty": "hard",
    "code": "from collections import defaultdict\n\ndef flight_with_stops(n, flights, src, dst, max_stops):\n    # Build the graph\n    graph = defaultdict(list)\n    for u, v, cost in flights:\n        graph[u].append((v, cost))\n    \n    # Initialize distances and visited sets\n    dist = [float('inf')] * n\n    dist[src] = 0\n    visited = set()\n    \n    # Priority queue to store (distance, stops, node)\n    pq = [(0, 0, src)]\n    \n    while pq:\n        current_dist, current_stops, current_node = heapq.heappop(pq)\n        \n        # If we have reached the destination or exceeded the maximum stops, return the distance\n        if current_node == dst or current_stops > max_stops:\n            return current_dist\n        \n        # If we have already visited this node with fewer stops, skip it\n        if (current_node, current_stops) in visited:\n            continue\n        \n        visited.add((current_node, current_stops))\n        \n        # Explore neighbors\n        for neighbor, cost in graph[current_node]:\n            new_dist = current_dist + cost\n            new_stops = current_stops + 1\n            \n            # If this path is better, update the distance and push into the priority queue\n            if new_dist < dist[neighbor]:\n                dist[neighbor] = new_dist\n                heapq.heappush(pq, (new_dist, new_stops, neighbor))\n    \n    # If no path is found, return -1\n    return -1\n\n# Test cases\nprint(flight_with_stops(4, [[0, 1, 100], [1, 2, 100], [2, 3, 100], [0, 3, 500]], 0, 3, 1))  # Output: 500\nprint(flight_with_stops(4, [[0, 1, 100], [1, 2, 100], [2, 3, 100], [0, 3, 500]], 0, 3, 2))  # Output: 300",
    "prompt": "Directed flights [u,v,cost] with positive costs. Minimum fare from src to dst using at most max_stops intermediate cities (at most max_stops+1 edges), or -1., function signature: flight_with_stops(n: int, flights: list[list[int]], src: int, dst: int, max_stops: int) -> int, input examples: [{'case_id': 'PY100-H18-T01', 'input': [4, [[0, 1, 100], [1, 2, 100], [2, 3, 100], [0, 3, 500]], 0, 3, 1], 'expected': 500}, {'case_id': 'PY100-H18-T02', 'input': [4, [[0, 1, 100], [1, 2, 100], [2, 3, 100], [0, 3, 500]], 0, 3, 2], 'expected': 300}] Do not include Markdown or any additional text. Only Python Code",
    "errors": [
      {
        "error": "NameError: name 'heapq' is not defined"
      }
    ]
  },
  {
    "passed": 1,
    "all": 6,
    "avg_code_run_elapsed": 2.0514591597020626e-05,
    "generate_code_elapsed": 24.87945068301633,
    "difficulty": "hard",
    "code": "from itertools import permutations\n\ndef shortest_walk_visit_all(n, edges):\n    # Create an adjacency list representation of the graph\n    adj_list = [[] for _ in range(n)]\n    for u, v in edges:\n        adj_list[u].append(v)\n        adj_list[v].append(u)\n    \n    # Function to calculate the length of a path\n    def path_length(path):\n        total_length = 0\n        for i in range(len(path)):\n            u, v = path[i], path[(i + 1) % len(path)]\n            total_length += 1  # Assuming each edge has a length of 1\n        return total_length\n    \n    # Generate all possible permutations of the nodes\n    all_permutations = permutations(range(n))\n    \n    # Find the permutation with the minimum path length\n    min_path_length = float('inf')\n    for perm in all_permutations:\n        current_length = path_length(perm)\n        if current_length < min_path_length:\n            min_path_length = current_length\n    \n    # If the minimum path length is infinity, it means the graph is disconnected\n    if min_path_length == float('inf'):\n        return -1\n    else:\n        return min_path_length\n\n# Test cases\nprint(shortest_walk_visit_all(4, [[0, 1], [0, 2], [0, 3]]))  # Output: 4\nprint(shortest_walk_visit_all(5, [[0, 1], [1, 2], [2, 3], [3, 4]]))  # Output: 4",
    "prompt": "Undirected graph nodes 0..n-1, n<=10. Start anywhere; shortest walk visiting all nodes at least once, repeating allowed; -1 if disconnected., function signature: shortest_walk_visit_all(n: int, edges: list[list[int]]) -> int, input examples: [{'case_id': 'PY100-H19-T01', 'input': [4, [[0, 1], [0, 2], [0, 3]]], 'expected': 4}, {'case_id': 'PY100-H19-T02', 'input': [5, [[0, 1], [1, 2], [2, 3], [3, 4]]], 'expected': 4}] Do not include Markdown or any additional text. Only Python Code",
    "errors": [
      {
        "case_id": "PY100-H19-T02",
        "error": "Wrong answer",
        "expected": "4",
        "actual": "5"
      },
      {
        "case_id": "PY100-H19-T03",
        "error": "Wrong answer",
        "expected": "0",
        "actual": "1"
      },
      {
        "case_id": "PY100-H19-T04",
        "error": "Wrong answer",
        "expected": "-1",
        "actual": "3"
      },
      {
        "case_id": "PY100-H19-T05",
        "error": "Wrong answer",
        "expected": "3",
        "actual": "4"
      },
      {
        "case_id": "PY100-H19-T06",
        "error": "Wrong answer",
        "expected": "1",
        "actual": "2"
      }
    ]
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 4.0049975117047625e-06,
    "generate_code_elapsed": 11.333736568922177,
    "difficulty": "hard",
    "code": "def min_grid_path_sum(grid):\n    rows, cols = len(grid), len(grid[0])\n    \n    # Initialize the first row and first column\n    for i in range(1, cols):\n        grid[0][i] += grid[0][i-1]\n    for j in range(1, rows):\n        grid[j][0] += grid[j-1][0]\n    \n    # Fill the rest of the grid\n    for i in range(1, rows):\n        for j in range(1, cols):\n            grid[i][j] += min(grid[i-1][j], grid[i][j-1])\n    \n    return grid[-1][-1]\n\n# Test cases\nprint(min_grid_path_sum([[1, 3, 1], [1, 5, 1], [4, 2, 1]]))  # Output: 7\nprint(min_grid_path_sum([[1, 2, 3], [4, 5, 6]]))  # Output: 12",
    "prompt": "Nonempty rectangular nonnegative grid. Start top-left, move only right/down; minimum sum including endpoints., function signature: min_grid_path_sum(grid: list[list[int]]) -> int, input examples: [{'case_id': 'PY100-H20-T01', 'input': [[[1, 3, 1], [1, 5, 1], [4, 2, 1]]], 'expected': 7}, {'case_id': 'PY100-H20-T02', 'input': [[[1, 2, 3], [4, 5, 6]]], 'expected': 12}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 5,
    "all": 6,
    "avg_code_run_elapsed": 6.465124897658825e-06,
    "generate_code_elapsed": 16.37240947317332,
    "difficulty": "hard",
    "code": "def unique_paths_obstacles(grid):\n    m, n = len(grid), len(grid[0])\n    \n    # Create a DP table with the same dimensions as the grid\n    dp = [[0] * n for _ in range(m)]\n    \n    # Base case: there's one way to reach the top-left cell\n    dp[0][0] = 1\n    \n    # Fill the first row and first column\n    for i in range(1, m):\n        if grid[i][0] == 0:\n            dp[i][0] = dp[i-1][0]\n    for j in range(1, n):\n        if grid[0][j] == 0:\n            dp[0][j] = dp[0][j-1]\n    \n    # Fill the rest of the DP table\n    for i in range(1, m):\n        for j in range(1, n):\n            if grid[i][j] == 0:\n                dp[i][j] = dp[i-1][j] + dp[i][j-1]\n    \n    # The bottom-right cell contains the number of unique paths\n    return dp[m-1][n-1]\n\n# Test cases\nprint(unique_paths_obstacles([[0, 0, 0], [0, 1, 0], [0, 0, 0]]))  # Output: 2\nprint(unique_paths_obstacles([[0, 1], [0, 0]]))  # Output: 1",
    "prompt": "Rectangular grid 0 open, 1 blocked. Count paths top-left to bottom-right moving only right/down, avoiding blocked cells., function signature: unique_paths_obstacles(grid: list[list[int]]) -> int, input examples: [{'case_id': 'PY100-H21-T01', 'input': [[[0, 0, 0], [0, 1, 0], [0, 0, 0]]], 'expected': 2}, {'case_id': 'PY100-H21-T02', 'input': [[[0, 1], [0, 0]]], 'expected': 1}] Do not include Markdown or any additional text. Only Python Code",
    "errors": [
      {
        "case_id": "PY100-H21-T03",
        "error": "Wrong answer",
        "expected": "0",
        "actual": "1"
      }
    ]
  },
  {
    "passed": 5,
    "all": 6,
    "avg_code_run_elapsed": 7.839330161611239e-06,
    "generate_code_elapsed": 10.77587366499938,
    "difficulty": "hard",
    "code": "def maximal_one_rectangle(grid):\n    if not grid or not grid[0]:\n        return 0\n\n    max_area = 0\n    heights = [0] * len(grid[0])\n\n    for row in grid:\n        for i in range(len(row)):\n            if row[i] == '1':\n                heights[i] += 1\n            else:\n                heights[i] = 0\n\n        stack = []\n        for i, height in enumerate(heights):\n            while stack and height < heights[stack[-1]]:\n                h = heights[stack.pop()]\n                width = i if not stack else i - stack[-1] - 1\n                max_area = max(max_area, h * width)\n            stack.append(i)\n\n    while stack:\n        h = heights[stack.pop()]\n        width = len(grid[0]) if not stack else len(grid[0]) - stack[-1] - 1\n        max_area = max(max_area, h * width)\n\n    return max_area",
    "prompt": "Rectangular rows of characters 0/1, find largest area rectangle consisting only of 1 cells., function signature: maximal_one_rectangle(grid: list[str]) -> int, input examples: [{'case_id': 'PY100-H22-T01', 'input': [['10100', '10111', '11111', '10010']], 'expected': 6}, {'case_id': 'PY100-H22-T02', 'input': [['0']], 'expected': 0}] Do not include Markdown or any additional text. Only Python Code",
    "errors": [
      {
        "case_id": "PY100-H22-T01",
        "error": "Wrong answer",
        "expected": "6",
        "actual": "4"
      }
    ]
  },
  {
    "passed": 1,
    "all": 6,
    "avg_code_run_elapsed": 7.926175991694132e-06,
    "generate_code_elapsed": 9.172883345978335,
    "difficulty": "hard",
    "code": "def palindrome_partition_cuts(text: str) -> int:\n    n = len(text)\n    if n == 0:\n        return 0\n\n    # Create a DP table where dp[i] represents the minimum cuts needed for the substring text[0:i]\n    dp = [float('inf')] * (n + 1)\n    dp[0] = 0  # Base case: an empty string requires 0 cuts\n\n    # Create a helper function to check if a substring is a palindrome\n    def is_palindrome(sub):\n        return sub == sub[::-1]\n\n    # Fill the DP table\n    for i in range(1, n + 1):\n        for j in range(i):\n            if is_palindrome(text[j:i]):\n                dp[i] = min(dp[i], dp[j] + 1)\n\n    return dp[n]",
    "prompt": "Minimum cuts dividing string into nonempty palindromic substrings; empty text requires zero cuts., function signature: palindrome_partition_cuts(text: str) -> int, input examples: [{'case_id': 'PY100-H23-T01', 'input': ['aab'], 'expected': 1}, {'case_id': 'PY100-H23-T02', 'input': ['a'], 'expected': 0}] Do not include Markdown or any additional text. Only Python Code",
    "errors": [
      {
        "case_id": "PY100-H23-T01",
        "error": "Wrong answer",
        "expected": "1",
        "actual": "2"
      },
      {
        "case_id": "PY100-H23-T02",
        "error": "Wrong answer",
        "expected": "0",
        "actual": "1"
      },
      {
        "case_id": "PY100-H23-T03",
        "error": "Wrong answer",
        "expected": "1",
        "actual": "2"
      },
      {
        "case_id": "PY100-H23-T05",
        "error": "Wrong answer",
        "expected": "0",
        "actual": "1"
      },
      {
        "case_id": "PY100-H23-T06",
        "error": "Wrong answer",
        "expected": "2",
        "actual": "3"
      }
    ]
  },
  {
    "passed": 6,
    "all": 6,
    "avg_code_run_elapsed": 6.254296749830246e-06,
    "generate_code_elapsed": 9.183107397984713,
    "difficulty": "hard",
    "code": "def maximal_one_square(grid):\n    if not grid or not grid[0]:\n        return 0\n\n    rows, cols = len(grid), len(grid[0])\n    max_side = 0\n\n    for i in range(rows):\n        for j in range(cols):\n            if grid[i][j] == '1':\n                # Initialize the side length of the square starting at (i, j)\n                side_length = 1\n                # Check downwards and to the right to expand the square\n                while i + side_length < rows and j + side_length < cols and grid[i + side_length][j] == '1' and grid[i][j + side_length] == '1':\n                    side_length += 1\n                # Update the maximum side length found\n                max_side = max(max_side, side_length)\n\n    return max_side * max_side",
    "prompt": "Rectangular binary character grid; area of largest all-1 square (0 if none)., function signature: maximal_one_square(grid: list[str]) -> int, input examples: [{'case_id': 'PY100-H24-T01', 'input': [['10100', '10111', '11111', '10010']], 'expected': 4}, {'case_id': 'PY100-H24-T02', 'input': [['0']], 'expected': 0}] Do not include Markdown or any additional text. Only Python Code",
    "errors": []
  },
  {
    "passed": 2,
    "all": 6,
    "avg_code_run_elapsed": 5.9962039813399315e-06,
    "generate_code_elapsed": 24.149902974953875,
    "difficulty": "hard",
    "code": "def minimum_stick_cut_cost(length, cuts):\n    # Sort the cuts to ensure they are in order\n    cuts.sort()\n    \n    # Add the start and end points of the stick to the cuts list\n    cuts = [0] + cuts + [length]\n    \n    # Initialize the dp table with infinity\n    dp = [float('inf')] * (length + 1)\n    \n    # Base case: the cost to cut a stick of length 0 is 0\n    dp[0] = 0\n    \n    # Fill the dp table\n    for i in range(1, len(cuts)):\n        for j in range(i):\n            # Calculate the cost of cutting at position cuts[j]\n            dp[cuts[i]] = min(dp[cuts[i]], dp[cuts[j]] + cuts[i] - cuts[j])\n    \n    # The result is the minimum cost to cut the stick of length length\n    return dp[length]\n\n# Test cases\nprint(minimum_stick_cut_cost(7, [1, 3, 4, 5]))  # Output: 16\nprint(minimum_stick_cut_cost(9, [5, 6, 1, 4, 2]))  # Output: 22",
    "prompt": "Stick from 0 to length, distinct interior cut positions. Cost per cut is current segment length. Find minimum total cost., function signature: minimum_stick_cut_cost(length: int, cuts: list[int]) -> int, input examples: [{'case_id': 'PY100-H25-T01', 'input': [7, [1, 3, 4, 5]], 'expected': 16}, {'case_id': 'PY100-H25-T02', 'input': [9, [5, 6, 1, 4, 2]], 'expected': 22}] Do not include Markdown or any additional text. Only Python Code",
    "errors": [
      {
        "case_id": "PY100-H25-T01",
        "error": "Wrong answer",
        "expected": "16",
        "actual": "7"
      },
      {
        "case_id": "PY100-H25-T02",
        "error": "Wrong answer",
        "expected": "22",
        "actual": "9"
      },
      {
        "case_id": "PY100-H25-T03",
        "error": "Wrong answer",
        "expected": "0",
        "actual": "10"
      },
      {
        "case_id": "PY100-H25-T06",
        "error": "Wrong answer",
        "expected": "10",
        "actual": "6"
      }
    ]
  }
]