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_52066_I
Julia loves to solve puzzles, and she recently encountered a sequence puzzle involving prime numbers. She has a sequence of integers and needs to identify the prime numbers in this sequence. She then intends to rearrange these prime numbers in ascending order while keeping the non-prime numbers in their original positi...
def is_prime(num): """ Helper function to determine if a number is prime. """ if num <= 1: return False if num == 2: return True # 2 is the only even prime number if num % 2 == 0: return False for i in range(3, int(num**0.5) + 1, 2): if num % i == 0: ...
from solution import sort_primes, is_prime # is_prime function tests def test_is_prime_positive_cases(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(5) == True assert is_prime(29) == True def test_is_prime_negative_cases(): assert is_prime(0) == False assert is_prime(...
[ { "docstring": "Helper function to determine if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Rearranges prime numbers in the sequence in ascending order while keeping non-prime numbers in their or...
[ 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 Determines if a number 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": "00052066", "row_id": 52066, "seed_ids": "[24544]" }
0.643409
Taco_52066
I
[ "is_prime", "sort_primes" ]
2
[ [ "sort_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ae17a2fb46e399dd15afdbf06a281edbdfa2ea95
618de2e81d348fb763d355ee1d752c060b4de6e6
v1.0
instruct
Taco
Taco_52081_I
Alice has recently started learning about binary search trees (BSTs). A binary search tree is a data structure that keeps elements in order, such that for any node: - All elements in the left subtree of the node are less than the node. - All elements in the right subtree are greater than the node. Alice is given a seq...
class TreeNode: def __init__(self, key): self.left = None self.right = None self.val = key def insert(root, key): if root is None: return TreeNode(key) else: if root.val < key: root.right = insert(root.right, key) else: root.left = ins...
from solution import calculate_max_depth def test_example(): n = 7 sequence = [4, 2, 6, 1, 3, 5, 7] assert calculate_max_depth(n, sequence) == 3 def test_single_element(): n = 1 sequence = [1] assert calculate_max_depth(n, sequence) == 1 def test_increasing_sequence(): n = 4 sequence ...
[]
[ 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": "class TreeNode:\n def __init__(self, key):\n self.left = None\n self.right = None\n self.val = key\n\nclass BST:\n def __init__(self):\n...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00052081", "row_id": 52081, "seed_ids": "[19761]" }
0.487375
Taco_52081
I
[ "insert", "maxDepth", "calculate_max_depth" ]
3
[ [ "calculate_max_depth", "insert" ], [ "calculate_max_depth", "maxDepth" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
c17587d31a4ca0a6a00a5a7eedd21c2231c479df
75c33e719a87097b4259b0f4f8c325f41f683a43
v1.0
instruct
Taco
Taco_52119_I
Given a string `pattern` of length `M` and a text `txt` of length `N`, your task is to identify if `pattern` exists in `txt`. If it does, return the starting index of each occurrence of `pattern` in `txt`. If `pattern` does not exist in `txt`, return an empty list. Implement the function `search_pattern(pattern: str,...
from typing import List def compute_lps(pattern: str) -> List[int]: M = len(pattern) lps = [0] * M length = 0 i = 1 while i < M: if pattern[i] == pattern[length]: length += 1 lps[i] = length i += 1 else: if length != 0: ...
from solution import search_pattern def test_search_pattern_basic(): assert search_pattern("abc", "ababcabc") == [2, 5] def test_search_pattern_no_match(): assert search_pattern("xyz", "ababcabc") == [] def test_search_pattern_pattern_at_start(): assert search_pattern("abc", "abcabcabc") == [0, 3, 6] de...
[ { "docstring": null, "function_declaration": "def compute_lps(pattern):", "function_name": "compute_lps", "parameter_list": "(pattern)" }, { "docstring": null, "function_declaration": "def search_pattern(pattern, txt):", "function_name": "search_pattern", "parameter_list": "(patt...
[ 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 typing import List\n\ndef compute_lps(pattern: str) -> List[int]:\n M = len(pattern)\n lps = [0] * M\n length = 0\n i = 1\n \n while i < M:\...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00052119", "row_id": 52119, "seed_ids": "[16773]" }
0.676804
Taco_52119
I
[ "compute_lps", "search_pattern" ]
2
[ [ "search_pattern", "compute_lps" ] ]
1
[]
false
[]
false
pytest
true
[]
true
622cf7455c38006c4177c7616a5692e6542c9142
26619bc45711486321c8b5eb2967ec341a76db38
v1.0
instruct
Taco
Taco_52184_I
You are given a string s and a list of words. Your task is to determine which words from the list are subsequences of the string s. A subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements. Write a function to find all su...
def is_subsequence(s, word): """ Checks if 'word' is a subsequence of 's'. """ it = iter(s) return all(char in it for char in word) def find_subsequences(s, words): """ Takes a string s and a list of words, returns the words that are subsequences of s. """ subsequences = [word for w...
from solution import is_subsequence, find_subsequences def test_is_subsequence(): assert is_subsequence("abcde", "a") == True assert is_subsequence("abcde", "bb") == False assert is_subsequence("abcde", "ace") == True assert is_subsequence("xyz", "xy") == True assert is_subsequence("xyz", "z") == T...
[ { "docstring": "Checks if 'word' is a subsequence of 's'.", "function_declaration": "def is_subsequence(s, word):", "function_name": "is_subsequence", "parameter_list": "(s, word)" }, { "docstring": "Takes a string s and a list of words, returns the words that are subsequences of s.", "f...
[ 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_subsequence(s, word):\n \"\"\"\n Check if word is a subsequence of s.\n \"\"\"\n it = iter(s)\n return all(char in it for char in word)\n\nde...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00052184", "row_id": 52184, "seed_ids": "[13769]" }
0.772218
Taco_52184
I
[ "is_subsequence", "find_subsequences" ]
2
[ [ "find_subsequences", "is_subsequence" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f6d4349d1a638b5e46842c48c4aedf586f049add
499eacc37d2a1001b8f6c34d4a423f0f7f30aecb
v1.0
instruct
Taco
Taco_52224_I
Develop a program that simulates a transportation scheduling system for a shared ride service. Each trip has a fixed capacity of C seats, and there are N passengers wishing to travel, each with a specific pickup location and drop-off location. The goal is to group passengers into the fewest number of trips while mainta...
def min_trips(N, C, passengers): """ Given the number of passengers and seating capacity, this function calculates the minimum number of trips required. """ passengers.sort() trips = 0 i = 0 while i < len(passengers): count = 1 end = passengers[i][1] trips += 1 ...
from solution import transportation_scheduling def test_case_1(): assert transportation_scheduling(4, 3, [(1, 5), (2, 6), (3, 7), (4, 8)]) == 2 def test_case_2(): assert transportation_scheduling(3, 2, [(1, 3), (2, 5), (4, 6)]) == 2 def test_case_3(): assert transportation_scheduling(5, 5, [(1, 10), (2, ...
[ { "docstring": "Given the number of passengers and seating capacity, this function calculates the minimum number of trips required.", "function_declaration": "def min_trips(N, C, passengers):", "function_name": "min_trips", "parameter_list": "(N, C, passengers)" }, { "docstring": null, "...
[ 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 min_trips(N, C, passengers):\n # Sort passengers by pickup location and then by drop-off location\n passengers.sort()\n\n trips = 0\n seats_used = ...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00052224", "row_id": 52224, "seed_ids": "[13463]" }
0.713801
Taco_52224
I
[ "min_trips", "transportation_scheduling" ]
2
[ [ "transportation_scheduling", "min_trips" ] ]
1
[]
false
[]
false
pytest
true
[]
true
41d1222f2b4a892ace05ac2b2cf3411925853721
244d0db03b42c0c8cbe5f86e8b4d46aee9183dde
v1.0
instruct
Taco
Taco_52229_I
Amy has a passion for exploring numerical patterns and number theory. One day, she stumbled upon a series of equations involving a special set of numbers called Perfect Numbers. A Perfect Number is a positive integer that is equal to the sum of its proper divisors, excluding itself. For example, 6 is a Perfect Number b...
def is_perfect_number(n): if n < 2: return False sum_of_divisors = 1 sqrt_n = int(n**0.5) for i in range(2, sqrt_n + 1): if n % i == 0: sum_of_divisors += i if i != n // i: sum_of_divisors += n // i return sum_of_divisors == n def count_perfec...
from solution import is_perfect_number, count_perfect_numbers_up_to_n, count_perfect_numbers def test_is_perfect_number(): assert is_perfect_number(6) == True assert is_perfect_number(28) == True assert is_perfect_number(496) == True assert is_perfect_number(12) == False assert is_perfect_number(27...
[ { "docstring": null, "function_declaration": "def is_perfect_number(n):", "function_name": "is_perfect_number", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def count_perfect_numbers_up_to_n(N):", "function_name": "count_perfect_numbers_up_to_n", "para...
[ 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_perfect_number(n):\n if n < 2:\n return False\n sum_of_divisors = 1\n sqrt_n = int(n**0.5)\n for i in range(2, sqrt_n + 1):\n if n...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00052229", "row_id": 52229, "seed_ids": "[3688]" }
0.694933
Taco_52229
I
[ "is_perfect_number", "count_perfect_numbers_up_to_n", "count_perfect_numbers" ]
3
[ [ "count_perfect_numbers", "is_perfect_number" ], [ "count_perfect_numbers_up_to_n", "is_perfect_number" ] ]
2
[]
false
[]
false
pytest
true
[]
true
478dc0e4355001d8d14662eff7c558db0a538e6f
0d74e5ed000528135ce9400982074f9e5dd8a9ca
v1.0
instruct
Taco
Taco_52235_I
Monica is learning data structures and algorithms. She challenges herself by solving a problem related to range queries. She has an array of $n$ integers $a_1, a_2, \dots, a_n$. She wants to answer $m$ queries. Each query consists of two integers $l$ and $r$ ($1 \leq l \leq r \leq n$) and asks her to find the sum of th...
def preprocess_array(array): """ Preprocess the array to create a prefix sum array. """ n = len(array) prefix_sum = [0] * (n + 1) for i in range(1, n + 1): prefix_sum[i] = prefix_sum[i - 1] + array[i - 1] return prefix_sum def range_sum(prefix_sum, l, r): """ C...
from solution import answer_queries def test_example_1(): n, m = 5, 3 array = [1, 2, 3, 4, 5] queries = [(1, 3), (2, 5), (1, 5)] expected = [6, 14, 15] assert answer_queries(n, m, array, queries) == expected def test_example_2(): n, m = 5, 2 array = [5, 5, -5, -5, 5] queries = [(1, 5),...
[ { "docstring": "Preprocess the array to create a prefix sum array.", "function_declaration": "def preprocess_array(array):", "function_name": "preprocess_array", "parameter_list": "(array)" }, { "docstring": "Calculate the sum for the range query (l, r) using the prefix sum array.", "fun...
[ 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):\n \"\"\"\n Preprocesses the input array to create a prefix sum array.\n \"\"\"\n prefix_sum = [0] * (len(array) + 1)\n for i ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00052235", "row_id": 52235, "seed_ids": "[10379]" }
0.654567
Taco_52235
I
[ "preprocess_array", "range_sum", "answer_queries" ]
3
[ [ "answer_queries", "preprocess_array" ], [ "answer_queries", "range_sum" ] ]
2
[]
false
[]
false
pytest
true
[]
true
9ded57f423b0d80152fdd87f101325361e557f3b
8f99f5fccd7e18e1067ee09c574b7d32c0dced60
v1.0
instruct
Taco
Taco_52270_I
Nina loves playing with trees, especially binary trees. She has a special game that involves traversing the binary tree in different orders (pre-order, in-order, and post-order). As a challenge, Nina wants you to reconstruct the binary tree given its in-order and post-order traversals. She will then ask you questions ...
class TreeNode: def __init__(self, key=0, left=None, right=None): self.key = key self.left = left self.right = right def build_tree(inorder, postorder): if not inorder or not postorder: return None root_val = postorder.pop() root = TreeNode(root_val) inorder_ind...
from solution import TreeNode, build_tree, preorder_traversal, reconstruct_and_traverse # Helper to compare two trees def is_same_tree(p, q): if not p and not q: return True if not p or not q: return False return p.key == q.key and is_same_tree(p.left, q.left) and is_same_tree(p.right, q.ri...
[]
[ 1, 1, 1 ]
3
easy
1
{ "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 build_t...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00052270", "row_id": 52270, "seed_ids": "[12454]" }
0.567939
Taco_52270
I
[ "build_tree", "preorder_traversal", "reconstruct_and_traverse" ]
3
[ [ "reconstruct_and_traverse", "build_tree" ], [ "reconstruct_and_traverse", "preorder_traversal" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
64c5ca43f78a687b838754dcac8c7ddc1cccb4e6
ddaeb9c7d63452427cd0bfca25bde81daa0ea941
v1.0
instruct
Taco
Taco_52373_I
A transportation company is building an automated delivery system. They have a network of delivery points represented as an undirected weighted graph. A delivery point can be a warehouse or a customer location. The company wants to ensure that every customer location is reachable from at least one warehouse and vice ve...
def find(parent, i): if parent[i] == i: return i 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] = xroot ...
def test_minimum_cost_to_ensure_connectivity(): assert minimum_cost_to_ensure_connectivity( 6, 7, ["W", "C", "C", "W", "C", "W"], [(1, 2, 10), (2, 3, 15), (3, 4, 10), (4, 5, 15), (3, 5, 10), (5, 6, 5), (1, 6, 20)] ) == 50 assert minimum_cost_to_ensure_connectivity( 4, ...
[ { "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 ]
1
medium
0.5
{ "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 xroot = find(parent, x)\n...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00052373", "row_id": 52373, "seed_ids": "[10944]" }
0.794709
Taco_52373
I
[ "find", "union", "kruskal", "minimum_cost_to_ensure_connectivity" ]
4
[ [ "kruskal", "find" ], [ "kruskal", "union" ], [ "minimum_cost_to_ensure_connectivity", "kruskal" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
false
[]
true
74ebc9fd8c5671cea53410bdaa0c5044c05deb06
d50c976b471d8feef3142c69e7b219073c13d327
v1.0
instruct
Taco
Taco_52393_I
You are given an undirected graph with n vertices and m edges. Each vertex has a color represented by an integer. You are asked to determine if it's possible to assign a color from a given set of three distinct colors {0, 1, 2} to each vertex such that no two adjacent vertices share the same color. Input: The first l...
def is_bipartite(graph, n): """ Helper function to check if a graph is bipartite using BFS """ color = [-1] * n queue = [] for start in range(n): if color[start] == -1: queue.append(start) color[start] = 0 while queue: node = queue.po...
from solution import can_color_graph def test_case_1(): vertices = 3 edges = [(1, 2), (2, 3), (3, 1)] assert can_color_graph(vertices, edges) == "No" def test_case_2(): vertices = 4 edges = [(1, 2), (2, 3), (3, 4), (4, 1)] assert can_color_graph(vertices, edges) == "Yes" def test_case_3(): ...
[ { "docstring": "Helper function to check if a graph is bipartite using BFS", "function_declaration": "def is_bipartite(graph, n):", "function_name": "is_bipartite", "parameter_list": "(graph, n)" }, { "docstring": "Returns \"Yes\" if it is possible to color the graph using three colors such ...
[ 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 is_graph_3_colorable(n, edges):\n \"\"\"\n Determines if the given graph with n vertices and edges is 3-colorable such that no\n two adjacent vertices...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00052393", "row_id": 52393, "seed_ids": "[574]" }
0.641685
Taco_52393
I
[ "is_bipartite", "can_color_graph" ]
2
[ [ "can_color_graph", "is_bipartite" ] ]
1
[]
false
[]
false
pytest
true
[]
true
834b288d11b30da02bb311933523fa71fee1be0d
cd0bebc9a8a3ca9a48c27fb697758dd171acc011
v1.0
instruct
Taco
Taco_52394_I
### Coding Assessment Question You are given two strings `s` and `t` consisting of lowercase English letters. Your task is to determine if you can transform string `s` into string `t` by deleting some (possibly zero) characters from `s` without changing the order of the remaining characters. In other words, you need ...
def is_subsequence(s, t): """ Check if `t` is a subsequence of `s`. """ iter_s = iter(s) return all(char in iter_s for char in t) def subsequence_result(s, t): return "YES" if is_subsequence(s, t) else "NO"
from solution import is_subsequence, subsequence_result def test_example_1(): assert subsequence_result("abcde", "ace") == "YES" def test_example_2(): assert subsequence_result("abcde", "aec") == "NO" def test_empty_t(): assert subsequence_result("abcde", "") == "YES" def test_empty_s(): assert subs...
[ { "docstring": "Check if `t` is a subsequence of `s`.", "function_declaration": "def is_subsequence(s, t):", "function_name": "is_subsequence", "parameter_list": "(s, t)" }, { "docstring": null, "function_declaration": "def subsequence_result(s, t):", "function_name": "subsequence_re...
[ 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(s, t):\n \"\"\"\n Determine if t is a subsequence of s.\n \n Args:\n s (str): The source string.\n t (str): The target string....
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00052394", "row_id": 52394, "seed_ids": "[12533]" }
0.726338
Taco_52394
I
[ "is_subsequence", "subsequence_result" ]
2
[ [ "subsequence_result", "is_subsequence" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6e7f1e601068cbd82439d9f08a704ca00ddd6639
6144a73e4f37882fac52cf56019474f3b314e90c
v1.0
instruct
Taco
Taco_52431_I
Fibonacci matrices are used in several areas of mathematics and algorithms, notably optimization. Given a 2x2 matrix M with elements: ``` M = [a, b] [c, d] ``` You can calculate the nth power of M, denoted as M^n. To raise this matrix to the nth power efficiently, use matrix exponentiation. Given the constraints...
MOD = 1000000007 def matrix_mult(A, B, mod=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][1...
from solution import matrix_exponentiation def test_matrix_exponentiation_example1(): assert matrix_exponentiation(2, 3, 4, 5, 2) == (16, 21, 28, 37) def test_matrix_exponentiation_example2(): assert matrix_exponentiation(1, 1, 1, 0, 5) == (8, 5, 5, 3) def test_matrix_exponentiation_identity(): assert ma...
[ { "docstring": null, "function_declaration": "def matrix_mult(A, B, mod=MOD):", "function_name": "matrix_mult", "parameter_list": "(A, B, mod=MOD)" }, { "docstring": null, "function_declaration": "def matrix_pow(M, n, mod=MOD):", "function_name": "matrix_pow", "parameter_list": "...
[ 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": "MOD = 1000000007\n\ndef matrix_mult(A, B):\n \"\"\"\n Multiplies two 2x2 matrices A and B and returns the result modulo MOD.\n \"\"\"\n return [\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00052431", "row_id": 52431, "seed_ids": "[17112]" }
0.562155
Taco_52431
I
[ "matrix_mult", "matrix_pow", "matrix_exponentiation" ]
3
[ [ "matrix_exponentiation", "matrix_pow" ], [ "matrix_pow", "matrix_mult" ] ]
2
[]
false
[]
false
pytest
true
[]
true
0f0f64ac2324ce27e4bd31c7a5f56169d61e5dfe
af6e3d3c19573f7001447beabafb6231a9a37f88
v1.0
instruct
Taco
Taco_52461_I
You are given a matrix of dimensions N x M, filled with integers. Your goal is to find the submatrix with the maximum sum. The submatrix should have at least one element. Constraints: * 1 \≤ N, M \≤ 100 * -1000 ≤ matrix[i][j] ≤ 1000 Input: The input is given from Standard Input in the following format: N M matrix...
def max_submatrix_sum(matrix): """ Returns the maximum sum of any submatrix within the given matrix. """ if not matrix or not matrix[0]: return 0 N = len(matrix) M = len(matrix[0]) max_sum = float('-inf') # Apply Kadane's Algorithm in 2D for left in range(M): te...
def test_max_submatrix_sum(): matrix1 = [ [1, 2, -1, -4, -20], [-8, -3, 4, 2, 1], [3, 8, 10, 1, 3], [-4, -1, 1, 7, -6] ] assert max_submatrix_sum(matrix1) == 29 matrix2 = [ [-1, -2], [-3, -4] ] assert max_submatrix_sum(matrix2) == -1 matrix3 ...
[ { "docstring": "Returns the maximum sum of any submatrix within the given matrix.", "function_declaration": "def max_submatrix_sum(matrix):", "function_name": "max_submatrix_sum", "parameter_list": "(matrix)" }, { "docstring": "Helper function to find the maximum sum subarray in a 1D array."...
[ 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 max_sum_submatrix(matrix):\n \"\"\"\n Finds the submatrix with the maximum sum.\n \"\"\"\n def kadane(arr):\n max_sum = arr[0]\n curr...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00052461", "row_id": 52461, "seed_ids": "[16775]" }
0.634455
Taco_52461
I
[ "max_submatrix_sum", "kadane" ]
2
[ [ "max_submatrix_sum", "kadane" ] ]
1
[]
false
[]
false
pytest
false
[]
true
3fa911c02875d13097c0218f76f79964552ea13a
b89cdd5a74a506f88a3b1ee416c6b0c7d893390d
v1.0
instruct
Taco
Taco_52486_I
You are tasked with creating a report card generator for a classroom. Each student has taken multiple exams and you need to compute their average score as well as determine their final grade based on the average. The letter grade is assigned based on the following scale: - Average score >= 90: A - 80 <= Average score ...
def compute_grade(average_score): """ Determines the grade based on the average_score. """ if average_score >= 90: return "A" elif average_score >= 80: return "B" elif average_score >= 70: return "C" elif average_score >= 60: return "D" else: retur...
def test_compute_grade(): assert compute_grade(95) == "A" assert compute_grade(85) == "B" assert compute_grade(75) == "C" assert compute_grade(65) == "D" assert compute_grade(55) == "F" def test_generate_report_card(): students_data = [ { "name": "Alice", "scores...
[ { "docstring": "Determines the grade based on the average_score.", "function_declaration": "def compute_grade(average_score):", "function_name": "compute_grade", "parameter_list": "(average_score)" }, { "docstring": "Generates report card for each student based on the input data.", "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": "def compute_average(scores):\n total_score = sum(scores)\n number_of_exams = len(scores)\n return total_score // number_of_exams\n\ndef determine_grade(av...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00052486", "row_id": 52486, "seed_ids": "[8722]" }
0.683254
Taco_52486
I
[ "compute_grade", "generate_report_card" ]
2
[ [ "generate_report_card", "compute_grade" ] ]
1
[]
false
[]
false
pytest
false
[]
true
88e03c59f4abfccbda73cb095fd629a7bb8bdbaa
500c226a0e23960d32a1048e18b715735e42d81c
v1.0
instruct
Taco
Taco_52597_I
Maya is learning about prime numbers and wants to write a program to find all prime numbers within a given range. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. Can you help Maya by writing a function that generates all prime numbers between two given integers,...
def sieve_of_eratosthenes(max_num): primes = [True] * (max_num + 1) primes[0] = primes[1] = False p = 2 while p * p <= max_num: if primes[p]: for i in range(p * p, max_num + 1, p): primes[i] = False p += 1 return primes def find_primes_in_range(A, B): ...
from solution import find_primes_in_range def test_example_case(): assert find_primes_in_range(10, 30) == [11, 13, 17, 19, 23, 29] def test_no_primes_case(): assert find_primes_in_range(14, 16) == ["No primes"] def test_entire_range_prime(): assert find_primes_in_range(2, 2) == [2] def test_range_with_s...
[ { "docstring": null, "function_declaration": "def sieve_of_eratosthenes(max_num):", "function_name": "sieve_of_eratosthenes", "parameter_list": "(max_num)" }, { "docstring": null, "function_declaration": "def find_primes_in_range(A, B):", "function_name": "find_primes_in_range", ...
[ 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 sieve_of_eratosthenes(max_num):\n primes = [True] * (max_num + 1)\n primes[0] = primes[1] = False\n p = 2\n while p * p <= max_num:\n if pri...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00052597", "row_id": 52597, "seed_ids": "[23706]" }
0.568177
Taco_52597
I
[ "sieve_of_eratosthenes", "find_primes_in_range" ]
2
[ [ "find_primes_in_range", "sieve_of_eratosthenes" ] ]
1
[]
false
[]
false
pytest
true
[]
true
23a288de1ef9761d039345546428747f7cf5856d
04f933c766ad14e50378e0f75f8f3b4fcbf11eea
v1.0
instruct
Taco
Taco_52602_I
Given a binary tree, write a function to calculate the sum of the nodes with even-valued grandparents. A node’s grandparent is the parent of its parent if it exists. -----Input----- The input will be in the format of an array representation of a binary tree, where `None` represents a missing node. For example: [6, 7...
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None def insert_level_order(arr, root, i, n): if i < n: temp = TreeNode(arr[i]) if arr[i] is not None else None root = temp if temp is not None: root.left = insert_level...
import pytest from solution import TreeNode, sumEvenGrandparent, insert_level_order def test_sumEvenGrandparent_example_1(): arr = [6, 7, 8, 2, 7, 1, 3, 9, None, 1, 4, None, None, None, 5] assert sumEvenGrandparent(arr) == 18 def test_sumEvenGrandparent_example_2(): arr = [1, 2, 3, 4, 5, 6, 7] assert ...
[]
[ 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": "class TreeNode:\n def __init__(self, x):\n self.val = x\n self.left = None\n self.right = None\n\ndef insert_level_order(arr, root, i, n):\...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00052602", "row_id": 52602, "seed_ids": "[11667]" }
0.624848
Taco_52602
I
[ "insert_level_order", "sumEvenGrandparent", "sumEvenGrandparentUtil" ]
3
[ [ "sumEvenGrandparent", "insert_level_order" ], [ "sumEvenGrandparent", "sumEvenGrandparentUtil" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
ddb9fc1ffffdbf5691fa00d3cf0cd51ad463d049
036fad204d25c0567f09aa93b5ca50cf1933a230
v1.0
instruct
Taco
Taco_52621_I
You have a group of friends who enjoy playing a game they created called "Number Chains." The game works as follows: start with a non-negative integer n, and repeatedly sum the squares of its digits to form a new number until the process eventually results in the number 1, or it enters a cycle that does not include 1. ...
def sum_of_squares_of_digits(n): """ Returns the sum of the squares of the digits of a given number n. """ return sum(int(digit) ** 2 for digit in str(n)) def is_happy_number(n): """ Determines if a number n is a happy number. """ seen = set() while n != 1 and n not in seen: ...
from solution import sum_of_squares_of_digits, is_happy_number, number_chains def test_sum_of_squares_of_digits(): assert sum_of_squares_of_digits(19) == 82 assert sum_of_squares_of_digits(82) == 68 assert sum_of_squares_of_digits(68) == 100 assert sum_of_squares_of_digits(100) == 1 def test_is_happy_...
[ { "docstring": "Returns the sum of the squares of the digits of a given number n.", "function_declaration": "def sum_of_squares_of_digits(n):", "function_name": "sum_of_squares_of_digits", "parameter_list": "(n)" }, { "docstring": "Determines if a number n is a happy number.", "function_...
[ 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 sum_of_squares_of_digits(n):\n \"\"\"\n Returns the sum of the squares of the digits of a given number n.\n \"\"\"\n return sum(int(digit) ** 2 for...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00052621", "row_id": 52621, "seed_ids": "[13679]" }
0.65439
Taco_52621
I
[ "sum_of_squares_of_digits", "is_happy_number", "number_chains" ]
3
[ [ "is_happy_number", "sum_of_squares_of_digits" ], [ "number_chains", "is_happy_number" ] ]
2
[]
false
[]
false
pytest
true
[]
true
09fa75ad310c046f0d3db94d8dc5519a964380ff
e91d1cac8c8fe62e222ae2ca14c49a418f95349e
v1.0
instruct
Taco
Taco_52634_I
The city of Techville is planning to set a new world record in constructing a "Digital Wall of Fame". A list of achievements by several programmers are to be engraved on this wall, but there is a catch. Each programmer's name will be engraved along with their achievements in lexicographical order. Given names and cor...
def sort_programmers_achievements(programmers_info): """ Given a list of programmers and their achievements, sorts the programmers by name and their achievements lexicographically. Args: programmers_info: list of tuples, each containing (str, int, list of str) - str: programmer's name ...
from solution import process_input, sort_programmers_achievements, display_sorted_achievements def test_example_case(): input_lines = [ "3", "alice 3 hackathon_leader top_coder open_source_contributor", "bob 2 ai_researcher robotics_spirit", "charlie 1 bug_finder" ] expected...
[ { "docstring": "Given a list of programmers and their achievements, sorts the programmers\nby name and their achievements lexicographically.\n\nArgs:\nprogrammers_info: list of tuples, each containing (str, int, list of str)\n - str: programmer's name\n - int: number of achievements\n - list of str: th...
[ 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 list_achievements(programmers):\n \"\"\"\n Given a list of programmers and their achievements, return a list of strings with each programmer's\n name ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00052634", "row_id": 52634, "seed_ids": "[1674]" }
0.624027
Taco_52634
I
[ "sort_programmers_achievements", "display_sorted_achievements", "process_input" ]
3
[ [ "process_input", "sort_programmers_achievements" ] ]
1
[ "process_input" ]
false
[]
false
pytest
true
[]
true
180933832fbea88d11f5ec574d59603f6eda0338
9077bbe37d99de18f839612b5ac320e8a4b2e91e
v1.0
instruct
Taco
Taco_52658_I
You are given a network of n computers labeled from 1 to n. Each computer is connected to other computers by bidirectional communication channels. You are provided with a list of connections where each connection is a tuple (a_i, b_i, t_i) representing a channel between computer a_i and computer b_i with a communicatio...
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_minimum_communication_delay(): assert minimumCommunicationDelay(4, [[1, 2, 1], [2, 3, 2], [3, 4, 1], [1, 4, 4]]) == 4 assert minimumCommunicationDelay(4, [[1, 2, 3], [3, 4, 4]]) == -1 assert minimumCommunicationDelay(3, [[1, 2, 1], [2, 3, 1], [1, 3, 2]]) == 2 assert minimumCommunicationDelay(5,...
[ { "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, 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 minimumCommunicationDelay(n, connections):\n \"\"\"\n Returns the minimum total communication delay to connect all computers or -1 if it's impossible.\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00052658", "row_id": 52658, "seed_ids": "[25293]" }
0.563437
Taco_52658
I
[ "find", "union", "minimumCommunicationDelay" ]
3
[ [ "minimumCommunicationDelay", "find" ], [ "minimumCommunicationDelay", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
false
[]
true
f18c0756de6052621b1bee761adc8a6c15ccf814
af29233abcf4fba913c7a8b96de49e1681f7fd11
v1.0
instruct
Taco
Taco_52670_I
Write a function that takes an integer `n` as input and returns the smallest integer which is both greater than `n` and a prime number. Constraints: - \( 1 \leq n \leq 10^5 \) Input Input is given from standard input in the following format: ``` n ``` Output Print the smallest prime number that is greater than `...
def is_prime(num): """ 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 False i += 6...
from solution import is_prime, next_prime def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(11) == True assert is_prime(25) == False def test_next_prime(): assert next_prime(10) == 11 assert next_prime(14) == 17 asser...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Find the smallest prime number greater than n.", "function_declaration": "def next_prime(n):", "function_name": "next_...
[ 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(num):\n \"\"\"\n Check if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n return True\n if ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00052670", "row_id": 52670, "seed_ids": "[11713]" }
0.607819
Taco_52670
I
[ "is_prime", "next_prime" ]
2
[ [ "next_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
02affd345ff5594d7760235a7dc1c8489bf79fd6
2a888a61cb17cf040b3ad25f8ae4042a2089c239
v1.0
instruct
Taco
Taco_52671_I
You are provided with an array of integers. Your task is to create a balanced binary tree from this array and then perform in-order traversal on the tree. A balanced binary tree is a binary tree in which the depth of the two subtrees of every node never differ by more than one. The in-order traversal of a binary tree...
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def sorted_array_to_bst(nums): """ Convert sorted array to balanced binary search tree. """ if not nums: return None mid = len(nums) // 2 ...
from solution import create_balanced_bst_and_inorder_traversal def test_example_case(): assert create_balanced_bst_and_inorder_traversal([3, 1, 4, 1, 5, 9, 2]) == [1, 1, 2, 3, 4, 5, 9] def test_single_element(): assert create_balanced_bst_and_inorder_traversal([1]) == [1] def test_two_elements(): assert ...
[]
[ 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": "class TreeNode:\n def __init__(self, key):\n self.left = None\n self.right = None\n self.val = key\n\ndef sorted_array_to_bst(nums):\n \...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00052671", "row_id": 52671, "seed_ids": "[20200]" }
0.694472
Taco_52671
I
[ "sorted_array_to_bst", "inorder_traversal", "create_balanced_bst_and_inorder_traversal" ]
3
[ [ "create_balanced_bst_and_inorder_traversal", "inorder_traversal" ], [ "create_balanced_bst_and_inorder_traversal", "sorted_array_to_bst" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
80294331a9e2192dc86e1e8d86bc9e119c16f03d
d8ae5d565c8ad4389d83665215902a1e803e7cc9
v1.0
instruct
Taco
Taco_52688_I
Alyssa is studying prime numbers in her discrete mathematics class and has come across an interesting problem. She wants to create a program that finds all unique pairs of prime numbers (p, q) such that p < q and p + q = given even number n. Your task is to help Alyssa by writing a program that outputs all such pairs...
def sieve(n): """Return a list of primes up to n using Sieve of Eratosthenes algorithm.""" 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 return [p for p in range(2, n + 1) if...
from solution import find_prime_pairs def test_find_prime_pairs_case_10(capfd): find_prime_pairs(10) out, err = capfd.readouterr() assert out == "2\n(3, 7)\n(5, 5)\n" def test_find_prime_pairs_case_18(capfd): find_prime_pairs(18) out, err = capfd.readouterr() assert out == "2\n(5, 13)\n(7, 11)...
[ { "docstring": "Return a list of primes up to n using Sieve of Eratosthenes algorithm.", "function_declaration": "def sieve(n):", "function_name": "sieve", "parameter_list": "(n)" }, { "docstring": "Find all unique pairs of prime numbers (p, q) such that p < q and p + q = n.", "function_...
[ 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(n):\n \"\"\"\n Sieve of Eratosthenes to generate all prime numbers up to n.\n \"\"\"\n is_prime = [True] * (n + 1)\n is_prime[0], is_prime...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00052688", "row_id": 52688, "seed_ids": "[18453]" }
0.744105
Taco_52688
I
[ "sieve", "find_prime_pairs" ]
2
[ [ "find_prime_pairs", "sieve" ] ]
1
[]
false
[]
false
pytest
true
[]
true
283ebc8c32fba715fb5e99c95f5a82c1326edfa8
02087b56d3d51e1d845a3ecb690eea0fc6bcca47
v1.0
instruct
Taco
Taco_52700_I
You are given a connected undirected graph G with n nodes and m edges. Each edge has a weight associated with it. Two players, Alice and Bob, are playing a game on this graph. They take turns choosing an edge and removing it from the graph. Alice always goes first. The player who makes the graph disconnected loses the ...
def find(parent, i): if parent[i] == i: return i else: parent[i] = find(parent, parent[i]) return 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[r...
def test_get_max_last_edge_weight_before_disconnect_example1(): n = 4 m = 5 edges = [ (1, 2, 3), (1, 3, 2), (2, 3, 1), (2, 4, 4), (3, 4, 5) ] result = get_max_last_edge_weight_before_disconnect(n, m, edges) assert result == 4 def test_get_max_last_edge_we...
[ { "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, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\nimport networkx as nx\n\ndef max_last_edge_weight(n, m, edges):\n \"\"\"\n Determines the maximum weight of an edge that could be\n the last...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00052700", "row_id": 52700, "seed_ids": "[4422]" }
0.69793
Taco_52700
I
[ "find", "union", "kruskal_mst_max_edge", "get_max_last_edge_weight_before_disconnect" ]
4
[ [ "get_max_last_edge_weight_before_disconnect", "kruskal_mst_max_edge" ], [ "kruskal_mst_max_edge", "find" ], [ "kruskal_mst_max_edge", "union" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
false
[]
true
5c3fb1ac721121df2a0e19a4bfd042f4d254e585
e5890bac29610e75ed035d816f1d67cdc98f9dc5
v1.0
instruct
Taco
Taco_52738_I
Given an m x n matrix, where each element of the matrix represents the cost to step on that cell, find the minimum cost to go from the top-left cell to the bottom-right cell. You can only move right or down from a given cell. Create a program that finds this minimum path cost. **Input:** The first line of input cont...
def min_path_cost(matrix): """ Computes the minimum cost to move from the top-left to the bottom-right corner of the matrix only moving right or down. """ if not matrix or not matrix[0]: return 0 m, n = len(matrix), len(matrix[0]) dp = [[0 for _ in range(n)] for _ in range(m)] ...
def test_min_path_cost(): matrix = [ [1, 3, 1], [1, 5, 1], [4, 2, 1] ] assert min_path_cost(matrix) == 7 def test_min_path_cost_single_row(): matrix = [ [1, 2, 3] ] assert min_path_cost(matrix) == 6 def test_min_path_cost_single_column(): matrix = [ ...
[ { "docstring": "Computes the minimum cost to move from the top-left to the bottom-right corner\nof the matrix only moving right or down.", "function_declaration": "def min_path_cost(matrix):", "function_name": "min_path_cost", "parameter_list": "(matrix)" }, { "docstring": null, "functio...
[ 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 min_cost_path(m, n, matrix):\n # Create a 2D dp array\n dp = [[0] * n for _ in range(m)]\n \n # Initialize the starting point\n dp[0][0] = matri...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00052738", "row_id": 52738, "seed_ids": "[24912]" }
0.680288
Taco_52738
I
[ "min_path_cost", "read_input_and_compute_min_cost" ]
2
[ [ "read_input_and_compute_min_cost", "min_path_cost" ] ]
1
[]
false
[]
false
pytest
false
[]
true
2a5fa99a6bad186f31d60973813f00beea6159b7
70eb79ec7b14292e2af5932e650bb4a36b78adb5
v1.0
instruct
Taco
Taco_52762_I
You are given a tree consisting of n nodes. A tree is a connected undirected graph with n-1 edges. Each node is labeled with a unique integer from 1 to n. The depth of a node in the tree is the number of edges from the node to the root (node 1). Your task is to find the maximum possible depth of the tree after perform...
from collections import defaultdict, deque def find_max_depth_after_operation(n, edges): def bfs(start_node): queue = deque([start_node]) depths = {start_node: 0} visited = {start_node} while queue: node = queue.popleft() for neighbor in adjacency_li...
from solution import max_possible_depth def test_max_possible_depth_case1(): assert max_possible_depth(4, [(1, 2), (2, 3), (2, 4)]) == 2 def test_max_possible_depth_case2(): assert max_possible_depth(6, [(1, 2), (1, 3), (3, 4), (3, 5), (5, 6)]) == 4 def test_max_possible_depth_case3(): assert max_possibl...
[ { "docstring": null, "function_declaration": "def find_max_depth_after_operation(n, edges):", "function_name": "find_max_depth_after_operation", "parameter_list": "(n, edges)" }, { "docstring": null, "function_declaration": "def max_possible_depth(n, edges):", "function_name": "max_p...
[ 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_max_depth(n, edges):\n from collections import defaultdict, deque\n \n def bfs(start_node):\n distances = [-1] * (n + 1)\n queue = ...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00052762", "row_id": 52762, "seed_ids": "[23817]" }
0.720392
Taco_52762
I
[ "find_max_depth_after_operation", "max_possible_depth" ]
2
[ [ "max_possible_depth", "find_max_depth_after_operation" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a7d2b6acf9742815b8cb92f99251965ec4df9753
01ef824f2481ceb59fb4329ba01da466b9da18bf
v1.0
instruct
Taco
Taco_52794_I
You are working on a warehouse management system where orders need to be fulfilled by picking items from shelves. The warehouse consists of multiple shelves, each containing multiple items. Each item has a specific weight and value. Given the weight capacity of a cart used for picking items, your goal is to maximize th...
def knapsack(values, weights, n, W): dp = [0] * (W + 1) for i in range(n): for w in range(W, weights[i] - 1, -1): dp[w] = max(dp[w], dp[w - weights[i]] + values[i]) return dp[W] def max_values_for_orders(n, m, items, orders): results = [] for k, w in orders: ...
from solution import main def test_example_case_1(): n, m = 5, 2 items = [(2, 3), (3, 4), (4, 5), (5, 6), (6, 7)] orders = [(3, 10), (2, 5)] result = main(n, m, items, orders) assert result == [12, 7] def test_single_item_case(): n, m = 1, 1 items = [(5, 10)] orders = [(1, 5)] resu...
[ { "docstring": null, "function_declaration": "def knapsack(values, weights, n, W):", "function_name": "knapsack", "parameter_list": "(values, weights, n, W)" }, { "docstring": null, "function_declaration": "def max_values_for_orders(n, m, items, orders):", "function_name": "max_value...
[ 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 knapsack_max_value(items, k, W):\n \"\"\"\n Calculate the maximum value of items that can be picked without exceeding the weight capacity.\n\n :param ...
trial_gpt4o_7
{ "original_instruction": "", "prompt_id": "00052794", "row_id": 52794, "seed_ids": "[4727]" }
0.737747
Taco_52794
I
[ "knapsack", "max_values_for_orders", "main" ]
3
[ [ "max_values_for_orders", "knapsack" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ea07bdfc209477cd2122f2cedf8ff4753396c7ce
ade56476486662035d6ccf5981f6572b87986934
v1.0
instruct
Taco
Taco_52828_I
You are given a grid with N rows and M columns filled with non-negative integers. The grid represents a landscape where each cell has a height value. Your task is to find the maximum area of a rectangular region in the grid, such that all the cells in the region have the same height. ------ Input Format ------ - The...
def max_rect_area(grid, N, M): """ Function to find the maximum area of a rectangular region in the grid where all cells have the same height. """ max_area = 0 for height in range(101): # Since heights are between 0 and 100 # Transform the grid into a binary matrix where 1 represents cells ...
from solution import process_input_and_find_max_areas def test_case_1(): input_data = "2\n3 3\n1 2 1\n2 2 2\n1 2 1\n4 5\n3 3 3 3 3\n3 3 3 3 3\n3 3 3 3 3\n3 3 3 3 3" expected_output = [3, 20] assert process_input_and_find_max_areas(input_data) == expected_output def test_single_row(): input_data = "1\n...
[ { "docstring": "Function to find the maximum area of a rectangular region in the grid where all cells have the same height.", "function_declaration": "def max_rect_area(grid, N, M):", "function_name": "max_rect_area", "parameter_list": "(grid, N, M)" }, { "docstring": "Given a binary matrix,...
[ 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 max_area_same_height(grid):\n from collections import defaultdict\n max_area = 0\n n = len(grid)\n m = len(grid[0])\n heights = defaultdict(list...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00052828", "row_id": 52828, "seed_ids": "[6932]" }
0.720687
Taco_52828
I
[ "max_rect_area", "max_histogram_area", "largest_rectangle_area", "process_input_and_find_max_areas" ]
4
[ [ "max_histogram_area", "largest_rectangle_area" ], [ "max_rect_area", "max_histogram_area" ], [ "process_input_and_find_max_areas", "max_rect_area" ] ]
3
[]
false
[]
false
pytest
true
[]
true
da0d4c9aa2b46e3d4f801b9420238600bebabfc7
e08b192dc3fc0a9027b3e98c95169852d0727044
v1.0
instruct
Taco
Taco_52904_I
Given a tuple of integers, your task is to return the sum of all elements that are prime numbers. Example 1: Input: numbers = (3, 4, 2, 7, 8) Output: 12 Explanation: The prime numbers in the given tuple are 3, 2, and 7. Their sum is 3 + 2 + 7 = 12. Example 2: Input: numbers = (10, 15, 18, 30) Output: 0 Explanation: T...
def is_prime(n): """ Determine if a number is 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 p += 2 return True def sum_of_primes(numbers): ...
from solution import sum_of_primes, is_prime def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(11) == True assert is_prime(25) == False assert is_prime(1) == False def test_sum_of_primes_example1(): numbers = (3, 4, 2, 7,...
[ { "docstring": "Determine if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the sum of all prime numbers in the given tuple of numbers.", "function_declaration": "def sum_of_primes(numbers):...
[ 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 Determine if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\n if n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00052904", "row_id": 52904, "seed_ids": "[21030]" }
0.618448
Taco_52904
I
[ "is_prime", "sum_of_primes" ]
2
[ [ "sum_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b5ad6ddc9b1ae34276494711f28bd75660b73054
3d8f3ea3d562f929b75aa7cd0cf7873f2f7d2dc1
v1.0
instruct
Taco
Taco_52943_I
Write a function that takes a list of integers as input and returns a list containing only the prime numbers from the input list. A number is prime if it is greater than 1 and has no divisors other than 1 and itself. Your function should iterate through the input list, check each element for primality, and collect the...
def is_prime(num): """ Helper function to check if a number is prime. """ if num <= 1: return False if num == 2: return True if num % 2 == 0: return False for i in range(3, int(num ** 0.5) + 1, 2): if num % i == 0: return False return True def...
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(18) == False assert is_prime(-5) == False assert is_prime(0) == False assert is_prime(1) == Fal...
[ { "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 containing only the prime numbers from the input list.", "function_declaration": "def fi...
[ 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 if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\n return False\n i = 5\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00052943", "row_id": 52943, "seed_ids": "[21830]" }
0.702812
Taco_52943
I
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5d8c1af8ebbab57b364473d85916debdad2bb9f0
5dbad3aac9c637e553ee9120aca3cacd4d11b11b
v1.0
instruct
Taco
Taco_53003_I
Design a function that calculates the smallest possible number that is divisibly by all integers from 1 to n (also known as the least common multiple of the set {1, 2, ..., n}). Example 1: Input: n = 5 Output: 60 Explanation: The smallest number that is divisibly by all numbers from 1 to 5 is 60. Example 2: Input: n ...
from math import gcd def lcm(a, b): """ Function to compute the Least Common Multiple (LCM) of two numbers. """ return a * b // gcd(a, b) def smallestMultiple(n): """ Returns the smallest number that is divisible by all integers from 1 to n. """ multiple = 1 for i in range(1, n + 1...
from solution import smallestMultiple def test_smallestMultiple_1(): assert smallestMultiple(1) == 1 def test_smallestMultiple_2(): assert smallestMultiple(2) == 2 def test_smallestMultiple_3(): assert smallestMultiple(3) == 6 def test_smallestMultiple_4(): assert smallestMultiple(4) == 12 def test...
[ { "docstring": "Function to compute the Least Common Multiple (LCM) of two numbers.", "function_declaration": "def lcm(a, b):", "function_name": "lcm", "parameter_list": "(a, b)" }, { "docstring": "Returns the smallest number that is divisible by all integers from 1 to n.", "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": "from math import gcd\n\ndef lcm(a, b):\n \"\"\"\n Compute the least common multiple of two numbers a and b.\n \"\"\"\n return a * b // gcd(a, b)\n\ndef...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00053003", "row_id": 53003, "seed_ids": "[401]" }
0.682187
Taco_53003
I
[ "lcm", "smallestMultiple" ]
2
[ [ "smallestMultiple", "lcm" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0f70b3018aed19ca471f621e044825e9a1d027c4
2b27f35e5509c2f5ea729a1e1fefcfa9a533ba0e
v1.0
instruct
Taco
Taco_53015_I
John loves palindromes for their symmetry. A palindrome is a word, number, phrase, or other sequences of characters which reads the same backward as forward. John has a list of N strings, and for each string, he wants to find out if it is a palindrome or not. Since John is busy reading about various types of palindrom...
def is_palindrome(s): """ Returns 'YES' if the string s is a palindrome, otherwise returns 'NO'. """ return 'YES' if s == s[::-1] else 'NO' def check_palindromes(strings): """ Takes a list of strings and returns a list of results ('YES' or 'NO') for each string. """ results = [] for...
from solution import is_palindrome, check_palindromes def test_is_palindrome(): assert is_palindrome("radar") == 'YES' assert is_palindrome("hello") == 'NO' assert is_palindrome("level") == 'YES' assert is_palindrome("world") == 'NO' assert is_palindrome("a") == 'YES' assert is_palindrome("") =...
[ { "docstring": "Returns 'YES' if the string s is a palindrome, otherwise returns 'NO'.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": "Takes a list of strings and returns a list of results ('YES' or 'NO') for eac...
[ 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(s):\n \"\"\"\n Returns 'YES' if the string s is a palindrome, otherwise 'NO'.\n \"\"\"\n return \"YES\" if s == s[::-1] else \"NO\"\n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00053015", "row_id": 53015, "seed_ids": "[15274]" }
0.825521
Taco_53015
I
[ "is_palindrome", "check_palindromes" ]
2
[ [ "check_palindromes", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
614c2c0123c6abb0ceb17e598e485fd2cd3202cd
5f971187ccb2f85227f40cdb24c17f7831ef10dd
v1.0
instruct
Taco
Taco_53053_I
You are required to write a program to help Alice with her image processing task. Alice has an image represented as an M x N matrix of pixel values, where each pixel value is a positive integer. She needs to adjust the brightness of the image by increasing or decreasing the pixel values according to specific rules. Ea...
def adjust_brightness(image, adjustments): """ Adjust the brightness of the image according to the given adjustments. Parameters: image (list of list of int): M x N matrix representing the image's pixel values. adjustments (list of tuple): List of adjustments (a, b, k). Returns: li...
def test_single_adjustment(): M, N = 3, 3 image = [ [10, 20, 30], [40, 50, 60], [70, 80, 90] ] Q = 1 adjustments = [(1, 2, 10)] expected_output = [ [20, 30, 40], [50, 60, 70], [70, 80, 90] ] from solution import process_image_data ...
[ { "docstring": "Adjust the brightness of the image according to the given adjustments.\n\nParameters:\nimage (list of list of int): M x N matrix representing the image's pixel values.\nadjustments (list of tuple): List of adjustments (a, b, k).\n\nReturns:\nlist of list of int: The adjusted image.", "functi...
[ 0, 0, 0, 0, 0, 1, 0, 0, 0 ]
1
hard
0.111
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def adjust_brightness(image, adjustments):\n \"\"\"\n Adjusts the brightness of the image based on the list of adjustments.\n \n :param image: List of ...
trial_gpt4o_5
{ "original_instruction": "", "prompt_id": "00053053", "row_id": 53053, "seed_ids": "[22259]" }
0.629055
Taco_53053
I
[ "adjust_brightness", "process_image_data" ]
2
[ [ "process_image_data", "adjust_brightness" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b963b982d6bd0a1ec66d1a3393b93fc8c84721d9
ebf0e2ba95fa9a8adc6a4a1a002eedec8f0520b6
v1.0
instruct
Taco
Taco_53056_I
Given a tree with `n` nodes, where each node is assigned a value. A node is considered "balanced" if the sum of values in its left subtree is equal to the sum of values in its right subtree. You need to write a program that processes `q` queries, each of which will require you to determine whether a given node is "ba...
class TreeNode: def __init__(self, value): self.value = value self.left = None self.right = None self.subtree_sum = value def calculate_subtree_sums(node): if node is None: return 0 left_sum = calculate_subtree_sums(node.left) right_sum = calculate_subtree_sums(n...
from solution import handle_queries def test_sample_input_1(): n = 5 values = [1, 2, 3, 4, 5] edges = [ (1, 2), (1, 3), (3, 4), (3, 5) ] q = 2 queries = [3, 2] expected_output = ["NO", "YES"] assert handle_queries(n, values, edges, q, queries) == expected...
[]
[ 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": "class TreeNode:\n def __init__(self, value):\n self.value = value\n self.children = []\n\ndef build_tree(values, edges):\n nodes = [TreeNode(va...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00053056", "row_id": 53056, "seed_ids": "[7530]" }
0.68903
Taco_53056
I
[ "calculate_subtree_sums", "is_balanced", "construct_tree", "process_queries", "handle_queries" ]
5
[ [ "construct_tree", "calculate_subtree_sums" ], [ "handle_queries", "construct_tree" ], [ "handle_queries", "process_queries" ], [ "process_queries", "is_balanced" ] ]
4
[ "process_queries", "handle_queries" ]
false
[ "TreeNode" ]
true
pytest
true
[]
true
4d19e80f9fc9d11e3baceb53bfa388e7fb857bf7
56e84887770984142debdef546244e86c41acca7
v1.0
instruct
Taco
Taco_53085_I
In a faraway land named Graphonia, there is a kingdom with several cities connected by bidirectional roads. Each road has a specific travel time associated with it. The king of Graphonia, King Algorithmar, has a special interest in the shortest paths between cities. He frequently sends his messengers to deliver letters...
def floyd_warshall(n, roads): """ Function to compute shortest paths using Floyd-Warshall algorithm. """ # Initialize distance matrix inf = float('inf') dist = [[inf] * (n + 1) for _ in range(n + 1)] # Distance from a city to itself is 0 for i in range(1, n + 1): dist[i][i] ...
from solution import shortest_paths def test_single_dataset(): cities = (4, 4) roads = [ (1, 2, 4), (1, 3, 2), (2, 3, 1), (3, 4, 1) ] queries = [ (1, 4), (2, 4) ] result = shortest_paths(cities, roads, queries) assert result == [3, 2] def tes...
[ { "docstring": "Function to compute shortest paths using Floyd-Warshall algorithm.", "function_declaration": "def floyd_warshall(n, roads):", "function_name": "floyd_warshall", "parameter_list": "(n, roads)" }, { "docstring": "Function to find shortest paths for multiple queries.", "func...
[ 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 floyd_warshall(n, roads):\n \"\"\"\n Implements the Floyd-Warshall algorithm to find the shortest paths between all pairs of cities.\n \"\"\"\n inf...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00053085", "row_id": 53085, "seed_ids": "[2699]" }
0.803964
Taco_53085
I
[ "floyd_warshall", "shortest_paths" ]
2
[ [ "shortest_paths", "floyd_warshall" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c80f454c78a73e1b69f7077b4c0b323e61c89458
7e1201791755f0c64ebb0f6cdf7f48b1f8f3ff36
v1.0
instruct
Taco
Taco_53169_I
Jessie is practicing data structures and has recently come across the concept of trees. She wants to understand the concept of the depth (or height) of a binary tree. To do so, she has posed a problem to herself. The problem states: Given a binary tree, calculate the depth of the tree. The depth of a binary tree is t...
class TreeNode: def __init__(self, value): self.value = value self.left = None self.right = None def build_tree(node_descriptions): nodes = {} for value, left, right in node_descriptions: if value not in nodes: nodes[value] = TreeNode(value) if left ...
import pytest from solution import calculate_depth, parse_input def test_single_node_tree(): input_data = "1\n1\n1 -1 -1" test_cases = parse_input(input_data) result = calculate_depth(test_cases) assert result == [0] def test_three_node_tree(): input_data = "1\n3\n1 2 3\n2 -1 -1\n3 -1 -1" test...
[]
[ 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": "class TreeNode:\n def __init__(self, value):\n self.value = value\n self.left = None\n self.right = None\n\ndef build_tree(nodes):\n if ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00053169", "row_id": 53169, "seed_ids": "[8407]" }
0.671194
Taco_53169
I
[ "build_tree", "tree_depth", "calculate_depth", "parse_input" ]
4
[ [ "calculate_depth", "build_tree" ], [ "calculate_depth", "tree_depth" ] ]
2
[ "parse_input" ]
false
[ "TreeNode" ]
true
pytest
true
[]
true
962b04dfcc21bde5155f38e78d53e0e555ddac73
7ba0667f1a5c36e4f9fb3e3bfc2b21ee3fd7a426
v1.0
instruct
Taco
Taco_53270_I
There is a tree with $N$ nodes and $(N-1)$ edges rooted at node $1$. Each node has a value assigned to it. You need to find the maximum sum of node values in any simple path in the tree. A simple path is a path that does not revisit any node. -----Input----- - The first line of the input contains a single integer $T...
def dfs_max_sum(node, parent, adj, values): max1, max2 = 0, 0 # top two longest paths from this node for child in adj[node]: if child == parent: continue max_child_sum = dfs_max_sum(child, node, adj, values) if max_child_sum > max1: max1, max2 = max_child_su...
from solution import max_sum_path_in_forest def test_single_test_case(): T = 1 test_cases = [ (3, [1, 2, 3], [(1, 2), (2, 3)]) ] assert max_sum_path_in_forest(T, test_cases) == [6] def test_multiple_test_cases(): T = 2 test_cases = [ (3, [1, 2, 3], [(1, 2), (2, 3)]), (4...
[ { "docstring": null, "function_declaration": "def dfs_max_sum(node, parent, adj, values):", "function_name": "dfs_max_sum", "parameter_list": "(node, parent, adj, values)" }, { "docstring": null, "function_declaration": "def max_sum_path_in_tree(N, values, edges):", "function_name": ...
[ 0, 1 ]
1
medium
0.5
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_path_sum_in_tree(T, test_cases):\n def dfs(node, parent):\n max_single_path, max_top_path = values[node - 1], values[node - 1]\n for neigh...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00053270", "row_id": 53270, "seed_ids": "[10863]" }
0.731743
Taco_53270
I
[ "dfs_max_sum", "max_sum_path_in_tree", "max_sum_path_in_forest" ]
3
[ [ "max_sum_path_in_forest", "max_sum_path_in_tree" ], [ "max_sum_path_in_tree", "dfs_max_sum" ] ]
2
[]
false
[]
false
pytest
true
[]
true
a61276016bdc941f0c2529338dfcc8bd5417c12c
81de24260b767cea69b1cc8a3ec94b57760342bd
v1.0
instruct
Taco
Taco_53422_I
You are given an undirected tree with N nodes and N-1 edges. Each node has a value associated with it, and node 1 is considered the root of the tree. You are required to answer Q queries on this tree. Each query is of the form: * Given a node v, find the maximum value of any node in the subtree rooted at v. Constrain...
import sys from collections import defaultdict, deque def find_subtree_max_values(root, values, adjacency_list): n = len(values) max_values = [0] * n visited = [False] * n def dfs(node): visited[node] = True max_value = values[node] for neighbor in adjacency_list[n...
def test_small_tree(): assert solve( 5, [1, 2, 3, 4, 5], [(1, 2), (1, 3), (2, 4), (3, 5)], [1, 2, 3] ) == [5, 4, 5] def test_medium_tree(): assert solve( 6, [10, 5, 20, 1, 2, 15], [(1, 2), (1, 3), (3, 4), (3, 5), (4, 6)], [3, 4] ) ==...
[ { "docstring": null, "function_declaration": "def find_subtree_max_values(root, values, adjacency_list):", "function_name": "find_subtree_max_values", "parameter_list": "(root, values, adjacency_list)" }, { "docstring": null, "function_declaration": "def solve(n, values, edges, queries):...
[ 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 find_subtree_max_values(N, values, edges, queries):\n from collections import defaultdict, deque\n \n # Create adjacency list for the tree\n tree =...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00053422", "row_id": 53422, "seed_ids": "[383]" }
0.716279
Taco_53422
I
[ "find_subtree_max_values", "solve", "main" ]
3
[ [ "solve", "find_subtree_max_values" ] ]
1
[]
false
[]
false
pytest
false
[]
true
2fcc3a020d78fd443615c1ef20f5a84b417df38a
fb5c7fb3ba6693e704baf211d3805db83fb9e952
v1.0
instruct
Taco
Taco_53451_I
Modern Urban Traffic Simulation You are tasked with developing a simulation for a modern urban traffic system where intersections are controlled by traffic signals. The city layout is represented as a grid of streets, with each intersection having a traffic signal that alternates between allowing horizontal (east-west...
from heapq import heappop, heappush def min_time_to_destination(N, M, T, vehicles): """ Computes the minimum time required for each vehicle to reach its destination under the given traffic signal rules. :param N: Number of rows in the grid :param M: Number of columns in the grid :param T: Dura...
def test_min_time_to_destination(): datasets = [ (3, 3, 2, [(1, 1, 3, 3), (2, 1, 2, 3)]), (4, 4, 3, [(1, 1, 4, 4)]) ] expected_output = [ [4, 2], [6] ] assert traffic_simulation(datasets) == expected_output def test_unreachable_destination(): datasets = [ ...
[ { "docstring": "Computes the minimum time required for each vehicle to reach its destination under the given traffic signal rules.\n\n:param N: Number of rows in the grid\n:param M: Number of columns in the grid\n:param T: Duration traffic signals remain in one state before switching to the other\n:param vehicl...
[ 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": "from collections import deque\n\ndef min_time_to_destination(N, M, T, vehicles):\n def bfs(sx, sy, dx, dy):\n queue = deque([(sx, sy, 0)])\n visit...
trial_gpt4o_7
{ "original_instruction": "", "prompt_id": "00053451", "row_id": 53451, "seed_ids": "[11568]" }
0.647949
Taco_53451
I
[ "min_time_to_destination", "traffic_simulation", "parse_input" ]
3
[ [ "parse_input", "traffic_simulation" ], [ "traffic_simulation", "min_time_to_destination" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
65efec8fb51077fa9d1940fb0f0fdb6a28c4bb26
3104c2494f5883283590949bf013c928d85a06a9
v1.0
instruct
Taco
Taco_53460_I
To help the Secret Service identify potential security threats, you've been given a task to analyze a list of phone call records. Each record contains the caller, the recipient, and the duration of the call in minutes. Your task is to find out the total call duration for each person (both as a caller and a recipient). ...
def calculate_total_call_durations(records): """ Calculates the total call duration for each person (both as a caller and recipient). Args: records (list of tuple): List of tuples where each tuple contains caller's name, recipient's name, and call duration. Returns: dict: Dictionary with names...
from solution import process_call_records def test_process_call_records_sample_input(): input_data = "5\nAlice Bob 10\nBob Alice 15\nAlice Charlie 20\nCharlie Alice 5\nBob Charlie 30" expected_output = {"Alice": 50, "Bob": 55, "Charlie": 55} assert process_call_records(input_data) == expected_output def t...
[ { "docstring": "Calculates the total call duration for each person (both as a caller and recipient).\n\nArgs:\nrecords (list of tuple): List of tuples where each tuple contains caller's name, recipient's name, and call duration.\n\nReturns:\ndict: Dictionary with names as keys and total call duration as values....
[ 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 total_call_durations(n, call_records):\n \"\"\"\n Calculate the total call duration of each person involved in the call records.\n\n Args:\n n (int...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00053460", "row_id": 53460, "seed_ids": "[18928]" }
0.533646
Taco_53460
I
[ "calculate_total_call_durations", "process_call_records" ]
2
[ [ "process_call_records", "calculate_total_call_durations" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e7d3e449726e426f9dd894414434d38006fed06b
ffa81b7074156c973a2458fb84003dcfbeea2f15
v1.0
instruct
Taco
Taco_53585_I
Given a 2D matrix of characters and a word, implement a function to determine if the word exists in the matrix. The word can be constructed from letters of sequentially adjacent cells, where "adjacent" cells are those horizontally or vertically neighboring. The same letter cell may not be used more than once. -----Inp...
def exist(board, word): def dfs(board, word, i, j, k): if not 0 <= i < len(board) or not 0 <= j < len(board[0]) or board[i][j] != word[k]: return False if k == len(word) - 1: return True tmp, board[i][j] = board[i][j], '/' found = dfs(board, word, i +...
def test_word_exists_in_matrix_1(): matrix = [ ["A", "B", "C", "E"], ["S", "F", "C", "S"], ["A", "D", "E", "E"] ] word = "ABCCED" assert word_exists_in_matrix(matrix, word) == "YES" def test_word_exists_in_matrix_2(): matrix = [ ["A", "B", "C", "E"], ["S", "F...
[ { "docstring": null, "function_declaration": "def exist(board, word):", "function_name": "exist", "parameter_list": "(board, word)" }, { "docstring": null, "function_declaration": "def word_exists_in_matrix(matrix, word):", "function_name": "word_exists_in_matrix", "parameter_lis...
[ 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 exist(board, word):\n \"\"\"\n Determines if the word exists in the 2D board of characters.\n \"\"\"\n\n def backtrack(board, word, visited, i, j, ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00053585", "row_id": 53585, "seed_ids": "[9121]" }
0.706893
Taco_53585
I
[ "exist", "word_exists_in_matrix" ]
2
[ [ "word_exists_in_matrix", "exist" ] ]
1
[]
false
[]
false
pytest
false
[]
true
cb98e5418a28e5a724fe3c8896ee147f4ccc0215
dfce142b96f365465687ab811e7a6e3262d0a298
v1.0
instruct
Taco
Taco_53591_I
A company is planning to organize a tournament where employees compete against each other in a series of one-on-one matches. Each employee participates exactly once in each round. The company wants to decide the order of employees such that each employee competes against new opponents in different rounds as much as pos...
def schedule_tournament(n, m, k, previous_matches): from itertools import combinations, permutations # Create a set of previous matches for quick lookup previous_set = set(map(tuple, previous_matches)) if n % 2 != 0: return "Not possible" # Helper function to generate matches ...
from solution import solve def test_example1(): input_str = "4 2 2\n1 2\n3 4" output_str = solve(input_str) assert output_str in ["1 3 2 4\n1 4 2 3", "1 4 2 3\n1 3 2 4"] def test_example2(): input_str = "4 3 2\n1 2\n1 3\n2 4" output_str = solve(input_str) assert output_str == "Not possible" d...
[ { "docstring": null, "function_declaration": "def schedule_tournament(n, m, k, previous_matches):", "function_name": "schedule_tournament", "parameter_list": "(n, m, k, previous_matches)" }, { "docstring": null, "function_declaration": "def solve(input_str):", "function_name": "solve...
[ 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 find_schedule(n, m, k, previous_matches):\n from itertools import combinations\n from collections import defaultdict\n \n # Parse the previous matc...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00053591", "row_id": 53591, "seed_ids": "[2045]" }
0.732417
Taco_53591
I
[ "schedule_tournament", "solve" ]
2
[ [ "solve", "schedule_tournament" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4c67fc236f516493fbf36622ea94374f6a312a32
1e23e2d5a8d34579f6430d956a8a18dc9fafedb9
v1.0
instruct
Taco
Taco_53594_I
You are given a binary search tree (BST) with N nodes, where each node contains an integer value. Given this BST, write a function findKthSmallest that returns the k-th smallest element in the tree. Note: - A Binary Search Tree is a binary tree in which for each node, the value of all the nodes in the left subtree is ...
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None def insert_into_bst(root, val): if root is None: return TreeNode(val) if val < root.val: root.left = insert_into_bst(root.left, val) else: root.right = insert_into_bst(...
from solution import findKthSmallest, build_bst_from_preorder def test_kth_smallest(): preorder = [3, 1, 2, 4] k = 2 root = build_bst_from_preorder(preorder) assert findKthSmallest(root, k) == 2 def test_kth_smallest_first_element(): preorder = [3, 1, 2, 4] k = 1 root = build_bst_from_preo...
[]
[ 1, 1, 1 ]
3
easy
1
{ "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 insert_into_bst(root, val):\n if r...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00053594", "row_id": 53594, "seed_ids": "[8801]" }
0.559209
Taco_53594
I
[ "insert_into_bst", "findKthSmallest", "build_bst_from_preorder" ]
3
[ [ "build_bst_from_preorder", "insert_into_bst" ] ]
1
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
5f79933deaeb668f71b1bafce2c0435e96fc9d3f
2364951519bb98c12433823afde7c89c459472ee
v1.0
instruct
Taco
Taco_53643_I
Given a string s, write a program to determine whether it is a palindrome, considering only alphanumeric characters and ignoring case. Input The input contains a single line with a string s (1 ≤ |s| ≤ 105). Output Output "YES" if the given string is a palindrome, otherwise output "NO". Examples Input A man, a pl...
def is_palindrome(s): """ Determines if the given string is a palindrome, considering only alphanumeric characters and ignoring case. """ # Filter out non-alphanumeric characters and convert to lower case filtered_chars = [char.lower() for char in s if char.isalnum()] # Check if the filtere...
from solution import check_palindrome def test_palindrome_with_punctuation_and_spaces(): assert check_palindrome("A man, a plan, a canal: Panama") == "YES" def test_non_palindrome_with_spaces(): assert check_palindrome("race a car") == "NO" def test_palindrome_single_character(): assert check_palindr...
[ { "docstring": "Determines if the given string is a palindrome, considering only alphanumeric characters and ignoring case.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def ch...
[ 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(s):\n \"\"\"\n Determine whether the given string is a palindrome, considering only alphanumeric characters and ignoring case.\n \n :...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00053643", "row_id": 53643, "seed_ids": "[7516]" }
0.778463
Taco_53643
I
[ "is_palindrome", "check_palindrome" ]
2
[ [ "check_palindrome", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
79dd0b26cf22fa2dc454481cb463a52c22a4bf35
12867c7bb7bcdf29ca21ac015a73efae2d8c58ac
v1.0
instruct
Taco
Taco_53755_I
You are given a series of stacks filled with plates. Plates in each stack are labeled with a number representing their cleanliness level, where a higher number indicates a cleaner plate. The task at hand is to help Raju determine the cleanliness level of the cleanest plate across all the stacks. Input: - The first lin...
def find_cleanest_plate(test_cases): """ Given a series of stacks filled with plates, each labeled with a cleanliness level, return the cleanliness level of the cleanest plate across all the stacks for each test case. :param test_cases: List of test cases, each test case is a tuple where the first ...
import pytest from solution import find_cleanest_plate, parse_input, solve def test_find_cleanest_plate_single_case(): test_cases = [(3, [[3, 5, 1, 9], [2, 3, 8], [4, 7, 6, 2, 4]])] assert find_cleanest_plate(test_cases) == [9] def test_find_cleanest_plate_multiple_cases(): test_cases = [ (3, [[3,...
[ { "docstring": "Given a series of stacks filled with plates, each labeled with a cleanliness level,\nreturn the cleanliness level of the cleanest plate across all the stacks for each test case.\n\n:param test_cases: List of test cases, each test case is a tuple where the first item is\n the nu...
[ 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 cleanest_plate(test_cases):\n \"\"\"\n Determine the cleanliness level of the cleanest plate across all stacks for each test case.\n\n Parameters:\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00053755", "row_id": 53755, "seed_ids": "[18733]" }
0.621513
Taco_53755
I
[ "find_cleanest_plate", "parse_input", "solve" ]
3
[ [ "solve", "find_cleanest_plate" ], [ "solve", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
c33d814543f2df256e430616212a9e22f49b3af1
5dc3cd8b165b02a49857f82d30cf0bd23974ffae
v1.0
instruct
Taco
Taco_53794_I
Write a function `sum_prime_CSV()` that takes a string representing a CSV file content, where each row contains numbers separated by commas, and returns the sum of all prime numbers found in the CSV file. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. The funct...
import csv from math import isqrt def is_prime(n): """ Returns True if n is a prime number, otherwise False. """ 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) ...
from solution import sum_prime_CSV def test_prime_numbers_on_single_line(): csv_content = "23,10,17,19,20" assert sum_prime_CSV(csv_content) == 59 def test_prime_numbers_across_multiple_lines(): csv_content = "23,10\n17,19,20\n4,5,6" assert sum_prime_CSV(csv_content) == 64 def test_no_prime_numbers()...
[ { "docstring": "Returns True if n is a prime number, otherwise False.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Takes a string representing CSV file content and returns the sum of all prime numbers found in the CSV f...
[ 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 is_prime(n):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return ...
trial_gpt4o_7
{ "original_instruction": "", "prompt_id": "00053794", "row_id": 53794, "seed_ids": "[17757]" }
0.615355
Taco_53794
I
[ "is_prime", "sum_prime_CSV" ]
2
[ [ "sum_prime_CSV", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d9e94ede171fe8028701497baa2ec91d940fa053
e9b50a33757ae6615ae4f9c2bb673ec84f3bf839
v1.0
instruct
Taco
Taco_53805_I
A large orchestra has N instruments. Each instrument i needs exactly D_i seconds to complete one full cycle of playing and resting. Initially, at time 0, all instruments start playing simultaneously. How many seconds will pass until all the instruments play simultaneously again? -----Constraints----- - 1 ≤ N ≤ 100 ...
from math import gcd from functools import reduce def lcm(a, b): """ Returns the least common multiple of a and b. """ return (a * b) // gcd(a, b) def orchestra_sync_time(N, D): """ Returns the time in seconds after which all instruments will play simultaneously again. Args: N : i...
from solution import orchestra_sync_time def test_orchestra_sync_time_case_1(): assert orchestra_sync_time(3, [2, 4, 5]) == 20 def test_orchestra_sync_time_case_2(): assert orchestra_sync_time(1, [10]) == 10 def test_orchestra_sync_time_case_3(): assert orchestra_sync_time(4, [2, 3, 6, 8]) == 24 def tes...
[ { "docstring": "Returns the least common multiple of a and b.", "function_declaration": "def lcm(a, b):", "function_name": "lcm", "parameter_list": "(a, b)" }, { "docstring": "Returns the time in seconds after which all instruments will play simultaneously again.\n\nArgs:\nN : int : Number o...
[ 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\n\ndef lcm(a, b):\n \"\"\"\n Return the least common multiple of a and b.\n \"\"\"\n return abs(a * b) // math.gcd(a, b)\n\ndef find_time_u...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00053805", "row_id": 53805, "seed_ids": "[14889]" }
0.707614
Taco_53805
I
[ "lcm", "orchestra_sync_time" ]
2
[ [ "orchestra_sync_time", "lcm" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b61c8c3eb792fdf5554dbf1f899014a0a0ae100e
94ab31c709d592a03278c89e60a351fa698e966c
v1.0
instruct
Taco
Taco_53844_I
Mike is passionate about palindromic numbers. A palindromic number is a number that remains the same when its digits are reversed. For example, 121 is palindromic, but 123 is not. He wants to perform some palindromic checks. Given a range of numbers [A, B], compute the largest palindromic number that lies within this ...
def is_palindromic(n): """ Check if a number n is palindromic. """ s = str(n) return s == s[::-1] def largest_palindromic_number(A, B): """ Returns the largest palindromic number in the range [A, B]. """ largest = -1 for number in range(B, A - 1, -1): if is_palindromic(n...
import pytest from solution import is_palindromic, largest_palindromic_number, process_cases def test_is_palindromic(): assert is_palindromic(121) == True assert is_palindromic(123) == False assert is_palindromic(1) == True assert is_palindromic(22) == True def test_largest_palindromic_number(): a...
[ { "docstring": "Check if a number n is palindromic.", "function_declaration": "def is_palindromic(n):", "function_name": "is_palindromic", "parameter_list": "(n)" }, { "docstring": "Returns the largest palindromic number in the range [A, B].", "function_declaration": "def largest_palindr...
[ 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_palindromic(n):\n \"\"\"\n Check if a number is a palindrome.\n \"\"\"\n return str(n) == str(n)[::-1]\n\ndef largest_palindromic_in_range(A, B)...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00053844", "row_id": 53844, "seed_ids": "[22469]" }
0.751152
Taco_53844
I
[ "is_palindromic", "largest_palindromic_number", "process_cases" ]
3
[ [ "largest_palindromic_number", "is_palindromic" ], [ "process_cases", "largest_palindromic_number" ] ]
2
[ "process_cases" ]
false
[]
false
pytest
true
[]
true
8e97590c82834c5c7f789e01acce6b91efbcb4b3
894efdde72ab0a6e0feeb1e01b605a215d7d1e65
v1.0
instruct
Taco
Taco_53887_I
Alice has just learned about Fibonacci numbers and their properties. Now, Alice is curious about how to find the n-th Fibonacci number efficiently. She knows the naive recursive method is too slow for large values of n, so she's asked for your help in writing a program to compute the n-th Fibonacci number using a more...
MOD = 10**9 + 7 def matrix_mult(A, B, mod=MOD): """ 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...
from solution import fib_mod def test_sample_input(): assert fib_mod(10) == 55 def test_zero(): assert fib_mod(0) == 0 def test_one(): assert fib_mod(1) == 1 def test_large_number(): # Just some example, as checking the exact large value can be intricate # Using properties like patterns in Fibon...
[ { "docstring": "Multiplies two 2x2 matrices A and B under modulo mod.", "function_declaration": "def matrix_mult(A, B, mod=MOD):", "function_name": "matrix_mult", "parameter_list": "(A, B, mod=MOD)" }, { "docstring": "Performs matrix exponentiation on a 2x2 matrix under modulo mod to find ma...
[ 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": "MOD = 10**9 + 7\n\ndef matrix_mult(A, B):\n 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],\n [(A[1][...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00053887", "row_id": 53887, "seed_ids": "[4815]" }
0.665429
Taco_53887
I
[ "matrix_mult", "matrix_pow", "fibonacci", "fib_mod" ]
4
[ [ "fib_mod", "fibonacci" ], [ "fibonacci", "matrix_pow" ], [ "matrix_pow", "matrix_mult" ] ]
3
[]
false
[]
false
pytest
true
[]
true
717a8cabbfeb3111ea070e8dfa7f4f62bc2c4d9a
28f6c5a4c67d4c000c089596be1813b84f11be98
v1.0
instruct
Taco
Taco_54007_I
A delivery company is organizing a new route to deliver parcels more efficiently. The logistics team has the task of determining the shortest possible delivery path that visits each delivery location once and returns to the starting point. The delivery routes can be represented as an undirected graph where each node i...
from itertools import permutations def find_min_tsp_cost(n, distance_matrix): min_cost = float('inf') locations = list(range(n)) for perm in permutations(locations[1:]): current_path = [0] + list(perm) + [0] current_cost = 0 for i in range(len(current_path) - 1): ...
from solution import tsp_solver def test_tsp_example_1(): input_data = "4\n0 10 15 20\n10 0 35 25\n15 35 0 30\n20 25 30 0" assert tsp_solver(input_data) == 80 def test_tsp_example_2(): input_data = "3\n0 5 9\n5 0 7\n9 7 0" assert tsp_solver(input_data) == 21 def test_tsp_min_locations(): input_da...
[ { "docstring": null, "function_declaration": "def find_min_tsp_cost(n, distance_matrix):", "function_name": "find_min_tsp_cost", "parameter_list": "(n, distance_matrix)" }, { "docstring": null, "function_declaration": "def tsp_solver(input_data):", "function_name": "tsp_solver", ...
[ 0, 0, 0, 0, 0, 1, 0, 0, 0 ]
1
hard
0.111
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from itertools import permutations\n\ndef tsp(n, distances):\n # Generate all permutations of the nodes except the starting node (node 0)\n nodes = list(rang...
trial_gpt4o_6
{ "original_instruction": "", "prompt_id": "00054007", "row_id": 54007, "seed_ids": "[19313]" }
0.663499
Taco_54007
I
[ "find_min_tsp_cost", "tsp_solver" ]
2
[ [ "tsp_solver", "find_min_tsp_cost" ] ]
1
[]
false
[]
false
pytest
true
[]
true
24b7d3cce90a7e4cf638bb471d68b4f67ba663ee
1672109cb8a90a79de487e3d5a772bca03f1d9d0
v1.0
instruct
Taco
Taco_54085_I
A company has n employees, each with a unique ID from 1 to n. The company uses a hierarchy represented by a tree structure where each node corresponds to an employee and the root node (employee with ID 1) is the CEO. Each employee except the CEO has exactly one direct manager. The CEO of the company wants to send a m...
from collections import defaultdict, deque def build_tree(n, edges): tree = defaultdict(list) for u, v in edges: tree[u].append(v) tree[v].append(u) return tree def bfs(tree, start): parent = {start: None} depth = {start: 0} q = deque([start]) while q: node = q.popl...
from solution import message_time def test_message_time(): n = 7 edges = [(1, 2), (1, 3), (2, 4), (2, 5), (3, 6), (3, 7)] queries = [(4, 5), (6, 7), (4, 7)] result = message_time(n, edges, queries) assert result == [2, 2, 4] def test_message_time_single_employee(): n = 1 edges = [] que...
[ { "docstring": null, "function_declaration": "def build_tree(n, edges):", "function_name": "build_tree", "parameter_list": "(n, edges)" }, { "docstring": null, "function_declaration": "def bfs(tree, start):", "function_name": "bfs", "parameter_list": "(tree, start)" }, { ...
[ 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, deque\n\ndef build_tree(n, edges):\n tree = defaultdict(list)\n for u, v in edges:\n tree[u].append(v)\n t...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00054085", "row_id": 54085, "seed_ids": "[9872]" }
0.615375
Taco_54085
I
[ "build_tree", "bfs", "lca", "message_time" ]
4
[ [ "message_time", "bfs" ], [ "message_time", "build_tree" ], [ "message_time", "lca" ] ]
3
[]
false
[]
false
pytest
true
[]
true
4886d6255b02c21bdd1e6fbf21d19691e892d497
ac5e99e705f3e1b75bc5db2dd2081f287468ebba
v1.0
instruct
Taco
Taco_54089_I
Alan has recently learned about balanced binary trees and is excited to implement one. He wants to write a function that will take an array of integers and build a balanced binary search tree (BST) from it. Given the nature of arrays, he is instructed to first sort the array to facilitate the creation of the BST. Alan...
class TreeNode: """ A tree node that contains an integer value, and left and right children. """ def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def sorted_array_to_bst(arr): """ Given a sorted array of integers, creat...
from solution import create_balanced_bst, TreeNode def test_inorder_traversal(): def inorder_traversal(root): if not root: return [] return inorder_traversal(root.left) + [root.val] + inorder_traversal(root.right) bst = create_balanced_bst([3, 1, 2]) assert inorder_traversa...
[]
[ 1, 1, 1 ]
3
easy
1
{ "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 create_...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00054089", "row_id": 54089, "seed_ids": "[9008]" }
0.749092
Taco_54089
I
[ "sorted_array_to_bst", "create_balanced_bst" ]
2
[ [ "create_balanced_bst", "sorted_array_to_bst" ] ]
1
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
0ce20e1ad2b2ef7870b80fe24d8392e61c06b087
b44f2d7e038b4ca1d18ab45548cf8c6bfae4f92c
v1.0
instruct
Taco
Taco_54191_I
Sarah is passionate about palindromes. A palindrome is a string that reads the same forward and backward. She wants to create new strings by rearranging the characters of a given string to form a palindrome or determine if it is impossible. Your task is to help Sarah by constructing a palindrome from the given string ...
from collections import Counter def can_form_palindrome(s): """ Helper function to determine if a palindrome can be formed from the given string. """ counts = Counter(s) odd_count = sum(1 for count in counts.values() if count % 2 != 0) return odd_count <= 1 def construct_palindrome(s): """...
def test_construct_palindrome(): assert construct_palindrome("civic") == "civic" assert construct_palindrome("aabbcc") == "abccba" assert construct_palindrome("abc") == "Impossible" assert construct_palindrome("aaabbb") == "Impossible" assert construct_palindrome("aabb") == "abba" assert constru...
[ { "docstring": "Helper function to determine if a palindrome can be formed from the given string.", "function_declaration": "def can_form_palindrome(s):", "function_name": "can_form_palindrome", "parameter_list": "(s)" }, { "docstring": "Function to construct the lexicographically smallest p...
[ 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 smallest_palindrome(S):\n from collections import Counter\n\n count = Counter(S)\n middle = \"\"\n halves = []\n\n for char in sorted(count):\n ...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00054191", "row_id": 54191, "seed_ids": "[3857]" }
0.851197
Taco_54191
I
[ "can_form_palindrome", "construct_palindrome", "process_input" ]
3
[ [ "construct_palindrome", "can_form_palindrome" ], [ "process_input", "construct_palindrome" ] ]
2
[ "process_input" ]
false
[]
false
pytest
false
[]
true
2066b4842d3c42007a0c1ccec506a3c8ca78360b
681e4506f0bb6e839ce7e9a31c908480a9bb4364
v1.0
instruct
Taco
Taco_54262_I
You are given two binary trees. Write a program to check if they are mirrors of each other. A binary tree is symmetrical if the left subtree is a mirror reflection of the right subtree and vice versa. For example: 1 1 / \ / \ 2 3 3 2 / \ / \ 4 5 5 4 In this example...
class TreeNode: def __init__(self, val=0): self.val = val self.left = None self.right = None def buildTree(nodes): node_dict = {} for parent, left, right in nodes: if parent not in node_dict: node_dict[parent] = TreeNode(parent) if left != -1: ...
from solution import check_if_trees_are_mirrors def test_case_1(): n = 6 tree1 = [ (1, 2, 3), (2, 4, 5), (3, -1, -1), (4, -1, -1), (5, -1, -1), (-1, -1, -1) ] m = 6 tree2 = [ (1, 3, 2), (3, -1, -1), (2, 5, 4), (5, -1, -...
[]
[ 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": "class TreeNode:\n def __init__(self, val=0):\n self.val = val\n self.left = None\n self.right = None\n\ndef buildTree(nodes):\n node_dic...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00054262", "row_id": 54262, "seed_ids": "[14872]" }
0.605725
Taco_54262
I
[ "buildTree", "isMirror", "check_if_trees_are_mirrors" ]
3
[ [ "check_if_trees_are_mirrors", "buildTree" ], [ "check_if_trees_are_mirrors", "isMirror" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
093f79078721289c7d7117d8a6783e4882958bf3
f3983a8f7f14adab6d75b06efa71063086304ef8
v1.0
instruct
Taco
Taco_54290_I
You are given a grid with n rows and m columns. Each cell in the grid can be in one of two states: 0 or 1. A cell is considered "active" if it is state 1. Two cells are "neighbors" if they share a side. You need to write a program that finds the largest rectangle in the grid which contains only active cells, i.e., cel...
def max_histogram_area(histogram): stack = list() max_area = 0 index = 0 while index < len(histogram): if not stack or histogram[stack[-1]] <= histogram[index]: stack.append(index) index += 1 else: top_of_stack = stack.pop() area = (hi...
from solution import max_rectangle_area def test_example_1(): grid = [ "1010", "1011", "1111", "0011" ] assert max_rectangle_area(grid) == 6 def test_example_2(): grid = [ "111111", "110001", "111001", "111111", "100111", ...
[ { "docstring": null, "function_declaration": "def max_histogram_area(histogram):", "function_name": "max_histogram_area", "parameter_list": "(histogram)" }, { "docstring": null, "function_declaration": "def max_rectangle_area(grid):", "function_name": "max_rectangle_area", "param...
[ 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_histogram_area(histogram):\n stack = list()\n max_area = 0\n index = 0\n \n while index < len(histogram):\n if not stack or histogram...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00054290", "row_id": 54290, "seed_ids": "[12559]" }
0.67386
Taco_54290
I
[ "max_histogram_area", "max_rectangle_area" ]
2
[ [ "max_rectangle_area", "max_histogram_area" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9c6838c38fee7e3abfc37ff2cba4a87d25122ef4
66fb5ae531f4d3803a17954519d31eea1013b37d
v1.0
instruct
Taco
Taco_54296_I
In Mathland, a country with a rich tradition of numerical puzzles, the citizens celebrate the Festival of Primes. During this festival, a special game is played involving prime numbers and arrays. You are given an array of integers, and your task is to find the longest contiguous subarray such that each element in the ...
def is_prime(n): 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 i += 6 return True def longest_prime_subarray_length(arr): ma...
from solution import longest_prime_subarray_length def test_case_1(): assert longest_prime_subarray_length([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2 def test_case_2(): assert longest_prime_subarray_length([11, 13, 17, 4, 5, 6, 7]) == 3 def test_case_3(): assert longest_prime_subarray_length([4, 6, 8, 10, 12]...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def longest_prime_subarray_length(arr):", "function_name": "longest_prime_subarray_length", "parameter_list": "(a...
[ 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 sieve_of_eratosthenes(max_num):\n \"\"\"\n Returns a list of booleans indicating whether numbers from 0 to max_num are prime.\n \"\"\"\n is_prime =...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00054296", "row_id": 54296, "seed_ids": "[8996]" }
0.677165
Taco_54296
I
[ "is_prime", "longest_prime_subarray_length" ]
2
[ [ "longest_prime_subarray_length", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b8cc8df5a1a3318d955204c2c5103a8ecdd03ec3
330245c3dd26365f20779a4b904e6d4533587508
v1.0
instruct
Taco
Taco_54382_I
# Task You are given a list of strings where each string consists of lowercase English letters. Your task is to find the longest string in the list of strings that can be formed by concatenating the words from a given dictionary. You may use each word in the dictionary at most once. If no string can be formed, return ...
from typing import List def can_form(target: str, dictionary: List[str], memo: dict) -> bool: if target in memo: return memo[target] if target == "": return True for word in dictionary: if target.startswith(word): if can_form(target[len(word):], dictionary, memo): ...
from solution import longestConcatenation def test_example_case(): dictionary = ["a", "banana", "app", "appl", "ap", "apply", "apple"] strings = ["appleapp", "bananaapple", "aapplebanana", "banana"] assert longestConcatenation(strings, dictionary) == "aapplebanana" def test_no_possible_concatenation(): ...
[ { "docstring": null, "function_declaration": "def can_form(target, dictionary, memo):", "function_name": "can_form", "parameter_list": "(target, dictionary, memo)" }, { "docstring": null, "function_declaration": "def longestConcatenation(strings, dictionary):", "function_name": "long...
[ 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 typing import List\n\ndef can_form(target: str, dictionary: List[str], memo: dict) -> bool:\n if target in memo:\n return memo[target]\n if targe...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00054382", "row_id": 54382, "seed_ids": "[10914]" }
0.737578
Taco_54382
I
[ "can_form", "longestConcatenation" ]
2
[ [ "longestConcatenation", "can_form" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c62dafd86f22a7081540cd18e117109cc1eee191
3e0e745c924a800339d82dca5ee282ad5a8a3a29
v1.0
instruct
Taco
Taco_54405_I
You are given an integer N. Output an NxN matrix with values from 1 to N^2 arranged in such a way that it forms a "snake-like" pattern. Specifically, the matrix should be filled as follows: - Fill the first row from left to right. - Fill the second row from right to left. - Fill the third row from left to right. - Con...
def generate_snake_pattern_matrix(N): """ Generates an NxN matrix filled with numbers in a snake-like pattern. """ matrix = [] num = 1 for i in range(N): row = [] for j in range(N): row.append(num) num += 1 if i % 2 == 1: # if the row index is odd...
from solution import generate_snake_pattern_matrix, format_matrix, solve_snake_patterns def test_generate_snake_pattern_matrix(): assert generate_snake_pattern_matrix(2) == [[1, 2], [4, 3]] assert generate_snake_pattern_matrix(3) == [[1, 2, 3], [6, 5, 4], [7, 8, 9]] assert generate_snake_pattern_matrix(4) ...
[ { "docstring": "Generates an NxN matrix filled with numbers in a snake-like pattern.", "function_declaration": "def generate_snake_pattern_matrix(N):", "function_name": "generate_snake_pattern_matrix", "parameter_list": "(N)" }, { "docstring": "Formats the matrix to the required form where e...
[ 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 generate_snake_matrix(N):\n \"\"\"\n Generates a NxN matrix with values from 1 to N^2 arranged in a \"snake-like\" pattern.\n \"\"\"\n matrix = [[0...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00054405", "row_id": 54405, "seed_ids": "[5780]" }
0.756799
Taco_54405
I
[ "generate_snake_pattern_matrix", "format_matrix", "solve_snake_patterns" ]
3
[ [ "solve_snake_patterns", "format_matrix" ], [ "solve_snake_patterns", "generate_snake_pattern_matrix" ] ]
2
[]
false
[]
false
pytest
true
[]
true
917211b12d9c9a4f0f0104c13515348d9b57b825
9d961e9f30ebebe8c6bf8c546bd1eb5c3a702533
v1.0
instruct
Taco
Taco_54461_I
A company wants to host a meeting where employees are seated around a circular table. Each employee shakes hands with exactly one other employee to form a pair. Determine the maximum number of handshakes that can happen such that no two handshakes cross each other. For example, if there are 4 employees (N=4), there ar...
def catalan_number(n): """ Return the nth Catalan number. This function uses a dynamic programming approach. """ if n == 0: return 1 dp = [0] * (n + 1) dp[0], dp[1] = 1, 1 for i in range(2, n + 1): for j in range(i): dp[i] += dp[j] * dp[i - j - 1] re...
def test_catalan_number(): assert catalan_number(0) == 1 assert catalan_number(1) == 1 assert catalan_number(2) == 2 assert catalan_number(3) == 5 assert catalan_number(4) == 14 assert catalan_number(5) == 42 def test_max_non_crossing_handshakes(): assert max_non_crossing_handshakes(4) == 2...
[ { "docstring": "Return the nth Catalan number. This function uses a dynamic programming approach.", "function_declaration": "def catalan_number(n):", "function_name": "catalan_number", "parameter_list": "(n)" }, { "docstring": "Return the maximum number of non-crossing handshakes for N emplo...
[ 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 count_non_crossing_handshakes(N):\n \"\"\"\n Returns the maximum number of non-crossing handshakes possible for N employees.\n This problem is related...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00054461", "row_id": 54461, "seed_ids": "[494]" }
0.633447
Taco_54461
I
[ "catalan_number", "max_non_crossing_handshakes", "solve" ]
3
[ [ "max_non_crossing_handshakes", "catalan_number" ], [ "solve", "max_non_crossing_handshakes" ] ]
2
[]
false
[]
false
pytest
false
[]
true
6eec41a98cdff45c12e8444cdc336cf55edeb884
b59be13494807caedd38bed354310847466d17c1
v1.0
instruct
Taco
Taco_54485_I
A small town has a peculiar tradition of building bonfires every weekend. The townsfolk arrange the wood pieces in a particular pattern: they form a number of rectangular blocks where each block can be described by its width, height, and number of wood pieces. At the end of the arrangement, they closely monitor the sur...
def is_stable(arrangement): """ Determine if the arrangement of blocks is stable. Parameters: arrangement (list of tuples): Each tuple represents (width_i, height_i, number_i). Returns: str: "Stable" if all blocks are sufficiently supported, "Unstable" otherwise. """ fo...
from solution import check_arrangement def test_example_1(): N = 3 blocks = [(3, 2, 9), (2, 1, 4), (5, 4, 25)] assert check_arrangement(N, blocks) == "Stable" def test_example_2(): N = 2 blocks = [(3, 3, 9), (4, 2, 5)] assert check_arrangement(N, blocks) == "Unstable" def test_single_block_st...
[ { "docstring": "Determine if the arrangement of blocks is stable.\n\nParameters:\n arrangement (list of tuples): Each tuple represents (width_i, height_i, number_i).\n\nReturns:\n str: \"Stable\" if all blocks are sufficiently supported, \"Unstable\" otherwise.", "function_declaration": "def is_stable...
[ 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_stable(arrangement):\n \"\"\"\n Determines if the arrangement of blocks is stable.\n \n Parameters:\n arrangement (list of tuples): List of t...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00054485", "row_id": 54485, "seed_ids": "[10393]" }
0.613622
Taco_54485
I
[ "is_stable", "check_arrangement" ]
2
[ [ "check_arrangement", "is_stable" ] ]
1
[]
false
[]
false
pytest
true
[]
true
27f211d9981ba027cc624ddac9e76866977a8658
bb190ea9a697189f9dd236aa2797f71b6c6d5fac
v1.0
instruct
Taco
Taco_54503_I
Given a list of words, you are required to determine the longest word that can be constructed using letters of another word. A word can be constructed when each letter in the word appears in the source word at least as many times as it appears in the original word. Constraints: 1 ≤ source_word length ≤ 100 1 ≤ n ≤ 20...
def can_construct(word, source_word): """ Check if 'word' can be constructed from 'source_word' by ensuring each character in 'word' is present in 'source_word' with at least the same frequency. """ from collections import Counter word_count = Counter(word) source_count = Counter(source_wor...
from solution import can_construct, find_longest_constructible_word def test_can_construct(): assert can_construct("apple", "abppplee") == True assert can_construct("able", "abppplee") == True assert can_construct("ale", "abppplee") == True assert can_construct("bale", "abppplee") == True assert ca...
[ { "docstring": "Check if 'word' can be constructed from 'source_word' by ensuring each character in 'word' is present in 'source_word' \nwith at least the same frequency.", "function_declaration": "def can_construct(word, source_word):", "function_name": "can_construct", "parameter_list": "(word, so...
[ 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_construct_from_source(source_word, word):\n \"\"\"\n Checks if a word can be constructed from the source word\n \"\"\"\n source_count = {}\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00054503", "row_id": 54503, "seed_ids": "[23866]" }
0.676488
Taco_54503
I
[ "can_construct", "find_longest_constructible_word" ]
2
[ [ "find_longest_constructible_word", "can_construct" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a396ea7d6024dfce61ce93bb7e0f90fa5e4c58c5
a33ec742f0cce040f6958c5c3f3132978b249b4b
v1.0
instruct
Taco
Taco_54511_I
Given an array of n integers, you need to answer q queries. Each query consists of two integers l and r, and you are required to find the sum of the elements between the l-th and r-th index in the array (both inclusive). The array is 1-indexed. ------ Input Format ------ - The first line contains two integers n and q...
def preprocess_prefix_sum(arr): """ Given a list of integers, returns a list where each index i contains the sum of elements from the beginning up to index i of the input list. """ n = len(arr) prefix_sum = [0] * (n + 1) for i in range(1, n + 1): prefix_sum[i] = prefix_sum[i - 1] + a...
def test_preprocess_prefix_sum(): arr = [1, 2, 3, 4, 5] expected_prefix_sum = [0, 1, 3, 6, 10, 15] assert preprocess_prefix_sum(arr) == expected_prefix_sum def test_range_sum_query(): prefix_sum = [0, 1, 3, 6, 10, 15] assert range_sum_query(prefix_sum, 1, 3) == 6 assert range_sum_query(prefix_s...
[ { "docstring": "Given a list of integers, returns a list where each index i contains\nthe sum of elements from the beginning up to index i of the input list.", "function_declaration": "def preprocess_prefix_sum(arr):", "function_name": "preprocess_prefix_sum", "parameter_list": "(arr)" }, { ...
[ 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 prefix_sums(arr):\n \"\"\"\n Helper function to compute prefix sums of the given array.\n \"\"\"\n n = len(arr)\n prefix = [0] * (n + 1)\n fo...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00054511", "row_id": 54511, "seed_ids": "[6573]" }
0.762131
Taco_54511
I
[ "preprocess_prefix_sum", "range_sum_query", "process_queries" ]
3
[ [ "process_queries", "preprocess_prefix_sum" ], [ "process_queries", "range_sum_query" ] ]
2
[ "process_queries" ]
false
[]
false
pytest
false
[]
true
f43ff75f919baa1231bc5f0c46df69919a4ef0c5
02512e9d2bde00de9629aa0bc7d44b5aa517974b
v1.0
instruct
Taco
Taco_54546_I
You have a string $s$ containing lowercase alphabetical characters and at most $10^5$ characters long. You are given two integers, $m$ and $n$. Your task is to determine if you can form a substring of $s$ that can be rearranged to become a palindrome after removing at most $m$ characters and adding at most $n$ characte...
from collections import Counter def can_form_palindrome(s, m, n): """ Determines if a substring of s can be rearranged to become a palindrome after removing at most m characters and adding at most n characters. """ freq = Counter(s) odd_count = sum(1 for count in freq.values() if count % 2 == 1...
from solution import solve def test_example_1(): assert solve("abac 1 1") == "YES" def test_example_2(): assert solve("abcde 1 1") == "NO" def test_no_modifications_needed(): assert solve("racecar 0 0") == "YES" def test_single_character(): assert solve("a 0 0") == "YES" def test_exactly_needs_one_...
[ { "docstring": "Determines if a substring of s can be rearranged to become a palindrome after removing\nat most m characters and adding at most n characters.", "function_declaration": "def can_form_palindrome(s, m, n):", "function_name": "can_form_palindrome", "parameter_list": "(s, m, n)" }, { ...
[ 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 Counter\n\ndef can_form_palindrome(s, m, n):\n \"\"\"\n Determines if a substring of s can be rearranged to become a palindrome after...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00054546", "row_id": 54546, "seed_ids": "[22024]" }
0.823294
Taco_54546
I
[ "can_form_palindrome", "solve" ]
2
[ [ "solve", "can_form_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7ce0c423efc55fbcd52988f6cc09a5e035406c0d
1485644a4cf1e98b7e168c94c2d44045e71c7da3
v1.0
instruct
Taco
Taco_54590_I
A treasure hunt game involves $n$ adventurers and $n$ treasures distributed across a grid. The grid can be described as a set of $n \times n$ cells. Each adventurer is located in a unique cell, and each treasure is hidden in a unique cell. The goal is for every adventurer to collect exactly one treasure, minimizing th...
from itertools import permutations def calculate_min_distance(adventurers, treasures): n = len(adventurers) min_distance = float('inf') for perm in permutations(treasures): distance = sum(abs(adventurers[i][0] - perm[i][0]) + abs(adventurers[i][1] - perm[i][1]) for i in range(n)) min_distan...
def test_parse_input(): input_str = "2\n2\n1 1\n2 2\n1 2\n2 1\n3\n1 2\n2 1\n3 3\n1 1\n2 2\n3 1\n" expected_output = [ ([(1, 1), (2, 2)], [(1, 2), (2, 1)]), ([(1, 2), (2, 1), (3, 3)], [(1, 1), (2, 2), (3, 1)]) ] assert parse_input(input_str) == expected_output def test_min_total_distance...
[ { "docstring": null, "function_declaration": "def calculate_min_distance(adventurers, treasures):", "function_name": "calculate_min_distance", "parameter_list": "(adventurers, treasures)" }, { "docstring": null, "function_declaration": "def min_total_distance(test_cases):", "function...
[ 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": "from itertools import permutations\n\ndef min_total_energy(t, test_cases):\n results = []\n for i in range(t):\n n = test_cases[i][0]\n adventu...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00054590", "row_id": 54590, "seed_ids": "[19080]" }
0.678777
Taco_54590
I
[ "calculate_min_distance", "min_total_distance", "parse_input" ]
3
[ [ "min_total_distance", "calculate_min_distance" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
62309c2c12d30513400b8c6cccf7a4c3ddf23392
b808181c6c6d3ce4991681130cef8a8eec31bfca
v1.0
instruct
Taco
Taco_54625_I
# Prime Sum Pairs Write function `prime_sum_pairs` (or `primeSumPairs`/`PrimeSumPairs` depending on language rules) that, given integer number `M` (in range `2..50`), returns an array of integers `1..M` arranged in a way, so the sum of each pair of adjacent numbers is a prime number. A valid solution must satisfy the...
from itertools import permutations def is_prime(n): """Check if a number is prime.""" if n <= 1: return False for i in range(2, int(n**0.5) + 1): if n % i != 0: continue else: return False return True def prime_sum_pairs(M): """Return an arrangement ...
from solution import prime_sum_pairs def test_prime_sum_pairs_valid_example(): M = 10 result = prime_sum_pairs(M) expected = [2, 1, 4, 3, 8, 5, 6, 7, 10, 9] assert sorted(result) == sorted(expected) assert all(is_prime(result[i] + result[(i + 1) % M]) for i in range(M)) def test_prime_sum_pairs_no...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Return an arrangement of numbers 1..M such that the sum of each pair of adjacent numbers is prime.", "function_declaration": "...
[ 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": "from itertools import permutations\nfrom sympy import isprime\n\ndef prime_sum_pairs(M):\n def is_valid_permutation(perm):\n for i in range(M):\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00054625", "row_id": 54625, "seed_ids": "[22003]" }
0.706252
Taco_54625
I
[ "is_prime", "prime_sum_pairs" ]
2
[ [ "prime_sum_pairs", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
189760a494e64554d1bcb8a369896455975776b2
50d476e94b170f2f01649eabe0a72fc4b6a6b34c
v1.0
instruct
Taco
Taco_54645_I
# Task **_Given_** two **_positive integers a and b_**, find the smallest integer N, such that: - **_N_** is *divisible by both a and b* - **_N_** is *greater than or equal to the least common multiple (LCM) of a and b*. ___ # Notes * The **_parameters (a, b)_** passed to the function are *only positive values*. ...
from math import gcd def lcm(a, b): """ Returns the least common multiple (LCM) of a and b. """ return a * b // gcd(a, b) def minMultiple(a, b): """ Returns the smallest integer N such that: - N is divisible by both a and b - N is greater than or equal to the least common multiple (LCM...
from solution import minMultiple def test_min_multiple_example_1(): assert minMultiple(6, 8) == 24 def test_min_multiple_example_2(): assert minMultiple(5, 15) == 15 def test_min_multiple_example_3(): assert minMultiple(7, 3) == 21 def test_min_multiple_prime_numbers(): assert minMultiple(13, 17) ==...
[ { "docstring": "Returns the least common multiple (LCM) of a and b.", "function_declaration": "def lcm(a, b):", "function_name": "lcm", "parameter_list": "(a, b)" }, { "docstring": "Returns the smallest integer N such that:\n- N is divisible by both a and b\n- N is greater than or equal to t...
[ 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 math import gcd\n\ndef min_multiple(a, b):\n \"\"\"\n Returns the smallest integer N that is divisible by both a and b, and\n is at least greater tha...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00054645", "row_id": 54645, "seed_ids": "[1167]" }
0.674532
Taco_54645
I
[ "lcm", "minMultiple" ]
2
[ [ "minMultiple", "lcm" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ec54b2fdc0e143a0a5844b18d58e8bf8c2f42774
b12b84d157a0f9b7d7dda58244026163f106754a
v1.0
instruct
Taco
Taco_54659_I
You are given a grid with $n$ rows and $m$ columns, containing positive integers in each cell. The task is to perform the following queries on the grid: Type 1. Given four integers $\boldsymbol{x_1}$, $\boldsymbol{y_1}$, $\boldsymbol{x_2}$, and $\boldsymbol{y_2}$ $(1 \leq x_1 \leq x_2 \leq n, 1 \leq y_1 \leq y_2 \leq ...
def perform_queries(n, m, grid, queries): """ Performs the given queries on the grid. Args: n : int : number of rows in the grid m : int : number of columns in the grid grid : list of list of int : the grid with its initial values queries : list of tuple : the queries to be performed ...
from solution import perform_queries, find_max, increment_values def test_sample_input(): n = 4 m = 4 grid = [ [1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16] ] queries = [ (1, 1, 1, 3, 3), (2, 2, 2, 4, 4), (1, 1, 1, 4, 4) ] ...
[ { "docstring": "Performs the given queries on the grid.\n\nArgs:\nn : int : number of rows in the grid\nm : int : number of columns in the grid\ngrid : list of list of int : the grid with its initial values\nqueries : list of tuple : the queries to be performed\n\nReturns:\nlist of int : results for each type 1...
[ 1, 0 ]
1
medium
0.5
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared1_results_combined.jsonl", "solution_code": "def perform_queries(n, m, grid, queries):\n \"\"\"\n Performs the given queries on the grid.\n \n Args:\n n : int : number ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00054659", "row_id": 54659, "seed_ids": "[9579]" }
0.740854
Taco_54659
I
[ "perform_queries", "find_max", "increment_values" ]
3
[ [ "perform_queries", "find_max" ], [ "perform_queries", "increment_values" ] ]
2
[]
false
[]
false
pytest
true
[]
true
63d14584d833d1001ec7653af30ad0933ee08adc
d4b77560918b58d60d8a0484888318fac6de843b
v1.0
instruct
Taco
Taco_54681_I
Alex is given an array of positive integers a1, a2, ..., an and he wants to split this array into exactly k non-empty contiguous subarrays such that the maximum possible sum of the subarrays is minimized. Help Alex find the minimized maximum sum of the subarrays. -----Input----- The first line contains two integers n...
def splitArray(nums, k): """ This function determines the minimized maximum sum of the subarrays. """ def can_split(nums, max_sum, k): current_sum = 0 subarrays = 1 for num in nums: if current_sum + num > max_sum: subarrays += 1 curren...
from solution import minimizedMaximumSum def test_example1(): assert minimizedMaximumSum(5, 2, [1, 2, 3, 4, 5]) == 9 def test_example2(): assert minimizedMaximumSum(7, 3, [1, 2, 3, 4, 5, 6, 7]) == 11 def test_single_element(): assert minimizedMaximumSum(1, 1, [10]) == 10 def test_all_equal_elements(): ...
[ { "docstring": "This function determines the minimized maximum sum of the subarrays.", "function_declaration": "def splitArray(nums, k):", "function_name": "splitArray", "parameter_list": "(nums, k)" }, { "docstring": null, "function_declaration": "def minimizedMaximumSum(n, k, array):",...
[ 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 splitArray(nums, k):\n \"\"\"\n This function determines the minimized maximum sum of the subarrays.\n \"\"\"\n def can_split(nums, max_sum, k):\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00054681", "row_id": 54681, "seed_ids": "[20237]" }
0.784027
Taco_54681
I
[ "splitArray", "minimizedMaximumSum" ]
2
[ [ "minimizedMaximumSum", "splitArray" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f90c8b18af11166dc6df245fe8ce2f08a58193bb
c9a70af7198e82a5a65e783f1f858775dd6d466a
v1.0
instruct
Taco
Taco_54699_I
You are given an undirected graph with N vertices labeled from 1 to N and M edges, where each edge forms a direct connection between two distinct vertices A and B. Each vertex represents a city, and each edge represents a road. Your task is to determine the minimum number of roads that need to be added to make the gra...
def find(parent, i): if parent[i] == i: return i else: parent[i] = find(parent, parent[i]) return parent[i] def union(parent, rank, x, y): rootX = find(parent, x) rootY = find(parent, y) if rootX != rootY: if rank[rootX] > rank[rootY]: parent[rootY] = ro...
def test_minimum_roads_to_connect(): assert minimum_roads_to_connect(6, 4, [(1, 2), (2, 3), (4, 5), (5, 6)]) == 1 assert minimum_roads_to_connect(3, 0, []) == 2 # No edges, 3 disconnected vertices assert minimum_roads_to_connect(4, 2, [(1, 2), (3, 4)]) == 1 # Two components assert minimum_roads_to_con...
[ { "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 parent[i] = find(parent, parent[i])\n return parent[i]\n\ndef union(paren...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00054699", "row_id": 54699, "seed_ids": "[20391]" }
0.731314
Taco_54699
I
[ "find", "union", "minimum_roads_to_connect" ]
3
[ [ "minimum_roads_to_connect", "find" ], [ "minimum_roads_to_connect", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
false
[]
true
ade3b2550f6f82bdd9e8202ac244cc9a5b0d28d5
6702b036ebaa425b6ecc8f07c4ecae37c7f2d38d
v1.0
instruct
Taco
Taco_54722_I
You are given a string containing a sequence of characters. Your task is to write a program that generates all possible permutations of the string and filters the permutations to provide only those that are valid palindromes. A palindrome is a sequence that reads the same backward as forward, such as "level" or "radar...
from itertools import permutations def is_palindrome(s): """Check if the string s is a palindrome.""" return s == s[::-1] def generate_palindrome_permutations(s): """Generate all unique palindrome permutations of the string s.""" unique_permutations = set(permutations(s)) palindrome_permutations =...
from solution import is_palindrome, generate_palindrome_permutations def test_is_palindrome(): assert is_palindrome("abba") == True assert is_palindrome("abcba") == True assert is_palindrome("abcd") == False assert is_palindrome("a") == True assert is_palindrome("aa") == True def test_generate_pal...
[ { "docstring": "Check if the string s is a palindrome.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": "Generate all unique palindrome permutations of the string s.", "function_declaration": "def generate_pali...
[ 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 itertools import permutations\n\ndef is_palindrome(s):\n return s == s[::-1]\n\ndef generate_palindrome_permutations(input_str):\n perms = set(permutati...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00054722", "row_id": 54722, "seed_ids": "[6612]" }
0.772854
Taco_54722
I
[ "is_palindrome", "generate_palindrome_permutations" ]
2
[ [ "generate_palindrome_permutations", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
cfc78a9729930db3b2fa19c4554c81c8d3be5339
75b63e0cec17eb2d1ef2371930f71a9789fddf44
v1.0
instruct
Taco
Taco_54725_I
You are given Q queries, where each query consists of an integer X. For each query, determine the number of distinct pairs [a, b] (a ≤ b) such that a and b satisfy the following conditions: * a and b are both prime numbers. * a + b is equal to X. Input format: The input is given in the following format: Q X_1 X_...
def sieve(limit): """ Generate a list of boolean values indicating whether numbers from `0` to `limit` are prime. """ is_prime = [True] * (limit + 1) is_prime[0] = is_prime[1] = False for num in range(2, int(limit**0.5) + 1): if is_prime[num]: for multiple in range(num*num, l...
from solution import solution def test_solution(): queries = [10, 6, 8] expected = [2, 1, 1] assert solution(queries) == expected def test_solution_with_large_inputs(): queries = [100, 50, 90, 92, 1000, 10000] # We will not specify the expected result for each query manually. This is more of a str...
[ { "docstring": "Generate a list of boolean values indicating whether numbers from `0` to `limit` are prime.", "function_declaration": "def sieve(limit):", "function_name": "sieve", "parameter_list": "(limit)" }, { "docstring": "Count the number of distinct pairs of prime numbers (a, b) such ...
[ 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_of_eratosthenes(n):\n sieve = [True] * (n+1)\n p = 2\n while (p * p <= n):\n if (sieve[p] == True):\n for i in range(p * p, n+...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00054725", "row_id": 54725, "seed_ids": "[18496]" }
0.671072
Taco_54725
I
[ "sieve", "prime_pairs_count", "solution" ]
3
[ [ "solution", "prime_pairs_count" ], [ "solution", "sieve" ] ]
2
[]
false
[]
false
pytest
true
[]
true
218574ed15f017a57c34be1842951be2b25b690e
7fc9520524e66ffab0503927996606dedf72fa3b
v1.0
instruct
Taco
Taco_54740_I
You are given a binary tree where each node has an integer value. Your task is to write a function to find the maximum path sum. A path in a binary tree is a series of connected nodes where each node can only be visited once, and it does not need to pass through the root. The path sum is the sum of the values of the n...
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def build_tree(nested_list): if not nested_list: return None node = TreeNode(nested_list[0]) if len(nested_list) > 1 and nested_list[1]: node.left...
from solution import find_max_path_sum def test_max_path_sum_simple(): tree = [1, [2, [4], [5]], [3, [6], [7]]] assert find_max_path_sum(tree) == 18 def test_max_path_sum_with_negative(): tree = [-10, [9], [20, [15], [7]]] assert find_max_path_sum(tree) == 42 def test_max_path_sum_single_node(): ...
[]
[ 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 TreeNode:\n def __init__(self, x):\n self.val = x\n self.left = None\n self.right = None\n\ndef build_tree(lst):\n \"\"\"\n Bui...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00054740", "row_id": 54740, "seed_ids": "[11551]" }
0.620933
Taco_54740
I
[ "build_tree", "max_path_sum", "find_max_path_sum" ]
3
[ [ "find_max_path_sum", "build_tree" ], [ "find_max_path_sum", "max_path_sum" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
16d08d8eac21bb082546a015e7b63538d54fd04f
0ba442cf24ed7ef83f356837b3da802350854568
v1.0
instruct
Taco
Taco_54825_I
In a distant land, there is a unique and magical tree with n nodes and n-1 edges, forming a tree structure. Each node represents a village, and each edge represents a direct path between two villages. The tree is rooted at node 1, and each node has a unique identifier from 1 to n. The villagers want to determine the d...
def calculate_depths(n, edges): from collections import deque, defaultdict # Create an adjacency list for the tree tree = defaultdict(list) for u, v in edges: tree[u].append(v) tree[v].append(u) # BFS to calculate depths depths = [-1] * (n + 1) queue = deque([(1, 0)...
from solution import tree_depths def test_tree_depths_example(): n = 5 edges_input = [ "1 2", "1 3", "3 4", "3 5" ] assert tree_depths(n, edges_input) == [0, 1, 1, 2, 2] def test_tree_depths_single_node(): n = 1 edges_input = [] assert tree_depths(n, edges_i...
[ { "docstring": null, "function_declaration": "def calculate_depths(n, edges):", "function_name": "calculate_depths", "parameter_list": "(n, edges)" }, { "docstring": null, "function_declaration": "def tree_depths(n, edges_input):", "function_name": "tree_depths", "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": "from collections import defaultdict, deque\n\ndef find_node_depths(n, edges):\n def bfs_depth(root):\n depths = [-1] * (n + 1)\n queue = deque([ro...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00054825", "row_id": 54825, "seed_ids": "[11455]" }
0.6518
Taco_54825
I
[ "calculate_depths", "tree_depths" ]
2
[ [ "tree_depths", "calculate_depths" ] ]
1
[]
false
[]
false
pytest
true
[]
true
af761fdde0a6c496dc467a18045ffefa22f517ca
9479bd25ad34ce1764f864bc864a4ab37a9d727b
v1.0
instruct
Taco
Taco_54858_I
The game of Spelling Bee is very popular in a small town. The town organizes it every year for all the students. This year, the rules are a bit different. Each student is given a word and they are asked to perform the following operations: * Replace every vowel ('a', 'e', 'i', 'o', 'u') in the word with a next conso...
def is_palindrome(word): return word == word[::-1] def modify_word(word): next_consonant = { 'a': 'b', 'e': 'f', 'i': 'j', 'o': 'p', 'u': 'v' } prev_consonant = { 'b': 'a', 'c': 'b', 'd': 'c', 'f': 'e', 'g': 'f', 'h': 'g', 'j': 'i', 'k': 'j', 'l': 'k', 'm': 'l', 'n': 'm', 'p': ...
from solution import spelling_bee def test_spelling_bee_example1(): assert spelling_bee("student14") == "Lose" def test_spelling_bee_example2(): assert spelling_bee("m@d@m") == "Win" def test_spelling_bee_special_characters(): assert spelling_bee("!@#$$#@!") == "Win" def test_spelling_bee_digits(): ...
[ { "docstring": null, "function_declaration": "def is_palindrome(word):", "function_name": "is_palindrome", "parameter_list": "(word)" }, { "docstring": null, "function_declaration": "def modify_word(word):", "function_name": "modify_word", "parameter_list": "(word)" }, { ...
[ 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 transform_word(word):\n def next_consonant(c):\n vowels = 'aeiou'\n alphabet = 'abcdefghijklmnopqrstuvwxyz'\n if c == 'u':\n ...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00054858", "row_id": 54858, "seed_ids": "[6982]" }
0.673653
Taco_54858
I
[ "is_palindrome", "modify_word", "spelling_bee" ]
3
[ [ "spelling_bee", "is_palindrome" ], [ "spelling_bee", "modify_word" ] ]
2
[]
false
[]
false
pytest
true
[]
true
df0481d7c45c100e9dbaa249c9c85baf6df2c070
1b1493ae0ea4f3696fec2e97c29f96482122f515
v1.0
instruct
Taco
Taco_54870_I
There is an undirected graph with N nodes and M edges. Each edge has a weight associated with it. You are initially at node 1 and want to reach node N, but at each step, you can only move to an adjacent node if the weight of the edge connecting to that node is a prime number. Determine the minimum number of edges you n...
import math import collections def is_prime(num): if num <= 1: return False if num == 2: return True if num % 2 == 0: return False limit = int(math.sqrt(num)) + 1 for i in range(3, limit, 2): if num % i == 0: return False return True def find_min_edg...
import pytest from solution import process_test_cases def test_case_1(): test_cases = [ [ (5, 5), (1, 2, 3), (1, 3, 4), (2, 4, 5), (3, 5, 7), (4, 5, 11), ], [ (3, 3), (1, 2, 6), (2, ...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def find_min_edges(N, M, edges):", "function_name": "find_min_edges", "parameter_list": "(N, M, edges)" }, ...
[ 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 deque, defaultdict\nimport math\n\ndef is_prime(n):\n \"\"\"Check if a number is prime.\"\"\"\n if n <= 1:\n return False\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00054870", "row_id": 54870, "seed_ids": "[11788]" }
0.76768
Taco_54870
I
[ "is_prime", "find_min_edges", "process_test_cases" ]
3
[ [ "find_min_edges", "is_prime" ], [ "process_test_cases", "find_min_edges" ] ]
2
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
ae2d9aa95b2e8d7998257596004c46cc9ff0f67a
516e9016c2a477de573d0f5e9245a4339c11a6c6
v1.0
instruct
Taco
Taco_54880_I
A large company has multiple offices spread across different cities. Each office has a set of employees working there. The company wants to improve its communication network between the offices by establishing a minimum number of direct communication lines (connections) such that any employee in the company can communi...
def kruskal_minimum_spanning_tree(n, connections): parent = list(range(n)) rank = [0] * n def find(x): if parent[x] != x: parent[x] = find(parent[x]) return parent[x] def union(x, y): rootX = find(x) rootY = find(y) if rootX != rootY: if ...
import pytest from solution import find_minimum_total_distance def test_example1(): n = 4 m = 5 connections = [ (1, 2, 3), (1, 3, 1), (1, 4, 4), (2, 4, 2), (3, 4, 5) ] assert find_minimum_total_distance(n, m, connections) == 6 def test_example2(): n = 3 ...
[ { "docstring": null, "function_declaration": "def kruskal_minimum_spanning_tree(n, connections):", "function_name": "kruskal_minimum_spanning_tree", "parameter_list": "(n, connections)" }, { "docstring": null, "function_declaration": "def find_minimum_total_distance(n, m, connections):",...
[ 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 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_1
{ "original_instruction": "", "prompt_id": "00054880", "row_id": 54880, "seed_ids": "[15754]" }
0.702039
Taco_54880
I
[ "kruskal_minimum_spanning_tree", "find_minimum_total_distance" ]
2
[ [ "find_minimum_total_distance", "kruskal_minimum_spanning_tree" ] ]
1
[]
false
[]
false
pytest
true
[]
true
32d12e3aa7d532d644d49b71e215eb295453f826
8e89bb39aff2248946d7703e868e6d551cb1829c
v1.0
instruct
Taco
Taco_54949_I
Given an array A of N integers, write a program to find the smallest positive integer that is missing from the array. Your solution should have a time complexity of O(n) and utilize constant space. Example 1: Input: Arr[] = {3, 4, -1, 1} Output: 2 Explanation: The smallest positive integer missing from the array is 2....
def findMissing(arr, n): """ Returns the smallest positive integer missing from the array. Args: arr: list of integers. n: size of the array. Returns: Smallest positive integer missing. """ # Move all the non-positive numbers to the left side of the array # and the pos...
def test_findMissing(): assert findMissing([3, 4, -1, 1], 4) == 2 assert findMissing([1, 2, 0], 3) == 3 assert findMissing([7, 8, 9, 11, 12], 5) == 1 assert findMissing([2, 3, 4, -1, -2, 0, 1], 7) == 5 assert findMissing([-5, -1, -2, -3], 4) == 1 assert findMissing([0, 2, 2, 1, 1], 5) == 3 def ...
[ { "docstring": "Returns the smallest positive integer missing from the array.\n\nArgs:\narr: list of integers.\nn: size of the array.\n\nReturns:\nSmallest positive integer missing.", "function_declaration": "def findMissing(arr, n):", "function_name": "findMissing", "parameter_list": "(arr, 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 findMissing(arr):\n \"\"\"\n Returns the smallest positive integer that is missing from the array.\n \"\"\"\n n = len(arr)\n \n # Step 1: Mov...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00054949", "row_id": 54949, "seed_ids": "[12720]" }
0.691021
Taco_54949
I
[ "findMissing", "partition", "findMissingPositive" ]
3
[ [ "findMissing", "findMissingPositive" ], [ "findMissing", "partition" ] ]
2
[]
false
[]
false
pytest
false
[]
true
6beedc92149a10e15ee177b67b47c37cc783e640
f87163c535b1b1e2bba5f67177aff57ea287d11b
v1.0
instruct
Taco
Taco_54995_I
A chef is designing a new dish and needs to perfectly balance the taste by mixing exactly a certain amount of two ingredients, A and B. The ingredients are available in packets of different weights. The chef needs to know if it is possible to measure out exactly the desired amount of both ingredients using any combinat...
def can_measure_out(ingredient_weights, target_weight): """ Determine if the target weight can be achieved using any combination of given weights. This is a variation of the subset sum problem. """ dp = [False] * (target_weight + 1) dp[0] = True for weight in ingredient_weights: for...
from solution import can_measure_out, can_balance_taste, parse_input, main def test_can_measure_out(): assert can_measure_out([1, 3, 5], 6) == True # 1+5 or 3+3 assert can_measure_out([2, 4], 6) == True # 2+4 assert can_measure_out([2, 4], 7) == False # impossible def test_can_balance_taste(): t...
[ { "docstring": "Determine if the target weight can be achieved using any combination of given weights.\nThis is a variation of the subset sum problem.", "function_declaration": "def can_measure_out(ingredient_weights, target_weight):", "function_name": "can_measure_out", "parameter_list": "(ingredie...
[ 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 can_measure(weights, target):\n \"\"\"\n Determines if we can make the exact target weight using any combination of the given weights.\n :param weight...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00054995", "row_id": 54995, "seed_ids": "[7239]" }
0.749818
Taco_54995
I
[ "can_measure_out", "can_balance_taste", "parse_input", "main" ]
4
[ [ "can_balance_taste", "can_measure_out" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
6e86b6946742044e47a4237ebc1d3400f83b39f6
cd96d8508ce895172d5b0fba7be73c846b0475ef
v1.0
instruct
Taco
Taco_55002_I
You are given a string `s` consisting of lowercase Latin letters and a list of strings `words`. Let's call a string in `words` a subsequence of `s` if it can be derived by deleting some (possibly zero) characters from `s` without changing the order of the remaining characters. Find the length of the longest string in...
def is_subsequence(s, word): """ Check if 'word' is a subsequence of 's'. """ it = iter(s) return all(char in it for char in word) def longest_subseq_length(s, words): """ Returns the length of the longest string in 'words' that is a subsequence of 's'. """ max_length = 0 for wo...
from solution import is_subsequence, longest_subseq_length, solve def test_is_subsequence(): assert is_subsequence("abpcplea", "apple") assert not is_subsequence("abpcplea", "monkey") assert is_subsequence("abcd", "abc") assert not is_subsequence("abcd", "ace") def test_longest_subseq_length(): as...
[ { "docstring": "Check if 'word' is a subsequence of 's'.", "function_declaration": "def is_subsequence(s, word):", "function_name": "is_subsequence", "parameter_list": "(s, word)" }, { "docstring": "Returns the length of the longest string in 'words' that is a subsequence of 's'.", "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": "def is_subsequence(s, word):\n it = iter(s)\n return all(char in it for char in word)\n\ndef longest_subsequence_length(s, words):\n max_length = 0\n f...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00055002", "row_id": 55002, "seed_ids": "[7112]" }
0.752893
Taco_55002
I
[ "is_subsequence", "longest_subseq_length", "solve" ]
3
[ [ "longest_subseq_length", "is_subsequence" ], [ "solve", "longest_subseq_length" ] ]
2
[]
false
[]
false
pytest
true
[]
true
a4c3763973e7aee0305fd41e2f221dcd685083b5
a4a802ee845aa620c4719cfba26858d08eb257cd
v1.0
instruct
Taco
Taco_55005_I
You are given a tree with `n` nodes, rooted at node 1. The weights of the edges between nodes are given. You need to process `q` queries, each containing two integers `u` and `v`, and for each query, determine the weight of the heaviest edge on the path from node `u` to node `v`. Input The first line of input contain...
import sys from collections import defaultdict import heapq sys.setrecursionlimit(500000) input = sys.stdin.read def prepare_lca(n, edges): # adjacency list for the graph graph = defaultdict(list) for u, v, w in edges: graph[u].append((v, w)) graph[v].append((u, w)) # log base 2 o...
from solution import process_queries def test_example_case_multiple_queries(): n = 5 edges = [(1, 2, 4), (1, 3, 2), (3, 4, 3), (3, 5, 1)] queries = [(2, 4), (1, 5), (4, 5)] expected_output = ['4', '2', '3'] assert process_queries(n, edges, queries) == expected_output def test_single_node_tree(): ...
[ { "docstring": null, "function_declaration": "def prepare_lca(n, edges):", "function_name": "prepare_lca", "parameter_list": "(n, edges)" }, { "docstring": null, "function_declaration": "def lca(u, v, up, max_edge, depth):", "function_name": "lca", "parameter_list": "(u, v, up, m...
[ 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 sys\nfrom collections import defaultdict\nimport heapq\n\nsys.setrecursionlimit(500000)\ninput = sys.stdin.read\n\ndef prepare_lca(n, edges):\n # adjacen...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00055005", "row_id": 55005, "seed_ids": "[5321]" }
0.725218
Taco_55005
I
[ "prepare_lca", "lca", "process_queries", "main" ]
4
[ [ "process_queries", "lca" ], [ "process_queries", "prepare_lca" ] ]
2
[ "process_queries" ]
false
[]
false
pytest
true
[]
true
96001d85cf8b22ce7740c5b842c435323cdc822f
79c58e8ef33a11990bc8b72bc49e9c2e87a0ed68
v1.0
instruct
Taco
Taco_55029_I
In a kingdom, there are n cities connected by m bidirectional roads. The kingdom's king wants to ensure that every city is accessible from every other city, meaning the road network needs to be connected. Each road between city u and city v has a cost c. To achieve the minimum total cost, the king wants to know the mi...
def find(parent, i): if parent[i] == i: return i else: return find(parent, parent[i]) def union(parent, rank, x, y): rootX = find(parent, x) rootY = find(parent, y) if rank[rootX] > rank[rootY]: parent[rootY] = rootX elif rank[rootX] < rank[rootY]: parent[rootX]...
from solution import minimum_spanning_tree def test_example_1(): n = 4 m = 5 roads = [ (1, 2, 1), (2, 3, 2), (3, 4, 1), (4, 1, 3), (1, 3, 2) ] assert minimum_spanning_tree(n, m, roads) == 4 def test_example_2(): n = 4 m = 2 roads = [ ...
[ { "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, 1 ]
2
medium
0.4
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class DisjointSetUnion:\n def __init__(self, n):\n self.parent = list(range(n))\n self.rank = [0] * n\n \n def find(self, u):\n if se...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00055029", "row_id": 55029, "seed_ids": "[7213]" }
0.71067
Taco_55029
I
[ "find", "union", "kruskal", "minimum_spanning_tree" ]
4
[ [ "kruskal", "find" ], [ "kruskal", "union" ], [ "minimum_spanning_tree", "kruskal" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
true
[]
true
896e71320be249f2e480b5f1d55d981d128f57c1
dcab353dcd3258d5d27c49d7f7738b81f91ff30c
v1.0
instruct
Taco
Taco_55037_I
You are given n integers ai. Your task is to construct the maximum possible number from these integers by concatenating them in some order. Input The first line contains a single integer n (1 ≤ n ≤ 100) — the number of integers. The second line contains n positive integers ai (1 ≤ ai ≤ 10^9). Output Print a single...
from functools import cmp_to_key def compare(n1, n2): if n1 + n2 > n2 + n1: return -1 else: return 1 def max_number(numbers): numbers = list(map(str, numbers)) numbers.sort(key=cmp_to_key(compare)) return ''.join(numbers) def solve_max_number(n, integers): return max_number(in...
from solution import solve_max_number def test_example_1(): assert solve_max_number(3, [50, 2, 1]) == "5021" def test_example_2(): assert solve_max_number(4, [9, 34, 5, 3]) == "95343" def test_single_number(): assert solve_max_number(1, [5]) == "5" def test_same_numbers(): assert solve_max_number(3,...
[ { "docstring": null, "function_declaration": "def compare(n1, n2):", "function_name": "compare", "parameter_list": "(n1, n2)" }, { "docstring": null, "function_declaration": "def max_number(numbers):", "function_name": "max_number", "parameter_list": "(numbers)" }, { "doc...
[ 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 functools import cmp_to_key\n\ndef compare(x, y):\n if x + y > y + x:\n return -1\n elif x + y < y + x:\n return 1\n else:\n ret...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00055037", "row_id": 55037, "seed_ids": "[19699]" }
0.696516
Taco_55037
I
[ "compare", "max_number", "solve_max_number" ]
3
[ [ "max_number", "compare" ], [ "solve_max_number", "max_number" ] ]
2
[]
false
[]
false
pytest
true
[]
true
c5feff3e1093de1c416fd5672c073dbd16efa873
8e042fcbe66dcb5b3cd70849412a345490ade01b
v1.0
instruct
Taco
Taco_55101_I
You are given a grid-based game where each cell in the grid has a certain cost associated with it. A player can only move right or down from the current position. The player starts at the top-left corner (1,1) and wants to reach the bottom-right corner (N, M) with the minimum cost possible. The cost of a path is the su...
def min_path_cost(grid): """ Finds the minimum cost to reach the bottom-right corner of the grid from the top-left corner. """ n, m = len(grid), len(grid[0]) dp = [[0] * m for _ in range(n)] dp[0][0] = grid[0][0] for i in range(1, n): dp[i][0] = dp[i-1][0] + grid[i][0] for ...
def test_min_path_cost(): grid1 = [ [1, 3, 1], [1, 5, 1], [4, 2, 1] ] assert min_path_cost(grid1) == 7 grid2 = [ [1, 2], [3, 4] ] assert min_path_cost(grid2) == 7 grid3 = [ [1, 1000], [1000, 1] ] assert min_path_cost(grid3) ==...
[ { "docstring": "Finds the minimum cost to reach the bottom-right corner of the grid from the top-left corner.", "function_declaration": "def min_path_cost(grid):", "function_name": "min_path_cost", "parameter_list": "(grid)" }, { "docstring": "Parses the input of multiple test cases and calc...
[ 1 ]
1
easy
1
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared1_results_combined.jsonl", "solution_code": "def min_path_cost(grid):\n \"\"\"\n Finds the minimum cost to reach the bottom-right corner of the grid from the top-left corner.\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00055101", "row_id": 55101, "seed_ids": "[21715]" }
0.731016
Taco_55101
I
[ "min_path_cost", "min_cost_to_reach_corner", "parse_input", "main" ]
4
[ [ "min_cost_to_reach_corner", "min_path_cost" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
2d999c6a29a5db50b2a4d299c8e57ec405d7a14f
8349002103f2638710bdab619521b5ce11f99c46
v1.0
instruct
Taco
Taco_55131_I
Consider a binary search tree (BST) where each node has a value and two children. You are required to perform multiple operations on this BST. The operations are of two types: 1. Insert an integer $x$ into the BST. 2. Delete an integer $y$ from the BST if it exists. Given a series of these operations, can you determi...
class TreeNode: def __init__(self, key): self.left = None self.right = None self.val = key def insert(root, key): if root is None: return TreeNode(key) else: if root.val < key: root.right = insert(root.right, key) else: root.left = ins...
from solution import bst_operations def test_sample_input_0(): operations = [ "Insert 10", "Insert 5", "Insert 15", "Delete 10", "Insert 20" ] assert bst_operations(operations) == [5, 15, 20] def test_insert_only(): operations = [ "Insert 8", "In...
[]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, key):\n self.left = None\n self.right = None\n self.val = key\n\ndef insert(root, key):\n if root i...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00055131", "row_id": 55131, "seed_ids": "[4471]" }
0.5166
Taco_55131
I
[ "insert", "minValueNode", "deleteNode", "inorderTraversal", "bst_operations" ]
5
[ [ "bst_operations", "deleteNode" ], [ "bst_operations", "inorderTraversal" ], [ "bst_operations", "insert" ], [ "deleteNode", "minValueNode" ] ]
4
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
32055e48dd33364b5e54eb9b5030f29b3d3e4019
f5ee0675abf81139026e5684bd8ed6c9c5a6f5d5
v1.0
instruct
Taco
Taco_55271_I
Write a function that takes a string `s` and a dictionary `d` and returns the longest word in `d` that can be formed by deleting some characters of the given string `s`. If there are more than one possible results, return the word which appears first in the dictionary. If there are no possible results, return an empty ...
def can_form(s, word): """ Helper function to determine if `word` can be formed by deleting some characters from `s`. """ it = iter(s) return all(char in it for char in word) def find_longest_word(s, d): """ Returns the longest word in `d` that can be formed by deleting some characters from...
def test_can_form(): assert can_form("abpcplea", "apple") == True assert can_form("abpcplea", "ale") == True assert can_form("abpcplea", "monkey") == False assert can_form("abpcplea", "plea") == True assert can_form("abpcplea", "applz") == False def test_find_longest_word(): assert find_longest...
[ { "docstring": "Helper function to determine if `word` can be formed by deleting some characters from `s`.", "function_declaration": "def can_form(s, word):", "function_name": "can_form", "parameter_list": "(s, word)" }, { "docstring": "Returns the longest word in `d` that can be formed by d...
[ 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 can_form(s, word):\n \"\"\"\n Helper function to determine if `word` can be formed by deleting some characters from `s`.\n \"\"\"\n it = iter(s)\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00055271", "row_id": 55271, "seed_ids": "[24719]" }
0.76611
Taco_55271
I
[ "can_form", "find_longest_word" ]
2
[ [ "find_longest_word", "can_form" ] ]
1
[]
false
[]
false
pytest
false
[]
true
900988ee30eaed41461b25f6b08ffb25637cee4e
faaa09daef2c40dc8e92e62ee0067c2af2e5be82
v1.0
instruct
Taco
Taco_55318_I
In the land of ByteWorld, there exists a kingdom where people communicate using digital signals. These signals are unique and are represented using strings of characters. The citizens of ByteWorld have recently encountered a peculiar problem. They want to determine whether any two different signals in the collection of...
def are_anagrams(str1, str2): """ Checks if two strings are anagrams of each other. """ return sorted(str1) == sorted(str2) def check_anagrams(test_cases): results = [] for signals in test_cases: anagram_found = False signal_count = len(signals) for i in ra...
def test_check_anagrams(): test_cases = [ ["abc", "bca", "xyz"], ["hello", "oellh", "world", "dlro"] ] expected_results = ["YES", "YES"] assert check_anagrams(test_cases) == expected_results def test_no_anagrams(): test_cases = [ ["abc", "def", "ghi"], ["one", "two",...
[ { "docstring": "Checks if two strings are anagrams of each other.", "function_declaration": "def are_anagrams(str1, str2):", "function_name": "are_anagrams", "parameter_list": "(str1, str2)" }, { "docstring": null, "function_declaration": "def check_anagrams(test_cases):", "function_...
[ 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 check_anagrams(test_cases):\n results = []\n for signals in test_cases:\n seen = set()\n has_anagram = False\n for signal in signals...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00055318", "row_id": 55318, "seed_ids": "[17106]" }
0.629242
Taco_55318
I
[ "are_anagrams", "check_anagrams" ]
2
[ [ "check_anagrams", "are_anagrams" ] ]
1
[]
false
[]
false
pytest
false
[]
true
8dd72e973eacc1f578c7f9a46a5602359c2d233b
da81dc4d134ab1f13e8f8a2731ea868b78294c82
v1.0
instruct
Taco
Taco_55378_I
A famous adventurer is planning his next big expedition to a vast network of caves. To make sure he doesn't get lost, he decides to create a map of the cave system that indicates the shortest path between various points within the caves. The cave system can be represented as an undirected graph where each cave is a no...
import heapq def dijkstra(N, edges, S, T): # Create a graph from the edges graph = {i: [] for i in range(1, N+1)} for u, v, l in edges: graph[u].append((v, l)) graph[v].append((u, l)) # Use a min heap as the priority queue pq = [(0, S)] # (distance, node) distances = {i: fl...
from solution import shortest_path_in_caves def test_example_1(): N = 5 M = 6 edges = [ (1, 2, 4), (1, 3, 1), (3, 4, 2), (2, 3, 3), (2, 4, 1), (4, 5, 6) ] S = 1 T = 5 assert shortest_path_in_caves(N, M, edges, S, T) == 9 def test_example_2():...
[ { "docstring": null, "function_declaration": "def dijkstra(N, edges, S, T):", "function_name": "dijkstra", "parameter_list": "(N, edges, S, T)" }, { "docstring": null, "function_declaration": "def shortest_path_in_caves(N, M, edges, S, T):", "function_name": "shortest_path_in_caves",...
[ 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 heapq\n\ndef shortest_path_in_caves(N, M, edges, S, T):\n # Create adjacency list\n graph = {i: [] for i in range(1, N+1)}\n for u, v, l in edges:\...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00055378", "row_id": 55378, "seed_ids": "[9775]" }
0.702695
Taco_55378
I
[ "dijkstra", "shortest_path_in_caves" ]
2
[ [ "shortest_path_in_caves", "dijkstra" ] ]
1
[]
false
[]
false
pytest
true
[]
true
64a0b2e74a250f8864e2f2a62bc41613cae91ff0
bbf30e71c45e63e102b076cae8e7ebc084df7474
v1.0
instruct
Taco
Taco_55381_I
Alex is fascinated by Binary Trees and he wants to perform a unique kind of traversal on them. Given a binary tree, he's interested in finding the "boundary traversal" of the tree. The boundary traversal includes the nodes on the boundary of the tree in an anti-clockwise direction starting from the root. The boundary i...
class TreeNode: def __init__(self, value=0, left=None, right=None): self.value = value self.left = left self.right = right def build_tree(node_info): nodes = {info[0]: TreeNode(info[0]) for info in node_info} root = nodes[node_info[0][0]] for value, left, right in node_info...
from solution import boundary_traversal_from_input def test_boundary_traversal_example(): assert boundary_traversal_from_input(5, [[1, 2, 3], [2, 4, -1], [4, -1, -1], [3, -1, 5], [5, -1, -1]]) == [1, 2, 4, 5, 3] def test_single_node(): assert boundary_traversal_from_input(1, [[1, -1, -1]]) == [1] def test_le...
[]
[ 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": "class TreeNode:\n def __init__(self, value):\n self.value = value\n self.left = None\n self.right = None\n\ndef build_tree(nodes):\n if ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00055381", "row_id": 55381, "seed_ids": "[18266]" }
0.631525
Taco_55381
I
[ "build_tree", "boundary_traversal", "boundary_traversal_from_input" ]
3
[ [ "boundary_traversal_from_input", "boundary_traversal" ], [ "boundary_traversal_from_input", "build_tree" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
a6a28b9c80aee6baf7fbf7c779583f575c98662f
83e5e6c7b7036123b0be00a7cb602471e6969700
v1.0
instruct
Taco
Taco_55393_I
You are given an array C of size N that contains integers. You want to partition this array into exactly K non-empty contiguous subarrays. The cost of a subarray is the sum of its elements. The total cost of a partitioning is the maximum cost among its K subarrays. Your task is to find the minimum possible total cost o...
def can_partition(nums, K, max_sum): """ Helper function to determine if we can partition the array into at most K subarrays with each subarray having a sum less than or equal to max_sum. """ current_sum = 0 current_k = 1 for num in nums: if current_sum + num > max_sum: ...
from solution import min_max_cost_partition def test_example_1(): assert min_max_cost_partition([1, 2, 3, 4, 5], 5, 3) == 6 def test_example_2(): assert min_max_cost_partition([1, 2, 3, 4, 5], 5, 2) == 9 def test_single_element(): assert min_max_cost_partition([10], 1, 1) == 10 def test_all_elements_sam...
[ { "docstring": "Helper function to determine if we can partition the array into at most K subarrays\nwith each subarray having a sum less than or equal to max_sum.", "function_declaration": "def can_partition(nums, K, max_sum):", "function_name": "can_partition", "parameter_list": "(nums, K, max_sum...
[ 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 can_partition(nums, K, max_sum):\n \"\"\"\n Helper function to determine if we can partition the array into at most K subarrays\n with each subarray h...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00055393", "row_id": 55393, "seed_ids": "[23772]" }
0.82195
Taco_55393
I
[ "can_partition", "min_max_cost_partition" ]
2
[ [ "min_max_cost_partition", "can_partition" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e523c8aaf213f6f50ae0fd67075ae765cf938943
057a66f37d9d9fed83227a04a4cf339a71968a30
v1.0
instruct
Taco
Taco_55449_I
Bob has a collection of $n$ balls, each uniquely numbered from $1$ to $n$, and he places them on a straight line. Alice challenges Bob to a game where she asks him to find the shortest path to swap the balls such that the resulting sequence is in ascending order. Bob can swap adjacent balls in one move, and he needs t...
def merge_and_count(arr, temp_arr, left, mid, right): i = left # Starting index for left subarray j = mid + 1 # Starting index for right subarray k = left # Starting index to be sorted inv_count = 0 # Conditions are checked to ensure that i doesn't exceed mid and j doesn't exceed right ...
import pytest from solution import minimum_swaps_to_sort def test_case_1(): assert minimum_swaps_to_sort([5, 4, 3, 2, 1]) == 10 def test_case_2(): assert minimum_swaps_to_sort([1, 2, 6, 4, 3, 5]) == 4 def test_case_3(): assert minimum_swaps_to_sort([1, 3, 5, 2, 4, 6]) == 3 def test_case_4(): assert ...
[ { "docstring": null, "function_declaration": "def merge_and_count(arr, temp_arr, left, mid, right):", "function_name": "merge_and_count", "parameter_list": "(arr, temp_arr, left, mid, right)" }, { "docstring": null, "function_declaration": "def merge_sort_and_count(arr, temp_arr, left, r...
[ 1, 0 ]
1
medium
0.5
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared1_results_combined.jsonl", "solution_code": "def merge_and_count(arr, temp_arr, left, mid, right):\n i = left # Starting index for left subarray\n j = mid + 1 # Starting inde...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00055449", "row_id": 55449, "seed_ids": "[24548]" }
0.749563
Taco_55449
I
[ "merge_and_count", "merge_sort_and_count", "minimum_swaps_to_sort" ]
3
[ [ "merge_sort_and_count", "merge_and_count" ], [ "minimum_swaps_to_sort", "merge_sort_and_count" ] ]
2
[]
false
[]
false
pytest
true
[]
true
13688d087ff311aa20edf81fd7766d6798a305ab
60822e15830afb631dfc29169333cc4c440d496a
v1.0
instruct
Taco
Taco_55459_I
Write a program to find the shortest path traversing every node exactly once in a weighted, undirected graph. This problem is also known as the Traveling Salesman Problem (TSP). Given a graph represented with an adjacency matrix, you need to output the minimum weight of the traversal. If it's not possible to traverse e...
import sys def tsp_helper(matrix, mask, pos, dp, N): if mask == (1 << N) - 1: return matrix[pos][0] if matrix[pos][0] != -1 else sys.maxsize if dp[mask][pos] != -1: return dp[mask][pos] ans = sys.maxsize for city in range(N): if (mask & (1 << city)) == 0 and matrix[pos][city] ...
from solution import find_min_tsp def test_case_1(): matrix = [ [0, 10, 15, 20], [10, 0, 35, 25], [15, 35, 0, 30], [20, 25, 30, 0] ] assert find_min_tsp(4, matrix) == 80 def test_case_2(): matrix = [ [0, -1, 10], [-1, 0, 20], [10, 20, 0] ] ...
[ { "docstring": null, "function_declaration": "def tsp_helper(matrix, mask, pos, dp, N):", "function_name": "tsp_helper", "parameter_list": "(matrix, mask, pos, dp, N)" }, { "docstring": null, "function_declaration": "def tsp(matrix):", "function_name": "tsp", "parameter_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": "import sys\n\ndef tsp_helper(matrix, mask, pos, dp, N):\n if mask == (1 << N) - 1:\n return matrix[pos][0] if matrix[pos][0] != -1 else sys.maxsize\n\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00055459", "row_id": 55459, "seed_ids": "[729]" }
0.74651
Taco_55459
I
[ "tsp_helper", "tsp", "find_min_tsp" ]
3
[ [ "find_min_tsp", "tsp" ], [ "tsp", "tsp_helper" ] ]
2
[]
false
[]
false
pytest
true
[]
true
a6d15f41903a9eb39ed699f2c499ccfac4c9141c
9be3f9ffeb589c8fb3aed2963f10d61d19a36d86
v1.0
instruct
Taco
Taco_55509_I
Given an array of integers where each element represents the width of a book and a separate integer representing the number of bookshelves, design a program that distributes these books across the shelves such that the width of the widest shelf is minimized. Example 1: Input: books = [1, 2, 3, 4, 5, 6, 7, 8, 9] shelve...
def can_place_books(books, shelves, max_width): current_width = 0 required_shelves = 1 for book in books: if current_width + book > max_width: required_shelves += 1 current_width = book if required_shelves > shelves: return False else: ...
from solution import minimizeShelfWidth def test_minimize_shelf_width_example1(): assert minimizeShelfWidth([1, 2, 3, 4, 5, 6, 7, 8, 9], 3) == 17 def test_minimize_shelf_width_example2(): assert minimizeShelfWidth([10, 20, 30, 40], 2) == 60 def test_minimize_shelf_width_single_shelf(): assert minimizeShe...
[ { "docstring": null, "function_declaration": "def can_place_books(books, shelves, max_width):", "function_name": "can_place_books", "parameter_list": "(books, shelves, max_width)" }, { "docstring": null, "function_declaration": "def minimizeShelfWidth(books, shelves):", "function_nam...
[ 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 minimizeShelfWidth(books, shelves):\n def canDistribute(books, shelves, maxWidth):\n currentShelfWidth = 0\n shelf_count = 1\n\n for bo...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00055509", "row_id": 55509, "seed_ids": "[17826]" }
0.645286
Taco_55509
I
[ "can_place_books", "minimizeShelfWidth" ]
2
[ [ "minimizeShelfWidth", "can_place_books" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e9149a7c15acaf6481ea478153acdedbd711e3b9
23ac515e4de9a8fedf4c1605bd40d003d2ac4dce
v1.0
instruct
Taco
Taco_55531_I
In a remote village, people have unique string patterns as their identifiers. However, the village has a peculiar rule: every identifier can be converted to a new identifier by repeatedly removing adjacent duplicate characters. For example, the identifier "abbac" can be converted to "c" by removing "bb" and then "aa". ...
def remove_adjacent_duplicates(identifier): stack = [] for char in identifier: if stack and stack[-1] == char: stack.pop() # Remove the duplicate else: stack.append(char) return ''.join(stack) def process_identifiers(identifiers): return [remove_adjacent_duplica...
from solution import remove_adjacent_duplicates, process_identifiers def test_remove_adjacent_duplicates_single(): assert remove_adjacent_duplicates("abbac") == "c" def test_remove_adjacent_duplicates_entire(): assert remove_adjacent_duplicates("aabbcc") == "" def test_remove_adjacent_duplicates_nested(): ...
[ { "docstring": null, "function_declaration": "def remove_adjacent_duplicates(identifier):", "function_name": "remove_adjacent_duplicates", "parameter_list": "(identifier)" }, { "docstring": null, "function_declaration": "def process_identifiers(identifiers):", "function_name": "proce...
[ 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 reduce_identifier(identifier):\n \"\"\"\n Reduces the identifier by repeatedly removing adjacent duplicate characters until no more removals can be made....
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00055531", "row_id": 55531, "seed_ids": "[4022]" }
0.732025
Taco_55531
I
[ "remove_adjacent_duplicates", "process_identifiers", "main" ]
3
[ [ "process_identifiers", "remove_adjacent_duplicates" ] ]
1
[]
false
[]
false
pytest
true
[]
true
54e1758ac6436cca636c3bbe7021144638e71b08
2f2e7fce936f9f52fa25f4159ee8e289c44582d0
v1.0
instruct
Taco
Taco_55553_I
Create a function that takes a list of integers and returns a list of integers from the original list that are prime numbers. Prime numbers are defined as numbers greater than 1 that have no divisors other than 1 and themselves. The result list should be sorted in ascending order. Assume the input list may contain d...
def is_prime(num): """ Helper function to check if a number is prime. """ if num <= 1: return False if num == 2: return True if num % 2 == 0: return False for i in range(3, int(num ** 0.5) + 1, 2): if num % i == 0: return False return True def...
from solution import filter_primes def test_filter_primes_basic(): assert filter_primes([2, 3, 4, 5, 6, 7]) == [2, 3, 5, 7] assert filter_primes([10, 11, 12, 11, 13]) == [11, 11, 13] assert filter_primes([1, 4, 6, 8, 9]) == [] assert filter_primes([29, 1, 17, 17, 23]) == [17, 17, 23, 29] def test_filt...
[ { "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 numbers from the input list.\nThe result list is sorted in ascending order.", "...
[ 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 if n <= 1:\n return False\n for i in range(2, int(n**0.5) + 1):\n if n % i == 0:\n return False\n return True\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00055553", "row_id": 55553, "seed_ids": "[2147]" }
0.716579
Taco_55553
I
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
be96a2bacb27265061d7d32ea87fd777f0d680e6
8308c4a34e3b1e37a444ecae37f9a0a6520863b4
v1.0
instruct
Taco
Taco_55556_I
In a busy city, there are several intersections connected by one-way streets of varying lengths. You are given a map of the city with the intersections and streets and your task is to help a delivery driver determine the shortest path to deliver packages. However, the delivery driver can only drive a certain maximum nu...
import heapq def dijkstra(N, edges, start, D): graph = [[] for _ in range(N)] for u, v, w in edges: graph[u-1].append((v-1, w)) distances = [float('inf')] * N distances[start] = 0 pq = [(0, start)] while pq: current_distance, u = heapq.heappop(pq) if c...
def test_sample_input(): from io import StringIO import sys input_data = '''4 4 5 1 2 3 2 3 4 3 4 6 1 3 2 2 1 4 3 1 ''' expected_output = '''1 -1 ''' old_stdin = sys.stdin sys.stdin = StringIO(input_data) old_stdout = sys.stdout sys.stdout = new_stdout = StringIO() main() ...
[ { "docstring": null, "function_declaration": "def dijkstra(N, edges, start, D):", "function_name": "dijkstra", "parameter_list": "(N, edges, start, D)" }, { "docstring": null, "function_declaration": "def minimum_breaks(N, M, D, edges, queries):", "function_name": "minimum_breaks", ...
[ 0, 1 ]
1
medium
0.5
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef dijkstra(graph, start, max_distance, n):\n dist = [float('inf')] * n\n dist[start] = 0\n pq = [(0, start)]\n \n while pq:\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00055556", "row_id": 55556, "seed_ids": "[23580]" }
0.796338
Taco_55556
I
[ "dijkstra", "minimum_breaks", "main" ]
3
[ [ "minimum_breaks", "dijkstra" ] ]
1
[]
false
[]
false
pytest
false
[]
true
bb73c2773827e5481024815f7ab87ff8367710bd
29cd9b19941aa166333436e89fd462aacdcf9c26
v1.0
instruct
Taco
Taco_55570_I
Problem description: You are given a list of strings representing book titles in a library. Some of these titles might appear multiple times due to multiple copies of the same book. Write a function to determine the number of unique book titles in the library. Input The first line contains an integer T, the number o...
def count_unique_titles(test_cases): """ Counts the number of unique book titles for each test case. Parameters: test_cases (list): a list of test cases, each test case is a tuple that contains the number of titles and a list of book titles. Returns: list: a lis...
def test_count_unique_titles(): test_cases = [ (5, ["The Great Gatsby", "Moby Dick", "The Great Gatsby", "War and Peace", "Moby Dick"]), (3, ["To Kill a Mockingbird", "1984", "1984"]) ] expected = [3, 2] assert library_unique_titles(2, test_cases) == expected def test_single_title(): ...
[ { "docstring": "Counts the number of unique book titles for each test case.\n\nParameters:\ntest_cases (list): a list of test cases, each test case is a tuple that contains \n the number of titles and a list of book titles.\n\nReturns:\nlist: a list containing the number of unique book titles ...
[ 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 count_unique_titles(T, test_cases):\n \"\"\"\n Returns the number of unique book titles for each test case.\n \n Parameters:\n T (int): The numb...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00055570", "row_id": 55570, "seed_ids": "[445]" }
0.629516
Taco_55570
I
[ "count_unique_titles", "library_unique_titles" ]
2
[ [ "library_unique_titles", "count_unique_titles" ] ]
1
[]
false
[]
false
pytest
false
[]
true
b7ab0bd789dc8a7fbacf0aa2237392f6191c1ed1
fe58d0e5485acbbff5ee13f00e80132e4ae5973a
v1.0
instruct
Taco
Taco_55599_I
Cathy and Dan are working on an image processing application that requires a specific transformation of a matrix. They need to know if it is possible to transform an initial matrix into a target matrix using a series of operations described below. An operation is defined as: select a submatrix of any size from the ini...
def rotate_90_clockwise(matrix): """ Rotate the given n x n matrix 90 degrees clockwise. """ n = len(matrix) return [[matrix[n - j - 1][i] for j in range(n)] for i in range(n)] def is_possible_to_transform(initial_matrix, target_matrix): """ Check if the target matrix can be obtained from t...
from solution import rotate_90_clockwise, is_possible_to_transform, matrix_transformation_possible def test_rotate_90_clockwise(): assert rotate_90_clockwise([ [1, 2], [3, 4] ]) == [ [3, 1], [4, 2] ] assert rotate_90_clockwise([ [1, 2, 3], [4, 5, 6], ...
[ { "docstring": "Rotate the given n x n matrix 90 degrees clockwise.", "function_declaration": "def rotate_90_clockwise(matrix):", "function_name": "rotate_90_clockwise", "parameter_list": "(matrix)" }, { "docstring": "Check if the target matrix can be obtained from the initial matrix via any...
[ 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 rotate_90_clockwise(matrix):\n \"\"\"\n Rotates the given n x n matrix 90 degrees clockwise.\n \"\"\"\n n = len(matrix)\n rotated_matrix = [[0] ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00055599", "row_id": 55599, "seed_ids": "[6175]" }
0.650851
Taco_55599
I
[ "rotate_90_clockwise", "is_possible_to_transform", "matrix_transformation_possible" ]
3
[ [ "is_possible_to_transform", "rotate_90_clockwise" ], [ "matrix_transformation_possible", "is_possible_to_transform" ] ]
2
[]
false
[]
false
pytest
true
[]
true
0cf290bd3a6ca9b20415b27f55c93b9af72a06f6
3b049904fddc8496ec3a114283278414145a641c
v1.0
instruct
Taco
Taco_55692_I
In a large company, an employee can have multiple direct reports but only one manager. The employees are represented as nodes in a tree, where each node contains an integer representing the employee's ID. The root node represents the CEO who has no manager. You need to implement a function that, given the root of this...
class TreeNode: def __init__(self, id): self.id = id self.children = [] def build_tree(n, ids, manager_pairs): nodes = {id: TreeNode(id) for id in ids} for u, v in manager_pairs: nodes[u].children.append(nodes[v]) root = nodes[ids[0]] return root def find_path(root, t...
from solution import employee_path def test_example(): n = 7 ids = [1, 2, 3, 4, 5, 6, 7] manager_pairs = [(1, 2), (1, 3), (2, 4), (2, 5), (3, 6), (3, 7)] target = 5 assert employee_path(n, ids, manager_pairs, target) == "1 -> 2 -> 5" def test_single_employee(): n = 1 ids = [1] manager_...
[]
[ 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": "class TreeNode:\n def __init__(self, id):\n self.id = id\n self.children = []\n\ndef build_tree(n, employees, relations):\n nodes = {id: TreeNo...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00055692", "row_id": 55692, "seed_ids": "[7732]" }
0.622828
Taco_55692
I
[ "build_tree", "find_path", "employee_path" ]
3
[ [ "employee_path", "build_tree" ], [ "employee_path", "find_path" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
c92f89c1e7fc55346e8d3253b5281bddc513aaaa
865e0d17e8d9a4c548e97e692460d494aac06c48
v1.0
instruct
Taco
Taco_55702_I
You are given a rectangular grid with `n` rows and `m` columns. Each cell in the grid contains a certain number of coins. You need to perform several queries on this grid. Each query consists of four integers `x1`, `y1`, `x2`, and `y2`, and you need to determine the total number of coins in the subrectangle defined by ...
def preprocess_grid(grid, n, m): prefix_sum = [[0] * (m + 1) for _ in range(n + 1)] for i in range(n): for j in range(m): prefix_sum[i + 1][j + 1] = grid[i][j] + prefix_sum[i][j + 1] + prefix_sum[i + 1][j] - prefix_sum[i][j] return prefix_sum def query_coins(prefix_sum, x1, y1...
from solution import grid_queries def test_single_query(): n, m = 3, 4 grid = [ [1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12] ] queries = [(1, 1, 2, 2)] assert grid_queries(n, m, grid, queries) == [14] def test_multiple_queries(): n, m = 3, 4 grid = [ [1, ...
[ { "docstring": null, "function_declaration": "def preprocess_grid(grid, n, m):", "function_name": "preprocess_grid", "parameter_list": "(grid, n, m)" }, { "docstring": null, "function_declaration": "def query_coins(prefix_sum, x1, y1, x2, y2):", "function_name": "query_coins", "p...
[ 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 preprocess_grid(grid):\n \"\"\"\n Preprocess the grid to create a prefix sum matrix.\n \"\"\"\n n = len(grid)\n m = len(grid[0])\n prefix_sum...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00055702", "row_id": 55702, "seed_ids": "[24872]" }
0.674314
Taco_55702
I
[ "preprocess_grid", "query_coins", "grid_queries" ]
3
[ [ "grid_queries", "preprocess_grid" ], [ "grid_queries", "query_coins" ] ]
2
[]
false
[]
false
pytest
true
[]
true
7aeb91a4c89239be7719bf1b22d8e41afea98669
cffd508a1f48649643f1872616c51329c8c2244f
v1.0
instruct
Taco
Taco_55712_I
In a game of strategic points, players collect points based on the order they visit a set of cities. This game is played on a road network consisting of $N$ cities connected by $M$ bidirectional roads. Each road connects a pair of cities $(u, v)$ and has an associated length $l$. The goal is to determine the minimum di...
import heapq def dijkstra(n, adj, start): dist = [float('inf')] * (n + 1) dist[start] = 0 pq = [(0, start)] # priority queue (distance, node) while pq: current_distance, u = heapq.heappop(pq) if current_distance > dist[u]: continue for v, length in adj[u]: ...
def test_dijkstra(): n = 5 adj = [[] for _ in range(n + 1)] edges = [(1, 2, 2), (1, 3, 5), (2, 3, 1), (2, 4, 4), (3, 5, 3), (4, 5, 1)] for u, v, l in edges: adj[u].append((v, l)) adj[v].append((u, l)) dist = dijkstra(n, adj, 1) assert dist[1] == 0 assert dist[2] == 2 asse...
[ { "docstring": null, "function_declaration": "def dijkstra(n, adj, start):", "function_name": "dijkstra", "parameter_list": "(n, adj, start)" }, { "docstring": null, "function_declaration": "def min_distance_to_collect_points(t, tests):", "function_name": "min_distance_to_collect_poi...
[ 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 dijkstra(graph, start, n):\n \"\"\"\n Dijkstra's algorithm to find the shortest path from start to all other nodes.\n Returns a list o...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00055712", "row_id": 55712, "seed_ids": "[22679]" }
0.736237
Taco_55712
I
[ "dijkstra", "min_distance_to_collect_points" ]
2
[ [ "min_distance_to_collect_points", "dijkstra" ] ]
1
[]
false
[]
false
pytest
false
[]
true
e888b59cdc898ea5d4b0e853ee2fea12afd4b8be
edb185fbf89ae1f3bbab6b47a0ee65304ff5022f
v1.0
instruct
Taco
Taco_55738_I
You are given a list of strings that represent file paths. Each file path is formed with directory names separated by forward slashes ('/'). Sometimes there may be redundant segments in the path, such as "." which means the current directory and ".." which means to go up one directory (i.e., to the parent directory). Y...
def simplify_path(path): parts = path.split('/') stack = [] for part in parts: if part == '..': if stack: stack.pop() elif part and part != '.': stack.append(part) simplified_path = '/' + '/'.join(stack) return simplified_path.rstr...
from solution import simplify_file_paths def test_single_trailing_slash(): assert simplify_file_paths(['/home/foo/']) == ['/home/foo'] def test_root_path_with_parent_directory(): assert simplify_file_paths(['/../']) == ['/'] def test_mixed_example(): assert simplify_file_paths(['/home//foo/bar/../baz']) ...
[ { "docstring": null, "function_declaration": "def simplify_path(path):", "function_name": "simplify_path", "parameter_list": "(path)" }, { "docstring": null, "function_declaration": "def simplify_file_paths(paths):", "function_name": "simplify_file_paths", "parameter_list": "(pat...
[ 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 simplify_path(paths):\n def simplify_single_path(path):\n stack = []\n parts = path.split('/')\n \n for part in parts:\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00055738", "row_id": 55738, "seed_ids": "[671]" }
0.588823
Taco_55738
I
[ "simplify_path", "simplify_file_paths" ]
2
[ [ "simplify_file_paths", "simplify_path" ] ]
1
[]
false
[]
false
pytest
true
[]
true
db5b27c0385f5dd16eaf7dd7c2564535fc6b9aea
4936baf2d296fb4cfa95b5d245da02a729e5a9fb