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: def isValidSudoku(board) -> bool:\n \"\"\"\n Determines if a given 9x9 Sudoku boar...
[ { "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 trulyMostPopular(names: List[Tuple[str, int]], synonyms: List[Tuple[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: def decode_string(s: str) -> str:\n \"\"\" Decode the given encoded string by followi...
[ { "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: ### Two‑Character Compression\n\n**Problem Description**\nYou are working on a text‑comp...
[ { "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: Warehouse Inventory Management\n\nProblem Statement\n\nA warehouse contains a grid of it...
[ { "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_team_strength(N: int, K: int, strengths: List[int]) -> int:\n \"\"\" Given 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: def checkWinner(board):\n \"\"\"\n Function to check if there is a winner in a Tic...
[ { "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 Stock Profit Queries\n\n**Time Limit:** 2 seconds\n**Memory Limit:** 512 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: ## Find the Peak in a Hidden Mountain Array\n\n### Problem Statement\nYou are given acce...
[ { "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**:\nYou are developing a program to calculate the amount of solar energy gene...
[ { "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: ### Complete Binary Tree Dashboard\n\n**Time Limit:** 2 seconds\n**Memory Limit:** 256 M...
[ { "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 collections\nfrom typing import List, Any, Tuple\n\ndef process_list(n: int, elem...
[ { "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 sequence of sensor readings recorded over time....
[ { "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 number pi to the 100-th decimal place is\n3.1415926535897932384626433832795028841971...
[ { "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: ### Context\nBinary Search is a fundamental algorithm in computer science, known for its...
[ { "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_increasing_subsequences(n: int, array: List[int]) -> int:\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: ### Global Influence Engine\n\n**Time Limit:** 2 seconds\n**Memory Limit:** 512 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: You are given a string s consisting of lowercase English letters. Your task is to find 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: You've been hired to develop an automated warehouse system. The warehouse consists of 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 Statement\n\nA vast orchard is organized as a **tree** of `n` vertices (numbe...
[ { "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_result_expression(expression: str) -> int:\n \"\"\"Compute the maximum possib...
[ { "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_replacements_to_alternate_parity(N: int, lst: List[int]) -> int:\n \"\"\"Dete...
[ { "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 string $$$s$$$ containing only characters 'a', 'b', and 'c'.\n\nIn one m...
[ { "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 tasked with creating a function that analyzes and repor...
[ { "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: ### 132 Trading Opportunity\n\nA trader keeps a record of the closing price of a single ...
[ { "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 logistics company ships containers every day. The size 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: ### One‑Row Keyboard\n\nPolycarp is going to build a **single‑row keyboard**. The row mu...
[ { "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\nAlice and Bob are playing a game with a deck that contains the 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: You are given a string expression that represents a valid arithmetic expression containi...
[ { "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: ## Volcanic Island Drainage\n\n### Problem Description\nYou are given a rectangular map ...
[ { "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 by a security audit team that needs to verify the c...
[ { "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 description of a **network of encrypted servers...
[ { "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: ## Dense Ranking of Scores\n\n**Time Limit:** 1 second\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: ### Cargo Route Loop Detection\n\n**Story**\nA global logistics platform stores every ca...
[ { "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_dominoes(t, dimensions):\n \"\"\"\n This function calculates the maximum 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: ## Pathfinding in a Two-Dimensional Grid\n\n### Scenario\nYou are working on a navigatio...
[ { "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 a binary array nums, return the maximum number of consecutive 1's in the arr...
[ { "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 `n` rooms and a list of `m` values representing keys. A 2D integ...
[ { "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 **0‑indexed** list `variables` of length `n`. Ea...
[ { "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_sum_of_subsequences(t: int, test_cases: List[Tuple[Tuple[int, int], List[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: ### Archaeologist’s Grid Search\n\n**Problem Statement**\n\nDr. Maya Armitage is catalog...
[ { "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 Index Tree – Height and Leaf Count\n\n**Time Limit:** 2 seconds\n\n**Memory ...
[ { "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 in charge of an infinite chain of lakes numbered by pos...
[ { "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, Optional\n\nclass TreeNode:\n def __init__(self, ...
[ { "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 a member of the telemetry team that monitors a massive dis...
[ { "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 next_permutation(arr):\n \"\"\"\n Modifies arr to the next lexicographical per...
[ { "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 minimizeLateness(tasks: List[Tuple[int, int]]) -> List[int]:\n \"\"\" Schedules 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: from typing import List\n\ndef count_substrings_vowel_to_consonant(T: int, test_cases: 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: ## Regenerating Boss and One‑Time Scrolls\n\n### Statement\nPetya has reached the final ...
[ { "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 array of integers, return the indices of the two numbers that add up to a speci...
[ { "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: ### Best‑Average Regional Team\n\nA multinational corporation has **N** regional teams. ...
[ { "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: ### Weighted Palindromic Subsequence\n\n**Story**\nAgent Maya has intercepted a secret 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: Alyssa is a software engineer who likes to play with strings in her free time. Recently,...
[ { "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 sum_of_c_and_d(c: int, d: int) -> int:\n \"\"\"Returns the sum of c and d.\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 a weighted, directed graph with `n` nodes and `m` edges. Each edge is repr...
[ { "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: ## Asset Ledger Simulation\n\n**Time Limit:** 1 second\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: ### All‑But‑One Product for a Sensor Array\n\n**Time Limit:** 1 second\n**Memory Limit:*...
[ { "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 to find the minimum number of elements that should be removed such 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: Given an integer array `arr` representing the stock prices of a company on different day...
[ { "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 sum_odd_numbers(lst):\n \"\"\"\n Returns the sum of all odd numbers in the giv...
[ { "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: ### Transaction Window Count\n\n**Time Limit:** 1 second \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: ## Robot Escape in a Massive Warehouse\n\n**Time limit:** 1 second\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: def thue_morse_length(n: int) -> int:\n \"\"\"\n Given an integer n (1 ≤ n ≤ 10^5)...
[ { "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 sort_and_find_difference(test_cases):\n \"\"\" From a given list of test cases, 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: ### Minimum Button Presses on a Retro Calculator\n\n#### Problem Statement\nYou have a 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: ## Scripting Engine Expression Evaluator\n\n### Story\nYou have been recruited by the 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: ## Problem Statement\n\nYou are implementing a **code formatter** that can invert the di...
[ { "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_candies(nums):\n \"\"\"\n Returns the maximum number of candies that can b...
[ { "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 three integers n, m, k. A good array arr of size n is defined as follows:\...
[ { "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: ## Overview\n\nWrite a function that takes in a list of words and a single character, an...
[ { "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_remaining_trees(x1: int, y1: int, x2: int, y2: int):\n \"\"\"\n Given 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: ### Frequency Tracker\n\n**Time Limit:** 1 second\n\n**Memory Limit:** 256 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: ### Maximum Verification Depth\n\n**Problem Statement**\n\nA distributed ledger stores 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: ### Electricity Usage Queries\n\n**Time Limit:** 2 seconds \n**Memory Limit:** 512 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: Given a matrix `grid` of size `m x n` which represents a maze, where `1` represents a wa...
[ { "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: ### Energy State Queries\n\n**Time Limit:** 1 second\n**Memory Limit:** 256 MB\n\n#### 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: ### Maximum Sunlit Buildings after Demolition\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: ### Interference‑Free Identification Numbers\n\nYou are the chief engineer of a massive ...
[ { "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 sequence of **sensor readings** recorded over...
[ { "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_player_ranks(t: int, test_cases: List[Tuple[int, List[int]]]) -> List[List[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: def aggregate_sales(reports: List[Dict[str, Union[str, int]]]) -> Dict[str, Dict[str, 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 process_queries(n: int, q: int, arr: List[int], queries: List[Tuple[int, ...]]) -> 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: ### Lexicographically Smallest Itinerary\n\n**Time Limit:** 2 seconds \n**Memory Limit:...
[ { "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_rsa_pin(pin: int) -> str:\n \"\"\" \n Checks if the given 6-digit pin...
[ { "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 implementing the automatic line‑wrapping feature of a m...
[ { "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\nA logistics company operates a fleet of **autonomous delivery dro...
[ { "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: ## Two Sensors and the Triangular Drop\n\nYou are in charge of testing the structural 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: ### Hotel Booking Window\n\nThe Grand Hotel records the number of rooms booked each day....
[ { "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 Prefix Queries\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: ## Problem Statement\n\nIn a magical beehive, cells are arranged in a perfect hexagonal ...
[ { "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: ## Secret Message Scrambler\n\n### Problem Statement\nA secret agency wants to transmit ...
[ { "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 a binary tree, find its minimum depth. The minimum depth is the number of nodes al...
[ { "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 n, find the smallest prime number greater than n. A prime number is a 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: ## Dynamic Islands with Additions and Deletions\n\n### Problem Statement\nA satellite co...
[ { "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 multinational corporation wants to spread an urgent memo to ev...
[ { "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 longest_bitonic_subsequence(arr: 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: import math\nfrom typing import List, Tuple\n\ndef min_trips(T: int, test_cases: 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: def restore_string(s: str, indices: List[int]) -> str:\n \"\"\" Restore the original ...
[ { "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 the country of **Byteburg** a single‑constituency Senate elec...
[ { "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_non_adjacent_sum(arr):\n \"\"\"\n Returns the maximum sum of non-adjacent ...