[
  {
    "id": "math",
    "version": "1.0.0",
    "tasks": [
      {
        "id": "crt-count",
        "title": "Overlapping congruences",
        "kind": "math",
        "prompt": "How many integers x with 0 <= x < 10^12 satisfy x ≡ 5 (mod 18), x ≡ 17 (mod 30), x ≡ 23 (mod 42), and are not divisible by 11? Submit the exact integer."
      },
      {
        "id": "blocked-lattice",
        "title": "Lattice paths avoiding checkpoints",
        "kind": "math",
        "prompt": "Count paths from (0,0) to (30,25) using steps (1,0) and (0,1), which never visit any of (10,8), (19,16), (25,20). Submit the exact integer."
      },
      {
        "id": "bounded-dyck",
        "title": "Bounded excursions with returns",
        "kind": "math",
        "prompt": "Count sequences of 36 steps, each +1 or -1, whose partial sums begin at 0, stay between 0 and 5 inclusive, end at 0, and equal 0 exactly four times after a step (including the final step; the initial 0 does not count). Submit the exact integer."
      },
      {
        "id": "urn-fraction",
        "title": "Conditional composition of a sample",
        "kind": "math",
        "prompt": "An urn contains 8 distinct red, 7 distinct blue and 6 distinct green balls. Nine balls are chosen uniformly without replacement. What is the probability that exactly 3 are red and at least 2 each are blue and green? Submit an exact reduced fraction."
      },
      {
        "id": "pattern-wait",
        "title": "Overlapping biased-coin pattern",
        "kind": "math",
        "prompt": "Independent coin flips have P(H)=2/3 and P(T)=1/3. Starting with no flips, what is the expected number of flips until the consecutive pattern HHTHH first appears? Overlapping occurrences are allowed. Submit an exact fraction."
      },
      {
        "id": "recurrence-sum",
        "title": "Signed recurrence and modular sum",
        "kind": "math",
        "prompt": "Let T0=2, T1=3, T2=5 and Tn=2*T(n-1)-T(n-2)+3*T(n-3) for n>=3. Find the least nonnegative residue of sum(Tn for n=0 through 5000 inclusive) modulo 1000000007. Submit the exact integer."
      },
      {
        "id": "integer-determinant",
        "title": "Structured integer determinant",
        "kind": "math",
        "prompt": "For 0-indexed i,j in {0,...,6}, define the 7 by 7 matrix A by A[i,j] = ((17*i+11*j+3*i*j) mod 19)-9+20*[i=j], where mod is the least nonnegative remainder and [i=j] is 1 if equal, 0 otherwise. Find det(A). Submit the exact integer."
      },
      {
        "id": "even-surjections",
        "title": "Surjections with even fibers",
        "kind": "math",
        "prompt": "How many functions from a labeled 14-element set to a labeled 6-element set are onto and have an even number of preimages at every codomain element? Submit the exact integer."
      },
      {
        "id": "fixed-size-subsets",
        "title": "Constrained subset sum",
        "kind": "math",
        "prompt": "How many 12-element subsets of {1,2,...,35} have sum exactly 210? Elements are distinct and order does not matter. Submit the exact integer."
      },
      {
        "id": "deleted-matching-trees",
        "title": "Spanning trees after deleting a matching",
        "kind": "math",
        "prompt": "Form a simple undirected graph with vertices a0,a1,a2,a3 and b0,b1,b2,b3,b4. Include every edge ai--bj except the four edges ai--bi for i=0,1,2,3. How many spanning trees does this labeled graph have? Submit the exact integer."
      },
      {
        "id": "fixed-weight-necklaces",
        "title": "Rotational equivalence with fixed weight",
        "kind": "math",
        "prompt": "How many binary necklaces of length 24 have exactly ten 1s? Two sequences are identified if one is a cyclic rotation of the other. Reflections are NOT identified. Submit the exact integer."
      },
      {
        "id": "decimal-automaton",
        "title": "Coupled digit constraints",
        "kind": "math",
        "prompt": "Count 18-digit positive base-10 integers (first digit nonzero) divisible by 37, whose digit sum is divisible by 7, and in which no two adjacent digits are equal. Submit the exact integer."
      }
    ]
  },
  {
    "id": "coding",
    "version": "1.0.0",
    "tasks": [
      {
        "id": "build-order",
        "title": "Dependency build planner",
        "kind": "coding",
        "prompt": "Repair this mini repository. solve({graph}) returns {order:[names]} or {error:\"cycle\"}. graph maps every node name to its dependencies; all dependency names exist as keys. Duplicate dependencies count once. Return the lexicographically smallest valid topological ordering (JS string ordering). Detect any cycle, including self-loops. Empty graph gives an empty order. Do not mutate the input.",
        "language": "javascript",
        "files": {
          "solution.js": "const { order } = require(\"./graph.js\");\nexports.solve = payload => ({order: order(payload.graph)});",
          "graph.js": "exports.order = graph => Object.keys(graph).sort(); // BUG: ignores dependencies and cycles"
        }
      },
      {
        "id": "warehouse-ledger",
        "title": "Inventory transfer ledger",
        "kind": "coding",
        "prompt": "Repair solve({stock,events}). stock maps location names to maps of SKU names to nonnegative integer quantities. Locations and SKUs in events may be new; their stock defaults to zero. Each event is {id,from,to,sku,qty}, qty positive integer, from != to. Process in input order. Only the FIRST event with a given id is processed, even if rejected; ignore subsequent events with that id. Accept a transfer only when source stock suffices, then subtract/add atomically. Return {stock,rejected:[ids]} where stock includes original locations/SKUs and locations/SKUs touched by ACCEPTED transfers, including zero quantities; rejected transfers create no entries. rejected is in processing order. Do not mutate input.",
        "language": "javascript",
        "files": {
          "solution.js": "const { transfer } = require(\"./ledger.js\");\nexports.solve = transfer;",
          "ledger.js": "exports.transfer = ({stock}) => ({stock, rejected: []}); // TODO apply idempotent atomic transfers"
        }
      },
      {
        "id": "catalog-page",
        "title": "Deterministic catalog pagination",
        "kind": "coding",
        "prompt": "Repair solve({items,page,perPage,minPrice,maxPrice}). Each item has unique integer id, string name, integer price (cents). page and perPage must be positive integers or return {error:\"bad_request\"}. Optional inclusive minPrice/maxPrice filters apply before sorting. Sort by price ascending then id ascending. Return {items,total,pages}; pages = ceil(total/perPage), including 0 for empty results. An out-of-range page has items:[] but retains total/pages. Do not mutate input.",
        "language": "javascript",
        "files": {
          "solution.js": "const { page } = require(\"./catalog.js\");\nexports.solve = page;",
          "catalog.js": "exports.page = p => ({items:p.items.slice(0,p.perPage),total:p.items.length,pages:1});"
        }
      },
      {
        "id": "log-summary",
        "title": "Structured log aggregation",
        "kind": "coding",
        "prompt": "Repair solve({text,level}). Split text on LF; remove one trailing CR from each line. Valid lines match exactly YYYY-MM-DD LEVEL message: the date is ten characters of digits/hyphens in that shape (calendar validity is not checked), then one space, level INFO/WARN/ERROR, then one space and a nonempty message. Count only valid lines whose level equals payload.level (case sensitive). Return {counts:{date:count},invalid:n} where invalid counts malformed lines regardless of requested level. Ignore empty lines after CR removal. Leading/trailing spaces are significant; do not trim. Messages may contain spaces.",
        "language": "javascript",
        "files": {
          "solution.js": "const { parse } = require(\"./logs.js\");\nexports.solve = ({text,level}) => ({counts:{},invalid:text.split(\"\\n\").filter(line=>!parse(line)).length});",
          "logs.js": "exports.parse = line => line.split(\" \"); // TODO strict parser"
        }
      },
      {
        "id": "event-reducer",
        "title": "Versioned document event reducer",
        "kind": "coding",
        "prompt": "Repair solve({events}). Events are {doc,version,type,value?}; doc is a string, version a nonnegative integer, type is \"set\" or \"delete\"; set value is JSON data. For each document, accept an event only if its version is strictly greater than the last accepted version (initially -1). Deletes advance the version even for absent documents, preventing stale resurrection. Return {documents,versions}; documents maps live documents to values, versions includes every document with an accepted event including deleted ones. Process input order and do not mutate input.",
        "language": "javascript",
        "files": {
          "solution.js": "const { reduce } = require(\"./events.js\");\nexports.solve = ({events}) => reduce(events);",
          "events.js": "exports.reduce = events => ({documents:Object.fromEntries(events.filter(e=>e.type===\"set\").map(e=>[e.doc,e.value])),versions:{}});"
        }
      },
      {
        "id": "csv-sales",
        "title": "Exact CSV sales totals",
        "kind": "coding",
        "prompt": "Repair solve({csv}). Parse CSV with a header containing region,amount,qty (column order may vary); CSV quoting and embedded newlines must work. Strip surrounding whitespace in region and numeric fields. Skip any row with empty region, missing fields, an amount not matching -?[0-9]+(\\.[0-9]{1,2})?, or qty not matching -?[0-9]+. Convert amount to exact integer cents, never binary floating point. Sum cents and qty by region; retain groups even if totals cancel to zero. Return a list of {region,cents,qty} sorted by region. If the header is absent or lacks required columns return {error:\"missing_column\"}. Blank CSV records are ignored. No filesystem data is needed; CSV is in payload.",
        "language": "python",
        "files": {
          "solution.py": "from sales import aggregate\ndef solve(payload):\n    return aggregate(payload[\"csv\"])\n",
          "sales.py": "def aggregate(text):\n    return [] # TODO parse quoted CSV, validate rows, sum exact cents\n"
        }
      },
      {
        "id": "markdown-outline",
        "title": "Markdown outline with stable anchors",
        "kind": "coding",
        "prompt": "Repair solve({documents}), where documents maps filenames to text. Process filenames in ascending Python string order and lines in source order. A heading is a line starting with 1 through 6 # characters followed by at least one ASCII space and a nonempty title; strip surrounding spaces from title. Ignore headings inside fenced code: a fence starts at column 0 with at least three backticks or tildes and optional trailing text; it closes only at column 0 with the same character at least the opening length, followed only by spaces. Other fence-looking lines inside do not close it. For a heading, slug = lowercase title, replace every maximal run of characters outside ASCII a-z/0-9 with one hyphen, trim hyphens; use \"section\" if empty. Ensure slugs unique per document: try base, then base-1, base-2,... until unused (including naturally occurring suffixed headings). Return [{file,level,title,slug}] in file/line order.",
        "language": "python",
        "files": {
          "solution.py": "from outline import headings\ndef solve(payload):\n    return headings(payload[\"documents\"])\n",
          "outline.py": "def headings(documents):\n    return [] # TODO fences and collision-aware anchors\n"
        }
      },
      {
        "id": "nested-config",
        "title": "Nested configuration validation",
        "kind": "coding",
        "prompt": "Repair solve({schema,config}). schema maps dotted field paths to {type,required}, with type one of string,integer,boolean,object,array. Path components are nonempty ASCII identifiers; traverse only dictionaries. A missing component, including traversal through a non-dictionary, means field absent. For an absent required path emit \"missing:<path>\"; absent optional paths are ignored. For present values of wrong type emit \"type:<path>:expected:<type>\". null matches none; integer means Python int excluding bool; object means dict; array means list. Extra fields are ignored. Return {valid:bool,errors:[strings sorted lexicographically]}. Do not mutate input.",
        "language": "python",
        "files": {
          "solution.py": "from validator import validate\ndef solve(payload):\n    return validate(payload[\"schema\"], payload[\"config\"])\n",
          "validator.py": "def validate(schema, config):\n    return {\"valid\": True, \"errors\": []} # TODO nested fields, strict types\n"
        }
      },
      {
        "id": "safe-template",
        "title": "One-pass escaped template rendering",
        "kind": "coding",
        "prompt": "Repair solve({text,values}). Replace placeholders matching {{ optional-spaces dotted.path optional-spaces }} where each path component is [A-Za-z_][A-Za-z0-9_]* and spaces means ASCII spaces only. Traverse dictionaries only. A missing path or a dictionary/list value leaves the EXACT original placeholder unchanged. Scalar values convert to text: null=\"\", true=\"true\", false=\"false\", strings unchanged, integers as decimal (inputs have no floats). HTML escape replacement text using &amp; &lt; &gt; &quot; &#39; for &,<,>,\",' respectively; preserve all other characters. Replace once: placeholders within inserted values are never expanded. Return the rendered string; the surrounding literal template is not escaped.",
        "language": "python",
        "files": {
          "solution.py": "from renderer import render\ndef solve(payload):\n    return render(payload[\"text\"],payload[\"values\"])\n",
          "renderer.py": "def render(text, values):\n    return text # TODO dotted lookup and escape only replacement values\n"
        }
      },
      {
        "id": "availability",
        "title": "Merged calendar availability",
        "kind": "coding",
        "prompt": "Repair solve({start,end,busy,minDuration}). All times and minDuration are integers, start<end and minDuration>=0. busy is a list of [a,b] with a<=b; intervals are half-open. Clip busy intervals to [start,end), discard empty intervals, merge overlaps and touching intervals, and return {busy:[merged intervals],free:[complement intervals of length >= minDuration],busyDuration:sum of merged lengths}. Never return empty free intervals, even when minDuration=0. Output intervals in ascending order; do not mutate input.",
        "language": "python",
        "files": {
          "solution.py": "from calendar_intervals import availability\ndef solve(payload):\n    return availability(payload)\n",
          "calendar_intervals.py": "def availability(p):\n    return {\"busy\":p[\"busy\"],\"free\":[],\"busyDuration\":0} # TODO clip, merge, complement\n"
        }
      }
    ]
  }
]
