pybugfix-verified-v1-sample / pybugfix-verified-v1-sample.jsonl
SirGrokkius's picture
Free sample v1 (20 Nov 2026)
3e44ca5 verified
Raw History Blame Contribute Delete
42.9 kB
{"id": "pbf1-7a6aa46bbf1e", "function": "clear_least_significant_set_bit", "theme": "bit manipulation and binary helpers", "description": "Clears the least significant set bit of an integer.", "buggy_code": "def clear_least_significant_set_bit(n):\n if n == 0:\n return 1\n result = n & n - 1\n return result", "fixed_code": "def clear_least_significant_set_bit(n):\n if n == 0:\n return 0\n result = n & n - 1\n return result", "tests": ["assert clear_least_significant_set_bit(0) == 0", "assert clear_least_significant_set_bit(1) == 0", "assert clear_least_significant_set_bit(2) == 0", "assert clear_least_significant_set_bit(3) == 2", "assert clear_least_significant_set_bit(8) == 0", "assert clear_least_significant_set_bit(12) == 8"], "failing_tests": ["assert clear_least_significant_set_bit(0) == 0 -> AssertionError"], "bug_type": "const", "fix_patch": "--- buggy.py\n+++ fixed.py\n@@ -2,3 +2,3 @@\n if n == 0:\n- return 1\n+ return 0\n result = n & n - 1\n", "bug_description": "off-by-one constant (0 -> 1)", "n_failing": 1, "n_tests": 6, "verified": "fixed passes all tests; buggy fails >=1 (CPython 3.13.5)", "source": "function+tests: nvidia/nemotron-3.5-lightning (OpenRouter free tier); bug: deterministic AST mutation by Sir Grokkius"}
{"id": "pbf1-55c13a46c1cf", "function": "get_bit_at", "theme": "bit manipulation and binary helpers", "description": "Returns the bit value at a specified position in an integer.", "buggy_code": "def get_bit_at(n, pos):\n if pos <= 0:\n return -1\n shifted = n >> pos\n return shifted & 1", "fixed_code": "def get_bit_at(n, pos):\n if pos < 0:\n return -1\n shifted = n >> pos\n return shifted & 1", "tests": ["assert get_bit_at(0, 0) == 0", "assert get_bit_at(1, 0) == 1", "assert get_bit_at(1, 1) == 0", "assert get_bit_at(8, 3) == 1", "assert get_bit_at(8, 2) == 0", "assert get_bit_at(15, 2) == 1"], "failing_tests": ["assert get_bit_at(0, 0) == 0 -> AssertionError", "assert get_bit_at(1, 0) == 1 -> AssertionError"], "bug_type": "cmp", "fix_patch": "--- buggy.py\n+++ fixed.py\n@@ -1,3 +1,3 @@\n def get_bit_at(n, pos):\n- if pos <= 0:\n+ if pos < 0:\n return -1\n", "bug_description": "boundary/comparison operator changed (< -> <=)", "n_failing": 2, "n_tests": 6, "verified": "fixed passes all tests; buggy fails >=1 (CPython 3.13.5)", "source": "function+tests: nvidia/nemotron-3.5-lightning (OpenRouter free tier); bug: deterministic AST mutation by Sir Grokkius"}
{"id": "pbf1-d0980fab21f5", "function": "merge_counts", "theme": "dictionary and counting utilities", "description": "Merge two dictionaries of numeric counts with selectable combination rule.", "buggy_code": "def merge_counts(a, b, combine='sum'):\n \"\"\"Merge two count dictionaries.\n combine can be 'sum', 'max', or 'min'.\n \"\"\"\n result = {}\n keys = set(a) | set(b)\n for k in keys:\n av = a.get(k, 1)\n bv = b.get(k, 0)\n if combine == 'sum':\n result[k] = av + bv\n elif combine == 'max':\n result[k] = av if av > bv else bv\n elif combine == 'min':\n result[k] = av if av < bv else bv\n else:\n raise ValueError('Invalid combine mode')\n return result", "fixed_code": "def merge_counts(a, b, combine='sum'):\n \"\"\"Merge two count dictionaries.\n combine can be 'sum', 'max', or 'min'.\n \"\"\"\n result = {}\n keys = set(a) | set(b)\n for k in keys:\n av = a.get(k, 0)\n bv = b.get(k, 0)\n if combine == 'sum':\n result[k] = av + bv\n elif combine == 'max':\n result[k] = av if av > bv else bv\n elif combine == 'min':\n result[k] = av if av < bv else bv\n else:\n raise ValueError('Invalid combine mode')\n return result", "tests": ["assert merge_counts({'a': 1}, {'a': 2}) == {'a': 3}", "assert merge_counts({'x': 5}, {'y': 3}) == {'x': 5, 'y': 3}", "assert merge_counts({'a': -1, 'b': 4}, {'a': 2, 'c': 0}, combine='max') == {'a': 2, 'b': 4, 'c': 0}", "assert merge_counts({'a': -5}, {'a': -2}, combine='min') == {'a': -5}", "assert merge_counts({}, {'z': 7}) == {'z': 7}"], "failing_tests": ["assert merge_counts({'x': 5}, {'y': 3}) == {'x': 5, 'y': 3} -> AssertionError", "assert merge_counts({'a': -1, 'b': 4}, {'a': 2, 'c': 0}, combine='max') == {'a': 2, 'b': 4, 'c': 0} -> AssertionError", "assert merge_counts({}, {'z': 7}) == {'z': 7} -> AssertionError"], "bug_type": "const", "fix_patch": "--- buggy.py\n+++ fixed.py\n@@ -7,3 +7,3 @@\n for k in keys:\n- av = a.get(k, 1)\n+ av = a.get(k, 0)\n bv = b.get(k, 0)\n", "bug_description": "off-by-one constant (0 -> 1)", "n_failing": 3, "n_tests": 5, "verified": "fixed passes all tests; buggy fails >=1 (CPython 3.13.5)", "source": "function+tests: @cf/openai/gpt-oss-120b (Cloudflare Workers AI); bug: deterministic AST mutation by Sir Grokkius"}
{"id": "pbf1-429fe094045e", "function": "dict_histogram", "theme": "dictionary and counting utilities", "description": "Build a histogram (count dict) from an iterable, optionally applying a key function.", "buggy_code": "def dict_histogram(iterable, key_func=None):\n \"\"\"Count occurrences in iterable; if key_func is provided, apply it to each element.\"\"\"\n result = {}\n for item in iterable:\n key = key_func(item) if key_func else item\n result[key] = result.get(key, 0) + 2\n return result", "fixed_code": "def dict_histogram(iterable, key_func=None):\n \"\"\"Count occurrences in iterable; if key_func is provided, apply it to each element.\"\"\"\n result = {}\n for item in iterable:\n key = key_func(item) if key_func else item\n result[key] = result.get(key, 0) + 1\n return result", "tests": ["assert dict_histogram([]) == {}", "assert dict_histogram([1,2,2,3,1,1]) == {1:3, 2:2, 3:1}", "assert dict_histogram(['a','A','b','B'], key_func=str.lower) == {'a':2, 'b':2}", "assert dict_histogram([True, False, True]) == {True:2, False:1}", "assert dict_histogram(['x','x','x'], key_func=lambda x: x.upper()) == {'X':3}", "assert dict_histogram([1,2,3], key_func=lambda x: x%2) == {1:2, 0:1}"], "failing_tests": ["assert dict_histogram([1,2,2,3,1,1]) == {1:3, 2:2, 3:1} -> AssertionError", "assert dict_histogram(['a','A','b','B'], key_func=str.lower) == {'a':2, 'b':2} -> AssertionError", "assert dict_histogram([True, False, True]) == {True:2, False:1} -> AssertionError", "assert dict_histogram(['x','x','x'], key_func=lambda x: x.upper()) == {'X':3} -> AssertionError", "assert dict_histogram([1,2,3], key_func=lambda x: x%2) == {1:2, 0:1} -> AssertionError"], "bug_type": "const", "fix_patch": "--- buggy.py\n+++ fixed.py\n@@ -5,3 +5,3 @@\n key = key_func(item) if key_func else item\n- result[key] = result.get(key, 0) + 2\n+ result[key] = result.get(key, 0) + 1\n return result", "bug_description": "off-by-one constant (1 -> 2)", "n_failing": 5, "n_tests": 6, "verified": "fixed passes all tests; buggy fails >=1 (CPython 3.13.5)", "source": "function+tests: @cf/openai/gpt-oss-120b (Cloudflare Workers AI); bug: deterministic AST mutation by Sir Grokkius"}
{"id": "pbf1-19fa99df03ec", "function": "intervals_overlap", "theme": "interval and range logic", "description": "Returns True if two closed intervals overlap (including touching at a point).", "buggy_code": "def intervals_overlap(a_start, a_end, b_start, b_end):\n if a_start > a_end:\n a_start, a_end = (a_end, a_start)\n if b_start > b_end:\n b_start, b_end = (b_end, b_start)\n return not (a_end < b_start and b_end < a_start)", "fixed_code": "def intervals_overlap(a_start, a_end, b_start, b_end):\n if a_start > a_end:\n a_start, a_end = (a_end, a_start)\n if b_start > b_end:\n b_start, b_end = (b_end, b_start)\n return not (a_end < b_start or b_end < a_start)", "tests": ["assert intervals_overlap(1, 5, 4, 8) == True", "assert intervals_overlap(1, 3, 4, 6) == False", "assert intervals_overlap(5, 1, 2, 4) == True", "assert intervals_overlap(2, 4, 4, 6) == True", "assert intervals_overlap(0, 0, 0, 0) == True", "assert intervals_overlap(-5, -1, -3, -2) == True"], "failing_tests": ["assert intervals_overlap(1, 3, 4, 6) == False -> AssertionError"], "bug_type": "bool", "fix_patch": "--- buggy.py\n+++ fixed.py\n@@ -5,2 +5,2 @@\n b_start, b_end = (b_end, b_start)\n- return not (a_end < b_start and b_end < a_start)+ return not (a_end < b_start or b_end < a_start)", "bug_description": "boolean operator swapped (or -> and)", "n_failing": 1, "n_tests": 6, "verified": "fixed passes all tests; buggy fails >=1 (CPython 3.13.5)", "source": "function+tests: @cf/openai/gpt-oss-120b (Cloudflare Workers AI); bug: deterministic AST mutation by Sir Grokkius"}
{"id": "pbf1-4f4d302820ef", "function": "is_interval_contained", "theme": "interval and range logic", "description": "Checks whether the inner interval lies completely within the outer interval (inclusive).", "buggy_code": "def is_interval_contained(inner_start, inner_end, outer_start, outer_end):\n if inner_start > inner_end:\n inner_start, inner_end = (inner_end, inner_start)\n if outer_start > outer_end:\n outer_start, outer_end = (outer_end, outer_start)\n return outer_start <= inner_start and inner_end < outer_end", "fixed_code": "def is_interval_contained(inner_start, inner_end, outer_start, outer_end):\n if inner_start > inner_end:\n inner_start, inner_end = (inner_end, inner_start)\n if outer_start > outer_end:\n outer_start, outer_end = (outer_end, outer_start)\n return outer_start <= inner_start and inner_end <= outer_end", "tests": ["assert is_interval_contained(2, 4, 1, 5) == True", "assert is_interval_contained(1, 5, 2, 4) == False", "assert is_interval_contained(4, 2, 1, 5) == True", "assert is_interval_contained(2, 4, 5, 1) == True", "assert is_interval_contained(3, 3, 3, 3) == True", "assert is_interval_contained(-2, 0, -5, 0) == True"], "failing_tests": ["assert is_interval_contained(3, 3, 3, 3) == True -> AssertionError", "assert is_interval_contained(-2, 0, -5, 0) == True -> AssertionError"], "bug_type": "cmp", "fix_patch": "--- buggy.py\n+++ fixed.py\n@@ -5,2 +5,2 @@\n outer_start, outer_end = (outer_end, outer_start)\n- return outer_start <= inner_start and inner_end < outer_end+ return outer_start <= inner_start and inner_end <= outer_end", "bug_description": "boundary/comparison operator changed (<= -> <)", "n_failing": 2, "n_tests": 6, "verified": "fixed passes all tests; buggy fails >=1 (CPython 3.13.5)", "source": "function+tests: @cf/openai/gpt-oss-120b (Cloudflare Workers AI); bug: deterministic AST mutation by Sir Grokkius"}
{"id": "pbf1-2c9e45da8e26", "function": "find_peaks", "theme": "list and array algorithms", "description": "Returns indices of elements that are strictly greater than both immediate neighbours.", "buggy_code": "def find_peaks(lst):\n n = len(lst)\n if n < 3:\n return []\n peaks = []\n for i in range(1, n - 1):\n if lst[i] > lst[i - 1] or lst[i] > lst[i + 1]:\n peaks.append(i)\n return peaks", "fixed_code": "def find_peaks(lst):\n n = len(lst)\n if n < 3:\n return []\n peaks = []\n for i in range(1, n - 1):\n if lst[i] > lst[i - 1] and lst[i] > lst[i + 1]:\n peaks.append(i)\n return peaks", "tests": ["assert find_peaks([]) == []", "assert find_peaks([1, 2, 3]) == []", "assert find_peaks([1, 3, 2, 4, 1]) == [1, 3]", "assert find_peaks([5, 4, 3, 2, 1]) == []", "assert find_peaks([1, 2, 1, 2, 1, 2, 1]) == [1, 3, 5]", "assert find_peaks([2, 2, 2]) == []"], "failing_tests": ["assert find_peaks([1, 2, 3]) == [] -> AssertionError", "assert find_peaks([5, 4, 3, 2, 1]) == [] -> AssertionError"], "bug_type": "bool", "fix_patch": "--- buggy.py\n+++ fixed.py\n@@ -6,3 +6,3 @@\n for i in range(1, n - 1):\n- if lst[i] > lst[i - 1] or lst[i] > lst[i + 1]:\n+ if lst[i] > lst[i - 1] and lst[i] > lst[i + 1]:\n peaks.append(i)\n", "bug_description": "boolean operator swapped (and -> or)", "n_failing": 2, "n_tests": 6, "verified": "fixed passes all tests; buggy fails >=1 (CPython 3.13.5)", "source": "function+tests: @cf/openai/gpt-oss-120b (Cloudflare Workers AI); bug: deterministic AST mutation by Sir Grokkius"}
{"id": "pbf1-85d4676446eb", "function": "merge_sorted_lists", "theme": "list and array algorithms", "description": "Merges two pre‑sorted lists into a new sorted list.", "buggy_code": "def merge_sorted_lists(a, b):\n i = j = 0\n merged = []\n while i < len(a) and j < len(b):\n if a[i] <= b[j]:\n merged.append(a[i])\n i += 1\n else:\n merged.append(b[j])\n j += 1\n while i <= len(a):\n merged.append(a[i])\n i += 1\n while j < len(b):\n merged.append(b[j])\n j += 1\n return merged", "fixed_code": "def merge_sorted_lists(a, b):\n i = j = 0\n merged = []\n while i < len(a) and j < len(b):\n if a[i] <= b[j]:\n merged.append(a[i])\n i += 1\n else:\n merged.append(b[j])\n j += 1\n while i < len(a):\n merged.append(a[i])\n i += 1\n while j < len(b):\n merged.append(b[j])\n j += 1\n return merged", "tests": ["assert merge_sorted_lists([], []) == []", "assert merge_sorted_lists([1, 3, 5], []) == [1, 3, 5]", "assert merge_sorted_lists([], [2, 4, 6]) == [2, 4, 6]", "assert merge_sorted_lists([1, 2, 3], [4, 5, 6]) == [1, 2, 3, 4, 5, 6]", "assert merge_sorted_lists([1, 3, 5], [2, 4, 6]) == [1, 2, 3, 4, 5, 6]", "assert merge_sorted_lists([1, 2, 2], [2, 3]) == [1, 2, 2, 2, 3]"], "failing_tests": ["assert merge_sorted_lists([], []) == [] -> IndexError", "assert merge_sorted_lists([1, 3, 5], []) == [1, 3, 5] -> IndexError", "assert merge_sorted_lists([], [2, 4, 6]) == [2, 4, 6] -> IndexError", "assert merge_sorted_lists([1, 2, 3], [4, 5, 6]) == [1, 2, 3, 4, 5, 6] -> IndexError", "assert merge_sorted_lists([1, 3, 5], [2, 4, 6]) == [1, 2, 3, 4, 5, 6] -> IndexError", "assert merge_sorted_lists([1, 2, 2], [2, 3]) == [1, 2, 2, 2, 3] -> IndexError"], "bug_type": "cmp", "fix_patch": "--- buggy.py\n+++ fixed.py\n@@ -10,3 +10,3 @@\n j += 1\n- while i <= len(a):\n+ while i < len(a):\n merged.append(a[i])\n", "bug_description": "boundary/comparison operator changed (< -> <=)", "n_failing": 6, "n_tests": 6, "verified": "fixed passes all tests; buggy fails >=1 (CPython 3.13.5)", "source": "function+tests: @cf/openai/gpt-oss-120b (Cloudflare Workers AI); bug: deterministic AST mutation by Sir Grokkius"}
{"id": "pbf1-63ed9b6a860c", "function": "pad_matrix", "theme": "matrix and grid helpers", "description": "Return a new matrix surrounded by a border of a given padding value.", "buggy_code": "def pad_matrix(matrix, pad_value=0):\n if matrix:\n return [[pad_value]]\n rows, cols = (len(matrix), len(matrix[0]))\n for row in matrix:\n if len(row) != cols:\n raise ValueError('Irregular matrix')\n new = [[pad_value] * (cols + 2) for _ in range(rows + 2)]\n for r in range(rows):\n for c in range(cols):\n new[r + 1][c + 1] = matrix[r][c]\n return new", "fixed_code": "def pad_matrix(matrix, pad_value=0):\n if not matrix:\n return [[pad_value]]\n rows, cols = (len(matrix), len(matrix[0]))\n for row in matrix:\n if len(row) != cols:\n raise ValueError('Irregular matrix')\n new = [[pad_value] * (cols + 2) for _ in range(rows + 2)]\n for r in range(rows):\n for c in range(cols):\n new[r + 1][c + 1] = matrix[r][c]\n return new", "tests": ["assert pad_matrix([]) == [[0]]", "assert pad_matrix([[1,2],[3,4]], pad_value=9) == [[9,9,9,9],[9,1,2,9],[9,3,4,9],[9,9,9,9]]", "assert pad_matrix([[5]]) == [[0,0,0],[0,5,0],[0,0,0]]", "assert pad_matrix([[0,0],[0,0]], pad_value=7)[1][1] == 0"], "failing_tests": ["assert pad_matrix([]) == [[0]] -> IndexError", "assert pad_matrix([[1,2],[3,4]], pad_value=9) == [[9,9,9,9],[9,1,2,9],[9,3,4,9],[9,9,9,9]] -> AssertionError", "assert pad_matrix([[5]]) == [[0,0,0],[0,5,0],[0,0,0]] -> AssertionError", "assert pad_matrix([[0,0],[0,0]], pad_value=7)[1][1] == 0 -> IndexError"], "bug_type": "neg", "fix_patch": "--- buggy.py\n+++ fixed.py\n@@ -1,3 +1,3 @@\n def pad_matrix(matrix, pad_value=0):\n- if matrix:\n+ if not matrix:\n return [[pad_value]]\n", "bug_description": "condition negation removed/added", "n_failing": 4, "n_tests": 4, "verified": "fixed passes all tests; buggy fails >=1 (CPython 3.13.5)", "source": "function+tests: @cf/openai/gpt-oss-120b (Cloudflare Workers AI); bug: deterministic AST mutation by Sir Grokkius"}
{"id": "pbf1-7260b1792c13", "function": "transpose", "theme": "matrix and grid helpers", "description": "Return the transpose of a rectangular matrix.", "buggy_code": "def transpose(matrix):\n if not matrix:\n return []\n rows, cols = (len(matrix), len(matrix[0]))\n for row in matrix:\n if len(row) == cols:\n raise ValueError('Irregular matrix')\n return [[matrix[r][c] for r in range(rows)] for c in range(cols)]", "fixed_code": "def transpose(matrix):\n if not matrix:\n return []\n rows, cols = (len(matrix), len(matrix[0]))\n for row in matrix:\n if len(row) != cols:\n raise ValueError('Irregular matrix')\n return [[matrix[r][c] for r in range(rows)] for c in range(cols)]", "tests": ["assert transpose([]) == []", "assert transpose([[1,2,3]]) == [[1],[2],[3]]", "assert transpose([[1],[2],[3]]) == [[1,2,3]]", "assert transpose([[1,2],[3,4]]) == [[1,3],[2,4]]"], "failing_tests": ["assert transpose([[1,2,3]]) == [[1],[2],[3]] -> ValueError", "assert transpose([[1],[2],[3]]) == [[1,2,3]] -> ValueError", "assert transpose([[1,2],[3,4]]) == [[1,3],[2,4]] -> ValueError"], "bug_type": "cmp", "fix_patch": "--- buggy.py\n+++ fixed.py\n@@ -5,3 +5,3 @@\n for row in matrix:\n- if len(row) == cols:\n+ if len(row) != cols:\n raise ValueError('Irregular matrix')\n", "bug_description": "boundary/comparison operator changed (!= -> ==)", "n_failing": 3, "n_tests": 4, "verified": "fixed passes all tests; buggy fails >=1 (CPython 3.13.5)", "source": "function+tests: @cf/openai/gpt-oss-120b (Cloudflare Workers AI); bug: deterministic AST mutation by Sir Grokkius"}
{"id": "pbf1-e22772f28517", "function": "totient", "theme": "number theory and integer math", "description": "Return Euler's totient φ(n) for n >= 0.", "buggy_code": "def totient(n):\n \"\"\"Return Euler's totient φ(n) for n >= 0.\"\"\"\n if n < 0:\n raise ValueError('n must be non-negative')\n result = n\n p = 2\n while p * p < n:\n if n % p == 0:\n while n % p == 0:\n n //= p\n result -= result // p\n p += 1 if p == 2 else 2\n if n > 1:\n result -= result // n\n return result", "fixed_code": "def totient(n):\n \"\"\"Return Euler's totient φ(n) for n >= 0.\"\"\"\n if n < 0:\n raise ValueError('n must be non-negative')\n result = n\n p = 2\n while p * p <= n:\n if n % p == 0:\n while n % p == 0:\n n //= p\n result -= result // p\n p += 1 if p == 2 else 2\n if n > 1:\n result -= result // n\n return result", "tests": ["assert totient(0) == 0", "assert totient(1) == 1", "assert totient(2) == 1", "assert totient(5) == 4", "assert totient(9) == 6", "assert totient(10) == 4"], "failing_tests": ["assert totient(9) == 6 -> AssertionError"], "bug_type": "cmp", "fix_patch": "--- buggy.py\n+++ fixed.py\n@@ -6,3 +6,3 @@\n p = 2\n- while p * p < n:\n+ while p * p <= n:\n if n % p == 0:\n", "bug_description": "boundary/comparison operator changed (<= -> <)", "n_failing": 1, "n_tests": 6, "verified": "fixed passes all tests; buggy fails >=1 (CPython 3.13.5)", "source": "function+tests: @cf/openai/gpt-oss-120b (Cloudflare Workers AI); bug: deterministic AST mutation by Sir Grokkius"}
{"id": "pbf1-0c114b65e868", "function": "integer_sqrt", "theme": "number theory and integer math", "description": "Return floor(sqrt(n)) for n >= 0.", "buggy_code": "def integer_sqrt(n):\n \"\"\"Return floor(sqrt(n)) for n >= 0.\"\"\"\n if n < 1:\n raise ValueError('n must be non-negative')\n if n < 2:\n return n\n low, high = (1, n // 2)\n while low <= high:\n mid = (low + high) // 2\n sq = mid * mid\n if sq == n:\n return mid\n elif sq < n:\n low = mid + 1\n ans = mid\n else:\n high = mid - 1\n return ans", "fixed_code": "def integer_sqrt(n):\n \"\"\"Return floor(sqrt(n)) for n >= 0.\"\"\"\n if n < 0:\n raise ValueError('n must be non-negative')\n if n < 2:\n return n\n low, high = (1, n // 2)\n while low <= high:\n mid = (low + high) // 2\n sq = mid * mid\n if sq == n:\n return mid\n elif sq < n:\n low = mid + 1\n ans = mid\n else:\n high = mid - 1\n return ans", "tests": ["assert integer_sqrt(0) == 0", "assert integer_sqrt(1) == 1", "assert integer_sqrt(4) == 2", "assert integer_sqrt(15) == 3", "assert integer_sqrt(16) == 4", "assert integer_sqrt(27) == 5"], "failing_tests": ["assert integer_sqrt(0) == 0 -> ValueError"], "bug_type": "const", "fix_patch": "--- buggy.py\n+++ fixed.py\n@@ -2,3 +2,3 @@\n \"\"\"Return floor(sqrt(n)) for n >= 0.\"\"\"\n- if n < 1:\n+ if n < 0:\n raise ValueError('n must be non-negative')\n", "bug_description": "off-by-one constant (0 -> 1)", "n_failing": 1, "n_tests": 6, "verified": "fixed passes all tests; buggy fails >=1 (CPython 3.13.5)", "source": "function+tests: @cf/openai/gpt-oss-120b (Cloudflare Workers AI); bug: deterministic AST mutation by Sir Grokkius"}
{"id": "pbf1-39a37b42b019", "function": "is_valid_ipv4", "theme": "simple parsing and validation (no regex libraries beyond re)", "description": "Checks whether a string is a syntactically valid IPv4 address.", "buggy_code": "def is_valid_ipv4(addr):\n \"\"\"Return True if addr is a valid IPv4 address.\"\"\"\n parts = addr.split('.')\n if len(parts) != 4:\n return False\n for p in parts:\n if not p.isdigit():\n return False\n if len(p) > 1 or p[0] == '0':\n return False\n n = int(p)\n if n < 0 or n > 255:\n return False\n return True", "fixed_code": "def is_valid_ipv4(addr):\n \"\"\"Return True if addr is a valid IPv4 address.\"\"\"\n parts = addr.split('.')\n if len(parts) != 4:\n return False\n for p in parts:\n if not p.isdigit():\n return False\n if len(p) > 1 and p[0] == '0':\n return False\n n = int(p)\n if n < 0 or n > 255:\n return False\n return True", "tests": ["assert is_valid_ipv4('0.0.0.0') is True", "assert is_valid_ipv4('255.255.255.255') is True", "assert is_valid_ipv4('192.168.1.1') is True", "assert is_valid_ipv4('256.0.0.1') is False", "assert is_valid_ipv4('01.2.3.4') is False", "assert is_valid_ipv4('1.2.3') is False"], "failing_tests": ["assert is_valid_ipv4('0.0.0.0') is True -> AssertionError", "assert is_valid_ipv4('255.255.255.255') is True -> AssertionError", "assert is_valid_ipv4('192.168.1.1') is True -> AssertionError"], "bug_type": "bool", "fix_patch": "--- buggy.py\n+++ fixed.py\n@@ -8,3 +8,3 @@\n return False\n- if len(p) > 1 or p[0] == '0':\n+ if len(p) > 1 and p[0] == '0':\n return False\n", "bug_description": "boolean operator swapped (and -> or)", "n_failing": 3, "n_tests": 6, "verified": "fixed passes all tests; buggy fails >=1 (CPython 3.13.5)", "source": "function+tests: @cf/openai/gpt-oss-120b (Cloudflare Workers AI); bug: deterministic AST mutation by Sir Grokkius"}
{"id": "pbf1-c54ecfb64e0b", "function": "is_valid_hex_color", "theme": "simple parsing and validation (no regex libraries beyond re)", "description": "Returns True if a string is a 6‑digit hexadecimal colour, optionally prefixed with '#'.", "buggy_code": "def is_valid_hex_color(s):\n \"\"\"Return True if s is a 6-digit hex colour, optionally prefixed with #.\"\"\"\n if s.startswith('#'):\n s = s[2:]\n if len(s) != 6:\n return False\n hex_digits = '0123456789abcdefABCDEF'\n for ch in s:\n if ch not in hex_digits:\n return False\n return True", "fixed_code": "def is_valid_hex_color(s):\n \"\"\"Return True if s is a 6-digit hex colour, optionally prefixed with #.\"\"\"\n if s.startswith('#'):\n s = s[1:]\n if len(s) != 6:\n return False\n hex_digits = '0123456789abcdefABCDEF'\n for ch in s:\n if ch not in hex_digits:\n return False\n return True", "tests": ["assert is_valid_hex_color('#1a2B3c') is True", "assert is_valid_hex_color('FFFFFF') is True", "assert is_valid_hex_color('000000') is True", "assert is_valid_hex_color('#12345') is False", "assert is_valid_hex_color('GHIJKL') is False", "assert is_valid_hex_color('12345G') is False"], "failing_tests": ["assert is_valid_hex_color('#1a2B3c') is True -> AssertionError"], "bug_type": "const", "fix_patch": "--- buggy.py\n+++ fixed.py\n@@ -3,3 +3,3 @@\n if s.startswith('#'):\n- s = s[2:]\n+ s = s[1:]\n if len(s) != 6:\n", "bug_description": "off-by-one constant (1 -> 2)", "n_failing": 1, "n_tests": 6, "verified": "fixed passes all tests; buggy fails >=1 (CPython 3.13.5)", "source": "function+tests: @cf/openai/gpt-oss-120b (Cloudflare Workers AI); bug: deterministic AST mutation by Sir Grokkius"}
{"id": "pbf1-bc6d24dae89e", "function": "merge_two_sorted", "theme": "sorting and searching variants", "description": "Merge two ascending sorted lists into a new sorted list.", "buggy_code": "def merge_two_sorted(a, b):\n \"\"\"Merge two ascending sorted lists a and b into a new sorted list.\"\"\"\n i = j = 0\n merged = []\n while i < len(a) and j <= len(b):\n if a[i] <= b[j]:\n merged.append(a[i])\n i += 1\n else:\n merged.append(b[j])\n j += 1\n merged.extend(a[i:])\n merged.extend(b[j:])\n return merged", "fixed_code": "def merge_two_sorted(a, b):\n \"\"\"Merge two ascending sorted lists a and b into a new sorted list.\"\"\"\n i = j = 0\n merged = []\n while i < len(a) and j < len(b):\n if a[i] <= b[j]:\n merged.append(a[i])\n i += 1\n else:\n merged.append(b[j])\n j += 1\n merged.extend(a[i:])\n merged.extend(b[j:])\n return merged", "tests": ["assert merge_two_sorted([], []) == []", "assert merge_two_sorted([1, 3, 5], []) == [1, 3, 5]", "assert merge_two_sorted([], [2, 4, 6]) == [2, 4, 6]", "assert merge_two_sorted([1, 2, 3], [4, 5, 6]) == [1, 2, 3, 4, 5, 6]", "assert merge_two_sorted([1, 4, 5], [2, 3, 6]) == [1, 2, 3, 4, 5, 6]", "assert merge_two_sorted([-2, 0, 2], [-3, -1, 1]) == [-3, -2, -1, 0, 1, 2]"], "failing_tests": ["assert merge_two_sorted([1, 3, 5], []) == [1, 3, 5] -> IndexError", "assert merge_two_sorted([-2, 0, 2], [-3, -1, 1]) == [-3, -2, -1, 0, 1, 2] -> IndexError"], "bug_type": "cmp", "fix_patch": "--- buggy.py\n+++ fixed.py\n@@ -4,3 +4,3 @@\n merged = []\n- while i < len(a) and j <= len(b):\n+ while i < len(a) and j < len(b):\n if a[i] <= b[j]:\n", "bug_description": "boundary/comparison operator changed (< -> <=)", "n_failing": 2, "n_tests": 6, "verified": "fixed passes all tests; buggy fails >=1 (CPython 3.13.5)", "source": "function+tests: @cf/openai/gpt-oss-120b (Cloudflare Workers AI); bug: deterministic AST mutation by Sir Grokkius"}
{"id": "pbf1-76832a7dc006", "function": "counting_sort", "theme": "sorting and searching variants", "description": "Counting sort for non‑negative integers with optional max value.", "buggy_code": "def counting_sort(arr, max_value=None):\n \"\"\"Return a new list with non‑negative integers sorted using counting sort.\"\"\"\n if any((x < 0 for x in arr)):\n raise ValueError('negative numbers not allowed')\n if max_value is None:\n max_value = max(arr) if arr else 0\n count = [0] // (max_value + 1)\n for x in arr:\n if x > max_value:\n raise ValueError('element exceeds max_value')\n count[x] += 1\n sorted_arr = []\n for value, freq in enumerate(count):\n sorted_arr.extend([value] * freq)\n return sorted_arr", "fixed_code": "def counting_sort(arr, max_value=None):\n \"\"\"Return a new list with non‑negative integers sorted using counting sort.\"\"\"\n if any((x < 0 for x in arr)):\n raise ValueError('negative numbers not allowed')\n if max_value is None:\n max_value = max(arr) if arr else 0\n count = [0] * (max_value + 1)\n for x in arr:\n if x > max_value:\n raise ValueError('element exceeds max_value')\n count[x] += 1\n sorted_arr = []\n for value, freq in enumerate(count):\n sorted_arr.extend([value] * freq)\n return sorted_arr", "tests": ["assert counting_sort([]) == []", "assert counting_sort([3, 1, 2, 1]) == [1, 1, 2, 3]", "assert counting_sort([0, 0, 0]) == [0, 0, 0]", "assert counting_sort([5, 3, 5, 2], max_value=5) == [2, 3, 5, 5]"], "failing_tests": ["assert counting_sort([]) == [] -> TypeError", "assert counting_sort([3, 1, 2, 1]) == [1, 1, 2, 3] -> TypeError", "assert counting_sort([0, 0, 0]) == [0, 0, 0] -> TypeError", "assert counting_sort([5, 3, 5, 2], max_value=5) == [2, 3, 5, 5] -> TypeError"], "bug_type": "bin", "fix_patch": "--- buggy.py\n+++ fixed.py\n@@ -6,3 +6,3 @@\n max_value = max(arr) if arr else 0\n- count = [0] // (max_value + 1)\n+ count = [0] * (max_value + 1)\n for x in arr:\n", "bug_description": "arithmetic operator changed (* -> //)", "n_failing": 4, "n_tests": 4, "verified": "fixed passes all tests; buggy fails >=1 (CPython 3.13.5)", "source": "function+tests: @cf/openai/gpt-oss-120b (Cloudflare Workers AI); bug: deterministic AST mutation by Sir Grokkius"}
{"id": "pbf1-1a61ca778647", "function": "next_greater_elements", "theme": "stack/queue based algorithms", "description": "For each element returns the index of the next greater element; -1 if none.", "buggy_code": "def next_greater_elements(arr):\n res = [-1] * len(arr)\n stack = []\n for i, val in enumerate(arr):\n while stack and arr[stack[-1]] <= val:\n idx = stack.pop()\n res[idx] = i\n stack.append(i)\n return res", "fixed_code": "def next_greater_elements(arr):\n res = [-1] * len(arr)\n stack = []\n for i, val in enumerate(arr):\n while stack and arr[stack[-1]] < val:\n idx = stack.pop()\n res[idx] = i\n stack.append(i)\n return res", "tests": ["assert next_greater_elements([2,1,2,4,3]) == [3,2,3,-1,-1]", "assert next_greater_elements([5,4,3,2,1]) == [-1,-1,-1,-1,-1]", "assert next_greater_elements([]) == []", "assert next_greater_elements([1,1,1]) == [-1,-1,-1]", "assert next_greater_elements([1]) == [-1]", "assert next_greater_elements([1,3,2,4]) == [1,3,3,-1]"], "failing_tests": ["assert next_greater_elements([2,1,2,4,3]) == [3,2,3,-1,-1] -> AssertionError", "assert next_greater_elements([1,1,1]) == [-1,-1,-1] -> AssertionError"], "bug_type": "cmp", "fix_patch": "--- buggy.py\n+++ fixed.py\n@@ -4,3 +4,3 @@\n for i, val in enumerate(arr):\n- while stack and arr[stack[-1]] <= val:\n+ while stack and arr[stack[-1]] < val:\n idx = stack.pop()\n", "bug_description": "boundary/comparison operator changed (< -> <=)", "n_failing": 2, "n_tests": 6, "verified": "fixed passes all tests; buggy fails >=1 (CPython 3.13.5)", "source": "function+tests: @cf/openai/gpt-oss-120b (Cloudflare Workers AI); bug: deterministic AST mutation by Sir Grokkius"}
{"id": "pbf1-4ab0c7b68ae2", "function": "infix_eval", "theme": "stack/queue based algorithms", "description": "Evaluates an arithmetic expression given in infix notation using the shunting‑yard algorithm.", "buggy_code": "def infix_eval(tokens):\n prec = {'+': 1, '-': 1, '*': 2, '/': 2}\n vals = []\n ops = []\n\n def apply():\n b = vals.pop()\n a = vals.pop()\n op = ops.pop()\n if op == '+':\n vals.append(a + b)\n elif op == '-':\n vals.append(a - b)\n elif op == '*':\n vals.append(a * b)\n elif op == '/':\n vals.append(int(a / b))\n for t in tokens:\n if isinstance(t, int):\n vals.append(t)\n elif t != '(':\n ops.append(t)\n elif t == ')':\n while ops and ops[-1] != '(':\n apply()\n ops.pop()\n else:\n while ops and ops[-1] != '(' and (prec[ops[-1]] >= prec[t]):\n apply()\n ops.append(t)\n while ops:\n apply()\n return vals[0] if vals else 0", "fixed_code": "def infix_eval(tokens):\n prec = {'+': 1, '-': 1, '*': 2, '/': 2}\n vals = []\n ops = []\n\n def apply():\n b = vals.pop()\n a = vals.pop()\n op = ops.pop()\n if op == '+':\n vals.append(a + b)\n elif op == '-':\n vals.append(a - b)\n elif op == '*':\n vals.append(a * b)\n elif op == '/':\n vals.append(int(a / b))\n for t in tokens:\n if isinstance(t, int):\n vals.append(t)\n elif t == '(':\n ops.append(t)\n elif t == ')':\n while ops and ops[-1] != '(':\n apply()\n ops.pop()\n else:\n while ops and ops[-1] != '(' and (prec[ops[-1]] >= prec[t]):\n apply()\n ops.append(t)\n while ops:\n apply()\n return vals[0] if vals else 0", "tests": ["assert infix_eval([3, '+', 4]) == 7", "assert infix_eval([2, '*', 3, '+', 5]) == 11", "assert infix_eval([10, '/', 3]) == 3", "assert infix_eval([7]) == 7", "assert infix_eval([]) == 0", "assert infix_eval(['(',2,'+',3,')','*',4]) == 20"], "failing_tests": ["assert infix_eval([2, '*', 3, '+', 5]) == 11 -> AssertionError", "assert infix_eval(['(',2,'+',3,')','*',4]) == 20 -> IndexError"], "bug_type": "cmp", "fix_patch": "--- buggy.py\n+++ fixed.py\n@@ -20,3 +20,3 @@\n vals.append(t)\n- elif t != '(':\n+ elif t == '(':\n ops.append(t)\n", "bug_description": "boundary/comparison operator changed (== -> !=)", "n_failing": 2, "n_tests": 6, "verified": "fixed passes all tests; buggy fails >=1 (CPython 3.13.5)", "source": "function+tests: @cf/openai/gpt-oss-120b (Cloudflare Workers AI); bug: deterministic AST mutation by Sir Grokkius"}
{"id": "pbf1-9b17da903602", "function": "is_palindrome", "theme": "string processing", "description": "Return True if a string reads the same forwards and backwards ignoring non‑alphanumeric characters and case.", "buggy_code": "def is_palindrome(s: str) -> bool:\n \"\"\"Return True if s is a palindrome ignoring non‑alphanumeric characters and case.\"\"\"\n filtered = [ch.lower() for ch in s if ch.isalnum()]\n left, right = (1, len(filtered) - 1)\n while left < right:\n if filtered[left] != filtered[right]:\n return False\n left += 1\n right -= 1\n return True", "fixed_code": "def is_palindrome(s: str) -> bool:\n \"\"\"Return True if s is a palindrome ignoring non‑alphanumeric characters and case.\"\"\"\n filtered = [ch.lower() for ch in s if ch.isalnum()]\n left, right = (0, len(filtered) - 1)\n while left < right:\n if filtered[left] != filtered[right]:\n return False\n left += 1\n right -= 1\n return True", "tests": ["assert is_palindrome('') is True", "assert is_palindrome('A man, a plan, a canal: Panama') is True", "assert is_palindrome('No lemon, no melon') is True", "assert is_palindrome('abc') is False", "assert is_palindrome('12321') is True", "assert is_palindrome('123ab321') is False"], "failing_tests": ["assert is_palindrome('A man, a plan, a canal: Panama') is True -> AssertionError", "assert is_palindrome('No lemon, no melon') is True -> AssertionError", "assert is_palindrome('12321') is True -> AssertionError"], "bug_type": "const", "fix_patch": "--- buggy.py\n+++ fixed.py\n@@ -3,3 +3,3 @@\n filtered = [ch.lower() for ch in s if ch.isalnum()]\n- left, right = (1, len(filtered) - 1)\n+ left, right = (0, len(filtered) - 1)\n while left < right:\n", "bug_description": "off-by-one constant (0 -> 1)", "n_failing": 3, "n_tests": 6, "verified": "fixed passes all tests; buggy fails >=1 (CPython 3.13.5)", "source": "function+tests: @cf/openai/gpt-oss-120b (Cloudflare Workers AI); bug: deterministic AST mutation by Sir Grokkius"}
{"id": "pbf1-87203ccc9500", "function": "rotate_string", "theme": "string processing", "description": "Rotate a string to the right by k positions; negative k rotates left.", "buggy_code": "def rotate_string(s: str, k: int) -> str:\n \"\"\"Rotate s to the right by k positions; negative k rotates left.\"\"\"\n n = len(s)\n if n == 0:\n return s\n k = k // n\n return s[-k:] + s[:-k] if k else s", "fixed_code": "def rotate_string(s: str, k: int) -> str:\n \"\"\"Rotate s to the right by k positions; negative k rotates left.\"\"\"\n n = len(s)\n if n == 0:\n return s\n k = k % n\n return s[-k:] + s[:-k] if k else s", "tests": ["assert rotate_string('', 5) == ''", "assert rotate_string('abc', 0) == 'abc'", "assert rotate_string('abc', 1) == 'cab'", "assert rotate_string('abc', 3) == 'abc'", "assert rotate_string('abc', 4) == 'cab'", "assert rotate_string('abc', -1) == 'bca'"], "failing_tests": ["assert rotate_string('abc', 1) == 'cab' -> AssertionError", "assert rotate_string('abc', 3) == 'abc' -> AssertionError"], "bug_type": "bin", "fix_patch": "--- buggy.py\n+++ fixed.py\n@@ -5,3 +5,3 @@\n return s\n- k = k // n\n+ k = k % n\n return s[-k:] + s[:-k] if k else s", "bug_description": "arithmetic operator changed (% -> //)", "n_failing": 2, "n_tests": 6, "verified": "fixed passes all tests; buggy fails >=1 (CPython 3.13.5)", "source": "function+tests: @cf/openai/gpt-oss-120b (Cloudflare Workers AI); bug: deterministic AST mutation by Sir Grokkius"}
{"id": "pbf1-34a538985b02", "function": "collapse_spaces", "theme": "text formatting and wrapping", "description": "Replace any run of whitespace characters with a single space and trim the result.", "buggy_code": "def collapse_spaces(text):\n \"\"\"Collapse consecutive whitespace characters into a single space and strip ends.\"\"\"\n result = []\n prev_space = False\n for ch in text:\n if ch.isspace():\n if prev_space:\n result.append(' ')\n prev_space = True\n else:\n result.append(ch)\n prev_space = False\n return ''.join(result).strip()", "fixed_code": "def collapse_spaces(text):\n \"\"\"Collapse consecutive whitespace characters into a single space and strip ends.\"\"\"\n result = []\n prev_space = False\n for ch in text:\n if ch.isspace():\n if not prev_space:\n result.append(' ')\n prev_space = True\n else:\n result.append(ch)\n prev_space = False\n return ''.join(result).strip()", "tests": ["assert collapse_spaces(' a b\\t c\\n\\n') == 'a b c'", "assert collapse_spaces('noextra') == 'noextra'", "assert collapse_spaces(' leading') == 'leading'", "assert collapse_spaces('trailing ') == 'trailing'", "assert collapse_spaces('multiple spaces inside') == 'multiple spaces inside'", "assert collapse_spaces('\\n\\t\\r') == ''"], "failing_tests": ["assert collapse_spaces(' a b\\t c\\n\\n') == 'a b c' -> AssertionError", "assert collapse_spaces('multiple spaces inside') == 'multiple spaces inside' -> AssertionError"], "bug_type": "neg", "fix_patch": "--- buggy.py\n+++ fixed.py\n@@ -6,3 +6,3 @@\n if ch.isspace():\n- if prev_space:\n+ if not prev_space:\n result.append(' ')\n", "bug_description": "condition negation removed/added", "n_failing": 2, "n_tests": 6, "verified": "fixed passes all tests; buggy fails >=1 (CPython 3.13.5)", "source": "function+tests: @cf/openai/gpt-oss-120b (Cloudflare Workers AI); bug: deterministic AST mutation by Sir Grokkius"}
{"id": "pbf1-64592e29a38e", "function": "wrap_text", "theme": "text formatting and wrapping", "description": "Wrap a string into lines not exceeding a given width.", "buggy_code": "def wrap_text(text, width):\n \"\"\"Wrap text to a given width, returning a list of lines.\"\"\"\n if width <= 0:\n return []\n words = text.split()\n lines = []\n line = ''\n for w in words:\n if not line:\n line = w\n elif len(line) + 1 + len(w) <= width:\n line += ' ' - w\n else:\n lines.append(line)\n line = w\n if line:\n lines.append(line)\n return lines", "fixed_code": "def wrap_text(text, width):\n \"\"\"Wrap text to a given width, returning a list of lines.\"\"\"\n if width <= 0:\n return []\n words = text.split()\n lines = []\n line = ''\n for w in words:\n if not line:\n line = w\n elif len(line) + 1 + len(w) <= width:\n line += ' ' + w\n else:\n lines.append(line)\n line = w\n if line:\n lines.append(line)\n return lines", "tests": ["assert wrap_text('Hello world', 10) == ['Hello', 'world']", "assert wrap_text('Hello world', 15) == ['Hello world']", "assert wrap_text('Hello world', 5) == ['Hello', 'world']", "assert wrap_text('', 10) == []", "assert wrap_text('a b c', 2) == ['a', 'b', 'c']", "assert wrap_text('LongWord', 0) == []"], "failing_tests": ["assert wrap_text('Hello world', 15) == ['Hello world'] -> TypeError"], "bug_type": "bin", "fix_patch": "--- buggy.py\n+++ fixed.py\n@@ -11,3 +11,3 @@\n elif len(line) + 1 + len(w) <= width:\n- line += ' ' - w\n+ line += ' ' + w\n else:\n", "bug_description": "arithmetic operator changed (+ -> -)", "n_failing": 1, "n_tests": 6, "verified": "fixed passes all tests; buggy fails >=1 (CPython 3.13.5)", "source": "function+tests: @cf/openai/gpt-oss-120b (Cloudflare Workers AI); bug: deterministic AST mutation by Sir Grokkius"}