version
stringclasses
1 value
style
stringclasses
2 values
subset
stringclasses
12 values
question_id
stringlengths
9
23
question
stringlengths
27
8.13k
solution
stringlengths
99
5.97k
test
stringlengths
105
4.45k
test_info
listlengths
0
13
gpt_pass_sequence
listlengths
1
10
gpt_pass_trial_num
int64
1
10
gpt_difficulty
stringclasses
3 values
gpt_pass_percentage
float64
0.1
1
trials
dict
chosen_trial
stringclasses
10 values
metadata
dict
benchmark_similarity
float64
0.16
0.93
benchmark_instruction
stringclasses
1 value
benchmark_task_id
stringclasses
1 value
filter_reason
stringclasses
1 value
base_id
stringlengths
7
21
variant
stringclasses
2 values
top_function_names
listlengths
2
13
n_top_functions
int64
2
13
helper_call_edges
listlengths
1
16
n_helper_call_edges
int64
1
16
harness_functions
listlengths
0
3
structural_wrapper
bool
1 class
class_names
listlengths
0
5
has_class
bool
2 classes
test_kind
stringclasses
1 value
test_has_solution_import
bool
2 classes
third_party_imports
listlengths
0
5
stdlib_only
bool
2 classes
question_norm_sha1
stringlengths
40
40
solution_ast_sha1
stringlengths
40
40
v1.0
instruct
Taco
Taco_66441_I
Binary Tree Height and Balance Check You are given the root node of a binary tree. Your task is to write a function to determine the height of the tree and whether the tree is balanced or not. In a balanced binary tree, the difference in the height of the left and right subtrees of every node is not more than 1. Inp...
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None def build_tree(level_order): from collections import deque if not level_order or level_order[0] == 'null': return None root = TreeNode(int(level_order[0])) queue = deque([roo...
from solution import process_test_cases def test_case_1(): T = 2 test_cases = [ "3 9 20 null null 15 7", "1 2 2 3 3 null null 4 4" ] result = process_test_cases(T, test_cases) assert result == ["3 1", "4 0"] def test_case_single_node(): T = 1 test_cases = ["1"] result =...
[]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import collections\n\nclass TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n self.left = left\n self.right ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00066441", "row_id": 66441, "seed_ids": "[5948]" }
0.773515
Taco_66441
I
[ "build_tree", "tree_height_and_balance", "process_test_cases" ]
3
[ [ "process_test_cases", "build_tree" ], [ "process_test_cases", "tree_height_and_balance" ] ]
2
[ "process_test_cases" ]
false
[ "TreeNode" ]
true
pytest
true
[]
true
ef0d1954ed142e5b177748e7513cb0a538c90302
4fe756d98e42a543271382c927091a3a51a63fa7
v1.0
instruct
Taco
Taco_66549_I
Given an array of integers, you need to determine if it is possible to select a contiguous subarray such that the product of its elements is a perfect square. A perfect square is an integer that is the square of some integer; thus, it can be written as $k^2$ where $k$ is an integer. -----Input----- The input consist...
def is_perfect_square(n): if n < 0: return False root = int(n ** 0.5) return root * root == n def perfect_square_subarray_exists(n, arr): for i in range(n): product = 1 for j in range(i, n): product *= arr[j] if is_perfect_square(product): ...
def test_is_perfect_square(): assert not is_perfect_square(-1) # Negative numbers assert is_perfect_square(0) # Zero assert is_perfect_square(1) # Smallest perfect square assert not is_perfect_square(2) # Non-perfect square assert is_perfect_square(4) # Small perfect square def test_perfect_square_...
[ { "docstring": null, "function_declaration": "def is_perfect_square(n):", "function_name": "is_perfect_square", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def perfect_square_subarray_exists(n, arr):", "function_name": "perfect_square_subarray_exists", ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_perfect_square(num):\n if num < 0:\n return False\n root = int(num**0.5)\n return root * root == num\n\ndef has_perfect_square_subarray(n, a...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00066549", "row_id": 66549, "seed_ids": "[19616]" }
0.664084
Taco_66549
I
[ "is_perfect_square", "perfect_square_subarray_exists", "solve" ]
3
[ [ "perfect_square_subarray_exists", "is_perfect_square" ], [ "solve", "perfect_square_subarray_exists" ] ]
2
[]
false
[]
false
pytest
false
[]
true
c984c43e5701df68ca6871a1e9d57880eefc8881
5986561a7bf5d7f9a03fed33d847be58729d270a
v1.0
instruct
Taco
Taco_66585_I
You are working with a new encryption scheme that involves some operations with prime numbers. The encryption and decryption operations depend on the following property: for any prime number $p$, there are exactly $p-1$ positive integers less than $p$ that are coprime with $p$. Given a list of numbers, identify how man...
def is_prime(n): """ Returns True if n is a prime number, False otherwise. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False ...
from solution import is_prime, prime_coprime_count def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(18) == False assert is_prime(1) == False def test_prime_coprime_count(): assert prime_coprim...
[ { "docstring": "Returns True if n is a prime number, False otherwise.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "For each number in numbers, return \"Not prime\" if it's not a prime number.\nIf it is a prime number, r...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Returns True if n is a prime number, False otherwise.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00066585", "row_id": 66585, "seed_ids": "[2541]" }
0.622463
Taco_66585
I
[ "is_prime", "prime_coprime_count" ]
2
[ [ "prime_coprime_count", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
83ea9bfcbe2fc91367faa8e5a768b29cdccd8764
0ec8fce9558e4620e50d0774dd034314f044fab9
v1.0
instruct
Taco
Taco_66607_I
Given an integer N, you are tasked with finding the number of ways to place N identical balls into N distinct bins such that no bin is left empty. But there's a twist: each bin has a maximum capacity K. Numz, the God of Numbers, challenges you to determine the number of valid distributions modulo 10^9 + 7. INPUT: The ...
MOD = 10**9 + 7 def factorial(n): if n == 0 or n == 1: return 1 result = 1 for i in range(2, n + 1): result = (result * i) % MOD return result def count_ways(N, K): if K <= 0: return 0 if K == 1: return 1 if N == 1 else 0 # Using Stirling numbers of the sec...
from solution import count_ways def test_small_cases(): assert count_ways(3, 2) == 6 assert count_ways(4, 3) == 24 assert count_ways(5, 1) == 0 def test_extreme_cases(): assert count_ways(1, 1) == 1 assert count_ways(1, 1000) == 1 assert count_ways(1000, 1000) > 0 def test_zero_capacity(): ...
[ { "docstring": null, "function_declaration": "def factorial(n):", "function_name": "factorial", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def count_ways(N, K):", "function_name": "count_ways", "parameter_list": "(N, K)" }, { "docstring": nul...
[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "MOD = 10**9 + 7\n\ndef solve_ball_distribution(N, K):\n # use a 2D DP array to store the number of ways\n dp = [[0] * (N + 1) for _ in range(N + 1)]\n dp[...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00066607", "row_id": 66607, "seed_ids": "[5981]" }
0.604009
Taco_66607
I
[ "factorial", "count_ways", "solve", "main" ]
4
[ [ "count_ways", "factorial" ], [ "solve", "count_ways" ] ]
2
[]
false
[]
false
pytest
true
[]
true
683e274b8d5f59611dd6b3a6e57c527f18547901
487ef520c5c9a0fc66a6bf9cf241f0f1bd663b58
v1.0
instruct
Taco
Taco_66651_I
You are organizing a reading contest and each participant will be reading books from a common pool. There are $N$ books in the pool and you are given a list of integers, where the $i$-th integer denotes the number of pages in the $i$-th book. Each participant will select a subset of books such that the total number of...
def knapsack(T, data): results = [] for case in data: N, P = case[0] pages = case[1] dp = [0] * (P + 1) for page in pages: for j in range(P, page - 1, -1): dp[j] = max(dp[j], dp[j - page] + page) results.append(d...
from solution import optimal_pages_read def test_sample_cases(): T = 3 participants_data = [ [(3, 50), [10, 20, 30]], [(4, 100), [40, 15,25,20]], [(5, 60), [10, 10, 10, 10, 10]] ] assert optimal_pages_read(T, participants_data) == [50, 100, 50] def test_single_book(): T = 1...
[ { "docstring": null, "function_declaration": "def knapsack(T, data):", "function_name": "knapsack", "parameter_list": "(T, data)" }, { "docstring": null, "function_declaration": "def optimal_pages_read(T, participants_data):", "function_name": "optimal_pages_read", "parameter_lis...
[ 0, 0, 0, 0, 1 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def optimal_book_subset(T, test_cases):\n \"\"\"\n Returns the total number of pages in the optimal subset for each participant.\n \n Each participant'...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00066651", "row_id": 66651, "seed_ids": "[24247]" }
0.74789
Taco_66651
I
[ "knapsack", "optimal_pages_read" ]
2
[ [ "optimal_pages_read", "knapsack" ] ]
1
[]
false
[]
false
pytest
true
[]
true
36df164181f63c235cb1244ca092729551a99a31
3a755c5c91d26be336789160523692cce3619d5a
v1.0
instruct
Taco
Taco_66762_I
### Preface A logistics company needs help optimizing its delivery routes. The company has multiple warehouses and each warehouse has its own distinct list of delivery locations for a day. All warehouses are connected through a grid layout of streets, where the delivery trucks can move horizontally or vertically. Due t...
def total_distance(warehouse, locations): """ Calculate the total Manhattan distance from the warehouse to all delivery locations. """ warehouse_x, warehouse_y = warehouse["x"], warehouse["y"] return sum(abs(warehouse_x - loc[0]) + abs(warehouse_y - loc[1]) for loc in locations) def find_optimal_wa...
from solution import find_optimal_warehouse def test_single_warehouse(): warehouses = [{"id": 1, "x": 3, "y": 2}] delivery_locations = {1: [[5,5],[3,6],[7,8]]} result = find_optimal_warehouse(warehouses, delivery_locations) assert result == "The optimal warehouse is number 1 with the coordinates x = 3 ...
[ { "docstring": "Calculate the total Manhattan distance from the warehouse to all delivery locations.", "function_declaration": "def total_distance(warehouse, locations):", "function_name": "total_distance", "parameter_list": "(warehouse, locations)" }, { "docstring": null, "function_decl...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def calculate_total_distance(warehouse, delivery_locations):\n \"\"\"\n Calculate the total travel distance from the given warehouse to all delivery location...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00066762", "row_id": 66762, "seed_ids": "[5678]" }
0.637249
Taco_66762
I
[ "total_distance", "find_optimal_warehouse" ]
2
[ [ "find_optimal_warehouse", "total_distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
47139309e3fd692eed891eff3518c3593c36a64c
06c8d3d13af30c3ef14cf649cf230bd132463bb7
v1.0
instruct
Taco
Taco_66770_I
## Task Given a list of integers, return a new list containing only the prime numbers from the original list. A prime number is defined as a number greater than 1 that has no positive divisors other than 1 and itself. ## Function Signature `def filter_primes(nums: List[int]) -> List[int]:` ## Input - `nums`: A list o...
from typing import List def is_prime(n: int) -> bool: """ Helper function to determine if a number is a prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False p = 3 while p * p <= n: if n % p == 0: return False ...
from solution import filter_primes, is_prime def test_single_element(): assert filter_primes([2]) == [2] assert filter_primes([4]) == [] assert filter_primes([1]) == [] def test_mixed_elements(): assert filter_primes([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [2, 3, 5, 7] assert filter_primes([10, 20, 30...
[ { "docstring": "Helper function to determine if a number is a prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list containing only the prime numbers from the original list.", "function_declaration": "d...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from typing import List\n\ndef filter_primes(nums: List[int]) -> List[int]:\n def is_prime(num: int) -> bool:\n if num <= 1:\n return False\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00066770", "row_id": 66770, "seed_ids": "[5567]" }
0.667279
Taco_66770
I
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
22af735ba6b983101b14c9f259d8cf4550eb5223
e829bc7424e0e28f0fd45a974ef0d5fcfa92316e
v1.0
instruct
Taco
Taco_66795_I
The Galaxy Explorers is a group of astronauts on an important mission. They have several missions, each involving travelling between planets connected by space routes. The safety of a route is judged by the number of asteroids frequently passing through it. Every route has a safety score representing the number of aste...
def find(parent, i): if parent[i] == i: return i else: return find(parent, parent[i]) def union(parent, rank, x, y): root_x = find(parent, x) root_y = find(parent, y) if root_x != root_y: if rank[root_x] > rank[root_y]: parent[root_y] = root_x elif r...
def test_sample_input(): from io import StringIO import sys input_str = "5 6\n1 2 5\n1 3 10\n2 3 3\n2 4 7\n3 5 9\n4 5 2\n" expected_output = "YES\n" sys.stdin = StringIO(input_str) try: main() finally: sys.stdin = sys.__stdin__ def test_no_safest_route(): from io im...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n else:\n return find(parent, parent[i])\n\ndef union(parent, rank, x, y):\n root_x = f...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00066795", "row_id": 66795, "seed_ids": "[2999]" }
0.658093
Taco_66795
I
[ "find", "union", "can_form_safest_route_system", "main" ]
4
[ [ "can_form_safest_route_system", "find" ], [ "can_form_safest_route_system", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
false
[]
true
03975c5c7feeba8cc7c7a2e7b775539e6546382c
dfc9d787d8dadf69a7aaaa3b143d598b016b4a2b
v1.0
instruct
Taco
Taco_66863_I
John is organizing a charity event and he needs to manage the donations. Each donor contributes a certain amount of money and a certain number of items. John needs to verify that the total value of donations matches the recorded total sum provided in a list. As John's assistant, you are assigned to confirm the correct ...
def verify_donations(donations): """ Verifies if the calculated total donation value matches the provided total value for each donation. Parameters: donations (list): A list of tuples where each tuple contains (money, item_quantity, item_value, provided_total_value) Returns: li...
from solution import verify_donations def test_correct_calculations(): donations = [ (100, 5, 20, 200), (200, 3, 50, 350), (150, 10, 10, 250), (300, 2, 75, 450) ] expected = ["CORRECT", "CORRECT", "CORRECT", "CORRECT"] assert verify_donations(donations) == expected def ...
[ { "docstring": "Verifies if the calculated total donation value matches the provided total value for each donation.\n\nParameters:\n donations (list): A list of tuples where each tuple contains (money, item_quantity, item_value, provided_total_value)\n\nReturns:\n list: A list containing \"CORRECT\" or \"...
[ 0, 0, 0, 0, 1 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def verify_donations(donations):\n \"\"\"\n Verifies if the calculated total value matches the provided total value for each donation.\n \n Args:\n ...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00066863", "row_id": 66863, "seed_ids": "[8521]" }
0.674718
Taco_66863
I
[ "verify_donations", "read_input_and_verify" ]
2
[ [ "read_input_and_verify", "verify_donations" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0e9cc882a63ce105de994ecd830e94f2aef11c78
be6c4383456924d022a4a68eb34bba2aaea8c912
v1.0
instruct
Taco
Taco_66886_I
A popular problem in graph theory is the Shortest Path Problem, where the goal is to find the shortest path between two vertices in a weighted graph. In this task, you are asked to implement Dijkstra's algorithm to solve the single-source shortest path problem for a given graph. Write a program that reads the descript...
import heapq def dijkstra(V, edges, source): graph = {i: [] for i in range(V)} for u, v, w in edges: graph[u].append((v, w)) distances = [float('inf')] * V distances[source] = 0 priority_queue = [(0, source)] while priority_queue: current_distance, current_vertex = hea...
def test_single_source_shortest_path(): assert single_source_shortest_path(5, 6, [[0, 1, 2], [0, 2, 4], [1, 2, 1], [1, 3, 7], [2, 4, 3], [3, 4, 1]], 0) == [0, 2, 3, 9, 6] assert single_source_shortest_path(4, 4, [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 0, 4]], 0) == [0, 1, 3, 6] assert single_source_shortest_p...
[ { "docstring": null, "function_declaration": "def dijkstra(V, edges, source):", "function_name": "dijkstra", "parameter_list": "(V, edges, source)" }, { "docstring": null, "function_declaration": "def single_source_shortest_path(V, E, edges, source):", "function_name": "single_source...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef dijkstra(V, edges, source):\n graph = [[] for _ in range(V)]\n for u, v, w in edges:\n graph[u].append((v, w))\n \n distance...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00066886", "row_id": 66886, "seed_ids": "[21856]" }
0.725145
Taco_66886
I
[ "dijkstra", "single_source_shortest_path" ]
2
[ [ "single_source_shortest_path", "dijkstra" ] ]
1
[]
false
[]
false
pytest
false
[]
true
2261b1ae818217e4eaf21ce8059bf3c7a7ce694e
96c1923f9973798bc34fe44d16f5fa3c7db50093
v1.0
instruct
Taco
Taco_66894_I
You are given two strings, S1 and S2. Determine if S1 is a subsequence of S2. A subsequence is a sequence that appears in the same relative order, but not necessarily consecutively. Constraints * 1 <= len(S1), len(S2) <= 1000 * S1 and S2 contain only lowercase English letters. Input Input is given from Standard Inp...
def is_subsequence(S1, S2): """ Determines if S1 is a subsequence of S2. """ iter_s2 = iter(S2) return all(char in iter_s2 for char in S1) def check_subsequence(S1, S2): if is_subsequence(S1, S2): return "YES" else: return "NO"
def test_check_subsequence(): assert check_subsequence("abc", "ahbgdc") == "YES" assert check_subsequence("axc", "ahbgdc") == "NO" assert check_subsequence("ace", "abcde") == "YES" assert check_subsequence("aec", "abcde") == "NO" assert check_subsequence("abc", "abc") == "YES" assert check_subse...
[ { "docstring": "Determines if S1 is a subsequence of S2.", "function_declaration": "def is_subsequence(S1, S2):", "function_name": "is_subsequence", "parameter_list": "(S1, S2)" }, { "docstring": null, "function_declaration": "def check_subsequence(S1, S2):", "function_name": "check_...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_subsequence(s1, s2):\n \"\"\"\n Determines if s1 is a subsequence of s2.\n \"\"\"\n iter_s2 = iter(s2)\n return all(char in iter_s2 for char ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00066894", "row_id": 66894, "seed_ids": "[15898]" }
0.752039
Taco_66894
I
[ "is_subsequence", "check_subsequence" ]
2
[ [ "check_subsequence", "is_subsequence" ] ]
1
[]
false
[]
false
pytest
false
[]
true
f53c32c1d3a6cbc9ed9eac7179ea245b3d3686ce
6a72a44c87109fc4d2989e72ea0b964e3e3d0866
v1.0
instruct
Taco
Taco_66903_I
Sam, a logistics manager, is tasked with optimizing the delivery routes for his company. The goal is to minimize the distance traveled by delivery trucks to ensure fuel efficiency and timely deliveries. Given a set of coordinates representing delivery locations, Sam wants to determine the minimum total distance that th...
import itertools import math def calculate_distance(point1, point2): """ Returns the Euclidean distance between two points. """ return math.sqrt((point1[0] - point2[0])**2 + (point1[1] - point2[1])**2) def tsp_min_distance(n, coordinates): """ Returns the minimum total travel distance for the ...
from solution import tsp_min_distance def test_tsp_min_distance_example(): coordinates = [(0, 0), (2, 0), (2, 2), (0, 2)] assert tsp_min_distance(4, coordinates) == 8.00 def test_tsp_min_distance_two_locations(): coordinates = [(0, 0), (3, 4)] assert tsp_min_distance(2, coordinates) == 10.00 # (0,0) ...
[ { "docstring": "Returns the Euclidean distance between two points.", "function_declaration": "def calculate_distance(point1, point2):", "function_name": "calculate_distance", "parameter_list": "(point1, point2)" }, { "docstring": "Returns the minimum total travel distance for the TSP problem...
[ 0, 0, 0, 0, 0, 0, 1, 0, 1, 1 ]
3
hard
0.3
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import itertools\nimport math\n\ndef calculate_distance(point1, point2):\n \"\"\"\n Calculate the Euclidean distance between two points.\n \"\"\"\n ret...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00066903", "row_id": 66903, "seed_ids": "[207]" }
0.676252
Taco_66903
I
[ "calculate_distance", "tsp_min_distance" ]
2
[ [ "tsp_min_distance", "calculate_distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
401b71cc41fb66a1e8cb11c35370071c69a51e25
5e1bfb9b235bed437a2b8a10c03cde7802081adc
v1.0
instruct
Taco
Taco_66953_I
In a mystical land, there is a special kind of forest called the Fibonacci Forest. This forest has magical trees that follow the Fibonacci sequence. The first two trees in the sequence have heights of 1 and 1. Each subsequent tree's height is the sum of the heights of the two preceding trees. Your task is to determine...
MOD = 10**9 + 7 def matrix_mult(A, B): """ Multiplies two 2x2 matrices A and B under modulo MOD """ return [ [(A[0][0] * B[0][0] + A[0][1] * B[1][0]) % MOD, (A[0][0] * B[0][1] + A[0][1] * B[1][1]) % MOD], [(A[1][0] * B[0][0] + A[1][1] * B[1][0]) % MOD, (A[1][0] * B[0][1] + A[1][1] * B[1...
from solution import fibonacci_sum, MOD def test_fibonacci_sum(): assert fibonacci_sum(1) == 1 assert fibonacci_sum(2) == 2 assert fibonacci_sum(5) == 12 assert fibonacci_sum(10) == 143 def test_fibonacci_sum_large(): # For large values of n, we just want to ensure it runs and # the results ar...
[ { "docstring": "Multiplies two 2x2 matrices A and B under modulo MOD", "function_declaration": "def matrix_mult(A, B):", "function_name": "matrix_mult", "parameter_list": "(A, B)" }, { "docstring": "Raises a 2x2 matrix to the power of exponent under modulo MOD using exponentiation by squarin...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def fib_sum(n):\n MOD = 10**9 + 7\n \n def matrix_mult(A, B):\n return [\n [(A[0][0] * B[0][0] + A[0][1] * B[1][0]) % MOD, (A[0][0] * B[...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00066953", "row_id": 66953, "seed_ids": "[20126]" }
0.498816
Taco_66953
I
[ "matrix_mult", "matrix_pow", "fibonacci_sum" ]
3
[ [ "fibonacci_sum", "matrix_pow" ], [ "matrix_pow", "matrix_mult" ] ]
2
[]
false
[]
false
pytest
true
[]
true
91c1e204d4c98dc63dcc991f92e7e752405010fb
75e202459aeb1032832de52237c84623708d19e3
v1.0
instruct
Taco
Taco_67034_I
Aliens have landed, and they are huge fans of prime numbers! They want to know how many prime numbers exist within different ranges of natural numbers. Your task is to help them by creating a program that processes a series of queries to count the number of prime numbers within specific ranges. To fulfill this, your p...
def preprocess_sieve(n): """ Preprocesses and returns the prime count up to n using the Sieve of Eratosthenes. """ is_prime = [True] * (n + 1) p = 2 while p * p <= n: if is_prime[p]: for i in range(p * p, n + 1, p): is_prime[i] = False p += 1 is_p...
import pytest from solution import process_queries def test_example_cases(): queries = [(2, 10), (11, 20), (1, 100)] expected = [4, 4, 25] assert process_queries(queries) == expected def test_single_value_range(): queries = [(5, 5), (10, 10)] expected = [1, 0] assert process_queries(queries) =...
[ { "docstring": "Preprocesses and returns the prime count up to n using the Sieve of Eratosthenes.", "function_declaration": "def preprocess_sieve(n):", "function_name": "preprocess_sieve", "parameter_list": "(n)" }, { "docstring": "Returns the count of prime numbers in the range [l, r] using...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sieve_of_eratosthenes(max_number):\n \"\"\"\n Function to use the Sieve of Eratosthenes algorithm to find all primes up to max_number.\n \"\"\"\n i...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00067034", "row_id": 67034, "seed_ids": "[18104]" }
0.652622
Taco_67034
I
[ "preprocess_sieve", "count_primes_in_range", "process_queries" ]
3
[ [ "process_queries", "count_primes_in_range" ], [ "process_queries", "preprocess_sieve" ] ]
2
[ "process_queries" ]
false
[]
false
pytest
true
[]
true
eec79c90c97374868a6496b4be8ab30c5df0602b
f7a7308bee1f86e053b9f46e2245bfda8409b5d6
v1.0
instruct
Taco
Taco_67037_I
Alice loves to collect different types of coins. She has $n$ types of coins, each type has an infinite number of coins. The $i$-th type of coin has a value $v_i$. Bob wants to give Alice a present on her birthday. He knows that Alice loves numbers that are divisible by every coin value she has collected, so he decides ...
from math import gcd from functools import reduce def lcm(a, b): """ Compute the Least Common Multiple of a and b """ return a * b // gcd(a, b) def smallest_number_divisible_by_all_coins(q, queries): results = [] for i in range(q): n = queries[i][0] coins = set(queries[i][1]) ...
import pytest from solution import lcm, smallest_number_divisible_by_all_coins def test_lcm(): assert lcm(4, 5) == 20 assert lcm(6, 8) == 24 assert lcm(21, 6) == 42 assert lcm(2, 3) == 6 def test_smallest_number_divisible_by_all_coins_case1(): result = smallest_number_divisible_by_all_coins(3, [ ...
[ { "docstring": "Compute the Least Common Multiple of a and b", "function_declaration": "def lcm(a, b):", "function_name": "lcm", "parameter_list": "(a, b)" }, { "docstring": null, "function_declaration": "def smallest_number_divisible_by_all_coins(q, queries):", "function_name": "sma...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\nfrom functools import reduce\n\ndef lcm(a, b):\n return abs(a * b) // math.gcd(a, b)\n\ndef smallest_divisible_number(coins):\n distinct_coins =...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00067037", "row_id": 67037, "seed_ids": "[16379]" }
0.729121
Taco_67037
I
[ "lcm", "smallest_number_divisible_by_all_coins" ]
2
[ [ "smallest_number_divisible_by_all_coins", "lcm" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c78c56bf9fdbbd9300513a98c68445e98f40dc09
ce299bdce4820644318c9e7665155724947958a5
v1.0
instruct
Taco
Taco_67083_I
A binary tree is given as a list of integers in level order, where null values are denoted by -1. Determine if the binary tree is height-balanced. A height-balanced binary tree is defined as a binary tree in which the left and right subtrees of every node differ in height by no more than 1. Example 1: Input: tree = [...
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def insert_level_order(arr, root, i, n): if i < n: if arr[i] == -1: return None temp = TreeNode(arr[i]) root = temp root.left...
from solution import is_height_balanced def test_balanced_tree(): assert is_height_balanced([3, 9, 20, -1, -1, 15, 7]) == True def test_unbalanced_tree(): assert is_height_balanced([1, 2, 2, 3, 3, -1, -1, 4, 4]) == False def test_empty_tree(): assert is_height_balanced([]) == True def test_single_node_t...
[]
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n self.left = left\n self.right = right\n\ndef level_o...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00067083", "row_id": 67083, "seed_ids": "[6500]" }
0.742954
Taco_67083
I
[ "insert_level_order", "check_balanced", "is_height_balanced" ]
3
[ [ "is_height_balanced", "check_balanced" ], [ "is_height_balanced", "insert_level_order" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
65cec23d43e9a98ede847a56b5cdb125da1d9518
741b2e476b8ebacb35c04efb9ae813c80795d2b2
v1.0
instruct
Taco
Taco_67093_I
In a particular kingdom, there are n cities connected by m bidirectional roads. Every road is characterized by two integers a and b indicating that there is a road between city a and city b. The kingdom's rule is that each road can be safely traversed without passing through more than one other city. The king wishes t...
def is_connected(n, m, connections): from collections import defaultdict, deque # Create the adjacency list for the graph graph = defaultdict(list) for a, b in connections: graph[a].append(b) graph[b].append(a) # Use BFS to check if all nodes are reachable from node 1 v...
from solution import connected_kingdom def test_fully_connected(): assert connected_kingdom(5, 5, [(1, 2), (2, 3), (3, 4), (4, 5), (2, 4)]) == "YES" def test_not_fully_connected(): assert connected_kingdom(4, 2, [(1, 2), (3, 4)]) == "NO" def test_single_city(): assert connected_kingdom(1, 0, []) == "YES"...
[ { "docstring": null, "function_declaration": "def is_connected(n, m, connections):", "function_name": "is_connected", "parameter_list": "(n, m, connections)" }, { "docstring": null, "function_declaration": "def connected_kingdom(n, m, roads):", "function_name": "connected_kingdom", ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def are_cities_connected(n, m, roads):\n from collections import defaultdict, deque\n\n if n == 0:\n return 'NO'\n\n if m == 0:\n return 'YE...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00067093", "row_id": 67093, "seed_ids": "[13645]" }
0.788219
Taco_67093
I
[ "is_connected", "connected_kingdom" ]
2
[ [ "connected_kingdom", "is_connected" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d545b7d3af8c26f1e64167a4d1e060e11a65087b
2ae36a735d6926bd70a164e42bcb8cdac20383f1
v1.0
instruct
Taco
Taco_67119_I
Maria is fascinated by palindromes and wants to write a program to help her find them in a list of strings. A palindrome is a word, phrase, or sequence that reads the same backward as forward, ignoring spaces, punctuation, and capitalization. Can you help Maria by writing a function that identifies all palindromes in ...
import re def is_palindrome(s): """ Checks if the given string is a palindrome, ignoring spaces, punctuation, and capitalization. """ cleaned_string = re.sub(r'[^A-Za-z0-9]', '', s).lower() return cleaned_string == cleaned_string[::-1] def identify_palindromes(strings): """ Identifies all ...
from solution import is_palindrome, identify_palindromes def test_is_palindrome(): assert is_palindrome("A man a plan a canal Panama") == True assert is_palindrome("No lemon, no melon") == True assert is_palindrome("Hello world") == False assert is_palindrome("Was it a car or a cat I saw") == True ...
[ { "docstring": "Checks if the given string is a palindrome, ignoring spaces, punctuation, and capitalization.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": "Identifies all palindromes in the given list of string...
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(s):\n \"\"\"\n Returns True if the string s is a palindrome, False otherwise.\n \"\"\"\n # Filter out non-alphanumeric characters and...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00067119", "row_id": 67119, "seed_ids": "[21831]" }
0.725293
Taco_67119
I
[ "is_palindrome", "identify_palindromes" ]
2
[ [ "identify_palindromes", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7b60c4d6ee7d269849af230441596897ff22d3ca
a0be993c91eaeaefe4b79e51a246c080d22082b9
v1.0
instruct
Taco
Taco_67121_I
Taru and Chandu are playing another game. This time Taru gives Chandu a number and asks him to find the number of ways to split the number into two parts such that both parts are prime numbers and the sum of these primes equals the given number. For example: For N = 10, the prime pairs that sum up to 10 are (3, 7) and...
def sieve_of_eratosthenes(max_num): """ Returns a list of boolean values where the index represents the number. True means the index number is prime. """ is_prime = [True] * (max_num + 1) p = 2 while (p * p <= max_num): if is_prime[p]: for i in range(p * p, max_num + 1, p): ...
from solution import solve def test_example_cases(): T = 2 assert solve([10, 12]) == [2, 1] def test_single_case_odd_number(): assert solve([9]) == [1] def test_large_number_with_multiple_pairs(): assert solve([26]) == [3] def test_number_with_no_pairs(): assert solve([4]) == [1] # The only pai...
[ { "docstring": "Returns a list of boolean values where the index represents the number. True means the index number is prime.", "function_declaration": "def sieve_of_eratosthenes(max_num):", "function_name": "sieve_of_eratosthenes", "parameter_list": "(max_num)" }, { "docstring": "Returns th...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sieve_of_eratosthenes(max_num):\n prime = [True] * (max_num + 1)\n p = 2\n while (p * p <= max_num):\n if prime[p] == True:\n for i ...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00067121", "row_id": 67121, "seed_ids": "[24994]" }
0.636466
Taco_67121
I
[ "sieve_of_eratosthenes", "count_prime_pairs", "solve" ]
3
[ [ "solve", "count_prime_pairs" ], [ "solve", "sieve_of_eratosthenes" ] ]
2
[]
false
[]
false
pytest
true
[]
true
2123436a466b40afb7f160033af5e87643052105
13ce52e9c3f28dd75c7d9e165a0372f67c8f83f0
v1.0
instruct
Taco
Taco_67203_I
Sunny loves trees and coding. He is given a binary tree with nodes numbered 1 to N. Sunny needs to check if the binary tree is balanced or not. A binary tree is balanced if for every node in the tree, the height difference between its left and right subtrees is at most 1. Write a function to determine whether a bina...
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None def build_tree(node_values_list, edges_list): if not node_values_list: return None nodes = {val: TreeNode(val) for val in node_values_list} for u, v, w in edges_list: if u in n...
from solution import check_balanced def test_balanced_tree(): assert check_balanced(3, [1, 2, 3], [(1, 2, 1), (1, 3, 1)]) == "Balanced" def test_not_balanced_tree(): # Tree structure: # 1 # / # 2 # / # 3 assert check_balanced(3, [1, 2, 3], [(1, 2, 1), (2, 3, 1)]) == "Not...
[]
[ 1, 0 ]
1
medium
0.5
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, x):\n self.val = x\n self.left = None\n self.right = None\n\ndef build_tree(node_values_list, edges_li...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00067203", "row_id": 67203, "seed_ids": "[17091]" }
0.849043
Taco_67203
I
[ "build_tree", "is_balanced", "check_balanced" ]
3
[ [ "check_balanced", "build_tree" ], [ "check_balanced", "is_balanced" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
536fc4c02fe37dcc882bde42fdf0e6763cc2a224
e7a7400601576ccac2b6f2a3f189f1cf96b4d6b7
v1.0
instruct
Taco
Taco_67240_I
You are the chief engineer working on a new artificial intelligence system for a parcel delivery service. The system needs to identify the best route for delivery vehicles to take, reducing the travel time and fuel consumption. One of the challenges you've encountered is determining the optimal sequence to visit certai...
import itertools import math def distance(point1, point2): """ Helper function to calculate Euclidean distance between two points. """ return math.sqrt((point2[0] - point1[0]) ** 2 + (point2[1] - point1[1]) ** 2) def min_travel_distance(points): """ Function to calculate the minimum travel dis...
from solution import min_travel_distance def test_min_travel_distance_example_case(): points = [(0, 0), (1, 1), (1, 0), (0, 1)] assert min_travel_distance(points) == 4.00 def test_min_travel_distance_two_points(): points = [(0, 0), (3, 4)] assert min_travel_distance(points) == 10.0 def test_min_trave...
[ { "docstring": "Helper function to calculate Euclidean distance between two points.", "function_declaration": "def distance(point1, point2):", "function_name": "distance", "parameter_list": "(point1, point2)" }, { "docstring": "Function to calculate the minimum travel distance for the Travel...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import itertools\nimport math\n\ndef euclidean_distance(point1, point2):\n return math.sqrt((point1[0] - point2[0]) ** 2 + (point1[1] - point2[1]) ** 2)\n\ndef ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00067240", "row_id": 67240, "seed_ids": "[16859]" }
0.658863
Taco_67240
I
[ "distance", "min_travel_distance" ]
2
[ [ "min_travel_distance", "distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
168cfc5e6a0116d0137f8a84343faa1d458f47e8
ee18ad35ab5c3a597a13090656614aa21ae8fa3b
v1.0
instruct
Taco
Taco_67241_I
You are given a tree with n nodes. There are q queries. Each query asks you to compute the distance between two nodes u and v in the tree. The tree is rooted at node 1. Input The first line contains two integers n and q (1 ≤ n ≤ 10^5, 1 ≤ q ≤ 10^5) — the number of nodes in the tree and the number of queries. The n...
from collections import deque def preprocess_lca(n, adj, root): """ Preprocesses the tree to enable fast LCA queries. Initializes the parent and depth matrices. """ parent = [-1] * (n + 1) depth = [0] * (n + 1) levels = [[] for _ in range(n + 1)] visited = [False] * (n + 1) def...
from solution import main def test_example_case(): n = 7 q = 3 edges = [(1, 2), (1, 3), (2, 4), (2, 5), (3, 6), (3, 7)] queries = [(4, 5), (4, 6), (6, 7)] assert main(n, q, edges, queries) == [2, 4, 2] def test_single_node(): n = 1 q = 1 edges = [] queries = [(1, 1)] assert mai...
[ { "docstring": "Preprocesses the tree to enable fast LCA queries.\nInitializes the parent and depth matrices.", "function_declaration": "def preprocess_lca(n, adj, root):", "function_name": "preprocess_lca", "parameter_list": "(n, adj, root)" }, { "docstring": "Finds the lowest common ancest...
[ 0, 0, 1, 0 ]
1
hard
0.25
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import defaultdict, deque\n\ndef preprocess_lca(n, edges):\n tree = defaultdict(list)\n for u, v in edges:\n tree[u].append(v)\n ...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00067241", "row_id": 67241, "seed_ids": "[16714]" }
0.730973
Taco_67241
I
[ "preprocess_lca", "lca", "distance_between_nodes", "main" ]
4
[ [ "distance_between_nodes", "lca" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f2e2376b7e356a95def367ee334e03333186d4c0
cb04ed0012ffafd7713f7501f602ab613b22f0e9
v1.0
instruct
Taco
Taco_67317_I
Given a grid of size NxN where each cell is either empty (denoted by '.') or contains a wall (denoted by '#'), find the shortest path from the top-left cell to the bottom-right cell. You are only allowed to move to adjacent cells (up, down, left, right) and cannot move through walls. You need to output the length of th...
from collections import deque def shortest_path_length(grid): N = len(grid) if grid[0][0] == '#' or grid[N-1][N-1] == '#': return -1 directions = [(0, 1), (1, 0), (0, -1), (-1, 0)] queue = deque([(0, 0, 1)]) visited = set((0, 0)) while queue: x, y, dist = queue.popleft() ...
from solution import solve, parse_input def test_example_cases(): input_string = "3\n4\n....\n.##.\n..#.\n....\n4\n.#..\n###.\n..#.\n...#\n2\n##\n..\n" test_cases = parse_input(input_string) assert solve(test_cases) == [7, -1, -1] def test_case_no_path_due_to_walls(): input_string = "1\n3\n###\n#.#\n#...
[ { "docstring": null, "function_declaration": "def shortest_path_length(grid):", "function_name": "shortest_path_length", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def solve(test_cases):", "function_name": "solve", "parameter_list": "(test_cases)"...
[ 0, 0, 0, 0, 0, 1, 0, 0, 1, 0 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef shortest_path_in_grid(grid):\n N = len(grid)\n if grid[0][0] == '#' or grid[N-1][N-1] == '#':\n return -1\n\n ...
trial_gpt4o_5
{ "original_instruction": "", "prompt_id": "00067317", "row_id": 67317, "seed_ids": "[10107]" }
0.743785
Taco_67317
I
[ "shortest_path_length", "solve", "parse_input" ]
3
[ [ "solve", "shortest_path_length" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
8681857f203734b8eacbc5064a773110e0256508
b1444a039a30ee4549f2dedc999755037cd8eb15
v1.0
instruct
Taco
Taco_67329_I
A courier company needs to deliver a series of packages to a number of cities organized in a network. Each city is connected to other cities via roads, and each road has an associated travel time. The company wants to determine the minimum time required to deliver all packages if it starts at a specified city and can c...
import heapq from typing import List, Tuple def dijkstra(graph: List[List[Tuple[int, int]]], start: int) -> List[int]: """Implementation of Dijkstra's algorithm to find shortest paths from start to all nodes.""" num_cities = len(graph) min_time = [float('inf')] * num_cities min_time[start] = 0 prio...
from solution import min_delivery_time def test_example_1(): graph = [ [(1, 2), (2, 4)], [(0, 2), (2, 1)], [(0, 4), (1, 1)] ] start = 0 packages = [1, 2] assert min_delivery_time(graph, start, packages) == 10 def test_example_2(): graph = [ [(1, 3), (2, 5)], ...
[ { "docstring": "Implementation of Dijkstra's algorithm to find shortest paths from start to all nodes.", "function_declaration": "def dijkstra(graph, start):", "function_name": "dijkstra", "parameter_list": "(graph, start)" }, { "docstring": "Returns the minimum time required to deliver all ...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\nfrom typing import List, Tuple\n\ndef dijkstra(graph: List[List[Tuple[int, int]]], start: int) -> List[int]:\n \"\"\"Implementation of Dijkstra's ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00067329", "row_id": 67329, "seed_ids": "[9292]" }
0.670047
Taco_67329
I
[ "dijkstra", "min_delivery_time" ]
2
[ [ "min_delivery_time", "dijkstra" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8d617f103e479a9df841fb6af36123e5c43b0ca2
0d528f5919b8747741cbd9350166e778995167ac
v1.0
instruct
Taco
Taco_67422_I
In a high-security building, a computer system is used to control access through various doors using a series of passcodes. Each passcode consists of multiple characters, and each character could be one of four types: upper-case letter, lower-case letter, digit, or special symbol. System analysts have found that each t...
def check_passcode(passcodes): results = [] for passcode in passcodes: has_upper = any(c.isupper() for c in passcode) has_lower = any(c.islower() for c in passcode) has_digit = any(c.isdigit() for c in passcode) has_special = any(not c.isalnum() for c in passcode) ...
import pytest from solution import read_and_check_passcodes def test_single_valid_passcode(): input_data = "1\nA1a!" expected_output = ["PASS"] assert read_and_check_passcodes(input_data) == expected_output def test_single_invalid_passcode(): input_data = "1\nabc" expected_output = ["FAIL"] as...
[ { "docstring": null, "function_declaration": "def check_passcode(passcodes):", "function_name": "check_passcode", "parameter_list": "(passcodes)" }, { "docstring": null, "function_declaration": "def read_and_check_passcodes(input_data):", "function_name": "read_and_check_passcodes", ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def check_passcode(passcodes):\n results = []\n for passcode in passcodes:\n has_upper = any(c.isupper() for c in passcode)\n has_lower = any(c...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00067422", "row_id": 67422, "seed_ids": "[15368]" }
0.591007
Taco_67422
I
[ "check_passcode", "read_and_check_passcodes" ]
2
[ [ "read_and_check_passcodes", "check_passcode" ] ]
1
[]
false
[]
false
pytest
true
[]
true
eaf119f6a0879a9853a5b0aa2fc937444f2b74ea
1966529593bd56979a9723fde189a90fac2a280c
v1.0
instruct
Taco
Taco_67423_I
Mary is organizing a team-building event where participants will sit in a circular arrangement. She needs to ensure that there are no two participants seated next to each other such that their skills are directly related, to promote better interaction. The skills of the participants are represented by integers and part...
from math import gcd from itertools import permutations def is_valid_arrangement(arrangement): n = len(arrangement) for i in range(n): if gcd(arrangement[i], arrangement[(i + 1) % n]) > 1: return False return True def find_arrangement(t, test_cases): results = [] for case in te...
import pytest from solution import team_building_event def test_example_1(): assert team_building_event(2, [(4, [2, 3, 5, 7]), (4, [2, 4, 8, 16])]) == "YES\n2 3 5 7\nNO" def test_single_case_yes(): assert team_building_event(1, [(3, [1, 6, 5])]) == "YES\n1 6 5" def test_single_case_no(): assert team_buil...
[ { "docstring": null, "function_declaration": "def is_valid_arrangement(arrangement):", "function_name": "is_valid_arrangement", "parameter_list": "(arrangement)" }, { "docstring": null, "function_declaration": "def find_arrangement(t, test_cases):", "function_name": "find_arrangement...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from math import gcd\nfrom itertools import permutations\n\ndef can_be_arranged(n, skills):\n for perm in permutations(skills):\n valid = True\n f...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00067423", "row_id": 67423, "seed_ids": "[12931]" }
0.691767
Taco_67423
I
[ "is_valid_arrangement", "find_arrangement", "team_building_event" ]
3
[ [ "find_arrangement", "is_valid_arrangement" ], [ "team_building_event", "find_arrangement" ] ]
2
[]
false
[]
false
pytest
true
[]
true
a2ccc6fd3d6c73ec20a70fe2e9d164e77a0ae77c
ea57569be8de8d5705ebdcd772673d80453a2cf5
v1.0
instruct
Taco
Taco_67478_I
## Task You are given a grid with N rows and M columns of cells. Each cell can either be empty or contain an obstacle. Your task is to find the maximum area of a rectangle consisting entirely of empty cells. You need to write a function `maxRectangleArea` that takes in a 2D list (grid) of integers where `1` represent...
def maxRectangleArea(grid): if not grid: return 0 nrows = len(grid) ncols = len(grid[0]) max_area = 0 heights = [0] * ncols for row in grid: for col in range(ncols): if row[col] == 0: heights[col] += 1 else: heigh...
from solution import maxRectangleArea def test_single_row(): grid = [[0, 1, 0, 0]] assert maxRectangleArea(grid) == 2 def test_single_column(): grid = [[0], [1], [0], [0]] assert maxRectangleArea(grid) == 2 def test_small_grid(): grid = [ [1, 0, 1, 0, 0], [1, 0, 0, 0, 1], ...
[ { "docstring": null, "function_declaration": "def maxRectangleArea(grid):", "function_name": "maxRectangleArea", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def largestRectangleInHistogram(heights):", "function_name": "largestRectangleInHistogram", ...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def maxRectangleArea(grid):\n def largestRectangleArea(heights):\n stack = []\n max_area = 0\n heights.append(0) # Add a zero to handle th...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00067478", "row_id": 67478, "seed_ids": "[7760]" }
0.709842
Taco_67478
I
[ "maxRectangleArea", "largestRectangleInHistogram" ]
2
[ [ "maxRectangleArea", "largestRectangleInHistogram" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a083c5b9e733481a37e4debdb7072dea68630f76
c1c6584092974b3c7876a2532d8f8e6706cefb39
v1.0
instruct
Taco
Taco_67554_I
Alice is organizing a community event and has decided to invite n friends. She wants to form k teams such that the skills within each team are well balanced. Every friend has a skill level represented by an integer, and Alice wants each team to have a similar skill level sum. Determine whether it is possible to divide...
def can_form_k_teams(n, k, skills): total_skill = sum(skills) min_team_sum = total_skill // k max_team_sum = min_team_sum + 1 num_teams_with_max_sum = total_skill % k return all(skill <= max_team_sum for skill in skills) and num_teams_with_max_sum <= k def is_possible_to_form_teams(n, k, skill...
from solution import is_possible_to_form_teams def test_case_1(): assert is_possible_to_form_teams(5, 2, [1, 2, 3, 4, 5]) == "YES" def test_case_2(): assert is_possible_to_form_teams(5, 3, [1, 1, 1, 1, 6]) == "NO" def test_case_3(): assert is_possible_to_form_teams(8, 4, [10, 10, 10, 10, 10, 10, 10, 10])...
[ { "docstring": null, "function_declaration": "def can_form_k_teams(n, k, skills):", "function_name": "can_form_k_teams", "parameter_list": "(n, k, skills)" }, { "docstring": null, "function_declaration": "def is_possible_to_form_teams(n, k, skills):", "function_name": "is_possible_to...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_divide_teams(n, k, skills):\n \"\"\"\n Determines whether it is possible to form k teams with balanced skill sums.\n\n Parameters:\n n (int): T...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00067554", "row_id": 67554, "seed_ids": "[1264]" }
0.7597
Taco_67554
I
[ "can_form_k_teams", "is_possible_to_form_teams" ]
2
[ [ "is_possible_to_form_teams", "can_form_k_teams" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e8211a29230d040c84a20b607c406885b676b28e
e01fcb4d05cb89ca52a9580d5dcf684bce674639
v1.0
instruct
Taco
Taco_67561_I
In a kingdom of N cities, the ruler plans to build a series of directed roads to connect the cities. Each road has a positive integer cost associated with it. However, due to budget constraints, the ruler wants to ensure that it's possible to travel between certain pairs of cities with minimal travel costs. Your task i...
import sys def floyd_warshall(n, roads): # Initialize distances dist = [[sys.maxsize] * n for _ in range(n)] for i in range(n): dist[i][i] = 0 # Add the given edges for u, v, w in roads: dist[u-1][v-1] = w # Floyd Warshall Algorithm to find all pairs shortest paths for k i...
from solution import minimum_travel_cost def test_minimum_travel_cost(): N = 4 M = 4 roads = [ (1, 2, 100), (2, 3, 200), (3, 4, 300), (1, 4, 1000) ] K = 2 queries = [ (1, 4), (2, 4) ] assert minimum_travel_cost(N, M, roads, K, queries) == ...
[ { "docstring": null, "function_declaration": "def floyd_warshall(n, roads):", "function_name": "floyd_warshall", "parameter_list": "(n, roads)" }, { "docstring": null, "function_declaration": "def minimum_travel_cost(N, M, roads, K, queries):", "function_name": "minimum_travel_cost",...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef dijkstra(n, graph, start):\n \"\"\"\n Use Dijkstra's algorithm to find the minimum travel costs from the \n start city to all other ci...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00067561", "row_id": 67561, "seed_ids": "[1190]" }
0.797956
Taco_67561
I
[ "floyd_warshall", "minimum_travel_cost" ]
2
[ [ "minimum_travel_cost", "floyd_warshall" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9fd6ac8450d4e0afba8049cfa075a3b8b0a6a154
17785c49235f6db5eed0764fa09cd4716051a4d9
v1.0
instruct
Taco
Taco_67564_I
You are given $N$ integers in an array representing scores, and you have a task to form the largest possible number by rearranging these integers. As the input size can be large, the approach needs to consider efficiency in terms of both time and space complexity. Write a program to solve this problem. ------ Input ...
from functools import cmp_to_key def custom_compare(x, y): # Convert numbers to string and compare combinations if x + y > y + x: return -1 elif x + y < y + x: return 1 else: return 0 def largest_number(arr): # Convert integers to strings for custom comparison arr = lis...
def test_custom_compare(): assert custom_compare("9", "34") == -1 assert custom_compare("34", "9") == 1 assert custom_compare("5", "50") == -1 assert custom_compare("50", "5") == 1 assert custom_compare("17", "171") == -1 def test_largest_number(): assert largest_number([10, 2, 9]) == '9210' ...
[ { "docstring": null, "function_declaration": "def custom_compare(x, y):", "function_name": "custom_compare", "parameter_list": "(x, y)" }, { "docstring": null, "function_declaration": "def largest_number(arr):", "function_name": "largest_number", "parameter_list": "(arr)" }, ...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from functools import cmp_to_key\n\ndef largest_number(nums):\n \"\"\"\n Forms the largest possible number by rearranging the given numbers.\n \"\"\"\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00067564", "row_id": 67564, "seed_ids": "[20274]" }
0.674448
Taco_67564
I
[ "custom_compare", "largest_number", "solve", "main" ]
4
[ [ "largest_number", "custom_compare" ], [ "solve", "largest_number" ] ]
2
[]
false
[]
false
pytest
false
[]
true
3c182c434af1172fc32d1f2b5b61d446f8ee3ad9
12d448941e0f0b6e78b37b8afa879bc0f77354e1
v1.0
instruct
Taco
Taco_67569_I
Given an integer N, determine if it can be expressed as a product of two distinct prime numbers. ------ Input Format ------ - The first line of input contains a single integer T — the number of test cases. Then the T test cases follow. - Each of the next T lines contains a single integer N. ------ Output Format ---...
def sieve_of_eratosthenes(limit): is_prime = [True] * (limit + 1) is_prime[0] = is_prime[1] = False for i in range(2, int(limit**0.5) + 1): if is_prime[i]: for j in range(i * i, limit + 1, i): is_prime[j] = False return [i for i in range(2, limit + 1) if is_prime[i]] ...
from solution import can_be_expressed_as_product_of_two_distinct_primes def test_sample_input(): assert can_be_expressed_as_product_of_two_distinct_primes(4, [10, 15, 21, 49]) == ["YES", "YES", "YES", "NO"] def test_single_prime(): assert can_be_expressed_as_product_of_two_distinct_primes(1, [7]) == ["NO"] d...
[ { "docstring": null, "function_declaration": "def sieve_of_eratosthenes(limit):", "function_name": "sieve_of_eratosthenes", "parameter_list": "(limit)" }, { "docstring": null, "function_declaration": "def can_be_product_of_two_distinct_primes(n, primes):", "function_name": "can_be_pr...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sieve(limit):\n \"\"\" Generate a list of prime numbers up to the given limit using the Sieve of Eratosthenes. \"\"\"\n is_prime = [True] * (limit + 1)\n...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00067569", "row_id": 67569, "seed_ids": "[19515]" }
0.623826
Taco_67569
I
[ "sieve_of_eratosthenes", "can_be_product_of_two_distinct_primes", "can_be_expressed_as_product_of_two_distinct_primes" ]
3
[ [ "can_be_expressed_as_product_of_two_distinct_primes", "can_be_product_of_two_distinct_primes" ], [ "can_be_expressed_as_product_of_two_distinct_primes", "sieve_of_eratosthenes" ] ]
2
[]
false
[]
false
pytest
true
[]
true
5acb6db3256e46a17fca8b4766f893b640948b0d
13abfa58e283a2aa091a6aed05cdda5b40ec957b
v1.0
instruct
Taco
Taco_67575_I
John loves palindromes. A palindrome is a string that reads the same forward and backward. He has a list of strings and wants to check if each string in the list is a valid palindrome or not. To make this more challenging, John considers only alphanumeric characters and ignores cases while checking palindromes. Given a...
import re def is_valid_palindrome(s): """ Checks if the given string is a valid palindrome considering only alphanumeric characters and ignoring case. :param s: The input string :return: "YES" if the string is a valid palindrome, "NO" otherwise """ # Remove non-alphanumeric characters and ...
from solution import is_valid_palindrome, palindrome_checker def test_is_valid_palindrome(): assert is_valid_palindrome("A man, a plan, a canal: Panama") == "YES" assert is_valid_palindrome("race a car") == "NO" assert is_valid_palindrome("Was it a car or a cat I saw?") == "YES" assert is_valid_palindr...
[ { "docstring": "Checks if the given string is a valid palindrome considering only alphanumeric characters and ignoring case.\n\n:param s: The input string\n:return: \"YES\" if the string is a valid palindrome, \"NO\" otherwise", "function_declaration": "def is_valid_palindrome(s):", "function_name": "is...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import re\n\ndef is_palindrome(s):\n \"\"\"\n Determines if the given string s is a palindrome, considering only alphanumeric characters and ignoring case.\n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00067575", "row_id": 67575, "seed_ids": "[7922]" }
0.824712
Taco_67575
I
[ "is_valid_palindrome", "palindrome_checker" ]
2
[ [ "palindrome_checker", "is_valid_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
33c4e5d8349e25c0d231ee1e7d02dfdc87a4b471
1973552d96d717847cf371f139a8aad81033278e
v1.0
instruct
Taco
Taco_67740_I
Given an array of integers nums, you need to repeatedly sum the digits of each number in the array until each number becomes a single-digit integer. After all numbers in the array are reduced to single digits, return the array sorted in non-decreasing order. First line contains an integer N denoting the number of inte...
def digit_root(n): """ Function to compute the digit root of a number. """ while n >= 10: n = sum(int(digit) for digit in str(n)) return n def process_and_sort(nums): """ Function to process the given list of numbers to their digit roots and sort the result. """ digit_roots ...
from solution import digit_root, process_and_sort, main def test_digit_root(): assert digit_root(38) == 2 assert digit_root(15) == 6 assert digit_root(122) == 5 assert digit_root(4) == 4 assert digit_root(91) == 1 assert digit_root(9999) == 9 assert digit_root(0) == 0 def test_process_and...
[ { "docstring": "Function to compute the digit root of a number.", "function_declaration": "def digit_root(n):", "function_name": "digit_root", "parameter_list": "(n)" }, { "docstring": "Function to process the given list of numbers to their digit roots and sort the result.", "function_de...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def digit_root(n):\n \"\"\"\n Calculate the digit root of a given number n.\n \"\"\"\n while n > 9:\n n = sum(int(digit) for digit in str(n))\n ...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00067740", "row_id": 67740, "seed_ids": "[674]" }
0.656847
Taco_67740
I
[ "digit_root", "process_and_sort", "main" ]
3
[ [ "process_and_sort", "digit_root" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ba3eae2cca6f41aa6ce549c7f92183f164bb6975
248133ab152cc08f9f134a8f3cd28c12ad8a4bff
v1.0
instruct
Taco
Taco_67751_I
Given a Binary Tree, find the Left View of the tree. The Left View of a Binary Tree is a set of nodes visible when the tree is viewed from the left side. Example 1: Input: 1 / \ 2 3 / \ 4 5 Output: 1 2 4 Example 2: Input: 10 / \ 20 30 / 40 Output: 10 20 40 Your Task: You need to ...
class Node: """ A binary tree node. """ def __init__(self, key): self.data = key self.left = None self.right = None def leftViewUtil(root, level, max_level, result): """ Utility function to get the left view of the binary tree. """ if root is None: return...
import pytest from solution import Node, leftView def test_left_view_example_1(): root = Node(1) root.left = Node(2) root.right = Node(3) root.right.left = Node(4) root.right.right = Node(5) assert leftView(root) == [1, 2, 4] def test_left_view_example_2(): root = Node(10) root.le...
[]
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class Node:\n def __init__(self, data):\n self.data = data\n self.left = None\n self.right = None\n\ndef leftViewUtil(root, level, max_leve...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00067751", "row_id": 67751, "seed_ids": "[2793]" }
0.512651
Taco_67751
I
[ "leftViewUtil", "leftView" ]
2
[ [ "leftView", "leftViewUtil" ] ]
1
[]
false
[ "Node" ]
true
pytest
true
[]
true
9077fa9db19f97f73b438a0ad44e4b36a0863d40
ca161097f1e97f675a52454ca0ca141ebacbde74
v1.0
instruct
Taco
Taco_67756_I
In this problem, you have to find the number of inversions in a given sequence of integers. An inversion is a pair of indices $(i, j)$ such that $i < j$ and $a[i] > a[j]$. For example, in the sequence 2 3 8 6 1, there are five inversions: $(0, 4), (1, 4), (2, 3), (2, 4), (3, 4)$. Your task is to write a program that...
def count_inversions(arr): """ Count the number of inversions in the array. """ return count_inversions_and_sort(arr, 0, len(arr) - 1) def count_inversions_and_sort(arr, left, right): """ Helper function to count inversions and sort the array. """ if left >= right: return 0 ...
from solution import count_inversions def test_simple_case(): assert count_inversions([2, 3, 8, 6, 1]) == 5 def test_sorted(): assert count_inversions([1, 2, 3, 4, 5]) == 0 def test_reverse_sorted(): assert count_inversions([5, 4, 3, 2, 1]) == 10 def test_duplicate_elements(): assert count_inversion...
[ { "docstring": "Count the number of inversions in the array.", "function_declaration": "def count_inversions(arr):", "function_name": "count_inversions", "parameter_list": "(arr)" }, { "docstring": "Helper function to count inversions and sort the array.", "function_declaration": "def co...
[ 0, 0, 0, 1, 1 ]
2
medium
0.4
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def count_inversions(arr):\n \"\"\"\n Function to count the number of inversions in the given array.\n \"\"\"\n def merge_count_split_inv(arr, temp_arr...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00067756", "row_id": 67756, "seed_ids": "[12830]" }
0.805929
Taco_67756
I
[ "count_inversions", "count_inversions_and_sort", "merge_and_count" ]
3
[ [ "count_inversions", "count_inversions_and_sort" ], [ "count_inversions_and_sort", "merge_and_count" ] ]
2
[]
false
[]
false
pytest
true
[]
true
1b65cf70c0f7449bd9354ca05c5b95684a15ca88
fbc0f7469ee3f76b7e710e117c7d135a2da2fe95
v1.0
instruct
Taco
Taco_67781_I
Problem description: A Pythagorean triple consists of three positive integers a, b, and c such that a^2 + b^2 = c^2. Given a list of sets of three integers, determine whether each set forms a Pythagorean triple. Input Each case is specified on a single line with three integers a, b, c. The last case is followed by a ...
def is_pythagorean_triple(a, b, c): """ Determines if the integers a, b, c form a Pythagorean triple. """ # Sort a, b, c to ensure a <= b <= c a, b, c = sorted([a, b, c]) # Check if the given numbers satisfy the Pythagorean theorem if a ** 2 + b ** 2 == c ** 2: return "VALID" ...
from solution import is_pythagorean_triple, check_pythagorean_triples def test_is_pythagorean_triple(): assert is_pythagorean_triple(3, 4, 5) == "VALID" assert is_pythagorean_triple(5, 12, 13) == "VALID" assert is_pythagorean_triple(8, 15, 17) == "VALID" assert is_pythagorean_triple(1, 2, 3) == "INVALI...
[ { "docstring": "Determines if the integers a, b, c form a Pythagorean triple.", "function_declaration": "def is_pythagorean_triple(a, b, c):", "function_name": "is_pythagorean_triple", "parameter_list": "(a, b, c)" }, { "docstring": "Check a list of triples to determine if each forms a Pytha...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_pythagorean_triple(a, b, c):\n \"\"\"\n Returns 'VALID' if a, b, and c form a Pythagorean triple, otherwise 'INVALID'.\n \"\"\"\n a, b, c = sort...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00067781", "row_id": 67781, "seed_ids": "[11997]" }
0.577295
Taco_67781
I
[ "is_pythagorean_triple", "check_pythagorean_triples" ]
2
[ [ "check_pythagorean_triples", "is_pythagorean_triple" ] ]
1
[]
false
[]
false
pytest
true
[]
true
843a9342bd37fbce4100d60efee79b19b0a17ca3
0222a8a7d0e0c0a5eb0e28e80db714508c6662cc
v1.0
instruct
Taco
Taco_67830_I
Roller Coaster Riders Alice loves to visit amusement parks and ride roller coasters. One day, she visited a new amusement park which had a very long roller coaster that can hold up to $n$ riders at a time. Riders line up in a row and are assigned numbers from $1$ to $n$. Alice observed that each rider carries a uniqu...
def preprocess_sums(energies): """ Precomputes the prefix sums for the given list of energies. """ n = len(energies) prefix_sums = [0] * (n + 1) # prefix_sums[0] is 0, starting from prefix_sums[1] to prefix_sums[n] for i in range(1, n + 1): prefix_sums[i] = prefix_sums[i - 1] + energies...
import pytest from solution import preprocess_sums, query_sum, generate_results def test_preprocess_sums(): energies = [7, 3, 2, 5, 1] expected_prefix_sums = [0, 7, 10, 12, 17, 18] assert preprocess_sums(energies) == expected_prefix_sums def test_query_sum(): prefix_sums = [0, 7, 10, 12, 17, 18] a...
[ { "docstring": "Precomputes the prefix sums for the given list of energies.", "function_declaration": "def preprocess_sums(energies):", "function_name": "preprocess_sums", "parameter_list": "(energies)" }, { "docstring": "Returns the sum of the elements from index i to j using the prefix sum...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def preprocess_and_query(n, energies, queries):\n \"\"\"\n Preprocess the energies array to allow fast range queries.\n :param n: Number of riders\n :p...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00067830", "row_id": 67830, "seed_ids": "[14921]" }
0.622554
Taco_67830
I
[ "preprocess_sums", "query_sum", "generate_results" ]
3
[ [ "generate_results", "preprocess_sums" ], [ "generate_results", "query_sum" ] ]
2
[ "generate_results" ]
false
[]
false
pytest
true
[]
true
8cd8383289770b2875d3e81f246ff2371d28acba
0c9eda0ce157f9f553d783265d6e6b48563f3c61
v1.0
instruct
Taco
Taco_67872_I
As a software developer, you are required to write a program to help a library manage their book check-ins and check-outs efficiently. The library follows a strict policy that a book can be checked out if and only if it is currently available (i.e., it was previously checked in). To implement this logic, you need to cr...
def library_management(events): book_status = {} for event in events: action, book_id = event.split() if action == "CheckIn": book_status[book_id] = "Available" elif action == "CheckOut": book_status[book_id] = "Checked Out" sorted_books = sorted(boo...
from solution import library_management def test_library_management_all_checked_out(): events = [ "CheckIn book1", "CheckOut book1", "CheckIn book2", "CheckOut book2", "CheckIn book3", "CheckOut book3" ] expected = [ ("book1", "Checked Out"), ...
[ { "docstring": null, "function_declaration": "def library_management(events):", "function_name": "library_management", "parameter_list": "(events)" }, { "docstring": null, "function_declaration": "def process_library_events(t, event_list):", "function_name": "process_library_events",...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def library_management_system(events):\n \"\"\"\n Returns the final status of each book in the library given a list of events.\n \"\"\"\n status = {}\n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00067872", "row_id": 67872, "seed_ids": "[15978]" }
0.67138
Taco_67872
I
[ "library_management", "process_library_events" ]
2
[ [ "process_library_events", "library_management" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1384c58f3cc082bb4b07387dca35f08fcbf1e167
ed4015f89b0c7e181bf22cab7352f04a18415f1b
v1.0
instruct
Taco
Taco_67884_I
Write a function that calculates the meeting time of three friends who are walking at different speeds towards each other on a circular track. Given the total distance around the track and their individual speeds, determine at what time they will all meet at a single point after they start walking. Assume: - The frien...
from math import gcd from functools import reduce def lcm(a, b): """ Helper function to calculate least common multiple of two numbers. """ return a * b // gcd(a, b) def meeting_time(L, vA, vB, vC): """ Calculate the meeting time of three friends on a circular track given the total length ...
from solution import meeting_time def test_meeting_time(): assert meeting_time(12, 3, 2, 1) == 12.0 def test_meeting_time_different_speeds(): # Friend A = 1, Friend B = 2, Friend C = 3, Track is 6 units # They will meet at every multiple of LCM(1, 2, 3) which is 6. assert meeting_time(6, 1, 2, 3) == 6...
[ { "docstring": "Helper function to calculate least common multiple of two numbers.", "function_declaration": "def lcm(a, b):", "function_name": "lcm", "parameter_list": "(a, b)" }, { "docstring": "Calculate the meeting time of three friends on a circular track given the total\nlength of the ...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from math import gcd\nfrom functools import reduce\n\ndef lcm(a, b):\n \"\"\"\n Helper function to calculate least common multiple of two numbers.\n \"\"\...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00067884", "row_id": 67884, "seed_ids": "[21502]" }
0.544989
Taco_67884
I
[ "lcm", "meeting_time" ]
2
[ [ "meeting_time", "lcm" ] ]
1
[]
false
[]
false
pytest
true
[]
true
213310a632cfeb00a0834a31933ecc75fc0dfb30
f3653e18115a6808f7e766a29eafa3f3447f93d9
v1.0
instruct
Taco
Taco_68022_I
A marathon event is being organized, and participants are divided into teams. Each team has a uniform color. As an organizer, you need to distribute the participants into teams such that no two adjacent participants in the list end up in the same team. Each participant has a unique ID, and they should be assigned a te...
def assign_team_colors(T, cases): results = [] for N in cases: min_colors = 2 colors = [] for i in range(N): colors.append((i % 2) + 1) # Alternates between 1 and 2 results.append((min_colors, colors)) return results def solve(T, cases): results = assig...
from solution import assign_team_colors def test_single_participant_case(): T = 1 cases = [1] results = assign_team_colors(T, cases) assert results == [(2, [1])] def test_three_participants_case(): T = 1 cases = [3] results = assign_team_colors(T, cases) assert results == [(2, [1, 2, 1...
[ { "docstring": null, "function_declaration": "def assign_team_colors(T, cases):", "function_name": "assign_team_colors", "parameter_list": "(T, cases)" }, { "docstring": null, "function_declaration": "def solve(T, cases):", "function_name": "solve", "parameter_list": "(T, cases)"...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def assign_team_colors(n):\n \"\"\"\n Returns the minimum number of team colors needed and a list representing the team color assigned to each participant.\n...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00068022", "row_id": 68022, "seed_ids": "[24248]" }
0.75503
Taco_68022
I
[ "assign_team_colors", "solve" ]
2
[ [ "solve", "assign_team_colors" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9a95247997f5aef9cdfe9bfc9ff90e1045195ca3
ae2d50b9499aab32a15fc1a2fe69d56e1725becd
v1.0
instruct
Taco
Taco_68065_I
Create a program that outputs all prime factors of a number n. The prime factor conditions are as follows. However, 2 ≤ n ≤ 100,000. If the number is prime, output "Prime". * A prime factor is a factor that is a prime number. * The factors should be printed in ascending order. Input Given multiple datasets. The fo...
def is_prime(num): """ Helper function to check if a number is prime. """ if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return F...
from solution import prime_factors, process_datasets def test_prime_factors_prime_number(): assert prime_factors(17) == "Prime" def test_prime_factors_normal_number(): assert prime_factors(28) == [2, 2, 7] assert prime_factors(100) == [2, 2, 5, 5] def test_prime_factors_composite_number(): assert pri...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns a list of prime factors of n.", "function_declaration": "def prime_factors(n):", "function_...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def prime_factors(n):\n if n <= 1:\n return []\n \n def is_prime(num):\n if num <= 1:\n return False\n if num == 2 or num ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00068065", "row_id": 68065, "seed_ids": "[11543]" }
0.666798
Taco_68065
I
[ "is_prime", "prime_factors", "process_datasets" ]
3
[ [ "prime_factors", "is_prime" ], [ "process_datasets", "prime_factors" ] ]
2
[ "process_datasets" ]
false
[]
false
pytest
true
[]
true
9506710342bf5f98482abe774683359a9358979f
545580603e562bbc34c3b769b4875d7e2dfe7a58
v1.0
instruct
Taco
Taco_68195_I
Steven is an avid gardener and he has planted a variety of flowers in his garden. The garden can be represented as a 2D grid of size $n \times n$. Each cell in the grid either contains a flower or is empty. Steven is particularly interested in finding the largest rectangular plot in his garden that does not contain any...
def maximalRectangle(matrix): if not matrix or not matrix[0]: return 0 max_area = 0 n = len(matrix) m = len(matrix[0]) heights = [0] * (m + 1) for row in matrix: for i in range(m): if row[i] == '.': heights[i] += 1 else: h...
from solution import largest_empty_rectangle def test_largest_empty_rectangle_single_row(): garden = ["...."] assert largest_empty_rectangle(garden) == 4 def test_largest_empty_rectangle_single_column(): garden = [".", ".", ".", "."] assert largest_empty_rectangle(garden) == 4 def test_largest_empty_...
[ { "docstring": null, "function_declaration": "def maximalRectangle(matrix):", "function_name": "maximalRectangle", "parameter_list": "(matrix)" }, { "docstring": null, "function_declaration": "def largest_empty_rectangle(garden):", "function_name": "largest_empty_rectangle", "par...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def maximalRectangle(matrix):\n if not matrix or not matrix[0]:\n return 0\n\n max_area = 0\n n = len(matrix)\n m = len(matrix[0])\n heights ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00068195", "row_id": 68195, "seed_ids": "[19636]" }
0.616701
Taco_68195
I
[ "maximalRectangle", "largest_empty_rectangle" ]
2
[ [ "largest_empty_rectangle", "maximalRectangle" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ce325dd3740c33f240b443d8c21b96c303aefd78
6b8561711fcddaa5d82dd838805b81ca563dbb5f
v1.0
instruct
Taco
Taco_68274_I
Masha is interested in collecting a specific type of strings called "fibonacci strings". A fibonacci string of order k is defined in the following way: - F1 = "a" - F2 = "b" - For i > 2, Fi = F(i-1) + F(i-2) Where "+" denotes string concatenation. For example: - F1 = "a" - F2 = "b" - F3 = "ba" (because F3 = F2 + F1 =...
import itertools def fibonacci_string_order_k(k): if k == 1: return "a" elif k == 2: return "b" else: Fi_minus_2 = "a" Fi_minus_1 = "b" Fi = "" for i in range(3, k + 1): Fi = Fi_minus_1 + Fi_minus_2 Fi_minus_2 = Fi_minus_1 ...
from solution import fibonacci_string_order_k, pth_permutation def test_fibonacci_string_order_k(): assert fibonacci_string_order_k(1) == "a" assert fibonacci_string_order_k(2) == "b" assert fibonacci_string_order_k(3) == "ba" assert fibonacci_string_order_k(4) == "bab" assert fibonacci_string_orde...
[ { "docstring": null, "function_declaration": "def fibonacci_string_order_k(k):", "function_name": "fibonacci_string_order_k", "parameter_list": "(k)" }, { "docstring": null, "function_declaration": "def pth_permutation(k, p):", "function_name": "pth_permutation", "parameter_list"...
[ 0, 0, 0, 0, 0, 0, 1, 0, 0 ]
1
hard
0.111
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import itertools\n\ndef get_fibonacci_string(k):\n if k == 1:\n return \"a\"\n elif k == 2:\n return \"b\"\n else:\n return get_fibon...
trial_gpt4o_7
{ "original_instruction": "", "prompt_id": "00068274", "row_id": 68274, "seed_ids": "[16246]" }
0.594129
Taco_68274
I
[ "fibonacci_string_order_k", "pth_permutation" ]
2
[ [ "pth_permutation", "fibonacci_string_order_k" ] ]
1
[]
false
[]
false
pytest
true
[]
true
518ed5f08d1181d2806fca63139d8bbdedcface4
b2ad0b43c724b139815325aa957c314a45f37015
v1.0
instruct
Taco
Taco_68292_I
A highway spanning a long distance has exactly N milestones marking its length at various points. These milestones are not equally placed but are positioned based on significant landmarks along the route. The milestone at position i has a coordinate xi. A driver wishes to travel from the first milestone to the last on...
def is_prime(num): if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while (i * i) <= num: if (num % i == 0) or (num % (i + 2) == 0): return False i += 6 return True def min_milestones_for_p...
def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(10) == False assert is_prime(11) == True def test_min_milestones_for_prime_distance(): test_cases = [(5, [2, 3, 5, 7, 11]), (4, [10, 20, 30, ...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def min_milestones_for_prime_distance(test_cases):", "function_name": "min_milestones_for_prime_distance", "p...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n if num <= 1:\n return False\n if num <= 3:\n return True\n if num % 2 == 0 or num % 3 == 0:\n return False\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00068292", "row_id": 68292, "seed_ids": "[23190]" }
0.692292
Taco_68292
I
[ "is_prime", "min_milestones_for_prime_distance" ]
2
[ [ "min_milestones_for_prime_distance", "is_prime" ] ]
1
[]
false
[]
false
pytest
false
[]
true
93a61ecfc18796a6881c8b36482cc0958ef8119d
a0ce3b8817d696bfaf573c3d44648f5aa72f4028
v1.0
instruct
Taco
Taco_68318_I
A city is planning to construct a new public transportation system with `N` subway stations. The stations are connected with `M` bidirectional subway lines, each having a specific travel time. To ensure efficiency, the city wants to optimize the travel time between all pairs of stations. You are given `Q` queries. Eac...
def floyd_warshall(n, distances): # Initialize the distance matrix with infinity inf = float('inf') dist = [[inf] * (n + 1) for _ in range(n + 1)] # Distance from a node to itself is 0 for i in range(1, n + 1): dist[i][i] = 0 # Fill initial distances based on input for u, v...
def test_min_travel_time(): n, m = 4, 3 edges = [ (1, 2, 4), (2, 3, 1), (3, 4, 2) ] q = 3 queries = [ (1, 4), (1, 3), (2, 1) ] expected = [7, 5, 4] assert min_travel_time(n, m, edges, q, queries) == expected def test_min_travel_time_discon...
[ { "docstring": null, "function_declaration": "def floyd_warshall(n, distances):", "function_name": "floyd_warshall", "parameter_list": "(n, distances)" }, { "docstring": null, "function_declaration": "def min_travel_time(n, m, edges, q, queries):", "function_name": "min_travel_time",...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def floyd_warshall(n, distances):\n # Initialize the distance matrix with infinity\n inf = float('inf')\n dist = [[inf] * (n + 1) for _ in range(n + 1)]\n...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00068318", "row_id": 68318, "seed_ids": "[10171]" }
0.803489
Taco_68318
I
[ "floyd_warshall", "min_travel_time" ]
2
[ [ "min_travel_time", "floyd_warshall" ] ]
1
[]
false
[]
false
pytest
false
[]
true
047febc6178fe20c886fc970deee4622ac3bea4a
4f416a79d66fb9d8f9a61ff9f5d8a0d3d3824a99
v1.0
instruct
Taco
Taco_68338_I
Given an input list of integers, return the list sorted in ascending order but with all prime numbers at the beginning of the list, followed by non-prime numbers. Preserve the original relative order of all prime and non-prime numbers within their respective sections. Input Input list of integers. Output Output list ...
def is_prime(n): """ Check if a number is prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def sort_primes_first(lst): """ ...
from solution import sort_primes_first def test_sort_primes_first_all_primes(): assert sort_primes_first([2, 3, 5, 7]) == [2, 3, 5, 7] def test_sort_primes_first_all_non_primes(): assert sort_primes_first([4, 6, 8, 9, 10]) == [4, 6, 8, 9, 10] def test_sort_primes_first_mixed(): assert sort_primes_first([...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Sort the list with prime numbers first while preserving the \nrelative order of the primes and non-primes.", "function_declara...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Returns True if n is a prime number, else False.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n retur...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00068338", "row_id": 68338, "seed_ids": "[2361]" }
0.565916
Taco_68338
I
[ "is_prime", "sort_primes_first" ]
2
[ [ "sort_primes_first", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6f2f8b8cfd80d0d4e86510889c37493c50d4fb1a
a2f09662c090cf3138b79599413e33ddda43e47f
v1.0
instruct
Taco
Taco_68397_I
In a distant kingdom, there existed a wise magician who had the ability to create powerful magic spells. To channel his magical abilities, the magician used crystals arranged in a specific manner. These crystals are placed in different cities, each having a certain number of magical points. Due to the complexity of the...
def can_form_right_angled_triangle(points): """ Determine if a set of magical points can form a right-angled triangle with the right angle at the origin (0, 0). Args: points (List[Tuple[int, int]]): List of tuples containing coordinates (xi, yi). Returns: str: "YES" if the points can ...
from solution import can_form_right_angled_triangle, check_cities def test_can_form_right_angled_triangle(): assert can_form_right_angled_triangle([(0, 0), (1, 2), (3, 0)]) == "YES" assert can_form_right_angled_triangle([(0, 0), (6, 8), (3, 0)]) == "YES" assert can_form_right_angled_triangle([(0, 0), (1, 1...
[ { "docstring": "Determine if a set of magical points can form a right-angled triangle \nwith the right angle at the origin (0, 0).\n\nArgs:\npoints (List[Tuple[int, int]]): List of tuples containing coordinates (xi, yi).\n\nReturns:\nstr: \"YES\" if the points can form a right-angled triangle with the right ang...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_form_right_angled_triangle(points):\n points_set = set(points) # Create a set of points for quicker lookups\n for x, y in points:\n # We need...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00068397", "row_id": 68397, "seed_ids": "[25207]" }
0.64595
Taco_68397
I
[ "can_form_right_angled_triangle", "check_cities" ]
2
[ [ "check_cities", "can_form_right_angled_triangle" ] ]
1
[]
false
[]
false
pytest
true
[]
true
edf7bf9d9671dea9aa3635d7e856498a774c976a
f76681582834a5a2da47f72e4de372fdc9cb432d
v1.0
instruct
Taco
Taco_68399_I
You are a librarian managing a series of book loans in a university library. Each book has a unique identification number and a certain number of days it can be loaned out to a student. You need to track the book returns and ensure all books are returned within their loan period. According to the library policy, if an...
def check_book_loans(N, loans): for loan in loans: ID, D, R = loan if R > D: return "FINE" return "ALL RETURNED" def library_fines(input_data): lines = input_data.strip().split('\n') N = int(lines[0]) loans = [tuple(map(int, line.split())) for line in lines[1:N+1]] r...
def test_library_fines_all_returned(): input_data = "2\n201 20 15\n202 10 10\n" assert library_fines(input_data) == "ALL RETURNED" def test_library_fines_fine(): input_data = "3\n101 14 10\n102 7 5\n103 30 35\n" assert library_fines(input_data) == "FINE" def test_library_fines_single_book_fine(): ...
[ { "docstring": null, "function_declaration": "def check_book_loans(N, loans):", "function_name": "check_book_loans", "parameter_list": "(N, loans)" }, { "docstring": null, "function_declaration": "def library_fines(input_data):", "function_name": "library_fines", "parameter_list"...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def check_book_loans(N, book_details):\n \"\"\"\n Given N book details, this function checks if all books are returned within the loan period.\n \n Par...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00068399", "row_id": 68399, "seed_ids": "[19553]" }
0.675839
Taco_68399
I
[ "check_book_loans", "library_fines" ]
2
[ [ "library_fines", "check_book_loans" ] ]
1
[]
false
[]
false
pytest
false
[]
true
6078837e413f771a447c8913b98320a9cb2b8bb0
bd6fea39aaa2ce802b55db089dac258eb9c24a8a
v1.0
instruct
Taco
Taco_68445_I
The Acme Widget Company is conducting their annual inventory audit and needs assistance with optimizing their warehouse storage. Each widget in their inventory has a specific volume and a value. The company wants to maximize the total value of widgets stored in a warehouse that has a maximum volume capacity. The chall...
def find_optimal_storage(n, V, widgets): dp = [0] * (V + 1) counts = [{} for _ in range(V + 1)] for widget_name, volume, value in widgets: for j in range(volume, V + 1): if dp[j - volume] + value > dp[j]: dp[j] = dp[j - volume] + value counts[j] = counts[...
from solution import optimal_storage def test_example_input(): input_str = "3 50\ngadget 10 60\ndoohickey 20 100\nthingamajig 30 120" output_str = optimal_storage(input_str) assert output_str == "gadget 5" or output_str == "thingamajig 2" def test_impossible_case(): input_str = "2 5\nwidget1 10 50\nwi...
[ { "docstring": null, "function_declaration": "def find_optimal_storage(n, V, widgets):", "function_name": "find_optimal_storage", "parameter_list": "(n, V, widgets)" }, { "docstring": null, "function_declaration": "def parse_input(input_str):", "function_name": "parse_input", "pa...
[ 0, 0, 0, 0, 0, 1, 1, 1, 0, 0 ]
3
hard
0.3
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def optimize_storage(n, V, widgets):\n dp = [0] * (V + 1)\n selection = [[] for _ in range(V + 1)]\n\n for name, volume, value in widgets:\n for v ...
trial_gpt4o_7
{ "original_instruction": "", "prompt_id": "00068445", "row_id": 68445, "seed_ids": "[12204]" }
0.680526
Taco_68445
I
[ "find_optimal_storage", "parse_input", "optimal_storage" ]
3
[ [ "optimal_storage", "find_optimal_storage" ], [ "optimal_storage", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
7e43eb203f6633a9859cc1731382ee2cb1a84246
1dfd2cc03ac7062c6d0e846b9bde5fc17228659d
v1.0
instruct
Taco
Taco_68455_I
### Problem Statement: #### Exploring Tunnels The sprawling city of Neo-City is known for its extensive network of underground tunnels. The tunnels can be conceptualized as a graph, where intersections are nodes and tunnels are the edges connecting them. The city administration wants to ensure that all intersections ...
def find(parent, i): if parent[i] == i: return i else: return find(parent, parent[i]) def union(parent, rank, x, y): xroot = find(parent, x) yroot = find(parent, y) if xroot != yroot: if rank[xroot] < rank[yroot]: parent[xroot] = yroot elif rank[...
import pytest from solution import min_connections_to_connect_all def test_sample_cases(): T = 3 test_cases = [ ((5, 2), (0, 1), (1, 2)), ((4, 0),), ((2, 1), (0, 1)) ] expected = [2, 3, 0] assert min_connections_to_connect_all(T, test_cases) == expected def test_no_conn...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n else:\n return find(parent, parent[i])\n \ndef union(parent, rank, x, y):\n xroot ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00068455", "row_id": 68455, "seed_ids": "[12184]" }
0.680371
Taco_68455
I
[ "find", "union", "min_connections_to_connect_all" ]
3
[ [ "min_connections_to_connect_all", "find" ], [ "min_connections_to_connect_all", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
true
[]
true
b38456e90f28e4d88785937f848ae0e573c76e08
a8a0f11f1572e3af6d3f70b4d7456a9f0f0daa1b
v1.0
instruct
Taco
Taco_68460_I
In a small town, there's a population of n people who each have one or no pet. Each person has either a cat, a dog, or no pet at all. The local government wants to understand the distribution of pets in the town, so they asked you to help them determine the possible combinations of cat and dog ownership among the popul...
def pet_distribution(t, populations): """ Returns the possible distributions of people owning cats and dogs. Args: t: int, number of test cases. populations: list of int, populations for each test case. Returns: list of list of tuples: each list of tuples corresponds to one test case and co...
from solution import pet_distribution, format_pet_distribution def test_pet_distribution(): assert pet_distribution(1, [2]) == [ [(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (2, 0)] ] assert pet_distribution(1, [3]) == [ [(0, 0), (0, 1), (0, 2), (0, 3), (1, 0), (1, 1), (1, 2), (2, 0), (2, 1), (...
[ { "docstring": "Returns the possible distributions of people owning cats and dogs.\nArgs:\nt: int, number of test cases.\npopulations: list of int, populations for each test case.\n\nReturns:\nlist of list of tuples: each list of tuples corresponds to one test case and contains (x, y) pairs.", "function_dec...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def pet_distribution(t, cases):\n results = []\n for n in cases:\n combinations = []\n for x in range(n + 1):\n for y in range(n - x...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00068460", "row_id": 68460, "seed_ids": "[97]" }
0.622137
Taco_68460
I
[ "pet_distribution", "format_pet_distribution", "main" ]
3
[ [ "format_pet_distribution", "pet_distribution" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3319c3a5d1be72f34f4b9b708431c7b02e52e495
15b91ebcdd845dfb915646594d3c3b648c3954c2
v1.0
instruct
Taco
Taco_68497_I
James is an avid hiker and likes to explore various trails across the country. Recently, he has developed an interest in mapping out optimal paths that connect different scenic spots in a trail. Each trail can be represented as a graph, where nodes represent the scenic spots and edges represent the paths connecting the...
class UnionFind: def __init__(self, n): self.parent = list(range(n)) self.rank = [0] * n def find(self, u): if self.parent[u] != u: self.parent[u] = self.find(self.parent[u]) return self.parent[u] def union(self, u, v): root_u = self.find(u) root...
def test_minimum_spanning_tree(): assert minimum_spanning_tree(4, 5, [(1, 2, 1), (1, 3, 4), (2, 3, 2), (2, 4, 7), (3, 4, 3)]) == 6 def test_minimum_spanning_tree_no_edges(): assert minimum_spanning_tree(2, 1, [(1, 2, 1)]) == 1 def test_minimum_spanning_tree_disconnected(): assert minimum_spanning_tree(4, ...
[]
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n return find(parent, parent[i])\n\ndef union(parent, rank, x, y):\n root_x = find(parent, x)\...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00068497", "row_id": 68497, "seed_ids": "[18828]" }
0.723066
Taco_68497
I
[ "kruskal_mst", "minimum_spanning_tree" ]
2
[ [ "minimum_spanning_tree", "kruskal_mst" ] ]
1
[]
false
[ "UnionFind" ]
true
pytest
false
[]
true
ceb6259bc3e8f0906cbc4998accb849a3763beed
41e52ad96487c97e2c0228c23bb76eb824803155
v1.0
instruct
Taco
Taco_68508_I
Alice is fond of manipulating sequences with unique integer elements. She has devised a special sequence operation called the "Inverse Swap". Given an initial sequence S1, S2, ..., SN and a target sequence T1, T2, ..., TN derived from S. The Inverse Swap operation consists of the following steps: 1. Find any subseque...
def min_swaps_to_transform(initial, target): if sorted(initial) != sorted(target): return -1 index_dict = {v: i for i, v in enumerate(target)} for i in range(len(initial)): initial[i] = index_dict[initial[i]] visited = [False] * len(initial) swaps = 0 for i in range(len(in...
from solution import min_swaps_helper def test_min_swaps_example(): assert min_swaps_helper(5, [3, 1, 2, 4, 5], [1, 2, 3, 4, 5]) == 2 def test_min_swaps_already_sorted(): assert min_swaps_helper(5, [1, 2, 3, 4, 5], [1, 2, 3, 4, 5]) == 0 def test_min_swaps_reverse(): assert min_swaps_helper(5, [5, 4, 3, 2...
[ { "docstring": null, "function_declaration": "def min_swaps_to_transform(initial, target):", "function_name": "min_swaps_to_transform", "parameter_list": "(initial, target)" }, { "docstring": null, "function_declaration": "def min_swaps_helper(N, initial, target):", "function_name": ...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def minimum_swaps_to_transform(S, T):\n \"\"\"\n Finds the minimum number of swaps needed to transform sequence S into sequence T\n using the Inverse Swap...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00068508", "row_id": 68508, "seed_ids": "[23465]" }
0.753147
Taco_68508
I
[ "min_swaps_to_transform", "min_swaps_helper" ]
2
[ [ "min_swaps_helper", "min_swaps_to_transform" ] ]
1
[]
false
[]
false
pytest
true
[]
true
42c64377eab70f7acd7278d8a637190cb16f3d62
c3f7f8b1a3843e643db3aaa5e7874a56921708d7
v1.0
instruct
Taco
Taco_68523_I
Implement a function that takes a list of strings and returns a list of booleans. Each boolean corresponds to whether the string at the same index of the input list is a valid "Palindrome Permutation." A "Palindrome Permutation" is a string that can be rearranged to form a palindrome. For example, "tactcoa" can be rea...
def is_palindrome_permutation(s): """ Return True if the input string can be rearranged to form a palindrome, else False. """ # Ignore spaces and consider characters case-insensitively s = s.replace(" ", "").lower() # Create a frequency dictionary to count each character char_count = {}...
from solution import check_palindrome_permutations def test_empty_string(): assert check_palindrome_permutations([""]) == [True] def test_single_character(): assert check_palindrome_permutations(["a"]) == [True] assert check_palindrome_permutations(["z"]) == [True] def test_multiple_words(): assert c...
[ { "docstring": "Return True if the input string can be rearranged to form a palindrome, else False.", "function_declaration": "def is_palindrome_permutation(s):", "function_name": "is_palindrome_permutation", "parameter_list": "(s)" }, { "docstring": "Takes a list of strings and returns a li...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome_permutation(s):\n \"\"\"\n Determine if a given string is a Palindrome Permutation.\n \"\"\"\n from collections import Counter\n \...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00068523", "row_id": 68523, "seed_ids": "[14540]" }
0.736079
Taco_68523
I
[ "is_palindrome_permutation", "check_palindrome_permutations" ]
2
[ [ "check_palindrome_permutations", "is_palindrome_permutation" ] ]
1
[]
false
[]
false
pytest
true
[]
true
23cbbe1e4200d1a4a5c9da4f5252cc073a8618a6
c14cba6b5b7c2a65474caeb6af059b2bd835a370
v1.0
instruct
Taco
Taco_68539_I
You are helping to organize a marathon and need to determine the relative ranking of participants based on their reported finishing times. However, some participants have reported their finishing times inconsistently, and you need to detect this. The marathon participants' finishing times are recorded in pairs, where ...
def check_consistency(n, m, comparisons): from collections import defaultdict, deque # Create a graph based on the pairwise comparisons graph = defaultdict(list) in_degree = [0] * n for a, b in comparisons: graph[a].append(b) in_degree[b] += 1 # Topological Sort (Kahn's Al...
from solution import marathon_ranking def test_sample_input1(): pairs = [(0, 1), (1, 2), (2, 3)] assert marathon_ranking(4, 3, pairs) == 'consistent' def test_sample_input2(): pairs = [(0, 1), (2, 1), (1, 3)] assert marathon_ranking(4, 3, pairs) == 'consistent' def test_sample_input3(): p...
[ { "docstring": null, "function_declaration": "def check_consistency(n, m, comparisons):", "function_name": "check_consistency", "parameter_list": "(n, m, comparisons)" }, { "docstring": null, "function_declaration": "def marathon_ranking(n, m, pairs):", "function_name": "marathon_ran...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import defaultdict\n\ndef is_consistent(N, M, comparisons):\n def dfs(v):\n stack = [(v, 0)]\n visited[v] = 0\n while stac...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00068539", "row_id": 68539, "seed_ids": "[23191]" }
0.635958
Taco_68539
I
[ "check_consistency", "marathon_ranking" ]
2
[ [ "marathon_ranking", "check_consistency" ] ]
1
[]
false
[]
false
pytest
true
[]
true
83ff334ae79b5154579f8233d19deafed31515d4
7c82ac8a08c82fdaa72b733cdc4e87ad272857fd
v1.0
instruct
Taco
Taco_68604_I
A land navigation robot is deployed in a grid with dimensions n x m. The grid contains some obstacles, represented as 1s, while free spaces are represented as 0s. The robot starts at the top left corner (1, 1) and must reach the bottom right corner (n, m). The robot can only move right or down at each step. Write a pro...
def unique_paths_with_obstacles(grid): n = len(grid) m = len(grid[0]) if n > 0 else 0 if grid[0][0] == 1 or grid[n-1][m-1] == 1: return 0 dp = [[0]*m for _ in range(n)] dp[0][0] = 1 for i in range(n): for j in range(m): if grid[i][j] == 1: dp[i][j] ...
from solution import unique_paths_with_obstacles, find_unique_paths, parse_input def test_unique_paths_with_obstacles(): grid1 = [ [0, 0, 0], [0, 1, 0], [0, 0, 0] ] assert unique_paths_with_obstacles(grid1) == 2 grid2 = [ [0, 1, 0], [0, 1, 0], [0, 0, 0] ...
[ { "docstring": null, "function_declaration": "def unique_paths_with_obstacles(grid):", "function_name": "unique_paths_with_obstacles", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def find_unique_paths(test_cases):", "function_name": "find_unique_paths"...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def unique_paths_with_obstacles(test_cases):\n results = []\n \n for case in test_cases:\n n, m, grid = case\n if grid[0][0] == 1 or grid[n-...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00068604", "row_id": 68604, "seed_ids": "[3683]" }
0.667578
Taco_68604
I
[ "unique_paths_with_obstacles", "find_unique_paths", "parse_input", "main" ]
4
[ [ "find_unique_paths", "unique_paths_with_obstacles" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
a3b6b78563dab2ac3cc9addcb1ca5d8b6264589c
a9ead1821b73a6d234cea0afd1e0c26d3243f0f6
v1.0
instruct
Taco
Taco_68615_I
Jimmy plans to build toy blocks using several types of components. He has various types of components, each of a certain size. Jimmy wants to create a single large block by aligning the components side by side in a row. However, he can only pick each component a specific number of times, and he wants the total length...
def max_block_length(K, components, L): dp = [0] * (L + 1) for size, count in components: for j in range(L, size - 1, -1): for k in range(1, count + 1): if j - k * size >= 0: dp[j] = max(dp[j], dp[j - k * size] + k * size) return dp[L] # Fun...
from solution import max_block_length def test_max_block_length_sample(): K = 3 components = [(5, 3), (10, 2), (3, 8)] L = 25 assert max_block_length(K, components, L) == 25 def test_max_block_length_no_reach(): K = 2 components = [(1, 2), (2, 3)] L = 10 assert max_block_length(K, comp...
[ { "docstring": null, "function_declaration": "def max_block_length(K, components, L):", "function_name": "max_block_length", "parameter_list": "(K, components, L)" }, { "docstring": null, "function_declaration": "def solve():", "function_name": "solve", "parameter_list": "()" }...
[ 1, 0 ]
1
medium
0.5
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_block_length(K, components, L):\n dp = [0] * (L + 1)\n \n for size, count in components:\n for j in range(L, size - 1, -1):\n fo...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00068615", "row_id": 68615, "seed_ids": "[5336]" }
0.655225
Taco_68615
I
[ "max_block_length", "solve" ]
2
[ [ "solve", "max_block_length" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4c706f41084d7dff41760b02f13fd1e22a48c093
fff4799b34a808489ac2b7e8a1fb12114687c209
v1.0
instruct
Taco
Taco_68624_I
In the kingdom of Gridlandia, there is a beautiful square garden of size $n \times n$. The garden is divided into unit square cells. Most of the cells are grassy, but some cells are waterlogged and cannot be stepped on. Gridlandia’s Queen wants to host a grand feast in the garden, and for that, she needs to find the l...
def maximalRectangle(grid): if not grid: return 0 n = len(grid) heights = [0] * n max_area = 0 for i in range(n): for j in range(n): heights[j] = heights[j] + 1 if grid[i][j] == 0 else 0 max_area = max(max_area, largestRectangleArea(heights)) return...
def test_maximalRectangle(): assert maximalRectangle([ [0, 1, 1, 0, 1], [1, 0, 1, 1, 0], [0, 0, 1, 0, 0], [1, 1, 0, 0, 0], [1, 0, 0, 1, 0] ]) == 4 assert maximalRectangle([ [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0...
[ { "docstring": null, "function_declaration": "def maximalRectangle(grid):", "function_name": "maximalRectangle", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def largestRectangleArea(heights):", "function_name": "largestRectangleArea", "parameter_li...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_histogram_area(heights):\n \"\"\"\n Helper function to calculate \"largest rectangle in histogram\" problem.\n \"\"\"\n stack = []\n max_are...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00068624", "row_id": 68624, "seed_ids": "[21851]" }
0.670971
Taco_68624
I
[ "maximalRectangle", "largestRectangleArea" ]
2
[ [ "maximalRectangle", "largestRectangleArea" ] ]
1
[]
false
[]
false
pytest
false
[]
true
ffbba69b420f35d2ab3111704fb0b47776f1727c
316ecfa9eb4d40293a9314b958daaf9aa945c41d
v1.0
instruct
Taco
Taco_68664_I
You are given a directed graph with $N$ vertices (numbered $1$ through $N$) and $M$ edges. Each edge has an associated integer weight. You need to compute the length of the shortest path from vertex $1$ to all other vertices. If a vertex is unreachable from vertex $1$, output $-1$ for that vertex. -----Input----- - Th...
import heapq def dijkstra(N, edges): """ Compute the shortest path from vertex 1 to all other vertices. :param N: Total number of vertices. :param edges: List of tuples representing directed edges (u, v, w) with weight w. :return: List of shortest distances from vertex 1 to vertex i (2 <= i <= N), ...
from solution import shortest_path_from_one def test_example_case(): N, M = 5, 6 edges = [ (1, 2, 2), (1, 3, 4), (2, 3, 1), (3, 4, 1), (2, 4, 7), (5, 3, 5) ] assert shortest_path_from_one(N, M, edges) == [2, 3, 4, -1] def test_no_path_case(): # 4 ver...
[ { "docstring": "Compute the shortest path from vertex 1 to all other vertices.\n:param N: Total number of vertices.\n:param edges: List of tuples representing directed edges (u, v, w) with weight w.\n:return: List of shortest distances from vertex 1 to vertex i (2 <= i <= N), or -1 if unreachable.", "functi...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef shortest_path(N, M, edges):\n # Create adjacency list for the graph\n graph = [[] for _ in range(N + 1)]\n for u, v, w in edges:\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00068664", "row_id": 68664, "seed_ids": "[6209]" }
0.82686
Taco_68664
I
[ "dijkstra", "shortest_path_from_one" ]
2
[ [ "shortest_path_from_one", "dijkstra" ] ]
1
[]
false
[]
false
pytest
true
[]
true
80f842a1c601d51467c8ba79e491dec955df6afe
cf0fe4c2545de179c00f9cc4cfaa0bb2f0257578
v1.0
instruct
Taco
Taco_68666_I
Prime Length Palindrome Substring Given a string $S$ of lowercase alphabets, you need to find the length of the longest substring of $S$ such that the length of the substring is a prime number and the substring is also a palindrome. If no such substring exists, output $-1$. ##### Input: - The first line contains an i...
def is_palindrome(s): return s == s[::-1] def generate_primes(n): primes = [] sieve = [True] * (n + 1) for p in range(2, n + 1): if sieve[p]: primes.append(p) for i in range(p * p, n + 1, p): sieve[i] = False return primes def longest_prime_length_pa...
from solution import solve def test_sample_cases(): assert solve(["abacabad", "abcde"]) == [7, -1] def test_single_character(): assert solve(["a"]) == [-1] def test_no_palindromes(): assert solve(["abcdefghijklmnopqrstuvwxyz"]) == [-1] def test_all_same_characters(): assert solve(["aaaaaaa"]) == [7]...
[ { "docstring": null, "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def generate_primes(n):", "function_name": "generate_primes", "parameter_list": "(n)" }, { "doc...
[ 0, 0, 0, 0, 0, 1, 1, 1, 0, 0 ]
3
hard
0.3
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"Helper function to check if a number is a prime number.\"\"\"\n if num <= 1:\n return False\n for i in range(2, int(num*...
trial_gpt4o_7
{ "original_instruction": "", "prompt_id": "00068666", "row_id": 68666, "seed_ids": "[6301]" }
0.750711
Taco_68666
I
[ "is_palindrome", "generate_primes", "longest_prime_length_palindrome", "solve" ]
4
[ [ "longest_prime_length_palindrome", "generate_primes" ], [ "longest_prime_length_palindrome", "is_palindrome" ], [ "solve", "longest_prime_length_palindrome" ] ]
3
[]
false
[]
false
pytest
true
[]
true
d14c3cfd29bab08cdd2f10c5a17bd43a735c2f98
aba2a1d90c0463b50b257503c79dc17ab47207b1
v1.0
instruct
Taco
Taco_68673_I
In a parallel universe, the city of Bitland has a peculiar system for maintaining its resources. The city consists of n sectors, each having a certain number of resource units associated with it. The resource units of the i-th sector are denoted by r_{i}. Managing these resources is crucial for the city's survival. Th...
def get_resource_score(resources): """ Returns the sum of the resource units mod 10^9 + 7. """ MOD = 10**9 + 7 return sum(resources) % MOD def update_resource(resources, index, new_value): """ Updates the resource at the given index with the new value and returns the updated sum. """ ...
from solution import resource_management def test_initial_setup(): assert resource_management(3, [1, 2, 3], []) == [6] def test_single_update(): assert resource_management(3, [1, 2, 3], [(2, 5)]) == [6, 9] def test_multiple_updates(): assert resource_management(3, [1, 2, 3], [(2, 5), (1, 6)]) == [6, 9, 1...
[ { "docstring": "Returns the sum of the resource units mod 10^9 + 7.", "function_declaration": "def get_resource_score(resources):", "function_name": "get_resource_score", "parameter_list": "(resources)" }, { "docstring": "Updates the resource at the given index with the new value and returns...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def get_resource_score(resources):\n \"\"\"\n Returns the sum of the resource units mod 10^9 + 7.\n \"\"\"\n MOD = 10**9 + 7\n return sum(resources)...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00068673", "row_id": 68673, "seed_ids": "[1571]" }
0.604591
Taco_68673
I
[ "get_resource_score", "update_resource", "resource_management" ]
3
[ [ "resource_management", "get_resource_score" ], [ "resource_management", "update_resource" ], [ "update_resource", "get_resource_score" ] ]
3
[]
false
[]
false
pytest
true
[]
true
e3d4afd6b1bb8b09ab890b345b5030d52bc673cd
765ea6aa135c8f7439e0b298741aa20fde2a6b2f
v1.0
instruct
Taco
Taco_68777_I
Given an undirected graph with `n` nodes and `m` edges, each edge has a weight. You are to find the smallest weight of a path from node `1` to node `n`. If no such path exists, return `-1`. The graph might contain cycles. Input: - The first line contains two integers `n` and `m` (1 ≤ n ≤ 1000, 0 ≤ m ≤ 10000) — the num...
import heapq def dijkstra(n, edges): def build_graph(n, edges): graph = {i: [] for i in range(1, n+1)} for u, v, w in edges: graph[u].append((v, w)) graph[v].append((u, w)) return graph graph = build_graph(n, edges) pq = [(0, 1)] # (distance, node) ...
from solution import find_shortest_path def test_example_1(): edges = [ (1, 2, 5), (2, 3, 10), (1, 3, 20), (3, 4, 1) ] assert find_shortest_path(4, 4, edges) == 16 def test_example_2(): edges = [ (1, 2, 1), (2, 3, 2), (3, 1, 4) ] assert f...
[ { "docstring": null, "function_declaration": "def dijkstra(n, edges):", "function_name": "dijkstra", "parameter_list": "(n, edges)" }, { "docstring": null, "function_declaration": "def find_shortest_path(n, m, edges):", "function_name": "find_shortest_path", "parameter_list": "(n...
[ 0, 0, 0, 0, 1, 1, 0, 0, 1 ]
3
medium
0.333
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared1_results_combined.jsonl", "solution_code": "import heapq\n\ndef dijkstra(n, graph, start=1, end=None):\n \"\"\"\n Dijkstra's algorithm to find the shortest path in a graph.\n ...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00068777", "row_id": 68777, "seed_ids": "[12426]" }
0.817377
Taco_68777
I
[ "dijkstra", "find_shortest_path" ]
2
[ [ "find_shortest_path", "dijkstra" ] ]
1
[]
false
[]
false
pytest
true
[]
true
af5ae90e2d484547def84af58250b4a7c7ebfe71
0869cf1e82e54740bac959099887642c47f98278
v1.0
instruct
Taco
Taco_68785_I
Alyssa loves painting and geometry. She has a canvas represented as a 2D grid with dimensions `n x m`, where each cell can be painted from a set of `k` possible colors. Each color is represented by a distinct integer from `1` to `k`. Alyssa strives to achieve a beautiful pattern on her canvas, and she does so by follow...
def can_color(canvas, i, j, n, m, k, p, q, r): used_colors = set() # Check colors directly above within p range for x in range(1, p+1): if i-x >= 0: used_colors.add(canvas[i-x][j]) # Check colors directly to the left within q range for y in range(1, q+1): if j-y >= 0: ...
from solution import paint_canvas def test_case_1(): n, m, k = 3, 3, 3 p, q, r = 2, 2, 1 assert paint_canvas(n, m, k, p, q, r) == ("YES", [[1, 2, 3], [2, 3, 1], [3, 1, 2]]) def test_case_2(): n, m, k = 3, 3, 2 p, q, r = 2, 2, 2 assert paint_canvas(n, m, k, p, q, r) == ("NO", []) def test_case...
[ { "docstring": null, "function_declaration": "def can_color(canvas, i, j, n, m, k, p, q, r):", "function_name": "can_color", "parameter_list": "(canvas, i, j, n, m, k, p, q, r)" }, { "docstring": null, "function_declaration": "def paint_canvas(n, m, k, p, q, r):", "function_name": "p...
[ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_paint_canvas(n, m, k, p, q, r):\n def is_valid(color, matrix, i, j):\n for x in range(1, p+1):\n if i - x >= 0 and matrix[i-x][j] == c...
trial_gpt4o_5
{ "original_instruction": "", "prompt_id": "00068785", "row_id": 68785, "seed_ids": "[2433]" }
0.76265
Taco_68785
I
[ "can_color", "paint_canvas", "format_canvas", "main" ]
4
[ [ "paint_canvas", "can_color" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2f5acb69e167d3be5a784234a9b9672815dad279
755a670bb301d97ff8ddae25a56a1cc89e570c8b
v1.0
instruct
Taco
Taco_68816_I
Write a function `calculate_roman_sum(s)` that takes a string `s` representing a Roman numeral expression. The string will be composed of multiple Roman numerals separated by the plus sign ('+'). Your function should return the sum of these Roman numerals as an integer. Roman numerals are represented by the following ...
def roman_to_int(roman): """ Converts a single Roman numeral string to an integer """ roman_values = { 'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000 } total = 0 prev_value = 0 for char in reversed(roman): value = roman_values[char] if value ...
from solution import calculate_roman_sum def test_single_numeral(): assert calculate_roman_sum("X") == 10 def test_two_numerals(): assert calculate_roman_sum("X+V") == 15 def test_three_numerals(): assert calculate_roman_sum("X+V+XII") == 27 def test_complex_expression(): assert calculate_roman_sum(...
[ { "docstring": "Converts a single Roman numeral string to an integer", "function_declaration": "def roman_to_int(roman):", "function_name": "roman_to_int", "parameter_list": "(roman)" }, { "docstring": "Given a string of Roman numeral expressions separated by '+', returns their sum as an int...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def roman_to_int(roman):\n \"\"\"\n Converts a single Roman numeral string to an integer\n \"\"\"\n roman_values = {\n 'I': 1, 'V': 5, 'X': 10, ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00068816", "row_id": 68816, "seed_ids": "[1652]" }
0.607863
Taco_68816
I
[ "roman_to_int", "calculate_roman_sum" ]
2
[ [ "calculate_roman_sum", "roman_to_int" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b823ace63a87cfe53b646628759d9b3de8bf46b0
c4255f453ad3b6dd805c361d000356a82dbe223e
v1.0
instruct
Taco
Taco_68823_I
You are given a set of points on a 2D plane, and you need to determine the smallest circle that can enclose all the points. If there are multiple circles with the same minimum radius, return the one whose center has the smallest x-coordinate. If there is still a tie, return the one with the smallest y-coordinate. Inpu...
import math from itertools import combinations def distance(p1, p2): """ Calculate the Euclidean distance between two points p1 and p2. """ return math.sqrt((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2) def get_circle_center_and_radius(p1, p2, p3): """ Find the circumcenter and radius of the ci...
import math from solution import distance, get_circle_center_and_radius, smallest_enclosing_circle def test_distance(): assert distance((0, 0), (3, 4)) == 5 assert distance((1, 1), (1, 1)) == 0 assert distance((-1, -1), (1, 1)) == math.sqrt(8) def test_get_circle_center_and_radius(): center, radius = ...
[ { "docstring": "Calculate the Euclidean distance between two points p1 and p2.", "function_declaration": "def distance(p1, p2):", "function_name": "distance", "parameter_list": "(p1, p2)" }, { "docstring": "Find the circumcenter and radius of the circle passing through points p1, p2, and p3....
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\nfrom typing import List, Tuple\n\ndef find_smallest_enclosing_circle(points: List[Tuple[int, int]]) -> Tuple[float, float, float]:\n def dist(p1, p...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00068823", "row_id": 68823, "seed_ids": "[18789]" }
0.643386
Taco_68823
I
[ "distance", "get_circle_center_and_radius", "smallest_enclosing_circle", "main" ]
4
[ [ "get_circle_center_and_radius", "distance" ], [ "smallest_enclosing_circle", "distance" ], [ "smallest_enclosing_circle", "get_circle_center_and_radius" ] ]
3
[]
false
[]
false
pytest
true
[]
true
f349b271fc59dbc029457606ac65bfba66e93b35
143e8e956bfe01217a93bb36223bc783373e4c92
v1.0
instruct
Taco
Taco_68912_I
Santa Claus wants to build a toy train from blocks of varying sizes. Each block has a specific size, density, and an identifier. To assemble the train, he must decide the order in which these blocks should be stacked. The train's stability directly relates to the blocks' densities and their sizes. The rules for assemb...
def sort_blocks(blocks): """ Sorts blocks based on given rules: 1. Blocks with higher density should be placed first. 2. If two blocks have the same density, the larger block should come before the smaller one. 3. If two blocks have both the same density and size, they can be in any order relative t...
from solution import get_sorted_identifiers def test_sort_blocks_example(): input_data = """4 1 10 5 Engine 2 8 6 Coach 3 15 4 Freight 4 15 7 Tender""" sorted_identifiers = get_sorted_identifiers(input_data) assert sorted_identifiers == [4, 3, 1, 2] def test_sort_blocks_same_density(): input_data = ""...
[ { "docstring": "Sorts blocks based on given rules:\n1. Blocks with higher density should be placed first.\n2. If two blocks have the same density, the larger block should come before the smaller one.\n3. If two blocks have both the same density and size, they can be in any order relative to each other.\n\nArgs:...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sort_blocks(blocks):\n \"\"\"\n Sort blocks by density in descending order. For blocks with the same density, \n sort by size in descending order.\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00068912", "row_id": 68912, "seed_ids": "[12083]" }
0.66921
Taco_68912
I
[ "sort_blocks", "process_input", "get_sorted_identifiers" ]
3
[ [ "get_sorted_identifiers", "process_input" ], [ "get_sorted_identifiers", "sort_blocks" ] ]
2
[ "process_input" ]
false
[]
false
pytest
true
[]
true
d08f8c383cc9bde56f9183e5431daf37fa6c970f
3a96e17a6b44addc4edb4c5fb6857d34b6d77b05
v1.0
instruct
Taco
Taco_68987_I
Given an array of n integers, you need to process q queries. Each query contains two integers l and r, and you need to determine the sum of the subarray that starts at index l and ends at index r. You need to print the result of each query. Note that the sum of the subarray should be taken modulo 1000000007 (10^9 + 7)...
MOD = 1000000007 def preprocess_prefix_sums(arr): """ Preprocess the array to compute prefix sums. """ n = len(arr) prefix_sums = [0] * (n + 1) for i in range(1, n + 1): prefix_sums[i] = (prefix_sums[i - 1] + arr[i - 1]) % MOD return prefix_sums def query_sum(prefix_sums, l, r): ...
def test_preprocess_prefix_sums(): arr = [1, 2, 3, 4, 5] expected_prefix_sums = [0, 1, 3, 6, 10, 15] assert preprocess_prefix_sums(arr) == expected_prefix_sums def test_query_sum(): prefix_sums = [0, 1, 3, 6, 10, 15] assert query_sum(prefix_sums, 1, 3) == 6 assert query_sum(prefix_sums, 2, 4) =...
[ { "docstring": "Preprocess the array to compute prefix sums.", "function_declaration": "def preprocess_prefix_sums(arr):", "function_name": "preprocess_prefix_sums", "parameter_list": "(arr)" }, { "docstring": "Return the sum of subarray from index l to r (1-based index), modulo 1000000007."...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def compute_subarray_sums(n, q, array, queries):\n \"\"\"\n Computes the sum of subarrays using given queries.\n \n Args:\n n : int : Number of elem...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00068987", "row_id": 68987, "seed_ids": "[25032]" }
0.722905
Taco_68987
I
[ "preprocess_prefix_sums", "query_sum", "process_queries" ]
3
[ [ "process_queries", "preprocess_prefix_sums" ], [ "process_queries", "query_sum" ] ]
2
[ "process_queries" ]
false
[]
false
pytest
false
[]
true
29c9d8d750c9781b594a6c67f08083fe1a03b1d6
96811e180770df68322f5f75eabb21b82f2f4c42
v1.0
instruct
Taco
Taco_69034_I
Robert the Scientist is working in his laboratory to create a special grid that adheres to a unique set of rules. This grid is an n by m matrix, where each cell can either contain an 'A' molecule or a 'B' molecule. The matrix is organized such that no two 'A' molecules can be in the same row or column. Robert needs to ...
from math import comb def count_valid_configurations(n, m, k): """ Returns the number of valid configurations of an n by m grid with exactly k 'A' molecules such that no two 'A' molecules are in the same row or column. """ if k > min(n, m): return 0 return comb(n, k) * comb(m, k) *...
from solution import count_valid_configurations def test_example1(): assert count_valid_configurations(2, 2, 2) == 2 def test_example2(): assert count_valid_configurations(3, 3, 1) == 9 def test_more_than_possible(): assert count_valid_configurations(2, 2, 3) == 0 def test_zero_configurations(): ass...
[ { "docstring": "Returns the number of valid configurations of an n by m grid with exactly k 'A' molecules\nsuch that no two 'A' molecules are in the same row or column.", "function_declaration": "def count_valid_configurations(n, m, k):", "function_name": "count_valid_configurations", "parameter_lis...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef num_configurations(n, m, k):\n \"\"\"\n Calculate number of valid configurations where no two 'A' molecules are in the same row or column....
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00069034", "row_id": 69034, "seed_ids": "[32]" }
0.698206
Taco_69034
I
[ "count_valid_configurations", "factorial" ]
2
[ [ "count_valid_configurations", "factorial" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9ba8234164abc640b023271fcbaceae9180c22a5
346a13a93079f6e76040595ee1ab07d4d5d084f5
v1.0
instruct
Taco
Taco_69057_I
A new startup has gained popularity for its innovative messaging system. The system works by allowing users to send specific types of messages that contain numeric codes. Each sequence of messages a user sends forms a list of integers. The system has a special feature that can merge two such lists into a single list wh...
def merge_lists(lists, operations): """ Function to merge multiple lists based on the given merge operations. Parameters: lists (List[List[int]]): A list of lists containing integers. operations (List[Tuple[int, int]]): A list of tuples where each tuple contains two integers representing indice...
import pytest from solution import process_input_and_merge, merge_lists def test_merge_simple_case(): data = "3\n1 2 3 4\n5 6 7\n8 9\n2\n1 2\n1 3" assert process_input_and_merge(data) == [1, 2, 3, 4, 5, 6, 7, 8, 9] def test_merge_no_operations(): data = "2\n1 2\n3 4\n0" assert process_input_and_merge(...
[ { "docstring": "Function to merge multiple lists based on the given merge operations.\n\nParameters:\nlists (List[List[int]]): A list of lists containing integers.\noperations (List[Tuple[int, int]]): A list of tuples where each tuple contains two integers representing indices of lists to merge.\n\nReturns:\nLi...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def merge_message_lists(m, lists, n, operations):\n \"\"\"\n Merges multiple lists of integers based on provided merge operations.\n\n Parameters:\n m ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00069057", "row_id": 69057, "seed_ids": "[1624]" }
0.618352
Taco_69057
I
[ "merge_lists", "process_input_and_merge" ]
2
[ [ "process_input_and_merge", "merge_lists" ] ]
1
[]
false
[]
false
pytest
true
[]
true
07c56a90474f82bee22cca4466dbd689179ba43b
3e0fa62191bd42df83146fd6c04c6828ab18ac02
v1.0
instruct
Taco
Taco_69074_I
You are given a rectangular grid with R rows and C columns, where each cell contains either '0' or '1'. '0' represents an empty cell while '1' represents an obstacle. A path from the top-left corner (0, 0) to the bottom-right corner (R-1, C-1) is valid if it only moves right or down at each step and does not pass throu...
def count_unique_paths(grid): R = len(grid) C = len(grid[0]) if grid[0][0] == '1' or grid[R-1][C-1] == '1': return 0 dp = [[0] * C for _ in range(R)] dp[0][0] = 1 for i in range(R): for j in range(C): if grid[i][j] == '1': dp[i][j] = 0 ...
from solution import unique_paths_in_grid def test_example1(): grid = "3 3\n000\n010\n000" assert unique_paths_in_grid(grid) == 2 def test_example2(): grid = "2 2\n00\n11" assert unique_paths_in_grid(grid) == 0 def test_example3(): grid = "4 4\n0000\n0110\n0000\n0010" assert unique_paths_in_g...
[ { "docstring": null, "function_declaration": "def count_unique_paths(grid):", "function_name": "count_unique_paths", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def unique_paths_in_grid(grid_str):", "function_name": "unique_paths_in_grid", "paramet...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def num_paths(grid):\n R = len(grid)\n C = len(grid[0])\n \n if grid[0][0] == '1' or grid[R-1][C-1] == '1':\n return 0\n \n dp = [[0] * C ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00069074", "row_id": 69074, "seed_ids": "[10031]" }
0.770813
Taco_69074
I
[ "count_unique_paths", "unique_paths_in_grid" ]
2
[ [ "unique_paths_in_grid", "count_unique_paths" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e3a7e5b4c404c75ef4acbf2b3fe8de2461486309
06c2f4b9293a6ee30a68b895a2f5295aec91118f
v1.0
instruct
Taco
Taco_69080_I
You are given a function that accepts a list of non-negative integers and returns the concatenation of those integers in the format that produces the largest possible number. Your task is to implement this function. The resulting number should still adhere to integer constraints (e.g., no leading zeros). The output sh...
from functools import cmp_to_key def compare(x, y): if x + y > y + x: return -1 elif x + y < y + x: return 1 else: return 0 def largest_number(nums): """ Returns the concatenation of the numbers in nums in a way that forms the largest possible number. """ # Convert ...
from solution import largest_number def test_single_digit_numbers(): assert largest_number([1, 2, 3, 4, 5]) == '54321' def test_double_digit_numbers(): assert largest_number([10, 2]) == '210' def test_complex_case(): assert largest_number([3, 30, 34, 5, 9]) == '9534330' def test_all_zeros(): ass...
[ { "docstring": null, "function_declaration": "def compare(x, y):", "function_name": "compare", "parameter_list": "(x, y)" }, { "docstring": "Returns the concatenation of the numbers in nums in a way that forms the largest possible number.", "function_declaration": "def largest_number(num...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from functools import cmp_to_key\n\ndef largest_number(nums):\n \"\"\"\n Returns the concatenation of integers in the list nums that forms the largest possib...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00069080", "row_id": 69080, "seed_ids": "[1534]" }
0.710273
Taco_69080
I
[ "compare", "largest_number" ]
2
[ [ "largest_number", "compare" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7861d54f2d564488f891a9e0a2ccc59f932cceba
480d63e3c0e45653cff6a0159bc6f74e953eac87
v1.0
instruct
Taco
Taco_69123_I
Given an array $A$ of $n$ integers, and $q$ queries, each of which asks for the sum of all values in a subarray defined by two indices $l$ and $r$ (inclusive). Your task is to efficiently compute the sum for each query. Constraints - $1 \leq n, q \leq 100,000$ - $1 \leq A[i] \leq 1,000$ - $1 \leq l, r \leq n$ Input ...
def compute_prefix_sums(arr): """ Computes the prefix sums of the given array. """ n = len(arr) prefix_sums = [0] * (n + 1) for i in range(1, n + 1): prefix_sums[i] = prefix_sums[i - 1] + arr[i - 1] return prefix_sums def range_sum(prefix_sums, l, r): """ Computes the sum ...
from solution import process_queries def test_process_queries_example(): n = 5 arr = [1, 2, 3, 4, 5] queries = [(1, 3), (2, 5), (1, 5)] expected_result = [6, 14, 15] result = process_queries(n, arr, queries) assert result == expected_result def test_process_queries_single_element(): n = 1 ...
[ { "docstring": "Computes the prefix sums of the given array.", "function_declaration": "def compute_prefix_sums(arr):", "function_name": "compute_prefix_sums", "parameter_list": "(arr)" }, { "docstring": "Computes the sum of the subarray from index l to r using the prefix sums array.", "...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def preprocess_array(A):\n \"\"\"\n Preprocess the array to create a prefix sum array.\n \n Args:\n A: List of integers.\n \n Returns:\n Li...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00069123", "row_id": 69123, "seed_ids": "[2473]" }
0.632519
Taco_69123
I
[ "compute_prefix_sums", "range_sum", "process_queries" ]
3
[ [ "process_queries", "compute_prefix_sums" ], [ "process_queries", "range_sum" ] ]
2
[ "process_queries" ]
false
[]
false
pytest
true
[]
true
eefb9b3a7276f393ee864198f8d9d228669275d3
baa8b157eaa83d7a202435351133906488ed5c11
v1.0
instruct
Taco
Taco_69186_I
In computer science, binary trees are a fundamental data structure used in various algorithms. A binary tree is a tree data structure in which each node has at most two children, referred to as the left child and the right child. A full binary tree is a type of binary tree where every node other than the leaves has ex...
class TreeNode: def __init__(self, value=0, left=None, right=None): self.value = value self.left = left self.right = right def build_tree(preorder, inorder): if not preorder or not inorder: return None root_value = preorder[0] root = TreeNode(root_value) mid = inord...
import pytest from solution import tree_postorder def test_example_1(): preorder = [1, 2, 4, 5, 3, 6] inorder = [4, 2, 5, 1, 6, 3] expected_postorder = [4, 5, 2, 6, 3, 1] assert tree_postorder(preorder, inorder) == expected_postorder def test_example_2(): preorder = [10, 5, 1, 7, 40, 50] inord...
[]
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared1_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, value=0, left=None, right=None):\n self.value = value\n self.left = left\n se...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00069186", "row_id": 69186, "seed_ids": "[12542]" }
0.613704
Taco_69186
I
[ "build_tree", "postorder_traversal", "tree_postorder" ]
3
[ [ "tree_postorder", "build_tree" ], [ "tree_postorder", "postorder_traversal" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
48424941f49f0927610363576f7f7c773060a2cc
a47af27779b16419d22bd9ccdf57b1dbc2fa6ba0
v1.0
instruct
Taco
Taco_69200_I
You are given a grid of cells, where each cell contains an integer. Your task is to find the maximum sum of integers you can collect starting from the top-left cell and moving to the bottom-right cell, given that you can only move either right or down at any step. Write a function that computes the maximum sum for eac...
def max_path_sum(n, m, grid): # Initialize a dp array dp = [[0] * m for _ in range(n)] # Fill the dp array dp[0][0] = grid[0][0] for i in range(1, n): dp[i][0] = dp[i-1][0] + grid[i][0] for j in range(1, m): dp[0][j] = dp[0][j-1] + grid[0][j] for i in range(1, n): ...
import pytest from solution import max_path_sum, solve, parse_input, format_output def test_max_path_sum_simple(): grid = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] assert max_path_sum(3, 3, grid) == 29 def test_max_path_sum_with_negatives(): grid = [ [-1, -2], [-3, 4]...
[ { "docstring": null, "function_declaration": "def max_path_sum(n, m, grid):", "function_name": "max_path_sum", "parameter_list": "(n, m, grid)" }, { "docstring": null, "function_declaration": "def solve(test_cases):", "function_name": "solve", "parameter_list": "(test_cases)" }...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_path_sum(n, m, grid):\n # Initialize a dp array\n dp = [[0] * m for _ in range(n)]\n \n # Fill the dp array\n dp[0][0] = grid[0][0]\n for...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00069200", "row_id": 69200, "seed_ids": "[7519]" }
0.686972
Taco_69200
I
[ "max_path_sum", "solve", "parse_input", "format_output" ]
4
[ [ "solve", "max_path_sum" ] ]
1
[ "parse_input", "format_output" ]
false
[]
false
pytest
true
[]
true
0623f741d8ded2d40bae1e31f87b6fa5a3c0e888
6e1ae5a09bc8c4c4dcec6f2ae4e929bb17079421
v1.0
instruct
Taco
Taco_69203_I
You are given a large text document containing multiple paragraphs. Your task is to find the paragraph which contains the highest number of unique words. A word is defined as a contiguous sequence of non-space characters and is case-insensitive (i.e., "Word" and "word" should be considered the same). Words are separate...
def highest_unique_words_paragraph(paragraphs): def unique_word_count(paragraph): words = set(word.lower() for word in re.findall(r'\b\w+\b', paragraph)) return len(words) max_unique_words = 0 paragraph_index = 0 for i, paragraph in enumerate(paragraphs): count = unique...
def test_highest_unique_words_paragraph(): paragraphs1 = [ "This is the first paragraph.", "Here is the second paragraph, which is slightly longer than the first.", "The third paragraph is here." ] assert highest_unique_words_paragraph(paragraphs1) == 2 paragraphs2 = [ "...
[ { "docstring": null, "function_declaration": "def highest_unique_words_paragraph(paragraphs):", "function_name": "highest_unique_words_paragraph", "parameter_list": "(paragraphs)" }, { "docstring": null, "function_declaration": "def find_paragraph_with_highest_unique_words():", "func...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import re\n\ndef find_paragraph_with_most_unique_words(paragraphs):\n max_unique_count = 0\n result_index = 0\n \n for index, paragraph in enumerate(pa...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00069203", "row_id": 69203, "seed_ids": "[6426]" }
0.602743
Taco_69203
I
[ "highest_unique_words_paragraph", "find_paragraph_with_highest_unique_words" ]
2
[ [ "find_paragraph_with_highest_unique_words", "highest_unique_words_paragraph" ] ]
1
[]
false
[]
false
pytest
false
[]
true
87d7dacc1af7ac945198cb1b97199e98045d84c2
ae152d5911a9680b42c34356c1823a117d12858b
v1.0
instruct
Taco
Taco_69281_I
You are given a matrix of size $n \times m$ filled with integers, and you are tasked with finding the sum of elements in multiple submatrices. For each query, the submatrix is defined by its top-left corner $(r1, c1)$ and bottom-right corner $(r2, c2)$. The sum of the submatrix includes all the elements between these ...
def preprocess_matrix(matrix): """ Preprocess the matrix to create a prefix sum matrix. """ n = len(matrix) m = len(matrix[0]) prefix_sum = [[0] * (m + 1) for _ in range(n + 1)] for i in range(1, n + 1): for j in range(1, m + 1): prefix_sum[i][j] = matrix[i - 1][j - 1] \...
def test_preprocess_matrix(): matrix = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] expected_prefix_sum = [ [0, 0, 0, 0], [0, 1, 3, 6], [0, 5, 12, 21], [0, 12, 27, 45] ] assert preprocess_matrix(matrix) == expected_prefix_sum def test_submatrix_sum(): ...
[ { "docstring": "Preprocess the matrix to create a prefix sum matrix.", "function_declaration": "def preprocess_matrix(matrix):", "function_name": "preprocess_matrix", "parameter_list": "(matrix)" }, { "docstring": "Use the prefix sum matrix to calculate the sum of the submatrix.", "funct...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def preprocess_matrix(matrix):\n \"\"\"\n Preprocesses the given matrix to create a prefix sum matrix for efficient submatrix sum queries.\n \"\"\"\n n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00069281", "row_id": 69281, "seed_ids": "[25073]" }
0.619157
Taco_69281
I
[ "preprocess_matrix", "submatrix_sum", "process_queries" ]
3
[ [ "process_queries", "preprocess_matrix" ], [ "process_queries", "submatrix_sum" ] ]
2
[ "process_queries" ]
false
[]
false
pytest
false
[]
true
8fd5b2b817d386b49d4633b1a16f56a23b007e4c
9ac56ea25fef8701ebd56ecd8f907f4e737578c6
v1.0
instruct
Taco
Taco_69301_I
John is a security expert who has discovered a security vulnerability in password patterns. He observes that many users often create passwords that are anagrams of one another, just with different casing per character. In order to analyze the vulnerability, John wants to check how many passwords have this problem. You...
from collections import defaultdict def count_anagram_pairs(passwords): """ Returns the number of pairs of passwords that are case-insensitive anagrams of each other. """ counter = defaultdict(int) for password in passwords: sorted_password = ''.join(sorted(password.lower())) counte...
from solution import calculate_anagram_pairs def test_case_1(): n = 4 passwords = ["abc", "Bac", "adb", "BAD"] assert calculate_anagram_pairs(n, passwords) == 2 def test_case_2(): n = 3 passwords = ["a", "A", "a"] assert calculate_anagram_pairs(n, passwords) == 3 def test_case_3(): n = 3 ...
[ { "docstring": "Returns the number of pairs of passwords that are case-insensitive anagrams of each other.", "function_declaration": "def count_anagram_pairs(passwords):", "function_name": "count_anagram_pairs", "parameter_list": "(passwords)" }, { "docstring": null, "function_declaratio...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import defaultdict\n\ndef count_anagram_pairs(passwords):\n \"\"\"\n Counts the number of pairs of passwords that are case-insensitive anagr...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00069301", "row_id": 69301, "seed_ids": "[25408]" }
0.620042
Taco_69301
I
[ "count_anagram_pairs", "calculate_anagram_pairs" ]
2
[ [ "calculate_anagram_pairs", "count_anagram_pairs" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e474250df9204e4b7458ba6bef0ab9e761f510d4
101422d1a8246db582e7541b796eafd992e06234
v1.0
instruct
Taco
Taco_69325_I
An old and mystical library has a chief librarian who is known for his skill in an ancient way of sorting books. These books have information written on each page about knowledge long forgotten. The chief librarian wants to sort these books based on the total information they contain. The total information in a book is...
def sort_books(test_cases): results = [] for n, pages, information in test_cases: total_info = [] for i in range(n): total_info.append((i, sum(information[i]))) sorted_info = sorted(total_info, key=lambda x: x[1]) results.append([idx for idx, _ in sorted_info]) re...
import pytest from solution import ancient_sorting_books def test_case_1(): input_text = "2\n3\n3 2 4\n1 2 3\n4 5\n3 3 3 3\n2\n5 2\n6 6 6 6 6\n1 1" expected_output = "0 1 2\n1 0" assert ancient_sorting_books(input_text) == expected_output def test_case_2(): input_text = "1\n2\n2 3\n2 3\n1 1 5" exp...
[ { "docstring": null, "function_declaration": "def sort_books(test_cases):", "function_name": "sort_books", "parameter_list": "(test_cases)" }, { "docstring": null, "function_declaration": "def parse_input(input_text):", "function_name": "parse_input", "parameter_list": "(input_te...
[ 0, 0, 0, 0, 0, 0, 1, 1, 0, 1 ]
3
hard
0.3
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sort_books_by_information(test_cases):\n results = []\n for t in range(test_cases):\n n = int(input().strip())\n pages = list(map(int, inpu...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00069325", "row_id": 69325, "seed_ids": "[24274]" }
0.751095
Taco_69325
I
[ "sort_books", "parse_input", "format_output", "ancient_sorting_books" ]
4
[ [ "ancient_sorting_books", "format_output" ], [ "ancient_sorting_books", "parse_input" ], [ "ancient_sorting_books", "sort_books" ] ]
3
[ "parse_input", "format_output" ]
false
[]
false
pytest
true
[]
true
01f06edf0034543eb3bf6f0173c3cf615ccf4721
b4811bb6765073d51fd9cc992075b38956d5c721
v1.0
instruct
Taco
Taco_69463_I
Alex is part of a cybersecurity team and needs to encode and decode messages efficiently. One technique involves encoding a message by reversing the string and then shifting each character by a certain number of positions in the ASCII table. To decode the message, one needs to reverse the encoding process. Your task i...
def encode(message, shift): """ Encodes the message by reversing the string and shifting each character in the ASCII table by shift positions. Parameters: message (str): The original message to encode. shift (int): The number of positions to shift each character in the ASCII table. Ret...
from solution import process_message def test_simple_message(): assert process_message(3, "hello") == "hello" def test_negative_shift(): assert process_message(-3, "world") == "world" def test_empty_string(): assert process_message(5, "") == "" def test_single_character(): assert process_message(1, ...
[ { "docstring": "Encodes the message by reversing the string and shifting each character in the ASCII table by shift positions.\n\nParameters:\nmessage (str): The original message to encode.\nshift (int): The number of positions to shift each character in the ASCII table.\n\nReturns:\nstr: The encoded message.",...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def encode(message, shift):\n # Reverse the string\n reversed_message = message[::-1]\n # Shift characters by `shift` positions\n encoded_message = ''....
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00069463", "row_id": 69463, "seed_ids": "[25294]" }
0.653373
Taco_69463
I
[ "encode", "decode", "process_message" ]
3
[ [ "process_message", "decode" ], [ "process_message", "encode" ] ]
2
[]
false
[]
false
pytest
true
[]
true
78cde25d663dd1106903e0da304ed603465369f9
9df4e6c7eb4f6035f90c94f92885ee73b960d3f0
v1.0
instruct
Taco
Taco_69476_I
You are given an array of integers, `arr`, of size `n` and a positive integer `k`. Define the "k-th distinct prime factor count" of an integer as the number of distinct prime factors of the k-th largest integer in the subarrays of length `k` of the given array. Your task is to determine the maximum "k-th distinct prime...
from collections import defaultdict import math # Function to compute prime factors of a number def prime_factors(n): factors = set() while n % 2 == 0: factors.add(2) n = n // 2 for i in range(3, int(math.sqrt(n)) + 1, 2): while n % i == 0: factors.add(i) n =...
from solution import max_k_th_prime_factor_count def test_case_0(): assert max_k_th_prime_factor_count(5, 3, [10, 15, 21, 24, 30]) == 3 def test_case_1(): assert max_k_th_prime_factor_count(8, 4, [7, 11, 13, 2, 3, 5, 14, 20]) == 2 def test_single_element_subarray(): assert max_k_th_prime_factor_count...
[ { "docstring": null, "function_declaration": "def prime_factors(n):", "function_name": "prime_factors", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def max_k_th_prime_factor_count(n, k, arr):", "function_name": "max_k_th_prime_factor_count", "paramete...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from math import isqrt\n\ndef distinct_prime_factors_count(num):\n ''' Function to count distinct prime factors '''\n if num == 1:\n return 0\n cou...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00069476", "row_id": 69476, "seed_ids": "[24853]" }
0.706822
Taco_69476
I
[ "prime_factors", "max_k_th_prime_factor_count" ]
2
[ [ "max_k_th_prime_factor_count", "prime_factors" ] ]
1
[]
false
[]
false
pytest
true
[]
true
291ab1b12595a4ab9ce8db13cabcd36b7340d5a4
4c0d103853b7509d668e7e8d7a120fc08ff4d859
v1.0
instruct
Taco
Taco_69515_I
Write a program that takes a list of integers and returns a new list containing only the prime numbers from the original list. Constraints - The length of the input list < 10000 - Each integer n in the list is such that 1 <= n <= 10^6 Input A space-separated list of integers given in a single line. Output Print t...
def is_prime(n): """ Helper function to check if a number is prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def filter_primes...
from solution import is_prime, filter_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(19) == True assert is_prime(20) == False assert is_prime(1) == False assert is_prime(0) == Fals...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Given a list of integers, return a new list containing only the prime numbers.", "function_declaration": "d...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Checks if a number n is prime.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\n if n %...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00069515", "row_id": 69515, "seed_ids": "[16514]" }
0.651783
Taco_69515
I
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
58a537e87d8b2ba5ce68c34b852781ce0183492a
4865e406669e3a36e07a39b2baa2acd9893a900c
v1.0
instruct
Taco
Taco_69520_I
You are given a list of N positive integers. You need to find the greatest common divisor (GCD) of all the integers in the list. Note that N will be between 1 and 100000. Input The single line contains N space-separated positive integers. Each of these integers will be at most 109. Output Print a single integer whi...
def gcd(a, b): """ Returns the greatest common divisor of a and b using Euclid's algorithm. """ while b: a, b = b, a % b return a def find_gcd_of_list(numbers): """ Returns the greatest common divisor of all the integers in the list. """ from functools import reduce retu...
from solution import gcd, find_gcd_of_list def test_gcd(): assert gcd(54, 24) == 6 assert gcd(48, 18) == 6 assert gcd(101, 103) == 1 assert gcd(56, 98) == 14 assert gcd(27, 0) == 27 def test_find_gcd_of_list(): assert find_gcd_of_list([6, 9, 15]) == 3 assert find_gcd_of_list([100, 75, 25, ...
[ { "docstring": "Returns the greatest common divisor of a and b using Euclid's algorithm.", "function_declaration": "def gcd(a, b):", "function_name": "gcd", "parameter_list": "(a, b)" }, { "docstring": "Returns the greatest common divisor of all the integers in the list.", "function_decl...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def gcd(a, b):\n \"\"\"\n Returns the greatest common divisor of a and b using Euclid's algorithm.\n \"\"\"\n while b:\n a, b = b, a % b\n re...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00069520", "row_id": 69520, "seed_ids": "[18192]" }
0.649628
Taco_69520
I
[ "gcd", "find_gcd_of_list" ]
2
[ [ "find_gcd_of_list", "gcd" ] ]
1
[]
false
[]
false
pytest
true
[]
true
170423f8d4d8c88ffa113bc55ad2b6160ca40720
62091e32570b7fe9826ab94c2e2c60d8922140f1
v1.0
instruct
Taco
Taco_69557_I
A new startup called "Binary Matrix Inc." is working on analyzing binary matrices. They want to identify specific patterns within these matrices. You have been enlisted to help them with one such problem. The problem is to determine the largest square sub-matrix within a given binary matrix that contains only 1's. For...
def largest_square(matrix): """ Returns the size of the largest square sub-matrix containing only 1's in the given binary matrix. """ if not matrix: return 0 M = len(matrix) N = len(matrix[0]) # Create a DP table to store the size of the largest square submatrix ending at (i, j...
def test_largest_square_basic(): matrix = [ [1, 0, 1, 0, 0], [1, 0, 1, 1, 1], [1, 1, 1, 1, 1], [1, 0, 0, 1, 0] ] assert largest_square(matrix) == 2 def test_largest_square_all_ones(): matrix = [ [1, 1, 1], [1, 1, 1], [1, 1, 0] ] assert lar...
[ { "docstring": "Returns the size of the largest square sub-matrix containing only 1's in the given binary matrix.", "function_declaration": "def largest_square(matrix):", "function_name": "largest_square", "parameter_list": "(matrix)" }, { "docstring": null, "function_declaration": "def ...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def largest_square(matrix):\n \"\"\"\n Returns the size of the largest square sub-matrix containing only 1's in the given binary matrix.\n \"\"\"\n if ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00069557", "row_id": 69557, "seed_ids": "[11097]" }
0.598871
Taco_69557
I
[ "largest_square", "analyze_matrices", "parse_input", "main" ]
4
[ [ "analyze_matrices", "largest_square" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
35378a20a397658bafd6f4e2bf6bac18b9e98c06
0f6c8963176300acd9bd50e6652f4efafb3dcbd4
v1.0
instruct
Taco
Taco_69629_I
You are given a weighted undirected graph with n nodes and m edges. Each node in the graph represents a point of interest, and each edge represents a bidirectional road connecting two points with a specific cost. Your task is to design a function that will compute the minimum total cost to connect all nodes in the gr...
def find(parent, i): if parent[i] == i: return i else: return find(parent, parent[i]) def union(parent, rank, x, y): xroot = find(parent, x) yroot = find(parent, y) if rank[xroot] < rank[yroot]: parent[xroot] = yroot elif rank[xroot] > rank[yroot]: parent[yroot] ...
def test_example_case(): n = 4 m = 5 edges = [ (1, 2, 1), (1, 3, 4), (2, 3, 2), (2, 4, 6), (3, 4, 3) ] result = minimum_spanning_tree_cost(n, m, edges) assert result == 6 def test_disconnected_graph(): n = 3 m = 3 edges = [ (1, 2, 1), ...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef find_minimum_spanning_tree(n, edges):\n \"\"\"\n Computes the minimum total cost to connect all nodes in the graph using the existing roa...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00069629", "row_id": 69629, "seed_ids": "[19962]" }
0.786293
Taco_69629
I
[ "find", "union", "kruskal_mst", "minimum_spanning_tree_cost" ]
4
[ [ "kruskal_mst", "find" ], [ "kruskal_mst", "union" ], [ "minimum_spanning_tree_cost", "kruskal_mst" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
false
[]
true
a87e3eb6e8bac277edee49d9efd2e39c58f23c99
5a33b5e0de9cab27979f8caa429435a219c37147
v1.0
instruct
Taco
Taco_69632_I
Design a traffic monitoring system for a highway. The system should track the number of vehicles passing through a certain point on the highway at different times during the day. Given the recorded time (hours, minutes) and a count of vehicles passing through at that time, determine the peak hour period with the highes...
def parse_time_string(time_str): hours, minutes = map(int, time_str.split(':')) return hours, minutes def time_in_minutes(hours, minutes): return hours * 60 + minutes def to_time_string(minutes): hours = minutes // 60 minutes = minutes % 60 return f"{hours:02}:{minutes:02}" def find_peak_leas...
def test_parse_time_string(): assert parse_time_string("08:00") == (8, 0) assert parse_time_string("23:59") == (23, 59) assert parse_time_string("00:00") == (0, 0) def test_time_in_minutes(): assert time_in_minutes(8, 0) == 480 assert time_in_minutes(23, 59) == 1439 assert time_in_minutes(0, 0)...
[ { "docstring": null, "function_declaration": "def parse_time_string(time_str):", "function_name": "parse_time_string", "parameter_list": "(time_str)" }, { "docstring": null, "function_declaration": "def time_in_minutes(hours, minutes):", "function_name": "time_in_minutes", "param...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def get_vehicle_data():\n data = []\n while True:\n m = int(input().strip())\n if m == 0:\n break\n records = []\n for...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00069632", "row_id": 69632, "seed_ids": "[12756]" }
0.532959
Taco_69632
I
[ "parse_time_string", "time_in_minutes", "to_time_string", "find_peak_least_periods", "process_inputs" ]
5
[ [ "find_peak_least_periods", "parse_time_string" ], [ "find_peak_least_periods", "to_time_string" ], [ "process_inputs", "find_peak_least_periods" ] ]
3
[ "process_inputs" ]
false
[]
false
pytest
false
[]
true
4a645e130e25f7cbd0c4070439100c89539e5e24
83e3371f8d1e6b75b6e8dba3bda54ec699cd0b01
v1.0
instruct
Taco
Taco_69666_I
Erin loves studying graphs, and she has recently learned about bipartite graphs. A bipartite graph is one where the set of vertices can be divided into two disjoint sets such that no two vertices within the same set are adjacent. Erin has a graph with `n` vertices and `m` edges. She wants to know if the given graph is ...
from collections import deque, defaultdict def is_bipartite(n, edges): graph = defaultdict(list) for u, v in edges: graph[u].append(v) graph[v].append(u) color = {} def bfs(start): queue = deque([start]) color[start] = 0 while queue: node = ...
from solution import solve def test_bipartite_graph(): n = 4 m = 4 edges = ["1 2", "1 3", "2 4", "3 4"] assert solve(n, m, edges) == "2\n1 4\n2\n2 3" def test_not_bipartite_graph(): n = 3 m = 3 edges = ["1 2", "1 3", "2 3"] assert solve(n, m, edges) == "-1" def test_single_edge(): ...
[ { "docstring": null, "function_declaration": "def is_bipartite(n, edges):", "function_name": "is_bipartite", "parameter_list": "(n, edges)" }, { "docstring": null, "function_declaration": "def solve(n, m, edge_list):", "function_name": "solve", "parameter_list": "(n, m, edge_list...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque, defaultdict\n\ndef is_bipartite(n, edges):\n graph = defaultdict(list)\n for u, v in edges:\n graph[u].append(v)\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00069666", "row_id": 69666, "seed_ids": "[5843]" }
0.613399
Taco_69666
I
[ "is_bipartite", "solve" ]
2
[ [ "solve", "is_bipartite" ] ]
1
[]
false
[]
false
pytest
true
[]
true
abdf65db9f19424a6c4239cd64d4be95d8e692ea
96a20e0407bc21ace5ce38902fce13c4a537cc1f
v1.0
instruct
Taco
Taco_69674_I
You are given an array A of N integers and an integer K. Your task is to determine if there are three distinct elements in the array such that their sum is divisible by K. ------ Input Format ------ - The first line of input contains a single integer T denoting the number of test cases. The description of T test cas...
def is_sum_divisible_by_k(arr, k): """ Checks if there are any three distinct elements in the array whose sum is divisible by k. """ n = len(arr) for i in range(n - 2): for j in range(i + 1, n - 1): for l in range(j + 1, n): if (arr[i] + arr[j] + arr[l]) % k == 0:...
def test_is_sum_divisible_by_k_yes(): assert is_sum_divisible_by_k([1, 2, 3, 4, 5], 3) == "YES" def test_is_sum_divisible_by_k_no(): assert is_sum_divisible_by_k([10, 15, 7, 8], 7) == "NO" def test_is_sum_divisible_by_k_borderline(): assert is_sum_divisible_by_k([3, 6, 9, 12, 15, 18], 11) == "YES" def te...
[ { "docstring": "Checks if there are any three distinct elements in the array whose sum is divisible by k.", "function_declaration": "def is_sum_divisible_by_k(arr, k):", "function_name": "is_sum_divisible_by_k", "parameter_list": "(arr, k)" }, { "docstring": "Handles multiple test cases for ...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_sum_divisible_by_k(arr, N, K):\n \"\"\"\n This function determines if there are three distinct elements in the array such that their sum is divisible ...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00069674", "row_id": 69674, "seed_ids": "[15562]" }
0.729124
Taco_69674
I
[ "is_sum_divisible_by_k", "process_multiple_test_cases", "transform_input", "main" ]
4
[ [ "process_multiple_test_cases", "is_sum_divisible_by_k" ] ]
1
[ "process_multiple_test_cases" ]
false
[]
false
pytest
false
[]
true
3f618e40b1bb19ae747166cce65c6c6ca8ee1fb8
71b438b656d7dd8c5ca7cda1f86f39489f531391
v1.0
instruct
Taco
Taco_69690_I
You are given a grid of size n x n (1 ≤ n ≤ 50) filled with integers. Your task is to perform a sequence of operations to transform the grid so that every row and every column contains the integers 1 through n exactly once (i.e., the grid should become a Latin square). The operations you can perform are swaps of entire...
def is_latin_square(grid, n): for i in range(n): if len(set(grid[i])) != n or len(set(row[i] for row in grid)) != n: return False return True def transpose(grid): return [list(row) for row in zip(*grid)] def process_grid(n, grid): from collections import defaultdict row_swaps =...
from solution import process_grid def test_process_grid_case_1(): n = 4 grid = [ [1, 2, 3, 4], [4, 3, 2, 1], [1, 3, 2, 4], [4, 1, 2, 3] ] process_grid(n, grid) def test_process_grid_case_2(): n = 3 grid = [ [1, 2, 3], [3, 2, 1], [2, 3, 1]...
[ { "docstring": null, "function_declaration": "def is_latin_square(grid, n):", "function_name": "is_latin_square", "parameter_list": "(grid, n)" }, { "docstring": null, "function_declaration": "def transpose(grid):", "function_name": "transpose", "parameter_list": "(grid)" }, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_operations_to_latin_square(grid):\n n = len(grid)\n \n # Output list for operations\n operations = []\n \n # Check if a row needs to be ...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00069690", "row_id": 69690, "seed_ids": "[16026]" }
0.743853
Taco_69690
I
[ "is_latin_square", "transpose", "process_grid" ]
3
[ [ "process_grid", "transpose" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3aa79773cf3c0a6cfac2c38e45e9e43ee4451a8c
d66d84b67d43955cae2f36fe57c3a863bdaf4c55
v1.0
instruct
Taco
Taco_69782_I
You are given a list of words and your task is to find the longest word in the list that can be formed by deleting some characters of a given string s without reordering the remaining characters. If there are multiple possible results, return the longest word in the list. If there are still multiple results, return the...
def is_subsequence(s, word): """ Helper function to check if word can be formed by deleting some characters from s. """ it = iter(s) return all(char in it for char in word) def longest_word_in_list(s, word_list): """ Returns the longest word that can be formed by deleting some characters ...
from solution import longest_word_in_list def test_case_1(): s = "abpcplea" word_list = ["apple", "monkey", "plea"] assert longest_word_in_list(s, word_list) == "apple" def test_case_2(): s = "abpcplea" word_list = ["a", "b", "c", "d"] assert longest_word_in_list(s, word_list) == "a" def test...
[ { "docstring": "Helper function to check if word can be formed by deleting some characters from s.", "function_declaration": "def is_subsequence(s, word):", "function_name": "is_subsequence", "parameter_list": "(s, word)" }, { "docstring": "Returns the longest word that can be formed by dele...
[ 0, 0, 0, 1, 1 ]
2
medium
0.4
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_subsequence(s, word):\n it = iter(s)\n return all(char in it for char in word)\n\ndef find_longest_word(s, words):\n words.sort(key=lambda word: (-...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00069782", "row_id": 69782, "seed_ids": "[19804]" }
0.703687
Taco_69782
I
[ "is_subsequence", "longest_word_in_list" ]
2
[ [ "longest_word_in_list", "is_subsequence" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0144b8867c7db4c345a72e75f73743ba12282d4f
5e9759204aa613f48cb7fe420e12770db3f68116
v1.0
instruct
Taco
Taco_69859_I
John is trying to create a special binary string based on some rules. Initially, he starts with an empty string. Each day, he appends one binary digit ('0' or '1') to the string based on the day number. Here's how he decides which digit to append: - If the current day `i` is a prime number, he appends the digit '1'. - ...
def sieve_of_eratosthenes(limit): prime = [True] * (limit + 1) p = 2 while (p * p <= limit): if (prime[p] == True): for i in range(p * p, limit + 1, p): prime[i] = False p += 1 prime[0], prime[1] = False, False return prime def count_ones_in_range(L, R, ...
from solution import sieve_of_eratosthenes, count_ones_in_range, process_queries def test_sieve_of_eratosthenes(): prime = sieve_of_eratosthenes(10) assert prime == [False, False, True, True, False, True, False, True, False, False, False] def test_count_ones_in_range(): prime = sieve_of_eratosthenes(20) ...
[ { "docstring": null, "function_declaration": "def sieve_of_eratosthenes(limit):", "function_name": "sieve_of_eratosthenes", "parameter_list": "(limit)" }, { "docstring": null, "function_declaration": "def count_ones_in_range(L, R, prime):", "function_name": "count_ones_in_range", ...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sieve_of_eratosthenes(limit):\n prime = [True] * (limit + 1)\n p = 2\n while (p * p <= limit):\n if (prime[p] == True):\n for i in r...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00069859", "row_id": 69859, "seed_ids": "[13000]" }
0.645802
Taco_69859
I
[ "sieve_of_eratosthenes", "count_ones_in_range", "process_queries" ]
3
[ [ "process_queries", "count_ones_in_range" ], [ "process_queries", "sieve_of_eratosthenes" ] ]
2
[ "process_queries" ]
false
[]
false
pytest
true
[]
true
cffaeb08850e86db15b45643d8294681d89b23c2
2aba58b719c797b6085a0179045b86e90294befe
v1.0
instruct
Taco
Taco_69992_I
Your task is to design a system that sorts a list of strings based on a 'weight' mapping provided. ### Problem Statement You are given a 'weight' mapping for each letter from 'a' to 'z'. Use this mapping to calculate the weight of each string (by summing the weights of its characters), and then sort the strings prima...
def calculate_weight(string, weights): """ Calculate and return the total weight of the string based on the given weights. """ return sum(weights[ord(char) - ord('a')] for char in string) def sort_strings_by_weight(weights, strings): """ Sort the given list of strings based on their calculated ...
def test_calculate_weight(): weights = list(range(1, 27)) assert calculate_weight("abb", weights) == 5 assert calculate_weight("abc", weights) == 6 assert calculate_weight("abcd", weights) == 10 assert calculate_weight("aaa", weights) == 3 assert calculate_weight("bcc", weights) == 8 def test_s...
[ { "docstring": "Calculate and return the total weight of the string based on the given weights.", "function_declaration": "def calculate_weight(string, weights):", "function_name": "calculate_weight", "parameter_list": "(string, weights)" }, { "docstring": "Sort the given list of strings bas...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def calculate_weight(string, weights):\n \"\"\"\n Calculate and return the total weight of the string based on the given weights.\n \"\"\"\n return sum...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00069992", "row_id": 69992, "seed_ids": "[9949]" }
0.643023
Taco_69992
I
[ "calculate_weight", "sort_strings_by_weight", "main" ]
3
[ [ "sort_strings_by_weight", "calculate_weight" ] ]
1
[]
false
[]
false
pytest
false
[]
true
ca7412cc11cd7aab71ae07cd787f333843250a8c
a5751d060e7194a48958b3273f6e51e972fb0beb
v1.0
instruct
Taco
Taco_70014_I
In a Sudoku game, the objective is to fill a 9x9 grid with digits so that each column, each row, and each of the nine 3x3 sub-grids that compose the grid (also called "boxes") contains all of the digits from 1 to 9. Starting with a partially completed grid, the goal is to complete it following the rules. **Problem Sta...
def solve_sudoku(board): """ Solves the given Sudoku board in place. :param board: list of list of str :return: None """ def is_valid(board, r, c, num): # Check the row for i in range(9): if board[r][i] == num: return False # Check the column ...
import pytest from solution import find_sudoku_solution def test_complete_sudoku(): input_grid = [ "5 3 . . 7 . . . .", "6 . . 1 9 5 . . .", ". 9 8 . . . . 6 .", "8 . . . 6 . . . 3", "4 . . 8 . 3 . . 1", "7 . . . 2 . . . 6", ". 6 . . . . 2 8 .", ". . ...
[ { "docstring": "Solves the given Sudoku board in place.\n:param board: list of list of str\n:return: None", "function_declaration": "def solve_sudoku(board):", "function_name": "solve_sudoku", "parameter_list": "(board)" }, { "docstring": null, "function_declaration": "def parse_input(gr...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_valid(board, row, col, num):\n for i in range(9):\n if board[row][i] == num or board[i][col] == num:\n return False\n \n box_row_...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00070014", "row_id": 70014, "seed_ids": "[793]" }
0.65985
Taco_70014
I
[ "solve_sudoku", "parse_input", "format_output", "find_sudoku_solution" ]
4
[ [ "find_sudoku_solution", "format_output" ], [ "find_sudoku_solution", "parse_input" ], [ "find_sudoku_solution", "solve_sudoku" ] ]
3
[ "parse_input", "format_output" ]
false
[]
false
pytest
true
[]
true
c1b014e4245ba26533e213808cda804f88f106e2
2135ab56b6eb81337db765124801c40d393624ee
v1.0
instruct
Taco
Taco_70022_I
You are given an n x m grid representing a field. Each cell of the grid can either be land or water. Your goal is to find all the islands in the grid and return the number of distinct islands. An island is a group of connected lands (1's) connected horizontally, vertically, or diagonally. The grid is considered to be c...
def num_islands(grid): if not grid: return 0 n, m = len(grid), len(grid[0]) visited = [[False for _ in range(m)] for _ in range(n)] def dfs(x, y): if x < 0 or y < 0 or x >= n or y >= m or grid[x][y] == '0' or visited[x][y]: return visited[x][y] = True # ...
def test_num_islands(): assert num_islands(["11110", "11010", "11000", "00001"]) == 2 assert num_islands(["111", "010", "111"]) == 1 def test_count_islands(): test_cases = [ (4, 5, ["11110", "11010", "11000", "00001"]), (3, 3, ["111", "010", "111"]) ] assert count_islands(test_cases...
[ { "docstring": null, "function_declaration": "def num_islands(grid):", "function_name": "num_islands", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def count_islands(test_cases):", "function_name": "count_islands", "parameter_list": "(test_cases)" ...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def num_islands(grid):\n if not grid:\n return 0\n\n n, m = len(grid), len(grid[0])\n visited = [[False for _ in range(m)] for _ in range(n)]\n\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00070022", "row_id": 70022, "seed_ids": "[3149]" }
0.611144
Taco_70022
I
[ "num_islands", "count_islands", "parse_input", "main" ]
4
[ [ "count_islands", "num_islands" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
132c0de05c53382b8f77a2d5a290869e44d96c05
3abec815f52c6e9906cee9284b9ff6967eb88c01
v1.0
instruct
Taco
Taco_70076_I
You recently discovered an island where people use a unique numbering system called Fibonacci System, based on the Fibonacci sequence. Their sequences start with numbers 1 and 2 instead of 0 and 1, so the sequence looks like 1, 2, 3, 5, 8, 13, 21, etc. The i-th number in this sequence is Fi. For any given integer numb...
def fibonacci_numbers_up_to(n): fibs = [1, 2] while fibs[-1] < n: fibs.append(fibs[-1] + fibs[-2]) return fibs def min_fib_numbers_sum(x): fibs = fibonacci_numbers_up_to(x) count = 0 i = len(fibs) - 1 while x > 0: if fibs[i] <= x: x -= fibs[i] count +...
from solution import solve_min_fib_numbers_sum, fibonacci_numbers_up_to, min_fib_numbers_sum def test_fibonacci_numbers_up_to(): assert fibonacci_numbers_up_to(10) == [1, 2, 3, 5, 8, 13], "Test case failed!" assert fibonacci_numbers_up_to(21) == [1, 2, 3, 5, 8, 13, 21], "Test case failed!" def test_min_fi...
[ { "docstring": null, "function_declaration": "def fibonacci_numbers_up_to(n):", "function_name": "fibonacci_numbers_up_to", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def min_fib_numbers_sum(x):", "function_name": "min_fib_numbers_sum", "parameter_li...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def generate_fibonacci_up_to(max_num):\n fibs = [1, 2]\n while fibs[-1] + fibs[-2] <= max_num:\n fibs.append(fibs[-1] + fibs[-2])\n return fibs\n\n...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00070076", "row_id": 70076, "seed_ids": "[3990]" }
0.627821
Taco_70076
I
[ "fibonacci_numbers_up_to", "min_fib_numbers_sum", "solve_min_fib_numbers_sum" ]
3
[ [ "min_fib_numbers_sum", "fibonacci_numbers_up_to" ], [ "solve_min_fib_numbers_sum", "min_fib_numbers_sum" ] ]
2
[]
false
[]
false
pytest
true
[]
true
caac31707f756eb88f634183b1a7026c39839479
954ddef36e8ab4683813d61537d83f626b145dbe
v1.0
instruct
Taco
Taco_70080_I
Ravi, a game developer, is designing a new 2D grid-based game. In this game, the player can move in four possible directions: up, down, left, and right. The player starts from a given starting position (startX, startY) and should reach a final position (endX, endY). However, some of the cells in the grid contain obstac...
def bfs(grid, startX, startY, endX, endY, N, M): from collections import deque # Define possible movements : up, down, left, right directions = [(-1, 0), (1, 0), (0, -1), (0, 1)] # Initialize the queue for BFS queue = deque([(startX, startY)]) grid[startX][startY] = True # Mark initial...
from solution import paths_exist def test_paths_exist(): T = 2 test_cases = [ (5, 5, (0, 0), (4, 4), 3, [(0, 1), (1, 0), (1, 2)]), (5, 5, (0, 0), (4, 4), 0, []) ] assert paths_exist(T, test_cases) == ['NO', 'YES'] def test_no_obstacles(): T = 1 test_cases = [ (3, 3, (0,...
[ { "docstring": null, "function_declaration": "def bfs(grid, startX, startY, endX, endY, N, M):", "function_name": "bfs", "parameter_list": "(grid, startX, startY, endX, endY, N, M)" }, { "docstring": null, "function_declaration": "def is_path_possible(N, M, startX, startY, endX, endY, ob...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def bfs(grid, startX, startY, endX, endY, N, M):\n from collections import deque\n \n # Define possible movements : up, down, left, right\n directions ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00070080", "row_id": 70080, "seed_ids": "[19866]" }
0.787334
Taco_70080
I
[ "bfs", "is_path_possible", "paths_exist" ]
3
[ [ "is_path_possible", "bfs" ], [ "paths_exist", "is_path_possible" ] ]
2
[]
false
[]
false
pytest
true
[]
true
e60bad318342a8fe47cfc2d335f1e22ea612dabe
0bc185b86813770859e4bdeb7acb6b5abe75e9a5
v1.0
instruct
Taco
Taco_70082_I
Rita is fascinated by palindromic numbers and wants to find the smallest palindromic number larger than a given integer x. A palindromic number is a number that reads the same forward and backward, such as 121 or 1331. Your task is to help Rita find this smallest palindromic number. Input The input consists of a sin...
def is_palindrome(n): """ Check if the number is a palindrome. """ return str(n) == str(n)[::-1] def next_palindrome(x): """ Find the smallest palindromic number greater than x. """ num = x + 1 while not is_palindrome(num): num += 1 return num
from solution import is_palindrome, next_palindrome def test_is_palindrome(): assert is_palindrome(121) == True assert is_palindrome(123) == False assert is_palindrome(1331) == True assert is_palindrome(10) == False def test_next_palindrome(): assert next_palindrome(123) == 131 assert next_pal...
[ { "docstring": "Check if the number is a palindrome.", "function_declaration": "def is_palindrome(n):", "function_name": "is_palindrome", "parameter_list": "(n)" }, { "docstring": "Find the smallest palindromic number greater than x.", "function_declaration": "def next_palindrome(x):", ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def next_palindrome(x):\n \"\"\"\n Returns the smallest palindromic number greater than x.\n \"\"\"\n # Function to check if a number is palindromic\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00070082", "row_id": 70082, "seed_ids": "[21100]" }
0.790001
Taco_70082
I
[ "is_palindrome", "next_palindrome" ]
2
[ [ "next_palindrome", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7f4c10fed40eedab30ab7b4a4b3168dfe6a256a8
0cc62e6d029e89b63d6e0c3ff5154c3388521166
v1.0
instruct
Taco
Taco_70084_I
Tom loves solving programming challenges. Given an array of integers, he wants to find the length of the longest contiguous subarray such that its elements are in an increasing order. Input The first line contains an integer T denoting the number of test cases. For each test case, the first line contains an integer N,...
def length_of_longest_increasing_subarray(arr): """ Returns the length of the longest contiguous increasing subarray. """ n = len(arr) if n == 0: return 0 max_length = 1 current_length = 1 for i in range(1, n): if arr[i] > arr[i-1]: current_length +=...
from solution import parse_input, solve, length_of_longest_increasing_subarray def test_length_of_longest_increasing_subarray(): assert length_of_longest_increasing_subarray([1, 3, 2, 3, 4, 5]) == 4 assert length_of_longest_increasing_subarray([15, 12, 20, 22]) == 3 assert length_of_longest_increasing_suba...
[ { "docstring": "Returns the length of the longest contiguous increasing subarray.", "function_declaration": "def length_of_longest_increasing_subarray(arr):", "function_name": "length_of_longest_increasing_subarray", "parameter_list": "(arr)" }, { "docstring": null, "function_declaration...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def length_of_longest_increasing_subarray(arr):\n \"\"\"\n Given an array of integers, find the length of the longest contiguous subarray\n such that its ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00070084", "row_id": 70084, "seed_ids": "[13404]" }
0.780099
Taco_70084
I
[ "length_of_longest_increasing_subarray", "solve", "parse_input" ]
3
[ [ "solve", "length_of_longest_increasing_subarray" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
aff72e50b392f044148d87b5a6e304888bad9d63
0d30e8422ac24c1ea787e15fdec97760f55c0042
v1.0
instruct
Taco
Taco_70105_I
In the kingdom of Valoria, there are n villages connected by roads in a way that forms a tree structure. Each village is numbered from 1 to n and each of the n-1 roads connects two villages bi-directionally. The villagers want to build a festival ground in one of the villages. They desire to maximize the minimum distan...
# We will use a combination of Depth First Search (DFS) and Breadth First Search (BFS) to solve this problem. # The idea is to first find the farthest node from an arbitrary starting node using BFS, then find the farthest node from there. # The middle of the path between these two nodes will be our answer. # This metho...
def test_find_festival_ground(): test_cases = [ (5, [(1, 2), (2, 3), (3, 4), (4, 5)]), (4, [(1, 2), (1, 3), (1, 4)]) ] T = len(test_cases) result = solve(T, test_cases) assert result == [3, 1] def test_single_village(): test_cases = [ (1, []), ] T = len(test_case...
[ { "docstring": null, "function_declaration": "def bfs_farthest_node(start, n, adj):", "function_name": "bfs_farthest_node", "parameter_list": "(start, n, adj)" }, { "docstring": null, "function_declaration": "def find_festival_ground(n, roads):", "function_name": "find_festival_groun...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "# We will use a combination of Depth First Search (DFS) and Breadth First Search (BFS) to solve this problem.\n# The idea is to first find the farthest node from a...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00070105", "row_id": 70105, "seed_ids": "[16518]" }
0.672219
Taco_70105
I
[ "bfs_farthest_node", "find_festival_ground", "solve" ]
3
[ [ "find_festival_ground", "bfs_farthest_node" ], [ "solve", "find_festival_ground" ] ]
2
[]
false
[]
false
pytest
false
[]
true
9dba42b50e05267970bff00b936e51590572f8d0
b0bd459192c1827748198a8737ba20773f40a69f
v1.0
instruct
Taco
Taco_70173_I
One day, Anjali encountered a challenge in an online coding platform. The challenge was to find out the count of prime numbers up to a given number N (inclusive). Being new to programming, she decides to solve this problem. Help her by writing a program. INPUT: The first line of the input contains a single integer T ...
def sieve_of_eratosthenes(n): """ Uses the Sieve of Eratosthenes to find all prime numbers up to a given number n. Returns a list indicating prime status for each number from 0 to n. """ is_prime = [True] * (n + 1) is_prime[0], is_prime[1] = False, False p = 2 while (p * p <= n): ...
def test_sieve_of_eratosthenes(): result = sieve_of_eratosthenes(10) expected = [False, False, True, True, False, True, False, True, False, False, False] assert result == expected def test_count_primes_up_to_n(): assert count_primes_up_to_n(10) == 4 assert count_primes_up_to_n(20) == 8 assert c...
[ { "docstring": "Uses the Sieve of Eratosthenes to find all prime numbers up to a given number n.\nReturns a list indicating prime status for each number from 0 to n.", "function_declaration": "def sieve_of_eratosthenes(n):", "function_name": "sieve_of_eratosthenes", "parameter_list": "(n)" }, { ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sieve_of_eratosthenes(n):\n \"\"\"Returns a list of booleans indicating prime status of numbers from 0 to n.\"\"\"\n primes = [True] * (n + 1)\n p = 2...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00070173", "row_id": 70173, "seed_ids": "[6603]" }
0.726012
Taco_70173
I
[ "sieve_of_eratosthenes", "count_primes_up_to_n", "prime_count_per_test_case" ]
3
[ [ "count_primes_up_to_n", "sieve_of_eratosthenes" ], [ "prime_count_per_test_case", "sieve_of_eratosthenes" ] ]
2
[ "prime_count_per_test_case" ]
false
[]
false
pytest
false
[]
true
cc7defdd847a82d7db0af260dc7c7bee012e8edc
75a9c73995068fad4d0bd43347b7b3384bd53354
v1.0
instruct
Taco
Taco_70176_I
You are given a string consisting of lowercase Latin letters. You have to form a palindromic string by removing the minimum number of characters from it. A string is called palindromic if it reads the same backward as forward. Write a program that helps achieve this task. -----Input----- The first line contains a si...
def longest_palindromic_subsequence(s): n = len(s) dp = [[0] * n for _ in range(n)] for i in range(n): dp[i][i] = 1 for cl in range(2, n + 1): for i in range(n - cl + 1): j = i + cl - 1 if s[i] == s[j] and cl == 2: dp[i][j] = 2 ...
import pytest from solution import minimal_removal_to_palindrome def test_minimal_removal_to_palindrome(): t = 3 cases = ["abc", "abac", "a"] expected = ["a", "aba", "a"] assert minimal_removal_to_palindrome(t, cases) == expected def test_single_letter_string(): t = 2 cases = ["a", "b"] ex...
[ { "docstring": null, "function_declaration": "def longest_palindromic_subsequence(s):", "function_name": "longest_palindromic_subsequence", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def form_palindromic_string(s, dp):", "function_name": "form_palindromi...
[ 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def longest_palindromic_subsequence(s):\n \"\"\"\n Returns the longest palindromic subsequence in the string s.\n \"\"\"\n n = len(s)\n dp = [[0] * ...
trial_gpt4o_7
{ "original_instruction": "", "prompt_id": "00070176", "row_id": 70176, "seed_ids": "[3257]" }
0.855184
Taco_70176
I
[ "longest_palindromic_subsequence", "form_palindromic_string", "minimal_removal_to_palindrome" ]
3
[ [ "minimal_removal_to_palindrome", "form_palindromic_string" ], [ "minimal_removal_to_palindrome", "longest_palindromic_subsequence" ] ]
2
[]
false
[]
false
pytest
true
[]
true
ab62375691853274714b46a7bb5a1a8cfdbdef18
3e01a78411c127ec18ded8f17f887c4cfbb61737