prompt
large_stringlengths
72
2.74k
completion
large_stringlengths
1
1.34k
category
large_stringclasses
13 values
meta
large_stringlengths
0
571
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def count_divisors(n): """Return the number of positive divisors of the positive integer ``n`` (including 1 and ``n`` itself). """ <|im_end|> <|im_start|>assistant <think> </think...
# solution return sum(1 for k in range(1, n + 1) if n % k == 0)
code_bench
{"entry_point": "count_divisors", "raw_prompt": "def count_divisors(n):\n \"\"\"Return the number of positive divisors of the positive integer ``n`` (including 1 and ``n`` itself).\n \"\"\"\n", "test": "def check(candidate):\n assert candidate(712) == 8\n assert candidate(797) == 2\n assert candidate(281...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def transform(xs): """Return a new list where every element of ``xs`` is incremented by 7. >>> transform([1, 2, 3]) [8, 9, 10] """ <|im_end|> <|im_start|>assistant <think>...
# solution return [x + 7 for x in xs]
code_bench
{"entry_point": "transform", "raw_prompt": "def transform(xs):\n \"\"\"Return a new list where every element of ``xs`` is incremented by 7.\n\n >>> transform([1, 2, 3])\n [8, 9, 10]\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([-5, -6, -3]) == [2, 1, 4]\n assert candidate([-6, 5, -6,...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def pair_count(xs): """Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 12``. """ <|im_end|> <|im_start|>assistant <think> </think>
# solution count = 0 for i in range(len(xs)): for j in range(i + 1, len(xs)): if xs[i] + xs[j] == 12: count += 1 return count
code_bench
{"entry_point": "pair_count", "raw_prompt": "def pair_count(xs):\n \"\"\"Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 12``.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([7, 9, 2]) == 0\n assert candidate([11, 4, 9, 8, 7, 1, 5]) == 3\n assert candid...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def repeat_chars(s): """Return a string where every character of ``s`` is repeated 2 times in place. ``repeat_chars('ab')`` is ``'aabb'``. """ <|im_end|> <|im_start|>assistant <thi...
# solution return "".join(c * 2 for c in s)
code_bench
{"entry_point": "repeat_chars", "raw_prompt": "def repeat_chars(s):\n \"\"\"Return a string where every character of ``s`` is repeated 2 times in place. ``repeat_chars('ab')`` is ``'aabb'``.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate('bAd') == 'bbAAdd'\n assert candidate('a') == 'aa'\n ...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def transform(xs): """Return a list where every element of ``xs`` is negated. >>> transform([1, -2, 3]) [-1, 2, -3] """ <|im_end|> <|im_start|>assistant <think> </think> ...
# solution return [-x for x in xs]
code_bench
{"entry_point": "transform", "raw_prompt": "def transform(xs):\n \"\"\"Return a list where every element of ``xs`` is negated.\n\n >>> transform([1, -2, 3])\n [-1, 2, -3]\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([0, 7, 1, -8, 2]) == [0, -7, -1, 8, -2]\n assert candidate([-2, -9])...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def pair_count(xs): """Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 12``. """ <|im_end|> <|im_start|>assistant <think> </think>
# solution count = 0 for i in range(len(xs)): for j in range(i + 1, len(xs)): if xs[i] + xs[j] == 12: count += 1 return count
code_bench
{"entry_point": "pair_count", "raw_prompt": "def pair_count(xs):\n \"\"\"Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 12``.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([7, 9, 2]) == 0\n assert candidate([11, 4, 9, 8, 7, 1, 5]) == 3\n assert candid...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def count_divisors(n): """Return the number of positive divisors of the positive integer ``n`` (including 1 and ``n`` itself). """ <|im_end|> <|im_start|>assistant <think> </think...
# solution return sum(1 for k in range(1, n + 1) if n % k == 0)
code_bench
{"entry_point": "count_divisors", "raw_prompt": "def count_divisors(n):\n \"\"\"Return the number of positive divisors of the positive integer ``n`` (including 1 and ``n`` itself).\n \"\"\"\n", "test": "def check(candidate):\n assert candidate(712) == 8\n assert candidate(797) == 2\n assert candidate(281...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def pair_count(xs): """Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 5``. """ <|im_end|> <|im_start|>assistant <think> </think>
# solution count = 0 for i in range(len(xs)): for j in range(i + 1, len(xs)): if xs[i] + xs[j] == 5: count += 1 return count
code_bench
{"entry_point": "pair_count", "raw_prompt": "def pair_count(xs):\n \"\"\"Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 5``.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([1, 5, 1, 3, 0, 4]) == 3\n assert candidate([3, 2, 2, 4]) == 2\n assert candidat...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def digit_sum(n): """Return the sum of the decimal digits of the non-negative integer ``n``. ``digit_sum(0)`` is 0. """ <|im_end|> <|im_start|>assistant <think> </think>
# solution return sum(int(d) for d in str(n))
code_bench
{"entry_point": "digit_sum", "raw_prompt": "def digit_sum(n):\n \"\"\"Return the sum of the decimal digits of the non-negative integer ``n``. ``digit_sum(0)`` is 0.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate(183) == 12\n assert candidate(704) == 11\n assert candidate(823) == 13\n a...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def pair_count(xs): """Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 6``. """ <|im_end|> <|im_start|>assistant <think> </think>
# solution count = 0 for i in range(len(xs)): for j in range(i + 1, len(xs)): if xs[i] + xs[j] == 6: count += 1 return count
code_bench
{"entry_point": "pair_count", "raw_prompt": "def pair_count(xs):\n \"\"\"Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 6``.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([3, 6, 0, 4]) == 1\n assert candidate([4, 2, 5, 6]) == 1\n assert candidate([1, ...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def pair_count(xs): """Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 9``. """ <|im_end|> <|im_start|>assistant <think> </think>
# solution count = 0 for i in range(len(xs)): for j in range(i + 1, len(xs)): if xs[i] + xs[j] == 9: count += 1 return count
code_bench
{"entry_point": "pair_count", "raw_prompt": "def pair_count(xs):\n \"\"\"Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 9``.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([3, 8, 6]) == 1\n assert candidate([4, 1, 1]) == 0\n assert candidate([0, 1, 1, ...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def pair_count(xs): """Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 6``. """ <|im_end|> <|im_start|>assistant <think> </think>
# solution count = 0 for i in range(len(xs)): for j in range(i + 1, len(xs)): if xs[i] + xs[j] == 6: count += 1 return count
code_bench
{"entry_point": "pair_count", "raw_prompt": "def pair_count(xs):\n \"\"\"Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 6``.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([3, 6, 0, 4]) == 1\n assert candidate([4, 2, 5, 6]) == 1\n assert candidate([1, ...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def is_balanced(s): """Return True if every '(' in ``s`` has a matching ')' to its right and the brackets are properly nested. Other characters are ignored. The empty string is balance...
# solution depth = 0 for c in s: if c == '(': depth += 1 elif c == ')': depth -= 1 if depth < 0: return False return depth == 0
code_bench
{"entry_point": "is_balanced", "raw_prompt": "def is_balanced(s):\n \"\"\"Return True if every '(' in ``s`` has a matching ')' to its right and the brackets are properly nested. Other characters are ignored. The empty string is balanced.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate('') == Tru...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def window_max_sum(xs, k): """Return the maximum sum of any contiguous window of exactly ``k`` consecutive elements in the list ``xs``. If ``k`` is larger than the length of ``xs`` or ...
# solution if not xs or k > len(xs) or k <= 0: return 0 return max(sum(xs[i:i + k]) for i in range(len(xs) - k + 1))
code_bench
{"entry_point": "window_max_sum", "raw_prompt": "def window_max_sum(xs, k):\n \"\"\"Return the maximum sum of any contiguous window of exactly ``k`` consecutive elements in the list ``xs``. If ``k`` is larger than the length of ``xs`` or ``xs`` is empty, return 0.\n \"\"\"\n", "test": "def check(candidate):\n ...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def transform(xs): """Return a list where every element of ``xs`` is doubled. >>> transform([1, 2, 3]) [2, 4, 6] """ <|im_end|> <|im_start|>assistant <think> </think>
# solution return [x * 2 for x in xs]
code_bench
{"entry_point": "transform", "raw_prompt": "def transform(xs):\n \"\"\"Return a list where every element of ``xs`` is doubled.\n\n >>> transform([1, 2, 3])\n [2, 4, 6]\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([-7, -4, -1, 6, 5, 1]) == [-14, -8, -2, 12, 10, 2]\n assert candidate([...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def alternate_case(s): """Return a new string where the i-th letter is uppercased for even i (0, 2, 4, ...) and lowercased for odd i. Non-letter characters are passed through unchanged...
# solution return "".join(ch.upper() if i % 2 == 0 else ch.lower() for i, ch in enumerate(s))
code_bench
{"entry_point": "alternate_case", "raw_prompt": "def alternate_case(s):\n \"\"\"Return a new string where the i-th letter is uppercased for even i (0, 2, 4, ...) and lowercased for odd i. Non-letter characters are passed through unchanged. Indexes count all characters, including non-letters.\n \"\"\"\n", "test": ...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def repeat_chars(s): """Return a string where every character of ``s`` is repeated 4 times in place. ``repeat_chars('ab')`` is ``'aaaabbbb'``. """ <|im_end|> <|im_start|>assistant ...
# solution return "".join(c * 4 for c in s)
code_bench
{"entry_point": "repeat_chars", "raw_prompt": "def repeat_chars(s):\n \"\"\"Return a string where every character of ``s`` is repeated 4 times in place. ``repeat_chars('ab')`` is ``'aaaabbbb'``.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate('A2') == 'AAAA2222'\n assert candidate('feF!') == ...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def pair_count(xs): """Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 10``. """ <|im_end|> <|im_start|>assistant <think> </think>
# solution count = 0 for i in range(len(xs)): for j in range(i + 1, len(xs)): if xs[i] + xs[j] == 10: count += 1 return count
code_bench
{"entry_point": "pair_count", "raw_prompt": "def pair_count(xs):\n \"\"\"Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 10``.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([5, 2, 4]) == 0\n assert candidate([5, 2, 6, 4, 5, 4, 2]) == 3\n assert candida...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def aggregate(xs): """Return the number of strictly positive elements of ``xs``. """ <|im_end|> <|im_start|>assistant <think> </think>
# solution return sum(1 for x in xs if x > 0)
code_bench
{"entry_point": "aggregate", "raw_prompt": "def aggregate(xs):\n \"\"\"Return the number of strictly positive elements of ``xs``.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([-7, -5, -3, -5]) == 0\n assert candidate([-7, 4, 4, 1, -5, 2, -5]) == 4\n assert candidate([-5, -1, 4, 0, -5, -...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def rle(s): """Return the run-length encoding of the string ``s`` as a list of (char, count) tuples. ``rle('')`` is ``[]``. ``rle('aaabb')`` is ``[('a', 3), ('b', 2)]``. """ <|im_e...
# solution if not s: return [] pairs = [] cur = s[0] cnt = 1 for ch in s[1:]: if ch == cur: cnt += 1 else: pairs.append((cur, cnt)) cur = ch cnt = 1 pairs.append((cur, cnt)) return pairs
code_bench
{"entry_point": "rle", "raw_prompt": "def rle(s):\n \"\"\"Return the run-length encoding of the string ``s`` as a list of (char, count) tuples. ``rle('')`` is ``[]``. ``rle('aaabb')`` is ``[('a', 3), ('b', 2)]``.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate('aabbb') == [('a', 2), ('b', 3)]\n ...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def transform(xs): """Return a new list where every element of ``xs`` is incremented by 2. >>> transform([1, 2, 3]) [3, 4, 5] """ <|im_end|> <|im_start|>assistant <think> ...
# solution return [x + 2 for x in xs]
code_bench
{"entry_point": "transform", "raw_prompt": "def transform(xs):\n \"\"\"Return a new list where every element of ``xs`` is incremented by 2.\n\n >>> transform([1, 2, 3])\n [3, 4, 5]\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([3, -1]) == [5, 1]\n assert candidate([-9, -4, 2]) == [-7,...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def transform(xs): """Return a list of the squares of each element of ``xs``. >>> transform([1, 2, 3]) [1, 4, 9] """ <|im_end|> <|im_start|>assistant <think> </think>
# solution return [x * x for x in xs]
code_bench
{"entry_point": "transform", "raw_prompt": "def transform(xs):\n \"\"\"Return a list of the squares of each element of ``xs``.\n\n >>> transform([1, 2, 3])\n [1, 4, 9]\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([-4, 3, -9, 3, -9]) == [16, 9, 81, 9, 81]\n assert candidate([8, 2, -2,...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def is_balanced(s): """Return True if every '(' in ``s`` has a matching ')' to its right and the brackets are properly nested. Other characters are ignored. The empty string is balance...
# solution depth = 0 for c in s: if c == '(': depth += 1 elif c == ')': depth -= 1 if depth < 0: return False return depth == 0
code_bench
{"entry_point": "is_balanced", "raw_prompt": "def is_balanced(s):\n \"\"\"Return True if every '(' in ``s`` has a matching ')' to its right and the brackets are properly nested. Other characters are ignored. The empty string is balanced.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate('') == Tru...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def transform(xs): """Return a new list where every element of ``xs`` is incremented by 5. >>> transform([1, 2, 3]) [6, 7, 8] """ <|im_end|> <|im_start|>assistant <think> ...
# solution return [x + 5 for x in xs]
code_bench
{"entry_point": "transform", "raw_prompt": "def transform(xs):\n \"\"\"Return a new list where every element of ``xs`` is incremented by 5.\n\n >>> transform([1, 2, 3])\n [6, 7, 8]\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([6, 1, -3]) == [11, 6, 2]\n assert candidate([3, -9]) == [...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def transform(xs): """Return a new list where every element of ``xs`` is incremented by 6. >>> transform([1, 2, 3]) [7, 8, 9] """ <|im_end|> <|im_start|>assistant <think> ...
# solution return [x + 6 for x in xs]
code_bench
{"entry_point": "transform", "raw_prompt": "def transform(xs):\n \"\"\"Return a new list where every element of ``xs`` is incremented by 6.\n\n >>> transform([1, 2, 3])\n [7, 8, 9]\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([2, 7, -2, -3]) == [8, 13, 4, 3]\n assert candidate([6, 1,...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def pair_count(xs): """Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 8``. """ <|im_end|> <|im_start|>assistant <think> </think>
# solution count = 0 for i in range(len(xs)): for j in range(i + 1, len(xs)): if xs[i] + xs[j] == 8: count += 1 return count
code_bench
{"entry_point": "pair_count", "raw_prompt": "def pair_count(xs):\n \"\"\"Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 8``.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([5, 8, 6, 8, 0]) == 2\n assert candidate([3, 0, 2, 6, 5]) == 2\n assert candidat...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def digital_root(n): """Return the digital root of the non-negative integer ``n``: repeatedly sum the decimal digits until the result has a single digit. """ <|im_end|> <|im_start|...
# solution while n >= 10: n = sum(int(d) for d in str(n)) return n
code_bench
{"entry_point": "digital_root", "raw_prompt": "def digital_root(n):\n \"\"\"Return the digital root of the non-negative integer ``n``: repeatedly sum the decimal digits until the result has a single digit.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate(147) == 3\n assert candidate(782) == 8\...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def is_balanced(s): """Return True if every '(' in ``s`` has a matching ')' to its right and the brackets are properly nested. Other characters are ignored. The empty string is balance...
# solution depth = 0 for c in s: if c == '(': depth += 1 elif c == ')': depth -= 1 if depth < 0: return False return depth == 0
code_bench
{"entry_point": "is_balanced", "raw_prompt": "def is_balanced(s):\n \"\"\"Return True if every '(' in ``s`` has a matching ')' to its right and the brackets are properly nested. Other characters are ignored. The empty string is balanced.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate('') == Tru...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def pair_count(xs): """Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 5``. """ <|im_end|> <|im_start|>assistant <think> </think>
# solution count = 0 for i in range(len(xs)): for j in range(i + 1, len(xs)): if xs[i] + xs[j] == 5: count += 1 return count
code_bench
{"entry_point": "pair_count", "raw_prompt": "def pair_count(xs):\n \"\"\"Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 5``.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([1, 5, 1, 3, 0, 4]) == 3\n assert candidate([3, 2, 2, 4]) == 2\n assert candidat...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def pair_count(xs): """Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 5``. """ <|im_end|> <|im_start|>assistant <think> </think>
# solution count = 0 for i in range(len(xs)): for j in range(i + 1, len(xs)): if xs[i] + xs[j] == 5: count += 1 return count
code_bench
{"entry_point": "pair_count", "raw_prompt": "def pair_count(xs):\n \"\"\"Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 5``.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([1, 5, 1, 3, 0, 4]) == 3\n assert candidate([3, 2, 2, 4]) == 2\n assert candidat...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def transform(xs): """Return a new list where every element of ``xs`` is incremented by 6. >>> transform([1, 2, 3]) [7, 8, 9] """ <|im_end|> <|im_start|>assistant <think> ...
# solution return [x + 6 for x in xs]
code_bench
{"entry_point": "transform", "raw_prompt": "def transform(xs):\n \"\"\"Return a new list where every element of ``xs`` is incremented by 6.\n\n >>> transform([1, 2, 3])\n [7, 8, 9]\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([2, 7, -2, -3]) == [8, 13, 4, 3]\n assert candidate([6, 1,...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def transform(xs): """Return a new list where every element of ``xs`` is incremented by 8. >>> transform([1, 2, 3]) [9, 10, 11] """ <|im_end|> <|im_start|>assistant <think...
# solution return [x + 8 for x in xs]
code_bench
{"entry_point": "transform", "raw_prompt": "def transform(xs):\n \"\"\"Return a new list where every element of ``xs`` is incremented by 8.\n\n >>> transform([1, 2, 3])\n [9, 10, 11]\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([-3, -3]) == [5, 5]\n assert candidate([-7, 4, 4, 1, 8, ...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def swap_pairs(s): """Return a string where every pair of adjacent characters has been swapped (so ``'abcd'`` becomes ``'badc'``). If the length is odd, the trailing character stays in...
# solution chars = list(s) for i in range(0, len(chars) - 1, 2): chars[i], chars[i + 1] = chars[i + 1], chars[i] return ''.join(chars)
code_bench
{"entry_point": "swap_pairs", "raw_prompt": "def swap_pairs(s):\n \"\"\"Return a string where every pair of adjacent characters has been swapped (so ``'abcd'`` becomes ``'badc'``). If the length is odd, the trailing character stays in place.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate('2!bdE...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def pair_count(xs): """Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 8``. """ <|im_end|> <|im_start|>assistant <think> </think>
# solution count = 0 for i in range(len(xs)): for j in range(i + 1, len(xs)): if xs[i] + xs[j] == 8: count += 1 return count
code_bench
{"entry_point": "pair_count", "raw_prompt": "def pair_count(xs):\n \"\"\"Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 8``.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([5, 8, 6, 8, 0]) == 2\n assert candidate([3, 0, 2, 6, 5]) == 2\n assert candidat...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def repeat_chars(s): """Return a string where every character of ``s`` is repeated 4 times in place. ``repeat_chars('ab')`` is ``'aaaabbbb'``. """ <|im_end|> <|im_start|>assistant ...
# solution return "".join(c * 4 for c in s)
code_bench
{"entry_point": "repeat_chars", "raw_prompt": "def repeat_chars(s):\n \"\"\"Return a string where every character of ``s`` is repeated 4 times in place. ``repeat_chars('ab')`` is ``'aaaabbbb'``.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate('A2') == 'AAAA2222'\n assert candidate('feF!') == ...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def alternate_case(s): """Return a new string where the i-th letter is uppercased for even i (0, 2, 4, ...) and lowercased for odd i. Non-letter characters are passed through unchanged...
# solution return "".join(ch.upper() if i % 2 == 0 else ch.lower() for i, ch in enumerate(s))
code_bench
{"entry_point": "alternate_case", "raw_prompt": "def alternate_case(s):\n \"\"\"Return a new string where the i-th letter is uppercased for even i (0, 2, 4, ...) and lowercased for odd i. Non-letter characters are passed through unchanged. Indexes count all characters, including non-letters.\n \"\"\"\n", "test": ...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def transform(xs): """Return a list of the absolute values of each element of ``xs``. >>> transform([-1, 2, -3]) [1, 2, 3] """ <|im_end|> <|im_start|>assistant <think> </...
# solution return [abs(x) for x in xs]
code_bench
{"entry_point": "transform", "raw_prompt": "def transform(xs):\n \"\"\"Return a list of the absolute values of each element of ``xs``.\n\n >>> transform([-1, 2, -3])\n [1, 2, 3]\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([-7, -3, -2]) == [7, 3, 2]\n assert candidate([-2, -1, -6, 1,...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def transform(xs): """Return a new list where every element of ``xs`` is incremented by 5. >>> transform([1, 2, 3]) [6, 7, 8] """ <|im_end|> <|im_start|>assistant <think> ...
# solution return [x + 5 for x in xs]
code_bench
{"entry_point": "transform", "raw_prompt": "def transform(xs):\n \"\"\"Return a new list where every element of ``xs`` is incremented by 5.\n\n >>> transform([1, 2, 3])\n [6, 7, 8]\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([6, 1, -3]) == [11, 6, 2]\n assert candidate([3, -9]) == [...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def is_balanced(s): """Return True if every '(' in ``s`` has a matching ')' to its right and the brackets are properly nested. Other characters are ignored. The empty string is balance...
# solution depth = 0 for c in s: if c == '(': depth += 1 elif c == ')': depth -= 1 if depth < 0: return False return depth == 0
code_bench
{"entry_point": "is_balanced", "raw_prompt": "def is_balanced(s):\n \"\"\"Return True if every '(' in ``s`` has a matching ')' to its right and the brackets are properly nested. Other characters are ignored. The empty string is balanced.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate('') == Tru...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def swap_pairs(s): """Return a string where every pair of adjacent characters has been swapped (so ``'abcd'`` becomes ``'badc'``). If the length is odd, the trailing character stays in...
# solution chars = list(s) for i in range(0, len(chars) - 1, 2): chars[i], chars[i + 1] = chars[i + 1], chars[i] return ''.join(chars)
code_bench
{"entry_point": "swap_pairs", "raw_prompt": "def swap_pairs(s):\n \"\"\"Return a string where every pair of adjacent characters has been swapped (so ``'abcd'`` becomes ``'badc'``). If the length is odd, the trailing character stays in place.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate('2!bdE...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def repeat_chars(s): """Return a string where every character of ``s`` is repeated 3 times in place. ``repeat_chars('ab')`` is ``'aaabbb'``. """ <|im_end|> <|im_start|>assistant <t...
# solution return "".join(c * 3 for c in s)
code_bench
{"entry_point": "repeat_chars", "raw_prompt": "def repeat_chars(s):\n \"\"\"Return a string where every character of ``s`` is repeated 3 times in place. ``repeat_chars('ab')`` is ``'aaabbb'``.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate('eDbC') == 'eeeDDDbbbCCC'\n assert candidate('2CD') ...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def transform(xs): """Return a new list where every element of ``xs`` is incremented by 7. >>> transform([1, 2, 3]) [8, 9, 10] """ <|im_end|> <|im_start|>assistant <think>...
# solution return [x + 7 for x in xs]
code_bench
{"entry_point": "transform", "raw_prompt": "def transform(xs):\n \"\"\"Return a new list where every element of ``xs`` is incremented by 7.\n\n >>> transform([1, 2, 3])\n [8, 9, 10]\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([-5, -6, -3]) == [2, 1, 4]\n assert candidate([-6, 5, -6,...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def pair_count(xs): """Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 6``. """ <|im_end|> <|im_start|>assistant <think> </think>
# solution count = 0 for i in range(len(xs)): for j in range(i + 1, len(xs)): if xs[i] + xs[j] == 6: count += 1 return count
code_bench
{"entry_point": "pair_count", "raw_prompt": "def pair_count(xs):\n \"\"\"Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 6``.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([3, 6, 0, 4]) == 1\n assert candidate([4, 2, 5, 6]) == 1\n assert candidate([1, ...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def pair_count(xs): """Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 6``. """ <|im_end|> <|im_start|>assistant <think> </think>
# solution count = 0 for i in range(len(xs)): for j in range(i + 1, len(xs)): if xs[i] + xs[j] == 6: count += 1 return count
code_bench
{"entry_point": "pair_count", "raw_prompt": "def pair_count(xs):\n \"\"\"Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 6``.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([3, 6, 0, 4]) == 1\n assert candidate([4, 2, 5, 6]) == 1\n assert candidate([1, ...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def pair_count(xs): """Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 5``. """ <|im_end|> <|im_start|>assistant <think> </think>
# solution count = 0 for i in range(len(xs)): for j in range(i + 1, len(xs)): if xs[i] + xs[j] == 5: count += 1 return count
code_bench
{"entry_point": "pair_count", "raw_prompt": "def pair_count(xs):\n \"\"\"Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 5``.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([1, 5, 1, 3, 0, 4]) == 3\n assert candidate([3, 2, 2, 4]) == 2\n assert candidat...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def pair_count(xs): """Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 5``. """ <|im_end|> <|im_start|>assistant <think> </think>
# solution count = 0 for i in range(len(xs)): for j in range(i + 1, len(xs)): if xs[i] + xs[j] == 5: count += 1 return count
code_bench
{"entry_point": "pair_count", "raw_prompt": "def pair_count(xs):\n \"\"\"Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 5``.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([1, 5, 1, 3, 0, 4]) == 3\n assert candidate([3, 2, 2, 4]) == 2\n assert candidat...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def is_anagram(a, b): """Return True if string ``a`` is an anagram of string ``b`` (case-sensitive). Different lengths return False. """ <|im_end|> <|im_start|>assistant <think> <...
# solution return sorted(a) == sorted(b)
code_bench
{"entry_point": "is_anagram", "raw_prompt": "def is_anagram(a, b):\n \"\"\"Return True if string ``a`` is an anagram of string ``b`` (case-sensitive). Different lengths return False.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate('ffffea', 'ffffey') == False\n assert candidate('eeec', 'ecee'...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def pair_count(xs): """Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 12``. """ <|im_end|> <|im_start|>assistant <think> </think>
# solution count = 0 for i in range(len(xs)): for j in range(i + 1, len(xs)): if xs[i] + xs[j] == 12: count += 1 return count
code_bench
{"entry_point": "pair_count", "raw_prompt": "def pair_count(xs):\n \"\"\"Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 12``.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([7, 9, 2]) == 0\n assert candidate([11, 4, 9, 8, 7, 1, 5]) == 3\n assert candid...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def transform(xs): """Return a new list where every element of ``xs`` is incremented by 7. >>> transform([1, 2, 3]) [8, 9, 10] """ <|im_end|> <|im_start|>assistant <think>...
# solution return [x + 7 for x in xs]
code_bench
{"entry_point": "transform", "raw_prompt": "def transform(xs):\n \"\"\"Return a new list where every element of ``xs`` is incremented by 7.\n\n >>> transform([1, 2, 3])\n [8, 9, 10]\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([-5, -6, -3]) == [2, 1, 4]\n assert candidate([-6, 5, -6,...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def repeat_chars(s): """Return a string where every character of ``s`` is repeated 2 times in place. ``repeat_chars('ab')`` is ``'aabb'``. """ <|im_end|> <|im_start|>assistant <thi...
# solution return "".join(c * 2 for c in s)
code_bench
{"entry_point": "repeat_chars", "raw_prompt": "def repeat_chars(s):\n \"\"\"Return a string where every character of ``s`` is repeated 2 times in place. ``repeat_chars('ab')`` is ``'aabb'``.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate('bAd') == 'bbAAdd'\n assert candidate('a') == 'aa'\n ...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def pair_count(xs): """Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 8``. """ <|im_end|> <|im_start|>assistant <think> </think>
# solution count = 0 for i in range(len(xs)): for j in range(i + 1, len(xs)): if xs[i] + xs[j] == 8: count += 1 return count
code_bench
{"entry_point": "pair_count", "raw_prompt": "def pair_count(xs):\n \"\"\"Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 8``.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([5, 8, 6, 8, 0]) == 2\n assert candidate([3, 0, 2, 6, 5]) == 2\n assert candidat...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def swap_pairs(s): """Return a string where every pair of adjacent characters has been swapped (so ``'abcd'`` becomes ``'badc'``). If the length is odd, the trailing character stays in...
# solution chars = list(s) for i in range(0, len(chars) - 1, 2): chars[i], chars[i + 1] = chars[i + 1], chars[i] return ''.join(chars)
code_bench
{"entry_point": "swap_pairs", "raw_prompt": "def swap_pairs(s):\n \"\"\"Return a string where every pair of adjacent characters has been swapped (so ``'abcd'`` becomes ``'badc'``). If the length is odd, the trailing character stays in place.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate('2!bdE...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def alternate_case(s): """Return a new string where the i-th letter is uppercased for even i (0, 2, 4, ...) and lowercased for odd i. Non-letter characters are passed through unchanged...
# solution return "".join(ch.upper() if i % 2 == 0 else ch.lower() for i, ch in enumerate(s))
code_bench
{"entry_point": "alternate_case", "raw_prompt": "def alternate_case(s):\n \"\"\"Return a new string where the i-th letter is uppercased for even i (0, 2, 4, ...) and lowercased for odd i. Non-letter characters are passed through unchanged. Indexes count all characters, including non-letters.\n \"\"\"\n", "test": ...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def transform(xs): """Return a new list where every element of ``xs`` is incremented by 6. >>> transform([1, 2, 3]) [7, 8, 9] """ <|im_end|> <|im_start|>assistant <think> ...
# solution return [x + 6 for x in xs]
code_bench
{"entry_point": "transform", "raw_prompt": "def transform(xs):\n \"\"\"Return a new list where every element of ``xs`` is incremented by 6.\n\n >>> transform([1, 2, 3])\n [7, 8, 9]\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([2, 7, -2, -3]) == [8, 13, 4, 3]\n assert candidate([6, 1,...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def pair_count(xs): """Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 12``. """ <|im_end|> <|im_start|>assistant <think> </think>
# solution count = 0 for i in range(len(xs)): for j in range(i + 1, len(xs)): if xs[i] + xs[j] == 12: count += 1 return count
code_bench
{"entry_point": "pair_count", "raw_prompt": "def pair_count(xs):\n \"\"\"Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 12``.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([7, 9, 2]) == 0\n assert candidate([11, 4, 9, 8, 7, 1, 5]) == 3\n assert candid...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def pair_count(xs): """Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 4``. """ <|im_end|> <|im_start|>assistant <think> </think>
# solution count = 0 for i in range(len(xs)): for j in range(i + 1, len(xs)): if xs[i] + xs[j] == 4: count += 1 return count
code_bench
{"entry_point": "pair_count", "raw_prompt": "def pair_count(xs):\n \"\"\"Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 4``.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([1, 2, 0, 1, 3, 1, 0]) == 3\n assert candidate([2, 1, 2, 4, 4]) == 1\n assert ca...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def transform(xs): """Return a list where every element of ``xs`` is negated. >>> transform([1, -2, 3]) [-1, 2, -3] """ <|im_end|> <|im_start|>assistant <think> </think> ...
# solution return [-x for x in xs]
code_bench
{"entry_point": "transform", "raw_prompt": "def transform(xs):\n \"\"\"Return a list where every element of ``xs`` is negated.\n\n >>> transform([1, -2, 3])\n [-1, 2, -3]\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([0, 7, 1, -8, 2]) == [0, -7, -1, 8, -2]\n assert candidate([-2, -9])...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def pair_count(xs): """Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 10``. """ <|im_end|> <|im_start|>assistant <think> </think>
# solution count = 0 for i in range(len(xs)): for j in range(i + 1, len(xs)): if xs[i] + xs[j] == 10: count += 1 return count
code_bench
{"entry_point": "pair_count", "raw_prompt": "def pair_count(xs):\n \"\"\"Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 10``.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([5, 2, 4]) == 0\n assert candidate([5, 2, 6, 4, 5, 4, 2]) == 3\n assert candida...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def window_max_sum(xs, k): """Return the maximum sum of any contiguous window of exactly ``k`` consecutive elements in the list ``xs``. If ``k`` is larger than the length of ``xs`` or ...
# solution if not xs or k > len(xs) or k <= 0: return 0 return max(sum(xs[i:i + k]) for i in range(len(xs) - k + 1))
code_bench
{"entry_point": "window_max_sum", "raw_prompt": "def window_max_sum(xs, k):\n \"\"\"Return the maximum sum of any contiguous window of exactly ``k`` consecutive elements in the list ``xs``. If ``k`` is larger than the length of ``xs`` or ``xs`` is empty, return 0.\n \"\"\"\n", "test": "def check(candidate):\n ...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def transform(xs): """Return a new list where every element of ``xs`` is incremented by 3. >>> transform([1, 2, 3]) [4, 5, 6] """ <|im_end|> <|im_start|>assistant <think> ...
# solution return [x + 3 for x in xs]
code_bench
{"entry_point": "transform", "raw_prompt": "def transform(xs):\n \"\"\"Return a new list where every element of ``xs`` is incremented by 3.\n\n >>> transform([1, 2, 3])\n [4, 5, 6]\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([-6, -7, -3, -2, -5, -8]) == [-3, -4, 0, 1, -2, -5]\n asse...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def transform(xs): """Return a new list where every element of ``xs`` is incremented by 2. >>> transform([1, 2, 3]) [3, 4, 5] """ <|im_end|> <|im_start|>assistant <think> ...
# solution return [x + 2 for x in xs]
code_bench
{"entry_point": "transform", "raw_prompt": "def transform(xs):\n \"\"\"Return a new list where every element of ``xs`` is incremented by 2.\n\n >>> transform([1, 2, 3])\n [3, 4, 5]\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([3, -1]) == [5, 1]\n assert candidate([-9, -4, 2]) == [-7,...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def pair_count(xs): """Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 12``. """ <|im_end|> <|im_start|>assistant <think> </think>
# solution count = 0 for i in range(len(xs)): for j in range(i + 1, len(xs)): if xs[i] + xs[j] == 12: count += 1 return count
code_bench
{"entry_point": "pair_count", "raw_prompt": "def pair_count(xs):\n \"\"\"Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 12``.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([7, 9, 2]) == 0\n assert candidate([11, 4, 9, 8, 7, 1, 5]) == 3\n assert candid...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def swap_pairs(s): """Return a string where every pair of adjacent characters has been swapped (so ``'abcd'`` becomes ``'badc'``). If the length is odd, the trailing character stays in...
# solution chars = list(s) for i in range(0, len(chars) - 1, 2): chars[i], chars[i + 1] = chars[i + 1], chars[i] return ''.join(chars)
code_bench
{"entry_point": "swap_pairs", "raw_prompt": "def swap_pairs(s):\n \"\"\"Return a string where every pair of adjacent characters has been swapped (so ``'abcd'`` becomes ``'badc'``). If the length is odd, the trailing character stays in place.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate('2!bdE...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def alternate_case(s): """Return a new string where the i-th letter is uppercased for even i (0, 2, 4, ...) and lowercased for odd i. Non-letter characters are passed through unchanged...
# solution return "".join(ch.upper() if i % 2 == 0 else ch.lower() for i, ch in enumerate(s))
code_bench
{"entry_point": "alternate_case", "raw_prompt": "def alternate_case(s):\n \"\"\"Return a new string where the i-th letter is uppercased for even i (0, 2, 4, ...) and lowercased for odd i. Non-letter characters are passed through unchanged. Indexes count all characters, including non-letters.\n \"\"\"\n", "test": ...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def aggregate(xs): """Return the number of strictly positive elements of ``xs``. """ <|im_end|> <|im_start|>assistant <think> </think>
# solution return sum(1 for x in xs if x > 0)
code_bench
{"entry_point": "aggregate", "raw_prompt": "def aggregate(xs):\n \"\"\"Return the number of strictly positive elements of ``xs``.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([-7, -5, -3, -5]) == 0\n assert candidate([-7, 4, 4, 1, -5, 2, -5]) == 4\n assert candidate([-5, -1, 4, 0, -5, -...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def pair_count(xs): """Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 4``. """ <|im_end|> <|im_start|>assistant <think> </think>
# solution count = 0 for i in range(len(xs)): for j in range(i + 1, len(xs)): if xs[i] + xs[j] == 4: count += 1 return count
code_bench
{"entry_point": "pair_count", "raw_prompt": "def pair_count(xs):\n \"\"\"Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 4``.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([1, 2, 0, 1, 3, 1, 0]) == 3\n assert candidate([2, 1, 2, 4, 4]) == 1\n assert ca...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def transform(xs): """Return a list of the absolute values of each element of ``xs``. >>> transform([-1, 2, -3]) [1, 2, 3] """ <|im_end|> <|im_start|>assistant <think> </...
# solution return [abs(x) for x in xs]
code_bench
{"entry_point": "transform", "raw_prompt": "def transform(xs):\n \"\"\"Return a list of the absolute values of each element of ``xs``.\n\n >>> transform([-1, 2, -3])\n [1, 2, 3]\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([-7, -3, -2]) == [7, 3, 2]\n assert candidate([-2, -1, -6, 1,...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def transform(xs): """Return a new list where every element of ``xs`` is incremented by 3. >>> transform([1, 2, 3]) [4, 5, 6] """ <|im_end|> <|im_start|>assistant <think> ...
# solution return [x + 3 for x in xs]
code_bench
{"entry_point": "transform", "raw_prompt": "def transform(xs):\n \"\"\"Return a new list where every element of ``xs`` is incremented by 3.\n\n >>> transform([1, 2, 3])\n [4, 5, 6]\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([-6, -7, -3, -2, -5, -8]) == [-3, -4, 0, 1, -2, -5]\n asse...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def aggregate(xs): """Return the number of strictly positive elements of ``xs``. """ <|im_end|> <|im_start|>assistant <think> </think>
# solution return sum(1 for x in xs if x > 0)
code_bench
{"entry_point": "aggregate", "raw_prompt": "def aggregate(xs):\n \"\"\"Return the number of strictly positive elements of ``xs``.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([-7, -5, -3, -5]) == 0\n assert candidate([-7, 4, 4, 1, -5, 2, -5]) == 4\n assert candidate([-5, -1, 4, 0, -5, -...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def is_palindrome(s): """Return True if the string ``s`` reads the same forwards and backwards (case-sensitive, no spaces stripped). Empty string is True. """ <|im_end|> <|im_start...
# solution return s == s[::-1]
code_bench
{"entry_point": "is_palindrome", "raw_prompt": "def is_palindrome(s):\n \"\"\"Return True if the string ``s`` reads the same forwards and backwards (case-sensitive, no spaces stripped). Empty string is True.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate('dd') == True\n assert candidate('afe...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def transform(xs): """Return a new list where every element of ``xs`` is incremented by 4. >>> transform([1, 2, 3]) [5, 6, 7] """ <|im_end|> <|im_start|>assistant <think> ...
# solution return [x + 4 for x in xs]
code_bench
{"entry_point": "transform", "raw_prompt": "def transform(xs):\n \"\"\"Return a new list where every element of ``xs`` is incremented by 4.\n\n >>> transform([1, 2, 3])\n [5, 6, 7]\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([-8, -3, 5, -3, -2]) == [-4, 1, 9, 1, 2]\n assert candidat...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def alternate_case(s): """Return a new string where the i-th letter is uppercased for even i (0, 2, 4, ...) and lowercased for odd i. Non-letter characters are passed through unchanged...
# solution return "".join(ch.upper() if i % 2 == 0 else ch.lower() for i, ch in enumerate(s))
code_bench
{"entry_point": "alternate_case", "raw_prompt": "def alternate_case(s):\n \"\"\"Return a new string where the i-th letter is uppercased for even i (0, 2, 4, ...) and lowercased for odd i. Non-letter characters are passed through unchanged. Indexes count all characters, including non-letters.\n \"\"\"\n", "test": ...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def transform(xs): """Return a list where every element of ``xs`` is negated. >>> transform([1, -2, 3]) [-1, 2, -3] """ <|im_end|> <|im_start|>assistant <think> </think> ...
# solution return [-x for x in xs]
code_bench
{"entry_point": "transform", "raw_prompt": "def transform(xs):\n \"\"\"Return a list where every element of ``xs`` is negated.\n\n >>> transform([1, -2, 3])\n [-1, 2, -3]\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([0, 7, 1, -8, 2]) == [0, -7, -1, 8, -2]\n assert candidate([-2, -9])...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def alternate_case(s): """Return a new string where the i-th letter is uppercased for even i (0, 2, 4, ...) and lowercased for odd i. Non-letter characters are passed through unchanged...
# solution return "".join(ch.upper() if i % 2 == 0 else ch.lower() for i, ch in enumerate(s))
code_bench
{"entry_point": "alternate_case", "raw_prompt": "def alternate_case(s):\n \"\"\"Return a new string where the i-th letter is uppercased for even i (0, 2, 4, ...) and lowercased for odd i. Non-letter characters are passed through unchanged. Indexes count all characters, including non-letters.\n \"\"\"\n", "test": ...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def is_palindrome(s): """Return True if the string ``s`` reads the same forwards and backwards (case-sensitive, no spaces stripped). Empty string is True. """ <|im_end|> <|im_start...
# solution return s == s[::-1]
code_bench
{"entry_point": "is_palindrome", "raw_prompt": "def is_palindrome(s):\n \"\"\"Return True if the string ``s`` reads the same forwards and backwards (case-sensitive, no spaces stripped). Empty string is True.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate('dd') == True\n assert candidate('afe...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def pair_count(xs): """Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 7``. """ <|im_end|> <|im_start|>assistant <think> </think>
# solution count = 0 for i in range(len(xs)): for j in range(i + 1, len(xs)): if xs[i] + xs[j] == 7: count += 1 return count
code_bench
{"entry_point": "pair_count", "raw_prompt": "def pair_count(xs):\n \"\"\"Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 7``.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([1, 7, 1, 1, 0, 6, 3]) == 4\n assert candidate([2, 3, 0, 1, 1, 3, 3]) == 0\n ass...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def transform(xs): """Return a new list where every element of ``xs`` is incremented by 4. >>> transform([1, 2, 3]) [5, 6, 7] """ <|im_end|> <|im_start|>assistant <think> ...
# solution return [x + 4 for x in xs]
code_bench
{"entry_point": "transform", "raw_prompt": "def transform(xs):\n \"\"\"Return a new list where every element of ``xs`` is incremented by 4.\n\n >>> transform([1, 2, 3])\n [5, 6, 7]\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([-8, -3, 5, -3, -2]) == [-4, 1, 9, 1, 2]\n assert candidat...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def pair_count(xs): """Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 5``. """ <|im_end|> <|im_start|>assistant <think> </think>
# solution count = 0 for i in range(len(xs)): for j in range(i + 1, len(xs)): if xs[i] + xs[j] == 5: count += 1 return count
code_bench
{"entry_point": "pair_count", "raw_prompt": "def pair_count(xs):\n \"\"\"Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 5``.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([1, 5, 1, 3, 0, 4]) == 3\n assert candidate([3, 2, 2, 4]) == 2\n assert candidat...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def alternate_case(s): """Return a new string where the i-th letter is uppercased for even i (0, 2, 4, ...) and lowercased for odd i. Non-letter characters are passed through unchanged...
# solution return "".join(ch.upper() if i % 2 == 0 else ch.lower() for i, ch in enumerate(s))
code_bench
{"entry_point": "alternate_case", "raw_prompt": "def alternate_case(s):\n \"\"\"Return a new string where the i-th letter is uppercased for even i (0, 2, 4, ...) and lowercased for odd i. Non-letter characters are passed through unchanged. Indexes count all characters, including non-letters.\n \"\"\"\n", "test": ...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def swap_pairs(s): """Return a string where every pair of adjacent characters has been swapped (so ``'abcd'`` becomes ``'badc'``). If the length is odd, the trailing character stays in...
# solution chars = list(s) for i in range(0, len(chars) - 1, 2): chars[i], chars[i + 1] = chars[i + 1], chars[i] return ''.join(chars)
code_bench
{"entry_point": "swap_pairs", "raw_prompt": "def swap_pairs(s):\n \"\"\"Return a string where every pair of adjacent characters has been swapped (so ``'abcd'`` becomes ``'badc'``). If the length is odd, the trailing character stays in place.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate('2!bdE...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def digit_sum(n): """Return the sum of the decimal digits of the non-negative integer ``n``. ``digit_sum(0)`` is 0. """ <|im_end|> <|im_start|>assistant <think> </think>
# solution return sum(int(d) for d in str(n))
code_bench
{"entry_point": "digit_sum", "raw_prompt": "def digit_sum(n):\n \"\"\"Return the sum of the decimal digits of the non-negative integer ``n``. ``digit_sum(0)`` is 0.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate(183) == 12\n assert candidate(704) == 11\n assert candidate(823) == 13\n a...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def pair_count(xs): """Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 6``. """ <|im_end|> <|im_start|>assistant <think> </think>
# solution count = 0 for i in range(len(xs)): for j in range(i + 1, len(xs)): if xs[i] + xs[j] == 6: count += 1 return count
code_bench
{"entry_point": "pair_count", "raw_prompt": "def pair_count(xs):\n \"\"\"Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 6``.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([3, 6, 0, 4]) == 1\n assert candidate([4, 2, 5, 6]) == 1\n assert candidate([1, ...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def rle(s): """Return the run-length encoding of the string ``s`` as a list of (char, count) tuples. ``rle('')`` is ``[]``. ``rle('aaabb')`` is ``[('a', 3), ('b', 2)]``. """ <|im_e...
# solution if not s: return [] pairs = [] cur = s[0] cnt = 1 for ch in s[1:]: if ch == cur: cnt += 1 else: pairs.append((cur, cnt)) cur = ch cnt = 1 pairs.append((cur, cnt)) return pairs
code_bench
{"entry_point": "rle", "raw_prompt": "def rle(s):\n \"\"\"Return the run-length encoding of the string ``s`` as a list of (char, count) tuples. ``rle('')`` is ``[]``. ``rle('aaabb')`` is ``[('a', 3), ('b', 2)]``.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate('aabbb') == [('a', 2), ('b', 3)]\n ...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def pair_count(xs): """Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 10``. """ <|im_end|> <|im_start|>assistant <think> </think>
# solution count = 0 for i in range(len(xs)): for j in range(i + 1, len(xs)): if xs[i] + xs[j] == 10: count += 1 return count
code_bench
{"entry_point": "pair_count", "raw_prompt": "def pair_count(xs):\n \"\"\"Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 10``.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([5, 2, 4]) == 0\n assert candidate([5, 2, 6, 4, 5, 4, 2]) == 3\n assert candida...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def transform(xs): """Return a new list where every element of ``xs`` is incremented by 4. >>> transform([1, 2, 3]) [5, 6, 7] """ <|im_end|> <|im_start|>assistant <think> ...
# solution return [x + 4 for x in xs]
code_bench
{"entry_point": "transform", "raw_prompt": "def transform(xs):\n \"\"\"Return a new list where every element of ``xs`` is incremented by 4.\n\n >>> transform([1, 2, 3])\n [5, 6, 7]\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([-8, -3, 5, -3, -2]) == [-4, 1, 9, 1, 2]\n assert candidat...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def pair_count(xs): """Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 9``. """ <|im_end|> <|im_start|>assistant <think> </think>
# solution count = 0 for i in range(len(xs)): for j in range(i + 1, len(xs)): if xs[i] + xs[j] == 9: count += 1 return count
code_bench
{"entry_point": "pair_count", "raw_prompt": "def pair_count(xs):\n \"\"\"Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 9``.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([3, 8, 6]) == 1\n assert candidate([4, 1, 1]) == 0\n assert candidate([0, 1, 1, ...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def transform(xs): """Return a new list where every element of ``xs`` is incremented by 4. >>> transform([1, 2, 3]) [5, 6, 7] """ <|im_end|> <|im_start|>assistant <think> ...
# solution return [x + 4 for x in xs]
code_bench
{"entry_point": "transform", "raw_prompt": "def transform(xs):\n \"\"\"Return a new list where every element of ``xs`` is incremented by 4.\n\n >>> transform([1, 2, 3])\n [5, 6, 7]\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([-8, -3, 5, -3, -2]) == [-4, 1, 9, 1, 2]\n assert candidat...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def pair_count(xs): """Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 8``. """ <|im_end|> <|im_start|>assistant <think> </think>
# solution count = 0 for i in range(len(xs)): for j in range(i + 1, len(xs)): if xs[i] + xs[j] == 8: count += 1 return count
code_bench
{"entry_point": "pair_count", "raw_prompt": "def pair_count(xs):\n \"\"\"Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 8``.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([5, 8, 6, 8, 0]) == 2\n assert candidate([3, 0, 2, 6, 5]) == 2\n assert candidat...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def transform(xs): """Return a new list where every element of ``xs`` is incremented by 3. >>> transform([1, 2, 3]) [4, 5, 6] """ <|im_end|> <|im_start|>assistant <think> ...
# solution return [x + 3 for x in xs]
code_bench
{"entry_point": "transform", "raw_prompt": "def transform(xs):\n \"\"\"Return a new list where every element of ``xs`` is incremented by 3.\n\n >>> transform([1, 2, 3])\n [4, 5, 6]\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([-6, -7, -3, -2, -5, -8]) == [-3, -4, 0, 1, -2, -5]\n asse...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def alternate_case(s): """Return a new string where the i-th letter is uppercased for even i (0, 2, 4, ...) and lowercased for odd i. Non-letter characters are passed through unchanged...
# solution return "".join(ch.upper() if i % 2 == 0 else ch.lower() for i, ch in enumerate(s))
code_bench
{"entry_point": "alternate_case", "raw_prompt": "def alternate_case(s):\n \"\"\"Return a new string where the i-th letter is uppercased for even i (0, 2, 4, ...) and lowercased for odd i. Non-letter characters are passed through unchanged. Indexes count all characters, including non-letters.\n \"\"\"\n", "test": ...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def pair_count(xs): """Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 5``. """ <|im_end|> <|im_start|>assistant <think> </think>
# solution count = 0 for i in range(len(xs)): for j in range(i + 1, len(xs)): if xs[i] + xs[j] == 5: count += 1 return count
code_bench
{"entry_point": "pair_count", "raw_prompt": "def pair_count(xs):\n \"\"\"Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 5``.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([1, 5, 1, 3, 0, 4]) == 3\n assert candidate([3, 2, 2, 4]) == 2\n assert candidat...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def is_palindrome(s): """Return True if the string ``s`` reads the same forwards and backwards (case-sensitive, no spaces stripped). Empty string is True. """ <|im_end|> <|im_start...
# solution return s == s[::-1]
code_bench
{"entry_point": "is_palindrome", "raw_prompt": "def is_palindrome(s):\n \"\"\"Return True if the string ``s`` reads the same forwards and backwards (case-sensitive, no spaces stripped). Empty string is True.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate('dd') == True\n assert candidate('afe...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def pair_count(xs): """Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 8``. """ <|im_end|> <|im_start|>assistant <think> </think>
# solution count = 0 for i in range(len(xs)): for j in range(i + 1, len(xs)): if xs[i] + xs[j] == 8: count += 1 return count
code_bench
{"entry_point": "pair_count", "raw_prompt": "def pair_count(xs):\n \"\"\"Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 8``.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([5, 8, 6, 8, 0]) == 2\n assert candidate([3, 0, 2, 6, 5]) == 2\n assert candidat...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def pair_count(xs): """Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 3``. """ <|im_end|> <|im_start|>assistant <think> </think>
# solution count = 0 for i in range(len(xs)): for j in range(i + 1, len(xs)): if xs[i] + xs[j] == 3: count += 1 return count
code_bench
{"entry_point": "pair_count", "raw_prompt": "def pair_count(xs):\n \"\"\"Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 3``.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([2, 2, 0, 0, 3]) == 2\n assert candidate([0, 3, 0, 0]) == 3\n assert candidate([...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def transform(xs): """Return a new list where every element of ``xs`` is incremented by 5. >>> transform([1, 2, 3]) [6, 7, 8] """ <|im_end|> <|im_start|>assistant <think> ...
# solution return [x + 5 for x in xs]
code_bench
{"entry_point": "transform", "raw_prompt": "def transform(xs):\n \"\"\"Return a new list where every element of ``xs`` is incremented by 5.\n\n >>> transform([1, 2, 3])\n [6, 7, 8]\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([6, 1, -3]) == [11, 6, 2]\n assert candidate([3, -9]) == [...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def pair_count(xs): """Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 12``. """ <|im_end|> <|im_start|>assistant <think> </think>
# solution count = 0 for i in range(len(xs)): for j in range(i + 1, len(xs)): if xs[i] + xs[j] == 12: count += 1 return count
code_bench
{"entry_point": "pair_count", "raw_prompt": "def pair_count(xs):\n \"\"\"Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 12``.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([7, 9, 2]) == 0\n assert candidate([11, 4, 9, 8, 7, 1, 5]) == 3\n assert candid...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def pair_count(xs): """Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 12``. """ <|im_end|> <|im_start|>assistant <think> </think>
# solution count = 0 for i in range(len(xs)): for j in range(i + 1, len(xs)): if xs[i] + xs[j] == 12: count += 1 return count
code_bench
{"entry_point": "pair_count", "raw_prompt": "def pair_count(xs):\n \"\"\"Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 12``.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([7, 9, 2]) == 0\n assert candidate([11, 4, 9, 8, 7, 1, 5]) == 3\n assert candid...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def transform(xs): """Return a list where every element of ``xs`` is negated. >>> transform([1, -2, 3]) [-1, 2, -3] """ <|im_end|> <|im_start|>assistant <think> </think> ...
# solution return [-x for x in xs]
code_bench
{"entry_point": "transform", "raw_prompt": "def transform(xs):\n \"\"\"Return a list where every element of ``xs`` is negated.\n\n >>> transform([1, -2, 3])\n [-1, 2, -3]\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([0, 7, 1, -8, 2]) == [0, -7, -1, 8, -2]\n assert candidate([-2, -9])...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def pair_count(xs): """Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 11``. """ <|im_end|> <|im_start|>assistant <think> </think>
# solution count = 0 for i in range(len(xs)): for j in range(i + 1, len(xs)): if xs[i] + xs[j] == 11: count += 1 return count
code_bench
{"entry_point": "pair_count", "raw_prompt": "def pair_count(xs):\n \"\"\"Return the number of unordered pairs (i, j) with i < j such that ``xs[i] + xs[j] == 11``.\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([6, 5, 6, 9, 11, 1, 0]) == 3\n assert candidate([5, 9, 3, 4]) == 0\n assert can...
<|im_start|>user Complete the following Python function. Output only the function body (no extra explanation, no markdown fences). def transform(xs): """Return a new list where every element of ``xs`` is incremented by 9. >>> transform([1, 2, 3]) [10, 11, 12] """ <|im_end|> <|im_start|>assistant <thin...
# solution return [x + 9 for x in xs]
code_bench
{"entry_point": "transform", "raw_prompt": "def transform(xs):\n \"\"\"Return a new list where every element of ``xs`` is incremented by 9.\n\n >>> transform([1, 2, 3])\n [10, 11, 12]\n \"\"\"\n", "test": "def check(candidate):\n assert candidate([0, -3, 3, -9, 2, -5]) == [9, 6, 12, 0, 11, 4]\n assert...