submissionId
stringlengths
25
25
title
stringlengths
17
17
payload
dict
cmsvntqa3021ag4p2yduxxjms
Submission UXXJMS
{ "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 res...
cmsvntqa3021bg4p2m0o078jt
Submission O078JT
{ "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 ...
cmsvntqa3021cg4p276rfekcs
Submission RFEKCS
{ "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" }
cmsvntqa3021dg4p2dihdig5x
Submission HDIG5X
{ "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...
cmsvntqa3021eg4p2h5xkneng
Submission XKNENG
{ "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 = \...
cmsvntqa3021fg4p2j3b7pdvo
Submission B7PDVO
{ "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...
cmsvntqa3021gg4p21zlzifwu
Submission LZIFWU
{ "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)...
cmsvntqa3021hg4p2ovxnx3j8
Submission XNX3J8
{ "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 ...
cmsvntqa3021ig4p229ukkrsm
Submission UKKRSM
{ "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), (...
cmsvntqa3021jg4p2ctwcbsyz
Submission WCBSYZ
{ "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 ...
cmsvntqa3021kg4p2gclhk2ed
Submission LHK2ED
{ "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 ...
cmsvntqa3021lg4p2664q7xjl
Submission 4Q7XJL
{ "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 *= ...
cmsvntqa3021mg4p22s63nj0g
Submission 63NJ0G
{ "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 ...
cmsvntqa3021ng4p2p6otthut
Submission OTTHUT
{ "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": "proc...
cmsvntqa3021og4p2j1wueozd
Submission WUEOZD
{ "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_m...
cmsvntqa3021pg4p2cjgd394y
Submission GD394Y
{ "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 ...
cmsvntqa3021qg4p2o5t39asc
Submission T39ASC
{ "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(val...
cmsvntqa3021rg4p24yz9djnt
Submission Z9DJNT
{ "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[serv...
cmsvobe4z0272g4p2ffjxwumd
Submission JXWUMD
{ "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]" }
cmsvobe4z0273g4p2ffo7uy5n
Submission O7UY5N
{ "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" }
cmsvobe4z0274g4p270o28upm
Submission O28UPM
{ "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}" }
cmsvobe4z0275g4p2olwpi9ya
Submission WPI9YA
{ "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')" }
cmsvobe4z0276g4p2icrwj8hr
Submission RWJ8HR
{ "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)]" }
cmsvobe4z0277g4p2waw08gmi
Submission W08GMI
{ "code": "def center_text(s, width):\n return s.center(width, '*')\n", "input": "center_text('hi', 6)", "language": "Python", "predicted_output": "**hi**" }
cmsvobe4z0278g4p2xgk64tgq
Submission K64TGQ
{ "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" }
cmsvobe4z0279g4p2lotasn3z
Submission TASN3Z
{ "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)" }
cmsvobe4z027ag4p2t4yj2p41
Submission YJ2P41
{ "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])" }
cmsvobe4z027bg4p27d3p075i
Submission 3P075I
{ "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')" }
cmsvonedl027wg4p2g4tzhb6o
Submission TZHB6O
{ "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" }
cmsvonedl027xg4p28tyxe2j9
Submission YXE2J9
{ "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" }
cmsvonedl027yg4p2ara94qv0
Submission A94QV0
{ "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" }
cmsvonedl027zg4p2wd2bpk14
Submission 2BPK14
{ "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" }
cmsvonedl0280g4p2w4c5fq1l
Submission C5FQ1L
{ "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(...
cmsvonedl0281g4p22e1tvplf
Submission 1TVPLF
{ "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" }
cmsvonedl0282g4p29wy6lb27
Submission Y6LB27
{ "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" }
cmsvonedl0283g4p2a8kjnfin
Submission KJNFIN
{ "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" }
cmsvonedl0284g4p2qjnz01m9
Submission NZ01M9
{ "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" }
cmsvonedl0285g4p2tqjo6ayr
Submission JO6AYR
{ "code": "\ndef binary_to_decimal(s):\n return int(s, 2)\n", "input": "binary_to_decimal('110110')", "language": "Python", "predicted_output": "54" }
cmsvonedl0286g4p29jv5wyy2
Submission V5WYY2
{ "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" }
cmsvonedl0287g4p2y2ykqh0r
Submission YKQH0R
{ "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" }
cmsvonedl0288g4p26p7q62on
Submission 7Q62ON
{ "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([...
cmsvonedl0289g4p2ce8jc32r
Submission 8JC32R
{ "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" }
cmsvonedl028ag4p29ab51vur
Submission B51VUR
{ "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,...
cmsvonedl028bg4p2tc49c7un
Submission 49C7UN
{ "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 resu...
cmsvonedl028cg4p2ak6r9gqw
Submission 6R9GQW
{ "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...
cmsvonedl028dg4p2npa3un1l
Submission A3UN1L
{ "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": "selectio...
cmsvonedl028eg4p2j997xe73
Submission 97XE73
{ "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]...
cmsvonedl028fg4p2yonk8bfx
Submission NK8BFX
{ "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...
cmsvonedl028gg4p2h1ogpovk
Submission OGPOVK
{ "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...
cmsvonedl028hg4p2n98ack4e
Submission 8ACK4E
{ "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:\...
cmsvonedl028ig4p2fsys7y2i
Submission YS7Y2I
{ "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" }
cmsvonedl028jg4p2vw1baq45
Submission 1BAQ45
{ "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])", ...
cmsvonedl028kg4p2h7x11ehi
Submission X11EHI
{ "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((pre...
cmsvonedl028lg4p2bf7mr0rs
Submission 7MR0RS
{ "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":...
cmsvonedl028mg4p2ssmoqg4f
Submission MOQG4F
{ "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 ...
cmsvonedl028ng4p2au7gsl8z
Submission 7GSL8Z
{ "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...
cmsvonedl028og4p2yotr85al
Submission TR85AL
{ "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_...
cmsvonedl028pg4p20yzfhdci
Submission ZFHDCI
{ "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"...
cmsvowogv02c2g4p21pxxjsiv
Submission XXJSIV
{ "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" }
cmsvowogv02c3g4p2kkcqfo64
Submission CQFO64
{ "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_outp...
cmsvowogv02c4g4p2zgx4ltxr
Submission X4LTXR
{ "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" }
cmsvowogv02c5g4p2aywrh3sy
Submission WRH3SY
{ "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...
cmsvowogw02c6g4p2tzczx8ly
Submission CZX8LY
{ "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]]" }
cmsvowogw02c7g4p2skrkqlbb
Submission RKQLBB
{ "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" }
cmsvowogw02c8g4p22a4rtkhy
Submission 4RTKHY
{ "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" }
cmsvowogw02c9g4p2w91z7420
Submission 1Z7420
{ "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 +=...
cmsvowogw02cag4p2vjzn6jya
Submission ZN6JYA
{ "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"...
cmsvowogw02cbg4p2esf34a77
Submission F34A77
{ "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_...
cmsvowogw02ccg4p23pbeo5qm
Submission BEO5QM
{ "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...
cmsvowogw02cdg4p2k2x8o3gi
Submission X8O3GI
{ "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" }
cmsvowogw02ceg4p2lkkhyk13
Submission KHYK13
{ "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')"...
cmsvowogw02cfg4p2iztbuf45
Submission TBUF45
{ "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] = mi...
cmsvowogw02cgg4p23z8i6bd6
Submission 8I6BD6
{ "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": "pyt...
cmsvowogw02chg4p2annz4uks
Submission NZ4UKS
{ "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...
cmsvowogw02cig4p2t4qzqdc7
Submission QZQDC7
{ "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({...
cmsvowogw02cjg4p2q2povkda
Submission POVKDA
{ "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" }
cmsvowogw02ckg4p2k5a4r8wd
Submission A4R8WD
{ "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": "...
cmsvowogw02clg4p232dj6h72
Submission DJ6H72
{ "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" }
cmsvowogw02cmg4p2t1fqlzys
Submission FQLZYS
{ "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,...
cmsvowogw02cng4p2ndltosnq
Submission LTOSNQ
{ "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 ...
cmsvowogw02cog4p2oco061i2
Submission O061I2
{ "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":...
cmsvowogw02cpg4p28r5wyvke
Submission 5WYVKE
{ "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" }
cmsvowogw02cqg4p29vd9dxeo
Submission D9DXEO
{ "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": "m...
cmsvowogw02crg4p2gk56wuq2
Submission 56WUQ2
{ "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" }
cmsvowogw02csg4p246t1dhbd
Submission T1DHBD
{ "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...
cmsvowogw02ctg4p213fs8p2i
Submission FS8P2I
{ "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]]" }
cmsvowogw02cug4p2j4xqi1lk
Submission XQI1LK
{ "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 els...
cmsvowogw02cvg4p2c0rt43ua
Submission RT43UA
{ "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)", "l...
cmsvq95rh02oug4p2yn7n6i78
Submission 7N6I78
{ "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\", \"Thursda...
cmsvq95rh02ovg4p2euuwncy8
Submission UWNCY8
{ "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...
cmsvq95rh02owg4p2pvmky86e
Submission MKY86E
{ "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...
cmsvq95rh02oxg4p2vlfv49vm
Submission FV49VM
{ "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('4...
cmsvq95rh02oyg4p2p567fdee
Submission 67FDEE
{ "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" }
cmsvq95rh02ozg4p2qjjdp1ej
Submission JDP1EJ
{ "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(r...
cmsvq95rh02p0g4p2bahv4hwd
Submission HV4HWD
{ "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 ...
cmsvq95rh02p1g4p2hegfgbt6
Submission GFGBT6
{ "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 ...
cmsvq95rh02p2g4p23sfxgm50
Submission FXGM50
{ "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_lo...
cmsvq95rh02p3g4p2l49o2zdq
Submission 9O2ZDQ
{ "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 == \")\"...
cmsvq95rh02p4g4p23xvti296
Submission VTI296
{ "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]...
cmsvq95rh02p5g4p25ibq3xpz
Submission BQ3XPZ
{ "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] = ...