| {"id":"cmskf3c8200071wp2lcgno27p","kind":"contributor_item","title":"Submission GNO27P","provisional":false,"code":"def demo():\n config = {\"retries\": 3}\n kept = config.setdefault(\"retries\", 10)\n added = config.setdefault(\"timeout\", 30)\n return (kept, added, config.get(\"timeout\", 99), sorted(config.items()))","input":"demo()","language":"Python","predicted_output":"(3, 30, 30, [('retries', 3), ('timeout', 30)])"} |
| {"id":"cmskf3c8200051wp25947eul8","kind":"contributor_item","title":"Submission 47EUL8","provisional":false,"code":"def demo():\n loose = []\n for factor in range(1, 4):\n loose.append(lambda x: x * factor)\n bound = [lambda x, factor=factor: x * factor for factor in range(1, 4)]\n return ([f(10) for f in loose], [f(10) for f in bound])","input":"demo()","language":"Python","predicted_output":"([30, 30, 30], [10, 20, 30])"} |
| {"id":"cmskf3c8300091wp29wn8ecs7","kind":"contributor_item","title":"Submission N8ECS7","provisional":false,"code":"def demo():\n path = \"a/b/c/d\"\n parts = path.split(\"/\")\n return (parts[::-1], \"/\".join(parts[1:-1]), path.partition(\"/\"), path[::2])","input":"demo()","language":"Python","predicted_output":"(['d', 'c', 'b', 'a'], 'b/c', ('a', '/', 'b/c/d'), 'abcd')"} |
| {"id":"cmskf3c8200031wp2jpynnp7y","kind":"contributor_item","title":"Submission YNNP7Y","provisional":false,"code":"def resolve(flag):\n try:\n if flag:\n return \"from-try\"\n raise ValueError(\"bad flag\")\n except ValueError:\n return \"from-except\"\n finally:\n print(\"cleanup ran\")\n\ndef demo():\n return (resolve(True), resolve(False))","input":"demo()","language":"Python","predicted_output":"cleanup ran\ncleanup ran\n('from-try', 'from-except')"} |
| {"id":"cmskf3c8200041wp2vszakqde","kind":"contributor_item","title":"Submission ZAKQDE","provisional":false,"code":"import copy\n\ndef demo():\n grid = [[0, 1], [2, 3]]\n shallow = list(grid)\n deep = copy.deepcopy(grid)\n grid[0][0] = 99\n return (shallow[0][0], deep[0][0], shallow[0] is grid[0])","input":"demo()","language":"Python","predicted_output":"(99, 0, True)"} |
| {"id":"cmskf3c8200011wp22kb81bve","kind":"contributor_item","title":"Submission B81BVE","provisional":false,"code":"records = [\n {\"name\": \"ida\", \"dept\": \"ops\", \"years\": 4},\n {\"name\": \"ben\", \"dept\": \"eng\", \"years\": 4},\n {\"name\": \"cy\", \"dept\": \"eng\", \"years\": 7},\n]\n\ndef rank():\n ordered = sorted(records, key=lambda r: (r[\"dept\"], -r[\"years\"], r[\"name\"]))\n return [(r[\"dept\"], r[\"name\"], r[\"years\"]) for r in ordered]","input":"rank()","language":"Python","predicted_output":"[('eng', 'cy', 7), ('eng', 'ben', 4), ('ops', 'ida', 4)]"} |
| {"id":"cmskf3c8200001wp2osjhk0zm","kind":"contributor_item","title":"Submission JHK0ZM","provisional":false,"code":"def collect(item, bucket=[]):\n bucket.append(item)\n return bucket\n\ndef demo():\n first = collect(\"a\")\n second = collect(\"b\")\n return (first, second, first is second)","input":"demo()","language":"Python","predicted_output":"(['a', 'b'], ['a', 'b'], True)"} |
| {"id":"cmskf3c8200081wp28tpa14hx","kind":"contributor_item","title":"Submission PA14HX","provisional":false,"code":"class ParseError(Exception):\n pass\n\ndef parse_port(raw):\n try:\n return int(raw)\n except ValueError:\n raise ParseError(\"not a port: \" + raw) from None\n\ndef demo():\n results = []\n for raw in [\"8080\", \"https\"]:\n try:\n results.append(parse_port(raw))\n except ParseError as exc:\n results.append(type(exc).__name__ + \": \" + str(exc))\n return results","input":"demo()","language":"Python","predicted_output":"[8080, 'ParseError: not a port: https']"} |
| {"id":"cmskf3c8200061wp24z0nxfpf","kind":"contributor_item","title":"Submission 0NXFPF","provisional":false,"code":"from itertools import groupby\n\ntickets = [\"ops-3\", \"eng-1\", \"ops-9\", \"eng-4\"]\n\ndef team_of(ticket):\n return ticket.split(\"-\")[0]\n\ndef demo():\n raw = [(team, list(g)) for team, g in groupby(tickets, key=team_of)]\n tidy = [(team, list(g)) for team, g in groupby(sorted(tickets), key=team_of)]\n return (raw, tidy)","input":"demo()","language":"Python","predicted_output":"([('ops', ['ops-3']), ('eng', ['eng-1']), ('ops', ['ops-9']), ('eng', ['eng-4'])], [('eng', ['eng-1', 'eng-4']), ('ops', ['ops-3', 'ops-9'])])"} |
| {"id":"cmskf3c8200021wp23qmbd6xs","kind":"contributor_item","title":"Submission MBD6XS","provisional":false,"code":"from collections import Counter\n\ndef tally():\n counts = Counter(\"pear fig pear plum fig date\".split())\n return (counts.most_common(2), counts[\"kiwi\"], len(counts))","input":"tally()","language":"Python","predicted_output":"([('pear', 2), ('fig', 2)], 0, 4)"} |
| {"id":"cmskfpd47000ix6p20pacmnuw","kind":"contributor_item","title":"Submission ACMNUW","provisional":false,"code":"from itertools import accumulate, chain, islice\n\ndef demo_itertools():\n running = list(accumulate([1, 2, 3, 4]))\n joined = list(chain([1, 2], \"ab\"))\n window = list(islice(range(10), 2, 7, 2))\n return (running, joined, window)","input":"demo_itertools()","language":"Python","predicted_output":"([1, 3, 6, 10], [1, 2, 'a', 'b'], [2, 4, 6])"} |
| {"id":"cmskfpd48000zx6p2kejqm7xx","kind":"contributor_item","title":"Submission JQM7XX","provisional":false,"code":"def make_counter():\n count = 0\n\n def bump():\n nonlocal count\n count += 1\n return count\n\n return bump\n\ndef demo_nonlocal():\n first = make_counter()\n second = make_counter()\n return (first(), first(), second())","input":"demo_nonlocal()","language":"Python","predicted_output":"(1, 2, 1)"} |
| {"id":"cmskfpd480011x6p2zei9p4qw","kind":"contributor_item","title":"Submission I9P4QW","provisional":false,"code":"def demo_try_else():\n log = []\n for raw in [\"5\", \"oops\"]:\n try:\n value = int(raw)\n except ValueError:\n log.append(\"except\")\n else:\n log.append(\"else:\" + str(value))\n finally:\n log.append(\"finally\")\n return log","input":"demo_try_else()","language":"Python","predicted_output":"['else:5', 'finally', 'except', 'finally']"} |
| {"id":"cmskfpd48000wx6p29wilm6gc","kind":"contributor_item","title":"Submission ILM6GC","provisional":false,"code":"def demo_formatting():\n value = 3.14159\n name = \"pi\"\n return (\n \"{:.2f}\".format(value),\n \"{:>8}\".format(name),\n \"{:08.3f}\".format(value),\n f\"{name:*^9}\",\n )","input":"demo_formatting()","language":"Python","predicted_output":"('3.14', ' pi', '0003.142', '***pi****')"} |
| {"id":"cmskfpd48000px6p2v14vqo4a","kind":"contributor_item","title":"Submission 4VQO4A","provisional":false,"code":"def demo_repeated_refs():\n shared = [[]] * 3\n shared[0].append(\"x\")\n independent = [[] for _ in range(3)]\n independent[0].append(\"y\")\n return (shared, independent, shared[1] is shared[2])","input":"demo_repeated_refs()","language":"Python","predicted_output":"([['x'], ['x'], ['x']], [['y'], [], []], True)"} |
| {"id":"cmskfpd47000ax6p223kae635","kind":"contributor_item","title":"Submission KAE635","provisional":false,"code":"class Temperature:\n def __init__(self, celsius):\n self._celsius = celsius\n\n @property\n def fahrenheit(self):\n return self._celsius * 9 / 5 + 32\n\n @fahrenheit.setter\n def fahrenheit(self, value):\n self._celsius = (value - 32) * 5 / 9\n\ndef demo_property():\n t = Temperature(100)\n before = t.fahrenheit\n t.fahrenheit = 32\n return (before, t._celsius)","input":"demo_property()","language":"Python","predicted_output":"(212.0, 0.0)"} |
| {"id":"cmskfpd47000fx6p2w5qkhnld","kind":"contributor_item","title":"Submission QKHNLD","provisional":false,"code":"def noisy_range(n):\n for i in range(n):\n print(\"yielding\", i)\n yield i\n\ndef demo_lazy():\n gen = noisy_range(3)\n print(\"created\")\n first = next(gen)\n print(\"got\", first)\n return list(gen)","input":"demo_lazy()","language":"Python","predicted_output":"created\nyielding 0\ngot 0\nyielding 1\nyielding 2\n[1, 2]"} |
| {"id":"cmskfpd48000qx6p2n2wi82p4","kind":"contributor_item","title":"Submission WI82P4","provisional":false,"code":"def demo_tuple_mutation():\n holder = ([1], \"fixed\")\n try:\n holder[0] += [2]\n outcome = \"no error\"\n except TypeError as exc:\n outcome = type(exc).__name__\n return (outcome, holder)","input":"demo_tuple_mutation()","language":"Python","predicted_output":"('TypeError', ([1, 2], 'fixed'))"} |
| {"id":"cmskfpd470006x6p2krj21lmm","kind":"contributor_item","title":"Submission J21LMM","provisional":false,"code":"from functools import partial\n\ndef power(base, exponent):\n return base ** exponent\n\ndef demo_partial():\n square = partial(power, exponent=2)\n cube_of_two = partial(power, 2)\n return (square(7), cube_of_two(3))","input":"demo_partial()","language":"Python","predicted_output":"(49, 8)"} |
| {"id":"cmskfpd47000nx6p27w17ork7","kind":"contributor_item","title":"Submission 17ORK7","provisional":false,"code":"def demo_dict_removal():\n data = {\"a\": 1, \"b\": 2, \"c\": 3}\n popped = data.pop(\"b\")\n missing = data.pop(\"zz\", \"default\")\n last = data.popitem()\n return (popped, missing, last, data)","input":"demo_dict_removal()","language":"Python","predicted_output":"(2, 'default', ('c', 3), {'a': 1})"} |
| {"id":"cmskfpd47000kx6p2it2r85a5","kind":"contributor_item","title":"Submission 2R85A5","provisional":false,"code":"def truthy(value):\n print(\"checking\", value)\n return value > 2\n\ndef demo_short_circuit():\n any_result = any(truthy(v) for v in [1, 3, 5])\n print(\"---\")\n all_result = all(truthy(v) for v in [3, 1, 5])\n return (any_result, all_result)","input":"demo_short_circuit()","language":"Python","predicted_output":"checking 1\nchecking 3\n---\nchecking 3\nchecking 1\n(True, False)"} |
| {"id":"cmskfpd47000hx6p2cnnrr8b4","kind":"contributor_item","title":"Submission NRR8B4","provisional":false,"code":"def demo_generator_expr():\n squares = (x * x for x in range(4))\n first_pass = list(squares)\n second_pass = list(squares)\n return (first_pass, second_pass)","input":"demo_generator_expr()","language":"Python","predicted_output":"([0, 1, 4, 9], [])"} |
| {"id":"cmskfpd470003x6p208eutk8e","kind":"contributor_item","title":"Submission EUTK8E","provisional":false,"code":"from collections import OrderedDict\n\ndef reorder():\n od = OrderedDict([(\"a\", 1), (\"b\", 2), (\"c\", 3)])\n od.move_to_end(\"a\")\n first = list(od.keys())\n od.move_to_end(\"c\", last=False)\n return (first, list(od.keys()))","input":"reorder()","language":"Python","predicted_output":"(['b', 'c', 'a'], ['c', 'b', 'a'])"} |
| {"id":"cmskfpd480012x6p25xexstzj","kind":"contributor_item","title":"Submission EXSTZJ","provisional":false,"code":"def demo_walrus():\n readings = [4, 8, 1, 9]\n kept = []\n while readings and (current := readings.pop(0)) < 9:\n kept.append(current)\n return (kept, readings, current)","input":"demo_walrus()","language":"Python","predicted_output":"([4, 8, 1], [], 9)"} |
| {"id":"cmskfpd47000cx6p2x1o0moev","kind":"contributor_item","title":"Submission O0MOEV","provisional":false,"code":"class Registry:\n members = []\n\n def __init__(self, name):\n self.name = name\n Registry.members.append(name)\n\n @classmethod\n def count(cls):\n return len(cls.members)\n\n @staticmethod\n def label():\n return \"registry\"\n\ndef demo_class_state():\n Registry(\"a\")\n Registry(\"b\")\n return (Registry.count(), Registry.label(), Registry.members)","input":"demo_class_state()","language":"Python","predicted_output":"(2, 'registry', ['a', 'b'])"} |
| {"id":"cmskfpd47000gx6p29j30ysdj","kind":"contributor_item","title":"Submission 30YSDJ","provisional":false,"code":"def demo_next_default():\n it = iter([10, 20])\n a = next(it)\n b = next(it)\n c = next(it, \"empty\")\n try:\n next(it)\n d = \"no error\"\n except StopIteration:\n d = \"StopIteration\"\n return (a, b, c, d)","input":"demo_next_default()","language":"Python","predicted_output":"(10, 20, 'empty', 'StopIteration')"} |
| {"id":"cmskfpd47000ox6p2dkksi4nv","kind":"contributor_item","title":"Submission KSI4NV","provisional":false,"code":"def demo_slice_assign():\n nums = [0, 1, 2, 3, 4, 5]\n nums[1:3] = [\"a\", \"b\", \"c\"]\n copy = nums[:]\n nums[::2] = [None] * len(nums[::2])\n return (copy, nums)","input":"demo_slice_assign()","language":"Python","predicted_output":"([0, 'a', 'b', 'c', 3, 4, 5], [None, 'a', None, 'c', None, 4, None])"} |
| {"id":"cmskfpd47000lx6p2pn9rllgy","kind":"contributor_item","title":"Submission 9RLLGY","provisional":false,"code":"def demo_sort_stability():\n rows = [(\"b\", 2), (\"a\", 2), (\"c\", 1)]\n by_number = sorted(rows, key=lambda r: r[1])\n in_place = list(rows)\n returned = in_place.sort()\n return (by_number, returned, in_place)","input":"demo_sort_stability()","language":"Python","predicted_output":"([('c', 1), ('b', 2), ('a', 2)], None, [('a', 2), ('b', 2), ('c', 1)])"} |
| {"id":"cmskfpd47000jx6p2kajq3aon","kind":"contributor_item","title":"Submission JQ3AON","provisional":false,"code":"def demo_zip_truncate():\n names = [\"a\", \"b\", \"c\"]\n scores = [1, 2]\n paired = list(zip(names, scores))\n unzipped = list(zip(*paired))\n return (paired, unzipped)","input":"demo_zip_truncate()","language":"Python","predicted_output":"([('a', 1), ('b', 2)], [('a', 'b'), (1, 2)])"} |
| {"id":"cmskfpd47000mx6p2eh1owurq","kind":"contributor_item","title":"Submission 1OWURQ","provisional":false,"code":"def demo_dict_comprehension():\n pairs = [(\"a\", 1), (\"b\", 2), (\"a\", 3)]\n collapsed = {k: v for k, v in pairs}\n merged = {**{\"a\": 0, \"z\": 9}, **collapsed}\n return (collapsed, merged, len(pairs))","input":"demo_dict_comprehension()","language":"Python","predicted_output":"({'a': 3, 'b': 2}, {'a': 3, 'z': 9, 'b': 2}, 3)"} |
| {"id":"cmskfpd48000rx6p2ub50qz4y","kind":"contributor_item","title":"Submission 50QZ4Y","provisional":false,"code":"def demo_unpacking():\n first, *middle, last = [1, 2, 3, 4, 5]\n (a, b), c = (1, 2), 3\n return (first, middle, last, a, b, c)","input":"demo_unpacking()","language":"Python","predicted_output":"(1, [2, 3, 4], 5, 1, 2, 3)"} |
| {"id":"cmskfpd48000vx6p2qp65b639","kind":"contributor_item","title":"Submission 65B639","provisional":false,"code":"def demo_string_methods():\n raw = \" Report-2024-final.txt \"\n trimmed = raw.strip()\n return (\n trimmed.split(\"-\"),\n trimmed.rsplit(\"-\", 1),\n trimmed.replace(\"-\", \"_\", 1),\n trimmed.endswith(\".txt\"),\n )","input":"demo_string_methods()","language":"Python","predicted_output":"(['Report', '2024', 'final.txt'], ['Report-2024', 'final.txt'], 'Report_2024-final.txt', True)"} |
| {"id":"cmskfpd48000ux6p22d5tlcj7","kind":"contributor_item","title":"Submission 5TLCJ7","provisional":false,"code":"def demo_float_precision():\n total = 0.1 + 0.2\n return (total, total == 0.3, abs(total - 0.3) < 1e-9, 1 / 3)","input":"demo_float_precision()","language":"Python","predicted_output":"(0.30000000000000004, False, True, 0.3333333333333333)"} |
| {"id":"cmskfpd48000xx6p26i7nnib7","kind":"contributor_item","title":"Submission 7NNIB7","provisional":false,"code":"import re\n\ndef demo_regex():\n text = \"id=12, id=345, name=ada\"\n numbers = re.findall(r\"id=(\\d+)\", text)\n masked = re.sub(r\"\\d+\", \"#\", text)\n match = re.search(r\"name=(\\w+)\", text)\n return (numbers, masked, match.group(1), match.span())","input":"demo_regex()","language":"Python","predicted_output":"(['12', '345'], 'id=#, id=#, name=ada', 'ada', (15, 23))"} |
| {"id":"cmskfpd48000yx6p27d6tmmfu","kind":"contributor_item","title":"Submission 6TMMFU","provisional":false,"code":"import json\n\ndef demo_json():\n payload = {\"b\": 2, \"a\": [1, {\"c\": None}], \"flag\": True}\n text = json.dumps(payload, sort_keys=True)\n restored = json.loads(text)\n return (text, restored[\"a\"][1][\"c\"], restored == payload)","input":"demo_json()","language":"Python","predicted_output":"('{\"a\": [1, {\"c\": null}], \"b\": 2, \"flag\": true}', None, True)"} |
| {"id":"cmskfpd48000sx6p2gt75dfwh","kind":"contributor_item","title":"Submission 75DFWH","provisional":false,"code":"def demo_floor_division():\n return (\n 7 // 2, -7 // 2,\n 7 % 3, -7 % 3,\n divmod(-7, 2),\n )","input":"demo_floor_division()","language":"Python","predicted_output":"(3, -4, 1, 2, (-4, 1))"} |
| {"id":"cmskfpd48000tx6p25c19vws9","kind":"contributor_item","title":"Submission 19VWS9","provisional":false,"code":"def demo_rounding():\n return (round(0.5), round(1.5), round(2.5), round(2.675, 2), round(-1.5))","input":"demo_rounding()","language":"Python","predicted_output":"(0, 2, 2, 2.67, -2)"} |
| {"id":"cmskfpd480010x6p2wy5lhlet","kind":"contributor_item","title":"Submission 5LHLET","provisional":false,"code":"def classify(n):\n for candidate in range(2, n):\n if n % candidate == 0:\n return (\"composite\", candidate)\n else:\n return (\"prime\", None)\n\ndef demo_for_else():\n return (classify(9), classify(7))","input":"demo_for_else()","language":"Python","predicted_output":"(('composite', 3), ('prime', None))"} |
| {"id":"cmskfpd480013x6p2eg5i0jjb","kind":"contributor_item","title":"Submission 5I0JJB","provisional":false,"code":"def tally(*args, sep=\"-\", **kwargs):\n return (args, sep, sorted(kwargs.items()))\n\ndef demo_signature():\n return (tally(1, 2, sep=\"+\", mode=\"fast\"), tally())","input":"demo_signature()","language":"Python","predicted_output":"(((1, 2), '+', [('mode', 'fast')]), ((), '-', []))"} |
| {"id":"cmskfpd470007x6p222pr0xuz","kind":"contributor_item","title":"Submission PR0XUZ","provisional":false,"code":"from functools import reduce\n\ndef fold():\n numbers = [3, 1, 4, 1, 5]\n total = reduce(lambda a, b: a + b, numbers)\n seeded = reduce(lambda a, b: a + b, numbers, 100)\n largest = reduce(lambda a, b: a if a > b else b, numbers)\n return (total, seeded, largest)","input":"fold()","language":"Python","predicted_output":"(14, 114, 5)"} |
| {"id":"cmskfpd47000ex6p25pphz9hy","kind":"contributor_item","title":"Submission PHZ9HY","provisional":false,"code":"class Resource:\n def __init__(self, log):\n self.log = log\n\n def __enter__(self):\n self.log.append(\"enter\")\n return self\n\n def __exit__(self, exc_type, exc, tb):\n self.log.append(\"exit:\" + (exc_type.__name__ if exc_type else \"clean\"))\n return True\n\ndef demo_context():\n log = []\n with Resource(log):\n log.append(\"body\")\n with Resource(log):\n raise ValueError(\"boom\")\n return log","input":"demo_context()","language":"Python","predicted_output":"['enter', 'body', 'exit:clean', 'enter', 'exit:ValueError']"} |
| {"id":"cmskfpd47000dx6p2ggiej64m","kind":"contributor_item","title":"Submission IEJ64M","provisional":false,"code":"class Counter:\n total = 0\n\n def bump(self):\n self.total += 1\n return self.total\n\ndef demo_shadowing():\n a = Counter()\n b = Counter()\n first = a.bump()\n second = a.bump()\n return (first, second, b.total, Counter.total, \"total\" in a.__dict__)","input":"demo_shadowing()","language":"Python","predicted_output":"(1, 2, 0, 0, True)"} |
| {"id":"cmskfpd460000x6p2765o8s86","kind":"contributor_item","title":"Submission 5O8S86","provisional":false,"code":"from collections import defaultdict\n\ndef index_by_initial(names):\n buckets = defaultdict(list)\n for name in names:\n buckets[name[0]].append(name)\n missing = buckets[\"z\"]\n return (dict(buckets), missing, \"z\" in buckets)","input":"index_by_initial([\"ana\", \"arjun\", \"bela\", \"cy\"])","language":"Python","predicted_output":"({'a': ['ana', 'arjun'], 'b': ['bela'], 'c': ['cy'], 'z': []}, [], True)"} |
| {"id":"cmskfpd470002x6p2ycc8i1sj","kind":"contributor_item","title":"Submission C8I1SJ","provisional":false,"code":"from collections import namedtuple\n\nPoint = namedtuple(\"Point\", [\"x\", \"y\"])\n\ndef move_point():\n origin = Point(0, 0)\n shifted = origin._replace(y=5)\n return (origin, shifted, origin == Point(0, 0), shifted._asdict())","input":"move_point()","language":"Python","predicted_output":"(Point(x=0, y=0), Point(x=0, y=5), True, {'x': 0, 'y': 5})"} |
| {"id":"cmskfpd470005x6p2foxxbcs1","kind":"contributor_item","title":"Submission XXBCS1","provisional":false,"code":"from functools import lru_cache\n\ncalls = []\n\n@lru_cache(maxsize=None)\ndef slow_square(n):\n calls.append(n)\n return n * n\n\ndef demo_cache():\n results = [slow_square(4), slow_square(4), slow_square(5)]\n return (results, calls)","input":"demo_cache()","language":"Python","predicted_output":"([16, 16, 25], [4, 5])"} |
| {"id":"cmskfpd470004x6p2uwirhw78","kind":"contributor_item","title":"Submission IRHW78","provisional":false,"code":"from collections import Counter\n\ndef counter_math():\n left = Counter(a=3, b=1)\n right = Counter(a=1, b=4)\n return (dict(left - right), dict(left + right), dict(left & right))","input":"counter_math()","language":"Python","predicted_output":"({'a': 2}, {'a': 4, 'b': 5}, {'a': 1, 'b': 1})"} |
| {"id":"cmskfpd470008x6p2phg7werx","kind":"contributor_item","title":"Submission G7WERX","provisional":false,"code":"from functools import wraps\n\ndef announce(fn):\n @wraps(fn)\n def inner(*args, **kwargs):\n return fn(*args, **kwargs) * 2\n return inner\n\ndef plain(fn):\n def inner(*args, **kwargs):\n return fn(*args, **kwargs)\n return inner\n\n@announce\ndef base(x):\n \"\"\"docstring here\"\"\"\n return x + 1\n\n@plain\ndef other(x):\n return x\n\ndef demo_wraps():\n return (base(4), base.__name__, base.__doc__, other.__name__)","input":"demo_wraps()","language":"Python","predicted_output":"(10, 'base', 'docstring here', 'inner')"} |
| {"id":"cmskfpd47000bx6p2bq3uvguo","kind":"contributor_item","title":"Submission 3UVGUO","provisional":false,"code":"class Money:\n def __init__(self, amount):\n self.amount = amount\n\n def __add__(self, other):\n return Money(self.amount + other.amount)\n\n def __eq__(self, other):\n return self.amount == other.amount\n\n def __repr__(self):\n return \"Money(\" + str(self.amount) + \")\"\n\ndef demo_operators():\n total = Money(5) + Money(7)\n return (total, total == Money(12), [Money(1), Money(2)])","input":"demo_operators()","language":"Python","predicted_output":"(Money(12), True, [Money(1), Money(2)])"} |
| {"id":"cmskfpd470001x6p23240prqe","kind":"contributor_item","title":"Submission 40PRQE","provisional":false,"code":"from collections import deque\n\ndef shuffle_queue():\n q = deque([1, 2, 3, 4], maxlen=4)\n q.rotate(1)\n snapshot = list(q)\n q.appendleft(99)\n return (snapshot, list(q), q.maxlen)","input":"shuffle_queue()","language":"Python","predicted_output":"([4, 1, 2, 3], [99, 4, 1, 2], 4)"} |
| {"id":"cmskfpd470009x6p2zmftr2s5","kind":"contributor_item","title":"Submission FTR2S5","provisional":false,"code":"class Base:\n def greet(self):\n return \"base\"\n\nclass Left(Base):\n def greet(self):\n return \"left->\" + super().greet()\n\nclass Right(Base):\n def greet(self):\n return \"right->\" + super().greet()\n\nclass Both(Left, Right):\n pass\n\ndef demo_mro():\n return (Both().greet(), [c.__name__ for c in Both.__mro__])","input":"demo_mro()","language":"Python","predicted_output":"('left->right->base', ['Both', 'Left', 'Right', 'Base', 'object'])"} |
| {"id":"cmsms65yl001rdmp21hfk09gv","kind":"contributor_item","title":"Submission FK09GV","provisional":false,"code":"def generator_pipeline(n):\n def squares():\n for i in range(n):\n yield i * i\n return list(x for x in squares() if x % 2 == 0)","input":"generator_pipeline(10)","language":"Python","predicted_output":"[0, 4, 16, 36, 64]"} |
| {"id":"cmsms65yl001fdmp242km4ilp","kind":"contributor_item","title":"Submission KM4ILP","provisional":false,"code":"def try_finally_demo(x):\n log = []\n try:\n if x < 0:\n raise ValueError(\"negative\")\n log.append(\"processed\")\n return x * 2\n except ValueError as e:\n log.append(f\"error: {e}\")\n return -1\n finally:\n log.append(\"cleanup\")\n return log","input":"try_finally_demo(-5)","language":"Python","predicted_output":"-1"} |
| {"id":"cmsms65yl0018dmp2el6rff6e","kind":"contributor_item","title":"Submission 6RFF6E","provisional":false,"code":"def flatten(nested):\n result = []\n for item in nested:\n if isinstance(item, list):\n result.extend(flatten(item))\n else:\n result.append(item)\n return result","input":"flatten([1, [2, 3, [4, [5, 6]], 7], 8])","language":"Python","predicted_output":"[1, 2, 3, 4, 5, 6, 7, 8]"} |
| {"id":"cmsms65ym0025dmp2hbik6tq3","kind":"contributor_item","title":"Submission IK6TQ3","provisional":false,"code":"def validate_and_transform(records):\n valid = []\n errors = []\n for r in records:\n try:\n age = int(r[\"age\"])\n if age < 0:\n raise ValueError(\"negative age\")\n valid.append({\"name\": r[\"name\"], \"age\": age})\n except (KeyError, ValueError) as e:\n errors.append(str(e))\n return valid, errors","input":"validate_and_transform([{\"name\": \"A\", \"age\": \"30\"}, {\"name\": \"B\", \"age\": \"-5\"}, {\"name\": \"C\"}])","language":"Python","predicted_output":"([{'name': 'A', 'age': 30}], ['negative age', \"'age'\"])"} |
| {"id":"cmsms65yl001mdmp253fhlc9x","kind":"contributor_item","title":"Submission FHLC9X","provisional":false,"code":"class Animal:\n def speak(self):\n return \"...\"\n\nclass Dog(Animal):\n def speak(self):\n return \"Woof\"\n\nclass Cat(Animal):\n def speak(self):\n return \"Meow\"\n\ndef speak_all(animals):\n return [a.speak() for a in animals]","input":"speak_all([Dog(), Cat(), Animal()])","language":"Python","predicted_output":"['Woof', 'Meow', '...']"} |
| {"id":"cmsms65ym0021dmp2fu55zszn","kind":"contributor_item","title":"Submission 55ZSZN","provisional":false,"code":"def context_manager_demo():\n class Resource:\n def __init__(self, name):\n self.name = name\n self.log = []\n def __enter__(self):\n self.log.append(f\"open:{self.name}\")\n return self\n def __exit__(self, exc_type, exc_val, exc_tb):\n self.log.append(f\"close:{self.name}\")\n return False\n\n r = Resource(\"db\")\n with r:\n r.log.append(\"using\")\n return r.log","input":"context_manager_demo()","language":"Python","predicted_output":"['open:db', 'using', 'close:db']"} |
| {"id":"cmsms65yl001cdmp2iet1jnom","kind":"contributor_item","title":"Submission T1JNOM","provisional":false,"code":"class Node:\n def __init__(self, value, next=None):\n self.value = value\n self.next = next\n\ndef linked_list_to_list(head):\n out = []\n while head:\n out.append(head.value)\n head = head.next\n return out\n\ndef build_and_walk():\n head = Node(1, Node(2, Node(3, Node(4))))\n return linked_list_to_list(head)","input":"build_and_walk()","language":"Python","predicted_output":"[1, 2, 3, 4]"} |
| {"id":"cmsms65yl0015dmp2r0v8hlyy","kind":"contributor_item","title":"Submission V8HLYY","provisional":false,"code":"def fib_memo(n, cache={}):\n if n in cache:\n return cache[n]\n if n <= 1:\n return n\n cache[n] = fib_memo(n - 1, cache) + fib_memo(n - 2, cache)\n return cache[n]\n\ndef fib_sequence(count):\n return [fib_memo(i) for i in range(count)]","input":"fib_sequence(10)","language":"Python","predicted_output":"[0, 1, 1, 2, 3, 5, 8, 13, 21, 34]"} |
| {"id":"cmsms65yl0016dmp2h7cwgkzy","kind":"contributor_item","title":"Submission CWGKZY","provisional":false,"code":"class Stack:\n def __init__(self):\n self._items = []\n def push(self, item):\n self._items.append(item)\n def pop(self):\n return self._items.pop()\n def __repr__(self):\n return f\"Stack({self._items})\"\n\ndef use_stack():\n s = Stack()\n for i in [1, 2, 3]:\n s.push(i * i)\n s.pop()\n return s","input":"use_stack()","language":"Python","predicted_output":"Stack([1, 4])"} |
| {"id":"cmsms65yl001udmp2lkajjzn0","kind":"contributor_item","title":"Submission AJJZN0","provisional":false,"code":"def binary_search(arr, target):\n lo, hi = 0, len(arr) - 1\n while lo <= hi:\n mid = (lo + hi) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n lo = mid + 1\n else:\n hi = mid - 1\n return -1","input":"binary_search([1, 3, 5, 7, 9, 11, 13], 9)","language":"Python","predicted_output":"4"} |
| {"id":"cmsms65yl001ldmp27xl7ddf4","kind":"contributor_item","title":"Submission L7DDF4","provisional":false,"code":"def chained_comparisons(a, b, c):\n return a < b < c, a < b > c","input":"chained_comparisons(1, 5, 10)","language":"Python","predicted_output":"(True, False)"} |
| {"id":"cmsms65ym001zdmp2lspm4jta","kind":"contributor_item","title":"Submission PM4JTA","provisional":false,"code":"def recursive_sum_digits(n):\n if n < 10:\n return n\n return n % 10 + recursive_sum_digits(n // 10)","input":"recursive_sum_digits(987654)","language":"Python","predicted_output":"39"} |
| {"id":"cmsms65ym0027dmp2wyqlwn0p","kind":"contributor_item","title":"Submission QLWN0P","provisional":false,"code":"class ReadOnlyDict:\n def __init__(self, data):\n self._data = dict(data)\n def __getitem__(self, key):\n return self._data[key]\n def __setitem__(self, key, value):\n raise TypeError(\"read-only\")\n def __repr__(self):\n return f\"ReadOnlyDict({self._data})\"\n\ndef try_mutate():\n d = ReadOnlyDict({\"a\": 1})\n try:\n d[\"a\"] = 2\n except TypeError as e:\n return str(e), d[\"a\"]","input":"try_mutate()","language":"Python","predicted_output":"('read-only', 1)"} |
| {"id":"cmsms65yl001pdmp28w0q1k9v","kind":"contributor_item","title":"Submission 0Q1K9V","provisional":false,"code":"from collections import namedtuple\nPoint = namedtuple(\"Point\", [\"x\", \"y\"])\n\ndef sum_points(points):\n total_x = sum(p.x for p in points)\n total_y = sum(p.y for p in points)\n return Point(total_x, total_y)","input":"sum_points([Point(1, 2), Point(3, 4), Point(5, 6)])","language":"Python","predicted_output":"Point(x=9, y=12)"} |
| {"id":"cmsms65ym002fdmp2sv8l9ze7","kind":"contributor_item","title":"Submission 8L9ZE7","provisional":false,"code":"def class_method_and_static_demo():\n class Circle:\n pi = 3.14159\n def __init__(self, radius):\n self.radius = radius\n @classmethod\n def unit_circle(cls):\n return cls(1)\n @staticmethod\n def area_for(radius):\n return Circle.pi * radius * radius\n def area(self):\n return Circle.area_for(self.radius)\n\n c = Circle.unit_circle()\n return c.area(), Circle.area_for(3)","input":"class_method_and_static_demo()","language":"Python","predicted_output":"(3.14159, 28.274309999999996)"} |
| {"id":"cmsms65ym002edmp24r7p7ur2","kind":"contributor_item","title":"Submission 7P7UR2","provisional":false,"code":"def find_duplicates_with_index(items):\n seen = {}\n dupes = []\n for i, item in enumerate(items):\n if item in seen:\n dupes.append((item, seen[item], i))\n else:\n seen[item] = i\n return dupes","input":"find_duplicates_with_index([\"a\", \"b\", \"a\", \"c\", \"b\", \"b\"])","language":"Python","predicted_output":"[('a', 0, 2), ('b', 1, 4), ('b', 1, 5)]"} |
| {"id":"cmsms65yl001tdmp26yej0i1k","kind":"contributor_item","title":"Submission EJ0I1K","provisional":false,"code":"def custom_exception_demo():\n class InsufficientFundsError(Exception):\n def __init__(self, balance, amount):\n self.balance = balance\n self.amount = amount\n super().__init__(f\"Cannot withdraw {amount}, balance is {balance}\")\n\n def withdraw(balance, amount):\n if amount > balance:\n raise InsufficientFundsError(balance, amount)\n return balance - amount\n\n try:\n withdraw(50, 100)\n except InsufficientFundsError as e:\n return str(e), e.balance, e.amount","input":"custom_exception_demo()","language":"Python","predicted_output":"('Cannot withdraw 100, balance is 50', 50, 100)"} |
| {"id":"cmsms65yl001edmp2hgo5ornw","kind":"contributor_item","title":"Submission O5ORNW","provisional":false,"code":"def custom_sort(records):\n return sorted(records, key=lambda r: (-r[1], r[0]))","input":"custom_sort([(\"apple\", 3), (\"banana\", 5), (\"cherry\", 3), (\"date\", 5)])","language":"Python","predicted_output":"[('banana', 5), ('date', 5), ('apple', 3), ('cherry', 3)]"} |
| {"id":"cmsms65yl001odmp2u9t9o5sk","kind":"contributor_item","title":"Submission T9O5SK","provisional":false,"code":"def walrus_demo(nums):\n result = []\n i = 0\n while (n := nums[i] if i < len(nums) else None) is not None:\n result.append(n * 2)\n i += 1\n return result","input":"walrus_demo([1, 2, 3])","language":"Python","predicted_output":"[2, 4, 6]"} |
| {"id":"cmsms65yl001idmp2po1v4lzd","kind":"contributor_item","title":"Submission 1V4LZD","provisional":false,"code":"def apply_decorator():\n def logged(func):\n calls = []\n def wrapper(*args, **kwargs):\n result = func(*args, **kwargs)\n calls.append((args, result))\n return result\n wrapper.calls = calls\n return wrapper\n\n @logged\n def square(x):\n return x * x\n\n square(2)\n square(3)\n square(4)\n return square.calls","input":"apply_decorator()","language":"Python","predicted_output":"[((2,), 4), ((3,), 9), ((4,), 16)]"} |
| {"id":"cmsms65yl001kdmp2w35m9my5","kind":"contributor_item","title":"Submission 5M9MY5","provisional":false,"code":"def default_arg_pitfall(value, bucket=[]):\n bucket.append(value)\n return bucket\n\ndef run_pitfall():\n a = default_arg_pitfall(1)\n b = default_arg_pitfall(2)\n return a, b","input":"run_pitfall()","language":"Python","predicted_output":"([1, 2], [1, 2])"} |
| {"id":"cmsms65ym001wdmp2pm5n7obm","kind":"contributor_item","title":"Submission 5N7OBM","provisional":false,"code":"import itertools\ndef pairwise_products(nums):\n return [a * b for a, b in itertools.combinations(nums, 2)]","input":"pairwise_products([1, 2, 3, 4])","language":"Python","predicted_output":"[2, 3, 4, 6, 8, 12]"} |
| {"id":"cmsms65ym002admp2k44z2fdq","kind":"contributor_item","title":"Submission 4Z2FDQ","provisional":false,"code":"def exception_chaining_demo():\n def parse(value):\n try:\n return int(value)\n except ValueError as e:\n raise RuntimeError(\"parse failed\") from e\n\n try:\n parse(\"abc\")\n except RuntimeError as e:\n return str(e), type(e.__cause__).__name__","input":"exception_chaining_demo()","language":"Python","predicted_output":"('parse failed', 'ValueError')"} |
| {"id":"cmsms65ym0024dmp2jsgsbo3f","kind":"contributor_item","title":"Submission GSBO3F","provisional":false,"code":"def lru_style_cache():\n from functools import lru_cache\n\n calls = []\n\n @lru_cache(maxsize=None)\n def expensive(n):\n calls.append(n)\n return n * n\n\n expensive(4)\n expensive(4)\n expensive(5)\n expensive(4)\n return calls, expensive(5)","input":"lru_style_cache()","language":"Python","predicted_output":"([4, 5], 25)"} |
| {"id":"cmsms65ym0022dmp2202rqi5h","kind":"contributor_item","title":"Submission 2RQI5H","provisional":false,"code":"def deep_update(base, updates):\n for key, value in updates.items():\n if isinstance(value, dict) and isinstance(base.get(key), dict):\n deep_update(base[key], value)\n else:\n base[key] = value\n return base","input":"deep_update({'a': 1, 'b': {'c': 2, 'd': 3}}, {'b': {'c': 20, 'e': 4}, 'f': 5})","language":"Python","predicted_output":"{'a': 1, 'b': {'c': 20, 'd': 3, 'e': 4}, 'f': 5}"} |
| {"id":"cmsms65ym0020dmp25eg7nx6x","kind":"contributor_item","title":"Submission G7NX6X","provisional":false,"code":"def slicing_tricks(lst):\n return lst[::2], lst[::-1], lst[1:-1], lst[-3:]","input":"slicing_tricks([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])","language":"Python","predicted_output":"([0, 2, 4, 6, 8], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [1, 2, 3, 4, 5, 6, 7, 8], [7, 8, 9])"} |
| {"id":"cmsms65ym001ydmp2xg18vj5g","kind":"contributor_item","title":"Submission 18VJ5G","provisional":false,"code":"class Vector:\n def __init__(self, x, y):\n self.x, self.y = x, y\n def __add__(self, other):\n return Vector(self.x + other.x, self.y + other.y)\n def __eq__(self, other):\n return self.x == other.x and self.y == other.y\n def __repr__(self):\n return f\"Vector({self.x}, {self.y})\"\n\ndef add_vectors():\n v1 = Vector(1, 2)\n v2 = Vector(3, 4)\n return v1 + v2","input":"add_vectors()","language":"Python","predicted_output":"Vector(4, 6)"} |
| {"id":"cmsms65ym0029dmp2fn3fu20h","kind":"contributor_item","title":"Submission 3FU20H","provisional":false,"code":"def sort_stability_demo(items):\n return sorted(items, key=lambda x: x[0])","input":"sort_stability_demo([(1, \"a\"), (2, \"b\"), (1, \"c\"), (2, \"d\"), (1, \"e\")])","language":"Python","predicted_output":"[(1, 'a'), (1, 'c'), (1, 'e'), (2, 'b'), (2, 'd')]"} |
| {"id":"cmsms65ym002cdmp20zjm36jy","kind":"contributor_item","title":"Submission JM36JY","provisional":false,"code":"def kwargs_and_args_demo(*args, **kwargs):\n return sum(args) + sum(kwargs.values()), sorted(kwargs.keys())","input":"kwargs_and_args_demo(1, 2, 3, x=10, y=20)","language":"Python","predicted_output":"(36, ['x', 'y'])"} |
| {"id":"cmsms65yl001gdmp272796quj","kind":"contributor_item","title":"Submission 796QUJ","provisional":false,"code":"def make_counter():\n count = 0\n def increment(step=1):\n nonlocal count\n count += step\n return count\n return increment\n\ndef run_counter():\n inc = make_counter()\n inc(3)\n inc(2)\n return inc(5)","input":"run_counter()","language":"Python","predicted_output":"10"} |
| {"id":"cmsms65yl001sdmp2givupg1f","kind":"contributor_item","title":"Submission VUPG1F","provisional":false,"code":"class Temperature:\n def __init__(self, celsius):\n self._celsius = celsius\n\n @property\n def fahrenheit(self):\n return self._celsius * 9 / 5 + 32\n\n @fahrenheit.setter\n def fahrenheit(self, value):\n self._celsius = (value - 32) * 5 / 9\n\ndef convert_round_trip():\n t = Temperature(25)\n f = t.fahrenheit\n t.fahrenheit = 100\n return round(f, 2), round(t._celsius, 2)","input":"convert_round_trip()","language":"Python","predicted_output":"(77.0, 37.78)"} |
| {"id":"cmsmt31me003ddmp2z9zdhdt7","kind":"contributor_item","title":"Submission ZDHDT7","provisional":false,"code":"def fib(n):\n a, b = 0, 1\n seq = []\n for _ in range(n):\n seq.append(a)\n a, b = b, a + b\n return seq","input":"fib(7)","language":"Python","predicted_output":"[0, 1, 1, 2, 3, 5, 8]"} |
| {"id":"cmsmt31me003bdmp2q8mw3cbt","kind":"contributor_item","title":"Submission MW3CBT","provisional":false,"code":"def word_lengths(sentence):\n return {w: len(w) for w in sentence.split()}","input":"word_lengths('the quick brown')","language":"Python","predicted_output":"{'the': 3, 'quick': 5, 'brown': 5}"} |
| {"id":"cmsmt31me0039dmp2sd0scuw6","kind":"contributor_item","title":"Submission 0SCUW6","provisional":false,"code":"def group_parity(nums):\n groups = {'even': [], 'odd': []}\n for n in nums:\n groups['even' if n % 2 == 0 else 'odd'].append(n)\n return groups","input":"group_parity([1, 2, 3, 4, 5])","language":"Python","predicted_output":"{'even': [2, 4], 'odd': [1, 3, 5]}"} |
| {"id":"cmsmt31me003fdmp2fy8adeje","kind":"contributor_item","title":"Submission 8ADEJE","provisional":false,"code":"def count_vowels(text):\n return sum(1 for c in text.lower() if c in 'aeiou')","input":"count_vowels('Encyclopedia')","language":"Python","predicted_output":"5"} |
| {"id":"cmsmt31me0037dmp2dnd6rlsg","kind":"contributor_item","title":"Submission D6RLSG","provisional":false,"code":"def safe_divs(pairs):\n out = []\n for a, b in pairs:\n try:\n out.append(round(a / b, 3))\n except ZeroDivisionError:\n out.append(None)\n return out","input":"safe_divs([(10, 4), (1, 0)])","language":"Python","predicted_output":"[2.5, None]"} |
| {"id":"cmsmt31me0038dmp2g8ln771t","kind":"contributor_item","title":"Submission LN771T","provisional":false,"code":"def flatten(nested):\n out = []\n for item in nested:\n if isinstance(item, list):\n out.extend(item)\n else:\n out.append(item)\n return out","input":"flatten([1, [2, 3], 4, [5]])","language":"Python","predicted_output":"[1, 2, 3, 4, 5]"} |
| {"id":"cmsmt31me003admp23gvj9ios","kind":"contributor_item","title":"Submission VJ9IOS","provisional":false,"code":"def unique_sorted(items):\n return sorted(set(items))","input":"unique_sorted([3, 1, 2, 3, 1, 4])","language":"Python","predicted_output":"[1, 2, 3, 4]"} |
| {"id":"cmsmt31me003edmp25clx0lg4","kind":"contributor_item","title":"Submission LX0LG4","provisional":false,"code":"def merge_dicts(a, b):\n result = dict(a)\n result.update(b)\n return result","input":"merge_dicts({'x': 1, 'y': 2}, {'y': 9, 'z': 3})","language":"Python","predicted_output":"{'x': 1, 'y': 9, 'z': 3}"} |
| {"id":"cmsmt31me003cdmp2aso8su1o","kind":"contributor_item","title":"Submission O8SU1O","provisional":false,"code":"def clamp_all(values, low, high):\n return [max(low, min(v, high)) for v in values]","input":"clamp_all([5, -3, 15], 0, 10)","language":"Python","predicted_output":"[5, 0, 10]"} |
| {"id":"cmsmt6sqa003qdmp2qhof64wq","kind":"contributor_item","title":"Submission OF64WQ","provisional":false,"code":"def rle_encode(s):\n if not s:\n return []\n out = []\n prev = s[0]\n count = 1\n for ch in s[1:]:\n if ch == prev:\n count += 1\n else:\n out.append((prev, count))\n prev = ch\n count = 1\n out.append((prev, count))\n return out","input":"rle_encode('aaabbc')","language":"Python","predicted_output":"[('a', 3), ('b', 2), ('c', 1)]"} |
| {"id":"cmsmt6sqa003hdmp2i68pnij5","kind":"contributor_item","title":"Submission 8PNIJ5","provisional":false,"code":"def first_letters(words):\n return [w[0] for w in words]","input":"first_letters(['tree', 'quiet', 'brown'])","language":"Python","predicted_output":"['t', 'q', 'b']"} |
| {"id":"cmsmt6sqa003pdmp2a9wxm3j6","kind":"contributor_item","title":"Submission WXM3J6","provisional":false,"code":"def stack_ops(commands):\n stack = []\n for op in commands:\n if op == 'pop':\n stack.pop()\n else:\n stack.append(op)\n return stack","input":"stack_ops(['a', 'b', 'pop', 'c'])","language":"Python","predicted_output":"['a', 'c']"} |
| {"id":"cmsmt6sqa003odmp21bz19ele","kind":"contributor_item","title":"Submission Z19ELE","provisional":false,"code":"def normalize(scores):\n lo, hi = min(scores), max(scores)\n span = hi - lo\n return [round((s - lo) / span, 2) for s in scores]","input":"normalize([10, 20, 30])","language":"Python","predicted_output":"[0.0, 0.5, 1.0]"} |
| {"id":"cmsmt6sqa003rdmp2tdati42s","kind":"contributor_item","title":"Submission ATI42S","provisional":false,"code":"def price_after_tax(prices, rate):\n return [round(p * (1 + rate), 2) for p in prices]","input":"price_after_tax([100, 250], 0.08)","language":"Python","predicted_output":"[108.0, 270.0]"} |
| {"id":"cmsmt6sqa003idmp2srnydpyp","kind":"contributor_item","title":"Submission NYDPYP","provisional":false,"code":"def running_max(nums):\n best = nums[0]\n out = []\n for n in nums:\n best = max(best, n)\n out.append(best)\n return out","input":"running_max([1, 3, 2, 5, 4])","language":"Python","predicted_output":"[1, 3, 3, 5, 5]"} |
| {"id":"cmsmt6sqa003jdmp2a67oiimk","kind":"contributor_item","title":"Submission 7OIIMK","provisional":false,"code":"def dedupe_keep_order(seq):\n seen = set()\n out = []\n for x in seq:\n if x not in seen:\n seen.add(x)\n out.append(x)\n return out","input":"dedupe_keep_order([3, 1, 3, 2, 1, 4])","language":"Python","predicted_output":"[3, 1, 2, 4]"} |
| {"id":"cmsmt6sqa003ldmp2fyfinuci","kind":"contributor_item","title":"Submission FINUCI","provisional":false,"code":"def invert_mapping(d):\n return {v: k for k, v in d.items()}","input":"invert_mapping({'a': 1, 'b': 2, 'c': 3})","language":"Python","predicted_output":"{1: 'a', 2: 'b', 3: 'c'}"} |
| {"id":"cmsmt6sqa003kdmp2m0ue36m9","kind":"contributor_item","title":"Submission UE36M9","provisional":false,"code":"def digit_sums(nums):\n return [sum(int(d) for d in str(abs(n))) for n in nums]","input":"digit_sums([12345, -99])","language":"Python","predicted_output":"[15, 18]"} |
| {"id":"cmsmt6sqa003sdmp2cahx7s60","kind":"contributor_item","title":"Submission HX7S60","provisional":false,"code":"def sum_by_key(records):\n totals = {}\n for r in records:\n totals[r['cat']] = totals.get(r['cat'], 0) + r['amt']\n return totals","input":"sum_by_key([{'cat': 'x', 'amt': 5}, {'cat': 'y', 'amt': 2}, {'cat': 'x', 'amt': 3}])","language":"Python","predicted_output":"{'x': 8, 'y': 2}"} |
| {"id":"cmsmt6sqa003ndmp27a8e4gov","kind":"contributor_item","title":"Submission 8E4GOV","provisional":false,"code":"def first_repeated(nums):\n seen = set()\n for n in nums:\n if n in seen:\n return n\n seen.add(n)\n return None","input":"first_repeated([2, 4, 6, 4, 8])","language":"Python","predicted_output":"4"} |
| {"id":"cmsmt6sqa003tdmp2yconun9n","kind":"contributor_item","title":"Submission ONUN9N","provisional":false,"code":"def all_balanced(strings):\n pairs = {')': '(', ']': '[', '}': '{'}\n result = []\n for s in strings:\n stack = []\n ok = True\n for ch in s:\n if ch in '([{':\n stack.append(ch)\n elif ch in pairs:\n if not stack or stack.pop() != pairs[ch]:\n ok = False\n break\n result.append(ok and not stack)\n return result","input":"all_balanced(['(a[b]{c})', '(]'])","language":"Python","predicted_output":"[True, False]"} |
| {"id":"cmsnc3d7m00636zp2q5zkdrvj","kind":"contributor_item","title":"Submission ZKDRVJ","provisional":false,"code":"def intersection_ordered(a,b):\n allowed=set(b); seen=set(); out=[]\n for x in a:\n if x in allowed and x not in seen: seen.add(x); out.append(x)\n return out","input":"intersection_ordered([3,1,2,3,4,2],[2,3,9])","language":"Python","predicted_output":"[3, 2]"} |
| {"id":"cmsnc3d7k005l6zp2v50vvnda","kind":"contributor_item","title":"Submission 0VVNDA","provisional":false,"code":"def invert_counts(items):\n d={}\n for x in items: d[x]=d.get(x,0)+1\n return sorted((v,k) for k,v in d.items())","input":"invert_counts(['b','a','b','c','a','b'])","language":"Python","predicted_output":"[(1, 'c'), (2, 'a'), (3, 'b')]"} |
| {"id":"cmsnc3d7k005m6zp23fioo3ow","kind":"contributor_item","title":"Submission IOO3OW","provisional":false,"code":"def zigzag(nums):\n return [x if i%2==0 else -x for i,x in enumerate(nums)]","input":"zigzag([4,1,-2,3])","language":"Python","predicted_output":"[4, -1, -2, -3]"} |
| {"id":"cmsnc3d7k005n6zp2csodixha","kind":"contributor_item","title":"Submission ODIXHA","provisional":false,"code":"def merge_defaults(defaults, override):\n out=defaults.copy(); out.update({k:v for k,v in override.items() if v is not None}); return out","input":"merge_defaults({'a':1,'b':2},{'b':5,'c':None,'d':9})","language":"Python","predicted_output":"{'a': 1, 'b': 5, 'd': 9}"} |
| {"id":"cmsnc3d7k005k6zp2hj2zuiq0","kind":"contributor_item","title":"Submission 2ZUIQ0","provisional":false,"code":"def compact_ranges(nums):\n if not nums: return []\n out=[]; start=prev=nums[0]\n for x in nums[1:]:\n if x==prev+1: prev=x; continue\n out.append((start,prev)); start=prev=x\n out.append((start,prev)); return out","input":"compact_ranges([1,2,3,5,8,9])","language":"Python","predicted_output":"[(1, 3), (5, 5), (8, 9)]"} |
| {"id":"cmsnc3d7k005q6zp2a3ly97qc","kind":"contributor_item","title":"Submission LY97QC","provisional":false,"code":"def transpose(rows):\n return [list(col) for col in zip(*rows)] if rows else []","input":"transpose([[1,2,3],[4,5,6]])","language":"Python","predicted_output":"[[1, 4], [2, 5], [3, 6]]"} |
| {"id":"cmsnc3d7k005r6zp2s663vi7e","kind":"contributor_item","title":"Submission 63VI7E","provisional":false,"code":"def unique_last(items):\n seen=set(); out=[]\n for x in reversed(items):\n if x not in seen: seen.add(x); out.append(x)\n return list(reversed(out))","input":"unique_last(['a','b','a','c','b'])","language":"Python","predicted_output":"['a', 'c', 'b']"} |
| {"id":"cmsnc3d7l005v6zp2bjn6zgkr","kind":"contributor_item","title":"Submission N6ZGKR","provisional":false,"code":"def rank_scores(scores):\n vals=sorted(set(scores),reverse=True)\n ranks={v:i+1 for i,v in enumerate(vals)}\n return [ranks[x] for x in scores]","input":"rank_scores([90,70,90,50,70])","language":"Python","predicted_output":"[1, 2, 1, 3, 2]"} |
| {"id":"cmsnc3d7l005t6zp2orp4mrzs","kind":"contributor_item","title":"Submission P4MRZS","provisional":false,"code":"def rotate_matrix(m):\n return [list(row) for row in zip(*m[::-1])]","input":"rotate_matrix([[1,2,3],[4,5,6]])","language":"Python","predicted_output":"[[4, 1], [5, 2], [6, 3]]"} |
| {"id":"cmsnc3d7m005z6zp2lzi01jq8","kind":"contributor_item","title":"Submission I01JQ8","provisional":false,"code":"def bucket(nums,size):\n out={}\n for x in nums:\n k=(x//size)*size\n out.setdefault(k,[]).append(x)\n return out","input":"bucket([1,9,10,11,19,20],10)","language":"Python","predicted_output":"{0: [1, 9], 10: [10, 11, 19], 20: [20]}"} |
| {"id":"cmsnc3d7m005x6zp2tg2qj3f3","kind":"contributor_item","title":"Submission 2QJ3F3","provisional":false,"code":"def diff_keys(a,b):\n keys=set(a)|set(b)\n return sorted(k for k in keys if a.get(k)!=b.get(k))","input":"diff_keys({'a':1,'b':2,'d':None},{'a':1,'b':3,'c':4})","language":"Python","predicted_output":"['b', 'c']"} |
| {"id":"cmsnc3d7k005p6zp2rfqiyxyh","kind":"contributor_item","title":"Submission QIYXYH","provisional":false,"code":"def safe_ints(values):\n out=[]\n for v in values:\n try: out.append(int(v))\n except (ValueError,TypeError): out.append(None)\n return out","input":"safe_ints(['12','-3','x',None,'04'])","language":"Python","predicted_output":"[12, -3, None, None, 4]"} |
| {"id":"cmsnc3d7k005o6zp2dejfcpub","kind":"contributor_item","title":"Submission JFCPUB","provisional":false,"code":"def window_sums(nums,k):\n if k<=0 or k>len(nums): return []\n s=sum(nums[:k]); out=[s]\n for i in range(k,len(nums)):\n s+=nums[i]-nums[i-k]; out.append(s)\n return out","input":"window_sums([2,5,-1,4,3],3)","language":"Python","predicted_output":"[6, 8, 6]"} |
| {"id":"cmsnc3d7m00616zp205npvp25","kind":"contributor_item","title":"Submission NPVP25","provisional":false,"code":"def normalize_record(r):\n return {k.strip().lower(): (v.strip() if isinstance(v,str) else v) for k,v in r.items()}","input":"normalize_record({' Name ':' Ada ','AGE':36})","language":"Python","predicted_output":"{'name': 'Ada', 'age': 36}"} |
| {"id":"cmsnc3d7k005s6zp2tb93tm85","kind":"contributor_item","title":"Submission 93TM85","provisional":false,"code":"def classify(nums):\n return {'neg':sum(x<0 for x in nums),'zero':sum(x==0 for x in nums),'pos':sum(x>0 for x in nums)}","input":"classify([-2,0,3,4,0,-1])","language":"Python","predicted_output":"{'neg': 2, 'zero': 2, 'pos': 2}"} |
| {"id":"cmsnc3d7m00626zp2niq0ghji","kind":"contributor_item","title":"Submission Q0GHJI","provisional":false,"code":"def take_until(nums,limit):\n out=[]; total=0\n for x in nums:\n if total+x>limit: break\n out.append(x); total+=x\n return out,total","input":"take_until([3,4,5,1],10)","language":"Python","predicted_output":"([3, 4], 7)"} |
| {"id":"cmsnc3d7l005w6zp27h5yuhmv","kind":"contributor_item","title":"Submission 5YUHMV","provisional":false,"code":"def flatten_once(items):\n out=[]\n for x in items:\n out.extend(x if isinstance(x,list) else [x])\n return out","input":"flatten_once([[1,2],3,[],[4,[5]]])","language":"Python","predicted_output":"[1, 2, 3, 4, [5]]"} |
| {"id":"cmsnc3d7m00606zp277m1l1vm","kind":"contributor_item","title":"Submission M1L1VM","provisional":false,"code":"def pairwise_delta(nums):\n return [b-a for a,b in zip(nums,nums[1:])]","input":"pairwise_delta([10,13,8,8,20])","language":"Python","predicted_output":"[3, -5, 0, 12]"} |
| {"id":"cmsnc3d7l005u6zp2jw9sxqku","kind":"contributor_item","title":"Submission 9SXQKU","provisional":false,"code":"def nested_get(obj,path,default=None):\n cur=obj\n for key in path:\n if not isinstance(cur,dict) or key not in cur: return default\n cur=cur[key]\n return cur","input":"(nested_get({'a':{'b':7}},['a','b']), nested_get({'a':{}},['a','x'],'missing'))","language":"Python","predicted_output":"(7, 'missing')"} |
| {"id":"cmsnc3d7m005y6zp2mc7bf5a7","kind":"contributor_item","title":"Submission 7BF5A7","provisional":false,"code":"def encode_runs(s):\n if not s:return []\n out=[]; ch=s[0]; n=1\n for c in s[1:]:\n if c==ch:n+=1\n else:out.append((ch,n));ch=c;n=1\n out.append((ch,n));return out","input":"encode_runs('aaabbccccaa')","language":"Python","predicted_output":"[('a', 3), ('b', 2), ('c', 4), ('a', 2)]"} |
| {"id":"cmso86qna00ar6zp21dgmzedj","kind":"contributor_item","title":"Submission GMZEDJ","provisional":false,"code":"def f(xs):\n return [sum(xs[:i]) for i in range(len(xs)+1)]","input":"f([2,-1,3])","language":"Python","predicted_output":"[0, 2, 1, 4]"} |
| {"id":"cmso86qna00au6zp20n1dn9eb","kind":"contributor_item","title":"Submission 1DN9EB","provisional":false,"code":"def f(s):\n return s[::2],s[1::2]","input":"f('abcdefg')","language":"Python","predicted_output":"('aceg', 'bdf')"} |
| {"id":"cmso86qna00b16zp274gz4vu3","kind":"contributor_item","title":"Submission GZ4VU3","provisional":false,"code":"def f(rows):\n return list(map(list,zip(*rows)))","input":"f([[1,2,3],[4,5,6]])","language":"Python","predicted_output":"[[1, 4], [2, 5], [3, 6]]"} |
| {"id":"cmso86qna00b46zp2vsn4gdtl","kind":"contributor_item","title":"Submission N4GDTL","provisional":false,"code":"def f(n):\n return divmod(n,60)","input":"f(367)","language":"Python","predicted_output":"(6, 7)"} |
| {"id":"cmso86qna00av6zp2dqeifczh","kind":"contributor_item","title":"Submission EIFCZH","provisional":false,"code":"def f(xs):\n return all(a<=b for a,b in zip(xs,xs[1:]))","input":"f([1,1,3,2])","language":"Python","predicted_output":"False"} |
| {"id":"cmso86qna00az6zp2lezxzmbm","kind":"contributor_item","title":"Submission ZXZMBM","provisional":false,"code":"def f(xs):\n return {x:i for i,x in enumerate(xs)}","input":"f(['a','b','a'])","language":"Python","predicted_output":"{'a': 2, 'b': 1}"} |
| {"id":"cmso86qna00b86zp2eyxxg698","kind":"contributor_item","title":"Submission XXG698","provisional":false,"code":"def f(a,b):\n return sorted(set(a)&set(b))","input":"f([1,2,3,3],[2,3,4])","language":"Python","predicted_output":"[2, 3]"} |
| {"id":"cmso86qna00b76zp2diwyb3st","kind":"contributor_item","title":"Submission WYB3ST","provisional":false,"code":"def f(xs):\n return sum(x<0 for x in xs),sum(x==0 for x in xs),sum(x>0 for x in xs)","input":"f([-2,0,3,4,0])","language":"Python","predicted_output":"(1, 2, 2)"} |
| {"id":"cmso86qna00ay6zp2l56j8bab","kind":"contributor_item","title":"Submission 6J8BAB","provisional":false,"code":"def f(x):\n try:return 100//x\n except ZeroDivisionError:return None","input":"(f(4),f(0))","language":"Python","predicted_output":"(25, None)"} |
| {"id":"cmso86qna00b06zp2zd2n1ugx","kind":"contributor_item","title":"Submission 2N1UGX","provisional":false,"code":"def f(n):\n return [i for i in range(n) if all(i%d for d in range(2,int(i**.5)+1)) and i>1]","input":"f(12)","language":"Python","predicted_output":"[2, 3, 5, 7, 11]"} |
| {"id":"cmso86qna00ba6zp25nlwkblx","kind":"contributor_item","title":"Submission LWKBLX","provisional":false,"code":"def f(d):\n return sum(v for k,v in d.items() if k.startswith('x'))","input":"f({'x1':3,'y':8,'x2':4})","language":"Python","predicted_output":"7"} |
| {"id":"cmso86qna00b56zp2fjgg13to","kind":"contributor_item","title":"Submission GG13TO","provisional":false,"code":"def f(xs):\n return min(xs,key=lambda x:(abs(x),x))","input":"f([-3,2,-2,5])","language":"Python","predicted_output":"-2"} |
| {"id":"cmso86qna00b36zp2amh9wsg9","kind":"contributor_item","title":"Submission H9WSG9","provisional":false,"code":"def f(xs):\n return [x for x in xs if xs.count(x)==1]","input":"f([1,2,1,3,4,3])","language":"Python","predicted_output":"[2, 4]"} |
| {"id":"cmso86qn900an6zp22woinimi","kind":"contributor_item","title":"Submission OINIMI","provisional":false,"code":"def f(n):\n return sum(i for i in range(n+1) if i%3==0)","input":"f(10)","language":"Python","predicted_output":"18"} |
| {"id":"cmso86qna00aw6zp2r24f0blp","kind":"contributor_item","title":"Submission 4F0BLP","provisional":false,"code":"def f(xs):\n return sorted(set(xs), reverse=True)[1]","input":"f([4,1,4,3,2])","language":"Python","predicted_output":"3"} |
| {"id":"cmso86qna00b66zp2fsd9xno7","kind":"contributor_item","title":"Submission D9XNO7","provisional":false,"code":"def f(s):\n return [p for p in s.split(',') if p]","input":"f('a,,b,c,')","language":"Python","predicted_output":"['a', 'b', 'c']"} |
| {"id":"cmso86qn900ap6zp2pgftznkt","kind":"contributor_item","title":"Submission FTZNKT","provisional":false,"code":"def f(xs):\n return list(zip(xs,xs[1:]))","input":"f([4,7,9])","language":"Python","predicted_output":"[(4, 7), (7, 9)]"} |
| {"id":"cmso86qn900al6zp2ieg6wc71","kind":"contributor_item","title":"Submission G6WC71","provisional":false,"code":"def f(s):\n return {c:s.count(c) for c in sorted(set(s))}","input":"f('banana')","language":"Python","predicted_output":"{'a': 3, 'b': 1, 'n': 2}"} |
| {"id":"cmso86qn900ak6zp2ou1ubwfs","kind":"contributor_item","title":"Submission 1UBWFS","provisional":false,"code":"def f(xs):\n return [x*x for x in xs if x%2]","input":"f([1,2,3,4,5])","language":"Python","predicted_output":"[1, 9, 25]"} |
| {"id":"cmso86qna00bb6zp2czvyle8c","kind":"contributor_item","title":"Submission VYLE8C","provisional":false,"code":"def f(s):\n return s == s[::-1]","input":"(f('level'),f('levels'))","language":"Python","predicted_output":"(True, False)"} |
| {"id":"cmso86qna00b96zp2ri7k951l","kind":"contributor_item","title":"Submission 7K951L","provisional":false,"code":"def f(xs,k):\n return [xs[i:i+k] for i in range(0,len(xs),k)]","input":"f([1,2,3,4,5],2)","language":"Python","predicted_output":"[[1, 2], [3, 4], [5]]"} |
| {"id":"cmso86qna00bc6zp2s6gkvemp","kind":"contributor_item","title":"Submission GKVEMP","provisional":false,"code":"def f(xs):\n return [b-a for a,b in zip(xs,xs[1:])]","input":"f([3,8,6,10])","language":"Python","predicted_output":"[5, -2, 4]"} |
| {"id":"cmso86qna00ax6zp2tv6a5vwz","kind":"contributor_item","title":"Submission 6A5VWZ","provisional":false,"code":"def f(s):\n from collections import Counter\n return Counter(s).most_common(2)","input":"f('mississippi')","language":"Python","predicted_output":"[('i', 4), ('s', 4)]"} |
| {"id":"cmso86qn900am6zp2o1017uh4","kind":"contributor_item","title":"Submission 017UH4","provisional":false,"code":"def f(xs):\n a=0\n for i,x in enumerate(xs): a+=i*x\n return a","input":"f([3,4,5])","language":"Python","predicted_output":"14"} |
| {"id":"cmso86qna00as6zp27fkmefbi","kind":"contributor_item","title":"Submission KMEFBI","provisional":false,"code":"def f(n):\n a,b=0,1\n for _ in range(n): a,b=b,a+b\n return a","input":"f(8)","language":"Python","predicted_output":"21"} |
| {"id":"cmso86qn900ao6zp2ao3ifi6i","kind":"contributor_item","title":"Submission 3IFI6I","provisional":false,"code":"def f(d):\n return sorted(d.items(), key=lambda p:(-p[1],p[0]))","input":"f({'b':2,'a':2,'c':1})","language":"Python","predicted_output":"[('a', 2), ('b', 2), ('c', 1)]"} |
| {"id":"cmso86qna00at6zp2epzu6444","kind":"contributor_item","title":"Submission ZU6444","provisional":false,"code":"def f(xs):\n return max(enumerate(xs),key=lambda p:p[1])","input":"f([5,9,9,2])","language":"Python","predicted_output":"(1, 9)"} |
| {"id":"cmsoiw6wv0002ctp2qii51bdk","kind":"contributor_item","title":"Submission I51BDK","provisional":false,"code":"def word_freq(text):\n freq = {}\n for w in text.split():\n freq[w] = freq.get(w, 0) + 1\n return sorted(freq.items())","input":"word_freq('a b a c b a')","language":"Python","predicted_output":"[('a', 3), ('b', 2), ('c', 1)]"} |
| {"id":"cmsoiw6wv0004ctp2137s2ov4","kind":"contributor_item","title":"Submission 7S2OV4","provisional":false,"code":"def merge_intervals(intervals):\n intervals = sorted(intervals)\n merged = []\n for start, end in intervals:\n if merged and start <= merged[-1][1]:\n merged[-1] = (merged[-1][0], max(merged[-1][1], end))\n else:\n merged.append((start, end))\n return merged","input":"merge_intervals([(1,3),(2,6),(8,10),(15,18)])","language":"Python","predicted_output":"[(1, 6), (8, 10), (15, 18)]"} |
| {"id":"cmsoiw6ww000cctp22nmb1dqv","kind":"contributor_item","title":"Submission MB1DQV","provisional":false,"code":"def matrix_transpose(m):\n return [list(row) for row in zip(*m)]","input":"matrix_transpose([[1,2,3],[4,5,6]])","language":"Python","predicted_output":"[[1, 4], [2, 5], [3, 6]]"} |
| {"id":"cmsoiw6wv0009ctp2ipjsuyvx","kind":"contributor_item","title":"Submission JSUYVX","provisional":false,"code":"def is_balanced(s):\n stack = []\n pairs = {')':'(', ']':'[', '}':'{'}\n for ch in s:\n if ch in '([{':\n stack.append(ch)\n elif ch in ')]}':\n if not stack or stack.pop() != pairs[ch]:\n return False\n return not stack","input":"is_balanced('([{}])')","language":"Python","predicted_output":"True"} |
| {"id":"cmsoiw6ww000actp2ew30hct5","kind":"contributor_item","title":"Submission 30HCT5","provisional":false,"code":"def gen_squares(n):\n def sq():\n for i in range(n):\n yield i * i\n return list(sq())","input":"gen_squares(6)","language":"Python","predicted_output":"[0, 1, 4, 9, 16, 25]"} |
| {"id":"cmsoiw6ww000fctp2s7vmficn","kind":"contributor_item","title":"Submission VMFICN","provisional":false,"code":"def slice_tricks(s):\n return (s[::-1], s[1:-1], s[::2])","input":"slice_tricks('abcdefgh')","language":"Python","predicted_output":"('hgfedcba', 'bcdefg', 'aceg')"} |
| {"id":"cmsoiw6ww000dctp286q9j66z","kind":"contributor_item","title":"Submission Q9J66Z","provisional":false,"code":"def binary_search(arr, target):\n lo, hi = 0, len(arr) - 1\n while lo <= hi:\n mid = (lo + hi) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n lo = mid + 1\n else:\n hi = mid - 1\n return -1","input":"binary_search([1,3,5,7,9,11], 7)","language":"Python","predicted_output":"3"} |
| {"id":"cmsoiw6ww000ectp21o6izba3","kind":"contributor_item","title":"Submission 6IZBA3","provisional":false,"code":"def default_dict_demo():\n from collections import defaultdict\n d = defaultdict(list)\n for k, v in [('a',1),('b',2),('a',3)]:\n d[k].append(v)\n return dict(d)","input":"default_dict_demo()","language":"Python","predicted_output":"{'a': [1, 3], 'b': [2]}"} |
| {"id":"cmsoiw6ww000gctp2bmubxfi2","kind":"contributor_item","title":"Submission UBXFI2","provisional":false,"code":"def sum_with_default_arg(lst, acc=None):\n if acc is None:\n acc = []\n acc.append(sum(lst))\n return acc","input":"sum_with_default_arg([1,2,3])","language":"Python","predicted_output":"[6]"} |
| {"id":"cmsoiw6ww000hctp291s78r9t","kind":"contributor_item","title":"Submission S78R9T","provisional":false,"code":"def zip_longest_demo():\n from itertools import zip_longest\n return list(zip_longest([1,2,3], ['a','b'], fillvalue='X'))","input":"zip_longest_demo()","language":"Python","predicted_output":"[(1, 'a'), (2, 'b'), (3, 'X')]"} |
| {"id":"cmsoiw6ww000ictp2yf6ejk23","kind":"contributor_item","title":"Submission 6EJK23","provisional":false,"code":"def recursive_factorial(n):\n if n <= 1:\n return 1\n return n * recursive_factorial(n - 1)","input":"recursive_factorial(6)","language":"Python","predicted_output":"720"} |
| {"id":"cmsoiw6ww000jctp29v8o8zs4","kind":"contributor_item","title":"Submission 8O8ZS4","provisional":false,"code":"def set_ops(a, b):\n sa, sb = set(a), set(b)\n return (sorted(sa & sb), sorted(sa | sb), sorted(sa - sb))","input":"set_ops([1,2,3,4], [3,4,5,6])","language":"Python","predicted_output":"([3, 4], [1, 2, 3, 4, 5, 6], [1, 2])"} |
| {"id":"cmsoiw6ww000mctp2lcd1lk4l","kind":"contributor_item","title":"Submission D1LK4L","provisional":false,"code":"def list_comp_nested():\n return [[i*j for j in range(3)] for i in range(3)]","input":"list_comp_nested()","language":"Python","predicted_output":"[[0, 0, 0], [0, 1, 2], [0, 2, 4]]"} |
| {"id":"cmsoiw6ww000octp2dhb2q6zr","kind":"contributor_item","title":"Submission B2Q6ZR","provisional":false,"code":"def tuple_unpack_star(items):\n first, *middle, last = items\n return (first, middle, last)","input":"tuple_unpack_star([1,2,3,4,5])","language":"Python","predicted_output":"(1, [2, 3, 4], 5)"} |
| {"id":"cmsoiw6ww000pctp2wuql4cqi","kind":"contributor_item","title":"Submission QL4CQI","provisional":false,"code":"def while_else_demo(n):\n i = 2\n while i < n:\n if n % i == 0:\n return False\n i += 1\n else:\n return True","input":"while_else_demo(17)","language":"Python","predicted_output":"True"} |
| {"id":"cmsoiw6ww000qctp2kqonlklt","kind":"contributor_item","title":"Submission ONLKLT","provisional":false,"code":"def sorted_with_key(items):\n return sorted(items, key=lambda x: (-x[1], x[0]))","input":"sorted_with_key([('a',2),('b',3),('c',2)])","language":"Python","predicted_output":"[('b', 3), ('a', 2), ('c', 2)]"} |
| {"id":"cmsoiw6ww000rctp2yfttzt5s","kind":"contributor_item","title":"Submission TTZT5S","provisional":false,"code":"def nested_dict_update():\n d = {'a': {'x': 1}, 'b': {'y': 2}}\n d['a']['z'] = 99\n d.setdefault('c', {})['w'] = 5\n return d","input":"nested_dict_update()","language":"Python","predicted_output":"{'a': {'x': 1, 'z': 99}, 'b': {'y': 2}, 'c': {'w': 5}}"} |
| {"id":"cmsoiw6ww000sctp23xzfrw36","kind":"contributor_item","title":"Submission ZFRW36","provisional":false,"code":"def chained_comparison(a, b, c):\n return a < b < c","input":"chained_comparison(1, 5, 10)","language":"Python","predicted_output":"True"} |
| {"id":"cmsoiw6ww000tctp23q7zs99g","kind":"contributor_item","title":"Submission 7ZS99G","provisional":false,"code":"def bytes_ops():\n b = bytes([104, 101, 108, 108, 111])\n return (b, b.decode(), len(b))","input":"bytes_ops()","language":"Python","predicted_output":"(b'hello', 'hello', 5)"} |
| {"id":"cmsoiw6wv0003ctp2zexklme7","kind":"contributor_item","title":"Submission XKLME7","provisional":false,"code":"class Stack:\n def __init__(self):\n self.data = []\n def push(self, x):\n self.data.append(x)\n def pop(self):\n return self.data.pop()\n def peek(self):\n return self.data[-1]\n\ndef stack_ops():\n s = Stack()\n s.push(1)\n s.push(2)\n s.push(3)\n s.pop()\n s.push(5)\n return (s.peek(), len(s.data))","input":"stack_ops()","language":"Python","predicted_output":"(5, 3)"} |
| {"id":"cmsoiw6wv0008ctp2a4c6cx15","kind":"contributor_item","title":"Submission C6CX15","provisional":false,"code":"def rotate_list(lst, k):\n if not lst:\n return lst\n k = k % len(lst)\n return lst[-k:] + lst[:-k]","input":"rotate_list([1,2,3,4,5], 2)","language":"Python","predicted_output":"[4, 5, 1, 2, 3]"} |
| {"id":"cmsoiw6ww000bctp2xn6m0ifa","kind":"contributor_item","title":"Submission 6M0IFA","provisional":false,"code":"def try_finally_demo():\n log = []\n try:\n log.append('try')\n raise ValueError('boom')\n except ValueError as e:\n log.append(f'except:{e}')\n finally:\n log.append('finally')\n return log","input":"try_finally_demo()","language":"Python","predicted_output":"['try', 'except:boom', 'finally']"} |
| {"id":"cmsoiw6ww000lctp2yyz7kppt","kind":"contributor_item","title":"Submission Z7KPPT","provisional":false,"code":"def enumerate_demo(items):\n return [f'{i}:{v}' for i, v in enumerate(items, start=1)]","input":"enumerate_demo(['x','y','z'])","language":"Python","predicted_output":"['1:x', '2:y', '3:z']"} |
| {"id":"cmsoiw6wv0006ctp21ozcdeu6","kind":"contributor_item","title":"Submission ZCDEU6","provisional":false,"code":"def flatten(nested):\n result = []\n for item in nested:\n if isinstance(item, list):\n result.extend(flatten(item))\n else:\n result.append(item)\n return result","input":"flatten([1, [2, 3, [4, 5]], 6, [7]])","language":"Python","predicted_output":"[1, 2, 3, 4, 5, 6, 7]"} |
| {"id":"cmsoiw6wv0007ctp2yoqjb9a9","kind":"contributor_item","title":"Submission QJB9A9","provisional":false,"code":"def char_count_map(s):\n from collections import Counter\n c = Counter(s)\n return dict(sorted(c.items()))","input":"char_count_map('mississippi')","language":"Python","predicted_output":"{'i': 4, 'm': 1, 'p': 2, 's': 4}"} |
| {"id":"cmspwitjl000g7vp2wwlc5kvb","kind":"contributor_item","title":"Submission LC5KVB","provisional":false,"code":"class ValidationError(Exception):\n pass\n\ndef validate_age(age):\n try:\n if age < 0:\n raise ValidationError(\"negative age\")\n return age * 2\n except ValidationError as e:\n return f\"error: {e}\"","input":"(validate_age(5), validate_age(-3))","language":"Python","predicted_output":"(10, 'error: negative age')"} |
| {"id":"cmspwitjl000h7vp2g6rrkp6v","kind":"contributor_item","title":"Submission RRKP6V","provisional":false,"code":"def compare_sets(a, b):\n return {\n \"union\": sorted(a | b),\n \"intersection\": sorted(a & b),\n \"difference\": sorted(a - b)\n }","input":"compare_sets({1, 2, 3, 4}, {3, 4, 5})","language":"Python","predicted_output":"{'union': [1, 2, 3, 4, 5], 'intersection': [3, 4], 'difference': [1, 2]}"} |
| {"id":"cmspwitjl000f7vp2s4nxh626","kind":"contributor_item","title":"Submission NXH626","provisional":false,"code":"def fib_seq(n):\n cache = {0: 0, 1: 1}\n for i in range(2, n + 1):\n cache[i] = cache[i - 1] + cache[i - 2]\n return [cache[i] for i in range(n + 1)]","input":"fib_seq(7)","language":"Python","predicted_output":"[0, 1, 1, 2, 3, 5, 8, 13]"} |
| {"id":"cmspwitjl000l7vp22s6oyzqf","kind":"contributor_item","title":"Submission 6OYZQF","provisional":false,"code":"def safe_factorial(n):\n if n < 0:\n raise ValueError(\"n must be non-negative\")\n if n == 0:\n return 1\n return n * safe_factorial(n - 1)\n\ndef try_factorial(n):\n try:\n return safe_factorial(n)\n except ValueError as e:\n return str(e)","input":"(try_factorial(5), try_factorial(-2))","language":"Python","predicted_output":"(120, 'n must be non-negative')"} |
| {"id":"cmspwitjl000j7vp23qk98jyo","kind":"contributor_item","title":"Submission K98JYO","provisional":false,"code":"def top_scores(records, n):\n return sorted(records, key=lambda r: (-r[1], r[0]))[:n]","input":"top_scores([(\"alice\", 90), (\"bob\", 95), (\"carol\", 90), (\"dave\", 95)], 3)","language":"Python","predicted_output":"[('bob', 95), ('dave', 95), ('alice', 90)]"} |
| {"id":"cmspwitjl000n7vp224dpj4xk","kind":"contributor_item","title":"Submission DPJ4XK","provisional":false,"code":"def divide_safe(a, b):\n try:\n result = a / b\n except ZeroDivisionError:\n return \"cannot divide by zero\"\n except TypeError:\n return \"invalid types\"\n else:\n return round(result, 2)","input":"(divide_safe(10, 4), divide_safe(5, 0), divide_safe(5, \"x\"))","language":"Python","predicted_output":"(2.5, 'cannot divide by zero', 'invalid types')"} |
| {"id":"cmspwitjl000k7vp2odtofi47","kind":"contributor_item","title":"Submission TOFI47","provisional":false,"code":"def even_squares(nums):\n for n in nums:\n if n % 2 == 0:\n yield n * n\n\ndef sum_even_squares(nums):\n return sum(even_squares(nums))","input":"sum_even_squares([1, 2, 3, 4, 5, 6])","language":"Python","predicted_output":"56"} |
| {"id":"cmspwitjl000m7vp2rr3l0mcu","kind":"contributor_item","title":"Submission 3L0MCU","provisional":false,"code":"def index_map(items):\n return {item: idx for idx, item in enumerate(items) if len(item) > 2}","input":"index_map([\"a\", \"cat\", \"dog\", \"it\", \"fish\"])","language":"Python","predicted_output":"{'cat': 1, 'dog': 2, 'fish': 4}"} |
| {"id":"cmspwitjm000o7vp23dxlwsjg","kind":"contributor_item","title":"Submission XLWSJG","provisional":false,"code":"def group_by_parity(nums):\n groups = {\"even\": [], \"odd\": []}\n for n in nums:\n key = \"even\" if n % 2 == 0 else \"odd\"\n groups[key].append(n)\n return groups","input":"group_by_parity([5, 8, 3, 12, 7, 2])","language":"Python","predicted_output":"{'even': [8, 12, 2], 'odd': [5, 3, 7]}"} |
| {"id":"cmsrbjijt0029e0p2pggsig1c","kind":"contributor_item","title":"Submission GSIG1C","provisional":false,"code":"def chunk_list(lst, size):\n return [lst[i:i + size] for i in range(0, len(lst), size)]","input":"chunk_list([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 3)","language":"Python","predicted_output":"[[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]]"} |
| {"id":"cmsrbjijt002ae0p2hlzm00gj","kind":"contributor_item","title":"Submission ZM00GJ","provisional":false,"code":"def are_anagrams(s1, s2):\n return sorted(s1.lower().replace(' ', '')) == sorted(s2.lower().replace(' ', ''))","input":"(are_anagrams(\"listen\", \"silent\"), are_anagrams(\"hello\", \"world\"))","language":"Python","predicted_output":"(True, False)"} |
| {"id":"cmsrbjijt002be0p24nrygwj9","kind":"contributor_item","title":"Submission RYGWJ9","provisional":false,"code":"def prime_factors(n):\n factors = []\n d = 2\n while d * d <= n:\n while n % d == 0:\n factors.append(d)\n n //= d\n d += 1\n if n > 1:\n factors.append(n)\n return factors","input":"prime_factors(360)","language":"Python","predicted_output":"[2, 2, 2, 3, 3, 5]"} |
| {"id":"cmsrbjijs001ze0p2jrqfx2y6","kind":"contributor_item","title":"Submission QFX2Y6","provisional":false,"code":"def fib(n, memo=None):\n if memo is None:\n memo = {}\n if n <= 1:\n return n\n if n not in memo:\n memo[n] = fib(n - 1, memo) + fib(n - 2, memo)\n return memo[n]","input":"fib(10)","language":"Python","predicted_output":"55"} |
| {"id":"cmsrbjijs0021e0p22mfpiqi0","kind":"contributor_item","title":"Submission FPIQI0","provisional":false,"code":"def transpose(matrix):\n return [list(row) for row in zip(*matrix)]","input":"transpose([[1, 2, 3], [4, 5, 6], [7, 8, 9]])","language":"Python","predicted_output":"[[1, 4, 7], [2, 5, 8], [3, 6, 9]]"} |
| {"id":"cmsrbjijs0023e0p2chvd1n9r","kind":"contributor_item","title":"Submission VD1N9R","provisional":false,"code":"def flatten(lst):\n result = []\n for item in lst:\n if isinstance(item, list):\n result.extend(flatten(item))\n else:\n result.append(item)\n return result","input":"flatten([1, [2, [3, [4, 5]], 6], 7, [8, 9]])","language":"Python","predicted_output":"[1, 2, 3, 4, 5, 6, 7, 8, 9]"} |
| {"id":"cmsrbjijt0027e0p2xg3dj7hf","kind":"contributor_item","title":"Submission 3DJ7HF","provisional":false,"code":"def rotate_list(lst, k):\n if not lst:\n return lst\n n = len(lst)\n k = k % n\n return lst[-k:] + lst[:-k] if k else list(lst)","input":"rotate_list([1, 2, 3, 4, 5, 6, 7], 3)","language":"Python","predicted_output":"[5, 6, 7, 1, 2, 3, 4]"} |
| {"id":"cmsrbjijt002de0p20ts6p8zm","kind":"contributor_item","title":"Submission S6P8ZM","provisional":false,"code":"def zip_with_fill(list1, list2, fill=None):\n length = max(len(list1), len(list2))\n result = []\n for i in range(length):\n a = list1[i] if i < len(list1) else fill\n b = list2[i] if i < len(list2) else fill\n result.append((a, b))\n return result","input":"zip_with_fill([1, 2, 3, 4], ['a', 'b'], fill=0)","language":"Python","predicted_output":"[(1, 'a'), (2, 'b'), (3, 0), (4, 0)]"} |
| {"id":"cmsrbjijt002ee0p2f5yni7f2","kind":"contributor_item","title":"Submission YNI7F2","provisional":false,"code":"def cumsum_until(values, threshold):\n total = 0\n result = []\n for v in values:\n total += v\n result.append(total)\n if total >= threshold:\n break\n return result","input":"cumsum_until([5, 3, 8, 2, 7, 4], 20)","language":"Python","predicted_output":"[5, 8, 16, 18, 25]"} |
| {"id":"cmsrbjijs0024e0p21q7b2w9t","kind":"contributor_item","title":"Submission 7B2W9T","provisional":false,"code":"def running_max(values):\n result = []\n current = float('-inf')\n for v in values:\n current = max(current, v)\n result.append(current)\n return result","input":"running_max([3, 1, 4, 1, 5, 9, 2, 6, 5])","language":"Python","predicted_output":"[3, 3, 4, 4, 5, 9, 9, 9, 9]"} |
| {"id":"cmsrbjijs0026e0p2jjnv7qve","kind":"contributor_item","title":"Submission NV7QVE","provisional":false,"code":"def count_vowels_consonants(s):\n vowels = set('aeiouAEIOU')\n v_count = sum(1 for c in s if c in vowels)\n c_count = sum(1 for c in s if c.isalpha() and c not in vowels)\n return {'vowels': v_count, 'consonants': c_count}","input":"count_vowels_consonants(\"Hello World\")","language":"Python","predicted_output":"{'vowels': 3, 'consonants': 7}"} |
| {"id":"cmsrbjijs0025e0p2xy76025p","kind":"contributor_item","title":"Submission 76025P","provisional":false,"code":"def deep_merge(base, override):\n result = dict(base)\n for k, v in override.items():\n if k in result and isinstance(result[k], dict) and isinstance(v, dict):\n result[k] = deep_merge(result[k], v)\n else:\n result[k] = v\n return result","input":"deep_merge({'a': {'x': 1, 'y': 2}, 'b': 3}, {'a': {'y': 99, 'z': 0}, 'c': 4})","language":"Python","predicted_output":"{'a': {'x': 1, 'y': 99, 'z': 0}, 'b': 3, 'c': 4}"} |
| {"id":"cmsrbjijs0022e0p2w1lkfihx","kind":"contributor_item","title":"Submission LKFIHX","provisional":false,"code":"def word_frequency(text):\n words = text.lower().split()\n freq = {}\n for word in words:\n freq[word] = freq.get(word, 0) + 1\n return dict(sorted(freq.items()))","input":"word_frequency(\"to be or not to be that is the question\")","language":"Python","predicted_output":"{'be': 2, 'is': 1, 'not': 1, 'or': 1, 'question': 1, 'that': 1, 'the': 1, 'to': 2}"} |
| {"id":"cmsrbjijs0020e0p21tx642mr","kind":"contributor_item","title":"Submission X642MR","provisional":false,"code":"def binary_search(arr, target):\n lo, hi = 0, len(arr) - 1\n while lo <= hi:\n mid = (lo + hi) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n lo = mid + 1\n else:\n hi = mid - 1\n return -1","input":"binary_search([2, 5, 8, 12, 16, 23, 38, 56, 72, 91], 23)","language":"Python","predicted_output":"5"} |
| {"id":"cmsrbjijt0028e0p23f6xd9b6","kind":"contributor_item","title":"Submission 6XD9B6","provisional":false,"code":"def rle_encode(s):\n if not s:\n return []\n result = []\n count = 1\n for i in range(1, len(s)):\n if s[i] == s[i - 1]:\n count += 1\n else:\n result.append((s[i - 1], count))\n count = 1\n result.append((s[-1], count))\n return result","input":"rle_encode(\"aaabbccddddee\")","language":"Python","predicted_output":"[('a', 3), ('b', 2), ('c', 2), ('d', 4), ('e', 2)]"} |
| {"id":"cmsrbjijt002ce0p2gajtgfln","kind":"contributor_item","title":"Submission JTGFLN","provisional":false,"code":"from collections import OrderedDict\n\nclass LRUCache:\n def __init__(self, capacity):\n self.capacity = capacity\n self.cache = OrderedDict()\n\n def get(self, key):\n if key not in self.cache:\n return -1\n self.cache.move_to_end(key)\n return self.cache[key]\n\n def put(self, key, value):\n if key in self.cache:\n self.cache.move_to_end(key)\n self.cache[key] = value\n if len(self.cache) > self.capacity:\n self.cache.popitem(last=False)\n\ndef simulate_lru(ops):\n cache = LRUCache(3)\n results = []\n for op, *args in ops:\n if op == 'put':\n cache.put(args[0], args[1])\n elif op == 'get':\n results.append(cache.get(args[0]))\n return results","input":"simulate_lru([('put', 1, 'a'), ('put', 2, 'b'), ('put', 3, 'c'), ('get', 1), ('put', 4, 'd'), ('get', 2), ('get', 1), ('get', 4)])","language":"Python","predicted_output":"['a', -1, 'a', 'd']"} |
| {"id":"cmsrbjijt002ge0p2bo2wdgr5","kind":"contributor_item","title":"Submission 2WDGR5","provisional":false,"code":"def merge_sorted(arr1, arr2):\n result = []\n i = j = 0\n while i < len(arr1) and j < len(arr2):\n if arr1[i] <= arr2[j]:\n result.append(arr1[i])\n i += 1\n else:\n result.append(arr2[j])\n j += 1\n result.extend(arr1[i:])\n result.extend(arr2[j:])\n return result","input":"merge_sorted([1, 4, 6, 8, 10], [2, 3, 5, 7, 9, 11])","language":"Python","predicted_output":"[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]"} |
| {"id":"cmsrbjijt002he0p22hij72ds","kind":"contributor_item","title":"Submission IJ72DS","provisional":false,"code":"def group_by(items, key_fn):\n groups = {}\n for item in items:\n k = key_fn(item)\n groups.setdefault(k, []).append(item)\n return groups","input":"group_by([1, 2, 3, 4, 5, 6, 7, 8, 9], lambda x: 'even' if x % 2 == 0 else 'odd')","language":"Python","predicted_output":"{'odd': [1, 3, 5, 7, 9], 'even': [2, 4, 6, 8]}"} |
| {"id":"cmsrbjijt002ie0p2ploixy71","kind":"contributor_item","title":"Submission OIXY71","provisional":false,"code":"def is_balanced(s):\n stack = []\n pairs = {')': '(', ']': '[', '}': '{'}\n for char in s:\n if char in '([{':\n stack.append(char)\n elif char in ')]}' :\n if not stack or stack[-1] != pairs[char]:\n return False\n stack.pop()\n return len(stack) == 0","input":"(is_balanced(\"({[a+b]*c}-d)\"), is_balanced(\"([)]\"), is_balanced(\"(()\"))","language":"Python","predicted_output":"(True, False, False)"} |
| {"id":"cmsrfjbt40026y8p2r6rccn9w","kind":"contributor_item","title":"Submission RCCN9W","provisional":false,"code":"def parity_fold(nums):\n acc=0\n out=[]\n for i,x in enumerate(nums):\n acc = acc + x if i % 2 == 0 else acc - x\n out.append(acc)\n return out\n","input":"parity_fold([5,2,7,3])","language":"Python","predicted_output":"[5, 3, 10, 7]"} |
| {"id":"cmsrfjbt40024y8p20wzabymf","kind":"contributor_item","title":"Submission ZABYMF","provisional":false,"code":"def rotate_map(pairs, k):\n d=dict(pairs)\n keys=sorted(d)\n return [(key, d[key] + i*k) for i, key in enumerate(keys)]\n","input":"rotate_map([('b',2),('a',5),('c',1)],3)","language":"Python","predicted_output":"[('a', 5), ('b', 5), ('c', 7)]"} |
| {"id":"cmsrfjbt40023y8p2zp9ryms4","kind":"contributor_item","title":"Submission 9RYMS4","provisional":false,"code":"def segment_sums(values):\n out=[]\n cur=0\n for x in values:\n if x is None:\n out.append(cur)\n cur=0\n else:\n cur += x\n out.append(cur)\n return out\n","input":"segment_sums([2,3,None,-1,4,None,7])","language":"Python","predicted_output":"[5, 3, 7]"} |
| {"id":"cmsrfjbt40025y8p2xkup6vgq","kind":"contributor_item","title":"Submission UP6VGQ","provisional":false,"code":"from collections import deque\n\ndef bounded_queue(values, limit):\n q=deque()\n dropped=[]\n for x in values:\n q.append(x)\n if len(q)>limit:\n dropped.append(q.popleft())\n return list(q), dropped\n","input":"bounded_queue([4,1,9,2,8],3)","language":"Python","predicted_output":"([9, 2, 8], [4, 1])"} |
| {"id":"cmsrfjbt40027y8p2r6jeyxf8","kind":"contributor_item","title":"Submission JEYXF8","provisional":false,"code":"def lookup_chain(mapping, keys):\n cur=mapping\n for k in keys:\n try:\n cur=cur[k]\n except (KeyError, TypeError, IndexError):\n return 'missing'\n return cur\n","input":"lookup_chain({'a':{'b':[10,20]}}, ['a','b',1])","language":"Python","predicted_output":"20"} |
| {"id":"cmsrg4wsu003yy8p28085utng","kind":"contributor_item","title":"Submission 85UTNG","provisional":false,"code":"def count_chars(s):\n from collections import Counter\n return dict(Counter(s))","input":"count_chars('banana')","language":"Python","predicted_output":"{'b': 1, 'a': 3, 'n': 2}"} |
| {"id":"cmsrg4wsu003zy8p2018cqu42","kind":"contributor_item","title":"Submission 8CQU42","provisional":false,"code":"class Stack:\n def __init__(self):\n self.items = []\n def push(self, x):\n self.items.append(x)\n def pop(self):\n return self.items.pop()\n\ndef stack_demo():\n s = Stack()\n s.push(1)\n s.push(2)\n s.push(3)\n a = s.pop()\n b = s.pop()\n return (a, b, s.items)","input":"stack_demo()","language":"Python","predicted_output":"(3, 2, [1])"} |
| {"id":"cmsrg4wst003xy8p2yo6ua2wo","kind":"contributor_item","title":"Submission 6UA2WO","provisional":false,"code":"def safe_divide(a, b):\n try:\n return a / b\n except ZeroDivisionError:\n return None","input":"(safe_divide(10, 2), safe_divide(5, 0))","language":"Python","predicted_output":"(5.0, None)"} |
| {"id":"cmsrg4wsu0040y8p2c7nvrbmr","kind":"contributor_item","title":"Submission NVRBMR","provisional":false,"code":"def fib_gen(n):\n a, b = 0, 1\n result = []\n for _ in range(n):\n result.append(a)\n a, b = b, a+b\n return result","input":"fib_gen(7)","language":"Python","predicted_output":"[0, 1, 1, 2, 3, 5, 8]"} |
| {"id":"cmsrg5dm70041y8p2gh9pyzno","kind":"contributor_item","title":"Submission 9PYZNO","provisional":false,"code":"def merge_dicts(d1, d2):\n merged = d1.copy()\n merged.update(d2)\n return merged","input":"merge_dicts({'a': 1, 'b': 2}, {'b': 3, 'c': 4})","language":"Python","predicted_output":"{'a': 1, 'b': 3, 'c': 4}"} |
| {"id":"cmsrg7uni0046y8p2linhpjbb","kind":"contributor_item","title":"Submission NHPJBB","provisional":false,"code":"class Counter2:\n def __init__(self):\n self.count = 0\n def __call__(self):\n self.count += 1\n return self.count\n\nc = Counter2()","input":"(c(), c(), c())","language":"Python","predicted_output":"(1, 2, 3)"} |
| {"id":"cmsrg7uni0045y8p2l27dvf1s","kind":"contributor_item","title":"Submission 7DVF1S","provisional":false,"code":"def default_mutable(lst=[]):\n lst.append(1)\n return lst","input":"(default_mutable(), default_mutable())","language":"Python","predicted_output":"([1, 1], [1, 1])"} |
| {"id":"cmsrg7uni0043y8p2g4jvoq9l","kind":"contributor_item","title":"Submission JVOQ9L","provisional":false,"code":"def try_finally_demo():\n log = []\n try:\n log.append('try')\n raise ValueError('oops')\n except ValueError as e:\n log.append(f'caught: {e}')\n finally:\n log.append('finally')\n return log","input":"try_finally_demo()","language":"Python","predicted_output":"['try', 'caught: oops', 'finally']"} |
| {"id":"cmsrg7uni0047y8p2aucpcxk1","kind":"contributor_item","title":"Submission CPCXK1","provisional":false,"code":"def gen_squares(n):\n for i in range(n):\n yield i*i","input":"list(gen_squares(5))","language":"Python","predicted_output":"[0, 1, 4, 9, 16]"} |
| {"id":"cmsrg7uni0048y8p25535s2zc","kind":"contributor_item","title":"Submission 35S2ZC","provisional":false,"code":"def zip_sum(a, b):\n return [x+y for x, y in zip(a, b)]","input":"zip_sum([1,2,3], [10,20,30,40])","language":"Python","predicted_output":"[11, 22, 33]"} |
| {"id":"cmsrg7uni004dy8p26qn2xug8","kind":"contributor_item","title":"Submission N2XUG8","provisional":false,"code":"def closure_counter():\n count = 0\n def increment():\n nonlocal count\n count += 1\n return count\n return increment\n\ninc = closure_counter()","input":"(inc(), inc(), inc())","language":"Python","predicted_output":"(1, 2, 3)"} |
| {"id":"cmsrg7uni004by8p20qbeqk5l","kind":"contributor_item","title":"Submission BEQK5L","provisional":false,"code":"def recursive_sum(lst):\n if not lst:\n return 0\n return lst[0] + recursive_sum(lst[1:])","input":"recursive_sum([1,2,3,4,5])","language":"Python","predicted_output":"15"} |
| {"id":"cmsrg7uni004cy8p2qi6wn2es","kind":"contributor_item","title":"Submission 6WN2ES","provisional":false,"code":"def set_operations(a, b):\n return {'union': sorted(a | b), 'intersection': sorted(a & b), 'diff': sorted(a - b)}","input":"set_operations({1,2,3,4}, {3,4,5,6})","language":"Python","predicted_output":"{'union': [1, 2, 3, 4, 5, 6], 'intersection': [3, 4], 'diff': [1, 2]}"} |
| {"id":"cmsrg8gp1004ey8p216tavi35","kind":"contributor_item","title":"Submission TAVI35","provisional":false,"code":"def slice_demo(s):\n return (s[::2], s[::-1], s[1:4])","input":"slice_demo('abcdefgh')","language":"Python","predicted_output":"('aceg', 'hgfedcba', 'bcd')"} |
| {"id":"cmsrg8gp1004fy8p2mri1qcdt","kind":"contributor_item","title":"Submission I1QCDT","provisional":false,"code":"import itertools\ndef combo_demo(items, r):\n return list(itertools.combinations(items, r))","input":"combo_demo([1,2,3], 2)","language":"Python","predicted_output":"[(1, 2), (1, 3), (2, 3)]"} |
| {"id":"cmsrg8m8m004hy8p2zz9k68uw","kind":"contributor_item","title":"Submission 9K68UW","provisional":false,"code":"def multiple_return(x):\n if x > 0:\n return 'positive', x\n elif x < 0:\n return 'negative', -x\n return 'zero', 0","input":"(multiple_return(5), multiple_return(-3), multiple_return(0))","language":"Python","predicted_output":"(('positive', 5), ('negative', 3), ('zero', 0))"} |
| {"id":"cmsrg8yka004iy8p25em8b0ah","kind":"contributor_item","title":"Submission M8B0AH","provisional":false,"code":"class Animal:\n def speak(self):\n return 'generic sound'\n\nclass Dog(Animal):\n def speak(self):\n return 'woof'\n\ndef animal_demo():\n animals = [Animal(), Dog()]\n return [a.speak() for a in animals]","input":"animal_demo()","language":"Python","predicted_output":"['generic sound', 'woof']"} |
| {"id":"cmsrg8yka004ly8p2u05xfuat","kind":"contributor_item","title":"Submission 5XFUAT","provisional":false,"code":"def all_any_demo(nums):\n return (all(n > 0 for n in nums), any(n < 0 for n in nums))","input":"all_any_demo([1, 2, -3, 4])","language":"Python","predicted_output":"(False, True)"} |
| {"id":"cmsrg8yka004my8p2jdapux77","kind":"contributor_item","title":"Submission APUX77","provisional":false,"code":"def string_methods_demo(s):\n return (s.strip().upper(), s.replace('a', 'X'), s.split(','))","input":"string_methods_demo(' banana,apple,cherry ')","language":"Python","predicted_output":"('BANANA,APPLE,CHERRY', ' bXnXnX,Xpple,cherry ', [' banana', 'apple', 'cherry '])"} |
| {"id":"cmsrg8yka004ny8p25v3wlpjn","kind":"contributor_item","title":"Submission 3WLPJN","provisional":false,"code":"def lambda_sort_demo(pairs):\n return sorted(pairs, key=lambda p: (-p[1], p[0]))","input":"lambda_sort_demo([('x', 1), ('y', 2), ('z', 1)])","language":"Python","predicted_output":"[('y', 2), ('x', 1), ('z', 1)]"} |
| {"id":"cmsrg9m71004py8p2rpodfc6u","kind":"contributor_item","title":"Submission ODFC6U","provisional":false,"code":"def list_vs_tuple_unpack():\n a, *b, c = [1, 2, 3, 4, 5]\n return (a, b, c)","input":"list_vs_tuple_unpack()","language":"Python","predicted_output":"(1, [2, 3, 4], 5)"} |
| {"id":"cmsrg9m71004sy8p2lwgsugub","kind":"contributor_item","title":"Submission GSUGUB","provisional":false,"code":"def flatten_dict(d, prefix=''):\n result = {}\n for k, v in d.items():\n key = f'{prefix}.{k}' if prefix else k\n if isinstance(v, dict):\n result.update(flatten_dict(v, key))\n else:\n result[key] = v\n return result","input":"flatten_dict({'a': 1, 'b': {'c': 2, 'd': {'e': 3}}})","language":"Python","predicted_output":"{'a': 1, 'b.c': 2, 'b.d.e': 3}"} |
| {"id":"cmsrg9m720057y8p2n5vw3bcj","kind":"contributor_item","title":"Submission VW3BCJ","provisional":false,"code":"def negative_indexing(lst):\n return (lst[-1], lst[-2], lst[-len(lst)])","input":"negative_indexing([10,20,30,40,50])","language":"Python","predicted_output":"(50, 40, 10)"} |
| {"id":"cmsrg9m720058y8p27saqul7r","kind":"contributor_item","title":"Submission AQUL7R","provisional":false,"code":"def dict_ordering():\n d = {}\n d['z'] = 1\n d['a'] = 2\n d['m'] = 3\n return list(d.keys())","input":"dict_ordering()","language":"Python","predicted_output":"['z', 'a', 'm']"} |
| {"id":"cmsrg9m71004oy8p21w1j15jr","kind":"contributor_item","title":"Submission 1J15JR","provisional":false,"code":"def try_else_demo(x):\n try:\n result = 10 / x\n except ZeroDivisionError:\n return 'error'\n else:\n return round(result, 2)","input":"(try_else_demo(2), try_else_demo(0))","language":"Python","predicted_output":"(5.0, 'error')"} |
| {"id":"cmsrg9m71004qy8p20rzuom6z","kind":"contributor_item","title":"Submission ZUOM6Z","provisional":false,"code":"def deep_copy_demo():\n import copy\n original = {'a': [1, 2, 3]}\n shallow = original.copy()\n deep = copy.deepcopy(original)\n original['a'].append(4)\n return (shallow, deep)","input":"deep_copy_demo()","language":"Python","predicted_output":"({'a': [1, 2, 3, 4]}, {'a': [1, 2, 3]})"} |
| {"id":"cmsrg9m71004ry8p2z7elnvbb","kind":"contributor_item","title":"Submission ELNVBB","provisional":false,"code":"class Vector:\n def __init__(self, x, y):\n self.x, self.y = x, y\n def __add__(self, other):\n return Vector(self.x + other.x, self.y + other.y)\n def __repr__(self):\n return f'Vector({self.x}, {self.y})'\n\ndef vector_demo():\n v1, v2 = Vector(1,2), Vector(3,4)\n return v1 + v2","input":"vector_demo()","language":"Python","predicted_output":"Vector(4, 6)"} |
| {"id":"cmsrg9m71004uy8p2zf0iwevd","kind":"contributor_item","title":"Submission 0IWEVD","provisional":false,"code":"def while_break_continue(n):\n result = []\n i = 0\n while i < n:\n i += 1\n if i % 2 == 0:\n continue\n if i > 7:\n break\n result.append(i)\n return result","input":"while_break_continue(10)","language":"Python","predicted_output":"[1, 3, 5, 7]"} |
| {"id":"cmsrg9m71004vy8p2zhhmofpv","kind":"contributor_item","title":"Submission HMOFPV","provisional":false,"code":"def multi_assignment():\n x = y = z = 5\n x += 1\n return (x, y, z)","input":"multi_assignment()","language":"Python","predicted_output":"(6, 5, 5)"} |
| {"id":"cmsrg9m71004xy8p2e2420igy","kind":"contributor_item","title":"Submission 420IGY","provisional":false,"code":"def chained_comparison(x):\n return 0 < x < 10","input":"(chained_comparison(5), chained_comparison(15), chained_comparison(-1))","language":"Python","predicted_output":"(True, False, False)"} |
| {"id":"cmsrg9m710052y8p2usc5fzhe","kind":"contributor_item","title":"Submission C5FZHE","provisional":false,"code":"def none_coalesce(a, b):\n return a if a is not None else b","input":"(none_coalesce(None, 5), none_coalesce(0, 5), none_coalesce(3, 5))","language":"Python","predicted_output":"(5, 0, 3)"} |
| {"id":"cmsrg9m720053y8p2hmeho25y","kind":"contributor_item","title":"Submission EHO25Y","provisional":false,"code":"def matrix_transpose(m):\n return list(zip(*m))","input":"matrix_transpose([[1,2,3],[4,5,6]])","language":"Python","predicted_output":"[(1, 4), (2, 5), (3, 6)]"} |
| {"id":"cmsrh0ira0074y8p28tbrw2q9","kind":"contributor_item","title":"Submission BRW2Q9","provisional":false,"code":"def bounded_product(values, cap):\n total=1\n for v in values:\n total*=v\n if total>cap: return cap\n return total","input":"bounded_product([2, 3, 5], 20)","language":"Python","predicted_output":"20"} |
| {"id":"cmsrh0ira0078y8p2rvl8xi8h","kind":"contributor_item","title":"Submission L8XI8H","provisional":false,"code":"def rotate_blocks(values, size):\n out=[]\n for i in range(0,len(values),size):\n block=values[i:i+size]\n out.extend(block[1:]+block[:1])\n return out","input":"rotate_blocks([1, 2, 3, 4, 5, 6, 7], 3)","language":"Python","predicted_output":"[2, 3, 1, 5, 6, 4, 7]"} |
| {"id":"cmsrh0ira0076y8p2qn2o8osr","kind":"contributor_item","title":"Submission 2O8OSR","provisional":false,"code":"def difference_chain(values):\n rows=[values]\n while len(rows[-1])>1:\n prev=rows[-1]; rows.append([b-a for a,b in zip(prev,prev[1:])])\n return rows","input":"difference_chain([2, 5, 11, 20])","language":"Python","predicted_output":"[[2, 5, 11, 20], [3, 6, 9], [3, 3], [0]]"} |
| {"id":"cmsrh0ira0077y8p2oaqbs5bc","kind":"contributor_item","title":"Submission QBS5BC","provisional":false,"code":"def difference_chain(values):\n rows=[values]\n while len(rows[-1])>1:\n prev=rows[-1]; rows.append([b-a for a,b in zip(prev,prev[1:])])\n return rows","input":"difference_chain([1, 4, 9, 16])","language":"Python","predicted_output":"[[1, 4, 9, 16], [3, 5, 7], [2, 2], [0]]"} |
| {"id":"cmsrh0ira007ay8p2gfci6v3s","kind":"contributor_item","title":"Submission CI6V3S","provisional":false,"code":"def count_transitions(values):\n return sum(a != b for a,b in zip(values,values[1:]))","input":"count_transitions([1, 1, 2, 2, 3, 1])","language":"Python","predicted_output":"3"} |
| {"id":"cmsrh0irb007ey8p2q6vslrus","kind":"contributor_item","title":"Submission VSLRUS","provisional":false,"code":"def rank_values(values):\n order={v:i+1 for i,v in enumerate(sorted(set(values)))}\n return [order[v] for v in values]","input":"rank_values([40, 10, 20, 10])","language":"Python","predicted_output":"[3, 1, 2, 1]"} |
| {"id":"cmsrh0irb007gy8p237joknta","kind":"contributor_item","title":"Submission JOKNTA","provisional":false,"code":"def clamped_deltas(values, limit):\n return [max(-limit,min(limit,b-a)) for a,b in zip(values,values[1:])]","input":"clamped_deltas([2, 10, 7, 20], 5)","language":"Python","predicted_output":"[5, -3, 5]"} |
| {"id":"cmsrh0irb007iy8p2avuq2cud","kind":"contributor_item","title":"Submission UQ2CUD","provisional":false,"code":"def pair_products(values):\n return [values[i]*values[-1-i] for i in range((len(values)+1)//2)]","input":"pair_products([2, 3, 4, 5])","language":"Python","predicted_output":"[10, 12]"} |
| {"id":"cmsrh0irb007ly8p23qizndaa","kind":"contributor_item","title":"Submission IZNDAA","provisional":false,"code":"def running_mod(values, modulus):\n total=0; out=[]\n for v in values:\n total=(total+v)%modulus; out.append(total)\n return out","input":"running_mod([5, -3, 11], 7)","language":"Python","predicted_output":"[5, 2, 6]"} |
| {"id":"cmsrh0irb007oy8p28cp1yv48","kind":"contributor_item","title":"Submission P1YV48","provisional":false,"code":"def weighted_index(values):\n return sum((i+1)*v for i,v in enumerate(values))","input":"weighted_index([3, 1, 4, 1])","language":"Python","predicted_output":"21"} |
| {"id":"cmsrh0irb007my8p2ojvpe7z5","kind":"contributor_item","title":"Submission VPE7Z5","provisional":false,"code":"def collapse_runs(values):\n out=[]\n for v in values:\n if not out or out[-1]!=v: out.append(v)\n return out","input":"collapse_runs([1, 1, 2, 2, 2, 3, 1, 1])","language":"Python","predicted_output":"[1, 2, 3, 1]"} |
| {"id":"cmsrh0irb007py8p2z6jobb6t","kind":"contributor_item","title":"Submission JOBB6T","provisional":false,"code":"def weighted_index(values):\n return sum((i+1)*v for i,v in enumerate(values))","input":"weighted_index([2, -1, 5])","language":"Python","predicted_output":"15"} |
| {"id":"cmsrh0irb007ny8p2vz7lc94h","kind":"contributor_item","title":"Submission 7LC94H","provisional":false,"code":"def collapse_runs(values):\n out=[]\n for v in values:\n if not out or out[-1]!=v: out.append(v)\n return out","input":"collapse_runs([4, 4, 4, 2, 4])","language":"Python","predicted_output":"[4, 2, 4]"} |
| {"id":"cmsrh0irb007sy8p2y72alqu5","kind":"contributor_item","title":"Submission 2ALQU5","provisional":false,"code":"def threshold_groups(values, threshold):\n low=[v for v in values if v<threshold]\n high=[v for v in values if v>=threshold]\n return [low,high]","input":"threshold_groups([8, 2, 7, 1, 9], 7)","language":"Python","predicted_output":"[[2, 1], [8, 7, 9]]"} |
| {"id":"cmsrh0irb007ty8p2pggu1z24","kind":"contributor_item","title":"Submission GU1Z24","provisional":false,"code":"def threshold_groups(values, threshold):\n low=[v for v in values if v<threshold]\n high=[v for v in values if v>=threshold]\n return [low,high]","input":"threshold_groups([0, -3, 4, 2], 1)","language":"Python","predicted_output":"[[0, -3], [4, 2]]"} |
| {"id":"cmsrh0irb007qy8p2vtblkhdh","kind":"contributor_item","title":"Submission BLKHDH","provisional":false,"code":"def mirror_sum(values):\n return [a+b for a,b in zip(values,reversed(values))]","input":"mirror_sum([1, 2, 3, 4])","language":"Python","predicted_output":"[5, 5, 5, 5]"} |
| {"id":"cmsrh0irb007wy8p2ejpsimh6","kind":"contributor_item","title":"Submission PSIMH6","provisional":false,"code":"def take_until_repeat(values):\n seen=set(); out=[]\n for v in values:\n if v in seen: break\n seen.add(v); out.append(v)\n return out","input":"take_until_repeat([3, 1, 4, 1, 5])","language":"Python","predicted_output":"[3, 1, 4]"} |
| {"id":"cmsrh0irb007uy8p2x9dmda5k","kind":"contributor_item","title":"Submission DMDA5K","provisional":false,"code":"def circular_differences(values):\n return [values[(i+1)%len(values)]-v for i,v in enumerate(values)]","input":"circular_differences([2, 5, 9])","language":"Python","predicted_output":"[3, 4, -7]"} |
| {"id":"cmsrh0irb007xy8p2mmxsf0yf","kind":"contributor_item","title":"Submission XSF0YF","provisional":false,"code":"def take_until_repeat(values):\n seen=set(); out=[]\n for v in values:\n if v in seen: break\n seen.add(v); out.append(v)\n return out","input":"take_until_repeat([2, 7, 9, 2])","language":"Python","predicted_output":"[2, 7, 9]"} |
| {"id":"cmsrh0irb007zy8p24vmuhwit","kind":"contributor_item","title":"Submission MUHWIT","provisional":false,"code":"def staircase_fill(start, steps):\n out=[]; value=start\n for step in steps:\n value+=step; out.append(value)\n return out","input":"staircase_fill(0, [5, -2, -2, 1])","language":"Python","predicted_output":"[5, 3, 1, 2]"} |
| {"id":"cmsrh0irb007yy8p2i50oegnp","kind":"contributor_item","title":"Submission 0OEGNP","provisional":false,"code":"def staircase_fill(start, steps):\n out=[]; value=start\n for step in steps:\n value+=step; out.append(value)\n return out","input":"staircase_fill(10, [1, 2, -3, 4])","language":"Python","predicted_output":"[11, 13, 10, 14]"} |
| {"id":"cmsrh0irb0085y8p22078tuy1","kind":"contributor_item","title":"Submission 78TUY1","provisional":false,"code":"def segment_totals(values, marker):\n out=[]; total=0\n for v in values:\n if v==marker: out.append(total); total=0\n else: total+=v\n out.append(total)\n return out","input":"segment_totals([1, -1, 9, 2, 9, 3], 9)","language":"Python","predicted_output":"[0, 2, 3]"} |
| {"id":"cmsrh0irb0083y8p2u7creluo","kind":"contributor_item","title":"Submission CRELUO","provisional":false,"code":"def bounded_gaps(values, bound):\n return [abs(b-a)<=bound for a,b in zip(values,values[1:])]","input":"bounded_gaps([5, 1, 0, 7], 4)","language":"Python","predicted_output":"[True, True, False]"} |
| {"id":"cmsrh0irb0088y8p2zczm29bs","kind":"contributor_item","title":"Submission ZM29BS","provisional":false,"code":"def rolling_range(values, size):\n return [max(values[i:i+size])-min(values[i:i+size]) for i in range(len(values)-size+1)]","input":"rolling_range([3, 8, 2, 7, 5], 3)","language":"Python","predicted_output":"[6, 6, 5]"} |
| {"id":"cmsrh0irb0087y8p2k2mjhsg2","kind":"contributor_item","title":"Submission MJHSG2","provisional":false,"code":"def index_peaks(values):\n return [i for i in range(1,len(values)-1) if values[i]>values[i-1] and values[i]>values[i+1]]","input":"index_peaks([9, 8, 7, 8, 7])","language":"Python","predicted_output":"[3]"} |
| {"id":"cmsrh0irb0089y8p2r3b89c5r","kind":"contributor_item","title":"Submission B89C5R","provisional":false,"code":"def rolling_range(values, size):\n return [max(values[i:i+size])-min(values[i:i+size]) for i in range(len(values)-size+1)]","input":"rolling_range([10, 9, 6, 8], 2)","language":"Python","predicted_output":"[1, 3, 2]"} |
| {"id":"cmsrh0irb0086y8p2wbqhfwfj","kind":"contributor_item","title":"Submission QHFWFJ","provisional":false,"code":"def index_peaks(values):\n return [i for i in range(1,len(values)-1) if values[i]>values[i-1] and values[i]>values[i+1]]","input":"index_peaks([1, 5, 2, 6, 3, 4])","language":"Python","predicted_output":"[1, 3]"} |
| {"id":"cmsrh0irb008by8p2fiif8dfg","kind":"contributor_item","title":"Submission IF8DFG","provisional":false,"code":"def stable_partition(values, divisor):\n return [v for v in values if v%divisor==0]+[v for v in values if v%divisor!=0]","input":"stable_partition([3, 10, 15, 8, 20], 5)","language":"Python","predicted_output":"[10, 15, 20, 3, 8]"} |
| {"id":"cmsrh0ira006zy8p2fisa3the","kind":"contributor_item","title":"Submission SA3THE","provisional":false,"code":"def window_sums(values, size):\n return [sum(values[i:i+size]) for i in range(len(values)-size+1)]","input":"window_sums([10, 0, -2, 7], 2)","language":"Python","predicted_output":"[10, -2, 5]"} |
| {"id":"cmsrh0ira006yy8p2ue0o1c0t","kind":"contributor_item","title":"Submission 0O1C0T","provisional":false,"code":"def window_sums(values, size):\n return [sum(values[i:i+size]) for i in range(len(values)-size+1)]","input":"window_sums([3, -1, 4, 2, 5], 3)","language":"Python","predicted_output":"[6, 5, 11]"} |
| {"id":"cmsrh0ira0070y8p2e0cka3t8","kind":"contributor_item","title":"Submission CKA3T8","provisional":false,"code":"def alternating_total(values):\n return sum(v if i % 2 == 0 else -v for i, v in enumerate(values))","input":"alternating_total([8, 3, 5, 2])","language":"Python","predicted_output":"8"} |
| {"id":"cmsrh0ira0075y8p2azk2uw8v","kind":"contributor_item","title":"Submission K2UW8V","provisional":false,"code":"def bounded_product(values, cap):\n total=1\n for v in values:\n total*=v\n if total>cap: return cap\n return total","input":"bounded_product([2, 3, 2], 20)","language":"Python","predicted_output":"12"} |
| {"id":"cmsrh0ira0073y8p2ur4g0e1k","kind":"contributor_item","title":"Submission 4G0E1K","provisional":false,"code":"def prefix_minima(values):\n out=[]\n cur=float('inf')\n for v in values:\n cur=min(cur,v); out.append(cur)\n return out","input":"prefix_minima([0, -1, 3, -5, 2])","language":"Python","predicted_output":"[0, -1, -1, -5, -5]"} |
| {"id":"cmsrh0ira007cy8p2w3hnwz7m","kind":"contributor_item","title":"Submission HNWZ7M","provisional":false,"code":"def zigzag_merge(left, right):\n out=[]\n for i in range(max(len(left),len(right))):\n if i<len(left): out.append(left[i])\n if i<len(right): out.append(right[-1-i])\n return out","input":"zigzag_merge([1, 2, 3], [7, 8, 9, 10])","language":"Python","predicted_output":"[1, 10, 2, 9, 3, 8, 7]"} |
| {"id":"cmsrh0irb007fy8p2tgcudf40","kind":"contributor_item","title":"Submission CUDF40","provisional":false,"code":"def rank_values(values):\n order={v:i+1 for i,v in enumerate(sorted(set(values)))}\n return [order[v] for v in values]","input":"rank_values([3, -1, 3, 7, 0])","language":"Python","predicted_output":"[3, 1, 3, 4, 2]"} |
| {"id":"cmsrh0irb007jy8p2yvj5e5l8","kind":"contributor_item","title":"Submission J5E5L8","provisional":false,"code":"def pair_products(values):\n return [values[i]*values[-1-i] for i in range((len(values)+1)//2)]","input":"pair_products([1, -2, 3, -4, 5])","language":"Python","predicted_output":"[5, 8, 9]"} |
| {"id":"cmsrh0irb007ry8p2f438nggp","kind":"contributor_item","title":"Submission 38NGGP","provisional":false,"code":"def mirror_sum(values):\n return [a+b for a,b in zip(values,reversed(values))]","input":"mirror_sum([5, -1, 0])","language":"Python","predicted_output":"[5, -2, 5]"} |
| {"id":"cmsrh0irb007vy8p2qysol362","kind":"contributor_item","title":"Submission SOL362","provisional":false,"code":"def circular_differences(values):\n return [values[(i+1)%len(values)]-v for i,v in enumerate(values)]","input":"circular_differences([10, 7, 7, 1])","language":"Python","predicted_output":"[-3, 0, -6, 9]"} |
| {"id":"cmsrh0irb0081y8p2bii3i3wi","kind":"contributor_item","title":"Submission I3I3WI","provisional":false,"code":"def odd_even_balance(values):\n return sum(v for v in values if v%2)-sum(v for v in values if v%2==0)","input":"odd_even_balance([6, 7, 8, 9])","language":"Python","predicted_output":"2"} |
| {"id":"cmsrh0irb0084y8p2gw6cg11i","kind":"contributor_item","title":"Submission 6CG11I","provisional":false,"code":"def segment_totals(values, marker):\n out=[]; total=0\n for v in values:\n if v==marker: out.append(total); total=0\n else: total+=v\n out.append(total)\n return out","input":"segment_totals([2, 3, 0, 4, 0, 5, 1], 0)","language":"Python","predicted_output":"[5, 4, 6]"} |
| {"id":"cmsrh0ira007by8p2zrqj9gzj","kind":"contributor_item","title":"Submission QJ9GZJ","provisional":false,"code":"def count_transitions(values):\n return sum(a != b for a,b in zip(values,values[1:]))","input":"count_transitions([5, 5, 5, 5])","language":"Python","predicted_output":"0"} |
| {"id":"cmsrh0irb007dy8p2swlfu0i2","kind":"contributor_item","title":"Submission LFU0I2","provisional":false,"code":"def zigzag_merge(left, right):\n out=[]\n for i in range(max(len(left),len(right))):\n if i<len(left): out.append(left[i])\n if i<len(right): out.append(right[-1-i])\n return out","input":"zigzag_merge([4, 5], [1, 2])","language":"Python","predicted_output":"[4, 2, 5, 1]"} |
| {"id":"cmsrh0irb008ay8p26g7zoed1","kind":"contributor_item","title":"Submission 7ZOED1","provisional":false,"code":"def stable_partition(values, divisor):\n return [v for v in values if v%divisor==0]+[v for v in values if v%divisor!=0]","input":"stable_partition([5, 6, 4, 9, 8], 2)","language":"Python","predicted_output":"[6, 4, 8, 5, 9]"} |
| {"id":"cmsrh0ira0072y8p27dh1pd1u","kind":"contributor_item","title":"Submission H1PD1U","provisional":false,"code":"def prefix_minima(values):\n out=[]\n cur=float('inf')\n for v in values:\n cur=min(cur,v); out.append(cur)\n return out","input":"prefix_minima([7, 4, 9, 2, 6])","language":"Python","predicted_output":"[7, 4, 4, 2, 2]"} |
| {"id":"cmsrh0irb007ky8p26yzmg5q4","kind":"contributor_item","title":"Submission ZMG5Q4","provisional":false,"code":"def running_mod(values, modulus):\n total=0; out=[]\n for v in values:\n total=(total+v)%modulus; out.append(total)\n return out","input":"running_mod([7, 8, 9, 10], 6)","language":"Python","predicted_output":"[1, 3, 0, 4]"} |
| {"id":"cmsrh0irb0080y8p25vqmwvbc","kind":"contributor_item","title":"Submission QMWVBC","provisional":false,"code":"def odd_even_balance(values):\n return sum(v for v in values if v%2)-sum(v for v in values if v%2==0)","input":"odd_even_balance([1, 2, 3, 4, 5])","language":"Python","predicted_output":"3"} |
| {"id":"cmsrh0ira0071y8p2xm72loa3","kind":"contributor_item","title":"Submission 72LOA3","provisional":false,"code":"def alternating_total(values):\n return sum(v if i % 2 == 0 else -v for i, v in enumerate(values))","input":"alternating_total([1, 9, 2, 8, 3])","language":"Python","predicted_output":"-11"} |
| {"id":"cmsrh0ira0079y8p2u2uyrxrf","kind":"contributor_item","title":"Submission UYRXRF","provisional":false,"code":"def rotate_blocks(values, size):\n out=[]\n for i in range(0,len(values),size):\n block=values[i:i+size]\n out.extend(block[1:]+block[:1])\n return out","input":"rotate_blocks([9, 8, 7, 6, 5], 2)","language":"Python","predicted_output":"[8, 9, 6, 7, 5]"} |
| {"id":"cmsrh0irb007hy8p2vo0hxq2e","kind":"contributor_item","title":"Submission 0HXQ2E","provisional":false,"code":"def clamped_deltas(values, limit):\n return [max(-limit,min(limit,b-a)) for a,b in zip(values,values[1:])]","input":"clamped_deltas([0, -9, -8, 4], 3)","language":"Python","predicted_output":"[-3, 1, 3]"} |
| {"id":"cmsrh0irb0082y8p2c133kyls","kind":"contributor_item","title":"Submission 33KYLS","provisional":false,"code":"def bounded_gaps(values, bound):\n return [abs(b-a)<=bound for a,b in zip(values,values[1:])]","input":"bounded_gaps([1, 4, 8, 10], 3)","language":"Python","predicted_output":"[True, False, True]"} |
| {"id":"cmsrk8iiq0002jmp233jr833y","kind":"contributor_item","title":"Submission JR833Y","provisional":false,"code":"def parse_versions(tags):\n parsed = []\n for tag in tags:\n try:\n parts = tuple(int(p) for p in tag.lstrip('v').split('.'))\n parsed.append(parts)\n except ValueError:\n parsed.append(None)\n return sorted(p for p in parsed if p is not None), parsed.count(None)","input":"parse_versions(['v1.2.10', 'v1.2.3', 'beta', 'v0.9'])","language":"Python","predicted_output":"([(0, 9), (1, 2, 3), (1, 2, 10)], 1)"} |
| {"id":"cmsrk8iiq0001jmp2o0hw4p3t","kind":"contributor_item","title":"Submission HW4P3T","provisional":false,"code":"def rotate_and_flag(matrix):\n rotated = [list(row) for row in zip(*matrix[::-1])]\n flags = [sum(row) % 2 == 0 for row in rotated]\n return rotated, flags","input":"rotate_and_flag([[1, 2], [3, 4]])","language":"Python","predicted_output":"([[3, 1], [4, 2]], [True, True])"} |
| {"id":"cmsrk8iiq0003jmp2go483anz","kind":"contributor_item","title":"Submission 483ANZ","provisional":false,"code":"def dedupe_keep_last(pairs):\n seen = {}\n for key, value in pairs:\n seen[key] = value\n return list(seen.items())","input":"dedupe_keep_last([('a', 1), ('b', 2), ('a', 3), ('c', 4), ('b', 5)])","language":"Python","predicted_output":"[('a', 3), ('b', 5), ('c', 4)]"} |
| {"id":"cmsrk8iiq0004jmp2waisuzyp","kind":"contributor_item","title":"Submission ISUZYP","provisional":false,"code":"def bucket_grades(scores):\n buckets = {'high': [], 'mid': [], 'low': []}\n for name, score in scores.items():\n key = 'high' if score >= 85 else 'mid' if score >= 60 else 'low'\n buckets[key].append(name)\n return {k: sorted(v) for k, v in buckets.items() if v}","input":"bucket_grades({'ana': 91, 'bo': 60, 'cy': 59, 'di': 85})","language":"Python","predicted_output":"{'high': ['ana', 'di'], 'mid': ['bo'], 'low': ['cy']}"} |
| {"id":"cmsrk8iiq0006jmp2d7atu5qv","kind":"contributor_item","title":"Submission ATU5QV","provisional":false,"code":"def safe_lookup_chain(data, path):\n current = data\n trail = []\n for key in path.split('.'):\n try:\n current = current[key]\n trail.append(key)\n except (KeyError, TypeError):\n return {'found': False, 'trail': trail}\n return {'found': True, 'value': current, 'trail': trail}","input":"safe_lookup_chain({'a': {'b': {'c': 7}}}, 'a.b.x')","language":"Python","predicted_output":"{'found': False, 'trail': ['a', 'b']}"} |
| {"id":"cmsrk8iiq000ajmp26a8mrqmq","kind":"contributor_item","title":"Submission 8MRQMQ","provisional":false,"code":"def expand_ranges(spec):\n pages = set()\n for part in spec.split(','):\n part = part.strip()\n if '-' in part:\n a, b = part.split('-')\n pages.update(range(int(a), int(b) + 1))\n else:\n pages.add(int(part))\n return sorted(pages)","input":"expand_ranges('1, 4-6, 5, 9')","language":"Python","predicted_output":"[1, 4, 5, 6, 9]"} |
| {"id":"cmsrk8iiq0008jmp2bbg6qua1","kind":"contributor_item","title":"Submission G6QUA1","provisional":false,"code":"def interleave_uneven(*seqs):\n result = []\n i = 0\n while any(i < len(s) for s in seqs):\n for s in seqs:\n if i < len(s):\n result.append(s[i])\n i += 1\n return result","input":"interleave_uneven([1, 2, 3], ['a'], [True, False])","language":"Python","predicted_output":"[1, 'a', True, 2, False, 3]"} |
| {"id":"cmsrk8iiq000bjmp2t4okouzv","kind":"contributor_item","title":"Submission OKOUZV","provisional":false,"code":"def summarize_types(values):\n from collections import Counter\n counts = Counter(type(v).__name__ for v in values)\n return sorted(counts.items(), key=lambda kv: (-kv[1], kv[0]))","input":"summarize_types([1, 'a', 2.0, True, 'b', None, 3])","language":"Python","predicted_output":"[('int', 2), ('str', 2), ('NoneType', 1), ('bool', 1), ('float', 1)]"} |
| {"id":"cmsrk8iip0000jmp283390488","kind":"contributor_item","title":"Submission 390488","provisional":false,"code":"def merge_intervals(intervals):\n intervals = sorted(intervals)\n merged = []\n for start, end in intervals:\n if merged and start <= merged[-1][1]:\n merged[-1] = (merged[-1][0], max(merged[-1][1], end))\n else:\n merged.append((start, end))\n return merged","input":"merge_intervals([(5, 8), (1, 3), (2, 6), (10, 12)])","language":"Python","predicted_output":"[(1, 8), (10, 12)]"} |
| {"id":"cmsrk8iiq0007jmp2a5k9bh05","kind":"contributor_item","title":"Submission K9BH05","provisional":false,"code":"def window_max(values, k):\n if k <= 0 or k > len(values):\n raise ValueError('bad window')\n return [max(values[i:i + k]) for i in range(len(values) - k + 1)]\n\ndef try_windows(values, sizes):\n out = {}\n for k in sizes:\n try:\n out[k] = window_max(values, k)\n except ValueError as e:\n out[k] = str(e)\n return out","input":"try_windows([3, 1, 4, 1, 5], [2, 6])","language":"Python","predicted_output":"{2: [3, 4, 4, 5], 6: 'bad window'}"} |
| {"id":"cmsrk8iiq0009jmp24nfyyby8","kind":"contributor_item","title":"Submission FYYBY8","provisional":false,"code":"def balance_report(entries):\n balance = 0\n low = 0\n overdrafts = 0\n for amount in entries:\n balance += amount\n if balance < low:\n low = balance\n if balance < 0:\n overdrafts += 1\n return {'final': balance, 'lowest': low, 'overdraft_steps': overdrafts}","input":"balance_report([100, -150, 30, -20, 80])","language":"Python","predicted_output":"{'final': 40, 'lowest': -50, 'overdraft_steps': 3}"} |
| {"id":"cmssht3mb007yjmp2im72inmd","kind":"contributor_item","title":"Submission 72INMD","provisional":false,"code":"def count_palindromes(words):\n return sum(1 for w in words if w == w[::-1])","input":"count_palindromes(['racecar', 'hello', 'level', 'world', 'madam'])","language":"Python","predicted_output":"3"} |
| {"id":"cmssht3ma007gjmp24693qh9o","kind":"contributor_item","title":"Submission 93QH9O","provisional":false,"code":"def flatten_once(nested):\n result = []\n for item in nested:\n if isinstance(item, list):\n result.extend(item)\n else:\n result.append(item)\n return result","input":"flatten_once([[1, 2], 3, [4, [5, 6]]])","language":"Python","predicted_output":"[1, 2, 3, 4, [5, 6]]"} |
| {"id":"cmssht3ma007rjmp2bmcjmm3r","kind":"contributor_item","title":"Submission CJMM3R","provisional":false,"code":"def clamp(value, lo, hi):\n return max(lo, min(value, hi))\n\ndef clamp_list(values, lo, hi):\n return [clamp(v, lo, hi) for v in values]","input":"clamp_list([-5, 0, 3, 7, 10, 15], 0, 10)","language":"Python","predicted_output":"[0, 0, 3, 7, 10, 10]"} |
| {"id":"cmssht3mb0080jmp2fj12d96t","kind":"contributor_item","title":"Submission 12D96T","provisional":false,"code":"def sliding_window_sum(lst, window):\n if window > len(lst):\n return []\n return [sum(lst[i:i+window]) for i in range(len(lst) - window + 1)]","input":"sliding_window_sum([1, 2, 3, 4, 5], 3)","language":"Python","predicted_output":"[6, 9, 12]"} |
| {"id":"cmssht3mb0081jmp2j3d25r6e","kind":"contributor_item","title":"Submission D25R6E","provisional":false,"code":"def compress_runs(lst):\n if not lst:\n return []\n result = [(lst[0], 1)]\n for item in lst[1:]:\n if item == result[-1][0]:\n result[-1] = (result[-1][0], result[-1][1] + 1)\n else:\n result.append((item, 1))\n return result","input":"compress_runs([1, 1, 2, 3, 3, 3, 1])","language":"Python","predicted_output":"[(1, 2), (2, 1), (3, 3), (1, 1)]"} |
| {"id":"cmssht3ma007hjmp24m04bdab","kind":"contributor_item","title":"Submission 04BDAB","provisional":false,"code":"def count_vowels(s):\n vowels = set('aeiouAEIOU')\n return sum(1 for ch in s if ch in vowels)","input":"count_vowels('Hello World')","language":"Python","predicted_output":"3"} |
| {"id":"cmssht3ma007tjmp2d7sbal7k","kind":"contributor_item","title":"Submission SBAL7K","provisional":false,"code":"def most_common(items):\n freq = {}\n for item in items:\n freq[item] = freq.get(item, 0) + 1\n return max(freq, key=freq.get)","input":"most_common(['apple', 'banana', 'apple', 'cherry', 'banana', 'apple'])","language":"Python","predicted_output":"apple"} |
| {"id":"cmssht3ma007jjmp2rfwsojd9","kind":"contributor_item","title":"Submission WSOJD9","provisional":false,"code":"def rotating_cipher(text, shift):\n result = []\n for ch in text:\n if ch.isalpha():\n base = ord('A') if ch.isupper() else ord('a')\n result.append(chr((ord(ch) - base + shift) % 26 + base))\n else:\n result.append(ch)\n return ''.join(result)","input":"rotating_cipher('Xyz!', 3)","language":"Python","predicted_output":"Abc!"} |
| {"id":"cmssht3ma007ljmp29yn7yjjx","kind":"contributor_item","title":"Submission N7YJJX","provisional":false,"code":"def cumulative_max(values):\n if not values:\n return []\n result = [values[0]]\n for v in values[1:]:\n result.append(max(result[-1], v))\n return result","input":"cumulative_max([3, 1, 4, 1, 5, 9, 2, 6])","language":"Python","predicted_output":"[3, 3, 4, 4, 5, 9, 9, 9]"} |
| {"id":"cmssht3ma007ijmp21vviay6o","kind":"contributor_item","title":"Submission VIAY6O","provisional":false,"code":"def merge_dicts_sum(d1, d2):\n result = dict(d1)\n for k, v in d2.items():\n result[k] = result.get(k, 0) + v\n return result","input":"merge_dicts_sum({'a': 1, 'b': 2}, {'b': 3, 'c': 4})","language":"Python","predicted_output":"{'a': 1, 'b': 5, 'c': 4}"} |
| {"id":"cmssht3ma007kjmp2dfwba04x","kind":"contributor_item","title":"Submission WBA04X","provisional":false,"code":"def partition_even_odd(nums):\n evens = [x for x in nums if x % 2 == 0]\n odds = [x for x in nums if x % 2 != 0]\n return evens, odds","input":"partition_even_odd([1, 2, 3, 4, 5, 6])","language":"Python","predicted_output":"([2, 4, 6], [1, 3, 5])"} |
| {"id":"cmssht3ma007mjmp2lafub73t","kind":"contributor_item","title":"Submission FUB73T","provisional":false,"code":"def word_frequency(sentence):\n freq = {}\n for word in sentence.split():\n freq[word] = freq.get(word, 0) + 1\n return freq","input":"word_frequency('the cat sat on the mat the cat')","language":"Python","predicted_output":"{'the': 3, 'cat': 2, 'sat': 1, 'on': 1, 'mat': 1}"} |
| {"id":"cmssht3ma007pjmp2f7lww1cf","kind":"contributor_item","title":"Submission LWW1CF","provisional":false,"code":"def matrix_diagonal_sum(matrix):\n return sum(matrix[i][i] for i in range(len(matrix)))","input":"matrix_diagonal_sum([[1, 2, 3], [4, 5, 6], [7, 8, 9]])","language":"Python","predicted_output":"15"} |
| {"id":"cmssht3ma007ojmp2zjk35ocu","kind":"contributor_item","title":"Submission K35OCU","provisional":false,"code":"def deduplicate_preserve_order(seq):\n seen = set()\n result = []\n for item in seq:\n if item not in seen:\n seen.add(item)\n result.append(item)\n return result","input":"deduplicate_preserve_order([3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5])","language":"Python","predicted_output":"[3, 1, 4, 5, 9, 2, 6]"} |
| {"id":"cmssht3ma007njmp2p0ghw1j2","kind":"contributor_item","title":"Submission GHW1J2","provisional":false,"code":"def safe_divide(a, b):\n try:\n result = a / b\n except ZeroDivisionError:\n return (None, 'division by zero')\n return (result, 'ok')","input":"(safe_divide(10, 4), safe_divide(5, 0))","language":"Python","predicted_output":"((2.5, 'ok'), (None, 'division by zero'))"} |
| {"id":"cmssht3ma007sjmp2mw7ivr38","kind":"contributor_item","title":"Submission 7IVR38","provisional":false,"code":"def nested_sum(data):\n total = 0\n for item in data:\n if isinstance(item, list):\n total += nested_sum(item)\n else:\n total += item\n return total","input":"nested_sum([1, [2, 3], [4, [5, 6]], 7])","language":"Python","predicted_output":"28"} |
| {"id":"cmssht3ma007qjmp2uwfw24av","kind":"contributor_item","title":"Submission FW24AV","provisional":false,"code":"def chunked(lst, n):\n return [lst[i:i+n] for i in range(0, len(lst), n)]","input":"chunked([1, 2, 3, 4, 5, 6, 7], 3)","language":"Python","predicted_output":"[[1, 2, 3], [4, 5, 6], [7]]"} |
| {"id":"cmssht3ma007wjmp2wmzkgzkt","kind":"contributor_item","title":"Submission ZKGZKT","provisional":false,"code":"def interleave(a, b):\n result = []\n for x, y in zip(a, b):\n result.extend([x, y])\n if len(a) > len(b):\n result.extend(a[len(b):])\n elif len(b) > len(a):\n result.extend(b[len(a):])\n return result","input":"interleave([1, 3, 5], [2, 4])","language":"Python","predicted_output":"[1, 2, 3, 4, 5]"} |
| {"id":"cmssht3ma007xjmp2kzoylwhw","kind":"contributor_item","title":"Submission OYLWHW","provisional":false,"code":"def transpose(matrix):\n if not matrix or not matrix[0]:\n return []\n return [[row[i] for row in matrix] for i in range(len(matrix[0]))]","input":"transpose([[1, 2, 3], [4, 5, 6]])","language":"Python","predicted_output":"[[1, 4], [2, 5], [3, 6]]"} |
| {"id":"cmssht3mb0082jmp2aoyfmgov","kind":"contributor_item","title":"Submission YFMGOV","provisional":false,"code":"def invert_dict(d):\n inverted = {}\n for k, v in d.items():\n inverted.setdefault(v, []).append(k)\n return inverted","input":"invert_dict({'a': 1, 'b': 2, 'c': 1, 'd': 3})","language":"Python","predicted_output":"{1: ['a', 'c'], 2: ['b'], 3: ['d']}"} |
| {"id":"cmssht3mb0084jmp28kds0eff","kind":"contributor_item","title":"Submission DS0EFF","provisional":false,"code":"def parse_key_value(pairs, sep='='):\n result = {}\n for pair in pairs:\n if sep in pair:\n k, _, v = pair.partition(sep)\n result[k.strip()] = v.strip()\n return result","input":"parse_key_value(['name = Alice', 'age = 30', 'invalid', 'city = Paris'])","language":"Python","predicted_output":"{'name': 'Alice', 'age': '30', 'city': 'Paris'}"} |
| {"id":"cmssht3mb0083jmp2tsp9n5bk","kind":"contributor_item","title":"Submission P9N5BK","provisional":false,"code":"def apply_until_stable(func, value, max_steps=100):\n for _ in range(max_steps):\n next_val = func(value)\n if next_val == value:\n return value\n value = next_val\n return value","input":"apply_until_stable(lambda x: x // 2 if x > 1 else x, 64)","language":"Python","predicted_output":"1"} |
| {"id":"cmssht3ma007ujmp2jglrz2a4","kind":"contributor_item","title":"Submission LRZ2A4","provisional":false,"code":"def zip_with_index(items, start=0):\n return [(i + start, item) for i, item in enumerate(items)]","input":"zip_with_index(['a', 'b', 'c'], start=1)","language":"Python","predicted_output":"[(1, 'a'), (2, 'b'), (3, 'c')]"} |
| {"id":"cmssht3mb007zjmp2qtd1s1fg","kind":"contributor_item","title":"Submission D1S1FG","provisional":false,"code":"def group_by_first_letter(words):\n groups = {}\n for word in words:\n key = word[0].lower()\n groups.setdefault(key, []).append(word)\n return groups","input":"group_by_first_letter(['Apple', 'ant', 'Banana', 'bee', 'avocado'])","language":"Python","predicted_output":"{'a': ['Apple', 'ant', 'avocado'], 'b': ['Banana', 'bee']}"} |
| {"id":"cmsshvjsl00a8jmp2e2m89pfo","kind":"contributor_item","title":"Submission M89PFO","provisional":false,"code":"def running_median(values):\n import heapq\n lo, hi = [], []\n result = []\n for v in values:\n if not lo or v <= -lo[0]:\n heapq.heappush(lo, -v)\n else:\n heapq.heappush(hi, v)\n if len(lo) > len(hi) + 1:\n heapq.heappush(hi, -heapq.heappop(lo))\n elif len(hi) > len(lo):\n heapq.heappush(lo, -heapq.heappop(hi))\n if len(lo) == len(hi):\n result.append((-lo[0] + hi[0]) / 2)\n else:\n result.append(float(-lo[0]))\n return result","input":"running_median([5, 2, 8, 1, 9])","language":"Python","predicted_output":"[5.0, 3.5, 5.0, 3.5, 5.0]"} |
| {"id":"cmsshxe3w00bnjmp2l5a00u7g","kind":"contributor_item","title":"Submission A00U7G","provisional":false,"code":"def word_frequencies_top_n(text, n):\n import re\n from collections import Counter\n words = re.findall(r\"[a-z']+\", text.lower())\n counts = Counter(words)\n return sorted(counts.items(), key=lambda kv: (-kv[1], kv[0]))[:n]","input":"word_frequencies_top_n(\"The quick brown fox. The Fox jumps! the dog barks, the dog runs.\", 3)","language":"Python","predicted_output":"[('the', 4), ('dog', 2), ('fox', 2)]"} |
| {"id":"cmsshxwcg00bojmp2kbm7qxyi","kind":"contributor_item","title":"Submission M7QXYI","provisional":false,"code":"def safe_divide_chain(pairs):\n results = []\n for a, b in pairs:\n try:\n results.append(a / b)\n except ZeroDivisionError:\n results.append(None)\n except TypeError:\n results.append('type_error')\n return results","input":"safe_divide_chain([(10, 2), (5, 0), ('x', 2), (9, 3)])","language":"Python","predicted_output":"[5.0, None, 'type_error', 3.0]"} |
| {"id":"cmsshypqd00bpjmp2yjz9ar9r","kind":"contributor_item","title":"Submission Z9AR9R","provisional":false,"code":"def memoized_fib(n, cache=None):\n if cache is None:\n cache = {}\n if n in cache:\n return cache[n]\n if n <= 1:\n return n\n result = memoized_fib(n - 1, cache) + memoized_fib(n - 2, cache)\n cache[n] = result\n return result\n\ndef fib_sequence(count):\n return [memoized_fib(i) for i in range(count)]","input":"fib_sequence(10)","language":"Python","predicted_output":"[0, 1, 1, 2, 3, 5, 8, 13, 21, 34]"} |
| {"id":"cmsshzf3300btjmp2gd4k94bj","kind":"contributor_item","title":"Submission 4K94BJ","provisional":false,"code":"class RateLimiter:\n def __init__(self, limit):\n self.limit = limit\n self.count = 0\n self.history = []\n\n def allow(self, ts):\n self.history = [t for t in self.history if t > ts - 10]\n if len(self.history) < self.limit:\n self.history.append(ts)\n return True\n return False\n\ndef simulate(events):\n rl = RateLimiter(2)\n return [rl.allow(t) for t in events]","input":"simulate([1, 2, 3, 12, 13, 25])","language":"Python","predicted_output":"[True, True, False, True, True, True]"} |
| {"id":"cmsshzf3200bqjmp2yddnr01j","kind":"contributor_item","title":"Submission DNR01J","provisional":false,"code":"def flatten_nested(data, depth=0):\n result = []\n for item in data:\n if isinstance(item, list) and depth < 2:\n result.extend(flatten_nested(item, depth + 1))\n else:\n result.append(item)\n return result","input":"flatten_nested([1, [2, 3, [4, [5, 6]]], 7, [8]])","language":"Python","predicted_output":"[1, 2, 3, 4, [5, 6], 7, 8]"} |
| {"id":"cmsshzf3300bujmp2rc52bm9l","kind":"contributor_item","title":"Submission 52BM9L","provisional":false,"code":"def matrix_transpose_and_sum(matrix):\n transposed = list(zip(*matrix))\n row_sums = [sum(row) for row in transposed]\n return transposed, row_sums","input":"matrix_transpose_and_sum([[1, 2, 3], [4, 5, 6]])","language":"Python","predicted_output":"([(1, 4), (2, 5), (3, 6)], [5, 7, 9])"} |
| {"id":"cmsshzf3300bvjmp2jhqmnf7o","kind":"contributor_item","title":"Submission QMNF7O","provisional":false,"code":"def parse_kv_config(text):\n config = {}\n for line in text.strip().split('\\n'):\n line = line.strip()\n if not line or line.startswith('#'):\n continue\n if '=' not in line:\n raise ValueError(f'bad line: {line}')\n k, v = line.split('=', 1)\n k, v = k.strip(), v.strip()\n if v.isdigit():\n v = int(v)\n elif v in ('true', 'false'):\n v = v == 'true'\n config[k] = v\n return config","input":"parse_kv_config('# config\\nhost = localhost\\nport=8080\\ndebug=true\\n\\nretries = 3')","language":"Python","predicted_output":"{'host': 'localhost', 'port': 8080, 'debug': True, 'retries': 3}"} |
| {"id":"cmsshzf3300c1jmp2kthupyjq","kind":"contributor_item","title":"Submission HUPYJQ","provisional":false,"code":"def binary_search_insert_position(sorted_list, targets):\n import bisect\n return [bisect.bisect_left(sorted_list, t) for t in targets]","input":"binary_search_insert_position([1, 3, 5, 7, 9, 11], [0, 4, 5, 12, 8])","language":"Python","predicted_output":"[0, 2, 2, 6, 4]"} |
| {"id":"cmsshzf3300c2jmp2139cqdf8","kind":"contributor_item","title":"Submission 9CQDF8","provisional":false,"code":"def context_manager_log():\n log = []\n\n class Timer:\n def __init__(self, name):\n self.name = name\n def __enter__(self):\n log.append(f'enter:{self.name}')\n return self\n def __exit__(self, exc_type, exc_val, exc_tb):\n log.append(f'exit:{self.name}')\n return exc_type is ValueError\n\n with Timer('a'):\n log.append('inside_a')\n try:\n with Timer('b'):\n log.append('inside_b')\n raise ValueError('boom')\n except ValueError:\n log.append('caught_outside')\n return log","input":"context_manager_log()","language":"Python","predicted_output":"['enter:a', 'inside_a', 'exit:a', 'enter:b', 'inside_b', 'exit:b']"} |
| {"id":"cmsshzf3300bzjmp21oo82fux","kind":"contributor_item","title":"Submission O82FUX","provisional":false,"code":"def dedupe_preserve_order_with_key(items, key):\n seen = set()\n result = []\n for item in items:\n k = key(item)\n if k not in seen:\n seen.add(k)\n result.append(item)\n return result\n\ndef dedupe_by_id(items):\n return dedupe_preserve_order_with_key(items, lambda d: d['id'])","input":"dedupe_by_id([{'id': 1, 'v': 'a'}, {'id': 2, 'v': 'b'}, {'id': 1, 'v': 'c'}])","language":"Python","predicted_output":"[{'id': 1, 'v': 'a'}, {'id': 2, 'v': 'b'}]"} |
| {"id":"cmsshzf3300brjmp25ku495m8","kind":"contributor_item","title":"Submission U495M8","provisional":false,"code":"def group_anagrams(words):\n groups = {}\n for w in words:\n key = ''.join(sorted(w))\n groups.setdefault(key, []).append(w)\n return sorted(groups.values(), key=lambda g: (-len(g), g[0]))","input":"group_anagrams(['eat', 'tea', 'tan', 'ate', 'nat', 'bat'])","language":"Python","predicted_output":"[['eat', 'tea', 'ate'], ['tan', 'nat'], ['bat']]"} |
| {"id":"cmsshzf3300bsjmp2mnt4tg5r","kind":"contributor_item","title":"Submission T4TG5R","provisional":false,"code":"def sliding_window_max(nums, k):\n from collections import deque\n dq = deque()\n result = []\n for i, n in enumerate(nums):\n while dq and nums[dq[-1]] <= n:\n dq.pop()\n dq.append(i)\n if dq[0] <= i - k:\n dq.popleft()\n if i >= k - 1:\n result.append(nums[dq[0]])\n return result","input":"sliding_window_max([1, 3, -1, -3, 5, 3, 6, 7], 3)","language":"Python","predicted_output":"[3, 3, 5, 5, 6, 7]"} |
| {"id":"cmsshzf3300bwjmp24h0r63l9","kind":"contributor_item","title":"Submission 0R63L9","provisional":false,"code":"def decorator_call_counter():\n calls = {}\n def decorator(fn):\n def wrapper(*args):\n calls[fn.__name__] = calls.get(fn.__name__, 0) + 1\n return fn(*args)\n return wrapper\n return decorator, calls\n\ndef build():\n dec, calls = decorator_call_counter()\n\n @dec\n def add(a, b):\n return a + b\n\n results = [add(1, 2), add(3, 4), add(5, 6)]\n return results, calls","input":"build()","language":"Python","predicted_output":"([3, 7, 11], {'add': 3})"} |
| {"id":"cmsshzf3300c3jmp2umrfq2xl","kind":"contributor_item","title":"Submission RFQ2XL","provisional":false,"code":"def multi_key_sort_with_ties(records):\n return sorted(records, key=lambda r: (-r['score'], r['name']))","input":"multi_key_sort_with_ties([{'name': 'bob', 'score': 90}, {'name': 'amy', 'score': 90}, {'name': 'cid', 'score': 95}, {'name': 'ann', 'score': 90}])","language":"Python","predicted_output":"[{'name': 'cid', 'score': 95}, {'name': 'amy', 'score': 90}, {'name': 'ann', 'score': 90}, {'name': 'bob', 'score': 90}]"} |
| {"id":"cmsshzf3300bxjmp2jfcuteta","kind":"contributor_item","title":"Submission CUTETA","provisional":false,"code":"def bracket_validity_stack(s):\n pairs = {')': '(', ']': '[', '}': '{'}\n stack = []\n for ch in s:\n if ch in '([{':\n stack.append(ch)\n elif ch in ')]}':\n if not stack or stack.pop() != pairs[ch]:\n return False\n return not stack\n\ndef check_all(strings):\n return [bracket_validity_stack(s) for s in strings]","input":"check_all(['(a[b]{c})', '([)]', '((()))', '{[()]}('])","language":"Python","predicted_output":"[True, False, True, False]"} |
| {"id":"cmsshzf3300c0jmp2z1klnw2h","kind":"contributor_item","title":"Submission KLNW2H","provisional":false,"code":"def custom_exception_chain():\n class ValidationError(Exception):\n pass\n\n def validate(age):\n if age < 0:\n raise ValidationError('negative age')\n if age > 150:\n raise ValidationError('unrealistic age')\n return age\n\n results = []\n for age in [25, -5, 200, 40]:\n try:\n results.append(validate(age))\n except ValidationError as e:\n results.append(str(e))\n return results","input":"custom_exception_chain()","language":"Python","predicted_output":"[25, 'negative age', 'unrealistic age', 40]"} |
| {"id":"cmsshzf3300byjmp22g0rf2od","kind":"contributor_item","title":"Submission 0RF2OD","provisional":false,"code":"def generator_chain(n):\n def evens():\n for i in range(n):\n if i % 2 == 0:\n yield i\n def squares(gen):\n for v in gen:\n yield v * v\n return list(squares(evens()))","input":"generator_chain(10)","language":"Python","predicted_output":"[0, 4, 16, 36, 64]"} |
| {"id":"cmssiaa5l00fhjmp280gd7npi","kind":"contributor_item","title":"Submission GD7NPI","provisional":false,"code":"class Point:\n def __init__(self, x, y):\n self.x = x\n self.y = y\n def __eq__(self, other):\n return isinstance(other, Point) and self.x == other.x and self.y == other.y\n def __hash__(self):\n return hash((self.x, self.y))\n def __repr__(self):\n return f\"Point({self.x},{self.y})\"\n\ndef dedupe_points(points):\n return sorted(set(points), key=lambda p: (p.x, p.y))","input":"dedupe_points([Point(1,2), Point(3,4), Point(1,2), Point(0,0), Point(3,4)])","language":"Python","predicted_output":"[Point(0,0), Point(1,2), Point(3,4)]"} |
| {"id":"cmssibcce00fijmp25knukchb","kind":"contributor_item","title":"Submission NUKCHB","provisional":false,"code":"def countdown(n):\n while n > 0:\n yield n\n n -= 1\n\ndef take_then_check(n, k):\n gen = countdown(n)\n taken = []\n exhausted_early = False\n for _ in range(k):\n try:\n taken.append(next(gen))\n except StopIteration:\n exhausted_early = True\n break\n remaining = list(gen)\n return taken, remaining, exhausted_early","input":"take_then_check(3, 5)","language":"Python","predicted_output":"([3, 2, 1], [], True)"} |
| {"id":"cmssic2tm00fjjmp2sjbrdya3","kind":"contributor_item","title":"Submission BRDYA3","provisional":false,"code":"def classify(n):\n log = []\n try:\n if n == 0:\n raise ZeroDivisionError(\"zero\")\n result = 100 / n\n except ZeroDivisionError as e:\n log.append(f\"error:{e}\")\n result = None\n else:\n log.append(\"no-error\")\n finally:\n log.append(\"done\")\n return result, log","input":"classify(0)","language":"Python","predicted_output":"(None, ['error:zero', 'done'])"} |
| {"id":"cmssidxll00g7jmp22qtwjnjr","kind":"contributor_item","title":"Submission TWJNJR","provisional":false,"code":"from functools import lru_cache\n\n@lru_cache(maxsize=None)\ndef num_ways(n):\n if n < 0:\n return 0\n if n == 0:\n return 1\n return num_ways(n - 1) + num_ways(n - 2) + num_ways(n - 3)","input":"tuple(num_ways(i) for i in range(7))","language":"Python","predicted_output":"(1, 1, 2, 4, 7, 13, 24)"} |
| {"id":"cmssidxll00g9jmp2gbetuiq4","kind":"contributor_item","title":"Submission ETUIQ4","provisional":false,"code":"def rank_scores(entries):\n return sorted(entries, key=lambda e: (-e[1], e[0]))","input":"rank_scores([(\"bob\", 90), (\"amy\", 95), (\"cid\", 90), (\"dee\", 95), (\"al\", 90)])","language":"Python","predicted_output":"[('amy', 95), ('dee', 95), ('al', 90), ('bob', 90), ('cid', 90)]"} |
| {"id":"cmssidxll00gcjmp2f0539elq","kind":"contributor_item","title":"Submission 539ELQ","provisional":false,"code":"import functools\n\ndef count_calls(func):\n @functools.wraps(func)\n def wrapper(*args, **kwargs):\n wrapper.calls += 1\n return func(*args, **kwargs)\n wrapper.calls = 0\n return wrapper\n\n@count_calls\ndef square(x):\n return x * x","input":"([square(x) for x in range(4)], square.calls, square.__name__)","language":"Python","predicted_output":"([0, 1, 4, 9], 4, 'square')"} |
| {"id":"cmssidxll00gajmp2rvt5ru5a","kind":"contributor_item","title":"Submission T5RU5A","provisional":false,"code":"def accumulate(value, bucket=[]):\n bucket.append(value)\n return bucket","input":"(accumulate(1), accumulate(2), accumulate(3, []))","language":"Python","predicted_output":"([1, 2], [1, 2], [3])"} |
| {"id":"cmssidxll00gbjmp26857gtmw","kind":"contributor_item","title":"Submission 57GTMW","provisional":false,"code":"class SuppressValueError:\n def __enter__(self):\n return self\n def __exit__(self, exc_type, exc_val, exc_tb):\n return exc_type is ValueError\n\ndef run_with_suppress():\n log = []\n with SuppressValueError():\n log.append(\"before\")\n raise ValueError(\"bad\")\n log.append(\"never\")\n log.append(\"after\")\n return log","input":"run_with_suppress()","language":"Python","predicted_output":"['before', 'after']"} |
| {"id":"cmssidxll00gejmp2ohvqbll5","kind":"contributor_item","title":"Submission VQBLL5","provisional":false,"code":"from collections import namedtuple\n\nEmployee = namedtuple(\"Employee\", [\"name\", \"salary\", \"dept\"])\n\ndef raise_salaries(employees, pct):\n return [e._replace(salary=round(e.salary * (1 + pct), 2)) for e in employees]","input":"raise_salaries([Employee(\"Ann\", 50000, \"Eng\"), Employee(\"Bo\", 60000, \"Sales\")], 0.1)","language":"Python","predicted_output":"[Employee(name='Ann', salary=55000.0, dept='Eng'), Employee(name='Bo', salary=66000.0, dept='Sales')]"} |
| {"id":"cmssidxll00ghjmp2mh8xk9cs","kind":"contributor_item","title":"Submission 8XK9CS","provisional":false,"code":"def transform(seq):\n reversed_seq = seq[::-1]\n every_other = seq[1::2]\n middle_out = seq[len(seq)//4 : -(len(seq)//4)] if len(seq) >= 4 else seq\n return reversed_seq, every_other, middle_out","input":"transform([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])","language":"Python","predicted_output":"([9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [1, 3, 5, 7, 9], [2, 3, 4, 5, 6, 7])"} |
| {"id":"cmssidxll00gljmp2dp2unqxg","kind":"contributor_item","title":"Submission 2UNQXG","provisional":false,"code":"import heapq\nimport bisect\n\ndef k_smallest_and_rank(values, k, target):\n smallest = heapq.nsmallest(k, values)\n sorted_vals = sorted(values)\n rank = bisect.bisect_left(sorted_vals, target)\n return smallest, rank","input":"k_smallest_and_rank([9, 3, 7, 1, 5, 2], 3, 5)","language":"Python","predicted_output":"([1, 2, 3], 3)"} |
| {"id":"cmssidxll00g6jmp2su60wlfg","kind":"contributor_item","title":"Submission 60WLFG","provisional":false,"code":"def word_stats(words):\n lengths = {w: len(w) for w in words if not w.startswith(\"_\")}\n unique_lengths = {len(w) for w in words if len(w) > 2}\n return lengths, sorted(unique_lengths)","input":"word_stats([\"hi\", \"_skip\", \"hello\", \"ok\", \"world\", \"_x\"])","language":"Python","predicted_output":"({'hi': 2, 'hello': 5, 'ok': 2, 'world': 5}, [5])"} |
| {"id":"cmssidxll00gijmp270pxaguh","kind":"contributor_item","title":"Submission PXAGUH","provisional":false,"code":"def make_multipliers_bad():\n return [lambda x: x * i for i in range(3)]\n\ndef make_multipliers_fixed():\n return [lambda x, i=i: x * i for i in range(3)]\n\ndef apply_all(funcs, x):\n return [f(x) for f in funcs]","input":"(apply_all(make_multipliers_bad(), 10), apply_all(make_multipliers_fixed(), 10))","language":"Python","predicted_output":"([20, 20, 20], [0, 10, 20])"} |
| {"id":"cmssidxll00g8jmp225vepn84","kind":"contributor_item","title":"Submission VEPN84","provisional":false,"code":"import itertools\n\ndef group_consecutive(values):\n result = []\n for key, group in itertools.groupby(values):\n result.append((key, len(list(group))))\n return result","input":"group_consecutive([1, 1, 2, 2, 2, 1, 3, 3])","language":"Python","predicted_output":"[(1, 2), (2, 3), (1, 1), (3, 2)]"} |
| {"id":"cmssidxll00gdjmp2xoat1j3x","kind":"contributor_item","title":"Submission AT1J3X","provisional":false,"code":"class Temperature:\n def __init__(self, celsius):\n self._celsius = celsius\n\n @property\n def celsius(self):\n return self._celsius\n\n @celsius.setter\n def celsius(self, value):\n if value < -273.15:\n raise ValueError(\"too cold\")\n self._celsius = value\n\n @property\n def fahrenheit(self):\n return self._celsius * 9 / 5 + 32\n\ndef adjust(temp_c, delta):\n t = Temperature(temp_c)\n try:\n t.celsius += delta\n return round(t.fahrenheit, 2)\n except ValueError:\n return \"invalid\"","input":"(adjust(20, 5), adjust(-270, -10))","language":"Python","predicted_output":"(77.0, 'invalid')"} |
| {"id":"cmssidxll00ggjmp2dwwom0bh","kind":"contributor_item","title":"Submission WOM0BH","provisional":false,"code":"def parse_int(s):\n try:\n return int(s)\n except ValueError as e:\n raise RuntimeError(f\"bad value: {s}\") from e\n\ndef safe_parse(values):\n results = []\n for v in values:\n try:\n results.append(parse_int(v))\n except RuntimeError as e:\n results.append((str(e), type(e.__cause__).__name__))\n return results","input":"safe_parse([\"12\", \"abc\", \"-5\"])","language":"Python","predicted_output":"[12, ('bad value: abc', 'ValueError'), -5]"} |
| {"id":"cmssidxll00gjjmp2n8e4y8nd","kind":"contributor_item","title":"Submission E4Y8ND","provisional":false,"code":"class Vector:\n def __init__(self, x, y):\n self.x, self.y = x, y\n def __add__(self, other):\n if isinstance(other, Vector):\n return Vector(self.x + other.x, self.y + other.y)\n return NotImplemented\n def __radd__(self, other):\n if other == 0:\n return self\n return self.__add__(other)\n def __repr__(self):\n return f\"Vector({self.x},{self.y})\"\n\ndef total(vectors):\n return sum(vectors, start=0)","input":"total([Vector(1,2), Vector(3,4), Vector(-1,1)])","language":"Python","predicted_output":"Vector(3,7)"} |
| {"id":"cmssidxll00gkjmp2zacjhucf","kind":"contributor_item","title":"Submission CJHUCF","provisional":false,"code":"def merge_records(records):\n merged = {}\n for r in records:\n key = r[\"id\"]\n if key not in merged:\n merged[key] = {\"id\": key, \"tags\": set(), \"total\": 0}\n merged[key][\"tags\"].update(r.get(\"tags\", []))\n merged[key][\"total\"] += r.get(\"amount\", 0)\n return [\n {\"id\": k, \"tags\": sorted(v[\"tags\"]), \"total\": v[\"total\"]}\n for k, v in sorted(merged.items())\n ]","input":"merge_records([{\"id\": 1, \"tags\": [\"a\",\"b\"], \"amount\": 10}, {\"id\": 2, \"tags\": [\"c\"], \"amount\": 5}, {\"id\": 1, \"tags\": [\"b\",\"d\"], \"amount\": 7}])","language":"Python","predicted_output":"[{'id': 1, 'tags': ['a', 'b', 'd'], 'total': 17}, {'id': 2, 'tags': ['c'], 'total': 5}]"} |
| {"id":"cmssijdp000grjmp2a8sjpjdk","kind":"contributor_item","title":"Submission SJPJDK","provisional":false,"code":"from collections import deque\n\ndef process(items, maxlen):\n d = deque(items, maxlen=maxlen)\n d.rotate(2)\n d.append(99)\n d.rotate(-1)\n return list(d)","input":"process([1,2,3,4,5], 4)","language":"Python","predicted_output":"[2, 3, 99, 5]"} |
| {"id":"cmssijdp000h1jmp2ug8w4gr7","kind":"contributor_item","title":"Submission 8W4GR7","provisional":false,"code":"def stable_sort(records):\n return sorted(records, key=lambda r: r[0])","input":"stable_sort([(1,'a'), (2,'b'), (1,'c'), (2,'d'), (1,'e')])","language":"Python","predicted_output":"[(1, 'a'), (1, 'c'), (1, 'e'), (2, 'b'), (2, 'd')]"} |
| {"id":"cmssijdp000h2jmp2l6zyvovj","kind":"contributor_item","title":"Submission ZYVOVJ","provisional":false,"code":"def roundtrip(s):\n encoded = s.encode('utf-8')\n b = bytearray(encoded)\n b[0] = ord('X') if b else 0\n try:\n decoded = bytes(b).decode('utf-8')\n except UnicodeDecodeError as e:\n decoded = f\"error: {e}\"\n return (encoded, decoded)","input":"roundtrip('café')","language":"Python","predicted_output":"(b'caf\\xc3\\xa9', 'Xafé')"} |
| {"id":"cmssijdp000gpjmp2xddgd3py","kind":"contributor_item","title":"Submission DGD3PY","provisional":false,"code":"import weakref\n\nclass Widget:\n def __init__(self, name):\n self.name = name\n\ndef track():\n w = Widget(\"gadget\")\n ref = weakref.ref(w)\n alive_before = ref() is not None\n name_before = ref().name\n del w\n alive_after = ref() is not None\n return (alive_before, name_before, alive_after)","input":"track()","language":"Python","predicted_output":"(True, 'gadget', False)"} |
| {"id":"cmssijdp000gvjmp2mf4qt93p","kind":"contributor_item","title":"Submission 4QT93P","provisional":false,"code":"import itertools\n\ndef combine(a, b):\n chained = list(itertools.chain(a, b))\n it1, it2 = itertools.tee(chained, 2)\n first_two = [next(it1), next(it1)]\n all_from_it2 = list(it2)\n return (first_two, all_from_it2)","input":"combine([1,2], [3,4,5])","language":"Python","predicted_output":"([1, 2], [1, 2, 3, 4, 5])"} |
| {"id":"cmssijdp000gmjmp2guwofbv0","kind":"contributor_item","title":"Submission WOFBV0","provisional":false,"code":"from dataclasses import dataclass, field\n\n@dataclass(frozen=True)\nclass Point:\n x: float\n y: float\n norm: float = field(init=False)\n\n def __post_init__(self):\n object.__setattr__(self, \"norm\", (self.x**2 + self.y**2) ** 0.5)\n\ndef make_and_try_mutate(x, y):\n p = Point(x, y)\n try:\n p.x = 100\n except Exception as e:\n return (p, type(e).__name__)\n return (p, None)","input":"make_and_try_mutate(3, 4)","language":"Python","predicted_output":"(Point(x=3, y=4, norm=5.0), 'FrozenInstanceError')"} |
| {"id":"cmssijdp000gojmp2copqdqq9","kind":"contributor_item","title":"Submission PQDQQ9","provisional":false,"code":"import contextvars\n\nctx_var = contextvars.ContextVar(\"ctx_var\", default=\"default\")\n\ndef show():\n return ctx_var.get()\n\ndef run():\n results = []\n results.append(show())\n token = ctx_var.set(\"outer\")\n results.append(show())\n ctx = contextvars.copy_context()\n def inner():\n ctx_var.set(\"inner\")\n return show()\n results.append(ctx.run(inner))\n results.append(show())\n ctx_var.reset(token)\n results.append(show())\n return results","input":"run()","language":"Python","predicted_output":"['default', 'outer', 'inner', 'outer', 'default']"} |
| {"id":"cmssijdp000gnjmp2ti0g2pr6","kind":"contributor_item","title":"Submission 0G2PR6","provisional":false,"code":"from enum import Enum\n\nclass Direction(Enum):\n NORTH = (0, 1)\n EAST = (1, 0)\n SOUTH = (0, -1)\n WEST = (-1, 0)\n\n def opposite(self):\n mapping = {\n Direction.NORTH: Direction.SOUTH,\n Direction.SOUTH: Direction.NORTH,\n Direction.EAST: Direction.WEST,\n Direction.WEST: Direction.EAST,\n }\n return mapping[self]\n\ndef describe(d):\n return (d.name, d.value, d.opposite().name)","input":"describe(Direction.EAST)","language":"Python","predicted_output":"('EAST', (1, 0), 'WEST')"} |
| {"id":"cmssijdp000gtjmp2gzmmqdoo","kind":"contributor_item","title":"Submission MMQDOO","provisional":false,"code":"class A:\n def greet(self):\n return \"A\"\n\nclass B(A):\n def greet(self):\n return \"B->\" + super().greet()\n\nclass C(A):\n def greet(self):\n return \"C->\" + super().greet()\n\nclass D(B, C):\n def greet(self):\n return \"D->\" + super().greet()\n\ndef run():\n d = D()\n return (d.greet(), [c.__name__ for c in D.__mro__])","input":"run()","language":"Python","predicted_output":"('D->B->C->A', ['D', 'B', 'C', 'A', 'object'])"} |
| {"id":"cmssijdp000h0jmp2lajbx4c7","kind":"contributor_item","title":"Submission JBX4C7","provisional":false,"code":"def build_counts(words):\n counts_get = {}\n counts_setdefault = {}\n calls = []\n for w in words:\n counts_setdefault.setdefault(w, []).append(1)\n val = counts_get.get(w, [])\n val.append(1)\n counts_get[w] = val\n return (counts_setdefault, counts_get)","input":"build_counts(['a','b','a','a'])","language":"Python","predicted_output":"({'a': [1, 1, 1], 'b': [1]}, {'a': [1, 1, 1], 'b': [1]})"} |
| {"id":"cmssijdp000gzjmp2ajjjg2ad","kind":"contributor_item","title":"Submission JJG2AD","provisional":false,"code":"def risky():\n try:\n raise ValueError(\"original\")\n finally:\n raise RuntimeError(\"from finally\")\n\ndef run():\n try:\n risky()\n except Exception as e:\n return (type(e).__name__, str(e))","input":"run()","language":"Python","predicted_output":"('RuntimeError', 'from finally')"} |
| {"id":"cmssijdp000h3jmp21yxf8xha","kind":"contributor_item","title":"Submission XF8XHA","provisional":false,"code":"def flatten(items, _seen=None):\n if _seen is None:\n _seen = set()\n result = []\n for item in items:\n if isinstance(item, list):\n result.extend(flatten(item, _seen))\n else:\n if id(item) not in _seen:\n _seen.add(id(item))\n result.append(item)\n return result\n\ndef run():\n first = flatten([1, [2, 3], [4, [5, 6]]])\n second = flatten([7, 8])\n return (first, second)","input":"run()","language":"Python","predicted_output":"([1, 2, 3, 4, 5, 6], [7, 8])"} |
| {"id":"cmssijdp000gyjmp21r1ijdf9","kind":"contributor_item","title":"Submission 1IJDF9","provisional":false,"code":"class Countdown:\n def __init__(self, start):\n self.start = start\n self.current = start\n\n def __iter__(self):\n return self\n\n def __next__(self):\n if self.current <= 0:\n raise StopIteration\n self.current -= 1\n return self.current + 1\n\ndef run(n):\n cd = Countdown(n)\n return list(cd) + list(cd)","input":"run(3)","language":"Python","predicted_output":"[3, 2, 1]"} |
| {"id":"cmssijdp000h5jmp2vcyy6170","kind":"contributor_item","title":"Submission YY6170","provisional":false,"code":"from itertools import zip_longest\n\ndef combine(a, b, c):\n short = list(zip(a, b, c))\n long_ = list(zip_longest(a, b, c, fillvalue=-1))\n return (short, long_)","input":"combine([1,2,3], [4,5], [6,7,8,9])","language":"Python","predicted_output":"([(1, 4, 6), (2, 5, 7)], [(1, 4, 6), (2, 5, 7), (3, -1, 8), (-1, -1, 9)])"} |
| {"id":"cmssijdp000h4jmp24fm31o51","kind":"contributor_item","title":"Submission M31O51","provisional":false,"code":"from functools import total_ordering\n\n@total_ordering\nclass Version:\n def __init__(self, major, minor):\n self.major = major\n self.minor = minor\n\n def __eq__(self, other):\n return (self.major, self.minor) == (other.major, other.minor)\n\n def __lt__(self, other):\n return (self.major, self.minor) < (other.major, other.minor)\n\n def __repr__(self):\n return f\"Version({self.major},{self.minor})\"\n\ndef compare(a, b):\n v1 = Version(*a)\n v2 = Version(*b)\n return (v1 < v2, v1 <= v2, v1 > v2, v1 >= v2, v1 == v2)","input":"compare((1,5), (1,10))","language":"Python","predicted_output":"(True, True, False, False, False)"} |
| {"id":"cmssipppu00mgjmp2njviof6s","kind":"contributor_item","title":"Submission VIOF6S","provisional":false,"code":"def safe_double(x):\n try:\n return x * 2\n except TypeError:\n return None","input":"safe_double(21)","language":"Python","predicted_output":"42"} |
| {"id":"cmssiq5hj00mmjmp234vuk15d","kind":"contributor_item","title":"Submission VUK15D","provisional":false,"code":"def fib_memo(n, memo=None):\n if memo is None:\n memo = {}\n if n in memo:\n return memo[n]\n if n <= 1:\n return n\n memo[n] = fib_memo(n - 1, memo) + fib_memo(n - 2, memo)\n return memo[n]","input":"(fib_memo(10), fib_memo(7))","language":"Python","predicted_output":"(55, 13)"} |
| {"id":"cmssiqlto00mzjmp24r153bpu","kind":"contributor_item","title":"Submission 153BPU","provisional":false,"code":"def process(vals):\n results = []\n for v in vals:\n try:\n if v < 0:\n raise ValueError('negative')\n results.append(10 // v)\n except ZeroDivisionError:\n results.append(None)\n except ValueError:\n results.append(-1)\n finally:\n results.append('done')\n return results","input":"process([2, 0, -1, 5])","language":"Python","predicted_output":"[5, 'done', None, 'done', -1, 'done', 2, 'done']"} |
| {"id":"cmssiqlto00mxjmp2mqoxfeli","kind":"contributor_item","title":"Submission OXFELI","provisional":false,"code":"def apply_counter_sequence(steps):\n count = 0\n def increment(step):\n nonlocal count\n count += step\n return count\n return [increment(s) for s in steps]","input":"apply_counter_sequence([1, 2, 3])","language":"Python","predicted_output":"[1, 3, 6]"} |
| {"id":"cmssiqlto00myjmp2etkghbbm","kind":"contributor_item","title":"Submission KGHBBM","provisional":false,"code":"def flatten_unique(nested):\n seen = set()\n result = []\n for group in nested:\n for item in group:\n if item not in seen:\n seen.add(item)\n result.append(item)\n return result","input":"flatten_unique([[1, 2, 2], [3, 1], [4]])","language":"Python","predicted_output":"[1, 2, 3, 4]"} |
| {"id":"cmssiqlto00n0jmp2l99k26ys","kind":"contributor_item","title":"Submission 9K26YS","provisional":false,"code":"def word_frequency_rank(text):\n freq = {}\n for word in text.split():\n freq[word] = freq.get(word, 0) + 1\n return sorted(freq.items(), key=lambda kv: (-kv[1], kv[0]))","input":"word_frequency_rank('the cat sat on the mat the cat ran')","language":"Python","predicted_output":"[('the', 3), ('cat', 2), ('mat', 1), ('on', 1), ('ran', 1), ('sat', 1)]"} |
| {"id":"cmssiquuo00n1jmp244ptx9mm","kind":"contributor_item","title":"Submission PTX9MM","provisional":false,"code":"def rank_scores(entries):\n ordered = sorted(entries, key=lambda kv: (-kv[1], kv[0]))\n ranks = {}\n previous = None\n position = 0\n for index, (name, score) in enumerate(ordered, start=1):\n if score != previous:\n position = index\n previous = score\n ranks[name] = position\n return ranks","input":"rank_scores([(\"ivy\", 70), (\"abe\", 90), (\"hal\", 70), (\"gus\", 90)])","language":"Python","predicted_output":"{'abe': 1, 'gus': 1, 'hal': 3, 'ivy': 3}"} |
| {"id":"cmssiquuo00n2jmp2533fu995","kind":"contributor_item","title":"Submission 3FU995","provisional":false,"code":"def resolve(values, key):\n log = []\n try:\n log.append(\"lookup\")\n return values[key]\n except KeyError:\n log.append(\"missing\")\n return None\n finally:\n log.append(\"cleanup\")\n if len(log) == 3:\n return tuple(log)","input":"(resolve({\"a\": 1}, \"a\"), resolve({\"a\": 1}, \"z\"))","language":"Python","predicted_output":"(1, ('lookup', 'missing', 'cleanup'))"} |
| {"id":"cmssiquuo00n3jmp2oj6v04st","kind":"contributor_item","title":"Submission 6V04ST","provisional":false,"code":"import copy\n\ndef apply_patch(rows):\n shallow = rows.copy()\n deep = copy.deepcopy(rows)\n shallow[0].append(\"s\")\n deep[0].append(\"d\")\n shallow.append([\"new\"])\n return (rows, deep, len(shallow), len(rows))","input":"apply_patch([[\"x\"], [\"y\"]])","language":"Python","predicted_output":"([['x', 's'], ['y']], [['x', 'd'], ['y']], 3, 2)"} |
| {"id":"cmssiquuo00n4jmp2y884dqan","kind":"contributor_item","title":"Submission 84DQAN","provisional":false,"code":"def summarize(readings):\n total = sum(readings)\n rounded = [round(value, 1) for value in readings]\n return {\n \"total\": total,\n \"rounded\": rounded,\n \"halves\": [round(value) for value in (0.5, 1.5, 2.5, 3.5)],\n \"exact\": total == 0.6,\n }","input":"summarize([0.1, 0.2, 0.15, 0.25])","language":"Python","predicted_output":"{'total': 0.7, 'rounded': [0.1, 0.2, 0.1, 0.2], 'halves': [0, 2, 2, 4], 'exact': False}"} |
| {"id":"cmssiquuo00n5jmp2negnwm5u","kind":"contributor_item","title":"Submission GNWM5U","provisional":false,"code":"def collect(item, bucket=[]):\n bucket.append(item)\n return list(bucket)\n\ndef collect_safe(item, bucket=None):\n if bucket is None:\n bucket = []\n bucket.append(item)\n return bucket","input":"(collect(\"a\"), collect(\"b\"), collect_safe(\"a\"), collect_safe(\"b\"))","language":"Python","predicted_output":"(['a'], ['a', 'b'], ['a'], ['b'])"} |
| {"id":"cmssis20b00nqjmp2wzy04ot3","kind":"contributor_item","title":"Submission Y04OT3","provisional":false,"code":"def count_chars(s):\n freq = {}\n for c in s:\n freq[c] = freq.get(c, 0) + 1\n return freq\n","input":"count_chars('mississippi')","language":"Python","predicted_output":"{'m': 1, 'i': 4, 's': 4, 'p': 2}"} |
| {"id":"cmssis20b00nsjmp2pia73jk4","kind":"contributor_item","title":"Submission A73JK4","provisional":false,"code":"def pascal_row(n):\n row = [1]\n for i in range(1, n + 1):\n row.append(row[-1] * (n - i + 1) // i)\n return row\n","input":"pascal_row(5)","language":"Python","predicted_output":"[1, 5, 10, 10, 5, 1]"} |
| {"id":"cmssis20b00ntjmp25n4rakt7","kind":"contributor_item","title":"Submission 4RAKT7","provisional":false,"code":"def chunk(lst, size):\n return [lst[i:i+size] for i in range(0, len(lst), size)]\n","input":"chunk([1, 2, 3, 4, 5, 6, 7], 3)","language":"Python","predicted_output":"[[1, 2, 3], [4, 5, 6], [7]]"} |
| {"id":"cmssis20b00nujmp2ieotj4ib","kind":"contributor_item","title":"Submission OTJ4IB","provisional":false,"code":"def safe_div(a, b):\n try:\n return a / b\n except ZeroDivisionError:\n return None\n","input":"(safe_div(10, 4), safe_div(7, 0))","language":"Python","predicted_output":"(2.5, None)"} |
| {"id":"cmssizqrl00pmjmp2vwp04cuz","kind":"contributor_item","title":"Submission P04CUZ","provisional":false,"code":"def running_sum(nums):\n total = 0\n result = []\n for n in nums:\n total += n\n result.append(total)\n return result\n","input":"running_sum([1, 2, 3, 4, 5])","language":"Python","predicted_output":"[1, 3, 6, 10, 15]"} |
| {"id":"cmssjh8zc00qvjmp2bob2cny3","kind":"contributor_item","title":"Submission B2CNY3","provisional":false,"code":"def local_peaks(values):\n return [(i, values[i]) for i in range(1, len(values)-1) if values[i] > values[i-1] and values[i] >= values[i+1]]","input":"local_peaks([1,4,4,2,5,3,3])","language":"Python","predicted_output":"[(1, 4), (4, 5)]"} |
| {"id":"cmssjh8zc00r1jmp2fe8qcdsq","kind":"contributor_item","title":"Submission 8QCDSQ","provisional":false,"code":"from itertools import groupby\ndef summarize_signs(values):\n key = lambda x: 'pos' if x > 0 else ('neg' if x < 0 else 'zero')\n return [(k, sum(1 for _ in g)) for k, g in groupby(values, key)]","input":"summarize_signs([2,1,0,0,-1,-3,4,-2])","language":"Python","predicted_output":"[('pos', 2), ('zero', 2), ('neg', 2), ('pos', 1), ('neg', 1)]"} |
| {"id":"cmssjh8zc00rsjmp2e5k2ffej","kind":"contributor_item","title":"Submission K2FFEJ","provisional":false,"code":"import statistics\ndef robust_summary(values):\n q = statistics.quantiles(values, n=4, method='inclusive')\n return statistics.median(values), q[0], q[2], round(statistics.pstdev(values), 3)","input":"robust_summary([2,4,4,4,5,5,7,9])","language":"Python","predicted_output":"(4.5, 4.0, 5.5, 2.0)"} |
| {"id":"cmssjh8zc00qwjmp2bqjh66ge","kind":"contributor_item","title":"Submission JH66GE","provisional":false,"code":"from collections import Counter\ndef multiset_delta(left, right):\n a, b = Counter(left), Counter(right)\n return sorted((a-b).elements()), sorted((b-a).elements())","input":"multiset_delta('mississippi', 'impossible')","language":"Python","predicted_output":"(['i', 'i', 'p', 's', 's'], ['b', 'e', 'l', 'o'])"} |
| {"id":"cmssjh8zc00r3jmp2uqyvuenq","kind":"contributor_item","title":"Submission YVUENQ","provisional":false,"code":"from functools import reduce\ndef compose_steps(value, steps):\n return reduce(lambda current, step: step(current), steps, value)","input":"compose_steps(3, [lambda x:x+4, lambda x:x*x, lambda x:x-5])","language":"Python","predicted_output":"44"} |
| {"id":"cmssjh8zc00rbjmp2oj9jvk1a","kind":"contributor_item","title":"Submission 9JVK1A","provisional":false,"code":"class Ledger:\n def __init__(self): self.entries = []\n def add(self, amount): self.entries.append(amount); return self\n @property\n def balance(self): return sum(self.entries)\n def __repr__(self): return f'Ledger({self.entries!r}, balance={self.balance})' ","input":"Ledger().add(10).add(-3).add(5)","language":"Python","predicted_output":"Ledger([10, -3, 5], balance=12)"} |
| {"id":"cmssjh8zc00rqjmp2g7uruy98","kind":"contributor_item","title":"Submission URUY98","provisional":false,"code":"import re\ndef capture_report(text):\n pattern = re.compile(r'(?P<key>[A-Z]+)=(?P<value>\\d+)')\n return [(m.group('key'), int(m.group('value')), m.span()) for m in pattern.finditer(text)]","input":"capture_report('CPU=81 MEM=64 note CPU=90')","language":"Python","predicted_output":"[('CPU', 81, (0, 6)), ('MEM', 64, (7, 13)), ('CPU', 90, (19, 25))]"} |
| {"id":"cmssjh8zb00qojmp2i54esuyd","kind":"contributor_item","title":"Submission 4ESUYD","provisional":false,"code":"def sparse_running_total(events):\n total = 0\n out = {}\n for key, delta in events:\n total += delta\n if total:\n out[key] = total\n return out","input":"sparse_running_total([('a', 3), ('b', -3), ('c', 5), ('d', -2)])","language":"Python","predicted_output":"{'a': 3, 'c': 5, 'd': 3}"} |
| {"id":"cmssjh8zb00qmjmp2629eulzl","kind":"contributor_item","title":"Submission 9EULZL","provisional":false,"code":"def rolling_windows(values, size):\n return [tuple(values[i:i+size]) for i in range(len(values)-size+1)]","input":"rolling_windows([3, 1, 4, 1, 5], 3)","language":"Python","predicted_output":"[(3, 1, 4), (1, 4, 1), (4, 1, 5)]"} |
| {"id":"cmssjh8zb00qnjmp2hpkwrpc7","kind":"contributor_item","title":"Submission KWRPC7","provisional":false,"code":"def partition_stable(values, pivot):\n lower = [x for x in values if x < pivot]\n equal = [x for x in values if x == pivot]\n higher = [x for x in values if x > pivot]\n return lower + equal + higher","input":"partition_stable([5, 2, 7, 2, 4, 2, 9], 2)","language":"Python","predicted_output":"[2, 2, 2, 5, 7, 4, 9]"} |
| {"id":"cmssjh8zb00qpjmp2qcltvgor","kind":"contributor_item","title":"Submission LTVGOR","provisional":false,"code":"def rotate_layers(matrix):\n return [list(row) for row in zip(*matrix[::-1])]","input":"rotate_layers([[1,2,3],[4,5,6],[7,8,9]])","language":"Python","predicted_output":"[[7, 4, 1], [8, 5, 2], [9, 6, 3]]"} |
| {"id":"cmssjh8zc00qtjmp2rst2kmv0","kind":"contributor_item","title":"Submission T2KMV0","provisional":false,"code":"def classify_runs(text):\n if not text:\n return []\n out, start = [], 0\n for i in range(1, len(text) + 1):\n if i == len(text) or text[i] != text[start]:\n out.append((text[start], i-start))\n start = i\n return out","input":"classify_runs('aaabbcaaaa')","language":"Python","predicted_output":"[('a', 3), ('b', 2), ('c', 1), ('a', 4)]"} |
| {"id":"cmssjh8zc00qsjmp2iha7p2ya","kind":"contributor_item","title":"Submission A7P2YA","provisional":false,"code":"def bounded_accumulate(values, low, high):\n total = 0\n out = []\n for value in values:\n total = min(high, max(low, total + value))\n out.append(total)\n return out","input":"bounded_accumulate([4, 9, -3, -20, 8], -5, 10)","language":"Python","predicted_output":"[4, 10, 7, -5, 3]"} |
| {"id":"cmssjh8zb00qqjmp2rw6y6c1p","kind":"contributor_item","title":"Submission 6Y6C1P","provisional":false,"code":"def merge_intervals(intervals):\n merged = []\n for start, end in sorted(intervals):\n if merged and start <= merged[-1][1] + 1:\n merged[-1] = (merged[-1][0], max(end, merged[-1][1]))\n else:\n merged.append((start, end))\n return merged","input":"merge_intervals([(8,10),(1,3),(2,6),(12,12),(11,11)])","language":"Python","predicted_output":"[(1, 6), (8, 12)]"} |
| {"id":"cmssjh8zc00qrjmp2xa5trepm","kind":"contributor_item","title":"Submission 5TREPM","provisional":false,"code":"def diagonal_zigzag(grid):\n out = []\n rows, cols = len(grid), len(grid[0])\n for s in range(rows + cols - 1):\n part = [grid[r][s-r] for r in range(rows) if 0 <= s-r < cols]\n out.extend(part[::-1] if s % 2 == 0 else part)\n return out","input":"diagonal_zigzag([[1,2,3],[4,5,6]])","language":"Python","predicted_output":"[1, 2, 4, 5, 3, 6]"} |
| {"id":"cmssjh8zc00qujmp22efm17q7","kind":"contributor_item","title":"Submission FM17Q7","provisional":false,"code":"def transpose_ragged(rows, fill=None):\n width = max(map(len, rows))\n return [[row[i] if i < len(row) else fill for row in rows] for i in range(width)]","input":"transpose_ragged([[1,2,3],[4],[5,6]], 0)","language":"Python","predicted_output":"[[1, 4, 5], [2, 0, 6], [3, 0, 0]]"} |
| {"id":"cmssjh8zc00qxjmp24nqrrwxt","kind":"contributor_item","title":"Submission QRRWXT","provisional":false,"code":"from collections import defaultdict\ndef invert_groups(mapping):\n out = defaultdict(list)\n for key, values in mapping.items():\n for value in values:\n out[value].append(key)\n return {k: sorted(v) for k, v in sorted(out.items())}","input":"invert_groups({'red':['a','c'],'blue':['b','c'],'green':['a']})","language":"Python","predicted_output":"{'a': ['green', 'red'], 'b': ['blue'], 'c': ['blue', 'red']}"} |
| {"id":"cmssjh8zc00r0jmp2f2gjfekf","kind":"contributor_item","title":"Submission GJFEKF","provisional":false,"code":"import bisect\ndef insert_and_rank(sorted_values, additions):\n values = list(sorted_values)\n ranks = []\n for x in additions:\n i = bisect.bisect_right(values, x)\n values.insert(i, x)\n ranks.append(i)\n return values, ranks","input":"insert_and_rank([1,3,3,8], [3,0,10])","language":"Python","predicted_output":"([0, 1, 3, 3, 3, 8, 10], [3, 0, 6])"} |
| {"id":"cmssjh8zc00qyjmp24znkwkna","kind":"contributor_item","title":"Submission NKWKNA","provisional":false,"code":"from collections import deque\ndef consume_round_robin(queues):\n active = deque(deque(q) for q in queues if q)\n out = []\n while active:\n q = active.popleft()\n out.append(q.popleft())\n if q:\n active.append(q)\n return out","input":"consume_round_robin([[1,2,3],['a'],[True,False]])","language":"Python","predicted_output":"[1, 'a', True, 2, False, 3]"} |
| {"id":"cmssjh8zc00qzjmp2nd57zo37","kind":"contributor_item","title":"Submission 57ZO37","provisional":false,"code":"import heapq\ndef scheduled_order(tasks):\n heap = [(time, priority, name) for name, time, priority in tasks]\n heapq.heapify(heap)\n return [heapq.heappop(heap)[2] for _ in range(len(heap))]","input":"scheduled_order([('backup',5,2),('alert',2,1),('sync',5,1),('index',2,3)])","language":"Python","predicted_output":"['alert', 'index', 'sync', 'backup']"} |
| {"id":"cmssjh8zc00r5jmp2x6ne579h","kind":"contributor_item","title":"Submission NE579H","provisional":false,"code":"def nested_get(data, path, default=None):\n cur = data\n for part in path:\n try:\n cur = cur[part]\n except (KeyError, IndexError, TypeError):\n return default\n return cur","input":"(nested_get({'a':[{'b':7}]}, ['a',0,'b']), nested_get({'a':[]}, ['a',1], 'missing'))","language":"Python","predicted_output":"(7, 'missing')"} |
| {"id":"cmssjh8zc00r2jmp2pngnujz5","kind":"contributor_item","title":"Submission GNUJZ5","provisional":false,"code":"from itertools import accumulate\ndef prefix_extrema(values):\n return list(accumulate(values, max)), list(accumulate(values, min))","input":"prefix_extrema([5,2,8,1,7])","language":"Python","predicted_output":"([5, 5, 8, 8, 8], [5, 2, 2, 1, 1])"} |
| {"id":"cmssjh8zc00r4jmp283mywie9","kind":"contributor_item","title":"Submission MYWIE9","provisional":false,"code":"def dictionary_diff(before, after):\n keys = before.keys() | after.keys()\n return {k:(before.get(k), after.get(k)) for k in sorted(keys) if before.get(k) != after.get(k)}","input":"dictionary_diff({'a':1,'b':2,'d':None}, {'b':3,'c':4,'d':None})","language":"Python","predicted_output":"{'a': (1, None), 'b': (2, 3), 'c': (None, 4)}"} |
| {"id":"cmssjh8zc00r6jmp2zvxxweah","kind":"contributor_item","title":"Submission XXWEAH","provisional":false,"code":"def parse_pairs(parts):\n out = {}\n errors = []\n for part in parts:\n try:\n key, raw = part.split('=', 1)\n out[key] = int(raw)\n except ValueError:\n errors.append(part)\n return out, errors","input":"parse_pairs(['x=4','bad','y=-2','z=3.5','note=a=b'])","language":"Python","predicted_output":"({'x': 4, 'y': -2}, ['bad', 'z=3.5', 'note=a=b'])"} |
| {"id":"cmssjh8zc00r8jmp2hiz10895","kind":"contributor_item","title":"Submission Z10895","provisional":false,"code":"def exception_chain(flag):\n try:\n if flag:\n raise KeyError('root')\n return 'ok'\n except KeyError as exc:\n try:\n raise RuntimeError('wrapped') from exc\n except RuntimeError as wrapped:\n return type(wrapped.__cause__).__name__, str(wrapped)\n finally:\n flag = None","input":"(exception_chain(False), exception_chain(True))","language":"Python","predicted_output":"('ok', ('KeyError', 'wrapped'))"} |
| {"id":"cmssjh8zc00r9jmp22a2fys68","kind":"contributor_item","title":"Submission 2FYS68","provisional":false,"code":"def transactional_update(state, operations):\n original = state.copy()\n try:\n for key, delta in operations:\n state[key] += delta\n if state[key] < 0:\n raise ValueError(key)\n except (KeyError, ValueError) as exc:\n state.clear(); state.update(original)\n return False, str(exc), state\n return True, None, state","input":"transactional_update({'cash':5,'stock':2}, [('cash',-3),('stock',-4)])","language":"Python","predicted_output":"(False, 'stock', {'cash': 5, 'stock': 2})"} |
| {"id":"cmssjh8zc00r7jmp2vkaolese","kind":"contributor_item","title":"Submission AOLESE","provisional":false,"code":"def guarded_index(values, indexes):\n out = []\n for index in indexes:\n try:\n out.append(values[index])\n except IndexError:\n out.append('out')\n else:\n out[-1] = (index, out[-1])\n return out","input":"guarded_index(['a','b','c'], [0,-1,3,-4])","language":"Python","predicted_output":"[(0, 'a'), (-1, 'c'), 'out', 'out']"} |
| {"id":"cmssjh8zc00rdjmp2r3unp2u7","kind":"contributor_item","title":"Submission UNP2U7","provisional":false,"code":"class CounterBox:\n def __init__(self, start): self.value = start\n def __enter__(self): self.value += 1; return self\n def __exit__(self, kind, exc, tb): self.value *= 2\ndef use_box(start):\n with CounterBox(start) as box:\n box.value += 3\n return box.value","input":"use_box(4)","language":"Python","predicted_output":"16"} |
| {"id":"cmssjh8zc00rajmp217t8kk8d","kind":"contributor_item","title":"Submission T8KK8D","provisional":false,"code":"def finally_override(value):\n try:\n return 10 // value\n except ZeroDivisionError:\n return 'zero'\n finally:\n if value < 0:\n return 'negative' ","input":"(finally_override(2), finally_override(0), finally_override(-2))","language":"Python","predicted_output":"(5, 'zero', 'negative')"} |
| {"id":"cmssjh8zc00rcjmp2f3lshcjl","kind":"contributor_item","title":"Submission LSHCJL","provisional":false,"code":"class Temperature:\n def __init__(self, c): self.c = c\n def __lt__(self, other): return self.c < other.c\n def __repr__(self): return f'{self.c}C'\ndef temperature_bounds(values):\n temps = [Temperature(v) for v in values]\n return min(temps), max(temps)","input":"temperature_bounds([12,-4,31,12])","language":"Python","predicted_output":"(-4C, 31C)"} |
| {"id":"cmssjh8zc00rgjmp2w56850dh","kind":"contributor_item","title":"Submission 6850DH","provisional":false,"code":"class Base:\n def label(self): return 'base'\nclass Left(Base):\n def label(self): return 'left>' + super().label()\nclass Right(Base):\n def label(self): return 'right>' + super().label()\nclass Combined(Left, Right): pass","input":"(Combined().label(), [c.__name__ for c in Combined.__mro__])","language":"Python","predicted_output":"('left>right>base', ['Combined', 'Left', 'Right', 'Base', 'object'])"} |
| {"id":"cmssjh8zc00rejmp22rqhmoxn","kind":"contributor_item","title":"Submission QHMOXN","provisional":false,"code":"class Node:\n def __init__(self, value, children=()): self.value, self.children = value, children\n def __iter__(self):\n yield self.value\n for child in self.children:\n yield from child\ndef tree_values():\n return list(Node('a',(Node('b'),Node('c',(Node('d'),)))))","input":"tree_values()","language":"Python","predicted_output":"['a', 'b', 'c', 'd']"} |
| {"id":"cmssjh8zc00rhjmp2t4smx4ao","kind":"contributor_item","title":"Submission SMX4AO","provisional":false,"code":"from dataclasses import dataclass, replace\n@dataclass(order=True, frozen=True)\nclass Job:\n priority: int\n name: str\ndef reprioritize(jobs):\n changed = [replace(j, priority=j.priority-1) if j.name.startswith('u') else j for j in jobs]\n return sorted(changed)","input":"reprioritize([Job(3,'upload'),Job(1,'audit'),Job(2,'update')])","language":"Python","predicted_output":"[Job(priority=1, name='audit'), Job(priority=1, name='update'), Job(priority=2, name='upload')]"} |
| {"id":"cmssjh8zc00rfjmp2qvi46etn","kind":"contributor_item","title":"Submission I46ETN","provisional":false,"code":"class Descriptor:\n def __set_name__(self, owner, name): self.name = '_' + name\n def __get__(self, obj, owner): return getattr(obj, self.name, 0)\n def __set__(self, obj, value): setattr(obj, self.name, max(0, value))\nclass Meter:\n reading = Descriptor()\n def __init__(self, value): self.reading = value","input":"(Meter(-3).reading, Meter(8).reading)","language":"Python","predicted_output":"(0, 8)"} |
| {"id":"cmssjh8zc00rjjmp2wf58k1f4","kind":"contributor_item","title":"Submission 58K1F4","provisional":false,"code":"def coroutine_trace(values):\n def running():\n total = 0\n while True:\n value = yield total\n total += value\n g = running(); out = [next(g)]\n out.extend(g.send(v) for v in values)\n return out","input":"coroutine_trace([3,-1,5])","language":"Python","predicted_output":"[0, 3, 2, 7]"} |
| {"id":"cmssjh8zc00rljmp2y0g45t1q","kind":"contributor_item","title":"Submission G45T1Q","provisional":false,"code":"from contextlib import contextmanager\n@contextmanager\ndef tagged(log, name):\n log.append('enter:'+name)\n try: yield name.upper()\n finally: log.append('exit:'+name)\ndef nested_tags():\n log=[]\n with tagged(log,'a') as a, tagged(log,'b') as b: log.append(a+b)\n return log","input":"nested_tags()","language":"Python","predicted_output":"['enter:a', 'enter:b', 'AB', 'exit:b', 'exit:a']"} |
| {"id":"cmssjh8zc00rkjmp22fotbkti","kind":"contributor_item","title":"Submission OTBKTI","provisional":false,"code":"def generator_cleanup(limit):\n log = []\n def gen():\n try:\n for i in range(limit): yield i\n finally: log.append('closed')\n g = gen(); first = next(g); g.close()\n return first, log","input":"generator_cleanup(4)","language":"Python","predicted_output":"(0, ['closed'])"} |
| {"id":"cmssjh8zc00rijmp2y9tpbk4c","kind":"contributor_item","title":"Submission TPBK4C","provisional":false,"code":"from enum import IntFlag\nclass Access(IntFlag):\n READ=1; WRITE=2; EXECUTE=4\ndef permissions(value):\n mask = Access(value)\n return bool(mask & Access.WRITE), (mask | Access.EXECUTE).value, (mask & ~Access.READ).value","input":"permissions(3)","language":"Python","predicted_output":"(True, 7, 2)"} |
| {"id":"cmssjh8zc00rpjmp23hazpxud","kind":"contributor_item","title":"Submission AZPXUD","provisional":false,"code":"from pathlib import PurePosixPath\ndef path_summary(paths):\n ps = [PurePosixPath(p) for p in paths]\n return [(p.name, p.suffix, len(p.parts)) for p in ps]","input":"path_summary(['/srv/app/main.py','docs/archive.tar.gz','README'])","language":"Python","predicted_output":"[('main.py', '.py', 4), ('archive.tar.gz', '.gz', 2), ('README', '', 1)]"} |
| {"id":"cmssjh8zc00rmjmp2i1qcwazm","kind":"contributor_item","title":"Submission QCWAZM","provisional":false,"code":"from decimal import Decimal, ROUND_HALF_UP\ndef invoice_total(prices, tax):\n subtotal = sum(map(Decimal, prices))\n total = subtotal * (Decimal('1') + Decimal(tax))\n return subtotal, total.quantize(Decimal('0.01'), rounding=ROUND_HALF_UP)","input":"invoice_total(['1.005','2.335','10.00'], '0.075')","language":"Python","predicted_output":"(Decimal('13.340'), Decimal('14.34'))"} |
| {"id":"cmssjh8zc00rojmp2oxip35pt","kind":"contributor_item","title":"Submission IP35PT","provisional":false,"code":"from datetime import datetime, timedelta, timezone\ndef timeline(start, offsets):\n base = datetime.fromisoformat(start).astimezone(timezone.utc)\n return [(base + timedelta(minutes=m)).isoformat() for m in offsets]","input":"timeline('2026-08-01T23:50:00+05:30', [0,20,75])","language":"Python","predicted_output":"['2026-08-01T18:20:00+00:00', '2026-08-01T18:40:00+00:00', '2026-08-01T19:35:00+00:00']"} |
| {"id":"cmssjh8zc00rtjmp2f5lv1qvt","kind":"contributor_item","title":"Submission LV1QVT","provisional":false,"code":"import math\ndef floating_edges(values):\n return [(math.isfinite(x), math.copysign(1.0,x), round(x,2)) for x in values]","input":"floating_edges([0.0,-0.0,2.675,float('inf')])","language":"Python","predicted_output":"[(True, 1.0, 0.0), (True, -1.0, -0.0), (True, 1.0, 2.67), (False, 1.0, inf)]"} |
| {"id":"cmssjh8zc00rxjmp2bwtdakip","kind":"contributor_item","title":"Submission TDAKIP","provisional":false,"code":"def closure_cells(start):\n value = start\n def get(): return value\n def bump(delta):\n nonlocal value\n value += delta\n return value\n return get, bump","input":"(lambda pair: (pair[0](), pair[1](4), pair[0](), pair[1](-2)))(closure_cells(3))","language":"Python","predicted_output":"(3, 7, 7, 5)"} |
| {"id":"cmssjh8zc00rujmp22pl5i7xj","kind":"contributor_item","title":"Submission L5I7XJ","provisional":false,"code":"import string\ndef translation_map(text):\n table = str.maketrans({'-':' ', '_':' ', '!':None})\n cleaned = text.translate(table)\n return cleaned, string.capwords(cleaned)","input":"translation_map('hello-world_test!')","language":"Python","predicted_output":"('hello world test', 'Hello World Test')"} |
| {"id":"cmssjh8zc00rwjmp2mt3osc79","kind":"contributor_item","title":"Submission 3OSC79","provisional":false,"code":"def memoized_paths(n):\n cache = {0:1, 1:1}\n def count(k):\n if k not in cache: cache[k] = count(k-1) + count(k-2)\n return cache[k]\n value = count(n)\n return value, sorted(cache.items())","input":"memoized_paths(6)","language":"Python","predicted_output":"(13, [(0, 1), (1, 1), (2, 2), (3, 3), (4, 5), (5, 8), (6, 13)])"} |
| {"id":"cmssjh8zc00rvjmp2plwb2vf7","kind":"contributor_item","title":"Submission WB2VF7","provisional":false,"code":"from operator import itemgetter\ndef ranked_rows(rows):\n ordered = sorted(rows, key=itemgetter(1,0), reverse=True)\n return [(i+1, row) for i,row in enumerate(ordered)]","input":"ranked_rows([('amy',3),('bob',5),('cid',5),('dee',2)])","language":"Python","predicted_output":"[(1, ('cid', 5)), (2, ('bob', 5)), (3, ('amy', 3)), (4, ('dee', 2))]"} |
| {"id":"cmssjh8zc00rzjmp2rt4ghjcv","kind":"contributor_item","title":"Submission 4GHJCV","provisional":false,"code":"def walrus_chunks(values, size):\n it = iter(values)\n out=[]\n while chunk := tuple(next(it, None) for _ in range(size)):\n clean = tuple(x for x in chunk if x is not None)\n if not clean: break\n out.append(clean)\n if len(clean) < size: break\n return out","input":"walrus_chunks([1,2,3,4,5], 2)","language":"Python","predicted_output":"[(1, 2), (3, 4), (5,)]"} |
| {"id":"cmssjh8zc00ryjmp2zwnw9e23","kind":"contributor_item","title":"Submission NW9E23","provisional":false,"code":"def match_records(records):\n out=[]\n for record in records:\n match record:\n case {'kind':'point','x':x,'y':y}: out.append(x+y)\n case [head,*tail]: out.append((head,len(tail)))\n case _: out.append(None)\n return out","input":"match_records([{'kind':'point','x':2,'y':5}, [9,8,7], {'kind':'other'}])","language":"Python","predicted_output":"[7, (9, 2), None]"} |
| {"id":"cmssjklag00sbjmp27ozveyy4","kind":"contributor_item","title":"Submission ZVEYY4","provisional":false,"code":"class Basket:\n contents = []\n\n def __init__(self, name):\n self.name = name\n\n def add(self, item):\n self.contents.append(item)\n return len(self.contents)\n\ndef shared_state():\n a, b = Basket(\"a\"), Basket(\"b\")\n first = a.add(\"x\")\n second = b.add(\"y\")\n return [first, second, a.contents, b.contents is a.contents]","input":"shared_state()","language":"Python","predicted_output":"[1, 2, ['x', 'y'], True]"} |
| {"id":"cmssjklag00sajmp26uoyx0vk","kind":"contributor_item","title":"Submission OYX0VK","provisional":false,"code":"def by_length(words):\n return sorted(words, key=len)","input":"by_length(['pear', 'fig', 'plum', 'kiwi', 'date'])","language":"Python","predicted_output":"['fig', 'pear', 'plum', 'kiwi', 'date']"} |
| {"id":"cmssjklag00sfjmp2zkiotfvy","kind":"contributor_item","title":"Submission IOTFVY","provisional":false,"code":"def divmods(pairs):\n return [(a // b, a % b) for a, b in pairs]","input":"divmods([(7, 3), (-7, 3), (7, -3), (-7, -3)])","language":"Python","predicted_output":"[(2, 1), (-3, 2), (-3, -2), (2, -1)]"} |
| {"id":"cmssjklag00s7jmp2gcrvq66h","kind":"contributor_item","title":"Submission RVQ66H","provisional":false,"code":"log = []\n\ndef tagged(items):\n for it in items:\n log.append(it)\n yield it * 2\n\ndef peek_then_log():\n gen = tagged([1, 2, 3])\n first = next(gen)\n snapshot = list(log)\n rest = list(gen)\n return [first, snapshot, rest, list(log)]","input":"peek_then_log()","language":"Python","predicted_output":"[2, [1], [4, 6], [1, 2, 3]]"} |
| {"id":"cmssjklag00sejmp2me6l7wmq","kind":"contributor_item","title":"Submission 6L7WMQ","provisional":false,"code":"def stripe(n):\n xs = list(range(n))\n xs[::2] = [0] * len(xs[::2])\n return xs","input":"stripe(7)","language":"Python","predicted_output":"[0, 1, 0, 3, 0, 5, 0]"} |
| {"id":"cmssjklag00sljmp2pjh64lsy","kind":"contributor_item","title":"Submission H64LSY","provisional":false,"code":"def risky(items):\n for it in items:\n if it == 0:\n raise ValueError(\"zero\")\n yield 10 // it\n\ndef collect_until_error(items):\n out = []\n try:\n for v in risky(items):\n out.append(v)\n except ValueError as e:\n out.append(str(e))\n return out","input":"collect_until_error([5, 2, 0, 1])","language":"Python","predicted_output":"[2, 5, 'zero']"} |
| {"id":"cmssjklaf00s5jmp2tz8iq3af","kind":"contributor_item","title":"Submission 8IQ3AF","provisional":false,"code":"def collect(value, bucket=[]):\n bucket.append(value)\n return list(bucket)\n\ndef run_three():\n return [collect(1), collect(2), collect(3)]","input":"run_three()","language":"Python","predicted_output":"[[1], [1, 2], [1, 2, 3]]"} |
| {"id":"cmssjklag00sjjmp23lkmqo42","kind":"contributor_item","title":"Submission KMQO42","provisional":false,"code":"def key_collisions():\n d = {}\n d[1] = \"int\"\n d[True] = \"bool\"\n d[1.0] = \"float\"\n return [len(d), list(d.keys()), d[1]]","input":"key_collisions()","language":"Python","predicted_output":"[1, [1], 'float']"} |
| {"id":"cmssjklaf00s6jmp2x4gbp1up","kind":"contributor_item","title":"Submission GBP1UP","provisional":false,"code":"def make_multipliers():\n fns = []\n for factor in range(1, 4):\n fns.append(lambda x: x * factor)\n return fns\n\ndef apply_all(x):\n return [f(x) for f in make_multipliers()]","input":"apply_all(5)","language":"Python","predicted_output":"[15, 15, 15]"} |
| {"id":"cmssjklag00sdjmp2lx9uo4pw","kind":"contributor_item","title":"Submission 9UO4PW","provisional":false,"code":"def which_wins():\n try:\n return \"try\"\n finally:\n return \"finally\"\n\ndef probe():\n return [which_wins()]","input":"probe()","language":"Python","predicted_output":"['finally']"} |
| {"id":"cmssjklag00sgjmp2mni5c6j1","kind":"contributor_item","title":"Submission I5C6J1","provisional":false,"code":"def tokens(text):\n return [text.split(), text.split(\" \")]","input":"tokens(' a b ')","language":"Python","predicted_output":"[['a', 'b'], ['', '', 'a', '', 'b', '']]"} |
| {"id":"cmssjklag00sijmp2mqjmrm0f","kind":"contributor_item","title":"Submission JMRM0F","provisional":false,"code":"def counted(fn):\n calls = {\"n\": 0}\n\n def wrapper(*args):\n calls[\"n\"] += 1\n return (calls[\"n\"], fn(*args))\n\n return wrapper\n\n@counted\ndef double(x):\n return x * 2\n\ndef three_calls():\n return [double(1), double(2), double(3)]","input":"three_calls()","language":"Python","predicted_output":"[(1, 2), (2, 4), (3, 6)]"} |
| {"id":"cmssjklag00s8jmp2cgsc5tds","kind":"contributor_item","title":"Submission SC5TDS","provisional":false,"code":"def pair_up(n):\n it = iter(range(n))\n return list(zip(it, it))","input":"pair_up(7)","language":"Python","predicted_output":"[(0, 1), (2, 3), (4, 5)]"} |
| {"id":"cmssjklag00sojmp2h6tklasp","kind":"contributor_item","title":"Submission TKLASP","provisional":false,"code":"from itertools import groupby\n\ndef group_parity(nums):\n key = lambda n: n % 2\n unsorted = [(k, list(g)) for k, g in groupby(nums, key)]\n presorted = [(k, list(g)) for k, g in groupby(sorted(nums, key=key), key)]\n return [len(unsorted), unsorted, presorted]","input":"group_parity([1, 3, 2, 4, 5])","language":"Python","predicted_output":"[3, [(1, [1, 3]), (0, [2, 4]), (1, [5])], [(0, [2, 4]), (1, [1, 3, 5])]]"} |
| {"id":"cmssjklag00skjmp2njd5uyy7","kind":"contributor_item","title":"Submission D5UYY7","provisional":false,"code":"import copy\n\ndef shallow_vs_deep():\n original = [[1, 2], [3, 4]]\n shallow = copy.copy(original)\n deep = copy.deepcopy(original)\n original[0].append(99)\n return [shallow, deep]","input":"shallow_vs_deep()","language":"Python","predicted_output":"[[[1, 2, 99], [3, 4]], [[1, 2], [3, 4]]]"} |
| {"id":"cmssjklag00smjmp23qegpoe5","kind":"contributor_item","title":"Submission EGPOE5","provisional":false,"code":"from functools import reduce\n\ndef fold(nums):\n with_init = reduce(lambda a, b: a * 10 + b, nums, 0)\n without = reduce(lambda a, b: a * 10 + b, nums)\n return [with_init, without]","input":"fold([1, 2, 3])","language":"Python","predicted_output":"[123, 123]"} |
| {"id":"cmssjklag00snjmp2d492nz8f","kind":"contributor_item","title":"Submission 92NZ8F","provisional":false,"code":"def fib(n, memo={}):\n if n < 2:\n return n\n if n not in memo:\n memo[n] = fib(n - 1, memo) + fib(n - 2, memo)\n return memo[n]\n\ndef two_rounds():\n first = fib(10)\n size_after = len(fib.__defaults__[0])\n return [first, size_after]","input":"two_rounds()","language":"Python","predicted_output":"[55, 9]"} |
| {"id":"cmssjklag00scjmp26ehbsxhb","kind":"contributor_item","title":"Submission HBSXHB","provisional":false,"code":"class Base:\n def trace(self):\n return [\"Base\"]\n\nclass Left(Base):\n def trace(self):\n return [\"Left\"] + super().trace()\n\nclass Right(Base):\n def trace(self):\n return [\"Right\"] + super().trace()\n\nclass Bottom(Left, Right):\n def trace(self):\n return [\"Bottom\"] + super().trace()","input":"Bottom().trace()","language":"Python","predicted_output":"['Bottom', 'Left', 'Right', 'Base']"} |
| {"id":"cmssjklag00s9jmp2bxzmd1gd","kind":"contributor_item","title":"Submission ZMD1GD","provisional":false,"code":"def merge_order():\n d = {\"a\": 1, \"b\": 2, \"c\": 3}\n d[\"a\"] = 99\n del d[\"b\"]\n d[\"b\"] = 5\n return list(d.items())","input":"merge_order()","language":"Python","predicted_output":"[('a', 99), ('c', 3), ('b', 5)]"} |
| {"id":"cmssjklag00shjmp2hsjy0ff9","kind":"contributor_item","title":"Submission JY0FF9","provisional":false,"code":"def squares_over(nums, floor):\n return [sq for n in nums if (sq := n * n) > floor]","input":"squares_over([1, 3, 5, 2, 7], 8)","language":"Python","predicted_output":"[9, 25, 49]"} |
| {"id":"cmsskjlzb0126jmp2fhk3lz6b","kind":"contributor_item","title":"Submission K3LZ6B","provisional":false,"code":"def accumulate(value, bucket=[]):\n bucket.append(value)\n return bucket","input":"(accumulate(1), accumulate(2), accumulate(3))","language":"Python","predicted_output":"([1, 2, 3], [1, 2, 3], [1, 2, 3])"} |
| {"id":"cmsskjlzc0127jmp25kgok4vn","kind":"contributor_item","title":"Submission GOK4VN","provisional":false,"code":"def safe_divide_chain(pairs):\n results = []\n for a, b in pairs:\n try:\n r = a / b\n except ZeroDivisionError:\n results.append(None)\n else:\n results.append(round(r, 2))\n finally:\n results.append('checked')\n return results","input":"safe_divide_chain([(10, 2), (5, 0), (7, 3)])","language":"Python","predicted_output":"[5.0, 'checked', None, 'checked', 2.33, 'checked']"} |
| {"id":"cmsskjlzc0128jmp2zndg4hge","kind":"contributor_item","title":"Submission DG4HGE","provisional":false,"code":"import itertools\n\ndef group_consecutive(items):\n return [(k, list(v)) for k, v in itertools.groupby(items)]","input":"group_consecutive([1, 1, 2, 1, 1, 3, 3])","language":"Python","predicted_output":"[(1, [1, 1]), (2, [2]), (1, [1, 1]), (3, [3, 3])]"} |
| {"id":"cmsskw28m013rjmp252fcmg1i","kind":"contributor_item","title":"Submission FCMG1I","provisional":false,"code":"def classify_matrix(matrix):\n return [\n [\"pos\" if val > 0 else \"neg\" if val < 0 else \"zero\" for val in row]\n for row in matrix\n ]","input":"classify_matrix([[1, -2, 0], [-5, 5, 0]])","language":"Python","predicted_output":"[['pos', 'neg', 'zero'], ['neg', 'pos', 'zero']]"} |
| {"id":"cmsskw28m013vjmp2qnmte7yb","kind":"contributor_item","title":"Submission MTE7YB","provisional":false,"code":"def rank_students(students):\n return sorted(students, key=lambda s: (-s[1], s[2]))","input":"rank_students([(\"Ann\", 85, 20), (\"Bob\", 90, 19), (\"Cy\", 85, 18), (\"Dee\", 90, 21)])","language":"Python","predicted_output":"[('Bob', 90, 19), ('Dee', 90, 21), ('Cy', 85, 18), ('Ann', 85, 20)]"} |
| {"id":"cmsskw28m013xjmp2n9vevf6e","kind":"contributor_item","title":"Submission VEVF6E","provisional":false,"code":"def compare_groups(a, b):\n set_a = set(a)\n set_b = set(b)\n return {\n \"only_a\": sorted(set_a - set_b),\n \"only_b\": sorted(set_b - set_a),\n \"common\": sorted(set_a & set_b),\n \"symmetric\": sorted(set_a ^ set_b),\n }","input":"compare_groups([1, 2, 3, 4, 2], [3, 4, 5, 6])","language":"Python","predicted_output":"{'only_a': [1, 2], 'only_b': [5, 6], 'common': [3, 4], 'symmetric': [1, 2, 5, 6]}"} |
| {"id":"cmsskw28m013ujmp2kn6h803o","kind":"contributor_item","title":"Submission 6H803O","provisional":false,"code":"from itertools import islice\n\ndef counter_gen(start, step):\n n = start\n while True:\n yield n\n n += step\n\ndef take_n(start, step, n):\n return list(islice(counter_gen(start, step), n))","input":"take_n(3, 5, 4)","language":"Python","predicted_output":"[3, 8, 13, 18]"} |
| {"id":"cmsskw28m013yjmp2e4praimr","kind":"contributor_item","title":"Submission PRAIMR","provisional":false,"code":"from functools import lru_cache\n\n@lru_cache(maxsize=None)\ndef collatz_steps(n):\n if n == 1:\n return 0\n if n % 2 == 0:\n return 1 + collatz_steps(n // 2)\n return 1 + collatz_steps(3 * n + 1)\n\ndef total_steps(nums):\n return sum(collatz_steps(n) for n in nums)","input":"total_steps([6, 7, 27])","language":"Python","predicted_output":"135"} |
| {"id":"cmsskw28m013zjmp26ggvjuza","kind":"contributor_item","title":"Submission GVJUZA","provisional":false,"code":"from collections import Counter\n\ndef top_words(text, n):\n words = text.lower().split()\n counts = Counter(words)\n return counts.most_common(n)","input":"top_words(\"dog cat bird cat bird dog cat bird bird fish\", 3)","language":"Python","predicted_output":"[('bird', 4), ('cat', 3), ('dog', 2)]"} |
| {"id":"cmsskw28m013qjmp20zfisbjv","kind":"contributor_item","title":"Submission FISBJV","provisional":false,"code":"def transform(nums):\n reversed_evens = [n for n in nums[::-1] if n % 2 == 0]\n return reversed_evens[1:-1]","input":"transform([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])","language":"Python","predicted_output":"[8, 6, 4]"} |
| {"id":"cmsskw28m013sjmp2bzsfewa9","kind":"contributor_item","title":"Submission SFEWA9","provisional":false,"code":"def index_map(names, scores):\n return {\n i: (name, score)\n for i, (name, score) in enumerate(zip(names, scores))\n if score >= 50\n }","input":"index_map([\"Ann\", \"Bob\", \"Cy\"], [40, 60, 75])","language":"Python","predicted_output":"{1: ('Bob', 60), 2: ('Cy', 75)}"} |
| {"id":"cmsskw28m013wjmp2dzj2iifh","kind":"contributor_item","title":"Submission J2IIFH","provisional":false,"code":"def format_prices(prices):\n return [f\"{p:.2f}\" for p in prices]","input":"format_prices([1.005, 2.675, 0.1 + 0.2, 10])","language":"Python","predicted_output":"['1.00', '2.67', '0.30', '10.00']"} |
| {"id":"cmssl291o014zjmp2spo9f1b8","kind":"contributor_item","title":"Submission O9F1B8","provisional":false,"code":"def append_item(item, bucket=[]):\n bucket.append(item)\n return bucket\n","input":"(append_item(1), append_item(2), append_item(3, []))","language":"Python","predicted_output":"([1, 2], [1, 2], [3])"} |
| {"id":"cmssl291o0150jmp2lctu60c9","kind":"contributor_item","title":"Submission TU60C9","provisional":false,"code":"def counter(n):\n for i in range(n):\n yield i * i\n\ndef drain_twice(n):\n g = counter(n)\n first = list(g)\n second = list(g)\n return (first, second)\n","input":"drain_twice(4)","language":"Python","predicted_output":"([0, 1, 4, 9], [])"} |
| {"id":"cmssl291o0152jmp2907d53rx","kind":"contributor_item","title":"Submission 7D53RX","provisional":false,"code":"def risky(x):\n try:\n return 10 / x\n except ZeroDivisionError:\n return -1\n finally:\n pass\n","input":"(risky(2), risky(0))","language":"Python","predicted_output":"(5.0, -1)"} |
| {"id":"cmssl291o0151jmp2bmqd4r4v","kind":"contributor_item","title":"Submission QD4R4V","provisional":false,"code":"def bucketize(nums):\n return {n: 'even' if n % 2 == 0 else 'odd' for n in nums}\n","input":"bucketize([5, 2, 8, 1])","language":"Python","predicted_output":"{5: 'odd', 2: 'even', 8: 'even', 1: 'odd'}"} |
| {"id":"cmsslaz2g015ijmp2cb4ih9wd","kind":"contributor_item","title":"Submission 4IH9WD","provisional":false,"code":"def parse_port(raw):\n try:\n value = int(raw)\n if not 0 < value < 65536:\n raise ValueError('out of range')\n return value\n except ValueError:\n return -1\n finally:\n if raw == '':\n return 0","input":"(parse_port('8080'), parse_port('70000'), parse_port('abc'), parse_port(''))","language":"Python","predicted_output":"(8080, -1, -1, 0)"} |
| {"id":"cmsslaz2g015jjmp2cake44iy","kind":"contributor_item","title":"Submission KE44IY","provisional":false,"code":"def normalize(readings):\n buckets = {}\n for name, value in readings:\n buckets[name] = round(value, 1)\n ordered = sorted(buckets.items(), key=lambda kv: (-kv[1], kv[0]))\n return ordered","input":"normalize([('east', 2.25), ('west', 2.35), ('north', 0.15), ('east', 1.05)])","language":"Python","predicted_output":"[('west', 2.4), ('east', 1.1), ('north', 0.1)]"} |
| {"id":"cmsslaz2g015hjmp2jqth2rgv","kind":"contributor_item","title":"Submission TH2RGV","provisional":false,"code":"from itertools import groupby\n\ndef summarize(records):\n out = {}\n for key, group in groupby(records, key=lambda r: r[0]):\n out.setdefault(key, []).extend(r[1] for r in group)\n return out","input":"summarize([('a', 1), ('b', 2), ('a', 3), ('a', 4)])","language":"Python","predicted_output":"{'a': [1, 3, 4], 'b': [2]}"} |
| {"id":"cmsslaz2g015fjmp2owavw52v","kind":"contributor_item","title":"Submission AVW52V","provisional":false,"code":"from collections import Counter\n\ndef rank_tags(tags, limit):\n counts = Counter(tags)\n top = counts.most_common(limit)\n return [name for name, _ in top], counts.total()","input":"rank_tags(['api', 'db', 'api', 'ui', 'db', 'api', 'ui'], 2)","language":"Python","predicted_output":"(['api', 'db'], 7)"} |
| {"id":"cmsslaz2g015gjmp24avbq5cn","kind":"contributor_item","title":"Submission VBQ5CN","provisional":false,"code":"def collect(entry, seen=[]):\n seen.append(entry)\n return list(seen)\n\ndef audit():\n first = collect('alpha')\n second = collect('beta')\n return first, second","input":"audit()","language":"Python","predicted_output":"(['alpha'], ['alpha', 'beta'])"} |
| {"id":"cmsslub3l0172jmp2x9fqet0l","kind":"contributor_item","title":"Submission FQET0L","provisional":false,"code":"def add_numbers(a, b):\n return a + b","input":"add_numbers(2, 3)","language":"Python","predicted_output":"5"} |
| {"id":"cmsslujti0173jmp28ssil2wj","kind":"contributor_item","title":"Submission SIL2WJ","provisional":false,"code":"from functools import lru_cache\n\n@lru_cache(maxsize=None)\ndef fib(n):\n if n < 2:\n return n\n return fib(n-1) + fib(n-2)","input":"fib(9)","language":"Python","predicted_output":"34"} |
| {"id":"cmsslv0760174jmp2qe91eag7","kind":"contributor_item","title":"Submission 91EAG7","provisional":false,"code":"def make_accumulator():\n total = 0\n history = []\n\n def add(x):\n nonlocal total\n total += x\n history.append(total)\n return total\n\n return add, history\n\ndef run_accumulator(values):\n add, history = make_accumulator()\n results = [add(v) for v in values]\n return results, history","input":"run_accumulator([5, -2, 10])","language":"Python","predicted_output":"([5, 3, 13], [5, 3, 13])"} |
| {"id":"cmsslvr6m017rjmp2y9bv2uqf","kind":"contributor_item","title":"Submission BV2UQF","provisional":false,"code":"from collections import Counter\n\ndef top_letters(text, n):\n counts = Counter(c for c in text.lower() if c.isalpha())\n return counts.most_common(n)","input":"top_letters('Mississippi River', 3)","language":"Python","predicted_output":"[('i', 5), ('s', 4), ('p', 2)]"} |
| {"id":"cmsslvr6m017qjmp28sk341tn","kind":"contributor_item","title":"Submission K341TN","provisional":false,"code":"def flatten_evens(matrix):\n return [value for row in matrix for value in row if value % 2 == 0]","input":"flatten_evens([[1,2,3],[4,5,6],[7,8,9]])","language":"Python","predicted_output":"[2, 4, 6, 8]"} |
| {"id":"cmsslvr6m017sjmp2pcib3nwm","kind":"contributor_item","title":"Submission IB3NWM","provisional":false,"code":"from collections import defaultdict\n\ndef group_by_mod(numbers, mod):\n groups = defaultdict(list)\n for num in numbers:\n groups[num % mod].append(num)\n return dict(groups)","input":"group_by_mod([10, 21, 32, 43, 54, 65], 3)","language":"Python","predicted_output":"{1: [10, 43], 0: [21, 54], 2: [32, 65]}"} |
| {"id":"cmsslvr6m017tjmp2oem0wof7","kind":"contributor_item","title":"Submission M0WOF7","provisional":false,"code":"def rank_students(students):\n return sorted(students, key=lambda s: (-s[1], s[0]))","input":"rank_students([('Ann', 88), ('Bo', 92), ('Cid', 88), ('Dee', 92)])","language":"Python","predicted_output":"[('Bo', 92), ('Dee', 92), ('Ann', 88), ('Cid', 88)]"} |
| {"id":"cmsslvr6m017xjmp2o7n96ms7","kind":"contributor_item","title":"Submission N96MS7","provisional":false,"code":"from collections import namedtuple\n\nPoint = namedtuple('Point', ['x', 'y'])\n\ndef reflect(points):\n return [Point(p.y, p.x) for p in points]","input":"reflect([Point(1, 2), Point(3, 4)])","language":"Python","predicted_output":"[Point(x=2, y=1), Point(x=4, y=3)]"} |
| {"id":"cmsslvr6m017zjmp27pg49bbz","kind":"contributor_item","title":"Submission G49BBZ","provisional":false,"code":"import itertools\n\ndef group_lengths(words):\n data = sorted(words, key=len)\n return {length: list(group) for length, group in itertools.groupby(data, key=len)}","input":"group_lengths(['fig', 'kiwi', 'pear', 'plum', 'date', 'apple'])","language":"Python","predicted_output":"{3: ['fig'], 4: ['kiwi', 'pear', 'plum', 'date'], 5: ['apple']}"} |
| {"id":"cmsslvr6m017pjmp24bulv49c","kind":"contributor_item","title":"Submission ULV49C","provisional":false,"code":"class InsufficientFundsError(Exception):\n pass\n\ndef withdraw(balance, amount):\n log = []\n try:\n if amount > balance:\n raise InsufficientFundsError(f\"cannot withdraw {amount} from {balance}\")\n balance -= amount\n return balance, log\n except InsufficientFundsError as e:\n return str(e), log\n finally:\n log.append(\"attempt complete\")","input":"(withdraw(100, 30), withdraw(50, 80))","language":"Python","predicted_output":"((70, ['attempt complete']), ('cannot withdraw 80 from 50', ['attempt complete']))"} |
| {"id":"cmsslvr6m017vjmp2feh2nqb1","kind":"contributor_item","title":"Submission H2NQB1","provisional":false,"code":"def factorial(n, _cache={0: 1, 1: 1}):\n if n in _cache:\n return _cache[n]\n result = n * factorial(n - 1, _cache)\n _cache[n] = result\n return result","input":"(factorial(5), factorial(6), sorted(factorial.__defaults__[0].items()))","language":"Python","predicted_output":"(120, 720, [(0, 1), (1, 1), (2, 2), (3, 6), (4, 24), (5, 120), (6, 720)])"} |
| {"id":"cmsslvr6m0180jmp2r9tab0yo","kind":"contributor_item","title":"Submission TAB0YO","provisional":false,"code":"def round_all(values, ndigits):\n return [round(v, ndigits) for v in values]","input":"round_all([2.675, 0.125, 1.005, 2.5, 3.5], 2)","language":"Python","predicted_output":"[2.67, 0.12, 1.0, 2.5, 3.5]"} |
| {"id":"cmsslvr6m017yjmp2iscxwa6x","kind":"contributor_item","title":"Submission CXWA6X","provisional":false,"code":"from dataclasses import dataclass, field\nfrom typing import List\n\n@dataclass\nclass Cart:\n items: List[str] = field(default_factory=list)\n total: float = 0.0\n\n def add(self, name, price):\n self.items.append(name)\n self.total += price\n return self","input":"(Cart().add('apple', 1.5).add('bread', 2.25), Cart())","language":"Python","predicted_output":"(Cart(items=['apple', 'bread'], total=3.75), Cart(items=[], total=0.0))"} |
| {"id":"cmsslvr6m017wjmp22uvvet3w","kind":"contributor_item","title":"Submission VVET3W","provisional":false,"code":"def analyze_sets(a, b):\n return {\n 'union': sorted(a | b),\n 'intersection': sorted(a & b),\n 'difference': sorted(a - b),\n 'symmetric_difference': sorted(a ^ b),\n }","input":"analyze_sets({1,2,3,4}, {3,4,5,6})","language":"Python","predicted_output":"{'union': [1, 2, 3, 4, 5, 6], 'intersection': [3, 4], 'difference': [1, 2], 'symmetric_difference': [1, 2, 5, 6]}"} |
| {"id":"cmsslvr6m0181jmp2t69rj7nv","kind":"contributor_item","title":"Submission 9RJ7NV","provisional":false,"code":"def slice_variants(s):\n return (s[::-1], s[2:-2], s[-1:-6:-2], s[::3])","input":"slice_variants('abcdefghij')","language":"Python","predicted_output":"('jihgfedcba', 'cdefgh', 'jhf', 'adgj')"} |
| {"id":"cmsslvr6m0183jmp28s3jafwu","kind":"contributor_item","title":"Submission 3JAFWU","provisional":false,"code":"class ParseError(Exception):\n pass\n\ndef parse_number(text):\n trace = []\n try:\n value = int(text)\n except ValueError as e:\n trace.append('conversion failed')\n raise ParseError(f\"bad input: {text}\") from e\n else:\n trace.append('conversion ok')\n return value, trace\n finally:\n trace.append('done')","input":"parse_number('42')","language":"Python","predicted_output":"(42, ['conversion ok', 'done'])"} |
| {"id":"cmsslvr6m0182jmp2j8g4h86a","kind":"contributor_item","title":"Submission G4H86A","provisional":false,"code":"def process_lists(original):\n alias = original\n snapshot = original[:]\n alias.append(99)\n original.sort()\n return original, alias, snapshot","input":"process_lists([5, 3, 8, 1])","language":"Python","predicted_output":"([1, 3, 5, 8, 99], [1, 3, 5, 8, 99], [5, 3, 8, 1])"} |
| {"id":"cmsslvr6m0185jmp2kedryiyl","kind":"contributor_item","title":"Submission DRYIYL","provisional":false,"code":"def bit_report(a, b):\n return {\n 'and': a & b,\n 'or': a | b,\n 'xor': a ^ b,\n 'left_shift': a << 2,\n 'right_shift': b >> 1,\n 'invert_a': ~a,\n }","input":"bit_report(12, 10)","language":"Python","predicted_output":"{'and': 8, 'or': 14, 'xor': 6, 'left_shift': 48, 'right_shift': 5, 'invert_a': -13}"} |
| {"id":"cmsslvr6m0184jmp2y4xnd359","kind":"contributor_item","title":"Submission XND359","provisional":false,"code":"def pair_data(names, scores):\n return [f\"{i}:{name}={score}\" for i, (name, score) in enumerate(zip(names, scores), start=1)]","input":"pair_data(['Al', 'Bo', 'Cy', 'Do'], [10, 20, 30])","language":"Python","predicted_output":"['1:Al=10', '2:Bo=20', '3:Cy=30']"} |
| {"id":"cmssm488101bpjmp2ie1h3tnq","kind":"contributor_item","title":"Submission 1H3TNQ","provisional":false,"code":"def gen():\n yield 1\n yield 2\n yield 3\n","input":"(lambda g: (list(g), list(g)))(gen())","language":"Python","predicted_output":"([1, 2, 3], [])"} |
| {"id":"cmssm488101bnjmp2lprsk0vh","kind":"contributor_item","title":"Submission RSK0VH","provisional":false,"code":"def add_item(item, bucket=[]):\n bucket.append(item)\n return bucket\n","input":"(add_item(1), add_item(2))","language":"Python","predicted_output":"([1, 2], [1, 2])"} |
| {"id":"cmssm488101bqjmp2f9om7tir","kind":"contributor_item","title":"Submission OM7TIR","provisional":false,"code":"def sort_by_abs(nums):\n return sorted(nums, key=abs)\n","input":"sort_by_abs([3, -1, -2, 0, -3])","language":"Python","predicted_output":"[0, -1, -2, 3, -3]"} |
| {"id":"cmssm488101brjmp27ic6hdkn","kind":"contributor_item","title":"Submission C6HDKN","provisional":false,"code":"def divmod_info(a, b):\n return divmod(a, b)\n","input":"divmod_info(-7, 3)","language":"Python","predicted_output":"(-3, 2)"} |
| {"id":"cmssm488101bojmp2cy5eyvma","kind":"contributor_item","title":"Submission 5EYVMA","provisional":false,"code":"def describe(person):\n return f\"{person['name']} is {person['age']} years old\"\n","input":"describe({'name': 'Ada', 'age': 30})","language":"Python","predicted_output":"Ada is 30 years old"} |
| {"id":"cmssng1ei0000g4p249od4kif","kind":"contributor_item","title":"Submission OD4KIF","provisional":false,"code":"def run_counter_trace(start, step, calls):\n count = [start]\n def counter():\n count[0] += step\n return count[0]\n def reset():\n count[0] = start\n return count[0]\n results = []\n for c in calls:\n if c == 'reset':\n results.append(reset())\n else:\n results.append(counter())\n return results","input":"run_counter_trace(10, 5, ['call','call','reset','call'])","language":"Python","predicted_output":"[15, 20, 10, 15]"} |
| {"id":"cmssnh1280002g4p206qcw0hz","kind":"contributor_item","title":"Submission QCW0HZ","provisional":false,"code":"def slice_variants(seq):\n return [\n seq[::-1],\n seq[1:-1],\n seq[-100:100],\n seq[5:2],\n seq[::2],\n ]","input":"slice_variants([0,1,2,3,4,5])","language":"Python","predicted_output":"[[5, 4, 3, 2, 1, 0], [1, 2, 3, 4], [0, 1, 2, 3, 4, 5], [], [0, 2, 4]]"} |
| {"id":"cmssnh1280003g4p2tt8t5cna","kind":"contributor_item","title":"Submission 8T5CNA","provisional":false,"code":"def tree_sum(node):\n if node is None:\n return 0\n left = tree_sum(node.get(\"left\"))\n right = tree_sum(node.get(\"right\"))\n return node.get(\"value\", 0) + left + right\n\ndef build_and_sum():\n tree = {\n \"value\": 5,\n \"left\": {\"value\": 3, \"left\": None, \"right\": {\"value\": 2}},\n \"right\": {\"value\": 8, \"left\": {\"value\": -1}, \"right\": None}\n }\n return tree_sum(tree)","input":"build_and_sum()","language":"Python","predicted_output":"17"} |
| {"id":"cmssnh1280004g4p2vb8qdeh9","kind":"contributor_item","title":"Submission 8QDEH9","provisional":false,"code":"def build_lookup(pairs):\n return {k: v for k, v in pairs}\n\ndef merge_and_count(pairs):\n lookup = build_lookup(pairs)\n return lookup, len(pairs) - len(lookup)","input":"merge_and_count([(\"a\",1),(\"b\",2),(\"a\",3),(\"c\",4),(\"b\",5)])","language":"Python","predicted_output":"({'a': 3, 'b': 5, 'c': 4}, 2)"} |
| {"id":"cmssnh1280007g4p2eu6gbi9h","kind":"contributor_item","title":"Submission 6GBI9H","provisional":false,"code":"def safe_divide_all(pairs):\n results = []\n for a, b in pairs:\n try:\n results.append(a / b)\n except ZeroDivisionError:\n results.append(float('inf') if a > 0 else float('-inf') if a < 0 else float('nan'))\n return results","input":"safe_divide_all([(10,2),(5,0),(-5,0),(0,0),(9,3)])","language":"Python","predicted_output":"[5.0, inf, -inf, nan, 3.0]"} |
| {"id":"cmssnh1280006g4p2xqi6dcdm","kind":"contributor_item","title":"Submission I6DCDM","provisional":false,"code":"class Shape:\n def __init__(self, name):\n self.name = name\n def describe(self):\n return f\"{self.name}: area={self.area()}\"\n def area(self):\n return 0\n\nclass Rectangle(Shape):\n def __init__(self, w, h):\n super().__init__(\"Rectangle\")\n self.w = w\n self.h = h\n def area(self):\n return self.w * self.h\n\nclass Square(Rectangle):\n def __init__(self, s):\n super().__init__(s, s)\n self.name = \"Square\"\n\ndef describe_shapes():\n shapes = [Rectangle(3,4), Square(5), Shape(\"Blob\")]\n return [s.describe() for s in shapes]","input":"describe_shapes()","language":"Python","predicted_output":"['Rectangle: area=12', 'Square: area=25', 'Blob: area=0']"} |
| {"id":"cmssnh1280001g4p2y7tduvzj","kind":"contributor_item","title":"Submission TDUVZJ","provisional":false,"code":"def weird_sum(values):\n total = 0\n details = []\n for v in values:\n total += v\n details.append(type(v).__name__)\n return total, details","input":"weird_sum([True, False, 3, 1.5, True])","language":"Python","predicted_output":"(6.5, ['bool', 'bool', 'int', 'float', 'bool'])"} |
| {"id":"cmssnh1280005g4p2fgx3y9cq","kind":"contributor_item","title":"Submission X3Y9CQ","provisional":false,"code":"def chunk(iterable, size):\n it = iter(iterable)\n while True:\n batch = []\n for _ in range(size):\n try:\n batch.append(next(it))\n except StopIteration:\n if batch:\n yield batch\n return\n yield batch\n\ndef chunk_list(lst, size):\n return list(chunk(lst, size))","input":"chunk_list([1,2,3,4,5,6,7], 3)","language":"Python","predicted_output":"[[1, 2, 3], [4, 5, 6], [7]]"} |
| {"id":"cmssnh1280008g4p2bxam0f4q","kind":"contributor_item","title":"Submission AM0F4Q","provisional":false,"code":"def analyze_sets(a, b):\n sa, sb = set(a), set(b)\n return {\n \"union\": sorted(sa | sb),\n \"intersection\": sorted(sa & sb),\n \"sym_diff\": sorted(sa ^ sb),\n \"only_a\": sorted(sa - sb),\n }","input":"analyze_sets([1,2,3,2,4], [3,4,5,5,6])","language":"Python","predicted_output":"{'union': [1, 2, 3, 4, 5, 6], 'intersection': [3, 4], 'sym_diff': [1, 2, 5, 6], 'only_a': [1, 2]}"} |
| {"id":"cmssnh1280009g4p2jqpxhw06","kind":"contributor_item","title":"Submission PXHW06","provisional":false,"code":"def format_report(values):\n lines = []\n for label, val in values:\n if isinstance(val, float):\n lines.append(f\"{label:>10}: {val:8.2f}\")\n else:\n lines.append(f\"{label:>10}: {val:>8,}\")\n return lines","input":"format_report([(\"total\", 1234567), (\"avg\", 42.5), (\"neg\", -3)])","language":"Python","predicted_output":"[' total: 1,234,567', ' avg: 42.50', ' neg: -3']"} |
| {"id":"cmssnh128000ag4p2cy6e8t6q","kind":"contributor_item","title":"Submission 6E8T6Q","provisional":false,"code":"def make_transaction_processor(initial_balance):\n balance = initial_balance\n history = []\n def process(amount):\n nonlocal balance\n if balance + amount < 0:\n history.append((\"rejected\", amount))\n return False\n balance += amount\n history.append((\"applied\", amount))\n return True\n def summary():\n return balance, history[:]\n process.summary = summary\n return process\n\ndef run_transactions(initial, amounts):\n proc = make_transaction_processor(initial)\n for amt in amounts:\n proc(amt)\n return proc.summary()","input":"run_transactions(100, [-50, 30, -200, -80, 25])","language":"Python","predicted_output":"(25, [('applied', -50), ('applied', 30), ('rejected', -200), ('applied', -80), ('applied', 25)])"} |
| {"id":"cmssnhet2000bg4p2tkmsogh1","kind":"contributor_item","title":"Submission MSOGH1","provisional":false,"code":"class ValidationError(Exception):\n pass\n\ndef parse_age(s):\n try:\n age = int(s)\n except ValueError as e:\n raise ValidationError(f\"invalid age: {s!r}\") from e\n if age < 0 or age > 150:\n raise ValidationError(f\"age out of range: {age}\")\n return age\n\ndef safe_parse_ages(values):\n results = []\n for v in values:\n try:\n results.append(parse_age(v))\n except ValidationError as e:\n results.append(str(e))\n return results","input":"safe_parse_ages([\"30\", \"abc\", \"-5\", \"200\", \"45\"])","language":"Python","predicted_output":"[30, \"invalid age: 'abc'\", 'age out of range: -5', 'age out of range: 200', 45]"} |
| {"id":"cmssnhet2000cg4p26mwu9z6f","kind":"contributor_item","title":"Submission WU9Z6F","provisional":false,"code":"def tokenize(expr):\n tokens = []\n current = \"\"\n for ch in expr:\n if ch in \"+-*/()\":\n if current:\n tokens.append(current)\n current = \"\"\n tokens.append(ch)\n elif ch == \" \":\n if current:\n tokens.append(current)\n current = \"\"\n else:\n current += ch\n if current:\n tokens.append(current)\n return tokens","input":"tokenize(\"12 + (3*4)- 5\")","language":"Python","predicted_output":"['12', '+', '(', '3', '*', '4', ')', '-', '5']"} |
| {"id":"cmssnhet2000dg4p24zliqztm","kind":"contributor_item","title":"Submission LIQZTM","provisional":false,"code":"def rank_students(records):\n return sorted(records, key=lambda r: (-r[1], r[2], r[0]))","input":"rank_students([(\"Amy\",90,20),(\"Bob\",85,22),(\"Cid\",90,19),(\"Dan\",85,21)])","language":"Python","predicted_output":"[('Cid', 90, 19), ('Amy', 90, 20), ('Dan', 85, 21), ('Bob', 85, 22)]"} |
| {"id":"cmssnhet2000eg4p2y578elhy","kind":"contributor_item","title":"Submission 78ELHY","provisional":false,"code":"def append_item(item, bucket=[]):\n bucket.append(item)\n return bucket\n\ndef run_mutation_demo():\n a = append_item(1)\n b = append_item(2)\n c = append_item(3, [])\n return a, b, c, a is b","input":"run_mutation_demo()","language":"Python","predicted_output":"([1, 2], [1, 2], [3], True)"} |
| {"id":"cmssnhet2000fg4p2k80xmero","kind":"contributor_item","title":"Submission 0XMERO","provisional":false,"code":"def memoize(fn):\n cache = {}\n calls = {\"count\": 0}\n def wrapper(*args):\n calls[\"count\"] += 1\n if args in cache:\n return cache[args]\n result = fn(*args)\n cache[args] = result\n return result\n wrapper.calls = calls\n return wrapper\n\n@memoize\ndef slow_square(x):\n return x * x\n\ndef memo_trace(xs):\n results = [slow_square(x) for x in xs]\n return results, slow_square.calls[\"count\"]","input":"memo_trace([2,3,2,4,3,2])","language":"Python","predicted_output":"([4, 9, 4, 16, 9, 4], 6)"} |
| {"id":"cmssni7gx000hg4p2rbzm7d6p","kind":"contributor_item","title":"Submission ZM7D6P","provisional":false,"code":"class Point:\n __slots__ = ('x','y')\n def __init__(self,x,y):\n self.x=x; self.y=y\n def __eq__(self,other):\n return isinstance(other,Point) and self.x==other.x and self.y==other.y\n def __hash__(self):\n return hash((self.x,self.y))\n def __repr__(self):\n return f\"Point({self.x},{self.y})\"\n\ndef dedup_points(pairs):\n pts = [Point(x,y) for x,y in pairs]\n unique = set(pts)\n return sorted(unique, key=lambda p:(p.x,p.y))","input":"dedup_points([(1,2),(3,4),(1,2),(0,0),(3,4)])","language":"Python","predicted_output":"[Point(0,0), Point(1,2), Point(3,4)]"} |
| {"id":"cmssni7gx000gg4p2xmdg8ovu","kind":"contributor_item","title":"Submission DG8OVU","provisional":false,"code":"def group_by_length(words):\n groups = {}\n for w in words:\n groups.setdefault(len(w), []).append(w)\n return {k: groups[k] for k in sorted(groups)}","input":"group_by_length([\"a\",\"bb\",\"cc\",\"ddd\",\"e\",\"ffff\"])","language":"Python","predicted_output":"{1: ['a', 'e'], 2: ['bb', 'cc'], 3: ['ddd'], 4: ['ffff']}"} |
| {"id":"cmssniip4000ig4p29uf6axbk","kind":"contributor_item","title":"Submission F6AXBK","provisional":false,"code":"def running_average():\n total = 0\n count = 0\n avg = None\n while True:\n value = yield avg\n total += value\n count += 1\n avg = total / count\n\ndef average_trace(values):\n gen = running_average()\n next(gen)\n return [gen.send(v) for v in values]","input":"average_trace([10, 20, 30, 40])","language":"Python","predicted_output":"[10.0, 15.0, 20.0, 25.0]"} |
| {"id":"cmssnktje000jg4p279v0c36l","kind":"contributor_item","title":"Submission V0C36L","provisional":false,"code":"def fib_with_cache(n, cache={}):\n if n in cache:\n return cache[n]\n if n <= 1:\n result = n\n else:\n result = fib_with_cache(n-1, cache) + fib_with_cache(n-2, cache)\n cache[n] = result\n return result","input":"(fib_with_cache(10), fib_with_cache(6), fib_with_cache(10))","language":"Python","predicted_output":"(55, 8, 55)"} |
| {"id":"cmsspw5ia002ug4p2fdrhzyju","kind":"contributor_item","title":"Submission RHZYJU","provisional":false,"code":"class Ledger:\n def __init__(self):\n self.entries = []\n def post(self, amount):\n if amount == 0:\n raise ValueError('zero entry')\n self.entries.append(amount)\n return len(self.entries)\n\ndef run(amounts):\n ledger = Ledger()\n errors = 0\n for amount in amounts:\n try:\n ledger.post(amount)\n except ValueError:\n errors += 1\n return sum(ledger.entries), errors, len(ledger.entries)","input":"run([10, 0, -4, 0, 7])","language":"Python","predicted_output":"(13, 2, 3)"} |
| {"id":"cmsspw5i9002sg4p2whb4qvou","kind":"contributor_item","title":"Submission B4QVOU","provisional":false,"code":"def merge_windows(windows):\n ordered = sorted(windows)\n merged = []\n for start, end in ordered:\n if merged and start <= merged[-1][1]:\n merged[-1] = (merged[-1][0], max(merged[-1][1], end))\n else:\n merged.append((start, end))\n return merged","input":"merge_windows([(5, 7), (1, 3), (2, 6), (9, 9)])","language":"Python","predicted_output":"[(1, 7), (9, 9)]"} |
| {"id":"cmsspw5ia002tg4p25wo72nzt","kind":"contributor_item","title":"Submission O72NZT","provisional":false,"code":"def tally_votes(ballots):\n counts = {}\n for ballot in ballots:\n for rank, name in enumerate(ballot):\n counts[name] = counts.get(name, 0) + (len(ballot) - rank)\n return sorted(counts.items(), key=lambda kv: (-kv[1], kv[0]))","input":"tally_votes([['ana', 'bo'], ['bo', 'cy', 'ana'], ['cy']])","language":"Python","predicted_output":"[('bo', 4), ('ana', 3), ('cy', 3)]"} |
| {"id":"cmsspyuqf0033g4p2ou02yufi","kind":"contributor_item","title":"Submission 02YUFI","provisional":false,"code":"def parse_record(line):\n key, _, rest = line.partition('=')\n parts = rest.split(',', 2)\n return key.strip(), len(parts), parts","input":"parse_record(' mode = fast,,deep,extra ')","language":"Python","predicted_output":"('mode', 3, [' fast', '', 'deep,extra '])"} |
| {"id":"cmsspyuqf0034g4p2pqmcqbfs","kind":"contributor_item","title":"Submission MCQBFS","provisional":false,"code":"def pair_up(names, scores):\n paired = [(n, s) for n, s in zip(names, scores) if s >= 50]\n total = sum(s for _, s in paired)\n return paired, total, len(names) - len(scores)","input":"pair_up(['p', 'q', 'r', 's'], [80, 20, 55])","language":"Python","predicted_output":"([('p', 80), ('r', 55)], 135, 1)"} |
| {"id":"cmsspyuqf002vg4p2hpfmctli","kind":"contributor_item","title":"Submission FMCTLI","provisional":false,"code":"def first_overdraft(transactions, limit):\n balance = 0\n for index, amount in enumerate(transactions):\n balance += amount\n if balance < limit:\n return index, balance\n return None, balance","input":"first_overdraft([100, -60, -30, -50, 200], -20)","language":"Python","predicted_output":"(3, -40)"} |
| {"id":"cmsspyuqf002wg4p208xr961i","kind":"contributor_item","title":"Submission XR961I","provisional":false,"code":"def prune_stale(inventory, threshold):\n removed = []\n for sku in list(inventory):\n if inventory[sku] < threshold:\n removed.append(sku)\n del inventory[sku]\n return inventory, removed","input":"prune_stale({'ab': 5, 'cd': 0, 'ef': 12, 'gh': 2}, 3)","language":"Python","predicted_output":"({'ab': 5, 'ef': 12}, ['cd', 'gh'])"} |
| {"id":"cmsspyuqf002yg4p2b6qc2t7c","kind":"contributor_item","title":"Submission QC2T7C","provisional":false,"code":"def collect(value, bucket=[]):\n bucket.append(value)\n return list(bucket)\n\ndef demo():\n return collect(1), collect(2), collect(3)","input":"demo()","language":"Python","predicted_output":"([1], [1, 2], [1, 2, 3])"} |
| {"id":"cmsspyuqf002xg4p2g7k2hibx","kind":"contributor_item","title":"Submission K2HIBX","provisional":false,"code":"def normalize_code(raw, width=4):\n cleaned = ''.join(ch for ch in raw if ch.isalnum()).upper()\n chunks = [cleaned[i:i + width] for i in range(0, len(cleaned), width)]\n return '-'.join(chunks), cleaned[::-1][:width]","input":"normalize_code('ab-12 cd/3e', 3)","language":"Python","predicted_output":"('AB1-2CD-3E', 'E3D')"} |
| {"id":"cmsspyuqf0030g4p2nw3dbklz","kind":"contributor_item","title":"Submission 3DBKLZ","provisional":false,"code":"def rank_entries(entries):\n by_score = sorted(entries, key=lambda e: e[1], reverse=True)\n return [name for name, _ in by_score]","input":"rank_entries([('ivy', 7), ('jon', 9), ('kai', 7), ('lee', 9), ('moe', 3)])","language":"Python","predicted_output":"['jon', 'lee', 'ivy', 'kai', 'moe']"} |
| {"id":"cmsspyuqf002zg4p2furpyfd8","kind":"contributor_item","title":"Submission RPYFD8","provisional":false,"code":"def split_shifts(total_minutes, per_shift):\n full = total_minutes // per_shift\n remainder = total_minutes % per_shift\n ratio = total_minutes / per_shift\n return full, remainder, round(ratio, 2)","input":"split_shifts(-95, 30)","language":"Python","predicted_output":"(-4, 25, -3.17)"} |
| {"id":"cmsspyuqf0032g4p23huiam7j","kind":"contributor_item","title":"Submission UIAM7J","provisional":false,"code":"def make_adders(offsets):\n funcs = []\n for off in offsets:\n funcs.append(lambda x, off=off: x + off)\n late = []\n for off in offsets:\n late.append(lambda x: x + off)\n return [f(10) for f in funcs], [f(10) for f in late]","input":"make_adders([1, 2, 3])","language":"Python","predicted_output":"([11, 12, 13], [13, 13, 13])"} |
| {"id":"cmsspyuqf0031g4p2djp90mjw","kind":"contributor_item","title":"Submission P90MJW","provisional":false,"code":"def guarded(steps):\n log = []\n for step in steps:\n try:\n if step == 'boom':\n raise RuntimeError(step)\n log.append('ok:' + step)\n except RuntimeError as exc:\n log.append('err:' + str(exc))\n continue\n finally:\n log.append('fin')\n return log","input":"guarded(['a', 'boom', 'b'])","language":"Python","predicted_output":"['ok:a', 'fin', 'err:boom', 'fin', 'ok:b', 'fin']"} |
| {"id":"cmsspyuqf0036g4p2w5nrawi0","kind":"contributor_item","title":"Submission NRAWI0","provisional":false,"code":"def audit_flags(readings, ceiling):\n breaches = [r > ceiling for r in readings]\n return sum(breaches), breaches.count(True), all(breaches), any(breaches)","input":"audit_flags([3, 11, 7, 20], 10)","language":"Python","predicted_output":"(2, 2, False, True)"} |
| {"id":"cmsspyuqf0035g4p2gd97u6zt","kind":"contributor_item","title":"Submission 97U6ZT","provisional":false,"code":"def paths(rows, cols, memo=None):\n if memo is None:\n memo = {}\n if rows == 1 or cols == 1:\n return 1\n key = (rows, cols)\n if key not in memo:\n memo[key] = paths(rows - 1, cols, memo) + paths(rows, cols - 1, memo)\n return memo[key]","input":"(paths(3, 3), paths(4, 2), paths(1, 9))","language":"Python","predicted_output":"(6, 4, 1)"} |
| {"id":"cmssudjwf007dg4p26ho7spcu","kind":"contributor_item","title":"Submission O7SPCU","provisional":false,"code":"def alternating_totals(values):\n total=0\n out=[]\n for i,v in enumerate(values):\n total += v if i%2==0 else -v\n out.append(total)\n return out","input":"alternating_totals([5,2,4,1])","language":"Python","predicted_output":"[5, 3, 7, 6]"} |
| {"id":"cmssudjwf007fg4p2oxtjjlpv","kind":"contributor_item","title":"Submission TJJLPV","provisional":false,"code":"def normalize_counts(words):\n from collections import Counter\n c=Counter(w.lower() for w in words)\n return sorted(c.items())","input":"normalize_counts(['A','b','a','B','c'])","language":"Python","predicted_output":"[('a', 2), ('b', 2), ('c', 1)]"} |
| {"id":"cmssudjwg007ig4p2ly0j2u56","kind":"contributor_item","title":"Submission 0J2U56","provisional":false,"code":"def safe_get(mapping,path,default=None):\n cur=mapping\n for key in path:\n if not isinstance(cur,dict) or key not in cur:\n return default\n cur=cur[key]\n return cur","input":"safe_get({'a':{'b':{'c':7}}},['a','b','c'],'x')","language":"Python","predicted_output":"7"} |
| {"id":"cmssudjwg007hg4p2ob3lwuy6","kind":"contributor_item","title":"Submission 3LWUY6","provisional":false,"code":"def rotate_pairs(items):\n return [(b,a) for a,b in items[::-1]]","input":"rotate_pairs([(1,'a'),(2,'b'),(3,'c')])","language":"Python","predicted_output":"[('c', 3), ('b', 2), ('a', 1)]"} |
| {"id":"cmssudjwg007lg4p2vxs4age0","kind":"contributor_item","title":"Submission S4AGE0","provisional":false,"code":"def unique_preserve(seq):\n seen=set(); out=[]\n for x in seq:\n if x not in seen:\n seen.add(x); out.append(x)\n return out","input":"unique_preserve([3,1,3,2,1,4])","language":"Python","predicted_output":"[3, 1, 2, 4]"} |
| {"id":"cmssudjwg007mg4p2g9rvuyur","kind":"contributor_item","title":"Submission RVUYUR","provisional":false,"code":"def score_rows(rows):\n return [name+':' + str(sum(vals)) for name,*vals in rows]","input":"score_rows([('a',2,3),('b',5,-1,2)])","language":"Python","predicted_output":"['a:5', 'b:6']"} |
| {"id":"cmssudjwg007vg4p2obmkwd8s","kind":"contributor_item","title":"Submission MKWD8S","provisional":false,"code":"def index_by_initial(words):\n out={}\n for w in words:\n out.setdefault(w[0].lower(),[]).append(w)\n return out","input":"index_by_initial(['Apple','ant','Boat','berry'])","language":"Python","predicted_output":"{'a': ['Apple', 'ant'], 'b': ['Boat', 'berry']}"} |
| {"id":"cmssudjwg007yg4p2dkwbv3p8","kind":"contributor_item","title":"Submission WBV3P8","provisional":false,"code":"def guarded_divisions(pairs):\n out=[]\n for a,b in pairs:\n try: out.append(round(a/b,2))\n except ZeroDivisionError: out.append(None)\n return out","input":"guarded_divisions([(5,2),(7,0),(-3,2)])","language":"Python","predicted_output":"[2.5, None, -1.5]"} |
| {"id":"cmssudjwg0080g4p2wgpfwgfh","kind":"contributor_item","title":"Submission PFWGFH","provisional":false,"code":"def map_lengths(mapping):\n return {k:len(v) for k,v in sorted(mapping.items())}","input":"map_lengths({'b':[1,2,3],'a':[],'c':[9]})","language":"Python","predicted_output":"{'a': 0, 'b': 3, 'c': 1}"} |
| {"id":"cmssudjwg007kg4p2yxejllg5","kind":"contributor_item","title":"Submission EJLLG5","provisional":false,"code":"def classify(nums):\n return {'neg':sum(x<0 for x in nums),'zero':sum(x==0 for x in nums),'pos':sum(x>0 for x in nums)}","input":"classify([-2,0,4,5,-1,0])","language":"Python","predicted_output":"{'neg': 2, 'zero': 2, 'pos': 2}"} |
| {"id":"cmssudjwg007ng4p2mn7khp0w","kind":"contributor_item","title":"Submission 7KHP0W","provisional":false,"code":"def invert_groups(groups):\n out={}\n for k,vals in groups.items():\n for v in vals:\n out.setdefault(v,[]).append(k)\n return out","input":"invert_groups({'x':[1,2],'y':[2,3]})","language":"Python","predicted_output":"{1: ['x'], 2: ['x', 'y'], 3: ['y']}"} |
| {"id":"cmssudjwg007rg4p2j2aruwnn","kind":"contributor_item","title":"Submission ARUWNN","provisional":false,"code":"def split_even_odd(nums):\n return ([x for x in nums if x%2==0],[x for x in nums if x%2])","input":"split_even_odd([5,2,8,3,0,-1])","language":"Python","predicted_output":"([2, 8, 0], [5, 3, -1])"} |
| {"id":"cmssudjwg007tg4p2odxhirea","kind":"contributor_item","title":"Submission XHIREA","provisional":false,"code":"def take_until(values,predicate):\n out=[]\n for x in values:\n if predicate(x): break\n out.append(x)\n return out","input":"take_until([2,4,7,8], lambda x:x%2==1)","language":"Python","predicted_output":"[2, 4]"} |
| {"id":"cmssudjwf007eg4p2d6z2tpao","kind":"contributor_item","title":"Submission Z2TPAO","provisional":false,"code":"def chunk_sums(values,size):\n return [sum(values[i:i+size]) for i in range(0,len(values),size)]","input":"chunk_sums([1,2,3,4,5],2)","language":"Python","predicted_output":"[3, 7, 5]"} |
| {"id":"cmssudjwg007jg4p2re87nx4e","kind":"contributor_item","title":"Submission 87NX4E","provisional":false,"code":"def window_diffs(values):\n return [values[i+1]-values[i] for i in range(len(values)-1)]","input":"window_diffs([10,7,9,3])","language":"Python","predicted_output":"[-3, 2, -6]"} |
| {"id":"cmssudjwg007og4p2b0i89ep1","kind":"contributor_item","title":"Submission I89EP1","provisional":false,"code":"def clamp_and_sum(values,lo,hi):\n return sum(min(hi,max(lo,v)) for v in values)","input":"clamp_and_sum([-5,3,20,7],0,10)","language":"Python","predicted_output":"20"} |
| {"id":"cmssudjwg007qg4p22ei52l12","kind":"contributor_item","title":"Submission I52L12","provisional":false,"code":"def cumulative_lengths(words):\n total=0; out=[]\n for w in words:\n total+=len(w); out.append(total)\n return out","input":"cumulative_lengths(['ab','cde','','x'])","language":"Python","predicted_output":"[2, 5, 5, 6]"} |
| {"id":"cmssudjwg007pg4p2p8n6weih","kind":"contributor_item","title":"Submission N6WEIH","provisional":false,"code":"def parse_flags(tokens):\n result={}\n for token in tokens:\n if token.startswith('--') and '=' in token:\n k,v=token[2:].split('=',1); result[k]=v\n return result","input":"parse_flags(['--mode=fast','x','--retry=3','--mode=safe'])","language":"Python","predicted_output":"{'mode': 'safe', 'retry': '3'}"} |
| {"id":"cmssudjwg007sg4p2jk4a922h","kind":"contributor_item","title":"Submission 4A922H","provisional":false,"code":"def summarize_matrix(m):\n return [sum(row) for row in m], [sum(col) for col in zip(*m)]","input":"summarize_matrix([[1,2,3],[4,5,6]])","language":"Python","predicted_output":"([6, 15], [5, 7, 9])"} |
| {"id":"cmssudjwg007zg4p2963assqt","kind":"contributor_item","title":"Submission 3ASSQT","provisional":false,"code":"def suffix_totals(nums):\n out=[0]*len(nums); total=0\n for i in range(len(nums)-1,-1,-1):\n total+=nums[i]; out[i]=total\n return out","input":"suffix_totals([3,-1,4,2])","language":"Python","predicted_output":"[8, 5, 6, 2]"} |
| {"id":"cmssudjwg007xg4p2qz8dtsc0","kind":"contributor_item","title":"Submission 8DTSC0","provisional":false,"code":"def pairwise_min(a,b):\n return [min(x,y) for x,y in zip(a,b)]","input":"pairwise_min([3,8,-1,5],[4,2,-3,9])","language":"Python","predicted_output":"[3, 2, -3, 5]"} |
| {"id":"cmssudjwg0083g4p2fenbb2a1","kind":"contributor_item","title":"Submission NBB2A1","provisional":false,"code":"def trim_empty(rows):\n return [[x for x in row if x is not None] for row in rows if any(x is not None for x in row)]","input":"trim_empty([[1,None,2],[None,None],[3,4,None]])","language":"Python","predicted_output":"[[1, 2], [3, 4]]"} |
| {"id":"cmssudjwg0082g4p20gxcz7xf","kind":"contributor_item","title":"Submission XCZ7XF","provisional":false,"code":"def weighted_sum(values):\n return sum((i+1)*v for i,v in enumerate(values))","input":"weighted_sum([4,-2,3])","language":"Python","predicted_output":"9"} |
| {"id":"cmssudjwg0086g4p2c02cdew6","kind":"contributor_item","title":"Submission 2CDEW6","provisional":false,"code":"def partition_threshold(values,t):\n low=[x for x in values if x<t]; high=[x for x in values if x>=t]\n return low,high","input":"partition_threshold([5,1,7,3,5],5)","language":"Python","predicted_output":"([1, 3], [5, 7, 5])"} |
| {"id":"cmssudjwg0084g4p29zad55l5","kind":"contributor_item","title":"Submission AD55L5","provisional":false,"code":"def histogram_lengths(words):\n from collections import Counter\n return dict(sorted(Counter(map(len,words)).items()))","input":"histogram_lengths(['a','to','be','cat',''])","language":"Python","predicted_output":"{0: 1, 1: 1, 2: 2, 3: 1}"} |
| {"id":"cmssudjwg0085g4p2lzdwiqn6","kind":"contributor_item","title":"Submission DWIQN6","provisional":false,"code":"def diagonal_sum(matrix):\n return sum(row[i] for i,row in enumerate(matrix) if i < len(row))","input":"diagonal_sum([[2,9,1],[4,3],[7,8,5,6]])","language":"Python","predicted_output":"10"} |
| {"id":"cmst1udzu00aqg4p2e3ir9cwg","kind":"contributor_item","title":"Submission IR9CWG","provisional":false,"code":"def collect(x, acc=[]):\n acc.append(x)\n return acc","input":"(collect(1), collect(2), collect(3))","language":"Python","predicted_output":"([1, 2, 3], [1, 2, 3], [1, 2, 3])"} |
| {"id":"cmst1udzv00b5g4p21dbimg2s","kind":"contributor_item","title":"Submission BIMG2S","provisional":false,"code":"def pick(a, b):\n return (a or b, a and b)","input":"(pick(0, 5), pick('x', ''))","language":"Python","predicted_output":"((5, 0), ('x', ''))"} |
| {"id":"cmst1udzv00b6g4p2efbcvcwr","kind":"contributor_item","title":"Submission BCVCWR","provisional":false,"code":"def grow(xs, s):\n xs.append(s)\n xs.extend(s)\n return xs","input":"grow([], 'hi')","language":"Python","predicted_output":"['hi', 'h', 'i']"} |
| {"id":"cmst1udzv00b0g4p22eqs4joi","kind":"contributor_item","title":"Submission QS4JOI","provisional":false,"code":"def gen():\n log = []\n def g():\n for i in range(3):\n log.append(('yield', i))\n yield i * i\n squares = list(g())\n return (squares, log)","input":"gen()","language":"Python","predicted_output":"([0, 1, 4], [('yield', 0), ('yield', 1), ('yield', 2)])"} |
| {"id":"cmst1udzv00axg4p2azmwoq3t","kind":"contributor_item","title":"Submission MWOQ3T","provisional":false,"code":"def order(pairs):\n return sorted(pairs, key=lambda p: p[0])","input":"order([(1, 'a'), (0, 'b'), (1, 'c'), (0, 'd')])","language":"Python","predicted_output":"[(0, 'b'), (0, 'd'), (1, 'a'), (1, 'c')]"} |
| {"id":"cmst1udzu00atg4p2upy8vf9i","kind":"contributor_item","title":"Submission Y8VF9I","provisional":false,"code":"def cmp(n):\n a = n\n b = int(str(n))\n return (a == b, a is b)","input":"(cmp(256), cmp(257))","language":"Python","predicted_output":"((True, True), (True, False))"} |
| {"id":"cmst1udzu00arg4p2rzcuuwl6","kind":"contributor_item","title":"Submission CUUWL6","provisional":false,"code":"def build():\n d = {}\n d['a'] = 1\n d['b'] = 2\n d['a'] = 3\n return list(d.items())","input":"build()","language":"Python","predicted_output":"[('a', 3), ('b', 2)]"} |
| {"id":"cmst1udzu00asg4p2ktuvotwh","kind":"contributor_item","title":"Submission UVOTWH","provisional":false,"code":"def dm(a, b):\n return (a // b, a % b)","input":"(dm(-7, 3), dm(7, -3))","language":"Python","predicted_output":"((-3, 2), (-3, -2))"} |
| {"id":"cmst1udzv00avg4p2xn85v05h","kind":"contributor_item","title":"Submission 85V05H","provisional":false,"code":"def splice(xs):\n xs[1:3] = [9, 9, 9]\n return xs","input":"splice([0, 1, 2, 3])","language":"Python","predicted_output":"[0, 9, 9, 9, 3]"} |
| {"id":"cmst1udzv00awg4p2jo2mbawk","kind":"contributor_item","title":"Submission 2MBAWK","provisional":false,"code":"def make():\n fns = []\n for i in range(3):\n fns.append(lambda: i)\n return [f() for f in fns]","input":"make()","language":"Python","predicted_output":"[2, 2, 2]"} |
| {"id":"cmst1udzv00aug4p2fz677u9a","kind":"contributor_item","title":"Submission 677U9A","provisional":false,"code":"def chained(seq):\n log = []\n def val(x):\n log.append(x)\n return x\n result = val(seq[0]) < val(seq[1]) < val(seq[2])\n return (result, log)","input":"chained([1, 0, 5])","language":"Python","predicted_output":"(False, [1, 0])"} |
| {"id":"cmst1udzv00azg4p2qi2i2n6d","kind":"contributor_item","title":"Submission 2I2N6D","provisional":false,"code":"def rep(s, n):\n return (s * n, bool(s * n))","input":"(rep('ab', 3), rep('x', 0))","language":"Python","predicted_output":"(('ababab', True), ('', False))"} |
| {"id":"cmst1udzv00b1g4p2gar9tz3g","kind":"contributor_item","title":"Submission R9TZ3G","provisional":false,"code":"def parse(items):\n out = []\n for it in items:\n try:\n out.append(int(it))\n except ValueError:\n out.append(None)\n return out","input":"parse(['1', 'x', '3', ''])","language":"Python","predicted_output":"[1, None, 3, None]"} |
| {"id":"cmst1udzv00ayg4p2bl2xhrtc","kind":"contributor_item","title":"Submission 2XHRTC","provisional":false,"code":"def dedup(xs):\n seen = set()\n out = []\n for x in xs:\n if x not in seen:\n seen.add(x)\n out.append(x)\n return out","input":"dedup([3, 1, 3, 2, 1, 4])","language":"Python","predicted_output":"[3, 1, 2, 4]"} |
| {"id":"cmst1udzv00b3g4p2ujqji6zo","kind":"contributor_item","title":"Submission QJI6ZO","provisional":false,"code":"def split(xs):\n first, *middle, last = xs\n return (first, middle, last)","input":"split([10, 20, 30, 40, 50])","language":"Python","predicted_output":"(10, [20, 30, 40], 50)"} |
| {"id":"cmst1udzv00b2g4p28ls4u583","kind":"contributor_item","title":"Submission S4U583","provisional":false,"code":"def counts(text):\n c = {}\n for ch in text:\n c[ch] = c.get(ch, 0) + 1\n return sorted(c.items())","input":"counts('banana')","language":"Python","predicted_output":"[('a', 3), ('b', 1), ('n', 2)]"} |
| {"id":"cmst1udzv00b4g4p29yoco2m9","kind":"contributor_item","title":"Submission OCO2M9","provisional":false,"code":"def half(n):\n return (n / 2, n // 2)","input":"(half(5), half(4))","language":"Python","predicted_output":"((2.5, 2), (2.0, 2))"} |
| {"id":"cmst1udzv00b9g4p2fphu3npc","kind":"contributor_item","title":"Submission HU3NPC","provisional":false,"code":"def alias():\n a = [1, 2, 3]\n b = a\n c = a[:]\n a.append(4)\n return (b, c)","input":"alias()","language":"Python","predicted_output":"([1, 2, 3, 4], [1, 2, 3])"} |
| {"id":"cmst1udzv00b8g4p2juewpe8o","kind":"contributor_item","title":"Submission EWPE8O","provisional":false,"code":"def rnd(xs):\n return [round(x) for x in xs]","input":"rnd([0.5, 1.5, 2.5, 3.5])","language":"Python","predicted_output":"[0, 2, 2, 4]"} |
| {"id":"cmst1udzv00b7g4p29phax3pj","kind":"contributor_item","title":"Submission HAX3PJ","provisional":false,"code":"def pairup(a, b):\n return [(i, x, y) for i, (x, y) in enumerate(zip(a, b), start=1)]","input":"pairup([1, 2, 3, 4], ['a', 'b', 'c'])","language":"Python","predicted_output":"[(1, 1, 'a'), (2, 2, 'b'), (3, 3, 'c')]"} |
| {"id":"cmst58o6y00cpg4p2wr5hjruj","kind":"contributor_item","title":"Submission 5HJRUJ","provisional":false,"code":"def accumulator(start=0):\n total = start\n received = []\n while True:\n value = yield total\n if value is None:\n received.append('none')\n continue\n total += value\n received.append(value)\n if total > 100:\n return received\n\n\ndef drive(steps):\n gen = accumulator(10)\n seen = [next(gen)]\n ended = None\n for s in steps:\n try:\n seen.append(gen.send(s))\n except StopIteration as stop:\n ended = stop.value\n break\n return (seen, ended)","input":"drive([5, 20, None, 70])","language":"Python","predicted_output":"([10, 15, 35, 35], [5, 20, 'none', 70])"} |
| {"id":"cmst58o6y00crg4p2x4jnu947","kind":"contributor_item","title":"Submission JNU947","provisional":false,"code":"from itertools import zip_longest\n\n\ndef merge(names, scores):\n padded = ['{}:{}'.format(n, s) for n, s in zip_longest(names, scores, fillvalue='?')]\n truncated = list(zip(names, scores))\n numeric = dict(zip_longest(names, scores, fillvalue=0))\n default_fill = list(zip_longest(names, scores))\n return (padded, len(truncated), numeric, default_fill[-1])","input":"merge(['a', 'b', 'c'], [1, 2])","language":"Python","predicted_output":"(['a:1', 'b:2', 'c:?'], 2, {'a': 1, 'b': 2, 'c': 0}, ('c', None))"} |
| {"id":"cmst58o6y00cvg4p2utz2o1cm","kind":"contributor_item","title":"Submission Z2O1CM","provisional":false,"code":"def explicit(raw):\n try:\n return int(raw)\n except ValueError as exc:\n raise TypeError('bad literal') from exc\n\n\ndef implicit(raw):\n try:\n return int(raw)\n except ValueError:\n raise TypeError('implicit')\n\n\ndef cleaned(raw):\n try:\n return int(raw)\n except ValueError:\n raise TypeError('clean') from None\n\n\ndef inspect(fn, raw):\n try:\n fn(raw)\n except TypeError as exc:\n cause = type(exc.__cause__).__name__ if exc.__cause__ is not None else None\n context = type(exc.__context__).__name__ if exc.__context__ is not None else None\n return (exc.args[0], cause, context, exc.__suppress_context__)\n return 'no error'\n\n\ndef chain_report():\n return (inspect(explicit, 'x'), inspect(implicit, 'x'), inspect(cleaned, 'x'), inspect(explicit, '7'))","input":"chain_report()","language":"Python","predicted_output":"(('bad literal', 'ValueError', 'ValueError', True), ('implicit', None, 'ValueError', False), ('clean', None, 'ValueError', True), 'no error')"} |
| {"id":"cmst58o6y00cfg4p2od2o36h3","kind":"contributor_item","title":"Submission 2O36H3","provisional":false,"code":"class Thermostat:\n def __init__(self, celsius):\n self._history = []\n self.celsius = celsius\n\n @property\n def celsius(self):\n return self._celsius\n\n @celsius.setter\n def celsius(self, value):\n self._celsius = max(0, min(40, value))\n self._history.append(self._celsius)\n\n @property\n def fahrenheit(self):\n return self._celsius * 9 / 5 + 32\n\n\ndef thermostat_run():\n t = Thermostat(55)\n t.celsius = -10\n t.celsius = 21\n locked = None\n try:\n t.fahrenheit = 100\n except AttributeError:\n locked = 'read-only'\n return (t.celsius, t.fahrenheit, t._history, locked)","input":"thermostat_run()","language":"Python","predicted_output":"(21, 69.8, [40, 0, 21], 'read-only')"} |
| {"id":"cmst58o6y00ceg4p2ckihxdpc","kind":"contributor_item","title":"Submission IHXDPC","provisional":false,"code":"class Point:\n __slots__ = ('x', 'y')\n\n def __init__(self, x, y):\n self.x = x\n self.y = y\n\n\nclass Tagged(Point):\n pass\n\n\ndef slots_probe():\n report = []\n p = Point(1, 2)\n try:\n p.z = 3\n report.append('assigned')\n except AttributeError as exc:\n report.append(type(exc).__name__)\n report.append(hasattr(p, '__dict__'))\n t = Tagged(3, 4)\n t.z = 5\n report.append(hasattr(t, '__dict__'))\n report.append(t.z + t.x)\n report.append(Point.__slots__)\n return tuple(report)","input":"slots_probe()","language":"Python","predicted_output":"('AttributeError', False, True, 8, ('x', 'y'))"} |
| {"id":"cmst58o6y00cjg4p2ohaiqbh4","kind":"contributor_item","title":"Submission AIQBH4","provisional":false,"code":"from collections import defaultdict\n\n\ndef build_groups(keys):\n calls = []\n\n def expensive(k):\n calls.append(k)\n return [k]\n\n plain = {}\n for k in keys:\n plain.setdefault(k, expensive(k)).append('p')\n\n dd = defaultdict(list)\n for k in keys:\n dd[k].append('d')\n\n return (plain, len(calls), calls, dict(dd), dd['zz'], len(dd))","input":"build_groups(['a', 'b', 'a'])","language":"Python","predicted_output":"({'a': ['a', 'p', 'p'], 'b': ['b', 'p']}, 3, ['a', 'b', 'a'], {'a': ['d', 'd'], 'b': ['d']}, [], 3)"} |
| {"id":"cmst58o6y00clg4p2n7uwnsn8","kind":"contributor_item","title":"Submission UWNSN8","provisional":false,"code":"def chain_probe(values):\n calls = []\n\n def mid(v):\n calls.append(v)\n return v\n\n results = []\n for v in values:\n results.append(1 < mid(v) < 10)\n short = 0 < mid(-5) < mid(99)\n return (results, calls, short)","input":"chain_probe([5, 20])","language":"Python","predicted_output":"([True, False], [5, 20, -5], False)"} |
| {"id":"cmst58o6y00cmg4p2d7adiujo","kind":"contributor_item","title":"Submission ADIUJO","provisional":false,"code":"def identity_probe():\n small_a, small_b = 256, int('256')\n big_a, big_b = 257, int('257')\n neg_a, neg_b = -5, int('-5')\n far_a, far_b = -6, int('-6')\n return (\n (small_a == small_b, small_a is small_b),\n (big_a == big_b, big_a is big_b),\n (neg_a == neg_b, neg_a is neg_b),\n (far_a == far_b, far_a is far_b),\n )","input":"identity_probe()","language":"Python","predicted_output":"((True, True), (True, False), (True, True), (True, False))"} |
| {"id":"cmst58o6y00chg4p2ibju1cgi","kind":"contributor_item","title":"Submission JU1CGI","provisional":false,"code":"from dataclasses import dataclass, field\n\n\n@dataclass(order=True)\nclass Task:\n priority: int\n name: str = field(compare=False)\n tags: list = field(default_factory=list, compare=False)\n\n\ndef task_run():\n a = Task(2, 'alpha')\n b = Task(2, 'beta', ['x'])\n c = Task(1, 'gamma')\n ordered = [t.name for t in sorted([a, b, c])]\n return (a == b, a < c, ordered, repr(c))","input":"task_run()","language":"Python","predicted_output":"(True, False, ['gamma', 'alpha', 'beta'], \"Task(priority=1, name='gamma', tags=[])\")"} |
| {"id":"cmst58o6y00cug4p2kjybo9y3","kind":"contributor_item","title":"Submission YBO9Y3","provisional":false,"code":"def build_config():\n scale = 10\n\n class Config:\n base = [1, 2, 3]\n doubled = [v * 2 for v in base]\n scaled = [v * scale for v in base]\n try:\n widths = [v * len(base) for v in base]\n except NameError as exc:\n widths = type(exc).__name__\n\n return (Config.doubled, Config.scaled, Config.widths, [v * len(Config.base) for v in Config.base])","input":"build_config()","language":"Python","predicted_output":"([2, 4, 6], [10, 20, 30], 'NameError', [3, 6, 9])"} |
| {"id":"cmst58o6y00ctg4p2gt67dvhy","kind":"contributor_item","title":"Submission 67DVHY","provisional":false,"code":"class Tracker:\n def __init__(self):\n self.data = {'x': 1}\n self.hits = []\n\n def __getattr__(self, name):\n self.hits.append(('missing', name))\n if name in self.data:\n return self.data[name]\n raise AttributeError(name)\n\n\nclass Loud:\n def __init__(self):\n object.__setattr__(self, 'log', [])\n object.__setattr__(self, 'real', 7)\n\n def __getattribute__(self, name):\n object.__getattribute__(self, 'log').append(name)\n if name == 'real':\n return 'intercepted'\n return object.__getattribute__(self, name)\n\n def __getattr__(self, name):\n return 'fallback:' + name\n\n\ndef attr_run():\n t = Tracker()\n got = (t.x, t.data['x'])\n err = None\n try:\n t.nope\n except AttributeError as exc:\n err = exc.args[0]\n hits = list(t.hits)\n lo = Loud()\n values = (lo.real, lo.missing)\n raw = object.__getattribute__(lo, 'real')\n return (got, hits, err, values, raw, lo.log)","input":"attr_run()","language":"Python","predicted_output":"((1, 1), [('missing', 'x'), ('missing', 'nope')], 'nope', ('intercepted', 'fallback:missing'), 7, ['real', 'missing', 'log'])"} |
| {"id":"cmst58o6y00cgg4p2naan9btd","kind":"contributor_item","title":"Submission AN9BTD","provisional":false,"code":"class Quiet:\n def __init__(self, *exc_types):\n self.exc_types = exc_types\n self.caught = None\n\n def __enter__(self):\n return self\n\n def __exit__(self, exc_type, exc, tb):\n if exc_type is not None and issubclass(exc_type, self.exc_types):\n self.caught = exc_type.__name__\n return True\n return False\n\n\ndef suppress_run():\n log = []\n q = Quiet(ValueError)\n with q:\n log.append('start')\n raise ValueError('bad')\n log.append('unreachable')\n log.append('after')\n log.append(q.caught)\n try:\n with Quiet(ValueError):\n raise KeyError('k')\n except KeyError as exc:\n log.append(exc.args[0])\n return log","input":"suppress_run()","language":"Python","predicted_output":"['start', 'after', 'ValueError', 'k']"} |
| {"id":"cmst58o6y00cig4p2jd6dfjp3","kind":"contributor_item","title":"Submission 6DFJP3","provisional":false,"code":"def make_counter():\n count = 0\n history = []\n\n def bump(step=1):\n nonlocal count\n count += step\n history.append(count)\n return count\n\n def reset():\n count = 0\n return count\n\n return bump, reset, (lambda: count), history\n\n\ndef counter_run():\n bump, reset, peek, history = make_counter()\n bump()\n bump(3)\n before = peek()\n returned = reset()\n return (before, returned, peek(), bump(0), history)","input":"counter_run()","language":"Python","predicted_output":"(4, 0, 4, 4, [1, 4, 4])"} |
| {"id":"cmst58o6y00cog4p27c04pk9j","kind":"contributor_item","title":"Submission 04PK9J","provisional":false,"code":"def normalize(text):\n table = str.maketrans({'a': '4', 'e': None, 'l': 'LL', ' ': '_'})\n strict = text.translate(table)\n fallback = text.translate(str.maketrans('abc', 'xyz', 'd'))\n return (strict, fallback, len(strict), text.translate({}) == text)","input":"normalize('ale bead')","language":"Python","predicted_output":"('4LL_b4d', 'xle yex', 7, True)"} |
| {"id":"cmst58o6y00cng4p2gcpv0qew","kind":"contributor_item","title":"Submission PV0QEW","provisional":false,"code":"def rank(records):\n by_tuple = [r['name'] for r in sorted(records, key=lambda r: (r['score'], r['name']))]\n reversed_all = [r['name'] for r in sorted(records, key=lambda r: (r['score'], r['name']), reverse=True)]\n negated = [r['name'] for r in sorted(records, key=lambda r: (-r['score'], r['name']))]\n ties_kept = [r['name'] for r in sorted(records, key=lambda r: r['score'], reverse=True)]\n return (by_tuple, reversed_all, negated, ties_kept)","input":"rank([{'name': 'ana', 'score': 3}, {'name': 'bo', 'score': 1}, {'name': 'cy', 'score': 3}, {'name': 'al', 'score': 3}])","language":"Python","predicted_output":"(['bo', 'al', 'ana', 'cy'], ['cy', 'ana', 'al', 'bo'], ['al', 'ana', 'cy', 'bo'], ['ana', 'cy', 'al', 'bo'])"} |
| {"id":"cmst58o6y00cqg4p2su3ut2cn","kind":"contributor_item","title":"Submission 3UT2CN","provisional":false,"code":"from itertools import islice, tee\n\n\ndef split_probe(source):\n it = iter(source)\n first = next(it)\n a, b = tee(it, 2)\n head_a = list(islice(a, 2))\n stolen = next(it)\n head_b = list(islice(b, 2))\n rest_a = list(a)\n rest_b = list(b)\n return (first, head_a, head_b, stolen, rest_a, rest_b, stolen in rest_b)","input":"split_probe([1, 2, 3, 4, 5, 6, 7])","language":"Python","predicted_output":"(1, [2, 3], [2, 3], 4, [5, 6, 7], [5, 6, 7], False)"} |
| {"id":"cmst58o6y00csg4p2tihi23ya","kind":"contributor_item","title":"Submission HI23YA","provisional":false,"code":"from functools import partial\n\n\ndef report(label, *values, sep='-', upper=False):\n body = sep.join(str(v) for v in values)\n text = '{}{}{}'.format(label, sep, body)\n return text.upper() if upper else text\n\n\ndef partial_run():\n p1 = partial(report, 'head')\n p2 = partial(report, sep='|')\n p3 = partial(p1, 1, 2, upper=True)\n a = p1(1, 2)\n b = p2('x', 9, sep='+')\n c = p3(3)\n d = partial(report, 'A', 'B')('C')\n return (a, b, c, d, p3.args, p1.func is report)","input":"partial_run()","language":"Python","predicted_output":"('head-1-2', 'x+9', 'HEAD-1-2-3', 'A-B-C', ('head', 1, 2), True)"} |
| {"id":"cmst58o6y00cxg4p23x6wiu7d","kind":"contributor_item","title":"Submission 6WIU7D","provisional":false,"code":"def combine(base, extra):\n left = base | extra\n right = extra | base\n inplace = dict(base)\n inplace |= extra\n from_pairs = dict(base)\n from_pairs |= [('z', 9), ('a', 0)]\n err = None\n try:\n base | [('q', 1)]\n except TypeError:\n err = 'TypeError'\n return (left, right, inplace, from_pairs, base, left is base, err)","input":"combine({'a': 1, 'b': 2}, {'b': 20, 'c': 3})","language":"Python","predicted_output":"({'a': 1, 'b': 20, 'c': 3}, {'b': 2, 'c': 3, 'a': 1}, {'a': 1, 'b': 20, 'c': 3}, {'a': 0, 'b': 2, 'z': 9}, {'a': 1, 'b': 2}, False, 'TypeError')"} |
| {"id":"cmst58o6y00ckg4p2hfyy988o","kind":"contributor_item","title":"Submission YY988O","provisional":false,"code":"def grid_report(rows, cols):\n shallow = [[0] * cols] * rows\n proper = [[0] * cols for _ in range(rows)]\n shallow[0][0] = 9\n proper[0][0] = 9\n row = [1, 2]\n row *= 2\n nested = [row]\n nested *= 2\n nested[0].append(7)\n return (shallow, proper, nested, nested[0] is nested[1], row is nested[1])","input":"grid_report(2, 3)","language":"Python","predicted_output":"([[9, 0, 0], [9, 0, 0]], [[9, 0, 0], [0, 0, 0]], [[1, 2, 1, 2, 7], [1, 2, 1, 2, 7]], True, True)"} |
| {"id":"cmst58o6y00cwg4p23cwyu10o","kind":"contributor_item","title":"Submission WYU10O","provisional":false,"code":"class Money:\n def __init__(self, cents):\n self.cents = cents\n\n def __add__(self, other):\n if isinstance(other, Money):\n return Money(self.cents + other.cents)\n if isinstance(other, int):\n return Money(self.cents + other)\n return NotImplemented\n\n def __radd__(self, other):\n return Money(self.cents + other + 1000)\n\n def __repr__(self):\n return 'Money({})'.format(self.cents)\n\n\nclass Premium(Money):\n def __radd__(self, other):\n return Money(self.cents * 2)\n\n\ndef money_run():\n a = Money(50)\n left = a + 5\n right = 5 + a\n total = sum([Money(1), Money(2)], Money(0))\n mixed = Money(10) + Premium(3)\n reflected = 7 + Premium(3)\n err = None\n try:\n Money(1) + 'x'\n except TypeError:\n err = 'TypeError'\n return (left, right, total, mixed, reflected, err)","input":"money_run()","language":"Python","predicted_output":"(Money(55), Money(1055), Money(3), Money(6), Money(6), 'TypeError')"} |
| {"id":"cmsu44b3l00f9g4p23xc4r2s1","kind":"contributor_item","title":"Submission C4R2S1","provisional":false,"code":"def rotate(matrix):\n return [list(row) for row in zip(*matrix[::-1])]","input":"rotate([[1, 2], [3, 4], [5, 6]])","language":"Python","predicted_output":"[[5, 3, 1], [6, 4, 2]]"} |
| {"id":"cmsu44b3l00f8g4p2s7gzhuxm","kind":"contributor_item","title":"Submission GZHUXM","provisional":false,"code":"def dedupe_runs(values):\n out = []\n for value in values:\n if not out or out[-1] != value:\n out.append(value)\n return out, len(values) - len(out)","input":"dedupe_runs([1, 1, 2, 2, 2, 1, 3, 3])","language":"Python","predicted_output":"([1, 2, 1, 3], 4)"} |
| {"id":"cmsu44b3l00fbg4p2tsyrd4v8","kind":"contributor_item","title":"Submission YRD4V8","provisional":false,"code":"class Counter:\n def __init__(self, start=0):\n self.value = start\n def __iadd__(self, other):\n self.value += other\n return self\n def __repr__(self):\n return 'Counter({})'.format(self.value)\n\ndef demo():\n a = Counter(1)\n b = a\n a += 5\n return a, b, a is b","input":"demo()","language":"Python","predicted_output":"(Counter(6), Counter(6), True)"} |
| {"id":"cmsu44b3l00fag4p2bor4o7ht","kind":"contributor_item","title":"Submission R4O7HT","provisional":false,"code":"def chunk_budget(costs, budget):\n batches = []\n current = []\n running = 0\n for cost in costs:\n if running + cost > budget and current:\n batches.append(current)\n current = []\n running = 0\n current.append(cost)\n running += cost\n if current:\n batches.append(current)\n return batches","input":"chunk_budget([4, 3, 5, 1, 9, 2], 8)","language":"Python","predicted_output":"[[4, 3], [5, 1], [9], [2]]"} |
| {"id":"cmsu44b3l00fcg4p2f8jsdzos","kind":"contributor_item","title":"Submission JSDZOS","provisional":false,"code":"def walk(tree, depth=0):\n if not isinstance(tree, dict):\n return [(depth, tree)]\n found = []\n for key in sorted(tree):\n found.append((depth, key))\n found.extend(walk(tree[key], depth + 1))\n return found","input":"walk({'b': {'d': 1}, 'a': 2})","language":"Python","predicted_output":"[(0, 'a'), (1, 2), (0, 'b'), (1, 'd'), (2, 1)]"} |
| {"id":"cmsudv4e800fzg4p2ogxn6tr8","kind":"contributor_item","title":"Submission XN6TR8","provisional":false,"code":"from collections import Counter\n\ndef top_endpoints(paths, limit):\n counts = Counter(paths)\n return counts.most_common(limit)","input":"top_endpoints([\"/a\", \"/b\", \"/a\", \"/c\", \"/b\", \"/a\"], 2)","language":"Python","predicted_output":"[('/a', 3), ('/b', 2)]"} |
| {"id":"cmsudv4e800fug4p2t4jrfh01","kind":"contributor_item","title":"Submission JRFH01","provisional":false,"code":"def rank_versions(tags):\n def key(tag):\n return tuple(int(part) for part in tag.lstrip(\"v\").split(\".\"))\n ordered = sorted(tags, key=key, reverse=True)\n return ordered[0], ordered[-1]","input":"rank_versions([\"v1.9.0\", \"v1.10.2\", \"v1.2.30\", \"v1.10.10\"])","language":"Python","predicted_output":"('v1.10.10', 'v1.2.30')"} |
| {"id":"cmsudv4e800g3g4p2f58pro0n","kind":"contributor_item","title":"Submission 8PRO0N","provisional":false,"code":"def round_half_even(values):\n return [round(value) for value in values]","input":"round_half_even([0.5, 1.5, 2.5, -0.5, -1.5])","language":"Python","predicted_output":"[0, 2, 2, 0, -2]"} |
| {"id":"cmsudv4e800fsg4p20136xcoq","kind":"contributor_item","title":"Submission 36XCOQ","provisional":false,"code":"def reorder_report(stock, thresholds):\n report = []\n for sku in sorted(stock):\n on_hand = stock[sku]\n floor = thresholds.get(sku, 10)\n if on_hand < floor:\n report.append((sku, floor - on_hand))\n return report","input":"reorder_report({\"axe\": 3, \"bolt\": 40, \"cog\": 10}, {\"axe\": 12, \"cog\": 10})","language":"Python","predicted_output":"[('axe', 9)]"} |
| {"id":"cmsudv4e800ftg4p2p3szc8us","kind":"contributor_item","title":"Submission SZC8US","provisional":false,"code":"def backoff_schedule(attempts, base, ceiling):\n delays = []\n delay = base\n for _ in range(attempts):\n delays.append(min(delay, ceiling))\n delay *= 2\n return delays","input":"backoff_schedule(6, 3, 20)","language":"Python","predicted_output":"[3, 6, 12, 20, 20, 20]"} |
| {"id":"cmsudv4e800fyg4p2hq4mv57s","kind":"contributor_item","title":"Submission 4MV57S","provisional":false,"code":"import itertools\n\ndef first_stable(readings, tolerance):\n pairs = zip(readings, readings[1:])\n steady = (a for a, b in pairs if abs(a - b) <= tolerance)\n return list(itertools.islice(steady, 2))","input":"first_stable([10, 11, 30, 31, 31, 80], 1)","language":"Python","predicted_output":"[10, 30]"} |
| {"id":"cmsudv4e800g2g4p22kplf9sg","kind":"contributor_item","title":"Submission PLF9SG","provisional":false,"code":"from functools import lru_cache\n\ndef probe():\n @lru_cache(maxsize=None)\n def steps(n):\n if n < 2:\n return n\n return steps(n - 1) + steps(n - 2)\n\n value = steps(10)\n info = steps.cache_info()\n return value, info.hits, info.misses","input":"probe()","language":"Python","predicted_output":"(55, 8, 11)"} |
| {"id":"cmsudv4e800g7g4p20aovw49a","kind":"contributor_item","title":"Submission OVW49A","provisional":false,"code":"def format_ids(raw_ids, width):\n return [str(raw).zfill(width) for raw in raw_ids]","input":"format_ids([7, 42, 12345], 4)","language":"Python","predicted_output":"['0007', '0042', '12345']"} |
| {"id":"cmsudv4e800g4g4p2na06pi29","kind":"contributor_item","title":"Submission 06PI29","provisional":false,"code":"def clock_offsets(offsets, period):\n return [(offset // period, offset % period) for offset in offsets]","input":"clock_offsets([7, -7, 0, -1], 3)","language":"Python","predicted_output":"[(2, 1), (-3, 2), (0, 0), (-1, 2)]"} |
| {"id":"cmsudv4e800g9g4p2jhyyq71r","kind":"contributor_item","title":"Submission YYQ71R","provisional":false,"code":"import itertools\n\ndef align(expected, actual):\n return list(itertools.zip_longest(expected, actual, fillvalue=\"-\"))","input":"align([\"a\", \"b\", \"c\"], [\"a\", \"b\"])","language":"Python","predicted_output":"[('a', 'a'), ('b', 'b'), ('c', '-')]"} |
| {"id":"cmsudv4e800g6g4p2zthh04b4","kind":"contributor_item","title":"Submission HH04B4","provisional":false,"code":"def index_by_initial(names):\n index = {}\n for name in names:\n index.setdefault(name[0], []).append(name)\n return index","input":"index_by_initial([\"ana\", \"arun\", \"bo\", \"ada\"])","language":"Python","predicted_output":"{'a': ['ana', 'arun', 'ada'], 'b': ['bo']}"} |
| {"id":"cmsudv4e800gag4p2hx7o7a38","kind":"contributor_item","title":"Submission 7O7A38","provisional":false,"code":"def commit(value):\n log = []\n try:\n log.append(\"try\")\n return log + [\"from-try\"]\n finally:\n log.append(\"finally\")\n\ndef observe():\n return commit(1)","input":"observe()","language":"Python","predicted_output":"['try', 'from-try']"} |
| {"id":"cmsudv4e800gbg4p27e5ydfek","kind":"contributor_item","title":"Submission 5YDFEK","provisional":false,"code":"import bisect\n\ndef insert_sorted(scores, incoming):\n ordered = list(scores)\n positions = []\n for score in incoming:\n position = bisect.bisect_left(ordered, score)\n ordered.insert(position, score)\n positions.append(position)\n return ordered, positions","input":"insert_sorted([10, 20, 30], [25, 10, 40])","language":"Python","predicted_output":"([10, 10, 20, 25, 30, 40], [2, 0, 5])"} |
| {"id":"cmsudv4e800g8g4p22iz4bwny","kind":"contributor_item","title":"Submission Z4BWNY","provisional":false,"code":"def sort_tickets(tickets):\n return sorted(tickets, key=lambda ticket: ticket[1])","input":"sort_tickets([(\"a\", 2), (\"b\", 1), (\"c\", 2), (\"d\", 1)])","language":"Python","predicted_output":"[('b', 1), ('d', 1), ('a', 2), ('c', 2)]"} |
| {"id":"cmsudv4e800fwg4p2ydm82nni","kind":"contributor_item","title":"Submission M82NNI","provisional":false,"code":"def merge_spans(spans):\n merged = []\n for start, end in sorted(spans):\n if merged and start <= merged[-1][1]:\n previous_start, previous_end = merged[-1]\n merged[-1] = (previous_start, max(previous_end, end))\n else:\n merged.append((start, end))\n return merged","input":"merge_spans([(5, 8), (1, 3), (2, 6), (11, 12)])","language":"Python","predicted_output":"[(1, 8), (11, 12)]"} |
| {"id":"cmsudv4e800fxg4p2i9agi3rr","kind":"contributor_item","title":"Submission AGI3RR","provisional":false,"code":"class QuotaError(Exception):\n pass\n\ndef consume(units, budget):\n trail = []\n try:\n if units > budget:\n raise QuotaError(\"over budget\")\n trail.append(\"charged\")\n return trail\n except QuotaError as exc:\n trail.append(\"denied:\" + str(exc))\n return trail\n finally:\n trail.append(\"audited\")","input":"(consume(3, 10), consume(30, 10))","language":"Python","predicted_output":"(['charged', 'audited'], ['denied:over budget', 'audited'])"} |
| {"id":"cmsudv4e800g1g4p21z2j6rz1","kind":"contributor_item","title":"Submission 2J6RZ1","provisional":false,"code":"def make_collector():\n def collect(entry, sink=[]):\n sink.append(entry)\n return list(sink)\n return collect\n\ndef audit_trail():\n collect = make_collector()\n first = collect(\"open\")\n second = collect(\"close\")\n return first, second","input":"audit_trail()","language":"Python","predicted_output":"(['open'], ['open', 'close'])"} |
| {"id":"cmsudv4e800g0g4p2oeq8zi6i","kind":"contributor_item","title":"Submission Q8ZI6I","provisional":false,"code":"def split_object_key(key):\n prefix, separator, name = key.rpartition(\"/\")\n stem, dot, extension = name.partition(\".\")\n return prefix, stem, extension or \"none\"","input":"split_object_key(\"templates/2026/report.final.docx\")","language":"Python","predicted_output":"('templates/2026', 'report', 'final.docx')"} |
| {"id":"cmsudv4e800g5g4p24eveh8ou","kind":"contributor_item","title":"Submission VEH8OU","provisional":false,"code":"def splice(rows, start, stop, replacement):\n copy = list(rows)\n copy[start:stop] = replacement\n return copy, len(copy)","input":"splice([1, 2, 3, 4, 5], 1, 4, ['x'])","language":"Python","predicted_output":"([1, 'x', 5], 3)"} |
| {"id":"cmsudv4e800fvg4p2jhkwqits","kind":"contributor_item","title":"Submission KWQITS","provisional":false,"code":"from collections import deque\n\ndef peak_window(readings, width):\n window = deque(maxlen=width)\n peaks = []\n for value in readings:\n window.append(value)\n if len(window) == width:\n peaks.append(max(window))\n return peaks","input":"peak_window([4, 1, 7, 3, 3, 9], 3)","language":"Python","predicted_output":"[7, 7, 7, 9]"} |
| {"id":"cmsugy1v400h6g4p2etkow937","kind":"contributor_item","title":"Submission KOW937","provisional":false,"code":"from collections import defaultdict\n\ndef group_by_parity(nums):\n groups = defaultdict(list)\n for n in nums:\n groups['even' if n % 2 == 0 else 'odd'].append(n)\n return dict(groups)","input":"group_by_parity([1, 2, 3, 4, 5, 6])","language":"Python","predicted_output":"{'odd': [1, 3, 5], 'even': [2, 4, 6]}"} |
| {"id":"cmsugy75f00h7g4p24asmp0ij","kind":"contributor_item","title":"Submission SMP0IJ","provisional":false,"code":"def append_to(value, target=[]):\n target.append(value)\n return target","input":"(append_to(1), append_to(2), append_to(3, []))","language":"Python","predicted_output":"([1, 2], [1, 2], [3])"} |
| {"id":"cmsugyc7500h8g4p2pos2w3r5","kind":"contributor_item","title":"Submission S2W3R5","provisional":false,"code":"def process(value):\n log = []\n try:\n if value < 0:\n raise ValueError('negative')\n log.append(f'ok:{value}')\n except ValueError as e:\n log.append(f'error:{e}')\n finally:\n log.append('cleanup')\n return log","input":"process(-5)","language":"Python","predicted_output":"['error:negative', 'cleanup']"} |
| {"id":"cmsugyyxj00h9g4p27pp67ty2","kind":"contributor_item","title":"Submission P67TY2","provisional":false,"code":"def fib(n, memo={}):\n if n in memo:\n return memo[n]\n if n < 2:\n result = n\n else:\n result = fib(n-1, memo) + fib(n-2, memo)\n memo[n] = result\n return result","input":"list(map(fib, range(10)))","language":"Python","predicted_output":"[0, 1, 1, 2, 3, 5, 8, 13, 21, 34]"} |
| {"id":"cmsugz5aa00hag4p2elyqi4pe","kind":"contributor_item","title":"Submission YQI4PE","provisional":false,"code":"import itertools\n\ndef flatten_gen(nested):\n for item in nested:\n if isinstance(item, list):\n yield from flatten_gen(item)\n else:\n yield item","input":"list(itertools.islice(flatten_gen([1, [2, 3], [4, [5, 6]], 7]), 10))","language":"Python","predicted_output":"[1, 2, 3, 4, 5, 6, 7]"} |
| {"id":"cmsuhgank00jlg4p23bsvtw29","kind":"contributor_item","title":"Submission SVTW29","provisional":false,"code":"class Point:\n def __init__(self, x, y):\n self.x = x\n self.y = y\n def __repr__(self):\n return f\"Point({self.x}, {self.y})\"\n def __eq__(self, other):\n return self.x == other.x and self.y == other.y\n def __add__(self, other):\n return Point(self.x + other.x, self.y + other.y)","input":"Point(1, 2) + Point(3, 4)","language":"Python","predicted_output":"Point(4, 6)"} |
| {"id":"cmsuhgank00jkg4p2xl514f3s","kind":"contributor_item","title":"Submission 514F3S","provisional":false,"code":"def reverse_words(s):\n return ' '.join(s.split()[::-1])","input":"reverse_words(\"the quick brown fox\")","language":"Python","predicted_output":"fox brown quick the"} |
| {"id":"cmsuhgank00jig4p24gujpqsm","kind":"contributor_item","title":"Submission UJPQSM","provisional":false,"code":"def factorial_acc(n, acc=1):\n if n <= 1:\n return acc\n return factorial_acc(n - 1, acc * n)","input":"factorial_acc(6)","language":"Python","predicted_output":"720"} |
| {"id":"cmsuhgank00jhg4p2xcieo4ea","kind":"contributor_item","title":"Submission IEO4EA","provisional":false,"code":"def format_report(name, score):\n grade = 'A' if score >= 90 else ('B' if score >= 80 else 'C')\n return f\"{name}: {score} ({grade})\"","input":"format_report(\"Alice\", 92)","language":"Python","predicted_output":"Alice: 92 (A)"} |
| {"id":"cmsuhgank00jjg4p2xeci78be","kind":"contributor_item","title":"Submission CI78BE","provisional":false,"code":"def set_ops(a, b):\n return (sorted(a & b), sorted(a | b), sorted(a - b))","input":"set_ops({1, 2, 3}, {2, 3, 4})","language":"Python","predicted_output":"([2, 3], [1, 2, 3, 4], [1])"} |
| {"id":"cmsuj9zm400ltg4p2bdlpv7oe","kind":"contributor_item","title":"Submission LPV7OE","provisional":false,"code":"def try_parse_int(values):\n results = []\n for v in values:\n try:\n results.append(int(v))\n except ValueError:\n results.append(None)\n return results","input":"try_parse_int(['42', 'abc', '-7', '3.5'])","language":"Python","predicted_output":"[42, None, -7, None]"} |
| {"id":"cmsuj9zm400lug4p2c6xtv3u7","kind":"contributor_item","title":"Submission XTV3U7","provisional":false,"code":"class Counter2:\n def __init__(self):\n self.counts = {}\n def add(self, key):\n self.counts[key] = self.counts.get(key, 0) + 1\n return self.counts[key]\n\ndef run_trace():\n c = Counter2()\n results = [c.add('a'), c.add('b'), c.add('a'), c.add('a')]\n return results","input":"run_trace()","language":"Python","predicted_output":"[1, 1, 2, 3]"} |
| {"id":"cmsuj9zm400lvg4p2ssgoys0m","kind":"contributor_item","title":"Submission GOYS0M","provisional":false,"code":"def flatten_one_level(nested):\n result = []\n for item in nested:\n if isinstance(item, list):\n result.extend(item)\n else:\n result.append(item)\n return result","input":"flatten_one_level([1, [2, 3], [4, [5, 6]], 7])","language":"Python","predicted_output":"[1, 2, 3, 4, [5, 6], 7]"} |
| {"id":"cmsuj9zm400lrg4p2hq6v1apu","kind":"contributor_item","title":"Submission 6V1APU","provisional":false,"code":"def dedupe_preserve_order(items):\n seen = set()\n result = []\n for x in items:\n if x not in seen:\n seen.add(x)\n result.append(x)\n return result","input":"dedupe_preserve_order([3, 1, 3, 2, 1, 4])","language":"Python","predicted_output":"[3, 1, 2, 4]"} |
| {"id":"cmsuj9zm400lsg4p2y5ck4p68","kind":"contributor_item","title":"Submission CK4P68","provisional":false,"code":"def chunk_list(lst, size):\n return [lst[i:i+size] for i in range(0, len(lst), size)]","input":"chunk_list([1,2,3,4,5,6,7], 3)","language":"Python","predicted_output":"[[1, 2, 3], [4, 5, 6], [7]]"} |
| {"id":"cmsupb4pg011sg4p2xwqfwhdh","kind":"contributor_item","title":"Submission QFWHDH","provisional":false,"code":"def parse_config_lines(lines):\n parsed = {}\n errors = []\n for line_no, raw_line in enumerate(lines, start=1):\n line = raw_line.strip()\n if not line or line.startswith(\"#\"):\n continue\n try:\n key, value = line.split(\"=\", 1)\n except ValueError:\n errors.append(f\"line {line_no}: missing '='\")\n continue\n key = key.strip()\n value = value.strip()\n if not key:\n errors.append(f\"line {line_no}: empty key\")\n continue\n if value.lstrip(\"-\").isdigit():\n value = int(value)\n parsed[key] = value\n return parsed, errors","input":"parse_config_lines([\"# config file\", \"\", \"timeout=30\", \"retries=-5\", \"path=/usr/local/bin=extra\", \"bad_line_no_equals\", \" = orphan_value\", \"timeout=60\"])","language":"Python","predicted_output":"({'timeout': 60, 'retries': -5, 'path': '/usr/local/bin=extra'}, [\"line 6: missing '='\", 'line 7: empty key'])"} |
| {"id":"cmsupb4pg011rg4p2jd6gu5m5","kind":"contributor_item","title":"Submission 6GU5M5","provisional":false,"code":"from collections import defaultdict\n\ndef bucket_by_grade(entries, curve=0):\n buckets = defaultdict(list)\n for name, score in entries:\n try:\n adjusted = score + curve\n if adjusted >= 90:\n grade = \"A\"\n elif adjusted >= 80:\n grade = \"B\"\n elif adjusted >= 70:\n grade = \"C\"\n else:\n grade = \"F\"\n except TypeError:\n grade = \"invalid\"\n buckets[grade].append(name)\n return dict(buckets)","input":"bucket_by_grade([(\"Alice\", 85), (\"Bob\", 72), (\"Carol\", 66), (\"Dave\", \"absent\"), (\"Eve\", 95)], curve=5)","language":"Python","predicted_output":"{'A': ['Alice', 'Eve'], 'C': ['Bob', 'Carol'], 'invalid': ['Dave']}"} |
| {"id":"cmsv70ftv018sg4p2ydw8qxyh","kind":"contributor_item","title":"Submission W8QXYH","provisional":false,"code":"def make_counter(start=0):\n count = start\n def increment(step=1):\n nonlocal count\n count += step\n return count\n return increment\n\ndef run_sequence():\n c = make_counter()\n return [c(), c(2), c()]","input":"(make_counter(10)(), make_counter(10)(5), run_sequence())","language":"Python","predicted_output":"(11, 15, [1, 3, 4])"} |
| {"id":"cmsv70uct018yg4p2nrepmjek","kind":"contributor_item","title":"Submission EPMJEK","provisional":false,"code":"def echo_transform():\n total = 0\n while True:\n received = yield total\n if received is None:\n break\n total += received\n\ndef run_generator():\n g = echo_transform()\n first = next(g)\n second = g.send(3)\n third = g.send(4)\n return [first, second, third]","input":"run_generator()","language":"Python","predicted_output":"[0, 3, 7]"} |
| {"id":"cmsv71a440194g4p2s11o4zmh","kind":"contributor_item","title":"Submission 1O4ZMH","provisional":false,"code":"def make_counter():\n count = [0]\n def increment(step=1):\n count[0] += step\n return count[0]\n return increment\n\nc1 = make_counter()","input":"(c1(), c1(5), c1())","language":"Python","predicted_output":"(1, 6, 7)"} |
| {"id":"cmsv71k7s0199g4p2mur1623v","kind":"contributor_item","title":"Submission R1623V","provisional":false,"code":"def tag_event(event, log={}):\n log.setdefault(event, 0)\n log[event] += 1\n return dict(log)","input":"(tag_event('start'), tag_event('start'), tag_event('stop'), tag_event('start', {}))","language":"Python","predicted_output":"({'start': 1}, {'start': 2}, {'start': 2, 'stop': 1}, {'start': 1})"} |
| {"id":"cmsv72054019hg4p2ibr1t678","kind":"contributor_item","title":"Submission R1T678","provisional":false,"code":"def counter_decorator(func):\n func.calls = 0\n def wrapper(*args, **kwargs):\n func.calls += 1\n wrapper.calls = func.calls\n return func(*args, **kwargs)\n return wrapper\n\ndef upper_decorator(func):\n def wrapper(*args, **kwargs):\n result = func(*args, **kwargs)\n return result.upper() if isinstance(result, str) else result\n return wrapper\n\n@counter_decorator\n@upper_decorator\ndef greet(name):\n return f\"hello {name}\"\n","input":"(greet('ann'), greet('bo'), greet.calls)","language":"Python","predicted_output":"('HELLO ANN', 'HELLO BO', 2)"} |
| {"id":"cmsv72ekl019qg4p2g385f8z6","kind":"contributor_item","title":"Submission 85F8Z6","provisional":false,"code":"def compute(x):\n try:\n if x == 0:\n raise ValueError(\"zero\")\n return x * 2\n except ValueError:\n return -1\n finally:\n if x == 0:\n return 99","input":"(compute(5), compute(0))","language":"Python","predicted_output":"(10, 99)"} |
| {"id":"cmsv740si01a6g4p2i1o0j120","kind":"contributor_item","title":"Submission O0J120","provisional":false,"code":"def make_funcs():\n return [lambda: i for i in range(4)]\n\ndef call_all(funcs):\n return [f() for f in funcs]","input":"call_all(make_funcs())","language":"Python","predicted_output":"[3, 3, 3, 3]"} |
| {"id":"cmsv74ghl01agg4p2p4hav0es","kind":"contributor_item","title":"Submission HAV0ES","provisional":false,"code":"def build_map(pairs):\n return {k % 3: v for k, v in pairs}","input":"build_map([(1, 'a'), (4, 'b'), (7, 'c'), (2, 'd')])","language":"Python","predicted_output":"{1: 'c', 2: 'd'}"} |
| {"id":"cmsv752v501aqg4p24htm4s5x","kind":"contributor_item","title":"Submission TM4S5X","provisional":false,"code":"def format_report(value, width):\n return f\"{value:>{width}.2f}|{value:+.1e}|{value!r}\"\n","input":"format_report(-3.14159, 10)","language":"Python","predicted_output":" -3.14|-3.1e+00|-3.14159"} |
| {"id":"cmsv75fnt01b1g4p2fgtsy27t","kind":"contributor_item","title":"Submission TSY27T","provisional":false,"code":"import functools\n\ncalls = []\n\n@functools.lru_cache(maxsize=None)\ndef fib(n):\n calls.append(n)\n if n < 2:\n return n\n return fib(n - 1) + fib(n - 2)\n","input":"(fib(7), len(calls))","language":"Python","predicted_output":"(13, 8)"} |
| {"id":"cmsv75x1v01bbg4p2drp84f21","kind":"contributor_item","title":"Submission P84F21","provisional":false,"code":"import itertools\n\ndef group_consecutive(items):\n return [(k, list(g)) for k, g in itertools.groupby(items)]","input":"group_consecutive([1, 1, 2, 1, 1, 3, 3])","language":"Python","predicted_output":"[(1, [1, 1]), (2, [2]), (1, [1, 1]), (3, [3, 3])]"} |
| {"id":"cmsv76bxg01bmg4p2ktz0uxh4","kind":"contributor_item","title":"Submission Z0UXH4","provisional":false,"code":"def make_funcs_fixed():\n return [lambda i=i: i for i in range(4)]\n\ndef call_all(funcs):\n return [f() for f in funcs]","input":"call_all(make_funcs_fixed())","language":"Python","predicted_output":"[0, 1, 2, 3]"} |
| {"id":"cmsv76pvm01bwg4p2dpnvi346","kind":"contributor_item","title":"Submission NVI346","provisional":false,"code":"def scoping_demo():\n x = 10\n gen = (x + i for i in range(3))\n x = 100\n return list(gen)","input":"scoping_demo()","language":"Python","predicted_output":"[100, 101, 102]"} |
| {"id":"cmsv774ls01c7g4p2agkocpck","kind":"contributor_item","title":"Submission KOCPCK","provisional":false,"code":"def parse_int(value):\n try:\n return int(value)\n except ValueError as e:\n raise RuntimeError(\"parse failed\") from e\n\ndef safe_parse(value):\n try:\n return parse_int(value)\n except RuntimeError as e:\n return (str(e), type(e.__cause__).__name__, str(e.__cause__))","input":"safe_parse('abc')","language":"Python","predicted_output":"('parse failed', 'ValueError', \"invalid literal for int() with base 10: 'abc'\")"} |
| {"id":"cmsv77jdw01chg4p2ycxbv00v","kind":"contributor_item","title":"Submission XBV00V","provisional":false,"code":"def wrap_with(tag):\n def decorator(func):\n def wrapper(*args, **kwargs):\n return f\"{tag}({func(*args, **kwargs)})\"\n return wrapper\n return decorator\n\n@wrap_with(\"A\")\n@wrap_with(\"B\")\n@wrap_with(\"C\")\ndef base(x):\n return str(x)","input":"base(5)","language":"Python","predicted_output":"A(B(C(5)))"} |
| {"id":"cmsv77xdl01crg4p2jo8bqnsr","kind":"contributor_item","title":"Submission 8BQNSR","provisional":false,"code":"def divide_track(a, b):\n log = []\n try:\n result = a / b\n except ZeroDivisionError:\n log.append(\"zero-div\")\n result = None\n except TypeError:\n log.append(\"type-err\")\n result = None\n else:\n log.append(\"ok\")\n finally:\n log.append(\"done\")\n return (result, log)","input":"(divide_track(10, 2), divide_track(10, 0), divide_track(10, 'x'))","language":"Python","predicted_output":"((5.0, ['ok', 'done']), (None, ['zero-div', 'done']), (None, ['type-err', 'done']))"} |
| {"id":"cmsv78cao01d1g4p29baw9vgz","kind":"contributor_item","title":"Submission AW9VGZ","provisional":false,"code":"import functools\n\ndef running_max_with_index(values):\n return functools.reduce(\n lambda acc, x: acc + [(x[0], max(x[1], acc[-1][1]))] if acc else [x],\n enumerate(values),\n []\n )","input":"running_max_with_index([3, 1, 4, 1, 5, 9, 2])","language":"Python","predicted_output":"[(0, 3), (1, 3), (2, 4), (3, 4), (4, 5), (5, 9), (6, 9)]"} |
| {"id":"cmsv78qhr01dcg4p25gkyt9ix","kind":"contributor_item","title":"Submission KYT9IX","provisional":false,"code":"def collect_path(n, path=None, seen=[]):\n if path is None:\n path = []\n path.append(n)\n seen.append(n)\n if n <= 1:\n return path, list(seen)\n return collect_path(n // 2, path, seen)","input":"(collect_path(13)[0], collect_path(6)[1])","language":"Python","predicted_output":"([13, 6, 3, 1], [13, 6, 3, 1, 6, 3, 1])"} |
| {"id":"cmsv7969101dlg4p2dgeyp5jd","kind":"contributor_item","title":"Submission EYP5JD","provisional":false,"code":"def legacy_format(name, score, ratio):\n return \"%-8s|%05d|%6.3f%%\" % (name, score, ratio * 100)","input":"legacy_format('ax', 42, 0.12345)","language":"Python","predicted_output":"ax |00042|12.345%"} |
| {"id":"cmsv79mo401dxg4p2x2hqpolm","kind":"contributor_item","title":"Submission HQPOLM","provisional":false,"code":"import itertools\n\ndef merge_rows(a, b, c):\n return list(itertools.zip_longest(a, b, c, fillvalue=0))","input":"merge_rows([1, 2, 3], [10, 20], [100])","language":"Python","predicted_output":"[(1, 10, 100), (2, 20, 0), (3, 0, 0)]"} |
| {"id":"cmsv7a1ub01e7g4p2zjsuzc0a","kind":"contributor_item","title":"Submission SUZC0A","provisional":false,"code":"class ValidationError(Exception):\n pass\n\nclass RangeError(ValidationError):\n pass\n\ndef validate(n):\n trace = []\n try:\n if n < 0:\n raise RangeError(f\"negative:{n}\")\n if n > 100:\n raise ValidationError(f\"too-big:{n}\")\n trace.append(\"passed\")\n except RangeError as e:\n trace.append(f\"range:{e}\")\n except ValidationError as e:\n trace.append(f\"generic:{e}\")\n return trace\n\ndef run_validations():\n return [validate(-5), validate(150), validate(50)]","input":"run_validations()","language":"Python","predicted_output":"[['range:negative:-5'], ['generic:too-big:150'], ['passed']]"} |
| {"id":"cmsv84zxr01g4g4p2o5yk1wsb","kind":"contributor_item","title":"Submission YK1WSB","provisional":false,"code":"def echo_transform():\n total = 0\n while True:\n received = yield total\n if received is None:\n continue\n total += received\n\ndef run_generator_send():\n gen = echo_transform()\n outputs = [next(gen)]\n outputs.append(gen.send(5))\n outputs.append(gen.send(10))\n outputs.append(gen.send(-3))\n return outputs","input":"run_generator_send()","language":"Python","predicted_output":"[0, 5, 15, 12]"} |
| {"id":"cmsv85g3m01g5g4p2n642gsxu","kind":"contributor_item","title":"Submission 42GSXU","provisional":false,"code":"def resilient_counter():\n count = 0\n while True:\n try:\n yield count\n count += 1\n except ValueError:\n count = -1\n yield count\n\ndef run_generator_throw():\n gen = resilient_counter()\n out = [next(gen), next(gen)]\n out.append(gen.throw(ValueError(\"reset\")))\n out.append(next(gen))\n return out","input":"run_generator_throw()","language":"Python","predicted_output":"[0, 1, -1, -1]"} |
| {"id":"cmsv85wqy01g6g4p2ms1ifp3a","kind":"contributor_item","title":"Submission 1IFP3A","provisional":false,"code":"class SuppressType:\n def __init__(self, *types):\n self.types = types\n def __enter__(self):\n return self\n def __exit__(self, exc_type, exc_val, exc_tb):\n return exc_type is not None and issubclass(exc_type, self.types)\n\ndef run_suppress_cm():\n log = []\n with SuppressType(KeyError):\n log.append(\"start\")\n raise KeyError(\"missing\")\n log.append(\"unreachable\")\n log.append(\"after\")\n try:\n with SuppressType(KeyError):\n raise TypeError(\"not suppressed\")\n except TypeError as e:\n log.append(f\"caught:{e}\")\n return log","input":"run_suppress_cm()","language":"Python","predicted_output":"['start', 'after', 'caught:not suppressed']"} |
| {"id":"cmsv86dza01g7g4p21qeurz8j","kind":"contributor_item","title":"Submission EURZ8J","provisional":false,"code":"import contextlib\n\ndef run_contextlib_suppress():\n log = []\n with contextlib.suppress(ZeroDivisionError, KeyError):\n result = 1 / 0\n log.append(result)\n log.append(\"continued\")\n d = {\"a\": 1}\n with contextlib.suppress(KeyError):\n value = d[\"missing\"]\n log.append(value)\n log.append(\"done\")\n try:\n with contextlib.suppress(ZeroDivisionError):\n raise TypeError(\"not suppressed here\")\n except TypeError as e:\n log.append(f\"caught:{e}\")\n return log","input":"run_contextlib_suppress()","language":"Python","predicted_output":"['continued', 'done', 'caught:not suppressed here']"} |
| {"id":"cmsv86t2p01g9g4p2lo85fhgh","kind":"contributor_item","title":"Submission 85FHGH","provisional":false,"code":"class UpperAttrMeta(type):\n def __new__(mcs, name, bases, namespace):\n upper_namespace = {}\n for key, value in namespace.items():\n if not key.startswith(\"__\"):\n upper_namespace[key.upper()] = value\n else:\n upper_namespace[key] = value\n return super().__new__(mcs, name, bases, upper_namespace)\n\nclass Config(metaclass=UpperAttrMeta):\n debug = False\n version = \"1.0\"\n\ndef run_metaclass():\n c = Config()\n return sorted(k for k in vars(Config) if not k.startswith(\"__\"))","input":"run_metaclass()","language":"Python","predicted_output":"['DEBUG', 'VERSION']"} |
| {"id":"cmsv879kc01gbg4p2hpxv1vg9","kind":"contributor_item","title":"Submission XV1VG9","provisional":false,"code":"class PositiveNumber:\n def __set_name__(self, owner, name):\n self.name = \"_\" + name\n def __get__(self, obj, objtype=None):\n if obj is None:\n return self\n return getattr(obj, self.name, None)\n def __set__(self, obj, value):\n if value <= 0:\n raise ValueError(f\"{self.name} must be positive, got {value}\")\n setattr(obj, self.name, value)\n\nclass Account:\n balance = PositiveNumber()\n def __init__(self, balance):\n self.balance = balance\n\ndef run_descriptor():\n a = Account(100)\n results = [a.balance]\n try:\n a.balance = -5\n except ValueError as e:\n results.append(str(e))\n a.balance = 50\n results.append(a.balance)\n return results","input":"run_descriptor()","language":"Python","predicted_output":"[100, '_balance must be positive, got -5', 50]"} |
| {"id":"cmsv87q3501gdg4p2r6q7x0i8","kind":"contributor_item","title":"Submission Q7X0I8","provisional":false,"code":"class Vector:\n def __init__(self, x, y):\n self.x, self.y = x, y\n def __add__(self, other):\n if isinstance(other, Vector):\n return Vector(self.x + other.x, self.y + other.y)\n return Vector(self.x + other, self.y + other)\n def __radd__(self, other):\n return self.__add__(other)\n def __iadd__(self, other):\n self.x += other.x\n self.y += other.y\n return self\n def __repr__(self):\n return f\"Vector({self.x}, {self.y})\"\n\ndef run_vector_ops():\n v1 = Vector(1, 2)\n v2 = Vector(3, 4)\n v3 = v1 + v2\n v4 = 10 + v1\n v1 += v2\n return [repr(v3), repr(v4), repr(v1)]","input":"run_vector_ops()","language":"Python","predicted_output":"['Vector(4, 6)', 'Vector(11, 12)', 'Vector(4, 6)']"} |
| {"id":"cmsv886ak01gfg4p21ndu8jw8","kind":"contributor_item","title":"Submission DU8JW8","provisional":false,"code":"from functools import total_ordering\n\n@total_ordering\nclass Card:\n RANKS = [\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"10\",\"J\",\"Q\",\"K\",\"A\"]\n def __init__(self, rank):\n self.rank = rank\n def __eq__(self, other):\n return self.RANKS.index(self.rank) == self.RANKS.index(other.rank)\n def __lt__(self, other):\n return self.RANKS.index(self.rank) < self.RANKS.index(other.rank)\n def __repr__(self):\n return self.rank\n\ndef run_card_sort():\n cards = [Card(\"K\"), Card(\"2\"), Card(\"A\"), Card(\"10\")]\n return [repr(c) for c in sorted(cards)] + [Card(\"K\") > Card(\"2\"), Card(\"A\") <= Card(\"A\")]","input":"run_card_sort()","language":"Python","predicted_output":"['2', '10', 'K', 'A', True, True]"} |
| {"id":"cmsv88pxz01gig4p2eyyyntp5","kind":"contributor_item","title":"Submission YYNTP5","provisional":false,"code":"def slice_demo(seq):\n return {\n \"reverse\": seq[::-1],\n \"every_second\": seq[::2],\n \"last_three\": seq[-3:],\n \"middle_step_neg\": seq[-2:-8:-2],\n \"empty\": seq[5:2],\n }","input":"slice_demo([0,1,2,3,4,5,6,7,8,9])","language":"Python","predicted_output":"{'reverse': [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], 'every_second': [0, 2, 4, 6, 8], 'last_three': [7, 8, 9], 'middle_step_neg': [8, 6, 4], 'empty': []}"} |
| {"id":"cmsv897s901glg4p2x0twxv2j","kind":"contributor_item","title":"Submission TWXV2J","provisional":false,"code":"def encoding_demo(s):\n utf8_bytes = s.encode(\"utf-8\")\n ascii_replaced = s.encode(\"ascii\", errors=\"replace\")\n ascii_ignored = s.encode(\"ascii\", errors=\"ignore\")\n back = utf8_bytes.decode(\"utf-8\")\n return (utf8_bytes, ascii_replaced, ascii_ignored, back == s)","input":"encoding_demo(\"café naïve\")","language":"Python","predicted_output":"(b'caf\\xc3\\xa9 na\\xc3\\xafve', b'caf? na?ve', b'caf nave', True)"} |
| {"id":"cmsv89qwp01gog4p2qqsdqoy8","kind":"contributor_item","title":"Submission SDQOY8","provisional":false,"code":"def stability_demo():\n data = [(\"a\", 2), (\"b\", 1), (\"c\", 2), (\"d\", 1), (\"e\", 2)]\n return sorted(data, key=lambda pair: pair[1])","input":"stability_demo()","language":"Python","predicted_output":"[('b', 1), ('d', 1), ('a', 2), ('c', 2), ('e', 2)]"} |
| {"id":"cmsv8a4u001grg4p2guqb2xil","kind":"contributor_item","title":"Submission QB2XIL","provisional":false,"code":"def read_chunks(data, size):\n pos = 0\n chunks = []\n while (chunk := data[pos:pos+size]):\n chunks.append(chunk)\n pos += size\n return chunks","input":"read_chunks(\"abcdefghij\", 3)","language":"Python","predicted_output":"['abc', 'def', 'ghi', 'j']"} |
| {"id":"cmsv8al6j01gtg4p2d0xgo649","kind":"contributor_item","title":"Submission XGO649","provisional":false,"code":"def walrus_filter(nums):\n return [y for x in nums if (y := x * x) > 10]","input":"walrus_filter([1,2,3,4,5,6])","language":"Python","predicted_output":"[16, 25, 36]"} |
| {"id":"cmsv8b4ex01gwg4p2x11r4qpx","kind":"contributor_item","title":"Submission 1R4QPX","provisional":false,"code":"def classify(point):\n match point:\n case (0, 0):\n return \"origin\"\n case (x, y) if x == y:\n return \"diagonal\"\n case (x, 0):\n return f\"on x-axis at {x}\"\n case (0, y):\n return f\"on y-axis at {y}\"\n case (x, y) if x > 0 and y > 0:\n return \"quadrant 1\"\n case _:\n return \"other\"\n\ndef run_classify():\n return [classify(p) for p in [(0,0),(3,3),(5,0),(0,-2),(2,4),(-1,-1)]]","input":"run_classify()","language":"Python","predicted_output":"['origin', 'diagonal', 'on x-axis at 5', 'on y-axis at -2', 'quadrant 1', 'diagonal']"} |
| {"id":"cmsv8bpkj01h0g4p2wvdtqvpf","kind":"contributor_item","title":"Submission DTQVPF","provisional":false,"code":"from dataclasses import dataclass\n\n@dataclass\nclass Point:\n x: int\n y: int\n\ndef describe(shape):\n match shape:\n case Point(x=0, y=0):\n return \"origin point\"\n case Point(x=x, y=y) if x == y:\n return f\"diagonal point at {x}\"\n case Point(x=x, y=y):\n return f\"point at ({x}, {y})\"\n case [Point(0, 0), Point(0, 0)]:\n return \"two origins\"\n case _:\n return \"unknown\"\n\ndef run_describe():\n return [describe(Point(0,0)), describe(Point(5,5)), describe(Point(1,2)), describe(\"nope\")]","input":"run_describe()","language":"Python","predicted_output":"['origin point', 'diagonal point at 5', 'point at (1, 2)', 'unknown']"} |
| {"id":"cmsv8cew301h4g4p2ao3kya2u","kind":"contributor_item","title":"Submission 3KYA2U","provisional":false,"code":"def coercion_demo():\n a = 0.1 + 0.2\n b = True + True + True\n c = 3 / 2\n d = 3 // 2\n e = -3 // 2\n f = -3 % 2\n g = int(2.9999999999999996)\n h = bool(0.0) or bool(-0.0)\n return (a, a == 0.3, b, type(b).__name__, c, d, e, f, g, h)","input":"coercion_demo()","language":"Python","predicted_output":"(0.30000000000000004, False, 3, 'int', 1.5, 1, -2, 1, 2, False)"} |
| {"id":"cmsv8dsej01h8g4p2drb8n7pn","kind":"contributor_item","title":"Submission B8N7PN","provisional":false,"code":"def set_demo():\n a = {1, 2, 3, 4}\n b = {3, 4, 5, 6}\n sym = a ^ b\n fs = frozenset(a)\n cache = {fs: \"cached_result\"}\n lookup = cache.get(frozenset({4,3,2,1}))\n try:\n fs.add(10)\n mutation_error = None\n except AttributeError as e:\n mutation_error = \"AttributeError\"\n return (sorted(sym), lookup, mutation_error, a.issubset(a | b))","input":"set_demo()","language":"Python","predicted_output":"([1, 2, 5, 6], 'cached_result', 'AttributeError', True)"} |
| {"id":"cmsv8euwv01hbg4p2mjljkyjv","kind":"contributor_item","title":"Submission LJKYJV","provisional":false,"code":"import weakref\n\nclass Node:\n def __init__(self, name):\n self.name = name\n\ndef run_weakref():\n n = Node(\"alpha\")\n ref = weakref.ref(n)\n before = ref() is not None\n log = [before, ref().name]\n del n\n after = ref() is None\n log.append(after)\n return log","input":"run_weakref()","language":"Python","predicted_output":"[True, 'alpha', True]"} |
| {"id":"cmsv8fx9i01hgg4p230jy4ct2","kind":"contributor_item","title":"Submission JY4CT2","provisional":false,"code":"class Temperature:\n def __init__(self, celsius):\n self._celsius = celsius\n @property\n def celsius(self):\n return self._celsius\n @celsius.setter\n def celsius(self, value):\n if value < -273.15:\n raise ValueError(\"below absolute zero\")\n self._celsius = value\n @property\n def fahrenheit(self):\n return self._celsius * 9/5 + 32\n\ndef run_temperature():\n t = Temperature(25)\n results = [t.fahrenheit]\n t.celsius = 100\n results.append(t.fahrenheit)\n try:\n t.celsius = -300\n except ValueError as e:\n results.append(str(e))\n return results","input":"run_temperature()","language":"Python","predicted_output":"[77.0, 212.0, 'below absolute zero']"} |
| {"id":"cmsv8h8yd01hlg4p2nl1wv5rp","kind":"contributor_item","title":"Submission 1WV5RP","provisional":false,"code":"class Point2D:\n __slots__ = (\"x\", \"y\")\n def __init__(self, x, y):\n self.x = x\n self.y = y\n\nclass Point3D(Point2D):\n __slots__ = (\"z\",)\n def __init__(self, x, y, z):\n super().__init__(x, y)\n self.z = z\n\ndef run_slots():\n p = Point2D(1, 2)\n results = []\n try:\n p.z = 5\n results.append(\"no error\")\n except AttributeError as e:\n results.append(\"AttributeError\")\n p3 = Point3D(1, 2, 3)\n p3.z = 10\n results.append((p3.x, p3.y, p3.z))\n try:\n p3.w = 1\n results.append(\"no error 2\")\n except AttributeError:\n results.append(\"AttributeError2\")\n return results","input":"run_slots()","language":"Python","predicted_output":"['AttributeError', (1, 2, 10), 'AttributeError2']"} |
| {"id":"cmsv9c94m01jog4p2c4u1rhyp","kind":"contributor_item","title":"Submission U1RHYP","provisional":false,"code":"from collections import deque\n\n\ndef window(values, size):\n dq = deque(maxlen=size)\n trail = []\n for v in values:\n dq.append(v)\n trail.append(list(dq))\n dq.appendleft(\"L\")\n after_left = list(dq)\n dq.rotate(2)\n after_rot = list(dq)\n dq.extendleft([7, 8, 9])\n return (trail, after_left, after_rot, list(dq), dq.maxlen)","input":"window([1, 2, 3, 4], 3)","language":"Python","predicted_output":"([[1], [1, 2], [1, 2, 3], [2, 3, 4]], ['L', 2, 3], [2, 3, 'L'], [9, 8, 7], 3)"} |
| {"id":"cmsv9c94m01jng4p2zsoo9wh4","kind":"contributor_item","title":"Submission OO9WH4","provisional":false,"code":"import heapq\n\n\ndef schedule(tasks):\n heap = []\n for name, pri in tasks:\n heapq.heappush(heap, (pri, name))\n snapshot = list(heap)\n first = heapq.heappop(heap)\n pushed = heapq.heappushpop(heap, (5, \"late\"))\n replaced = heapq.heapreplace(heap, (0, \"now\"))\n return (snapshot, first, pushed, replaced, heap[0], sorted(heap))","input":"schedule([(\"b\", 2), (\"a\", 2), (\"c\", 1), (\"d\", 3)])","language":"Python","predicted_output":"([(1, 'c'), (2, 'b'), (2, 'a'), (3, 'd')], (1, 'c'), (2, 'a'), (2, 'b'), (0, 'now'), [(0, 'now'), (3, 'd'), (5, 'late')])"} |
| {"id":"cmsv9c94m01jqg4p2wk8m5xh5","kind":"contributor_item","title":"Submission 8M5XH5","provisional":false,"code":"def carve(text, sep):\n return (\n text.partition(sep),\n text.rpartition(sep),\n text.split(sep, 1),\n text.rsplit(sep, 1),\n \"nope\".partition(sep),\n \"nope\".rpartition(sep),\n len(text.partition(sep)),\n len(\"nope\".split(sep)),\n )","input":"carve(\"a=b=c\", \"=\")","language":"Python","predicted_output":"(('a', '=', 'b=c'), ('a=b', '=', 'c'), ['a', 'b=c'], ['a=b', 'c'], ('nope', '', ''), ('', '', 'nope'), 3, 1)"} |
| {"id":"cmsv9c94m01jtg4p2bbitbyxl","kind":"contributor_item","title":"Submission ITBYXL","provisional":false,"code":"from decimal import Decimal, ROUND_HALF_EVEN, ROUND_HALF_UP\nfrom fractions import Fraction\n\n\ndef money():\n exact = Decimal(\"0.1\") * 3\n return (\n str(exact),\n exact == Decimal(\"0.3\"),\n Decimal(0.1) == Decimal(\"0.1\"),\n str(Decimal(\"2.665\").quantize(Decimal(\"0.01\"), rounding=ROUND_HALF_UP)),\n str(Decimal(\"2.665\").quantize(Decimal(\"0.01\"), rounding=ROUND_HALF_EVEN)),\n round(2.675, 2),\n str(Decimal(\"1.10\") + Decimal(\"2.20\")),\n Decimal(\"1.10\") == Decimal(\"1.1\"),\n Fraction(Decimal(\"0.25\")) == Fraction(1, 4),\n Fraction(0.1).limit_denominator(100),\n )","input":"money()","language":"Python","predicted_output":"('0.3', True, False, '2.67', '2.66', 2.67, '3.30', True, True, Fraction(1, 10))"} |
| {"id":"cmsv9c94n01jvg4p24j3xeyhb","kind":"contributor_item","title":"Submission 3XEYHB","provisional":false,"code":"class Grid:\n def __init__(self, data):\n self.data = data\n\n def __getitem__(self, key):\n if isinstance(key, tuple):\n return (\"tuple\", tuple(self._show(k) for k in key))\n return (\"single\", self._show(key))\n\n def _show(self, k):\n if isinstance(k, slice):\n parts = (k.start, k.stop, k.step)\n if all(p is None or isinstance(p, int) for p in parts):\n return parts + (k.indices(len(self.data)),)\n return parts + (\"unindexable\",)\n return k\n\n\ndef probe(grid):\n return (\n grid[1],\n grid[1:3],\n grid[1:3, ::-1],\n grid[..., 2],\n grid[1:9:2],\n grid[\"a\":\"b\"],\n )","input":"probe(Grid([0, 1, 2, 3, 4]))","language":"Python","predicted_output":"(('single', 1), ('single', (1, 3, None, (1, 3, 1))), ('tuple', ((1, 3, None, (1, 3, 1)), (None, None, -1, (4, -1, -1)))), ('tuple', (Ellipsis, 2)), ('single', (1, 9, 2, (1, 5, 2))), ('single', ('a', 'b', None, 'unindexable')))"} |
| {"id":"cmsv9c94n01jwg4p2afmlfur4","kind":"contributor_item","title":"Submission MLFUR4","provisional":false,"code":"class Point:\n def __init__(self, x):\n self.x = x\n\n def __eq__(self, other):\n if not isinstance(other, Point):\n return NotImplemented\n return self.x == other.x\n\n\nclass Tagged(Point):\n __hash__ = object.__hash__\n\n\ndef check():\n out = []\n p = Point(1)\n t = Tagged(1)\n out.append(Point.__hash__)\n try:\n hash(p)\n except TypeError as exc:\n out.append(type(exc).__name__)\n out.append(Tagged.__hash__ is object.__hash__)\n out.append(hash(t) == hash(Tagged(1)))\n out.append(p == Point(1))\n out.append(p != Point(2))\n out.append(p == 1)\n try:\n {p: 1}\n except TypeError as exc:\n out.append(str(exc))\n return tuple(out)","input":"check()","language":"Python","predicted_output":"(None, 'TypeError', True, False, True, True, False, \"unhashable type: 'Point'\")"} |
| {"id":"cmsv9c94n01jxg4p2rioqq5o7","kind":"contributor_item","title":"Submission OQQ5O7","provisional":false,"code":"def sets():\n table = {frozenset([1, 2]): \"pair\", frozenset(): \"empty\"}\n s = {1, 2, 3}\n f = frozenset([3, 4])\n return (\n table[frozenset([2, 1])],\n table[frozenset()],\n frozenset([1, 2]) == {1, 2},\n s | f,\n type(s | f).__name__,\n type(f | s).__name__,\n f - s,\n s ^ f,\n len({frozenset([1, 2]), frozenset([2, 1])}),\n frozenset([1, 2]) <= s,\n )","input":"sets()","language":"Python","predicted_output":"('pair', 'empty', True, {1, 2, 3, 4}, 'set', 'frozenset', frozenset({4}), {1, 2, 4}, 1, True)"} |
| {"id":"cmsv9c94m01jug4p2s1k1wnp0","kind":"contributor_item","title":"Submission K1WNP0","provisional":false,"code":"def bits(n):\n return (\n n >> 1,\n n >> 100,\n ~n,\n n.bit_length(),\n (-1) >> 10,\n n & 0xFF,\n format(n & 0xFF, \"08b\"),\n n.to_bytes(2, \"big\", signed=True),\n int.from_bytes(b\"\\xff\\xfe\", \"big\", signed=True),\n int.from_bytes(b\"\\xff\\xfe\", \"big\"),\n )","input":"bits(-5)","language":"Python","predicted_output":"(-3, -1, 4, 3, -1, 251, '11111011', b'\\xff\\xfb', -2, 65534)"} |
| {"id":"cmsv9c94n01jzg4p2s9n2695w","kind":"contributor_item","title":"Submission N2695W","provisional":false,"code":"import functools\n\n\n@functools.total_ordering\nclass Ver:\n def __init__(self, n):\n self.n = n\n\n def __eq__(self, other):\n if not isinstance(other, Ver):\n return NotImplemented\n return self.n == other.n\n\n def __lt__(self, other):\n if not isinstance(other, Ver):\n return NotImplemented\n return self.n < other.n\n\n\ndef probe():\n a, b = Ver(1), Ver(2)\n return (\n a < b,\n a <= b,\n a >= b,\n b > a,\n a != b,\n sorted(k for k in Ver.__dict__ if k in (\"__lt__\", \"__le__\", \"__gt__\", \"__ge__\")),\n a.__gt__(5),\n a.__eq__(5),\n Ver(1) <= Ver(1),\n [v.n for v in sorted([Ver(3), Ver(1), Ver(2)], reverse=True)],\n )","input":"probe()","language":"Python","predicted_output":"(True, True, False, True, True, ['__ge__', '__gt__', '__le__', '__lt__'], NotImplemented, NotImplemented, True, [3, 2, 1])"} |
| {"id":"cmsv9c94n01jyg4p2ax0z6e3q","kind":"contributor_item","title":"Submission 0Z6E3Q","provisional":false,"code":"import enum\n\n\nclass Status(enum.Enum):\n OK = 1\n FINE = 1\n BAD = 2\n\n @classmethod\n def _missing_(cls, value):\n if value == \"ok\":\n return cls.OK\n return None\n\n\ndef probe():\n out = [m.name for m in Status]\n out.append(Status.FINE is Status.OK)\n out.append(Status.FINE.name)\n out.append(Status(\"ok\").name)\n out.append(sorted(Status.__members__))\n out.append(Status(2).name)\n out.append(len(Status))\n try:\n Status(\"nope\")\n except ValueError as exc:\n out.append(type(exc).__name__)\n return tuple(out)","input":"probe()","language":"Python","predicted_output":"('OK', 'BAD', True, 'OK', 'OK', ['BAD', 'FINE', 'OK'], 'BAD', 2, 'ValueError')"} |
| {"id":"cmsv9c94n01k3g4p24r66tu8f","kind":"contributor_item","title":"Submission 66TU8F","provisional":false,"code":"def find_first(items, target):\n log = []\n for i, x in enumerate(items):\n log.append(x)\n if x == target:\n break\n else:\n log.append(\"no-break\")\n return (-1, log)\n return (i, log)\n\n\ndef probe():\n return (\n find_first([3, 5, 7], 5),\n find_first([3, 5, 7], 9),\n find_first([], 9),\n find_first([3, 5, 7], 3),\n )","input":"probe()","language":"Python","predicted_output":"((1, [3, 5]), (-1, [3, 5, 7, 'no-break']), (-1, ['no-break']), (0, [3]))"} |
| {"id":"cmsv9c94n01k2g4p2wpxhj7t2","kind":"contributor_item","title":"Submission XHJ7T2","provisional":false,"code":"def trace(mode):\n log = []\n\n def run():\n try:\n log.append(\"try\")\n if mode == \"raise\":\n raise ValueError(\"x\")\n if mode == \"return\":\n return \"from-try\"\n except ValueError:\n log.append(\"except\")\n return \"from-except\"\n else:\n log.append(\"else\")\n return \"from-else\"\n finally:\n log.append(\"finally\")\n\n return (run(), log)\n\n\ndef all_modes():\n return [trace(m) for m in (\"raise\", \"return\", \"plain\")]","input":"all_modes()","language":"Python","predicted_output":"[('from-except', ['try', 'except', 'finally']), ('from-try', ['try', 'finally']), ('from-else', ['try', 'else', 'finally'])]"} |
| {"id":"cmsv9c94n01k4g4p24ol79632","kind":"contributor_item","title":"Submission L79632","provisional":false,"code":"import contextlib\n\n\ndef probe():\n log = []\n with contextlib.suppress(KeyError, IndexError):\n log.append(\"start\")\n data = {}\n log.append(data[\"missing\"])\n log.append(\"unreachable\")\n log.append(\"after\")\n try:\n with contextlib.suppress(KeyError):\n raise ValueError(\"boom\")\n except ValueError as exc:\n log.append((\"escaped\", str(exc)))\n with contextlib.suppress(Exception):\n log.append([1][5])\n with contextlib.suppress(KeyError):\n log.append(\"clean\")\n return tuple(log)","input":"probe()","language":"Python","predicted_output":"('start', 'after', ('escaped', 'boom'), 'clean')"} |
| {"id":"cmsv9c94n01k5g4p213kufy4d","kind":"contributor_item","title":"Submission KUFY4D","provisional":false,"code":"def make_source(values):\n it = iter(values)\n\n def pull():\n return next(it, None)\n\n return pull\n\n\ndef probe():\n src = make_source([1, 2, 0, 3, 4])\n got = list(iter(src, 0))\n rest = [src(), src(), src()]\n counter = {\"n\": 0}\n\n def tick():\n counter[\"n\"] += 1\n return counter[\"n\"]\n\n stopped = list(iter(tick, 4))\n never = iter(tick, \"never\")\n return (got, rest, stopped, counter[\"n\"], next(never), callable(src))","input":"probe()","language":"Python","predicted_output":"([1, 2], [3, 4, None], [1, 2, 3], 4, 5, True)"} |
| {"id":"cmsv9c94m01jsg4p2896ucicd","kind":"contributor_item","title":"Submission 6UCICD","provisional":false,"code":"def floaty():\n a = 0.1 + 0.2\n return (\n a,\n a == 0.3,\n repr(a) == \"0.30000000000000004\",\n float(repr(a)) == a,\n round(a, 2),\n round(2.675, 2),\n (round(0.5), round(1.5), round(2.5), round(-0.5)),\n 1e16 + 1 == 1e16,\n 0.1 + 0.2 + 0.3 == 0.1 + (0.2 + 0.3),\n )","input":"floaty()","language":"Python","predicted_output":"(0.30000000000000004, False, True, True, 0.3, 2.67, (0, 2, 2, 0), True, False)"} |
| {"id":"cmsv9c94m01jrg4p209o5iu2r","kind":"contributor_item","title":"Submission O5IU2R","provisional":false,"code":"def mutate(raw):\n ba = bytearray(raw)\n ba[0] = ba[0] + 1\n ba[1:3] = b\"XYZ\"\n return (\n raw[0],\n raw[:1],\n list(raw),\n bytes(ba),\n len(ba),\n raw,\n raw + b\"!\",\n bytes(bytearray(3)),\n )","input":"mutate(b\"abc\")","language":"Python","predicted_output":"(97, b'a', [97, 98, 99], b'bXYZ', 4, b'abc', b'abc!', b'\\x00\\x00\\x00')"} |
| {"id":"cmsv9c94m01jpg4p2g2qfcpo2","kind":"contributor_item","title":"Submission QFCPO2","provisional":false,"code":"from collections import OrderedDict\n\n\ndef reorder(pairs):\n od = OrderedDict(pairs)\n plain = dict(pairs)\n od.move_to_end(\"a\")\n od.move_to_end(\"c\", last=False)\n mirror = OrderedDict(reversed(list(od.items())))\n same_order = od == mirror\n as_plain = dict(od) == dict(mirror)\n vs_dict = plain == dict(od)\n popped = od.popitem(last=False)\n return (list(od), list(mirror), same_order, as_plain, vs_dict, popped, list(plain))","input":"reorder([(\"a\", 1), (\"b\", 2), (\"c\", 3)])","language":"Python","predicted_output":"(['b', 'a'], ['a', 'b', 'c'], False, True, True, ('c', 3), ['a', 'b', 'c'])"} |
| {"id":"cmsv9c94n01k1g4p2g1l7ctg6","kind":"contributor_item","title":"Submission L7CTG6","provisional":false,"code":"from dataclasses import dataclass, field, asdict, replace\n\n\n@dataclass\nclass Cart:\n owner: str\n items: list = field(default_factory=list)\n tag: str = field(default=\"x\", repr=False)\n\n def add(self, thing):\n self.items.append(thing)\n return self\n\n\ndef probe():\n a = Cart(\"ann\")\n b = Cart(\"bob\")\n a.add(\"apple\")\n c = replace(a, owner=\"cat\")\n c.items.append(\"pear\")\n snap = asdict(a)\n a.add(\"plum\")\n return (a.items, b.items, c.items, a.items is c.items, a.items is b.items, repr(b), snap)","input":"probe()","language":"Python","predicted_output":"(['apple', 'pear', 'plum'], [], ['apple', 'pear', 'plum'], True, False, \"Cart(owner='bob', items=[])\", {'owner': 'ann', 'items': ['apple', 'pear'], 'tag': 'x'})"} |
| {"id":"cmsv9c94m01jmg4p2ezphf5e1","kind":"contributor_item","title":"Submission PHF5E1","provisional":false,"code":"import bisect\n\n\ndef insert_both(words, word):\n left = sorted(words, key=len)\n right = list(left)\n bisect.insort_left(left, word, key=len)\n bisect.insort_right(right, word, key=len)\n pos_left = bisect.bisect_left(sorted(words, key=len), len(word), key=len)\n pos_right = bisect.bisect_right(sorted(words, key=len), len(word), key=len)\n return (left, right, pos_left, pos_right)","input":"insert_both([\"aa\", \"bb\", \"cc\", \"dddd\"], \"xx\")","language":"Python","predicted_output":"(['xx', 'aa', 'bb', 'cc', 'dddd'], ['aa', 'bb', 'cc', 'xx', 'dddd'], 0, 3)"} |
| {"id":"cmsv9c94n01k0g4p22tupv5jw","kind":"contributor_item","title":"Submission UPV5JW","provisional":false,"code":"def describe(a, b, /, c, *, d=4, **rest):\n return (a, b, c, d, rest)\n\n\ndef probe():\n out = []\n out.append(describe(1, 2, 3))\n out.append(describe(1, 2, c=3, d=9, a=99, b=100))\n try:\n describe(1, 2, 3, 4)\n except TypeError as exc:\n out.append(type(exc).__name__)\n try:\n describe(a=1, b=2, c=3)\n except TypeError as exc:\n out.append(type(exc).__name__)\n out.append(describe(*[1, 2], **{\"c\": 3, \"d\": 0}))\n return tuple(out)","input":"probe()","language":"Python","predicted_output":"((1, 2, 3, 4, {}), (1, 2, 3, 9, {'a': 99, 'b': 100}), 'TypeError', 'TypeError', (1, 2, 3, 0, {}))"} |
| {"id":"cmsvchb1101nvg4p2u5ltajpz","kind":"contributor_item","title":"Submission LTAJPZ","provisional":false,"code":"def classify(value):\n try:\n return 10 / value\n except ZeroDivisionError:\n return 'zero'\n except TypeError:\n return 'type'\n\ndef run():\n return [classify(v) for v in (5, 0, 'x')]","input":"run()","language":"Python","predicted_output":"[2.0, 'zero', 'type']"} |
| {"id":"cmsvchb1101nug4p285cv2zf1","kind":"contributor_item","title":"Submission CV2ZF1","provisional":false,"code":"def reshape(values):\n out = list(values)\n out[1:3] = ['a']\n out[0:0] = ['start']\n return out, len(out)","input":"reshape([10, 20, 30, 40])","language":"Python","predicted_output":"(['start', 10, 'a', 40], 4)"} |
| {"id":"cmsvchb1101nwg4p22s57bx7k","kind":"contributor_item","title":"Submission 57BX7K","provisional":false,"code":"def leaderboard(rows):\n return sorted(rows, key=lambda r: (r['pts'], -len(r['name'])), reverse=True)","input":"leaderboard([{'name': 'ann', 'pts': 3}, {'name': 'bo', 'pts': 3}, {'name': 'cyd', 'pts': 5}])","language":"Python","predicted_output":"[{'name': 'cyd', 'pts': 5}, {'name': 'bo', 'pts': 3}, {'name': 'ann', 'pts': 3}]"} |
| {"id":"cmsvchb1101nsg4p2zvklbmo3","kind":"contributor_item","title":"Submission KLBMO3","provisional":false,"code":"def counter():\n log = []\n def gen():\n for i in range(5):\n log.append(i)\n yield i * i\n squares = gen()\n first_two = [next(squares), next(squares)]\n return first_two, log","input":"counter()","language":"Python","predicted_output":"([0, 1], [0, 1])"} |
| {"id":"cmsvchb1101ntg4p272q2apwm","kind":"contributor_item","title":"Submission Q2APWM","provisional":false,"code":"def probe(store):\n a = store.get('x', 0)\n b = store.setdefault('y', 0)\n c = store.setdefault('y', 99)\n return a, b, c, sorted(store)","input":"probe({'z': 1})","language":"Python","predicted_output":"(0, 0, 0, ['y', 'z'])"} |
| {"id":"cmsvg8rg101oeg4p2wxkp0g6b","kind":"contributor_item","title":"Submission KP0G6B","provisional":false,"code":"def running_median(nums):\n import bisect\n sorted_so_far = []\n medians = []\n for n in nums:\n bisect.insort(sorted_so_far, n)\n length = len(sorted_so_far)\n mid = length // 2\n if length % 2 == 1:\n medians.append(sorted_so_far[mid])\n else:\n medians.append((sorted_so_far[mid - 1] + sorted_so_far[mid]) / 2)\n return medians","input":"running_median([5, 2, 8, 1, 9, 3])","language":"Python","predicted_output":"[5, 3.5, 5, 3.5, 5, 4.0]"} |
| {"id":"cmsvg8rg101ofg4p2czsiq8tl","kind":"contributor_item","title":"Submission SIQ8TL","provisional":false,"code":"def parse_key_values(pairs):\n result = {}\n for pair in pairs:\n try:\n key, value = pair.split(\"=\", 1)\n except ValueError:\n continue\n key = key.strip()\n value = value.strip()\n if value.isdigit():\n result[key] = int(value)\n else:\n try:\n result[key] = float(value)\n except ValueError:\n result[key] = value\n return result","input":"parse_key_values([\"a=10\", \"b=3.5\", \"c=hello\", \"broken\", \"d= 7 \"])","language":"Python","predicted_output":"{'a': 10, 'b': 3.5, 'c': 'hello', 'd': 7}"} |
| {"id":"cmsvg8rg101ogg4p2ywgce6y2","kind":"contributor_item","title":"Submission GCE6Y2","provisional":false,"code":"def dedupe_preserve_order(items):\n seen = set()\n result = []\n for item in items:\n key = item.lower() if isinstance(item, str) else item\n if key in seen:\n continue\n seen.add(key)\n result.append(item)\n return result\n\ndef zip_with_index(items, start=1):\n return [(start + i, v) for i, v in enumerate(dedupe_preserve_order(items))]","input":"zip_with_index([\"Apple\", \"banana\", \"apple\", \"Cherry\", \"BANANA\"], start=100)","language":"Python","predicted_output":"[(100, 'Apple'), (101, 'banana'), (102, 'Cherry')]"} |
| {"id":"cmsvg8rg101ocg4p2k6vrje5s","kind":"contributor_item","title":"Submission VRJE5S","provisional":false,"code":"def bucket_scores(scores):\n buckets = {\"low\": [], \"mid\": [], \"high\": []}\n for s in scores:\n if not isinstance(s, (int, float)):\n continue\n if s < 50:\n buckets[\"low\"].append(s)\n elif s < 80:\n buckets[\"mid\"].append(s)\n else:\n buckets[\"high\"].append(s)\n return {k: sorted(v) for k, v in buckets.items() if v}","input":"bucket_scores([45, 91, \"skip\", 62, 79, 100, 12])","language":"Python","predicted_output":"{'low': [12, 45], 'mid': [62, 79], 'high': [91, 100]}"} |
| {"id":"cmsvg8rg101odg4p2tggwl9ih","kind":"contributor_item","title":"Submission GWL9IH","provisional":false,"code":"class Inventory:\n def __init__(self):\n self.stock = {}\n def add(self, name, qty):\n self.stock[name] = self.stock.get(name, 0) + qty\n def remove(self, name, qty):\n if name not in self.stock or self.stock[name] < qty:\n raise ValueError(f\"insufficient stock for {name}\")\n self.stock[name] -= qty\n if self.stock[name] == 0:\n del self.stock[name]\n def snapshot(self):\n return dict(sorted(self.stock.items()))\n\ndef run_ops():\n inv = Inventory()\n inv.add(\"widget\", 10)\n inv.add(\"gadget\", 5)\n inv.remove(\"widget\", 4)\n try:\n inv.remove(\"gizmo\", 1)\n except ValueError as e:\n errmsg = str(e)\n return (inv.snapshot(), errmsg)","input":"run_ops()","language":"Python","predicted_output":"({'gadget': 5, 'widget': 6}, 'insufficient stock for gizmo')"} |
| {"id":"cmsvgvd6401r9g4p2ha3kk07q","kind":"contributor_item","title":"Submission 3KK07Q","provisional":false,"code":"def flatten(lst):\n result = []\n for item in lst:\n if isinstance(item, list):\n result.extend(flatten(item))\n else:\n result.append(item)\n return result","input":"flatten([1, [2, 3, [4, 5]], 6, [7, [8, [9]]]])","language":"Python","predicted_output":"[1, 2, 3, 4, 5, 6, 7, 8, 9]"} |
| {"id":"cmsvgvd6401rag4p26o3rhyqv","kind":"contributor_item","title":"Submission 3RHYQV","provisional":false,"code":"def gcd_steps(a, b):\n steps = 0\n while b:\n a, b = b, a % b\n steps += 1\n return (a, steps)","input":"gcd_steps(252, 105)","language":"Python","predicted_output":"(21, 3)"} |
| {"id":"cmsvgwu2901rbg4p25vf687de","kind":"contributor_item","title":"Submission F687DE","provisional":false,"code":"import itertools\n\ndef take_n_squares(n):\n def gen():\n i = 1\n while True:\n yield i * i\n i += 1\n return list(itertools.islice(gen(), n))","input":"take_n_squares(6)","language":"Python","predicted_output":"[1, 4, 9, 16, 25, 36]"} |
| {"id":"cmsvgxdx301rcg4p2bbdyquxq","kind":"contributor_item","title":"Submission DYQUXQ","provisional":false,"code":"import re\n\ndef tokenize(text):\n return [t for t in re.split(r\"[,;\\s]+\", text.strip()) if t]","input":"tokenize(\"apple, banana, cherry ,date\")","language":"Python","predicted_output":"['apple', 'banana', 'cherry', 'date']"} |
| {"id":"cmsvgyl4f01rdg4p2rw9fgj3y","kind":"contributor_item","title":"Submission 9FGJ3Y","provisional":false,"code":"from collections import Counter\n\ndef top_words(text, k):\n words = text.lower().split()\n return Counter(words).most_common(k)","input":"top_words(\"the cat sat on the mat the cat ran\", 2)","language":"Python","predicted_output":"[('the', 3), ('cat', 2)]"} |
| {"id":"cmsvgyl4f01reg4p2a49hwugz","kind":"contributor_item","title":"Submission 9HWUGZ","provisional":false,"code":"def flatten_dict(d, parent_key=\"\"):\n items = {}\n for k, v in d.items():\n new_key = f\"{parent_key}.{k}\" if parent_key else k\n if isinstance(v, dict):\n items.update(flatten_dict(v, new_key))\n else:\n items[new_key] = v\n return items","input":"flatten_dict({\"a\": 1, \"b\": {\"c\": 2, \"d\": {\"e\": 3}}})","language":"Python","predicted_output":"{'a': 1, 'b.c': 2, 'b.d.e': 3}"} |
| {"id":"cmsvgz4ah01rfg4p2ylkbpjg2","kind":"contributor_item","title":"Submission KBPJG2","provisional":false,"code":"class ValidationError(Exception):\n pass\n\ndef validate_all(records):\n errors = []\n for i, r in enumerate(records):\n if \"age\" not in r:\n errors.append(f\"record {i}: missing age\")\n elif r[\"age\"] < 0:\n errors.append(f\"record {i}: negative age\")\n if errors:\n raise ValidationError(\"; \".join(errors))\n return \"all valid\"\n\ndef run_validation(records):\n try:\n return validate_all(records)\n except ValidationError as e:\n return str(e)","input":"run_validation([{\"age\": 5}, {\"name\": \"x\"}, {\"age\": -3}])","language":"Python","predicted_output":"record 1: missing age; record 2: negative age"} |
| {"id":"cmsvh09gc01rhg4p2hdmhquum","kind":"contributor_item","title":"Submission MHQUUM","provisional":false,"code":"def is_balanced(s):\n pairs = {\")\": \"(\", \"]\": \"[\", \"}\": \"{\"}\n stack = []\n for ch in s:\n if ch in \"([{\":\n stack.append(ch)\n elif ch in \")]}\":\n if not stack or stack.pop() != pairs[ch]:\n return False\n return not stack","input":"is_balanced(\"([a{b}c](d))\")","language":"Python","predicted_output":"True"} |
| {"id":"cmsvh09gc01rgg4p2crm31q55","kind":"contributor_item","title":"Submission M31Q55","provisional":false,"code":"def merge_sorted(a, b):\n result = []\n i = j = 0\n while i < len(a) and j < len(b):\n if a[i] <= b[j]:\n result.append(a[i])\n i += 1\n else:\n result.append(b[j])\n j += 1\n result.extend(a[i:])\n result.extend(b[j:])\n return result","input":"merge_sorted([1, 4, 6], [2, 3, 9, 10])","language":"Python","predicted_output":"[1, 2, 3, 4, 6, 9, 10]"} |
| {"id":"cmsvh09gc01rig4p21uvm3dup","kind":"contributor_item","title":"Submission VM3DUP","provisional":false,"code":"def caesar(text, shift):\n result = []\n for ch in text:\n if ch.isalpha():\n base = ord(\"A\") if ch.isupper() else ord(\"a\")\n result.append(chr((ord(ch) - base + shift) % 26 + base))\n else:\n result.append(ch)\n return \"\".join(result)","input":"caesar(\"Hello, World!\", 5)","language":"Python","predicted_output":"Mjqqt, Btwqi!"} |
| {"id":"cmsvh1ew801rkg4p2ah41bavi","kind":"contributor_item","title":"Submission 41BAVI","provisional":false,"code":"def caesar_encrypt(text, shift):\n result = []\n for ch in text:\n if ch.isalpha():\n base = ord('A') if ch.isupper() else ord('a')\n result.append(chr((ord(ch) - base + shift) % 26 + base))\n else:\n result.append(ch)\n return \"\".join(result)","input":"caesar_encrypt('Hello, World!', 3)","language":"Python","predicted_output":"Khoor, Zruog!"} |
| {"id":"cmsvh1ew801rjg4p25twjdmy0","kind":"contributor_item","title":"Submission WJDMY0","provisional":false,"code":"def compute_facts(ns):\n cache = {}\n def fact(n):\n if n in cache:\n return cache[n]\n if n <= 1:\n result = 1\n else:\n result = n * fact(n - 1)\n cache[n] = result\n return result\n return [fact(x) for x in ns]","input":"compute_facts([0, 1, 2, 3, 4, 5])","language":"Python","predicted_output":"[1, 1, 2, 6, 24, 120]"} |
| {"id":"cmsvh1ew801rlg4p2b5ielaub","kind":"contributor_item","title":"Submission IELAUB","provisional":false,"code":"def rotate_left(lst, k):\n if not lst:\n return lst\n k %= len(lst)\n return lst[k:] + lst[:k]","input":"rotate_left([1, 2, 3, 4, 5], 8)","language":"Python","predicted_output":"[4, 5, 1, 2, 3]"} |
| {"id":"cmsvh1rgp01rrg4p2v8usgajo","kind":"contributor_item","title":"Submission USGAJO","provisional":false,"code":"class Point:\n def __init__(self, x, y):\n self.x = x\n self.y = y\n def __eq__(self, other):\n return isinstance(other, Point) and self.x == other.x and self.y == other.y\n def __hash__(self):\n return hash((self.x, self.y))\n def __repr__(self):\n return f\"Point({self.x}, {self.y})\"\n\ndef dedupe_points(points):\n return sorted(set(points), key=lambda p: (p.x, p.y))","input":"dedupe_points([Point(1, 2), Point(3, 4), Point(1, 2), Point(0, 0)])","language":"Python","predicted_output":"[Point(0, 0), Point(1, 2), Point(3, 4)]"} |
| {"id":"cmsvh1rgp01rpg4p2zs5swh2h","kind":"contributor_item","title":"Submission 5SWH2H","provisional":false,"code":"def modes(values):\n from collections import Counter\n counts = Counter(values)\n max_count = max(counts.values())\n return sorted(v for v, c in counts.items() if c == max_count)","input":"modes([1, 2, 2, 3, 3, 4])","language":"Python","predicted_output":"[2, 3]"} |
| {"id":"cmsvh1rgp01rsg4p28dd4alq4","kind":"contributor_item","title":"Submission D4ALQ4","provisional":false,"code":"def pipeline_sum(nums):\n evens = filter(lambda x: x % 2 == 0, nums)\n doubled = map(lambda x: x * 2, evens)\n return sum(doubled)","input":"pipeline_sum([1, 2, 3, 4, 5, 6, 7, 8])","language":"Python","predicted_output":"40"} |
| {"id":"cmsvh1rgp01rqg4p26r0i5nwy","kind":"contributor_item","title":"Submission 0I5NWY","provisional":false,"code":"def two_sum(nums, target):\n seen = {}\n for i, n in enumerate(nums):\n complement = target - n\n if complement in seen:\n return [seen[complement], i]\n seen[n] = i\n return None","input":"two_sum([2, 7, 11, 15, 3], 13)","language":"Python","predicted_output":"[0, 2]"} |
| {"id":"cmsvh1rgp01rmg4p2tws8r7v8","kind":"contributor_item","title":"Submission S8R7V8","provisional":false,"code":"from collections import OrderedDict\n\nclass LRUCache:\n def __init__(self, capacity):\n self.capacity = capacity\n self.data = OrderedDict()\n def get(self, key):\n if key not in self.data:\n return -1\n self.data.move_to_end(key)\n return self.data[key]\n def put(self, key, value):\n if key in self.data:\n self.data.move_to_end(key)\n self.data[key] = value\n if len(self.data) > self.capacity:\n self.data.popitem(last=False)\n\ndef run_cache():\n c = LRUCache(2)\n c.put(\"a\", 1)\n c.put(\"b\", 2)\n c.get(\"a\")\n c.put(\"c\", 3)\n return list(c.data.items())","input":"run_cache()","language":"Python","predicted_output":"[('a', 1), ('c', 3)]"} |
| {"id":"cmsvh1rgp01rog4p2u6zuzhn5","kind":"contributor_item","title":"Submission ZUZHN5","provisional":false,"code":"def chunk(lst, n):\n return [lst[i:i + n] for i in range(0, len(lst), n)]","input":"chunk([1, 2, 3, 4, 5, 6, 7], 3)","language":"Python","predicted_output":"[[1, 2, 3], [4, 5, 6], [7]]"} |
| {"id":"cmsvh1rgp01rng4p2korsuouz","kind":"contributor_item","title":"Submission RSUOUZ","provisional":false,"code":"def int_to_roman(num):\n vals = [(1000, \"M\"), (900, \"CM\"), (500, \"D\"), (400, \"CD\"), (100, \"C\"),\n (90, \"XC\"), (50, \"L\"), (40, \"XL\"), (10, \"X\"), (9, \"IX\"),\n (5, \"V\"), (4, \"IV\"), (1, \"I\")]\n result = \"\"\n for v, sym in vals:\n while num >= v:\n result += sym\n num -= v\n return result","input":"int_to_roman(1994)","language":"Python","predicted_output":"MCMXCIV"} |
| {"id":"cmsvh3vna01s0g4p2rz19dqbh","kind":"contributor_item","title":"Submission 19DQBH","provisional":false,"code":"def quicksort(arr):\n if len(arr) <= 1:\n return arr\n pivot = arr[len(arr) // 2]\n left = [x for x in arr if x < pivot]\n mid = [x for x in arr if x == pivot]\n right = [x for x in arr if x > pivot]\n return quicksort(left) + mid + quicksort(right)","input":"quicksort([5, 2, 9, 1, 5, 6])","language":"Python","predicted_output":"[1, 2, 5, 5, 6, 9]"} |
| {"id":"cmsvh3vna01s1g4p2wsoodnw4","kind":"contributor_item","title":"Submission OODNW4","provisional":false,"code":"def max_subarray_sum(nums):\n best = nums[0]\n current = nums[0]\n for n in nums[1:]:\n current = max(n, current + n)\n best = max(best, current)\n return best","input":"max_subarray_sum([-2, 1, -3, 4, -1, 2, 1, -5, 4])","language":"Python","predicted_output":"6"} |
| {"id":"cmsvh3vna01rug4p2rchwkc82","kind":"contributor_item","title":"Submission HWKC82","provisional":false,"code":"def primes_up_to(n):\n sieve = [True] * (n + 1)\n sieve[0:2] = [False, False]\n for i in range(2, int(n ** 0.5) + 1):\n if sieve[i]:\n for j in range(i * i, n + 1, i):\n sieve[j] = False\n return [i for i, is_p in enumerate(sieve) if is_p]","input":"primes_up_to(30)","language":"Python","predicted_output":"[2, 3, 5, 7, 11, 13, 17, 19, 23, 29]"} |
| {"id":"cmsvh3vna01rtg4p2dud9lsao","kind":"contributor_item","title":"Submission D9LSAO","provisional":false,"code":"def fib_sequence(n):\n a, b = 0, 1\n seq = []\n for _ in range(n):\n seq.append(a)\n a, b = b, a + b\n return seq","input":"fib_sequence(10)","language":"Python","predicted_output":"[0, 1, 1, 2, 3, 5, 8, 13, 21, 34]"} |
| {"id":"cmsvh3vna01rvg4p2h1hf5l6y","kind":"contributor_item","title":"Submission HF5L6Y","provisional":false,"code":"def gcd(a, b):\n while b:\n a, b = b, a % b\n return a\n\ndef gcd_lcm_pair(a, b):\n g = gcd(a, b)\n return (g, a * b // g)","input":"gcd_lcm_pair(48, 18)","language":"Python","predicted_output":"(6, 144)"} |
| {"id":"cmsvh3vna01s2g4p21vgxpiy2","kind":"contributor_item","title":"Submission GXPIY2","provisional":false,"code":"def roman_to_int(s):\n values = {\"I\": 1, \"V\": 5, \"X\": 10, \"L\": 50, \"C\": 100, \"D\": 500, \"M\": 1000}\n total = 0\n prev = 0\n for ch in reversed(s):\n v = values[ch]\n if v < prev:\n total -= v\n else:\n total += v\n prev = v\n return total","input":"roman_to_int(\"MCMXCIV\")","language":"Python","predicted_output":"1994"} |
| {"id":"cmsvh3vna01rwg4p2r776mh9b","kind":"contributor_item","title":"Submission 76MH9B","provisional":false,"code":"def word_freq(text):\n words = text.lower().split()\n freq = {}\n for w in words:\n freq[w] = freq.get(w, 0) + 1\n return sorted(freq.items(), key=lambda kv: (-kv[1], kv[0]))","input":"word_freq(\"the cat sat on the mat the cat ran\")","language":"Python","predicted_output":"[('the', 3), ('cat', 2), ('mat', 1), ('on', 1), ('ran', 1), ('sat', 1)]"} |
| {"id":"cmsvh3vna01ryg4p2hx4bq6mh","kind":"contributor_item","title":"Submission 4BQ6MH","provisional":false,"code":"def matmul(a, b):\n rows_a, cols_a = len(a), len(a[0])\n cols_b = len(b[0])\n result = [[0] * cols_b for _ in range(rows_a)]\n for i in range(rows_a):\n for j in range(cols_b):\n total = 0\n for k in range(cols_a):\n total += a[i][k] * b[k][j]\n result[i][j] = total\n return result","input":"matmul([[1, 2], [3, 4]], [[5, 6], [7, 8]])","language":"Python","predicted_output":"[[19, 22], [43, 50]]"} |
| {"id":"cmsvh3vna01rzg4p2u26zgec3","kind":"contributor_item","title":"Submission 6ZGEC3","provisional":false,"code":"def longest_common_prefix(words):\n if not words:\n return \"\"\n prefix = words[0]\n for w in words[1:]:\n while not w.startswith(prefix):\n prefix = prefix[:-1]\n if not prefix:\n return \"\"\n return prefix","input":"longest_common_prefix([\"flower\", \"flow\", \"flight\"])","language":"Python","predicted_output":"fl"} |
| {"id":"cmsvh3vna01rxg4p26kbl19jw","kind":"contributor_item","title":"Submission BL19JW","provisional":false,"code":"def run_length_encode(s):\n if not s:\n return \"\"\n result = []\n prev = s[0]\n count = 1\n for ch in s[1:]:\n if ch == prev:\n count += 1\n else:\n result.append(prev + str(count))\n prev = ch\n count = 1\n result.append(prev + str(count))\n return \"\".join(result)","input":"run_length_encode(\"aaabbbccd\")","language":"Python","predicted_output":"a3b3c2d1"} |
| {"id":"cmsvh4bxd01s5g4p2go3kauzs","kind":"contributor_item","title":"Submission 3KAUZS","provisional":false,"code":"class TreeNode:\n def __init__(self, val, left=None, right=None):\n self.val = val\n self.left = left\n self.right = right\n\ndef inorder(node):\n if node is None:\n return []\n return inorder(node.left) + [node.val] + inorder(node.right)\n\ndef build_tree():\n return TreeNode(4, TreeNode(2, TreeNode(1), TreeNode(3)), TreeNode(6, TreeNode(5), TreeNode(7)))\n\ndef run_inorder():\n return inorder(build_tree())","input":"run_inorder()","language":"Python","predicted_output":"[1, 2, 3, 4, 5, 6, 7]"} |
| {"id":"cmsvh4bxd01s8g4p24grgeyz1","kind":"contributor_item","title":"Submission RGEYZ1","provisional":false,"code":"def knapsack(weights, values, capacity):\n n = len(weights)\n dp = [[0] * (capacity + 1) for _ in range(n + 1)]\n for i in range(1, n + 1):\n for w in range(capacity + 1):\n if weights[i - 1] <= w:\n dp[i][w] = max(dp[i - 1][w], dp[i - 1][w - weights[i - 1]] + values[i - 1])\n else:\n dp[i][w] = dp[i - 1][w]\n return dp[n][capacity]","input":"knapsack([1, 3, 4, 5], [1, 4, 5, 7], 7)","language":"Python","predicted_output":"9"} |
| {"id":"cmsvh4bxd01s3g4p2aarbja9w","kind":"contributor_item","title":"Submission RBJA9W","provisional":false,"code":"def eval_rpn(tokens):\n stack = []\n for tok in tokens:\n if tok in (\"+\", \"-\", \"*\", \"/\"):\n b = stack.pop()\n a = stack.pop()\n if tok == \"+\":\n stack.append(a + b)\n elif tok == \"-\":\n stack.append(a - b)\n elif tok == \"*\":\n stack.append(a * b)\n else:\n stack.append(int(a / b))\n else:\n stack.append(int(tok))\n return stack[0]","input":"eval_rpn([\"2\", \"1\", \"1\", \"+\", \"*\"])","language":"Python","predicted_output":"4"} |
| {"id":"cmsvh4bxd01sag4p2vhnssnjd","kind":"contributor_item","title":"Submission NSSNJD","provisional":false,"code":"def rotate_matrix(matrix):\n return [list(row) for row in zip(*matrix[::-1])]","input":"rotate_matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]])","language":"Python","predicted_output":"[[7, 4, 1], [8, 5, 2], [9, 6, 3]]"} |
| {"id":"cmsvh4bxd01s7g4p22mhu04dn","kind":"contributor_item","title":"Submission HU04DN","provisional":false,"code":"def combination_sum(candidates, target):\n result = []\n def backtrack(start, path, remaining):\n if remaining == 0:\n result.append(list(path))\n return\n if remaining < 0:\n return\n for i in range(start, len(candidates)):\n path.append(candidates[i])\n backtrack(i, path, remaining - candidates[i])\n path.pop()\n backtrack(0, [], target)\n return result","input":"combination_sum([2, 3, 6, 7], 7)","language":"Python","predicted_output":"[[2, 2, 3], [7]]"} |
| {"id":"cmsvh4bxd01sbg4p2ykvr0uv4","kind":"contributor_item","title":"Submission VR0UV4","provisional":false,"code":"def unique_paths(m, n):\n dp = [[1] * n for _ in range(m)]\n for i in range(1, m):\n for j in range(1, n):\n dp[i][j] = dp[i - 1][j] + dp[i][j - 1]\n return dp[m - 1][n - 1]","input":"unique_paths(3, 7)","language":"Python","predicted_output":"28"} |
| {"id":"cmsvh4bxd01scg4p2knd4r09s","kind":"contributor_item","title":"Submission D4R09S","provisional":false,"code":"def edit_distance(a, b):\n m, n = len(a), len(b)\n dp = [[0] * (n + 1) for _ in range(m + 1)]\n for i in range(m + 1):\n dp[i][0] = i\n for j in range(n + 1):\n dp[0][j] = j\n for i in range(1, m + 1):\n for j in range(1, n + 1):\n if a[i - 1] == b[j - 1]:\n dp[i][j] = dp[i - 1][j - 1]\n else:\n dp[i][j] = 1 + min(dp[i - 1][j], dp[i][j - 1], dp[i - 1][j - 1])\n return dp[m][n]","input":"edit_distance(\"horse\", \"ros\")","language":"Python","predicted_output":"3"} |
| {"id":"cmsvh4bxd01s6g4p2f6j83e69","kind":"contributor_item","title":"Submission J83E69","provisional":false,"code":"def permutations(lst):\n if len(lst) <= 1:\n return [lst]\n result = []\n for i in range(len(lst)):\n rest = lst[:i] + lst[i + 1:]\n for p in permutations(rest):\n result.append([lst[i]] + p)\n return result","input":"permutations([1, 2, 3])","language":"Python","predicted_output":"[[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]]"} |
| {"id":"cmsvh4bxd01s4g4p2cds6wpky","kind":"contributor_item","title":"Submission S6WPKY","provisional":false,"code":"class Node:\n def __init__(self, val, nxt=None):\n self.val = val\n self.next = nxt\n\ndef reverse_list(head):\n prev = None\n while head:\n nxt = head.next\n head.next = prev\n prev = head\n head = nxt\n return prev\n\ndef to_list(head):\n out = []\n while head:\n out.append(head.val)\n head = head.next\n return out\n\ndef build(vals):\n head = None\n for v in reversed(vals):\n head = Node(v, head)\n return head\n\ndef run_reverse(vals):\n return to_list(reverse_list(build(vals)))","input":"run_reverse([1, 2, 3, 4, 5])","language":"Python","predicted_output":"[5, 4, 3, 2, 1]"} |
| {"id":"cmsvh4bxd01s9g4p28p9vc6dn","kind":"contributor_item","title":"Submission 9VC6DN","provisional":false,"code":"def compress_if_shorter(s):\n if not s:\n return s\n parts = []\n prev = s[0]\n count = 1\n for ch in s[1:]:\n if ch == prev:\n count += 1\n else:\n parts.append(prev + str(count))\n prev = ch\n count = 1\n parts.append(prev + str(count))\n compressed = \"\".join(parts)\n return compressed if len(compressed) < len(s) else s","input":"compress_if_shorter(\"aabcccccaaa\")","language":"Python","predicted_output":"a2b1c5a3"} |
| {"id":"cmsvmflok01vmg4p2zoakvz25","kind":"contributor_item","title":"Submission AKVZ25","provisional":false,"code":"def is_prime(n):\n if n < 2:\n return False\n for i in range(2, int(n ** 0.5) + 1):\n if n % i == 0:\n return False\n return True","input":"is_prime(97)","language":"Python","predicted_output":"True"} |
| {"id":"cmsvmflok01vqg4p2grjwr7te","kind":"contributor_item","title":"Submission JWR7TE","provisional":false,"code":"def binary_to_decimal(s):\n return int(s, 2)","input":"binary_to_decimal('110101')","language":"Python","predicted_output":"53"} |
| {"id":"cmsvmflok01vng4p25skrn71b","kind":"contributor_item","title":"Submission KRN71B","provisional":false,"code":"def fibonacci(n):\n seq = [0, 1]\n for i in range(2, n):\n seq.append(seq[-1] + seq[-2])\n return seq[:n]","input":"fibonacci(10)","language":"Python","predicted_output":"[0, 1, 1, 2, 3, 5, 8, 13, 21, 34]"} |
| {"id":"cmsvmflok01vog4p29ui9ckr5","kind":"contributor_item","title":"Submission I9CKR5","provisional":false,"code":"def mat_mult(a, b):\n result = [[0, 0], [0, 0]]\n for i in range(2):\n for j in range(2):\n for k in range(2):\n result[i][j] += a[i][k] * b[k][j]\n return result","input":"mat_mult([[1, 2], [3, 4]], [[5, 6], [7, 8]])","language":"Python","predicted_output":"[[19, 22], [43, 50]]"} |
| {"id":"cmsvmflok01vpg4p28lbtyg12","kind":"contributor_item","title":"Submission BTYG12","provisional":false,"code":"def group_anagrams(words):\n groups = {}\n for w in words:\n key = \"\".join(sorted(w))\n groups.setdefault(key, []).append(w)\n return groups","input":"group_anagrams(['eat', 'tea', 'tan', 'ate', 'nat', 'bat'])","language":"Python","predicted_output":"{'aet': ['eat', 'tea', 'ate'], 'ant': ['tan', 'nat'], 'abt': ['bat']}"} |
| {"id":"cmsvmflol01vvg4p29cttz8ab","kind":"contributor_item","title":"Submission TTZ8AB","provisional":false,"code":"def run_length_decode(s):\n result = []\n i = 0\n while i < len(s):\n ch = s[i]\n i += 1\n num_start = i\n while i < len(s) and s[i].isdigit():\n i += 1\n count = int(s[num_start:i])\n result.append(ch * count)\n return ''.join(result)","input":"run_length_decode('a3b1c5')","language":"Python","predicted_output":"aaabccccc"} |
| {"id":"cmsvmflol01vtg4p2wtglqurr","kind":"contributor_item","title":"Submission GLQURR","provisional":false,"code":"def compute_zigzag_checksum(values, mod=97):\n total = 0\n direction = 1\n for idx, v in enumerate(values):\n total += direction * (v ** 2 + idx)\n if (idx + 1) % 3 == 0:\n direction *= -1\n return total % mod","input":"compute_zigzag_checksum([4, 9, 2, 7, 5, 1, 8, 3])","language":"Python","predicted_output":"6"} |
| {"id":"cmsvmflok01vrg4p2j06uf87l","kind":"contributor_item","title":"Submission 6UF87L","provisional":false,"code":"def decimal_to_binary(n):\n if n == 0:\n return '0'\n digits = []\n while n > 0:\n digits.append(str(n % 2))\n n //= 2\n return ''.join(reversed(digits))","input":"decimal_to_binary(53)","language":"Python","predicted_output":"110101"} |
| {"id":"cmsvmflok01vsg4p2sxnc0u48","kind":"contributor_item","title":"Submission NC0U48","provisional":false,"code":"def gcd_lcm(a, b):\n x, y = a, b\n while y:\n x, y = y, x % y\n gcd = x\n lcm = a * b // gcd\n return (gcd, lcm)","input":"gcd_lcm(12, 18)","language":"Python","predicted_output":"(6, 36)"} |
| {"id":"cmsvmflol01vug4p2qcpu73lp","kind":"contributor_item","title":"Submission PU73LP","provisional":false,"code":"def merge_two_sorted(a, b):\n i = j = 0\n result = []\n while i < len(a) and j < len(b):\n if a[i] <= b[j]:\n result.append(a[i])\n i += 1\n else:\n result.append(b[j])\n j += 1\n result.extend(a[i:])\n result.extend(b[j:])\n return result","input":"merge_two_sorted([1, 4, 7], [2, 3, 8, 9])","language":"Python","predicted_output":"[1, 2, 3, 4, 7, 8, 9]"} |
| {"id":"cmsvmjjpi01x7g4p2u8i9c0m6","kind":"contributor_item","title":"Submission I9C0M6","provisional":false,"code":"def dedupe_preserve_order(items):\n seen = set()\n result = []\n for item in items:\n if item not in seen:\n seen.add(item)\n result.append(item)\n return result","input":"dedupe_preserve_order([3, 1, 2, 3, 1, 4, 2, 5])","language":"Python","predicted_output":"[3, 1, 2, 4, 5]"} |
| {"id":"cmsvmjjpi01x1g4p2xvm4it39","kind":"contributor_item","title":"Submission M4IT39","provisional":false,"code":"def valid_brackets(s):\n pairs = {')': '(', ']': '[', '}': '{'}\n stack = []\n for ch in s:\n if ch in '([{':\n stack.append(ch)\n elif ch in pairs:\n if not stack or stack.pop() != pairs[ch]:\n return False\n return not stack","input":"valid_brackets('a(b[c]{d}e)f')","language":"Python","predicted_output":"True"} |
| {"id":"cmsvmjjpi01x0g4p2bpkvv869","kind":"contributor_item","title":"Submission KVV869","provisional":false,"code":"def roman_to_int(s):\n vals = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000}\n total = 0\n for i in range(len(s)):\n v = vals[s[i]]\n if i + 1 < len(s) and v < vals[s[i + 1]]:\n total -= v\n else:\n total += v\n return total","input":"roman_to_int('MCMXCIV')","language":"Python","predicted_output":"1994"} |
| {"id":"cmsvmjjpi01x3g4p2ntoh7pto","kind":"contributor_item","title":"Submission OH7PTO","provisional":false,"code":"class VisitCounter:\n def __init__(self):\n self.counts = {}\n def visit(self, page):\n self.counts[page] = self.counts.get(page, 0) + 1\n return self.counts[page]\n\ndef run_visits(pages):\n vc = VisitCounter()\n return [vc.visit(p) for p in pages]","input":"run_visits(['home', 'about', 'home', 'home', 'about'])","language":"Python","predicted_output":"[1, 1, 2, 3, 2]"} |
| {"id":"cmsvmjjpi01x5g4p23d3qdkp1","kind":"contributor_item","title":"Submission 3QDKP1","provisional":false,"code":"def upper_bound(nums, target):\n lo, hi = 0, len(nums)\n while lo < hi:\n mid = (lo + hi) // 2\n if nums[mid] <= target:\n lo = mid + 1\n else:\n hi = mid\n return lo","input":"upper_bound([1, 2, 2, 2, 3, 5], 2)","language":"Python","predicted_output":"4"} |
| {"id":"cmsvmjjpi01x8g4p25296zhi7","kind":"contributor_item","title":"Submission 96ZHI7","provisional":false,"code":"def digit_sum(n):\n n = abs(n)\n if n < 10:\n return n\n return n % 10 + digit_sum(n // 10)","input":"digit_sum(987654321)","language":"Python","predicted_output":"45"} |
| {"id":"cmsvmjjpi01x6g4p2scptpsih","kind":"contributor_item","title":"Submission PTPSIH","provisional":false,"code":"def flatten_list(lst):\n result = []\n for item in lst:\n if isinstance(item, list):\n result.extend(flatten_list(item))\n else:\n result.append(item)\n return result","input":"flatten_list([1, [2, [3, 4], 5], [[6]], 7])","language":"Python","predicted_output":"[1, 2, 3, 4, 5, 6, 7]"} |
| {"id":"cmsvmjjpi01x2g4p2ot7poq9u","kind":"contributor_item","title":"Submission 7POQ9U","provisional":false,"code":"def caesar_decode(text, shift):\n result = []\n for ch in text:\n if ch.isalpha():\n base = ord('A') if ch.isupper() else ord('a')\n result.append(chr((ord(ch) - base - shift) % 26 + base))\n else:\n result.append(ch)\n return ''.join(result)","input":"caesar_decode('Mjqqt, Btwqi!', 5)","language":"Python","predicted_output":"Hello, World!"} |
| {"id":"cmsvmjjpi01x9g4p2mee2vj01","kind":"contributor_item","title":"Submission E2VJ01","provisional":false,"code":"def power_set(items):\n result = [[]]\n for item in items:\n result += [subset + [item] for subset in result]\n return sorted(result, key=lambda s: (len(s), s))","input":"power_set([1, 2, 3])","language":"Python","predicted_output":"[[], [1], [2], [3], [1, 2], [1, 3], [2, 3], [1, 2, 3]]"} |
| {"id":"cmsvmjjpi01x4g4p2k4q8bewz","kind":"contributor_item","title":"Submission Q8BEWZ","provisional":false,"code":"def rle(s):\n if not s:\n return \"\"\n out = []\n prev = s[0]\n count = 1\n for ch in s[1:]:\n if ch == prev:\n count += 1\n else:\n out.append(prev + str(count))\n prev = ch\n count = 1\n out.append(prev + str(count))\n return \"\".join(out)","input":"rle('aaabbbccd')","language":"Python","predicted_output":"a3b3c2d1"} |
| {"id":"cmsvnghm301ymg4p2scqmrajj","kind":"contributor_item","title":"Submission QMRAJJ","provisional":false,"code":"def scale_recipe(ingredients, factor):\n scaled = {}\n for name, amount in ingredients.items():\n new_amount = round(amount * factor, 2)\n scaled[name] = new_amount\n return scaled","input":"scale_recipe({'flour': 2.5, 'sugar': 1.0, 'eggs': 3, 'butter': 0.75}, 1.5)","language":"Python","predicted_output":"{'flour': 3.75, 'sugar': 1.5, 'eggs': 4.5, 'butter': 1.12}"} |
| {"id":"cmsvnghm301yqg4p2yuzplvdv","kind":"contributor_item","title":"Submission ZPLVDV","provisional":false,"code":"def weighted_round_robin(servers, num_requests):\n current_weights = {name: 0 for name, _ in servers}\n total_weight = sum(w for _, w in servers)\n assignments = []\n for _ in range(num_requests):\n for name, weight in servers:\n current_weights[name] += weight\n chosen = max(current_weights, key=lambda k: current_weights[k])\n current_weights[chosen] -= total_weight\n assignments.append(chosen)\n return assignments","input":"weighted_round_robin([('A', 5), ('B', 1), ('C', 1)], 7)","language":"Python","predicted_output":"['A', 'A', 'B', 'A', 'C', 'A', 'A']"} |
| {"id":"cmsvnghm301ytg4p2f9zj3gm0","kind":"contributor_item","title":"Submission ZJ3GM0","provisional":false,"code":"def compute_standings(matches):\n table = {}\n for home, away, home_score, away_score in matches:\n for team in (home, away):\n table.setdefault(team, {\"points\": 0, \"gd\": 0})\n if home_score > away_score:\n table[home][\"points\"] += 3\n elif away_score > home_score:\n table[away][\"points\"] += 3\n else:\n table[home][\"points\"] += 1\n table[away][\"points\"] += 1\n table[home][\"gd\"] += home_score - away_score\n table[away][\"gd\"] += away_score - home_score\n ranked = sorted(table.items(), key=lambda kv: (-kv[1][\"points\"], -kv[1][\"gd\"]))\n return [name for name, _ in ranked]","input":"compute_standings([('A','B',2,1), ('C','D',0,0), ('B','C',3,1), ('A','D',1,1)])","language":"Python","predicted_output":"['A', 'B', 'D', 'C']"} |
| {"id":"cmsvnghm301yyg4p2uno6sesp","kind":"contributor_item","title":"Submission O6SESP","provisional":false,"code":"def validate_order_transitions(transitions):\n allowed = {\n \"created\": {\"paid\", \"cancelled\"},\n \"paid\": {\"shipped\", \"refunded\"},\n \"shipped\": {\"delivered\", \"returned\"},\n \"delivered\": set(),\n \"cancelled\": set(),\n \"refunded\": set(),\n \"returned\": {\"refunded\"},\n }\n state = \"created\"\n for next_state in transitions:\n if next_state not in allowed.get(state, set()):\n return f\"invalid transition: {state} -> {next_state}\"\n state = next_state\n return state","input":"validate_order_transitions(['paid', 'shipped', 'delivered'])","language":"Python","predicted_output":"delivered"} |
| {"id":"cmsvnghm301ywg4p23r5hik5j","kind":"contributor_item","title":"Submission 5HIK5J","provisional":false,"code":"def rank_word_frequency(text, top_n):\n words = text.lower().split()\n freq = {}\n order = {}\n for i, w in enumerate(words):\n w = w.strip(\".,!?\")\n if w not in freq:\n order[w] = i\n freq[w] = freq.get(w, 0) + 1\n ranked = sorted(freq.items(), key=lambda kv: (-kv[1], order[kv[0]]))\n return ranked[:top_n]","input":"rank_word_frequency('the quick fox jumps the lazy fox the fox runs', 2)","language":"Python","predicted_output":"[('the', 3), ('fox', 3)]"} |
| {"id":"cmsvnghm301yxg4p2pmfuckys","kind":"contributor_item","title":"Submission FUCKYS","provisional":false,"code":"def find_overlapping_shifts(shifts):\n conflicts = []\n sorted_shifts = sorted(shifts, key=lambda s: s[1])\n for i in range(len(sorted_shifts)):\n for j in range(i + 1, len(sorted_shifts)):\n name_i, start_i, end_i = sorted_shifts[i]\n name_j, start_j, end_j = sorted_shifts[j]\n if name_i == name_j and start_j < end_i:\n conflicts.append((name_i, (start_i, end_i), (start_j, end_j)))\n return conflicts","input":"find_overlapping_shifts([('Sam', 9, 17), ('Sam', 16, 20), ('Lee', 8, 12), ('Lee', 13, 18)])","language":"Python","predicted_output":"[('Sam', (9, 17), (16, 20))]"} |
| {"id":"cmsvnghm301yvg4p2gvqpajb4","kind":"contributor_item","title":"Submission QPAJB4","provisional":false,"code":"def order_pick_path(items_by_aisle):\n aisles = sorted(items_by_aisle.keys())\n path = []\n for idx, aisle in enumerate(aisles):\n bins = sorted(items_by_aisle[aisle])\n if idx % 2 == 1:\n bins = bins[::-1]\n for b in bins:\n path.append((aisle, b))\n return path","input":"order_pick_path({1: [3, 1, 2], 2: [5, 4], 3: [7, 6, 8]})","language":"Python","predicted_output":"[(1, 1), (1, 2), (1, 3), (2, 5), (2, 4), (3, 6), (3, 7), (3, 8)]"} |
| {"id":"cmsvnghm301yhg4p2akco3ijq","kind":"contributor_item","title":"Submission CO3IJQ","provisional":false,"code":"def process_tasks_with_aging(tasks, boost_after):\n processed = []\n remaining = [dict(t) for t in tasks]\n tick = 0\n while remaining:\n for t in remaining:\n if tick - t[\"submitted\"] >= boost_after and t[\"priority\"] > 1:\n t[\"priority\"] -= 1\n remaining.sort(key=lambda t: (t[\"priority\"], t[\"submitted\"]))\n current = remaining.pop(0)\n processed.append(current[\"name\"])\n tick += 1\n return processed","input":"process_tasks_with_aging([{'name':'A','priority':3,'submitted':0}, {'name':'B','priority':1,'submitted':1}, {'name':'C','priority':3,'submitted':0}], 2)","language":"Python","predicted_output":"['B', 'A', 'C']"} |
| {"id":"cmsvnghm301ygg4p28eks1oag","kind":"contributor_item","title":"Submission KS1OAG","provisional":false,"code":"def has_adjacent_vip_conflict(seating_row, vip_set):\n for i in range(len(seating_row) - 1):\n if seating_row[i] in vip_set and seating_row[i+1] in vip_set:\n return True\n return False","input":"has_adjacent_vip_conflict(['Ana', 'Ben', 'Cid', 'Dax', 'Eve'], {'Cid', 'Dax', 'Eve'})","language":"Python","predicted_output":"True"} |
| {"id":"cmsvnghm301yig4p2pdndfg8c","kind":"contributor_item","title":"Submission NDFG8C","provisional":false,"code":"def evaluate_polynomial(coefficients, x):\n result = 0\n for coef in coefficients:\n result = result * x + coef\n return result","input":"evaluate_polynomial([2, -3, 0, 5], 3)","language":"Python","predicted_output":"32"} |
| {"id":"cmsvnghm301yfg4p2jzcnjd3l","kind":"contributor_item","title":"Submission CNJD3L","provisional":false,"code":"def redact_digits_runs(text, min_run):\n result = []\n i = 0\n n = len(text)\n while i < n:\n if text[i].isdigit():\n j = i\n while j < n and text[j].isdigit():\n j += 1\n run_len = j - i\n if run_len >= min_run:\n result.append(\"*\" * run_len)\n else:\n result.append(text[i:j])\n i = j\n else:\n result.append(text[i])\n i += 1\n return \"\".join(result)","input":"redact_digits_runs('Card 4242424242424242 exp 12/28 cvv 123', 6)","language":"Python","predicted_output":"Card **************** exp 12/28 cvv 123"} |
| {"id":"cmsvnghm301ypg4p2ztecr1vs","kind":"contributor_item","title":"Submission ECR1VS","provisional":false,"code":"def group_duplicate_files(files):\n def simple_hash(content):\n h = 0\n for ch in content:\n h = (h * 31 + ord(ch)) % 1000000007\n return h\n groups = {}\n for name, content in files:\n h = simple_hash(content)\n groups.setdefault(h, []).append(name)\n return sorted([sorted(g) for g in groups.values() if len(g) > 1])","input":"group_duplicate_files([('a.txt','hello'), ('b.txt','world'), ('c.txt','hello'), ('d.txt','hello'), ('e.txt','unique')])","language":"Python","predicted_output":"[['a.txt', 'c.txt', 'd.txt']]"} |
| {"id":"cmsvnghm301yng4p2er6xiu56","kind":"contributor_item","title":"Submission 6XIU56","provisional":false,"code":"def match_route(routes, path):\n path_parts = path.strip(\"/\").split(\"/\")\n for pattern, handler in routes:\n pattern_parts = pattern.strip(\"/\").split(\"/\")\n if len(pattern_parts) != len(path_parts):\n continue\n params = {}\n matched = True\n for pp, ap in zip(pattern_parts, path_parts):\n if pp.startswith(\":\"):\n params[pp[1:]] = ap\n elif pp != ap:\n matched = False\n break\n if matched:\n return handler, params\n return None, {}","input":"match_route([('/users/:id', 'get_user'), ('/users/:id/posts/:postId', 'get_post')], '/users/42/posts/7')","language":"Python","predicted_output":"('get_post', {'id': '42', 'postId': '7'})"} |
| {"id":"cmsvnghm301yjg4p2wlgqxgjz","kind":"contributor_item","title":"Submission GQXGJZ","provisional":false,"code":"def compute_backoff_schedule(base_delay, max_delay, attempts):\n schedule = []\n delay = base_delay\n for _ in range(attempts):\n schedule.append(min(delay, max_delay))\n delay *= 2\n return schedule","input":"compute_backoff_schedule(1, 20, 6)","language":"Python","predicted_output":"[1, 2, 4, 8, 16, 20]"} |
| {"id":"cmsvnghm301yog4p28zvuk598","kind":"contributor_item","title":"Submission VUK598","provisional":false,"code":"def compare_versions(v1, v2):\n parts1 = [int(x) for x in v1.split(\".\")]\n parts2 = [int(x) for x in v2.split(\".\")]\n length = max(len(parts1), len(parts2))\n parts1 += [0] * (length - len(parts1))\n parts2 += [0] * (length - len(parts2))\n for a, b in zip(parts1, parts2):\n if a != b:\n return 1 if a > b else -1\n return 0","input":"[compare_versions('1.2.3', '1.2'), compare_versions('2.0', '1.9.9'), compare_versions('1.0.0', '1.0.0')]","language":"Python","predicted_output":"[1, 1, 0]"} |
| {"id":"cmsvnghm301ysg4p2ftjgc0vu","kind":"contributor_item","title":"Submission JGC0VU","provisional":false,"code":"def detect_spikes(readings, window, threshold):\n spikes = []\n for i in range(len(readings)):\n start = max(0, i - window)\n history = readings[start:i]\n if not history:\n continue\n avg = sum(history) / len(history)\n if abs(readings[i] - avg) > threshold:\n spikes.append(i)\n return spikes","input":"detect_spikes([20, 21, 19, 22, 55, 20, 21, 60, 19], 3, 10)","language":"Python","predicted_output":"[4, 5, 6, 7, 8]"} |
| {"id":"cmsvnghm301yug4p2z7tiq3lq","kind":"contributor_item","title":"Submission TIQ3LQ","provisional":false,"code":"def wrap_text(words, width):\n lines = []\n current = []\n current_len = 0\n for word in words:\n extra = len(word) + (1 if current else 0)\n if current_len + extra > width:\n lines.append(\" \".join(current))\n current = [word]\n current_len = len(word)\n else:\n current.append(word)\n current_len += extra\n if current:\n lines.append(\" \".join(current))\n return lines","input":"wrap_text(['The', 'quick', 'brown', 'fox', 'jumps', 'over', 'the', 'lazy', 'dog'], 12)","language":"Python","predicted_output":"['The quick', 'brown fox', 'jumps over', 'the lazy dog']"} |
| {"id":"cmsvnghm301yrg4p2nrlkyind","kind":"contributor_item","title":"Submission LKYIND","provisional":false,"code":"def count_palindromic_substrings_min_length(s, min_length):\n count = 0\n n = len(s)\n for i in range(n):\n for j in range(i + min_length, n + 1):\n sub = s[i:j]\n if sub == sub[::-1]:\n count += 1\n return count","input":"count_palindromic_substrings_min_length('abaaba', 3)","language":"Python","predicted_output":"4"} |
| {"id":"cmsvnghm301ykg4p2dhktnu7o","kind":"contributor_item","title":"Submission KTNU7O","provisional":false,"code":"def nearest_warehouse(warehouses, point):\n best = None\n best_dist = None\n for name, (x, y) in sorted(warehouses.items()):\n dist = abs(x - point[0]) + abs(y - point[1])\n if best_dist is None or dist < best_dist:\n best_dist = dist\n best = name\n return best, best_dist","input":"nearest_warehouse({'W1': (0,0), 'W2': (5,5), 'W3': (2,3)}, (3,3))","language":"Python","predicted_output":"('W3', 1)"} |
| {"id":"cmsvnghm301ylg4p2k2h8o7v3","kind":"contributor_item","title":"Submission H8O7V3","provisional":false,"code":"def dedupe_events(events, window_seconds):\n result = []\n last_seen = {}\n for event_type, ts in events:\n if event_type in last_seen and ts - last_seen[event_type] < window_seconds:\n continue\n last_seen[event_type] = ts\n result.append((event_type, ts))\n return result","input":"dedupe_events([('click', 0), ('click', 2), ('hover', 3), ('click', 6), ('click', 7), ('hover', 10)], 5)","language":"Python","predicted_output":"[('click', 0), ('hover', 3), ('click', 6), ('hover', 10)]"} |
| {"id":"cmsvntqa30218g4p2bperzaeg","kind":"contributor_item","title":"Submission ERZAEG","provisional":false,"code":"def safe_transpose(matrix):\n if not matrix:\n return []\n row_len = len(matrix[0])\n for row in matrix:\n if len(row) != row_len:\n raise ValueError(\"Jagged matrix cannot be transposed\")\n return [[matrix[r][c] for r in range(len(matrix))] for c in range(row_len)]","input":"safe_transpose([[1,2,3],[4,5,6]])","language":"Python","predicted_output":"[[1, 4], [2, 5], [3, 6]]"} |
| {"id":"cmsvntqa3021bg4p2m0o078jt","kind":"contributor_item","title":"Submission O078JT","provisional":false,"code":"def merge_playlists(playlist_a, playlist_b):\n i = j = 0\n merged = []\n while i < len(playlist_a) and j < len(playlist_b):\n if playlist_a[i][1] <= playlist_b[j][1]:\n merged.append(playlist_a[i])\n i += 1\n else:\n merged.append(playlist_b[j])\n j += 1\n merged.extend(playlist_a[i:])\n merged.extend(playlist_b[j:])\n return merged","input":"merge_playlists([('SongA', 10), ('SongC', 30)], [('SongB', 20), ('SongD', 25), ('SongE', 40)])","language":"Python","predicted_output":"[('SongA', 10), ('SongB', 20), ('SongD', 25), ('SongC', 30), ('SongE', 40)]"} |
| {"id":"cmsvntqa3021fg4p2j3b7pdvo","kind":"contributor_item","title":"Submission B7PDVO","provisional":false,"code":"def longest_login_streak(dates):\n from datetime import datetime\n parsed = sorted(datetime.strptime(d, \"%Y-%m-%d\") for d in set(dates))\n longest = 1 if parsed else 0\n current = 1\n for i in range(1, len(parsed)):\n if (parsed[i] - parsed[i-1]).days == 1:\n current += 1\n longest = max(longest, current)\n else:\n current = 1\n return longest","input":"longest_login_streak(['2026-01-01','2026-01-02','2026-01-03','2026-01-05','2026-01-06','2026-01-07','2026-01-08'])","language":"Python","predicted_output":"4"} |
| {"id":"cmsvntqa3021jg4p2ctwcbsyz","kind":"contributor_item","title":"Submission WCBSYZ","provisional":false,"code":"def bucket_students_by_grade(students):\n buckets = {\"A\": [], \"B\": [], \"C\": [], \"D/F\": []}\n for name, score in students:\n if score >= 90:\n buckets[\"A\"].append(name)\n elif score >= 80:\n buckets[\"B\"].append(name)\n elif score >= 70:\n buckets[\"C\"].append(name)\n else:\n buckets[\"D/F\"].append(name)\n averages = {}\n for grade, names in buckets.items():\n scores = [s for n, s in students if n in names]\n averages[grade] = round(sum(scores) / len(scores), 1) if scores else None\n return averages","input":"bucket_students_by_grade([('Ana', 95), ('Ben', 82), ('Cid', 71), ('Dan', 60), ('Eve', 88), ('Fay', 91)])","language":"Python","predicted_output":"{'A': 93.0, 'B': 85.0, 'C': 71.0, 'D/F': 60.0}"} |
| {"id":"cmsvntqa3021rg4p24yz9djnt","kind":"contributor_item","title":"Submission Z9DJNT","provisional":false,"code":"def count_log_levels_by_service(log_lines):\n counts = {}\n for line in log_lines:\n parts = line.split(\" \", 2)\n if len(parts) < 3:\n continue\n service, level = parts[0], parts[1]\n counts.setdefault(service, {})\n counts[service][level] = counts[service].get(level, 0) + 1\n return counts","input":"count_log_levels_by_service(['auth WARN token expiring', 'auth ERROR login failed', 'billing INFO charge ok', 'auth ERROR login failed', 'billing ERROR timeout'])","language":"Python","predicted_output":"{'auth': {'WARN': 1, 'ERROR': 2}, 'billing': {'INFO': 1, 'ERROR': 1}}"} |
| {"id":"cmsvntqa3021qg4p2o5t39asc","kind":"contributor_item","title":"Submission T39ASC","provisional":false,"code":"def weighted_moving_average(values, weights):\n n = len(weights)\n result = []\n for i in range(len(values)):\n window = []\n window_weights = []\n for j in range(n):\n idx = i - (n // 2) + j\n if 0 <= idx < len(values):\n window.append(values[idx])\n window_weights.append(weights[j])\n total_weight = sum(window_weights)\n weighted_sum = sum(v * w for v, w in zip(window, window_weights))\n result.append(round(weighted_sum / total_weight, 2))\n return result","input":"weighted_moving_average([10, 12, 9, 14, 20, 18], [1, 2, 1])","language":"Python","predicted_output":"[10.67, 10.75, 11.0, 14.25, 18.0, 18.67]"} |
| {"id":"cmsvntqa30219g4p29upct5uf","kind":"contributor_item","title":"Submission PCT5UF","provisional":false,"code":"def count_allowed_requests(timestamps, window_size, max_requests):\n allowed = []\n window = []\n for t in timestamps:\n window = [w for w in window if t - w < window_size]\n if len(window) < max_requests:\n window.append(t)\n allowed.append(t)\n return allowed","input":"count_allowed_requests([1,2,3,4,10,11,12,20], 5, 3)","language":"Python","predicted_output":"[1, 2, 3, 10, 11, 12, 20]"} |
| {"id":"cmsvntqa3021ig4p229ukkrsm","kind":"contributor_item","title":"Submission UKKRSM","provisional":false,"code":"def compute_reorder_points(items):\n result = {}\n for name, daily_sales, lead_time_days, safety_stock in items:\n reorder_point = daily_sales * lead_time_days + safety_stock\n result[name] = reorder_point\n return result","input":"compute_reorder_points([('widget', 12, 5, 20), ('gadget', 3, 10, 5), ('gizmo', 25, 2, 0)])","language":"Python","predicted_output":"{'widget': 80, 'gadget': 35, 'gizmo': 50}"} |
| {"id":"cmsvntqa3021ng4p2p6otthut","kind":"contributor_item","title":"Submission OTTHUT","provisional":false,"code":"def process_ledger(transactions, overdraft_limit):\n balance = 0\n declined = []\n for desc, amount in transactions:\n if balance + amount < -overdraft_limit:\n declined.append(desc)\n continue\n balance += amount\n return balance, declined","input":"process_ledger([('deposit', 100), ('rent', -300), ('paycheck', 150), ('groceries', -60), ('car payment', -250)], 200)","language":"Python","predicted_output":"(-110, ['car payment'])"} |
| {"id":"cmsvntqa3021pg4p2cjgd394y","kind":"contributor_item","title":"Submission GD394Y","provisional":false,"code":"class FrequencyCache:\n def __init__(self, capacity):\n self.capacity = capacity\n self.store = {}\n self.freq = {}\n\n def put(self, key, value):\n if key in self.store:\n self.store[key] = value\n self.freq[key] += 1\n return\n if len(self.store) >= self.capacity:\n least_key = min(self.freq, key=lambda k: self.freq[k])\n del self.store[least_key]\n del self.freq[least_key]\n self.store[key] = value\n self.freq[key] = 1\n\n def get(self, key):\n if key not in self.store:\n return None\n self.freq[key] += 1\n return self.store[key]\n\ndef run_cache_ops(ops):\n cache = FrequencyCache(2)\n results = []\n for op in ops:\n if op[0] == \"put\":\n cache.put(op[1], op[2])\n results.append(None)\n else:\n results.append(cache.get(op[1]))\n return results","input":"run_cache_ops([('put','a',1),('put','b',2),('get','a'),('put','c',3),('get','b'),('get','c')])","language":"Python","predicted_output":"[None, None, 1, None, None, 3]"} |
| {"id":"cmsvntqa3021dg4p2dihdig5x","kind":"contributor_item","title":"Submission HDIG5X","provisional":false,"code":"def round_robin_schedule(tasks, quantum):\n from collections import deque\n queue = deque((name, burst) for name, burst in tasks)\n time = 0\n order = []\n while queue:\n name, burst = queue.popleft()\n run_time = min(quantum, burst)\n time += run_time\n remaining = burst - run_time\n order.append((name, time))\n if remaining > 0:\n queue.append((name, remaining))\n return order","input":"round_robin_schedule([('P1', 5), ('P2', 3), ('P3', 8)], 4)","language":"Python","predicted_output":"[('P1', 4), ('P2', 7), ('P3', 11), ('P1', 12), ('P3', 16)]"} |
| {"id":"cmsvntqa3021mg4p22s63nj0g","kind":"contributor_item","title":"Submission 63NJ0G","provisional":false,"code":"def find_cyclic_targets(dependencies):\n graph = {}\n for src, dst in dependencies:\n graph.setdefault(src, []).append(dst)\n graph.setdefault(dst, [])\n state = {}\n cyclic = set()\n\n def dfs(node, path):\n state[node] = \"visiting\"\n path.append(node)\n for nxt in graph.get(node, []):\n if state.get(nxt) == \"visiting\":\n cycle_start = path.index(nxt)\n cyclic.update(path[cycle_start:])\n elif state.get(nxt) != \"done\":\n dfs(nxt, path)\n path.pop()\n state[node] = \"done\"\n\n for node in list(graph):\n if state.get(node) is None:\n dfs(node, [])\n return sorted(cyclic)","input":"find_cyclic_targets([('build','compile'),('compile','link'),('link','build'),('test','compile'),('deploy','test')])","language":"Python","predicted_output":"['build', 'compile', 'link']"} |
| {"id":"cmsvntqa3021hg4p2ovxnx3j8","kind":"contributor_item","title":"Submission XNX3J8","provisional":false,"code":"def dispatch_elevator(elevator_positions, call_floor, direction):\n best_idx = None\n best_dist = None\n for i, (pos, moving_dir) in enumerate(elevator_positions):\n if moving_dir == \"idle\" or moving_dir == direction:\n dist = abs(pos - call_floor)\n if best_dist is None or dist < best_dist:\n best_dist = dist\n best_idx = i\n return best_idx","input":"dispatch_elevator([(1, 'idle'), (5, 'up'), (10, 'down')], 6, 'up')","language":"Python","predicted_output":"1"} |
| {"id":"cmsvntqa3021kg4p2gclhk2ed","kind":"contributor_item","title":"Submission LHK2ED","provisional":false,"code":"def normalize_and_dedupe_contacts(raw_numbers):\n seen = set()\n result = []\n for raw in raw_numbers:\n digits = \"\".join(ch for ch in raw if ch.isdigit())\n if len(digits) == 11 and digits.startswith(\"1\"):\n digits = digits[1:]\n if len(digits) != 10:\n continue\n formatted = f\"({digits[0:3]}) {digits[3:6]}-{digits[6:10]}\"\n if formatted not in seen:\n seen.add(formatted)\n result.append(formatted)\n return result","input":"normalize_and_dedupe_contacts(['415-555-0132', '(415) 555-0132', '1-415-555-0199', '555-0199', '4155550199'])","language":"Python","predicted_output":"['(415) 555-0132', '(415) 555-0199']"} |
| {"id":"cmsvntqa3021cg4p276rfekcs","kind":"contributor_item","title":"Submission RFEKCS","provisional":false,"code":"def compute_company_checksum(digits):\n weights = [7, 3, 1, 9, 7, 3, 1]\n total = sum(d * w for d, w in zip(digits, weights[:len(digits)]))\n return total % 11","input":"compute_company_checksum([4, 2, 7, 1, 9, 0, 3])","language":"Python","predicted_output":"6"} |
| {"id":"cmsvntqa3021eg4p2h5xkneng","kind":"contributor_item","title":"Submission XKNENG","provisional":false,"code":"def split_csv_row(row):\n fields = []\n current = \"\"\n in_quotes = False\n i = 0\n while i < len(row):\n ch = row[i]\n if ch == '\"':\n in_quotes = not in_quotes\n elif ch == ',' and not in_quotes:\n fields.append(current)\n current = \"\"\n else:\n current += ch\n i += 1\n fields.append(current)\n return fields","input":"split_csv_row('John,\"Doe, Jr.\",42,\"New York, NY\"')","language":"Python","predicted_output":"['John', 'Doe, Jr.', '42', 'New York, NY']"} |
| {"id":"cmsvntqa3021lg4p2664q7xjl","kind":"contributor_item","title":"Submission 4Q7XJL","provisional":false,"code":"def shipping_cost(weight_kg, distance_km):\n if weight_kg <= 1:\n base = 5.0\n elif weight_kg <= 5:\n base = 5.0 + (weight_kg - 1) * 1.5\n else:\n base = 11.0 + (weight_kg - 5) * 2.0\n if distance_km > 500:\n base *= 1.4\n elif distance_km > 100:\n base *= 1.15\n return round(base, 2)","input":"[shipping_cost(0.5, 50), shipping_cost(3, 200), shipping_cost(8, 800)]","language":"Python","predicted_output":"[5.0, 9.2, 23.8]"} |
| {"id":"cmsvntqa3021gg4p21zlzifwu","kind":"contributor_item","title":"Submission LZIFWU","provisional":false,"code":"def evaluate_expression(expr):\n tokens = []\n num = \"\"\n for ch in expr.replace(\" \", \"\"):\n if ch.isdigit() or ch == \".\":\n num += ch\n else:\n if num:\n tokens.append(float(num))\n num = \"\"\n tokens.append(ch)\n if num:\n tokens.append(float(num))\n\n def apply_ops(values, ops):\n b = values.pop()\n a = values.pop()\n op = ops.pop()\n if op == \"+\": values.append(a + b)\n elif op == \"-\": values.append(a - b)\n elif op == \"*\": values.append(a * b)\n elif op == \"/\": values.append(a / b)\n\n values, ops = [], []\n precedence = {\"+\": 1, \"-\": 1, \"*\": 2, \"/\": 2}\n for tok in tokens:\n if isinstance(tok, float):\n values.append(tok)\n else:\n while ops and precedence.get(ops[-1], 0) >= precedence.get(tok, 0):\n apply_ops(values, ops)\n ops.append(tok)\n while ops:\n apply_ops(values, ops)\n result = values[0]\n return int(result) if result == int(result) else result","input":"evaluate_expression('3 + 4 * 2 - 6 / 3')","language":"Python","predicted_output":"9"} |
| {"id":"cmsvntqa3021ag4p2yduxxjms","kind":"contributor_item","title":"Submission UXXJMS","provisional":false,"code":"def flatten_dict(d, prefix=\"\"):\n result = {}\n for key, value in d.items():\n full_key = f\"{prefix}.{key}\" if prefix else key\n if isinstance(value, dict):\n result.update(flatten_dict(value, full_key))\n else:\n result[full_key] = value\n return result","input":"flatten_dict({'user': {'name': 'Ana', 'address': {'city': 'Reno', 'zip': '89501'}}, 'active': True})","language":"Python","predicted_output":"{'user.name': 'Ana', 'user.address.city': 'Reno', 'user.address.zip': '89501', 'active': True}"} |
| {"id":"cmsvntqa3021og4p2j1wueozd","kind":"contributor_item","title":"Submission WUEOZD","provisional":false,"code":"def merge_meetings_with_buffer(meetings, buffer_minutes):\n if not meetings:\n return []\n sorted_meetings = sorted(meetings)\n merged = [list(sorted_meetings[0])]\n for start, end in sorted_meetings[1:]:\n last_start, last_end = merged[-1]\n if start <= last_end + buffer_minutes:\n merged[-1][1] = max(last_end, end)\n else:\n merged.append([start, end])\n return [tuple(m) for m in merged]","input":"merge_meetings_with_buffer([(9,10),(10,11),(13,14),(14,16),(20,21)], 15)","language":"Python","predicted_output":"[(9, 21)]"} |
| {"id":"cmsvobe4z0276g4p2icrwj8hr","kind":"contributor_item","title":"Submission RWJ8HR","provisional":false,"code":"def pairs(n):\n return [(i, j) for i in range(n) for j in range(i) if (i + j) % 2 == 0]\n","input":"pairs(4)","language":"Python","predicted_output":"[(2, 0), (3, 1)]"} |
| {"id":"cmsvobe4z027bg4p27d3p075i","kind":"contributor_item","title":"Submission 3P075I","provisional":false,"code":"def parse_key_value(s):\n key, value = s.split('=', 1)\n return (key.strip(), value.strip())\n","input":"parse_key_value(' name = John Smith = extra ')","language":"Python","predicted_output":"('name', 'John Smith = extra')"} |
| {"id":"cmsvobe4z0277g4p2waw08gmi","kind":"contributor_item","title":"Submission W08GMI","provisional":false,"code":"def center_text(s, width):\n return s.center(width, '*')\n","input":"center_text('hi', 6)","language":"Python","predicted_output":"**hi**"} |
| {"id":"cmsvobe4z0275g4p2olwpi9ya","kind":"contributor_item","title":"Submission WPI9YA","provisional":false,"code":"def classify(n):\n try:\n result = 10 / n\n except ZeroDivisionError:\n return 'undefined'\n else:\n return f'ok:{result}'\n","input":"(classify(5), classify(0))","language":"Python","predicted_output":"('ok:2.0', 'undefined')"} |
| {"id":"cmsvobe4z0272g4p2ffjxwumd","kind":"contributor_item","title":"Submission JXWUMD","provisional":false,"code":"def reverse_evens(nums):\n return nums[::-2]\n","input":"reverse_evens([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])","language":"Python","predicted_output":"[10, 8, 6, 4, 2]"} |
| {"id":"cmsvobe4z0274g4p270o28upm","kind":"contributor_item","title":"Submission O28UPM","provisional":false,"code":"def transform(d):\n return {k: (v * 2 if v % 2 == 0 else v) for k, v in d.items()}\n","input":"transform({'a': 1, 'b': 2, 'c': 3, 'd': 4})","language":"Python","predicted_output":"{'a': 1, 'b': 4, 'c': 3, 'd': 8}"} |
| {"id":"cmsvobe4z0279g4p2lotasn3z","kind":"contributor_item","title":"Submission TASN3Z","provisional":false,"code":"def split_first_last(items):\n first, *middle, last = items\n return (first, middle, last)\n","input":"split_first_last([1, 2, 3, 4, 5])","language":"Python","predicted_output":"(1, [2, 3, 4], 5)"} |
| {"id":"cmsvobe4z0278g4p2xgk64tgq","kind":"contributor_item","title":"Submission K64TGQ","provisional":false,"code":"def fib(n, memo={}):\n if n in memo:\n return memo[n]\n if n <= 1:\n return n\n memo[n] = fib(n - 1, memo) + fib(n - 2, memo)\n return memo[n]\n","input":"fib(10)","language":"Python","predicted_output":"55"} |
| {"id":"cmsvobe4z027ag4p2t4yj2p41","kind":"contributor_item","title":"Submission YJ2P41","provisional":false,"code":"def analyze(a, b):\n return (sorted(a | b), sorted(a & b), sorted(a - b))\n","input":"analyze({1, 2, 3}, {2, 3, 4})","language":"Python","predicted_output":"([1, 2, 3, 4], [2, 3], [1])"} |
| {"id":"cmsvobe4z0273g4p2ffo7uy5n","kind":"contributor_item","title":"Submission O7UY5N","provisional":false,"code":"def repeat_join(words, n):\n return '-'.join(words) * n\n","input":"repeat_join(['a', 'b'], 2)","language":"Python","predicted_output":"a-ba-b"} |
| {"id":"cmsvonedl027wg4p2g4tzhb6o","kind":"contributor_item","title":"Submission TZHB6O","provisional":false,"code":"\ndef fib(n, memo=None):\n if memo is None:\n memo = {}\n if n in memo:\n return memo[n]\n if n <= 1:\n return n\n memo[n] = fib(n - 1, memo) + fib(n - 2, memo)\n return memo[n]\n","input":"fib(20)","language":"Python","predicted_output":"6765"} |
| {"id":"cmsvonedl027xg4p28tyxe2j9","kind":"contributor_item","title":"Submission YXE2J9","provisional":false,"code":"\ndef gcd(a, b):\n while b:\n a, b = b, a % b\n return a\n","input":"gcd(252, 105)","language":"Python","predicted_output":"21"} |
| {"id":"cmsvonedl027yg4p2ara94qv0","kind":"contributor_item","title":"Submission A94QV0","provisional":false,"code":"\ndef gcd(a, b):\n while b:\n a, b = b, a % b\n return a\n\ndef lcm(a, b):\n return a * b // gcd(a, b)\n","input":"lcm(4, 6)","language":"Python","predicted_output":"12"} |
| {"id":"cmsvonedl027zg4p2wd2bpk14","kind":"contributor_item","title":"Submission 2BPK14","provisional":false,"code":"\ndef is_palindrome(s):\n cleaned = ''.join(ch.lower() for ch in s if ch.isalnum())\n return cleaned == cleaned[::-1]\n","input":"is_palindrome('A man a plan a canal Panama')","language":"Python","predicted_output":"True"} |
| {"id":"cmsvonedl0280g4p2w4c5fq1l","kind":"contributor_item","title":"Submission C5FQ1L","provisional":false,"code":"\ndef run_length_encode(s):\n if not s:\n return ''\n result = []\n prev = s[0]\n count = 1\n for ch in s[1:]:\n if ch == prev:\n count += 1\n else:\n result.append(prev + str(count))\n prev = ch\n count = 1\n result.append(prev + str(count))\n return ''.join(result)\n","input":"run_length_encode('aaabbbccd')","language":"Python","predicted_output":"a3b3c2d1"} |
| {"id":"cmsvonedl0281g4p22e1tvplf","kind":"contributor_item","title":"Submission 1TVPLF","provisional":false,"code":"\ndef digit_sum(n):\n return sum(int(d) for d in str(n))\n","input":"digit_sum(987654)","language":"Python","predicted_output":"39"} |
| {"id":"cmsvonedl0282g4p29wy6lb27","kind":"contributor_item","title":"Submission Y6LB27","provisional":false,"code":"\ndef reverse_int(n):\n sign = -1 if n < 0 else 1\n rev = int(str(abs(n))[::-1])\n return sign * rev\n","input":"reverse_int(-12345)","language":"Python","predicted_output":"-54321"} |
| {"id":"cmsvonedl0283g4p2a8kjnfin","kind":"contributor_item","title":"Submission KJNFIN","provisional":false,"code":"\ndef is_perfect(n):\n divisors_sum = sum(i for i in range(1, n) if n % i == 0)\n return divisors_sum == n\n","input":"is_perfect(28)","language":"Python","predicted_output":"True"} |
| {"id":"cmsvonedl0284g4p2qjnz01m9","kind":"contributor_item","title":"Submission NZ01M9","provisional":false,"code":"\ndef is_armstrong(n):\n digits = str(n)\n power = len(digits)\n return n == sum(int(d) ** power for d in digits)\n","input":"is_armstrong(153)","language":"Python","predicted_output":"True"} |
| {"id":"cmsvonedl0285g4p2tqjo6ayr","kind":"contributor_item","title":"Submission JO6AYR","provisional":false,"code":"\ndef binary_to_decimal(s):\n return int(s, 2)\n","input":"binary_to_decimal('110110')","language":"Python","predicted_output":"54"} |
| {"id":"cmsvonedl0286g4p29jv5wyy2","kind":"contributor_item","title":"Submission V5WYY2","provisional":false,"code":"\ndef decimal_to_binary(n):\n if n == 0:\n return '0'\n bits = []\n while n > 0:\n bits.append(str(n % 2))\n n //= 2\n return ''.join(reversed(bits))\n","input":"decimal_to_binary(233)","language":"Python","predicted_output":"11101001"} |
| {"id":"cmsvonedl0287g4p2y2ykqh0r","kind":"contributor_item","title":"Submission YKQH0R","provisional":false,"code":"\ndef count_set_bits(n):\n count = 0\n while n:\n count += n & 1\n n >>= 1\n return count\n","input":"count_set_bits(255)","language":"python","predicted_output":"8"} |
| {"id":"cmsvonedl0288g4p26p7q62on","kind":"contributor_item","title":"Submission 7Q62ON","provisional":false,"code":"\ndef permutations_of(items):\n if len(items) <= 1:\n return [items]\n result = []\n for i in range(len(items)):\n rest = items[:i] + items[i + 1:]\n for p in permutations_of(rest):\n result.append([items[i]] + p)\n return result\n","input":"permutations_of([1, 2, 3])","language":"python","predicted_output":"[[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]]"} |
| {"id":"cmsvonedl0289g4p2ce8jc32r","kind":"contributor_item","title":"Submission 8JC32R","provisional":false,"code":"\nimport math\n\ndef n_choose_r(n, r):\n return math.factorial(n) // (math.factorial(r) * math.factorial(n - r))\n","input":"n_choose_r(10, 3)","language":"python","predicted_output":"120"} |
| {"id":"cmsvonedl028ag4p29ab51vur","kind":"contributor_item","title":"Submission B51VUR","provisional":false,"code":"\ndef rotate_matrix_clockwise(matrix):\n n = len(matrix)\n m = len(matrix[0])\n result = [[None] * n for _ in range(m)]\n for i in range(n):\n for j in range(m):\n result[j][n - 1 - i] = matrix[i][j]\n return result\n","input":"rotate_matrix_clockwise([[1, 2, 3], [4, 5, 6]])","language":"python","predicted_output":"[[4, 1], [5, 2], [6, 3]]"} |
| {"id":"cmsvonedl028bg4p2tc49c7un","kind":"contributor_item","title":"Submission 49C7UN","provisional":false,"code":"\ndef matmul(a, b):\n rows_a = len(a)\n cols_a = len(a[0])\n cols_b = len(b[0])\n result = [[0] * cols_b for _ in range(rows_a)]\n for i in range(rows_a):\n for j in range(cols_b):\n for k in range(cols_a):\n result[i][j] += a[i][k] * b[k][j]\n return result\n","input":"matmul([[1, 2], [3, 4]], [[5, 6], [7, 8]])","language":"python","predicted_output":"[[19, 22], [43, 50]]"} |
| {"id":"cmsvonedl028cg4p2ak6r9gqw","kind":"contributor_item","title":"Submission 6R9GQW","provisional":false,"code":"\ndef bubble_sort(arr):\n arr = list(arr)\n n = len(arr)\n for i in range(n):\n for j in range(0, n - i - 1):\n if arr[j] > arr[j + 1]:\n arr[j], arr[j + 1] = arr[j + 1], arr[j]\n return arr\n","input":"bubble_sort([5, 2, 8, 1, 9, 3])","language":"python","predicted_output":"[1, 2, 3, 5, 8, 9]"} |
| {"id":"cmsvonedl028dg4p2npa3un1l","kind":"contributor_item","title":"Submission A3UN1L","provisional":false,"code":"\ndef selection_sort(arr):\n arr = list(arr)\n n = len(arr)\n for i in range(n):\n min_idx = i\n for j in range(i + 1, n):\n if arr[j] < arr[min_idx]:\n min_idx = j\n arr[i], arr[min_idx] = arr[min_idx], arr[i]\n return arr\n","input":"selection_sort([64, 25, 12, 22, 11])","language":"python","predicted_output":"[11, 12, 22, 25, 64]"} |
| {"id":"cmsvonedl028eg4p2j997xe73","kind":"contributor_item","title":"Submission 97XE73","provisional":false,"code":"\ndef insertion_sort(arr):\n arr = list(arr)\n for i in range(1, len(arr)):\n key = arr[i]\n j = i - 1\n while j >= 0 and arr[j] > key:\n arr[j + 1] = arr[j]\n j -= 1\n arr[j + 1] = key\n return arr\n","input":"insertion_sort([12, 11, 13, 5, 6])","language":"python","predicted_output":"[5, 6, 11, 12, 13]"} |
| {"id":"cmsvonedl028fg4p2yonk8bfx","kind":"contributor_item","title":"Submission NK8BFX","provisional":false,"code":"\ndef quick_sort(arr):\n if len(arr) <= 1:\n return list(arr)\n pivot = arr[len(arr) // 2]\n left = [x for x in arr if x < pivot]\n mid = [x for x in arr if x == pivot]\n right = [x for x in arr if x > pivot]\n return quick_sort(left) + mid + quick_sort(right)\n","input":"quick_sort([10, 7, 8, 9, 1, 5])","language":"python","predicted_output":"[1, 5, 7, 8, 9, 10]"} |
| {"id":"cmsvonedl028gg4p2h1ogpovk","kind":"contributor_item","title":"Submission OGPOVK","provisional":false,"code":"\ndef merge_sort(arr):\n if len(arr) <= 1:\n return list(arr)\n mid = len(arr) // 2\n left = merge_sort(arr[:mid])\n right = merge_sort(arr[mid:])\n result = []\n i = j = 0\n while i < len(left) and j < len(right):\n if left[i] <= right[j]:\n result.append(left[i])\n i += 1\n else:\n result.append(right[j])\n j += 1\n result.extend(left[i:])\n result.extend(right[j:])\n return result\n","input":"merge_sort([38, 27, 43, 3, 9, 82, 10])","language":"python","predicted_output":"[3, 9, 10, 27, 38, 43, 82]"} |
| {"id":"cmsvonedl028hg4p2n98ack4e","kind":"contributor_item","title":"Submission 8ACK4E","provisional":false,"code":"\ndef search_rotated(nums, target):\n lo, hi = 0, len(nums) - 1\n while lo <= hi:\n mid = (lo + hi) // 2\n if nums[mid] == target:\n return mid\n if nums[lo] <= nums[mid]:\n if nums[lo] <= target < nums[mid]:\n hi = mid - 1\n else:\n lo = mid + 1\n else:\n if nums[mid] < target <= nums[hi]:\n lo = mid + 1\n else:\n hi = mid - 1\n return -1\n","input":"search_rotated([4, 5, 6, 7, 0, 1, 2], 0)","language":"python","predicted_output":"4"} |
| {"id":"cmsvonedl028ig4p2fsys7y2i","kind":"contributor_item","title":"Submission YS7Y2I","provisional":false,"code":"\ndef find_median(a, b):\n merged = sorted(a + b)\n n = len(merged)\n mid = n // 2\n if n % 2 == 0:\n return (merged[mid - 1] + merged[mid]) / 2\n return float(merged[mid])\n","input":"find_median([1, 3], [2, 7, 8])","language":"python","predicted_output":"3.0"} |
| {"id":"cmsvonedl028jg4p2vw1baq45","kind":"contributor_item","title":"Submission 1BAQ45","provisional":false,"code":"\ndef lis_length(nums):\n if not nums:\n return 0\n dp = [1] * len(nums)\n for i in range(len(nums)):\n for j in range(i):\n if nums[j] < nums[i]:\n dp[i] = max(dp[i], dp[j] + 1)\n return max(dp)\n","input":"lis_length([10, 9, 2, 5, 3, 7, 101, 18])","language":"python","predicted_output":"4"} |
| {"id":"cmsvonedl028kg4p2h7x11ehi","kind":"contributor_item","title":"Submission X11EHI","provisional":false,"code":"\ndef run_length_encode(s):\n if not s:\n return []\n result = []\n prev = s[0]\n count = 1\n for ch in s[1:]:\n if ch == prev:\n count += 1\n else:\n result.append((prev, count))\n prev = ch\n count = 1\n result.append((prev, count))\n return result\n","input":"run_length_encode('aaabbbccd')","language":"python","predicted_output":"[('a', 3), ('b', 3), ('c', 2), ('d', 1)]"} |
| {"id":"cmsvonedl028lg4p2bf7mr0rs","kind":"contributor_item","title":"Submission 7MR0RS","provisional":false,"code":"\ndef is_valid_parens(s):\n pairs = {')': '(', ']': '[', '}': '{'}\n stack = []\n for ch in s:\n if ch in '([{':\n stack.append(ch)\n elif ch in pairs:\n if not stack or stack.pop() != pairs[ch]:\n return False\n return not stack\n","input":"is_valid_parens('{[()()]}')","language":"python","predicted_output":"true"} |
| {"id":"cmsvonedl028mg4p2ssmoqg4f","kind":"contributor_item","title":"Submission MOQG4F","provisional":false,"code":"\ndef min_path_sum(grid):\n rows = len(grid)\n cols = len(grid[0])\n dp = [[0] * cols for _ in range(rows)]\n dp[0][0] = grid[0][0]\n for j in range(1, cols):\n dp[0][j] = dp[0][j - 1] + grid[0][j]\n for i in range(1, rows):\n dp[i][0] = dp[i - 1][0] + grid[i][0]\n for i in range(1, rows):\n for j in range(1, cols):\n dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]) + grid[i][j]\n return dp[rows - 1][cols - 1]\n","input":"min_path_sum([[1, 3, 1], [1, 5, 1], [4, 2, 1]])","language":"python","predicted_output":"7"} |
| {"id":"cmsvonedl028ng4p2au7gsl8z","kind":"contributor_item","title":"Submission 7GSL8Z","provisional":false,"code":"\ndef max_subarray_sum_circular(nums):\n total = sum(nums)\n cur_max = best_max = nums[0]\n cur_min = best_min = nums[0]\n for x in nums[1:]:\n cur_max = max(x, cur_max + x)\n best_max = max(best_max, cur_max)\n cur_min = min(x, cur_min + x)\n best_min = min(best_min, cur_min)\n if best_max < 0:\n return best_max\n return max(best_max, total - best_min)\n","input":"max_subarray_sum_circular([5, -3, 5])","language":"python","predicted_output":"10"} |
| {"id":"cmsvonedl028og4p2yotr85al","kind":"contributor_item","title":"Submission TR85AL","provisional":false,"code":"\ndef flatten(nested):\n result = []\n for item in nested:\n if isinstance(item, list):\n result.extend(flatten(item))\n else:\n result.append(item)\n return result\n","input":"flatten([1, [2, 3, [4, 5], 6], [7, [8]]])","language":"python","predicted_output":"[1, 2, 3, 4, 5, 6, 7, 8]"} |
| {"id":"cmsvonedl028pg4p20yzfhdci","kind":"contributor_item","title":"Submission ZFHDCI","provisional":false,"code":"\ndef group_anagrams(words):\n groups = {}\n for w in words:\n key = ''.join(sorted(w))\n groups.setdefault(key, []).append(w)\n return sorted(groups.values(), key=lambda g: sorted(g))\n","input":"group_anagrams(['eat', 'tea', 'tan', 'ate', 'nat', 'bat'])","language":"python","predicted_output":"[[\"eat\", \"tea\", \"ate\"], [\"bat\"], [\"tan\", \"nat\"]]"} |
| {"id":"cmsvowogv02c3g4p2kkcqfo64","kind":"contributor_item","title":"Submission CQFO64","provisional":false,"code":"\ndef monthly_payment(principal, annual_rate, months):\n r = annual_rate / 12\n if r == 0:\n return principal / months\n return principal * r * (1 + r) ** months / ((1 + r) ** months - 1)\n","input":"round(monthly_payment(18500, 0.065, 48), 2)","language":"python","predicted_output":"438.73"} |
| {"id":"cmsvowogw02c7g4p2skrkqlbb","kind":"contributor_item","title":"Submission RKQLBB","provisional":false,"code":"\ndef total_with_tax(subtotal):\n if subtotal <= 100:\n rate = 0.05\n elif subtotal <= 500:\n rate = 0.07\n else:\n rate = 0.0825\n return round(subtotal * (1 + rate), 2)\n","input":"total_with_tax(632.40)","language":"python","predicted_output":"684.57"} |
| {"id":"cmsvowogw02c8g4p22a4rtkhy","kind":"contributor_item","title":"Submission 4RTKHY","provisional":false,"code":"\ndef apply_discounts(price, discounts):\n for d in discounts:\n price -= price * d\n return round(price, 2)\n","input":"apply_discounts(250.0, [0.1, 0.15, 0.05])","language":"python","predicted_output":"181.69"} |
| {"id":"cmsvowogw02cbg4p2esf34a77","kind":"contributor_item","title":"Submission F34A77","provisional":false,"code":"\ndef roman_to_int(s):\n vals = {'I':1,'V':5,'X':10,'L':50,'C':100,'D':500,'M':1000}\n total = 0\n for i, ch in enumerate(s):\n v = vals[ch]\n if i+1 < len(s) and vals[s[i+1]] > v:\n total -= v\n else:\n total += v\n return total\n","input":"roman_to_int('MCMXCIV')","language":"python","predicted_output":"1994"} |
| {"id":"cmsvowogw02ccg4p23pbeo5qm","kind":"contributor_item","title":"Submission BEO5QM","provisional":false,"code":"\ndef is_valid(s):\n pairs = {')':'(', ']':'[', '}':'{'}\n stack = []\n for ch in s:\n if ch in '([{':\n stack.append(ch)\n elif ch in pairs:\n if not stack or stack.pop() != pairs[ch]:\n return False\n return not stack\n","input":"is_valid('{[()()]}[]')","language":"python","predicted_output":"True"} |
| {"id":"cmsvowogw02ceg4p2lkkhyk13","kind":"contributor_item","title":"Submission KHYK13","provisional":false,"code":"\ndef most_common_word(text):\n words = text.lower().split()\n freq = {}\n for w in words:\n w = w.strip('.,!?')\n freq[w] = freq.get(w, 0) + 1\n return max(freq.items(), key=lambda x: x[1])[0]\n","input":"most_common_word('the quick fox jumps over the lazy dog the fox runs')","language":"python","predicted_output":"the"} |
| {"id":"cmsvowogw02cfg4p2iztbuf45","kind":"contributor_item","title":"Submission TBUF45","provisional":false,"code":"\ndef levenshtein(a, b):\n m, n = len(a), len(b)\n dp = [[0]*(n+1) for _ in range(m+1)]\n for i in range(m+1): dp[i][0] = i\n for j in range(n+1): dp[0][j] = j\n for i in range(1, m+1):\n for j in range(1, n+1):\n cost = 0 if a[i-1]==b[j-1] else 1\n dp[i][j] = min(dp[i-1][j]+1, dp[i][j-1]+1, dp[i-1][j-1]+cost)\n return dp[m][n]\n","input":"levenshtein('kitten', 'sitting')","language":"python","predicted_output":"3"} |
| {"id":"cmsvowogw02cig4p2t4qzqdc7","kind":"contributor_item","title":"Submission QZQDC7","provisional":false,"code":"\ndef flatten(d, parent_key=''):\n items = {}\n for k, v in d.items():\n new_key = f'{parent_key}.{k}' if parent_key else k\n if isinstance(v, dict):\n items.update(flatten(v, new_key))\n else:\n items[new_key] = v\n return items\n","input":"flatten({'user': {'name': 'Alice', 'address': {'city': 'Reno', 'zip': '89501'}}, 'active': True})","language":"python","predicted_output":"{'user.name': 'Alice', 'user.address.city': 'Reno', 'user.address.zip': '89501', 'active': True}"} |
| {"id":"cmsvowogw02cjg4p2q2povkda","kind":"contributor_item","title":"Submission POVKDA","provisional":false,"code":"\ndef convert_hour(hour, from_offset, to_offset):\n diff = to_offset - from_offset\n return (hour + diff) % 24\n","input":"convert_hour(14, -5, 9)","language":"python","predicted_output":"4"} |
| {"id":"cmsvowogw02ckg4p2k5a4r8wd","kind":"contributor_item","title":"Submission A4R8WD","provisional":false,"code":"\ndef bmi_category(weight_kg, height_m):\n bmi = weight_kg / (height_m ** 2)\n if bmi < 18.5:\n cat = 'underweight'\n elif bmi < 25:\n cat = 'normal'\n elif bmi < 30:\n cat = 'overweight'\n else:\n cat = 'obese'\n return f'{round(bmi,1)}:{cat}'\n","input":"bmi_category(82, 1.78)","language":"python","predicted_output":"25.9:overweight"} |
| {"id":"cmsvowogw02clg4p232dj6h72","kind":"contributor_item","title":"Submission DJ6H72","provisional":false,"code":"\ndef compound_interest(principal, rate, times_per_year, years):\n amount = principal * (1 + rate/times_per_year) ** (times_per_year*years)\n return round(amount, 2)\n","input":"compound_interest(5000, 0.045, 12, 10)","language":"python","predicted_output":"7834.96"} |
| {"id":"cmsvowogw02cmg4p2t1fqlzys","kind":"contributor_item","title":"Submission FQLZYS","provisional":false,"code":"\ndef reverse_in_groups(lst, k):\n result = []\n for i in range(0, len(lst), k):\n chunk = lst[i:i+k]\n result.extend(chunk[::-1])\n return result\n","input":"reverse_in_groups([1,2,3,4,5,6,7,8,9,10], 3)","language":"python","predicted_output":"[3, 2, 1, 6, 5, 4, 9, 8, 7, 10]"} |
| {"id":"cmsvowogw02cog4p2oco061i2","kind":"contributor_item","title":"Submission O061I2","provisional":false,"code":"\ndef compute_gpa(grades_credits):\n total_points = sum(g*c for g, c in grades_credits)\n total_credits = sum(c for _, c in grades_credits)\n return round(total_points / total_credits, 2)\n","input":"compute_gpa([(4.0,3),(3.7,4),(3.3,3),(4.0,2)])","language":"python","predicted_output":"3.73"} |
| {"id":"cmsvowogw02cpg4p28r5wyvke","kind":"contributor_item","title":"Submission 5WYVKE","provisional":false,"code":"\nimport re\ndef is_palindrome(s):\n cleaned = re.sub(r'[^a-z0-9]', '', s.lower())\n return cleaned == cleaned[::-1]\n","input":"is_palindrome('A man, a plan, a canal: Panama')","language":"python","predicted_output":"True"} |
| {"id":"cmsvowogw02cqg4p29vd9dxeo","kind":"contributor_item","title":"Submission D9DXEO","provisional":false,"code":"\ndef merge_sorted(a, b):\n result = []\n i = j = 0\n while i < len(a) and j < len(b):\n if a[i] <= b[j]:\n result.append(a[i]); i += 1\n else:\n result.append(b[j]); j += 1\n result.extend(a[i:])\n result.extend(b[j:])\n return result\n","input":"merge_sorted([1,4,7,10,15], [2,3,8,9,20])","language":"python","predicted_output":"[1, 2, 3, 4, 7, 8, 9, 10, 15, 20]"} |
| {"id":"cmsvowogw02cvg4p2c0rt43ua","kind":"contributor_item","title":"Submission RT43UA","provisional":false,"code":"\nimport cmath\ndef solve_quadratic(a, b, c):\n disc = b**2 - 4*a*c\n root1 = (-b + cmath.sqrt(disc)) / (2*a)\n root2 = (-b - cmath.sqrt(disc)) / (2*a)\n return (round(root1.real,3), round(root2.real,3)) if disc >= 0 else (str(root1), str(root2))\n","input":"solve_quadratic(2, -7, 3)","language":"python","predicted_output":"(3.0, 0.5)"} |
| {"id":"cmsvowogw02cgg4p23z8i6bd6","kind":"contributor_item","title":"Submission 8I6BD6","provisional":false,"code":"\ndef shipping_cost(weight_kg, distance_km):\n base = 5.0\n weight_cost = weight_kg * 0.8\n distance_cost = distance_km * 0.05\n if weight_kg > 20:\n distance_cost *= 1.15\n return round(base + weight_cost + distance_cost, 2)\n","input":"shipping_cost(25, 340)","language":"python","predicted_output":"44.55"} |
| {"id":"cmsvowogw02c9g4p2w91z7420","kind":"contributor_item","title":"Submission 1Z7420","provisional":false,"code":"\nfrom datetime import datetime, timedelta\ndef business_days_between(start_date, end_date):\n d1 = datetime.strptime(start_date, '%Y-%m-%d')\n d2 = datetime.strptime(end_date, '%Y-%m-%d')\n days = 0\n current = d1\n while current < d2:\n if current.weekday() < 5:\n days += 1\n current += timedelta(days=1)\n return days\n","input":"business_days_between('2026-08-01', '2026-08-15')","language":"python","predicted_output":"10"} |
| {"id":"cmsvowogv02c5g4p2aywrh3sy","kind":"contributor_item","title":"Submission WRH3SY","provisional":false,"code":"\nimport re\ndef password_strength(pw):\n score = 0\n if len(pw) >= 8: score += 1\n if re.search(r'[A-Z]', pw): score += 1\n if re.search(r'[a-z]', pw): score += 1\n if re.search(r'[0-9]', pw): score += 1\n if re.search(r'[^A-Za-z0-9]', pw): score += 1\n labels = {0:'very weak',1:'weak',2:'weak',3:'medium',4:'strong',5:'very strong'}\n return labels[score]\n","input":"password_strength('Tr0ub4dor&3')","language":"python","predicted_output":"very strong"} |
| {"id":"cmsvowogw02csg4p246t1dhbd","kind":"contributor_item","title":"Submission T1DHBD","provisional":false,"code":"\ndef lcs_length(a, b):\n m, n = len(a), len(b)\n dp = [[0] * (n + 1) for _ in range(m + 1)]\n for i in range(1, m + 1):\n for j in range(1, n + 1):\n if a[i - 1] == b[j - 1]:\n dp[i][j] = dp[i - 1][j - 1] + 1\n else:\n dp[i][j] = max(dp[i - 1][j], dp[i][j - 1])\n return dp[m][n]\n","input":"lcs_length('ABCBDAB', 'BDCABA')","language":"Python","predicted_output":"4"} |
| {"id":"cmsvowogv02c2g4p21pxxjsiv","kind":"contributor_item","title":"Submission XXJSIV","provisional":false,"code":"\ndef reorder_point(avg_daily_usage, lead_time_days, safety_stock):\n return avg_daily_usage * lead_time_days + safety_stock\n","input":"reorder_point(42, 6, 75)","language":"python","predicted_output":"327"} |
| {"id":"cmsvowogw02c6g4p2tzczx8ly","kind":"contributor_item","title":"Submission CZX8LY","provisional":false,"code":"\ndef transpose(m):\n return [list(row) for row in zip(*m)]\n","input":"transpose([[1,2,3],[4,5,6]])","language":"python","predicted_output":"[[1, 4], [2, 5], [3, 6]]"} |
| {"id":"cmsvowogw02cag4p2vjzn6jya","kind":"contributor_item","title":"Submission ZN6JYA","provisional":false,"code":"\ndef max_window_sum(nums, k):\n window = sum(nums[:k])\n best = window\n for i in range(k, len(nums)):\n window += nums[i] - nums[i-k]\n best = max(best, window)\n return best\n","input":"max_window_sum([4,-1,3,7,-2,5,9,-8,2], 3)","language":"python","predicted_output":"12"} |
| {"id":"cmsvowogw02chg4p2annz4uks","kind":"contributor_item","title":"Submission NZ4UKS","provisional":false,"code":"\ndef caesar_encode(text, shift):\n result = []\n for ch in text:\n if ch.isupper():\n result.append(chr((ord(ch)-65+shift)%26+65))\n elif ch.islower():\n result.append(chr((ord(ch)-97+shift)%26+97))\n else:\n result.append(ch)\n return ''.join(result)\n","input":"caesar_encode('Attack at Dawn!', 7)","language":"python","predicted_output":"Haahjr ha Khdu!"} |
| {"id":"cmsvowogw02ctg4p213fs8p2i","kind":"contributor_item","title":"Submission FS8P2I","provisional":false,"code":"\ndef rotate_ccw(matrix):\n n = len(matrix)\n m = len(matrix[0])\n return [[matrix[r][c] for r in range(n)] for c in range(m - 1, -1, -1)]\n","input":"rotate_ccw([[1, 2, 3], [4, 5, 6]])","language":"Python","predicted_output":"[[3, 6], [2, 5], [1, 4]]"} |
| {"id":"cmsvowogw02cug4p2j4xqi1lk","kind":"contributor_item","title":"Submission XQI1LK","provisional":false,"code":"\ndef sort_colors(nums):\n low, mid, high = 0, 0, len(nums) - 1\n nums = list(nums)\n while mid <= high:\n if nums[mid] == 0:\n nums[low], nums[mid] = nums[mid], nums[low]\n low += 1\n mid += 1\n elif nums[mid] == 1:\n mid += 1\n else:\n nums[mid], nums[high] = nums[high], nums[mid]\n high -= 1\n return nums\n","input":"sort_colors([2, 0, 2, 1, 1, 0])","language":"Python","predicted_output":"[0, 0, 1, 1, 2, 2]"} |
| {"id":"cmsvowogw02crg4p2gk56wuq2","kind":"contributor_item","title":"Submission 56WUQ2","provisional":false,"code":"\ndef digital_root(n):\n while n >= 10:\n n = sum(int(d) for d in str(n))\n return n\n","input":"digital_root(9875)","language":"Python","predicted_output":"2"} |
| {"id":"cmsvowogw02cdg4p2k2x8o3gi","kind":"contributor_item","title":"Submission X8O3GI","provisional":false,"code":"\ndef sum_numeric_column(csv_text, col_index):\n rows = [r.split(',') for r in csv_text.strip().split('\\n')]\n return sum(float(r[col_index]) for r in rows)\n","input":"sum_numeric_column('a,10,x\\nb,20,y\\nc,30,z', 1)","language":"python","predicted_output":"60.0"} |
| {"id":"cmsvowogv02c4g4p2zgx4ltxr","kind":"contributor_item","title":"Submission X4LTXR","provisional":false,"code":"\ndef wind_chill(temp_f, wind_mph):\n if wind_mph <= 3 or temp_f > 50:\n return temp_f\n wc = 35.74 + 0.6215*temp_f - 35.75*(wind_mph**0.16) + 0.4275*temp_f*(wind_mph**0.16)\n return round(wc, 2)\n","input":"wind_chill(20, 15)","language":"python","predicted_output":"6.22"} |
| {"id":"cmsvowogw02cng4p2ndltosnq","kind":"contributor_item","title":"Submission LTOSNQ","provisional":false,"code":"\ndef eval_postfix(expr):\n stack = []\n for tok in expr.split():\n if tok in '+-*/':\n b = stack.pop()\n a = stack.pop()\n if tok == '+': stack.append(a+b)\n elif tok == '-': stack.append(a-b)\n elif tok == '*': stack.append(a*b)\n elif tok == '/': stack.append(a/b)\n else:\n stack.append(float(tok))\n return stack[0]\n","input":"eval_postfix('4 6 2 * + 3 -')","language":"python","predicted_output":"13.0"} |
| {"id":"cmsvq95rh02p2g4p23sfxgm50","kind":"contributor_item","title":"Submission FXGM50","provisional":false,"code":"\ndef weighted_average_drop_lowest(scores, weights):\n pairs = list(zip(scores, weights))\n pairs.sort(key=lambda p: p[0])\n dropped = pairs[1:]\n total_weight = sum(w for _, w in dropped)\n return round(sum(s*w for s, w in dropped) / total_weight, 2)\n","input":"weighted_average_drop_lowest([88, 45, 92, 79], [0.3, 0.2, 0.25, 0.25])","language":"Python","predicted_output":"86.44"} |
| {"id":"cmsvq95rh02p4g4p23xvti296","kind":"contributor_item","title":"Submission VTI296","provisional":false,"code":"\ndef union_find_components(n, edges):\n parent = list(range(n))\n def find(x):\n while parent[x] != x:\n parent[x] = parent[parent[x]]\n x = parent[x]\n return x\n def union(a, b):\n ra, rb = find(a), find(b)\n if ra != rb:\n parent[ra] = rb\n for a, b in edges:\n union(a, b)\n return len(set(find(i) for i in range(n)))\n","input":"union_find_components(5, [(0,1),(1,2),(3,4)])","language":"Python","predicted_output":"2"} |
| {"id":"cmsvq95rh02p5g4p25ibq3xpz","kind":"contributor_item","title":"Submission BQ3XPZ","provisional":false,"code":"\nclass TrieNode:\n def __init__(self):\n self.children = {}\n self.is_end = False\n\ndef trie_search_prefix(words, prefix):\n root = TrieNode()\n for w in words:\n node = root\n for ch in w:\n if ch not in node.children:\n node.children[ch] = TrieNode()\n node = node.children[ch]\n node.is_end = True\n node = root\n for ch in prefix:\n if ch not in node.children:\n return []\n node = node.children[ch]\n results = []\n def dfs(n, path):\n if n.is_end:\n results.append(prefix + path)\n for c, child in n.children.items():\n dfs(child, path + c)\n dfs(node, \"\")\n return sorted(results)\n","input":"trie_search_prefix(['cat', 'car', 'cart', 'dog'], 'ca')","language":"Python","predicted_output":"['car', 'cart', 'cat']"} |
| {"id":"cmsvq95ri02p9g4p253t1w1nv","kind":"contributor_item","title":"Submission T1W1NV","provisional":false,"code":"\ndef majority_element(nums):\n count = 0\n candidate = None\n for n in nums:\n if count == 0:\n candidate = n\n count += 1 if n == candidate else -1\n return candidate\n","input":"majority_element([2,2,1,1,1,2,2])","language":"Python","predicted_output":"2"} |
| {"id":"cmsvq95rh02p8g4p2bocpvrmq","kind":"contributor_item","title":"Submission CPVRMQ","provisional":false,"code":"\ndef reservoir_sample_deterministic(stream, k, rand_sequence):\n reservoir = stream[:k]\n for i in range(k, len(stream)):\n j = rand_sequence[i - k] % (i + 1)\n if j < k:\n reservoir[j] = stream[i]\n return reservoir\n","input":"reservoir_sample_deterministic([10,20,30,40,50,60], 3, [0,1,2])","language":"Python","predicted_output":"[40, 50, 60]"} |
| {"id":"cmsvq95ri02pag4p2mbvq3fro","kind":"contributor_item","title":"Submission VQ3FRO","provisional":false,"code":"\ndef max_subarray_with_indices(nums):\n best_sum = nums[0]\n cur_sum = nums[0]\n best_start = best_end = cur_start = 0\n for i in range(1, len(nums)):\n if cur_sum < 0:\n cur_sum = nums[i]\n cur_start = i\n else:\n cur_sum += nums[i]\n if cur_sum > best_sum:\n best_sum = cur_sum\n best_start = cur_start\n best_end = i\n return (best_sum, best_start, best_end)\n","input":"max_subarray_with_indices([-2,1,-3,4,-1,2,1,-5,4])","language":"Python","predicted_output":"(6, 3, 6)"} |
| {"id":"cmsvq95ri02pdg4p2y3lg3s2l","kind":"contributor_item","title":"Submission LG3S2L","provisional":false,"code":"\ndef mod_pow(base, exp, mod):\n result = 1\n base = base % mod\n while exp > 0:\n if exp % 2 == 1:\n result = (result * base) % mod\n exp //= 2\n base = (base * base) % mod\n return result\n","input":"mod_pow(4, 13, 497)","language":"Python","predicted_output":"445"} |
| {"id":"cmsvq95ri02pgg4p2mttzsxd9","kind":"contributor_item","title":"Submission TZSXD9","provisional":false,"code":"\ndef bresenham_line(x0, y0, x1, y1):\n points = []\n dx = abs(x1 - x0)\n dy = abs(y1 - y0)\n sx = 1 if x0 < x1 else -1\n sy = 1 if y0 < y1 else -1\n err = dx - dy\n while True:\n points.append((x0, y0))\n if x0 == x1 and y0 == y1:\n break\n e2 = 2 * err\n if e2 > -dy:\n err -= dy\n x0 += sx\n if e2 < dx:\n err += dx\n y0 += sy\n return points\n","input":"bresenham_line(0, 0, 5, 3)","language":"Python","predicted_output":"[(0, 0), (1, 1), (2, 1), (3, 2), (4, 2), (5, 3)]"} |
| {"id":"cmsvq95ri02phg4p2m21hhxsp","kind":"contributor_item","title":"Submission 1HHXSP","provisional":false,"code":"\nimport heapq\n\ndef huffman_code_lengths(freqs):\n heap = [[f, i, [ch]] for i, (ch, f) in enumerate(freqs.items())]\n heapq.heapify(heap)\n lengths = {ch: 0 for ch in freqs}\n counter = len(heap)\n while len(heap) > 1:\n f1, _, chars1 = heapq.heappop(heap)\n f2, _, chars2 = heapq.heappop(heap)\n for ch in chars1 + chars2:\n lengths[ch] += 1\n heapq.heappush(heap, [f1 + f2, counter, chars1 + chars2])\n counter += 1\n return dict(sorted(lengths.items()))\n","input":"huffman_code_lengths({'a': 5, 'b': 9, 'c': 12, 'd': 13, 'e': 16, 'f': 45})","language":"Python","predicted_output":"{'a': 4, 'b': 4, 'c': 3, 'd': 3, 'e': 3, 'f': 1}"} |
| {"id":"cmsvq95ri02pig4p2bc7os007","kind":"contributor_item","title":"Submission 7OS007","provisional":false,"code":"\ndef rabin_karp_search(text, pattern):\n n, m = len(text), len(pattern)\n if m > n:\n return -1\n base, mod = 256, 1000000007\n h = pow(base, m - 1, mod)\n p_hash = t_hash = 0\n for i in range(m):\n p_hash = (p_hash * base + ord(pattern[i])) % mod\n t_hash = (t_hash * base + ord(text[i])) % mod\n for i in range(n - m + 1):\n if p_hash == t_hash and text[i:i+m] == pattern:\n return i\n if i < n - m:\n t_hash = ((t_hash - ord(text[i]) * h) * base + ord(text[i + m])) % mod\n return -1\n","input":"rabin_karp_search('ABABDABACDABABCABAB', 'ABABCABAB')","language":"Python","predicted_output":"10"} |
| {"id":"cmsvq95ri02pfg4p2topd80c2","kind":"contributor_item","title":"Submission PD80C2","provisional":false,"code":"\ndef morse_encode(text):\n MORSE = {\n \"A\": \".-\", \"B\": \"-...\", \"C\": \"-.-.\", \"D\": \"-..\", \"E\": \".\",\n \"F\": \"..-.\", \"G\": \"--.\", \"H\": \"....\", \"I\": \"..\", \"J\": \".---\",\n \"K\": \"-.-\", \"L\": \".-..\", \"M\": \"--\", \"N\": \"-.\", \"O\": \"---\",\n \"P\": \".--.\", \"Q\": \"--.-\", \"R\": \".-.\", \"S\": \"...\", \"T\": \"-\",\n \"U\": \"..-\", \"V\": \"...-\", \"W\": \".--\", \"X\": \"-..-\", \"Y\": \"-.--\", \"Z\": \"--..\",\n \" \": \"/\"\n }\n return \" \".join(MORSE[ch] for ch in text.upper())\n","input":"morse_encode('SOS')","language":"Python","predicted_output":"... --- ..."} |
| {"id":"cmsvq95rh02ovg4p2euuwncy8","kind":"contributor_item","title":"Submission UWNCY8","provisional":false,"code":"\ndef gregorian_to_jdn(year, month, day):\n a = (14 - month) // 12\n y = year + 4800 - a\n m = month + 12 * a - 3\n jdn = day + (153 * m + 2) // 5 + 365 * y + y // 4 - y // 100 + y // 400 - 32045\n return jdn\n","input":"gregorian_to_jdn(2000, 1, 1)","language":"Python","predicted_output":"2451545"} |
| {"id":"cmsvq95rh02oxg4p2vlfv49vm","kind":"contributor_item","title":"Submission FV49VM","provisional":false,"code":"\ndef luhn_checksum(card_number: str):\n digits = [int(d) for d in card_number]\n odd_digits = digits[-1::-2]\n even_digits = digits[-2::-2]\n total = sum(odd_digits)\n for d in even_digits:\n total += sum(divmod(d * 2, 10))\n return total % 10 == 0\n","input":"luhn_checksum('4532015112830366')","language":"Python","predicted_output":"True"} |
| {"id":"cmsvq95rh02oug4p2yn7n6i78","kind":"contributor_item","title":"Submission 7N6I78","provisional":false,"code":"\ndef zellers_congruence(year, month, day):\n if month < 3:\n month += 12\n year -= 1\n k = year % 100\n j = year // 100\n h = (day + (13 * (month + 1)) // 5 + k + k // 4 + j // 4 + 5 * j) % 7\n days = [\"Saturday\", \"Sunday\", \"Monday\", \"Tuesday\", \"Wednesday\", \"Thursday\", \"Friday\"]\n return days[h]\n","input":"zellers_congruence(2026, 8, 16)","language":"Python","predicted_output":"Sunday"} |
| {"id":"cmsvq95rh02oyg4p2p567fdee","kind":"contributor_item","title":"Submission 67FDEE","provisional":false,"code":"\ndef collatz_length(n):\n steps = 0\n while n != 1:\n n = n // 2 if n % 2 == 0 else 3 * n + 1\n steps += 1\n return steps\n","input":"collatz_length(27)","language":"Python","predicted_output":"111"} |
| {"id":"cmsvq95rh02p0g4p2bahv4hwd","kind":"contributor_item","title":"Submission HV4HWD","provisional":false,"code":"\ndef caesar_encrypt(text, shift):\n result = []\n for ch in text:\n if ch.isupper():\n result.append(chr((ord(ch) - 65 + shift) % 26 + 65))\n elif ch.islower():\n result.append(chr((ord(ch) - 97 + shift) % 26 + 97))\n else:\n result.append(ch)\n return \"\".join(result)\n","input":"caesar_encrypt('Attack at Dawn!', 3)","language":"Python","predicted_output":"Dwwdfn dw Gdzq!"} |
| {"id":"cmsvq95rh02ozg4p2qjjdp1ej","kind":"contributor_item","title":"Submission JDP1EJ","provisional":false,"code":"\ndef base62_encode(num):\n alphabet = \"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\"\n if num == 0:\n return alphabet[0]\n arr = []\n base = len(alphabet)\n while num:\n num, rem = divmod(num, base)\n arr.append(alphabet[rem])\n return \"\".join(reversed(arr))\n","input":"base62_encode(123456789)","language":"Python","predicted_output":"8M0kX"} |
| {"id":"cmsvq95rh02p1g4p2hegfgbt6","kind":"contributor_item","title":"Submission GFGBT6","provisional":false,"code":"\ndef vigenere_encrypt(text, key):\n result = []\n key = key.upper()\n ki = 0\n for ch in text:\n if ch.isalpha():\n shift = ord(key[ki % len(key)]) - 65\n base = 65 if ch.isupper() else 97\n result.append(chr((ord(ch) - base + shift) % 26 + base))\n ki += 1\n else:\n result.append(ch)\n return \"\".join(result)\n","input":"vigenere_encrypt('ATTACKATDAWN', 'LEMON')","language":"Python","predicted_output":"LXFOPVEFRNHR"} |
| {"id":"cmsvq95rh02p7g4p2s3op3ytr","kind":"contributor_item","title":"Submission OP3YTR","provisional":false,"code":"\ndef dijkstra(n, edges, src):\n import heapq\n graph = [[] for _ in range(n)]\n for u, v, w in edges:\n graph[u].append((v, w))\n graph[v].append((u, w))\n dist = [float('inf')] * n\n dist[src] = 0\n pq = [(0, src)]\n while pq:\n d, u = heapq.heappop(pq)\n if d > dist[u]:\n continue\n for v, w in graph[u]:\n nd = d + w\n if nd < dist[v]:\n dist[v] = nd\n heapq.heappush(pq, (nd, v))\n return dist\n","input":"dijkstra(5, [(0,1,4),(0,2,1),(2,1,2),(1,3,1),(2,3,5),(3,4,3)], 0)","language":"Python","predicted_output":"[0, 3, 1, 4, 7]"} |
| {"id":"cmsvq95rh02p6g4p2z6fxe4sb","kind":"contributor_item","title":"Submission FXE4SB","provisional":false,"code":"\ndef topological_sort(n, edges):\n from collections import deque\n indeg = [0] * n\n graph = [[] for _ in range(n)]\n for u, v in edges:\n graph[u].append(v)\n indeg[v] += 1\n q = deque([i for i in range(n) if indeg[i] == 0])\n order = []\n while q:\n u = q.popleft()\n order.append(u)\n for v in graph[u]:\n indeg[v] -= 1\n if indeg[v] == 0:\n q.append(v)\n return order\n","input":"topological_sort(6, [(5,2),(5,0),(4,0),(4,1),(2,3),(3,1)])","language":"Python","predicted_output":"[4, 5, 2, 0, 3, 1]"} |
| {"id":"cmsvq95rh02owg4p2pvmky86e","kind":"contributor_item","title":"Submission MKY86E","provisional":false,"code":"\ndef crc8(data: bytes, poly=0x07):\n crc = 0\n for byte in data:\n crc ^= byte\n for _ in range(8):\n if crc & 0x80:\n crc = ((crc << 1) ^ poly) & 0xFF\n else:\n crc = (crc << 1) & 0xFF\n return crc\n","input":"crc8(b'123456789')","language":"Python","predicted_output":"244"} |
| {"id":"cmsvq95ri02pcg4p2hq4d1qkx","kind":"contributor_item","title":"Submission 4D1QKX","provisional":false,"code":"\ndef extended_gcd(a, b):\n if b == 0:\n return (a, 1, 0)\n g, x1, y1 = extended_gcd(b, a % b)\n x = y1\n y = x1 - (a // b) * y1\n return (g, x, y)\n","input":"extended_gcd(240, 46)","language":"Python","predicted_output":"(2, -9, 47)"} |
| {"id":"cmsvq95ri02pbg4p2uffku3ir","kind":"contributor_item","title":"Submission FKU3IR","provisional":false,"code":"\ndef sieve_of_sundaram(limit):\n if limit < 2:\n return []\n n = (limit - 1) // 2\n marked = [False] * (n + 1)\n for i in range(1, n + 1):\n j = i\n while i + j + 2 * i * j <= n:\n marked[i + j + 2 * i * j] = True\n j += 1\n primes = [2] if limit >= 2 else []\n for i in range(1, n + 1):\n if not marked[i]:\n primes.append(2 * i + 1)\n return primes\n","input":"sieve_of_sundaram(30)","language":"Python","predicted_output":"[2, 3, 5, 7, 11, 13, 17, 19, 23, 29]"} |
| {"id":"cmsvq95ri02peg4p2ehj5dmd5","kind":"contributor_item","title":"Submission J5DMD5","provisional":false,"code":"\ndef miller_rabin(n):\n if n < 2:\n return False\n for p in [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]:\n if n % p == 0:\n return n == p\n d = n - 1\n r = 0\n while d % 2 == 0:\n d //= 2\n r += 1\n for a in [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]:\n x = pow(a, d, n)\n if x == 1 or x == n - 1:\n continue\n for _ in range(r - 1):\n x = x * x % n\n if x == n - 1:\n break\n else:\n return False\n return True\n","input":"miller_rabin(561)","language":"Python","predicted_output":"False"} |
| {"id":"cmsvq95ri02pjg4p28mlbt92o","kind":"contributor_item","title":"Submission LBT92O","provisional":false,"code":"\nimport datetime\n\ndef iso_week_date(year, month, day):\n d = datetime.date(year, month, day)\n iso_year, iso_week, iso_weekday = d.isocalendar()\n return (iso_year, iso_week, iso_weekday)\n","input":"iso_week_date(2027, 1, 1)","language":"Python","predicted_output":"(2026, 53, 5)"} |
| {"id":"cmsvq95rh02p3g4p2l49o2zdq","kind":"contributor_item","title":"Submission 9O2ZDQ","provisional":false,"code":"\ndef infix_to_postfix(expr):\n prec = {\"+\": 1, \"-\": 1, \"*\": 2, \"/\": 2}\n output = []\n ops = []\n tokens = expr.split()\n for tok in tokens:\n if tok.isdigit():\n output.append(tok)\n elif tok == \"(\":\n ops.append(tok)\n elif tok == \")\":\n while ops and ops[-1] != \"(\":\n output.append(ops.pop())\n ops.pop()\n else:\n while ops and ops[-1] != \"(\" and prec.get(ops[-1], 0) >= prec.get(tok, 0):\n output.append(ops.pop())\n ops.append(tok)\n while ops:\n output.append(ops.pop())\n return \" \".join(output)\n","input":"infix_to_postfix('3 + 4 * ( 2 - 1 )')","language":"Python","predicted_output":"3 4 2 1 - * +"} |
| {"id":"cmsvqtegb02scg4p2ga6e0cpi","kind":"contributor_item","title":"Submission 6E0CPI","provisional":false,"code":"\ndef kaprekar_steps(n):\n steps = 0\n seen = n\n while seen != 6174 and steps < 100:\n digits = f\"{seen:04d}\"\n asc = int(\"\".join(sorted(digits)))\n desc = int(\"\".join(sorted(digits, reverse=True)))\n seen = desc - asc\n steps += 1\n return steps\n","input":"kaprekar_steps(3524)","language":"Python","predicted_output":"3"} |
| {"id":"cmsvte58z0009uvp2o0qoxh1y","kind":"contributor_item","title":"Submission QOXH1Y","provisional":false,"code":"def parse_csv_row_types(row):\n result = []\n for cell in row.split(','):\n cell = cell.strip()\n try:\n result.append(int(cell))\n except ValueError:\n try:\n result.append(float(cell))\n except ValueError:\n if cell.lower() in ('true', 'false'):\n result.append(cell.lower() == 'true')\n else:\n result.append(cell)\n return result","input":"parse_csv_row_types('42, 3.14, true, hello, false')","language":"Python","predicted_output":"[42, 3.14, True, 'hello', False]"} |
| {"id":"cmsvte58z000euvp24fpfsuuc","kind":"contributor_item","title":"Submission PFSUUC","provisional":false,"code":"def group_anagrams(words):\n groups = {}\n for w in words:\n key = ''.join(sorted(w))\n groups.setdefault(key, []).append(w)\n return sorted(groups.values(), key=lambda g: (-len(g), g[0]))","input":"group_anagrams(['eat','tea','tan','ate','nat','bat'])","language":"Python","predicted_output":"[['eat', 'tea', 'ate'], ['tan', 'nat'], ['bat']]"} |
| {"id":"cmsvte58z000iuvp2w0l3s15j","kind":"contributor_item","title":"Submission L3S15J","provisional":false,"code":"def validate_and_normalize_paths(paths):\n import posixpath\n normalized = []\n for p in paths:\n try:\n norm = posixpath.normpath(p)\n if norm.startswith('..'):\n raise ValueError('escapes root')\n normalized.append(norm)\n except ValueError as e:\n normalized.append(f'invalid: {e}')\n return normalized","input":"validate_and_normalize_paths(['/a/b/../c', '../etc/passwd', './x/./y/', 'a//b///c'])","language":"Python","predicted_output":"['/a/c', 'invalid: escapes root', 'x/y', 'a/b/c']"} |
| {"id":"cmsvte58z000huvp289ttatv2","kind":"contributor_item","title":"Submission TTATV2","provisional":false,"code":"def recursive_fib_memo(n, memo=None):\n if memo is None:\n memo = {}\n if n in memo:\n return memo[n]\n if n <= 1:\n return n\n memo[n] = recursive_fib_memo(n-1, memo) + recursive_fib_memo(n-2, memo)\n return memo[n]\n\ndef fib_sequence(n):\n return [recursive_fib_memo(i) for i in range(n)]","input":"fib_sequence(12)","language":"Python","predicted_output":"[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]"} |
| {"id":"cmsvte58z0007uvp2zj525tkh","kind":"contributor_item","title":"Submission 525TKH","provisional":false,"code":"def dedupe_preserve_order(items):\n seen = set()\n out = []\n for item in items:\n key = item if isinstance(item, (int, str)) else tuple(item)\n if key not in seen:\n seen.add(key)\n out.append(item)\n return out","input":"dedupe_preserve_order([1, 2, 2, 3, 1, 4, 3])","language":"Python","predicted_output":"[1, 2, 3, 4]"} |
| {"id":"cmsvte58z000buvp2dxwtcafd","kind":"contributor_item","title":"Submission WTCAFD","provisional":false,"code":"def merge_intervals(intervals):\n intervals = sorted(intervals, key=lambda x: x[0])\n merged = [intervals[0]]\n for start, end in intervals[1:]:\n last = merged[-1]\n if start <= last[1]:\n merged[-1] = (last[0], max(last[1], end))\n else:\n merged.append((start, end))\n return merged","input":"merge_intervals([(1,3),(2,6),(8,10),(15,18),(9,12)])","language":"Python","predicted_output":"[(1, 6), (8, 12), (15, 18)]"} |
| {"id":"cmsvte58z000juvp2dcqkmrgw","kind":"contributor_item","title":"Submission QKMRGW","provisional":false,"code":"def custom_sort_with_key_errors(records):\n def key_fn(r):\n try:\n return (-r['priority'], r['name'])\n except KeyError:\n return (0, '')\n valid = [r for r in records if 'priority' in r and 'name' in r]\n return sorted(valid, key=key_fn)","input":"custom_sort_with_key_errors([{'name':'b','priority':2},{'name':'a','priority':2},{'name':'c'},{'name':'d','priority':5}])","language":"Python","predicted_output":"[{'name': 'd', 'priority': 5}, {'name': 'a', 'priority': 2}, {'name': 'b', 'priority': 2}]"} |
| {"id":"cmsvte58z0001uvp2iibbmckr","kind":"contributor_item","title":"Submission BBMCKR","provisional":false,"code":"def flatten_nested(items, depth=0):\n result = []\n for item in items:\n if isinstance(item, list) and depth < 2:\n result.extend(flatten_nested(item, depth + 1))\n else:\n result.append(item)\n return result","input":"flatten_nested([1, [2, 3, [4, [5, 6]]], 7])","language":"Python","predicted_output":"[1, 2, 3, 4, [5, 6], 7]"} |
| {"id":"cmsvte58z0002uvp26r4dy0fl","kind":"contributor_item","title":"Submission 4DY0FL","provisional":false,"code":"class CircularBuffer:\n def __init__(self, size):\n self.size = size\n self.buf = []\n def push(self, val):\n self.buf.append(val)\n if len(self.buf) > self.size:\n self.buf.pop(0)\n def snapshot(self):\n return list(self.buf)\n\ndef drive(vals, size):\n cb = CircularBuffer(size)\n snaps = []\n for v in vals:\n cb.push(v)\n snaps.append(cb.snapshot())\n return snaps","input":"drive([1,2,3,4,5], 3)","language":"Python","predicted_output":"[[1], [1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5]]"} |
| {"id":"cmsvte58z0004uvp2iice54pt","kind":"contributor_item","title":"Submission CE54PT","provisional":false,"code":"def word_frequency_rank(text):\n from collections import Counter\n words = text.lower().split()\n counts = Counter(words)\n ranked = sorted(counts.items(), key=lambda kv: (-kv[1], kv[0]))\n return ranked[:3]","input":"word_frequency_rank('the cat sat on the mat the cat ran')","language":"Python","predicted_output":"[('the', 3), ('cat', 2), ('mat', 1)]"} |
| {"id":"cmsvte58z0005uvp2bsdt7tiu","kind":"contributor_item","title":"Submission DT7TIU","provisional":false,"code":"def matrix_transpose_sum(matrix):\n rows = len(matrix)\n cols = len(matrix[0])\n transposed = [[matrix[r][c] for r in range(rows)] for c in range(cols)]\n row_sums = [sum(row) for row in transposed]\n return transposed, row_sums","input":"matrix_transpose_sum([[1,2,3],[4,5,6]])","language":"Python","predicted_output":"([[1, 4], [2, 5], [3, 6]], [5, 7, 9])"} |
| {"id":"cmsvte58z0006uvp259dhxku9","kind":"contributor_item","title":"Submission DHXKU9","provisional":false,"code":"def retry_with_backoff(attempts, fail_until):\n log = []\n for i in range(1, attempts + 1):\n if i < fail_until:\n log.append(f'attempt {i}: failed')\n else:\n log.append(f'attempt {i}: success')\n break\n else:\n log.append('exhausted')\n return log","input":"retry_with_backoff(5, 3)","language":"Python","predicted_output":"['attempt 1: failed', 'attempt 2: failed', 'attempt 3: success']"} |
| {"id":"cmsvte58z0003uvp2ra8h9zw3","kind":"contributor_item","title":"Submission 8H9ZW3","provisional":false,"code":"def safe_divide_chain(nums):\n results = []\n acc = nums[0]\n for n in nums[1:]:\n try:\n acc = acc / n\n except ZeroDivisionError:\n results.append('div0')\n acc = 0\n continue\n results.append(round(acc, 3))\n return results","input":"safe_divide_chain([100, 2, 0, 5, 0])","language":"Python","predicted_output":"[50.0, 'div0', 0.0, 'div0']"} |
| {"id":"cmsvte58z0000uvp2ph62id6s","kind":"contributor_item","title":"Submission 62ID6S","provisional":false,"code":"def running_median(values):\n import bisect\n sorted_vals = []\n medians = []\n for v in values:\n bisect.insort(sorted_vals, v)\n n = len(sorted_vals)\n if n % 2 == 1:\n medians.append(sorted_vals[n // 2])\n else:\n medians.append((sorted_vals[n // 2 - 1] + sorted_vals[n // 2]) / 2)\n return medians","input":"running_median([5, 2, 8, 1, 9])","language":"Python","predicted_output":"[5, 3.5, 5, 3.5, 5]"} |
| {"id":"cmsvte58z000auvp2ytl3q4vb","kind":"contributor_item","title":"Submission L3Q4VB","provisional":false,"code":"def sliding_window_max(nums, k):\n from collections import deque\n dq = deque()\n result = []\n for i, n in enumerate(nums):\n while dq and nums[dq[-1]] <= n:\n dq.pop()\n dq.append(i)\n if dq[0] <= i - k:\n dq.popleft()\n if i >= k - 1:\n result.append(nums[dq[0]])\n return result","input":"sliding_window_max([1,3,-1,-3,5,3,6,7], 3)","language":"Python","predicted_output":"[3, 3, 5, 5, 6, 7]"} |
| {"id":"cmsvte58z000cuvp2vwvnlsez","kind":"contributor_item","title":"Submission VNLSEZ","provisional":false,"code":"def exception_chain(vals):\n out = []\n for v in vals:\n try:\n if v < 0:\n raise ValueError('negative')\n if v == 0:\n raise ZeroDivisionError('zero')\n out.append(100 / v)\n except (ValueError, ZeroDivisionError) as e:\n out.append(str(e))\n finally:\n out.append('checked')\n return out","input":"exception_chain([5, -1, 0, 4])","language":"Python","predicted_output":"[20.0, 'checked', 'negative', 'checked', 'zero', 'checked', 25.0, 'checked']"} |
| {"id":"cmsvte58z000duvp27buqyehf","kind":"contributor_item","title":"Submission UQYEHF","provisional":false,"code":"def state_machine(events):\n state = 'idle'\n transitions = {\n ('idle', 'start'): 'running',\n ('running', 'pause'): 'paused',\n ('paused', 'resume'): 'running',\n ('running', 'stop'): 'idle',\n ('paused', 'stop'): 'idle',\n }\n history = [state]\n for e in events:\n state = transitions.get((state, e), state)\n history.append(state)\n return history","input":"state_machine(['start', 'pause', 'resume', 'stop', 'start'])","language":"Python","predicted_output":"['idle', 'running', 'paused', 'running', 'idle', 'running']"} |
| {"id":"cmsvte58z0008uvp2t64v3orx","kind":"contributor_item","title":"Submission 4V3ORX","provisional":false,"code":"class Graph:\n def __init__(self):\n self.adj = {}\n def add_edge(self, a, b):\n self.adj.setdefault(a, []).append(b)\n self.adj.setdefault(b, []).append(a)\n def bfs(self, start):\n visited = [start]\n queue = [start]\n while queue:\n node = queue.pop(0)\n for neighbor in sorted(self.adj.get(node, [])):\n if neighbor not in visited:\n visited.append(neighbor)\n queue.append(neighbor)\n return visited\n\ndef build_and_bfs(edges, start):\n g = Graph()\n for a, b in edges:\n g.add_edge(a, b)\n return g.bfs(start)","input":"build_and_bfs([(1,2),(1,3),(2,4),(3,4),(4,5)], 1)","language":"Python","predicted_output":"[1, 2, 3, 4, 5]"} |
| {"id":"cmsvte58z000guvp224esun4x","kind":"contributor_item","title":"Submission ESUN4X","provisional":false,"code":"def bit_manipulation_stats(n):\n binary = bin(n)[2:]\n ones = binary.count('1')\n zeros = binary.count('0')\n reversed_val = int(binary[::-1], 2)\n return {'binary': binary, 'ones': ones, 'zeros': zeros, 'reversed': reversed_val}","input":"bit_manipulation_stats(43)","language":"Python","predicted_output":"{'binary': '101011', 'ones': 4, 'zeros': 2, 'reversed': 53}"} |
| {"id":"cmsvte58z000fuvp2gd1yzt3n","kind":"contributor_item","title":"Submission 1YZT3N","provisional":false,"code":"def lru_cache_sim(capacity, ops):\n from collections import OrderedDict\n cache = OrderedDict()\n results = []\n for op in ops:\n if op[0] == 'put':\n k, v = op[1], op[2]\n if k in cache:\n cache.move_to_end(k)\n cache[k] = v\n if len(cache) > capacity:\n cache.popitem(last=False)\n results.append(None)\n else:\n k = op[1]\n if k in cache:\n cache.move_to_end(k)\n results.append(cache[k])\n else:\n results.append(-1)\n return results","input":"lru_cache_sim(2, [('put',1,1),('put',2,2),('get',1),('put',3,3),('get',2),('get',3)])","language":"Python","predicted_output":"[None, None, 1, None, -1, 3]"} |
| {"id":"cmsw2qs96003huvp2g020j92y","kind":"contributor_item","title":"Submission 20J92Y","provisional":false,"code":"class LazyTag:\n def __init__(self, label):\n self.label = label\n\n def __get__(self, obj, owner=None):\n if obj is None:\n return \"class-access\"\n return (\"nondata\", self.label)\n\n\nclass Doubling:\n def __set_name__(self, owner, name):\n self.slot = name\n\n def __get__(self, obj, owner=None):\n if obj is None:\n return \"class-access\"\n return (\"data\", obj.__dict__.get(self.slot, \"unset\"))\n\n def __set__(self, obj, value):\n obj.__dict__[self.slot] = value * 2\n\n\nclass Node:\n lazy = LazyTag(\"lazy\")\n weight = Doubling()\n\n\ndef descriptor_probe():\n n = Node()\n first = n.lazy\n n.__dict__[\"lazy\"] = \"shadow\"\n second = n.lazy\n third = n.weight\n n.weight = 5\n fourth = n.weight\n fifth = n.__dict__[\"weight\"]\n n.__dict__[\"weight\"] = 99\n sixth = n.weight\n return (first, second, third, fourth, fifth, sixth, sorted(n.__dict__))","input":"descriptor_probe()","language":"Python","predicted_output":"(('nondata', 'lazy'), 'shadow', ('data', 'unset'), ('data', 10), 10, ('data', 99), ['lazy', 'weight'])"} |
| {"id":"cmsw2qs96003nuvp2c8tfi5xl","kind":"contributor_item","title":"Submission TFI5XL","provisional":false,"code":"from collections import deque\n\n\ndef ring_buffer_run():\n d = deque([1, 2, 3], maxlen=4)\n d.append(4)\n d.append(5)\n a = list(d)\n d.appendleft(0)\n b = list(d)\n d.rotate(-1)\n c = list(d)\n\n e = deque(maxlen=3)\n e.extendleft([1, 2, 3, 4])\n f = list(e)\n\n g = deque(\"abc\")\n g.rotate(2)\n h = \"\".join(g)\n\n return (\n a,\n b,\n c,\n f,\n h,\n deque([1, 2, 3]).maxlen,\n list(deque([1, 2, 3, 4, 5], maxlen=2)),\n deque([1, 2, 3]) == deque([1, 2, 3]),\n list(deque([1, 2, 3]) + deque([4])),\n d.count(3),\n list(reversed(d)),\n )","input":"ring_buffer_run()","language":"Python","predicted_output":"([2, 3, 4, 5], [0, 2, 3, 4], [2, 3, 4, 0], [4, 3, 2], 'bca', None, [4, 5], True, [1, 2, 3, 4], 1, [0, 4, 3, 2])"} |
| {"id":"cmsw2qs96003quvp2bh55cis9","kind":"contributor_item","title":"Submission 55CIS9","provisional":false,"code":"def make_lambdas(values):\n plain = [lambda: v for v in values]\n bound = [lambda v=v: v for v in values]\n return plain, bound\n\n\ndef binding_run():\n plain, bound = make_lambdas([1, 2, 3])\n a = [f() for f in plain]\n b = [f() for f in bound]\n\n data = [1, 2, 3]\n gen = (x * 10 for x in data)\n data = [4, 5]\n c = list(gen)\n\n src = [1, 2, 3]\n gen2 = (x * 10 for x in src)\n src.append(4)\n d = list(gen2)\n\n factor = 2\n gen3 = (x * factor for x in [1, 2])\n factor = 100\n e = list(gen3)\n\n n = 0\n lst = [n for n in range(3)]\n f = (lst, n)\n\n total = 0\n for total in range(3):\n pass\n return (a, b, c, d, e, f, total)","input":"binding_run()","language":"Python","predicted_output":"([3, 3, 3], [1, 2, 3], [10, 20, 30], [10, 20, 30, 40], [100, 200], ([0, 1, 2], 0), 2)"} |
| {"id":"cmsw2qs96003xuvp20mkxm78q","kind":"contributor_item","title":"Submission KXM78Q","provisional":false,"code":"import functools\nfrom collections import OrderedDict\n\n\n@functools.singledispatch\ndef describe(value):\n return (\"generic\", type(value).__name__)\n\n\n@describe.register\ndef _(value: int):\n return (\"int\", value)\n\n\n@describe.register(bool)\ndef _(value):\n return (\"bool\", value)\n\n\n@describe.register(list)\ndef _(value):\n return (\"list\", len(value))\n\n\n@describe.register(dict)\ndef _(value):\n return (\"dict\", sorted(value))\n\n\n@functools.singledispatch\ndef kind(value):\n return \"generic\"\n\n\n@kind.register(int)\ndef _(value):\n return \"int\"\n\n\nclass MyList(list):\n pass\n\n\ndef dispatch_run():\n return (\n describe(3),\n describe(True),\n describe(MyList([1, 2])),\n describe(OrderedDict(a=1)),\n describe(3.5),\n sorted(t.__name__ for t in describe.registry),\n (kind(True), kind(2), kind(2.0)),\n )","input":"dispatch_run()","language":"Python","predicted_output":"(('int', 3), ('bool', True), ('list', 2), ('dict', ['a']), ('generic', 'float'), ['bool', 'dict', 'int', 'list', 'object'], ('int', 'int', 'generic'))"} |
| {"id":"cmsw2qs96003uuvp2ge4813c2","kind":"contributor_item","title":"Submission 4813C2","provisional":false,"code":"def slice_surgery():\n a = list(range(8))\n a[::2] = [\"x\"] * 4\n r1 = list(a)\n try:\n a[::2] = [\"y\"] * 3\n r2 = \"ok\"\n except ValueError:\n r2 = \"ValueError\"\n\n b = list(range(6))\n b[1:4] = [\"p\"]\n r3 = list(b)\n\n c = list(range(8))\n del c[::3]\n r4 = list(c)\n\n d = list(range(5))\n d[5:9] = [\"tail\"]\n r5 = list(d)\n\n e = list(range(5))\n e[2:2] = [\"ins1\", \"ins2\"]\n r6 = list(e)\n\n f = list(range(5))\n f[::-1] = list(\"abcde\")\n r7 = list(f)\n\n g = [1, 2, 3]\n g[:] = \"xy\"\n r8 = list(g)\n\n h = list(range(6))\n r9 = (h[4:1:-1], h[-1:-4:-1], h[1:5:2])\n return (r1, r2, r3, r4, r5, r6, r7, r8, r9)","input":"slice_surgery()","language":"Python","predicted_output":"(['x', 1, 'x', 3, 'x', 5, 'x', 7], 'ValueError', [0, 'p', 4, 5], [1, 2, 4, 5, 7], [0, 1, 2, 3, 4, 'tail'], [0, 1, 'ins1', 'ins2', 2, 3, 4], ['e', 'd', 'c', 'b', 'a'], ['x', 'y'], ([4, 3, 2], [5, 4, 3], [1, 3]))"} |
| {"id":"cmsw2qs96003ouvp2jib841qb","kind":"contributor_item","title":"Submission B841QB","provisional":false,"code":"def buffer_share():\n buf = bytearray(b\"abcdef\")\n mv = memoryview(buf)\n a = (mv[0], bytes(mv[1:3]), mv.nbytes, mv.readonly)\n mv[2:4] = b\"ZZ\"\n b = bytes(buf)\n\n rows = memoryview(bytes(range(6))).cast(\"B\", shape=(2, 3))\n c = (rows.shape, rows.ndim, rows.tolist(), rows.tolist()[1][2])\n\n ro = memoryview(b\"xyz\")\n try:\n ro[0] = 65\n d = \"mutated\"\n except TypeError:\n d = \"TypeError\"\n\n e = memoryview(b\"abc\") == b\"abc\"\n\n stride = mv[::2]\n f = (stride.tolist(), stride.contiguous)\n\n try:\n buf.append(7)\n g = \"resized\"\n except BufferError:\n g = \"BufferError\"\n\n stride.release()\n mv.release()\n buf.append(7)\n return (a, b, c, d, e, f, g, bytes(buf))","input":"buffer_share()","language":"Python","predicted_output":"((97, b'bc', 6, False), b'abZZef', ((2, 3), 2, [[0, 1, 2], [3, 4, 5]], 5), 'TypeError', True, ([97, 90, 101], False), 'BufferError', b'abZZef\\x07')"} |
| {"id":"cmsw2qs96003muvp2bkj6f8gf","kind":"contributor_item","title":"Submission J6F8GF","provisional":false,"code":"from collections import ChainMap\n\n\ndef layered_config():\n defaults = {\"color\": \"red\", \"size\": \"M\", \"qty\": 1}\n session = {\"size\": \"L\"}\n cm = ChainMap(session, defaults)\n a = (cm[\"size\"], cm[\"color\"], len(cm))\n cm[\"color\"] = \"blue\"\n b = (defaults[\"color\"], sorted(session.items()))\n del cm[\"color\"]\n c = (cm[\"color\"], \"color\" in session)\n child = cm.new_child({\"qty\": 9})\n d = (child[\"qty\"], len(child.maps), len(cm.maps))\n e = list(child.parents.maps) == list(cm.maps)\n session[\"qty\"] = 5\n f = (cm[\"qty\"], child[\"qty\"], sorted(cm.keys()))\n g = dict(ChainMap({\"a\": 1}, {\"a\": 2, \"b\": 3}))\n return (a, b, c, d, e, f, g)","input":"layered_config()","language":"Python","predicted_output":"(('L', 'red', 3), ('red', [('color', 'blue'), ('size', 'L')]), ('red', False), (9, 3, 2), True, (5, 9, ['color', 'qty', 'size']), {'a': 1, 'b': 3})"} |
| {"id":"cmsw2qs96003ruvp2gigql761","kind":"contributor_item","title":"Submission GQL761","provisional":false,"code":"def case_map_run():\n s = \"straße\"\n a = (s.upper(), len(s), len(s.upper()))\n b = (\"ß\".casefold(), \"ß\".upper().casefold(),\n \"ß\".casefold() == \"SS\".casefold())\n c = (\"İ\".lower(), len(\"İ\".lower()))\n d = (\"Dž\".title(), \"Dž\".upper(), \"Dž\".lower(), \"Dž\".capitalize())\n e = \"o'neill mcdonald\".title()\n f = (\"fi\".upper(), len(\"fi\".upper()), \"fi\".capitalize())\n g = (\"DŽ\".istitle(), \"Dž\".istitle(), \"dž\".istitle())\n h = \"ß\".capitalize()\n return (a, b, c, d, e, f, g, h)","input":"case_map_run()","language":"Python","predicted_output":"(('STRASSE', 6, 7), ('ss', 'ss', True), ('i̇', 2), ('Dž', 'DŽ', 'dž', 'Dž'), \"O'Neill Mcdonald\", ('FI', 2, 'Fi'), (True, True, False), 'Ss')"} |
| {"id":"cmsw2qs96003puvp2tbwd45mb","kind":"contributor_item","title":"Submission WD45MB","provisional":false,"code":"class Point:\n __match_args__ = (\"x\", \"y\")\n\n def __init__(self, x, y):\n self.x = x\n self.y = y\n\n\ndef classify(value):\n match value:\n case Point(0, 0):\n return \"origin\"\n case Point(x, 0) | Point(0, x):\n return (\"axis\", x)\n case Point(x=a, y=b) if a == b:\n return (\"diagonal\", a)\n case str() as s:\n return (\"string\", len(s))\n case [1, *rest]:\n return (\"starts-one\", rest)\n case {\"k\": v, **extra}:\n return (\"mapping\", v, sorted(extra))\n case (int() | float()) as n if n < 0:\n return (\"negative\", n)\n case _:\n return \"other\"\n\n\ndef classify_all():\n samples = [\n Point(0, 0),\n Point(3, 0),\n Point(0, 4),\n Point(2, 2),\n \"abc\",\n [1, 2, 3],\n (1, 9),\n {\"k\": 5, \"z\": 6},\n -2.5,\n 7,\n b\"\\x01\\x02\",\n ]\n return tuple(classify(v) for v in samples)","input":"classify_all()","language":"Python","predicted_output":"('origin', ('axis', 3), ('axis', 4), ('diagonal', 2), ('string', 3), ('starts-one', [2, 3]), ('starts-one', [9]), ('mapping', 5, ['z']), ('negative', -2.5), 'other', 'other')"} |
| {"id":"cmsw2qs96003yuvp2v8et66so","kind":"contributor_item","title":"Submission ET66SO","provisional":false,"code":"def sentinel_iter():\n seq = [3, 1, 4, 1, 5, 9]\n it = iter(seq)\n a = list(iter(lambda: next(it, None), None))\n\n counter = {\"n\": 0}\n\n def tick():\n counter[\"n\"] += 1\n return counter[\"n\"] * counter[\"n\"]\n\n b = list(iter(tick, 16))\n c = counter[\"n\"]\n d = next(iter([]), \"empty\")\n\n chunks = iter([b\"ab\", b\"cd\", b\"\"])\n e = list(iter(lambda: next(chunks), b\"\"))\n\n words = iter([\"x\", \"y\", \"stop\", \"z\"])\n f = list(iter(lambda: next(words), \"stop\"))\n g = next(words)\n\n it2 = iter(\"ab\")\n h = (next(it2), next(it2), next(it2, \"done\"), iter(it2) is it2)\n return (a, b, c, d, e, f, g, h)","input":"sentinel_iter()","language":"Python","predicted_output":"([3, 1, 4, 1, 5, 9], [1, 4, 9], 4, 'empty', [b'ab', b'cd'], ['x', 'y'], 'z', ('a', 'b', 'done', True))"} |
| {"id":"cmsw2qs96003kuvp2ncb5d6qj","kind":"contributor_item","title":"Submission B5D6QJ","provisional":false,"code":"class Fallback(dict):\n def __init__(self, *args, **kwargs):\n super().__init__(*args, **kwargs)\n self.misses = []\n\n def __missing__(self, key):\n self.misses.append(key)\n value = \"gen-\" + key\n self[key] = value\n return value\n\n\ndef missing_run():\n d = Fallback(a=\"A\")\n r1 = d[\"a\"]\n r2 = d[\"b\"]\n r3 = d.get(\"c\", \"default\")\n r4 = \"c\" in d\n r5 = d.setdefault(\"d\", \"D\")\n r6 = d.pop(\"zz\", \"nope\")\n return (r1, r2, r3, r4, r5, r6, d.misses, sorted(d.items()))","input":"missing_run()","language":"Python","predicted_output":"('A', 'gen-b', 'default', False, 'D', 'nope', ['b'], [('a', 'A'), ('b', 'gen-b'), ('d', 'D')])"} |
| {"id":"cmsw2qs96003iuvp2xlo3s736","kind":"contributor_item","title":"Submission O3S736","provisional":false,"code":"EVENTS = []\n\n\nclass Marker:\n def __set_name__(self, owner, name):\n EVENTS.append((\"set_name\", owner.__name__, name))\n\n\nclass Base:\n def __init_subclass__(cls, tag=\"none\", **kwargs):\n super().__init_subclass__(**kwargs)\n EVENTS.append((\"init_subclass\", cls.__name__, tag))\n cls.tag = tag\n\n\nclass Child(Base, tag=\"alpha\"):\n a = Marker()\n b = Marker()\n\n\nclass Grand(Child):\n c = Marker()\n\n\ndef class_creation_events():\n return (\n list(EVENTS),\n Child.tag,\n Grand.tag,\n \"tag\" in Grand.__dict__,\n \"tag\" in Base.__dict__,\n )","input":"class_creation_events()","language":"Python","predicted_output":"([('set_name', 'Child', 'a'), ('set_name', 'Child', 'b'), ('init_subclass', 'Child', 'alpha'), ('set_name', 'Grand', 'c'), ('init_subclass', 'Grand', 'none')], 'alpha', 'none', True, False)"} |
| {"id":"cmsw2qs96003juvp2rmjt85pf","kind":"contributor_item","title":"Submission JT85PF","provisional":false,"code":"def inner():\n try:\n received = yield \"a\"\n yield (\"echo\", received)\n except ValueError as exc:\n yield (\"caught\", exc.args[0])\n return \"fin\"\n\n\ndef outer(log):\n delivered = yield from inner()\n log.append(delivered)\n yield \"tail\"\n\n\ndef delegate_run():\n log = []\n gen = outer(log)\n s1 = next(gen)\n s2 = gen.send(7)\n s3 = gen.throw(ValueError(\"bad\"))\n s4 = next(gen)\n\n other = []\n gen2 = outer(other)\n next(gen2)\n gen2.close()\n try:\n next(gen2)\n after = \"ran\"\n except StopIteration:\n after = \"stopped\"\n return (s1, s2, s3, s4, log, other, after)","input":"delegate_run()","language":"Python","predicted_output":"('a', ('echo', 7), ('caught', 'bad'), 'tail', ['fin'], [], 'stopped')"} |
| {"id":"cmsw2qs96003luvp2esnnw0rg","kind":"contributor_item","title":"Submission NNW0RG","provisional":false,"code":"class Temp:\n def __init__(self, celsius):\n self.celsius = celsius\n\n def __format__(self, spec):\n if spec.endswith(\"F\"):\n return format(self.celsius * 9 / 5 + 32, spec[:-1]) + \"F\"\n if not spec:\n return \"T(\" + str(self.celsius) + \")\"\n return format(self.celsius, spec)\n\n def __repr__(self):\n return \"Temp(%r)\" % (self.celsius,)\n\n def __str__(self):\n return \"temp:\" + str(self.celsius)\n\n\ndef format_run():\n t = Temp(21.5)\n return (\n format(t),\n format(t, \".1fF\"),\n \"{:>10.2f}|\".format(t),\n \"{0!r} {0!s} {0}\".format(t),\n \"{:*^12.3f}\".format(t),\n \"{:{w}.{p}f}\".format(t, w=9, p=3),\n f\"{t:.0fF}\",\n \"%s|%r\" % (t, t),\n )","input":"format_run()","language":"Python","predicted_output":"('T(21.5)', '70.7F', ' 21.50|', 'Temp(21.5) temp:21.5 T(21.5)', '***21.500***', ' 21.500', '71F', 'temp:21.5|Temp(21.5)')"} |
| {"id":"cmsw2qs96003vuvp27kijhswy","kind":"contributor_item","title":"Submission IJHSWY","provisional":false,"code":"import itertools\n\n\ndef stream_consume():\n src = iter(range(10))\n a = list(itertools.islice(src, 3))\n b = next(src)\n c = list(itertools.islice(src, 0, 4, 2))\n d = next(src)\n\n x, y = itertools.tee(iter(\"abcd\"))\n e = (next(x), next(x), \"\".join(y), \"\".join(x))\n\n counter = itertools.count(5, -2)\n f = list(itertools.takewhile(lambda n: n > 0, counter))\n g = next(counter)\n\n fresh = [(k, list(v)) for k, v in itertools.groupby(\"aabbba\")]\n stale = [(k, v) for k, v in itertools.groupby(\"aabbba\")]\n h = [(k, list(v)) for k, v in stale]\n return (a, b, c, d, e, f, g, fresh, h)","input":"stream_consume()","language":"Python","predicted_output":"([0, 1, 2], 3, [4, 6], 8, ('a', 'b', 'abcd', 'cd'), [5, 3, 1], -3, [('a', ['a', 'a']), ('b', ['b', 'b', 'b']), ('a', ['a'])], [('a', []), ('b', []), ('a', [])])"} |
| {"id":"cmsw2qs96003tuvp2rcaieoy1","kind":"contributor_item","title":"Submission AIEOY1","provisional":false,"code":"def view_algebra():\n d = {\"a\": 1, \"b\": 2, \"c\": 3}\n keys = d.keys()\n items = d.items()\n values = d.values()\n\n a = (sorted(keys & {\"b\", \"c\", \"z\"}), sorted(keys - {\"a\"}),\n sorted(keys ^ {\"a\", \"z\"}))\n d[\"e\"] = 5\n b = (sorted(keys), len(items))\n c = sorted(items & {(\"a\", 1), (\"b\", 99)})\n e = ({\"a\": 1}.keys() == {\"a\"}, {\"a\": 1}.values() == {\"a\": 1}.values())\n f = list(reversed(list(d)))\n g = (\"a\", 1) in items\n\n other = {\"x\": [1]}\n try:\n other.items() & {(\"x\", [1])}\n h = \"ok\"\n except TypeError:\n h = \"TypeError\"\n\n i = list(zip(d.keys(), d.values())) == list(d.items())\n j = sorted(values)\n try:\n values & {1}\n k = \"ok\"\n except TypeError:\n k = \"TypeError\"\n return (a, b, c, e, f, g, h, i, j, k)","input":"view_algebra()","language":"Python","predicted_output":"((['b', 'c'], ['b', 'c'], ['b', 'c', 'z']), (['a', 'b', 'c', 'e'], 4), [('a', 1)], (True, False), ['e', 'c', 'b', 'a'], True, 'TypeError', True, [1, 2, 3, 5], 'TypeError')"} |
| {"id":"cmsw2qs96003wuvp29r7hjgco","kind":"contributor_item","title":"Submission 7HJGCO","provisional":false,"code":"def codec_run():\n s = \"café ☃\"\n a = (s.encode(\"ascii\", \"replace\"), s.encode(\"ascii\", \"ignore\"),\n s.encode(\"ascii\", \"backslashreplace\"))\n b = s.encode(\"ascii\", \"xmlcharrefreplace\")\n c = s.encode(\"latin-1\", \"backslashreplace\")\n\n raw = b\"valid \\xff\\xfe tail\"\n d = (raw.decode(\"utf-8\", \"replace\"), raw.decode(\"utf-8\", \"ignore\"),\n raw.decode(\"utf-8\", \"backslashreplace\"))\n escaped = raw.decode(\"utf-8\", \"surrogateescape\")\n e = (len(escaped), [hex(ord(ch)) for ch in escaped[6:8]])\n f = escaped.encode(\"utf-8\", \"surrogateescape\") == raw\n try:\n escaped.encode(\"utf-8\")\n g = \"ok\"\n except UnicodeEncodeError as exc:\n g = type(exc).__name__\n h = (\"é\".encode(\"utf-8\"), len(\"é\".encode(\"utf-8\")),\n \"é\".encode(\"utf-16-le\"))\n return (a, b, c, d, e, f, g, h)","input":"codec_run()","language":"Python","predicted_output":"((b'caf? ?', b'caf ', b'caf\\\\xe9 \\\\u2603'), b'café ☃', b'caf\\xe9 \\\\u2603', ('valid �� tail', 'valid tail', 'valid \\\\xff\\\\xfe tail'), (13, ['0xdcff', '0xdcfe']), True, 'UnicodeEncodeError', (b'\\xc3\\xa9', 2, b'\\xe9\\x00'))"} |
| {"id":"cmsw2qs96003zuvp2a3f9tpfv","kind":"contributor_item","title":"Submission F9TPFV","provisional":false,"code":"def zip_drain():\n it = iter(range(7))\n a = list(zip(it, it, it))\n b = list(it)\n\n it2 = iter(\"abcdef\")\n pairs = list(zip(it2, it2))\n c = (pairs, list(it2))\n\n short = iter([1, 2, 3])\n other = iter([\"a\", \"b\"])\n d = list(zip(short, other))\n e = list(short)\n\n try:\n list(zip([1, 2, 3], [\"a\"], strict=True))\n f = \"ok\"\n except ValueError:\n f = \"ValueError\"\n\n return (a, b, c, d, e, f, list(zip(*[])), list(zip()),\n list(zip([1, 2], [3, 4], [5])))","input":"zip_drain()","language":"Python","predicted_output":"([(0, 1, 2), (3, 4, 5)], [], ([('a', 'b'), ('c', 'd'), ('e', 'f')], []), [(1, 'a'), (2, 'b')], [], 'ValueError', [], [], [(1, 3, 5)])"} |
| {"id":"cmsw2qs960040uvp25ryyx656","kind":"contributor_item","title":"Submission YYX656","provisional":false,"code":"import copy\n\n\ndef cyclic_repr():\n a = [1, 2]\n a.append(a)\n r1 = repr(a)\n\n d = {\"k\": 1}\n d[\"self\"] = d\n r2 = repr(d)\n\n r3 = (a[2] is a, len(a))\n\n c = copy.deepcopy(a)\n r4 = (c is not a, c[2] is c, repr(c))\n\n t = ([1],)\n t[0].append(t)\n r5 = repr(t)\n\n s = [1]\n s.append([s])\n r6 = repr(s)\n\n nested = []\n nested.append([nested])\n r7 = repr(nested)\n\n shallow = copy.copy(a)\n r8 = (shallow[2] is a, repr(shallow))\n return (r1, r2, r3, r4, r5, r6, r7, r8)","input":"cyclic_repr()","language":"Python","predicted_output":"('[1, 2, [...]]', \"{'k': 1, 'self': {...}}\", (True, 3), (True, True, '[1, 2, [...]]'), '([1, (...)],)', '[1, [[...]]]', '[[[...]]]', (True, '[1, 2, [1, 2, [...]]]'))"} |
| {"id":"cmsw2qs96003suvp2cfhsp54b","kind":"contributor_item","title":"Submission HSP54B","provisional":false,"code":"import unicodedata\n\n\ndef normalize_run():\n nfc = chr(0x00E9)\n nfd = \"e\" + chr(0x0301)\n a = (len(nfc), len(nfd), nfc == nfd,\n unicodedata.normalize(\"NFC\", nfd) == nfc)\n b = (unicodedata.name(nfd[1]), unicodedata.combining(nfd[1]))\n c = ([hex(ord(ch)) for ch in unicodedata.normalize(\"NFKC\", chr(0xFB01))],\n [hex(ord(ch)) for ch in unicodedata.normalize(\"NFC\", chr(0xFB01))])\n d = ([hex(ord(ch)) for ch in unicodedata.normalize(\"NFKC\", chr(0x00BD))],\n len(unicodedata.normalize(\"NFC\", chr(0x00BD))))\n e = (chr(0x2460).isdigit(), chr(0x2460).isnumeric(),\n unicodedata.decimal(chr(0x0663)), unicodedata.numeric(chr(0x00BD)))\n ordered = sorted({nfc, nfd, unicodedata.normalize(\"NFC\", nfd)})\n f = [[hex(ord(ch)) for ch in item] for item in ordered]\n g = (chr(0x00C5) == chr(0x212B),\n unicodedata.normalize(\"NFC\", chr(0x212B)) == chr(0x00C5),\n unicodedata.normalize(\"NFD\", chr(0x00C5)) == \"A\" + chr(0x030A))\n return (a, b, c, d, e, f, g)","input":"normalize_run()","language":"Python","predicted_output":"((1, 2, False, True), ('COMBINING ACUTE ACCENT', 230), (['0x66', '0x69'], ['0xfb01']), (['0x31', '0x2044', '0x32'], 1), (True, True, 3, 0.5), [['0x65', '0x301'], ['0xe9']], (False, True, True))"} |
| {"id":"cmswrsvaa007kuvp2tkyqv3nl","kind":"contributor_item","title":"Submission YQV3NL","provisional":false,"code":"from itertools import groupby\ndef group_lengths(words):\n words = sorted(words, key=len)\n return {length: list(group) for length, group in groupby(words, key=len)}","input":"group_lengths(['a', 'bb', 'cc', 'ddd', 'e', 'ff'])","language":"Python","predicted_output":"{1: ['a', 'e'], 2: ['bb', 'cc', 'ff'], 3: ['ddd']}"} |
| {"id":"cmswrta8f007ouvp2ouorxbh5","kind":"contributor_item","title":"Submission ORXBH5","provisional":false,"code":"from dataclasses import dataclass, field\n\n@dataclass(order=True)\nclass Point:\n x: int\n y: int\n\n def manhattan(self):\n return abs(self.x) + abs(self.y)\n\ndef farthest(points):\n return max(points, key=lambda p: p.manhattan())","input":"farthest([Point(1, 2), Point(-3, 1), Point(2, 2)])","language":"Python","predicted_output":"Point(x=-3, y=1)"} |
| {"id":"cmswrta8f007nuvp2c4j3sdeg","kind":"contributor_item","title":"Submission J3SDEG","provisional":false,"code":"import operator\ndef apply_ops(a, b, ops):\n table = {'+': operator.add, '-': operator.sub, '*': operator.mul, '/': operator.truediv}\n return [table[op](a, b) for op in ops]","input":"apply_ops(10, 4, ['+', '-', '*', '/'])","language":"Python","predicted_output":"[14, 6, 40, 2.5]"} |
| {"id":"cmswrta8f007puvp2fmvj1luy","kind":"contributor_item","title":"Submission VJ1LUY","provisional":false,"code":"from enum import Enum, auto\n\nclass Direction(Enum):\n NORTH = auto()\n EAST = auto()\n SOUTH = auto()\n WEST = auto()\n\ndef turn_right(d):\n order = [Direction.NORTH, Direction.EAST, Direction.SOUTH, Direction.WEST]\n idx = order.index(d)\n return order[(idx + 1) % 4]","input":"turn_right(Direction.WEST)","language":"Python","predicted_output":"Direction.NORTH"} |
| {"id":"cmswrta8f007luvp2eco0fl0y","kind":"contributor_item","title":"Submission O0FL0Y","provisional":false,"code":"from itertools import permutations\ndef unique_arrangements(s):\n return sorted(set(''.join(p) for p in permutations(s)))","input":"unique_arrangements('aab')","language":"Python","predicted_output":"['aab', 'aba', 'baa']"} |
| {"id":"cmswrtj5p007ruvp21yxefhfo","kind":"contributor_item","title":"Submission XEFHFO","provisional":false,"code":"import textwrap\ndef wrap_and_count(text, width):\n lines = textwrap.wrap(text, width=width)\n return (len(lines), lines)","input":"wrap_and_count('the quick brown fox jumps over the lazy dog', 12)","language":"Python","predicted_output":"(4, ['the quick', 'brown fox', 'jumps over', 'the lazy dog'])"} |
| {"id":"cmswrtj5p007suvp2jk990d3h","kind":"contributor_item","title":"Submission 990D3H","provisional":false,"code":"from decimal import Decimal, ROUND_HALF_UP\ndef price_with_tax(price_str, rate_str):\n price = Decimal(price_str)\n rate = Decimal(rate_str)\n total = price * (1 + rate)\n return str(total.quantize(Decimal('0.01'), rounding=ROUND_HALF_UP))","input":"price_with_tax('19.99', '0.0825')","language":"Python","predicted_output":"21.64"} |
| {"id":"cmswrtj5p007tuvp20r884nfq","kind":"contributor_item","title":"Submission 884NFQ","provisional":false,"code":"from fractions import Fraction\ndef sum_fractions(pairs):\n total = Fraction(0)\n for num, den in pairs:\n total += Fraction(num, den)\n return total","input":"sum_fractions([(1, 3), (1, 6), (1, 2)])","language":"Python","predicted_output":"1"} |
| {"id":"cmswrtj5p007uuvp2dwtmyclc","kind":"contributor_item","title":"Submission TMYCLC","provisional":false,"code":"class Resource:\n def __init__(self, name):\n self.name = name\n self.log = []\n\n def __enter__(self):\n self.log.append(f\"open {self.name}\")\n return self\n\n def __exit__(self, exc_type, exc_val, exc_tb):\n self.log.append(f\"close {self.name}\")\n return True\n\ndef use_resource():\n r = Resource(\"db\")\n with r:\n r.log.append(\"working\")\n raise ValueError(\"boom\")\n return r.log","input":"use_resource()","language":"Python","predicted_output":"['open db', 'working', 'close db']"} |
| {"id":"cmswrtqie007wuvp2lr0dkgcx","kind":"contributor_item","title":"Submission 0DKGCX","provisional":false,"code":"class A:\n def greet(self):\n return \"A\"\n\nclass B(A):\n def greet(self):\n return \"B->\" + super().greet()\n\nclass C(A):\n def greet(self):\n return \"C->\" + super().greet()\n\nclass D(B, C):\n def greet(self):\n return \"D->\" + super().greet()\n\ndef mro_greeting():\n return D().greet()","input":"mro_greeting()","language":"Python","predicted_output":"D->B->C->A"} |
| {"id":"cmswrtqie007xuvp2eyji5guc","kind":"contributor_item","title":"Submission JI5GUC","provisional":false,"code":"from itertools import filterfalse\n\ndef partition_by_predicate(nums, pred):\n matches = list(filter(pred, nums))\n non_matches = list(filterfalse(pred, nums))\n return (matches, non_matches)","input":"partition_by_predicate([1, 2, 3, 4, 5, 6, 7, 8], lambda n: n % 3 == 0)","language":"Python","predicted_output":"([3, 6], [1, 2, 4, 5, 7, 8])"} |
| {"id":"cmswrtqie007yuvp24oj7ep6a","kind":"contributor_item","title":"Submission J7EP6A","provisional":false,"code":"def first_and_rest(items):\n first, *rest = items\n *init, last = rest\n return (first, init, last)","input":"first_and_rest([10, 20, 30, 40, 50])","language":"Python","predicted_output":"(10, [20, 30, 40], 50)"} |
| {"id":"cmswrtqid007vuvp2rj1h11os","kind":"contributor_item","title":"Submission 1H11OS","provisional":false,"code":"class Circle:\n def __init__(self, radius):\n self._radius = radius\n\n @property\n def radius(self):\n return self._radius\n\n @radius.setter\n def radius(self, value):\n if value < 0:\n raise ValueError(\"radius must be non-negative\")\n self._radius = value\n\n @property\n def area(self):\n return round(3.14159 * self._radius ** 2, 2)\n\ndef resize_and_area(r, new_radius):\n c = Circle(r)\n c.radius = new_radius\n return c.area","input":"resize_and_area(5, 3)","language":"Python","predicted_output":"28.27"} |
| {"id":"cmswrtqie007zuvp2390lz77p","kind":"contributor_item","title":"Submission 0LZ77P","provisional":false,"code":"def make_multipliers():\n return [lambda x, i=i: x * i for i in range(4)]\n\ndef apply_all(x):\n fns = make_multipliers()\n return [f(x) for f in fns]","input":"apply_all(3)","language":"Python","predicted_output":"[0, 3, 6, 9]"} |
| {"id":"cmswrtvsk0081uvp27q6b7rnj","kind":"contributor_item","title":"Submission 6B7RNJ","provisional":false,"code":"from functools import lru_cache\n\n@lru_cache(maxsize=None)\ndef digit_sum(n):\n if n < 10:\n return n\n return n % 10 + digit_sum(n // 10)\n\n@lru_cache(maxsize=None)\ndef repeated_digit_sum(n):\n while n >= 10:\n n = digit_sum(n)\n return n","input":"repeated_digit_sum(9875)","language":"Python","predicted_output":"2"} |
| {"id":"cmswru6ev0084uvp2f34u6age","kind":"contributor_item","title":"Submission 4U6AGE","provisional":false,"code":"def all_ascending(nums):\n return all(a < b for a, b in zip(nums, nums[1:]))\n\ndef any_negative(nums):\n return any(n < 0 for n in nums)\n\ndef check_list(nums):\n return (all_ascending(nums), any_negative(nums))","input":"check_list([1, 3, 5, 4, -2])","language":"Python","predicted_output":"(False, True)"} |
| {"id":"cmswruw3r0086uvp2xxkurg56","kind":"contributor_item","title":"Submission KURG56","provisional":false,"code":"import random\ndef deterministic_shuffle(items, seed):\n rng = random.Random(seed)\n items = list(items)\n rng.shuffle(items)\n return items","input":"deterministic_shuffle([1, 2, 3, 4, 5], 42)","language":"Python","predicted_output":"[4, 2, 3, 5, 1]"} |
| {"id":"cmswzw85l00cuuvp2deb6mh6t","kind":"contributor_item","title":"Submission B6MH6T","provisional":false,"code":"def normalize_ports(tokens):\n ports = []\n for token in tokens:\n try:\n ports.append(int(token))\n except ValueError:\n ports.append(-1)\n else:\n if ports[-1] > 1024:\n ports[-1] = 1024\n finally:\n if ports[-1] == 0:\n ports.pop()\n return ports","input":"normalize_ports(['80', 'http', '65535', '0', '1024'])","language":"Python","predicted_output":"[80, -1, 1024, 1024]"} |
| {"id":"cmswzw85l00ctuvp2jwiq4hvp","kind":"contributor_item","title":"Submission IQ4HVP","provisional":false,"code":"def accumulate(pairs, store={}):\n for key, value in pairs:\n store.setdefault(key, []).append(value)\n return dict(store)","input":"(accumulate([('a', 1), ('b', 2)]), accumulate([('a', 3)]))","language":"Python","predicted_output":"({'a': [1, 3], 'b': [2]}, {'a': [1, 3], 'b': [2]})"} |
| {"id":"cmswzw85l00cwuvp2o78uxhev","kind":"contributor_item","title":"Submission 8UXHEV","provisional":false,"code":"from datetime import datetime, timedelta\n\ndef window_labels(start, count, minutes):\n base = datetime.strptime(start, '%Y-%m-%d %H:%M')\n return [(base + timedelta(minutes=minutes * step)).strftime('%d/%H:%M') for step in range(count)]","input":"window_labels('2026-02-28 23:20', 4, 25)","language":"Python","predicted_output":"['28/23:20', '28/23:45', '01/00:10', '01/00:35']"} |
| {"id":"cmswzw85l00cvuvp2t7q436b8","kind":"contributor_item","title":"Submission Q436B8","provisional":false,"code":"from itertools import groupby\n\ndef collapse_runs(records):\n summary = []\n for level, group in groupby(records, key=lambda record: record['level']):\n summary.append((level, sum(1 for _ in group)))\n return summary","input":"collapse_runs([{'level': 'INFO'}, {'level': 'INFO'}, {'level': 'WARN'}, {'level': 'INFO'}])","language":"Python","predicted_output":"[('INFO', 2), ('WARN', 1), ('INFO', 1)]"} |
| {"id":"cmswzw85l00cxuvp2gfqke4xn","kind":"contributor_item","title":"Submission QKE4XN","provisional":false,"code":"def competition_ranks(scores):\n ordered = sorted(scores.items(), key=lambda pair: (-pair[1], pair[0]))\n ranks = {}\n previous_score = None\n current_rank = 0\n for position, (name, score) in enumerate(ordered, start=1):\n if score != previous_score:\n current_rank = position\n previous_score = score\n ranks[name] = current_rank\n return ranks","input":"competition_ranks({'ana': 90, 'bo': 95, 'cy': 90, 'di': 80})","language":"Python","predicted_output":"{'bo': 1, 'ana': 2, 'cy': 2, 'di': 4}"} |
| {"id":"cmsx35cwm0002x3p2xv9ydh3o","kind":"contributor_item","title":"Submission 9YDH3O","provisional":false,"code":"class Shape:\n def area(self):\n raise NotImplementedError\n\nclass Rectangle(Shape):\n def __init__(self, w, h):\n self.w = w\n self.h = h\n def area(self):\n return self.w * self.h\n\nclass Circle(Shape):\n def __init__(self, r):\n self.r = r\n def area(self):\n return round(3.14159 * self.r * self.r, 2)\n\ndef total_area(shapes):\n return sum(s.area() for s in shapes)","input":"total_area([Rectangle(3, 4), Circle(2), Rectangle(5, 5)])","language":"Python","predicted_output":"49.57"} |
| {"id":"cmsx35cwm0000x3p25q4cap3o","kind":"contributor_item","title":"Submission 4CAP3O","provisional":false,"code":"class SkipMultiples:\n def __init__(self, limit, n):\n self.limit = limit\n self.n = n\n self.current = 0\n def __iter__(self):\n return self\n def __next__(self):\n while self.current < self.limit:\n self.current += 1\n if self.current % self.n != 0:\n return self.current\n raise StopIteration\n\ndef collect(limit, n):\n return list(SkipMultiples(limit, n))","input":"collect(15, 3)","language":"Python","predicted_output":"[1, 2, 4, 5, 7, 8, 10, 11, 13, 14]"} |
| {"id":"cmsx35cwn0008x3p2gbkl82fo","kind":"contributor_item","title":"Submission KL82FO","provisional":false,"code":"def slice_report(s):\n return {\n 'reverse': s[::-1],\n 'every_other': s[::2],\n 'middle': s[2:-2],\n 'oob_high': s[100:200],\n 'neg_step_range': s[8:2:-1],\n }","input":"slice_report('abcdefghij')","language":"Python","predicted_output":"{'reverse': 'jihgfedcba', 'every_other': 'acegi', 'middle': 'cdefgh', 'oob_high': '', 'neg_step_range': 'ihgfed'}"} |
| {"id":"cmsx35cwm0004x3p2se7oe3wm","kind":"contributor_item","title":"Submission 7OE3WM","provisional":false,"code":"from functools import reduce\n\ndef running_max_index(nums):\n def combine(acc, pair):\n idx, val = pair\n best_idx, best_val, results = acc\n if val > best_val:\n best_idx, best_val = idx, val\n results = results + [(best_idx, best_val)]\n return best_idx, best_val, results\n _, _, results = reduce(combine, enumerate(nums), (-1, float('-inf'), []))\n return results","input":"running_max_index([3, 1, 4, 1, 5, 9, 2, 6])","language":"Python","predicted_output":"[(0, 3), (0, 3), (2, 4), (2, 4), (4, 5), (5, 9), (5, 9), (5, 9)]"} |
| {"id":"cmsx35cwm0006x3p2rst9h4qv","kind":"contributor_item","title":"Submission T9H4QV","provisional":false,"code":"class Version:\n def __init__(self, major, minor, patch):\n self.major = major\n self.minor = minor\n self.patch = patch\n def __eq__(self, other):\n return (self.major, self.minor, self.patch) == (other.major, other.minor, other.patch)\n def __lt__(self, other):\n return (self.major, self.minor, self.patch) < (other.major, other.minor, other.patch)\n def __repr__(self):\n return f'{self.major}.{self.minor}.{self.patch}'\n\ndef sort_versions(versions):\n return sorted(versions)","input":"sort_versions([Version(1, 2, 0), Version(1, 10, 0), Version(1, 2, 3), Version(0, 9, 9)])","language":"Python","predicted_output":"[0.9.9, 1.2.0, 1.2.3, 1.10.0]"} |
| {"id":"cmsx35cwn0007x3p2jusawql0","kind":"contributor_item","title":"Submission SAWQL0","provisional":false,"code":"def safe_divider(pairs):\n for a, b in pairs:\n try:\n yield a / b\n except ZeroDivisionError:\n yield None\n\ndef run_divisions(pairs):\n return list(safe_divider(pairs))","input":"run_divisions([(10, 2), (5, 0), (9, 3), (1, 0)])","language":"Python","predicted_output":"[5.0, None, 3.0, None]"} |
| {"id":"cmsx35cwn0009x3p2i1qo2kew","kind":"contributor_item","title":"Submission QO2KEW","provisional":false,"code":"class Node:\n def __init__(self, value, nxt=None):\n self.value = value\n self.nxt = nxt\n\ndef build_list(values):\n head = None\n for v in reversed(values):\n head = Node(v, head)\n return head\n\ndef reverse_recursive(node, prev=None):\n if node is None:\n return prev\n nxt = node.nxt\n node.nxt = prev\n return reverse_recursive(nxt, node)\n\ndef to_list(head):\n out = []\n while head is not None:\n out.append(head.value)\n head = head.nxt\n return out\n\ndef run_reverse(values):\n head = build_list(values)\n reversed_head = reverse_recursive(head)\n return to_list(reversed_head)","input":"run_reverse([1, 2, 3, 4, 5])","language":"Python","predicted_output":"[5, 4, 3, 2, 1]"} |
| {"id":"cmsx36tfl000ax3p2e7c1vsqw","kind":"contributor_item","title":"Submission C1VSQW","provisional":false,"code":"def make_account(balance):\n history = []\n def deposit(amount):\n nonlocal balance\n balance += amount\n history.append(('deposit', amount, balance))\n return balance\n def withdraw(amount):\n nonlocal balance\n if amount > balance:\n history.append(('rejected', amount, balance))\n return None\n balance -= amount\n history.append(('withdraw', amount, balance))\n return balance\n def get_history():\n return history\n return deposit, withdraw, get_history","input":"(lambda: (lambda d, w, h: (d(50), w(30), w(1000), d(10), h()))(*make_account(100)))()","language":"Python","predicted_output":"(150, 120, None, 130, [('deposit', 50, 150), ('withdraw', 30, 120), ('rejected', 1000, 120), ('deposit', 10, 130)])"} |
| {"id":"cmsx373zl000cx3p2drgjnea1","kind":"contributor_item","title":"Submission GJNEA1","provisional":false,"code":"def flatten(items):\n result = []\n for item in items:\n if isinstance(item, list):\n result.extend(flatten(item))\n else:\n result.append(item)\n return result","input":"flatten([1, [2, 3, [4, [5, 6], 7]], 8, [], [9]])","language":"Python","predicted_output":"[1, 2, 3, 4, 5, 6, 7, 8, 9]"} |
| {"id":"cmsx374iy000dx3p2rdut569v","kind":"contributor_item","title":"Submission UT569V","provisional":false,"code":"def add_item(item, bucket=[]):\n bucket.append(item)\n return bucket\n\ndef run_trap():\n first = add_item(1)\n second = add_item(2)\n third = add_item(3, [])\n return first, second, third, first is second","input":"run_trap()","language":"Python","predicted_output":"([1, 2], [1, 2], [3], True)"} |
| {"id":"cmsx375kr000gx3p2l779uvhz","kind":"contributor_item","title":"Submission 79UVHZ","provisional":false,"code":"def memoize(func):\n cache = {}\n calls = [0]\n def wrapper(n):\n calls[0] += 1\n if n not in cache:\n cache[n] = func(n)\n return cache[n]\n wrapper.calls = calls\n return wrapper\n\n@memoize\ndef fib(n):\n if n < 2:\n return n\n return fib(n - 1) + fib(n - 2)\n\ndef run_fib(n):\n result = fib(n)\n return result, fib.calls[0]","input":"run_fib(10)","language":"Python","predicted_output":"(55, 19)"} |
| {"id":"cmsx38p48000jx3p2spzz8jpr","kind":"contributor_item","title":"Submission ZZ8JPR","provisional":false,"code":"class Suppress:\n def __init__(self, exc_type):\n self.exc_type = exc_type\n self.suppressed = False\n def __enter__(self):\n return self\n def __exit__(self, exc_type, exc_val, exc_tb):\n if exc_type is not None and issubclass(exc_type, self.exc_type):\n self.suppressed = True\n return True\n return False\n\ndef run_block(will_raise, exc_kind):\n s = Suppress(ValueError)\n with s:\n if will_raise:\n if exc_kind == 'value':\n raise ValueError('bad value')\n else:\n raise TypeError('bad type')\n return s.suppressed\n\ndef run_suppress_demo():\n return [run_block(True, 'value'), run_block(False, 'value')]","input":"run_suppress_demo()","language":"Python","predicted_output":"[True, False]"} |
| {"id":"cmsx38p48000hx3p2z4sklufy","kind":"contributor_item","title":"Submission SKLUFY","provisional":false,"code":"class InsufficientFundsError(Exception):\n pass\n\ndef process_payment(balance, amount):\n log = []\n try:\n if amount <= 0:\n raise ValueError(\"amount must be positive\")\n if amount > balance:\n raise InsufficientFundsError(f\"need {amount - balance} more\")\n balance -= amount\n except ValueError as e:\n log.append(f\"value_error:{e}\")\n except InsufficientFundsError as e:\n log.append(f\"insufficient:{e}\")\n else:\n log.append(f\"success:{balance}\")\n finally:\n log.append(\"done\")\n return log\n\ndef run_payments():\n return [process_payment(100, 50), process_payment(100, -5), process_payment(100, 500)]","input":"run_payments()","language":"Python","predicted_output":"[['success:50', 'done'], ['value_error:amount must be positive', 'done'], ['insufficient:need 400 more', 'done']]"} |
| {"id":"cmsxkh6jg00f7kup2eddnae88","kind":"contributor_item","title":"Submission DNAE88","provisional":false,"code":"def reconcile(events):\n stock = {}\n rejected = []\n for sku, delta in events:\n current = stock.get(sku, 0)\n if current + delta < 0:\n rejected.append((sku, delta, current))\n else:\n stock[sku] = current + delta\n return dict(sorted(stock.items())), rejected","input":"reconcile([('A', 5), ('B', 2), ('A', -7), ('A', -2), ('C', -1)])","language":"Python","predicted_output":"({'A': 3, 'B': 2}, [('A', -7, 5), ('C', -1, 0)])"} |
| {"id":"cmsxkh6jg00f8kup2qnzeb2j0","kind":"contributor_item","title":"Submission ZEB2J0","provisional":false,"code":"from collections import deque\n\ndef rolling_windows(values, width):\n window = deque()\n total = 0\n result = []\n for value in values:\n window.append(value)\n total += value\n if len(window) > width:\n total -= window.popleft()\n if len(window) == width:\n result.append((window[0], window[-1], total))\n return result","input":"rolling_windows([4, -1, 3, 7, -2], 3)","language":"Python","predicted_output":"[(4, 3, 6), (-1, 7, 9), (3, -2, 8)]"} |
| {"id":"cmsxkh6jh00fckup23bczfrda","kind":"contributor_item","title":"Submission CZFRDA","provisional":false,"code":"def trace_aliases(mapping, names):\n result = {}\n for start in names:\n path = []\n node = start\n while node in mapping and node not in path:\n path.append(node)\n node = mapping[node]\n if node in path:\n cycle = path[path.index(node):]\n result[start] = ('cycle', tuple(cycle))\n else:\n result[start] = ('target', node)\n return result","input":"trace_aliases({'api': 'service', 'service': 'v2', 'old': 'legacy', 'legacy': 'old'}, ['api', 'old', 'missing'])","language":"Python","predicted_output":"{'api': ('target', 'v2'), 'old': ('cycle', ('old', 'legacy')), 'missing': ('target', 'missing')}"} |
| {"id":"cmsxkh6jh00fekup228aurw2t","kind":"contributor_item","title":"Submission AURW2T","provisional":false,"code":"def compact_bookings(bookings):\n merged = []\n for room, start, end in sorted(bookings):\n if merged and merged[-1][0] == room and start <= merged[-1][2]:\n old_room, old_start, old_end = merged[-1]\n merged[-1] = (old_room, old_start, max(old_end, end))\n else:\n merged.append((room, start, end))\n return merged","input":"compact_bookings([('B', 5, 8), ('A', 1, 3), ('A', 3, 6), ('B', 1, 2), ('A', 8, 9), ('B', 7, 10)])","language":"Python","predicted_output":"[('A', 1, 6), ('A', 8, 9), ('B', 1, 2), ('B', 5, 10)]"} |
| {"id":"cmsxkh6jh00ffkup2y8txjicf","kind":"contributor_item","title":"Submission TXJICF","provisional":false,"code":"def session_durations(events):\n active = {}\n durations = {}\n anomalies = []\n for user, minute, action in events:\n if action == 'login':\n if user in active:\n anomalies.append((user, 'duplicate_login', minute))\n else:\n active[user] = minute\n elif action == 'logout':\n if user not in active:\n anomalies.append((user, 'orphan_logout', minute))\n else:\n durations.setdefault(user, []).append(minute - active.pop(user))\n return dict(sorted(durations.items())), anomalies, dict(sorted(active.items()))","input":"session_durations([('ana', 2, 'login'), ('bo', 4, 'logout'), ('ana', 7, 'login'), ('ana', 12, 'logout'), ('bo', 15, 'login')])","language":"Python","predicted_output":"({'ana': [10]}, [('bo', 'orphan_logout', 4), ('ana', 'duplicate_login', 7)], {'bo': 15})"} |
| {"id":"cmsxkh6jh00fakup2rs29u4sc","kind":"contributor_item","title":"Submission 29U4SC","provisional":false,"code":"def allocate(requests, capacities):\n remaining = capacities.copy()\n allocations = []\n for team, resource, amount in requests:\n available = remaining.get(resource, 0)\n granted = min(max(amount, 0), available)\n if granted:\n allocations.append((team, resource, granted))\n remaining[resource] = available - granted\n return allocations, dict(sorted(remaining.items()))","input":"allocate([('red', 'cpu', 3), ('blue', 'cpu', 4), ('red', 'gpu', 2), ('green', 'ram', 1), ('blue', 'gpu', -1)], {'cpu': 5, 'gpu': 1})","language":"Python","predicted_output":"([('red', 'cpu', 3), ('blue', 'cpu', 2), ('red', 'gpu', 1)], {'cpu': 0, 'gpu': 0})"} |
| {"id":"cmsxkh6jh00f9kup2fdgtsmmt","kind":"contributor_item","title":"Submission GTSMMT","provisional":false,"code":"def coerce_rows(rows, schema):\n result = []\n errors = []\n for index, row in enumerate(rows):\n clean = {}\n for field, kind in schema.items():\n value = row.get(field)\n try:\n if kind == 'int':\n clean[field] = int(value)\n elif kind == 'float':\n clean[field] = round(float(value), 2)\n elif kind == 'bool':\n lowered = str(value).lower()\n if lowered not in ('yes', 'no'):\n raise ValueError\n clean[field] = lowered == 'yes'\n except (TypeError, ValueError):\n clean[field] = None\n errors.append((index, field, value))\n result.append(clean)\n return result, errors","input":"coerce_rows([{'age': '30', 'score': '8.256', 'active': 'yes'}, {'age': 'x', 'score': 4, 'active': 'maybe'}, {'age': 0, 'score': None, 'active': 'no'}], {'age': 'int', 'score': 'float', 'active': 'bool'})","language":"Python","predicted_output":"([{'age': 30, 'score': 8.26, 'active': True}, {'age': None, 'score': 4.0, 'active': None}, {'age': 0, 'score': None, 'active': False}], [(1, 'age', 'x'), (1, 'active', 'maybe'), (2, 'score', None)])"} |
| {"id":"cmsxkh6jh00fbkup2cqdur2dn","kind":"contributor_item","title":"Submission DUR2DN","provisional":false,"code":"def retry_summary(jobs, limit):\n summary = {}\n exhausted = []\n for name in sorted(jobs):\n attempts = 0\n succeeded = False\n for outcome in jobs[name][:limit]:\n attempts += 1\n if outcome:\n succeeded = True\n break\n summary[name] = (attempts, succeeded)\n if not succeeded:\n exhausted.append(name)\n return summary, exhausted","input":"retry_summary({'sync': [False, True, True], 'backup': [False, False, True], 'email': [True]}, 2)","language":"Python","predicted_output":"({'backup': (2, False), 'email': (1, True), 'sync': (2, True)}, ['backup'])"} |
| {"id":"cmsxkh6jh00fdkup2g9iug9xn","kind":"contributor_item","title":"Submission IUG9XN","provisional":false,"code":"def settle(entries, overdraft_fee=5):\n balances = {}\n alerts = []\n for account, amount in entries:\n before = balances.get(account, 0)\n after = before + amount\n if amount < 0 and after < 0:\n after -= overdraft_fee\n alerts.append((account, before, amount, after))\n balances[account] = after\n return dict(sorted(balances.items())), alerts","input":"settle([('A', 20), ('B', -3), ('A', -25), ('B', 10), ('A', 15)])","language":"Python","predicted_output":"({'A': 5, 'B': 2}, [('B', 0, -3, -8), ('A', 20, -25, -10)])"} |
| {"id":"cmsxkh6jh00fgkup2qxick56s","kind":"contributor_item","title":"Submission ICK56S","provisional":false,"code":"import copy\n\ndef apply_patches(document, patches):\n result = copy.deepcopy(document)\n applied = []\n rejected = []\n for path, value in patches:\n keys = path.split('.')\n current = result\n valid = True\n for key in keys[:-1]:\n if key not in current:\n current[key] = {}\n if not isinstance(current[key], dict):\n valid = False\n break\n current = current[key]\n if valid:\n current[keys[-1]] = value\n applied.append(path)\n else:\n rejected.append(path)\n return result, applied, rejected","input":"apply_patches({'user': {'name': 'Mira'}, 'version': 2}, [('user.active', True), ('settings.theme', 'dark'), ('version.major', 3), ('user.name', 'M')])","language":"Python","predicted_output":"({'user': {'name': 'M', 'active': True}, 'version': 2, 'settings': {'theme': 'dark'}}, ['user.active', 'settings.theme', 'user.name'], ['version.major'])"} |
|
|