Resolved current policy:
- cutoff_hour 18, cutoff_inclusive false, lead_minutes 60, timezone UTC
- adjacency_allowed false, cancelled_blocks false, duplicate_policy last, duration_max 90
- capacity 2, report_order input
- blackout_day 2026-11-02, priority_high_first false

Design decisions:
- Deduplication keeps the first insertion position for each id but uses the last value, with that value's own original index.
- Processing order is priority ascending, ties by original index.
- Output lists are sorted by retained original index, since report_order is "input".
- Intervals are compared in UTC. With adjacency_allowed false, touching endpoints count as overlapping.
- Accepted intervals include only non-cancelled appointments, because cancelled ones are rejected when cancelled_blocks is false.
- Invalid appointments are rejected.
- An id that is dropped as a duplicate does not appear separately.
- The cutoff is computed on the start's local day in the policy timezone.
- Local-time conversion uses ZoneInfo.
- Dedup position: the retained row's "position" is the first occurrence's position. The output order uses the retained row's original index, as specified ("retained original index"), so I sort by that index.

```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': 18,\n    'cutoff_inclusive': False,\n    'lead_minutes': 60,\n    'timezone': 'UTC',\n    'adjacency_allowed': False,\n    'cancelled_blocks': False,\n    'duplicate_policy': 'last',\n    'duration_max': 90,\n    'capacity': 2,\n    'report_order': 'input',\n    'blackout_day': '2026-11-02',\n    'priority_high_first': False,\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    d = datetime.fromisoformat(s)\n    if d.tzinfo is None or d.tzinfo.utcoffset(d) is None:\n        raise ValueError('naive')\n    return d\n\ndef overlaps(a, b, adjacency_allowed):\n    if adjacency_allowed:\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, overlaps\n\ndef run(payload, policy):\n    now = parse_dt(payload['now']).astimezone(timezone.utc)\n    tz = ZoneInfo(policy['timezone'])\n    rows = list(payload.get('appointments', []))\n    kept = {}\n    order = []\n    for i, a in enumerate(rows):\n        k = a.get('id')\n        if k not in kept:\n            order.append(k)\n            kept[k] = (i, a)\n        elif policy['duplicate_policy'] == 'last':\n            kept[k] = (i, a)\n    items = [kept[k] for k in order]\n    rev = bool(policy['priority_high_first'])\n    if rev:\n        items.sort(key=lambda t: (-t[1]['priority'], t[0]))\n    else:\n        items.sort(key=lambda t: (t[1]['priority'], t[0]))\n    selected, blocked, rejected = [], [], []\n    accepted = []\n    lead = timedelta(minutes=policy['lead_minutes'])\n    for idx, a in items:\n        ok = False\n        try:\n            dur = a['duration']\n            if isinstance(dur, bool) or not isinstance(dur, (int, float)):\n                raise ValueError\n            if dur <= 0 or dur > policy['duration_max']:\n                raise ValueError\n            st = parse_dt(a['start']).astimezone(timezone.utc)\n            if st < now + lead:\n                raise ValueError\n            en = st + timedelta(minutes=dur)\n            local = st.astimezone(tz)\n            if local.date().isoformat() == policy['blackout_day']:\n                raise ValueError\n            cut = datetime(local.year, local.month, local.day, policy['cutoff_hour'], 0, tzinfo=tz).astimezone(timezone.utc)\n            if policy['cutoff_inclusive']:\n                if en > cut:\n                    raise ValueError\n            elif en >= cut:\n                raise ValueError\n            if a.get('cancelled') and not policy['cancelled_blocks']:\n                raise ValueError\n            n = sum(1 for x in accepted if overlaps((st, en), x, policy['adjacency_allowed']))\n            if n >= policy['capacity']:\n                raise ValueError\n            ok = True\n        except Exception:\n            ok = False\n        if ok:\n            accepted.append((st, en))\n            (blocked if a.get('cancelled') else selected).append((idx, a['id']))\n        else:\n            rejected.append((idx, a.get('id')))\n    def out(lst):\n        if policy['report_order'] == 'id':\n            return [x[1] for x in sorted(lst, key=lambda t: str(t[1]))]\n        return [x[1] for x in sorted(lst, key=lambda t: t[0])]\n    return {'selected': out(selected), 'blocked': out(blocked), 'rejected': out(rejected)}\n"}}
```