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
complete
Taco
Taco_67872_C
def library_management(events): """ Determine the final status of each book in the library based on a series of check-in and check-out events. Args: events (List[str]): A list of strings representing the events in chronological order. Each event is either "CheckIn <book_id>" or ...
def library_management(events): book_status = {} for event in events: action, book_id = event.split() if action == "CheckIn": book_status[book_id] = "Available" elif action == "CheckOut": book_status[book_id] = "Checked Out" sorted_books = sorted(boo...
from solution import library_management def test_library_management_all_checked_out(): events = [ "CheckIn book1", "CheckOut book1", "CheckIn book2", "CheckOut book2", "CheckIn book3", "CheckOut book3" ] expected = [ ("book1", "Checked Out"), ...
[ { "docstring": null, "function_declaration": "def library_management(events):", "function_name": "library_management", "parameter_list": "(events)" }, { "docstring": null, "function_declaration": "def process_library_events(t, event_list):", "function_name": "process_library_events",...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def library_management_system(events):\n \"\"\"\n Returns the final status of each book in the library given a list of events.\n \"\"\"\n status = {}\n...
trial_gpt4o_2
{ "original_instruction": "As a software developer, you are required to write a program to help a library manage their book check-ins and check-outs efficiently. The library follows a strict policy that a book can be checked out if and only if it is currently available (i.e., it was previously checked in). To impleme...
0.609214
Taco_67872
C
[ "library_management", "process_library_events" ]
2
[ [ "process_library_events", "library_management" ] ]
1
[]
false
[]
false
pytest
true
[]
true
86863b7c944c873152d126edfad9fe9b9da5c636
ed4015f89b0c7e181bf22cab7352f04a18415f1b
v1.0
complete
Taco
Taco_68065_C
def is_prime(num): """ Helper function to check if a number is prime. """ pass def prime_factors(n): """ Returns a list of prime factors of n. """ pass def process_datasets(datasets): """ Processes multiple datasets to output prime factors. """ pass if __name__ == "__m...
def is_prime(num): """ Helper function to check if a number is prime. """ if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return F...
from solution import prime_factors, process_datasets def test_prime_factors_prime_number(): assert prime_factors(17) == "Prime" def test_prime_factors_normal_number(): assert prime_factors(28) == [2, 2, 7] assert prime_factors(100) == [2, 2, 5, 5] def test_prime_factors_composite_number(): assert pri...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns a list of prime factors of n.", "function_declaration": "def prime_factors(n):", "function_...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def prime_factors(n):\n if n <= 1:\n return []\n \n def is_prime(num):\n if num <= 1:\n return False\n if num == 2 or num ...
trial_gpt4o_2
{ "original_instruction": "Create a program that outputs all prime factors of a number n.\n\nThe prime factor conditions are as follows. However, 2 ≤ n ≤ 100,000. If the number is prime, output \"Prime\".\n\n* A prime factor is a factor that is a prime number.\n* The factors should be printed in ascending order.\n\n\...
0.709597
Taco_68065
C
[ "is_prime", "prime_factors", "process_datasets" ]
3
[ [ "prime_factors", "is_prime" ], [ "process_datasets", "prime_factors" ] ]
2
[ "process_datasets" ]
false
[]
false
pytest
true
[]
true
74e67d1d7cbfe1131fcadcfdac7b0fec31ee2263
545580603e562bbc34c3b769b4875d7e2dfe7a58
v1.0
complete
Taco
Taco_68274_C
import itertools def fibonacci_string_order_k(k: int) -> str: """Generate the fibonacci string of order k. >>> fibonacci_string_order_k(1) 'a' >>> fibonacci_string_order_k(2) 'b' >>> fibonacci_string_order_k(3) 'ba' >>> fibonacci_string_order_k(4) 'bab' """ # Implement the f...
import itertools def fibonacci_string_order_k(k): if k == 1: return "a" elif k == 2: return "b" else: Fi_minus_2 = "a" Fi_minus_1 = "b" Fi = "" for i in range(3, k + 1): Fi = Fi_minus_1 + Fi_minus_2 Fi_minus_2 = Fi_minus_1 ...
from solution import fibonacci_string_order_k, pth_permutation def test_fibonacci_string_order_k(): assert fibonacci_string_order_k(1) == "a" assert fibonacci_string_order_k(2) == "b" assert fibonacci_string_order_k(3) == "ba" assert fibonacci_string_order_k(4) == "bab" assert fibonacci_string_orde...
[ { "docstring": null, "function_declaration": "def fibonacci_string_order_k(k):", "function_name": "fibonacci_string_order_k", "parameter_list": "(k)" }, { "docstring": null, "function_declaration": "def pth_permutation(k, p):", "function_name": "pth_permutation", "parameter_list"...
[ 0, 0, 0, 0, 0, 0, 1, 0, 0 ]
1
hard
0.111
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import itertools\n\ndef get_fibonacci_string(k):\n if k == 1:\n return \"a\"\n elif k == 2:\n return \"b\"\n else:\n return get_fibon...
trial_gpt4o_7
{ "original_instruction": "Masha is interested in collecting a specific type of strings called \"fibonacci strings\". A fibonacci string of order k is defined in the following way:\n\n- F1 = \"a\"\n- F2 = \"b\"\n- For i > 2, Fi = F(i-1) + F(i-2)\n\nWhere \"+\" denotes string concatenation. For example:\n- F1 = \"a\"\...
0.668549
Taco_68274
C
[ "fibonacci_string_order_k", "pth_permutation" ]
2
[ [ "pth_permutation", "fibonacci_string_order_k" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e2c5db06f8240c717fc43dbcc5fb48a549d5bbf4
b2ad0b43c724b139815325aa957c314a45f37015
v1.0
complete
Taco
Taco_68195_C
def largest_empty_rectangle(garden: List[str]) -> int: """ Determine the area of the largest rectangle that consists entirely of empty cells in a garden grid. Parameters: garden (List[str]): A 2D grid of characters where '.' denotes an empty cell and '*' denotes a cell with a flower. Retur...
def maximalRectangle(matrix): if not matrix or not matrix[0]: return 0 max_area = 0 n = len(matrix) m = len(matrix[0]) heights = [0] * (m + 1) for row in matrix: for i in range(m): if row[i] == '.': heights[i] += 1 else: h...
from solution import largest_empty_rectangle def test_largest_empty_rectangle_single_row(): garden = ["...."] assert largest_empty_rectangle(garden) == 4 def test_largest_empty_rectangle_single_column(): garden = [".", ".", ".", "."] assert largest_empty_rectangle(garden) == 4 def test_largest_empty_...
[ { "docstring": null, "function_declaration": "def maximalRectangle(matrix):", "function_name": "maximalRectangle", "parameter_list": "(matrix)" }, { "docstring": null, "function_declaration": "def largest_empty_rectangle(garden):", "function_name": "largest_empty_rectangle", "par...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def maximalRectangle(matrix):\n if not matrix or not matrix[0]:\n return 0\n\n max_area = 0\n n = len(matrix)\n m = len(matrix[0])\n heights ...
trial_gpt4o_0
{ "original_instruction": "Steven is an avid gardener and he has planted a variety of flowers in his garden. The garden can be represented as a 2D grid of size $n \\times n$. Each cell in the grid either contains a flower or is empty. Steven is particularly interested in finding the largest rectangular plot in his ga...
0.645894
Taco_68195
C
[ "maximalRectangle", "largest_empty_rectangle" ]
2
[ [ "largest_empty_rectangle", "maximalRectangle" ] ]
1
[]
false
[]
false
pytest
true
[]
true
abb3679d2b929e8c5e00f007b7be180b196c77dd
6b8561711fcddaa5d82dd838805b81ca563dbb5f
v1.0
complete
Taco
Taco_68399_C
def library_fines(input_data: str) -> str: """ Determine if all books have been returned within their loan periods. If any book is returned late, return "FINE". Otherwise, return "ALL RETURNED". >>> library_fines("2\n201 20 15\n202 10 10\n") 'ALL RETURNED' >>> library_fines("3\n101 14 10\n102 ...
def check_book_loans(N, loans): for loan in loans: ID, D, R = loan if R > D: return "FINE" return "ALL RETURNED" def library_fines(input_data): lines = input_data.strip().split('\n') N = int(lines[0]) loans = [tuple(map(int, line.split())) for line in lines[1:N+1]] r...
def test_library_fines_all_returned(): input_data = "2\n201 20 15\n202 10 10\n" assert library_fines(input_data) == "ALL RETURNED" def test_library_fines_fine(): input_data = "3\n101 14 10\n102 7 5\n103 30 35\n" assert library_fines(input_data) == "FINE" def test_library_fines_single_book_fine(): ...
[ { "docstring": null, "function_declaration": "def check_book_loans(N, loans):", "function_name": "check_book_loans", "parameter_list": "(N, loans)" }, { "docstring": null, "function_declaration": "def library_fines(input_data):", "function_name": "library_fines", "parameter_list"...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def check_book_loans(N, book_details):\n \"\"\"\n Given N book details, this function checks if all books are returned within the loan period.\n \n Par...
trial_gpt4o_2
{ "original_instruction": "You are a librarian managing a series of book loans in a university library. Each book has a unique identification number and a certain number of days it can be loaned out to a student. You need to track the book returns and ensure all books are returned within their loan period.\n\nAccordi...
0.584255
Taco_68399
C
[ "check_book_loans", "library_fines" ]
2
[ [ "library_fines", "check_book_loans" ] ]
1
[]
false
[]
false
pytest
false
[]
true
2910d5f6cb4863284f64f26f5f10885ba2992f69
bd6fea39aaa2ce802b55db089dac258eb9c24a8a
v1.0
complete
Taco
Taco_68338_C
def sort_primes_first(lst): """ Given an input list of integers, return the list sorted in ascending order but with all prime numbers at the beginning of the list, followed by non-prime numbers. Preserve the original relative order of all prime and non-prime numbers within their respective sections. ...
def is_prime(n): """ Check if a number is prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def sort_primes_first(lst): """ ...
from solution import sort_primes_first def test_sort_primes_first_all_primes(): assert sort_primes_first([2, 3, 5, 7]) == [2, 3, 5, 7] def test_sort_primes_first_all_non_primes(): assert sort_primes_first([4, 6, 8, 9, 10]) == [4, 6, 8, 9, 10] def test_sort_primes_first_mixed(): assert sort_primes_first([...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Sort the list with prime numbers first while preserving the \nrelative order of the primes and non-primes.", "function_declara...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Returns True if n is a prime number, else False.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n retur...
trial_gpt4o_1
{ "original_instruction": "Given an input list of integers, return the list sorted in ascending order but with all prime numbers at the beginning of the list, followed by non-prime numbers. Preserve the original relative order of all prime and non-prime numbers within their respective sections.\n\nInput\nInput list o...
0.617344
Taco_68338
C
[ "is_prime", "sort_primes_first" ]
2
[ [ "sort_primes_first", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f207bd7b30ead2804d4f3c008d16612714c27825
a2f09662c090cf3138b79599413e33ddda43e47f
v1.0
complete
Taco
Taco_68497_C
def minimum_spanning_tree(n: int, m: int, edges: List[Tuple[int, int, int]]) -> int: """ Calculate the total weight of the Minimum Spanning Tree (MST) formed by the given edges. >>> minimum_spanning_tree(4, 5, [(1, 2, 1), (1, 3, 4), (2, 3, 2), (2, 4, 7), (3, 4, 3)]) 6 """
class UnionFind: def __init__(self, n): self.parent = list(range(n)) self.rank = [0] * n def find(self, u): if self.parent[u] != u: self.parent[u] = self.find(self.parent[u]) return self.parent[u] def union(self, u, v): root_u = self.find(u) root...
def test_minimum_spanning_tree(): assert minimum_spanning_tree(4, 5, [(1, 2, 1), (1, 3, 4), (2, 3, 2), (2, 4, 7), (3, 4, 3)]) == 6 def test_minimum_spanning_tree_no_edges(): assert minimum_spanning_tree(2, 1, [(1, 2, 1)]) == 1 def test_minimum_spanning_tree_disconnected(): assert minimum_spanning_tree(4, ...
[]
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n return find(parent, parent[i])\n\ndef union(parent, rank, x, y):\n root_x = find(parent, x)\...
trial_gpt4o_3
{ "original_instruction": "James is an avid hiker and likes to explore various trails across the country. Recently, he has developed an interest in mapping out optimal paths that connect different scenic spots in a trail. Each trail can be represented as a graph, where nodes represent the scenic spots and edges repre...
0.749263
Taco_68497
C
[ "kruskal_mst", "minimum_spanning_tree" ]
2
[ [ "minimum_spanning_tree", "kruskal_mst" ] ]
1
[]
false
[ "UnionFind" ]
true
pytest
false
[]
true
3ae0202d372a5ebdaa44dcbc10a7fdf3264dcf79
41e52ad96487c97e2c0228c23bb76eb824803155
v1.0
complete
Taco
Taco_68445_C
def optimal_storage(input_str: str) -> str: """ Optimize storage for Acme Widget Company to maximize value without exceeding warehouse volume. >>> optimal_storage("3 50\ngadget 10 60\ndoohickey 20 100\nthingamajig 30 120") 'gadget 5' >>> optimal_storage("2 5\nwidget1 10 50\nwidget2 20 100...
def find_optimal_storage(n, V, widgets): dp = [0] * (V + 1) counts = [{} for _ in range(V + 1)] for widget_name, volume, value in widgets: for j in range(volume, V + 1): if dp[j - volume] + value > dp[j]: dp[j] = dp[j - volume] + value counts[j] = counts[...
from solution import optimal_storage def test_example_input(): input_str = "3 50\ngadget 10 60\ndoohickey 20 100\nthingamajig 30 120" output_str = optimal_storage(input_str) assert output_str == "gadget 5" or output_str == "thingamajig 2" def test_impossible_case(): input_str = "2 5\nwidget1 10 50\nwi...
[ { "docstring": null, "function_declaration": "def find_optimal_storage(n, V, widgets):", "function_name": "find_optimal_storage", "parameter_list": "(n, V, widgets)" }, { "docstring": null, "function_declaration": "def parse_input(input_str):", "function_name": "parse_input", "pa...
[ 0, 0, 0, 0, 0, 1, 1, 1, 0, 0 ]
3
hard
0.3
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def optimize_storage(n, V, widgets):\n dp = [0] * (V + 1)\n selection = [[] for _ in range(V + 1)]\n\n for name, volume, value in widgets:\n for v ...
trial_gpt4o_7
{ "original_instruction": "The Acme Widget Company is conducting their annual inventory audit and needs assistance with optimizing their warehouse storage. Each widget in their inventory has a specific volume and a value. The company wants to maximize the total value of widgets stored in a warehouse that has a maximu...
0.57784
Taco_68445
C
[ "find_optimal_storage", "parse_input", "optimal_storage" ]
3
[ [ "optimal_storage", "find_optimal_storage" ], [ "optimal_storage", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
d4027479e1b5e8598ee2520e3d16aa360527309d
1dfd2cc03ac7062c6d0e846b9bde5fc17228659d
v1.0
complete
Taco
Taco_68523_C
from typing import List def is_palindrome_permutation(s: str) -> bool: """ Return True if the input string can be rearranged to form a palindrome, else False. Ignore spaces and consider characters case-insensitively. """ def check_palindrome_permutations(input_list: List[str]) -> List[bool]: """ ...
def is_palindrome_permutation(s): """ Return True if the input string can be rearranged to form a palindrome, else False. """ # Ignore spaces and consider characters case-insensitively s = s.replace(" ", "").lower() # Create a frequency dictionary to count each character char_count = {}...
from solution import check_palindrome_permutations def test_empty_string(): assert check_palindrome_permutations([""]) == [True] def test_single_character(): assert check_palindrome_permutations(["a"]) == [True] assert check_palindrome_permutations(["z"]) == [True] def test_multiple_words(): assert c...
[ { "docstring": "Return True if the input string can be rearranged to form a palindrome, else False.", "function_declaration": "def is_palindrome_permutation(s):", "function_name": "is_palindrome_permutation", "parameter_list": "(s)" }, { "docstring": "Takes a list of strings and returns a li...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome_permutation(s):\n \"\"\"\n Determine if a given string is a Palindrome Permutation.\n \"\"\"\n from collections import Counter\n \...
trial_gpt4o_2
{ "original_instruction": "Implement a function that takes a list of strings and returns a list of booleans. Each boolean corresponds to whether the string at the same index of the input list is a valid \"Palindrome Permutation.\"\n\nA \"Palindrome Permutation\" is a string that can be rearranged to form a palindrome...
0.798884
Taco_68523
C
[ "is_palindrome_permutation", "check_palindrome_permutations" ]
2
[ [ "check_palindrome_permutations", "is_palindrome_permutation" ] ]
1
[]
false
[]
false
pytest
true
[]
true
56fb3a67bee5737db578929672b0e5b23323196f
c14cba6b5b7c2a65474caeb6af059b2bd835a370
v1.0
complete
Taco
Taco_68292_C
from typing import List, Tuple def is_prime(num: int) -> bool: """ Check if the given number is a prime number. >>> is_prime(2) True >>> is_prime(4) False >>> is_prime(11) True """ def min_milestones_for_prime_distance(test_cases: List[Tuple[int, List[int]]]) -> List[int]: """ Dete...
def is_prime(num): if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while (i * i) <= num: if (num % i == 0) or (num % (i + 2) == 0): return False i += 6 return True def min_milestones_for_p...
def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(10) == False assert is_prime(11) == True def test_min_milestones_for_prime_distance(): test_cases = [(5, [2, 3, 5, 7, 11]), (4, [10, 20, 30, ...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def min_milestones_for_prime_distance(test_cases):", "function_name": "min_milestones_for_prime_distance", "p...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n if num <= 1:\n return False\n if num <= 3:\n return True\n if num % 2 == 0 or num % 3 == 0:\n return False\n ...
trial_gpt4o_0
{ "original_instruction": "A highway spanning a long distance has exactly N milestones marking its length at various points. These milestones are not equally placed but are positioned based on significant landmarks along the route. The milestone at position i has a coordinate xi.\n\nA driver wishes to travel from the...
0.595484
Taco_68292
C
[ "is_prime", "min_milestones_for_prime_distance" ]
2
[ [ "min_milestones_for_prime_distance", "is_prime" ] ]
1
[]
false
[]
false
pytest
false
[]
true
51b2bdc931c5908fbd1ed703d04eaca5f3ad142b
a0ce3b8817d696bfaf573c3d44648f5aa72f4028
v1.0
complete
Taco
Taco_68539_C
def marathon_ranking(n: int, m: int, pairs: List[Tuple[int, int]]) -> str: """ Determine the consistency of marathon participants' finishing times based on reported pairwise rankings. Args: n : int : number of participants m : int : number of reported comparisons pairs : List[Tuple[int, in...
def check_consistency(n, m, comparisons): from collections import defaultdict, deque # Create a graph based on the pairwise comparisons graph = defaultdict(list) in_degree = [0] * n for a, b in comparisons: graph[a].append(b) in_degree[b] += 1 # Topological Sort (Kahn's Al...
from solution import marathon_ranking def test_sample_input1(): pairs = [(0, 1), (1, 2), (2, 3)] assert marathon_ranking(4, 3, pairs) == 'consistent' def test_sample_input2(): pairs = [(0, 1), (2, 1), (1, 3)] assert marathon_ranking(4, 3, pairs) == 'consistent' def test_sample_input3(): p...
[ { "docstring": null, "function_declaration": "def check_consistency(n, m, comparisons):", "function_name": "check_consistency", "parameter_list": "(n, m, comparisons)" }, { "docstring": null, "function_declaration": "def marathon_ranking(n, m, pairs):", "function_name": "marathon_ran...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import defaultdict\n\ndef is_consistent(N, M, comparisons):\n def dfs(v):\n stack = [(v, 0)]\n visited[v] = 0\n while stac...
trial_gpt4o_1
{ "original_instruction": "You are helping to organize a marathon and need to determine the relative ranking of participants based on their reported finishing times. However, some participants have reported their finishing times inconsistently, and you need to detect this.\n\nThe marathon participants' finishing time...
0.604392
Taco_68539
C
[ "check_consistency", "marathon_ranking" ]
2
[ [ "marathon_ranking", "check_consistency" ] ]
1
[]
false
[]
false
pytest
true
[]
true
69c5d00a2d0d47c5408f7a699a3e9bfb23a123c9
7c82ac8a08c82fdaa72b733cdc4e87ad272857fd
v1.0
complete
Taco
Taco_68615_C
def max_block_length(K, components, L): """ Calculate the maximum length of the block that can be created without exceeding L. >>> max_block_length(3, [(5, 3), (10, 2), (3, 8)], 25) 25 >>> max_block_length(2, [(1, 2), (2, 3)], 10) 8 >>> max_block_length(2, [(5, 1), (10, 2)], 20) 20 >>> m...
def max_block_length(K, components, L): dp = [0] * (L + 1) for size, count in components: for j in range(L, size - 1, -1): for k in range(1, count + 1): if j - k * size >= 0: dp[j] = max(dp[j], dp[j - k * size] + k * size) return dp[L] # Fun...
from solution import max_block_length def test_max_block_length_sample(): K = 3 components = [(5, 3), (10, 2), (3, 8)] L = 25 assert max_block_length(K, components, L) == 25 def test_max_block_length_no_reach(): K = 2 components = [(1, 2), (2, 3)] L = 10 assert max_block_length(K, comp...
[ { "docstring": null, "function_declaration": "def max_block_length(K, components, L):", "function_name": "max_block_length", "parameter_list": "(K, components, L)" }, { "docstring": null, "function_declaration": "def solve():", "function_name": "solve", "parameter_list": "()" }...
[ 1, 0 ]
1
medium
0.5
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_block_length(K, components, L):\n dp = [0] * (L + 1)\n \n for size, count in components:\n for j in range(L, size - 1, -1):\n fo...
trial_gpt4o_0
{ "original_instruction": "Jimmy plans to build toy blocks using several types of components. He has various types of components, each of a certain size. Jimmy wants to create a single large block by aligning the components side by side in a row. \n\nHowever, he can only pick each component a specific number of times...
0.576802
Taco_68615
C
[ "max_block_length", "solve" ]
2
[ [ "solve", "max_block_length" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f045247f6324d91eb955eb4142c3693945ce687b
fff4799b34a808489ac2b7e8a1fb12114687c209
v1.0
complete
Taco
Taco_68508_C
def min_swaps_helper(N: int, initial: List[int], target: List[int]) -> int: """ Determines the minimum number of swaps needed to transform the initial sequence into the target sequence. If it's not possible to transform the initial sequence into the target sequence, returns -1. Args: N: the len...
def min_swaps_to_transform(initial, target): if sorted(initial) != sorted(target): return -1 index_dict = {v: i for i, v in enumerate(target)} for i in range(len(initial)): initial[i] = index_dict[initial[i]] visited = [False] * len(initial) swaps = 0 for i in range(len(in...
from solution import min_swaps_helper def test_min_swaps_example(): assert min_swaps_helper(5, [3, 1, 2, 4, 5], [1, 2, 3, 4, 5]) == 2 def test_min_swaps_already_sorted(): assert min_swaps_helper(5, [1, 2, 3, 4, 5], [1, 2, 3, 4, 5]) == 0 def test_min_swaps_reverse(): assert min_swaps_helper(5, [5, 4, 3, 2...
[ { "docstring": null, "function_declaration": "def min_swaps_to_transform(initial, target):", "function_name": "min_swaps_to_transform", "parameter_list": "(initial, target)" }, { "docstring": null, "function_declaration": "def min_swaps_helper(N, initial, target):", "function_name": ...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def minimum_swaps_to_transform(S, T):\n \"\"\"\n Finds the minimum number of swaps needed to transform sequence S into sequence T\n using the Inverse Swap...
trial_gpt4o_2
{ "original_instruction": "Alice is fond of manipulating sequences with unique integer elements. She has devised a special sequence operation called the \"Inverse Swap\".\n\nGiven an initial sequence S1, S2, ..., SN and a target sequence T1, T2, ..., TN derived from S. The Inverse Swap operation consists of the follo...
0.654102
Taco_68508
C
[ "min_swaps_to_transform", "min_swaps_helper" ]
2
[ [ "min_swaps_helper", "min_swaps_to_transform" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8bd1335f837a1c008676940d5790377ee1f43b22
c3f7f8b1a3843e643db3aaa5e7874a56921708d7
v1.0
complete
Taco
Taco_68816_C
def calculate_roman_sum(s: str) -> int: """ Given a string of Roman numeral expressions separated by '+', returns their sum as an integer. >>> calculate_roman_sum("X") == 10 >>> calculate_roman_sum("X+V") == 15 >>> calculate_roman_sum("X+V+XII") == 27 >>> calculate_roman_sum("IX+VIII+III") == 20 ...
def roman_to_int(roman): """ Converts a single Roman numeral string to an integer """ roman_values = { 'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000 } total = 0 prev_value = 0 for char in reversed(roman): value = roman_values[char] if value ...
from solution import calculate_roman_sum def test_single_numeral(): assert calculate_roman_sum("X") == 10 def test_two_numerals(): assert calculate_roman_sum("X+V") == 15 def test_three_numerals(): assert calculate_roman_sum("X+V+XII") == 27 def test_complex_expression(): assert calculate_roman_sum(...
[ { "docstring": "Converts a single Roman numeral string to an integer", "function_declaration": "def roman_to_int(roman):", "function_name": "roman_to_int", "parameter_list": "(roman)" }, { "docstring": "Given a string of Roman numeral expressions separated by '+', returns their sum as an int...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def roman_to_int(roman):\n \"\"\"\n Converts a single Roman numeral string to an integer\n \"\"\"\n roman_values = {\n 'I': 1, 'V': 5, 'X': 10, ...
trial_gpt4o_0
{ "original_instruction": "Write a function `calculate_roman_sum(s)` that takes a string `s` representing a Roman numeral expression. The string will be composed of multiple Roman numerals separated by the plus sign ('+'). Your function should return the sum of these Roman numerals as an integer.\n\nRoman numerals ar...
0.61439
Taco_68816
C
[ "roman_to_int", "calculate_roman_sum" ]
2
[ [ "calculate_roman_sum", "roman_to_int" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8f26447e889feb194434678feb18b67169f65d4e
c4255f453ad3b6dd805c361d000356a82dbe223e
v1.0
complete
Taco
Taco_68664_C
from typing import List, Tuple def shortest_path_from_one(N: int, M: int, edge_list: List[Tuple[int, int, int]]) -> List[int]: """ Compute the length of the shortest path from vertex 1 to all other vertices. :param N: The number of vertices :param M: The number of edges :param edge_list: List ...
import heapq def dijkstra(N, edges): """ Compute the shortest path from vertex 1 to all other vertices. :param N: Total number of vertices. :param edges: List of tuples representing directed edges (u, v, w) with weight w. :return: List of shortest distances from vertex 1 to vertex i (2 <= i <= N), ...
from solution import shortest_path_from_one def test_example_case(): N, M = 5, 6 edges = [ (1, 2, 2), (1, 3, 4), (2, 3, 1), (3, 4, 1), (2, 4, 7), (5, 3, 5) ] assert shortest_path_from_one(N, M, edges) == [2, 3, 4, -1] def test_no_path_case(): # 4 ver...
[ { "docstring": "Compute the shortest path from vertex 1 to all other vertices.\n:param N: Total number of vertices.\n:param edges: List of tuples representing directed edges (u, v, w) with weight w.\n:return: List of shortest distances from vertex 1 to vertex i (2 <= i <= N), or -1 if unreachable.", "functi...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef shortest_path(N, M, edges):\n # Create adjacency list for the graph\n graph = [[] for _ in range(N + 1)]\n for u, v, w in edges:\n ...
trial_gpt4o_2
{ "original_instruction": "You are given a directed graph with $N$ vertices (numbered $1$ through $N$) and $M$ edges. Each edge has an associated integer weight. You need to compute the length of the shortest path from vertex $1$ to all other vertices. If a vertex is unreachable from vertex $1$, output $-1$ for that ...
0.649727
Taco_68664
C
[ "dijkstra", "shortest_path_from_one" ]
2
[ [ "shortest_path_from_one", "dijkstra" ] ]
1
[]
false
[]
false
pytest
true
[]
true
96bf4a7af168ac8b213d3064de0afafc17595f4f
cf0fe4c2545de179c00f9cc4cfaa0bb2f0257578
v1.0
complete
Taco
Taco_68785_C
def paint_canvas(n: int, m: int, k: int, p: int, q: int, r: int) -> Tuple[str, List[List[int]]]: """ Determine if there exists a way to paint the entire canvas following the given rules. >>> paint_canvas(3, 3, 3, 2, 2, 1) ("YES", [[1, 2, 3], [2, 3, 1], [3, 1, 2]]) >>> paint_canvas(3, 3, 2, 2, 2, 2) ...
def can_color(canvas, i, j, n, m, k, p, q, r): used_colors = set() # Check colors directly above within p range for x in range(1, p+1): if i-x >= 0: used_colors.add(canvas[i-x][j]) # Check colors directly to the left within q range for y in range(1, q+1): if j-y >= 0: ...
from solution import paint_canvas def test_case_1(): n, m, k = 3, 3, 3 p, q, r = 2, 2, 1 assert paint_canvas(n, m, k, p, q, r) == ("YES", [[1, 2, 3], [2, 3, 1], [3, 1, 2]]) def test_case_2(): n, m, k = 3, 3, 2 p, q, r = 2, 2, 2 assert paint_canvas(n, m, k, p, q, r) == ("NO", []) def test_case...
[ { "docstring": null, "function_declaration": "def can_color(canvas, i, j, n, m, k, p, q, r):", "function_name": "can_color", "parameter_list": "(canvas, i, j, n, m, k, p, q, r)" }, { "docstring": null, "function_declaration": "def paint_canvas(n, m, k, p, q, r):", "function_name": "p...
[ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_paint_canvas(n, m, k, p, q, r):\n def is_valid(color, matrix, i, j):\n for x in range(1, p+1):\n if i - x >= 0 and matrix[i-x][j] == c...
trial_gpt4o_5
{ "original_instruction": "Alyssa loves painting and geometry. She has a canvas represented as a 2D grid with dimensions `n x m`, where each cell can be painted from a set of `k` possible colors. Each color is represented by a distinct integer from `1` to `k`. Alyssa strives to achieve a beautiful pattern on her canv...
0.56112
Taco_68785
C
[ "can_color", "paint_canvas", "format_canvas", "main" ]
4
[ [ "paint_canvas", "can_color" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5c596322b2a673890d26e82404dac570d98a8877
755a670bb301d97ff8ddae25a56a1cc89e570c8b
v1.0
complete
Taco
Taco_68673_C
def get_resource_score(resources): """ Returns the sum of the resource units mod 10^9 + 7. """ MOD = 10**9 + 7 return sum(resources) % MOD def update_resource(resources, index, new_value): """ Updates the resource at the given index with the new value and returns the updated sum. """ ...
def get_resource_score(resources): """ Returns the sum of the resource units mod 10^9 + 7. """ MOD = 10**9 + 7 return sum(resources) % MOD def update_resource(resources, index, new_value): """ Updates the resource at the given index with the new value and returns the updated sum. """ ...
from solution import resource_management def test_initial_setup(): assert resource_management(3, [1, 2, 3], []) == [6] def test_single_update(): assert resource_management(3, [1, 2, 3], [(2, 5)]) == [6, 9] def test_multiple_updates(): assert resource_management(3, [1, 2, 3], [(2, 5), (1, 6)]) == [6, 9, 1...
[ { "docstring": "Returns the sum of the resource units mod 10^9 + 7.", "function_declaration": "def get_resource_score(resources):", "function_name": "get_resource_score", "parameter_list": "(resources)" }, { "docstring": "Updates the resource at the given index with the new value and returns...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def get_resource_score(resources):\n \"\"\"\n Returns the sum of the resource units mod 10^9 + 7.\n \"\"\"\n MOD = 10**9 + 7\n return sum(resources)...
trial_gpt4o_0
{ "original_instruction": "In a parallel universe, the city of Bitland has a peculiar system for maintaining its resources. The city consists of n sectors, each having a certain number of resource units associated with it. The resource units of the i-th sector are denoted by r_{i}. Managing these resources is crucial...
0.532535
Taco_68673
C
[ "get_resource_score", "update_resource", "resource_management" ]
3
[ [ "resource_management", "get_resource_score" ], [ "resource_management", "update_resource" ], [ "update_resource", "get_resource_score" ] ]
3
[]
false
[]
false
pytest
true
[]
true
5062dc63399adca69fa639f4b5e9dd338a9bbf0a
765ea6aa135c8f7439e0b298741aa20fde2a6b2f
v1.0
complete
Taco
Taco_68666_C
from typing import List def solve(test_cases: List[str]) -> List[int]: """Given a list of strings, return the length of the longest substring of each string such that the length of the substring is a prime number and the substring is also a palindrome. If no such substring exists, return -1. >>> solv...
def is_palindrome(s): return s == s[::-1] def generate_primes(n): primes = [] sieve = [True] * (n + 1) for p in range(2, n + 1): if sieve[p]: primes.append(p) for i in range(p * p, n + 1, p): sieve[i] = False return primes def longest_prime_length_pa...
from solution import solve def test_sample_cases(): assert solve(["abacabad", "abcde"]) == [7, -1] def test_single_character(): assert solve(["a"]) == [-1] def test_no_palindromes(): assert solve(["abcdefghijklmnopqrstuvwxyz"]) == [-1] def test_all_same_characters(): assert solve(["aaaaaaa"]) == [7]...
[ { "docstring": null, "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def generate_primes(n):", "function_name": "generate_primes", "parameter_list": "(n)" }, { "doc...
[ 0, 0, 0, 0, 0, 1, 1, 1, 0, 0 ]
3
hard
0.3
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"Helper function to check if a number is a prime number.\"\"\"\n if num <= 1:\n return False\n for i in range(2, int(num*...
trial_gpt4o_7
{ "original_instruction": "Prime Length Palindrome Substring\n\nGiven a string $S$ of lowercase alphabets, you need to find the length of the longest substring of $S$ such that the length of the substring is a prime number and the substring is also a palindrome. If no such substring exists, output $-1$.\n\n##### Inpu...
0.660557
Taco_68666
C
[ "is_palindrome", "generate_primes", "longest_prime_length_palindrome", "solve" ]
4
[ [ "longest_prime_length_palindrome", "generate_primes" ], [ "longest_prime_length_palindrome", "is_palindrome" ], [ "solve", "longest_prime_length_palindrome" ] ]
3
[]
false
[]
false
pytest
true
[]
true
fb5228ac2c1d51422dc22e77953cc6e269e1e8d0
aba2a1d90c0463b50b257503c79dc17ab47207b1
v1.0
complete
Taco
Taco_69080_C
from typing import List def largest_number(nums: List[int]) -> str: """ Returns the concatenation of the numbers in nums in a way that forms the largest possible number. >>> largest_number([3, 30, 34, 5, 9]) '9534330' >>> largest_number([10, 2]) '210' >>> largest_number([0, 0, 0, 0]) '0' >>> l...
from functools import cmp_to_key def compare(x, y): if x + y > y + x: return -1 elif x + y < y + x: return 1 else: return 0 def largest_number(nums): """ Returns the concatenation of the numbers in nums in a way that forms the largest possible number. """ # Convert ...
from solution import largest_number def test_single_digit_numbers(): assert largest_number([1, 2, 3, 4, 5]) == '54321' def test_double_digit_numbers(): assert largest_number([10, 2]) == '210' def test_complex_case(): assert largest_number([3, 30, 34, 5, 9]) == '9534330' def test_all_zeros(): ass...
[ { "docstring": null, "function_declaration": "def compare(x, y):", "function_name": "compare", "parameter_list": "(x, y)" }, { "docstring": "Returns the concatenation of the numbers in nums in a way that forms the largest possible number.", "function_declaration": "def largest_number(num...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from functools import cmp_to_key\n\ndef largest_number(nums):\n \"\"\"\n Returns the concatenation of integers in the list nums that forms the largest possib...
trial_gpt4o_2
{ "original_instruction": "You are given a function that accepts a list of non-negative integers and returns the concatenation of those integers in the format that produces the largest possible number.\n\nYour task is to implement this function. The resulting number should still adhere to integer constraints (e.g., n...
0.767
Taco_69080
C
[ "compare", "largest_number" ]
2
[ [ "largest_number", "compare" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8733863f3500dacf4c04d4fb1e23c61ad0153eb8
480d63e3c0e45653cff6a0159bc6f74e953eac87
v1.0
complete
Taco
Taco_69074_C
def unique_paths_in_grid(grid_str: str) -> int: """ Determine the number of unique valid paths in a grid. This function takes a string representation of a grid and returns the number of unique valid paths from the top-left corner to the bottom-right corner. The first line of the input string conta...
def count_unique_paths(grid): R = len(grid) C = len(grid[0]) if grid[0][0] == '1' or grid[R-1][C-1] == '1': return 0 dp = [[0] * C for _ in range(R)] dp[0][0] = 1 for i in range(R): for j in range(C): if grid[i][j] == '1': dp[i][j] = 0 ...
from solution import unique_paths_in_grid def test_example1(): grid = "3 3\n000\n010\n000" assert unique_paths_in_grid(grid) == 2 def test_example2(): grid = "2 2\n00\n11" assert unique_paths_in_grid(grid) == 0 def test_example3(): grid = "4 4\n0000\n0110\n0000\n0010" assert unique_paths_in_g...
[ { "docstring": null, "function_declaration": "def count_unique_paths(grid):", "function_name": "count_unique_paths", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def unique_paths_in_grid(grid_str):", "function_name": "unique_paths_in_grid", "paramet...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def num_paths(grid):\n R = len(grid)\n C = len(grid[0])\n \n if grid[0][0] == '1' or grid[R-1][C-1] == '1':\n return 0\n \n dp = [[0] * C ...
trial_gpt4o_2
{ "original_instruction": "You are given a rectangular grid with R rows and C columns, where each cell contains either '0' or '1'. '0' represents an empty cell while '1' represents an obstacle. A path from the top-left corner (0, 0) to the bottom-right corner (R-1, C-1) is valid if it only moves right or down at each...
0.642255
Taco_69074
C
[ "count_unique_paths", "unique_paths_in_grid" ]
2
[ [ "unique_paths_in_grid", "count_unique_paths" ] ]
1
[]
false
[]
false
pytest
true
[]
true
59fc883755638fd47949eab6eeb2c1e1be6bcc6e
06c2f4b9293a6ee30a68b895a2f5295aec91118f
v1.0
complete
Taco
Taco_68624_C
def maximalRectangle(grid): """Find the area of the largest rectangular patch of grassy land in the given n x n binary matrix where 0 represents grassy cell and 1 represents waterlogged cell. Args: grid (List[List[int]]): A n x n binary matrix representing the garden layout. Returns: int: ...
def maximalRectangle(grid): if not grid: return 0 n = len(grid) heights = [0] * n max_area = 0 for i in range(n): for j in range(n): heights[j] = heights[j] + 1 if grid[i][j] == 0 else 0 max_area = max(max_area, largestRectangleArea(heights)) return...
def test_maximalRectangle(): assert maximalRectangle([ [0, 1, 1, 0, 1], [1, 0, 1, 1, 0], [0, 0, 1, 0, 0], [1, 1, 0, 0, 0], [1, 0, 0, 1, 0] ]) == 4 assert maximalRectangle([ [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0...
[ { "docstring": null, "function_declaration": "def maximalRectangle(grid):", "function_name": "maximalRectangle", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def largestRectangleArea(heights):", "function_name": "largestRectangleArea", "parameter_li...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_histogram_area(heights):\n \"\"\"\n Helper function to calculate \"largest rectangle in histogram\" problem.\n \"\"\"\n stack = []\n max_are...
trial_gpt4o_1
{ "original_instruction": "In the kingdom of Gridlandia, there is a beautiful square garden of size $n \\times n$. The garden is divided into unit square cells. Most of the cells are grassy, but some cells are waterlogged and cannot be stepped on.\n\nGridlandia’s Queen wants to host a grand feast in the garden, and f...
0.644922
Taco_68624
C
[ "maximalRectangle", "largestRectangleArea" ]
2
[ [ "maximalRectangle", "largestRectangleArea" ] ]
1
[]
false
[]
false
pytest
false
[]
true
62a5f800fb4423bdc50ac4a8f330c88fb6fc7470
316ecfa9eb4d40293a9314b958daaf9aa945c41d
v1.0
complete
Taco
Taco_69034_C
from math import comb def count_valid_configurations(n: int, m: int, k: int) -> int: """ Returns the number of valid configurations of an n by m grid with exactly k 'A' molecules such that no two 'A' molecules are in the same row or column. >>> count_valid_configurations(2, 2, 2) == 2 >>> cou...
from math import comb def count_valid_configurations(n, m, k): """ Returns the number of valid configurations of an n by m grid with exactly k 'A' molecules such that no two 'A' molecules are in the same row or column. """ if k > min(n, m): return 0 return comb(n, k) * comb(m, k) *...
from solution import count_valid_configurations def test_example1(): assert count_valid_configurations(2, 2, 2) == 2 def test_example2(): assert count_valid_configurations(3, 3, 1) == 9 def test_more_than_possible(): assert count_valid_configurations(2, 2, 3) == 0 def test_zero_configurations(): ass...
[ { "docstring": "Returns the number of valid configurations of an n by m grid with exactly k 'A' molecules\nsuch that no two 'A' molecules are in the same row or column.", "function_declaration": "def count_valid_configurations(n, m, k):", "function_name": "count_valid_configurations", "parameter_lis...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef num_configurations(n, m, k):\n \"\"\"\n Calculate number of valid configurations where no two 'A' molecules are in the same row or column....
trial_gpt4o_9
{ "original_instruction": "Robert the Scientist is working in his laboratory to create a special grid that adheres to a unique set of rules. This grid is an n by m matrix, where each cell can either contain an 'A' molecule or a 'B' molecule. The matrix is organized such that no two 'A' molecules can be in the same ro...
0.5773
Taco_69034
C
[ "count_valid_configurations", "factorial" ]
2
[ [ "count_valid_configurations", "factorial" ] ]
1
[]
false
[]
false
pytest
true
[]
true
171a66e7d20a82957b7dce3dbc41bd862d2ba454
346a13a93079f6e76040595ee1ab07d4d5d084f5
v1.0
complete
Taco
Taco_68912_C
def get_sorted_identifiers(data: str) -> List[int]: """ Given a list of blocks with their identifiers, sizes, and densities, sort them according to the rules: 1. Blocks with higher density should be placed first. 2. If two blocks have the same density, the larger block should come before the smaller one. ...
def sort_blocks(blocks): """ Sorts blocks based on given rules: 1. Blocks with higher density should be placed first. 2. If two blocks have the same density, the larger block should come before the smaller one. 3. If two blocks have both the same density and size, they can be in any order relative t...
from solution import get_sorted_identifiers def test_sort_blocks_example(): input_data = """4 1 10 5 Engine 2 8 6 Coach 3 15 4 Freight 4 15 7 Tender""" sorted_identifiers = get_sorted_identifiers(input_data) assert sorted_identifiers == [4, 3, 1, 2] def test_sort_blocks_same_density(): input_data = ""...
[ { "docstring": "Sorts blocks based on given rules:\n1. Blocks with higher density should be placed first.\n2. If two blocks have the same density, the larger block should come before the smaller one.\n3. If two blocks have both the same density and size, they can be in any order relative to each other.\n\nArgs:...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sort_blocks(blocks):\n \"\"\"\n Sort blocks by density in descending order. For blocks with the same density, \n sort by size in descending order.\n ...
trial_gpt4o_1
{ "original_instruction": "Santa Claus wants to build a toy train from blocks of varying sizes. Each block has a specific size, density, and an identifier. To assemble the train, he must decide the order in which these blocks should be stacked. The train's stability directly relates to the blocks' densities and their...
0.531627
Taco_68912
C
[ "sort_blocks", "process_input", "get_sorted_identifiers" ]
3
[ [ "get_sorted_identifiers", "process_input" ], [ "get_sorted_identifiers", "sort_blocks" ] ]
2
[ "process_input" ]
false
[]
false
pytest
true
[]
true
81200c30a4b2e3bb658b307ebdfc0f747fa4be8c
3a96e17a6b44addc4edb4c5fb6857d34b6d77b05
v1.0
complete
Taco
Taco_68397_C
def can_form_right_angled_triangle(points): """ Determine if a set of magical points can form a right-angled triangle with the right angle at the origin (0, 0). Args: points (List[Tuple[int, int]]): List of tuples containing coordinates (xi, yi). Returns: str: "YES" if the points can ...
def can_form_right_angled_triangle(points): """ Determine if a set of magical points can form a right-angled triangle with the right angle at the origin (0, 0). Args: points (List[Tuple[int, int]]): List of tuples containing coordinates (xi, yi). Returns: str: "YES" if the points can ...
from solution import can_form_right_angled_triangle, check_cities def test_can_form_right_angled_triangle(): assert can_form_right_angled_triangle([(0, 0), (1, 2), (3, 0)]) == "YES" assert can_form_right_angled_triangle([(0, 0), (6, 8), (3, 0)]) == "YES" assert can_form_right_angled_triangle([(0, 0), (1, 1...
[ { "docstring": "Determine if a set of magical points can form a right-angled triangle \nwith the right angle at the origin (0, 0).\n\nArgs:\npoints (List[Tuple[int, int]]): List of tuples containing coordinates (xi, yi).\n\nReturns:\nstr: \"YES\" if the points can form a right-angled triangle with the right ang...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_form_right_angled_triangle(points):\n points_set = set(points) # Create a set of points for quicker lookups\n for x, y in points:\n # We need...
trial_gpt4o_2
{ "original_instruction": "In a distant kingdom, there existed a wise magician who had the ability to create powerful magic spells. To channel his magical abilities, the magician used crystals arranged in a specific manner. These crystals are placed in different cities, each having a certain number of magical points....
0.680515
Taco_68397
C
[ "can_form_right_angled_triangle", "check_cities" ]
2
[ [ "check_cities", "can_form_right_angled_triangle" ] ]
1
[]
false
[]
false
pytest
true
[]
true
da896019a26ad75f469320736a6cdf7b7ece7d63
f76681582834a5a2da47f72e4de372fdc9cb432d
v1.0
complete
Taco
Taco_69123_C
def process_queries(n: int, arr: List[int], queries: List[Tuple[int, int]]) -> List[int]: """ Processes the queries to find the sum of subarrays defined by the given queries. >>> process_queries(5, [1, 2, 3, 4, 5], [(1, 3), (2, 5), (1, 5)]) [6, 14, 15] >>> process_queries(1, [10], [(1, 1)...
def compute_prefix_sums(arr): """ Computes the prefix sums of the given array. """ n = len(arr) prefix_sums = [0] * (n + 1) for i in range(1, n + 1): prefix_sums[i] = prefix_sums[i - 1] + arr[i - 1] return prefix_sums def range_sum(prefix_sums, l, r): """ Computes the sum ...
from solution import process_queries def test_process_queries_example(): n = 5 arr = [1, 2, 3, 4, 5] queries = [(1, 3), (2, 5), (1, 5)] expected_result = [6, 14, 15] result = process_queries(n, arr, queries) assert result == expected_result def test_process_queries_single_element(): n = 1 ...
[ { "docstring": "Computes the prefix sums of the given array.", "function_declaration": "def compute_prefix_sums(arr):", "function_name": "compute_prefix_sums", "parameter_list": "(arr)" }, { "docstring": "Computes the sum of the subarray from index l to r using the prefix sums array.", "...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def preprocess_array(A):\n \"\"\"\n Preprocess the array to create a prefix sum array.\n \n Args:\n A: List of integers.\n \n Returns:\n Li...
trial_gpt4o_2
{ "original_instruction": "Given an array $A$ of $n$ integers, and $q$ queries, each of which asks for the sum of all values in a subarray defined by two indices $l$ and $r$ (inclusive). Your task is to efficiently compute the sum for each query.\n\nConstraints\n\n- $1 \\leq n, q \\leq 100,000$\n- $1 \\leq A[i] \\leq...
0.625248
Taco_69123
C
[ "compute_prefix_sums", "range_sum", "process_queries" ]
3
[ [ "process_queries", "compute_prefix_sums" ], [ "process_queries", "range_sum" ] ]
2
[ "process_queries" ]
false
[]
false
pytest
true
[]
true
6c958dc7754b5c6eadf85fa9aad2643dfb9e4792
baa8b157eaa83d7a202435351133906488ed5c11
v1.0
complete
Taco
Taco_69301_C
from typing import List def calculate_anagram_pairs(n: int, passwords: List[str]) -> int: """ Returns the number of pairs of passwords that are case-insensitive anagrams of each other. >>> calculate_anagram_pairs(4, ["abc", "Bac", "adb", "BAD"]) 2 >>> calculate_anagram_pairs(3, ["a", "A", "a"]) 3 ...
from collections import defaultdict def count_anagram_pairs(passwords): """ Returns the number of pairs of passwords that are case-insensitive anagrams of each other. """ counter = defaultdict(int) for password in passwords: sorted_password = ''.join(sorted(password.lower())) counte...
from solution import calculate_anagram_pairs def test_case_1(): n = 4 passwords = ["abc", "Bac", "adb", "BAD"] assert calculate_anagram_pairs(n, passwords) == 2 def test_case_2(): n = 3 passwords = ["a", "A", "a"] assert calculate_anagram_pairs(n, passwords) == 3 def test_case_3(): n = 3 ...
[ { "docstring": "Returns the number of pairs of passwords that are case-insensitive anagrams of each other.", "function_declaration": "def count_anagram_pairs(passwords):", "function_name": "count_anagram_pairs", "parameter_list": "(passwords)" }, { "docstring": null, "function_declaratio...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import defaultdict\n\ndef count_anagram_pairs(passwords):\n \"\"\"\n Counts the number of pairs of passwords that are case-insensitive anagr...
trial_gpt4o_2
{ "original_instruction": "John is a security expert who has discovered a security vulnerability in password patterns. He observes that many users often create passwords that are anagrams of one another, just with different casing per character. In order to analyze the vulnerability, John wants to check how many pass...
0.714644
Taco_69301
C
[ "count_anagram_pairs", "calculate_anagram_pairs" ]
2
[ [ "calculate_anagram_pairs", "count_anagram_pairs" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a5c98b2fe641e245adebea3b680c9d3f5d48af2b
101422d1a8246db582e7541b796eafd992e06234
v1.0
complete
Taco
Taco_68318_C
from typing import List, Tuple def floyd_warshall(n: int, distances: List[Tuple[int, int, int]]) -> List[List[int]]: """ Perform the Floyd-Warshall algorithm to find shortest paths between all pairs of nodes. """ pass def min_travel_time(n: int, m: int, edges: List[Tuple[int, int, int]], q: int, queries: List...
def floyd_warshall(n, distances): # Initialize the distance matrix with infinity inf = float('inf') dist = [[inf] * (n + 1) for _ in range(n + 1)] # Distance from a node to itself is 0 for i in range(1, n + 1): dist[i][i] = 0 # Fill initial distances based on input for u, v...
def test_min_travel_time(): n, m = 4, 3 edges = [ (1, 2, 4), (2, 3, 1), (3, 4, 2) ] q = 3 queries = [ (1, 4), (1, 3), (2, 1) ] expected = [7, 5, 4] assert min_travel_time(n, m, edges, q, queries) == expected def test_min_travel_time_discon...
[ { "docstring": null, "function_declaration": "def floyd_warshall(n, distances):", "function_name": "floyd_warshall", "parameter_list": "(n, distances)" }, { "docstring": null, "function_declaration": "def min_travel_time(n, m, edges, q, queries):", "function_name": "min_travel_time",...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def floyd_warshall(n, distances):\n # Initialize the distance matrix with infinity\n inf = float('inf')\n dist = [[inf] * (n + 1) for _ in range(n + 1)]\n...
trial_gpt4o_0
{ "original_instruction": "A city is planning to construct a new public transportation system with `N` subway stations. The stations are connected with `M` bidirectional subway lines, each having a specific travel time. To ensure efficiency, the city wants to optimize the travel time between all pairs of stations.\n\...
0.665387
Taco_68318
C
[ "floyd_warshall", "min_travel_time" ]
2
[ [ "min_travel_time", "floyd_warshall" ] ]
1
[]
false
[]
false
pytest
false
[]
true
b1fc40f32d1f89c878619cbc8cfb0b1e83f10643
4f416a79d66fb9d8f9a61ff9f5d8a0d3d3824a99
v1.0
complete
Taco
Taco_68777_C
def find_shortest_path(n: int, m: int, edges: List[Tuple[int, int, int]]) -> int: """ Find the smallest weight of a path from node `1` to node `n` in an undirected graph. Args: n (int): Number of nodes in the graph. m (int): Number of edges in the graph. edges (List[Tuple[int, int, int]]): List...
import heapq def dijkstra(n, edges): def build_graph(n, edges): graph = {i: [] for i in range(1, n+1)} for u, v, w in edges: graph[u].append((v, w)) graph[v].append((u, w)) return graph graph = build_graph(n, edges) pq = [(0, 1)] # (distance, node) ...
from solution import find_shortest_path def test_example_1(): edges = [ (1, 2, 5), (2, 3, 10), (1, 3, 20), (3, 4, 1) ] assert find_shortest_path(4, 4, edges) == 16 def test_example_2(): edges = [ (1, 2, 1), (2, 3, 2), (3, 1, 4) ] assert f...
[ { "docstring": null, "function_declaration": "def dijkstra(n, edges):", "function_name": "dijkstra", "parameter_list": "(n, edges)" }, { "docstring": null, "function_declaration": "def find_shortest_path(n, m, edges):", "function_name": "find_shortest_path", "parameter_list": "(n...
[ 0, 0, 0, 0, 1, 1, 0, 0, 1 ]
3
medium
0.333
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared1_results_combined.jsonl", "solution_code": "import heapq\n\ndef dijkstra(n, graph, start=1, end=None):\n \"\"\"\n Dijkstra's algorithm to find the shortest path in a graph.\n ...
trial_gpt4o_9
{ "original_instruction": "Given an undirected graph with `n` nodes and `m` edges, each edge has a weight. You are to find the smallest weight of a path from node `1` to node `n`. If no such path exists, return `-1`. The graph might contain cycles.\n\nInput:\n- The first line contains two integers `n` and `m` (1 ≤ n ...
0.771343
Taco_68777
C
[ "dijkstra", "find_shortest_path" ]
2
[ [ "find_shortest_path", "dijkstra" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3882f654dd6a516ca21768f24383af716295a148
0869cf1e82e54740bac959099887642c47f98278
v1.0
complete
Taco
Taco_68823_C
import math from itertools import combinations from typing import List, Tuple def distance(p1: Tuple[int, int], p2: Tuple[int, int]) -> float: """Calculate the Euclidean distance between two points p1 and p2. >>> distance((0, 0), (3, 4)) 5.0 >>> distance((1, 1), (1, 1)) 0.0 """ pass def ge...
import math from itertools import combinations def distance(p1, p2): """ Calculate the Euclidean distance between two points p1 and p2. """ return math.sqrt((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2) def get_circle_center_and_radius(p1, p2, p3): """ Find the circumcenter and radius of the ci...
import math from solution import distance, get_circle_center_and_radius, smallest_enclosing_circle def test_distance(): assert distance((0, 0), (3, 4)) == 5 assert distance((1, 1), (1, 1)) == 0 assert distance((-1, -1), (1, 1)) == math.sqrt(8) def test_get_circle_center_and_radius(): center, radius = ...
[ { "docstring": "Calculate the Euclidean distance between two points p1 and p2.", "function_declaration": "def distance(p1, p2):", "function_name": "distance", "parameter_list": "(p1, p2)" }, { "docstring": "Find the circumcenter and radius of the circle passing through points p1, p2, and p3....
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\nfrom typing import List, Tuple\n\ndef find_smallest_enclosing_circle(points: List[Tuple[int, int]]) -> Tuple[float, float, float]:\n def dist(p1, p...
trial_gpt4o_1
{ "original_instruction": "You are given a set of points on a 2D plane, and you need to determine the smallest circle that can enclose all the points. If there are multiple circles with the same minimum radius, return the one whose center has the smallest x-coordinate. If there is still a tie, return the one with the...
0.601891
Taco_68823
C
[ "distance", "get_circle_center_and_radius", "smallest_enclosing_circle", "main" ]
4
[ [ "get_circle_center_and_radius", "distance" ], [ "smallest_enclosing_circle", "distance" ], [ "smallest_enclosing_circle", "get_circle_center_and_radius" ] ]
3
[]
false
[]
false
pytest
true
[]
true
b1bdeded4aab665a1bed0f5aa1bdc15136609c33
143e8e956bfe01217a93bb36223bc783373e4c92
v1.0
complete
Taco
Taco_68460_C
def pet_distribution(t, populations): """ Returns the possible distributions of people owning cats and dogs. Args: t: int, number of test cases. populations: list of int, populations for each test case. Returns: list of list of tuples: each list of tuples corresponds to one test case and c...
def pet_distribution(t, populations): """ Returns the possible distributions of people owning cats and dogs. Args: t: int, number of test cases. populations: list of int, populations for each test case. Returns: list of list of tuples: each list of tuples corresponds to one test case and co...
from solution import pet_distribution, format_pet_distribution def test_pet_distribution(): assert pet_distribution(1, [2]) == [ [(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (2, 0)] ] assert pet_distribution(1, [3]) == [ [(0, 0), (0, 1), (0, 2), (0, 3), (1, 0), (1, 1), (1, 2), (2, 0), (2, 1), (...
[ { "docstring": "Returns the possible distributions of people owning cats and dogs.\nArgs:\nt: int, number of test cases.\npopulations: list of int, populations for each test case.\n\nReturns:\nlist of list of tuples: each list of tuples corresponds to one test case and contains (x, y) pairs.", "function_dec...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def pet_distribution(t, cases):\n results = []\n for n in cases:\n combinations = []\n for x in range(n + 1):\n for y in range(n - x...
trial_gpt4o_2
{ "original_instruction": "In a small town, there's a population of n people who each have one or no pet. Each person has either a cat, a dog, or no pet at all. The local government wants to understand the distribution of pets in the town, so they asked you to help them determine the possible combinations of cat and ...
0.666982
Taco_68460
C
[ "pet_distribution", "format_pet_distribution", "main" ]
3
[ [ "format_pet_distribution", "pet_distribution" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0d93a8cfb65c2dac06c41f5236c3e7a16eba245c
15b91ebcdd845dfb915646594d3c3b648c3954c2
v1.0
complete
Taco
Taco_68987_C
MOD = 1000000007 def preprocess_prefix_sums(arr): """ Preprocess the array to compute prefix sums. """ n = len(arr) prefix_sums = [0] * (n + 1) for i in range(1, n + 1): prefix_sums[i] = (prefix_sums[i - 1] + arr[i - 1]) % MOD return prefix_sums def query_sum(prefix_sums, l, r): ...
MOD = 1000000007 def preprocess_prefix_sums(arr): """ Preprocess the array to compute prefix sums. """ n = len(arr) prefix_sums = [0] * (n + 1) for i in range(1, n + 1): prefix_sums[i] = (prefix_sums[i - 1] + arr[i - 1]) % MOD return prefix_sums def query_sum(prefix_sums, l, r): ...
def test_preprocess_prefix_sums(): arr = [1, 2, 3, 4, 5] expected_prefix_sums = [0, 1, 3, 6, 10, 15] assert preprocess_prefix_sums(arr) == expected_prefix_sums def test_query_sum(): prefix_sums = [0, 1, 3, 6, 10, 15] assert query_sum(prefix_sums, 1, 3) == 6 assert query_sum(prefix_sums, 2, 4) =...
[ { "docstring": "Preprocess the array to compute prefix sums.", "function_declaration": "def preprocess_prefix_sums(arr):", "function_name": "preprocess_prefix_sums", "parameter_list": "(arr)" }, { "docstring": "Return the sum of subarray from index l to r (1-based index), modulo 1000000007."...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def compute_subarray_sums(n, q, array, queries):\n \"\"\"\n Computes the sum of subarrays using given queries.\n \n Args:\n n : int : Number of elem...
trial_gpt4o_2
{ "original_instruction": "Given an array of n integers, you need to process q queries. Each query contains two integers l and r, and you need to determine the sum of the subarray that starts at index l and ends at index r. You need to print the result of each query.\n\nNote that the sum of the subarray should be tak...
0.553402
Taco_68987
C
[ "preprocess_prefix_sums", "query_sum", "process_queries" ]
3
[ [ "process_queries", "preprocess_prefix_sums" ], [ "process_queries", "query_sum" ] ]
2
[ "process_queries" ]
false
[]
false
pytest
false
[]
true
157943085be090880c6c29a13ea24ef9344557e3
96811e180770df68322f5f75eabb21b82f2f4c42
v1.0
complete
Taco
Taco_69203_C
def highest_unique_words_paragraph(paragraphs: List[str]) -> int: """ You are given a large text document containing multiple paragraphs. Your task is to find the paragraph which contains the highest number of unique words. A word is defined as a contiguous sequence of non-space characters and is case-ins...
def highest_unique_words_paragraph(paragraphs): def unique_word_count(paragraph): words = set(word.lower() for word in re.findall(r'\b\w+\b', paragraph)) return len(words) max_unique_words = 0 paragraph_index = 0 for i, paragraph in enumerate(paragraphs): count = unique...
def test_highest_unique_words_paragraph(): paragraphs1 = [ "This is the first paragraph.", "Here is the second paragraph, which is slightly longer than the first.", "The third paragraph is here." ] assert highest_unique_words_paragraph(paragraphs1) == 2 paragraphs2 = [ "...
[ { "docstring": null, "function_declaration": "def highest_unique_words_paragraph(paragraphs):", "function_name": "highest_unique_words_paragraph", "parameter_list": "(paragraphs)" }, { "docstring": null, "function_declaration": "def find_paragraph_with_highest_unique_words():", "func...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import re\n\ndef find_paragraph_with_most_unique_words(paragraphs):\n max_unique_count = 0\n result_index = 0\n \n for index, paragraph in enumerate(pa...
trial_gpt4o_1
{ "original_instruction": "You are given a large text document containing multiple paragraphs. Your task is to find the paragraph which contains the highest number of unique words. A word is defined as a contiguous sequence of non-space characters and is case-insensitive (i.e., \"Word\" and \"word\" should be conside...
0.683971
Taco_69203
C
[ "highest_unique_words_paragraph", "find_paragraph_with_highest_unique_words" ]
2
[ [ "find_paragraph_with_highest_unique_words", "highest_unique_words_paragraph" ] ]
1
[]
false
[]
false
pytest
false
[]
true
b83a7a0de257d14bf06efdc6593bba99e20513a3
ae152d5911a9680b42c34356c1823a117d12858b
v1.0
complete
Taco
Taco_68604_C
from typing import List def unique_paths_with_obstacles(grid: List[List[int]]) -> int: """ Determine the number of unique paths the robot can take to reach the bottom right corner of the grid without colliding with any obstacles. Args: - grid (List[List[int]]): The grid representing the field with obs...
def unique_paths_with_obstacles(grid): n = len(grid) m = len(grid[0]) if n > 0 else 0 if grid[0][0] == 1 or grid[n-1][m-1] == 1: return 0 dp = [[0]*m for _ in range(n)] dp[0][0] = 1 for i in range(n): for j in range(m): if grid[i][j] == 1: dp[i][j] ...
from solution import unique_paths_with_obstacles, find_unique_paths, parse_input def test_unique_paths_with_obstacles(): grid1 = [ [0, 0, 0], [0, 1, 0], [0, 0, 0] ] assert unique_paths_with_obstacles(grid1) == 2 grid2 = [ [0, 1, 0], [0, 1, 0], [0, 0, 0] ...
[ { "docstring": null, "function_declaration": "def unique_paths_with_obstacles(grid):", "function_name": "unique_paths_with_obstacles", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def find_unique_paths(test_cases):", "function_name": "find_unique_paths"...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def unique_paths_with_obstacles(test_cases):\n results = []\n \n for case in test_cases:\n n, m, grid = case\n if grid[0][0] == 1 or grid[n-...
trial_gpt4o_1
{ "original_instruction": "A land navigation robot is deployed in a grid with dimensions n x m. The grid contains some obstacles, represented as 1s, while free spaces are represented as 0s. The robot starts at the top left corner (1, 1) and must reach the bottom right corner (n, m). The robot can only move right or d...
0.635811
Taco_68604
C
[ "unique_paths_with_obstacles", "find_unique_paths", "parse_input", "main" ]
4
[ [ "find_unique_paths", "unique_paths_with_obstacles" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
d452c3b22490ac8d425abd652edbabdb3d194c7b
a9ead1821b73a6d234cea0afd1e0c26d3243f0f6
v1.0
complete
Taco
Taco_69463_C
def encode(message: str, shift: int) -> str: """ Encodes the message by reversing the string and shifting each character in the ASCII table by shift positions. """ pass def decode(encoded_message: str, shift: int) -> str: """ Decodes the message by reversing the shifting each character in the A...
def encode(message, shift): """ Encodes the message by reversing the string and shifting each character in the ASCII table by shift positions. Parameters: message (str): The original message to encode. shift (int): The number of positions to shift each character in the ASCII table. Ret...
from solution import process_message def test_simple_message(): assert process_message(3, "hello") == "hello" def test_negative_shift(): assert process_message(-3, "world") == "world" def test_empty_string(): assert process_message(5, "") == "" def test_single_character(): assert process_message(1, ...
[ { "docstring": "Encodes the message by reversing the string and shifting each character in the ASCII table by shift positions.\n\nParameters:\nmessage (str): The original message to encode.\nshift (int): The number of positions to shift each character in the ASCII table.\n\nReturns:\nstr: The encoded message.",...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def encode(message, shift):\n # Reverse the string\n reversed_message = message[::-1]\n # Shift characters by `shift` positions\n encoded_message = ''....
trial_gpt4o_9
{ "original_instruction": "Alex is part of a cybersecurity team and needs to encode and decode messages efficiently. One technique involves encoding a message by reversing the string and then shifting each character by a certain number of positions in the ASCII table. To decode the message, one needs to reverse the e...
0.685515
Taco_69463
C
[ "encode", "decode", "process_message" ]
3
[ [ "process_message", "decode" ], [ "process_message", "encode" ] ]
2
[]
false
[]
false
pytest
true
[]
true
65acdd8728d21834bb61944b22dc5a346fb7b31c
9df4e6c7eb4f6035f90c94f92885ee73b960d3f0
v1.0
complete
Taco
Taco_69515_C
def is_prime(n: int) -> bool: """ Helper function to check if a number is prime. :param n: Integer to check for primality. :return: True if n is a prime number, False otherwise. >>> is_prime(2) True >>> is_prime(4) False >>> is_prime(19) True >>> is_prime(20) Fa...
def is_prime(n): """ Helper function to check if a number is prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def filter_primes...
from solution import is_prime, filter_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(19) == True assert is_prime(20) == False assert is_prime(1) == False assert is_prime(0) == Fals...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Given a list of integers, return a new list containing only the prime numbers.", "function_declaration": "d...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Checks if a number n is prime.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\n if n %...
trial_gpt4o_2
{ "original_instruction": "Write a program that takes a list of integers and returns a new list containing only the prime numbers from the original list.\n\nConstraints\n\n- The length of the input list < 10000\n- Each integer n in the list is such that 1 <= n <= 10^6\n\nInput\n\nA space-separated list of integers gi...
0.762973
Taco_69515
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
037e2d09fbddc195476578ea6d2fcde1529bdd6e
4865e406669e3a36e07a39b2baa2acd9893a900c
v1.0
complete
Taco
Taco_69520_C
from typing import List from functools import reduce def gcd(a: int, b: int) -> int: """ Returns the greatest common divisor of a and b using Euclid's algorithm. >>> gcd(54, 24) 6 >>> gcd(48, 18) 6 >>> gcd(101, 103) 1 >>> gcd(56, 98) 14 >>> gcd(27, 0) 27 """ # Im...
def gcd(a, b): """ Returns the greatest common divisor of a and b using Euclid's algorithm. """ while b: a, b = b, a % b return a def find_gcd_of_list(numbers): """ Returns the greatest common divisor of all the integers in the list. """ from functools import reduce retu...
from solution import gcd, find_gcd_of_list def test_gcd(): assert gcd(54, 24) == 6 assert gcd(48, 18) == 6 assert gcd(101, 103) == 1 assert gcd(56, 98) == 14 assert gcd(27, 0) == 27 def test_find_gcd_of_list(): assert find_gcd_of_list([6, 9, 15]) == 3 assert find_gcd_of_list([100, 75, 25, ...
[ { "docstring": "Returns the greatest common divisor of a and b using Euclid's algorithm.", "function_declaration": "def gcd(a, b):", "function_name": "gcd", "parameter_list": "(a, b)" }, { "docstring": "Returns the greatest common divisor of all the integers in the list.", "function_decl...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def gcd(a, b):\n \"\"\"\n Returns the greatest common divisor of a and b using Euclid's algorithm.\n \"\"\"\n while b:\n a, b = b, a % b\n re...
trial_gpt4o_0
{ "original_instruction": "You are given a list of N positive integers. You need to find the greatest common divisor (GCD) of all the integers in the list. Note that N will be between 1 and 100000.\n\nInput\n\nThe single line contains N space-separated positive integers. Each of these integers will be at most 109.\n\...
0.772656
Taco_69520
C
[ "gcd", "find_gcd_of_list" ]
2
[ [ "find_gcd_of_list", "gcd" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3f4b912f58fa6bebc47eddedda4d4e88326183af
62091e32570b7fe9826ab94c2e2c60d8922140f1
v1.0
complete
Taco
Taco_69057_C
def merge_lists(lists, operations): """ Function to merge multiple lists based on the given merge operations. Parameters: lists (List[List[int]]): A list of lists containing integers. operations (List[Tuple[int, int]]): A list of tuples where each tuple contains two integers representing indice...
def merge_lists(lists, operations): """ Function to merge multiple lists based on the given merge operations. Parameters: lists (List[List[int]]): A list of lists containing integers. operations (List[Tuple[int, int]]): A list of tuples where each tuple contains two integers representing indice...
import pytest from solution import process_input_and_merge, merge_lists def test_merge_simple_case(): data = "3\n1 2 3 4\n5 6 7\n8 9\n2\n1 2\n1 3" assert process_input_and_merge(data) == [1, 2, 3, 4, 5, 6, 7, 8, 9] def test_merge_no_operations(): data = "2\n1 2\n3 4\n0" assert process_input_and_merge(...
[ { "docstring": "Function to merge multiple lists based on the given merge operations.\n\nParameters:\nlists (List[List[int]]): A list of lists containing integers.\noperations (List[Tuple[int, int]]): A list of tuples where each tuple contains two integers representing indices of lists to merge.\n\nReturns:\nLi...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def merge_message_lists(m, lists, n, operations):\n \"\"\"\n Merges multiple lists of integers based on provided merge operations.\n\n Parameters:\n m ...
trial_gpt4o_2
{ "original_instruction": "A new startup has gained popularity for its innovative messaging system. The system works by allowing users to send specific types of messages that contain numeric codes. Each sequence of messages a user sends forms a list of integers. The system has a special feature that can merge two suc...
0.581985
Taco_69057
C
[ "merge_lists", "process_input_and_merge" ]
2
[ [ "process_input_and_merge", "merge_lists" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ac0f4d507a593ed168e5e39a6655b42104dc10b8
3e0fa62191bd42df83146fd6c04c6828ab18ac02
v1.0
complete
Taco
Taco_69325_C
def ancient_sorting_books(input_text: str) -> str: """ An old and mystical library has a chief librarian who is known for his skill in an ancient way of sorting books. These books have information written on each page about knowledge long forgotten. The chief librarian wants to sort these books based on the total i...
def sort_books(test_cases): results = [] for n, pages, information in test_cases: total_info = [] for i in range(n): total_info.append((i, sum(information[i]))) sorted_info = sorted(total_info, key=lambda x: x[1]) results.append([idx for idx, _ in sorted_info]) re...
import pytest from solution import ancient_sorting_books def test_case_1(): input_text = "2\n3\n3 2 4\n1 2 3\n4 5\n3 3 3 3\n2\n5 2\n6 6 6 6 6\n1 1" expected_output = "0 1 2\n1 0" assert ancient_sorting_books(input_text) == expected_output def test_case_2(): input_text = "1\n2\n2 3\n2 3\n1 1 5" exp...
[ { "docstring": null, "function_declaration": "def sort_books(test_cases):", "function_name": "sort_books", "parameter_list": "(test_cases)" }, { "docstring": null, "function_declaration": "def parse_input(input_text):", "function_name": "parse_input", "parameter_list": "(input_te...
[ 0, 0, 0, 0, 0, 0, 1, 1, 0, 1 ]
3
hard
0.3
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sort_books_by_information(test_cases):\n results = []\n for t in range(test_cases):\n n = int(input().strip())\n pages = list(map(int, inpu...
trial_gpt4o_9
{ "original_instruction": "An old and mystical library has a chief librarian who is known for his skill in an ancient way of sorting books. These books have information written on each page about knowledge long forgotten. The chief librarian wants to sort these books based on the total information they contain. The t...
0.713016
Taco_69325
C
[ "sort_books", "parse_input", "format_output", "ancient_sorting_books" ]
4
[ [ "ancient_sorting_books", "format_output" ], [ "ancient_sorting_books", "parse_input" ], [ "ancient_sorting_books", "sort_books" ] ]
3
[ "parse_input", "format_output" ]
false
[]
false
pytest
true
[]
true
1c3901092359464f74336cb37c885f3fb35a8b7f
b4811bb6765073d51fd9cc992075b38956d5c721
v1.0
complete
Taco
Taco_69200_C
from typing import List, Tuple def max_path_sum(n: int, m: int, grid: List[List[int]]) -> int: """ Computes the maximum sum of integers you can collect starting from the top-left cell and moving to the bottom-right cell, given that you can only move either right or down at any step. Args: n (int): number o...
def max_path_sum(n, m, grid): # Initialize a dp array dp = [[0] * m for _ in range(n)] # Fill the dp array dp[0][0] = grid[0][0] for i in range(1, n): dp[i][0] = dp[i-1][0] + grid[i][0] for j in range(1, m): dp[0][j] = dp[0][j-1] + grid[0][j] for i in range(1, n): ...
import pytest from solution import max_path_sum, solve, parse_input, format_output def test_max_path_sum_simple(): grid = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] assert max_path_sum(3, 3, grid) == 29 def test_max_path_sum_with_negatives(): grid = [ [-1, -2], [-3, 4]...
[ { "docstring": null, "function_declaration": "def max_path_sum(n, m, grid):", "function_name": "max_path_sum", "parameter_list": "(n, m, grid)" }, { "docstring": null, "function_declaration": "def solve(test_cases):", "function_name": "solve", "parameter_list": "(test_cases)" }...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_path_sum(n, m, grid):\n # Initialize a dp array\n dp = [[0] * m for _ in range(n)]\n \n # Fill the dp array\n dp[0][0] = grid[0][0]\n for...
trial_gpt4o_0
{ "original_instruction": "You are given a grid of cells, where each cell contains an integer. Your task is to find the maximum sum of integers you can collect starting from the top-left cell and moving to the bottom-right cell, given that you can only move either right or down at any step.\n\nWrite a function that c...
0.64256
Taco_69200
C
[ "max_path_sum", "solve", "parse_input", "format_output" ]
4
[ [ "solve", "max_path_sum" ] ]
1
[ "parse_input", "format_output" ]
false
[]
false
pytest
true
[]
true
4409fe1a24d1804e295c89f3a1049291dd29e1f6
6e1ae5a09bc8c4c4dcec6f2ae4e929bb17079421
v1.0
complete
Taco
Taco_69476_C
from typing import List def prime_factors(n: int) -> set: """ Compute the prime factors of a number. Args: n (int): The number to factorize. Returns: set: A set of prime factors of the number. """ # Implementation here def max_k_th_prime_factor_count(n: int, k: int, arr: List[int]) -> in...
from collections import defaultdict import math # Function to compute prime factors of a number def prime_factors(n): factors = set() while n % 2 == 0: factors.add(2) n = n // 2 for i in range(3, int(math.sqrt(n)) + 1, 2): while n % i == 0: factors.add(i) n =...
from solution import max_k_th_prime_factor_count def test_case_0(): assert max_k_th_prime_factor_count(5, 3, [10, 15, 21, 24, 30]) == 3 def test_case_1(): assert max_k_th_prime_factor_count(8, 4, [7, 11, 13, 2, 3, 5, 14, 20]) == 2 def test_single_element_subarray(): assert max_k_th_prime_factor_count...
[ { "docstring": null, "function_declaration": "def prime_factors(n):", "function_name": "prime_factors", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def max_k_th_prime_factor_count(n, k, arr):", "function_name": "max_k_th_prime_factor_count", "paramete...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from math import isqrt\n\ndef distinct_prime_factors_count(num):\n ''' Function to count distinct prime factors '''\n if num == 1:\n return 0\n cou...
trial_gpt4o_3
{ "original_instruction": "You are given an array of integers, `arr`, of size `n` and a positive integer `k`. Define the \"k-th distinct prime factor count\" of an integer as the number of distinct prime factors of the k-th largest integer in the subarrays of length `k` of the given array. Your task is to determine t...
0.765647
Taco_69476
C
[ "prime_factors", "max_k_th_prime_factor_count" ]
2
[ [ "max_k_th_prime_factor_count", "prime_factors" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1791ee22a9d63ebffe5811f46e9b5952393ad8f9
4c0d103853b7509d668e7e8d7a120fc08ff4d859
v1.0
complete
Taco
Taco_69281_C
def preprocess_matrix(matrix): """ Preprocess the matrix to create a prefix sum matrix. """ def submatrix_sum(prefix_sum, r1, c1, r2, c2): """ Use the prefix sum matrix to calculate the sum of the submatrix. """ def process_queries(matrix, queries): """ Process all queries and retu...
def preprocess_matrix(matrix): """ Preprocess the matrix to create a prefix sum matrix. """ n = len(matrix) m = len(matrix[0]) prefix_sum = [[0] * (m + 1) for _ in range(n + 1)] for i in range(1, n + 1): for j in range(1, m + 1): prefix_sum[i][j] = matrix[i - 1][j - 1] \...
def test_preprocess_matrix(): matrix = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] expected_prefix_sum = [ [0, 0, 0, 0], [0, 1, 3, 6], [0, 5, 12, 21], [0, 12, 27, 45] ] assert preprocess_matrix(matrix) == expected_prefix_sum def test_submatrix_sum(): ...
[ { "docstring": "Preprocess the matrix to create a prefix sum matrix.", "function_declaration": "def preprocess_matrix(matrix):", "function_name": "preprocess_matrix", "parameter_list": "(matrix)" }, { "docstring": "Use the prefix sum matrix to calculate the sum of the submatrix.", "funct...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def preprocess_matrix(matrix):\n \"\"\"\n Preprocesses the given matrix to create a prefix sum matrix for efficient submatrix sum queries.\n \"\"\"\n n...
trial_gpt4o_2
{ "original_instruction": "You are given a matrix of size $n \\times m$ filled with integers, and you are tasked with finding the sum of elements in multiple submatrices.\n\nFor each query, the submatrix is defined by its top-left corner $(r1, c1)$ and bottom-right corner $(r2, c2)$. The sum of the submatrix includes...
0.527778
Taco_69281
C
[ "preprocess_matrix", "submatrix_sum", "process_queries" ]
3
[ [ "process_queries", "preprocess_matrix" ], [ "process_queries", "submatrix_sum" ] ]
2
[ "process_queries" ]
false
[]
false
pytest
false
[]
true
61240c7a098e14c28e15239920ec56f054b972cf
9ac56ea25fef8701ebd56ecd8f907f4e737578c6
v1.0
complete
Taco
Taco_69186_C
class TreeNode: def __init__(self, value=0, left=None, right=None): self.value = value self.left = left self.right = right def build_tree(preorder, inorder): """ Build the binary tree from preorder and inorder traversals. """ pass def postorder_traversal(root): """ ...
class TreeNode: def __init__(self, value=0, left=None, right=None): self.value = value self.left = left self.right = right def build_tree(preorder, inorder): if not preorder or not inorder: return None root_value = preorder[0] root = TreeNode(root_value) mid = inord...
import pytest from solution import tree_postorder def test_example_1(): preorder = [1, 2, 4, 5, 3, 6] inorder = [4, 2, 5, 1, 6, 3] expected_postorder = [4, 5, 2, 6, 3, 1] assert tree_postorder(preorder, inorder) == expected_postorder def test_example_2(): preorder = [10, 5, 1, 7, 40, 50] inord...
[]
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared1_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, value=0, left=None, right=None):\n self.value = value\n self.left = left\n se...
trial_gpt4o_2
{ "original_instruction": "In computer science, binary trees are a fundamental data structure used in various algorithms. A binary tree is a tree data structure in which each node has at most two children, referred to as the left child and the right child.\n\nA full binary tree is a type of binary tree where every no...
0.502992
Taco_69186
C
[ "build_tree", "postorder_traversal", "tree_postorder" ]
3
[ [ "tree_postorder", "build_tree" ], [ "tree_postorder", "postorder_traversal" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
ad17e55b9116d91c8bb54507012721f0c8a0255a
a47af27779b16419d22bd9ccdf57b1dbc2fa6ba0
v1.0
complete
Taco
Taco_69666_C
def solve(n: int, m: int, edge_list: List[str]) -> str: """ Determine if a given graph is bipartite and find the two disjoint sets of vertices if it is. Parameters: n (int): The number of vertices in the graph. m (int): The number of edges in the graph. edge_list (List[str]): A list of edges in the...
from collections import deque, defaultdict def is_bipartite(n, edges): graph = defaultdict(list) for u, v in edges: graph[u].append(v) graph[v].append(u) color = {} def bfs(start): queue = deque([start]) color[start] = 0 while queue: node = ...
from solution import solve def test_bipartite_graph(): n = 4 m = 4 edges = ["1 2", "1 3", "2 4", "3 4"] assert solve(n, m, edges) == "2\n1 4\n2\n2 3" def test_not_bipartite_graph(): n = 3 m = 3 edges = ["1 2", "1 3", "2 3"] assert solve(n, m, edges) == "-1" def test_single_edge(): ...
[ { "docstring": null, "function_declaration": "def is_bipartite(n, edges):", "function_name": "is_bipartite", "parameter_list": "(n, edges)" }, { "docstring": null, "function_declaration": "def solve(n, m, edge_list):", "function_name": "solve", "parameter_list": "(n, m, edge_list...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque, defaultdict\n\ndef is_bipartite(n, edges):\n graph = defaultdict(list)\n for u, v in edges:\n graph[u].append(v)\n ...
trial_gpt4o_0
{ "original_instruction": "Erin loves studying graphs, and she has recently learned about bipartite graphs. A bipartite graph is one where the set of vertices can be divided into two disjoint sets such that no two vertices within the same set are adjacent. Erin has a graph with `n` vertices and `m` edges. She wants t...
0.535305
Taco_69666
C
[ "is_bipartite", "solve" ]
2
[ [ "solve", "is_bipartite" ] ]
1
[]
false
[]
false
pytest
true
[]
true
48d26b0b61009c04f3dd5d7fc93387fb2f4029a6
96a20e0407bc21ace5ce38902fce13c4a537cc1f
v1.0
complete
Taco
Taco_69782_C
def is_subsequence(s: str, word: str) -> bool: """ Check if word can be formed by deleting some characters from s. """ it = iter(s) return all(char in it for char in word) def longest_word_in_list(s: str, word_list: List[str]) -> str: """ Returns the longest word that can be formed by delet...
def is_subsequence(s, word): """ Helper function to check if word can be formed by deleting some characters from s. """ it = iter(s) return all(char in it for char in word) def longest_word_in_list(s, word_list): """ Returns the longest word that can be formed by deleting some characters ...
from solution import longest_word_in_list def test_case_1(): s = "abpcplea" word_list = ["apple", "monkey", "plea"] assert longest_word_in_list(s, word_list) == "apple" def test_case_2(): s = "abpcplea" word_list = ["a", "b", "c", "d"] assert longest_word_in_list(s, word_list) == "a" def test...
[ { "docstring": "Helper function to check if word can be formed by deleting some characters from s.", "function_declaration": "def is_subsequence(s, word):", "function_name": "is_subsequence", "parameter_list": "(s, word)" }, { "docstring": "Returns the longest word that can be formed by dele...
[ 0, 0, 0, 1, 1 ]
2
medium
0.4
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_subsequence(s, word):\n it = iter(s)\n return all(char in it for char in word)\n\ndef find_longest_word(s, words):\n words.sort(key=lambda word: (-...
trial_gpt4o_4
{ "original_instruction": "You are given a list of words and your task is to find the longest word in the list that can be formed by deleting some characters of a given string s without reordering the remaining characters. If there are multiple possible results, return the longest word in the list. If there are still...
0.728965
Taco_69782
C
[ "is_subsequence", "longest_word_in_list" ]
2
[ [ "longest_word_in_list", "is_subsequence" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b5551ab2c0a6f1a60844df0d39803ac353693a50
5e9759204aa613f48cb7fe420e12770db3f68116
v1.0
complete
Taco
Taco_70082_C
def is_palindrome(n: int) -> bool: """ Check if the number is a palindrome. >>> is_palindrome(121) True >>> is_palindrome(123) False >>> is_palindrome(1331) True >>> is_palindrome(10) False """ def next_palindrome(x: int) -> int: """ Find the smallest palindromic number greater ...
def is_palindrome(n): """ Check if the number is a palindrome. """ return str(n) == str(n)[::-1] def next_palindrome(x): """ Find the smallest palindromic number greater than x. """ num = x + 1 while not is_palindrome(num): num += 1 return num
from solution import is_palindrome, next_palindrome def test_is_palindrome(): assert is_palindrome(121) == True assert is_palindrome(123) == False assert is_palindrome(1331) == True assert is_palindrome(10) == False def test_next_palindrome(): assert next_palindrome(123) == 131 assert next_pal...
[ { "docstring": "Check if the number is a palindrome.", "function_declaration": "def is_palindrome(n):", "function_name": "is_palindrome", "parameter_list": "(n)" }, { "docstring": "Find the smallest palindromic number greater than x.", "function_declaration": "def next_palindrome(x):", ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def next_palindrome(x):\n \"\"\"\n Returns the smallest palindromic number greater than x.\n \"\"\"\n # Function to check if a number is palindromic\n ...
trial_gpt4o_2
{ "original_instruction": "Rita is fascinated by palindromic numbers and wants to find the smallest palindromic number larger than a given integer x. A palindromic number is a number that reads the same forward and backward, such as 121 or 1331.\n\nYour task is to help Rita find this smallest palindromic number.\n\nI...
0.733137
Taco_70082
C
[ "is_palindrome", "next_palindrome" ]
2
[ [ "next_palindrome", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1e713c5ac14dee0135762894394c3a9a193be4bc
0cc62e6d029e89b63d6e0c3ff5154c3388521166
v1.0
complete
Taco
Taco_69674_C
def is_sum_divisible_by_k(arr, k): """ Checks if there are any three distinct elements in the array whose sum is divisible by k. >>> is_sum_divisible_by_k([1, 2, 3, 4, 5], 3) "YES" >>> is_sum_divisible_by_k([10, 15, 7, 8], 7) "NO" >>> is_sum_divisible_by_k([3, 6, 9, 12, 15, 18], 11) "YES" ...
def is_sum_divisible_by_k(arr, k): """ Checks if there are any three distinct elements in the array whose sum is divisible by k. """ n = len(arr) for i in range(n - 2): for j in range(i + 1, n - 1): for l in range(j + 1, n): if (arr[i] + arr[j] + arr[l]) % k == 0:...
def test_is_sum_divisible_by_k_yes(): assert is_sum_divisible_by_k([1, 2, 3, 4, 5], 3) == "YES" def test_is_sum_divisible_by_k_no(): assert is_sum_divisible_by_k([10, 15, 7, 8], 7) == "NO" def test_is_sum_divisible_by_k_borderline(): assert is_sum_divisible_by_k([3, 6, 9, 12, 15, 18], 11) == "YES" def te...
[ { "docstring": "Checks if there are any three distinct elements in the array whose sum is divisible by k.", "function_declaration": "def is_sum_divisible_by_k(arr, k):", "function_name": "is_sum_divisible_by_k", "parameter_list": "(arr, k)" }, { "docstring": "Handles multiple test cases for ...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_sum_divisible_by_k(arr, N, K):\n \"\"\"\n This function determines if there are three distinct elements in the array such that their sum is divisible ...
trial_gpt4o_3
{ "original_instruction": "You are given an array A of N integers and an integer K. Your task is to determine if there are three distinct elements in the array such that their sum is divisible by K.\n\n------ Input Format ------ \n\n- The first line of input contains a single integer T denoting the number of test cas...
0.670121
Taco_69674
C
[ "is_sum_divisible_by_k", "process_multiple_test_cases", "transform_input", "main" ]
4
[ [ "process_multiple_test_cases", "is_sum_divisible_by_k" ] ]
1
[ "process_multiple_test_cases" ]
false
[]
false
pytest
false
[]
true
aaad870273b7c523fb3071c0cfbb3d4cc3973bb3
71b438b656d7dd8c5ca7cda1f86f39489f531391
v1.0
complete
Taco
Taco_69632_C
def parse_time_string(time_str): """Parse the time string into hours and minutes >>> parse_time_string("08:00") (8, 0) >>> parse_time_string("23:59") (23, 59) >>> parse_time_string("00:00") (0, 0) """ # Define function body here def time_in_minutes(hours, minutes): """Convert ti...
def parse_time_string(time_str): hours, minutes = map(int, time_str.split(':')) return hours, minutes def time_in_minutes(hours, minutes): return hours * 60 + minutes def to_time_string(minutes): hours = minutes // 60 minutes = minutes % 60 return f"{hours:02}:{minutes:02}" def find_peak_leas...
def test_parse_time_string(): assert parse_time_string("08:00") == (8, 0) assert parse_time_string("23:59") == (23, 59) assert parse_time_string("00:00") == (0, 0) def test_time_in_minutes(): assert time_in_minutes(8, 0) == 480 assert time_in_minutes(23, 59) == 1439 assert time_in_minutes(0, 0)...
[ { "docstring": null, "function_declaration": "def parse_time_string(time_str):", "function_name": "parse_time_string", "parameter_list": "(time_str)" }, { "docstring": null, "function_declaration": "def time_in_minutes(hours, minutes):", "function_name": "time_in_minutes", "param...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def get_vehicle_data():\n data = []\n while True:\n m = int(input().strip())\n if m == 0:\n break\n records = []\n for...
trial_gpt4o_2
{ "original_instruction": "Design a traffic monitoring system for a highway. The system should track the number of vehicles passing through a certain point on the highway at different times during the day. Given the recorded time (hours, minutes) and a count of vehicles passing through at that time, determine the pea...
0.6401
Taco_69632
C
[ "parse_time_string", "time_in_minutes", "to_time_string", "find_peak_least_periods", "process_inputs" ]
5
[ [ "find_peak_least_periods", "parse_time_string" ], [ "find_peak_least_periods", "to_time_string" ], [ "process_inputs", "find_peak_least_periods" ] ]
3
[ "process_inputs" ]
false
[]
false
pytest
false
[]
true
9c4358d24d838d53e56f6ac2ba592b161c7efbb1
83e3371f8d1e6b75b6e8dba3bda54ec699cd0b01
v1.0
complete
Taco
Taco_70176_C
from typing import List def minimal_removal_to_palindrome(t: int, cases: List[str]) -> List[str]: """ Form a palindromic string by removing the minimum number of characters. Args: t (int): number of test cases. cases (List[str]): list of strings for each test case. Returns: List[str]: li...
def longest_palindromic_subsequence(s): n = len(s) dp = [[0] * n for _ in range(n)] for i in range(n): dp[i][i] = 1 for cl in range(2, n + 1): for i in range(n - cl + 1): j = i + cl - 1 if s[i] == s[j] and cl == 2: dp[i][j] = 2 ...
import pytest from solution import minimal_removal_to_palindrome def test_minimal_removal_to_palindrome(): t = 3 cases = ["abc", "abac", "a"] expected = ["a", "aba", "a"] assert minimal_removal_to_palindrome(t, cases) == expected def test_single_letter_string(): t = 2 cases = ["a", "b"] ex...
[ { "docstring": null, "function_declaration": "def longest_palindromic_subsequence(s):", "function_name": "longest_palindromic_subsequence", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def form_palindromic_string(s, dp):", "function_name": "form_palindromi...
[ 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def longest_palindromic_subsequence(s):\n \"\"\"\n Returns the longest palindromic subsequence in the string s.\n \"\"\"\n n = len(s)\n dp = [[0] * ...
trial_gpt4o_7
{ "original_instruction": "You are given a string consisting of lowercase Latin letters. You have to form a palindromic string by removing the minimum number of characters from it. A string is called palindromic if it reads the same backward as forward.\n\nWrite a program that helps achieve this task.\n\n-----Input--...
0.75858
Taco_70176
C
[ "longest_palindromic_subsequence", "form_palindromic_string", "minimal_removal_to_palindrome" ]
3
[ [ "minimal_removal_to_palindrome", "form_palindromic_string" ], [ "minimal_removal_to_palindrome", "longest_palindromic_subsequence" ] ]
2
[]
false
[]
false
pytest
true
[]
true
4c8b59a984796d5e0c632617eb691de0458d2293
3e01a78411c127ec18ded8f17f887c4cfbb61737
v1.0
complete
Taco
Taco_70084_C
def length_of_longest_increasing_subarray(arr): """ Returns the length of the longest contiguous increasing subarray. >>> length_of_longest_increasing_subarray([1, 3, 2, 3, 4, 5]) == 4 >>> length_of_longest_increasing_subarray([15, 12, 20, 22]) == 3 >>> length_of_longest_increasing_subarray([1, 2, 3...
def length_of_longest_increasing_subarray(arr): """ Returns the length of the longest contiguous increasing subarray. """ n = len(arr) if n == 0: return 0 max_length = 1 current_length = 1 for i in range(1, n): if arr[i] > arr[i-1]: current_length +=...
from solution import parse_input, solve, length_of_longest_increasing_subarray def test_length_of_longest_increasing_subarray(): assert length_of_longest_increasing_subarray([1, 3, 2, 3, 4, 5]) == 4 assert length_of_longest_increasing_subarray([15, 12, 20, 22]) == 3 assert length_of_longest_increasing_suba...
[ { "docstring": "Returns the length of the longest contiguous increasing subarray.", "function_declaration": "def length_of_longest_increasing_subarray(arr):", "function_name": "length_of_longest_increasing_subarray", "parameter_list": "(arr)" }, { "docstring": null, "function_declaration...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def length_of_longest_increasing_subarray(arr):\n \"\"\"\n Given an array of integers, find the length of the longest contiguous subarray\n such that its ...
trial_gpt4o_2
{ "original_instruction": "Tom loves solving programming challenges. Given an array of integers, he wants to find the length of the longest contiguous subarray such that its elements are in an increasing order.\n\nInput\nThe first line contains an integer T denoting the number of test cases.\nFor each test case, the ...
0.738315
Taco_70084
C
[ "length_of_longest_increasing_subarray", "solve", "parse_input" ]
3
[ [ "solve", "length_of_longest_increasing_subarray" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
6388dabee25ec700948c5c0075e8d19f2bbb7ac9
0d30e8422ac24c1ea787e15fdec97760f55c0042
v1.0
complete
Taco
Taco_70290_C
def sequence_sort_check(n: int, seq: List[int]) -> Union[List[int], int]: """ Determine if the sequence can be sorted in non-decreasing order by changing at most one integer in the sequence. Return the list of integers after the change, or -1 if it is not possible. >>> sequence_sort_check(5, [1, 2, 10, 5, ...
def can_be_sorted_by_one_change(sequence): n = len(sequence) # Helper function to check if a sequence is sorted in non-decreasing order def is_sorted(seq): return all(seq[i] <= seq[i + 1] for i in range(len(seq) - 1)) if is_sorted(sequence): return sequence # Already sorted ...
from solution import sequence_sort_check def test_case_1(): assert sequence_sort_check(5, [1, 2, 10, 5, 6]) == [1, 2, 5, 5, 6] def test_case_2(): assert sequence_sort_check(3, [4, 1, 3]) == [1, 1, 3] def test_case_3(): assert sequence_sort_check(4, [5, 4, 3, 2]) == -1 def test_already_sorted(): asse...
[ { "docstring": null, "function_declaration": "def can_be_sorted_by_one_change(sequence):", "function_name": "can_be_sorted_by_one_change", "parameter_list": "(sequence)" }, { "docstring": null, "function_declaration": "def sequence_sort_check(n, seq):", "function_name": "sequence_sor...
[ 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_be_sorted_by_one_change(n, arr):\n \"\"\"\n Determines if the sequence can be sorted in non-decreasing order by changing\n at most one integer in ...
trial_gpt4o_1
{ "original_instruction": "Karl is working on a project to analyze sequences of integers. He has a sequence of integers of length n. He wants to determine if the sequence can be sorted in non-decreasing order by changing at most one integer in the sequence. If possible, return the list of integers after the change. I...
0.682112
Taco_70290
C
[ "can_be_sorted_by_one_change", "sequence_sort_check" ]
2
[ [ "sequence_sort_check", "can_be_sorted_by_one_change" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3f264729f7ece75f87ecba481a874960b6eb16c9
676bed394a15dbbf755ad495b7ecc8629629df2f
v1.0
complete
Taco
Taco_70076_C
def fibonacci_numbers_up_to(n): """ Generate a list of Fibonacci numbers up to n in the Fibonacci System (starting with 1, 2, ...). >>> fibonacci_numbers_up_to(10) [1, 2, 3, 5, 8, 13] >>> fibonacci_numbers_up_to(21) [1, 2, 3, 5, 8, 13, 21] """ def min_fib_numbers_sum(x): """ Find the mi...
def fibonacci_numbers_up_to(n): fibs = [1, 2] while fibs[-1] < n: fibs.append(fibs[-1] + fibs[-2]) return fibs def min_fib_numbers_sum(x): fibs = fibonacci_numbers_up_to(x) count = 0 i = len(fibs) - 1 while x > 0: if fibs[i] <= x: x -= fibs[i] count +...
from solution import solve_min_fib_numbers_sum, fibonacci_numbers_up_to, min_fib_numbers_sum def test_fibonacci_numbers_up_to(): assert fibonacci_numbers_up_to(10) == [1, 2, 3, 5, 8, 13], "Test case failed!" assert fibonacci_numbers_up_to(21) == [1, 2, 3, 5, 8, 13, 21], "Test case failed!" def test_min_fi...
[ { "docstring": null, "function_declaration": "def fibonacci_numbers_up_to(n):", "function_name": "fibonacci_numbers_up_to", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def min_fib_numbers_sum(x):", "function_name": "min_fib_numbers_sum", "parameter_li...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def generate_fibonacci_up_to(max_num):\n fibs = [1, 2]\n while fibs[-1] + fibs[-2] <= max_num:\n fibs.append(fibs[-1] + fibs[-2])\n return fibs\n\n...
trial_gpt4o_1
{ "original_instruction": "You recently discovered an island where people use a unique numbering system called Fibonacci System, based on the Fibonacci sequence. Their sequences start with numbers 1 and 2 instead of 0 and 1, so the sequence looks like 1, 2, 3, 5, 8, 13, 21, etc. The i-th number in this sequence is Fi...
0.679591
Taco_70076
C
[ "fibonacci_numbers_up_to", "min_fib_numbers_sum", "solve_min_fib_numbers_sum" ]
3
[ [ "min_fib_numbers_sum", "fibonacci_numbers_up_to" ], [ "solve_min_fib_numbers_sum", "min_fib_numbers_sum" ] ]
2
[]
false
[]
false
pytest
true
[]
true
e7ba5e91081a908eb73911ec5f29ca43f79a69c9
954ddef36e8ab4683813d61537d83f626b145dbe
v1.0
complete
Taco
Taco_70080_C
def paths_exist(T: int, test_cases: List[Tuple[int, int, Tuple[int, int], Tuple[int, int], int, List[Tuple[int, int]]]]) -> List[str]: """ Determine if there is a path for the player to move from the starting position to the final position without hitting any obstacles for each test case. Parameters: T...
def bfs(grid, startX, startY, endX, endY, N, M): from collections import deque # Define possible movements : up, down, left, right directions = [(-1, 0), (1, 0), (0, -1), (0, 1)] # Initialize the queue for BFS queue = deque([(startX, startY)]) grid[startX][startY] = True # Mark initial...
from solution import paths_exist def test_paths_exist(): T = 2 test_cases = [ (5, 5, (0, 0), (4, 4), 3, [(0, 1), (1, 0), (1, 2)]), (5, 5, (0, 0), (4, 4), 0, []) ] assert paths_exist(T, test_cases) == ['NO', 'YES'] def test_no_obstacles(): T = 1 test_cases = [ (3, 3, (0,...
[ { "docstring": null, "function_declaration": "def bfs(grid, startX, startY, endX, endY, N, M):", "function_name": "bfs", "parameter_list": "(grid, startX, startY, endX, endY, N, M)" }, { "docstring": null, "function_declaration": "def is_path_possible(N, M, startX, startY, endX, endY, ob...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def bfs(grid, startX, startY, endX, endY, N, M):\n from collections import deque\n \n # Define possible movements : up, down, left, right\n directions ...
trial_gpt4o_0
{ "original_instruction": "Ravi, a game developer, is designing a new 2D grid-based game. In this game, the player can move in four possible directions: up, down, left, and right. The player starts from a given starting position (startX, startY) and should reach a final position (endX, endY). However, some of the cel...
0.704055
Taco_70080
C
[ "bfs", "is_path_possible", "paths_exist" ]
3
[ [ "is_path_possible", "bfs" ], [ "paths_exist", "is_path_possible" ] ]
2
[]
false
[]
false
pytest
true
[]
true
0835a54be2e3fd0116b106f02327593154c9139b
0bc185b86813770859e4bdeb7acb6b5abe75e9a5
v1.0
complete
Taco
Taco_69992_C
def calculate_weight(string, weights): """ Calculate and return the total weight of the string based on the given weights. """ # Your code here def sort_strings_by_weight(weights, strings): """ Sort the given list of strings based on their calculated weights. Maintain the original order in ...
def calculate_weight(string, weights): """ Calculate and return the total weight of the string based on the given weights. """ return sum(weights[ord(char) - ord('a')] for char in string) def sort_strings_by_weight(weights, strings): """ Sort the given list of strings based on their calculated ...
def test_calculate_weight(): weights = list(range(1, 27)) assert calculate_weight("abb", weights) == 5 assert calculate_weight("abc", weights) == 6 assert calculate_weight("abcd", weights) == 10 assert calculate_weight("aaa", weights) == 3 assert calculate_weight("bcc", weights) == 8 def test_s...
[ { "docstring": "Calculate and return the total weight of the string based on the given weights.", "function_declaration": "def calculate_weight(string, weights):", "function_name": "calculate_weight", "parameter_list": "(string, weights)" }, { "docstring": "Sort the given list of strings bas...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def calculate_weight(string, weights):\n \"\"\"\n Calculate and return the total weight of the string based on the given weights.\n \"\"\"\n return sum...
trial_gpt4o_0
{ "original_instruction": "Your task is to design a system that sorts a list of strings based on a 'weight' mapping provided.\n\n### Problem Statement\n\nYou are given a 'weight' mapping for each letter from 'a' to 'z'. Use this mapping to calculate the weight of each string (by summing the weights of its characters)...
0.636959
Taco_69992
C
[ "calculate_weight", "sort_strings_by_weight", "main" ]
3
[ [ "sort_strings_by_weight", "calculate_weight" ] ]
1
[]
false
[]
false
pytest
false
[]
true
641dd682697a158d4b1ddb5cfe02417f21425e44
a5751d060e7194a48958b3273f6e51e972fb0beb
v1.0
complete
Taco
Taco_70225_C
from typing import List, Tuple def number_of_branches(initial_branches: int, year: int) -> int: """Given the initial number of branches and a specific year, returns the number of branches in that year. >>> number_of_branches(5, 3) 20 >>> number_of_branches(5, 5) 80 """ pass def total_branc...
def number_of_branches(initial_branches, year): """ Given the initial number of branches and a specific year, returns the number of branches in that year. """ return initial_branches * (2 ** (year - 1)) def total_branches_between_years(initial_branches, start_year, end_year): """ Given the init...
import pytest from solution import number_of_branches, total_branches_between_years, process_queries def test_number_of_branches(): assert number_of_branches(5, 3) == 20 assert number_of_branches(5, 5) == 80 assert number_of_branches(1, 1) == 1 assert number_of_branches(1, 2) == 2 assert number_of_...
[ { "docstring": "Given the initial number of branches and a specific year, returns the number of branches in that year.", "function_declaration": "def number_of_branches(initial_branches, year):", "function_name": "number_of_branches", "parameter_list": "(initial_branches, year)" }, { "docstr...
[ 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 phoenix_tree_growth(B, queries):\n \"\"\"\n Analyzes the Phoenix Tree's branches growth based on the given queries.\n \n :param B: Initial number o...
trial_gpt4o_2
{ "original_instruction": "In a distant kingdom, there is a legendary Phoenix Tree. The branches of this tree grow in a unique way, such that every branch splits into two new branches every year. The people of the kingdom are fascinated by the growth patterns, and they've kept records of the tree's branches.\n\nYou h...
0.498463
Taco_70225
C
[ "number_of_branches", "total_branches_between_years", "process_queries" ]
3
[ [ "process_queries", "number_of_branches" ], [ "process_queries", "total_branches_between_years" ], [ "total_branches_between_years", "number_of_branches" ] ]
3
[ "process_queries" ]
false
[]
false
pytest
true
[]
true
141c55ff2aec04d4713be565ad6f40eaa9428a32
7ce4db87b2bcae67a6e03dc2185ad24a7cfccda3
v1.0
complete
Taco
Taco_70224_C
def main(z: int, r: int, road_list: List[Tuple[int, int, int]]) -> List[List[int]]: """ Write a function to find the Minimum Spanning Tree (MST) for a given graph of zones and roads. The function should return the roads included in the MST that will connect all the zones with the minimum total length. ...
def find(parent, i): if parent[i] == i: return i return find(parent, parent[i]) def union(parent, rank, x, y): root_x = find(parent, x) root_y = find(parent, y) if rank[root_x] < rank[root_y]: parent[root_x] = root_y elif rank[root_x] > rank[root_y]: parent[root_y] ...
def test_sample_input(): z = 4 r = 5 roads = [ (0, 1, 1), (0, 2, 2), (0, 3, 1), (1, 3, 3), (2, 3, 4) ] expected_output = [ [0, 1, 1], [0, 3, 1], [0, 2, 2] ] # The order of roads might be different, so we check all possible correct ...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n return find(parent, parent[i])\n\ndef union(parent, rank, x, y):\n root_x = find(parent, x)\...
trial_gpt4o_0
{ "original_instruction": "A popular city has been divided into several zones and the transport authority wants to plan an efficient transportation route for their new bus service. The main objective is to connect every zone with the minimum total length of roads. You have to help the authorities find a way to achiev...
0.635565
Taco_70224
C
[ "find", "union", "kruskal_mst", "main" ]
4
[ [ "kruskal_mst", "find" ], [ "kruskal_mst", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
false
[]
true
1da3bbb9bb33cfff079e3018a0678b4f8f54cdff
9eae3ad8287a987f0bc46c60a4360e1924a597e8
v1.0
complete
Taco
Taco_69629_C
from typing import List, Tuple def minimum_spanning_tree_cost(n: int, m: int, edge_list: List[Tuple[int, int, int]]) -> int: """ Compute the minimum total cost to connect all nodes in the graph using the existing roads. Args: n (int): The number of nodes in the graph. m (int): The number of edges ...
def find(parent, i): if parent[i] == i: return i else: return find(parent, parent[i]) def union(parent, rank, x, y): xroot = find(parent, x) yroot = find(parent, y) if rank[xroot] < rank[yroot]: parent[xroot] = yroot elif rank[xroot] > rank[yroot]: parent[yroot] ...
def test_example_case(): n = 4 m = 5 edges = [ (1, 2, 1), (1, 3, 4), (2, 3, 2), (2, 4, 6), (3, 4, 3) ] result = minimum_spanning_tree_cost(n, m, edges) assert result == 6 def test_disconnected_graph(): n = 3 m = 3 edges = [ (1, 2, 1), ...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef find_minimum_spanning_tree(n, edges):\n \"\"\"\n Computes the minimum total cost to connect all nodes in the graph using the existing roa...
trial_gpt4o_3
{ "original_instruction": "You are given a weighted undirected graph with n nodes and m edges. Each node in the graph represents a point of interest, and each edge represents a bidirectional road connecting two points with a specific cost. \n\nYour task is to design a function that will compute the minimum total cost...
0.739373
Taco_69629
C
[ "find", "union", "kruskal_mst", "minimum_spanning_tree_cost" ]
4
[ [ "kruskal_mst", "find" ], [ "kruskal_mst", "union" ], [ "minimum_spanning_tree_cost", "kruskal_mst" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
false
[]
true
506881c6389649dc9f8f5378e5fda62dfd797b27
5a33b5e0de9cab27979f8caa429435a219c37147
v1.0
complete
Taco
Taco_70478_C
def is_prime(n: int) -> bool: """ Determines if a given number n is prime. :param n: The integer to check for primality. :return: True if n is a prime number, else False. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(10) False ...
def is_prime(n): """ Determines if a given number n is prime. :param n: The integer to check for primality. :return: True if n is a prime number, else False. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = ...
from solution import is_prime, check_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(10) == False assert is_prime(1) == False assert is_prime(29) == True assert is_prime(30) == False...
[ { "docstring": "Determines if a given number n is prime.\n\n:param n: The integer to check for primality.\n:return: True if n is a prime number, else False.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Determines prime ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Returns True if n is a prime number, otherwise False.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n ...
trial_gpt4o_2
{ "original_instruction": "You are given a list of natural numbers. Your task is to determine which of the given numbers are prime.\n\nInput\nAn integer T, denoting the number of testcases, followed by T lines, each containing a single natural number N.\n\nOutput \nFor each integer N given at input, output a single l...
0.84597
Taco_70478
C
[ "is_prime", "check_primes" ]
2
[ [ "check_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9695b6daa31345fbfd59fcb3980fa2a41c94ab82
ceb1e5a022a43e23d11275de3e1a67d29ffd5fc8
v1.0
complete
Taco
Taco_70356_C
def generate_flower_bed(n: int) -> List[List[int]]: """ Generate a flower bed with pyramid-shaped layers composed of numbers. Args: n (int): The number of layers in the flower bed Returns: List[List[int]]: The flower bed represented as a list of layers Examples: >>...
def generate_flower_bed(n): flower_bed = [] for i in range(1, n + 1): layer = [] for j in range(1, i + 1): layer.append(j) for j in range(i - 1, 0, -1): layer.append(j) flower_bed.append(layer) return flower_bed def print_flower_bed(n): flower_bed...
from solution import generate_flower_bed, print_flower_bed def test_generate_flower_bed_single_layer(): result = generate_flower_bed(1) assert result == [[1]] def test_generate_flower_bed_two_layers(): result = generate_flower_bed(2) assert result == [[1], [1, 2, 1]] def test_generate_flower_bed_thre...
[ { "docstring": null, "function_declaration": "def generate_flower_bed(n):", "function_name": "generate_flower_bed", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def print_flower_bed(n):", "function_name": "print_flower_bed", "parameter_list": "(n)" }...
[ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def flower_bed(n):\n \"\"\"\n Prints a pyramid-shaped flower bed for a given n.\n \"\"\"\n for i in range(n):\n # Calculate the leading spaces\n...
trial_gpt4o_6
{ "original_instruction": "A gardener wants to build a pyramid-shaped flower bed in his garden. The flower bed will be composed of layers of flowers, where each layer forms an upside-down triangle. The gardener will plant the flowers in a specific order. Each layer i (0-indexed) contains flowers numbered from `1` to ...
0.525502
Taco_70356
C
[ "generate_flower_bed", "print_flower_bed" ]
2
[ [ "print_flower_bed", "generate_flower_bed" ] ]
1
[]
false
[]
false
pytest
true
[]
true
83aea2f90327de6ec06c3f40738b84ad4309c486
0a0d9957a7e9d123c223ffce08a3e8c4ece5fcec
v1.0
complete
Taco
Taco_70173_C
def sieve_of_eratosthenes(n): """ Uses the Sieve of Eratosthenes to find all prime numbers up to a given number n. Returns a list indicating prime status for each number from 0 to n. """ pass def count_primes_up_to_n(n): """ Given a number n, returns the count of prime numbers up to and inc...
def sieve_of_eratosthenes(n): """ Uses the Sieve of Eratosthenes to find all prime numbers up to a given number n. Returns a list indicating prime status for each number from 0 to n. """ is_prime = [True] * (n + 1) is_prime[0], is_prime[1] = False, False p = 2 while (p * p <= n): ...
def test_sieve_of_eratosthenes(): result = sieve_of_eratosthenes(10) expected = [False, False, True, True, False, True, False, True, False, False, False] assert result == expected def test_count_primes_up_to_n(): assert count_primes_up_to_n(10) == 4 assert count_primes_up_to_n(20) == 8 assert c...
[ { "docstring": "Uses the Sieve of Eratosthenes to find all prime numbers up to a given number n.\nReturns a list indicating prime status for each number from 0 to n.", "function_declaration": "def sieve_of_eratosthenes(n):", "function_name": "sieve_of_eratosthenes", "parameter_list": "(n)" }, { ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sieve_of_eratosthenes(n):\n \"\"\"Returns a list of booleans indicating prime status of numbers from 0 to n.\"\"\"\n primes = [True] * (n + 1)\n p = 2...
trial_gpt4o_2
{ "original_instruction": "One day, Anjali encountered a challenge in an online coding platform. The challenge was to find out the count of prime numbers up to a given number N (inclusive). Being new to programming, she decides to solve this problem. Help her by writing a program.\n\nINPUT:\n\nThe first line of the i...
0.736294
Taco_70173
C
[ "sieve_of_eratosthenes", "count_primes_up_to_n", "prime_count_per_test_case" ]
3
[ [ "count_primes_up_to_n", "sieve_of_eratosthenes" ], [ "prime_count_per_test_case", "sieve_of_eratosthenes" ] ]
2
[ "prime_count_per_test_case" ]
false
[]
false
pytest
false
[]
true
458b431f35edb087473982109bdb6a845f153daf
75a9c73995068fad4d0bd43347b7b3384bd53354
v1.0
complete
Taco
Taco_70014_C
def find_sudoku_solution(grid_lines: List[str]) -> str: """ Solve a given Sudoku puzzle and return the completed grid in the same format. The input consists of 9 lines, each containing 9 characters which represent the Sudoku grid. Empty cells are denoted by '.', and filled cells contain digits from '1'...
def solve_sudoku(board): """ Solves the given Sudoku board in place. :param board: list of list of str :return: None """ def is_valid(board, r, c, num): # Check the row for i in range(9): if board[r][i] == num: return False # Check the column ...
import pytest from solution import find_sudoku_solution def test_complete_sudoku(): input_grid = [ "5 3 . . 7 . . . .", "6 . . 1 9 5 . . .", ". 9 8 . . . . 6 .", "8 . . . 6 . . . 3", "4 . . 8 . 3 . . 1", "7 . . . 2 . . . 6", ". 6 . . . . 2 8 .", ". . ...
[ { "docstring": "Solves the given Sudoku board in place.\n:param board: list of list of str\n:return: None", "function_declaration": "def solve_sudoku(board):", "function_name": "solve_sudoku", "parameter_list": "(board)" }, { "docstring": null, "function_declaration": "def parse_input(gr...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_valid(board, row, col, num):\n for i in range(9):\n if board[row][i] == num or board[i][col] == num:\n return False\n \n box_row_...
trial_gpt4o_2
{ "original_instruction": "In a Sudoku game, the objective is to fill a 9x9 grid with digits so that each column, each row, and each of the nine 3x3 sub-grids that compose the grid (also called \"boxes\") contains all of the digits from 1 to 9. Starting with a partially completed grid, the goal is to complete it foll...
0.575157
Taco_70014
C
[ "solve_sudoku", "parse_input", "format_output", "find_sudoku_solution" ]
4
[ [ "find_sudoku_solution", "format_output" ], [ "find_sudoku_solution", "parse_input" ], [ "find_sudoku_solution", "solve_sudoku" ] ]
3
[ "parse_input", "format_output" ]
false
[]
false
pytest
true
[]
true
471f64c6d03a3017e51d7e427be021d270a446d4
2135ab56b6eb81337db765124801c40d393624ee
v1.0
complete
Taco
Taco_70507_C
def is_prime(n: int) -> bool: """ Check if a number is prime """ 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 ret...
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 subarray_with_prime_sum(arr): n = len(...
from solution import subarray_with_prime_sum def test_positive_case_1(): assert subarray_with_prime_sum([1, 2, 3, 4, 5]) == "YES" def test_positive_case_2(): assert subarray_with_prime_sum([7, 1, 12]) == "YES" def test_negative_case_1(): assert subarray_with_prime_sum([4, 6, 8, 10]) == "NO" def test_sin...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def subarray_with_prime_sum(arr):", "function_name": "subarray_with_prime_sum", "parameter_list": "(arr)" } ]
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "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_2
{ "original_instruction": "You are given an array b consisting of n integers. Your task is to find out if there exists a subarray (a contiguous subsequence) of the given array whose sum is a prime number.\n\nIf such a subarray exists, print \"YES\". Otherwise, print \"NO\".\n\nInput\n\nThe first line of the input con...
0.762884
Taco_70507
C
[ "is_prime", "subarray_with_prime_sum" ]
2
[ [ "subarray_with_prime_sum", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
abd56613fdf1c22a832bf22d1d6d86eb9e7f4350
2b1d236dbee4a5f3e0e0e2e61210e582ec350aa6
v1.0
complete
Taco
Taco_70669_C
def can_be_single_character_string(S: str) -> str: """ Determine if it is possible to transform string S into a single-character string based on the given operations. >>> can_be_single_character_string("aaab") "IMPOSSIBLE" >>> can_be_single_character_string("a") "a" """ pass def process_tes...
def can_be_single_character_string(S): """ Function to determine if it is possible to transform the string S into a single-character string. """ for i in range(1, len(S)): # Check if there is any adjacent pair of different characters if S[i] != S[i-1]: return "IMPOSSIBLE"...
from solution import can_be_single_character_string, process_test_cases def test_can_be_single_character_string(): assert can_be_single_character_string("aaab") == "IMPOSSIBLE" assert can_be_single_character_string("bbbaa") == "IMPOSSIBLE" assert can_be_single_character_string("a") == "a" assert can_be...
[ { "docstring": "Function to determine if it is possible to transform the string S into a\nsingle-character string.", "function_declaration": "def can_be_single_character_string(S):", "function_name": "can_be_single_character_string", "parameter_list": "(S)" }, { "docstring": "Function to pro...
[ 0, 0, 1, 0 ]
1
hard
0.25
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_transform_to_single_char(S):\n \"\"\"\n Determines if the string S can be transformed into a single-character\n string using the given operations....
trial_gpt4o_3
{ "original_instruction": "You are given a string `S` consisting of lowercase English letters. Your task is to process the string to create a new string `T` based on the following operations, which you can perform any number of times:\n\n1. If there are two adjacent same letters `aa` in the string, you can replace th...
0.604416
Taco_70669
C
[ "can_be_single_character_string", "process_test_cases", "solution" ]
3
[ [ "process_test_cases", "can_be_single_character_string" ], [ "solution", "process_test_cases" ] ]
2
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
c751f3f212ee2f4914a0e0a0eaaa6248258f8484
2b5c5c2517baba2faee13eb33c8cb1eb9b72c09a
v1.0
complete
Taco
Taco_70559_C
from typing import List def lcm(a, b): """ Returns the least common multiple of a and b. """ pass def smallest_multiple(N): """ Returns the smallest positive integer that is evenly divisible by all the numbers from 1 to N. """ pass def solve(inputs): """ Handles multiple test ...
from math import gcd def lcm(a, b): """ Returns the least common multiple of a and b. """ return a * b // gcd(a, b) def smallest_multiple(N): """ Returns the smallest positive integer that is evenly divisible by all the numbers from 1 to N. """ smallest_mul = 1 for i in range(1, N ...
from solution import smallest_multiple, solve def test_smallest_multiple(): assert smallest_multiple(1) == 1 assert smallest_multiple(5) == 60 assert smallest_multiple(10) == 2520 assert smallest_multiple(4) == 12 assert smallest_multiple(6) == 60 def test_solve(): inputs = ["3", "1", "5", "10...
[ { "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 smallest positive integer that is evenly divisible by all the numbers from 1 to N.", "function_decla...
[ 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 return a * b // math.gcd(a, b)\n\ndef smallest_multiple(n):\n smallest_mult = 1\n for i in range(1, n + 1):\n small...
trial_gpt4o_2
{ "original_instruction": "Alex loves puzzles, especially those that involve numbers. Recently, he came across a challenge where he needs to find the smallest positive integer that is evenly divisible by all of the numbers from 1 to a given integer N.\n\nGiven a number N, write a program to determine the smallest pos...
0.663656
Taco_70559
C
[ "lcm", "smallest_multiple", "solve" ]
3
[ [ "smallest_multiple", "lcm" ], [ "solve", "smallest_multiple" ] ]
2
[]
false
[]
false
pytest
true
[]
true
4dcb8af5ea5a7ca43b4f2a811cb611c18209aeb5
a8584d7dfe2fa131a7b025adddd0633b5a73bf03
v1.0
complete
Taco
Taco_70663_C
def check_quasi_symmetric(string_input: str) -> str: """ Determine if a given n x n matrix is quasi-symmetric. For every pair of indices (i, j), the sum of matrix elements satisfies the following condition: A[i][j] + A[j][i] = A[n-1-i][n-1-j] + A[n-1-j][n-1-i] Input The first line contains the ...
def is_quasi_symmetric(matrix): n = len(matrix) for i in range(n): for j in range(n): if matrix[i][j] + matrix[j][i] != matrix[n-1-i][n-1-j] + matrix[n-1-j][n-1-i]: return False return True def check_quasi_symmetric(string_input): lines = string_input.strip().split('...
import pytest from solution import check_quasi_symmetric def test_example_case(): input_data = "3\n1 2 3\n4 5 6\n7 8 9" assert check_quasi_symmetric(input_data) == "NO" def test_symmetric_case(): input_data = "2\n1 2\n2 1" assert check_quasi_symmetric(input_data) == "YES" def test_another_case(): ...
[ { "docstring": null, "function_declaration": "def is_quasi_symmetric(matrix):", "function_name": "is_quasi_symmetric", "parameter_list": "(matrix)" }, { "docstring": null, "function_declaration": "def check_quasi_symmetric(string_input):", "function_name": "check_quasi_symmetric", ...
[ 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_quasi_symmetric(matrix):\n \"\"\"\n Determines if a given n x n matrix is quasi-symmetric.\n \n Args:\n matrix (list of list of int): The inp...
trial_gpt4o_7
{ "original_instruction": "An n x n matrix is defined as a \"quasi-symmetric\" matrix if, for every pair of indices (i, j), the sum of matrix elements satisfies the following condition:\n```\nA[i][j] + A[j][i] = A[n-1-i][n-1-j] + A[n-1-j][n-1-i]\n```\n\nYou are given a matrix of size n x n (1 ≤ n ≤ 500) filled with i...
0.500159
Taco_70663
C
[ "is_quasi_symmetric", "check_quasi_symmetric" ]
2
[ [ "check_quasi_symmetric", "is_quasi_symmetric" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e5915b2231fb1dd477486f95095bc8677b683579
d4545060e7a1210a88f3d51aa459a86eacd78657
v1.0
complete
Taco
Taco_69859_C
def sieve_of_eratosthenes(limit): """ Sieve of Eratosthenes algorithm to find all prime numbers up to a specified integer limit. Parameters: limit (int): The upper limit up to which to look for prime numbers. Returns: List[bool]: A boolean array where a value at index i is True if i is...
def sieve_of_eratosthenes(limit): prime = [True] * (limit + 1) p = 2 while (p * p <= limit): if (prime[p] == True): for i in range(p * p, limit + 1, p): prime[i] = False p += 1 prime[0], prime[1] = False, False return prime def count_ones_in_range(L, R, ...
from solution import sieve_of_eratosthenes, count_ones_in_range, process_queries def test_sieve_of_eratosthenes(): prime = sieve_of_eratosthenes(10) assert prime == [False, False, True, True, False, True, False, True, False, False, False] def test_count_ones_in_range(): prime = sieve_of_eratosthenes(20) ...
[ { "docstring": null, "function_declaration": "def sieve_of_eratosthenes(limit):", "function_name": "sieve_of_eratosthenes", "parameter_list": "(limit)" }, { "docstring": null, "function_declaration": "def count_ones_in_range(L, R, prime):", "function_name": "count_ones_in_range", ...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sieve_of_eratosthenes(limit):\n prime = [True] * (limit + 1)\n p = 2\n while (p * p <= limit):\n if (prime[p] == True):\n for i in r...
trial_gpt4o_0
{ "original_instruction": "John is trying to create a special binary string based on some rules. Initially, he starts with an empty string. Each day, he appends one binary digit ('0' or '1') to the string based on the day number. Here's how he decides which digit to append:\n- If the current day `i` is a prime number...
0.606685
Taco_69859
C
[ "sieve_of_eratosthenes", "count_ones_in_range", "process_queries" ]
3
[ [ "process_queries", "count_ones_in_range" ], [ "process_queries", "sieve_of_eratosthenes" ] ]
2
[ "process_queries" ]
false
[]
false
pytest
true
[]
true
e931f51edb1817f1120b43c3c925094a1f4c960d
2aba58b719c797b6085a0179045b86e90294befe
v1.0
complete
Taco
Taco_70625_C
def sports_event_winner(input_data: str) -> str: """ Determine the winner of a sports event based on participants' scores in multiple events. Parameters: input_data (str): A string representing the number of participants and events, followed by each participant's scores for each event. Returns: ...
def find_winner(participants_scores): """ Finds the winner based on the highest total score. In case of a tie, the participant with the lower number wins. :param participants_scores: List of tuples where each tuple contains participant number and their scores in all events. :return: Tuple cont...
from solution import sports_event_winner def test_single_participant(): input_data = "1 3\n1 10 20 30" assert sports_event_winner(input_data) == "1 60" def test_multiple_participants(): input_data = "3 2\n1 50 60\n2 60 50\n3 30 40" assert sports_event_winner(input_data) == "1 110" def test_tie_with_l...
[ { "docstring": "Finds the winner based on the highest total score. \nIn case of a tie, the participant with the lower number wins.\n\n:param participants_scores: List of tuples where each tuple contains participant number and their scores in all events.\n:return: Tuple containing the winner's participant number...
[ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_winner(n, m, scores):\n max_score = -1\n winner_number = -1\n \n for participant in scores:\n total_score = sum(participant[1])\n ...
trial_gpt4o_6
{ "original_instruction": "In a sports event, athletes competed in multiple events, and their scores for each event have been recorded. The athlete with the highest total score wins. If there is a tie, the athlete with the lowest participant number is declared the winner.\n\nCreate a program that reads the list of pa...
0.663832
Taco_70625
C
[ "find_winner", "sports_event_winner" ]
2
[ [ "sports_event_winner", "find_winner" ] ]
1
[]
false
[]
false
pytest
true
[]
true
062d1bbb9448d7aa36f4c3108cece787a1f96a00
1c174b54ca6a6af60f6b13c112b537f7d260927d
v1.0
complete
Taco
Taco_70651_C
def preprocess_array(arr): """Preprocess the given array to get only distinct elements and then sort them.""" return sorted(set(arr)) def count_distinct_leq(preprocessed_arr, x): """Count the number of distinct elements in the preprocessed array that are less than or equal to x.""" pass def distinct_e...
def preprocess_array(arr): """ Preprocess the given array to get only distinct elements and then sort them. This will be used to quickly answer the queries. """ return sorted(set(arr)) def count_distinct_leq(preprocessed_arr, x): """ Count the number of distinct elements in the preprocessed...
import pytest from solution import distinct_elements_count def test_example_1(): assert distinct_elements_count(6, 3, [1, 5, 2, 2, 3, 5], [2, 4, 5]) == [2, 3, 4] def test_example_2(): assert distinct_elements_count(5, 2, [8, 8, 8, 8, 8], [7, 9]) == [0, 1] def test_single_element_array(): assert distinct_...
[ { "docstring": "Preprocess the given array to get only distinct elements and then sort them.\nThis will be used to quickly answer the queries.", "function_declaration": "def preprocess_array(arr):", "function_name": "preprocess_array", "parameter_list": "(arr)" }, { "docstring": "Count the n...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def count_distinct_less_equal(arr, queries):\n \"\"\"\n Returns a list where each element is the number of distinct integers in the array \n that are less...
trial_gpt4o_1
{ "original_instruction": "You are given an array of n integers and a series of q queries. Each query consists of a single integer value and requires you to find the number of distinct integers in the array that are less than or equal to that query value.\n\nInput\n\nThe first line contains two integers n and q (1 ≤ ...
0.658952
Taco_70651
C
[ "preprocess_array", "count_distinct_leq", "distinct_elements_count" ]
3
[ [ "distinct_elements_count", "count_distinct_leq" ], [ "distinct_elements_count", "preprocess_array" ] ]
2
[]
false
[]
false
pytest
true
[]
true
2b002381a16f69c3ac31794026dee8ae4de7889f
c1735f15449368931784c21036cda2cdff969d54
v1.0
complete
Taco
Taco_70282_C
from typing import List class TreeNode: def __init__(self, id): self.id = id self.value = 0 self.children = [] def update_value(node: TreeNode, x: int): """ Update the value of a specific node. """ pass def find_max_in_subtree(node: TreeNode) -> int: """ Query the maximum valu...
class TreeNode: def __init__(self, id): self.id = id self.value = 0 self.children = [] def update_value(node, x): node.value = x def find_max_in_subtree(node): max_value = node.value for child in node.children: max_value = max(max_value, find_max_in_subtree(child)) ...
def test_tree_operations(): n = 5 q = 6 edges = [1, 1, 2, 2] operations = ["1 1 5", "1 3 3", "1 4 7", "2 1", "2 2", "2 5"] expected_outputs = [7, 7, 0] assert process_operations(n, edges, operations) == expected_outputs def test_single_node_tree(): n = 1 q = 2 edges = [] op...
[]
[ 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=0):\n self.value = value\n self.children = []\n\nclass Tree:\n def __init__(self, n):\n self....
trial_gpt4o_1
{ "original_instruction": "You are given a binary tree with n nodes. Each node is uniquely numbered with integers from 1 to n. Additionally, each node contains a value, which is a non-negative integer. \n\nYou need to perform q update and query operations on this tree:\n1. Update the value of a specific node.\n2. Que...
0.602484
Taco_70282
C
[ "update_value", "find_max_in_subtree", "process_operations" ]
3
[ [ "process_operations", "find_max_in_subtree" ], [ "process_operations", "update_value" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
false
[]
true
37890da349e0fb24391c482f31864823cf9970ad
f965d56a633e49bb186e0afe1e7ec348372c46b9
v1.0
complete
Taco
Taco_70719_C
def largest_island_size(grid): """ Returns the size of the largest island in the given 2D grid of 'L' and 'W'. An island is defined as a group of adjacent 'L's connected horizontally or vertically. >>> largest_island_size(["LWLWL", "WWWLL", "LLLWW", "LWLWL"]) 5 >>> largest_island_size(["WLW", "...
def largest_island_size(grid): """ Returns the size of the largest island in the given 2D grid of 'L' and 'W'. An island is defined as a group of adjacent 'L's connected horizontally or vertically. """ def is_valid(x, y, visited): return 0 <= x < len(grid) and 0 <= y < len(grid[0]) and ...
def test_largest_island_size_example1(): data = """4 5 LWLWL WWWLL LLLWW LWLWL""" assert process_largest_island_size_input(data) == 5 def test_largest_island_size_example2(): data = """3 3 WLW LLL WLW""" assert process_largest_island_size_input(data) == 5 def test_no_islands(): data = """2 2 WW WW...
[ { "docstring": "Returns the size of the largest island in the given 2D grid of 'L' and 'W'.\nAn island is defined as a group of adjacent 'L's connected horizontally or vertically.", "function_declaration": "def largest_island_size(grid):", "function_name": "largest_island_size", "parameter_list": "(...
[ 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 largest_island_size(grid):\n def dfs(x, y):\n if x < 0 or x >= M or y < 0 or y >= N or grid[x][y] != 'L':\n return 0\n grid[x][y] =...
trial_gpt4o_2
{ "original_instruction": "Given a 2D grid of characters representing a map of islands (*'L'*) and water (*'W'*), you need to determine the size of the largest island. An island is defined as a group of adjacent cells containing 'L' connected in horizontal or vertical directions.\n\n**Input:**\n- First line contains ...
0.546889
Taco_70719
C
[ "largest_island_size", "process_largest_island_size_input" ]
2
[ [ "process_largest_island_size_input", "largest_island_size" ] ]
1
[]
false
[]
false
pytest
false
[]
true
b24f37437e6a6592f04136a8637d4b224fcfc6bc
45d27544ec322f3a1e9f0fc6812c1d95fdd8a3f1
v1.0
complete
Taco
Taco_70660_C
from typing import List def sieve(limit: int) -> List[bool]: """ Generate a list of booleans representing prime numbers up to a given limit. """ # Implementation of the sieve algorithm goes here def smallest_prime_geq(arr: List[int], queries: List[int]) -> List[int]: """ For each query, find the small...
from bisect import bisect_left import sys input = sys.stdin.read def sieve(limit): is_prime = [True] * (limit + 1) is_prime[0] = is_prime[1] = False for i in range(2, int(limit**0.5) + 1): if is_prime[i]: for j in range(i * i, limit + 1, i): is_prime[j] = False retur...
from solution import smallest_prime_geq def test_example_1(): arr = [2, 3, 5, 7, 11, 13] queries = [4, 6, 12] assert smallest_prime_geq(arr, queries) == [5, 7, 13] def test_example_2(): arr = [1, 4, 6, 8, 9] queries = [5, 10] assert smallest_prime_geq(arr, queries) == [-1, -1] def test_only_p...
[ { "docstring": null, "function_declaration": "def sieve(limit):", "function_name": "sieve", "parameter_list": "(limit)" }, { "docstring": null, "function_declaration": "def smallest_prime_geq(arr, queries):", "function_name": "smallest_prime_geq", "parameter_list": "(arr, queries...
[ 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 bisect import bisect_left\nimport sys\ninput = sys.stdin.read\n\ndef sieve(limit):\n is_prime = [True] * (limit + 1)\n is_prime[0] = is_prime[1] = False...
trial_gpt4o_0
{ "original_instruction": "You are given a set of integers. You need to answer a series of queries, each asking for the smallest prime number greater than or equal to a given integer in the set.\n\nTo simplify, each query specifies an integer x, and you need to find the smallest prime number in the set which is great...
0.616881
Taco_70660
C
[ "sieve", "smallest_prime_geq", "main" ]
3
[ [ "smallest_prime_geq", "sieve" ] ]
1
[]
false
[]
false
pytest
true
[]
true
39cdb4ecca1ae85488d938d9152d62d29ec9fa8a
9e1747f542425e28247f24abd41f8ed36090d189
v1.0
complete
Taco
Taco_70105_C
from typing import List, Tuple def find_festival_ground(n: int, roads: List[Tuple[int, int]]) -> int: """ Determine the village where the festival ground should be built to maximize the minimum distance from any village to the festival ground. Args: n (int): The number of villages. roads (List[Tu...
# We will use a combination of Depth First Search (DFS) and Breadth First Search (BFS) to solve this problem. # The idea is to first find the farthest node from an arbitrary starting node using BFS, then find the farthest node from there. # The middle of the path between these two nodes will be our answer. # This metho...
def test_find_festival_ground(): test_cases = [ (5, [(1, 2), (2, 3), (3, 4), (4, 5)]), (4, [(1, 2), (1, 3), (1, 4)]) ] T = len(test_cases) result = solve(T, test_cases) assert result == [3, 1] def test_single_village(): test_cases = [ (1, []), ] T = len(test_case...
[ { "docstring": null, "function_declaration": "def bfs_farthest_node(start, n, adj):", "function_name": "bfs_farthest_node", "parameter_list": "(start, n, adj)" }, { "docstring": null, "function_declaration": "def find_festival_ground(n, roads):", "function_name": "find_festival_groun...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "# We will use a combination of Depth First Search (DFS) and Breadth First Search (BFS) to solve this problem.\n# The idea is to first find the farthest node from a...
trial_gpt4o_0
{ "original_instruction": "In the kingdom of Valoria, there are n villages connected by roads in a way that forms a tree structure. Each village is numbered from 1 to n and each of the n-1 roads connects two villages bi-directionally. The villagers want to build a festival ground in one of the villages. They desire t...
0.615265
Taco_70105
C
[ "bfs_farthest_node", "find_festival_ground", "solve" ]
3
[ [ "find_festival_ground", "bfs_farthest_node" ], [ "solve", "find_festival_ground" ] ]
2
[]
false
[]
false
pytest
false
[]
true
8732c012a348a3a7501d2568c4c886d032ae1193
b0bd459192c1827748198a8737ba20773f40a69f
v1.0
complete
Taco
Taco_70595_C
from typing import List, Tuple def can_cut_into_k_pieces(M: int, N: int, K: int, cake: List[str]) -> str: """ Determine if it is possible to cut the cake into exactly K pieces such that no piece contains more than one strawberry. >>> can_cut_into_k_pieces(3, 3, 4, ["...", ".S.", "..."]) "YES" >>> can_...
def can_cut_into_k_pieces(M, N, K, cake): # Count the number of strawberries in the cake strawberry_count = sum(row.count('S') for row in cake) # If the number of strawberries is greater than K, it's impossible to achieve the goal. if strawberry_count > K: return "NO" # If there ar...
from solution import solve, parse_input def test_case_1(): input_string = """3 3 3 4 ... .S. ... 5 5 5 ..... ...S. ..... .S... ..... 4 4 2 .S.. ..S. .... ....""" test_cases = parse_input(input_string) assert solve(test_cases) == ["YES", "NO", "NO"] def test_case_2(): input_string = """1 5 5 10 ..S.. ....
[ { "docstring": null, "function_declaration": "def can_cut_into_k_pieces(M, N, K, cake):", "function_name": "can_cut_into_k_pieces", "parameter_list": "(M, N, K, cake)" }, { "docstring": null, "function_declaration": "def solve(test_cases):", "function_name": "solve", "parameter_l...
[ 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 can_cut_cake(M, N, K, cake_grid):\n # Count the number of strawberries\n strawberry_count = sum(row.count('S') for row in cake_grid)\n\n # To cut into...
trial_gpt4o_1
{ "original_instruction": "Chef is trying to cut a large rectangular cake which is represented by a grid of cells of size M x N. Each cell can be either plain (represented by '.') or contain a strawberry (represented by 'S'). Chef can only make vertical or horizontal cuts between the cells, and once a cut is made, it...
0.668542
Taco_70595
C
[ "can_cut_into_k_pieces", "solve", "parse_input" ]
3
[ [ "solve", "can_cut_into_k_pieces" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
32dbc0e83129fb46c3bf77f88a25574109ccdd8f
d00ff01da0b574d3e4ae16ace5881fc21dfdbb7a
v1.0
complete
Taco
Taco_70786_C
def update_value(array, index, value): """ Updates the value at the given index of the array. """ pass def range_sum(array, left, right): """ Returns the sum of elements in the array from index left to right, inclusive. """ pass def process_queries(N, Q, array, queries): """ Pr...
def update_value(array, index, value): """ Updates the value at the given index of the array. """ array[index - 1] = value def range_sum(array, left, right): """ Returns the sum of elements in the array from index left to right, inclusive. """ return sum(array[left - 1:right]) def proc...
import pytest from solution import update_value, range_sum, process_queries def test_update_value(): array = [1, 2, 3, 4, 5] update_value(array, 2, 10) assert array == [1, 10, 3, 4, 5] def test_range_sum(): array = [1, 2, 3, 4, 5] assert range_sum(array, 1, 3) == 6 assert range_sum(array, 2, 4...
[ { "docstring": "Updates the value at the given index of the array.", "function_declaration": "def update_value(array, index, value):", "function_name": "update_value", "parameter_list": "(array, index, value)" }, { "docstring": "Returns the sum of elements in the array from index left to rig...
[ 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 NumArray:\n def __init__(self, nums):\n self.nums = nums\n self.n = len(nums)\n self.tree = [0] * (self.n + 1)\n for i in rang...
trial_gpt4o_2
{ "original_instruction": "Problem :\n\nYou are given an array A comprising of N non-negative integers A[1], A[2]...A[N]. You need to perform a series of operations that include updating the array and calculating the sum of elements within a given range. The two types of queries you will receive are:\n\n1. Update ope...
0.528964
Taco_70786
C
[ "update_value", "range_sum", "process_queries" ]
3
[ [ "process_queries", "range_sum" ], [ "process_queries", "update_value" ] ]
2
[ "process_queries" ]
false
[]
false
pytest
true
[]
true
85ab659a752f6c6594267bc4976b668bb2e8e3fe
826c7b242489d8296e8a77fe4afac5b9198a2fab
v1.0
complete
Taco
Taco_70619_C
import math from typing import List, Tuple def minimum_spanning_tree(n: int, coordinates: List[Tuple[int, int]]) -> float: """ Computes the minimum total length of roads required to connect all buildings without any cycles, using the Minimum Spanning Tree (MST) concept. Parameters: n (int): ...
import math import heapq def calculate_distance(x1, y1, x2, y2): return math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2) def minimum_spanning_tree(n, coordinates): edges = [] for i in range(n): for j in range(i + 1, n): x1, y1 = coordinates[i] x2, y2 = coordinates[j] ...
from solution import minimum_spanning_tree def test_example_1(): n = 4 coordinates = [(0, 0), (0, 1), (1, 0), (1, 1)] result = minimum_spanning_tree(n, coordinates) assert math.isclose(result, 3.0000000000, abs_tol=1e-6) def test_example_2(): n = 3 coordinates = [(0, 0), (4, 0), (0, 3)] re...
[ { "docstring": null, "function_declaration": "def calculate_distance(x1, y1, x2, y2):", "function_name": "calculate_distance", "parameter_list": "(x1, y1, x2, y2)" }, { "docstring": null, "function_declaration": "def minimum_spanning_tree(n, coordinates):", "function_name": "minimum_...
[ 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": "import math\nimport heapq\n\ndef euclidean_distance(point1, point2):\n return math.sqrt((point1[0] - point2[0]) ** 2 + (point1[1] - point2[1]) ** 2)\n\ndef mini...
trial_gpt4o_1
{ "original_instruction": "You are tasked with designing a city road network for a new smart city project. The city will consist of n buildings connected by roads. The goal is to ensure that there is no cycle in the road network while minimizing the total length of the roads. Thus, the network should form a Minimum S...
0.600619
Taco_70619
C
[ "calculate_distance", "minimum_spanning_tree" ]
2
[ [ "minimum_spanning_tree", "calculate_distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3d6956da2f794ffa178a2b11f7fc98fcd0ac560f
80183ca1d5b456ccaa4c7bce06e52c3700e4940e
v1.0
complete
Taco
Taco_70912_C
from itertools import combinations def find_subsets(numbers): """ Finds all possible subsets of the array and returns them in a lexicographic order. >>> find_subsets([1, 2, 3]) [(), (1,), (2,), (3,), (1, 2,), (1, 3,), (2, 3,), (1, 2, 3,)] >>> find_subsets([10, 9]) [(), (9,), (10,), (9, 10,)] ...
from itertools import combinations def find_subsets(numbers): """ Finds all possible subsets of the array and returns them in a lexicographic order. """ numbers.sort() subsets = [] n = len(numbers) for i in range(n + 1): for comb in combinations(numbers, i): subsets...
from solution import find_subsets, print_subsets from io import StringIO import sys def test_find_subsets_with_3_elements(): numbers = [1, 2, 3] result = find_subsets(numbers) expected = [ (), (1,), (2,), (3,), (1, 2,), (1, 3,), (2, 3,), (1, 2...
[ { "docstring": "Finds all possible subsets of the array and returns them in a lexicographic order.", "function_declaration": "def find_subsets(numbers):", "function_name": "find_subsets", "parameter_list": "(numbers)" }, { "docstring": null, "function_declaration": "def print_subsets(n, ...
[ 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": "from itertools import combinations\n\ndef power_set_lexicographic(arr):\n \"\"\"\n Returns the power set of the array sorted in lexicographic order.\n \"\...
trial_gpt4o_4
{ "original_instruction": "For a given array of distinct integers, write a program to find all possible subsets (the power set) and output them in lexicographic order.\n\nConstraints\n\n* The array will have no more than 10 distinct elements.\n* Each subset should be listed on a new line, with elements separated by a...
0.6588
Taco_70912
C
[ "find_subsets", "print_subsets" ]
2
[ [ "print_subsets", "find_subsets" ] ]
1
[]
false
[]
false
pytest
true
[]
true
abe9ddff5a728ed3bac3be01502e0b8a6ca427bc
e73a5e07b32617c88570d96a241b2c2fdd9cea20
v1.0
complete
Taco
Taco_70865_C
def is_palindrome(s: str) -> bool: """ Helper function to check if a string is a palindrome. >>> is_palindrome("a") True >>> is_palindrome("aa") True >>> is_palindrome("racecar") True >>> is_palindrome("raceecar") True >>> is_palindrome("radar") True >>> is_palindrom...
def is_palindrome(s: str) -> bool: """ Helper function to check if a string is a palindrome. """ return s == s[::-1] def isAlmostPalindrome(s: str) -> bool: """ Returns True if the string s can be transformed into a palindrome by removing at most one character, otherwise, returns False. ...
def test_isAlmostPalindrome(): assert isAlmostPalindrome("abca") == True assert isAlmostPalindrome("abc") == False assert isAlmostPalindrome("a") == True assert isAlmostPalindrome("aa") == True assert isAlmostPalindrome("racecar") == True assert isAlmostPalindrome("raceecar") == True assert ...
[ { "docstring": "Helper function to check if a string is a palindrome.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": "Returns True if the string s can be transformed into a palindrome by \nremoving at most one ch...
[ 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_palindrome(s):\n \"\"\"\n Helper function to check if a given string is a palindrome.\n \"\"\"\n return s == s[::-1]\n\ndef isAlmostPalindrome(s...
trial_gpt4o_1
{ "original_instruction": "Function checkPalindrome() is an ideal interview question testing for understanding of recursion and string manipulation.\nGiven a string s, check if it can be transformed into a palindrome by removing at most one character from it. A string is considered a palindrome if it reads the same f...
0.87256
Taco_70865
C
[ "is_palindrome", "isAlmostPalindrome" ]
2
[ [ "isAlmostPalindrome", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
false
[]
true
1e38c85746310df125ab419e133da6ff402495f8
0688efe78c66f8e647e70d4df286bf44afa761d8
v1.0
complete
Taco
Taco_70729_C
from typing import List, Tuple def can_complete_deliveries(n: int, m: int, roads: List[Tuple[int, int, int]], k: int, capacities: List[int], l: int, deliveries: List[Tuple[int, int]]) -> int: """ A delivery company has a large fleet of delivery trucks that often visit multiple destinations. Each truck has...
import heapq import sys from collections import defaultdict, deque def dijkstra(graph, start, n): distances = [float('inf')] * (n + 1) distances[start] = 0 priority_queue = [(0, start)] while priority_queue: current_distance, current_node = heapq.heappop(priority_queue) if...
def test_example_1(): n = 5 m = 6 roads = [ (1, 2, 3), (1, 3, 4), (1, 4, 2), (2, 4, 5), (3, 4, 1), (4, 5, 6) ] k = 3 capacities = [2, 2, 4] l = 3 deliveries = [ (1, 5), (3, 3), (5, 1) ] assert can_complete_de...
[ { "docstring": null, "function_declaration": "def dijkstra(graph, start, n):", "function_name": "dijkstra", "parameter_list": "(graph, start, n)" }, { "docstring": null, "function_declaration": "def can_complete_deliveries(n, m, roads, k, capacities, l, deliveries):", "function_name"...
[ 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": "import heapq\n\ndef dijkstra(adj, start, n):\n # Initialize distances and priority queue\n dist = [float('inf')] * (n + 1)\n dist[start] = 0\n pq = [(0...
trial_gpt4o_4
{ "original_instruction": "A delivery company has a large fleet of delivery trucks that often visit multiple destinations. Each truck has a delivery capacity, which is the maximum number of locations it can visit in one trip. Due to recent traffic issues, the company wants to minimize the total travel distance of its...
0.681136
Taco_70729
C
[ "dijkstra", "can_complete_deliveries" ]
2
[ [ "can_complete_deliveries", "dijkstra" ] ]
1
[]
false
[]
false
pytest
false
[]
true
5f90928dedd80b70b0d951b5101837b870da1f2f
5c737ce42b6105f53457224b7f875d8fa6087964
v1.0
complete
Taco
Taco_71114_C
[Completion Task in Python] def is_special(num: int) -> bool: """ Check if a number is 'special', i.e., if the sum of its digits is divisible by 3. >>> is_special(123) == True >>> is_special(38) == False >>> is_special(39) == True """ def find_smallest_special_number(N: int) -> int: """ ...
def is_special(num): """ Check if a number is 'special', i.e., if the sum of its digits is divisible by 3. """ digit_sum = sum(int(digit) for digit in str(num)) return digit_sum % 3 == 0 def find_smallest_special_number(N): """ Find the smallest 'special' number greater than or equal to N. ...
def test_is_special(): assert is_special(123) == True assert is_special(38) == False assert is_special(39) == True assert is_special(57) == True def test_find_smallest_special_number(): assert find_smallest_special_number(57) == 57 assert find_smallest_special_number(38) == 39 assert find_s...
[ { "docstring": "Check if a number is 'special', i.e., if the sum of its digits is divisible by 3.", "function_declaration": "def is_special(num):", "function_name": "is_special", "parameter_list": "(num)" }, { "docstring": "Find the smallest 'special' number greater than or equal to N.", ...
[ 0, 0, 0, 1, 1 ]
2
medium
0.4
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_special_number(n):\n \"\"\"\n Checks whether the sum of digits of `n` is divisible by 3.\n \"\"\"\n return sum(int(digit) for digit in str(n)) %...
trial_gpt4o_4
{ "original_instruction": "Alice is a big fan of number theory and enjoys playing with numbers. She has recently discovered an interesting property of numbers. She calls a number 'special' if the sum of its digits is divisible by 3. For example, 123 is special because 1 + 2 + 3 = 6, which is divisible by 3. \n\nGiven...
0.642077
Taco_71114
C
[ "is_special", "find_smallest_special_number" ]
2
[ [ "find_smallest_special_number", "is_special" ] ]
1
[]
false
[]
false
pytest
false
[]
true
3a14d1a7011c3367970d596ffcbf31156e061b27
a91a921b1f63be9efd25ddec0bc2b4174f1bef07
v1.0
complete
Taco
Taco_71008_C
class Node: def __init__(self, key): self.data = key self.left = None self.right = None def leftViewUtil(current_node, current_level, max_level, view): """Utility function to find the left view of the binary tree.""" if current_node is None: return # If this is the ...
class Node: def __init__(self, key): self.data = key self.left = None self.right = None def leftViewUtil(current_node, current_level, max_level, view): """Utility function to find the left view of the binary tree.""" if current_node is None: return # If this is the ...
from solution import Node, leftView def test_left_view_example_1(): root = Node(1) root.left = Node(2) root.right = Node(3) root.left.left = Node(4) root.left.right = Node(5) root.right.left = Node(6) root.right.right = Node(7) root.left.right.right = Node(8) assert leftView(ro...
[]
[ 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, value=0, left=None, right=None):\n self.value = value\n self.left = left\n self.right = right\n\ndef l...
trial_gpt4o_2
{ "original_instruction": "Given a binary tree, the task is to find the left view of the binary tree. The left view of a binary tree is the set of nodes visible when the tree is viewed from the left side.\n\nExample 1: \nInput:\n```\n 1\n / \\\n 2 3\n / \\ / \\\n 4 5 6 7\n ...
0.552464
Taco_71008
C
[ "leftViewUtil", "leftView" ]
2
[ [ "leftView", "leftViewUtil" ] ]
1
[]
false
[ "Node" ]
true
pytest
true
[]
true
5475c12712cad50436e37eae19f4dd8b39ca9ac9
a7795cadd783d65b26d9f7514950e15f943a977b
v1.0
complete
Taco
Taco_71179_C
def largest_rectangle_in_grid(n: int, m: int, grid: List[str]) -> int: """ Find the area of the largest rectangular plot of fertile land in a given grid. >>> largest_rectangle_in_grid(3, 4, ['1011', '1101', '1110']) 4 >>> largest_rectangle_in_grid(2, 2, ['11', '01']) 2 >>> largest_rectangle_in_g...
def largest_rectangle_area_in_histogram(heights): stack = [] max_area = 0 index = 0 while index < len(heights): if not stack or heights[stack[-1]] <= heights[index]: stack.append(index) index += 1 else: top_of_stack = stack.pop() area ...
def test_largest_rectangle_in_grid_1(): n, m = 3, 4 grid = [ '1011', '1101', '1110' ] assert largest_rectangle_in_grid(n, m, grid) == 4 def test_largest_rectangle_in_grid_2(): n, m = 2, 2 grid = [ '11', '01' ] assert largest_rectangle_in_grid(n, m...
[ { "docstring": null, "function_declaration": "def largest_rectangle_area_in_histogram(heights):", "function_name": "largest_rectangle_area_in_histogram", "parameter_list": "(heights)" }, { "docstring": null, "function_declaration": "def largest_rectangle_in_grid(n, m, grid):", "funct...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def largest_rectangle_area_in_histogram(heights):\n stack = []\n max_area = 0\n index = 0\n \n while index < len(heights):\n if not stack or ...
trial_gpt4o_0
{ "original_instruction": "Your friend is working on a virtual farming simulation game. The game world consists of a rectangular grid of size `n x m`. Each cell in the grid either contains fertile land or an obstacle (like a rock or a tree).\n\nThe objective of the game is to find the largest possible rectangular plo...
0.697644
Taco_71179
C
[ "largest_rectangle_area_in_histogram", "largest_rectangle_in_grid" ]
2
[ [ "largest_rectangle_in_grid", "largest_rectangle_area_in_histogram" ] ]
1
[]
false
[]
false
pytest
false
[]
true
24463b2b04769abaf68f3de2bea6dcff27adfed0
c7d312ebc68fd2aab9d51c0e875f0179d07921d6
v1.0
complete
Taco
Taco_71176_C
def valid_task_sequence(T: int, D: int, dependencies: List[Tuple[int, int]]) -> str: """ Determine a valid sequence of task completions that respects all dependencies. :param T: int - Number of tasks. :param D: int - Number of dependencies. :param dependencies: List[Tuple[int, int]] - Each tuple (a, b) ...
from collections import deque def find_task_order(T, D, dependencies): graph = {i: [] for i in range(1, T + 1)} in_degrees = {i: 0 for i in range(1, T + 1)} for a, b in dependencies: graph[a].append(b) in_degrees[b] += 1 queue = deque([node for node in in_degrees if in_degrees[node] =...
from solution import valid_task_sequence def test_case_1(): assert valid_task_sequence(4, 3, [(1, 2), (1, 3), (3, 4)]) in {"1 3 4 2", "1 3 2 4", "1 2 3 4"} def test_case_2(): assert valid_task_sequence(3, 3, [(1, 2), (2, 3), (3, 1)]) == "IMPOSSIBLE" def test_case_3(): assert valid_task_sequence(2, 0, [])...
[ { "docstring": null, "function_declaration": "def find_task_order(T, D, dependencies):", "function_name": "find_task_order", "parameter_list": "(T, D, dependencies)" }, { "docstring": null, "function_declaration": "def valid_task_sequence(T, D, dependencies):", "function_name": "vali...
[ 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 collections import defaultdict, deque\n\ndef find_task_order(T, D, dependencies):\n def kahn_topological_sort():\n in_degree = [0] * (T + 1)\n ...
trial_gpt4o_1
{ "original_instruction": "A company is organizing a team-building event where employees will participate in a series of tasks. Each task can be performed by one or more employees, and some tasks depend on the completion of others. In order to ensure the event runs smoothly, the organizers need to determine the order...
0.534862
Taco_71176
C
[ "find_task_order", "valid_task_sequence" ]
2
[ [ "valid_task_sequence", "find_task_order" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2f16ce6a6240b8ebc765a67448e361448332402c
5972f0b8e257fdf37abbeb8073ffabc240cb3de0
v1.0
complete
Taco
Taco_71188_C
from typing import List def get_primes(numbers: List[int]) -> List[int]: """ Takes a list of integers and returns a new list containing only the prime numbers from the original list, arranged in descending order. >>> get_primes([2, 3, 4, 5, 6, 7, 8, 9, 10]) == [7, 5, 3, 2] >>> get_primes([12, 14...
def is_prime(n): """ Helper function to check if a number is prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def get_primes(nu...
from solution import get_primes def test_no_primes(): assert get_primes([1, 4, 6, 8, 10, 12]) == [] def test_some_primes(): assert get_primes([2, 3, 4, 5, 6, 7, 8, 9, 10]) == [7, 5, 3, 2] def test_all_primes(): assert get_primes([2, 3, 5, 7, 11]) == [11, 7, 5, 3, 2] def test_mixed_numbers(): ass...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of prime numbers from the input list, sorted in descending order.", "function_declaration": ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Helper function to check if a number n is prime.\n \"\"\"\n if n <= 1:\n return False\n for i in range(2, int(n**...
trial_gpt4o_2
{ "original_instruction": "Write a function that takes a list of integers and returns a new list containing only the prime numbers from the original list, arranged in descending order. \n\nA prime number is a natural number greater than 1 that is not a product of two smaller natural numbers.\n\nFor example:\n```pytho...
0.749242
Taco_71188
C
[ "is_prime", "get_primes" ]
2
[ [ "get_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
85653e174ae9795d6f376852e63ffb57724e7f89
983d019a4912f514b30b60597dae2962f0f49b46
v1.0
complete
Taco
Taco_71002_C
def is_unlockable_sequence(N, sequence): """ Returns whether the given sequence of strings is unlockable. A sequence is unlockable if all strings are permutations of each other. :param N: Number of strings in the sequence :param sequence: List of strings representing the lock sequence ...
def is_unlockable_sequence(N, sequence): """ Returns whether the given sequence of strings is unlockable. A sequence is unlockable if all strings are permutations of each other. :param N: Number of strings in the sequence :param sequence: List of strings representing the lock sequence ...
import pytest from solution import is_unlockable_sequence, unlock_sequences def test_is_unlockable_sequence_all_permutations(): assert is_unlockable_sequence(3, ['123', '321', '312']) == "Unlockable" def test_is_unlockable_sequence_not_permutations(): assert is_unlockable_sequence(2, ['111', '121']) == "Not U...
[ { "docstring": "Returns whether the given sequence of strings is unlockable.\nA sequence is unlockable if all strings are permutations of \neach other.\n\n:param N: Number of strings in the sequence\n:param sequence: List of strings representing the lock sequence\n:return: \"Unlockable\" if the sequence can be ...
[ 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_unlockable(sequence):\n \"\"\"\n Determines if a sequence of strings can unlock the vault by\n verifying if all strings are permutations of each ot...
trial_gpt4o_2
{ "original_instruction": "A digital competition requires participants to unlock a secure vault by solving a sequence of challenges. Each participant needs to crack a custom sequence of lock codes that follow specific constraints. Your task is to write a program to determine whether a given sequence can be unlocked.\...
0.542602
Taco_71002
C
[ "is_unlockable_sequence", "process_input", "unlock_sequences" ]
3
[ [ "unlock_sequences", "is_unlockable_sequence" ], [ "unlock_sequences", "process_input" ] ]
2
[ "process_input" ]
false
[]
false
pytest
true
[]
true
0fb40b36127264ea9ed3a3ae9d48e82f4852c755
3fdaea3a800df42ad56aeae2d0b7b2091943788c
v1.0
complete
Taco
Taco_71367_C
def next_prime(n: int) -> int: """Given a positive integer n, return the smallest prime number that is greater than n. If n is a prime number itself, return the next prime number. >>> next_prime(7) 11 >>> next_prime(14) 17 >>> next_prime(29) 31 """
def is_prime(num): """ Helper function to check if a number is prime. """ if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return F...
from solution import next_prime def test_next_prime_of_7(): assert next_prime(7) == 11 def test_next_prime_of_14(): assert next_prime(14) == 17 def test_next_prime_of_29(): assert next_prime(29) == 31 def test_next_prime_of_prime_number_23(): assert next_prime(23) == 29 def test_next_prime_of_large...
[ { "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 the smallest prime number that is greater than n.\nIf n is a prime number itself, returns the 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(x):\n \"\"\"\n Checks whether a given number x is prime.\n \"\"\"\n if x <= 1:\n return False\n if x <= 3:\n return True\...
trial_gpt4o_1
{ "original_instruction": "Given a positive integer `n`, return the smallest prime number that is greater than `n`. If `n` is a prime number itself, return the next prime number.\n\n**Note**: Efficient solutions are required because large inputs will be tested.\n\n## Examples:\n\nFor `n = 7`, the next prime number is...
0.74767
Taco_71367
C
[ "is_prime", "next_prime" ]
2
[ [ "next_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1ec4dd10dd6769d1a2931c5ef523c1d50aae6f47
bd3bff960f79b506e503a8128956ce4400505099
v1.0
complete
Taco
Taco_71329_C
def restore_ip_addresses(s: str) -> List[str]: """ Given a string of digits, return all possible valid IP addresses by inserting dots. Each IP address consists of exactly four integers (each between 0 and 255, inclusive), and integers cannot have leading zeros (unless they are zero). >>> restore_i...
def is_valid(segment): """ Check if a segment is a valid IP address part. """ if not segment or (segment[0] == '0' and len(segment) > 1) or int(segment) > 255: return False return True def restore_ip_addresses(s): """ Given a string of digits, return all possible valid IP addresses ...
from solution import restore_ip_addresses def test_restore_ip_addresses_1(): assert restore_ip_addresses("25525511135") == ["255.255.11.135", "255.255.111.35"] def test_restore_ip_addresses_2(): assert restore_ip_addresses("0000") == ["0.0.0.0"] def test_restore_ip_addresses_3(): assert restore_ip_addres...
[ { "docstring": "Check if a segment is a valid IP address part.", "function_declaration": "def is_valid(segment):", "function_name": "is_valid", "parameter_list": "(segment)" }, { "docstring": "Given a string of digits, return all possible valid IP addresses by inserting dots.", "function...
[ 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 valid_ip(s):\n \"\"\"\n Given a string containing only digits, return all possible valid IP addresses\n that can be obtained by inserting dots into th...
trial_gpt4o_2
{ "original_instruction": "Given a string of digits, find and return all possible valid IP addresses that can be obtained by inserting dots into the string. A valid IP address must follow these rules:\n\n1. It consists of exactly four integers, each integer is between 0 and 255, inclusive.\n2. Integers cannot have le...
0.608694
Taco_71329
C
[ "is_valid", "restore_ip_addresses" ]
2
[ [ "restore_ip_addresses", "is_valid" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2702f02340739fcb8486e433035c36ac344935e9
e18e9c7547f4a0abc7c2ac7f50ae54607b7de166
v1.0
complete
Taco
Taco_71237_C
def exists_path_in_grids(T: int, test_cases: List[List[List[str]]]) -> List[str]: """ Determines if there exists a path from the top-left corner to the bottom-right corner of the grid for each test case. :param T: Integer -- the number of test cases :param test_cases: List of grid for each test case (g...
def path_exists(grid): """ Determines if there exists a path from the top-left corner to the bottom-right corner of the grid. :param grid: List[List[str]] -- the grid of size N x N :return: str -- "YES" if a path exists, otherwise "NO" """ N = len(grid) if grid[0][0] == 'O' or grid[N-1]...
import pytest from solution import exists_path_in_grids def test_single_tests(): assert exists_path_in_grids(2, [ [['E', 'E'], ['E', 'O']], [['E', 'O', 'E'], ['E', 'E', 'E'], ['O', 'E', 'E']] ]) == ["NO", "YES"] def test_edge_case_smallest_grid(): assert exists_path_in_grids(1, [ [...
[ { "docstring": "Determines if there exists a path from the top-left corner to the bottom-right corner of the grid.\n\n:param grid: List[List[str]] -- the grid of size N x N\n:return: str -- \"YES\" if a path exists, otherwise \"NO\"", "function_declaration": "def path_exists(grid):", "function_name": "p...
[ 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 can_reach_end(grid):\n \"\"\"\n Determines if there exists a path from the top-left corner to the bottom-right corner in the grid.\n Only right and do...
trial_gpt4o_4
{ "original_instruction": "There is a large square grid of size N x N. Each cell in the grid can either be 'empty' or contain an 'obstacle'. You are given the grid and need to determine if there exists a path from the top-left corner of the grid (0, 0) to the bottom-right corner of the grid (N-1, N-1). You can only m...
0.644742
Taco_71237
C
[ "path_exists", "exists_path_in_grids", "formatted_result" ]
3
[ [ "exists_path_in_grids", "path_exists" ], [ "formatted_result", "exists_path_in_grids" ] ]
2
[]
false
[]
false
pytest
true
[]
true
5e27c894a9f7968eadac702eab7cfaf2b8888d28
3999c460570d00ef3cfa1ba12a60846857c543b5
v1.0
complete
Taco
Taco_70946_C
from typing import List, Tuple def find_shortest_path(N: int, M: int, S: int, T: int, edges: List[Tuple[int, int, int]]) -> int: """ Finds the shortest path from location S to location T in a warehouse represented as a graph of N nodes and M edges. Parameters: ----------- N : int Number of...
import heapq def dijkstra(N, M, S, T, edges): graph = [[] for _ in range(N + 1)] for u, v, w in edges: graph[u].append((v, w)) graph[v].append((u, w)) pq = [(0, S)] distances = {i: float('inf') for i in range(1, N + 1)} distances[S] = 0 while pq: current_distance, curr...
from solution import find_shortest_path def test_shortest_path_sample_1(): N, M = 5, 6 S, T = 1, 5 edges = [ (1, 2, 4), (1, 3, 2), (2, 3, 5), (2, 4, 10), (3, 4, 3), (4, 5, 7), ] assert find_shortest_path(N, M, S, T, edges) == 12 def test_no_path(...
[ { "docstring": null, "function_declaration": "def dijkstra(N, M, S, T, edges):", "function_name": "dijkstra", "parameter_list": "(N, M, S, T, edges)" }, { "docstring": null, "function_declaration": "def find_shortest_path(N, M, S, T, edges):", "function_name": "find_shortest_path", ...
[ 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(N, M, S, T, edges):\n \"\"\"\n Calculate the shortest path from location S to location T using Dijkstra's algorithm.\n \...
trial_gpt4o_2
{ "original_instruction": "You are managing a warehouse and need to move packages between different locations. The warehouse consists of $N$ locations, represented as nodes in a graph, and there are $M$ bidirectional paths between these locations, represented as edges. Each edge has a weight associated with it, repre...
0.663183
Taco_70946
C
[ "dijkstra", "find_shortest_path" ]
2
[ [ "find_shortest_path", "dijkstra" ] ]
1
[]
false
[]
false
pytest
true
[]
true
831a8ccbfee74ff13c7c95f0b781427d13551edb
fd662b0d634c720085ede9835c388b07bad74d01
v1.0
complete
Taco
Taco_71455_C
from typing import List def is_prime(num: int) -> bool: """ Check if a number is prime. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(17) True >>> is_prime(1000) False >>> is_prime(9999) False """ pass def is_valid_house_number...
def is_prime(num): if num <= 1: return False for i in range(2, int(num**0.5) + 1): if num % i == 0: return False return True def is_valid_house_number(house_number): letters = house_number[:3] number = int(house_number[3:]) ascii_sum = sum(ord(char) for char in ...
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(1000) == False assert is_prime(9999) == False def test_is_valid_house_number(): assert is_valid_house_number("ABC1237") == True assert is_va...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def is_valid_house_number(house_number):", "function_name": "is_valid_house_number", "parameter_list": "(hous...
[ 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 is_prime(num):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num == 2:\n r...
trial_gpt4o_2
{ "original_instruction": "In a parallel world, there exists a unique numbering system for houses in a neighborhood. Each house number is a combination of a 3-letter string followed by a 4-digit number (e.g., ABC1234). The mayor of the neighborhood decided to introduce a new house numbering rule and wants to number o...
0.656638
Taco_71455
C
[ "is_prime", "is_valid_house_number", "check_house_numbers" ]
3
[ [ "check_house_numbers", "is_valid_house_number" ], [ "is_valid_house_number", "is_prime" ] ]
2
[]
false
[]
false
pytest
false
[]
true
4ad4863b999de23768fc38c6f8a1fffebf421cb2
254c72db723c1435333ac4abd1710297938b519a
v1.0
complete
Taco
Taco_71427_C
import os def normalize(path): """ Normalize the given file path by removing redundant cwd (.) and parent (..) references and unnecessary slashes. >>> normalize("a/b/../c/./d") "a/c/d" >>> normalize("/a//b////c/d//") "/a/b/c/d" >>> normalize("/a/b/../../c/./d") "/c/d" >>> normalize("/a/b/../../..")...
import os def normalize(path): """ Normalize the given file path by removing redundant cwd (.) and parent (..) references and unnecessary slashes. """ if not isinstance(path, str) or not path: raise ValueError("Invalid path") normalized_path = os.path.normpath(path) if normalized_path =...
import pytest from solution import normalize, is_absolute, join, basename def test_normalize(): assert normalize("a/b/../c/./d") == "a/c/d" assert normalize("/a//b////c/d//") == "/a/b/c/d" assert normalize("/a/b/../../c/./d") == "/c/d" assert normalize("/a/b/../../..") == "/" assert normalize(".") ...
[ { "docstring": "Normalize the given file path by removing redundant cwd (.) and parent (..) references and unnecessary slashes.", "function_declaration": "def normalize(path):", "function_name": "normalize", "parameter_list": "(path)" }, { "docstring": "Check if the given path is an absolute...
[ 0, 0, 1, 0 ]
1
hard
0.25
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import os\n\ndef normalize(path):\n if not isinstance(path, str):\n raise ValueError(\"Invalid path\")\n normalized_path = os.path.normpath(path)\n ...
trial_gpt4o_3
{ "original_instruction": "A common problem in software engineering is managing file paths. Operating systems provide various APIs to handle file operations such as reading and writing data to files, navigating directories, and managing paths.\n\n# Path Manager Contract\n\n## normalize(path)\n\n`normalize` accepts a ...
0.590493
Taco_71427
C
[ "normalize", "is_absolute", "join", "basename" ]
4
[ [ "join", "normalize" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f21039347ca282ae251a3c0f40eade54be2375e2
8477e33f59490e8d9711c2832e789a129b92d83c
v1.0
complete
Taco
Taco_71450_C
def messenger_travel_time(N: int, M: int, roads: List[Tuple[int, int, int]]) -> int: """ Determines the maximum time it takes for a messenger to travel from the capital city (city 1) to any other city using optimal routes. >>> messenger_travel_time(6, 7, [(1, 2, 4), (1, 3, 2), (2, 3, 1), (2, 4, 7), (3, 5, 3), (...
import heapq def dijkstra(graph, N, src): """ Performs Dijkstra's algorithm to find the shortest path from the source node to all other nodes. :param graph: The adjacency list of the graph. :param N: The total number of nodes. :param src: The source node. :return: The shortest path distanc...
def test_messenger_travel_time(): assert messenger_travel_time(6, 7, [(1, 2, 4), (1, 3, 2), (2, 3, 1), (2, 4, 7), (3, 5, 3), (5, 4, 2), (4, 6, 1)]) == 8 assert messenger_travel_time(5, 4, [(1, 2, 2), (2, 3, 4), (3, 4, 1), (4, 5, 3)]) == 10 assert messenger_travel_time(2, 1, [(1, 2, 5)]) == 5 assert mess...
[ { "docstring": "Performs Dijkstra's algorithm to find the shortest path from the source node to all other nodes.\n\n:param graph: The adjacency list of the graph.\n:param N: The total number of nodes.\n:param src: The source node.\n:return: The shortest path distances from the source node to all other nodes.", ...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef dijkstra(graph, N, src):\n \"\"\"\n Performs Dijkstra's algorithm to find the shortest path from the source node to all other nodes.\n ...
trial_gpt4o_0
{ "original_instruction": "A kingdom is divided into N cities connected by M bidirectional roads. Each road has a certain travel time associated with it. The ruler of the kingdom wants to ensure that it takes as little time as possible for a messenger to travel from the capital city to any other city.\n\nYou are give...
0.662782
Taco_71450
C
[ "dijkstra", "messenger_travel_time" ]
2
[ [ "messenger_travel_time", "dijkstra" ] ]
1
[]
false
[]
false
pytest
false
[]
true
149b442d7f8730a124496fa889805625babf1875
33d28d146f3a33e2df64fdf8341f1668d65b92d9
v1.0
complete
Taco
Taco_71610_C
def process_queries(n: int, m: int, grid: List[List[int]], queries: List[Tuple[int, int, int, int]]) -> List[int]: """ Find the sum of integers in the sub-grid for multiple queries. >>> process_queries(3, 3, [[1, 2, 3], [4, 5, 6], [7, 8, 9]], [(1, 1, 2, 2), (2, 2, 3, 3)]) == [12, 28] >>> process_queries(2, ...
def compute_prefix_sum(matrix): n = len(matrix) m = len(matrix[0]) prefix_sum = [[0] * (m + 1) for _ in range(n + 1)] for i in range(1, n + 1): for j in range(1, m + 1): prefix_sum[i][j] = matrix[i-1][j-1] + \ prefix_sum[i-1][j] + \ ...
def test_process_queries(): n, m = 3, 3 grid = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] queries = [ (1, 1, 2, 2), # sub-grid: [[1, 2], [4, 5]] -> sum = 12 (2, 2, 3, 3) # sub-grid: [[5, 6], [8, 9]] -> sum = 28 ] expected = [12, 28] assert process_queries(...
[ { "docstring": null, "function_declaration": "def compute_prefix_sum(matrix):", "function_name": "compute_prefix_sum", "parameter_list": "(matrix)" }, { "docstring": null, "function_declaration": "def sum_subgrid(prefix_sum, x1, y1, x2, y2):", "function_name": "sum_subgrid", "par...
[ 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 compute_subgrid_sums(n, m, grid, queries):\n \"\"\"\n Computes the sum of integers in the sub-grid for multiple queries.\n \n Parameters:\n n (i...
trial_gpt4o_1
{ "original_instruction": "You are given a grid of size `n x m` consisting of non-negative integers. Your task is to find the sum of integers in the sub-grid for multiple queries. Specifically, for each query, you will be given the top left and bottom right coordinates of a sub-grid, and you need to compute the sum o...
0.611626
Taco_71610
C
[ "compute_prefix_sum", "sum_subgrid", "process_queries" ]
3
[ [ "process_queries", "compute_prefix_sum" ], [ "process_queries", "sum_subgrid" ] ]
2
[ "process_queries" ]
false
[]
false
pytest
false
[]
true
fc9999aa0593f916d599a14b3dceeea06a0080df
41357b34d27a74eecceed4cd453d4f4ab26d52d0
v1.0
complete
Taco
Taco_71652_C
def validPalindrome(s: str) -> bool: """ Given a string s consisting of lowercase alphabets, check if the string is a palindrome or can be made palindrome by removing at most one character. A string is considered a palindrome if it reads the same forward and backward. Args: s (str): the input strin...
def is_palindrome(s, left, right): """ Helper function to check if the substring s[left:right+1] is a palindrome. """ while left < right: if s[left] != s[right]: return False left += 1 right -= 1 return True def validPalindrome(s): """ Returns True if the...
from solution import validPalindrome def test_palindrome(): # Perfect palindrome assert validPalindrome("racecar") == True def test_single_removal_make_palindrome(): # Single character removal to make palindrome assert validPalindrome("abca") == True # Removing 'c' makes it "aba" assert validPali...
[ { "docstring": "Helper function to check if the substring s[left:right+1] is a palindrome.", "function_declaration": "def is_palindrome(s, left, right):", "function_name": "is_palindrome", "parameter_list": "(s, left, right)" }, { "docstring": "Returns True if the string can be made a palind...
[ 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 validPalindrome(s):\n \"\"\"\n Returns True if the string can be a palindrome after removing at most one character.\n \"\"\"\n def is_palindrome(su...
trial_gpt4o_2
{ "original_instruction": "Given a string s consisting of lowercase alphabets, the task is to check if the string is a palindrome or can be made palindrome by removing at most one character. A string is considered a palindrome if it reads the same forward and backward.\nExample:\nInput: s = \"abca\"\nOutput: True\nEx...
0.871329
Taco_71652
C
[ "is_palindrome", "validPalindrome" ]
2
[ [ "validPalindrome", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
00f13405c27bb0da14bdffb8edac9978a45ce1c7
0a27f52a583bb7d2d2b94231b5e3b73e08512df3
v1.0
complete
Taco
Taco_71686_C
def solve(test_cases: List[int]) -> List[int]: """ Compute the sum of Fibonacci sequence up to p-th term for each test case and return the results modulo 10^9+7. >>> solve([5]) [12] >>> solve([4]) [7] >>> solve([6]) [20] >>> solve([5, 4, 6]) [12, 7, 20] """ pass def fibonacc...
def fibonacci_mod(n, mod=10**9 + 7): if n == 0: return 0 if n == 1: return 1 a, b = 0, 1 for _ in range(2, n+1): a, b = b, (a + b) % mod return b def sum_fibonacci_series(p, mod=10**9 + 7): sum_fib = 0 for i in range(1, p + 1): sum_fib = (sum_fib + fibonacci_mod(i, mod)) % m...
from solution import solve def test_case_1(): test_input = [5] expected_output = [12] assert solve(test_input) == expected_output def test_case_2(): test_input = [4] expected_output = [7] assert solve(test_input) == expected_output def test_case_3(): test_input = [6] expected_output =...
[ { "docstring": null, "function_declaration": "def fibonacci_mod(n, mod=10 ** 9 + 7):", "function_name": "fibonacci_mod", "parameter_list": "(n, mod=10 ** 9 + 7)" }, { "docstring": null, "function_declaration": "def sum_fibonacci_series(p, mod=10 ** 9 + 7):", "function_name": "sum_fib...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def fibonacci_sum_modulo(p, mod=10**9 + 7):\n if p < 1:\n return 0\n\n if p == 1:\n return 1\n\n # Initialize the first two Fibonacci number...
trial_gpt4o_1
{ "original_instruction": "You are given a sequence whose $n^{\\text{th}}$ term is \n\n$T_{n}=F_{m}$\nwhere $F_{m}$ is the $m^{\\text{th}}$ Fibonacci number.\n\nYou have to evaluate the series\n$S_p=T_{1}+T_{2}+T_{3}+\\cdots+T_{p}$\nFind $S_p\\:\\text{mod}\\:(10^9+7)$.\n\nInput Format \n\nThe first line of input con...
0.732527
Taco_71686
C
[ "fibonacci_mod", "sum_fibonacci_series", "solve" ]
3
[ [ "solve", "sum_fibonacci_series" ], [ "sum_fibonacci_series", "fibonacci_mod" ] ]
2
[]
false
[]
false
pytest
true
[]
true
5b8cf0974534d4b00fecbb034d3b68c27502b3b2
6ada32337473506c74aaaf4bd57cb25193c03512
v1.0
complete
Taco
Taco_71658_C
def digit_sum(n: int) -> int: """ Returns the sum of digits of the given integer n. >>> digit_sum(123) == 6 >>> digit_sum(405) == 9 >>> digit_sum(120) == 3 >>> digit_sum(99999) == 45 >>> digit_sum(12345) == 15 >>> digit_sum(1000000000) == 1 """ def min_operations_to_single_...
def digit_sum(n): """ Returns the sum of digits of the given integer n. """ return sum(int(digit) for digit in str(n)) def min_operations_to_single_digit_array(arr): """ Returns the minimum number of operations required to turn all elements in the array into single-digit numbers. """ ...
from solution import digit_sum, min_operations_to_single_digit_array def test_digit_sum(): assert digit_sum(123) == 6 assert digit_sum(405) == 9 assert digit_sum(120) == 3 assert digit_sum(99999) == 45 assert digit_sum(12345) == 15 assert digit_sum(1000000000) == 1 def test_min_operations_to_s...
[ { "docstring": "Returns the sum of digits of the given integer n.", "function_declaration": "def digit_sum(n):", "function_name": "digit_sum", "parameter_list": "(n)" }, { "docstring": "Returns the minimum number of operations required to turn all elements\nin the array into single-digit num...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sum_of_digits(num):\n \"\"\"\n Returns the sum of the digits of num.\n \"\"\"\n return sum(int(ch) for ch in str(num))\n\ndef minimum_operations_to...
trial_gpt4o_9
{ "original_instruction": "A young programmer enjoys creating mini-games. One day, he designed a simple game involving an array of integers and a special operation. The operation allows the player to choose any contiguous subarray and replace each element in that subarray with the sum of its digits. For example, give...
0.718548
Taco_71658
C
[ "digit_sum", "min_operations_to_single_digit_array" ]
2
[ [ "min_operations_to_single_digit_array", "digit_sum" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d1b328f0f84b97bfee266d33a79c7caa1fc18a6b
b3fc64acf53e04a4d058d00a55899d3efbb6b8e4
v1.0
complete
Taco
Taco_71628_C
def longest_common_subsequence(strings: List[str]) -> int: """ Given a list of strings, determine the length of the longest subsequence of characters that is common to all strings. A subsequence is defined as a sequence that can be derived from another sequence by deleting some or no elements without changing t...
def longest_common_subsequence(strings): def lcs(str1, str2): len1 = len(str1) len2 = len(str2) dp = [[0] * (len2 + 1) for _ in range(len1 + 1)] for i in range(1, len1 + 1): for j in range(1, len2 + 1): if str1[i - 1] == str2[j - 1]: dp...
from solution import longest_common_subsequence def test_longest_common_subsequence_example_1(): strings = ["abcdef", "acdf", "ade"] assert longest_common_subsequence(strings) == 2 def test_longest_common_subsequence_all_same(): strings = ["abc", "abc", "abc"] assert longest_common_subsequence(strings...
[ { "docstring": null, "function_declaration": "def longest_common_subsequence(strings):", "function_name": "longest_common_subsequence", "parameter_list": "(strings)" }, { "docstring": null, "function_declaration": "def lcs_string(str1, str2, lcs_length):", "function_name": "lcs_strin...
[ 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 longest_common_subsequence_length(strings):\n \"\"\"\n Finds the length of the longest subsequence that is common to all given strings.\n \n :param...
trial_gpt4o_4
{ "original_instruction": "Given a list of strings, determine the length of the longest subsequence of characters that is common to all strings. A subsequence is defined as a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements.\n\nInp...
0.707038
Taco_71628
C
[ "longest_common_subsequence", "lcs_string" ]
2
[ [ "longest_common_subsequence", "lcs_string" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f2b0b5f904e64c8d6bb5c9b87e8fd7204201da58
d3eadd841f080ae83d024679797a2e328d154622
v1.0
complete
Taco
Taco_71769_C
def countPrimeFactors(M: int, B: List[int]) -> int: """ Given an array B[ ] of M integers, find the number of distinct prime factors of the product of all elements in the array. Example: >>> countPrimeFactors(3, [2, 3, 5]) 3 >>> countPrimeFactors(5, [4, 9, 25, 16, 7]) 4 """
import math def get_prime_factors(n): prime_factors = set() # Check if 2 is a prime factor while n % 2 == 0: prime_factors.add(2) n //= 2 # Check for odd prime factors for i in range(3, int(math.sqrt(n)) + 1, 2): while n % i == 0: prime_factors.add(i) ...
from solution import countPrimeFactors def test_example_1(): assert countPrimeFactors(3, [2, 3, 5]) == 3 def test_example_2(): assert countPrimeFactors(5, [4, 9, 25, 16, 7]) == 4 def test_single_element(): assert countPrimeFactors(1, [10]) == 2 def test_multiple_same_elements(): assert countPrimeFac...
[ { "docstring": null, "function_declaration": "def get_prime_factors(n):", "function_name": "get_prime_factors", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def countPrimeFactors(M, B):", "function_name": "countPrimeFactors", "parameter_list": "(M, B)"...
[ 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": "from math import isqrt\nfrom functools import reduce\nfrom typing import List\n\ndef countPrimeFactors(M: int, B: List[int]) -> int:\n def sieve(n):\n pr...
trial_gpt4o_4
{ "original_instruction": "Given an array B[ ] of M integers, your task is to find the number of distinct prime factors of the product of all elements in the array.\n\nExample 1:\nInput:\nM = 3\nB = {2, 3, 5}\nOutput:\n3\nExplanation:\nThe product of the given array is 2 * 3 * 5 = 30.\nThe distinct prime factors are ...
0.695483
Taco_71769
C
[ "get_prime_factors", "countPrimeFactors" ]
2
[ [ "countPrimeFactors", "get_prime_factors" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a71470247969e15e35cbeafde7f2b6fb343047de
c15dc9421220236cc6ee359a8db45ae5d3c5392e
v1.0
complete
Taco
Taco_71778_C
def is_transformable(n: int, m: int, matrix: List[List[int]]) -> str: """ Determine if all elements in the matrix can be made equal by adding 1 to all elements of a row or a column any number of times. >>> is_transformable(2, 2, [[1, 2], [3, 4]]) 'YES' >>> is_transformable(2, 3, [[1, 2, 3], [4, 5, 6]]) 'NO'...
def can_make_elements_equal(matrix): # Calculate the difference between first row and all other rows row_diffs = [] reference_first_row = matrix[0] for i in range(1, len(matrix)): diff = [matrix[i][j] - reference_first_row[j] for j in range(len(matrix[0]))] row_diffs.append(diff) ...
from solution import is_transformable def test_sample_input_1(): n = 2 m = 2 matrix = [ [1, 2], [3, 4] ] assert is_transformable(n, m, matrix) == "YES" def test_sample_input_2(): n = 2 m = 3 matrix = [ [1, 2, 3], [4, 5, 6] ] assert is_transformab...
[ { "docstring": null, "function_declaration": "def can_make_elements_equal(matrix):", "function_name": "can_make_elements_equal", "parameter_list": "(matrix)" }, { "docstring": null, "function_declaration": "def is_transformable(n, m, matrix):", "function_name": "is_transformable", ...
[ 0, 1 ]
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 can_make_elements_equal(matrix, n, m):\n \"\"\"\n Determines if it is possible to make all elements of the matrix equal by \n ...
trial_gpt4o_2
{ "original_instruction": "You are given a matrix with n rows and m columns filled with integers. You can perform the following operation any number of times: select any row and add 1 to each element of that row or select any column and add 1 to each element of that column. Determine if it is possible to make all the...
0.54182
Taco_71778
C
[ "can_make_elements_equal", "is_transformable" ]
2
[ [ "is_transformable", "can_make_elements_equal" ] ]
1
[]
false
[]
false
pytest
true
[]
true
499b3605919d7e0779041c7fc581e041bbeb1008
703e7c8a359524a0335e5cb946106a087f90bec9
v1.0
complete
Taco
Taco_71760_C
def is_prime(n: int) -> bool: """ Checks if a number n is prime. >>> is_prime(2) True >>> is_prime(4) False """ def smallest_prime_ge(x: int) -> int: """ Finds the smallest prime number that is greater than or equal to x. >>> smallest_prime_ge(5) 5 >>> smallest_prime_ge(10) 11 """ ...
def is_prime(n): """ Checks if a number n is prime. """ 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 T...
from solution import process_queries def test_single_query_with_prime(): assert process_queries([5]) == [5] def test_single_query_with_non_prime(): assert process_queries([10]) == [11] def test_multiple_queries(): assert process_queries([5, 10]) == [5, 11] def test_edge_case_one(): assert process_qu...
[ { "docstring": "Checks if a number n is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Finds the smallest prime number that is greater than or equal to x.", "function_declaration": "def smallest_prime_ge(x):", ...
[ 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_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_2
{ "original_instruction": "In the realm of competitive programming, prime numbers often play a significant role. Take this challenge for instance:\n\nYou are tasked with finding the smallest positive integer that is not only a prime number but also greater than or equal to a given number $X$. Your job is to write an ...
0.671725
Taco_71760
C
[ "is_prime", "smallest_prime_ge", "process_queries" ]
3
[ [ "process_queries", "smallest_prime_ge" ], [ "smallest_prime_ge", "is_prime" ] ]
2
[ "process_queries" ]
false
[]
false
pytest
true
[]
true
de52da6bce93542cee511a70f5c74805094f2794
bdeb2096c412f1a3adf330c6ade3aa2315c9db9d
v1.0
complete
Taco
Taco_71741_C
def max_combined_potency(T: int, cases: List[Tuple[int, List[int], int, List[int]]]) -> List[int]: """Calculate the maximum combined potency that can be achieved by selecting one Mana Blossom from each list. Args: T (int): Number of test cases. cases (List[Tuple[int, List[int], int, List[int]]]): List ...
def max_combined_potency(T, cases): results = [] for i in range(T): N = cases[i][0] first_list = cases[i][1] M = cases[i][2] second_list = cases[i][3] # Calculate the maximum possible potency max_potency = max(first_list) + max(second_list) result...
from solution import solve def test_case_1(): T = 2 cases = [ (3, [4, 7, 2], 4, [5, 10, 6, 3]), (2, [1, 9], 3, [8, 5, 9]) ] assert solve(T, cases) == [17, 18] def test_case_2(): T = 1 cases = [ (5, [1, 2, 3, 4, 5], 5, [5, 4, 3, 2, 1]) ] assert solve(T, cases) ==...
[ { "docstring": null, "function_declaration": "def max_combined_potency(T, cases):", "function_name": "max_combined_potency", "parameter_list": "(T, cases)" }, { "docstring": null, "function_declaration": "def solve(T, cases):", "function_name": "solve", "parameter_list": "(T, cas...
[ 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 max_combined_potency(T, test_cases):\n results = []\n for i in range(T):\n N = test_cases[i]['N']\n A = test_cases[i]['A']\n M = tes...
trial_gpt4o_2
{ "original_instruction": "In a mystical land, there lived a group of sorcerers who had the ability to create magical potions. To enhance the potency of their potions, they utilized a rare herb called \"Mana Blossom\". The potency of a potion is maximized by combining the right amounts of two different types of Mana ...
0.591814
Taco_71741
C
[ "max_combined_potency", "solve" ]
2
[ [ "solve", "max_combined_potency" ] ]
1
[]
false
[]
false
pytest
true
[]
true
946f693b4ba96e52ee8243af097a3cad13063acf
f4ddbc5ea6ea086fcdd10bf3830492cab4ad5b16
v1.0
complete
Taco
Taco_71831_C
def is_prime(num): """ Returns True if num is a prime number, False otherwise. """ 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 ...
def is_prime(num): """ Returns True if num is a prime number, False otherwise. """ 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 ...
import pytest from solution import is_prime, nth_prime_fibonacci 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 def test_nth_prime_fibonacci(): assert nth_prime_fibonacci(1) == 2 ...
[ { "docstring": "Returns True if num is a prime number, False otherwise. ", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the n-th prime Fibonacci number. ", "function_declaration": "def nth_prime_fibonacci(...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Check if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num == 2:\n return True\n if ...
trial_gpt4o_3
{ "original_instruction": "Mia is learning about prime numbers and Fibonacci sequences in her mathematics class. Her teacher gave her an interesting problem to solve:\n\nGiven an integer $N$, Mia must find the $N$-th number in the sequence that consists only of prime numbers appearing in the Fibonacci sequence.\n\nHe...
0.869599
Taco_71831
C
[ "is_prime", "nth_prime_fibonacci" ]
2
[ [ "nth_prime_fibonacci", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
92d5ae8a0db28738428021b7a25f629492d2a077
7c5cbb72bd89bfb218cdd4f57a7b0eabb292a37e