messages
listlengths
3
3
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ## Problem Description\nYou are given **k** sorted iterators, each producing a non‑decre...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: def is_valid_parentheses(s: str) -> bool:\n \"\"\"\n Determine if a given sequence...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: def can_arrange_bin_ids(bin_ids: List[int]) -> Tuple[str, List[int]]:\n \"\"\"\n D...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: Implement a function that normalizes out of range sequence indexes (converts them to 'in...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: def is_path_exist(grid: List[str]) -> bool:\n \"\"\" Determine whether a path exists ...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ### Problem Statement\n\nA telemetry system continuously records the IDs of sensors that...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ### Balanced Workload Split with Leading‑Digit Parity\n\n#### Statement\nA data‑center s...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: A company utilizes a machine to sort products into categories based on their weights. Ho...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: def three_consecutive_odds(arr: List[int]) -> bool:\n \"\"\"\n Given an array of i...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ## Malware Containment in a Flattened Network\n\n### Problem Statement\nYou are given a ...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: def min_difference_partition(n: int, tasks: List[int]) -> int:\n \"\"\"\n Returns ...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ## Problem Statement\n\nThe city library keeps a chronological log of every **borrow** a...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ## Decrypt the Message\n\nYou have intercepted an encrypted message that is represented ...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: You are given a rooted binary tree with a structure that allows it to be represented as ...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: Consider an input string `s` representing a mathematical expression containing only digi...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ## Problem Statement\nYou are hired to implement the core of an image‑processing pipelin...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: from typing import List\n\ndef strassen_matrix_multiplication(A: List[List[int]], B: Lis...
[ { "role": "system", "content": "You will complete a python code block to implement the desired function. You will only write code blocks." }, { "role": "user", "content": "Complete the following python code: ```python\nfrom typing import Tuple\n\ndef count_valid_dicts(t: Tuple[int, ...]) -> int:...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ### Dynamic Longest Consecutive Block\n\n**Time Limit:** 2 seconds\n**Memory Limit:** 25...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ### Coding Assessment Question\n\n#### Context\nA Turing machine is a mathematical model...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: def count_communications(n: int, m: int, edges: List[Tuple[int, int]]) -> Union[int, str...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ### Problem Statement\nYou are working for a digital library that stores a massive colle...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ### Problem Statement\n\nYou are given a log of **M** key‑press events recorded by a hig...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ### Question\n\nImplement a function `validate_expression` that checks if a mathematical...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ### Maximum Adjusted Profit\n\nYou are given the projected price of a commodity for the ...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ## Satellite Sensor Calibration – First Sensor Over Limit\n\n**Time limit:** 2 seconds\n...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: You are given an incomplete 9x9 Sudoku grid represented by a 2D list, where empty cells ...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: def number_of_paths(n: int, m: int, k: int, dangerous_cells: set) -> int:\n \"\"\" De...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: Given an integer array of size n, write a function that returns the smallest index i (0 ...
[ { "role": "system", "content": "You will complete a python code block to implement the desired function. You will only write code blocks." }, { "role": "user", "content": "Complete the following python code: import csv\n\n\ndef task_func(csv_file_path, column_name):\n \"\"\"\n Reads a CSV ...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: from typing import List, Tuple\n\ndef kth_smallest_unique(a: List[int], queries: List[Tu...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ## Unique Substring Queries\n\n**Problem Statement**\nA high‑security system continuousl...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: **Problem Description**\n\nIn a massive distributed system each software component is id...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ### Problem Statement\nChef has inherited a collection of **N** empty bottles. The *i‑th...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: Write a function that, given a string representing a mathematical expression containing ...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ## Cups and Balls – Query Edition\n\n### Problem Statement\nA magician has **N** cups pl...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ## Limited‑Transit Shipping Queries\n\n**Time Limit:** 2 seconds\n**Memory Limit:** 256 ...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ### Problem Statement\n\nA popular online retailer sells **n** different products. The p...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: def canAssembleModules(n: int, dependencies: List[List[int]]) -> bool:\n \"\"\" Deter...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: You are given a list of integers representing the heights of a series of buildings. You ...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ### Data‑Center Broadcast\n\n#### Statement\nYou are given a data‑center grid with **N**...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ### Problem Title\n**Maximum Consecutive Burst Length**\n\n#### Statement\nA network of ...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: The Guardians of Artefacts have hidden a precious artefact in one of the cells of a 2D g...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: def min_changes_to_palindrome(n: int) -> int:\n \"\"\"\n Given a positive integer ...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: def solve(n: int, q: int, s: str, queries: List[str]) -> List[str]:\n \"\"\" Solve th...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ### Infinite Piano Keyboard\n\nA grand piano stretches infinitely to the right. The colo...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ### Remainder Comparison\n\n**Time limit:** 2 seconds\n\n**Memory limit:** 256 megabytes...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: Problem Statement\n\nYou are developing a real‑time analytics engine that continuously r...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: You are given a 2D grid of size m x n filled with non-negative numbers. The task is to f...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: def get_word_weight(word: str) -> int:\n \"\"\"\n Calculates the weight of a given...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: def length_of_LIS(nums) -> int:\n \"\"\" Returns the length of the longest increasing...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ## Alien Alphabet Reconstruction\n\n**Time Limit:** 2 seconds\n**Memory Limit:** 256 MB\...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ## Balanced Transmission Pattern\n\n**Time limit:** 1 second\n**Memory limit:** 256 MB\n...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ### Asterisk Triangles\n\n**Time Limit:** 1 second \n**Memory Limit:** 64 MB\n\n#### Pr...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ### Sorting an Array with a Custom Comparator\n\nYou are tasked with developing software...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: In English, numbers can be written in words (e.g., \"one\", \"two\", \"three\", etc.). F...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: def find_quest_order(n: int, Q: List[int]) -> Union[List[int], str]:\n \"\"\" Determi...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: \nGiven two strings first and second, consider occurrences in some text of the form &quo...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: You are given a grid consisting of n rows and m columns. Each cell of the grid contains ...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ### DNA Fragment Anagram Matching\n\n**Time limit:** 1 second\n**Memory limit:** 256 MB\...
[ { "role": "system", "content": "You will complete a python code block to implement the desired function. You will only write code blocks." }, { "role": "user", "content": "Complete the following python code: ```python\ndef drone_safety_counts(N: int, M: int, column_names: list[str], rows: list[l...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ### SensorAlert – Online Severity Accumulator\n\n**Time limit:** 2 seconds\n**Memory lim...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: def max_beauty(T: int, test_cases: List[Tuple[int, List[int]]]) -> List[int]:\n \"\"\...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ### Heavy Spam Segments\n\n**Problem Statement**\n\nYou are given a chat log consisting ...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ### Scenario\nImage processing often necessitates manipulating pixels based on their int...
[ { "role": "system", "content": "You will complete a python code block to implement the desired function. You will only write code blocks." }, { "role": "user", "content": "Complete the following python code: ```python\nfrom typing import List\n\ndef compute_histogram(csv_file_path: str, column_n...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: Peter loves playing with strings. Recently, he invented a game with strings where he rep...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ### Task\nImplement a function `flatten_and_filter(lst: list, threshold: int) -> list` t...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ### Problem Statement\nYou are hired to implement the core of a real‑time calendar servi...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ### Royal Garden – Dual Cyclic Arrangement\n\nThe royal gardener has been given a **dist...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: def calculate_total_cost(items, shopping_list) -> float:\n \"\"\"\n Calculates the...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ### Temperature Trend Analyzer\n\n**Time Limit:** 1 second \n**Memory Limit:** 64 MB\n\...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: You are designing a system to manage a list of reservations at a restaurant. Each reserv...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ## Synchronized Alarm\n\n### Problem Statement\nA large monitoring system records a sens...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: def maxMovies(movies: List[int], limit: int) -> int:\n \"\"\"\n Finds the maximum ...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ### Mythical Menagerie\n\nHercules is about to step into the arena of ancient Greece. Be...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: def countConsecutiveSubstrings(s: str) -> int:\n \"\"\" Returns the number of substri...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: from typing import List, Tuple\n\ndef trap_rain_water(height: List[int]) -> int:\n \"...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: def min_distance(n: int, points: List[Tuple[int, int]]) -> int:\n \"\"\" Find the min...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ## Problem Statement\n\nIn a hierarchical communication network every device is represen...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: def count_unique_car_ids(n: int, car_ids: List[int]) -> int:\n \"\"\" \n Returns t...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ### Maximum Profit Window with Fixed Volatility\n\n**Problem Statement**\n\nA trader rec...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: import heapq\nimport sys\nfrom collections import defaultdict\nfrom typing import List, ...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: def longest_palindrome_prefix(arr: List[int]) -> List[int]:\n \"\"\" Returns the long...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: A company has hired you to design a function that returns the minimum number of operatio...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: def max_contiguous_buildings(N: int, heightsA: List[int], heightsB: List[int]) -> int:\n...
[ { "role": "system", "content": "You will complete a python code block to implement the desired function. You will only write code blocks." }, { "role": "user", "content": "Complete the following python code: def tribonacci(n: int):\n \"\"\"The Tribonacci sequence is a generalization of the Fi...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: def find_positions(arr, start, end):\n \"\"\"\n Finds the position of the leftmost...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ## Bird Sanctuary Queries\n\n### Problem Statement\nThe **Sanctuary of Wings** keeps a l...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ## Deadline Grid Navigation\n\n**Time limit:** 2 seconds\n\n**Memory limit:** 256 MB\n\n...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: from typing import List, Tuple\n\ndef has_path_with_sum(n: int, m: int, S: int, edges: L...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: One day the Codeforces round author sat exams. He had n exams and he needed to get an in...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: def longest_subarray(arr):\n \"\"\"\n Returns the length of the longest subarray w...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: \nGiven an array of positive integers nums, return an array answer that consists of the ...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ### Coding Question: Implement a Genetic Algorithm for the Traveling Salesman Problem (T...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ### Rescue Drone – Top‑K Supply Caches\n\nYou are given a **0‑indexed** rectangular grid...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: def is_prime(n):\n \"\"\"\n Check if a number is a prime number.\n >>> is_prime...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ## Kingdom Watchtowers – Range Maximum Index Queries\n\n### Problem Statement\nIn the ki...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: from typing import List\n\ndef find_frequent_product(transactions: List[str]) -> str:\n ...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ## Reservoir Management\n\n**Time Limit:** 1 second\n\n**Memory Limit:** 256 MB\n\n### P...