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: from typing import List, Tuple\n\ndef optimal_stops(F: int, requests: List[Tuple[int, 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: ## Persistent Palindromic Substrings\n\n**Time limit:** 1 second\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: import math\nfrom typing import List, Tuple\n\ndef smallest_distance(hurricane_path: Lis...
[ { "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: ### Integer Intercept Lines\n\nChef is wandering in the plains and discovers a lattice 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: from collections import Counter\n\ndef can_win_by_swapping(your_cards, opponent_cards):\...
[ { "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 National Health Statistics Agency (NHSA) continuously receiv...
[ { "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 Hierarchy – Most Stocked Subcategory\n\n**Time Limit:** 2 seconds\n**Memor...
[ { "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 (Online)\n\n**Time limit:** 1 second\n\n**Memory limit:** 512 ...
[ { "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 wave_sort(arr):\n \"\"\"\n Sorts the array in a wave-like fashion.\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: A certain company has recently opened a large network of warehouses, which are connected...
[ { "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: ## Real‑Time Order Book – K‑th Cheapest Order\n\n### Problem Statement\nA high‑frequency...
[ { "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_grid_queries(T: int, test_cases: List[Dict[str, Union[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: from typing import List\n\ndef find_words(grid: List[List[str]], words: List[str]) -> Li...
[ { "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 strings. Write a function that groups them by their first char...
[ { "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 Number of Contracts\n\n**Time Limit:** 1 second\n\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: A programming competition is being held, and the organizers need a system to quickly det...
[ { "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\n### Background\nA large code‑review platform stores source files...
[ { "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 have been hired to implement the back‑end of a live editorial ...
[ { "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 most_frequent_token(tokens: str) -> str:\n \"\"\"\n Returns the token with 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: ### Ancient Manuscript Palindrome\n\n**Story**\n\nWhile cataloguing a newly discovered 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: class ListNode:\n def __init__(self, x):\n self.val = x\n self.next = 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 Friend Circles\n\n**Time Limit:** 2 seconds \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: class Node:\n def __init__(self, data: int) -> None:\n self.data = data\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: ## Rotational Dice Equality\n\n**Time Limit:** 2 seconds\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: def is_prime(num):\n \"\"\"\n Check if a number is a prime number.\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: def can_return_to_origin(s: str) -> bool:\n \"\"\"\n Returns true if Petra 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: ### Longest Balanced Substring with Limited Flips\n\n**Problem Statement**\n\nA compress...
[ { "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: class MinStack:\n def __init__(self) -> None:\n \"\"\"\n Initialize 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: from typing import List\n\ndef isIncreasingPath(M: int, N: int, matrix: 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: ### Project State Aggregation\n\n**Time limit:** 2 seconds \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: def convert_to_zigzag(s: str, numRows: int) -> str:\n \"\"\"\n Convert a string to...
[ { "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_profit(prices):\n \"\"\"\n Calculate the maximum profit that can be made 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: ### Prime Score Validation\n\n**Time Limit:** 1 second\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: The only difference between the easy and the hard versions is the maximum value of $k$.\...
[ { "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\n\nYou have a list of integers representing the number of points each player has...
[ { "role": "system", "content": "You will complete a python code block to implement the desired function. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: def simulate_traffic_lights(n: int, m: int):\n \"\"\"\n Simulate a 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: ### Stable File Size Ordering\n\n**Background**\nA cloud‑storage service stores a catalo...
[ { "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_non_decreasing_subsequence(nums: List[int]) -> int:\n \"\"\"\n Calcula...
[ { "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: **Longest Common Suffix in a List of Strings**\n\nYou are given a list of strings. Your ...
[ { "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 data centre contains **N** servers. The *i*-th server initially...
[ { "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\nIn a futuristic amusement park there are **M ticket gates**. Gat...
[ { "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_paths(N: int, M: int, grid: List[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: ### Roman Substring 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: class QueryProcessor:\n def __init__(self, n, arr):\n \"\"\"\n Initiali...
[ { "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 integer array nums, return the number of reverse pairs in the array.\nA rever...
[ { "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 evaluate_expression(expression: str) -> int:\n \"\"\"\n Evaluate a mathematica...
[ { "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 Provinces\n\nIn the kingdom of **Graphland**, there are `V` cities numbered ...
[ { "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\nYou are developing a messaging application that includes a feature to count...
[ { "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 in charge of the status board of a data‑center. The board ...
[ { "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 secret vault can be opened only with a **mirrored key 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: ### Matrix Rotation by k Steps\n\nYou are working on a project involving image processin...
[ { "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: ### Exactly One Prime Outpost on the Path\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: ### Problem Statement\n\nA logistics company needs to ship a set of cargo loads. There 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: ### Coding Assessment Question\n\nBinary Search Trees (BST) are fundamental data structu...
[ { "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_move_zeros(nums):\n \"\"\"\n Takes a list of integers and returns 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: ## Dominant Signal Pairs\n\nIn a deep‑space telemetry system the strength of a received ...
[ { "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 research robot is tasked with inspecting a deck of playing 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: ### Maximum XOR Beauty (Hard Version)\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: def max_overlapping_tasks(n: int, tasks: List[Tuple[int, int]]) -> int:\n \"\"\" Find...
[ { "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 fetch_and_merge(base_url: str, auth_token: str) -> dict:\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: import math\nfrom typing import List\n\ndef is_prime(n: int) -> bool:\n \"\"\"\n 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: def does_return_to_origin(moves: str) -> str:\n \"\"\"\n Determine if the 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: ### Sorting a List of Tuples by Multiple Keys\n\n#### Objective:\nYou are given a list o...
[ { "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: ## Pacific‑Atlantic Dual Flow\n\n### Description\nYou are given a rectangular map 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: ### Volunteer Staffing\n\nIn a massive disaster‑relief operation a coordinator is respon...
[ { "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 given an array `a` of length `N` that represents the curr...
[ { "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: ### Palindrome Feasibility with Online Updates\n\n**Time Limit:** 2 seconds\n**Memory Li...
[ { "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 an `n × n` integer matrix `grid`. The matrix repre...
[ { "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 sunset_views(heights: List[int]) -> List[bool]:\n \"\"\"\n Determine whether e...
[ { "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: ### Mumbling Cipher – Reconstructing the Identifier\n\n#### Problem Statement\nA secret ...
[ { "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 implementing the core of a real‑time collaborative text e...
[ { "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_transform_within_budget(n: int, b: int, initial: str, target: 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: def can_make_values_equal(n: int, m: int, grid: List[str]) -> str:\n \"\"\"\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: ## Problem Title\n**Maximum Floor Area after Range Scaling**\n\n### Statement\nA constru...
[ { "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 heapq import heappush, heappop\nfrom typing import List, Optional\n\nclass ListNode...
[ { "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 cryptographic analyst is examining a massive key‑space segmen...
[ { "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: ## Balance Point in a Sorted Log\n\n**Time Limit:** 1 second \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: ### Two‑Digit Multiple\n\n**Problem Statement**\n\nA secret cryptographic device can onl...
[ { "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 two strings, `s1` and `s2`, consisting only of lower-case English letters....
[ { "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: ### Rounded Bank Balance\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: ## Problem Statement\n\nYou are given a square satellite image of size **n × n**. The im...
[ { "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\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: ## Salary Ledger\n\n**Time Limit:** 2 seconds\n**Memory Limit:** 256 MB\n\n### Problem 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: **Matrix Flatten Shuffle**\n\nTime Limit: 2 seconds\nMemory Limit: 512 MB\n\n### Problem...
[ { "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_value_of_ores(N, W, ores):\n \"\"\"\n Computes the maximum value of ores 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: def custom_sort(m: int, order: List[int], n: int, arr: 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: You are given an array `arr` of `n` integers that represents the height of students stan...
[ { "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\nYou are tasked with implementing a function that checks if an undirected...
[ { "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: class ElevatorControlSystem:\n def __init__(self, number_of_floors: 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 canPartition(nums):\n \"\"\"\n Determines whether the array nums can be partit...
[ { "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 on the firmware of a security monitoring system. ...
[ { "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: ### Chronological User ID Generator\n\n**Time limit:** 1 second\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: ## Problem Statement\n\nA multinational corporation records badge‑swipe events of its em...
[ { "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: ### Even Fibonacci Treasure\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: \nFor two strings s and t, we say "t divides s" if and only if s = t + t + 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\n\nChandan has a 24‑hour digital clock that shows the current 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: In Absurdistan, there are n towns (numbered 1 through n) and m bidirectional railways. 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: def shift_encrypt(shift: int, message: str) -> str:\n \"\"\"\n Encrypt the given 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: ### Log Analyzer – Counting Cryptic Time Windows\n\n#### Problem Statement\nA data‑cente...
[ { "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_losses(M: str) -> int:\n \"\"\"\n Returns the number of matches the seco...