{
  "pilot-csv-1-append": "def select_rows(rows):\n    selected = {}\n    for row in rows:\n        row_id = row[\"id\"]\n        if row_id not in selected or row[\"stamp\"] > selected[row_id][\"stamp\"]:\n            selected[row_id] = row\n\n    return [dict(row) for row in selected.values()]",
  "pilot-csv-1-plan": "The current function copies every row. I\u2019ll update it to scan the rows once, tracking seen IDs in a set. When an ID first appears, I\u2019ll append `dict(row)` to the result; later rows with that ID will be skipped. This preserves first-appearance order, uses case-sensitive ID matching, and keeps every field in an independent shallow copy without modifying the input.",
  "pilot-csv-1-rewrite": "def select_rows(rows):\n    selected = {}\n    for row in rows:\n        row_id = row[\"id\"]\n        if row_id not in selected or row[\"stamp\"] > selected[row_id][\"stamp\"]:\n            selected[row_id] = row\n    return [dict(row) for row in selected.values()]",
  "pilot-invoice-1-append": "from decimal import Context, Decimal, ROUND_HALF_UP, localcontext\n\n_CENT = Decimal(\"0.01\")\n\n\ndef total(lines):\n    amounts = [Decimal(line) for line in lines]\n    if not amounts:\n        return \"0.00\"\n\n    # Keep every input digit and leave room for carries when summing and rounding.\n    lowest_place = min(-2, min(amount.as_tuple().exponent for amount in amounts))\n    highest_place = max(0, max(amount.adjusted() for amount in amounts))\n    precision = highest_place - lowest_place + len(str(len(amounts))) + 2\n\n    with localcontext(Context(prec=precision)):\n        amount = sum(amounts, Decimal(\"0\"))\n        rounded = amount.quantize(_CENT, rounding=ROUND_HALF_UP)\n\n    return \"0.00\" if rounded.is_zero() else format(rounded, \".2f\")",
  "pilot-invoice-1-plan": "The current `total()` parses the inputs as `Decimal` values, then sums them without rounding or enforcing a two-decimal output.\n\n1. Round each line to `Decimal(\"0.01\")` with `ROUND_HALF_UP` before adding it to the total. Negative lines remain credits.\n2. If the total is zero, return `\"0.00\"`; otherwise, format it with exactly two decimal places.\n3. Verify that `[\"0.005\", \"0.005\"]` returns `\"0.02\"` (rounding happens per line), `[\"-1.005\"]` returns `\"-1.01\"`, and `[\"-0.004\"]` returns `\"0.00\"`.",
  "pilot-invoice-1-rewrite": "from decimal import MAX_EMAX, MIN_EMIN, Context, Decimal, ROUND_HALF_UP, localcontext\n\n_CENT = Decimal(\"0.01\")\n\n\ndef total(lines):\n    amounts = [amount for amount in map(Decimal, lines) if not amount.is_zero()]\n    if not amounts:\n        return \"0.00\"\n\n    # Keep every input digit and allow enough room for carries in the sum.\n    lowest_place = min(-2, min(amount.as_tuple().exponent for amount in amounts))\n    highest_place = max(amount.adjusted() for amount in amounts)\n    precision = max(1, highest_place - lowest_place + 1 + len(str(len(amounts))))\n\n    with localcontext(Context(prec=precision, Emax=MAX_EMAX, Emin=MIN_EMIN)):\n        amount = sum(amounts, Decimal(0))\n        rounded = amount.quantize(_CENT, rounding=ROUND_HALF_UP)\n\n    return \"0.00\" if rounded.is_zero() else format(rounded, \"f\")",
  "pilot-scheduler-1-append": "from datetime import datetime\nfrom zoneinfo import ZoneInfo\n\n\ndef service_day(stamp, venue_zone):\n    return datetime.fromisoformat(stamp).astimezone(ZoneInfo(venue_zone)).date().isoformat()",
  "pilot-scheduler-1-plan": "The current code takes the date written in `stamp`, which can differ from the UTC date. I\u2019ll parse the timestamp with `datetime.fromisoformat`, convert it to UTC with `astimezone(UTC)`, and return `.date().isoformat()`. I\u2019ll keep `venue_zone` in the function signature for compatibility, but it won\u2019t affect the result. I\u2019ll remove the unused `ZoneInfo` import and check cases where conversion crosses midnight in either direction.",
  "pilot-scheduler-1-rewrite": "from datetime import datetime\nfrom zoneinfo import ZoneInfo\n\n\ndef service_day(stamp, venue_zone):\n    return datetime.fromisoformat(stamp).astimezone(ZoneInfo(venue_zone)).date().isoformat()",
  "pilot2-csv-1-append": "def select_rows(rows):\n    selected = {}\n    for row in rows:\n        row_id = row[\"id\"]\n        if row_id not in selected or row[\"stamp\"] > selected[row_id][\"stamp\"]:\n            selected[row_id] = row\n\n    return [dict(row) for row in selected.values()]",
  "pilot2-csv-1-plan": "**Dry run:** The exact ordered output, shown as `(id, stamp, value)` tuples, is `[(b, 2, H), (A, 5, P), (a, 9, R)]`. Later rows for each id are ignored, and `A` and `a` are distinct.\n\n**Minimal permutation:** Swap the first and third rows, `(b, 2, H)` and `(b, 8, Q)`. This is one swap, and it preserves both the set of ids and their first-appearance order. The output becomes `[(b, 8, Q), (A, 5, P), (a, 9, R)]`.\n\n**Aliasing check:** Returning the original row dictionaries would pass a value-equality test, but assigning a new `stamp` in a returned row would also change the caller\u2019s input. Each selected row needs its own dictionary; nested values may still be shared because the copy is shallow.\n\n**Plan:** The starter already makes shallow copies, but it copies every row. Keep `dict(row)` and add a `seen` set: scan once, and append a copy only the first time each id appears. This preserves all fields and leaves the input untouched.",
  "pilot2-csv-1-rewrite": "def select_rows(rows):\n    selected = {}\n    for row in rows:\n        row_id = row[\"id\"]\n        if row_id not in selected or row[\"stamp\"] > selected[row_id][\"stamp\"]:\n            selected[row_id] = row\n\n    return [dict(row) for row in selected.values()]",
  "pilot2-invoice-1-append": "from decimal import MAX_EMAX, MIN_EMIN, Context, Decimal, ROUND_HALF_UP, localcontext\n\n_CENT = Decimal(\"0.01\")\n_ZERO = Decimal(\"0\")\n\n\ndef total(lines):\n    amounts = [Decimal(line) for line in lines]\n    amounts = [amount for amount in amounts if not amount.is_zero()]\n    if not amounts:\n        return \"0.00\"\n\n    # Allow enough digits to align all inputs exactly and absorb any carry.\n    lowest_place = min(-2, min(amount.as_tuple().exponent for amount in amounts))\n    highest_place = max(amount.adjusted() for amount in amounts)\n    precision = highest_place - lowest_place + 1 + len(str(len(amounts)))\n\n    with localcontext(Context(prec=precision, Emin=MIN_EMIN, Emax=MAX_EMAX)):\n        amount = sum(amounts, _ZERO)\n        rounded = amount.quantize(_CENT, rounding=ROUND_HALF_UP)\n\n    return \"0.00\" if rounded.is_zero() else format(rounded, \"f\")",
  "pilot2-invoice-1-plan": "### Dry run: round each line before adding\n\n| Input | Rounded to cents (half-up) | Running total |\n|---|---:|---:|\n| `12.495` | `12.50` | `12.50` |\n| `-3.005` | `-3.01` | `9.49` |\n| `0.015` | `0.02` | `9.51` |\n| `-0.004` | `-0.00` | `9.51` |\n| `0.005` | `0.01` | `9.52` |\n| `-0.005` | `-0.01` | `9.51` |\n\nThe ledger returns `\"9.51\"`.\n\n### Shortest counterexample\n\n`[\"0.005\", \"-0.004\"]` has two entries, the minimum needed for both a charge and a credit.\n\n- **Round each line first:** `0.01 + (-0.00) = 0.01`.\n- **Round only the total:** `0.005 + (-0.004) = 0.001`, which rounds to `0.00`.\n\n### Implementation plan\n\nThe current `total` sums unrounded `Decimal` values and returns `str(amount)`, so it neither rounds each line nor guarantees two decimal places. Keep parsing with `Decimal`, quantize each line to `Decimal(\"0.01\")` using `ROUND_HALF_UP`, and sum the rounded values. Return `\"0.00\"` for any zero total; otherwise format it with exactly two decimal places.",
  "pilot2-invoice-1-rewrite": "from decimal import Context, Decimal, ROUND_HALF_UP, localcontext\n\n\n_CENT = Decimal(\"0.01\")\n\n\ndef total(lines):\n    amounts = [Decimal(line) for line in lines]\n    amounts = [amount for amount in amounts if not amount.is_zero()]\n    if not amounts:\n        return \"0.00\"\n\n    # Allow enough digits to sum exactly and to handle a carry when rounding.\n    highest_place = max(0, max(amount.adjusted() for amount in amounts))\n    lowest_place = min(-2, min(amount.as_tuple().exponent for amount in amounts))\n    precision = highest_place - lowest_place + len(str(len(amounts))) + 1\n\n    with localcontext(Context(prec=precision)):\n        amount = sum(amounts, Decimal(\"0\"))\n        rounded = amount.quantize(_CENT, rounding=ROUND_HALF_UP)\n\n    return \"0.00\" if rounded.is_zero() else format(rounded, \".2f\")",
  "pilot2-scheduler-1-append": "from datetime import datetime\nfrom zoneinfo import ZoneInfo\n\n\ndef service_day(stamp, venue_zone):\n    return datetime.fromisoformat(stamp).astimezone(ZoneInfo(venue_zone)).date().isoformat()",
  "pilot2-scheduler-1-plan": "Under the current rule, the **UTC date** owns the booking for every venue. The venue-local dates below are independent comparisons.\n\n| Booking timestamp | UTC instant | Booking date (UTC) | America/Vancouver date | Pacific/Kiritimati date |\n|---|---|---|---|---|\n| `2026-11-01T01:45:00-07:00` | `2026-11-01T08:45:00Z` | `2026-11-01` | `2026-11-01` | `2026-11-01` |\n| `2026-11-01T01:15:00-08:00` | `2026-11-01T09:15:00Z` | `2026-11-01` | `2026-11-01` | `2026-11-01` |\n| `2027-01-01T00:10:00+14:00` | `2026-12-31T10:10:00Z` | `2026-12-31` | `2026-12-31` | `2027-01-01` |\n\nThe `01:45-07:00` booking comes **30 minutes before** the `01:15-08:00` booking. Vancouver\u2019s fall-back repeats the 1 a.m. hour, so sorting by the printed wall times alone puts `01:15` first and reverses the actual order.\n\n**Plan:** The current split returns the date printed in the timestamp, which is wrong for the third booking. Replace it with `datetime.fromisoformat(stamp).astimezone(UTC).date().isoformat()`. Import `UTC` from `datetime`, remove the unused `ZoneInfo` import, and keep `venue_zone` in the signature without using it. Verify all three rows with both venue arguments.",
  "pilot2-scheduler-1-rewrite": "from datetime import datetime\nfrom zoneinfo import ZoneInfo\n\n\ndef service_day(stamp, venue_zone):\n    return datetime.fromisoformat(stamp).astimezone(ZoneInfo(venue_zone)).date().isoformat()",
  "scored-csv-1-append": "def select_rows(rows):\n    selected = {}\n    for row in rows:\n        row_id = row[\"id\"]\n        if row_id not in selected or row[\"stamp\"] > selected[row_id][\"stamp\"]:\n            selected[row_id] = row\n\n    return [dict(row) for row in selected.values()]",
  "scored-csv-1-plan": "**Dry run:** The first occurrences are `b` at row 1, `A` at row 2, and `a` at row 4. `A` and `a` are distinct, and later rows are ignored regardless of stamp. The exact output in tuple notation is `[(b,2,H), (A,5,P), (a,9,R)]`.\n\n**Minimal permutation:** Swap the first two rows and leave the rest unchanged. This single adjacent swap preserves the set of ids but changes the ordered output to `[(A,5,P), (b,2,H), (a,9,R)]`.\n\n**Aliasing check:** Returning the original selected dictionaries would pass a value-only test, but assigning to a field in a returned row would also change the caller\u2019s row. Test that each returned dictionary is a distinct object. Nested mutable values may still be shared because the copy is shallow.\n\n**Plan:** The starting module already copies rows but doesn\u2019t filter duplicates. Keep `dict(row)` for the copy, scan once with a set of seen ids, and append a copy only on the first encounter of each id.",
  "scored-csv-1-rewrite": "def select_rows(rows):\n    selected = {}\n    for row in rows:\n        row_id = row[\"id\"]\n        if row_id not in selected or row[\"stamp\"] > selected[row_id][\"stamp\"]:\n            selected[row_id] = row\n\n    return [dict(row) for row in selected.values()]",
  "scored-csv-2-append": "def select_rows(rows):\n    \"\"\"Copy the highest-stamp row for each id, keeping the earliest on ties.\"\"\"\n    selected = {}\n    for row in rows:\n        row_id = row[\"id\"]\n        if row_id not in selected or row[\"stamp\"] > selected[row_id][\"stamp\"]:\n            selected[row_id] = row\n\n    return [dict(row) for row in selected.values()]",
  "scored-csv-2-plan": "**Checked output:** `[(b, 2, H), (A, 5, P), (a, 9, R)]`. The first occurrences are at positions 1, 2, and 4. `A` and `a` are distinct, and stamps do not affect selection.\n\n**Minimal permutation:** Swap rows 1 and 3, the first two `b` rows. This single swap preserves both the set of ids and their first-appearance order, but changes the output to `[(b, 8, Q), (A, 5, P), (a, 9, R)]`.\n\n**Aliasing check:** Returning a selected input dictionary directly would pass an equality test, but assigning to a top-level field in the result would also change the caller\u2019s row. Test that each returned dictionary is a distinct object. A shallow copy may still share a mutable payload.\n\n**Plan:** The starting function already shallow-copies each row but doesn\u2019t filter duplicates. Keep `dict(row)` for the copy, scan once with a set of seen ids, and append a copy only on the first encounter. This preserves every field and the first-appearance order without modifying the input.",
  "scored-csv-2-rewrite": "def select_rows(rows):\n    selected = {}\n    for row in rows:\n        row_id = row[\"id\"]\n        if row_id not in selected or row[\"stamp\"] > selected[row_id][\"stamp\"]:\n            selected[row_id] = row\n\n    return [dict(row) for row in selected.values()]",
  "scored-csv-3-append": "def select_rows(rows):\n    selected = {}\n    for row in rows:\n        row_id = row[\"id\"]\n        if row_id not in selected or row[\"stamp\"] > selected[row_id][\"stamp\"]:\n            selected[row_id] = row\n\n    return [dict(row) for row in selected.values()]",
  "scored-csv-3-plan": "**Checked output** (`id, stamp, value`): `[(b, 2, H), (A, 5, P), (a, 9, R)]`. These are the first rows for `b`, `A`, and `a`, in that order. `A` and `a` are distinct IDs.\n\n**Minimal permutation:** Swap the first two rows and leave the rest unchanged. One adjacent swap preserves the set of IDs but changes the output to `[(A, 5, P), (b, 2, H), (a, 9, R)]`.\n\n**Aliasing check:** Returning the original row dictionaries would pass a value-only comparison, but assigning to a field in a returned row would also change the caller\u2019s row. Test that each returned dictionary is a different object from its source. Nested values may still be shared because the copies are shallow.\n\n**Plan:** The starting code already makes shallow copies but copies every row. Scan once with a set of seen IDs. For each unseen ID, mark it seen and append `dict(row)`; skip later rows with that exact ID. This preserves first-appearance order and every field without modifying the input.",
  "scored-csv-3-rewrite": "def select_rows(rows):\n    best_by_id = {}\n    for row in rows:\n        row_id = row[\"id\"]\n        if row_id not in best_by_id or row[\"stamp\"] > best_by_id[row_id][\"stamp\"]:\n            best_by_id[row_id] = row\n\n    return [dict(row) for row in best_by_id.values()]",
  "scored-csv-4-append": "def select_rows(rows):\n    \"\"\"Copy the highest-stamp row for each ID, in first-appearance order.\"\"\"\n    selected = {}\n    for row in rows:\n        row_id = row[\"id\"]\n        if row_id not in selected or row[\"stamp\"] > selected[row_id][\"stamp\"]:\n            selected[row_id] = row\n    return [dict(row) for row in selected.values()]",
  "scored-csv-4-plan": "**Dry run:** `b` first appears at `(b,2,H)`, `A` at `(A,5,P)`, and `a` at `(a,9,R)`. `A` and `a` are distinct, and later stamps do not affect selection. The exact ordered output, shown as tuples, is:\n\n```text\n[(b,2,H), (A,5,P), (a,9,R)]\n```\n\n**Minimal permutation:** Swap the first and third rows, `(b,2,H)` and `(b,8,Q)`. This single swap preserves both the set of IDs and their first-appearance order, but changes which `b` row wins:\n\n```text\n[(b,8,Q), (A,5,P), (a,9,R)]\n```\n\n**Aliasing check:** Returning the original row dictionaries would pass a value-only comparison. But assigning a new value to `result[0][\"stamp\"]` would also change the caller\u2019s row. Each selected row needs a new outer dictionary; nested values remain shared because the copy is shallow.\n\n**Plan:** The starter already makes shallow copies, but it copies every row. Keep `dict(row)` and add a `seen` set. Scan once, appending a copy only when the exact ID hasn\u2019t been seen before. This preserves every field and first-appearance order without modifying the input.",
  "scored-csv-4-rewrite": "def select_rows(rows):\n    selected = {}\n    for row in rows:\n        row_id = row[\"id\"]\n        if row_id not in selected or row[\"stamp\"] > selected[row_id][\"stamp\"]:\n            selected[row_id] = row\n\n    return [dict(row) for row in selected.values()]",
  "scored-csv-5-append": "def select_rows(rows):\n    selected = {}\n    for row in rows:\n        row_id = row[\"id\"]\n        if row_id not in selected or row[\"stamp\"] > selected[row_id][\"stamp\"]:\n            selected[row_id] = row\n\n    return [dict(row) for row in selected.values()]",
  "scored-csv-5-plan": "**Dry run:** The first `b` is `(b,2,H)`, the first `A` is `(A,5,P)`, and the first `a` is `(a,9,R)`. All later rows for those IDs are ignored, regardless of stamp. The exact ordered output, in tuple notation, is:\n\n```text\n[(b,2,H), (A,5,P), (a,9,R)]\n```\n\n**Minimal permutation:** Swap just the first two rows. The set of IDs is unchanged, but `A` now appears before `b`, so the output becomes `[(A,5,P), (b,2,H), (a,9,R)]`.\n\n**Aliasing check:** Returning the original row dicts would pass a value-equality test, but assigning to a field in a returned dict would also change the caller\u2019s row. Test that each returned dict is a distinct object from its source. Sharing nested values is expected for a shallow copy.\n\n**Plan:** The current function copies every row without filtering. Keep `dict(row)` for the copy, but scan once with a `seen` set of case-sensitive IDs. Append a copy only on the first encounter with each ID, preserving every field and leaving the input untouched.",
  "scored-csv-5-rewrite": "def select_rows(rows):\n    selected = {}\n    for row in rows:\n        row_id = row[\"id\"]\n        if row_id not in selected or row[\"stamp\"] > selected[row_id][\"stamp\"]:\n            selected[row_id] = row\n    return [dict(row) for row in selected.values()]",
  "scored-invoice-1-append": "from decimal import Context, Decimal, ROUND_HALF_UP, localcontext\n\n_CENT = Decimal(\"0.01\")\n\n\ndef total(lines: list[str]) -> str:\n    amounts = [Decimal(line) for line in lines]\n    amounts = [amount for amount in amounts if not amount.is_zero()]\n    if not amounts:\n        return \"0.00\"\n\n    # Allow enough digits to align every input and sum without rounding.\n    lowest_place = min(-2, min(amount.as_tuple().exponent for amount in amounts))\n    highest_place = max(0, max(amount.adjusted() for amount in amounts))\n    precision = highest_place - lowest_place + 1 + len(str(len(amounts)))\n\n    with localcontext(Context(prec=precision, rounding=ROUND_HALF_UP)):\n        rounded = sum(amounts, Decimal(\"0\")).quantize(_CENT)\n\n    return \"0.00\" if rounded.is_zero() else format(rounded, \"f\")",
  "scored-invoice-1-plan": "**Dry run \u2014 round each line to cents using `ROUND_HALF_UP`, then add:**\n\n| Input | Rounded line | Running total |\n|---:|---:|---:|\n| `12.495` | `12.50` | `12.50` |\n| `-3.005` | `-3.01` | `9.49` |\n| `0.015` | `0.02` | `9.51` |\n| `-0.004` | `-0.00` | `9.51` |\n| `0.005` | `0.01` | `9.52` |\n| `-0.005` | `-0.01` | `9.51` |\n\nThe ledger returns `\"9.51\"`.\n\n**Shortest counterexample:** `[\"0.005\", \"-0.004\"]`. Two entries are necessary to include both a charge and a credit.\n\n- **Line-level rounding:** `0.01 + (-0.00) = 0.01` \u2192 `\"0.01\"`.\n- **Total-level rounding:** `0.005 + (-0.004) = 0.001`, which rounds to `\"0.00\"`.\n\n**Implementation plan:** Keep parsing inputs with `Decimal`, but quantize each line to `Decimal(\"0.01\")` with `ROUND_HALF_UP` before adding it. Sum the rounded values exactly, return `\"0.00\"` for any zero total, and format all other totals with exactly two decimal places.",
  "scored-invoice-1-rewrite": "from decimal import Context, Decimal, MAX_EMAX, MIN_EMIN, ROUND_HALF_UP\n\n_CENT = Decimal(\"0.01\")\n\n\ndef total(lines):\n    amounts = [Decimal(line) for line in lines]\n    amounts = [amount for amount in amounts if not amount.is_zero()]\n    if not amounts:\n        return \"0.00\"\n\n    # Allow enough digits to sum exactly, including carries and the cents place.\n    lowest_place = min(-2, min(amount.as_tuple().exponent for amount in amounts))\n    highest_place = max(amount.adjusted() for amount in amounts)\n    precision = max(1, highest_place - lowest_place + 1) + len(str(len(amounts)))\n    context = Context(\n        prec=precision,\n        rounding=ROUND_HALF_UP,\n        Emin=MIN_EMIN,\n        Emax=MAX_EMAX,\n    )\n\n    amount = Decimal(0)\n    for line in amounts:\n        amount = context.add(amount, line)\n\n    rounded = context.quantize(amount, _CENT)\n    return \"0.00\" if rounded.is_zero() else format(rounded, \"f\")",
  "scored-invoice-2-append": "from decimal import Context, Decimal, MAX_EMAX, MIN_EMIN, ROUND_HALF_UP, localcontext\n\n\n_CENT = Decimal(\"0.01\")\n\n\ndef total(lines: list[str]) -> str:\n    amounts = [Decimal(line) for line in lines]\n    if not amounts:\n        return \"0.00\"\n\n    # Leave room for every input digit, carries from addition, and cents.\n    lowest_place = min(-2, min(amount.as_tuple().exponent for amount in amounts))\n    highest_place = max(0, max(amount.adjusted() for amount in amounts))\n    precision = highest_place - lowest_place + 1 + len(str(len(amounts)))\n\n    with localcontext(Context(prec=precision, Emax=MAX_EMAX, Emin=MIN_EMIN)):\n        amount = sum(amounts, Decimal(\"0\"))\n        rounded = amount.quantize(_CENT, rounding=ROUND_HALF_UP)\n\n    return \"0.00\" if rounded.is_zero() else format(rounded, \"f\")",
  "scored-invoice-2-plan": "**The ledger total is `9.51`.** Round each line to cents using `ROUND_HALF_UP`, then add:\n\n| Input | Rounded line | Running total |\n|---:|---:|---:|\n| `12.495` | `12.50` | `12.50` |\n| `-3.005` | `-3.01` | `9.49` |\n| `0.015` | `0.02` | `9.51` |\n| `-0.004` | `-0.00` | `9.51` |\n| `0.005` | `0.01` | `9.52` |\n| `-0.005` | `-0.01` | `9.51` |\n\n**Shortest counterexample:** `[\"0.005\", \"-0.004\"]`. Two lines are the minimum because the list must contain both a charge and a credit.\n\n- **Round each line first:** `0.01 + (-0.00) = 0.01`.\n- **Round only the total:** `0.005 - 0.004 = 0.001`, which rounds to `0.00`.\n\n**Plan:** The current `total` sums unrounded `Decimal` values and returns their string form. Instead, parse each line as a `Decimal`, quantize it to `0.01` with `ROUND_HALF_UP`, and accumulate the rounded amounts as integer cents. Format the result with exactly two decimal places, returning `0.00` whenever the accumulated cents are zero.",
  "scored-invoice-2-rewrite": "from decimal import Decimal\nfrom fractions import Fraction\n\n\ndef total(lines):\n    \"\"\"Sum dollar amounts exactly, then round the total half-up to cents.\"\"\"\n    exact_cents = sum((Fraction(Decimal(line)) for line in lines), Fraction(0)) * 100\n    cents, remainder = divmod(abs(exact_cents.numerator), exact_cents.denominator)\n    if 2 * remainder >= exact_cents.denominator:\n        cents += 1\n\n    sign = \"-\" if exact_cents < 0 and cents else \"\"\n    dollars, pennies = divmod(cents, 100)\n    return f\"{sign}{Decimal(dollars):f}.{pennies:02d}\"",
  "scored-invoice-3-append": "from decimal import MAX_EMAX, MIN_EMIN, Context, Decimal, ROUND_HALF_UP, localcontext\n\n_CENT = Decimal(\"0.01\")\n\n\ndef total(lines):\n    amounts = [amount for line in lines if (amount := Decimal(line))]\n    if not amounts:\n        return \"0.00\"\n\n    # Allow for all input decimal places, the cents place, and carries.\n    lowest_place = min(-2, min(amount.as_tuple().exponent for amount in amounts))\n    highest_place = max(-2, max(amount.adjusted() for amount in amounts))\n    precision = highest_place - lowest_place + 1 + len(str(len(amounts)))\n\n    with localcontext(Context(prec=precision, Emin=MIN_EMIN, Emax=MAX_EMAX)):\n        amount = sum(amounts, Decimal(0))\n        rounded = amount.quantize(_CENT, rounding=ROUND_HALF_UP)\n\n    return \"0.00\" if rounded.is_zero() else format(rounded, \".2f\")",
  "scored-invoice-3-plan": "The starting module sums the unrounded `Decimal` values. The selected rule is to round each line to cents with `ROUND_HALF_UP` before adding it to the ledger.\n\n| Input | Rounded line | Running total |\n|---:|---:|---:|\n| `12.495` | `12.50` | `12.50` |\n| `-3.005` | `-3.01` | `9.49` |\n| `0.015` | `0.02` | `9.51` |\n| `-0.004` | `-0.00` | `9.51` |\n| `0.005` | `0.01` | `9.52` |\n| `-0.005` | `-0.01` | `9.51` |\n\nThe line-level total is **`9.51`**. For comparison, the unrounded sum is `9.501`, which rounds to `9.50`.\n\n**Shortest counterexample:** `[\"0.005\", \"-0.004\"]`. Two lines are necessary to have both a charge and a credit.\n- **Line-level:** `0.01 + (-0.00) = 0.01`.\n- **Total-level:** `0.005 - 0.004 = 0.001`, which rounds to `0.00`.\n\n**Implementation plan:** Parse each string as a `Decimal`, quantize each line to `0.01` with `ROUND_HALF_UP`, and sum the rounded lines. If the total is zero, return `\"0.00\"` regardless of its sign; otherwise, format it with exactly two decimal places.",
  "scored-invoice-3-rewrite": "from decimal import Context, Decimal, MAX_EMAX, MIN_EMIN, ROUND_HALF_UP, localcontext\n\n\n_CENT = Decimal(\"0.01\")\n\n\ndef total(lines):\n    amounts = []\n    for line in lines:\n        amount = Decimal(line)\n        if not amount.is_zero():\n            amounts.append(amount)\n\n    if not amounts:\n        return \"0.00\"\n\n    # Cover every input digit, the cents place, and any carry from summation.\n    lowest_place = min(-2, min(amount.as_tuple().exponent for amount in amounts))\n    highest_place = max(0, max(amount.adjusted() for amount in amounts))\n    precision = highest_place - lowest_place + 1 + len(str(len(amounts)))\n\n    with localcontext(Context(prec=precision, Emax=MAX_EMAX, Emin=MIN_EMIN)):\n        amount = sum(amounts, Decimal(\"0\"))\n        rounded = amount.quantize(_CENT, rounding=ROUND_HALF_UP)\n\n    return \"0.00\" if rounded.is_zero() else format(rounded, \"f\")",
  "scored-invoice-4-append": "from decimal import MAX_EMAX, MIN_EMIN, Decimal, ROUND_HALF_UP, localcontext\n\n_CENT = Decimal(\"0.01\")\n\n\ndef total(lines: list[str]) -> str:\n    amounts = [Decimal(line) for line in lines]\n    amounts = [amount for amount in amounts if not amount.is_zero()]\n    if not amounts:\n        return \"0.00\"\n\n    lowest_place = min(-2, min(amount.as_tuple().exponent for amount in amounts))\n    highest_place = max(amount.adjusted() for amount in amounts)\n\n    # Preserve every input digit and leave room for carries during summation.\n    precision = max(1, highest_place - lowest_place + 1) + len(str(len(amounts)))\n    with localcontext(prec=precision, Emin=MIN_EMIN, Emax=MAX_EMAX, clamp=0):\n        amount = sum(amounts, Decimal(0))\n        rounded = amount.quantize(_CENT, rounding=ROUND_HALF_UP)\n\n    return \"0.00\" if rounded.is_zero() else format(rounded, \".2f\")",
  "scored-invoice-4-plan": "**Dry run \u2014 round each line half up to cents, then add:**\n\n| Input | Rounded line | Running total |\n|---:|---:|---:|\n| `12.495` | `12.50` | `12.50` |\n| `-3.005` | `-3.01` | `9.49` |\n| `0.015` | `0.02` | `9.51` |\n| `-0.004` | `-0.00` | `9.51` |\n| `0.005` | `0.01` | `9.52` |\n| `-0.005` | `-0.01` | `9.51` |\n\nThe function should return `\"9.51\"`.\n\n**Shortest counterexample:** `[\"0.005\", \"-0.004\"]`. Two lines are the minimum because the list must contain both a charge and a credit.\n\n- **Line-level rounding:** `0.01 + (-0.00) = 0.01`.\n- **Total-level rounding:** `0.005 + (-0.004) = 0.001`, which rounds to `0.00`.\n\n**Plan:** The current module sums unrounded `Decimal` values and returns `str(amount)`, so it neither rounds each line nor guarantees two decimal places. Parse each line as a `Decimal`, quantize it to `0.01` with `ROUND_HALF_UP`, and add the rounded amounts exactly. Return `\"0.00\"` if the total is zero; otherwise format it with exactly two decimal places.",
  "scored-invoice-4-rewrite": "from decimal import Context, Decimal, MAX_EMAX, MIN_EMIN, ROUND_HALF_UP, localcontext\n\n_CENT = Decimal(\"0.01\")\n_ZERO = Decimal(\"0\")\n\n\ndef total(lines: list[str]) -> str:\n    amounts = [Decimal(line) for line in lines]\n    if not amounts:\n        return \"0.00\"\n\n    # Allow enough digits to align the inputs and sum them without rounding.\n    lowest_place = min(-2, min(amount.as_tuple().exponent for amount in amounts))\n    highest_place = max(0, max(amount.adjusted() for amount in amounts))\n    precision = highest_place - lowest_place + 1 + len(str(len(amounts)))\n\n    with localcontext(Context(prec=precision, Emin=MIN_EMIN, Emax=MAX_EMAX)):\n        rounded = sum(amounts, _ZERO).quantize(_CENT, rounding=ROUND_HALF_UP)\n\n    return \"0.00\" if rounded.is_zero() else format(rounded, \"f\")",
  "scored-invoice-5-append": "from decimal import Context, Decimal, MAX_EMAX, MIN_EMIN, ROUND_HALF_UP, localcontext\n\n_CENT = Decimal(\"0.01\")\n_ZERO = Decimal(\"0\")\n\n\ndef total(lines):\n    amounts = [Decimal(line) for line in lines]\n    if not amounts:\n        return \"0.00\"\n\n    # Keep every input digit, with room for carries and the final cents.\n    lowest_place = min(-2, min(amount.as_tuple().exponent for amount in amounts))\n    highest_place = max(0, max(amount.adjusted() for amount in amounts))\n    precision = highest_place - lowest_place + 1 + len(str(len(amounts)))\n\n    with localcontext(Context(prec=precision, Emin=MIN_EMIN, Emax=MAX_EMAX)):\n        rounded = sum(amounts, _ZERO).quantize(_CENT, rounding=ROUND_HALF_UP)\n\n    return \"0.00\" if rounded.is_zero() else format(rounded, \".2f\")",
  "scored-invoice-5-plan": "The current module sums the inputs without rounding. Under the selected rule, each line is rounded to cents with `ROUND_HALF_UP` before it enters the running total.\n\n| Input | Rounded line | Running total |\n|---:|---:|---:|\n| `12.495` | `12.50` | `12.50` |\n| `-3.005` | `-3.01` | `9.49` |\n| `0.015` | `0.02` | `9.51` |\n| `-0.004` | `-0.00` | `9.51` |\n| `0.005` | `0.01` | `9.52` |\n| `-0.005` | `-0.01` | `9.51` |\n\n**Returned total:** `\"9.51\"`.\n\n**Shortest counterexample:** `[\"0.005\", \"-0.004\"]`. Two lines are the minimum because the list needs both a charge and a credit.\n- **Line-level rounding:** `0.01 + (-0.00) = 0.01`.\n- **Total-level rounding:** `0.005 + (-0.004) = 0.001`, which rounds to `0.00`.\n\n**Plan:** Parse each string as a `Decimal`, quantize each line to `Decimal(\"0.01\")` with `ROUND_HALF_UP`, and sum the rounded lines. Return `\"0.00\"` for any zero total, regardless of sign; otherwise format the total with exactly two decimal places.",
  "scored-invoice-5-rewrite": "from decimal import MAX_EMAX, MIN_EMIN, Context, Decimal, ROUND_HALF_UP, localcontext\n\n_CENT = Decimal(\"0.01\")\n\n\ndef total(lines):\n    amounts = [Decimal(line) for line in lines]\n    amounts = [amount for amount in amounts if not amount.is_zero()]\n    if not amounts:\n        return \"0.00\"\n\n    # Allow enough digits to align every input exactly and absorb any carry.\n    lowest_place = min(-2, min(amount.as_tuple().exponent for amount in amounts))\n    highest_place = max(-2, max(amount.adjusted() for amount in amounts))\n    precision = highest_place - lowest_place + 1 + len(str(len(amounts)))\n\n    with localcontext(\n        Context(prec=precision, rounding=ROUND_HALF_UP, Emin=MIN_EMIN, Emax=MAX_EMAX)\n    ):\n        rounded = sum(amounts, Decimal(0)).quantize(_CENT)\n\n    return \"0.00\" if rounded.is_zero() else format(rounded, \".2f\")",
  "scored-scheduler-1-append": "from datetime import datetime\nfrom zoneinfo import ZoneInfo\n\n\ndef service_day(stamp, venue_zone):\n    return datetime.fromisoformat(stamp).astimezone(ZoneInfo(venue_zone)).date().isoformat()",
  "scored-scheduler-1-plan": "**The booking date is the UTC date for every venue.** The venue-local dates below are comparison values only.\n\n| Input timestamp | UTC instant | Booking date (UTC) | America/Vancouver date | Pacific/Kiritimati date |\n|---|---|---|---|---|\n| `2026-11-01T01:45:00-07:00` | `2026-11-01T08:45:00Z` | `2026-11-01` | `2026-11-01` | `2026-11-01` |\n| `2026-11-01T01:15:00-08:00` | `2026-11-01T09:15:00Z` | `2026-11-01` | `2026-11-01` | `2026-11-01` |\n| `2027-01-01T00:10:00+14:00` | `2026-12-31T10:10:00Z` | `2026-12-31` | `2026-12-31` | `2027-01-01` |\n\nThe first booking occurs **30 minutes before** the second. During Vancouver\u2019s fall-back hour, `01:45` at `\u221207:00` occurs before `01:15` at `\u221208:00`. Sorting by the printed wall time would put `01:15` first because it ignores the offsets.\n\n**Plan:** Replace the current string split, which returns the date as written, with `datetime.fromisoformat(stamp).astimezone(UTC).date().isoformat()`. Keep `venue_zone` in the function signature for compatibility, but don\u2019t use it in the calculation. Replace the unused `ZoneInfo` import with `UTC` from `datetime`, and test the three cases above plus a timestamp ending in `Z`.",
  "scored-scheduler-1-rewrite": "from datetime import datetime\nfrom zoneinfo import ZoneInfo\n\n\ndef service_day(stamp, venue_zone):\n    booking = datetime.fromisoformat(stamp)\n    return booking.astimezone(ZoneInfo(venue_zone)).date().isoformat()",
  "scored-scheduler-2-append": "from datetime import datetime\nfrom zoneinfo import ZoneInfo\n\n\ndef service_day(stamp: str, venue_zone: str) -> str:\n    return (\n        datetime.fromisoformat(stamp)\n        .astimezone(ZoneInfo(venue_zone))\n        .date()\n        .isoformat()\n    )",
  "scored-scheduler-2-plan": "Under the current rule, the **UTC date** owns the booking for every venue. The venue-local dates below are for comparison only.\n\n| Input timestamp | UTC instant | Booking date (UTC) | America/Vancouver date | Pacific/Kiritimati date |\n|---|---|---|---|---|\n| `2026-11-01T01:45:00-07:00` | `2026-11-01T08:45:00Z` | `2026-11-01` | `2026-11-01` | `2026-11-01` |\n| `2026-11-01T01:15:00-08:00` | `2026-11-01T09:15:00Z` | `2026-11-01` | `2026-11-01` | `2026-11-01` |\n| `2027-01-01T00:10:00+14:00` | `2026-12-31T10:10:00Z` | `2026-12-31` | `2026-12-31` | `2027-01-01` |\n\nThe first booking is **30 minutes earlier** than the second. Vancouver\u2019s clock falls back during that interval: `01:45` at `-07:00` occurs before `01:15` at `-08:00`. Sorting by wall time alone would put `01:15` first and reverse the actual order.\n\n**Plan:** Replace `stamp.split('T')[0]`, which returns the date as written and gets the third case wrong. Parse `stamp` with `datetime.fromisoformat`, convert the resulting aware datetime to UTC, and return its date with `.date().isoformat()`. Keep `venue_zone` in the function signature for compatibility, but do not use it in the calculation.",
  "scored-scheduler-2-rewrite": "from datetime import datetime\nfrom zoneinfo import ZoneInfo\n\n\ndef service_day(stamp, venue_zone):\n    return datetime.fromisoformat(stamp).astimezone(ZoneInfo(venue_zone)).date().isoformat()",
  "scored-scheduler-3-append": "from datetime import datetime\nfrom zoneinfo import ZoneInfo\n\n\ndef service_day(stamp, venue_zone):\n    instant = datetime.fromisoformat(stamp)\n    return instant.astimezone(ZoneInfo(venue_zone)).date().isoformat()",
  "scored-scheduler-3-plan": "Under the current rule, the **UTC date** owns the booking. The venue-local dates below are independent comparisons and do not affect the result.\n\n| Input timestamp | UTC instant | Booking date (UTC) | America/Vancouver date | Pacific/Kiritimati date |\n|---|---|---|---|---|\n| `2026-11-01T01:45:00-07:00` | `2026-11-01T08:45:00Z` | `2026-11-01` | `2026-11-01` | `2026-11-01` |\n| `2026-11-01T01:15:00-08:00` | `2026-11-01T09:15:00Z` | `2026-11-01` | `2026-11-01` | `2026-11-01` |\n| `2027-01-01T00:10:00+14:00` | `2026-12-31T10:10:00Z` | `2026-12-31` | `2026-12-31` | `2027-01-01` |\n\nThe `01:45-07:00` booking comes first, 30 minutes before `01:15-08:00`. Vancouver\u2019s fall-back repeats the 01:00 hour, so sorting by the printed wall times alone would put `01:15` first and reverse the actual order.\n\n**Plan:** The current `stamp.split('T')[0]` returns the date as written, which is wrong for the third booking. Replace it with `datetime.fromisoformat` parsing, convert the offset-aware result to UTC, then return `.date().isoformat()`. Keep `venue_zone` in the signature but leave it unused under the UTC rule, remove the unused `ZoneInfo` import, and verify all three rows.",
  "scored-scheduler-3-rewrite": "from datetime import datetime\nfrom zoneinfo import ZoneInfo\n\n\ndef service_day(stamp, venue_zone):\n    instant = datetime.fromisoformat(stamp)\n    return instant.astimezone(ZoneInfo(venue_zone)).date().isoformat()",
  "scored-scheduler-4-append": "from datetime import datetime\nfrom zoneinfo import ZoneInfo\n\n\ndef service_day(stamp, venue_zone):\n    return datetime.fromisoformat(stamp).astimezone(ZoneInfo(venue_zone)).date().isoformat()",
  "scored-scheduler-4-plan": "The booking date is the **UTC calendar date** for every venue. The venue-local dates below are comparison values only.\n\n| Input timestamp | UTC instant | Booking date (UTC) | America/Vancouver date | Pacific/Kiritimati date |\n|---|---|---|---|---|\n| `2026-11-01T01:45:00-07:00` | `2026-11-01T08:45:00Z` | `2026-11-01` | `2026-11-01` | `2026-11-01` |\n| `2026-11-01T01:15:00-08:00` | `2026-11-01T09:15:00Z` | `2026-11-01` | `2026-11-01` | `2026-11-01` |\n| `2027-01-01T00:10:00+14:00` | `2026-12-31T10:10:00Z` | `2026-12-31` | `2026-12-31` | `2027-01-01` |\n\nThe first booking occurs **30 minutes before** the second. Vancouver\u2019s clocks fall back during that interval, so sorting by the printed wall times alone would put `01:15` before `01:45` and reverse the true order.\n\n**Plan:** Replace `stamp.split('T')[0]`, which takes the date as written and ignores the offset. Parse `stamp` with `datetime.fromisoformat`, convert it to UTC, and return `.date().isoformat()`. Keep `venue_zone` in the function signature for compatibility, but don\u2019t use it in the calculation. Test the three rows above and a `Z` input.",
  "scored-scheduler-4-rewrite": "from datetime import datetime\nfrom zoneinfo import ZoneInfo\n\n\ndef service_day(stamp, venue_zone):\n    booking = datetime.fromisoformat(stamp)\n    return booking.astimezone(ZoneInfo(venue_zone)).date().isoformat()",
  "scored-scheduler-5-append": "from datetime import datetime\nfrom zoneinfo import ZoneInfo\n\n\ndef service_day(stamp, venue_zone):\n    instant = datetime.fromisoformat(stamp)\n    return instant.astimezone(ZoneInfo(venue_zone)).date().isoformat()",
  "scored-scheduler-5-plan": "Under the current rule, the booking date is the **UTC calendar date**, regardless of venue. The two venue columns are independent comparisons, not inputs to that rule.\n\n| Input timestamp | UTC instant | Booking date (UTC) | America/Vancouver date | Pacific/Kiritimati date |\n|---|---|---|---|---|\n| `2026-11-01T01:45:00-07:00` | `2026-11-01T08:45:00Z` | `2026-11-01` | `2026-11-01` | `2026-11-01` |\n| `2026-11-01T01:15:00-08:00` | `2026-11-01T09:15:00Z` | `2026-11-01` | `2026-11-01` | `2026-11-01` |\n| `2027-01-01T00:10:00+14:00` | `2026-12-31T10:10:00Z` | `2026-12-31` | `2026-12-31` | `2027-01-01` |\n\nThe first booking is **30 minutes earlier** than the second. Sorting by the clock times printed in the inputs would put `01:15` before `01:45`, reversing their actual order because it ignores the offsets.\n\n**Plan:** The current `split('T')[0]` takes the input\u2019s calendar date, so it gets the third booking wrong. Replace it with `datetime.fromisoformat`, convert the parsed timestamp to UTC, then return `.date().isoformat()`. Keep `venue_zone` in the signature for compatibility, but leave it unused and remove the `ZoneInfo` import. Test all three cases and an equivalent timestamp ending in `Z`.",
  "scored-scheduler-5-rewrite": "from datetime import datetime\nfrom zoneinfo import ZoneInfo\n\n\ndef service_day(stamp, venue_zone):\n    booking = datetime.fromisoformat(stamp)\n    return booking.astimezone(ZoneInfo(venue_zone)).date().isoformat()"
}