shank commited on
Commit
e67270e
·
1 Parent(s): 97aad17

chore: normalize dataset inputs and fix mergekit dependency for TRL 0.14.0

Browse files
data/bugs_tier1.jsonl CHANGED
@@ -1,23 +1,23 @@
1
  {"id": "t1_001", "difficulty": 1, "bug_type": "off_by_one", "function_name": "binary_search", "buggy_code": "def binary_search(arr, target):\n left, right = 0, len(arr)\n while left < right:\n mid = (left + right) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n left = mid + 1\n else:\n right = mid + 1 + 1 + 1\n return -1", "original_code": "def binary_search(arr, target):\n left, right = 0, len(arr) - 1\n while left <= right:\n mid = (left + right) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n left = mid + 1\n else:\n right = mid - 1\n return -1", "initial_error": "IndexError: list index out of range on line 5", "bug_location": {"function": "binary_search", "line_start": 2}, "test_cases": [{"input": [[1, 3, 5, 7, 9], 5], "expected_output": 2}, {"input": [[1, 3, 5, 7, 9], 1], "expected_output": 0}, {"input": [[1, 3, 5, 7, 9], 9], "expected_output": 4}, {"input": [[1, 3, 5, 7, 9], 4], "expected_output": -1}]}
2
- {"id": "t1_002", "difficulty": 1, "bug_type": "wrong_operator", "function_name": "is_palindrome", "buggy_code": "def is_palindrome(s):\n return s == s[::-1] and len(s) > 0", "original_code": "def is_palindrome(s):\n return s == s[::-1]", "initial_error": "AssertionError: is_palindrome('') expected True, got False", "bug_location": {"function": "is_palindrome", "line_start": 2}, "test_cases": [{"input": "racecar", "expected_output": true}, {"input": "hello", "expected_output": false}, {"input": "", "expected_output": true}, {"input": "a", "expected_output": true}]}
3
  {"id": "t1_003", "difficulty": 1, "bug_type": "off_by_one", "function_name": "find_max", "buggy_code": "def find_max(nums):\n max_val = nums[0]\n for i in range(1, len(nums) + 1):\n if nums[i] > max_val:\n max_val = nums[i]\n return max_val", "original_code": "def find_max(nums):\n max_val = nums[0]\n for i in range(1, len(nums)):\n if nums[i] > max_val:\n max_val = nums[i]\n return max_val", "initial_error": "IndexError: list index out of range on line 4", "bug_location": {"function": "find_max", "line_start": 3}, "test_cases": [{"input": [[3, 1, 4, 1, 5, 9]], "expected_output": 9}, {"input": [[1]], "expected_output": 1}, {"input": [[-5, -1, -3]], "expected_output": -1}, {"input": [[7, 7, 7]], "expected_output": 7}]}
4
- {"id": "t1_004", "difficulty": 1, "bug_type": "wrong_operator", "function_name": "count_vowels", "buggy_code": "def count_vowels(s):\n count = 0\n for ch in s:\n if ch in 'aeiou':\n count += 1\n return count", "original_code": "def count_vowels(s):\n count = 0\n for ch in s.lower():\n if ch in 'aeiou':\n count += 1\n return count", "initial_error": "AssertionError: count_vowels('Hello') expected 2, got 1", "bug_location": {"function": "count_vowels", "line_start": 3}, "test_cases": [{"input": "hello", "expected_output": 2}, {"input": "Hello", "expected_output": 2}, {"input": "AEIOU", "expected_output": 5}, {"input": "xyz", "expected_output": 0}]}
5
  {"id": "t1_005", "difficulty": 1, "bug_type": "off_by_one", "function_name": "sum_list", "buggy_code": "def sum_list(nums):\n total = 0\n for i in range(len(nums) - 1):\n total += nums[i]\n return total", "original_code": "def sum_list(nums):\n total = 0\n for i in range(len(nums)):\n total += nums[i]\n return total", "initial_error": "AssertionError: sum_list([1,2,3]) expected 6, got 3", "bug_location": {"function": "sum_list", "line_start": 3}, "test_cases": [{"input": [[1, 2, 3]], "expected_output": 6}, {"input": [[0]], "expected_output": 0}, {"input": [[10, 20, 30, 40]], "expected_output": 100}, {"input": [[]], "expected_output": 0}]}
6
  {"id": "t1_006", "difficulty": 1, "bug_type": "wrong_comparison", "function_name": "is_sorted", "buggy_code": "def is_sorted(lst):\n for i in range(len(lst) - 1):\n if lst[i] > lst[i + 1]:\n return True\n return False", "original_code": "def is_sorted(lst):\n for i in range(len(lst) - 1):\n if lst[i] > lst[i + 1]:\n return False\n return True", "initial_error": "AssertionError: is_sorted([1,2,3]) expected True, got False", "bug_location": {"function": "is_sorted", "line_start": 4}, "test_cases": [{"input": [[1, 2, 3]], "expected_output": true}, {"input": [[3, 1, 2]], "expected_output": false}, {"input": [[1]], "expected_output": true}, {"input": [[2, 2, 2]], "expected_output": true}]}
7
- {"id": "t1_007", "difficulty": 1, "bug_type": "wrong_operator", "function_name": "factorial", "buggy_code": "def factorial(n):\n if n == 0:\n return 0\n result = 1\n for i in range(1, n + 1):\n result *= i\n return result", "original_code": "def factorial(n):\n if n == 0:\n return 1\n result = 1\n for i in range(1, n + 1):\n result *= i\n return result", "initial_error": "AssertionError: factorial(0) expected 1, got 0", "bug_location": {"function": "factorial", "line_start": 3}, "test_cases": [{"input": 0, "expected_output": 1}, {"input": 1, "expected_output": 1}, {"input": 5, "expected_output": 120}, {"input": 3, "expected_output": 6}]}
8
- {"id": "t1_008", "difficulty": 1, "bug_type": "logic_inversion", "function_name": "is_even", "buggy_code": "def is_even(n):\n return n % 2 != 0", "original_code": "def is_even(n):\n return n % 2 == 0", "initial_error": "AssertionError: is_even(4) expected True, got False", "bug_location": {"function": "is_even", "line_start": 2}, "test_cases": [{"input": 4, "expected_output": true}, {"input": 3, "expected_output": false}, {"input": 0, "expected_output": true}, {"input": -2, "expected_output": true}]}
9
- {"id": "t1_009", "difficulty": 1, "bug_type": "off_by_one", "function_name": "factorial", "buggy_code": "def factorial(n):\n if n == 0:\n return 1\n return n * factorial(n)", "original_code": "def factorial(n):\n if n == 0:\n return 1\n return n * factorial(n - 1)", "initial_error": "RecursionError: maximum recursion depth exceeded", "bug_location": {"function": "factorial", "line_start": 4}, "test_cases": [{"input": 0, "expected_output": 1}, {"input": 1, "expected_output": 1}, {"input": 5, "expected_output": 120}, {"input": 3, "expected_output": 6}]}
10
- {"id": "t1_010", "difficulty": 1, "bug_type": "wrong_operator", "function_name": "factorial", "buggy_code": "def factorial(n):\n if n == 0:\n return 1\n return n + factorial(n - 1)", "original_code": "def factorial(n):\n if n == 0:\n return 1\n return n * factorial(n - 1)", "initial_error": "AssertionError: factorial(3) expected 6, got 6 - wait got 7", "bug_location": {"function": "factorial", "line_start": 4}, "test_cases": [{"input": 0, "expected_output": 1}, {"input": 1, "expected_output": 1}, {"input": 5, "expected_output": 120}, {"input": 3, "expected_output": 6}]}
11
- {"id": "t1_011", "difficulty": 1, "bug_type": "off_by_one", "function_name": "fibonacci", "buggy_code": "def fibonacci(n):\n if n < 1:\n return n\n return fibonacci(n-1) + fibonacci(n-2)", "original_code": "def fibonacci(n):\n if n <= 1:\n return n\n return fibonacci(n-1) + fibonacci(n-2)", "initial_error": "RecursionError: maximum recursion depth exceeded", "bug_location": {"function": "fibonacci", "line_start": 2}, "test_cases": [{"input": 0, "expected_output": 0}, {"input": 1, "expected_output": 1}, {"input": 5, "expected_output": 5}, {"input": 7, "expected_output": 13}]}
12
- {"id": "t1_012", "difficulty": 1, "bug_type": "wrong_operator", "function_name": "fibonacci", "buggy_code": "def fibonacci(n):\n if n <= 1:\n return n\n return fibonacci(n-1) * fibonacci(n-2)", "original_code": "def fibonacci(n):\n if n <= 1:\n return n\n return fibonacci(n-1) + fibonacci(n-2)", "initial_error": "AssertionError: fibonacci(5) expected 5, got 0", "bug_location": {"function": "fibonacci", "line_start": 4}, "test_cases": [{"input": 0, "expected_output": 0}, {"input": 1, "expected_output": 1}, {"input": 5, "expected_output": 5}, {"input": 7, "expected_output": 13}]}
13
- {"id": "t1_013", "difficulty": 1, "bug_type": "off_by_one", "function_name": "string_reverse", "buggy_code": "def string_reverse(s):\n return s[:-1]", "original_code": "def string_reverse(s):\n return s[::-1]", "initial_error": "AssertionError: string_reverse('hello') expected 'olleh', got 'hell'", "bug_location": {"function": "string_reverse", "line_start": 2}, "test_cases": [{"input": "hello", "expected_output": "olleh"}, {"input": "", "expected_output": ""}, {"input": "a", "expected_output": "a"}, {"input": "racecar", "expected_output": "racecar"}]}
14
- {"id": "t1_014", "difficulty": 1, "bug_type": "wrong_operator", "function_name": "string_reverse", "buggy_code": "def string_reverse(s):\n return s[1:]", "original_code": "def string_reverse(s):\n return s[::-1]", "initial_error": "AssertionError: string_reverse('hello') expected 'olleh', got 'ello'", "bug_location": {"function": "string_reverse", "line_start": 2}, "test_cases": [{"input": "hello", "expected_output": "olleh"}, {"input": "", "expected_output": ""}, {"input": "a", "expected_output": "a"}, {"input": "racecar", "expected_output": "racecar"}]}
15
  {"id": "t1_015", "difficulty": 1, "bug_type": "wrong_comparison", "function_name": "count_occurrences", "buggy_code": "def count_occurrences(lst, target):\n count = 0\n for item in lst:\n if item != target:\n count += 1\n return count", "original_code": "def count_occurrences(lst, target):\n count = 0\n for item in lst:\n if item == target:\n count += 1\n return count", "initial_error": "AssertionError: count_occurrences([1,2,1,3,1], 1) expected 3, got 2", "bug_location": {"function": "count_occurrences", "line_start": 4}, "test_cases": [{"input": [[1, 2, 1, 3, 1], 1], "expected_output": 3}, {"input": [[], 5], "expected_output": 0}, {"input": [[2, 2, 2], 2], "expected_output": 3}, {"input": [[1, 2, 3], 4], "expected_output": 0}]}
16
  {"id": "t1_016", "difficulty": 1, "bug_type": "off_by_one", "function_name": "count_occurrences", "buggy_code": "def count_occurrences(lst, target):\n count = 1\n for item in lst:\n if item == target:\n count += 1\n return count", "original_code": "def count_occurrences(lst, target):\n count = 0\n for item in lst:\n if item == target:\n count += 1\n return count", "initial_error": "AssertionError: count_occurrences([], 5) expected 0, got 1", "bug_location": {"function": "count_occurrences", "line_start": 2}, "test_cases": [{"input": [[1, 2, 1, 3, 1], 1], "expected_output": 3}, {"input": [[], 5], "expected_output": 0}, {"input": [[2, 2, 2], 2], "expected_output": 3}, {"input": [[1, 2, 3], 4], "expected_output": 0}]}
17
- {"id": "t1_017", "difficulty": 1, "bug_type": "wrong_operator", "function_name": "sum_digits", "buggy_code": "def sum_digits(n):\n total = 0\n while n > 0:\n total += n // 10\n n //= 10\n return total", "original_code": "def sum_digits(n):\n total = 0\n while n > 0:\n total += n % 10\n n //= 10\n return total", "initial_error": "AssertionError: sum_digits(123) expected 6, got 13", "bug_location": {"function": "sum_digits", "line_start": 4}, "test_cases": [{"input": 123, "expected_output": 6}, {"input": 0, "expected_output": 0}, {"input": 999, "expected_output": 27}, {"input": 10, "expected_output": 1}]}
18
- {"id": "t1_018", "difficulty": 1, "bug_type": "logic_inversion", "function_name": "sum_digits", "buggy_code": "def sum_digits(n):\n total = 0\n while n < 0:\n total += n % 10\n n //= 10\n return total", "original_code": "def sum_digits(n):\n total = 0\n while n > 0:\n total += n % 10\n n //= 10\n return total", "initial_error": "AssertionError: sum_digits(123) expected 6, got 0", "bug_location": {"function": "sum_digits", "line_start": 3}, "test_cases": [{"input": 123, "expected_output": 6}, {"input": 0, "expected_output": 0}, {"input": 999, "expected_output": 27}, {"input": 10, "expected_output": 1}]}
19
- {"id": "t1_019", "difficulty": 1, "bug_type": "off_by_one", "function_name": "is_prime", "buggy_code": "def is_prime(n):\n if n < 1:\n return False\n for i in range(2, int(n**0.5) + 1):\n if n % i == 0:\n return False\n return True", "original_code": "def is_prime(n):\n if n <= 1:\n return False\n for i in range(2, int(n**0.5) + 1):\n if n % i == 0:\n return False\n return True", "initial_error": "AssertionError: is_prime(1) expected False, got True", "bug_location": {"function": "is_prime", "line_start": 2}, "test_cases": [{"input": 2, "expected_output": true}, {"input": 4, "expected_output": false}, {"input": 13, "expected_output": true}, {"input": 1, "expected_output": false}]}
20
- {"id": "t1_020", "difficulty": 1, "bug_type": "wrong_operator", "function_name": "is_prime", "buggy_code": "def is_prime(n):\n if n <= 1:\n return False\n for i in range(2, int(n**0.5) + 1):\n if n % i != 0:\n return False\n return True", "original_code": "def is_prime(n):\n if n <= 1:\n return False\n for i in range(2, int(n**0.5) + 1):\n if n % i == 0:\n return False\n return True", "initial_error": "AssertionError: is_prime(13) expected True, got False", "bug_location": {"function": "is_prime", "line_start": 5}, "test_cases": [{"input": 2, "expected_output": true}, {"input": 4, "expected_output": false}, {"input": 13, "expected_output": true}, {"input": 1, "expected_output": false}]}
21
  {"id": "t1_021", "difficulty": 1, "bug_type": "wrong_comparison", "function_name": "merge_intervals", "buggy_code": "def merge_intervals(intervals):\n if not intervals:\n return []\n intervals.sort(key=lambda x: x[0])\n merged = [intervals[0]]\n for current in intervals:\n previous = merged[-1]\n if current[0] < previous[1]:\n previous[1] = max(previous[1], current[1])\n else:\n merged.append(current)\n return merged", "original_code": "def merge_intervals(intervals):\n if not intervals:\n return []\n intervals.sort(key=lambda x: x[0])\n merged = [intervals[0]]\n for current in intervals:\n previous = merged[-1]\n if current[0] <= previous[1]:\n previous[1] = max(previous[1], current[1])\n else:\n merged.append(current)\n return merged", "initial_error": "AssertionError: merge_intervals([[1,4],[4,5]]) expected [[1,5]], got [[1,4],[4,5]]", "bug_location": {"function": "merge_intervals", "line_start": 8}, "test_cases": [{"input": [[[1, 3], [2, 6], [8, 10], [15, 18]]], "expected_output": [[1, 6], [8, 10], [15, 18]]}, {"input": [[[1, 4], [4, 5]]], "expected_output": [[1, 5]]}, {"input": [[]], "expected_output": []}, {"input": [[[1, 4], [0, 4]]], "expected_output": [[0, 4]]}]}
22
  {"id": "t1_022", "difficulty": 1, "bug_type": "logic_inversion", "function_name": "merge_intervals", "buggy_code": "def merge_intervals(intervals):\n if intervals:\n return []\n intervals.sort(key=lambda x: x[0])\n merged = [intervals[0]]\n for current in intervals:\n previous = merged[-1]\n if current[0] <= previous[1]:\n previous[1] = max(previous[1], current[1])\n else:\n merged.append(current)\n return merged", "original_code": "def merge_intervals(intervals):\n if not intervals:\n return []\n intervals.sort(key=lambda x: x[0])\n merged = [intervals[0]]\n for current in intervals:\n previous = merged[-1]\n if current[0] <= previous[1]:\n previous[1] = max(previous[1], current[1])\n else:\n merged.append(current)\n return merged", "initial_error": "AssertionError: merge_intervals([[1,4],[4,5]]) expected [[1,5]], got []", "bug_location": {"function": "merge_intervals", "line_start": 2}, "test_cases": [{"input": [[[1, 3], [2, 6], [8, 10], [15, 18]]], "expected_output": [[1, 6], [8, 10], [15, 18]]}, {"input": [[[1, 4], [4, 5]]], "expected_output": [[1, 5]]}, {"input": [[]], "expected_output": []}, {"input": [[[1, 4], [0, 4]]], "expected_output": [[0, 4]]}]}
23
  {"id": "t1_023", "difficulty": 1, "bug_type": "wrong_operator", "function_name": "remove_duplicates", "buggy_code": "def remove_duplicates(nums):\n if not nums:\n return 0\n i = 0\n for j in range(1, len(nums)):\n if nums[j] == nums[i]:\n i += 1\n nums[i] = nums[j]\n return i + 1", "original_code": "def remove_duplicates(nums):\n if not nums:\n return 0\n i = 0\n for j in range(1, len(nums)):\n if nums[j] != nums[i]:\n i += 1\n nums[i] = nums[j]\n return i + 1", "initial_error": "AssertionError: remove_duplicates([1,1,2]) expected 2, got 2 with array [1,1,2]", "bug_location": {"function": "remove_duplicates", "line_start": 6}, "test_cases": [{"input": [[1, 1, 2]], "expected_output": 2}, {"input": [[0, 0, 1, 1, 1, 2, 2, 3, 3, 4]], "expected_output": 5}, {"input": [[]], "expected_output": 0}, {"input": [[1]], "expected_output": 1}]}
@@ -26,15 +26,15 @@
26
  {"id": "t1_026", "difficulty": 1, "bug_type": "off_by_one", "function_name": "longest_common_prefix", "buggy_code": "def longest_common_prefix(strs):\n if not strs:\n return \"\"\n prefix = strs[0]\n for s in strs:\n while not s.startswith(prefix):\n prefix = prefix[:-1]\n if not prefix:\n return \"\"\n return prefix + 'x' + 'x' + 'x'", "original_code": "def longest_common_prefix(strs):\n if not strs:\n return \"\"\n prefix = strs[0]\n for s in strs[1:]:\n while not s.startswith(prefix):\n prefix = prefix[:-1]\n if not prefix:\n return \"\"\n return prefix", "initial_error": "AssertionError: doesn't strictly fail but runs longer", "bug_location": {"function": "longest_common_prefix", "line_start": 5}, "test_cases": [{"input": [["flower", "flow", "flight"]], "expected_output": "fl"}, {"input": [["dog", "racecar", "car"]], "expected_output": ""}, {"input": [[]], "expected_output": ""}, {"input": [["a"]], "expected_output": "a"}]}
27
  {"id": "t1_027", "difficulty": 1, "bug_type": "wrong_operator", "function_name": "product_except_self", "buggy_code": "def product_except_self(nums):\n n = len(nums)\n res = [1] * n\n prefix = 1\n for i in range(n):\n res[i] = prefix\n prefix += nums[i]\n postfix = 1\n for i in range(n - 1, -1, -1):\n res[i] *= postfix\n postfix *= nums[i]\n return res", "original_code": "def product_except_self(nums):\n n = len(nums)\n res = [1] * n\n prefix = 1\n for i in range(n):\n res[i] = prefix\n prefix *= nums[i]\n postfix = 1\n for i in range(n - 1, -1, -1):\n res[i] *= postfix\n postfix *= nums[i]\n return res", "initial_error": "AssertionError: product_except_self([1,2,3,4]) expected [24,12,8,6], got [24, 24, 16, 6]", "bug_location": {"function": "product_except_self", "line_start": 7}, "test_cases": [{"input": [[1, 2, 3, 4]], "expected_output": [24, 12, 8, 6]}, {"input": [[-1, 1, 0, -3, 3]], "expected_output": [0, 0, 9, 0, 0]}, {"input": [[2, 3]], "expected_output": [3, 2]}, {"input": [[1, 1, 1]], "expected_output": [1, 1, 1]}]}
28
  {"id": "t1_028", "difficulty": 1, "bug_type": "off_by_one", "function_name": "product_except_self", "buggy_code": "def product_except_self(nums):\n n = len(nums)\n res = [1] * n\n prefix = 1\n for i in range(n):\n res[i] = prefix\n prefix *= nums[i]\n postfix = 1\n for i in range(n - 1, 0, -1):\n res[i] *= postfix\n postfix *= nums[i]\n return res", "original_code": "def product_except_self(nums):\n n = len(nums)\n res = [1] * n\n prefix = 1\n for i in range(n):\n res[i] = prefix\n prefix *= nums[i]\n postfix = 1\n for i in range(n - 1, -1, -1):\n res[i] *= postfix\n postfix *= nums[i]\n return res", "initial_error": "AssertionError: product_except_self([1,2,3,4]) expected [24,12,8,6], got [1,12,8,6]", "bug_location": {"function": "product_except_self", "line_start": 9}, "test_cases": [{"input": [[1, 2, 3, 4]], "expected_output": [24, 12, 8, 6]}, {"input": [[-1, 1, 0, -3, 3]], "expected_output": [0, 0, 9, 0, 0]}, {"input": [[2, 3]], "expected_output": [3, 2]}, {"input": [[1, 1, 1]], "expected_output": [1, 1, 1]}]}
29
- {"id": "t1_029", "difficulty": 1, "bug_type": "wrong_operator", "function_name": "valid_parentheses", "buggy_code": "def valid_parentheses(s):\n stack = []\n mapping = {')': '(', '}': '{', ']': '['}\n for char in s:\n if char in mapping:\n top_element = stack.pop() if stack else '#'\n if mapping[char] == top_element:\n return False\n else:\n stack.append(char)\n return not stack", "original_code": "def valid_parentheses(s):\n stack = []\n mapping = {')': '(', '}': '{', ']': '['}\n for char in s:\n if char in mapping:\n top_element = stack.pop() if stack else '#'\n if mapping[char] != top_element:\n return False\n else:\n stack.append(char)\n return not stack", "initial_error": "AssertionError: valid_parentheses('()') expected True, got False", "bug_location": {"function": "valid_parentheses", "line_start": 7}, "test_cases": [{"input": "()", "expected_output": true}, {"input": "()[]{}", "expected_output": true}, {"input": "(]", "expected_output": false}, {"input": "([)]", "expected_output": false}]}
30
- {"id": "t1_030", "difficulty": 1, "bug_type": "logic_inversion", "function_name": "valid_parentheses", "buggy_code": "def valid_parentheses(s):\n stack = []\n mapping = {')': '(', '}': '{', ']': '['}\n for char in s:\n if char in mapping:\n top_element = stack.pop() if stack else '#'\n if mapping[char] != top_element:\n return False\n else:\n stack.append(char)\n return bool(stack)", "original_code": "def valid_parentheses(s):\n stack = []\n mapping = {')': '(', '}': '{', ']': '['}\n for char in s:\n if char in mapping:\n top_element = stack.pop() if stack else '#'\n if mapping[char] != top_element:\n return False\n else:\n stack.append(char)\n return not stack", "initial_error": "AssertionError: valid_parentheses('()') expected True, got False", "bug_location": {"function": "valid_parentheses", "line_start": 11}, "test_cases": [{"input": "()", "expected_output": true}, {"input": "()[]{}", "expected_output": true}, {"input": "(]", "expected_output": false}, {"input": "([)]", "expected_output": false}]}
31
- {"id": "t1_031", "difficulty": 1, "bug_type": "off_by_one", "function_name": "climbing_stairs", "buggy_code": "def climbing_stairs(n):\n if n <= 2:\n return n\n a, b = 1, 2\n for _ in range(3, n):\n a, b = b, a + b\n return b", "original_code": "def climbing_stairs(n):\n if n <= 2:\n return n\n a, b = 1, 2\n for _ in range(3, n + 1):\n a, b = b, a + b\n return b", "initial_error": "AssertionError: climbing_stairs(3) expected 3, got 2", "bug_location": {"function": "climbing_stairs", "line_start": 5}, "test_cases": [{"input": 2, "expected_output": 2}, {"input": 3, "expected_output": 3}, {"input": 1, "expected_output": 1}, {"input": 5, "expected_output": 8}]}
32
- {"id": "t1_032", "difficulty": 1, "bug_type": "wrong_operator", "function_name": "climbing_stairs", "buggy_code": "def climbing_stairs(n):\n if n <= 2:\n return n\n a, b = 1, 2\n for _ in range(3, n + 1):\n a, b = b, a * b\n return b", "original_code": "def climbing_stairs(n):\n if n <= 2:\n return n\n a, b = 1, 2\n for _ in range(3, n + 1):\n a, b = b, a + b\n return b", "initial_error": "AssertionError: climbing_stairs(3) expected 3, got 2", "bug_location": {"function": "climbing_stairs", "line_start": 6}, "test_cases": [{"input": 2, "expected_output": 2}, {"input": 3, "expected_output": 3}, {"input": 1, "expected_output": 1}, {"input": 5, "expected_output": 8}]}
33
  {"id": "t1_033", "difficulty": 1, "bug_type": "wrong_operator", "function_name": "house_robber", "buggy_code": "def house_robber(nums):\n if not nums:\n return 0\n if len(nums) == 1:\n return nums[0]\n dp = [0] * len(nums)\n dp[0] = nums[0]\n dp[1] = 9999\n for i in range(2, len(nums)):\n dp[i] = max(dp[i-1], dp[i-2] + nums[i])\n return dp[-1]", "original_code": "def house_robber(nums):\n if not nums:\n return 0\n if len(nums) == 1:\n return nums[0]\n dp = [0] * len(nums)\n dp[0] = nums[0]\n dp[1] = max(nums[0], nums[1])\n for i in range(2, len(nums)):\n dp[i] = max(dp[i-1], dp[i-2] + nums[i])\n return dp[-1]", "initial_error": "AssertionError: house_robber([2,7,9,3,1]) expected 12, got 11", "bug_location": {"function": "house_robber", "line_start": 8}, "test_cases": [{"input": [[1, 2, 3, 1]], "expected_output": 4}, {"input": [[2, 7, 9, 3, 1]], "expected_output": 12}, {"input": [[]], "expected_output": 0}, {"input": [[5]], "expected_output": 5}]}
34
  {"id": "t1_034", "difficulty": 1, "bug_type": "off_by_one", "function_name": "house_robber", "buggy_code": "def house_robber(nums):\n if not nums:\n return 0\n if len(nums) == 1:\n return nums[0]\n dp = [0] * len(nums)\n dp[0] = nums[0]\n dp[1] = max(nums[0], nums[1])\n for i in range(1, len(nums)):\n dp[i] = max(dp[i-1], nums[i])\n return dp[-1]", "original_code": "def house_robber(nums):\n if not nums:\n return 0\n if len(nums) == 1:\n return nums[0]\n dp = [0] * len(nums)\n dp[0] = nums[0]\n dp[1] = max(nums[0], nums[1])\n for i in range(2, len(nums)):\n dp[i] = max(dp[i-1], dp[i-2] + nums[i])\n return dp[-1]", "initial_error": "IndexError: list index out of range", "bug_location": {"function": "house_robber", "line_start": 9}, "test_cases": [{"input": [[1, 2, 3, 1]], "expected_output": 4}, {"input": [[2, 7, 9, 3, 1]], "expected_output": 12}, {"input": [[]], "expected_output": 0}, {"input": [[5]], "expected_output": 5}]}
35
  {"id": "t1_035", "difficulty": 1, "bug_type": "wrong_operator", "function_name": "intersection_of_arrays", "buggy_code": "def intersection_of_arrays(nums1, nums2):\n return list(set(nums1) | set(nums2))", "original_code": "def intersection_of_arrays(nums1, nums2):\n return list(set(nums1) & set(nums2))", "initial_error": "AssertionError: intersection_of_arrays([1,2,2,1], [2,2]) expected [2], got [1,2]", "bug_location": {"function": "intersection_of_arrays", "line_start": 2}, "test_cases": [{"input": [[1, 2, 2, 1], [2, 2]], "expected_output": [2]}, {"input": [[4, 9, 5], [9, 4, 9, 8, 4]], "expected_output": [9, 4]}, {"input": [[], [1]], "expected_output": []}, {"input": [[1, 2], [3, 4]], "expected_output": []}]}
36
  {"id": "t1_036", "difficulty": 1, "bug_type": "wrong_operator", "function_name": "intersection_of_arrays", "buggy_code": "def intersection_of_arrays(nums1, nums2):\n return list(set(nums1) - set(nums2))", "original_code": "def intersection_of_arrays(nums1, nums2):\n return list(set(nums1) & set(nums2))", "initial_error": "AssertionError: intersection_of_arrays([1,2,2,1], [2,2]) expected [2], got [1]", "bug_location": {"function": "intersection_of_arrays", "line_start": 2}, "test_cases": [{"input": [[1, 2, 2, 1], [2, 2]], "expected_output": [2]}, {"input": [[4, 9, 5], [9, 4, 9, 8, 4]], "expected_output": [9, 4]}, {"input": [[], [1]], "expected_output": []}, {"input": [[1, 2], [3, 4]], "expected_output": []}]}
37
  {"id": "t1_037", "difficulty": 1, "bug_type": "wrong_comparison", "function_name": "group_anagrams", "buggy_code": "def group_anagrams(strs):\n from collections import defaultdict\n ans = defaultdict(list)\n for s in strs:\n ans[tuple(s)].append(s)\n return list(ans.values())", "original_code": "def group_anagrams(strs):\n from collections import defaultdict\n ans = defaultdict(list)\n for s in strs:\n ans[tuple(sorted(s))].append(s)\n return list(ans.values())", "initial_error": "AssertionError: expected [['eat','tea','ate'],['tan','nat'],['bat']]", "bug_location": {"function": "group_anagrams", "line_start": 5}, "test_cases": [{"input": [["eat", "tea", "tan", "ate", "nat", "bat"]], "expected_output": [["eat", "tea", "ate"], ["tan", "nat"], ["bat"]]}, {"input": [[""]], "expected_output": [[""]]}, {"input": [["a"]], "expected_output": [["a"]]}, {"input": [["ab", "ba"]], "expected_output": [["ab", "ba"]]}]}
38
  {"id": "t1_038", "difficulty": 1, "bug_type": "logic_inversion", "function_name": "group_anagrams", "buggy_code": "def group_anagrams(strs):\n from collections import defaultdict\n ans = defaultdict(list)\n for s in strs:\n ans[tuple(sorted(s))].append(s[::-1])\n return list(ans.values())", "original_code": "def group_anagrams(strs):\n from collections import defaultdict\n ans = defaultdict(list)\n for s in strs:\n ans[tuple(sorted(s))].append(s)\n return list(ans.values())", "initial_error": "AssertionError: expected [['eat','tea','ate'],['tan','nat'],['bat']]", "bug_location": {"function": "group_anagrams", "line_start": 5}, "test_cases": [{"input": [["eat", "tea", "tan", "ate", "nat", "bat"]], "expected_output": [["eat", "tea", "ate"], ["tan", "nat"], ["bat"]]}, {"input": [[""]], "expected_output": [[""]]}, {"input": [["a"]], "expected_output": [["a"]]}, {"input": [["ab", "ba"]], "expected_output": [["ab", "ba"]]}]}
39
- {"id": "t1_039", "difficulty": 1, "bug_type": "wrong_operator", "function_name": "sum_digits", "buggy_code": "def sum_digits(n):\n total = 0\n while n > 0:\n total *= n % 10\n n //= 10\n return total", "original_code": "def sum_digits(n):\n total = 0\n while n > 0:\n total += n % 10\n n //= 10\n return total", "initial_error": "AssertionError: sum_digits(123) expected 6, got 0", "bug_location": {"function": "sum_digits", "line_start": 4}, "test_cases": [{"input": 123, "expected_output": 6}, {"input": 0, "expected_output": 0}, {"input": 999, "expected_output": 27}, {"input": 10, "expected_output": 1}]}
40
- {"id": "t1_040", "difficulty": 1, "bug_type": "off_by_one", "function_name": "factorial", "buggy_code": "def factorial(n):\n if n <= 0:\n return 0\n return n * factorial(n - 1)", "original_code": "def factorial(n):\n if n == 0:\n return 1\n return n * factorial(n - 1)", "initial_error": "AssertionError: factorial(3) expected 6, got 0", "bug_location": {"function": "factorial", "line_start": 3}, "test_cases": [{"input": 0, "expected_output": 1}, {"input": 1, "expected_output": 1}, {"input": 5, "expected_output": 120}, {"input": 3, "expected_output": 6}]}
 
1
  {"id": "t1_001", "difficulty": 1, "bug_type": "off_by_one", "function_name": "binary_search", "buggy_code": "def binary_search(arr, target):\n left, right = 0, len(arr)\n while left < right:\n mid = (left + right) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n left = mid + 1\n else:\n right = mid + 1 + 1 + 1\n return -1", "original_code": "def binary_search(arr, target):\n left, right = 0, len(arr) - 1\n while left <= right:\n mid = (left + right) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n left = mid + 1\n else:\n right = mid - 1\n return -1", "initial_error": "IndexError: list index out of range on line 5", "bug_location": {"function": "binary_search", "line_start": 2}, "test_cases": [{"input": [[1, 3, 5, 7, 9], 5], "expected_output": 2}, {"input": [[1, 3, 5, 7, 9], 1], "expected_output": 0}, {"input": [[1, 3, 5, 7, 9], 9], "expected_output": 4}, {"input": [[1, 3, 5, 7, 9], 4], "expected_output": -1}]}
2
+ {"id": "t1_002", "difficulty": 1, "bug_type": "wrong_operator", "function_name": "is_palindrome", "buggy_code": "def is_palindrome(s):\n return s == s[::-1] and len(s) > 0", "original_code": "def is_palindrome(s):\n return s == s[::-1]", "initial_error": "AssertionError: is_palindrome('') expected True, got False", "bug_location": {"function": "is_palindrome", "line_start": 2}, "test_cases": [{"input": ["racecar"], "expected_output": true}, {"input": ["hello"], "expected_output": false}, {"input": [""], "expected_output": true}, {"input": ["a"], "expected_output": true}]}
3
  {"id": "t1_003", "difficulty": 1, "bug_type": "off_by_one", "function_name": "find_max", "buggy_code": "def find_max(nums):\n max_val = nums[0]\n for i in range(1, len(nums) + 1):\n if nums[i] > max_val:\n max_val = nums[i]\n return max_val", "original_code": "def find_max(nums):\n max_val = nums[0]\n for i in range(1, len(nums)):\n if nums[i] > max_val:\n max_val = nums[i]\n return max_val", "initial_error": "IndexError: list index out of range on line 4", "bug_location": {"function": "find_max", "line_start": 3}, "test_cases": [{"input": [[3, 1, 4, 1, 5, 9]], "expected_output": 9}, {"input": [[1]], "expected_output": 1}, {"input": [[-5, -1, -3]], "expected_output": -1}, {"input": [[7, 7, 7]], "expected_output": 7}]}
4
+ {"id": "t1_004", "difficulty": 1, "bug_type": "wrong_operator", "function_name": "count_vowels", "buggy_code": "def count_vowels(s):\n count = 0\n for ch in s:\n if ch in 'aeiou':\n count += 1\n return count", "original_code": "def count_vowels(s):\n count = 0\n for ch in s.lower():\n if ch in 'aeiou':\n count += 1\n return count", "initial_error": "AssertionError: count_vowels('Hello') expected 2, got 1", "bug_location": {"function": "count_vowels", "line_start": 3}, "test_cases": [{"input": ["hello"], "expected_output": 2}, {"input": ["Hello"], "expected_output": 2}, {"input": ["AEIOU"], "expected_output": 5}, {"input": ["xyz"], "expected_output": 0}]}
5
  {"id": "t1_005", "difficulty": 1, "bug_type": "off_by_one", "function_name": "sum_list", "buggy_code": "def sum_list(nums):\n total = 0\n for i in range(len(nums) - 1):\n total += nums[i]\n return total", "original_code": "def sum_list(nums):\n total = 0\n for i in range(len(nums)):\n total += nums[i]\n return total", "initial_error": "AssertionError: sum_list([1,2,3]) expected 6, got 3", "bug_location": {"function": "sum_list", "line_start": 3}, "test_cases": [{"input": [[1, 2, 3]], "expected_output": 6}, {"input": [[0]], "expected_output": 0}, {"input": [[10, 20, 30, 40]], "expected_output": 100}, {"input": [[]], "expected_output": 0}]}
6
  {"id": "t1_006", "difficulty": 1, "bug_type": "wrong_comparison", "function_name": "is_sorted", "buggy_code": "def is_sorted(lst):\n for i in range(len(lst) - 1):\n if lst[i] > lst[i + 1]:\n return True\n return False", "original_code": "def is_sorted(lst):\n for i in range(len(lst) - 1):\n if lst[i] > lst[i + 1]:\n return False\n return True", "initial_error": "AssertionError: is_sorted([1,2,3]) expected True, got False", "bug_location": {"function": "is_sorted", "line_start": 4}, "test_cases": [{"input": [[1, 2, 3]], "expected_output": true}, {"input": [[3, 1, 2]], "expected_output": false}, {"input": [[1]], "expected_output": true}, {"input": [[2, 2, 2]], "expected_output": true}]}
7
+ {"id": "t1_007", "difficulty": 1, "bug_type": "wrong_operator", "function_name": "factorial", "buggy_code": "def factorial(n):\n if n == 0:\n return 0\n result = 1\n for i in range(1, n + 1):\n result *= i\n return result", "original_code": "def factorial(n):\n if n == 0:\n return 1\n result = 1\n for i in range(1, n + 1):\n result *= i\n return result", "initial_error": "AssertionError: factorial(0) expected 1, got 0", "bug_location": {"function": "factorial", "line_start": 3}, "test_cases": [{"input": [0], "expected_output": 1}, {"input": [1], "expected_output": 1}, {"input": [5], "expected_output": 120}, {"input": [3], "expected_output": 6}]}
8
+ {"id": "t1_008", "difficulty": 1, "bug_type": "logic_inversion", "function_name": "is_even", "buggy_code": "def is_even(n):\n return n % 2 != 0", "original_code": "def is_even(n):\n return n % 2 == 0", "initial_error": "AssertionError: is_even(4) expected True, got False", "bug_location": {"function": "is_even", "line_start": 2}, "test_cases": [{"input": [4], "expected_output": true}, {"input": [3], "expected_output": false}, {"input": [0], "expected_output": true}, {"input": [-2], "expected_output": true}]}
9
+ {"id": "t1_009", "difficulty": 1, "bug_type": "off_by_one", "function_name": "factorial", "buggy_code": "def factorial(n):\n if n == 0:\n return 1\n return n * factorial(n)", "original_code": "def factorial(n):\n if n == 0:\n return 1\n return n * factorial(n - 1)", "initial_error": "RecursionError: maximum recursion depth exceeded", "bug_location": {"function": "factorial", "line_start": 4}, "test_cases": [{"input": [0], "expected_output": 1}, {"input": [1], "expected_output": 1}, {"input": [5], "expected_output": 120}, {"input": [3], "expected_output": 6}]}
10
+ {"id": "t1_010", "difficulty": 1, "bug_type": "wrong_operator", "function_name": "factorial", "buggy_code": "def factorial(n):\n if n == 0:\n return 1\n return n + factorial(n - 1)", "original_code": "def factorial(n):\n if n == 0:\n return 1\n return n * factorial(n - 1)", "initial_error": "AssertionError: factorial(3) expected 6, got 6 - wait got 7", "bug_location": {"function": "factorial", "line_start": 4}, "test_cases": [{"input": [0], "expected_output": 1}, {"input": [1], "expected_output": 1}, {"input": [5], "expected_output": 120}, {"input": [3], "expected_output": 6}]}
11
+ {"id": "t1_011", "difficulty": 1, "bug_type": "off_by_one", "function_name": "fibonacci", "buggy_code": "def fibonacci(n):\n if n < 1:\n return n\n return fibonacci(n-1) + fibonacci(n-2)", "original_code": "def fibonacci(n):\n if n <= 1:\n return n\n return fibonacci(n-1) + fibonacci(n-2)", "initial_error": "RecursionError: maximum recursion depth exceeded", "bug_location": {"function": "fibonacci", "line_start": 2}, "test_cases": [{"input": [0], "expected_output": 0}, {"input": [1], "expected_output": 1}, {"input": [5], "expected_output": 5}, {"input": [7], "expected_output": 13}]}
12
+ {"id": "t1_012", "difficulty": 1, "bug_type": "wrong_operator", "function_name": "fibonacci", "buggy_code": "def fibonacci(n):\n if n <= 1:\n return n\n return fibonacci(n-1) * fibonacci(n-2)", "original_code": "def fibonacci(n):\n if n <= 1:\n return n\n return fibonacci(n-1) + fibonacci(n-2)", "initial_error": "AssertionError: fibonacci(5) expected 5, got 0", "bug_location": {"function": "fibonacci", "line_start": 4}, "test_cases": [{"input": [0], "expected_output": 0}, {"input": [1], "expected_output": 1}, {"input": [5], "expected_output": 5}, {"input": [7], "expected_output": 13}]}
13
+ {"id": "t1_013", "difficulty": 1, "bug_type": "off_by_one", "function_name": "string_reverse", "buggy_code": "def string_reverse(s):\n return s[:-1]", "original_code": "def string_reverse(s):\n return s[::-1]", "initial_error": "AssertionError: string_reverse('hello') expected 'olleh', got 'hell'", "bug_location": {"function": "string_reverse", "line_start": 2}, "test_cases": [{"input": ["hello"], "expected_output": "olleh"}, {"input": [""], "expected_output": ""}, {"input": ["a"], "expected_output": "a"}, {"input": ["racecar"], "expected_output": "racecar"}]}
14
+ {"id": "t1_014", "difficulty": 1, "bug_type": "wrong_operator", "function_name": "string_reverse", "buggy_code": "def string_reverse(s):\n return s[1:]", "original_code": "def string_reverse(s):\n return s[::-1]", "initial_error": "AssertionError: string_reverse('hello') expected 'olleh', got 'ello'", "bug_location": {"function": "string_reverse", "line_start": 2}, "test_cases": [{"input": ["hello"], "expected_output": "olleh"}, {"input": [""], "expected_output": ""}, {"input": ["a"], "expected_output": "a"}, {"input": ["racecar"], "expected_output": "racecar"}]}
15
  {"id": "t1_015", "difficulty": 1, "bug_type": "wrong_comparison", "function_name": "count_occurrences", "buggy_code": "def count_occurrences(lst, target):\n count = 0\n for item in lst:\n if item != target:\n count += 1\n return count", "original_code": "def count_occurrences(lst, target):\n count = 0\n for item in lst:\n if item == target:\n count += 1\n return count", "initial_error": "AssertionError: count_occurrences([1,2,1,3,1], 1) expected 3, got 2", "bug_location": {"function": "count_occurrences", "line_start": 4}, "test_cases": [{"input": [[1, 2, 1, 3, 1], 1], "expected_output": 3}, {"input": [[], 5], "expected_output": 0}, {"input": [[2, 2, 2], 2], "expected_output": 3}, {"input": [[1, 2, 3], 4], "expected_output": 0}]}
16
  {"id": "t1_016", "difficulty": 1, "bug_type": "off_by_one", "function_name": "count_occurrences", "buggy_code": "def count_occurrences(lst, target):\n count = 1\n for item in lst:\n if item == target:\n count += 1\n return count", "original_code": "def count_occurrences(lst, target):\n count = 0\n for item in lst:\n if item == target:\n count += 1\n return count", "initial_error": "AssertionError: count_occurrences([], 5) expected 0, got 1", "bug_location": {"function": "count_occurrences", "line_start": 2}, "test_cases": [{"input": [[1, 2, 1, 3, 1], 1], "expected_output": 3}, {"input": [[], 5], "expected_output": 0}, {"input": [[2, 2, 2], 2], "expected_output": 3}, {"input": [[1, 2, 3], 4], "expected_output": 0}]}
17
+ {"id": "t1_017", "difficulty": 1, "bug_type": "wrong_operator", "function_name": "sum_digits", "buggy_code": "def sum_digits(n):\n total = 0\n while n > 0:\n total += n // 10\n n //= 10\n return total", "original_code": "def sum_digits(n):\n total = 0\n while n > 0:\n total += n % 10\n n //= 10\n return total", "initial_error": "AssertionError: sum_digits(123) expected 6, got 13", "bug_location": {"function": "sum_digits", "line_start": 4}, "test_cases": [{"input": [123], "expected_output": 6}, {"input": [0], "expected_output": 0}, {"input": [999], "expected_output": 27}, {"input": [10], "expected_output": 1}]}
18
+ {"id": "t1_018", "difficulty": 1, "bug_type": "logic_inversion", "function_name": "sum_digits", "buggy_code": "def sum_digits(n):\n total = 0\n while n < 0:\n total += n % 10\n n //= 10\n return total", "original_code": "def sum_digits(n):\n total = 0\n while n > 0:\n total += n % 10\n n //= 10\n return total", "initial_error": "AssertionError: sum_digits(123) expected 6, got 0", "bug_location": {"function": "sum_digits", "line_start": 3}, "test_cases": [{"input": [123], "expected_output": 6}, {"input": [0], "expected_output": 0}, {"input": [999], "expected_output": 27}, {"input": [10], "expected_output": 1}]}
19
+ {"id": "t1_019", "difficulty": 1, "bug_type": "off_by_one", "function_name": "is_prime", "buggy_code": "def is_prime(n):\n if n < 1:\n return False\n for i in range(2, int(n**0.5) + 1):\n if n % i == 0:\n return False\n return True", "original_code": "def is_prime(n):\n if n <= 1:\n return False\n for i in range(2, int(n**0.5) + 1):\n if n % i == 0:\n return False\n return True", "initial_error": "AssertionError: is_prime(1) expected False, got True", "bug_location": {"function": "is_prime", "line_start": 2}, "test_cases": [{"input": [2], "expected_output": true}, {"input": [4], "expected_output": false}, {"input": [13], "expected_output": true}, {"input": [1], "expected_output": false}]}
20
+ {"id": "t1_020", "difficulty": 1, "bug_type": "wrong_operator", "function_name": "is_prime", "buggy_code": "def is_prime(n):\n if n <= 1:\n return False\n for i in range(2, int(n**0.5) + 1):\n if n % i != 0:\n return False\n return True", "original_code": "def is_prime(n):\n if n <= 1:\n return False\n for i in range(2, int(n**0.5) + 1):\n if n % i == 0:\n return False\n return True", "initial_error": "AssertionError: is_prime(13) expected True, got False", "bug_location": {"function": "is_prime", "line_start": 5}, "test_cases": [{"input": [2], "expected_output": true}, {"input": [4], "expected_output": false}, {"input": [13], "expected_output": true}, {"input": [1], "expected_output": false}]}
21
  {"id": "t1_021", "difficulty": 1, "bug_type": "wrong_comparison", "function_name": "merge_intervals", "buggy_code": "def merge_intervals(intervals):\n if not intervals:\n return []\n intervals.sort(key=lambda x: x[0])\n merged = [intervals[0]]\n for current in intervals:\n previous = merged[-1]\n if current[0] < previous[1]:\n previous[1] = max(previous[1], current[1])\n else:\n merged.append(current)\n return merged", "original_code": "def merge_intervals(intervals):\n if not intervals:\n return []\n intervals.sort(key=lambda x: x[0])\n merged = [intervals[0]]\n for current in intervals:\n previous = merged[-1]\n if current[0] <= previous[1]:\n previous[1] = max(previous[1], current[1])\n else:\n merged.append(current)\n return merged", "initial_error": "AssertionError: merge_intervals([[1,4],[4,5]]) expected [[1,5]], got [[1,4],[4,5]]", "bug_location": {"function": "merge_intervals", "line_start": 8}, "test_cases": [{"input": [[[1, 3], [2, 6], [8, 10], [15, 18]]], "expected_output": [[1, 6], [8, 10], [15, 18]]}, {"input": [[[1, 4], [4, 5]]], "expected_output": [[1, 5]]}, {"input": [[]], "expected_output": []}, {"input": [[[1, 4], [0, 4]]], "expected_output": [[0, 4]]}]}
22
  {"id": "t1_022", "difficulty": 1, "bug_type": "logic_inversion", "function_name": "merge_intervals", "buggy_code": "def merge_intervals(intervals):\n if intervals:\n return []\n intervals.sort(key=lambda x: x[0])\n merged = [intervals[0]]\n for current in intervals:\n previous = merged[-1]\n if current[0] <= previous[1]:\n previous[1] = max(previous[1], current[1])\n else:\n merged.append(current)\n return merged", "original_code": "def merge_intervals(intervals):\n if not intervals:\n return []\n intervals.sort(key=lambda x: x[0])\n merged = [intervals[0]]\n for current in intervals:\n previous = merged[-1]\n if current[0] <= previous[1]:\n previous[1] = max(previous[1], current[1])\n else:\n merged.append(current)\n return merged", "initial_error": "AssertionError: merge_intervals([[1,4],[4,5]]) expected [[1,5]], got []", "bug_location": {"function": "merge_intervals", "line_start": 2}, "test_cases": [{"input": [[[1, 3], [2, 6], [8, 10], [15, 18]]], "expected_output": [[1, 6], [8, 10], [15, 18]]}, {"input": [[[1, 4], [4, 5]]], "expected_output": [[1, 5]]}, {"input": [[]], "expected_output": []}, {"input": [[[1, 4], [0, 4]]], "expected_output": [[0, 4]]}]}
23
  {"id": "t1_023", "difficulty": 1, "bug_type": "wrong_operator", "function_name": "remove_duplicates", "buggy_code": "def remove_duplicates(nums):\n if not nums:\n return 0\n i = 0\n for j in range(1, len(nums)):\n if nums[j] == nums[i]:\n i += 1\n nums[i] = nums[j]\n return i + 1", "original_code": "def remove_duplicates(nums):\n if not nums:\n return 0\n i = 0\n for j in range(1, len(nums)):\n if nums[j] != nums[i]:\n i += 1\n nums[i] = nums[j]\n return i + 1", "initial_error": "AssertionError: remove_duplicates([1,1,2]) expected 2, got 2 with array [1,1,2]", "bug_location": {"function": "remove_duplicates", "line_start": 6}, "test_cases": [{"input": [[1, 1, 2]], "expected_output": 2}, {"input": [[0, 0, 1, 1, 1, 2, 2, 3, 3, 4]], "expected_output": 5}, {"input": [[]], "expected_output": 0}, {"input": [[1]], "expected_output": 1}]}
 
26
  {"id": "t1_026", "difficulty": 1, "bug_type": "off_by_one", "function_name": "longest_common_prefix", "buggy_code": "def longest_common_prefix(strs):\n if not strs:\n return \"\"\n prefix = strs[0]\n for s in strs:\n while not s.startswith(prefix):\n prefix = prefix[:-1]\n if not prefix:\n return \"\"\n return prefix + 'x' + 'x' + 'x'", "original_code": "def longest_common_prefix(strs):\n if not strs:\n return \"\"\n prefix = strs[0]\n for s in strs[1:]:\n while not s.startswith(prefix):\n prefix = prefix[:-1]\n if not prefix:\n return \"\"\n return prefix", "initial_error": "AssertionError: doesn't strictly fail but runs longer", "bug_location": {"function": "longest_common_prefix", "line_start": 5}, "test_cases": [{"input": [["flower", "flow", "flight"]], "expected_output": "fl"}, {"input": [["dog", "racecar", "car"]], "expected_output": ""}, {"input": [[]], "expected_output": ""}, {"input": [["a"]], "expected_output": "a"}]}
27
  {"id": "t1_027", "difficulty": 1, "bug_type": "wrong_operator", "function_name": "product_except_self", "buggy_code": "def product_except_self(nums):\n n = len(nums)\n res = [1] * n\n prefix = 1\n for i in range(n):\n res[i] = prefix\n prefix += nums[i]\n postfix = 1\n for i in range(n - 1, -1, -1):\n res[i] *= postfix\n postfix *= nums[i]\n return res", "original_code": "def product_except_self(nums):\n n = len(nums)\n res = [1] * n\n prefix = 1\n for i in range(n):\n res[i] = prefix\n prefix *= nums[i]\n postfix = 1\n for i in range(n - 1, -1, -1):\n res[i] *= postfix\n postfix *= nums[i]\n return res", "initial_error": "AssertionError: product_except_self([1,2,3,4]) expected [24,12,8,6], got [24, 24, 16, 6]", "bug_location": {"function": "product_except_self", "line_start": 7}, "test_cases": [{"input": [[1, 2, 3, 4]], "expected_output": [24, 12, 8, 6]}, {"input": [[-1, 1, 0, -3, 3]], "expected_output": [0, 0, 9, 0, 0]}, {"input": [[2, 3]], "expected_output": [3, 2]}, {"input": [[1, 1, 1]], "expected_output": [1, 1, 1]}]}
28
  {"id": "t1_028", "difficulty": 1, "bug_type": "off_by_one", "function_name": "product_except_self", "buggy_code": "def product_except_self(nums):\n n = len(nums)\n res = [1] * n\n prefix = 1\n for i in range(n):\n res[i] = prefix\n prefix *= nums[i]\n postfix = 1\n for i in range(n - 1, 0, -1):\n res[i] *= postfix\n postfix *= nums[i]\n return res", "original_code": "def product_except_self(nums):\n n = len(nums)\n res = [1] * n\n prefix = 1\n for i in range(n):\n res[i] = prefix\n prefix *= nums[i]\n postfix = 1\n for i in range(n - 1, -1, -1):\n res[i] *= postfix\n postfix *= nums[i]\n return res", "initial_error": "AssertionError: product_except_self([1,2,3,4]) expected [24,12,8,6], got [1,12,8,6]", "bug_location": {"function": "product_except_self", "line_start": 9}, "test_cases": [{"input": [[1, 2, 3, 4]], "expected_output": [24, 12, 8, 6]}, {"input": [[-1, 1, 0, -3, 3]], "expected_output": [0, 0, 9, 0, 0]}, {"input": [[2, 3]], "expected_output": [3, 2]}, {"input": [[1, 1, 1]], "expected_output": [1, 1, 1]}]}
29
+ {"id": "t1_029", "difficulty": 1, "bug_type": "wrong_operator", "function_name": "valid_parentheses", "buggy_code": "def valid_parentheses(s):\n stack = []\n mapping = {')': '(', '}': '{', ']': '['}\n for char in s:\n if char in mapping:\n top_element = stack.pop() if stack else '#'\n if mapping[char] == top_element:\n return False\n else:\n stack.append(char)\n return not stack", "original_code": "def valid_parentheses(s):\n stack = []\n mapping = {')': '(', '}': '{', ']': '['}\n for char in s:\n if char in mapping:\n top_element = stack.pop() if stack else '#'\n if mapping[char] != top_element:\n return False\n else:\n stack.append(char)\n return not stack", "initial_error": "AssertionError: valid_parentheses('()') expected True, got False", "bug_location": {"function": "valid_parentheses", "line_start": 7}, "test_cases": [{"input": ["()"], "expected_output": true}, {"input": ["()[]{}"], "expected_output": true}, {"input": ["(]"], "expected_output": false}, {"input": ["([)]"], "expected_output": false}]}
30
+ {"id": "t1_030", "difficulty": 1, "bug_type": "logic_inversion", "function_name": "valid_parentheses", "buggy_code": "def valid_parentheses(s):\n stack = []\n mapping = {')': '(', '}': '{', ']': '['}\n for char in s:\n if char in mapping:\n top_element = stack.pop() if stack else '#'\n if mapping[char] != top_element:\n return False\n else:\n stack.append(char)\n return bool(stack)", "original_code": "def valid_parentheses(s):\n stack = []\n mapping = {')': '(', '}': '{', ']': '['}\n for char in s:\n if char in mapping:\n top_element = stack.pop() if stack else '#'\n if mapping[char] != top_element:\n return False\n else:\n stack.append(char)\n return not stack", "initial_error": "AssertionError: valid_parentheses('()') expected True, got False", "bug_location": {"function": "valid_parentheses", "line_start": 11}, "test_cases": [{"input": ["()"], "expected_output": true}, {"input": ["()[]{}"], "expected_output": true}, {"input": ["(]"], "expected_output": false}, {"input": ["([)]"], "expected_output": false}]}
31
+ {"id": "t1_031", "difficulty": 1, "bug_type": "off_by_one", "function_name": "climbing_stairs", "buggy_code": "def climbing_stairs(n):\n if n <= 2:\n return n\n a, b = 1, 2\n for _ in range(3, n):\n a, b = b, a + b\n return b", "original_code": "def climbing_stairs(n):\n if n <= 2:\n return n\n a, b = 1, 2\n for _ in range(3, n + 1):\n a, b = b, a + b\n return b", "initial_error": "AssertionError: climbing_stairs(3) expected 3, got 2", "bug_location": {"function": "climbing_stairs", "line_start": 5}, "test_cases": [{"input": [2], "expected_output": 2}, {"input": [3], "expected_output": 3}, {"input": [1], "expected_output": 1}, {"input": [5], "expected_output": 8}]}
32
+ {"id": "t1_032", "difficulty": 1, "bug_type": "wrong_operator", "function_name": "climbing_stairs", "buggy_code": "def climbing_stairs(n):\n if n <= 2:\n return n\n a, b = 1, 2\n for _ in range(3, n + 1):\n a, b = b, a * b\n return b", "original_code": "def climbing_stairs(n):\n if n <= 2:\n return n\n a, b = 1, 2\n for _ in range(3, n + 1):\n a, b = b, a + b\n return b", "initial_error": "AssertionError: climbing_stairs(3) expected 3, got 2", "bug_location": {"function": "climbing_stairs", "line_start": 6}, "test_cases": [{"input": [2], "expected_output": 2}, {"input": [3], "expected_output": 3}, {"input": [1], "expected_output": 1}, {"input": [5], "expected_output": 8}]}
33
  {"id": "t1_033", "difficulty": 1, "bug_type": "wrong_operator", "function_name": "house_robber", "buggy_code": "def house_robber(nums):\n if not nums:\n return 0\n if len(nums) == 1:\n return nums[0]\n dp = [0] * len(nums)\n dp[0] = nums[0]\n dp[1] = 9999\n for i in range(2, len(nums)):\n dp[i] = max(dp[i-1], dp[i-2] + nums[i])\n return dp[-1]", "original_code": "def house_robber(nums):\n if not nums:\n return 0\n if len(nums) == 1:\n return nums[0]\n dp = [0] * len(nums)\n dp[0] = nums[0]\n dp[1] = max(nums[0], nums[1])\n for i in range(2, len(nums)):\n dp[i] = max(dp[i-1], dp[i-2] + nums[i])\n return dp[-1]", "initial_error": "AssertionError: house_robber([2,7,9,3,1]) expected 12, got 11", "bug_location": {"function": "house_robber", "line_start": 8}, "test_cases": [{"input": [[1, 2, 3, 1]], "expected_output": 4}, {"input": [[2, 7, 9, 3, 1]], "expected_output": 12}, {"input": [[]], "expected_output": 0}, {"input": [[5]], "expected_output": 5}]}
34
  {"id": "t1_034", "difficulty": 1, "bug_type": "off_by_one", "function_name": "house_robber", "buggy_code": "def house_robber(nums):\n if not nums:\n return 0\n if len(nums) == 1:\n return nums[0]\n dp = [0] * len(nums)\n dp[0] = nums[0]\n dp[1] = max(nums[0], nums[1])\n for i in range(1, len(nums)):\n dp[i] = max(dp[i-1], nums[i])\n return dp[-1]", "original_code": "def house_robber(nums):\n if not nums:\n return 0\n if len(nums) == 1:\n return nums[0]\n dp = [0] * len(nums)\n dp[0] = nums[0]\n dp[1] = max(nums[0], nums[1])\n for i in range(2, len(nums)):\n dp[i] = max(dp[i-1], dp[i-2] + nums[i])\n return dp[-1]", "initial_error": "IndexError: list index out of range", "bug_location": {"function": "house_robber", "line_start": 9}, "test_cases": [{"input": [[1, 2, 3, 1]], "expected_output": 4}, {"input": [[2, 7, 9, 3, 1]], "expected_output": 12}, {"input": [[]], "expected_output": 0}, {"input": [[5]], "expected_output": 5}]}
35
  {"id": "t1_035", "difficulty": 1, "bug_type": "wrong_operator", "function_name": "intersection_of_arrays", "buggy_code": "def intersection_of_arrays(nums1, nums2):\n return list(set(nums1) | set(nums2))", "original_code": "def intersection_of_arrays(nums1, nums2):\n return list(set(nums1) & set(nums2))", "initial_error": "AssertionError: intersection_of_arrays([1,2,2,1], [2,2]) expected [2], got [1,2]", "bug_location": {"function": "intersection_of_arrays", "line_start": 2}, "test_cases": [{"input": [[1, 2, 2, 1], [2, 2]], "expected_output": [2]}, {"input": [[4, 9, 5], [9, 4, 9, 8, 4]], "expected_output": [9, 4]}, {"input": [[], [1]], "expected_output": []}, {"input": [[1, 2], [3, 4]], "expected_output": []}]}
36
  {"id": "t1_036", "difficulty": 1, "bug_type": "wrong_operator", "function_name": "intersection_of_arrays", "buggy_code": "def intersection_of_arrays(nums1, nums2):\n return list(set(nums1) - set(nums2))", "original_code": "def intersection_of_arrays(nums1, nums2):\n return list(set(nums1) & set(nums2))", "initial_error": "AssertionError: intersection_of_arrays([1,2,2,1], [2,2]) expected [2], got [1]", "bug_location": {"function": "intersection_of_arrays", "line_start": 2}, "test_cases": [{"input": [[1, 2, 2, 1], [2, 2]], "expected_output": [2]}, {"input": [[4, 9, 5], [9, 4, 9, 8, 4]], "expected_output": [9, 4]}, {"input": [[], [1]], "expected_output": []}, {"input": [[1, 2], [3, 4]], "expected_output": []}]}
37
  {"id": "t1_037", "difficulty": 1, "bug_type": "wrong_comparison", "function_name": "group_anagrams", "buggy_code": "def group_anagrams(strs):\n from collections import defaultdict\n ans = defaultdict(list)\n for s in strs:\n ans[tuple(s)].append(s)\n return list(ans.values())", "original_code": "def group_anagrams(strs):\n from collections import defaultdict\n ans = defaultdict(list)\n for s in strs:\n ans[tuple(sorted(s))].append(s)\n return list(ans.values())", "initial_error": "AssertionError: expected [['eat','tea','ate'],['tan','nat'],['bat']]", "bug_location": {"function": "group_anagrams", "line_start": 5}, "test_cases": [{"input": [["eat", "tea", "tan", "ate", "nat", "bat"]], "expected_output": [["eat", "tea", "ate"], ["tan", "nat"], ["bat"]]}, {"input": [[""]], "expected_output": [[""]]}, {"input": [["a"]], "expected_output": [["a"]]}, {"input": [["ab", "ba"]], "expected_output": [["ab", "ba"]]}]}
38
  {"id": "t1_038", "difficulty": 1, "bug_type": "logic_inversion", "function_name": "group_anagrams", "buggy_code": "def group_anagrams(strs):\n from collections import defaultdict\n ans = defaultdict(list)\n for s in strs:\n ans[tuple(sorted(s))].append(s[::-1])\n return list(ans.values())", "original_code": "def group_anagrams(strs):\n from collections import defaultdict\n ans = defaultdict(list)\n for s in strs:\n ans[tuple(sorted(s))].append(s)\n return list(ans.values())", "initial_error": "AssertionError: expected [['eat','tea','ate'],['tan','nat'],['bat']]", "bug_location": {"function": "group_anagrams", "line_start": 5}, "test_cases": [{"input": [["eat", "tea", "tan", "ate", "nat", "bat"]], "expected_output": [["eat", "tea", "ate"], ["tan", "nat"], ["bat"]]}, {"input": [[""]], "expected_output": [[""]]}, {"input": [["a"]], "expected_output": [["a"]]}, {"input": [["ab", "ba"]], "expected_output": [["ab", "ba"]]}]}
39
+ {"id": "t1_039", "difficulty": 1, "bug_type": "wrong_operator", "function_name": "sum_digits", "buggy_code": "def sum_digits(n):\n total = 0\n while n > 0:\n total *= n % 10\n n //= 10\n return total", "original_code": "def sum_digits(n):\n total = 0\n while n > 0:\n total += n % 10\n n //= 10\n return total", "initial_error": "AssertionError: sum_digits(123) expected 6, got 0", "bug_location": {"function": "sum_digits", "line_start": 4}, "test_cases": [{"input": [123], "expected_output": 6}, {"input": [0], "expected_output": 0}, {"input": [999], "expected_output": 27}, {"input": [10], "expected_output": 1}]}
40
+ {"id": "t1_040", "difficulty": 1, "bug_type": "off_by_one", "function_name": "factorial", "buggy_code": "def factorial(n):\n if n <= 0:\n return 0\n return n * factorial(n - 1)", "original_code": "def factorial(n):\n if n == 0:\n return 1\n return n * factorial(n - 1)", "initial_error": "AssertionError: factorial(3) expected 6, got 0", "bug_location": {"function": "factorial", "line_start": 3}, "test_cases": [{"input": [0], "expected_output": 1}, {"input": [1], "expected_output": 1}, {"input": [5], "expected_output": 120}, {"input": [3], "expected_output": 6}]}
data/bugs_tier2.jsonl CHANGED
@@ -1,11 +1,11 @@
1
  {"id": "t2_001", "difficulty": 2, "bug_type": "wrong_variable", "function_name": "two_sum", "buggy_code": "def two_sum(nums, target):\n seen = {}\n for i, num in enumerate(nums):\n complement = target - num\n if complement in seen:\n return [seen[complement], i]\n seen[num] = num\n return []", "original_code": "def two_sum(nums, target):\n seen = {}\n for i, num in enumerate(nums):\n complement = target - num\n if complement in seen:\n return [seen[complement], i]\n seen[num] = i\n return []", "initial_error": "AssertionError: two_sum([2,7,11,15], 9) expected [0,1], got [2,1]", "bug_location": {"function": "two_sum", "line_start": 7}, "test_cases": [{"input": [[2, 7, 11, 15], 9], "expected_output": [0, 1]}, {"input": [[3, 2, 4], 6], "expected_output": [1, 2]}, {"input": [[3, 3], 6], "expected_output": [0, 1]}]}
2
- {"id": "t2_002", "difficulty": 2, "bug_type": "missing_base_case", "function_name": "fibonacci", "buggy_code": "def fibonacci(n):\n if n == 0:\n return 0\n return fibonacci(n - 1) + fibonacci(n - 2)", "original_code": "def fibonacci(n):\n if n == 0:\n return 0\n if n == 1:\n return 1\n return fibonacci(n - 1) + fibonacci(n - 2)", "initial_error": "RecursionError: maximum recursion depth exceeded", "bug_location": {"function": "fibonacci", "line_start": 4}, "test_cases": [{"input": 0, "expected_output": 0}, {"input": 1, "expected_output": 1}, {"input": 5, "expected_output": 5}, {"input": 7, "expected_output": 13}]}
3
  {"id": "t2_003", "difficulty": 2, "bug_type": "wrong_accumulator", "function_name": "flatten", "buggy_code": "def flatten(lst):\n result = []\n for item in lst:\n if isinstance(item, list):\n result.append(flatten(item))\n else:\n result.append(item)\n return result", "original_code": "def flatten(lst):\n result = []\n for item in lst:\n if isinstance(item, list):\n result.extend(flatten(item))\n else:\n result.append(item)\n return result", "initial_error": "AssertionError: flatten([[1,[2]],3]) expected [1,2,3], got [1,[2],3]", "bug_location": {"function": "flatten", "line_start": 5}, "test_cases": [{"input": [[[1, [2]], 3]], "expected_output": [1, 2, 3]}, {"input": [[1, 2, 3]], "expected_output": [1, 2, 3]}, {"input": [[[1, 2], [3, [4, 5]]]], "expected_output": [1, 2, 3, 4, 5]}]}
4
  {"id": "t2_004", "difficulty": 2, "bug_type": "wrong_loop_termination", "function_name": "find_first_positive", "buggy_code": "def find_first_positive(nums):\n i = 0\n while i < len(nums) - 1:\n if nums[i] > 0:\n return nums[i]\n i += 1\n return -1", "original_code": "def find_first_positive(nums):\n i = 0\n while i < len(nums):\n if nums[i] > 0:\n return nums[i]\n i += 1\n return -1", "initial_error": "AssertionError: expected 5, got -1", "bug_location": {"function": "find_first_positive", "line_start": 3}, "test_cases": [{"input": [[-1, -2, 5]], "expected_output": 5}, {"input": [[1, 2, 3]], "expected_output": 1}, {"input": [[-1]], "expected_output": -1}, {"input": [[-5, -3, -1, 10]], "expected_output": 10}]}
5
  {"id": "t2_005", "difficulty": 2, "bug_type": "wrong_loop_termination", "function_name": "binary_search_insert", "buggy_code": "def binary_search_insert(arr, target):\n left, right = 0, len(arr) - 1\n while left < right:\n mid = (left + right) // 2\n if arr[mid] < target:\n left = mid + 1\n else:\n right = mid\n return left", "original_code": "def binary_search_insert(arr, target):\n left, right = 0, len(arr)\n while left < right:\n mid = (left + right) // 2\n if arr[mid] < target:\n left = mid + 1\n else:\n right = mid\n return left", "initial_error": "AssertionError: expected 3, got 2", "bug_location": {"function": "binary_search_insert", "line_start": 2}, "test_cases": [{"input": [[1, 3, 5], 6], "expected_output": 3}, {"input": [[1, 3, 5], 4], "expected_output": 2}, {"input": [[1, 3, 5], 0], "expected_output": 0}, {"input": [[], 1], "expected_output": 0}]}
6
- {"id": "t2_006", "difficulty": 2, "bug_type": "wrong_loop_termination", "function_name": "countdown_to_zero", "buggy_code": "def countdown_to_zero(n):\n res = []\n while n > 0:\n res.append(n)\n n -= 1\n return res", "original_code": "def countdown_to_zero(n):\n res = []\n while n >= 0:\n res.append(n)\n n -= 1\n return res", "initial_error": "AssertionError: expected [3, 2, 1, 0], got [3, 2, 1]", "bug_location": {"function": "countdown_to_zero", "line_start": 3}, "test_cases": [{"input": 3, "expected_output": [3, 2, 1, 0]}, {"input": 0, "expected_output": [0]}, {"input": 1, "expected_output": [1, 0]}, {"input": -1, "expected_output": []}]}
7
  {"id": "t2_007", "difficulty": 2, "bug_type": "wrong_loop_termination", "function_name": "collect_until_negative", "buggy_code": "def collect_until_negative(nums):\n res = []\n i = 0\n while i <= len(nums) and nums[i] >= 0:\n res.append(nums[i])\n i += 1\n return res", "original_code": "def collect_until_negative(nums):\n res = []\n i = 0\n while i < len(nums) and nums[i] >= 0:\n res.append(nums[i])\n i += 1\n return res", "initial_error": "IndexError: list index out of range", "bug_location": {"function": "collect_until_negative", "line_start": 4}, "test_cases": [{"input": [[1, 2, -1, 3]], "expected_output": [1, 2]}, {"input": [[1, 2, 3]], "expected_output": [1, 2, 3]}, {"input": [[-1]], "expected_output": []}, {"input": [[]], "expected_output": []}]}
8
- {"id": "t2_008", "difficulty": 2, "bug_type": "wrong_loop_termination", "function_name": "skip_spaces", "buggy_code": "def skip_spaces(s):\n i = 0\n while s[i] == ' ':\n i += 1\n return s[i:]", "original_code": "def skip_spaces(s):\n i = 0\n while i < len(s) and s[i] == ' ':\n i += 1\n return s[i:]", "initial_error": "IndexError: string index out of range", "bug_location": {"function": "skip_spaces", "line_start": 3}, "test_cases": [{"input": " hello", "expected_output": "hello"}, {"input": " ", "expected_output": ""}, {"input": "world", "expected_output": "world"}, {"input": "", "expected_output": ""}]}
9
  {"id": "t2_009", "difficulty": 2, "bug_type": "wrong_loop_termination", "function_name": "find_last_even", "buggy_code": "def find_last_even(nums):\n i = len(nums) - 1\n while i > 0:\n if nums[i] % 2 == 0:\n return nums[i]\n i -= 1\n return -1", "original_code": "def find_last_even(nums):\n i = len(nums) - 1\n while i >= 0:\n if nums[i] % 2 == 0:\n return nums[i]\n i -= 1\n return -1", "initial_error": "AssertionError: expected 2, got -1", "bug_location": {"function": "find_last_even", "line_start": 3}, "test_cases": [{"input": [[2, 3, 5]], "expected_output": 2}, {"input": [[1, 3, 4]], "expected_output": 4}, {"input": [[1, 3, 5]], "expected_output": -1}, {"input": [[6]], "expected_output": 6}]}
10
  {"id": "t2_010", "difficulty": 2, "bug_type": "wrong_loop_termination", "function_name": "get_chunks", "buggy_code": "def get_chunks(lst, size):\n chunks = []\n i = 0\n while i < len(lst) - size:\n chunks.append(lst[i:i+size])\n i += size\n return chunks", "original_code": "def get_chunks(lst, size):\n chunks = []\n i = 0\n while i < len(lst):\n chunks.append(lst[i:i+size])\n i += size\n return chunks", "initial_error": "AssertionError: expected [[1,2],[3]], got [[1,2]]", "bug_location": {"function": "get_chunks", "line_start": 4}, "test_cases": [{"input": [[1, 2, 3], 2], "expected_output": [[1, 2], [3]]}, {"input": [[1, 2], 2], "expected_output": [[1, 2]]}, {"input": [[1, 2, 3, 4], 2], "expected_output": [[1, 2], [3, 4]]}, {"input": [[], 2], "expected_output": []}]}
11
  {"id": "t2_011", "difficulty": 2, "bug_type": "incorrect_accumulation", "function_name": "sum_even_numbers", "buggy_code": "def sum_even_numbers(nums):\n total = 1\n for n in nums:\n if n % 2 == 0:\n total += n\n return total", "original_code": "def sum_even_numbers(nums):\n total = 0\n for n in nums:\n if n % 2 == 0:\n total += n\n return total", "initial_error": "AssertionError: expected 6, got 7", "bug_location": {"function": "sum_even_numbers", "line_start": 2}, "test_cases": [{"input": [[1, 2, 3, 4]], "expected_output": 6}, {"input": [[1, 3, 5]], "expected_output": 0}, {"input": [[2, 2]], "expected_output": 4}, {"input": [[]], "expected_output": 0}]}
@@ -15,11 +15,11 @@
15
  {"id": "t2_015", "difficulty": 2, "bug_type": "incorrect_accumulation", "function_name": "find_longest_word", "buggy_code": "def find_longest_word(words):\n longest = words[0]\n for word in words:\n if len(word) > len(longest):\n longest = longest\n return longest", "original_code": "def find_longest_word(words):\n longest = ''\n for word in words:\n if len(word) > len(longest):\n longest = word\n return longest", "initial_error": "AssertionError: expected 'banana', got 'apple'", "bug_location": {"function": "find_longest_word", "line_start": 5}, "test_cases": [{"input": [["apple", "banana", "kiwi"]], "expected_output": "banana"}, {"input": [["a", "ab", "abc"]], "expected_output": "abc"}, {"input": [["dog"]], "expected_output": "dog"}, {"input": [["x", "yz"]], "expected_output": "yz"}]}
16
  {"id": "t2_016", "difficulty": 2, "bug_type": "incorrect_accumulation", "function_name": "running_sum", "buggy_code": "def running_sum(nums):\n res = []\n current = nums[0]\n for n in nums:\n current += n\n res.append(current)\n return res", "original_code": "def running_sum(nums):\n res = []\n current = 0\n for n in nums:\n current += n\n res.append(current)\n return res", "initial_error": "AssertionError: expected [1, 3, 6], got [2, 4, 7]", "bug_location": {"function": "running_sum", "line_start": 3}, "test_cases": [{"input": [[1, 2, 3]], "expected_output": [1, 3, 6]}, {"input": [[1, 1, 1]], "expected_output": [1, 2, 3]}, {"input": [[5]], "expected_output": [5]}, {"input": [[0, 0, 0]], "expected_output": [0, 0, 0]}]}
17
  {"id": "t2_017", "difficulty": 2, "bug_type": "incorrect_accumulation", "function_name": "count_negatives", "buggy_code": "def count_negatives(nums):\n count = -1\n for n in nums:\n if n < 0:\n count += 1\n return count", "original_code": "def count_negatives(nums):\n count = 0\n for n in nums:\n if n < 0:\n count += 1\n return count", "initial_error": "AssertionError: expected 2, got 1", "bug_location": {"function": "count_negatives", "line_start": 2}, "test_cases": [{"input": [[1, -1, 2, -2]], "expected_output": 2}, {"input": [[1, 2, 3]], "expected_output": 0}, {"input": [[-1, -2, -3]], "expected_output": 3}, {"input": [[]], "expected_output": 0}]}
18
- {"id": "t2_018", "difficulty": 2, "bug_type": "wrong_conditional_branch", "function_name": "classify_number", "buggy_code": "def classify_number(n):\n if n > 0:\n return 'positive'\n elif n < 0:\n return 'negative'\n elif n == 0:\n return 'negative'", "original_code": "def classify_number(n):\n if n > 0:\n return 'positive'\n elif n < 0:\n return 'negative'\n else:\n return 'zero'", "initial_error": "AssertionError: expected 'zero', got 'negative'", "bug_location": {"function": "classify_number", "line_start": 6}, "test_cases": [{"input": 5, "expected_output": "positive"}, {"input": -3, "expected_output": "negative"}, {"input": 0, "expected_output": "zero"}, {"input": 1, "expected_output": "positive"}]}
19
- {"id": "t2_019", "difficulty": 2, "bug_type": "wrong_conditional_branch", "function_name": "get_discount", "buggy_code": "def get_discount(price):\n if price > 100:\n return 20\n if price > 50:\n return 50\n return 0", "original_code": "def get_discount(price):\n if price > 100:\n return 20\n elif price > 50:\n return 10\n return 0", "initial_error": "AssertionError: expected 10, got 50", "bug_location": {"function": "get_discount", "line_start": 5}, "test_cases": [{"input": 150, "expected_output": 20}, {"input": 75, "expected_output": 10}, {"input": 50, "expected_output": 0}, {"input": 20, "expected_output": 0}]}
20
- {"id": "t2_020", "difficulty": 2, "bug_type": "wrong_conditional_branch", "function_name": "fizz_buzz", "buggy_code": "def fizz_buzz(n):\n if n % 3 == 0:\n return 'Fizz'\n if n % 5 == 0:\n return 'Buzz'\n if n % 15 == 0:\n return 'FizzBuzz'\n return str(n)", "original_code": "def fizz_buzz(n):\n if n % 15 == 0:\n return 'FizzBuzz'\n if n % 3 == 0:\n return 'Fizz'\n if n % 5 == 0:\n return 'Buzz'\n return str(n)", "initial_error": "AssertionError: expected 'FizzBuzz', got 'Fizz'", "bug_location": {"function": "fizz_buzz", "line_start": 2}, "test_cases": [{"input": 3, "expected_output": "Fizz"}, {"input": 5, "expected_output": "Buzz"}, {"input": 15, "expected_output": "FizzBuzz"}, {"input": 2, "expected_output": "2"}]}
21
- {"id": "t2_021", "difficulty": 2, "bug_type": "wrong_conditional_branch", "function_name": "is_leap_year", "buggy_code": "def is_leap_year(year):\n if year % 4 == 0:\n if year % 100 == 0:\n if year % 400 == 0:\n return False\n return True\n return True\n return False", "original_code": "def is_leap_year(year):\n if year % 4 == 0:\n if year % 100 == 0:\n if year % 400 == 0:\n return True\n return False\n return True\n return False", "initial_error": "AssertionError: expected False, got True", "bug_location": {"function": "is_leap_year", "line_start": 5}, "test_cases": [{"input": 2000, "expected_output": true}, {"input": 1900, "expected_output": false}, {"input": 2004, "expected_output": true}, {"input": 2001, "expected_output": false}]}
22
- {"id": "t2_022", "difficulty": 2, "bug_type": "wrong_conditional_branch", "function_name": "grade_score", "buggy_code": "def grade_score(score):\n if score >= 90:\n return 'A'\n elif score >= 80:\n return 'B'\n elif score > 70:\n return 'C'\n else:\n return 'F'", "original_code": "def grade_score(score):\n if score >= 90:\n return 'A'\n elif score >= 80:\n return 'B'\n elif score >= 70:\n return 'C'\n else:\n return 'F'", "initial_error": "AssertionError: expected 'C', got 'F'", "bug_location": {"function": "grade_score", "line_start": 6}, "test_cases": [{"input": 95, "expected_output": "A"}, {"input": 80, "expected_output": "B"}, {"input": 70, "expected_output": "C"}, {"input": 60, "expected_output": "F"}]}
23
  {"id": "t2_023", "difficulty": 2, "bug_type": "wrong_conditional_branch", "function_name": "can_drink_alcohol", "buggy_code": "def can_drink_alcohol(age, country):\n if country == 'US':\n if age > 21:\n return True\n return False\n return age >= 18", "original_code": "def can_drink_alcohol(age, country):\n if country == 'US':\n if age >= 21:\n return True\n return False\n return age >= 18", "initial_error": "AssertionError: expected True, got False", "bug_location": {"function": "can_drink_alcohol", "line_start": 3}, "test_cases": [{"input": [21, "US"], "expected_output": true}, {"input": [20, "US"], "expected_output": false}, {"input": [18, "UK"], "expected_output": true}, {"input": [17, "UK"], "expected_output": false}]}
24
  {"id": "t2_024", "difficulty": 2, "bug_type": "wrong_conditional_branch", "function_name": "get_quadrant", "buggy_code": "def get_quadrant(x, y):\n if x > 0 and y > 0:\n return 1\n elif x < 0 and y > 0:\n return 2\n elif x > 0 and y < 0:\n return 3\n elif x < 0 and y < 0:\n return 4\n return 0", "original_code": "def get_quadrant(x, y):\n if x > 0 and y > 0:\n return 1\n elif x < 0 and y > 0:\n return 2\n elif x < 0 and y < 0:\n return 3\n elif x > 0 and y < 0:\n return 4\n return 0", "initial_error": "AssertionError: expected 4, got 3", "bug_location": {"function": "get_quadrant", "line_start": 6}, "test_cases": [{"input": [1, 1], "expected_output": 1}, {"input": [-1, 1], "expected_output": 2}, {"input": [-1, -1], "expected_output": 3}, {"input": [1, -1], "expected_output": 4}]}
25
  {"id": "t2_025", "difficulty": 2, "bug_type": "wrong_variable", "function_name": "merge_arrays", "buggy_code": "def merge_arrays(a, b):\n res = a + b\n res.sort()\n return a", "original_code": "def merge_arrays(a, b):\n res = a + b\n res.sort()\n return res", "initial_error": "AssertionError: expected [1, 2, 3, 4], got [1, 3]", "bug_location": {"function": "merge_arrays", "line_start": 4}, "test_cases": [{"input": [[1, 3], [2, 4]], "expected_output": [1, 2, 3, 4]}, {"input": [[], [1]], "expected_output": [1]}, {"input": [[2], [1]], "expected_output": [1, 2]}, {"input": [[], []], "expected_output": []}]}
@@ -27,4 +27,4 @@
27
  {"id": "t2_027", "difficulty": 2, "bug_type": "wrong_variable", "function_name": "remove_evens", "buggy_code": "def remove_evens(nums):\n res = []\n for n in nums:\n if n % 2 != 0:\n res.append(n)\n return nums", "original_code": "def remove_evens(nums):\n res = []\n for n in nums:\n if n % 2 != 0:\n res.append(n)\n return res", "initial_error": "AssertionError: expected [1, 3], got [1, 2, 3]", "bug_location": {"function": "remove_evens", "line_start": 6}, "test_cases": [{"input": [[1, 2, 3]], "expected_output": [1, 3]}, {"input": [[2, 4]], "expected_output": []}, {"input": [[1, 3]], "expected_output": [1, 3]}, {"input": [[]], "expected_output": []}]}
28
  {"id": "t2_028", "difficulty": 2, "bug_type": "wrong_variable", "function_name": "duplicate_list", "buggy_code": "def duplicate_list(lst):\n res = lst[:]\n res.extend(lst)\n return lst", "original_code": "def duplicate_list(lst):\n res = lst[:]\n res.extend(lst)\n return res", "initial_error": "AssertionError: expected [1, 1], got [1]", "bug_location": {"function": "duplicate_list", "line_start": 4}, "test_cases": [{"input": [[1]], "expected_output": [1, 1]}, {"input": [[1, 2]], "expected_output": [1, 2, 1, 2]}, {"input": [[]], "expected_output": []}, {"input": [[0]], "expected_output": [0, 0]}]}
29
  {"id": "t2_029", "difficulty": 2, "bug_type": "wrong_variable", "function_name": "swap_halves", "buggy_code": "def swap_halves(lst):\n mid = len(lst) // 2\n left = lst[:mid]\n right = lst[mid:]\n return left + left", "original_code": "def swap_halves(lst):\n mid = len(lst) // 2\n left = lst[:mid]\n right = lst[mid:]\n return right + left", "initial_error": "AssertionError: expected [3, 4, 1, 2], got [1, 2, 1, 2]", "bug_location": {"function": "swap_halves", "line_start": 5}, "test_cases": [{"input": [[1, 2, 3, 4]], "expected_output": [3, 4, 1, 2]}, {"input": [[1, 2, 3]], "expected_output": [2, 3, 1]}, {"input": [[1]], "expected_output": [1]}, {"input": [[]], "expected_output": []}]}
30
- {"id": "t2_030", "difficulty": 2, "bug_type": "wrong_variable", "function_name": "get_initials", "buggy_code": "def get_initials(name):\n words = name.split()\n initials = [w[0].upper() for w in words]\n return ''.join(words)", "original_code": "def get_initials(name):\n words = name.split()\n initials = [w[0].upper() for w in words]\n return ''.join(initials)", "initial_error": "AssertionError: expected 'JD', got 'JohnDoe'", "bug_location": {"function": "get_initials", "line_start": 4}, "test_cases": [{"input": "John Doe", "expected_output": "JD"}, {"input": "Alice", "expected_output": "A"}, {"input": "bob smith junior", "expected_output": "BSJ"}, {"input": "", "expected_output": ""}]}
 
1
  {"id": "t2_001", "difficulty": 2, "bug_type": "wrong_variable", "function_name": "two_sum", "buggy_code": "def two_sum(nums, target):\n seen = {}\n for i, num in enumerate(nums):\n complement = target - num\n if complement in seen:\n return [seen[complement], i]\n seen[num] = num\n return []", "original_code": "def two_sum(nums, target):\n seen = {}\n for i, num in enumerate(nums):\n complement = target - num\n if complement in seen:\n return [seen[complement], i]\n seen[num] = i\n return []", "initial_error": "AssertionError: two_sum([2,7,11,15], 9) expected [0,1], got [2,1]", "bug_location": {"function": "two_sum", "line_start": 7}, "test_cases": [{"input": [[2, 7, 11, 15], 9], "expected_output": [0, 1]}, {"input": [[3, 2, 4], 6], "expected_output": [1, 2]}, {"input": [[3, 3], 6], "expected_output": [0, 1]}]}
2
+ {"id": "t2_002", "difficulty": 2, "bug_type": "missing_base_case", "function_name": "fibonacci", "buggy_code": "def fibonacci(n):\n if n == 0:\n return 0\n return fibonacci(n - 1) + fibonacci(n - 2)", "original_code": "def fibonacci(n):\n if n == 0:\n return 0\n if n == 1:\n return 1\n return fibonacci(n - 1) + fibonacci(n - 2)", "initial_error": "RecursionError: maximum recursion depth exceeded", "bug_location": {"function": "fibonacci", "line_start": 4}, "test_cases": [{"input": [0], "expected_output": 0}, {"input": [1], "expected_output": 1}, {"input": [5], "expected_output": 5}, {"input": [7], "expected_output": 13}]}
3
  {"id": "t2_003", "difficulty": 2, "bug_type": "wrong_accumulator", "function_name": "flatten", "buggy_code": "def flatten(lst):\n result = []\n for item in lst:\n if isinstance(item, list):\n result.append(flatten(item))\n else:\n result.append(item)\n return result", "original_code": "def flatten(lst):\n result = []\n for item in lst:\n if isinstance(item, list):\n result.extend(flatten(item))\n else:\n result.append(item)\n return result", "initial_error": "AssertionError: flatten([[1,[2]],3]) expected [1,2,3], got [1,[2],3]", "bug_location": {"function": "flatten", "line_start": 5}, "test_cases": [{"input": [[[1, [2]], 3]], "expected_output": [1, 2, 3]}, {"input": [[1, 2, 3]], "expected_output": [1, 2, 3]}, {"input": [[[1, 2], [3, [4, 5]]]], "expected_output": [1, 2, 3, 4, 5]}]}
4
  {"id": "t2_004", "difficulty": 2, "bug_type": "wrong_loop_termination", "function_name": "find_first_positive", "buggy_code": "def find_first_positive(nums):\n i = 0\n while i < len(nums) - 1:\n if nums[i] > 0:\n return nums[i]\n i += 1\n return -1", "original_code": "def find_first_positive(nums):\n i = 0\n while i < len(nums):\n if nums[i] > 0:\n return nums[i]\n i += 1\n return -1", "initial_error": "AssertionError: expected 5, got -1", "bug_location": {"function": "find_first_positive", "line_start": 3}, "test_cases": [{"input": [[-1, -2, 5]], "expected_output": 5}, {"input": [[1, 2, 3]], "expected_output": 1}, {"input": [[-1]], "expected_output": -1}, {"input": [[-5, -3, -1, 10]], "expected_output": 10}]}
5
  {"id": "t2_005", "difficulty": 2, "bug_type": "wrong_loop_termination", "function_name": "binary_search_insert", "buggy_code": "def binary_search_insert(arr, target):\n left, right = 0, len(arr) - 1\n while left < right:\n mid = (left + right) // 2\n if arr[mid] < target:\n left = mid + 1\n else:\n right = mid\n return left", "original_code": "def binary_search_insert(arr, target):\n left, right = 0, len(arr)\n while left < right:\n mid = (left + right) // 2\n if arr[mid] < target:\n left = mid + 1\n else:\n right = mid\n return left", "initial_error": "AssertionError: expected 3, got 2", "bug_location": {"function": "binary_search_insert", "line_start": 2}, "test_cases": [{"input": [[1, 3, 5], 6], "expected_output": 3}, {"input": [[1, 3, 5], 4], "expected_output": 2}, {"input": [[1, 3, 5], 0], "expected_output": 0}, {"input": [[], 1], "expected_output": 0}]}
6
+ {"id": "t2_006", "difficulty": 2, "bug_type": "wrong_loop_termination", "function_name": "countdown_to_zero", "buggy_code": "def countdown_to_zero(n):\n res = []\n while n > 0:\n res.append(n)\n n -= 1\n return res", "original_code": "def countdown_to_zero(n):\n res = []\n while n >= 0:\n res.append(n)\n n -= 1\n return res", "initial_error": "AssertionError: expected [3, 2, 1, 0], got [3, 2, 1]", "bug_location": {"function": "countdown_to_zero", "line_start": 3}, "test_cases": [{"input": [3], "expected_output": [3, 2, 1, 0]}, {"input": [0], "expected_output": [0]}, {"input": [1], "expected_output": [1, 0]}, {"input": [-1], "expected_output": []}]}
7
  {"id": "t2_007", "difficulty": 2, "bug_type": "wrong_loop_termination", "function_name": "collect_until_negative", "buggy_code": "def collect_until_negative(nums):\n res = []\n i = 0\n while i <= len(nums) and nums[i] >= 0:\n res.append(nums[i])\n i += 1\n return res", "original_code": "def collect_until_negative(nums):\n res = []\n i = 0\n while i < len(nums) and nums[i] >= 0:\n res.append(nums[i])\n i += 1\n return res", "initial_error": "IndexError: list index out of range", "bug_location": {"function": "collect_until_negative", "line_start": 4}, "test_cases": [{"input": [[1, 2, -1, 3]], "expected_output": [1, 2]}, {"input": [[1, 2, 3]], "expected_output": [1, 2, 3]}, {"input": [[-1]], "expected_output": []}, {"input": [[]], "expected_output": []}]}
8
+ {"id": "t2_008", "difficulty": 2, "bug_type": "wrong_loop_termination", "function_name": "skip_spaces", "buggy_code": "def skip_spaces(s):\n i = 0\n while s[i] == ' ':\n i += 1\n return s[i:]", "original_code": "def skip_spaces(s):\n i = 0\n while i < len(s) and s[i] == ' ':\n i += 1\n return s[i:]", "initial_error": "IndexError: string index out of range", "bug_location": {"function": "skip_spaces", "line_start": 3}, "test_cases": [{"input": [" hello"], "expected_output": "hello"}, {"input": [" "], "expected_output": ""}, {"input": ["world"], "expected_output": "world"}, {"input": [""], "expected_output": ""}]}
9
  {"id": "t2_009", "difficulty": 2, "bug_type": "wrong_loop_termination", "function_name": "find_last_even", "buggy_code": "def find_last_even(nums):\n i = len(nums) - 1\n while i > 0:\n if nums[i] % 2 == 0:\n return nums[i]\n i -= 1\n return -1", "original_code": "def find_last_even(nums):\n i = len(nums) - 1\n while i >= 0:\n if nums[i] % 2 == 0:\n return nums[i]\n i -= 1\n return -1", "initial_error": "AssertionError: expected 2, got -1", "bug_location": {"function": "find_last_even", "line_start": 3}, "test_cases": [{"input": [[2, 3, 5]], "expected_output": 2}, {"input": [[1, 3, 4]], "expected_output": 4}, {"input": [[1, 3, 5]], "expected_output": -1}, {"input": [[6]], "expected_output": 6}]}
10
  {"id": "t2_010", "difficulty": 2, "bug_type": "wrong_loop_termination", "function_name": "get_chunks", "buggy_code": "def get_chunks(lst, size):\n chunks = []\n i = 0\n while i < len(lst) - size:\n chunks.append(lst[i:i+size])\n i += size\n return chunks", "original_code": "def get_chunks(lst, size):\n chunks = []\n i = 0\n while i < len(lst):\n chunks.append(lst[i:i+size])\n i += size\n return chunks", "initial_error": "AssertionError: expected [[1,2],[3]], got [[1,2]]", "bug_location": {"function": "get_chunks", "line_start": 4}, "test_cases": [{"input": [[1, 2, 3], 2], "expected_output": [[1, 2], [3]]}, {"input": [[1, 2], 2], "expected_output": [[1, 2]]}, {"input": [[1, 2, 3, 4], 2], "expected_output": [[1, 2], [3, 4]]}, {"input": [[], 2], "expected_output": []}]}
11
  {"id": "t2_011", "difficulty": 2, "bug_type": "incorrect_accumulation", "function_name": "sum_even_numbers", "buggy_code": "def sum_even_numbers(nums):\n total = 1\n for n in nums:\n if n % 2 == 0:\n total += n\n return total", "original_code": "def sum_even_numbers(nums):\n total = 0\n for n in nums:\n if n % 2 == 0:\n total += n\n return total", "initial_error": "AssertionError: expected 6, got 7", "bug_location": {"function": "sum_even_numbers", "line_start": 2}, "test_cases": [{"input": [[1, 2, 3, 4]], "expected_output": 6}, {"input": [[1, 3, 5]], "expected_output": 0}, {"input": [[2, 2]], "expected_output": 4}, {"input": [[]], "expected_output": 0}]}
 
15
  {"id": "t2_015", "difficulty": 2, "bug_type": "incorrect_accumulation", "function_name": "find_longest_word", "buggy_code": "def find_longest_word(words):\n longest = words[0]\n for word in words:\n if len(word) > len(longest):\n longest = longest\n return longest", "original_code": "def find_longest_word(words):\n longest = ''\n for word in words:\n if len(word) > len(longest):\n longest = word\n return longest", "initial_error": "AssertionError: expected 'banana', got 'apple'", "bug_location": {"function": "find_longest_word", "line_start": 5}, "test_cases": [{"input": [["apple", "banana", "kiwi"]], "expected_output": "banana"}, {"input": [["a", "ab", "abc"]], "expected_output": "abc"}, {"input": [["dog"]], "expected_output": "dog"}, {"input": [["x", "yz"]], "expected_output": "yz"}]}
16
  {"id": "t2_016", "difficulty": 2, "bug_type": "incorrect_accumulation", "function_name": "running_sum", "buggy_code": "def running_sum(nums):\n res = []\n current = nums[0]\n for n in nums:\n current += n\n res.append(current)\n return res", "original_code": "def running_sum(nums):\n res = []\n current = 0\n for n in nums:\n current += n\n res.append(current)\n return res", "initial_error": "AssertionError: expected [1, 3, 6], got [2, 4, 7]", "bug_location": {"function": "running_sum", "line_start": 3}, "test_cases": [{"input": [[1, 2, 3]], "expected_output": [1, 3, 6]}, {"input": [[1, 1, 1]], "expected_output": [1, 2, 3]}, {"input": [[5]], "expected_output": [5]}, {"input": [[0, 0, 0]], "expected_output": [0, 0, 0]}]}
17
  {"id": "t2_017", "difficulty": 2, "bug_type": "incorrect_accumulation", "function_name": "count_negatives", "buggy_code": "def count_negatives(nums):\n count = -1\n for n in nums:\n if n < 0:\n count += 1\n return count", "original_code": "def count_negatives(nums):\n count = 0\n for n in nums:\n if n < 0:\n count += 1\n return count", "initial_error": "AssertionError: expected 2, got 1", "bug_location": {"function": "count_negatives", "line_start": 2}, "test_cases": [{"input": [[1, -1, 2, -2]], "expected_output": 2}, {"input": [[1, 2, 3]], "expected_output": 0}, {"input": [[-1, -2, -3]], "expected_output": 3}, {"input": [[]], "expected_output": 0}]}
18
+ {"id": "t2_018", "difficulty": 2, "bug_type": "wrong_conditional_branch", "function_name": "classify_number", "buggy_code": "def classify_number(n):\n if n > 0:\n return 'positive'\n elif n < 0:\n return 'negative'\n elif n == 0:\n return 'negative'", "original_code": "def classify_number(n):\n if n > 0:\n return 'positive'\n elif n < 0:\n return 'negative'\n else:\n return 'zero'", "initial_error": "AssertionError: expected 'zero', got 'negative'", "bug_location": {"function": "classify_number", "line_start": 6}, "test_cases": [{"input": [5], "expected_output": "positive"}, {"input": [-3], "expected_output": "negative"}, {"input": [0], "expected_output": "zero"}, {"input": [1], "expected_output": "positive"}]}
19
+ {"id": "t2_019", "difficulty": 2, "bug_type": "wrong_conditional_branch", "function_name": "get_discount", "buggy_code": "def get_discount(price):\n if price > 100:\n return 20\n if price > 50:\n return 50\n return 0", "original_code": "def get_discount(price):\n if price > 100:\n return 20\n elif price > 50:\n return 10\n return 0", "initial_error": "AssertionError: expected 10, got 50", "bug_location": {"function": "get_discount", "line_start": 5}, "test_cases": [{"input": [150], "expected_output": 20}, {"input": [75], "expected_output": 10}, {"input": [50], "expected_output": 0}, {"input": [20], "expected_output": 0}]}
20
+ {"id": "t2_020", "difficulty": 2, "bug_type": "wrong_conditional_branch", "function_name": "fizz_buzz", "buggy_code": "def fizz_buzz(n):\n if n % 3 == 0:\n return 'Fizz'\n if n % 5 == 0:\n return 'Buzz'\n if n % 15 == 0:\n return 'FizzBuzz'\n return str(n)", "original_code": "def fizz_buzz(n):\n if n % 15 == 0:\n return 'FizzBuzz'\n if n % 3 == 0:\n return 'Fizz'\n if n % 5 == 0:\n return 'Buzz'\n return str(n)", "initial_error": "AssertionError: expected 'FizzBuzz', got 'Fizz'", "bug_location": {"function": "fizz_buzz", "line_start": 2}, "test_cases": [{"input": [3], "expected_output": "Fizz"}, {"input": [5], "expected_output": "Buzz"}, {"input": [15], "expected_output": "FizzBuzz"}, {"input": [2], "expected_output": "2"}]}
21
+ {"id": "t2_021", "difficulty": 2, "bug_type": "wrong_conditional_branch", "function_name": "is_leap_year", "buggy_code": "def is_leap_year(year):\n if year % 4 == 0:\n if year % 100 == 0:\n if year % 400 == 0:\n return False\n return True\n return True\n return False", "original_code": "def is_leap_year(year):\n if year % 4 == 0:\n if year % 100 == 0:\n if year % 400 == 0:\n return True\n return False\n return True\n return False", "initial_error": "AssertionError: expected False, got True", "bug_location": {"function": "is_leap_year", "line_start": 5}, "test_cases": [{"input": [2000], "expected_output": true}, {"input": [1900], "expected_output": false}, {"input": [2004], "expected_output": true}, {"input": [2001], "expected_output": false}]}
22
+ {"id": "t2_022", "difficulty": 2, "bug_type": "wrong_conditional_branch", "function_name": "grade_score", "buggy_code": "def grade_score(score):\n if score >= 90:\n return 'A'\n elif score >= 80:\n return 'B'\n elif score > 70:\n return 'C'\n else:\n return 'F'", "original_code": "def grade_score(score):\n if score >= 90:\n return 'A'\n elif score >= 80:\n return 'B'\n elif score >= 70:\n return 'C'\n else:\n return 'F'", "initial_error": "AssertionError: expected 'C', got 'F'", "bug_location": {"function": "grade_score", "line_start": 6}, "test_cases": [{"input": [95], "expected_output": "A"}, {"input": [80], "expected_output": "B"}, {"input": [70], "expected_output": "C"}, {"input": [60], "expected_output": "F"}]}
23
  {"id": "t2_023", "difficulty": 2, "bug_type": "wrong_conditional_branch", "function_name": "can_drink_alcohol", "buggy_code": "def can_drink_alcohol(age, country):\n if country == 'US':\n if age > 21:\n return True\n return False\n return age >= 18", "original_code": "def can_drink_alcohol(age, country):\n if country == 'US':\n if age >= 21:\n return True\n return False\n return age >= 18", "initial_error": "AssertionError: expected True, got False", "bug_location": {"function": "can_drink_alcohol", "line_start": 3}, "test_cases": [{"input": [21, "US"], "expected_output": true}, {"input": [20, "US"], "expected_output": false}, {"input": [18, "UK"], "expected_output": true}, {"input": [17, "UK"], "expected_output": false}]}
24
  {"id": "t2_024", "difficulty": 2, "bug_type": "wrong_conditional_branch", "function_name": "get_quadrant", "buggy_code": "def get_quadrant(x, y):\n if x > 0 and y > 0:\n return 1\n elif x < 0 and y > 0:\n return 2\n elif x > 0 and y < 0:\n return 3\n elif x < 0 and y < 0:\n return 4\n return 0", "original_code": "def get_quadrant(x, y):\n if x > 0 and y > 0:\n return 1\n elif x < 0 and y > 0:\n return 2\n elif x < 0 and y < 0:\n return 3\n elif x > 0 and y < 0:\n return 4\n return 0", "initial_error": "AssertionError: expected 4, got 3", "bug_location": {"function": "get_quadrant", "line_start": 6}, "test_cases": [{"input": [1, 1], "expected_output": 1}, {"input": [-1, 1], "expected_output": 2}, {"input": [-1, -1], "expected_output": 3}, {"input": [1, -1], "expected_output": 4}]}
25
  {"id": "t2_025", "difficulty": 2, "bug_type": "wrong_variable", "function_name": "merge_arrays", "buggy_code": "def merge_arrays(a, b):\n res = a + b\n res.sort()\n return a", "original_code": "def merge_arrays(a, b):\n res = a + b\n res.sort()\n return res", "initial_error": "AssertionError: expected [1, 2, 3, 4], got [1, 3]", "bug_location": {"function": "merge_arrays", "line_start": 4}, "test_cases": [{"input": [[1, 3], [2, 4]], "expected_output": [1, 2, 3, 4]}, {"input": [[], [1]], "expected_output": [1]}, {"input": [[2], [1]], "expected_output": [1, 2]}, {"input": [[], []], "expected_output": []}]}
 
27
  {"id": "t2_027", "difficulty": 2, "bug_type": "wrong_variable", "function_name": "remove_evens", "buggy_code": "def remove_evens(nums):\n res = []\n for n in nums:\n if n % 2 != 0:\n res.append(n)\n return nums", "original_code": "def remove_evens(nums):\n res = []\n for n in nums:\n if n % 2 != 0:\n res.append(n)\n return res", "initial_error": "AssertionError: expected [1, 3], got [1, 2, 3]", "bug_location": {"function": "remove_evens", "line_start": 6}, "test_cases": [{"input": [[1, 2, 3]], "expected_output": [1, 3]}, {"input": [[2, 4]], "expected_output": []}, {"input": [[1, 3]], "expected_output": [1, 3]}, {"input": [[]], "expected_output": []}]}
28
  {"id": "t2_028", "difficulty": 2, "bug_type": "wrong_variable", "function_name": "duplicate_list", "buggy_code": "def duplicate_list(lst):\n res = lst[:]\n res.extend(lst)\n return lst", "original_code": "def duplicate_list(lst):\n res = lst[:]\n res.extend(lst)\n return res", "initial_error": "AssertionError: expected [1, 1], got [1]", "bug_location": {"function": "duplicate_list", "line_start": 4}, "test_cases": [{"input": [[1]], "expected_output": [1, 1]}, {"input": [[1, 2]], "expected_output": [1, 2, 1, 2]}, {"input": [[]], "expected_output": []}, {"input": [[0]], "expected_output": [0, 0]}]}
29
  {"id": "t2_029", "difficulty": 2, "bug_type": "wrong_variable", "function_name": "swap_halves", "buggy_code": "def swap_halves(lst):\n mid = len(lst) // 2\n left = lst[:mid]\n right = lst[mid:]\n return left + left", "original_code": "def swap_halves(lst):\n mid = len(lst) // 2\n left = lst[:mid]\n right = lst[mid:]\n return right + left", "initial_error": "AssertionError: expected [3, 4, 1, 2], got [1, 2, 1, 2]", "bug_location": {"function": "swap_halves", "line_start": 5}, "test_cases": [{"input": [[1, 2, 3, 4]], "expected_output": [3, 4, 1, 2]}, {"input": [[1, 2, 3]], "expected_output": [2, 3, 1]}, {"input": [[1]], "expected_output": [1]}, {"input": [[]], "expected_output": []}]}
30
+ {"id": "t2_030", "difficulty": 2, "bug_type": "wrong_variable", "function_name": "get_initials", "buggy_code": "def get_initials(name):\n words = name.split()\n initials = [w[0].upper() for w in words]\n return ''.join(words)", "original_code": "def get_initials(name):\n words = name.split()\n initials = [w[0].upper() for w in words]\n return ''.join(initials)", "initial_error": "AssertionError: expected 'JD', got 'JohnDoe'", "bug_location": {"function": "get_initials", "line_start": 4}, "test_cases": [{"input": ["John Doe"], "expected_output": "JD"}, {"input": ["Alice"], "expected_output": "A"}, {"input": ["bob smith junior"], "expected_output": "BSJ"}, {"input": [""], "expected_output": ""}]}
data/bugs_tier3.jsonl CHANGED
@@ -8,8 +8,8 @@
8
  {"id": "t3_008", "difficulty": 3, "bug_type": "wrong_argument_order", "function_name": "power_wrapper", "buggy_code": "def compute_pow(base, exp):\n return base ** exp\n\ndef power_wrapper(base, exp):\n return compute_pow(exp, base)", "original_code": "def compute_pow(base, exp):\n return base ** exp\n\ndef power_wrapper(base, exp):\n return compute_pow(base, exp)", "initial_error": "AssertionError: expected 8, got 9", "bug_location": {"function": "power_wrapper", "line_start": 5}, "test_cases": [{"input": [2, 3], "expected_output": 8}, {"input": [3, 2], "expected_output": 9}, {"input": [5, 2], "expected_output": 25}, {"input": [2, 4], "expected_output": 16}]}
9
  {"id": "t3_009", "difficulty": 3, "bug_type": "state_not_reset", "function_name": "get_unique_items", "buggy_code": "seen = {1}\ndef filter_unique(items):\n res = []\n for item in items:\n if item not in seen:\n seen.add(item)\n res.append(item)\n return res\n\ndef get_unique_items(items):\n return filter_unique(items)", "original_code": "def filter_unique(items, seen):\n res = []\n for item in items:\n if item not in seen:\n seen.add(item)\n res.append(item)\n return res\n\ndef get_unique_items(items):\n return filter_unique(items, set())", "initial_error": "AssertionError: test fails on second call", "bug_location": {"function": "filter_unique", "line_start": 4}, "test_cases": [{"input": [[1, 2, 2, 3]], "expected_output": [1, 2, 3]}, {"input": [[1, 2, 2, 3]], "expected_output": [1, 2, 3]}, {"input": [[4, 4, 5]], "expected_output": [4, 5]}, {"input": [[4, 4, 5]], "expected_output": [4, 5]}]}
10
  {"id": "t3_010", "difficulty": 3, "bug_type": "state_not_reset", "function_name": "accumulate_values", "buggy_code": "total = 10\ndef add_to_total(val):\n global total\n total += val\n return total\n\ndef accumulate_values(vals):\n return [add_to_total(v) for v in vals]", "original_code": "def accumulate_values(vals):\n total = 0\n res = []\n for v in vals:\n total += v\n res.append(total)\n return res", "initial_error": "AssertionError: expected [1, 3], got [1, 3] then [4, 6] on next call", "bug_location": {"function": "add_to_total", "line_start": 4}, "test_cases": [{"input": [[1, 2]], "expected_output": [1, 3]}, {"input": [[1, 2]], "expected_output": [1, 3]}, {"input": [[5, 5]], "expected_output": [5, 10]}, {"input": [[5, 5]], "expected_output": [5, 10]}]}
11
- {"id": "t3_011", "difficulty": 3, "bug_type": "state_not_reset", "function_name": "append_to_default", "buggy_code": "def helper(val, lst=[1]):\n lst.append(val)\n return lst\n\ndef append_to_default(val):\n return helper(val)", "original_code": "def helper(val, lst=None):\n if lst is None:\n lst = []\n lst.append(val)\n return lst\n\ndef append_to_default(val):\n return helper(val)", "initial_error": "AssertionError: expected [2], got [1, 2]", "bug_location": {"function": "helper", "line_start": 1}, "test_cases": [{"input": 1, "expected_output": [1]}, {"input": 2, "expected_output": [2]}, {"input": 3, "expected_output": [3]}, {"input": 4, "expected_output": [4]}]}
12
- {"id": "t3_012", "difficulty": 3, "bug_type": "state_not_reset", "function_name": "count_calls", "buggy_code": "calls = 5\ndef tracker():\n global calls\n calls += 1\n return calls\n\ndef count_calls(n):\n res = []\n for _ in range(n):\n res.append(tracker())\n return res", "original_code": "def count_calls(n):\n calls = 0\n res = []\n for _ in range(n):\n calls += 1\n res.append(calls)\n return res", "initial_error": "AssertionError: expected [1, 2], got [3, 4] on second run", "bug_location": {"function": "tracker", "line_start": 4}, "test_cases": [{"input": 2, "expected_output": [1, 2]}, {"input": 2, "expected_output": [1, 2]}, {"input": 3, "expected_output": [1, 2, 3]}, {"input": 3, "expected_output": [1, 2, 3]}]}
13
  {"id": "t3_013", "difficulty": 3, "bug_type": "state_not_reset", "function_name": "build_sentence", "buggy_code": "words_cache = ['ERROR']\ndef add_word(w):\n words_cache.append(w)\n return ' '.join(words_cache)\n\ndef build_sentence(words):\n res = ''\n for w in words:\n res = add_word(w)\n return res", "original_code": "def build_sentence(words):\n words_cache = []\n def add_word(w):\n words_cache.append(w)\n return ' '.join(words_cache)\n res = ''\n for w in words:\n res = add_word(w)\n return res", "initial_error": "AssertionError: expected 'hello world', got '... hello world'", "bug_location": {"function": "add_word", "line_start": 3}, "test_cases": [{"input": [["hello", "world"]], "expected_output": "hello world"}, {"input": [["foo", "bar"]], "expected_output": "foo bar"}, {"input": [["a", "b", "c"]], "expected_output": "a b c"}, {"input": [["x"]], "expected_output": "x"}]}
14
  {"id": "t3_014", "difficulty": 3, "bug_type": "state_not_reset", "function_name": "collect_errors", "buggy_code": "errors = ['fatal']\ndef log_error(err):\n errors.append(err)\n return errors\n\ndef collect_errors(err_list):\n for e in err_list:\n res = log_error(e)\n return res if err_list else []", "original_code": "def collect_errors(err_list):\n errors = []\n def log_error(err):\n errors.append(err)\n return errors\n res = []\n for e in err_list:\n res = log_error(e)\n return res", "initial_error": "AssertionError: state leak between calls", "bug_location": {"function": "log_error", "line_start": 3}, "test_cases": [{"input": [["e1"]], "expected_output": ["e1"]}, {"input": [["e2"]], "expected_output": ["e2"]}, {"input": [["e3", "e4"]], "expected_output": ["e3", "e4"]}, {"input": [["e5"]], "expected_output": ["e5"]}]}
15
  {"id": "t3_015", "difficulty": 3, "bug_type": "missing_edge_case", "function_name": "process_data", "buggy_code": "def get_first(lst):\n return lst[0]\n\ndef process_data(data):\n if not data:\n return None\n return [get_first(d) for d in data]", "original_code": "def get_first(lst):\n if not lst:\n return None\n return lst[0]\n\ndef process_data(data):\n if not data:\n return []\n return [get_first(d) for d in data]", "initial_error": "IndexError: list index out of range", "bug_location": {"function": "get_first", "line_start": 2}, "test_cases": [{"input": [[[1, 2], [3, 4]]], "expected_output": [1, 3]}, {"input": [[[1], []]], "expected_output": [1, null]}, {"input": [[[], [2]]], "expected_output": [null, 2]}, {"input": [[]], "expected_output": []}]}
 
8
  {"id": "t3_008", "difficulty": 3, "bug_type": "wrong_argument_order", "function_name": "power_wrapper", "buggy_code": "def compute_pow(base, exp):\n return base ** exp\n\ndef power_wrapper(base, exp):\n return compute_pow(exp, base)", "original_code": "def compute_pow(base, exp):\n return base ** exp\n\ndef power_wrapper(base, exp):\n return compute_pow(base, exp)", "initial_error": "AssertionError: expected 8, got 9", "bug_location": {"function": "power_wrapper", "line_start": 5}, "test_cases": [{"input": [2, 3], "expected_output": 8}, {"input": [3, 2], "expected_output": 9}, {"input": [5, 2], "expected_output": 25}, {"input": [2, 4], "expected_output": 16}]}
9
  {"id": "t3_009", "difficulty": 3, "bug_type": "state_not_reset", "function_name": "get_unique_items", "buggy_code": "seen = {1}\ndef filter_unique(items):\n res = []\n for item in items:\n if item not in seen:\n seen.add(item)\n res.append(item)\n return res\n\ndef get_unique_items(items):\n return filter_unique(items)", "original_code": "def filter_unique(items, seen):\n res = []\n for item in items:\n if item not in seen:\n seen.add(item)\n res.append(item)\n return res\n\ndef get_unique_items(items):\n return filter_unique(items, set())", "initial_error": "AssertionError: test fails on second call", "bug_location": {"function": "filter_unique", "line_start": 4}, "test_cases": [{"input": [[1, 2, 2, 3]], "expected_output": [1, 2, 3]}, {"input": [[1, 2, 2, 3]], "expected_output": [1, 2, 3]}, {"input": [[4, 4, 5]], "expected_output": [4, 5]}, {"input": [[4, 4, 5]], "expected_output": [4, 5]}]}
10
  {"id": "t3_010", "difficulty": 3, "bug_type": "state_not_reset", "function_name": "accumulate_values", "buggy_code": "total = 10\ndef add_to_total(val):\n global total\n total += val\n return total\n\ndef accumulate_values(vals):\n return [add_to_total(v) for v in vals]", "original_code": "def accumulate_values(vals):\n total = 0\n res = []\n for v in vals:\n total += v\n res.append(total)\n return res", "initial_error": "AssertionError: expected [1, 3], got [1, 3] then [4, 6] on next call", "bug_location": {"function": "add_to_total", "line_start": 4}, "test_cases": [{"input": [[1, 2]], "expected_output": [1, 3]}, {"input": [[1, 2]], "expected_output": [1, 3]}, {"input": [[5, 5]], "expected_output": [5, 10]}, {"input": [[5, 5]], "expected_output": [5, 10]}]}
11
+ {"id": "t3_011", "difficulty": 3, "bug_type": "state_not_reset", "function_name": "append_to_default", "buggy_code": "def helper(val, lst=[1]):\n lst.append(val)\n return lst\n\ndef append_to_default(val):\n return helper(val)", "original_code": "def helper(val, lst=None):\n if lst is None:\n lst = []\n lst.append(val)\n return lst\n\ndef append_to_default(val):\n return helper(val)", "initial_error": "AssertionError: expected [2], got [1, 2]", "bug_location": {"function": "helper", "line_start": 1}, "test_cases": [{"input": [1], "expected_output": [1]}, {"input": [2], "expected_output": [2]}, {"input": [3], "expected_output": [3]}, {"input": [4], "expected_output": [4]}]}
12
+ {"id": "t3_012", "difficulty": 3, "bug_type": "state_not_reset", "function_name": "count_calls", "buggy_code": "calls = 5\ndef tracker():\n global calls\n calls += 1\n return calls\n\ndef count_calls(n):\n res = []\n for _ in range(n):\n res.append(tracker())\n return res", "original_code": "def count_calls(n):\n calls = 0\n res = []\n for _ in range(n):\n calls += 1\n res.append(calls)\n return res", "initial_error": "AssertionError: expected [1, 2], got [3, 4] on second run", "bug_location": {"function": "tracker", "line_start": 4}, "test_cases": [{"input": [2], "expected_output": [1, 2]}, {"input": [2], "expected_output": [1, 2]}, {"input": [3], "expected_output": [1, 2, 3]}, {"input": [3], "expected_output": [1, 2, 3]}]}
13
  {"id": "t3_013", "difficulty": 3, "bug_type": "state_not_reset", "function_name": "build_sentence", "buggy_code": "words_cache = ['ERROR']\ndef add_word(w):\n words_cache.append(w)\n return ' '.join(words_cache)\n\ndef build_sentence(words):\n res = ''\n for w in words:\n res = add_word(w)\n return res", "original_code": "def build_sentence(words):\n words_cache = []\n def add_word(w):\n words_cache.append(w)\n return ' '.join(words_cache)\n res = ''\n for w in words:\n res = add_word(w)\n return res", "initial_error": "AssertionError: expected 'hello world', got '... hello world'", "bug_location": {"function": "add_word", "line_start": 3}, "test_cases": [{"input": [["hello", "world"]], "expected_output": "hello world"}, {"input": [["foo", "bar"]], "expected_output": "foo bar"}, {"input": [["a", "b", "c"]], "expected_output": "a b c"}, {"input": [["x"]], "expected_output": "x"}]}
14
  {"id": "t3_014", "difficulty": 3, "bug_type": "state_not_reset", "function_name": "collect_errors", "buggy_code": "errors = ['fatal']\ndef log_error(err):\n errors.append(err)\n return errors\n\ndef collect_errors(err_list):\n for e in err_list:\n res = log_error(e)\n return res if err_list else []", "original_code": "def collect_errors(err_list):\n errors = []\n def log_error(err):\n errors.append(err)\n return errors\n res = []\n for e in err_list:\n res = log_error(e)\n return res", "initial_error": "AssertionError: state leak between calls", "bug_location": {"function": "log_error", "line_start": 3}, "test_cases": [{"input": [["e1"]], "expected_output": ["e1"]}, {"input": [["e2"]], "expected_output": ["e2"]}, {"input": [["e3", "e4"]], "expected_output": ["e3", "e4"]}, {"input": [["e5"]], "expected_output": ["e5"]}]}
15
  {"id": "t3_015", "difficulty": 3, "bug_type": "missing_edge_case", "function_name": "process_data", "buggy_code": "def get_first(lst):\n return lst[0]\n\ndef process_data(data):\n if not data:\n return None\n return [get_first(d) for d in data]", "original_code": "def get_first(lst):\n if not lst:\n return None\n return lst[0]\n\ndef process_data(data):\n if not data:\n return []\n return [get_first(d) for d in data]", "initial_error": "IndexError: list index out of range", "bug_location": {"function": "get_first", "line_start": 2}, "test_cases": [{"input": [[[1, 2], [3, 4]]], "expected_output": [1, 3]}, {"input": [[[1], []]], "expected_output": [1, null]}, {"input": [[[], [2]]], "expected_output": [null, 2]}, {"input": [[]], "expected_output": []}]}
data/generate_bugs.py CHANGED
@@ -58,10 +58,10 @@ TIER1_BUGS = [{'id': 't1_001',
58
  'original_code': 'def is_palindrome(s):\n return s == s[::-1]',
59
  'initial_error': "AssertionError: is_palindrome('') expected True, got False",
60
  'bug_location': {'function': 'is_palindrome', 'line_start': 2},
61
- 'test_cases': [{'input': 'racecar', 'expected_output': True},
62
- {'input': 'hello', 'expected_output': False},
63
- {'input': '', 'expected_output': True},
64
- {'input': 'a', 'expected_output': True}]},
65
  {'id': 't1_003',
66
  'difficulty': 1,
67
  'bug_type': 'off_by_one',
@@ -102,10 +102,10 @@ TIER1_BUGS = [{'id': 't1_001',
102
  ' return count',
103
  'initial_error': "AssertionError: count_vowels('Hello') expected 2, got 1",
104
  'bug_location': {'function': 'count_vowels', 'line_start': 3},
105
- 'test_cases': [{'input': 'hello', 'expected_output': 2},
106
- {'input': 'Hello', 'expected_output': 2},
107
- {'input': 'AEIOU', 'expected_output': 5},
108
- {'input': 'xyz', 'expected_output': 0}]},
109
  {'id': 't1_005',
110
  'difficulty': 1,
111
  'bug_type': 'off_by_one',
@@ -166,10 +166,10 @@ TIER1_BUGS = [{'id': 't1_001',
166
  ' return result',
167
  'initial_error': 'AssertionError: factorial(0) expected 1, got 0',
168
  'bug_location': {'function': 'factorial', 'line_start': 3},
169
- 'test_cases': [{'input': 0, 'expected_output': 1},
170
- {'input': 1, 'expected_output': 1},
171
- {'input': 5, 'expected_output': 120},
172
- {'input': 3, 'expected_output': 6}]},
173
  {'id': 't1_008',
174
  'difficulty': 1,
175
  'bug_type': 'logic_inversion',
@@ -178,10 +178,10 @@ TIER1_BUGS = [{'id': 't1_001',
178
  'original_code': 'def is_even(n):\n return n % 2 == 0',
179
  'initial_error': 'AssertionError: is_even(4) expected True, got False',
180
  'bug_location': {'function': 'is_even', 'line_start': 2},
181
- 'test_cases': [{'input': 4, 'expected_output': True},
182
- {'input': 3, 'expected_output': False},
183
- {'input': 0, 'expected_output': True},
184
- {'input': -2, 'expected_output': True}]},
185
  {'id': 't1_009',
186
  'difficulty': 1,
187
  'bug_type': 'off_by_one',
@@ -190,10 +190,10 @@ TIER1_BUGS = [{'id': 't1_001',
190
  'original_code': 'def factorial(n):\n if n == 0:\n return 1\n return n * factorial(n - 1)',
191
  'initial_error': 'RecursionError: maximum recursion depth exceeded',
192
  'bug_location': {'function': 'factorial', 'line_start': 4},
193
- 'test_cases': [{'input': 0, 'expected_output': 1},
194
- {'input': 1, 'expected_output': 1},
195
- {'input': 5, 'expected_output': 120},
196
- {'input': 3, 'expected_output': 6}]},
197
  {'id': 't1_010',
198
  'difficulty': 1,
199
  'bug_type': 'wrong_operator',
@@ -202,10 +202,10 @@ TIER1_BUGS = [{'id': 't1_001',
202
  'original_code': 'def factorial(n):\n if n == 0:\n return 1\n return n * factorial(n - 1)',
203
  'initial_error': 'AssertionError: factorial(3) expected 6, got 6 - wait got 7',
204
  'bug_location': {'function': 'factorial', 'line_start': 4},
205
- 'test_cases': [{'input': 0, 'expected_output': 1},
206
- {'input': 1, 'expected_output': 1},
207
- {'input': 5, 'expected_output': 120},
208
- {'input': 3, 'expected_output': 6}]},
209
  {'id': 't1_011',
210
  'difficulty': 1,
211
  'bug_type': 'off_by_one',
@@ -214,10 +214,10 @@ TIER1_BUGS = [{'id': 't1_001',
214
  'original_code': 'def fibonacci(n):\n if n <= 1:\n return n\n return fibonacci(n-1) + fibonacci(n-2)',
215
  'initial_error': 'RecursionError: maximum recursion depth exceeded',
216
  'bug_location': {'function': 'fibonacci', 'line_start': 2},
217
- 'test_cases': [{'input': 0, 'expected_output': 0},
218
- {'input': 1, 'expected_output': 1},
219
- {'input': 5, 'expected_output': 5},
220
- {'input': 7, 'expected_output': 13}]},
221
  {'id': 't1_012',
222
  'difficulty': 1,
223
  'bug_type': 'wrong_operator',
@@ -226,10 +226,10 @@ TIER1_BUGS = [{'id': 't1_001',
226
  'original_code': 'def fibonacci(n):\n if n <= 1:\n return n\n return fibonacci(n-1) + fibonacci(n-2)',
227
  'initial_error': 'AssertionError: fibonacci(5) expected 5, got 0',
228
  'bug_location': {'function': 'fibonacci', 'line_start': 4},
229
- 'test_cases': [{'input': 0, 'expected_output': 0},
230
- {'input': 1, 'expected_output': 1},
231
- {'input': 5, 'expected_output': 5},
232
- {'input': 7, 'expected_output': 13}]},
233
  {'id': 't1_013',
234
  'difficulty': 1,
235
  'bug_type': 'off_by_one',
@@ -238,10 +238,10 @@ TIER1_BUGS = [{'id': 't1_001',
238
  'original_code': 'def string_reverse(s):\n return s[::-1]',
239
  'initial_error': "AssertionError: string_reverse('hello') expected 'olleh', got 'hell'",
240
  'bug_location': {'function': 'string_reverse', 'line_start': 2},
241
- 'test_cases': [{'input': 'hello', 'expected_output': 'olleh'},
242
- {'input': '', 'expected_output': ''},
243
- {'input': 'a', 'expected_output': 'a'},
244
- {'input': 'racecar', 'expected_output': 'racecar'}]},
245
  {'id': 't1_014',
246
  'difficulty': 1,
247
  'bug_type': 'wrong_operator',
@@ -250,10 +250,10 @@ TIER1_BUGS = [{'id': 't1_001',
250
  'original_code': 'def string_reverse(s):\n return s[::-1]',
251
  'initial_error': "AssertionError: string_reverse('hello') expected 'olleh', got 'ello'",
252
  'bug_location': {'function': 'string_reverse', 'line_start': 2},
253
- 'test_cases': [{'input': 'hello', 'expected_output': 'olleh'},
254
- {'input': '', 'expected_output': ''},
255
- {'input': 'a', 'expected_output': 'a'},
256
- {'input': 'racecar', 'expected_output': 'racecar'}]},
257
  {'id': 't1_015',
258
  'difficulty': 1,
259
  'bug_type': 'wrong_comparison',
@@ -316,10 +316,10 @@ TIER1_BUGS = [{'id': 't1_001',
316
  ' return total',
317
  'initial_error': 'AssertionError: sum_digits(123) expected 6, got 13',
318
  'bug_location': {'function': 'sum_digits', 'line_start': 4},
319
- 'test_cases': [{'input': 123, 'expected_output': 6},
320
- {'input': 0, 'expected_output': 0},
321
- {'input': 999, 'expected_output': 27},
322
- {'input': 10, 'expected_output': 1}]},
323
  {'id': 't1_018',
324
  'difficulty': 1,
325
  'bug_type': 'logic_inversion',
@@ -338,10 +338,10 @@ TIER1_BUGS = [{'id': 't1_001',
338
  ' return total',
339
  'initial_error': 'AssertionError: sum_digits(123) expected 6, got 0',
340
  'bug_location': {'function': 'sum_digits', 'line_start': 3},
341
- 'test_cases': [{'input': 123, 'expected_output': 6},
342
- {'input': 0, 'expected_output': 0},
343
- {'input': 999, 'expected_output': 27},
344
- {'input': 10, 'expected_output': 1}]},
345
  {'id': 't1_019',
346
  'difficulty': 1,
347
  'bug_type': 'off_by_one',
@@ -362,10 +362,10 @@ TIER1_BUGS = [{'id': 't1_001',
362
  ' return True',
363
  'initial_error': 'AssertionError: is_prime(1) expected False, got True',
364
  'bug_location': {'function': 'is_prime', 'line_start': 2},
365
- 'test_cases': [{'input': 2, 'expected_output': True},
366
- {'input': 4, 'expected_output': False},
367
- {'input': 13, 'expected_output': True},
368
- {'input': 1, 'expected_output': False}]},
369
  {'id': 't1_020',
370
  'difficulty': 1,
371
  'bug_type': 'wrong_operator',
@@ -386,10 +386,10 @@ TIER1_BUGS = [{'id': 't1_001',
386
  ' return True',
387
  'initial_error': 'AssertionError: is_prime(13) expected True, got False',
388
  'bug_location': {'function': 'is_prime', 'line_start': 5},
389
- 'test_cases': [{'input': 2, 'expected_output': True},
390
- {'input': 4, 'expected_output': False},
391
- {'input': 13, 'expected_output': True},
392
- {'input': 1, 'expected_output': False}]},
393
  {'id': 't1_021',
394
  'difficulty': 1,
395
  'bug_type': 'wrong_comparison',
@@ -670,10 +670,10 @@ TIER1_BUGS = [{'id': 't1_001',
670
  ' return not stack',
671
  'initial_error': "AssertionError: valid_parentheses('()') expected True, got False",
672
  'bug_location': {'function': 'valid_parentheses', 'line_start': 7},
673
- 'test_cases': [{'input': '()', 'expected_output': True},
674
- {'input': '()[]{}', 'expected_output': True},
675
- {'input': '(]', 'expected_output': False},
676
- {'input': '([)]', 'expected_output': False}]},
677
  {'id': 't1_030',
678
  'difficulty': 1,
679
  'bug_type': 'logic_inversion',
@@ -702,10 +702,10 @@ TIER1_BUGS = [{'id': 't1_001',
702
  ' return not stack',
703
  'initial_error': "AssertionError: valid_parentheses('()') expected True, got False",
704
  'bug_location': {'function': 'valid_parentheses', 'line_start': 11},
705
- 'test_cases': [{'input': '()', 'expected_output': True},
706
- {'input': '()[]{}', 'expected_output': True},
707
- {'input': '(]', 'expected_output': False},
708
- {'input': '([)]', 'expected_output': False}]},
709
  {'id': 't1_031',
710
  'difficulty': 1,
711
  'bug_type': 'off_by_one',
@@ -726,10 +726,10 @@ TIER1_BUGS = [{'id': 't1_001',
726
  ' return b',
727
  'initial_error': 'AssertionError: climbing_stairs(3) expected 3, got 2',
728
  'bug_location': {'function': 'climbing_stairs', 'line_start': 5},
729
- 'test_cases': [{'input': 2, 'expected_output': 2},
730
- {'input': 3, 'expected_output': 3},
731
- {'input': 1, 'expected_output': 1},
732
- {'input': 5, 'expected_output': 8}]},
733
  {'id': 't1_032',
734
  'difficulty': 1,
735
  'bug_type': 'wrong_operator',
@@ -750,10 +750,10 @@ TIER1_BUGS = [{'id': 't1_001',
750
  ' return b',
751
  'initial_error': 'AssertionError: climbing_stairs(3) expected 3, got 2',
752
  'bug_location': {'function': 'climbing_stairs', 'line_start': 6},
753
- 'test_cases': [{'input': 2, 'expected_output': 2},
754
- {'input': 3, 'expected_output': 3},
755
- {'input': 1, 'expected_output': 1},
756
- {'input': 5, 'expected_output': 8}]},
757
  {'id': 't1_033',
758
  'difficulty': 1,
759
  'bug_type': 'wrong_operator',
@@ -906,10 +906,10 @@ TIER1_BUGS = [{'id': 't1_001',
906
  ' return total',
907
  'initial_error': 'AssertionError: sum_digits(123) expected 6, got 0',
908
  'bug_location': {'function': 'sum_digits', 'line_start': 4},
909
- 'test_cases': [{'input': 123, 'expected_output': 6},
910
- {'input': 0, 'expected_output': 0},
911
- {'input': 999, 'expected_output': 27},
912
- {'input': 10, 'expected_output': 1}]},
913
  {'id': 't1_040',
914
  'difficulty': 1,
915
  'bug_type': 'off_by_one',
@@ -918,10 +918,10 @@ TIER1_BUGS = [{'id': 't1_001',
918
  'original_code': 'def factorial(n):\n if n == 0:\n return 1\n return n * factorial(n - 1)',
919
  'initial_error': 'AssertionError: factorial(3) expected 6, got 0',
920
  'bug_location': {'function': 'factorial', 'line_start': 3},
921
- 'test_cases': [{'input': 0, 'expected_output': 1},
922
- {'input': 1, 'expected_output': 1},
923
- {'input': 5, 'expected_output': 120},
924
- {'input': 3, 'expected_output': 6}]}]
925
 
926
  TIER2_BUGS = [{'id': 't2_001',
927
  'difficulty': 2,
@@ -961,10 +961,10 @@ TIER2_BUGS = [{'id': 't2_001',
961
  ' return fibonacci(n - 1) + fibonacci(n - 2)',
962
  'initial_error': 'RecursionError: maximum recursion depth exceeded',
963
  'bug_location': {'function': 'fibonacci', 'line_start': 4},
964
- 'test_cases': [{'input': 0, 'expected_output': 0},
965
- {'input': 1, 'expected_output': 1},
966
- {'input': 5, 'expected_output': 5},
967
- {'input': 7, 'expected_output': 13}]},
968
  {'id': 't2_003',
969
  'difficulty': 2,
970
  'bug_type': 'wrong_accumulator',
@@ -1060,10 +1060,10 @@ TIER2_BUGS = [{'id': 't2_001',
1060
  ' return res',
1061
  'initial_error': 'AssertionError: expected [3, 2, 1, 0], got [3, 2, 1]',
1062
  'bug_location': {'function': 'countdown_to_zero', 'line_start': 3},
1063
- 'test_cases': [{'input': 3, 'expected_output': [3, 2, 1, 0]},
1064
- {'input': 0, 'expected_output': [0]},
1065
- {'input': 1, 'expected_output': [1, 0]},
1066
- {'input': -1, 'expected_output': []}]},
1067
  {'id': 't2_007',
1068
  'difficulty': 2,
1069
  'bug_type': 'wrong_loop_termination',
@@ -1100,10 +1100,10 @@ TIER2_BUGS = [{'id': 't2_001',
1100
  ' return s[i:]',
1101
  'initial_error': 'IndexError: string index out of range',
1102
  'bug_location': {'function': 'skip_spaces', 'line_start': 3},
1103
- 'test_cases': [{'input': ' hello', 'expected_output': 'hello'},
1104
- {'input': ' ', 'expected_output': ''},
1105
- {'input': 'world', 'expected_output': 'world'},
1106
- {'input': '', 'expected_output': ''}]},
1107
  {'id': 't2_009',
1108
  'difficulty': 2,
1109
  'bug_type': 'wrong_loop_termination',
@@ -1314,10 +1314,10 @@ TIER2_BUGS = [{'id': 't2_001',
1314
  " return 'zero'",
1315
  'initial_error': "AssertionError: expected 'zero', got 'negative'",
1316
  'bug_location': {'function': 'classify_number', 'line_start': 6},
1317
- 'test_cases': [{'input': 5, 'expected_output': 'positive'},
1318
- {'input': -3, 'expected_output': 'negative'},
1319
- {'input': 0, 'expected_output': 'zero'},
1320
- {'input': 1, 'expected_output': 'positive'}]},
1321
  {'id': 't2_019',
1322
  'difficulty': 2,
1323
  'bug_type': 'wrong_conditional_branch',
@@ -1336,10 +1336,10 @@ TIER2_BUGS = [{'id': 't2_001',
1336
  ' return 0',
1337
  'initial_error': 'AssertionError: expected 10, got 50',
1338
  'bug_location': {'function': 'get_discount', 'line_start': 5},
1339
- 'test_cases': [{'input': 150, 'expected_output': 20},
1340
- {'input': 75, 'expected_output': 10},
1341
- {'input': 50, 'expected_output': 0},
1342
- {'input': 20, 'expected_output': 0}]},
1343
  {'id': 't2_020',
1344
  'difficulty': 2,
1345
  'bug_type': 'wrong_conditional_branch',
@@ -1362,10 +1362,10 @@ TIER2_BUGS = [{'id': 't2_001',
1362
  ' return str(n)',
1363
  'initial_error': "AssertionError: expected 'FizzBuzz', got 'Fizz'",
1364
  'bug_location': {'function': 'fizz_buzz', 'line_start': 2},
1365
- 'test_cases': [{'input': 3, 'expected_output': 'Fizz'},
1366
- {'input': 5, 'expected_output': 'Buzz'},
1367
- {'input': 15, 'expected_output': 'FizzBuzz'},
1368
- {'input': 2, 'expected_output': '2'}]},
1369
  {'id': 't2_021',
1370
  'difficulty': 2,
1371
  'bug_type': 'wrong_conditional_branch',
@@ -1388,10 +1388,10 @@ TIER2_BUGS = [{'id': 't2_001',
1388
  ' return False',
1389
  'initial_error': 'AssertionError: expected False, got True',
1390
  'bug_location': {'function': 'is_leap_year', 'line_start': 5},
1391
- 'test_cases': [{'input': 2000, 'expected_output': True},
1392
- {'input': 1900, 'expected_output': False},
1393
- {'input': 2004, 'expected_output': True},
1394
- {'input': 2001, 'expected_output': False}]},
1395
  {'id': 't2_022',
1396
  'difficulty': 2,
1397
  'bug_type': 'wrong_conditional_branch',
@@ -1416,10 +1416,10 @@ TIER2_BUGS = [{'id': 't2_001',
1416
  " return 'F'",
1417
  'initial_error': "AssertionError: expected 'C', got 'F'",
1418
  'bug_location': {'function': 'grade_score', 'line_start': 6},
1419
- 'test_cases': [{'input': 95, 'expected_output': 'A'},
1420
- {'input': 80, 'expected_output': 'B'},
1421
- {'input': 70, 'expected_output': 'C'},
1422
- {'input': 60, 'expected_output': 'F'}]},
1423
  {'id': 't2_023',
1424
  'difficulty': 2,
1425
  'bug_type': 'wrong_conditional_branch',
@@ -1574,10 +1574,10 @@ TIER2_BUGS = [{'id': 't2_001',
1574
  " return ''.join(initials)",
1575
  'initial_error': "AssertionError: expected 'JD', got 'JohnDoe'",
1576
  'bug_location': {'function': 'get_initials', 'line_start': 4},
1577
- 'test_cases': [{'input': 'John Doe', 'expected_output': 'JD'},
1578
- {'input': 'Alice', 'expected_output': 'A'},
1579
- {'input': 'bob smith junior', 'expected_output': 'BSJ'},
1580
- {'input': '', 'expected_output': ''}]}]
1581
 
1582
  TIER3_BUGS = [{'id': 't3_001',
1583
  'difficulty': 3,
@@ -1835,10 +1835,10 @@ TIER3_BUGS = [{'id': 't3_001',
1835
  ' return helper(val)',
1836
  'initial_error': 'AssertionError: expected [2], got [1, 2]',
1837
  'bug_location': {'function': 'helper', 'line_start': 1},
1838
- 'test_cases': [{'input': 1, 'expected_output': [1]},
1839
- {'input': 2, 'expected_output': [2]},
1840
- {'input': 3, 'expected_output': [3]},
1841
- {'input': 4, 'expected_output': [4]}]},
1842
  {'id': 't3_012',
1843
  'difficulty': 3,
1844
  'bug_type': 'state_not_reset',
@@ -1863,10 +1863,10 @@ TIER3_BUGS = [{'id': 't3_001',
1863
  ' return res',
1864
  'initial_error': 'AssertionError: expected [1, 2], got [3, 4] on second run',
1865
  'bug_location': {'function': 'tracker', 'line_start': 4},
1866
- 'test_cases': [{'input': 2, 'expected_output': [1, 2]},
1867
- {'input': 2, 'expected_output': [1, 2]},
1868
- {'input': 3, 'expected_output': [1, 2, 3]},
1869
- {'input': 3, 'expected_output': [1, 2, 3]}]},
1870
  {'id': 't3_013',
1871
  'difficulty': 3,
1872
  'bug_type': 'state_not_reset',
 
58
  'original_code': 'def is_palindrome(s):\n return s == s[::-1]',
59
  'initial_error': "AssertionError: is_palindrome('') expected True, got False",
60
  'bug_location': {'function': 'is_palindrome', 'line_start': 2},
61
+ 'test_cases': [{'input': ['racecar'], 'expected_output': True},
62
+ {'input': ['hello'], 'expected_output': False},
63
+ {'input': [''], 'expected_output': True},
64
+ {'input': ['a'], 'expected_output': True}]},
65
  {'id': 't1_003',
66
  'difficulty': 1,
67
  'bug_type': 'off_by_one',
 
102
  ' return count',
103
  'initial_error': "AssertionError: count_vowels('Hello') expected 2, got 1",
104
  'bug_location': {'function': 'count_vowels', 'line_start': 3},
105
+ 'test_cases': [{'input': ['hello'], 'expected_output': 2},
106
+ {'input': ['Hello'], 'expected_output': 2},
107
+ {'input': ['AEIOU'], 'expected_output': 5},
108
+ {'input': ['xyz'], 'expected_output': 0}]},
109
  {'id': 't1_005',
110
  'difficulty': 1,
111
  'bug_type': 'off_by_one',
 
166
  ' return result',
167
  'initial_error': 'AssertionError: factorial(0) expected 1, got 0',
168
  'bug_location': {'function': 'factorial', 'line_start': 3},
169
+ 'test_cases': [{'input': [0], 'expected_output': 1},
170
+ {'input': [1], 'expected_output': 1},
171
+ {'input': [5], 'expected_output': 120},
172
+ {'input': [3], 'expected_output': 6}]},
173
  {'id': 't1_008',
174
  'difficulty': 1,
175
  'bug_type': 'logic_inversion',
 
178
  'original_code': 'def is_even(n):\n return n % 2 == 0',
179
  'initial_error': 'AssertionError: is_even(4) expected True, got False',
180
  'bug_location': {'function': 'is_even', 'line_start': 2},
181
+ 'test_cases': [{'input': [4], 'expected_output': True},
182
+ {'input': [3], 'expected_output': False},
183
+ {'input': [0], 'expected_output': True},
184
+ {'input': [-2], 'expected_output': True}]},
185
  {'id': 't1_009',
186
  'difficulty': 1,
187
  'bug_type': 'off_by_one',
 
190
  'original_code': 'def factorial(n):\n if n == 0:\n return 1\n return n * factorial(n - 1)',
191
  'initial_error': 'RecursionError: maximum recursion depth exceeded',
192
  'bug_location': {'function': 'factorial', 'line_start': 4},
193
+ 'test_cases': [{'input': [0], 'expected_output': 1},
194
+ {'input': [1], 'expected_output': 1},
195
+ {'input': [5], 'expected_output': 120},
196
+ {'input': [3], 'expected_output': 6}]},
197
  {'id': 't1_010',
198
  'difficulty': 1,
199
  'bug_type': 'wrong_operator',
 
202
  'original_code': 'def factorial(n):\n if n == 0:\n return 1\n return n * factorial(n - 1)',
203
  'initial_error': 'AssertionError: factorial(3) expected 6, got 6 - wait got 7',
204
  'bug_location': {'function': 'factorial', 'line_start': 4},
205
+ 'test_cases': [{'input': [0], 'expected_output': 1},
206
+ {'input': [1], 'expected_output': 1},
207
+ {'input': [5], 'expected_output': 120},
208
+ {'input': [3], 'expected_output': 6}]},
209
  {'id': 't1_011',
210
  'difficulty': 1,
211
  'bug_type': 'off_by_one',
 
214
  'original_code': 'def fibonacci(n):\n if n <= 1:\n return n\n return fibonacci(n-1) + fibonacci(n-2)',
215
  'initial_error': 'RecursionError: maximum recursion depth exceeded',
216
  'bug_location': {'function': 'fibonacci', 'line_start': 2},
217
+ 'test_cases': [{'input': [0], 'expected_output': 0},
218
+ {'input': [1], 'expected_output': 1},
219
+ {'input': [5], 'expected_output': 5},
220
+ {'input': [7], 'expected_output': 13}]},
221
  {'id': 't1_012',
222
  'difficulty': 1,
223
  'bug_type': 'wrong_operator',
 
226
  'original_code': 'def fibonacci(n):\n if n <= 1:\n return n\n return fibonacci(n-1) + fibonacci(n-2)',
227
  'initial_error': 'AssertionError: fibonacci(5) expected 5, got 0',
228
  'bug_location': {'function': 'fibonacci', 'line_start': 4},
229
+ 'test_cases': [{'input': [0], 'expected_output': 0},
230
+ {'input': [1], 'expected_output': 1},
231
+ {'input': [5], 'expected_output': 5},
232
+ {'input': [7], 'expected_output': 13}]},
233
  {'id': 't1_013',
234
  'difficulty': 1,
235
  'bug_type': 'off_by_one',
 
238
  'original_code': 'def string_reverse(s):\n return s[::-1]',
239
  'initial_error': "AssertionError: string_reverse('hello') expected 'olleh', got 'hell'",
240
  'bug_location': {'function': 'string_reverse', 'line_start': 2},
241
+ 'test_cases': [{'input': ['hello'], 'expected_output': 'olleh'},
242
+ {'input': [''], 'expected_output': ''},
243
+ {'input': ['a'], 'expected_output': 'a'},
244
+ {'input': ['racecar'], 'expected_output': 'racecar'}]},
245
  {'id': 't1_014',
246
  'difficulty': 1,
247
  'bug_type': 'wrong_operator',
 
250
  'original_code': 'def string_reverse(s):\n return s[::-1]',
251
  'initial_error': "AssertionError: string_reverse('hello') expected 'olleh', got 'ello'",
252
  'bug_location': {'function': 'string_reverse', 'line_start': 2},
253
+ 'test_cases': [{'input': ['hello'], 'expected_output': 'olleh'},
254
+ {'input': [''], 'expected_output': ''},
255
+ {'input': ['a'], 'expected_output': 'a'},
256
+ {'input': ['racecar'], 'expected_output': 'racecar'}]},
257
  {'id': 't1_015',
258
  'difficulty': 1,
259
  'bug_type': 'wrong_comparison',
 
316
  ' return total',
317
  'initial_error': 'AssertionError: sum_digits(123) expected 6, got 13',
318
  'bug_location': {'function': 'sum_digits', 'line_start': 4},
319
+ 'test_cases': [{'input': [123], 'expected_output': 6},
320
+ {'input': [0], 'expected_output': 0},
321
+ {'input': [999], 'expected_output': 27},
322
+ {'input': [10], 'expected_output': 1}]},
323
  {'id': 't1_018',
324
  'difficulty': 1,
325
  'bug_type': 'logic_inversion',
 
338
  ' return total',
339
  'initial_error': 'AssertionError: sum_digits(123) expected 6, got 0',
340
  'bug_location': {'function': 'sum_digits', 'line_start': 3},
341
+ 'test_cases': [{'input': [123], 'expected_output': 6},
342
+ {'input': [0], 'expected_output': 0},
343
+ {'input': [999], 'expected_output': 27},
344
+ {'input': [10], 'expected_output': 1}]},
345
  {'id': 't1_019',
346
  'difficulty': 1,
347
  'bug_type': 'off_by_one',
 
362
  ' return True',
363
  'initial_error': 'AssertionError: is_prime(1) expected False, got True',
364
  'bug_location': {'function': 'is_prime', 'line_start': 2},
365
+ 'test_cases': [{'input': [2], 'expected_output': True},
366
+ {'input': [4], 'expected_output': False},
367
+ {'input': [13], 'expected_output': True},
368
+ {'input': [1], 'expected_output': False}]},
369
  {'id': 't1_020',
370
  'difficulty': 1,
371
  'bug_type': 'wrong_operator',
 
386
  ' return True',
387
  'initial_error': 'AssertionError: is_prime(13) expected True, got False',
388
  'bug_location': {'function': 'is_prime', 'line_start': 5},
389
+ 'test_cases': [{'input': [2], 'expected_output': True},
390
+ {'input': [4], 'expected_output': False},
391
+ {'input': [13], 'expected_output': True},
392
+ {'input': [1], 'expected_output': False}]},
393
  {'id': 't1_021',
394
  'difficulty': 1,
395
  'bug_type': 'wrong_comparison',
 
670
  ' return not stack',
671
  'initial_error': "AssertionError: valid_parentheses('()') expected True, got False",
672
  'bug_location': {'function': 'valid_parentheses', 'line_start': 7},
673
+ 'test_cases': [{'input': ['()'], 'expected_output': True},
674
+ {'input': ['()[]{}'], 'expected_output': True},
675
+ {'input': ['(]'], 'expected_output': False},
676
+ {'input': ['([)]'], 'expected_output': False}]},
677
  {'id': 't1_030',
678
  'difficulty': 1,
679
  'bug_type': 'logic_inversion',
 
702
  ' return not stack',
703
  'initial_error': "AssertionError: valid_parentheses('()') expected True, got False",
704
  'bug_location': {'function': 'valid_parentheses', 'line_start': 11},
705
+ 'test_cases': [{'input': ['()'], 'expected_output': True},
706
+ {'input': ['()[]{}'], 'expected_output': True},
707
+ {'input': ['(]'], 'expected_output': False},
708
+ {'input': ['([)]'], 'expected_output': False}]},
709
  {'id': 't1_031',
710
  'difficulty': 1,
711
  'bug_type': 'off_by_one',
 
726
  ' return b',
727
  'initial_error': 'AssertionError: climbing_stairs(3) expected 3, got 2',
728
  'bug_location': {'function': 'climbing_stairs', 'line_start': 5},
729
+ 'test_cases': [{'input': [2], 'expected_output': 2},
730
+ {'input': [3], 'expected_output': 3},
731
+ {'input': [1], 'expected_output': 1},
732
+ {'input': [5], 'expected_output': 8}]},
733
  {'id': 't1_032',
734
  'difficulty': 1,
735
  'bug_type': 'wrong_operator',
 
750
  ' return b',
751
  'initial_error': 'AssertionError: climbing_stairs(3) expected 3, got 2',
752
  'bug_location': {'function': 'climbing_stairs', 'line_start': 6},
753
+ 'test_cases': [{'input': [2], 'expected_output': 2},
754
+ {'input': [3], 'expected_output': 3},
755
+ {'input': [1], 'expected_output': 1},
756
+ {'input': [5], 'expected_output': 8}]},
757
  {'id': 't1_033',
758
  'difficulty': 1,
759
  'bug_type': 'wrong_operator',
 
906
  ' return total',
907
  'initial_error': 'AssertionError: sum_digits(123) expected 6, got 0',
908
  'bug_location': {'function': 'sum_digits', 'line_start': 4},
909
+ 'test_cases': [{'input': [123], 'expected_output': 6},
910
+ {'input': [0], 'expected_output': 0},
911
+ {'input': [999], 'expected_output': 27},
912
+ {'input': [10], 'expected_output': 1}]},
913
  {'id': 't1_040',
914
  'difficulty': 1,
915
  'bug_type': 'off_by_one',
 
918
  'original_code': 'def factorial(n):\n if n == 0:\n return 1\n return n * factorial(n - 1)',
919
  'initial_error': 'AssertionError: factorial(3) expected 6, got 0',
920
  'bug_location': {'function': 'factorial', 'line_start': 3},
921
+ 'test_cases': [{'input': [0], 'expected_output': 1},
922
+ {'input': [1], 'expected_output': 1},
923
+ {'input': [5], 'expected_output': 120},
924
+ {'input': [3], 'expected_output': 6}]}]
925
 
926
  TIER2_BUGS = [{'id': 't2_001',
927
  'difficulty': 2,
 
961
  ' return fibonacci(n - 1) + fibonacci(n - 2)',
962
  'initial_error': 'RecursionError: maximum recursion depth exceeded',
963
  'bug_location': {'function': 'fibonacci', 'line_start': 4},
964
+ 'test_cases': [{'input': [0], 'expected_output': 0},
965
+ {'input': [1], 'expected_output': 1},
966
+ {'input': [5], 'expected_output': 5},
967
+ {'input': [7], 'expected_output': 13}]},
968
  {'id': 't2_003',
969
  'difficulty': 2,
970
  'bug_type': 'wrong_accumulator',
 
1060
  ' return res',
1061
  'initial_error': 'AssertionError: expected [3, 2, 1, 0], got [3, 2, 1]',
1062
  'bug_location': {'function': 'countdown_to_zero', 'line_start': 3},
1063
+ 'test_cases': [{'input': [3], 'expected_output': [3, 2, 1, 0]},
1064
+ {'input': [0], 'expected_output': [0]},
1065
+ {'input': [1], 'expected_output': [1, 0]},
1066
+ {'input': [-1], 'expected_output': []}]},
1067
  {'id': 't2_007',
1068
  'difficulty': 2,
1069
  'bug_type': 'wrong_loop_termination',
 
1100
  ' return s[i:]',
1101
  'initial_error': 'IndexError: string index out of range',
1102
  'bug_location': {'function': 'skip_spaces', 'line_start': 3},
1103
+ 'test_cases': [{'input': [' hello'], 'expected_output': 'hello'},
1104
+ {'input': [' '], 'expected_output': ''},
1105
+ {'input': ['world'], 'expected_output': 'world'},
1106
+ {'input': [''], 'expected_output': ''}]},
1107
  {'id': 't2_009',
1108
  'difficulty': 2,
1109
  'bug_type': 'wrong_loop_termination',
 
1314
  " return 'zero'",
1315
  'initial_error': "AssertionError: expected 'zero', got 'negative'",
1316
  'bug_location': {'function': 'classify_number', 'line_start': 6},
1317
+ 'test_cases': [{'input': [5], 'expected_output': 'positive'},
1318
+ {'input': [-3], 'expected_output': 'negative'},
1319
+ {'input': [0], 'expected_output': 'zero'},
1320
+ {'input': [1], 'expected_output': 'positive'}]},
1321
  {'id': 't2_019',
1322
  'difficulty': 2,
1323
  'bug_type': 'wrong_conditional_branch',
 
1336
  ' return 0',
1337
  'initial_error': 'AssertionError: expected 10, got 50',
1338
  'bug_location': {'function': 'get_discount', 'line_start': 5},
1339
+ 'test_cases': [{'input': [150], 'expected_output': 20},
1340
+ {'input': [75], 'expected_output': 10},
1341
+ {'input': [50], 'expected_output': 0},
1342
+ {'input': [20], 'expected_output': 0}]},
1343
  {'id': 't2_020',
1344
  'difficulty': 2,
1345
  'bug_type': 'wrong_conditional_branch',
 
1362
  ' return str(n)',
1363
  'initial_error': "AssertionError: expected 'FizzBuzz', got 'Fizz'",
1364
  'bug_location': {'function': 'fizz_buzz', 'line_start': 2},
1365
+ 'test_cases': [{'input': [3], 'expected_output': 'Fizz'},
1366
+ {'input': [5], 'expected_output': 'Buzz'},
1367
+ {'input': [15], 'expected_output': 'FizzBuzz'},
1368
+ {'input': [2], 'expected_output': '2'}]},
1369
  {'id': 't2_021',
1370
  'difficulty': 2,
1371
  'bug_type': 'wrong_conditional_branch',
 
1388
  ' return False',
1389
  'initial_error': 'AssertionError: expected False, got True',
1390
  'bug_location': {'function': 'is_leap_year', 'line_start': 5},
1391
+ 'test_cases': [{'input': [2000], 'expected_output': True},
1392
+ {'input': [1900], 'expected_output': False},
1393
+ {'input': [2004], 'expected_output': True},
1394
+ {'input': [2001], 'expected_output': False}]},
1395
  {'id': 't2_022',
1396
  'difficulty': 2,
1397
  'bug_type': 'wrong_conditional_branch',
 
1416
  " return 'F'",
1417
  'initial_error': "AssertionError: expected 'C', got 'F'",
1418
  'bug_location': {'function': 'grade_score', 'line_start': 6},
1419
+ 'test_cases': [{'input': [95], 'expected_output': 'A'},
1420
+ {'input': [80], 'expected_output': 'B'},
1421
+ {'input': [70], 'expected_output': 'C'},
1422
+ {'input': [60], 'expected_output': 'F'}]},
1423
  {'id': 't2_023',
1424
  'difficulty': 2,
1425
  'bug_type': 'wrong_conditional_branch',
 
1574
  " return ''.join(initials)",
1575
  'initial_error': "AssertionError: expected 'JD', got 'JohnDoe'",
1576
  'bug_location': {'function': 'get_initials', 'line_start': 4},
1577
+ 'test_cases': [{'input': ['John Doe'], 'expected_output': 'JD'},
1578
+ {'input': ['Alice'], 'expected_output': 'A'},
1579
+ {'input': ['bob smith junior'], 'expected_output': 'BSJ'},
1580
+ {'input': [''], 'expected_output': ''}]}]
1581
 
1582
  TIER3_BUGS = [{'id': 't3_001',
1583
  'difficulty': 3,
 
1835
  ' return helper(val)',
1836
  'initial_error': 'AssertionError: expected [2], got [1, 2]',
1837
  'bug_location': {'function': 'helper', 'line_start': 1},
1838
+ 'test_cases': [{'input': [1], 'expected_output': [1]},
1839
+ {'input': [2], 'expected_output': [2]},
1840
+ {'input': [3], 'expected_output': [3]},
1841
+ {'input': [4], 'expected_output': [4]}]},
1842
  {'id': 't3_012',
1843
  'difficulty': 3,
1844
  'bug_type': 'state_not_reset',
 
1863
  ' return res',
1864
  'initial_error': 'AssertionError: expected [1, 2], got [3, 4] on second run',
1865
  'bug_location': {'function': 'tracker', 'line_start': 4},
1866
+ 'test_cases': [{'input': [2], 'expected_output': [1, 2]},
1867
+ {'input': [2], 'expected_output': [1, 2]},
1868
+ {'input': [3], 'expected_output': [1, 2, 3]},
1869
+ {'input': [3], 'expected_output': [1, 2, 3]}]},
1870
  {'id': 't3_013',
1871
  'difficulty': 3,
1872
  'bug_type': 'state_not_reset',
demo/gradio_app.py CHANGED
@@ -265,10 +265,7 @@ def _run_tests(code: str, function_name: str, test_cases: list) -> dict:
265
  for tc in test_cases:
266
  inp = tc["input"]
267
  expected = tc["expected_output"]
268
- if isinstance(inp, (list, tuple)):
269
- args_str = ", ".join(repr(x) for x in inp)
270
- else:
271
- args_str = repr(inp)
272
  script = (
273
  f"{code}\n"
274
  f"try:\n"
 
265
  for tc in test_cases:
266
  inp = tc["input"]
267
  expected = tc["expected_output"]
268
+ args_str = ", ".join(repr(x) for x in inp)
 
 
 
269
  script = (
270
  f"{code}\n"
271
  f"try:\n"
env/environment.py CHANGED
@@ -326,10 +326,7 @@ class DebuggerEnvironment:
326
  inp = test["input"]
327
  expected = test["expected_output"]
328
 
329
- if isinstance(inp, (list, tuple)):
330
- args_str = ", ".join(repr(x) for x in inp)
331
- else:
332
- args_str = repr(inp)
333
 
334
  script = f"""
335
  {proposed_code}
 
326
  inp = test["input"]
327
  expected = test["expected_output"]
328
 
329
+ args_str = ", ".join(repr(x) for x in inp)
 
 
 
330
 
331
  script = f"""
332
  {proposed_code}
requirements.txt CHANGED
@@ -6,6 +6,7 @@ datasets==3.0.2
6
  transformers==4.46.3
7
  accelerate==1.0.1
8
  trl==0.14.0
 
9
  torch==2.5.1+cu121
10
  bitsandbytes==0.43.3
11
  peft==0.13.2
 
6
  transformers==4.46.3
7
  accelerate==1.0.1
8
  trl==0.14.0
9
+ mergekit
10
  torch==2.5.1+cu121
11
  bitsandbytes==0.43.3
12
  peft==0.13.2
requirements_kaggle.txt CHANGED
@@ -5,5 +5,6 @@ datasets==3.0.2
5
  transformers==4.46.3
6
  accelerate==1.0.1
7
  trl==0.14.0
 
8
  bitsandbytes==0.45.3
9
  peft==0.13.2
 
5
  transformers==4.46.3
6
  accelerate==1.0.1
7
  trl==0.14.0
8
+ mergekit
9
  bitsandbytes==0.45.3
10
  peft==0.13.2
training/train_grpo.py CHANGED
@@ -155,7 +155,7 @@ def _run_fix(proposed_code: str, bug: dict) -> dict:
155
  passed = 0
156
  for test in test_cases:
157
  inp = test["input"]
158
- args_str = ", ".join(repr(x) for x in inp) if isinstance(inp, (list, tuple)) else repr(inp)
159
  script = (
160
  f"{proposed_code}\n"
161
  f"try:\n"
 
155
  passed = 0
156
  for test in test_cases:
157
  inp = test["input"]
158
+ args_str = ", ".join(repr(x) for x in inp)
159
  script = (
160
  f"{proposed_code}\n"
161
  f"try:\n"