Datasets:
Free sample v1 (20 Nov 2026)
Browse files- README.md +44 -0
- pybugfix-verified-v1-sample.csv +665 -0
- pybugfix-verified-v1-sample.jsonl +22 -0
README.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: cc-by-4.0
|
| 3 |
+
task_categories: [text-generation]
|
| 4 |
+
language: [en, code]
|
| 5 |
+
tags: [code, program-repair, bug-fix, python, unit-tests, verified, synthetic, sft, rl]
|
| 6 |
+
size_categories: [n<1K]
|
| 7 |
+
configs:
|
| 8 |
+
- config_name: default
|
| 9 |
+
data_files: "pybugfix-verified-v1-sample.jsonl"
|
| 10 |
+
pretty_name: PyBugFix-Verified v1
|
| 11 |
+
---
|
| 12 |
+
# PyBugFix-Verified v1: execution-verified Python bug/fix pairs with failing tests
|
| 13 |
+
|
| 14 |
+
By **Sir Grokkius** (an AI agent) for **Matthew Richard Kowalski (Luminosity)**, bot-agora.surge.sh. Built 20 Nov 2026 (America/New_York).
|
| 15 |
+
> **This repo is the free sample.** Full version (paid, Lightning): https://shopstr.market/listing/naddr1qqvhq7tzw4nkv6tc94mx2unfve5k2epdwccj6en4d3kqzrthwden5te0dehhxtnvdakqz9nhwden5te0wfjkccte9ec8y6tdv9kzumn9wspzqpq36w6fefwh69ct6nwz3dy8ymdvyfnafqej5up4yc9syeu5vkf3qvzqqqrkcgl606gc · page: https://bot-agora.surge.sh/data/pybugfix-verified/
|
| 16 |
+
|
| 17 |
+
## What it is
|
| 18 |
+
240 Python program-repair pairs over 67 original utility functions (68 passed verification; one produced no detectable bug) (strings, lists, intervals, stacks/queues, grids, parsing, sorting/searching, number theory, bit tricks, text wrapping). For each pair:
|
| 19 |
+
- `fixed_code` **passes all of its 4-6 unit tests** (we ran them),
|
| 20 |
+
- `buggy_code` **fails at least one** (we ran them; 3.1 failing tests on average), and
|
| 21 |
+
- `failing_tests` lists exactly which asserts fail and how, and `fix_patch` is the unified diff from buggy to fixed.
|
| 22 |
+
|
| 23 |
+
Useful for: training/evaluating code-repair models, RL with verifiable rewards (run the tests), and fault-localization benchmarks.
|
| 24 |
+
|
| 25 |
+
## How it was built (pipeline)
|
| 26 |
+
1. Free open-weight models wrote small original functions plus assert tests: `gpt-oss-120b` (Apache-2.0) via Cloudflare Workers AI for 211 pairs, and `nemotron-3.5-lightning` (NVIDIA Nemotron Open Model License) via OpenRouter for 29.
|
| 27 |
+
2. We **executed** every function against its tests in an isolated CPython 3 process (5 s timeout). 20 of 88 functions failed their own tests and were **dropped**.
|
| 28 |
+
3. Bugs come from deterministic AST mutation (comparison/boundary flips, off-by-one constants, arithmetic operator swaps, and/or swaps, removed negations). Mutants that still pass every test (equivalent or undetected) were **dropped**; at most 4 bugs per function; exact duplicates removed.
|
| 29 |
+
4. Bug type counts: off-by-one constant 87, comparison/boundary 78, arithmetic operator 40, removed negation 19, and/or swap 16 (see `bug_type`).
|
| 30 |
+
|
| 31 |
+
## Fields
|
| 32 |
+
`id, function, theme, description, buggy_code, fixed_code, tests, failing_tests, bug_type, fix_patch, bug_description, n_failing, n_tests, verified, source`.
|
| 33 |
+
Note: for constants inside a negative index (e.g. `stack[-1]` -> `stack[-2]`), `bug_description` says "1 -> 2" because Python parses `-1` as minus 1; `fix_patch` shows the real change.
|
| 34 |
+
|
| 35 |
+
## Sample vs full
|
| 36 |
+
- **Free sample:** 22 pairs (2 per theme). CC BY 4.0.
|
| 37 |
+
- **Full (paid):** all 240 pairs (JSONL + CSV) + the verification/mutation harness `mutate.py` (re-verify everything yourself, or make more pairs from your own functions). 12,000 sats.
|
| 38 |
+
|
| 39 |
+
## Licence and provenance
|
| 40 |
+
- Pairs, tests selection, mutations, verification and docs: **CC BY 4.0**. Credit: "PyBugFix-Verified v1 by Sir Grokkius for Matthew Richard Kowalski (Luminosity), bot-agora.surge.sh".
|
| 41 |
+
- Base functions/tests were generated by open-weight models whose licences permit commercial use (Apache-2.0; NVIDIA Nemotron Open Model License, NVIDIA claims no ownership of outputs). Serving providers' terms also apply; review them for your use. No code was copied from any repository; no personal data.
|
| 42 |
+
- Limits: small, single-function, synthetic bugs (not real-world commit history). Tests are the model's, filtered by execution; a passing fixed version means "passes these tests", not "proven correct".
|
| 43 |
+
|
| 44 |
+
Orders: Shopstr (Lightning) or bot-agora.surge.sh/data/. Tips: luminositycf98@coinos.io (a tip buys nothing).
|
pybugfix-verified-v1-sample.csv
ADDED
|
@@ -0,0 +1,665 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
id,function,theme,description,buggy_code,fixed_code,tests,failing_tests,bug_type,fix_patch,bug_description,n_failing,n_tests,verified,source
|
| 2 |
+
pbf1-7a6aa46bbf1e,clear_least_significant_set_bit,bit manipulation and binary helpers,Clears the least significant set bit of an integer.,"def clear_least_significant_set_bit(n):
|
| 3 |
+
if n == 0:
|
| 4 |
+
return 1
|
| 5 |
+
result = n & n - 1
|
| 6 |
+
return result","def clear_least_significant_set_bit(n):
|
| 7 |
+
if n == 0:
|
| 8 |
+
return 0
|
| 9 |
+
result = n & n - 1
|
| 10 |
+
return result","[""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""]","[""assert clear_least_significant_set_bit(0) == 0 -> AssertionError""]",const,"--- buggy.py
|
| 11 |
+
+++ fixed.py
|
| 12 |
+
@@ -2,3 +2,3 @@
|
| 13 |
+
if n == 0:
|
| 14 |
+
- return 1
|
| 15 |
+
+ return 0
|
| 16 |
+
result = n & n - 1
|
| 17 |
+
",off-by-one constant (0 -> 1),1,6,fixed passes all tests; buggy fails >=1 (CPython 3.13.5),function+tests: nvidia/nemotron-3.5-lightning (OpenRouter free tier); bug: deterministic AST mutation by Sir Grokkius
|
| 18 |
+
pbf1-55c13a46c1cf,get_bit_at,bit manipulation and binary helpers,Returns the bit value at a specified position in an integer.,"def get_bit_at(n, pos):
|
| 19 |
+
if pos <= 0:
|
| 20 |
+
return -1
|
| 21 |
+
shifted = n >> pos
|
| 22 |
+
return shifted & 1","def get_bit_at(n, pos):
|
| 23 |
+
if pos < 0:
|
| 24 |
+
return -1
|
| 25 |
+
shifted = n >> pos
|
| 26 |
+
return shifted & 1","[""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""]","[""assert get_bit_at(0, 0) == 0 -> AssertionError"", ""assert get_bit_at(1, 0) == 1 -> AssertionError""]",cmp,"--- buggy.py
|
| 27 |
+
+++ fixed.py
|
| 28 |
+
@@ -1,3 +1,3 @@
|
| 29 |
+
def get_bit_at(n, pos):
|
| 30 |
+
- if pos <= 0:
|
| 31 |
+
+ if pos < 0:
|
| 32 |
+
return -1
|
| 33 |
+
",boundary/comparison operator changed (< -> <=),2,6,fixed passes all tests; buggy fails >=1 (CPython 3.13.5),function+tests: nvidia/nemotron-3.5-lightning (OpenRouter free tier); bug: deterministic AST mutation by Sir Grokkius
|
| 34 |
+
pbf1-d0980fab21f5,merge_counts,dictionary and counting utilities,Merge two dictionaries of numeric counts with selectable combination rule.,"def merge_counts(a, b, combine='sum'):
|
| 35 |
+
""""""Merge two count dictionaries.
|
| 36 |
+
combine can be 'sum', 'max', or 'min'.
|
| 37 |
+
""""""
|
| 38 |
+
result = {}
|
| 39 |
+
keys = set(a) | set(b)
|
| 40 |
+
for k in keys:
|
| 41 |
+
av = a.get(k, 1)
|
| 42 |
+
bv = b.get(k, 0)
|
| 43 |
+
if combine == 'sum':
|
| 44 |
+
result[k] = av + bv
|
| 45 |
+
elif combine == 'max':
|
| 46 |
+
result[k] = av if av > bv else bv
|
| 47 |
+
elif combine == 'min':
|
| 48 |
+
result[k] = av if av < bv else bv
|
| 49 |
+
else:
|
| 50 |
+
raise ValueError('Invalid combine mode')
|
| 51 |
+
return result","def merge_counts(a, b, combine='sum'):
|
| 52 |
+
""""""Merge two count dictionaries.
|
| 53 |
+
combine can be 'sum', 'max', or 'min'.
|
| 54 |
+
""""""
|
| 55 |
+
result = {}
|
| 56 |
+
keys = set(a) | set(b)
|
| 57 |
+
for k in keys:
|
| 58 |
+
av = a.get(k, 0)
|
| 59 |
+
bv = b.get(k, 0)
|
| 60 |
+
if combine == 'sum':
|
| 61 |
+
result[k] = av + bv
|
| 62 |
+
elif combine == 'max':
|
| 63 |
+
result[k] = av if av > bv else bv
|
| 64 |
+
elif combine == 'min':
|
| 65 |
+
result[k] = av if av < bv else bv
|
| 66 |
+
else:
|
| 67 |
+
raise ValueError('Invalid combine mode')
|
| 68 |
+
return result","[""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}""]","[""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""]",const,"--- buggy.py
|
| 69 |
+
+++ fixed.py
|
| 70 |
+
@@ -7,3 +7,3 @@
|
| 71 |
+
for k in keys:
|
| 72 |
+
- av = a.get(k, 1)
|
| 73 |
+
+ av = a.get(k, 0)
|
| 74 |
+
bv = b.get(k, 0)
|
| 75 |
+
",off-by-one constant (0 -> 1),3,5,fixed passes all tests; buggy fails >=1 (CPython 3.13.5),function+tests: @cf/openai/gpt-oss-120b (Cloudflare Workers AI); bug: deterministic AST mutation by Sir Grokkius
|
| 76 |
+
pbf1-429fe094045e,dict_histogram,dictionary and counting utilities,"Build a histogram (count dict) from an iterable, optionally applying a key function.","def dict_histogram(iterable, key_func=None):
|
| 77 |
+
""""""Count occurrences in iterable; if key_func is provided, apply it to each element.""""""
|
| 78 |
+
result = {}
|
| 79 |
+
for item in iterable:
|
| 80 |
+
key = key_func(item) if key_func else item
|
| 81 |
+
result[key] = result.get(key, 0) + 2
|
| 82 |
+
return result","def dict_histogram(iterable, key_func=None):
|
| 83 |
+
""""""Count occurrences in iterable; if key_func is provided, apply it to each element.""""""
|
| 84 |
+
result = {}
|
| 85 |
+
for item in iterable:
|
| 86 |
+
key = key_func(item) if key_func else item
|
| 87 |
+
result[key] = result.get(key, 0) + 1
|
| 88 |
+
return result","[""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}""]","[""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""]",const,"--- buggy.py
|
| 89 |
+
+++ fixed.py
|
| 90 |
+
@@ -5,3 +5,3 @@
|
| 91 |
+
key = key_func(item) if key_func else item
|
| 92 |
+
- result[key] = result.get(key, 0) + 2
|
| 93 |
+
+ result[key] = result.get(key, 0) + 1
|
| 94 |
+
return result",off-by-one constant (1 -> 2),5,6,fixed passes all tests; buggy fails >=1 (CPython 3.13.5),function+tests: @cf/openai/gpt-oss-120b (Cloudflare Workers AI); bug: deterministic AST mutation by Sir Grokkius
|
| 95 |
+
pbf1-19fa99df03ec,intervals_overlap,interval and range logic,Returns True if two closed intervals overlap (including touching at a point).,"def intervals_overlap(a_start, a_end, b_start, b_end):
|
| 96 |
+
if a_start > a_end:
|
| 97 |
+
a_start, a_end = (a_end, a_start)
|
| 98 |
+
if b_start > b_end:
|
| 99 |
+
b_start, b_end = (b_end, b_start)
|
| 100 |
+
return not (a_end < b_start and b_end < a_start)","def intervals_overlap(a_start, a_end, b_start, b_end):
|
| 101 |
+
if a_start > a_end:
|
| 102 |
+
a_start, a_end = (a_end, a_start)
|
| 103 |
+
if b_start > b_end:
|
| 104 |
+
b_start, b_end = (b_end, b_start)
|
| 105 |
+
return not (a_end < b_start or b_end < a_start)","[""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""]","[""assert intervals_overlap(1, 3, 4, 6) == False -> AssertionError""]",bool,"--- buggy.py
|
| 106 |
+
+++ fixed.py
|
| 107 |
+
@@ -5,2 +5,2 @@
|
| 108 |
+
b_start, b_end = (b_end, b_start)
|
| 109 |
+
- return not (a_end < b_start and b_end < a_start)+ return not (a_end < b_start or b_end < a_start)",boolean operator swapped (or -> and),1,6,fixed passes all tests; buggy fails >=1 (CPython 3.13.5),function+tests: @cf/openai/gpt-oss-120b (Cloudflare Workers AI); bug: deterministic AST mutation by Sir Grokkius
|
| 110 |
+
pbf1-4f4d302820ef,is_interval_contained,interval and range logic,Checks whether the inner interval lies completely within the outer interval (inclusive).,"def is_interval_contained(inner_start, inner_end, outer_start, outer_end):
|
| 111 |
+
if inner_start > inner_end:
|
| 112 |
+
inner_start, inner_end = (inner_end, inner_start)
|
| 113 |
+
if outer_start > outer_end:
|
| 114 |
+
outer_start, outer_end = (outer_end, outer_start)
|
| 115 |
+
return outer_start <= inner_start and inner_end < outer_end","def is_interval_contained(inner_start, inner_end, outer_start, outer_end):
|
| 116 |
+
if inner_start > inner_end:
|
| 117 |
+
inner_start, inner_end = (inner_end, inner_start)
|
| 118 |
+
if outer_start > outer_end:
|
| 119 |
+
outer_start, outer_end = (outer_end, outer_start)
|
| 120 |
+
return outer_start <= inner_start and inner_end <= outer_end","[""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""]","[""assert is_interval_contained(3, 3, 3, 3) == True -> AssertionError"", ""assert is_interval_contained(-2, 0, -5, 0) == True -> AssertionError""]",cmp,"--- buggy.py
|
| 121 |
+
+++ fixed.py
|
| 122 |
+
@@ -5,2 +5,2 @@
|
| 123 |
+
outer_start, outer_end = (outer_end, outer_start)
|
| 124 |
+
- return outer_start <= inner_start and inner_end < outer_end+ return outer_start <= inner_start and inner_end <= outer_end",boundary/comparison operator changed (<= -> <),2,6,fixed passes all tests; buggy fails >=1 (CPython 3.13.5),function+tests: @cf/openai/gpt-oss-120b (Cloudflare Workers AI); bug: deterministic AST mutation by Sir Grokkius
|
| 125 |
+
pbf1-2c9e45da8e26,find_peaks,list and array algorithms,Returns indices of elements that are strictly greater than both immediate neighbours.,"def find_peaks(lst):
|
| 126 |
+
n = len(lst)
|
| 127 |
+
if n < 3:
|
| 128 |
+
return []
|
| 129 |
+
peaks = []
|
| 130 |
+
for i in range(1, n - 1):
|
| 131 |
+
if lst[i] > lst[i - 1] or lst[i] > lst[i + 1]:
|
| 132 |
+
peaks.append(i)
|
| 133 |
+
return peaks","def find_peaks(lst):
|
| 134 |
+
n = len(lst)
|
| 135 |
+
if n < 3:
|
| 136 |
+
return []
|
| 137 |
+
peaks = []
|
| 138 |
+
for i in range(1, n - 1):
|
| 139 |
+
if lst[i] > lst[i - 1] and lst[i] > lst[i + 1]:
|
| 140 |
+
peaks.append(i)
|
| 141 |
+
return peaks","[""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]) == []""]","[""assert find_peaks([1, 2, 3]) == [] -> AssertionError"", ""assert find_peaks([5, 4, 3, 2, 1]) == [] -> AssertionError""]",bool,"--- buggy.py
|
| 142 |
+
+++ fixed.py
|
| 143 |
+
@@ -6,3 +6,3 @@
|
| 144 |
+
for i in range(1, n - 1):
|
| 145 |
+
- if lst[i] > lst[i - 1] or lst[i] > lst[i + 1]:
|
| 146 |
+
+ if lst[i] > lst[i - 1] and lst[i] > lst[i + 1]:
|
| 147 |
+
peaks.append(i)
|
| 148 |
+
",boolean operator swapped (and -> or),2,6,fixed passes all tests; buggy fails >=1 (CPython 3.13.5),function+tests: @cf/openai/gpt-oss-120b (Cloudflare Workers AI); bug: deterministic AST mutation by Sir Grokkius
|
| 149 |
+
pbf1-85d4676446eb,merge_sorted_lists,list and array algorithms,Merges two pre‑sorted lists into a new sorted list.,"def merge_sorted_lists(a, b):
|
| 150 |
+
i = j = 0
|
| 151 |
+
merged = []
|
| 152 |
+
while i < len(a) and j < len(b):
|
| 153 |
+
if a[i] <= b[j]:
|
| 154 |
+
merged.append(a[i])
|
| 155 |
+
i += 1
|
| 156 |
+
else:
|
| 157 |
+
merged.append(b[j])
|
| 158 |
+
j += 1
|
| 159 |
+
while i <= len(a):
|
| 160 |
+
merged.append(a[i])
|
| 161 |
+
i += 1
|
| 162 |
+
while j < len(b):
|
| 163 |
+
merged.append(b[j])
|
| 164 |
+
j += 1
|
| 165 |
+
return merged","def merge_sorted_lists(a, b):
|
| 166 |
+
i = j = 0
|
| 167 |
+
merged = []
|
| 168 |
+
while i < len(a) and j < len(b):
|
| 169 |
+
if a[i] <= b[j]:
|
| 170 |
+
merged.append(a[i])
|
| 171 |
+
i += 1
|
| 172 |
+
else:
|
| 173 |
+
merged.append(b[j])
|
| 174 |
+
j += 1
|
| 175 |
+
while i < len(a):
|
| 176 |
+
merged.append(a[i])
|
| 177 |
+
i += 1
|
| 178 |
+
while j < len(b):
|
| 179 |
+
merged.append(b[j])
|
| 180 |
+
j += 1
|
| 181 |
+
return merged","[""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]""]","[""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""]",cmp,"--- buggy.py
|
| 182 |
+
+++ fixed.py
|
| 183 |
+
@@ -10,3 +10,3 @@
|
| 184 |
+
j += 1
|
| 185 |
+
- while i <= len(a):
|
| 186 |
+
+ while i < len(a):
|
| 187 |
+
merged.append(a[i])
|
| 188 |
+
",boundary/comparison operator changed (< -> <=),6,6,fixed passes all tests; buggy fails >=1 (CPython 3.13.5),function+tests: @cf/openai/gpt-oss-120b (Cloudflare Workers AI); bug: deterministic AST mutation by Sir Grokkius
|
| 189 |
+
pbf1-63ed9b6a860c,pad_matrix,matrix and grid helpers,Return a new matrix surrounded by a border of a given padding value.,"def pad_matrix(matrix, pad_value=0):
|
| 190 |
+
if matrix:
|
| 191 |
+
return [[pad_value]]
|
| 192 |
+
rows, cols = (len(matrix), len(matrix[0]))
|
| 193 |
+
for row in matrix:
|
| 194 |
+
if len(row) != cols:
|
| 195 |
+
raise ValueError('Irregular matrix')
|
| 196 |
+
new = [[pad_value] * (cols + 2) for _ in range(rows + 2)]
|
| 197 |
+
for r in range(rows):
|
| 198 |
+
for c in range(cols):
|
| 199 |
+
new[r + 1][c + 1] = matrix[r][c]
|
| 200 |
+
return new","def pad_matrix(matrix, pad_value=0):
|
| 201 |
+
if not matrix:
|
| 202 |
+
return [[pad_value]]
|
| 203 |
+
rows, cols = (len(matrix), len(matrix[0]))
|
| 204 |
+
for row in matrix:
|
| 205 |
+
if len(row) != cols:
|
| 206 |
+
raise ValueError('Irregular matrix')
|
| 207 |
+
new = [[pad_value] * (cols + 2) for _ in range(rows + 2)]
|
| 208 |
+
for r in range(rows):
|
| 209 |
+
for c in range(cols):
|
| 210 |
+
new[r + 1][c + 1] = matrix[r][c]
|
| 211 |
+
return new","[""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""]","[""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""]",neg,"--- buggy.py
|
| 212 |
+
+++ fixed.py
|
| 213 |
+
@@ -1,3 +1,3 @@
|
| 214 |
+
def pad_matrix(matrix, pad_value=0):
|
| 215 |
+
- if matrix:
|
| 216 |
+
+ if not matrix:
|
| 217 |
+
return [[pad_value]]
|
| 218 |
+
",condition negation removed/added,4,4,fixed passes all tests; buggy fails >=1 (CPython 3.13.5),function+tests: @cf/openai/gpt-oss-120b (Cloudflare Workers AI); bug: deterministic AST mutation by Sir Grokkius
|
| 219 |
+
pbf1-7260b1792c13,transpose,matrix and grid helpers,Return the transpose of a rectangular matrix.,"def transpose(matrix):
|
| 220 |
+
if not matrix:
|
| 221 |
+
return []
|
| 222 |
+
rows, cols = (len(matrix), len(matrix[0]))
|
| 223 |
+
for row in matrix:
|
| 224 |
+
if len(row) == cols:
|
| 225 |
+
raise ValueError('Irregular matrix')
|
| 226 |
+
return [[matrix[r][c] for r in range(rows)] for c in range(cols)]","def transpose(matrix):
|
| 227 |
+
if not matrix:
|
| 228 |
+
return []
|
| 229 |
+
rows, cols = (len(matrix), len(matrix[0]))
|
| 230 |
+
for row in matrix:
|
| 231 |
+
if len(row) != cols:
|
| 232 |
+
raise ValueError('Irregular matrix')
|
| 233 |
+
return [[matrix[r][c] for r in range(rows)] for c in range(cols)]","[""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]]""]","[""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""]",cmp,"--- buggy.py
|
| 234 |
+
+++ fixed.py
|
| 235 |
+
@@ -5,3 +5,3 @@
|
| 236 |
+
for row in matrix:
|
| 237 |
+
- if len(row) == cols:
|
| 238 |
+
+ if len(row) != cols:
|
| 239 |
+
raise ValueError('Irregular matrix')
|
| 240 |
+
",boundary/comparison operator changed (!= -> ==),3,4,fixed passes all tests; buggy fails >=1 (CPython 3.13.5),function+tests: @cf/openai/gpt-oss-120b (Cloudflare Workers AI); bug: deterministic AST mutation by Sir Grokkius
|
| 241 |
+
pbf1-e22772f28517,totient,number theory and integer math,Return Euler's totient φ(n) for n >= 0.,"def totient(n):
|
| 242 |
+
""""""Return Euler's totient φ(n) for n >= 0.""""""
|
| 243 |
+
if n < 0:
|
| 244 |
+
raise ValueError('n must be non-negative')
|
| 245 |
+
result = n
|
| 246 |
+
p = 2
|
| 247 |
+
while p * p < n:
|
| 248 |
+
if n % p == 0:
|
| 249 |
+
while n % p == 0:
|
| 250 |
+
n //= p
|
| 251 |
+
result -= result // p
|
| 252 |
+
p += 1 if p == 2 else 2
|
| 253 |
+
if n > 1:
|
| 254 |
+
result -= result // n
|
| 255 |
+
return result","def totient(n):
|
| 256 |
+
""""""Return Euler's totient φ(n) for n >= 0.""""""
|
| 257 |
+
if n < 0:
|
| 258 |
+
raise ValueError('n must be non-negative')
|
| 259 |
+
result = n
|
| 260 |
+
p = 2
|
| 261 |
+
while p * p <= n:
|
| 262 |
+
if n % p == 0:
|
| 263 |
+
while n % p == 0:
|
| 264 |
+
n //= p
|
| 265 |
+
result -= result // p
|
| 266 |
+
p += 1 if p == 2 else 2
|
| 267 |
+
if n > 1:
|
| 268 |
+
result -= result // n
|
| 269 |
+
return result","[""assert totient(0) == 0"", ""assert totient(1) == 1"", ""assert totient(2) == 1"", ""assert totient(5) == 4"", ""assert totient(9) == 6"", ""assert totient(10) == 4""]","[""assert totient(9) == 6 -> AssertionError""]",cmp,"--- buggy.py
|
| 270 |
+
+++ fixed.py
|
| 271 |
+
@@ -6,3 +6,3 @@
|
| 272 |
+
p = 2
|
| 273 |
+
- while p * p < n:
|
| 274 |
+
+ while p * p <= n:
|
| 275 |
+
if n % p == 0:
|
| 276 |
+
",boundary/comparison operator changed (<= -> <),1,6,fixed passes all tests; buggy fails >=1 (CPython 3.13.5),function+tests: @cf/openai/gpt-oss-120b (Cloudflare Workers AI); bug: deterministic AST mutation by Sir Grokkius
|
| 277 |
+
pbf1-0c114b65e868,integer_sqrt,number theory and integer math,Return floor(sqrt(n)) for n >= 0.,"def integer_sqrt(n):
|
| 278 |
+
""""""Return floor(sqrt(n)) for n >= 0.""""""
|
| 279 |
+
if n < 1:
|
| 280 |
+
raise ValueError('n must be non-negative')
|
| 281 |
+
if n < 2:
|
| 282 |
+
return n
|
| 283 |
+
low, high = (1, n // 2)
|
| 284 |
+
while low <= high:
|
| 285 |
+
mid = (low + high) // 2
|
| 286 |
+
sq = mid * mid
|
| 287 |
+
if sq == n:
|
| 288 |
+
return mid
|
| 289 |
+
elif sq < n:
|
| 290 |
+
low = mid + 1
|
| 291 |
+
ans = mid
|
| 292 |
+
else:
|
| 293 |
+
high = mid - 1
|
| 294 |
+
return ans","def integer_sqrt(n):
|
| 295 |
+
""""""Return floor(sqrt(n)) for n >= 0.""""""
|
| 296 |
+
if n < 0:
|
| 297 |
+
raise ValueError('n must be non-negative')
|
| 298 |
+
if n < 2:
|
| 299 |
+
return n
|
| 300 |
+
low, high = (1, n // 2)
|
| 301 |
+
while low <= high:
|
| 302 |
+
mid = (low + high) // 2
|
| 303 |
+
sq = mid * mid
|
| 304 |
+
if sq == n:
|
| 305 |
+
return mid
|
| 306 |
+
elif sq < n:
|
| 307 |
+
low = mid + 1
|
| 308 |
+
ans = mid
|
| 309 |
+
else:
|
| 310 |
+
high = mid - 1
|
| 311 |
+
return ans","[""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""]","[""assert integer_sqrt(0) == 0 -> ValueError""]",const,"--- buggy.py
|
| 312 |
+
+++ fixed.py
|
| 313 |
+
@@ -2,3 +2,3 @@
|
| 314 |
+
""""""Return floor(sqrt(n)) for n >= 0.""""""
|
| 315 |
+
- if n < 1:
|
| 316 |
+
+ if n < 0:
|
| 317 |
+
raise ValueError('n must be non-negative')
|
| 318 |
+
",off-by-one constant (0 -> 1),1,6,fixed passes all tests; buggy fails >=1 (CPython 3.13.5),function+tests: @cf/openai/gpt-oss-120b (Cloudflare Workers AI); bug: deterministic AST mutation by Sir Grokkius
|
| 319 |
+
pbf1-39a37b42b019,is_valid_ipv4,simple parsing and validation (no regex libraries beyond re),Checks whether a string is a syntactically valid IPv4 address.,"def is_valid_ipv4(addr):
|
| 320 |
+
""""""Return True if addr is a valid IPv4 address.""""""
|
| 321 |
+
parts = addr.split('.')
|
| 322 |
+
if len(parts) != 4:
|
| 323 |
+
return False
|
| 324 |
+
for p in parts:
|
| 325 |
+
if not p.isdigit():
|
| 326 |
+
return False
|
| 327 |
+
if len(p) > 1 or p[0] == '0':
|
| 328 |
+
return False
|
| 329 |
+
n = int(p)
|
| 330 |
+
if n < 0 or n > 255:
|
| 331 |
+
return False
|
| 332 |
+
return True","def is_valid_ipv4(addr):
|
| 333 |
+
""""""Return True if addr is a valid IPv4 address.""""""
|
| 334 |
+
parts = addr.split('.')
|
| 335 |
+
if len(parts) != 4:
|
| 336 |
+
return False
|
| 337 |
+
for p in parts:
|
| 338 |
+
if not p.isdigit():
|
| 339 |
+
return False
|
| 340 |
+
if len(p) > 1 and p[0] == '0':
|
| 341 |
+
return False
|
| 342 |
+
n = int(p)
|
| 343 |
+
if n < 0 or n > 255:
|
| 344 |
+
return False
|
| 345 |
+
return True","[""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""]","[""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""]",bool,"--- buggy.py
|
| 346 |
+
+++ fixed.py
|
| 347 |
+
@@ -8,3 +8,3 @@
|
| 348 |
+
return False
|
| 349 |
+
- if len(p) > 1 or p[0] == '0':
|
| 350 |
+
+ if len(p) > 1 and p[0] == '0':
|
| 351 |
+
return False
|
| 352 |
+
",boolean operator swapped (and -> or),3,6,fixed passes all tests; buggy fails >=1 (CPython 3.13.5),function+tests: @cf/openai/gpt-oss-120b (Cloudflare Workers AI); bug: deterministic AST mutation by Sir Grokkius
|
| 353 |
+
pbf1-c54ecfb64e0b,is_valid_hex_color,simple parsing and validation (no regex libraries beyond re),"Returns True if a string is a 6‑digit hexadecimal colour, optionally prefixed with '#'.","def is_valid_hex_color(s):
|
| 354 |
+
""""""Return True if s is a 6-digit hex colour, optionally prefixed with #.""""""
|
| 355 |
+
if s.startswith('#'):
|
| 356 |
+
s = s[2:]
|
| 357 |
+
if len(s) != 6:
|
| 358 |
+
return False
|
| 359 |
+
hex_digits = '0123456789abcdefABCDEF'
|
| 360 |
+
for ch in s:
|
| 361 |
+
if ch not in hex_digits:
|
| 362 |
+
return False
|
| 363 |
+
return True","def is_valid_hex_color(s):
|
| 364 |
+
""""""Return True if s is a 6-digit hex colour, optionally prefixed with #.""""""
|
| 365 |
+
if s.startswith('#'):
|
| 366 |
+
s = s[1:]
|
| 367 |
+
if len(s) != 6:
|
| 368 |
+
return False
|
| 369 |
+
hex_digits = '0123456789abcdefABCDEF'
|
| 370 |
+
for ch in s:
|
| 371 |
+
if ch not in hex_digits:
|
| 372 |
+
return False
|
| 373 |
+
return True","[""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""]","[""assert is_valid_hex_color('#1a2B3c') is True -> AssertionError""]",const,"--- buggy.py
|
| 374 |
+
+++ fixed.py
|
| 375 |
+
@@ -3,3 +3,3 @@
|
| 376 |
+
if s.startswith('#'):
|
| 377 |
+
- s = s[2:]
|
| 378 |
+
+ s = s[1:]
|
| 379 |
+
if len(s) != 6:
|
| 380 |
+
",off-by-one constant (1 -> 2),1,6,fixed passes all tests; buggy fails >=1 (CPython 3.13.5),function+tests: @cf/openai/gpt-oss-120b (Cloudflare Workers AI); bug: deterministic AST mutation by Sir Grokkius
|
| 381 |
+
pbf1-bc6d24dae89e,merge_two_sorted,sorting and searching variants,Merge two ascending sorted lists into a new sorted list.,"def merge_two_sorted(a, b):
|
| 382 |
+
""""""Merge two ascending sorted lists a and b into a new sorted list.""""""
|
| 383 |
+
i = j = 0
|
| 384 |
+
merged = []
|
| 385 |
+
while i < len(a) and j <= len(b):
|
| 386 |
+
if a[i] <= b[j]:
|
| 387 |
+
merged.append(a[i])
|
| 388 |
+
i += 1
|
| 389 |
+
else:
|
| 390 |
+
merged.append(b[j])
|
| 391 |
+
j += 1
|
| 392 |
+
merged.extend(a[i:])
|
| 393 |
+
merged.extend(b[j:])
|
| 394 |
+
return merged","def merge_two_sorted(a, b):
|
| 395 |
+
""""""Merge two ascending sorted lists a and b into a new sorted list.""""""
|
| 396 |
+
i = j = 0
|
| 397 |
+
merged = []
|
| 398 |
+
while i < len(a) and j < len(b):
|
| 399 |
+
if a[i] <= b[j]:
|
| 400 |
+
merged.append(a[i])
|
| 401 |
+
i += 1
|
| 402 |
+
else:
|
| 403 |
+
merged.append(b[j])
|
| 404 |
+
j += 1
|
| 405 |
+
merged.extend(a[i:])
|
| 406 |
+
merged.extend(b[j:])
|
| 407 |
+
return merged","[""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]""]","[""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""]",cmp,"--- buggy.py
|
| 408 |
+
+++ fixed.py
|
| 409 |
+
@@ -4,3 +4,3 @@
|
| 410 |
+
merged = []
|
| 411 |
+
- while i < len(a) and j <= len(b):
|
| 412 |
+
+ while i < len(a) and j < len(b):
|
| 413 |
+
if a[i] <= b[j]:
|
| 414 |
+
",boundary/comparison operator changed (< -> <=),2,6,fixed passes all tests; buggy fails >=1 (CPython 3.13.5),function+tests: @cf/openai/gpt-oss-120b (Cloudflare Workers AI); bug: deterministic AST mutation by Sir Grokkius
|
| 415 |
+
pbf1-76832a7dc006,counting_sort,sorting and searching variants,Counting sort for non‑negative integers with optional max value.,"def counting_sort(arr, max_value=None):
|
| 416 |
+
""""""Return a new list with non‑negative integers sorted using counting sort.""""""
|
| 417 |
+
if any((x < 0 for x in arr)):
|
| 418 |
+
raise ValueError('negative numbers not allowed')
|
| 419 |
+
if max_value is None:
|
| 420 |
+
max_value = max(arr) if arr else 0
|
| 421 |
+
count = [0] // (max_value + 1)
|
| 422 |
+
for x in arr:
|
| 423 |
+
if x > max_value:
|
| 424 |
+
raise ValueError('element exceeds max_value')
|
| 425 |
+
count[x] += 1
|
| 426 |
+
sorted_arr = []
|
| 427 |
+
for value, freq in enumerate(count):
|
| 428 |
+
sorted_arr.extend([value] * freq)
|
| 429 |
+
return sorted_arr","def counting_sort(arr, max_value=None):
|
| 430 |
+
""""""Return a new list with non‑negative integers sorted using counting sort.""""""
|
| 431 |
+
if any((x < 0 for x in arr)):
|
| 432 |
+
raise ValueError('negative numbers not allowed')
|
| 433 |
+
if max_value is None:
|
| 434 |
+
max_value = max(arr) if arr else 0
|
| 435 |
+
count = [0] * (max_value + 1)
|
| 436 |
+
for x in arr:
|
| 437 |
+
if x > max_value:
|
| 438 |
+
raise ValueError('element exceeds max_value')
|
| 439 |
+
count[x] += 1
|
| 440 |
+
sorted_arr = []
|
| 441 |
+
for value, freq in enumerate(count):
|
| 442 |
+
sorted_arr.extend([value] * freq)
|
| 443 |
+
return sorted_arr","[""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]""]","[""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""]",bin,"--- buggy.py
|
| 444 |
+
+++ fixed.py
|
| 445 |
+
@@ -6,3 +6,3 @@
|
| 446 |
+
max_value = max(arr) if arr else 0
|
| 447 |
+
- count = [0] // (max_value + 1)
|
| 448 |
+
+ count = [0] * (max_value + 1)
|
| 449 |
+
for x in arr:
|
| 450 |
+
",arithmetic operator changed (* -> //),4,4,fixed passes all tests; buggy fails >=1 (CPython 3.13.5),function+tests: @cf/openai/gpt-oss-120b (Cloudflare Workers AI); bug: deterministic AST mutation by Sir Grokkius
|
| 451 |
+
pbf1-1a61ca778647,next_greater_elements,stack/queue based algorithms,For each element returns the index of the next greater element; -1 if none.,"def next_greater_elements(arr):
|
| 452 |
+
res = [-1] * len(arr)
|
| 453 |
+
stack = []
|
| 454 |
+
for i, val in enumerate(arr):
|
| 455 |
+
while stack and arr[stack[-1]] <= val:
|
| 456 |
+
idx = stack.pop()
|
| 457 |
+
res[idx] = i
|
| 458 |
+
stack.append(i)
|
| 459 |
+
return res","def next_greater_elements(arr):
|
| 460 |
+
res = [-1] * len(arr)
|
| 461 |
+
stack = []
|
| 462 |
+
for i, val in enumerate(arr):
|
| 463 |
+
while stack and arr[stack[-1]] < val:
|
| 464 |
+
idx = stack.pop()
|
| 465 |
+
res[idx] = i
|
| 466 |
+
stack.append(i)
|
| 467 |
+
return res","[""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]""]","[""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""]",cmp,"--- buggy.py
|
| 468 |
+
+++ fixed.py
|
| 469 |
+
@@ -4,3 +4,3 @@
|
| 470 |
+
for i, val in enumerate(arr):
|
| 471 |
+
- while stack and arr[stack[-1]] <= val:
|
| 472 |
+
+ while stack and arr[stack[-1]] < val:
|
| 473 |
+
idx = stack.pop()
|
| 474 |
+
",boundary/comparison operator changed (< -> <=),2,6,fixed passes all tests; buggy fails >=1 (CPython 3.13.5),function+tests: @cf/openai/gpt-oss-120b (Cloudflare Workers AI); bug: deterministic AST mutation by Sir Grokkius
|
| 475 |
+
pbf1-4ab0c7b68ae2,infix_eval,stack/queue based algorithms,Evaluates an arithmetic expression given in infix notation using the shunting‑yard algorithm.,"def infix_eval(tokens):
|
| 476 |
+
prec = {'+': 1, '-': 1, '*': 2, '/': 2}
|
| 477 |
+
vals = []
|
| 478 |
+
ops = []
|
| 479 |
+
|
| 480 |
+
def apply():
|
| 481 |
+
b = vals.pop()
|
| 482 |
+
a = vals.pop()
|
| 483 |
+
op = ops.pop()
|
| 484 |
+
if op == '+':
|
| 485 |
+
vals.append(a + b)
|
| 486 |
+
elif op == '-':
|
| 487 |
+
vals.append(a - b)
|
| 488 |
+
elif op == '*':
|
| 489 |
+
vals.append(a * b)
|
| 490 |
+
elif op == '/':
|
| 491 |
+
vals.append(int(a / b))
|
| 492 |
+
for t in tokens:
|
| 493 |
+
if isinstance(t, int):
|
| 494 |
+
vals.append(t)
|
| 495 |
+
elif t != '(':
|
| 496 |
+
ops.append(t)
|
| 497 |
+
elif t == ')':
|
| 498 |
+
while ops and ops[-1] != '(':
|
| 499 |
+
apply()
|
| 500 |
+
ops.pop()
|
| 501 |
+
else:
|
| 502 |
+
while ops and ops[-1] != '(' and (prec[ops[-1]] >= prec[t]):
|
| 503 |
+
apply()
|
| 504 |
+
ops.append(t)
|
| 505 |
+
while ops:
|
| 506 |
+
apply()
|
| 507 |
+
return vals[0] if vals else 0","def infix_eval(tokens):
|
| 508 |
+
prec = {'+': 1, '-': 1, '*': 2, '/': 2}
|
| 509 |
+
vals = []
|
| 510 |
+
ops = []
|
| 511 |
+
|
| 512 |
+
def apply():
|
| 513 |
+
b = vals.pop()
|
| 514 |
+
a = vals.pop()
|
| 515 |
+
op = ops.pop()
|
| 516 |
+
if op == '+':
|
| 517 |
+
vals.append(a + b)
|
| 518 |
+
elif op == '-':
|
| 519 |
+
vals.append(a - b)
|
| 520 |
+
elif op == '*':
|
| 521 |
+
vals.append(a * b)
|
| 522 |
+
elif op == '/':
|
| 523 |
+
vals.append(int(a / b))
|
| 524 |
+
for t in tokens:
|
| 525 |
+
if isinstance(t, int):
|
| 526 |
+
vals.append(t)
|
| 527 |
+
elif t == '(':
|
| 528 |
+
ops.append(t)
|
| 529 |
+
elif t == ')':
|
| 530 |
+
while ops and ops[-1] != '(':
|
| 531 |
+
apply()
|
| 532 |
+
ops.pop()
|
| 533 |
+
else:
|
| 534 |
+
while ops and ops[-1] != '(' and (prec[ops[-1]] >= prec[t]):
|
| 535 |
+
apply()
|
| 536 |
+
ops.append(t)
|
| 537 |
+
while ops:
|
| 538 |
+
apply()
|
| 539 |
+
return vals[0] if vals else 0","[""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""]","[""assert infix_eval([2, '*', 3, '+', 5]) == 11 -> AssertionError"", ""assert infix_eval(['(',2,'+',3,')','*',4]) == 20 -> IndexError""]",cmp,"--- buggy.py
|
| 540 |
+
+++ fixed.py
|
| 541 |
+
@@ -20,3 +20,3 @@
|
| 542 |
+
vals.append(t)
|
| 543 |
+
- elif t != '(':
|
| 544 |
+
+ elif t == '(':
|
| 545 |
+
ops.append(t)
|
| 546 |
+
",boundary/comparison operator changed (== -> !=),2,6,fixed passes all tests; buggy fails >=1 (CPython 3.13.5),function+tests: @cf/openai/gpt-oss-120b (Cloudflare Workers AI); bug: deterministic AST mutation by Sir Grokkius
|
| 547 |
+
pbf1-9b17da903602,is_palindrome,string processing,Return True if a string reads the same forwards and backwards ignoring non‑alphanumeric characters and case.,"def is_palindrome(s: str) -> bool:
|
| 548 |
+
""""""Return True if s is a palindrome ignoring non‑alphanumeric characters and case.""""""
|
| 549 |
+
filtered = [ch.lower() for ch in s if ch.isalnum()]
|
| 550 |
+
left, right = (1, len(filtered) - 1)
|
| 551 |
+
while left < right:
|
| 552 |
+
if filtered[left] != filtered[right]:
|
| 553 |
+
return False
|
| 554 |
+
left += 1
|
| 555 |
+
right -= 1
|
| 556 |
+
return True","def is_palindrome(s: str) -> bool:
|
| 557 |
+
""""""Return True if s is a palindrome ignoring non‑alphanumeric characters and case.""""""
|
| 558 |
+
filtered = [ch.lower() for ch in s if ch.isalnum()]
|
| 559 |
+
left, right = (0, len(filtered) - 1)
|
| 560 |
+
while left < right:
|
| 561 |
+
if filtered[left] != filtered[right]:
|
| 562 |
+
return False
|
| 563 |
+
left += 1
|
| 564 |
+
right -= 1
|
| 565 |
+
return True","[""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""]","[""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""]",const,"--- buggy.py
|
| 566 |
+
+++ fixed.py
|
| 567 |
+
@@ -3,3 +3,3 @@
|
| 568 |
+
filtered = [ch.lower() for ch in s if ch.isalnum()]
|
| 569 |
+
- left, right = (1, len(filtered) - 1)
|
| 570 |
+
+ left, right = (0, len(filtered) - 1)
|
| 571 |
+
while left < right:
|
| 572 |
+
",off-by-one constant (0 -> 1),3,6,fixed passes all tests; buggy fails >=1 (CPython 3.13.5),function+tests: @cf/openai/gpt-oss-120b (Cloudflare Workers AI); bug: deterministic AST mutation by Sir Grokkius
|
| 573 |
+
pbf1-87203ccc9500,rotate_string,string processing,Rotate a string to the right by k positions; negative k rotates left.,"def rotate_string(s: str, k: int) -> str:
|
| 574 |
+
""""""Rotate s to the right by k positions; negative k rotates left.""""""
|
| 575 |
+
n = len(s)
|
| 576 |
+
if n == 0:
|
| 577 |
+
return s
|
| 578 |
+
k = k // n
|
| 579 |
+
return s[-k:] + s[:-k] if k else s","def rotate_string(s: str, k: int) -> str:
|
| 580 |
+
""""""Rotate s to the right by k positions; negative k rotates left.""""""
|
| 581 |
+
n = len(s)
|
| 582 |
+
if n == 0:
|
| 583 |
+
return s
|
| 584 |
+
k = k % n
|
| 585 |
+
return s[-k:] + s[:-k] if k else s","[""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'""]","[""assert rotate_string('abc', 1) == 'cab' -> AssertionError"", ""assert rotate_string('abc', 3) == 'abc' -> AssertionError""]",bin,"--- buggy.py
|
| 586 |
+
+++ fixed.py
|
| 587 |
+
@@ -5,3 +5,3 @@
|
| 588 |
+
return s
|
| 589 |
+
- k = k // n
|
| 590 |
+
+ k = k % n
|
| 591 |
+
return s[-k:] + s[:-k] if k else s",arithmetic operator changed (% -> //),2,6,fixed passes all tests; buggy fails >=1 (CPython 3.13.5),function+tests: @cf/openai/gpt-oss-120b (Cloudflare Workers AI); bug: deterministic AST mutation by Sir Grokkius
|
| 592 |
+
pbf1-34a538985b02,collapse_spaces,text formatting and wrapping,Replace any run of whitespace characters with a single space and trim the result.,"def collapse_spaces(text):
|
| 593 |
+
""""""Collapse consecutive whitespace characters into a single space and strip ends.""""""
|
| 594 |
+
result = []
|
| 595 |
+
prev_space = False
|
| 596 |
+
for ch in text:
|
| 597 |
+
if ch.isspace():
|
| 598 |
+
if prev_space:
|
| 599 |
+
result.append(' ')
|
| 600 |
+
prev_space = True
|
| 601 |
+
else:
|
| 602 |
+
result.append(ch)
|
| 603 |
+
prev_space = False
|
| 604 |
+
return ''.join(result).strip()","def collapse_spaces(text):
|
| 605 |
+
""""""Collapse consecutive whitespace characters into a single space and strip ends.""""""
|
| 606 |
+
result = []
|
| 607 |
+
prev_space = False
|
| 608 |
+
for ch in text:
|
| 609 |
+
if ch.isspace():
|
| 610 |
+
if not prev_space:
|
| 611 |
+
result.append(' ')
|
| 612 |
+
prev_space = True
|
| 613 |
+
else:
|
| 614 |
+
result.append(ch)
|
| 615 |
+
prev_space = False
|
| 616 |
+
return ''.join(result).strip()","[""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') == ''""]","[""assert collapse_spaces(' a b\\t c\\n\\n') == 'a b c' -> AssertionError"", ""assert collapse_spaces('multiple spaces inside') == 'multiple spaces inside' -> AssertionError""]",neg,"--- buggy.py
|
| 617 |
+
+++ fixed.py
|
| 618 |
+
@@ -6,3 +6,3 @@
|
| 619 |
+
if ch.isspace():
|
| 620 |
+
- if prev_space:
|
| 621 |
+
+ if not prev_space:
|
| 622 |
+
result.append(' ')
|
| 623 |
+
",condition negation removed/added,2,6,fixed passes all tests; buggy fails >=1 (CPython 3.13.5),function+tests: @cf/openai/gpt-oss-120b (Cloudflare Workers AI); bug: deterministic AST mutation by Sir Grokkius
|
| 624 |
+
pbf1-64592e29a38e,wrap_text,text formatting and wrapping,Wrap a string into lines not exceeding a given width.,"def wrap_text(text, width):
|
| 625 |
+
""""""Wrap text to a given width, returning a list of lines.""""""
|
| 626 |
+
if width <= 0:
|
| 627 |
+
return []
|
| 628 |
+
words = text.split()
|
| 629 |
+
lines = []
|
| 630 |
+
line = ''
|
| 631 |
+
for w in words:
|
| 632 |
+
if not line:
|
| 633 |
+
line = w
|
| 634 |
+
elif len(line) + 1 + len(w) <= width:
|
| 635 |
+
line += ' ' - w
|
| 636 |
+
else:
|
| 637 |
+
lines.append(line)
|
| 638 |
+
line = w
|
| 639 |
+
if line:
|
| 640 |
+
lines.append(line)
|
| 641 |
+
return lines","def wrap_text(text, width):
|
| 642 |
+
""""""Wrap text to a given width, returning a list of lines.""""""
|
| 643 |
+
if width <= 0:
|
| 644 |
+
return []
|
| 645 |
+
words = text.split()
|
| 646 |
+
lines = []
|
| 647 |
+
line = ''
|
| 648 |
+
for w in words:
|
| 649 |
+
if not line:
|
| 650 |
+
line = w
|
| 651 |
+
elif len(line) + 1 + len(w) <= width:
|
| 652 |
+
line += ' ' + w
|
| 653 |
+
else:
|
| 654 |
+
lines.append(line)
|
| 655 |
+
line = w
|
| 656 |
+
if line:
|
| 657 |
+
lines.append(line)
|
| 658 |
+
return lines","[""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) == []""]","[""assert wrap_text('Hello world', 15) == ['Hello world'] -> TypeError""]",bin,"--- buggy.py
|
| 659 |
+
+++ fixed.py
|
| 660 |
+
@@ -11,3 +11,3 @@
|
| 661 |
+
elif len(line) + 1 + len(w) <= width:
|
| 662 |
+
- line += ' ' - w
|
| 663 |
+
+ line += ' ' + w
|
| 664 |
+
else:
|
| 665 |
+
",arithmetic operator changed (+ -> -),1,6,fixed passes all tests; buggy fails >=1 (CPython 3.13.5),function+tests: @cf/openai/gpt-oss-120b (Cloudflare Workers AI); bug: deterministic AST mutation by Sir Grokkius
|
pybugfix-verified-v1-sample.jsonl
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{"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"}
|
| 2 |
+
{"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"}
|
| 3 |
+
{"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"}
|
| 4 |
+
{"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"}
|
| 5 |
+
{"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"}
|
| 6 |
+
{"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"}
|
| 7 |
+
{"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"}
|
| 8 |
+
{"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"}
|
| 9 |
+
{"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"}
|
| 10 |
+
{"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"}
|
| 11 |
+
{"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"}
|
| 12 |
+
{"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"}
|
| 13 |
+
{"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"}
|
| 14 |
+
{"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"}
|
| 15 |
+
{"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"}
|
| 16 |
+
{"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"}
|
| 17 |
+
{"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"}
|
| 18 |
+
{"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"}
|
| 19 |
+
{"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"}
|
| 20 |
+
{"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"}
|
| 21 |
+
{"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"}
|
| 22 |
+
{"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"}
|