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 notes:
- Deduplication keeps the first insertion position but takes the last value, and the retained row's index is that value's original index. Dedup order is by first position, but the index used for tie-breaking and report order is the last occurrence's index.
- Processing order is priority ascending, with ties broken by original index.
- Validation (any failure goes to rejected): duration is a positive int and <= 90; start >= now + 60 minutes; the local date of start is not the blackout day; end < cutoff, where cutoff is 18:00 on the start's local day.
- A cancelled appointment is rejected because cancelled_blocks is false.
- Validation runs before the capacity check, and only accepted intervals are counted. Since cancelled_blocks is false, no cancelled appointment reserves capacity.
- Overlap is counted by intersection with adjacency false, so intervals sharing an endpoint overlap: a.start <= b.end and b.start <= a.end. The appointment is accepted if the count is below capacity.
- Output lists are sorted by retained original index. The blocked list is always empty under the current policy, but the code still supports it.
- Dedup is done with a dict keyed by id: the first insertion position is preserved by dict order, and the value is replaced on later duplicates, along with its index.
- UTC arithmetic is done by converting to UTC. The cutoff is built from the local date in the zone, then converted to UTC for comparison.

```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\nfrom zoneinfo import ZoneInfo\n\ndef parse(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.utcoffset() is None:\n        raise ValueError('naive')\n    return d\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, overlaps\n\ndef run(payload, policy):\n    now = parse(payload['now']).astimezone(timezone.utc)\n    tz = ZoneInfo(policy['timezone'])\n    rows = {}\n    for i, a in enumerate(payload.get('appointments', [])):\n        k = a['id']\n        if k in rows:\n            if policy['duplicate_policy'] == 'last':\n                rows[k] = (i, a)\n        else:\n            rows[k] = (i, a)\n    items = list(rows.values())\n    sgn = -1 if policy['priority_high_first'] else 1\n    items.sort(key=lambda t: (sgn * 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            d = a['duration']\n            if isinstance(d, bool) or not isinstance(d, int):\n                raise ValueError\n            if d <= 0 or d > policy['duration_max']:\n                raise ValueError\n            st = parse(a['start'])\n            stu = st.astimezone(timezone.utc)\n            if stu < now + lead:\n                raise ValueError\n            loc = stu.astimezone(tz)\n            if loc.date().isoformat() == policy['blackout_day']:\n                raise ValueError\n            cut = datetime(loc.year, loc.month, loc.day, policy['cutoff_hour'], 0, tzinfo=tz).astimezone(timezone.utc)\n            end = stu + timedelta(minutes=d)\n            if policy['cutoff_inclusive']:\n                if end > cut:\n                    raise ValueError\n            elif end >= cut:\n                raise ValueError\n            cancelled = bool(a.get('cancelled', False))\n            if cancelled and not policy['cancelled_blocks']:\n                raise ValueError\n            iv = (stu, end)\n            n = sum(1 for x in accepted if overlaps(iv, 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(iv)\n            (blocked if cancelled else selected).append((idx, a['id']))\n        else:\n            rejected.append((idx, a['id']))\n    def out(l):\n        if policy['report_order'] == 'id':\n            return [x[1] for x in sorted(l, key=lambda t: t[1])]\n        return [x[1] for x in sorted(l, key=lambda t: t[0])]\n    return {'selected': out(selected), 'blocked': out(blocked), 'rejected': out(rejected)}\n"}}
```