prompt listlengths 1 1 | completion listlengths 1 1 | meta dict |
|---|---|---|
[
{
"role": "user",
"content": "Implement a strict double-entry bookkeeping journal using frozen dataclasses and precise Decimal arithmetic (standard library only). A `Posting` holds an account code (matching the pattern `^\\d{2}(-\\d{2}){0,2}$`, e.g. `10-10`) and a `Decimal` amount that is positive for debit... | [
{
"role": "assistant",
"content": "from __future__ import annotations\n\nimport re\nfrom collections import OrderedDict\nfrom dataclasses import dataclass, field\nfrom datetime import date\nfrom decimal import Decimal, ROUND_HALF_EVEN\nfrom typing import Optional, Tuple\n\nCENT = Decimal(\"0.01\")\nACCOUNT_... | {
"idx": 3404,
"topic": "accounting record dataclasses and schemas",
"difficulty": "hard",
"provider": "together",
"in_tokens": 0,
"out_tokens": 2690,
"latency_s": 125.6
} |
[
{
"role": "user",
"content": "You are given a CSV file `transactions.csv` where each row contains: date (YYYY-MM-DD), account (string), description (string), and amount (a decimal string in dollars, e.g. '123.45', possibly negative). Write a program that (1) reads the CSV, (2) validates each row: the date m... | [
{
"role": "assistant",
"content": "import csv\nfrom datetime import datetime\nfrom decimal import Decimal, ROUND_HALF_UP, InvalidOperation\n\nINPUT_FILE = 'transactions.csv'\nVALID_FILE = 'valid_transactions.csv'\nREPORT_FILE = 'validation_report.txt'\n\n\ndef validate_date(date_str):\n try:\n dat... | {
"idx": 3177,
"topic": "transaction CSV import, validation, and export",
"difficulty": "medium",
"provider": "together",
"in_tokens": 0,
"out_tokens": 820,
"latency_s": 2.2
} |
[
{
"role": "user",
"content": "A bookkeeper must reconcile an amortizing loan ledger. Given a principal P (a Decimal amount), a nominal annual interest rate r (Decimal, e.g. 0.05 for 5%), and a number of monthly payments n (integer), produce the full amortization schedule using exact Decimal arithmetic with ... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\n\nCENT = Decimal('0.01')\n\ndef cents(x):\n return Decimal(x).quantize(CENT, rounding=ROUND_HALF_UP)\n\ndef amortize(principal, annual_rate, n):\n principal = Decimal(principal)\n annual_rate = Decimal(annual_rate)\n ... | {
"idx": 3299,
"topic": "interest calculation and payment schedules",
"difficulty": "medium",
"provider": "together",
"in_tokens": 0,
"out_tokens": 690,
"latency_s": 8.5
} |
[
{
"role": "user",
"content": "A small agency processes sales invoices and must split each invoice's total into three parts: a 12% commission for the salesperson, an 8% tip for the support staff pool, and the remainder for the company. Because money must be tracked to the cent, all arithmetic uses Decimal wi... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\n\n\ndef split_invoices(invoices):\n \"\"\"Split invoice totals into commission, tip, and company portions.\n\n Args:\n invoices: list of (invoice_id, total_string) pairs.\n\n Returns:\n (entries, totals) wh... | {
"idx": 1498,
"topic": "commission, tip, and percentage splits",
"difficulty": "medium",
"provider": "together",
"in_tokens": 0,
"out_tokens": 936,
"latency_s": 7.8
} |
[
{
"role": "user",
"content": "A restaurant's bookkeeping software must post each paid invoice to a ledger, splitting the gross amount into a house commission, a tip pool divided among the servers, and the net revenue. Write a function `split_invoice(amount, commission_rate, tip_rate, servers)` where `amount... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\n\n\ndef split_invoice(amount, commission_rate, tip_rate, servers):\n \"\"\"Split a gross invoice into commission, tip shares, and net revenue.\n\n All amounts are Decimals quantized to two decimal places (ROUND_HALF_UP).\n ... | {
"idx": 3109,
"topic": "commission, tip, and percentage splits",
"difficulty": "medium",
"provider": "novita",
"in_tokens": 199,
"out_tokens": 1639,
"latency_s": 16.2
} |
[
{
"role": "user",
"content": "You maintain a simple double-entry ledger where each transaction is a list of (account, amount) lines, and the sum of amounts in a transaction must equal zero (debits positive, credits negative). Occasionally a transaction is entered incorrectly: it must be corrected by a 'reve... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\n\n\ndef apply_corrections(entries, corrections):\n balances = {}\n\n def check_and_post(lines):\n if sum((amt for _, amt in lines), Decimal('0')) != 0:\n raise ValueError('transaction does not balance to z... | {
"idx": 1858,
"topic": "correcting entries, reversals, and voided transactions",
"difficulty": "medium",
"provider": "together",
"in_tokens": 0,
"out_tokens": 733,
"latency_s": 2.1
} |
[
{
"role": "user",
"content": "Write a function `monthly_amortization_schedule(principal, annual_rate, years)` that builds a fixed-payment mortgage amortization schedule using Python's `decimal.Decimal` for exact monetary arithmetic. The monthly interest rate is `annual_rate / 12` (no compounding adjustment)... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\n\nCENT = Decimal('0.01')\n\ndef _round(x):\n return x.quantize(CENT, rounding=ROUND_HALF_UP)\n\ndef monthly_amortization_schedule(principal, annual_rate, years):\n principal = Decimal(str(principal))\n annual_rate = Deci... | {
"idx": 1568,
"topic": "loan and mortgage amortization schedules",
"difficulty": "easy",
"provider": "together",
"in_tokens": 0,
"out_tokens": 705,
"latency_s": 4.9
} |
[
{
"role": "user",
"content": "A bookkeeper needs to validate a chart of accounts and categorize expense entries. You are given a chart of accounts as a list of tuples (account_number, account_name, normal_balance) where normal_balance is 'debit' or 'credit', and a list of journal entries as tuples (account_... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\nfrom collections import defaultdict\n\n\ndef categorize_expenses(chart, entries):\n names = {}\n for account_number, account_name, _ in chart:\n names[account_number] = account_name\n\n totals = defaultdict(lambda... | {
"idx": 1411,
"topic": "chart of accounts and expense categorization",
"difficulty": "medium",
"provider": "together",
"in_tokens": 0,
"out_tokens": 720,
"latency_s": 6.2
} |
[
{
"role": "user",
"content": "A small business keeps its ledger on a cash basis but needs a month-end accrual adjustment report. You are given a list of invoices (each with an invoice date, an amount, and a boolean indicating whether it has been paid) and a list of payments (each with a payment date and amo... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\nfrom datetime import date\n\n\ndef accrual_adjustment(invoices, payments, cutoff):\n cutoff_date = date.fromisoformat(cutoff)\n\n total_invoiced = sum(\n (Decimal(amount) for _, amount in invoices),\n Decimal(... | {
"idx": 189,
"topic": "accrual versus cash basis adjustments",
"difficulty": "easy",
"provider": "together",
"in_tokens": 0,
"out_tokens": 550,
"latency_s": 43.6
} |
[
{
"role": "user",
"content": "Build a small command-line FIFO cost-basis bookkeeping tool. The program reads commands from standard input, one per line: `LOT <date> <qty> <price> <fee>` records a purchase lot where the lot's cost basis is `qty*price + fee`; `SELL <date> <qty> <price> <fee>` sells shares, co... | [
{
"role": "assistant",
"content": "import sys\nfrom decimal import Decimal, ROUND_HALF_EVEN\n\nCENT = Decimal(\"0.01\")\nZERO = Decimal(\"0\")\n\n\ndef q(amount):\n \"\"\"Quantize to cents with banker's rounding for display only.\"\"\"\n return amount.quantize(CENT, rounding=ROUND_HALF_EVEN)\n\n\nclas... | {
"idx": 2087,
"topic": "small bookkeeping command-line tool logic",
"difficulty": "hard",
"provider": "together",
"in_tokens": 0,
"out_tokens": 1176,
"latency_s": 7.8
} |
[
{
"role": "user",
"content": "You are building a settlement report for a multi-currency accounting journal. Each transaction in the journal consists of a currency code, a total amount given as a decimal string, and a list of (account_id, weight) pairs with positive integer weights; the total must be split a... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN, getcontext\nfrom collections import defaultdict\n\ngetcontext().prec = 50\n\nCURRENCY_RULES = {\n \"USD\": (ROUND_HALF_UP, Decimal(\"0.01\")),\n \"CHF\": (ROUND_HALF_EVEN, Decimal(\"0.01\")),\n \"JPY\": ... | {
"idx": 392,
"topic": "currency rounding rules with the Decimal type",
"difficulty": "hard",
"provider": "together",
"in_tokens": 0,
"out_tokens": 1526,
"latency_s": 58.4
} |
[
{
"role": "user",
"content": "You are maintaining a simple multi-currency ledger. Each transaction is given as a tuple (currency, amount) where amount is a Decimal that may be positive (a debit/receivable) or negative (a credit/payable). Your company reports in USD, and you are given a dictionary of exchang... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\n\ndef total_usd(transactions, rates, base_rates):\n current_total = Decimal('0')\n base_total = Decimal('0')\n for currency, amount in transactions:\n rate = rates.get(currency, Decimal('1'))\n base_rate = ... | {
"idx": 3286,
"topic": "multi-currency conversion and FX gain/loss",
"difficulty": "easy",
"provider": "together",
"in_tokens": 0,
"out_tokens": 628,
"latency_s": 5.5
} |
[
{
"role": "user",
"content": "Write a function `apply_sales_tax(amounts, rate)` that applies sales tax (or VAT) to a list of pre-tax invoice line amounts and returns the tax amounts, correctly rounded to the nearest cent. Each line amount is given as a string like '19.99' to avoid float issues, and the tax ... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\n\nTWO_PLACES = Decimal('0.01')\n\ndef apply_sales_tax(amounts, rate):\n tax_rate = Decimal(rate) / Decimal('100')\n results = []\n total = Decimal('0')\n for amount_str in amounts:\n amount = Decimal(amount_str... | {
"idx": 2038,
"topic": "sales tax and VAT computation and rounding",
"difficulty": "easy",
"provider": "together",
"in_tokens": 0,
"out_tokens": 379,
"latency_s": 1.6
} |
[
{
"role": "user",
"content": "Implement an append-only ledger that maintains an immutable audit trail for a small business. Each entry is a dictionary with a sequential id (starting at 1), a date string 'YYYY-MM-DD', a description, a Decimal amount (positive for debit, negative for credit), and a SHA-256 ha... | [
{
"role": "assistant",
"content": "import hashlib\nfrom decimal import Decimal, ROUND_HALF_UP\n\n\nclass ImmutableLedger:\n GENESIS = 'GENESIS'\n\n def __init__(self):\n self.entries = []\n self._prev_hash = self.GENESIS\n\n @staticmethod\n def _canonical(date, description, amount)... | {
"idx": 1790,
"topic": "audit trails and immutable entry logs",
"difficulty": "medium",
"provider": "baseten",
"in_tokens": 199,
"out_tokens": 842,
"latency_s": 7.8
} |
[
{
"role": "user",
"content": "At period end, a bookkeeper must generate closing entries from a trial balance of temporary (nominal) accounts. Given a dictionary mapping account names to balances (as strings, debit-positive for expenses, credit-positive for revenues, i.e. revenues > 0 and expenses < 0), prod... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\n\n\ndef two_places(value):\n return value.quantize(Decimal('0.01'), rounding=ROUND_HALF_UP)\n\n\ndef generate_closing_entries(trial_balance):\n \"\"\"Generate period-end closing entries from a trial balance of nominal accou... | {
"idx": 1294,
"topic": "period-end closing entries and routines",
"difficulty": "medium",
"provider": "together",
"in_tokens": 0,
"out_tokens": 920,
"latency_s": 14.5
} |
[
{
"role": "user",
"content": "Write a function `compute_net_pay(gross, federal_rate, state_rate, pre_tax_deductions)` that computes a payroll check for one employee. The gross pay, the federal withholding rate, the state withholding rate, and a list of pre-tax deduction amounts (e.g., health insurance premi... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\n\nCENT = Decimal('0.01')\n\n\ndef _round_to_cent(value):\n return value.quantize(CENT, rounding=ROUND_HALF_UP)\n\n\ndef compute_net_pay(gross, federal_rate, state_rate, pre_tax_deductions):\n gross = Decimal(gross)\n fed... | {
"idx": 3207,
"topic": "payroll calculations, withholdings, and deductions",
"difficulty": "easy",
"provider": "novita",
"in_tokens": 200,
"out_tokens": 894,
"latency_s": 9.4
} |
[
{
"role": "user",
"content": "A small firm records its transactions in a ledger and wants a fiscal-quarter report. Each ledger entry is a tuple (iso_date, description, amount) where amount is a Decimal in cents, e.g. Decimal('150.00'). The firm's fiscal year equals the calendar year, so fiscal quarters are ... | [
{
"role": "assistant",
"content": "import calendar\nfrom datetime import date\nfrom decimal import Decimal, ROUND_HALF_UP\n\n\ndef month_end(year, month):\n \"\"\"Return the last calendar day of the given month as a datetime.date.\"\"\"\n last_day = calendar.monthrange(year, month)[1]\n return date... | {
"idx": 52,
"topic": "fiscal periods, quarters, and month-end date utilities",
"difficulty": "medium",
"provider": "together",
"in_tokens": 0,
"out_tokens": 1014,
"latency_s": 11.5
} |
[
{
"role": "user",
"content": "A small business keeps a simple ledger of transactions. Each transaction is recorded as a tuple (id, type, amount) where type is one of 'sale', 'purchase', 'reversal', or 'void'. A 'sale' adds to the net balance, a 'purchase' subtracts from it. A 'reversal' cancels out a previo... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\n\ndef compute_net(transactions):\n \"\"\"Compute the net balance from a chronological ledger of transactions.\n\n Each transaction is a tuple (id, type, amount):\n - 'sale': adds amount to the net balance\n -... | {
"idx": 3451,
"topic": "correcting entries, reversals, and voided transactions",
"difficulty": "easy",
"provider": "together",
"in_tokens": 0,
"out_tokens": 1212,
"latency_s": 16.6
} |
[
{
"role": "user",
"content": "Implement a small general-ledger engine with exact monetary arithmetic. First, write allocate(total, weights): split the money string total proportionally according to a list of Decimal weight strings by computing each exact share at 50-digit precision, rounding each share to c... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP, getcontext\nfrom collections import OrderedDict\n\ngetcontext().prec = 50\nCENT = Decimal(\"0.01\")\n\n\ndef allocate(total, weights):\n \"\"\"Split `total` proportionally by `weights`, cent-accurate, zero drift.\"\"\"\n to... | {
"idx": 3683,
"topic": "general ledger and T-account operations",
"difficulty": "hard",
"provider": "together",
"in_tokens": 0,
"out_tokens": 1686,
"latency_s": 67.4
} |
[
{
"role": "user",
"content": "Write a function `process_payroll(employee_records, tax_brackets, standard_deduction)` that computes net pay for a list of employees and produces a payroll register. Each employee record is a dict with keys `name`, `gross_wages` (a string like '5250.75'), `pretax_401k` (a strin... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\n\nTWO = Decimal('0.01')\n\n\ndef _money(value):\n return Decimal(value).quantize(TWO, rounding=ROUND_HALF_UP)\n\n\ndef _federal_tax(taxable_income, standard_deduction, brackets):\n income = taxable_income - Decimal(str(stan... | {
"idx": 1567,
"topic": "payroll calculations, withholdings, and deductions",
"difficulty": "medium",
"provider": "together",
"in_tokens": 0,
"out_tokens": 896,
"latency_s": 16.9
} |
[
{
"role": "user",
"content": "You are maintaining a small loan ledger. A loan of principal P is repaid with N equal monthly payments (annuity), computed with monthly interest rate r (as a Decimal, e.g. '0.01' for 1%). The payment amount is PMT = P * r / (1 - (1+r)**(-N)), rounded to the nearest cent with RO... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\n\nCENT = Decimal('0.01')\n\ndef _round(x):\n return x.quantize(CENT, rounding=ROUND_HALF_UP)\n\ndef amortize(principal, rate, months):\n P = Decimal(principal)\n r = Decimal(rate)\n n = int(months)\n one = Decimal(... | {
"idx": 2981,
"topic": "interest calculation and payment schedules",
"difficulty": "medium",
"provider": "together",
"in_tokens": 0,
"out_tokens": 579,
"latency_s": 5.6
} |
[
{
"role": "user",
"content": "Implement a function `process_transactions(input_csv, output_csv)` that imports a CSV of double-entry bookkeeping journal lines, validates them, applies them to running account balances, and exports a formatted ledger.\n\nThe input CSV must have exactly the header `entry_id,dat... | [
{
"role": "assistant",
"content": "import csv\nimport re\nfrom collections import OrderedDict, defaultdict\nfrom datetime import date\nfrom decimal import Decimal\n\nEXPECTED_HEADER = [\"entry_id\", \"date\", \"account\", \"debit\", \"credit\", \"memo\"]\nAMOUNT_RE = re.compile(r\"^\\d+(?:\\.\\d{1,2})?$\")\... | {
"idx": 33,
"topic": "transaction CSV import, validation, and export",
"difficulty": "hard",
"provider": "together",
"in_tokens": 0,
"out_tokens": 2230,
"latency_s": 39.6
} |
[
{
"role": "user",
"content": "You are given a list of ledger transactions, each represented as a tuple (tx_id, date, description, amount) where amount is a string like '123.45' (positive = debit, negative = credit). Write a function `flag_suspicious(transactions)` that returns a list of tx_ids flagged as su... | [
{
"role": "assistant",
"content": "from decimal import Decimal\n\n\ndef flag_suspicious(transactions):\n flagged = []\n seen = set() # (date, description, amount) exact keys\n seen_reversible = set() # (date, description, amount) for reversed-sign check\n\n for tx_id, date, description... | {
"idx": 3758,
"topic": "detecting duplicate or anomalous transactions",
"difficulty": "medium",
"provider": "novita",
"in_tokens": 198,
"out_tokens": 834,
"latency_s": 9
} |
[
{
"role": "user",
"content": "You are building an expense categorizer for a small business. You are given a chart of accounts as a dict mapping 4-digit account codes (strings) to account names, a list of expense entries, and a set of keyword mappings. Each entry is a dict with keys 'description' (string) an... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\n\n\ndef build_expense_report(chart, entries, mappings):\n \"\"\"Categorize expense entries against a chart of accounts and produce a summary report.\"\"\"\n CENT = Decimal(\"0.01\")\n\n def to_cents(value):\n retu... | {
"idx": 3964,
"topic": "chart of accounts and expense categorization",
"difficulty": "medium",
"provider": "novita",
"in_tokens": 199,
"out_tokens": 2711,
"latency_s": 28.9
} |
[
{
"role": "user",
"content": "You are building a perpetual inventory valuation engine for a bookkeeping system. Given a chronological list of transactions, where each transaction is a tuple (\"BUY\", quantity, unit_cost) or (\"SELL\", quantity, unit_price), write a function inventory_report(transactions) th... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\n\nCENT = Decimal(\"0.01\")\nZERO = Decimal(\"0\")\n\n\ndef _round_to_cent(amount):\n return amount.quantize(CENT, rounding=ROUND_HALF_UP)\n\n\ndef _cost_from_front(layers, qty):\n \"\"\"Remove qty units from the oldest laye... | {
"idx": 2588,
"topic": "inventory valuation (FIFO, LIFO, weighted average)",
"difficulty": "hard",
"provider": "together",
"in_tokens": 0,
"out_tokens": 1434,
"latency_s": 103.7
} |
[
{
"role": "user",
"content": "Implement a small ledger module with a function `post_and_balance(entries)` that validates and posts journal entries to a ledger and returns the final balance per account. Each entry is a tuple `(account, amount)` where `amount` is a Decimal or a string convertible to Decimal; ... | [
{
"role": "assistant",
"content": "import unittest\nfrom decimal import Decimal, InvalidOperation, ROUND_HALF_UP\n\nCENT = Decimal('0.01')\n\n\ndef _to_money(value):\n try:\n d = Decimal(str(value))\n except (InvalidOperation, ValueError, TypeError) as exc:\n raise ValueError(f\"invalid ... | {
"idx": 1860,
"topic": "unit tests for accounting functions",
"difficulty": "medium",
"provider": "together",
"in_tokens": 0,
"out_tokens": 1034,
"latency_s": 3
} |
[
{
"role": "user",
"content": "Build a FIFO capital-gains calculator for a small bookkeeping tool. The input consists of one trade per line in the format 'BUY <qty> <price> <fee>' or 'SELL <qty> <price> <fee>', where qty is an integer number of shares and price/fee are decimal money amounts; all arithmetic m... | [
{
"role": "assistant",
"content": "import sys\nfrom decimal import Decimal, ROUND_HALF_UP\n\nCENT = Decimal(\"0.01\")\n\n\ndef q(value):\n return value.quantize(CENT, rounding=ROUND_HALF_UP)\n\n\ndef process(lines):\n lots = [] # each lot: [remaining_qty, price, remaining_fee]\n outputs = []\n ... | {
"idx": 2163,
"topic": "small bookkeeping command-line tool logic",
"difficulty": "hard",
"provider": "together",
"in_tokens": 0,
"out_tokens": 1165,
"latency_s": 11.7
} |
[
{
"role": "user",
"content": "Implement payroll_report(salary, k401_rate, health_pp) that builds a full-year semimonthly (24 pay periods) payroll ledger for one employee as a JSON-serializable dict. Per-period gross is salary/24 rounded half-up to cents; the employee contributes k401_rate of salary to a 401... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\n\nCENT = Decimal(\"0.01\")\nPERIODS = 24\n\nBRACKETS = [\n (Decimal(\"11000\"), Decimal(\"0.10\")),\n (Decimal(\"44725\"), Decimal(\"0.12\")),\n (Decimal(\"95375\"), Decimal(\"0.22\")),\n (Decimal(\"182100\"), Decimal... | {
"idx": 1343,
"topic": "payroll calculations, withholdings, and deductions",
"difficulty": "hard",
"provider": "together",
"in_tokens": 0,
"out_tokens": 1867,
"latency_s": 117.4
} |
[
{
"role": "user",
"content": "Implement an append-only audit ledger for a small bookkeeping office. Each entry is a tuple (date, description, amount) where amount is a Decimal in dollars, positive for debits (charges) and negative for credits (payments). The ledger must be immutable: implement a class Audit... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\nimport hashlib\n\nclass AuditLedger:\n def __init__(self):\n self._entries = [] # list of dicts: date, description, amount, hash\n\n def add_entry(self, date, description, amount):\n amount = Decimal(amount)\... | {
"idx": 667,
"topic": "audit trails and immutable entry logs",
"difficulty": "medium",
"provider": "together",
"in_tokens": 0,
"out_tokens": 782,
"latency_s": 24.2
} |
[
{
"role": "user",
"content": "A small business keeps its ledger on a cash basis but wants a month-end accrual adjustment for unpaid bills. Given a list of expenses, each with a date (YYYY-MM-DD string), an amount (string, may include cents), and a 'paid' status (True/False), write a function accrual_adjustm... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\n\ndef accrual_adjustment(expenses):\n cash = Decimal('0')\n accrual = Decimal('0')\n for _date, amount, paid in expenses:\n amt = Decimal(amount)\n accrual += amt\n if paid:\n cash += amt\... | {
"idx": 1907,
"topic": "accrual versus cash basis adjustments",
"difficulty": "easy",
"provider": "together",
"in_tokens": 0,
"out_tokens": 371,
"latency_s": 1.5
} |
[
{
"role": "user",
"content": "A boutique agency processes weekly invoices and must split each invoice's total into three parts: an agent commission (a given percentage of the invoice total), a processing fee (a given percentage of the invoice total), and the remainder to the client's ledger balance. All mon... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\n\nCENT = Decimal('0.01')\n\n\ndef split_invoices(invoices, commission_pct, fee_pct):\n cp = Decimal(commission_pct) / Decimal('100')\n fp = Decimal(fee_pct) / Decimal('100')\n per_invoice = {}\n total_commission = Dec... | {
"idx": 989,
"topic": "commission, tip, and percentage splits",
"difficulty": "medium",
"provider": "together",
"in_tokens": 0,
"out_tokens": 843,
"latency_s": 3.8
} |
[
{
"role": "user",
"content": "Implement a double-entry bookkeeping engine. A journal entry is a dict with an 'id' and a list of lines; each line has 'account' (str), 'debit' (str) and 'credit' (str) representing money amounts as decimal strings. A journal entry is valid only if (1) every line has exactly on... | [
{
"role": "assistant",
"content": "from decimal import Decimal\n\n\ndef post(entries):\n ledger = {}\n posted = []\n rejected = []\n\n def line_amount(line):\n d = Decimal(line['debit'])\n c = Decimal(line['credit'])\n return d, c\n\n def two_places_ok(x):\n # exac... | {
"idx": 486,
"topic": "double-entry journal entries and posting rules",
"difficulty": "medium",
"provider": "together",
"in_tokens": 0,
"out_tokens": 813,
"latency_s": 7.9
} |
[
{
"role": "user",
"content": "Write a function `reconcile(bank_lines, ledger_lines)` that reconciles a bank statement against a cash ledger. Both inputs are lists of tuples: `(date_str, description, amount_str)` where `amount_str` is a decimal string, positive for deposits/debits in your favor and negative ... | [
{
"role": "assistant",
"content": "from decimal import Decimal\nfrom collections import Counter\n\n\ndef reconcile(bank_lines, ledger_lines):\n \"\"\"Reconcile a bank statement against a cash ledger.\n\n Each line is (date, description, amount_str). Lines match one-for-one\n when date, description,... | {
"idx": 2945,
"topic": "bank statement reconciliation",
"difficulty": "easy",
"provider": "together",
"in_tokens": 0,
"out_tokens": 911,
"latency_s": 10.8
} |
[
{
"role": "user",
"content": "Write a command-line bookkeeping tool that processes ledger entries from stdin and prints a balance report. Each input line is one of: 'DEPOSIT <account> <amount>', 'WITHDRAW <account> <amount>', or 'TRANSFER <from> <to> <amount>', where amounts are decimal strings with up to 2... | [
{
"role": "assistant",
"content": "import sys\nfrom decimal import Decimal, ROUND_HALF_UP, InvalidOperation\n\nTWO = Decimal('0.01')\n\n\ndef q(value):\n return value.quantize(TWO, rounding=ROUND_HALF_UP)\n\n\ndef main():\n balances = {}\n for raw in sys.stdin:\n line = raw.strip()\n ... | {
"idx": 341,
"topic": "small bookkeeping command-line tool logic",
"difficulty": "medium",
"provider": "together",
"in_tokens": 0,
"out_tokens": 700,
"latency_s": 6.2
} |
[
{
"role": "user",
"content": "A small business posts a monthly rent expense that recurs on the same day of every month. Given a start date, a number of occurrences, a monthly amount, and the ledger account name, generate the recurring journal entries and compute the total posted. Rules: each entry has a dat... | [
{
"role": "assistant",
"content": "import calendar\nfrom datetime import date\nfrom decimal import Decimal, ROUND_HALF_UP\n\ndef generate_recurring_entries(start_str, occurrences, amount_str, account_name):\n start = date.fromisoformat(start_str)\n day = start.day\n amount = Decimal(amount_str).qua... | {
"idx": 1743,
"topic": "recurring and calendar-based postings",
"difficulty": "easy",
"provider": "together",
"in_tokens": 0,
"out_tokens": 506,
"latency_s": 1.6
} |
[
{
"role": "user",
"content": "A petty cash fund starts with a fixed imprest amount (e.g., $100.00). Each disbursement reduces the cash on hand; at month end the fund is replenished back to the imprest amount. Write a function `petty_cash_report(imprest, entries)` where `imprest` is a string like '100.00' an... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\n\ndef petty_cash_report(imprest, entries):\n TWO = Decimal('0.01')\n def q(x):\n return x.quantize(TWO, rounding=ROUND_HALF_UP)\n imp = Decimal(imprest)\n total_disb = Decimal('0')\n for date, desc, amt in e... | {
"idx": 2195,
"topic": "petty cash logs and replenishment",
"difficulty": "easy",
"provider": "together",
"in_tokens": 0,
"out_tokens": 435,
"latency_s": 2.3
} |
[
{
"role": "user",
"content": "You are given a bookkeeping ledger as CSV text with the header `txn_id,date,account,description,amount`, where each row is a single posting and all rows sharing a `txn_id` form one journal transaction. Write a function `analyze_ledger(csv_text)` that returns a report with three... | [
{
"role": "assistant",
"content": "import csv\nimport io\nimport json\nimport re\nfrom datetime import datetime\nfrom decimal import Decimal, ROUND_HALF_EVEN\n\nTWO_PLACES = Decimal(\"0.01\")\nTHRESHOLD = Decimal(\"10000.00\")\nMULTIPLE = Decimal(\"1000.00\")\n\n\ndef normalize_description(text):\n \"\"\... | {
"idx": 1080,
"topic": "detecting duplicate or anomalous transactions",
"difficulty": "hard",
"provider": "together",
"in_tokens": 0,
"out_tokens": 1555,
"latency_s": 147
} |
[
{
"role": "user",
"content": "Implement a `JournalEntry` dataclass and a `Ledger` class for a simple double-entry bookkeeping system. Each `JournalEntry` has a `date` (string 'YYYY-MM-DD'), `description` (string), and a list of `Line` objects, where each `Line` has an `account` (string), a `debit` (Decimal,... | [
{
"role": "assistant",
"content": "from dataclasses import dataclass, field\nfrom decimal import Decimal, ROUND_HALF_UP\nfrom typing import List\n\n\n@dataclass\nclass Line:\n account: str\n debit: Decimal = Decimal('0')\n credit: Decimal = Decimal('0')\n\n\n@dataclass\nclass JournalEntry:\n dat... | {
"idx": 3206,
"topic": "accounting record dataclasses and schemas",
"difficulty": "easy",
"provider": "novita",
"in_tokens": 198,
"out_tokens": 840,
"latency_s": 8.7
} |
[
{
"role": "user",
"content": "Write a function `validate_journal_entry(lines)` that checks whether a double-entry journal entry balances. Each line is a tuple `(account, debit, credit)` where debit and credit are strings representing money amounts (e.g. '150.00'). The function must use `decimal.Decimal` for... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\n\ndef validate_journal_entry(lines):\n total_debits = Decimal('0')\n total_credits = Decimal('0')\n for account, debit_s, credit_s in lines:\n debit = Decimal(debit_s)\n credit = Decimal(credit_s)\n ... | {
"idx": 770,
"topic": "double-entry journal entries and posting rules",
"difficulty": "easy",
"provider": "together",
"in_tokens": 0,
"out_tokens": 474,
"latency_s": 2.1
} |
[
{
"role": "user",
"content": "You are maintaining a small accounting ledger in which every monetary amount must be stored as a Decimal rounded to exactly 2 decimal places. Entries arrive as raw strings that may have any number of decimal digits (e.g. '10.005', '3.7', '-0.125'), and each entry is either a cr... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\n\nTWO_PLACES = Decimal('0.01')\n\ndef apply_entries(entries):\n total = Decimal('0.00')\n largest_debit = Decimal('0.00')\n count = 0\n for sign, amount_str in entries:\n amount = Decimal(amount_str).quantize(T... | {
"idx": 3819,
"topic": "currency rounding rules with the Decimal type",
"difficulty": "medium",
"provider": "together",
"in_tokens": 0,
"out_tokens": 538,
"latency_s": 9.6
} |
[
{
"role": "user",
"content": "A bookkeeper must produce a loan amortization schedule using precise decimal arithmetic. Given a loan principal P, an annual nominal interest rate r (compounded monthly), and a term of n months, compute the level monthly payment using the standard annuity formula payment = P * ... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP, getcontext\n\ngetcontext().prec = 28\n\nCENT = Decimal('0.01')\n\n\ndef to_cent(value):\n return value.quantize(CENT, rounding=ROUND_HALF_UP)\n\n\ndef amortize(principal, annual_rate, months):\n principal = Decimal(principa... | {
"idx": 3380,
"topic": "interest calculation and payment schedules",
"difficulty": "medium",
"provider": "together",
"in_tokens": 0,
"out_tokens": 677,
"latency_s": 36.8
} |
[
{
"role": "user",
"content": "You are given a bank statement (list of transactions) and an internal ledger for the same period. Each transaction is a tuple (date, description, amount) where amount is a string like '123.45' or '-50.00' (negative = withdrawal, positive = deposit). Each ledger entry is a tuple... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\nfrom collections import defaultdict\n\n\ndef _parse(entry):\n date, desc, amount = entry\n return (date, desc, Decimal(amount))\n\n\ndef reconcile(statement, ledger, starting_balance):\n stmt = [_parse(e) for e in statem... | {
"idx": 3024,
"topic": "bank statement reconciliation",
"difficulty": "medium",
"provider": "together",
"in_tokens": 0,
"out_tokens": 753,
"latency_s": 2.6
} |
[
{
"role": "user",
"content": "A restaurant records its nightly tip pool and must distribute it among staff according to fixed percentage shares: servers get 70%, kitchen staff 20%, and the host 10%. Write a function distribute_tips(total_cents, shares) where total_cents is an integer amount in cents and sha... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\n\n\ndef distribute_tips(total_cents, shares):\n total_pct = sum(Decimal(str(p)) for p in shares.values())\n if total_pct != Decimal('100'):\n raise ValueError('shares must sum to exactly 100')\n\n total = Decimal(... | {
"idx": 3468,
"topic": "commission, tip, and percentage splits",
"difficulty": "medium",
"provider": "together",
"in_tokens": 0,
"out_tokens": 668,
"latency_s": 6.5
} |
[
{
"role": "user",
"content": "Write a Python function `reconcile_ledger(entries)` for a small bookkeeping CLI tool. Each entry is a tuple `(date, description, amount)` where `date` is a string 'YYYY-MM-DD', `description` is a string, and `amount` is a string representing a decimal number (e.g. '123.45', '-5... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP, InvalidOperation\nfrom datetime import datetime\n\n\ndef reconcile_ledger(entries):\n valid = []\n for date, description, amount in entries:\n try:\n datetime.strptime(date, '%Y-%m-%d')\n except (Va... | {
"idx": 540,
"topic": "small bookkeeping command-line tool logic",
"difficulty": "medium",
"provider": "together",
"in_tokens": 0,
"out_tokens": 612,
"latency_s": 27.6
} |
[
{
"role": "user",
"content": "Write a function `depreciation_schedule(cost, salvage, useful_life, rate=None)` that builds a depreciation schedule for an asset using the straight-line method (when `rate` is None) or the declining-balance method (when `rate` is given as a decimal fraction, e.g. 0.4 for 40%). ... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\n\n\ndef _q(value):\n return Decimal(value).quantize(Decimal('0.01'), rounding=ROUND_HALF_UP)\n\n\ndef depreciation_schedule(cost, salvage, useful_life, rate=None):\n cost = _q(cost)\n salvage = _q(salvage)\n schedule ... | {
"idx": 3081,
"topic": "depreciation schedules (straight-line, declining balance)",
"difficulty": "easy",
"provider": "novita",
"in_tokens": 201,
"out_tokens": 710,
"latency_s": 8.4
} |
[
{
"role": "user",
"content": "Implement an append-only ledger for a small bookkeeping system. Each entry records an account name, a description, and a signed Decimal amount (credits positive, debits negative). To guarantee immutability, entries are hash-chained: entry 0 has a `prev_hash` of 'GENESIS', and e... | [
{
"role": "assistant",
"content": "import hashlib\nfrom decimal import Decimal, ROUND_HALF_UP\n\nTWO = Decimal('0.01')\n\n\nclass Ledger:\n def __init__(self):\n self._entries = [] # each: dict(index, prev_hash, account, description, amount, hash)\n\n @staticmethod\n def _canonical(index, p... | {
"idx": 3378,
"topic": "audit trails and immutable entry logs",
"difficulty": "medium",
"provider": "together",
"in_tokens": 0,
"out_tokens": 839,
"latency_s": 2.7
} |
[
{
"role": "user",
"content": "Define a dataclass JournalEntry with fields date (str), description (str), debit_account (str), credit_account (str), and amount (Decimal, exactly 2 decimal places). Write a function validate_entries(entries) that returns a list of entry indices (0-based) which are invalid: an ... | [
{
"role": "assistant",
"content": "import re\nfrom dataclasses import dataclass\nfrom decimal import Decimal, ROUND_HALF_UP\n\n\n@dataclass\nclass JournalEntry:\n date: str\n description: str\n debit_account: str\n credit_account: str\n amount: Decimal\n\n def is_valid(self):\n if n... | {
"idx": 898,
"topic": "accounting record dataclasses and schemas",
"difficulty": "easy",
"provider": "together",
"in_tokens": 0,
"out_tokens": 673,
"latency_s": 3.9
} |
[
{
"role": "user",
"content": "Write a function `aging_report(invoices, as_of)` that produces an accounts receivable/payable aging report. Each invoice is a dict with keys `id` (str), `due_date` (a `datetime.date`), and `amount` (a `Decimal` representing the outstanding balance, always non-negative). `as_of`... | [
{
"role": "assistant",
"content": "from datetime import date\nfrom decimal import Decimal, ROUND_HALF_UP\n\nBUCKETS = ['current', '1-30', '31-60', '61-90', '90+']\n\n\ndef aging_report(invoices, as_of):\n totals = {b: Decimal('0') for b in BUCKETS}\n for inv in invoices:\n amount = inv['amount'... | {
"idx": 3935,
"topic": "accounts receivable and payable aging reports",
"difficulty": "medium",
"provider": "together",
"in_tokens": 0,
"out_tokens": 613,
"latency_s": 6.4
} |
[
{
"role": "user",
"content": "Write a function `aging_report(invoices, as_of)` that produces an accounts receivable/payable aging report. Each invoice is a dict with keys 'id' (str), 'customer' (str), 'due_date' (datetime.date), and 'amount' (Decimal, always positive). `as_of` is a datetime.date. An invoice... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\nfrom datetime import date\n\nBUCKETS = ['Current', '1-30', '31-60', '61-90', 'Over 90']\n\n\ndef aging_report(invoices, as_of):\n bucket_totals = {b: Decimal('0.00') for b in BUCKETS}\n customer_totals = {}\n\n for inv i... | {
"idx": 3550,
"topic": "accounts receivable and payable aging reports",
"difficulty": "medium",
"provider": "together",
"in_tokens": 0,
"out_tokens": 778,
"latency_s": 11.6
} |
[
{
"role": "user",
"content": "At period end, a bookkeeper must post a single closing entry that zeroes out each revenue and expense account (temporary accounts) and transfers the net difference to the 'Retained Earnings' account (an equity account). Given a dictionary of account balances where keys are acco... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\n\nTWO = Decimal('0.01')\n\n\ndef _round2(amount):\n return amount.quantize(TWO, rounding=ROUND_HALF_UP)\n\n\ndef closing_entry(balances):\n \"\"\"Compute the period-end closing entry for temporary accounts.\n\n Args:\n ... | {
"idx": 31,
"topic": "period-end closing entries and routines",
"difficulty": "easy",
"provider": "together",
"in_tokens": 0,
"out_tokens": 986,
"latency_s": 14.8
} |
[
{
"role": "user",
"content": "You are given a list of ledger transactions, where each transaction is a tuple (date, description, amount). The amount is a string representing money (e.g. '120.50'). Write a function `find_duplicates(transactions)` that returns a list of transactions which are exact duplicates... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\n\ndef find_duplicates(transactions):\n seen = set()\n duplicates = []\n for date, description, amount in transactions:\n norm_desc = description.strip().lower()\n norm_amount = Decimal(amount).quantize(Deci... | {
"idx": 1910,
"topic": "detecting duplicate or anomalous transactions",
"difficulty": "easy",
"provider": "together",
"in_tokens": 0,
"out_tokens": 448,
"latency_s": 2
} |
[
{
"role": "user",
"content": "A petty cash fund starts with a fixed imprest amount (e.g., $100.00). Each day, small expenses are recorded in a log as (description, amount) pairs. Write a function `replenishment_needed(imprest, expenses)` that takes the imprest amount as a string and a list of (description, ... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\n\ndef replenishment_needed(imprest, expenses):\n imprest_d = Decimal(imprest)\n total = sum((Decimal(amount) for _, amount in expenses), Decimal('0'))\n if total > imprest_d:\n return 'OVERDRAWN'\n result = (im... | {
"idx": 2762,
"topic": "petty cash logs and replenishment",
"difficulty": "easy",
"provider": "together",
"in_tokens": 0,
"out_tokens": 345,
"latency_s": 18
} |
[
{
"role": "user",
"content": "You are building a multi-currency general-ledger reconciler for an accounting system. Given a list of entries as tuples (account, currency, amount_string), compute each account's balance per currency and the per-currency grand total, applying these currency-specific rounding ru... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN\n\nCURRENCY_RULES = {\n \"USD\": (Decimal(\"0.01\"), ROUND_HALF_UP),\n \"EUR\": (Decimal(\"0.01\"), ROUND_HALF_UP),\n \"SEK\": (Decimal(\"0.01\"), ROUND_HALF_EVEN),\n \"JPY\": (Decimal(\"1\"), ROUND_HA... | {
"idx": 2995,
"topic": "currency rounding rules with the Decimal type",
"difficulty": "hard",
"provider": "together",
"in_tokens": 0,
"out_tokens": 1158,
"latency_s": 71.2
} |
[
{
"role": "user",
"content": "Implement an append-only ledger for a small bookkeeping system that supports an audit trail with hash chaining. Each entry records a date (ISO string), a description, and an amount (Decimal, positive for debit, negative for credit). The ledger must reject any attempt to modify ... | [
{
"role": "assistant",
"content": "import hashlib\nimport json\nfrom decimal import Decimal, ROUND_HALF_UP\n\nGENESIS = '0' * 64\n\n\ndef _entry_hash(index, date, description, amount, prev_hash):\n data = f\"{index}|{date}|{description}|{amount:.2f}|{prev_hash}\"\n return hashlib.sha256(data.encode('u... | {
"idx": 2879,
"topic": "audit trails and immutable entry logs",
"difficulty": "medium",
"provider": "together",
"in_tokens": 0,
"out_tokens": 784,
"latency_s": 13
} |
[
{
"role": "user",
"content": "You maintain the loan ledger for a small bookkeeping firm. A client takes an amortizing loan with a principal P (in cents, as an integer), an annual nominal interest rate r (as a string like '5.5' meaning 5.5%), a term of n monthly payments, and a fixed monthly payment amount M... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP, getcontext\n\ngetcontext().prec = 28\n\nCENT = Decimal('0.01')\n\ndef _round_to_cents(value: Decimal) -> int:\n \"\"\"Round a Decimal amount half-up to whole cents, return cents as int.\"\"\"\n return int((value.quantize(CE... | {
"idx": 32,
"topic": "interest calculation and payment schedules",
"difficulty": "medium",
"provider": "together",
"in_tokens": 0,
"out_tokens": 805,
"latency_s": 7.5
} |
[
{
"role": "user",
"content": "A small shop pays its sales clerk a commission on each sale and also records a tip jar split. Write a function `process_sales(sales)` that takes a list of tuples `(sale_id, gross_amount, commission_rate_str, tip_str)` and returns a ledger report. For each sale, compute the comm... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\n\nCENT = Decimal('0.01')\n\ndef _round_cent(value):\n return value.quantize(CENT, rounding=ROUND_HALF_UP)\n\ndef process_sales(sales):\n entries = []\n totals = {\n 'total_gross': Decimal('0.00'),\n 'total_... | {
"idx": 2860,
"topic": "commission, tip, and percentage splits",
"difficulty": "easy",
"provider": "together",
"in_tokens": 0,
"out_tokens": 749,
"latency_s": 5.4
} |
[
{
"role": "user",
"content": "Implement a general ledger with T-account support using Decimal arithmetic. Each account has a name, a type ('asset', 'liability', 'equity', 'revenue', or 'expense'), and a list of entries. Each entry is either a debit or credit with a Decimal amount. Debits increase asset and ... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\n\nTWO = Decimal('0.01')\n\nDEBIT_NORMAL = {'asset', 'expense'}\nVALID_TYPES = {'asset', 'liability', 'equity', 'revenue', 'expense'}\n\n\ndef _round(amount):\n return Decimal(amount).quantize(TWO, rounding=ROUND_HALF_UP)\n\n\n... | {
"idx": 3634,
"topic": "general ledger and T-account operations",
"difficulty": "medium",
"provider": "together",
"in_tokens": 0,
"out_tokens": 1147,
"latency_s": 11.7
} |
[
{
"role": "user",
"content": "You are keeping a small sales ledger. Each line of the ledger is a net (tax-exclusive) amount in cents given as an integer. Your job is to compute the VAT (value added tax) for each line at a given rate, the gross amount per line, and the ledger totals. To avoid floating-point ... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\n\nTWO = Decimal('0.01')\n\ndef compute_ledger(net_amounts, vat_rate):\n rate = Decimal(vat_rate)\n lines = []\n total_net = Decimal('0.00')\n total_vat = Decimal('0.00')\n total_gross = Decimal('0.00')\n for cen... | {
"idx": 562,
"topic": "sales tax and VAT computation and rounding",
"difficulty": "easy",
"provider": "together",
"in_tokens": 0,
"out_tokens": 526,
"latency_s": 6.8
} |
[
{
"role": "user",
"content": "Write a function `compute_payroll(hours, hourly_rate, federal_rate, state_rate, pre_tax_deductions)` that computes an employee's net pay using precise Decimal arithmetic. Gross pay is hours times hourly_rate minus pre_tax_deductions (if deductions exceed gross pay, taxable inco... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\n\n\ndef _money(value):\n return value.quantize(Decimal('0.01'), rounding=ROUND_HALF_UP)\n\n\ndef compute_payroll(hours, hourly_rate, federal_rate, state_rate, pre_tax_deductions):\n hours = Decimal(str(hours))\n hourly_r... | {
"idx": 2859,
"topic": "payroll calculations, withholdings, and deductions",
"difficulty": "medium",
"provider": "together",
"in_tokens": 0,
"out_tokens": 590,
"latency_s": 4.5
} |
[
{
"role": "user",
"content": "A small agency processes invoices and must split each payment three ways: a 15% commission to the sales agent, a 3% platform fee to the marketplace, and the remainder to the vendor. All amounts must be computed with Decimal arithmetic, rounding each split to the nearest cent wi... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\n\nCENT = Decimal('0.01')\nCOMMISSION_RATE = Decimal('0.15')\nFEE_RATE = Decimal('0.03')\n\n\ndef _round_cents(value):\n return value.quantize(CENT, rounding=ROUND_HALF_UP)\n\n\ndef split_invoices(invoices):\n \"\"\"Split ea... | {
"idx": 154,
"topic": "commission, tip, and percentage splits",
"difficulty": "medium",
"provider": "together",
"in_tokens": 0,
"out_tokens": 700,
"latency_s": 21.1
} |
[
{
"role": "user",
"content": "You are given a list of budget line items and a list of actual expenses, each as tuples of (category, amount) where amounts are strings representing money (e.g. '150.00'). Write a function `variance_report(budget, actuals)` that returns a dictionary mapping each category to its... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\n\n\ndef variance_report(budget, actuals):\n \"\"\"Compute budget-minus-actual variance per category using Decimal.\"\"\"\n budget_totals = {}\n for category, amount in budget:\n budget_totals[category] = budget_to... | {
"idx": 1999,
"topic": "budget versus actual variance analysis",
"difficulty": "easy",
"provider": "together",
"in_tokens": 0,
"out_tokens": 526,
"latency_s": 1.7
} |
[
{
"role": "user",
"content": "Write a command-line bookkeeping tool that processes ledger entries from stdin and prints an account summary. Each input line is one of: 'ENTRY <account> <description> <amount>' where amount is a decimal string that may be negative (debit) or positive (credit), or 'BALANCE' whi... | [
{
"role": "assistant",
"content": "import sys\nfrom decimal import Decimal\n\n\ndef main():\n accounts = {}\n for raw in sys.stdin:\n line = raw.strip()\n if not line:\n continue\n parts = line.split()\n cmd = parts[0]\n if cmd == 'ENTRY' and len(parts) >=... | {
"idx": 466,
"topic": "small bookkeeping command-line tool logic",
"difficulty": "medium",
"provider": "together",
"in_tokens": 0,
"out_tokens": 426,
"latency_s": 3.7
} |
[
{
"role": "user",
"content": "You are given a list of bookkeeping transactions, each represented as a tuple (date, description, amount), where amount is a Decimal (positive for debit, negative for credit). A transaction is considered a 'duplicate' if another transaction in the list has the same date, the sa... | [
{
"role": "assistant",
"content": "from decimal import Decimal\nimport re\n\n\ndef _normalize(text):\n return re.sub(r'\\s+', ' ', text.strip().lower())\n\n\ndef flag_transactions(transactions):\n threshold = Decimal('10000.00')\n seen = {}\n duplicate_keys = set()\n\n for date, description, ... | {
"idx": 3536,
"topic": "detecting duplicate or anomalous transactions",
"difficulty": "medium",
"provider": "together",
"in_tokens": 0,
"out_tokens": 584,
"latency_s": 4.3
} |
[
{
"role": "user",
"content": "You maintain an immutable audit trail of ledger entries for a small business. Each entry has an id (assigned sequentially starting at 1), a description, and a signed Decimal amount (positive for debit, negative for credit). Implement a class AuditTrail with methods: add_entry(d... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\n\n\nclass AuditTrail:\n def __init__(self):\n self._entries = []\n self._next_id = 1\n\n def add_entry(self, description, amount):\n if not isinstance(amount, Decimal):\n raise TypeError('amo... | {
"idx": 1780,
"topic": "audit trails and immutable entry logs",
"difficulty": "easy",
"provider": "novita",
"in_tokens": 198,
"out_tokens": 746,
"latency_s": 8.9
} |
[
{
"role": "user",
"content": "Implement a bookkeeping utility `quarterly_report(fiscal_year_start_month, fiscal_year, entries)` (plus a helper `month_end(year, month)` returning the last calendar day of a month as a `datetime.date`) using only the standard library, with all monetary arithmetic done in `Deci... | [
{
"role": "assistant",
"content": "import calendar\nfrom datetime import date, datetime\nfrom decimal import Decimal, ROUND_HALF_UP\n\nCENT = Decimal(\"0.01\")\n\n\ndef month_end(year, month):\n \"\"\"Return the last calendar day of the given month as a datetime.date.\"\"\"\n last_day = calendar.month... | {
"idx": 1452,
"topic": "fiscal periods, quarters, and month-end date utilities",
"difficulty": "hard",
"provider": "together",
"in_tokens": 0,
"out_tokens": 1420,
"latency_s": 65.3
} |
[
{
"role": "user",
"content": "Write a function `reconcile(bank_lines, ledger_entries, bank_ending_balance)` that reconciles a company ledger against a bank statement. Each bank line and ledger entry is a tuple `(date, description, amount)` where `date` is an ISO string, `description` is free text, and `amou... | [
{
"role": "assistant",
"content": "import json\nimport re\nfrom datetime import date\nfrom decimal import Decimal, ROUND_HALF_UP\n\nCENT = Decimal(\"0.01\")\n\n\ndef money(value):\n return Decimal(str(value)).quantize(CENT, rounding=ROUND_HALF_UP)\n\n\ndef normalize_description(text):\n cleaned = re.s... | {
"idx": 3726,
"topic": "bank statement reconciliation",
"difficulty": "hard",
"provider": "together",
"in_tokens": 0,
"out_tokens": 2207,
"latency_s": 79.3
} |
[
{
"role": "user",
"content": "A small business uses a cash-basis ledger where each posting is a tuple (date_str, description, amount) with amount as a Decimal (negative = expense, positive = income). The business pays rent of 550.00 on the 1st of every month and earns a subscription fee of 199.99 on the 15t... | [
{
"role": "assistant",
"content": "from datetime import date\nfrom decimal import Decimal, ROUND_HALF_UP\n\nRENT_AMOUNT = Decimal('550.00')\nSUB_AMOUNT = Decimal('199.99')\n\n\ndef _month_iter(start_date, end_date):\n \"\"\"Yield the first and fifteenth of each month between the dates.\"\"\"\n y, m = ... | {
"idx": 3373,
"topic": "recurring and calendar-based postings",
"difficulty": "medium",
"provider": "together",
"in_tokens": 0,
"out_tokens": 688,
"latency_s": 4.3
} |
[
{
"role": "user",
"content": "Write a program that imports transactions from a CSV file, validates them, and exports a cleaned ledger. The input CSV has a header row and columns: date,description,amount. A transaction is valid if the date is in ISO format YYYY-MM-DD (must be a real calendar date), the descr... | [
{
"role": "assistant",
"content": "import csv\nimport datetime\nimport io\nfrom decimal import Decimal, ROUND_HALF_UP, InvalidOperation\n\nTWO = Decimal('0.01')\n\n\ndef _validate_amount(raw):\n raw = raw.strip()\n if not raw:\n return None\n try:\n value = Decimal(raw)\n except In... | {
"idx": 3613,
"topic": "transaction CSV import, validation, and export",
"difficulty": "medium",
"provider": "together",
"in_tokens": 0,
"out_tokens": 1101,
"latency_s": 9.9
} |
[
{
"role": "user",
"content": "Write a function `post_journal(entries)` that validates and posts a list of double-entry journal entries to a general ledger and returns account balances. Each entry is a dict with a `date` string (ISO format), a `description`, and a list of `lines`, where each line is a dict w... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\nimport json\n\nCENT = Decimal('0.01')\n\n\ndef _parse_amount(raw):\n if raw is None:\n return None\n try:\n value = Decimal(raw)\n except Exception as exc:\n raise ValueError(f\"Invalid amount: {raw!... | {
"idx": 973,
"topic": "double-entry journal entries and posting rules",
"difficulty": "medium",
"provider": "together",
"in_tokens": 0,
"out_tokens": 1098,
"latency_s": 3.5
} |
[
{
"role": "user",
"content": "Write a function `reconcile(bank_lines, ledger_entries)` that reconciles a bank statement against a company ledger. `bank_lines` is a list of tuples `(date, description, amount)` where `amount` is a string like '-45.10' (negative = withdrawal), and `ledger_entries` is a list of... | [
{
"role": "assistant",
"content": "from decimal import Decimal\nfrom datetime import date, timedelta\n\n\ndef _parse_date(s):\n y, m, d = s.split('-')\n return date(int(y), int(m), int(d))\n\n\ndef reconcile(bank_lines, ledger_entries):\n bank = [(d, desc, Decimal(amt)) for d, desc, amt in bank_lin... | {
"idx": 890,
"topic": "bank statement reconciliation",
"difficulty": "medium",
"provider": "together",
"in_tokens": 0,
"out_tokens": 741,
"latency_s": 4.8
} |
[
{
"role": "user",
"content": "A petty cash fund starts with a fixed imprest amount (e.g., 100.00) and is replenished back to that amount at the end of each period. You are given an initial imprest amount and a log of petty cash transactions, where each entry is a tuple (description, amount) and the amount i... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\n\n\ndef petty_cash_report(imprest, entries):\n balance = Decimal(imprest)\n lines = []\n for description, amount in entries:\n balance += Decimal(amount)\n lines.append('After {}: {:.2f}'.format(description... | {
"idx": 3698,
"topic": "petty cash logs and replenishment",
"difficulty": "easy",
"provider": "together",
"in_tokens": 0,
"out_tokens": 486,
"latency_s": 5.1
} |
[
{
"role": "user",
"content": "You are maintaining the loan ledger for a small business. A loan of $10,000.00 is taken with an annual nominal interest rate of 6% (0.5% per month), compounded monthly, to be repaid over 12 equal monthly payments. Write a function `amortization_schedule(principal, annual_rate, ... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\n\nCENT = Decimal('0.01')\n\ndef amortization_schedule(principal, annual_rate, months):\n principal = Decimal(str(principal))\n r = Decimal(str(annual_rate)) / Decimal('12')\n months = int(months)\n\n one = Decimal('1'... | {
"idx": 706,
"topic": "loan and mortgage amortization schedules",
"difficulty": "easy",
"provider": "together",
"in_tokens": 0,
"out_tokens": 507,
"latency_s": 2.6
} |
[
{
"role": "user",
"content": "Implement `process_ledger(transactions)` that processes an ordered journal of bookkeeping transactions and returns each account's balance (total debits minus total credits) as a `Decimal` quantized to cents, with accounts sorted alphabetically as dict keys. Each transaction is ... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\n\nCENT = Decimal(\"0.01\")\n\n\ndef _to_cents(value):\n return Decimal(value).quantize(CENT, rounding=ROUND_HALF_UP)\n\n\ndef process_ledger(transactions):\n balances = {}\n posted = {} # txn id -> list of (account, si... | {
"idx": 3351,
"topic": "correcting entries, reversals, and voided transactions",
"difficulty": "hard",
"provider": "together",
"in_tokens": 0,
"out_tokens": 1547,
"latency_s": 32.8
} |
[
{
"role": "user",
"content": "Implement a mini general ledger supporting double-entry journal entries and percentage-based posting rules, using Decimal with cents quantized via ROUND_HALF_UP. A posting rule names one credit account and a list of (debit account, percentage) allocations whose percentages must... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\n\nCENT = Decimal(\"0.01\")\nONE = Decimal(\"1\")\nZERO = Decimal(\"0\")\n\n\ndef to_cents(value):\n \"\"\"Quantize a monetary value to cents using ROUND_HALF_UP.\"\"\"\n return Decimal(value).quantize(CENT, rounding=ROUND_H... | {
"idx": 2280,
"topic": "double-entry journal entries and posting rules",
"difficulty": "hard",
"provider": "novita",
"in_tokens": 199,
"out_tokens": 5703,
"latency_s": 57.6
} |
[
{
"role": "user",
"content": "Implement a double-entry bookkeeping module using dataclasses and Decimal with precise cent-level monetary handling. Define a frozen `Posting` dataclass (fields: `account: str`, `debit: Decimal = 0`, `credit: Decimal = 0`) validated in `__post_init__` so that the account is a n... | [
{
"role": "assistant",
"content": "from __future__ import annotations\n\nfrom dataclasses import dataclass\nfrom datetime import date\nfrom decimal import Decimal\nfrom enum import Enum\nfrom typing import Dict, List, Optional, Tuple\n\nTWO_PLACES = Decimal(\"0.01\")\nZERO = Decimal(\"0.00\")\n\n\nclass Boo... | {
"idx": 2536,
"topic": "accounting record dataclasses and schemas",
"difficulty": "hard",
"provider": "together",
"in_tokens": 0,
"out_tokens": 2958,
"latency_s": 133.6
} |
[
{
"role": "user",
"content": "You are building the core logic of a small bookkeeping command-line tool. Write a function `apply_entries(ledger, entries)` that processes a list of journal entries against a ledger of accounts. The ledger is a dict mapping account names (strings) to balances given as strings r... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP, InvalidOperation\n\nTWO_PLACES = Decimal('0.01')\n\ndef _quantize(value):\n return value.quantize(TWO_PLACES, rounding=ROUND_HALF_UP)\n\ndef apply_entries(ledger, entries):\n result = {}\n for account, raw_balance in led... | {
"idx": 3752,
"topic": "small bookkeeping command-line tool logic",
"difficulty": "medium",
"provider": "together",
"in_tokens": 0,
"out_tokens": 699,
"latency_s": 7
} |
[
{
"role": "user",
"content": "Implement an immutable audit trail for a ledger using Decimal money. Each entry has an id, an account name, a description, and a signed Decimal amount. The audit trail must be append-only: any attempt to modify or delete an existing entry must be rejected (raise a ValueError). ... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\nimport uuid\n\n\nclass AuditTrail:\n def __init__(self):\n self._entries = []\n\n def add_entry(self, account, description, amount):\n if not isinstance(amount, Decimal):\n raise TypeError('amount m... | {
"idx": 582,
"topic": "audit trails and immutable entry logs",
"difficulty": "medium",
"provider": "together",
"in_tokens": 0,
"out_tokens": 810,
"latency_s": 12.2
} |
[
{
"role": "user",
"content": "Write a function `quarter_end_report(ledger)` that takes a list of ledger entries and produces a per-quarter summary for a fiscal year. Each ledger entry is a tuple `(date_string, description, amount_string)` where `date_string` is in ISO format 'YYYY-MM-DD' and `amount_string`... | [
{
"role": "assistant",
"content": "import decimal\nfrom decimal import Decimal, ROUND_HALF_UP\nfrom datetime import date\n\n\ndef quarter_end_report(ledger):\n quarter_end_months = {1: 3, 2: 6, 3: 9, 4: 12}\n month_days = {3: 31, 6: 30, 9: 30, 12: 31}\n\n totals = {q: Decimal('0') for q in range(1,... | {
"idx": 2785,
"topic": "fiscal periods, quarters, and month-end date utilities",
"difficulty": "easy",
"provider": "together",
"in_tokens": 0,
"out_tokens": 616,
"latency_s": 5.7
} |
[
{
"role": "user",
"content": "A bookkeeper needs a depreciation schedule for a fixed asset. Given a purchase price (as a string, e.g. \"5000.00\"), a salvage value, a useful life in whole years, and a declining-balance rate factor (e.g. 2.0 for double-declining), produce two schedules using Decimal arithmet... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\n\nCENT = Decimal(\"0.01\")\n\n\ndef _q(value):\n return value.quantize(CENT, rounding=ROUND_HALF_UP)\n\n\ndef depreciation_schedules(cost, salvage, life, factor):\n cost = Decimal(str(cost))\n salvage = Decimal(str(salva... | {
"idx": 232,
"topic": "depreciation schedules (straight-line, declining balance)",
"difficulty": "easy",
"provider": "together",
"in_tokens": 0,
"out_tokens": 848,
"latency_s": 8
} |
[
{
"role": "user",
"content": "A trial balance lists every general-ledger account with its debit or credit balance; the total debits must equal total credits. Write a function `trial_balance_report(entries)` that takes a list of tuples `(account_name, side, amount)` where `side` is either 'D' or 'C' and `amo... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\n\n\ndef trial_balance_report(entries):\n order = []\n debits = {}\n credits = {}\n for account, side, amount in entries:\n value = Decimal(amount)\n if account not in debits and account not in credits:\n... | {
"idx": 1250,
"topic": "trial balance construction and imbalance detection",
"difficulty": "medium",
"provider": "together",
"in_tokens": 0,
"out_tokens": 790,
"latency_s": 8.9
} |
[
{
"role": "user",
"content": "You are building the accounting core of a small bookkeeping application and must verify it with unit tests using only the standard library. Implement a class `Ledger` with an `add_entry(description, amount)` method that records an entry as a `Decimal` amount (positive for debit... | [
{
"role": "assistant",
"content": "import unittest\nfrom decimal import Decimal, ROUND_HALF_UP\n\nTWO_PLACES = Decimal('0.01')\n\n\nclass Ledger:\n def __init__(self):\n self.entries = []\n\n def add_entry(self, description, amount):\n if not isinstance(amount, Decimal):\n amo... | {
"idx": 102,
"topic": "unit tests for accounting functions",
"difficulty": "easy",
"provider": "together",
"in_tokens": 0,
"out_tokens": 827,
"latency_s": 4.6
} |
[
{
"role": "user",
"content": "Write a function `reconcile_ledger(entries)` for a small bookkeeping CLI that reconciles a list of ledger entries against a bank statement. Each entry is a tuple `(id, kind, amount)` where `kind` is either `'debit'` or `'credit'` and `amount` is a string like `'12.34'`; debits ... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\n\nCENT = Decimal('0.01')\nTOL = Decimal('0.005')\n\ndef reconcile_ledger(entries, bank_balance):\n bank = Decimal(bank_balance).quantize(CENT, rounding=ROUND_HALF_UP)\n balance = Decimal('0.00')\n suspect_id = None\n ... | {
"idx": 92,
"topic": "small bookkeeping command-line tool logic",
"difficulty": "medium",
"provider": "together",
"in_tokens": 0,
"out_tokens": 637,
"latency_s": 7.5
} |
[
{
"role": "user",
"content": "You are maintaining a simple loan ledger. A loan of principal P is repaid in N equal monthly payments, with an annual interest rate of R percent, where interest is applied monthly as R/12 percent of the outstanding balance before each payment. Write a function `payment_schedule... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\n\nTWO = Decimal('0.01')\n\ndef r2(x):\n return x.quantize(TWO, rounding=ROUND_HALF_UP)\n\ndef payment_schedule(principal, annual_rate_percent, months):\n principal = Decimal(principal)\n monthly_rate = Decimal(annual_rat... | {
"idx": 912,
"topic": "interest calculation and payment schedules",
"difficulty": "easy",
"provider": "together",
"in_tokens": 0,
"out_tokens": 626,
"latency_s": 7.8
} |
[
{
"role": "user",
"content": "A bookkeeper must split an invoice total across multiple cost centers while keeping the ledger balanced. Write a function `allocate(total, weights, currency_exponent=2)` that takes a string `total` (the invoice amount), a list of positive integers `weights` (one per cost center... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\n\n\ndef allocate(total, weights, currency_exponent=2):\n if not weights:\n raise ValueError('weights must not be empty')\n if any(w <= 0 for w in weights):\n raise ValueError('all weights must be positive')\n\... | {
"idx": 1020,
"topic": "currency rounding rules with the Decimal type",
"difficulty": "medium",
"provider": "together",
"in_tokens": 0,
"out_tokens": 871,
"latency_s": 5.7
} |
[
{
"role": "user",
"content": "Write a function `summarize_ledger(entries)` for a small bookkeeping CLI tool. Each entry is a tuple `(date, description, amount)` where `amount` is a string like '12.50' or '-3.25' representing a signed amount in dollars (positive = credit, negative = debit). Use `decimal.Deci... | [
{
"role": "assistant",
"content": "from decimal import Decimal, InvalidOperation, ROUND_HALF_UP\n\ndef summarize_ledger(entries):\n \"\"\"Summarize ledger entries.\n\n Each entry is (date, description, amount) with amount as a string.\n Returns (net_balance, n_credits, n_debits) where net_balance i... | {
"idx": 992,
"topic": "small bookkeeping command-line tool logic",
"difficulty": "easy",
"provider": "together",
"in_tokens": 0,
"out_tokens": 590,
"latency_s": 6.1
} |
[
{
"role": "user",
"content": "Write a function `amortize(principal, annual_rate, years, payments_per_year=12)` that builds a full amortization ledger for a fixed-rate loan using the `Decimal` type with cent-level (ROUND_HALF_UP) rounding. Each payment entry must record: payment number, payment amount, inter... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\n\nCENT = Decimal('0.01')\n\ndef _round(d):\n return d.quantize(CENT, rounding=ROUND_HALF_UP)\n\ndef amortize(principal, annual_rate, years, payments_per_year=12):\n principal = Decimal(str(principal))\n annual_rate = Dec... | {
"idx": 1062,
"topic": "loan and mortgage amortization schedules",
"difficulty": "medium",
"provider": "together",
"in_tokens": 0,
"out_tokens": 657,
"latency_s": 8.5
} |
[
{
"role": "user",
"content": "A small business posts a monthly rent expense of 850.00 on the last day of every month, starting 2024-01-31, plus a weekly cleaning service of 60.00 every Friday starting 2024-01-05. Given a start date and an end date (inclusive), compute the total posted amount in that window ... | [
{
"role": "assistant",
"content": "from datetime import date, timedelta\nfrom decimal import Decimal\n\n\ndef total_postings(start: str, end: str) -> tuple:\n start_d = date.fromisoformat(start)\n end_d = date.fromisoformat(end)\n if end_d < start_d:\n return (Decimal(\"0.00\"), 0, 0)\n\n ... | {
"idx": 2502,
"topic": "recurring and calendar-based postings",
"difficulty": "easy",
"provider": "together",
"in_tokens": 0,
"out_tokens": 531,
"latency_s": 6.1
} |
[
{
"role": "user",
"content": "A small shop needs to compute the VAT-inclusive total for a basket of items. Each item has a net price (a Decimal with exactly 2 decimal places) and a quantity (a non-negative integer). The VAT rate is given as a percentage string, e.g. '7.7' for 7.7%. For each item, compute th... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\n\nTWO = Decimal('0.01')\n\n\ndef _round2(value):\n return value.quantize(TWO, rounding=ROUND_HALF_UP)\n\n\ndef compute_invoice(items, vat_rate):\n rate = Decimal(vat_rate)\n total_net = Decimal('0.00')\n total_vat = D... | {
"idx": 1190,
"topic": "sales tax and VAT computation and rounding",
"difficulty": "easy",
"provider": "together",
"in_tokens": 0,
"out_tokens": 571,
"latency_s": 18.2
} |
[
{
"role": "user",
"content": "You process a bookkeeping log where each non-empty line is one transaction in one of these forms: `POST <date> <id> <lines>`, `REVERSE <date> <id> ref=<id>`, `VOID <date> <id> ref=<id>`, or `CORRECT <date> <id> ref=<id> <lines>` — dates are ISO `YYYY-MM-DD`, ids are tokens like... | [
{
"role": "assistant",
"content": "import sys\nfrom decimal import Decimal, ROUND_HALF_EVEN\n\nCENT = Decimal(\"0.01\")\nZERO = Decimal(\"0\")\n\n\ndef fmt(d):\n return str(d.quantize(CENT, rounding=ROUND_HALF_EVEN))\n\n\ndef process_log(log_lines):\n txns = {} # id -> {\"type\", \"date\", \"line... | {
"idx": 1231,
"topic": "correcting entries, reversals, and voided transactions",
"difficulty": "hard",
"provider": "together",
"in_tokens": 0,
"out_tokens": 2039,
"latency_s": 147.7
} |
[
{
"role": "user",
"content": "You are building the categorization engine for a small-business bookkeeping system. Each expense line item has a description string, and you must assign it to the correct account from a chart of accounts using keyword rules. The chart of accounts is a list of (code, name, keywo... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\nfrom collections import OrderedDict\n\ndef categorize_expenses(chart, items):\n D = Decimal\n totals = OrderedDict()\n counts = OrderedDict()\n names = {}\n for code, name, keywords in chart:\n names[code] =... | {
"idx": 2360,
"topic": "chart of accounts and expense categorization",
"difficulty": "medium",
"provider": "together",
"in_tokens": 0,
"out_tokens": 738,
"latency_s": 7.5
} |
[
{
"role": "user",
"content": "You are given a chart of accounts as a list of tuples (account_code, account_name, account_type) where account_type is one of 'Asset', 'Liability', 'Equity', 'Revenue', 'Expense'. You must write a function `categorize_expenses(entries, accounts)` that takes a list of journal en... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\n\n\ndef categorize_expenses(entries, accounts):\n code_to_account = {}\n for code, name, acc_type in accounts:\n code_to_account[code] = (name, acc_type)\n\n balances = {}\n for entry in entries:\n for c... | {
"idx": 2531,
"topic": "chart of accounts and expense categorization",
"difficulty": "medium",
"provider": "together",
"in_tokens": 0,
"out_tokens": 731,
"latency_s": 188.7
} |
[
{
"role": "user",
"content": "Implement a small general ledger with T-accounts using the Decimal type for exact monetary arithmetic. Each account has a name, a type ('debit' or 'credit' normal balance), and a list of entries. Your ledger must support posting an entry to one account (date, description, amoun... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\n\nCENT = Decimal('0.01')\n\n\ndef to_money(value):\n \"\"\"Convert to a Decimal quantized to 2 places, ROUND_HALF_UP.\"\"\"\n if not isinstance(value, Decimal):\n value = Decimal(str(value))\n return value.quantiz... | {
"idx": 3867,
"topic": "general ledger and T-account operations",
"difficulty": "medium",
"provider": "together",
"in_tokens": 0,
"out_tokens": 1421,
"latency_s": 14.2
} |
[
{
"role": "user",
"content": "A bookkeeper needs to allocate a total invoice amount across three cost centers proportionally to their shares, using cents as the smallest unit. Given a total amount as a string (e.g. '1000.00') and three non-negative integer weights (e.g. 500, 300, 200), compute each center's... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\n\ndef allocate(total: str, weights: list[int]) -> list[str]:\n total = Decimal(total).quantize(Decimal('0.01'), rounding=ROUND_HALF_UP)\n wsum = sum(weights)\n if wsum == 0:\n raise ValueError('weights must not al... | {
"idx": 3643,
"topic": "currency rounding rules with the Decimal type",
"difficulty": "medium",
"provider": "together",
"in_tokens": 0,
"out_tokens": 593,
"latency_s": 7.3
} |
[
{
"role": "user",
"content": "A small business wants to automate recurring monthly postings. A recurring posting rule is defined by: a monthly amount (a string like '120.00'), a start date, an end date (inclusive), and a posting day of month (1-28, always valid). On the posting day of each month in the rang... | [
{
"role": "assistant",
"content": "from datetime import date\nfrom decimal import Decimal, ROUND_HALF_UP\n\n\ndef post_recurring(ledger, amount, start, end, day, description):\n amount = Decimal(amount)\n total = Decimal('0')\n year, month = start.year, start.month\n while (year, month) <= (end.... | {
"idx": 1522,
"topic": "recurring and calendar-based postings",
"difficulty": "medium",
"provider": "together",
"in_tokens": 0,
"out_tokens": 562,
"latency_s": 7.8
} |
[
{
"role": "user",
"content": "A bookkeeper needs a quick sanity check on a general ledger before closing the month. Write a function `build_trial_balance(entries)` that takes a list of ledger entries, where each entry is a tuple `(account_name, debit, credit)` with debit and credit given as strings represen... | [
{
"role": "assistant",
"content": "from decimal import Decimal\nfrom collections import defaultdict\n\n\ndef build_trial_balance(entries):\n balances = defaultdict(Decimal)\n total_debits = Decimal(\"0.00\")\n total_credits = Decimal(\"0.00\")\n for account, debit, credit in entries:\n d ... | {
"idx": 2690,
"topic": "trial balance construction and imbalance detection",
"difficulty": "easy",
"provider": "together",
"in_tokens": 0,
"out_tokens": 499,
"latency_s": 49.3
} |
[
{
"role": "user",
"content": "A bookkeeper has recorded all of a company's year's activity on the cash basis and must convert the results to the accrual basis at year end. You are given (1) `cash_entries`: a list of tuples `(date, account, amount_str)` where `amount_str` is a decimal string in dollars, posi... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\n\nCENT = Decimal('0.01')\n\n\ndef _to_cents(value):\n \"\"\"Convert a Decimal to an integer number of cents using ROUND_HALF_UP.\"\"\"\n return int((value.quantize(CENT, rounding=ROUND_HALF_UP) * 100).to_integral_value())\n... | {
"idx": 2886,
"topic": "accrual versus cash basis adjustments",
"difficulty": "hard",
"provider": "together",
"in_tokens": 0,
"out_tokens": 1792,
"latency_s": 18.6
} |
[
{
"role": "user",
"content": "You are given a list of general-ledger account balances as tuples (account_name, balance), where debits are positive Decimal amounts and credits are negative Decimal amounts (e.g., ('Cash', Decimal('150.00')), ('Accounts Payable', Decimal('-60.00'))). Build a trial balance repo... | [
{
"role": "assistant",
"content": "from decimal import Decimal, ROUND_HALF_UP\n\nTWO = Decimal('0.01')\nZERO = Decimal('0.00')\n\n\ndef _q(value):\n return value.quantize(TWO, rounding=ROUND_HALF_UP)\n\n\ndef trial_balance(accounts):\n rows = []\n total_debits = Decimal('0')\n total_credits = De... | {
"idx": 1281,
"topic": "trial balance construction and imbalance detection",
"difficulty": "medium",
"provider": "together",
"in_tokens": 0,
"out_tokens": 859,
"latency_s": 17.6
} |
[
{
"role": "user",
"content": "Write a function `quarter_end_report(ledger, year, quarter)` that produces a summarized quarterly report from a bookkeeping ledger. The ledger is a list of tuples `(date_str, account, debit, credit)`, where `date_str` is an ISO date string 'YYYY-MM-DD', `account` is a string, a... | [
{
"role": "assistant",
"content": "from datetime import date\nfrom decimal import Decimal, ROUND_HALF_UP\n\n\ndef quarter_end_report(ledger, year, quarter):\n if quarter not in (1, 2, 3, 4):\n raise ValueError(\"quarter must be 1, 2, 3, or 4\")\n\n start_month = (quarter - 1) * 3 + 1\n start... | {
"idx": 3857,
"topic": "fiscal periods, quarters, and month-end date utilities",
"difficulty": "medium",
"provider": "together",
"in_tokens": 0,
"out_tokens": 823,
"latency_s": 12.6
} |
[
{
"role": "user",
"content": "Implement a small ledger module with two accounting functions and write unit tests for them using only the standard library. `post_entry(entries, date, description, debit, credit)` appends a balanced journal entry (a dict with keys 'date', 'description', 'debit', 'credit') to a... | [
{
"role": "assistant",
"content": "import unittest\nfrom decimal import Decimal, ROUND_HALF_UP\n\n\ndef post_entry(entries, date, description, debit, credit):\n if not isinstance(debit, Decimal) or not isinstance(credit, Decimal):\n raise ValueError('debit and credit must be Decimal')\n if debi... | {
"idx": 1750,
"topic": "unit tests for accounting functions",
"difficulty": "medium",
"provider": "together",
"in_tokens": 0,
"out_tokens": 970,
"latency_s": 4.7
} |
[
{
"role": "user",
"content": "Implement a simple double-entry ledger with precise monetary handling, plus a test suite for it. The Ledger class must support add_entry(date, description, lines) where lines is a list of (account, Decimal_amount) pairs with positive amounts for debits and negative for credits;... | [
{
"role": "assistant",
"content": "import unittest\nfrom decimal import Decimal, ROUND_HALF_UP\n\nCENT = Decimal('0.01')\n\n\ndef to_cents(value):\n return Decimal(value).quantize(CENT, rounding=ROUND_HALF_UP)\n\n\nclass Ledger:\n def __init__(self):\n self.entries = []\n self._balances ... | {
"idx": 2044,
"topic": "unit tests for accounting functions",
"difficulty": "medium",
"provider": "together",
"in_tokens": 0,
"out_tokens": 1207,
"latency_s": 3.8
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.