Current policy after applying all updates:
- cutoff_hour 17, cutoff_inclusive true, lead_minutes 30, timezone America/New_York
- adjacency_allowed true, cancelled_blocks true, duplicate_policy first, duration_max 120
- capacity 1, report_order id
- blackout_day 2026-11-01, priority_high_first true

Design decisions:
- Deduplication keeps the first occurrence under "first" and the last under "last". The retained row sits at the first-seen position, and its original index is the index of the chosen value.
- Rows are processed by priority (descending when priority_high_first), with ties broken by original index.
- Validation order: duration, then lead time, then blackout, then cutoff. A cancelled appointment with cancelled_blocks=false is rejected.
- An appointment that passes validation is accepted only if the number of accepted intervals overlapping it is below capacity. Cancelled ones that pass validation reserve capacity and go to blocked.
- Overlap with adjacency_allowed means a.start < b.end and b.start < a.end; otherwise it uses <= on both sides.
- Output lists sort by id, or by retained original index when report_order is "index". Ids are sorted with a key that keeps mixed types safe.
- Datetimes are parsed with fromisoformat, with "Z" replaced by "+00:00".
- Arithmetic uses UTC. The cutoff is built as a local datetime in the zone and compared in UTC.

```json
{"files": {"main.py": "from core import run\nfrom policy import POLICY\ndef evaluate(payload):\n    return run(payload, POLICY)\n", "policy.py": "POLICY = {\n    'cutoff_hour': 17,\n    'cutoff_inclusive': True,\n    'lead_minutes': 30,\n    'timezone': 'America/New_York',\n    'adjacency_allowed': True,\n    'cancelled_blocks': True,\n    'duplicate_policy': 'first',\n    'duration_max': 120,\n    'capacity': 1,\n    'report_order': 'id',\n    'blackout_day': '2026-11-01',\n    'priority_high_first': True,\n}\n", "helpers.py": "from datetime import datetime, timedelta, timezone\n\ndef parse_dt(s):\n    if isinstance(s, str) and s.endswith('Z'):\n        s = s[:-1] + '+00:00'\n    return datetime.fromisoformat(s)\n\ndef to_utc(d):\n    return d.astimezone(timezone.utc)\n\ndef overlaps(a, b, adj):\n    if adj:\n        return a[0] < b[1] and b[0] < a[1]\n    return a[0] <= b[1] and b[0] <= a[1]\n", "core.py": "from datetime import datetime, timedelta, timezone\nfrom zoneinfo import ZoneInfo\nfrom helpers import parse_dt, to_utc, overlaps\n\ndef run(payload, policy):\n    tz = ZoneInfo(policy['timezone'])\n    now = to_utc(parse_dt(payload['now']))\n    rows = payload.get('appointments', [])\n    chosen = {}\n    order = []\n    for i, r in enumerate(rows):\n        k = r['id']\n        if k not in chosen:\n            order.append(k)\n            chosen[k] = (i, r)\n        elif policy['duplicate_policy'] == 'last':\n            chosen[k] = (i, r)\n    items = [(chosen[k][0], chosen[k][1]) for k in order]\n    hi = policy['priority_high_first']\n    items.sort(key=lambda t: (-t[1]['priority'] if hi else t[1]['priority'], t[0]))\n    accepted = []\n    selected, blocked, rejected = [], [], []\n    idx = {}\n    for i, r in items:\n        idx[r['id']] = i\n        rid = r['id']\n        ok = True\n        try:\n            dur = r['duration']\n            if r.get('cancelled') and not policy['cancelled_blocks']:\n                ok = False\n            if ok and not (dur > 0 and dur <= policy['duration_max']):\n                ok = False\n            if ok:\n                st = to_utc(parse_dt(r['start']))\n                en = st + timedelta(minutes=dur)\n                if st < now + timedelta(minutes=policy['lead_minutes']):\n                    ok = False\n            if ok:\n                loc = st.astimezone(tz)\n                if loc.date().isoformat() == policy['blackout_day']:\n                    ok = False\n            if ok:\n                cut = datetime(loc.year, loc.month, loc.day, policy['cutoff_hour'], 0, tzinfo=tz)\n                cut = to_utc(cut)\n                if policy['cutoff_inclusive']:\n                    ok = en <= cut\n                else:\n                    ok = en < cut\n            if ok:\n                iv = (st, en)\n                n = sum(1 for a in accepted if overlaps(iv, a, policy['adjacency_allowed']))\n                if n >= policy['capacity']:\n                    ok = False\n        except Exception:\n            ok = False\n        if not ok:\n            rejected.append(rid)\n            continue\n        accepted.append(iv)\n        if r.get('cancelled'):\n            blocked.append(rid)\n        else:\n            selected.append(rid)\n    def srt(lst):\n        if policy['report_order'] == 'index':\n            return sorted(lst, key=lambda x: idx[x])\n        return sorted(lst, key=lambda x: (str(type(x)), x))\n    return {'selected': srt(selected), 'blocked': srt(blocked), 'rejected': srt(rejected)}\n"}}
```