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_64147_C
def palindromic_prime_digit_numbers(n: int) -> List[int]: """Returns a list of all integers in the range [1, n] (inclusive) that are palindromic and that consist of prime digits only. >>> palindromic_prime_digit_numbers(1) == [] >>> palindromic_prime_digit_numbers(10) == [2, 3, 5, 7] >>> palindromi...
def is_palindromic(num): """ Helper function to determine if a number is palindromic. """ s = str(num) return s == s[::-1] def has_prime_digits_only(num): """ Helper function to determine if a number contains only prime digits (2, 3, 5, 7). """ prime_digits = {'2', '3', '5', '7'} ...
from solution import palindromic_prime_digit_numbers def test_no_palindromic_prime_digit_numbers(): assert palindromic_prime_digit_numbers(0) == [] assert palindromic_prime_digit_numbers(1) == [] assert palindromic_prime_digit_numbers(8) == [2, 3, 5, 7] def test_all_one_digit_palindromic_prime_digit_numbe...
[ { "docstring": "Helper function to determine if a number is palindromic.", "function_declaration": "def is_palindromic(num):", "function_name": "is_palindromic", "parameter_list": "(num)" }, { "docstring": "Helper function to determine if a number contains only prime digits (2, 3, 5, 7).", ...
[ 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_palindromic(num):\n \"\"\"\n Returns True if the number is palindromic, otherwise False.\n \"\"\"\n return str(num) == str(num)[0:][::-1]\n\ndef...
trial_gpt4o_2
{ "original_instruction": "Design a function that takes an integer `n` and returns a list of all integers in the range `[1, n]` (inclusive) that are palindromic and which have prime digits only. A palindromic number is one that reads the same forward and backward (e.g., 121 or 1331). Prime digits include 2, 3, 5, and...
0.640599
Taco_64147
C
[ "is_palindromic", "has_prime_digits_only", "palindromic_prime_digit_numbers" ]
3
[ [ "palindromic_prime_digit_numbers", "has_prime_digits_only" ], [ "palindromic_prime_digit_numbers", "is_palindromic" ] ]
2
[]
false
[]
false
pytest
true
[]
true
68dd289863b3e591c9a06fb69f708e968ae7056b
83380f33af9b1a75bbd6c0918e6e97f4e6e37e96
v1.0
complete
Taco
Taco_64481_C
def is_happy_number(n: int) -> bool: """ Determines if the number n is a happy number. """ def check_numbers(numbers): """ For a list of numbers, determine if each number is a happy number. For every number, return "ALEX IS HAPPY" if it is a happy number, otherwise return "ALEX IS SAD". ...
def is_happy_number(n: int) -> bool: """ Determines if the number n is a happy number. """ def get_next(number): total_sum = 0 while number > 0: number, digit = divmod(number, 10) total_sum += digit ** 2 return total_sum seen = set() while n !...
from solution import is_happy_number, check_numbers def test_is_happy_number(): assert is_happy_number(19) == True assert is_happy_number(20) == False assert is_happy_number(7) == True assert is_happy_number(1) == True assert is_happy_number(2) == False def test_check_numbers(): assert che...
[ { "docstring": "Determines if the number n is a happy number.", "function_declaration": "def is_happy_number(n):", "function_name": "is_happy_number", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def check_numbers(numbers):", "function_name": "check_number...
[ 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_happy_number(n):\n \"\"\"\n Check whether a number is a happy number.\n \"\"\"\n def get_next_number(num):\n total_sum = 0\n while...
trial_gpt4o_3
{ "original_instruction": "Alex the Mathematician is studying a special sequence of numbers defined as follows: \n- The sequence starts with any non-negative integer.\n- The next number in the sequence is found by summing the squares of its digits.\n\nThe process is repeated until the sequence either reaches the numb...
0.669827
Taco_64481
C
[ "is_happy_number", "check_numbers" ]
2
[ [ "check_numbers", "is_happy_number" ] ]
1
[]
false
[]
false
pytest
true
[]
true
168d613760113489b1560a811c9ae765df094d2c
88398f49b198940d4bbf5d237cd533368159d102
v1.0
complete
Taco
Taco_63334_C
def charity_walkathon_badge(input_str: str) -> str: """ Process the input and return unique badge representations for each participant, one per line, in the format "ID followed by unique short name". >>> charity_walkathon_badge("1\n3\n1 John Doe\n2 Jane Doe\n3 Jack Doe") '1 JDoe\n2 JaDoe\n3 JacDoe' ...
def generate_badges(test_cases): from collections import defaultdict results = [] for test_case in test_cases: M, participants = test_case id_name_dict = {} unique_badges = defaultdict(list) # To store all attempted and successful short names for unique constraints final_b...
def test_single_case(): input_data = "1\n3\n1 John Doe\n2 Jane Doe\n3 Jack Doe" expected_output = "1 JDoe\n2 JaDoe\n3 JacDoe" assert charity_walkathon_badge(input_data) == expected_output def test_multiple_cases(): input_data = """2 3 1 John Doe 2 Jane Doe 3 Jack Doe 2 1 Alice B...
[ { "docstring": null, "function_declaration": "def generate_badges(test_cases):", "function_name": "generate_badges", "parameter_list": "(test_cases)" }, { "docstring": null, "function_declaration": "def parse_input(input_str):", "function_name": "parse_input", "parameter_list": "...
[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 1 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def unique_badges(T, test_cases):\n results = []\n for case in test_cases:\n M, participants = case\n unique_names = {}\n for participan...
trial_gpt4o_9
{ "original_instruction": "Riya is organizing a charity walkathon and she wants to print badges for all the participants. Each participant has a unique ID number from 1 to M and provides a string with their first name and last name. Riya wants to optimize the printing format so that each name is printed in the shorte...
0.598106
Taco_63334
C
[ "generate_badges", "parse_input", "parse_output", "charity_walkathon_badge" ]
4
[ [ "charity_walkathon_badge", "generate_badges" ], [ "charity_walkathon_badge", "parse_input" ], [ "charity_walkathon_badge", "parse_output" ] ]
3
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
9d75e8e6c366ac6032a32f43f3ff171692bce23c
6d9b9e8b2eaf3cfc21cea71ad2ece76a53eee01d
v1.0
complete
Taco
Taco_64327_C
def is_power_of_two(n): """ Helper function to check if a given number n is a power of 2. """ # Implement the function to check if n is a power of 2 pass def can_partition_to_powers_of_two(S): """ Function to check if string S can be partitioned into parts where each part is a power of 2. ...
def is_power_of_two(n): """ Helper function to check if a given number n is a power of 2. """ # Convert number to int, if not valid return False try: num = int(n) except ValueError: return False # Check if number is a power of two return num > 0 and (num & (num - 1))...
def test_is_power_of_two(): assert is_power_of_two("1") == True assert is_power_of_two("2") == True assert is_power_of_two("4") == True assert is_power_of_two("8") == True assert is_power_of_two("16") == True assert is_power_of_two("32") == True assert is_power_of_two("64") == True asser...
[ { "docstring": "Helper function to check if a given number n is a power of 2.", "function_declaration": "def is_power_of_two(n):", "function_name": "is_power_of_two", "parameter_list": "(n)" }, { "docstring": "Function to check if string S can be partitioned into parts where each part is a p...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_power_of_two(num):\n \"\"\"\n This function checks if the given number is a power of 2.\n Leading zeros are also considered invalid unless the numb...
trial_gpt4o_2
{ "original_instruction": "Zara is exploring a mysterious number sequence.\n\nGiven a string S made up of digits (0-9), determine if there is a way to partition S into one or more parts such that each part is a power of 2 (e.g., 1, 2, 4, 8, 16, 32, ...). Each power of 2 must appear at least once in its complete form ...
0.624993
Taco_64327
C
[ "is_power_of_two", "can_partition_to_powers_of_two", "mysterious_number_sequence" ]
3
[ [ "can_partition_to_powers_of_two", "is_power_of_two" ], [ "mysterious_number_sequence", "can_partition_to_powers_of_two" ] ]
2
[]
false
[]
false
pytest
false
[]
true
34894a0ff0bad8823b0d41057eb798544bf8486a
7b6bdc55a900bf9b50efcc297c80de5f3b27ce81
v1.0
complete
Taco
Taco_64191_C
from typing import List def count_inversions(arr: List[int]) -> int: """ Given a list of integers, find the number of inversions in the list. An inversion is a pair of indices (i, j) such that i < j and list[i] > list[j]. >>> count_inversions([2, 3, 8, 6, 1]) 5 >>> count_inversions([1, 2, 3, 4]) ...
def merge_count_split_inv(arr, temp_arr, left, mid, right): i = left # Starting index for left subarray j = mid + 1 # Starting index for right subarray k = left # Starting index to be sorted inv_count = 0 while i <= mid and j <= right: if arr[i] <= arr[j]: temp_arr[k] = arr[i...
from solution import count_inversions def test_example_1(): assert count_inversions([2, 3, 8, 6, 1]) == 5 def test_example_2(): assert count_inversions([1, 2, 3, 4]) == 0 def test_example_3(): assert count_inversions([3, 1, 2]) == 2 def test_single_element(): assert count_inversions([1]) == 0 def t...
[ { "docstring": null, "function_declaration": "def merge_count_split_inv(arr, temp_arr, left, mid, right):", "function_name": "merge_count_split_inv", "parameter_list": "(arr, temp_arr, left, mid, right)" }, { "docstring": null, "function_declaration": "def merge_sort_and_count(arr, temp_...
[ 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 count_inversions(arr):\n \"\"\"\n Returns the number of inversions in the array.\n \"\"\"\n def merge_count_split_inv(arr, temp_arr, left, right):\...
trial_gpt4o_2
{ "original_instruction": "Given a list of integers, an inversion is a pair of indices (i, j) such that i < j and list[i] > list[j]. Your task is to find the number of inversions in the given list.\n\n### Input\n- The first line contains a single integer N (1 ≤ N ≤ 100,000) — the length of the list.\n- The second lin...
0.850358
Taco_64191
C
[ "merge_count_split_inv", "merge_sort_and_count", "count_inversions" ]
3
[ [ "count_inversions", "merge_sort_and_count" ], [ "merge_sort_and_count", "merge_count_split_inv" ] ]
2
[]
false
[]
false
pytest
true
[]
true
2073fbd70c9d4b46e00273731d4bbf537a36dbc7
b1315e437f2a024636a72eee3052c778ecd0c25f
v1.0
complete
Taco
Taco_64278_C
from typing import List def simulate_growth(n: int, m: int, k: int, initial_grid: List[List[int]]) -> List[List[int]]: """ Simulate the growth of bacteria in a petri dish over k generations. Args: n (int): The number of rows in the petri dish. m (int): The number of columns in the petri dish. k (i...
def get_next_state(grid, n, m): """ Calculate the next state of the grid based on the growth rules. """ def get_neighbors_count(x, y): directions = [(-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 1), (1, -1), (1, 0), (1, 1)] count = 0 for dx, dy in directions: nx, ny = x + ...
from solution import simulate_growth def test_simulate_growth_one_generation(): initial_grid = [ [0, 1, 0], [0, 1, 0], [0, 1, 0] ] expected_output = [ [0, 0, 0], [1, 1, 1], [0, 0, 0] ] assert simulate_growth(3, 3, 1, initial_grid) == expected_output ...
[ { "docstring": "Calculate the next state of the grid based on the growth rules.", "function_declaration": "def get_next_state(grid, n, m):", "function_name": "get_next_state", "parameter_list": "(grid, n, m)" }, { "docstring": "Simulate the growth of the bacteria for k generations.", "fu...
[ 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_neighbors_count(grid, x, y):\n \"\"\"\n Returns the count of neighboring colonies for the cell at position (x, y).\n \"\"\"\n count = 0\n di...
trial_gpt4o_2
{ "original_instruction": "A scientist is analyzing the growth of bacteria in a petri dish. The petri dish is represented by a grid of cells, each of which can either be empty (denoted by 0) or contain a bacteria colony (denoted by 1). The growth follows these rules:\n\n1. Any cell with exactly three neighboring colo...
0.506839
Taco_64278
C
[ "get_next_state", "simulate_growth" ]
2
[ [ "simulate_growth", "get_next_state" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7781d13ac8445908b573960c0f83a1dee9465be9
747de36f3f9285410eccf91a261ad061d0b10084
v1.0
complete
Taco
Taco_64452_C
def is_palindrome(s: str) -> bool: """ Check if a string is a palindrome. >>> is_palindrome("12321") True >>> is_palindrome("abcba") True >>> is_palindrome("hello") False """ def find_palindromic_ids(test_cases: List[Tuple[int, List[str]]]) -> List[List[str]]: """ For each test case...
def is_palindrome(s): """ Check if a string is a palindrome. """ return s == s[::-1] def find_palindromic_ids(test_cases): """ For each test case, find the painting IDs that are palindromes. """ results = [] for case in test_cases: N, ids = case palindromic_ids = [pi...
from solution import find_palindromic_ids, is_palindrome def test_single_palindrome(): test_cases = [(1, ["12321"])] expected = [["12321"]] assert find_palindromic_ids(test_cases) == expected def test_multiple_palindromes(): test_cases = [(5, ["12321", "abcba", "notpalindrome", "1234321", "hello"])] ...
[ { "docstring": "Check if a string is a palindrome.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": "For each test case, find the painting IDs that are palindromes.", "function_declaration": "def find_palindrom...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(s):\n \"\"\"\n Helper function to check if a given string is a palindrome.\n \"\"\"\n return s == s[::-1]\n\ndef find_palindromic_ids...
trial_gpt4o_1
{ "original_instruction": "Mallika owns an art studio and has a collection of unique paintings. To manage her inventory, she assigns a unique ID to each painting. One day, a potential buyer asks her to provide a list of IDs of paintings that are palindromes. A palindromic ID reads the same backward as forward.\n\nGiv...
0.715448
Taco_64452
C
[ "is_palindrome", "find_palindromic_ids" ]
2
[ [ "find_palindromic_ids", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9e6af0ed573768dbeaa0bc72772d58e3ba168c66
027add44f056fa2a36918b175c7dd34ec0c37cfd
v1.0
complete
Taco
Taco_63683_C
from typing import List def is_prime(n: int) -> bool: """ Helper function to check if a number is a prime. """ pass def sumOfPrimes(arr: List[int]) -> int: """ Returns the sum of all prime numbers in the array. >>> sumOfPrimes([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) 17 >>> sumOfPrime...
def is_prime(n): """ Helper function to check if a number is a 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 ...
from solution import sumOfPrimes def test_example_cases(): assert sumOfPrimes([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 17 assert sumOfPrimes([11, 13, 17, 23, 29, 31, 37, 41, 43, 47]) == 292 assert sumOfPrimes([4, 6, 8, 10, 12]) == 0 def test_no_primes(): assert sumOfPrimes([0, 1, -3, 4, 15]) == 0 def test...
[ { "docstring": "Helper function to check if a number is a prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the sum of all prime numbers in the array.", "function_declaration": "def sumOfPrimes(arr):", ...
[ 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(num):\n \"\"\"Helper function to check if a number is prime.\"\"\"\n if num <= 1:\n return False\n if num <= 3:\n return True\n...
trial_gpt4o_2
{ "original_instruction": "# Description:\n\nYou are given an array of integers `arr`. Your task is to find the sum of all the prime numbers present in the array.\n\nA prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself.\n\nImplement a function `sumOfPrimes(arr)` that...
0.765722
Taco_63683
C
[ "is_prime", "sumOfPrimes" ]
2
[ [ "sumOfPrimes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a73e891649d9421736c3f92452d115f68e570c5a
4bfaef6349b69831a5f60a71455ca99625bc87ac
v1.0
complete
Taco
Taco_64027_C
def create_cake_grid(m: int, n: int) -> List[List[str]]: """ Creates a m x n grid with cakes ('P' for plain, 'I' for icing) such that no two cakes of the same type are adjacent horizontally, vertically, or diagonally. Args: m (int): Number of rows n (int): Number of columns Returns: Li...
def create_cake_grid(m, n): """ Creates a m x n grid with cakes ('P' for plain, 'I' for icing) such that no two cakes of the same type are adjacent horizontally, vertically, or diagonally. Args: m (int): Number of rows n (int): Number of columns Returns: List[List[str]]: m x n grid rep...
from solution import create_cake_grid def test_cake_grid_2x2(): grid = create_cake_grid(2, 2) assert grid == [['P', 'I'], ['I', 'P']] or grid == [['I', 'P'], ['P', 'I']] def test_cake_grid_3x3(): grid = create_cake_grid(3, 3) assert grid == [['P', 'I', 'P'], ['I', 'P', 'I'], ['P', 'I', 'P']] or \ ...
[ { "docstring": "Creates a m x n grid with cakes ('P' for plain, 'I' for icing) such that no two cakes\nof the same type are adjacent horizontally, vertically, or diagonally.\n\nArgs:\nm (int): Number of rows\nn (int): Number of columns\n\nReturns:\nList[List[str]]: m x n grid represented as a list of lists", ...
[ 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 create_cake_grid(m, n):\n \"\"\"\n Creates a m x n grid with cakes ('P' for plain, 'I' for icing) such that no two cakes\n of the same type are adjace...
trial_gpt4o_0
{ "original_instruction": "The Dessert Chef is arranging a display of cakes on a rectangular grid for a bakery competition. Each cell in the grid can hold exactly one cake. All the cakes are either plain or with icing. However, the competition rules stipulate that no two cakes of the same type should be placed next t...
0.604649
Taco_64027
C
[ "create_cake_grid", "print_cake_grid" ]
2
[ [ "print_cake_grid", "create_cake_grid" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5db84e821f09e8eb446c54058cbbe5a98b2e3a41
e8cce8f03534eabca0e1bb273d783a856b7306a6
v1.0
complete
Taco
Taco_64703_C
from typing import List def is_prime(number: int) -> bool: """ Check if a number is prime. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(17) True """ pass def smallest_prime_ge(N: int) -> int: """ Given an integer N, find the smallest prim...
def is_prime(number): if number <= 1: return False if number == 2 or number == 3: return True if number % 2 == 0 or number % 3 == 0: return False i = 5 while i * i <= number: if number % i == 0 or number % (i + 2) == 0: return False i += 6 retu...
from solution import is_prime, smallest_prime_ge 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(29) == True assert is_prime(10) == False assert is_prime(1) == False assert is_prime(0) == F...
[ { "docstring": null, "function_declaration": "def is_prime(number):", "function_name": "is_prime", "parameter_list": "(number)" }, { "docstring": null, "function_declaration": "def smallest_prime_ge(N):", "function_name": "smallest_prime_ge", "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 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 <= 3:\n r...
trial_gpt4o_2
{ "original_instruction": "Write a function that takes an integer N and returns the smallest prime number that is greater than or equal to N. If N is less than or equal to 1, return 2. Note that the scope of this problem is to handle numbers up to 10^6 efficiently.\n\n-----Input-----\nAn integer N.\n\n-----Output----...
0.766812
Taco_64703
C
[ "is_prime", "smallest_prime_ge" ]
2
[ [ "smallest_prime_ge", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c915fdeeabe8374349f59b873596b24b032331fb
acc816e78023694ac82aed1b1db5c9ff56be5cc0
v1.0
complete
Taco
Taco_64352_C
def solveSudoku(board: List[List[str]]) -> None: """Write a program to solve the Sudoku puzzle by filling in empty cells. A Sudoku solution must satisfy all the following rules: 1. Each of the digits 1-9 must occur exactly once in each row. 2. Each of the digits 1-9 must occur exactly once in each column. ...
def solveSudoku(board): """ Solves the Sudoku puzzle by filling in empty cells. """ solve(board) def solve(board): empty = find_empty(board) if not empty: return True row, col = empty for num in range(1, 10): if is_valid(board, str(num), row, col): board...
from solution import solveSudoku def test_sudoku_solved(): board = [["5","3",".",".","7",".",".",".","."], ["6",".",".","1","9","5",".",".","."], [".","9","8",".",".",".",".","6","."], ["8",".",".",".","6",".",".",".","3"], ["4",".",".","8",".","3",".",".","1"], ...
[ { "docstring": "Solves the Sudoku puzzle by filling in empty cells.", "function_declaration": "def solveSudoku(board):", "function_name": "solveSudoku", "parameter_list": "(board)" }, { "docstring": null, "function_declaration": "def solve(board):", "function_name": "solve", "par...
[ 0, 0, 0, 0, 0, 1, 1, 1, 1, 1 ]
5
medium
0.5
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def solveSudoku(board):\n \"\"\"\n Solves the Sudoku puzzle by filling the empty cells.\n The board is modified in-place.\n\n :param board: List[List[s...
trial_gpt4o_9
{ "original_instruction": "Write a program to solve the Sudoku puzzle by filling in empty cells. A Sudoku solution must satisfy all the following rules:\n1. Each of the digits 1-9 must occur exactly once in each row.\n2. Each of the digits 1-9 must occur exactly once in each column.\n3. Each of the digits 1-9 must oc...
0.532922
Taco_64352
C
[ "solveSudoku", "solve", "find_empty", "is_valid" ]
4
[ [ "solve", "find_empty" ], [ "solve", "is_valid" ], [ "solveSudoku", "solve" ] ]
3
[]
false
[]
false
pytest
true
[]
true
f8df877e75a2baec1a416238c1b4a4b157373833
f85003cc72428d7d95d586796a3b2f278ba0520e
v1.0
complete
Taco
Taco_64692_C
def is_prime(num: int) -> bool: """ Check if a number is prime. >>> is_prime(2) True >>> is_prime(5) True >>> is_prime(4) False """ def sumConsecutivePrimes(n: int) -> int: """ Returns the sum of the first n consecutive prime numbers. >>> sumConsecutivePrimes(1) 2 >>> sumConsecutivePrim...
def is_prime(num): """ Check if a number is prime. """ if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return False i += 6...
from solution import sumConsecutivePrimes def test_sumConsecutivePrimes_1(): assert sumConsecutivePrimes(1) == 2 def test_sumConsecutivePrimes_2(): assert sumConsecutivePrimes(2) == 5 def test_sumConsecutivePrimes_5(): assert sumConsecutivePrimes(5) == 28 def test_sumConsecutivePrimes_10(): assert s...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the sum of the first n consecutive prime numbers.", "function_declaration": "def sumConsecutivePrimes(n):", "f...
[ 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(num):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n r...
trial_gpt4o_1
{ "original_instruction": "# Summing Consecutive Prime Numbers\n\nWrite a function that returns the sum of the first `n` consecutive prime numbers. Prime numbers are natural numbers greater than 1 that have no positive divisors other than 1 and itself.\n\n## Examples\n```\nsumConsecutivePrimes(1) ==> 2\nsumConsecuti...
0.745252
Taco_64692
C
[ "is_prime", "sumConsecutivePrimes" ]
2
[ [ "sumConsecutivePrimes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6e12e94816bb054084046b33a2ffb09274c79ae7
dcd7ecfb17364bfa4a25b58ba97eb0ced8a40cae
v1.0
complete
Taco
Taco_63957_C
from typing import List, Tuple def has_cycle(graph, N): visited = [False] * N parent = [-1] * N def dfs(v): visited[v] = True for neighbor in graph[v]: if not visited[neighbor]: parent[neighbor] = v if dfs(neighbor): return Tr...
def has_cycle(graph, N): visited = [False] * N parent = [-1] * N def dfs(v): visited[v] = True for neighbor in graph[v]: if not visited[neighbor]: parent[neighbor] = v if dfs(neighbor): return True elif parent[v] !=...
import pytest from solution import main, graph_input_parser, detect_cycles def test_parser(): input_string = "2\n3 3\n0 1\n1 2\n2 0\n4 2\n0 1\n2 3\n" expected_output = [(3, 3, [(0, 1), (1, 2), (2, 0)]), (4, 2, [(0, 1), (2, 3)])] assert graph_input_parser(input_string) == expected_output def test_detect_cy...
[ { "docstring": null, "function_declaration": "def has_cycle(graph, N):", "function_name": "has_cycle", "parameter_list": "(graph, N)" }, { "docstring": null, "function_declaration": "def detect_cycles(test_cases):", "function_name": "detect_cycles", "parameter_list": "(test_cases...
[ 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 has_cycle(graph, node, visited, parent):\n \"\"\"\n Helper function to detect cycle using DFS.\n \"\"\"\n visited[node] = True\n \n for neigh...
trial_gpt4o_2
{ "original_instruction": "Detecting a cycle in a graph is a fundamental problem in computer science. A cycle in a graph is a path that starts and ends at the same vertex. For this problem, you will be given an undirected graph, and your task is to determine whether the graph has any cycles.\n\nInput\nThe first line ...
0.642945
Taco_63957
C
[ "has_cycle", "detect_cycles", "graph_input_parser", "main" ]
4
[ [ "detect_cycles", "has_cycle" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5ef57a279878aaa51fd7e71fcff0c6abe58024b6
cee6c40f51fb61e7c11f6daae788c48d00326a3a
v1.0
complete
Taco
Taco_64702_C
def max_distinct_after_change(s: str) -> int: """ Returns the maximum number of distinct characters that can be achieved by changing any one character in the string s. """ pass def process_test_cases(test_cases: List[str]) -> List[int]: """ Processes a list of test cases and returns the res...
def max_distinct_after_change(s): """ Returns the maximum number of distinct characters that can be achieved by changing any one character in the string s. """ distinct_chars = len(set(s)) # If the number of distinct characters is already the maximum possible (length of string), # changing o...
from solution import max_distinct_after_change, process_test_cases, solve def test_max_distinct_after_change(): assert max_distinct_after_change("abca") == 4 assert max_distinct_after_change("abcde") == 5 assert max_distinct_after_change("zzzzz") == 2 # Changed from 1 to 2 because we can change one 'z' to...
[ { "docstring": "Returns the maximum number of distinct characters that can be achieved\nby changing any one character in the string s.", "function_declaration": "def max_distinct_after_change(s):", "function_name": "max_distinct_after_change", "parameter_list": "(s)" }, { "docstring": null, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
1
hard
0.111
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_distinct_characters(s):\n \"\"\"\n Given a string s, this function returns the maximum number of distinct characters\n Madoka can achieve by chang...
trial_gpt4o_9
{ "original_instruction": "Madoka and Zen are playing a game with a string `s` consisting of lowercase English letters. The game proceeds as follows:\n\n1. Initially, Zen writes down the string `s`.\n2. Madoka can perform the following operation exactly once:\n - Replace any character in the string with any other l...
0.687592
Taco_64702
C
[ "max_distinct_after_change", "process_test_cases", "solve" ]
3
[ [ "process_test_cases", "max_distinct_after_change" ], [ "solve", "process_test_cases" ] ]
2
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
a1721c81191c6286a43bafc9b94cb5b2cadfff7e
23f7c177ca8373c3140ead7c41a276eed6aed48d
v1.0
complete
Taco
Taco_64648_C
def count_sequences(n: int) -> int: """Calculate the total number of unique sequences of processes A and B of length n, modulo 10^9 + 7. The input consists of a single integer n (1 ≤ n ≤ 10^18) - the length of the sequence. Args: n: The length of the sequence. Returns: The number of unique se...
MOD = 10**9 + 7 def matrix_mult(A, B, mod=MOD): """Multiplies two matrices A and B under modulo.""" return [[(A[0][0] * B[0][0] + A[0][1] * B[1][0]) % mod, (A[0][0] * B[0][1] + A[0][1] * B[1][1]) % mod], [(A[1][0] * B[0][0] + A[1][1] * B[1][0]) % mod, (A[1][0] * B[0][1] + A[1][1] * B[1][1]) % mod]]...
from solution import count_sequences def test_count_sequences(): assert count_sequences(1) == 2 assert count_sequences(2) == 4 assert count_sequences(3) == 8 assert count_sequences(10) == 1024 def test_large_n(): assert count_sequences(10**8) == pow(2, 10**8, 10**9 + 7) % (10**9 + 7) def test_edg...
[ { "docstring": "Multiplies two matrices A and B under modulo.", "function_declaration": "def matrix_mult(A, B, mod=MOD):", "function_name": "matrix_mult", "parameter_list": "(A, B, mod=MOD)" }, { "docstring": "Computes the power of a matrix under modulo using exponentiation by squaring.", ...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "MOD = 10**9 + 7\n\ndef matrix_multiply(A, B):\n return [\n [(A[0][0] * B[0][0] + A[0][1] * B[1][0]) % MOD, (A[0][0] * B[0][1] + A[0][1] * B[1][1]) % MOD]...
trial_gpt4o_2
{ "original_instruction": "A factory manufacturing all kinds of items wants to track the number of ways to construct different items using a specific method. Each item can be constructed using either one of the two processes over a sequence of steps. The steps can be either process A or process B. The overall sequenc...
0.636982
Taco_64648
C
[ "matrix_mult", "matrix_pow", "count_sequences" ]
3
[ [ "count_sequences", "matrix_pow" ], [ "matrix_pow", "matrix_mult" ] ]
2
[]
false
[]
false
pytest
true
[]
true
39a10ddaac10b9c52b269802aefaf0c017a695d9
46a88ba5d4e94a32f82edb0a25fa64bf2b01e8b1
v1.0
complete
Taco
Taco_64270_C
def is_possible_sequence(pairs): """ Develop a program to find out if it is possible to create a sequence of unique pairs (x, y) such that they satisfy the rules given below: You are provided with a list of pairs (x, y), and you need to determine if these pairs can be rearranged into a sequence where each c...
def is_possible_sequence(pairs): from collections import defaultdict, deque if not pairs: return "Possible" graph_x = defaultdict(list) graph_y = defaultdict(list) for x, y in pairs: graph_x[x].append(y) graph_y[y].append(x) visited = set() need_to_visit = deque([...
def test_is_possible_sequence(): input_data = """2 3 1 2 2 2 3 2 4 1 1 2 2 3 1 4 2""" expected_output = "Possible\nNot Possible" assert main(input_data) == expected_output def test_single_pair(): input_data = "1\n1\n1 1" expected_output = "Possible" assert main(input_data) == exp...
[ { "docstring": null, "function_declaration": "def is_possible_sequence(pairs):", "function_name": "is_possible_sequence", "parameter_list": "(pairs)" }, { "docstring": null, "function_declaration": "def solve(test_cases):", "function_name": "solve", "parameter_list": "(test_cases...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import defaultdict\n\ndef can_form_sequence(pairs):\n adjacency_list_x = defaultdict(list)\n adjacency_list_y = defaultdict(list)\n \n ...
trial_gpt4o_1
{ "original_instruction": "Develop a program to find out if it is possible to create a sequence of unique pairs (x, y) such that they satisfy the rules given below. You are provided with a list of pairs (x, y), and you need to determine if these pairs can be rearranged into a sequence where each consecutive pair in t...
0.686125
Taco_64270
C
[ "is_possible_sequence", "solve", "parse_input", "main" ]
4
[ [ "solve", "is_possible_sequence" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
d23168f7ccbce280a4fe502633a65f05ac97feee
049d4a2cdb8ab4d292c64f6bc449f7d1e1ed724c
v1.0
complete
Taco
Taco_64609_C
def evaluate_prefix_expression(expression: str) -> int: """ Evaluates a single prefix expression. >>> evaluate_prefix_expression('+ 3 4') == 7 >>> evaluate_prefix_expression('- * 10 20 30') == 170 >>> evaluate_prefix_expression('/ 100 5') == 20 >>> evaluate_prefix_expression('+ 10 * 2 3') == 16 ...
def evaluate_prefix_expression(expression): """ Evaluates a single prefix expression. """ stack = [] operators = {'+', '-', '*', '/'} # Split the expression by space and reverse it to process it right to left tokens = expression.split()[::-1] for token in tokens: if tok...
from solution import evaluate_prefix_expression, evaluate_prefix_expressions, process_input def test_evaluate_prefix_expression(): assert evaluate_prefix_expression('+ 3 4') == 7 assert evaluate_prefix_expression('- * 10 20 30') == 170 assert evaluate_prefix_expression('/ 100 5') == 20 assert evaluate_...
[ { "docstring": "Evaluates a single prefix expression.", "function_declaration": "def evaluate_prefix_expression(expression):", "function_name": "evaluate_prefix_expression", "parameter_list": "(expression)" }, { "docstring": "Evaluates multiple prefix expressions.", "function_declaration...
[ 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 evaluate_prefix(expression):\n \"\"\"\n Evaluates a single prefix expression and returns the result.\n \"\"\"\n tokens = expression.split()\n to...
trial_gpt4o_1
{ "original_instruction": "You are given a prefix expression (Polish notation) in the form of a string. Your task is to evaluate the expression and print its value. \n\nA prefix expression is evaluated using the following rules:\n1. The operator comes before its operands.\n2. The evaluation is performed from right to...
0.598239
Taco_64609
C
[ "evaluate_prefix_expression", "evaluate_prefix_expressions", "process_input" ]
3
[ [ "evaluate_prefix_expressions", "evaluate_prefix_expression" ], [ "process_input", "evaluate_prefix_expressions" ] ]
2
[ "process_input" ]
false
[]
false
pytest
true
[]
true
e5f112c3a7eb5fdb21f2ffece54ef41c5eb07881
76f5095b440479958e7eafaa49731e9c419f34ee
v1.0
complete
Taco
Taco_64370_C
from typing import List, Tuple def can_form_palindrome(s: str) -> bool: """ Helper function to check if a given string can be rearranged to form a palindrome. >>> can_form_palindrome("civic") True >>> can_form_palindrome("ivicc") True >>> can_form_palindrome("hello") False """ def...
def can_form_palindrome(s): """ Helper function to check if a given string can be rearranged to form a palindrome. """ from collections import Counter # Count occurrences of each character count = Counter(s) # A string can form a palindrome if at most one character has an odd count...
from solution import can_all_strings_form_palindrome, parse_input def test_multiple_cases(): input_data = """2 3 civic ivicc hello 2 racecar level""" test_cases = parse_input(input_data) assert can_all_strings_form_palindrome(test_cases) == ["NO", "YES"] def test_empty_string()...
[ { "docstring": "Helper function to check if a given string can be rearranged to form a palindrome.", "function_declaration": "def can_form_palindrome(s):", "function_name": "can_form_palindrome", "parameter_list": "(s)" }, { "docstring": "Determines if all strings in each test case can be re...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_form_palindrome(s):\n \"\"\"\n Checks if it's possible to rearrange the characters of the string to form a palindrome.\n \"\"\"\n from collecti...
trial_gpt4o_2
{ "original_instruction": "Given a list of strings, determine if it is possible to rearrange the characters of each string to form a palindrome. A palindrome is a word that reads the same backward as forward, such as \"radar\" or \"level\".\n\nInput:\nThe first line of input gives a single integer t, the number of te...
0.702468
Taco_64370
C
[ "can_form_palindrome", "can_all_strings_form_palindrome", "parse_input" ]
3
[ [ "can_all_strings_form_palindrome", "can_form_palindrome" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
e01fbc2c98186c45fdd3dc5dd4fc570db844136c
b8f37d61f9d8245a102cbc1f44124b087b2a448b
v1.0
complete
Taco
Taco_64881_C
def can_become_palindrome(s: str) -> bool: """ Determines if the string can become a palindrome by removing at most one character. >>> can_become_palindrome("abca") == True # YES >>> can_become_palindrome("abcdef") == False # NO >>> can_become_palindrome("racecar") == True # YES >>> can...
def is_palindrome(s): """ Helper function to check if a string is a palindrome. """ return s == s[::-1] def can_become_palindrome(s): """ Determines if the string can become a palindrome by removing at most one character. """ left, right = 0, len(s) - 1 while left < right: ...
from solution import can_become_palindrome def test_can_become_palindrome(): # Provided sample test case assert can_become_palindrome("abca") == True # YES # Case: Already a palindrome assert can_become_palindrome("racecar") == True # YES # Case: Not possible to become palindrome by rem...
[ { "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": "Determines if the string can become a palindrome by removing at most one character.", "fun...
[ 0, 0, 1, 1 ]
2
medium
0.5
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_become_palindrome(s):\n \"\"\"\n Determines if the input string can become a palindrome by removing at most one character.\n \"\"\"\n def is_pa...
trial_gpt4o_4
{ "original_instruction": "Given a string s, you are allowed to remove at most one character from the string. You need to determine if it can become a palindrome by removing at most one character.\n\nA string is considered a palindrome if it reads the same forward and backward.\n\n-----Constraints-----\n- The length ...
0.848362
Taco_64881
C
[ "is_palindrome", "can_become_palindrome" ]
2
[ [ "can_become_palindrome", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0e9342f959f4c2ada3b5ffb832730ff13d13f58b
3351be7d52757ecd8f91beae8f6e1012446a7c4c
v1.0
complete
Taco
Taco_64837_C
def sieve_of_eratosthenes(n): """ Returns a list of first n prime numbers using the Sieve of Eratosthenes algorithm. """ limit = 20000 # Arbitrary large limit to ensure we get at least 1000 primes sieve = [True] * limit sieve[0] = sieve[1] = False primes = [] for num in range(2, li...
def sieve_of_eratosthenes(n): """ Returns a list of first n prime numbers using the Sieve of Eratosthenes algorithm. """ limit = 20000 # Arbitrary large limit to ensure we get at least 1000 primes sieve = [True] * limit sieve[0] = sieve[1] = False primes = [] for num in range(2, li...
from solution import prime_address def test_prime_address_example_case(): assert prime_address([1, 2, 10]) == [2, 3, 29] def test_prime_address_single_case(): assert prime_address([5]) == [11] def test_prime_address_edge_case(): assert prime_address([1]) == [2] assert prime_address([1000]) == [7919] ...
[ { "docstring": "Returns a list of first n prime numbers using the Sieve of Eratosthenes algorithm.", "function_declaration": "def sieve_of_eratosthenes(n):", "function_name": "sieve_of_eratosthenes", "parameter_list": "(n)" }, { "docstring": "Returns a list of prime numbers corresponding to ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sieve_of_eratosthenes(max_num):\n \"\"\"\n Helper function to generate all prime numbers up to max_num using Sieve of Eratosthenes.\n \"\"\"\n is_p...
trial_gpt4o_1
{ "original_instruction": "In a certain country, street addresses follow a peculiar numbering pattern. The country uses an ordered list of numbers called prime indexes. Prime index numbers are defined as the position numbers within the ordered sequence of prime numbers starting from the smallest prime number, 2.\n\nY...
0.698556
Taco_64837
C
[ "sieve_of_eratosthenes", "prime_address" ]
2
[ [ "prime_address", "sieve_of_eratosthenes" ] ]
1
[]
false
[]
false
pytest
true
[]
true
11cfe74609a79ba4918acd88b76cf7d7f20894d2
4681a7f979ae6215b0a5ac72b5b82897ee47aa1d
v1.0
complete
Taco
Taco_64917_C
def is_prime(n): """ Helper function to check if a number is prime. """ pass def prime_concatenation_possible(primes): """ Returns "YES" if it is possible to concatenate any two distinct primes from the list to form a new prime number, otherwise "NO". >>> prime_concatenation_possible([...
def is_prime(n): """ Helper function to 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 +...
from solution import prime_concatenation_possible def test_example_1(): primes = [2, 3, 5, 11] assert prime_concatenation_possible(primes) == "YES" def test_example_2(): primes = [2, 5, 7] assert prime_concatenation_possible(primes) == "NO" def test_single_prime(): primes = [2] assert prime_c...
[ { "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 \"YES\" if it is possible to concatenate any two distinct primes from\nthe list to form a new prime num...
[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n if n <= 1:\n return False\n if n == 2:\n return True # 2 is the only even prime number\n if n % 2 == 0:\n return ...
trial_gpt4o_8
{ "original_instruction": "Prime Concatenation\nYou are given a list of distinct prime numbers, and your task is to determine if it is possible to concatenate any two distinct primes from the list to form a new prime number.\nA prime number is a natural number greater than 1 that has no positive divisors other than 1...
0.867218
Taco_64917
C
[ "is_prime", "prime_concatenation_possible" ]
2
[ [ "prime_concatenation_possible", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5e038e5f1544a6e6318796c0d0fd97ff8249b108
3ffcfe5ca335fdd27b6c27284bded59299e6155d
v1.0
complete
Taco
Taco_64459_C
def is_valid_command(command: str) -> str: """ Check if the given command is valid based on the rules: 1. Must start with an action (MOVE, REMOVE, COPY) followed by a space and a subject. 2. Optionally it can have an object after another space. 3. Should not have more than three parts (action, subje...
def is_valid_command(command): """ Check if the given command is valid based on the rules: 1. Must start with an action (MOVE, REMOVE, COPY) followed by a space and a subject. 2. Optionally it can have an object after another space. 3. Should not have more than three parts (action, subject, object)....
from solution import validate_commands def test_validate_commands_all_valid(): commands = [ "MOVE BOX", "REMOVE BOX CHAIR", "COPY BOOK SHELF" ] assert validate_commands(3, commands) == ["VALID", "VALID", "VALID"] def test_validate_commands_invalid_format(): commands = [ ...
[ { "docstring": "Check if the given command is valid based on the rules:\n1. Must start with an action (MOVE, REMOVE, COPY) followed by a space and a subject.\n2. Optionally it can have an object after another space.\n3. Should not have more than three parts (action, subject, object).", "function_declaration...
[ 0, 0, 0, 0, 0, 1, 0, 0, 1, 0 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def validate_commands(n, logs):\n valid_actions = {\"MOVE\", \"REMOVE\", \"COPY\"}\n valid_results = []\n \n for log in logs:\n parts = log.spli...
trial_gpt4o_8
{ "original_instruction": "Emma is working on a system where she needs to parse commands from a log. Each command is composed of three parts: an action, a subject, and an optional object. The possible actions are \"MOVE\", \"REMOVE\", and \"COPY\". The subjects are always single words composed of uppercase alphabets ...
0.482974
Taco_64459
C
[ "is_valid_command", "validate_commands" ]
2
[ [ "validate_commands", "is_valid_command" ] ]
1
[]
false
[]
false
pytest
true
[]
true
09a4704701c2608f05fd857607c315c0bb64e8b4
36413342ae50e34d4d5f634c6acddd4331bc47cc
v1.0
complete
Taco
Taco_64519_C
from typing import List def sieve_of_eratosthenes(max_num: int) -> List[int]: """ Sieve of Eratosthenes to find all prime numbers up to max_num. """ pass def can_be_expressed_as_product_of_two_distinct_primes(n: int, primes: List[int]) -> bool: """ Check if a number can be expressed as a prod...
def sieve_of_eratosthenes(max_num): """ Sieve of Eratosthenes to find all prime numbers up to max_num. """ is_prime = [True] * (max_num + 1) p = 2 while p * p <= max_num: if is_prime[p]: for i in range(p * p, max_num + 1, p): is_prime[i] = False p += 1...
from solution import sieve_of_eratosthenes, can_be_expressed_as_product_of_two_distinct_primes, check_numbers def test_sieve_of_eratosthenes(): assert sieve_of_eratosthenes(10) == [2, 3, 5, 7] assert sieve_of_eratosthenes(20) == [2, 3, 5, 7, 11, 13, 17, 19] def test_can_be_expressed_as_product_of_two_distinct...
[ { "docstring": "Sieve of Eratosthenes to find all prime numbers up to max_num.", "function_declaration": "def sieve_of_eratosthenes(max_num):", "function_name": "sieve_of_eratosthenes", "parameter_list": "(max_num)" }, { "docstring": "Check if a number can be expressed as a product of two di...
[ 0, 0, 0, 0, 1, 0, 0, 0, 0 ]
1
hard
0.111
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sieve_of_eratosthenes(max_num):\n \"\"\"\n Generate a list of prime numbers up to max_num using the Sieve of Eratosthenes algorithm.\n \"\"\"\n is_...
trial_gpt4o_5
{ "original_instruction": "You are given an array of N integers. For each integer in the array, you have to determine whether it can be expressed as a product of two distinct prime numbers. If an integer can be expressed as such a product, output \"YES\", otherwise output \"NO\".\n\nConstraints:\n* 1 \\leq N \\leq 10...
0.647448
Taco_64519
C
[ "sieve_of_eratosthenes", "can_be_expressed_as_product_of_two_distinct_primes", "check_numbers", "main" ]
4
[ [ "check_numbers", "can_be_expressed_as_product_of_two_distinct_primes" ], [ "check_numbers", "sieve_of_eratosthenes" ] ]
2
[]
false
[]
false
pytest
true
[]
true
8a5fc9634b7c47907d2ae31425f8e41ecb37a7c1
22d88e2ba2c6c19fe8e1750f6d8adcfd79a1c4b0
v1.0
complete
Taco
Taco_64896_C
from typing import List def find_words_in_grid(grid: List[List[str]], words: List[str]) -> List[bool]: """ Determine if each word in the list can be formed by a sequence of adjacent letters in the grid. The same letter cannot be used more than once in forming a word. Letters are considered adjacent if th...
def is_word_in_grid(grid, word): rows = len(grid) cols = len(grid[0]) def dfs(x, y, word): if not word: return True if x < 0 or x >= rows or y < 0 or y >= cols or grid[x][y] != word[0]: return False temp = grid[x][y] grid[x][y] = '' ...
def test_find_words_in_grid(): grid = [ ['A', 'B', 'C', 'E'], ['S', 'F', 'C', 'S'], ['A', 'D', 'E', 'E'] ] words = ['ABCCED', 'SEE', 'ABCB'] expected = [True, True, False] assert find_words_in_grid(grid, words) == expected def test_find_words_in_grid_single_letter_words(): gr...
[ { "docstring": null, "function_declaration": "def is_word_in_grid(grid, word):", "function_name": "is_word_in_grid", "parameter_list": "(grid, word)" }, { "docstring": null, "function_declaration": "def find_words_in_grid(grid, words):", "function_name": "find_words_in_grid", "pa...
[ 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 exist_word(grid, word):\n rows, cols = len(grid), len(grid[0])\n \n def dfs(r, c, i):\n if i == len(word):\n return True\n if...
trial_gpt4o_1
{ "original_instruction": "Given a grid of letters and a list of words, determine if each word in the list can be formed by a sequence of adjacent letters in the grid. The same letter cannot be used more than once in forming a word. Letters are considered adjacent if they are horizontally or vertically neighboring. \...
0.626516
Taco_64896
C
[ "is_word_in_grid", "find_words_in_grid" ]
2
[ [ "find_words_in_grid", "is_word_in_grid" ] ]
1
[]
false
[]
false
pytest
false
[]
true
12724bd7ffdc993e55d1a0a0bf1505d06a65408e
0e16e3ebd5a6e25ba43925502fff7626f37fde3d
v1.0
complete
Taco
Taco_63503_C
def minimum_construction_cost(n: int, m: int, roads: List[Tuple[int, int, int]]) -> int: """ Determine the minimum cost to construct a railway network that connects all cities. Args: n (int): Number of cities. m (int): Number of roads. roads (List[Tuple[int, int, int]]): List of tuples where ea...
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] = r...
def test_minimum_construction_cost_example1(): n = 4 m = 5 roads = [ (1, 2, 3), (2, 3, 4), (3, 4, 5), (1, 4, 1), (1, 3, 2) ] assert minimum_construction_cost(n, m, roads) == 6 def test_minimum_construction_cost_example2(): n = 3 m = 1 roads = [ ...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 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 find(parent, i):\n if parent[i] == i:\n return i\n return find(parent, parent[i])\n\n\ndef union(parent, rank, x, y):\n root_x = find(parent, x...
trial_gpt4o_0
{ "original_instruction": "### Road Construction Cost Minimization\n\nA country consists of n cities and m roads connecting them. Each road has a certain cost to travel. The government wants to construct a high-speed railway network such that every city is reachable from any other city using this network. The constru...
0.664566
Taco_63503
C
[ "find", "union", "minimum_construction_cost" ]
3
[ [ "minimum_construction_cost", "find" ], [ "minimum_construction_cost", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
false
[]
true
1a1de46ad610aaa339efb8fbc5f5f920dcf0f165
dd5aa1a5c2e5e438cd2917ae21cb01485ba5cc21
v1.0
complete
Taco
Taco_65195_C
def is_prime(n): """ Determines if n is a prime number. Parameters: n (int): The number to be checked for primality. Returns: bool: True if n is a prime number, otherwise False. >>> is_prime(2) True >>> is_prime(15) False >>> is_prime(23) True "...
def is_prime(n): """ Determines if n is a prime number. """ 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 prime_book_selector(T, pa...
from solution import is_prime, prime_book_selector def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(29) == True assert is_prime(15) == False assert is_prime(23) == True assert is_prime(1) == False assert is_prime(997)...
[ { "docstring": "Determines if n is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "For each page count, determines if it is a prime number.", "function_declaration": "def prime_book_selector(T, page_cou...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Determines if n is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\n if...
trial_gpt4o_0
{ "original_instruction": "Alice is an avid reader and has recently started a book club. She has a peculiar way of selecting books to read: she only reads books whose total page count is a prime number. To help her streamline her book selection process, she needs you to write a program that helps her determine if the...
0.617269
Taco_65195
C
[ "is_prime", "prime_book_selector" ]
2
[ [ "prime_book_selector", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
82689b9805d39c45de5bee55066509a0d48e9785
b8386274f233b69534ac5cf860245956ddedb007
v1.0
complete
Taco
Taco_65024_C
def solve_garden_problem(n, m, k, flowers): """ Determines if it's possible to repaint the faded flowers such that the garden contains at least k consecutive flowers of the same color. Args: n (int): number of flowers. m (int): number of different colors. k (int): minimum number of con...
def can_make_garden_beautiful(n, m, k, flowers): """ Determines if it's possible to repaint the faded flowers such that the garden contains at least k consecutive flowers of the same color. Args: n (int): number of flowers. m (int): number of different colors. k (int): minimum number o...
def test_can_make_garden_beautiful_example1(): assert solve_garden_problem(5, 3, 3, "a?a??") == "YES" def test_can_make_garden_beautiful_example2(): assert solve_garden_problem(4, 2, 4, "ab??") == "NO" def test_all_question_marks(): assert solve_garden_problem(4, 2, 2, "????") == "YES" assert solve_ga...
[ { "docstring": "Determines if it's possible to repaint the faded flowers such that the garden \ncontains at least k consecutive flowers of the same color.\n\nArgs:\nn (int): number of flowers.\nm (int): number of different colors.\nk (int): minimum number of consecutive flowers required to be of the same color....
[ 0, 0, 0, 0, 0, 1, 0, 0, 0, 1 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_beautiful_possible(n, m, k, garden):\n \"\"\"\n Determines if it's possible to repaint the faded flowers in the garden to make it beautiful.\n \n ...
trial_gpt4o_9
{ "original_instruction": "Arkady has a garden containing $n$ flowers. Each flower can be in one of $m$ different colors. The garden looks beautiful when there are at least $k$ consecutive flowers of the same color.\n\nHowever, due to harsh weather conditions, some flowers have lost their colors. You need to help Ark...
0.571966
Taco_65024
C
[ "can_make_garden_beautiful", "solve_garden_problem" ]
2
[ [ "solve_garden_problem", "can_make_garden_beautiful" ] ]
1
[]
false
[]
false
pytest
false
[]
true
6f1802d2335c3810f684ee007954faf33be6627f
a356f806562d174e4fddd02daffcfdc4d61343a8
v1.0
complete
Taco
Taco_64909_C
def castle_connected_min_roads(input_str: str) -> List[Union[int, str]]: """ In a fictional land, there are N castles connected by M bidirectional roads. The king wants to ensure that every pair of castles is connected either directly by a road or indirectly through other castles. Additionally, the king prefers...
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_sample_cases(): input_data = '''2 4 3 1 2 2 3 3 4 5 2 1 2 4 5''' expected_output = [3, 'IMPOSSIBLE'] result = castle_connected_min_roads(input_data) assert result == expected_output def test_no_roads(): input_data = '''1 3 0''' expected_output = ['IMPOSSIBLE'] result = castle...
[ { "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, 0, 1, 0, 1, 1, 0 ]
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": "def solve(T, test_cases):\n results = []\n \n def find_components(N, edges):\n from collections import deque, defaultdict\...
trial_gpt4o_8
{ "original_instruction": "In a fictional land, there are $N$ castles connected by $M$ bidirectional roads. The king wants to ensure that every pair of castles is connected either directly by a road or indirectly through other castles. Additionally, the king prefers that the total number of roads used is minimal.\n\n...
0.70668
Taco_64909
C
[ "find", "union", "kruskal_minimum_roads_needed", "process_castle_connection", "castle_connected_min_roads" ]
5
[ [ "castle_connected_min_roads", "process_castle_connection" ], [ "kruskal_minimum_roads_needed", "find" ], [ "kruskal_minimum_roads_needed", "union" ], [ "process_castle_connection", "kruskal_minimum_roads_needed" ], [ "union", "find" ] ]
5
[]
false
[]
false
pytest
false
[]
true
0a8c902c96519f63fc5b934a67b4ba9f9834df04
723957c5b53dc366f355122cb8817b538015ecab
v1.0
complete
Taco
Taco_64738_C
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def balanceBST(root): """ Converts an unbalanced binary search tree (BST) into a balanced binary search tree with the same set of nodes. >>> root = TreeNode(...
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def inOrderTraversal(root, nodes): if root: inOrderTraversal(root.left, nodes) nodes.append(root) inOrderTraversal(root.right, nodes) def buildBa...
from solution import TreeNode, balanceBST def inOrderValues(root): if root is None: return [] return inOrderValues(root.left) + [root.val] + inOrderValues(root.right) def test_balance_already_balanced_bst(): root = TreeNode(30) root.left = TreeNode(20) root.right = TreeNode(40) root.le...
[]
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, value=0, left=None, right=None):\n self.value = value\n self.left = left\n self.right = right\n\ndef i...
trial_gpt4o_1
{ "original_instruction": "Given a binary search tree (BST) with N nodes, convert it into a balanced binary search tree (BST) with the same set of nodes.\n\nExample 1:\nInput:\nBST = \n 30\n / \\\n 20 40\n / \\ \\\n 10 25 50\n \nOutput:\nBalanced BST =\n 30\n / \\\n 20 ...
0.683223
Taco_64738
C
[ "inOrderTraversal", "buildBalancedBST", "balanceBST" ]
3
[ [ "balanceBST", "buildBalancedBST" ], [ "balanceBST", "inOrderTraversal" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
3f593a57b36c74936ec1dc5ee938e839261d77fa
35eb2b39046e985efbf7a19c06b7359f11afbc0b
v1.0
complete
Taco
Taco_65341_C
def minimal_connection_network(T: int, test_cases: List[Tuple[Tuple[int, int], List[Tuple[int, int, int]]]]) -> List[int]: """ Determine the minimum total weight required for the Minimal Connection Network. >>> minimal_connection_network(1, [((4, 5), [(1, 2, 1), (2, 3, 2), (3, 4, 4), (4, 1, 3), (1, 3, 5)])]) ...
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] ...
from solution import minimal_connection_network def test_single_case(): T = 1 test_cases = [ [(4, 5), (1, 2, 1), (2, 3, 2), (3, 4, 4), (4, 1, 3), (1, 3, 5)] ] assert minimal_connection_network(T, test_cases) == [6] def test_multiple_cases(): T = 2 test_cases = [ [(4, 5), (1, 2,...
[ { "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, 0, 0, 0, 1, 1, 0 ]
2
hard
0.222
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def minimal_connection_network(T, test_cases):\n def find(parent, i):\n if parent[i] == i:\n return i\n else:\n return find(...
trial_gpt4o_8
{ "original_instruction": "During a recent city event, the mayor of Hackland was thrilled with a new transportation initiative: the Hackland Tram Network. The tram network consists of a number of stations connected by bidirectional tracks. Each track connects exactly two distinct stations and has a specific weight re...
0.674691
Taco_65341
C
[ "find", "union", "kruskal_mst", "minimal_connection_network" ]
4
[ [ "kruskal_mst", "find" ], [ "kruskal_mst", "union" ], [ "minimal_connection_network", "kruskal_mst" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
true
[]
true
2cfaec81532a720e322ba717e4e28b31c0eebcd7
edd86a733f2f1b65ca934c7dfc919f05dedb644d
v1.0
complete
Taco
Taco_65251_C
def gcd(a: int, b: int) -> int: """Calculate the greatest common divisor (GCD) of two numbers. >>> gcd(4, 6) 2 >>> gcd(6, 8) 2 >>> gcd(10, 15) 5 """ pass def lcm(n: int, m: int) -> int: """Calculate the least common multiple (LCM) of two numbers. >>> lcm(4, 6) 12 >>>...
def gcd(a, b): """ Calculate the greatest common divisor (GCD) of two numbers. """ while b: a, b = b, a % b return a def lcm(n, m): """ Calculate the least common multiple (LCM) of two numbers. """ return abs(n * m) // gcd(n, m)
from solution import gcd, lcm # Test GCD Function def test_gcd(): assert gcd(4, 6) == 2 assert gcd(6, 8) == 2 assert gcd(10, 15) == 5 assert gcd(21, 14) == 7 assert gcd(1, 1) == 1 # Test LCM Function def test_lcm(): assert lcm(4, 6) == 12 assert lcm(6, 8) == 24 assert lcm(10, 15) == 30...
[ { "docstring": "Calculate the greatest common divisor (GCD) of two numbers.", "function_declaration": "def gcd(a, b):", "function_name": "gcd", "parameter_list": "(a, b)" }, { "docstring": "Calculate the least common multiple (LCM) of two numbers.", "function_declaration": "def lcm(n, m)...
[ 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 gcd(a, b):\n \"\"\"\n Returns the greatest common divisor (GCD) of a and b.\n \"\"\"\n while b != 0:\n a, b = b, a % b\n return a\n\ndef ...
trial_gpt4o_1
{ "original_instruction": "Write a program that reads two integers, n and m, and prints the least common multiple (LCM) of these two numbers. You can assume that 1 ≤ n, m ≤ 1000.\n\nInput\n\nTwo integers n and m separated by a space in a line.\n\nOutput\n\nPrint the LCM of n and m in a line.\n\nExample\n\nInput\n\n4 ...
0.794648
Taco_65251
C
[ "gcd", "lcm" ]
2
[ [ "lcm", "gcd" ] ]
1
[]
false
[]
false
pytest
true
[]
true
daa052e60627fa336ec74096aefb7f8e7ffad992
987993c061496fad7e5c25397c3f5966f666b295
v1.0
complete
Taco
Taco_65406_C
def digit_to_word(digit): """ Helper function to convert a single digit to its corresponding English word. >>> digit_to_word('0') == 'zero' >>> digit_to_word('1') == 'one' >>> digit_to_word('2') == 'two' >>> digit_to_word('3') == 'three' >>> digit_to_word('4') == 'four' >>> digit_to_word...
def digit_to_word(digit): """ Helper function to convert a single digit to its corresponding English word. """ digit_words = { '0': 'zero', '1': 'one', '2': 'two', '3': 'three', '4': 'four', '5': 'five', '6': 'six', '7': 'seven', '8': 'eight', '9': 'nine' } return digit_w...
from solution import translate_expression, digit_to_word def test_digit_to_word(): assert digit_to_word('0') == 'zero' assert digit_to_word('1') == 'one' assert digit_to_word('2') == 'two' assert digit_to_word('3') == 'three' assert digit_to_word('4') == 'four' assert digit_to_word('5') == 'fiv...
[ { "docstring": "Helper function to convert a single digit to its corresponding English word.", "function_declaration": "def digit_to_word(digit):", "function_name": "digit_to_word", "parameter_list": "(digit)" }, { "docstring": "Takes a string containing a mathematical expression 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 digit_to_word(digit):\n \"\"\"\n Helper function to convert a single digit to its corresponding English word.\n \"\"\"\n digit_words = {\n '...
trial_gpt4o_0
{ "original_instruction": "## Task\n\nWrite a function that takes a string containing a mathematical expression and returns a translated string where all the digits have been replaced with their English word equivalents.\n\n### Inputs\n- A string representing a mathematical expression, which includes digits (0-9) and...
0.578276
Taco_65406
C
[ "digit_to_word", "translate_expression" ]
2
[ [ "translate_expression", "digit_to_word" ] ]
1
[]
false
[]
false
pytest
true
[]
true
183e483f644a639ed906db5ef733ae0fa4f8186a
0c95260e4d0219707e103f268f2eb2a83d8d2f26
v1.0
complete
Taco
Taco_65554_C
def solve(m: int, n: int, matrix: List[List[int]]) -> int: """ Find the largest rectangle in the grid that contains only crops. >>> solve(4, 4, [[1, 0, 1, 0], [1, 0, 1, 1], [1, 1, 1, 1], [0, 1, 0, 0]]) == 4 >>> solve(3, 3, [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0 >>> solve(2, 4, [[1, 1, 1, 1], [1, 1, 1, ...
def largest_rectangle_area(matrix): if not matrix: return 0 max_area = 0 n = len(matrix[0]) heights = [0] * n for row in matrix: for i in range(n): if row[i] == 0: heights[i] = 0 else: heights[i] += 1 max_area ...
def test_example_1(): m, n = 4, 4 matrix = [ [1, 0, 1, 0], [1, 0, 1, 1], [1, 1, 1, 1], [0, 1, 0, 0] ] assert solve(m, n, matrix) == 4 def test_example_2(): m, n = 3, 3 matrix = [ [0, 0, 0], [0, 0, 0], [0, 0, 0] ] assert solve(m, n,...
[ { "docstring": null, "function_declaration": "def largest_rectangle_area(matrix):", "function_name": "largest_rectangle_area", "parameter_list": "(matrix)" }, { "docstring": null, "function_declaration": "def max_histogram_area(heights):", "function_name": "max_histogram_area", "...
[ 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 maximalRectangle(matrix):\n if len(matrix) == 0:\n return 0\n \n n = len(matrix[0])\n heights = [0] * n\n max_area = 0\n \n def max...
trial_gpt4o_2
{ "original_instruction": "Farmer Alex has a rectangular field, divided into a grid of m rows and n columns. Each cell in the field can either contain a crop or be empty. The task is to find the largest rectangle in the grid that contains only crops. \n\nYou are given a binary matrix where 1 represents a crop and 0 r...
0.64054
Taco_65554
C
[ "largest_rectangle_area", "max_histogram_area", "solve" ]
3
[ [ "largest_rectangle_area", "max_histogram_area" ], [ "solve", "largest_rectangle_area" ] ]
2
[]
false
[]
false
pytest
false
[]
true
424a51ea2bba28cc901626cecc4adc9ff35f856f
6af56ce9d055fc35c60d2106295e3b098aa13630
v1.0
complete
Taco
Taco_65327_C
def mergeSort(arr): """ Implement the Merge Sort algorithm to sort an array in non-decreasing order. Parameters: arr (List[int]): the unsorted array of integers Returns: List[int]: the array sorted in non-decreasing order Examples: >>> mergeSort([]) [] >>> mergeSort([1]) [...
def mergeSort(arr): if len(arr) <= 1: return arr # Divide the array into two halves mid = len(arr) // 2 left_half = arr[:mid] right_half = arr[mid:] # Recursively sort each half left_sorted = mergeSort(left_half) right_sorted = mergeSort(right_half) # Merge the...
from solution import mergeSort def test_mergeSort_empty(): assert mergeSort([]) == [] def test_mergeSort_single_element(): assert mergeSort([1]) == [1] def test_mergeSort_sorted(): assert mergeSort([1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5] def test_mergeSort_reverse_sorted(): assert mergeSort([5, 4, 3, 2,...
[ { "docstring": null, "function_declaration": "def mergeSort(arr):", "function_name": "mergeSort", "parameter_list": "(arr)" }, { "docstring": null, "function_declaration": "def merge(left, right):", "function_name": "merge", "parameter_list": "(left, right)" } ]
[ 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 mergeSort(arr):\n if len(arr) <= 1:\n return arr\n \n def merge(left, right):\n sorted_array = []\n while left and right:\n ...
trial_gpt4o_2
{ "original_instruction": "You are given an array of integers. In this challenge, your task is to implement the Merge Sort algorithm to sort the array in non-decreasing order. Merge Sort is a divide-and-conquer algorithm that works as follows:\n\nStep 1: Divide\n- Divide the unsorted array into two roughly equal smal...
0.682375
Taco_65327
C
[ "mergeSort", "merge" ]
2
[ [ "mergeSort", "merge" ] ]
1
[]
false
[]
false
pytest
true
[]
true
74c0efe68fc753ff503c5aeea9afc953dd7f472c
09a501b0e463ef97fcb45bfe37bb0d923af4fadf
v1.0
complete
Taco
Taco_65683_C
def euclidean_distance_squared(point1, point2): """ Calculate the squared Euclidean distance between two points on a 2D plane. """ def check_distances(points, k): """ Check if there exists a pair of points such that their squared Euclidean distance is exactly k^2. """ def process_input(T, test...
import math def euclidean_distance_squared(point1, point2): x1, y1 = point1 x2, y2 = point2 return (x2 - x1) ** 2 + (y2 - y1) ** 2 def check_distances(points, k): k_squared = k * k for i in range(len(points)): for j in range(i + 1, len(points)): if euclidean_distance_squared(po...
from solution import euclidean_distance_squared, check_distances, process_input def test_euclidean_distance_squared(): assert euclidean_distance_squared((0, 0), (3, 4)) == 25 assert euclidean_distance_squared((1, 2), (1, 2)) == 0 assert euclidean_distance_squared((-1, -1), (1, 1)) == 8 def test_check_dist...
[ { "docstring": null, "function_declaration": "def euclidean_distance_squared(point1, point2):", "function_name": "euclidean_distance_squared", "parameter_list": "(point1, point2)" }, { "docstring": null, "function_declaration": "def check_distances(points, k):", "function_name": "che...
[ 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\n\ndef check_distance(points, k):\n k_squared = k * k\n n = len(points)\n \n for i in range(n):\n for j in range(i + 1, n):\n ...
trial_gpt4o_1
{ "original_instruction": "You are given n pairs of integers where each pair represents the coordinates (x, y) of a point on a 2D plane. Your task is to determine if there exists a pair of points such that their Euclidean distance is exactly k.\n\nThe Euclidean distance between two points (x1, y1) and (x2, y2) is def...
0.586503
Taco_65683
C
[ "euclidean_distance_squared", "check_distances", "process_input", "solve" ]
4
[ [ "check_distances", "euclidean_distance_squared" ], [ "process_input", "check_distances" ], [ "solve", "process_input" ] ]
3
[ "process_input" ]
false
[]
false
pytest
true
[]
true
c49a88e4be4a0f8ceeb7ec36f310e98f93d650b3
71ce1b6f9188f657c09bdd3948d77d1157a6b35a
v1.0
complete
Taco
Taco_65260_C
def count_nodes_on_path(n: int, edges: List[Tuple[int, int]], queries: List[Tuple[int, int]]) -> List[int]: """ Returns the number of nodes on the path between u and v for each query. Args: n : int : Number of nodes in the tree. edges : List[Tuple[int, int]] : List of edges where each edge is r...
from collections import deque def bfs(tree, start, n): """ Perform BFS to calculate depth and parent arrays. """ depth = [-1] * (n + 1) parent = [-1] * (n + 1) queue = deque([start]) depth[start] = 0 while queue: node = queue.popleft() for neighbor in tree[node]: ...
from solution import count_nodes_on_path def test_example_case(): n = 5 edges = [(1, 2), (1, 3), (2, 4), (2, 5)] queries = [(1, 4), (4, 5), (3, 5)] assert count_nodes_on_path(n, edges, queries) == [3, 3, 4] def test_single_node(): n = 1 edges = [] queries = [(1, 1)] assert count_nodes_...
[ { "docstring": "Perform BFS to calculate depth and parent arrays.", "function_declaration": "def bfs(tree, start, n):", "function_name": "bfs", "parameter_list": "(tree, start, n)" }, { "docstring": "Find the lowest common ancestor of u and v using depth and parent arrays.", "function_de...
[ 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 collections import deque, defaultdict\n\ndef bfs_depth_and_parent(tree, N, start_node):\n depth = [-1] * (N + 1) # Depth of each node\n parent = [-1] *...
trial_gpt4o_4
{ "original_instruction": "A tree T is an undirected graph with N nodes and N-1 edges such that there is a unique path between any pair of nodes. You are given a tree T and Q queries. In each query, you are given two nodes u and v, and you need to calculate the number of nodes on the unique path between u and v (incl...
0.630296
Taco_65260
C
[ "bfs", "lca", "count_nodes_on_path" ]
3
[ [ "count_nodes_on_path", "bfs" ], [ "count_nodes_on_path", "lca" ] ]
2
[]
false
[]
false
pytest
true
[]
true
0499ee4d946d0bff59fc38f3e18959a1f30b1f21
1e7177bd112d1c74c28a725005d6314547cd6a14
v1.0
complete
Taco
Taco_65307_C
def solve_puzzle(n: int, m: int, grid: List[List[int]]) -> int: """ Find the path with the minimum cost from the top-left corner of the grid to the bottom-right corner. >>> solve_puzzle(3, 3, [ ... [1, 3, 1], ... [1, 5, 1], ... [4, 2, 1] ... ]) 7 >>> solve_puzzle(1, 1, [ ... [5] ...
import heapq def min_cost_path(grid): n = len(grid) m = len(grid[0]) # Priority queue to store (cost, (row, col)) pq = [(grid[0][0], (0, 0))] # Directions for movement: up, down, left, right directions = [(-1, 0), (1, 0), (0, -1), (0, 1)] # 2D list to store the minimum cost t...
from solution import solve_puzzle def test_min_cost_path_3x3(): grid = [ [1, 3, 1], [1, 5, 1], [4, 2, 1] ] assert solve_puzzle(3, 3, grid) == 7 def test_min_cost_path_1x1(): grid = [ [5] ] assert solve_puzzle(1, 1, grid) == 5 def test_min_cost_path_2x2(): g...
[ { "docstring": null, "function_declaration": "def min_cost_path(grid):", "function_name": "min_cost_path", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def solve_puzzle(n, m, grid):", "function_name": "solve_puzzle", "parameter_list": "(n, m, grid)"...
[ 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 min_cost_path(n, m, grid):\n \"\"\"\n Calculates the minimum cost path from the top-left corner to the bottom-right corner of a grid.\n \n :param n...
trial_gpt4o_6
{ "original_instruction": "A popular video game requires players to solve puzzles to advance to the next level. One such puzzle involves navigating through a grid of rooms. Each room is marked with a number that indicates the cost of visiting that room. The player can move up, down, left, or right, but not diagonally...
0.646566
Taco_65307
C
[ "min_cost_path", "solve_puzzle" ]
2
[ [ "solve_puzzle", "min_cost_path" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c5048835e9681348b061ce77ef0c3353331335e2
7ca6a745e68e4f844032ddf4dc5cba876513e488
v1.0
complete
Taco
Taco_65482_C
def max_histogram_area(histogram: List[int]) -> int: """ Calculate the maximum area of a histogram. >>> max_histogram_area([2, 1, 5, 6, 2, 3]) 10 >>> max_histogram_area([2, 4]) 4 """ def maximal_rectangle_area(grid: List[List[str]]) -> int: """ Given a grid of size N x N where each cell...
def max_histogram_area(histogram): stack = [] max_area = 0 index = 0 while index < len(histogram): if not stack or histogram[stack[-1]] <= histogram[index]: stack.append(index) index += 1 else: top_of_stack = stack.pop() area = (histogram[...
def test_max_histogram_area(): assert max_histogram_area([2, 1, 5, 6, 2, 3]) == 10 assert max_histogram_area([2, 4]) == 4 assert max_histogram_area([6, 2, 5, 4, 5, 1, 6]) == 12 def test_maximal_rectangle_area(): grid1 = [['1', '0', '1', '0'], ['1', '0', '1', '1'], ['1', '1',...
[ { "docstring": null, "function_declaration": "def max_histogram_area(histogram):", "function_name": "max_histogram_area", "parameter_list": "(histogram)" }, { "docstring": null, "function_declaration": "def maximal_rectangle_area(grid):", "function_name": "maximal_rectangle_area", ...
[ 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 maximalRectangle(grid):\n if not grid:\n return 0\n\n N = len(grid)\n heights = [0] * N\n max_area = 0\n \n for row in range(N):\n ...
trial_gpt4o_1
{ "original_instruction": "Given a grid of size N x N where each cell is either '1' or '0', your task is to find the largest rectangle containing only '1's and return its area.\n\nConstraints:\n\n* 1≤N≤300\n* Each cell in the grid is either '0' or '1'\n\nInput:\n\nThe input is given from the standard input in the fol...
0.677693
Taco_65482
C
[ "max_histogram_area", "maximal_rectangle_area" ]
2
[ [ "maximal_rectangle_area", "max_histogram_area" ] ]
1
[]
false
[]
false
pytest
false
[]
true
e4442a5826c2ca963691fdd6af2b69b2eaed9512
a48493d62b9aae6ce0980229804ded6804c5731c
v1.0
complete
Taco
Taco_65414_C
def preprocess_array(arr): """ Preprocess the array to calculate the prefix sums. """ pass def range_sum_query(prefix_sums, L, R): """ Returns the sum of the elements in the subarray from index L to R inclusive. """ pass def process_queries(N, Q, arr, queries): """ Processes al...
def preprocess_array(arr): """ Preprocess the array to calculate the prefix sums. """ prefix_sums = [0] * (len(arr) + 1) for i in range(len(arr)): prefix_sums[i + 1] = prefix_sums[i] + arr[i] return prefix_sums def range_sum_query(prefix_sums, L, R): """ Returns the sum of the e...
from solution import preprocess_array, range_sum_query, process_queries def test_preprocess_array(): arr = [1, 2, 3, 4, 5] expected_prefix_sums = [0, 1, 3, 6, 10, 15] assert preprocess_array(arr) == expected_prefix_sums def test_range_sum_query(): prefix_sums = [0, 1, 3, 6, 10, 15] assert range_su...
[ { "docstring": "Preprocess the array to calculate the prefix sums.", "function_declaration": "def preprocess_array(arr):", "function_name": "preprocess_array", "parameter_list": "(arr)" }, { "docstring": "Returns the sum of the elements in the subarray from index L to R inclusive.", "fun...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def range_sum_query(n, q, array, queries):\n \"\"\"\n Processes range sum queries efficiently using prefix sums.\n \n :param n: Number of elements in t...
trial_gpt4o_2
{ "original_instruction": "Zara is developing a new application that needs to handle various queries on arrays efficiently. She has designed a specific type of query called a \"range sum query.\" Given an array of integers, each query will ask for the sum of a subarray defined by a range [L, R] inclusive. Zara is loo...
0.585676
Taco_65414
C
[ "preprocess_array", "range_sum_query", "process_queries" ]
3
[ [ "process_queries", "preprocess_array" ], [ "process_queries", "range_sum_query" ] ]
2
[ "process_queries" ]
false
[]
false
pytest
true
[]
true
0c4053922122fd752dadb9c53ab90511f7ed320a
1397e9147e34e3c9e3de09a62d618e3ecb9186b9
v1.0
complete
Taco
Taco_65664_C
def can_reorder(tree1: dict, tree2: dict) -> bool: """ Determine if the second tree can be transformed into the first tree by reordering its nodes. >>> tree1 = { 'A': ('B', 'C'), 'B': (None, None), 'C': (None, None) } >>> tree3 = { 'A': ('C', 'B'), ...
def inorder_traversal(tree, node, result): if node is None: return left, right = tree.get(node, (None, None)) inorder_traversal(tree, left, result) result.append(node) inorder_traversal(tree, right, result) def preorder_traversal(tree, node, result): if node is None: return ...
from solution import can_reorder def test_can_reorder_true(): tree1 = { 'A': ('B', 'C'), 'B': (None, None), 'C': (None, None) } tree3 = { 'A': ('C', 'B'), 'B': (None, None), 'C': (None, None) } assert can_reorder(tree1, tree3) == True def test_can_re...
[ { "docstring": null, "function_declaration": "def inorder_traversal(tree, node, result):", "function_name": "inorder_traversal", "parameter_list": "(tree, node, result)" }, { "docstring": null, "function_declaration": "def preorder_traversal(tree, node, result):", "function_name": "p...
[ 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 in_order_traversal(tree, node):\n if node is None:\n return []\n left, right = tree.get(node, (None, None))\n return in_order_traversal(tree, l...
trial_gpt4o_9
{ "original_instruction": "Vani found two binary trees in the deep forest. She decides to traverse both trees in a unique way, first with an in-order traversal and then with a pre-order traversal. She then combined the results of both traversals to determine if by making some adjustments to the second tree, it can be...
0.497598
Taco_65664
C
[ "inorder_traversal", "preorder_traversal", "can_reorder" ]
3
[ [ "can_reorder", "inorder_traversal" ], [ "can_reorder", "preorder_traversal" ] ]
2
[]
false
[]
false
pytest
true
[]
true
60e9b49ac2bb981c72efec6c95047db26493f601
91adcd5d5c024b27500ccc3e96139e4713678678
v1.0
complete
Taco
Taco_65248_C
def find_minimum_difficulty(N, routes): """ Given a set of routes and their difficulty levels, find the minimum total difficulty level required to visit all checkpoints exactly once and return to checkpoint 1. Args: N: int - number of checkpoints routes: List[Tuple[int, int, int]] - list of rou...
import sys from itertools import permutations def find_minimum_difficulty(N, routes): graph = [[sys.maxsize]*N for _ in range(N)] for a, b, d in routes: graph[a-1][b-1] = d graph[b-1][a-1] = d min_difficulty = sys.maxsize checkpoints = list(range(1, N)) # Try every permutation to ...
def test_example_case(): from io import StringIO from unittest.mock import patch example_input = "2\n4\n5\n1 2 10\n2 3 10\n3 4 10\n4 1 10\n1 3 15\n3\n3\n1 2 7\n2 3 8\n1 3 12\n" expected_output = "40\n27\n" with patch('sys.stdin', StringIO(example_input)), patch('sys.stdout', new_callable=StringIO)...
[ { "docstring": null, "function_declaration": "def find_minimum_difficulty(N, routes):", "function_name": "find_minimum_difficulty", "parameter_list": "(N, routes)" }, { "docstring": null, "function_declaration": "def solve():", "function_name": "solve", "parameter_list": "()" }...
[ 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 sys\nimport itertools\n\ndef min_difficulty_for_all_checkpoints(T, test_cases):\n results = []\n for case in test_cases:\n N, M, edges = case\n...
trial_gpt4o_1
{ "original_instruction": "A company is organizing a transport system for delivering packages using drones. There is a set of N routes, each connecting two checkpoints identified by integers. A route between checkpoint A and checkpoint B has an associated difficulty level D. The difficulty level determines the batter...
0.642045
Taco_65248
C
[ "find_minimum_difficulty", "solve" ]
2
[ [ "solve", "find_minimum_difficulty" ] ]
1
[]
false
[]
false
pytest
false
[]
true
fd1c13e21f351ba08ff3e7c9860595cebaf78eb6
8a200a5edf71c72957221cd6960020a57205a7ad
v1.0
complete
Taco
Taco_65217_C
def is_almost_palindrome(s): """ Determines if it's possible to make the given string s a palindrome by removing at most one character. """ def is_palindrome_range(i, j): """ Helper function to check if the substring s[i:j+1] is a palindrome. """ return all(s[k] == s[j-k+i] for k in...
def is_almost_palindrome(s): """ Determines if it's possible to make the given string s a palindrome by removing at most one character. """ def is_palindrome_range(i, j): """ Helper function to check if the substring s[i:j+1] is a palindrome. """ return all(s[k] == s[j-k+i] for k in...
from solution import almost_palindrome def test_almost_palindrome(): assert almost_palindrome("abca") == "YES" assert almost_palindrome("racecar") == "YES" assert almost_palindrome("abcdef") == "NO" assert almost_palindrome("a") == "YES" assert almost_palindrome("aa") == "YES" assert almost_pal...
[ { "docstring": "Determines if it's possible to make the given string s a palindrome \nby removing at most one character.", "function_declaration": "def is_almost_palindrome(s):", "function_name": "is_almost_palindrome", "parameter_list": "(s)" }, { "docstring": "Outputs \"YES\" if it is poss...
[ 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_be_palindrome(s: str) -> str:\n def is_palindrome_range(i, j):\n return all(s[k] == s[j - k + i] for k in range(i, j))\n\n for i in range(len(...
trial_gpt4o_1
{ "original_instruction": "You are given a string s consisting of lowercase and uppercase Latin characters. Your task is to determine if it is possible to make the given string a palindrome by removing at most one character.\n\n\n-----Input-----\n\nThe only line of input contains a string s of length between 1 and 10...
0.800634
Taco_65217
C
[ "is_almost_palindrome", "almost_palindrome" ]
2
[ [ "almost_palindrome", "is_almost_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e5f383b04263fb32ac3d1e32695ebc7cd1b0a7d1
f655db09ee3eb3497c40fe2b0b3eb35e4283bac1
v1.0
complete
Taco
Taco_65492_C
def max_coins(grid): """ Given a grid of integers, returns the maximum number of coins that can be collected from the top-left to the bottom-right corner. """ pass def parse_input(input_str): """ Parses the input string into a list of grids. >>> parse_input('3 3\n1 3 1\n1 5 1\n4 2 1\n2 ...
def max_coins(grid): """ Given a grid of integers, returns the maximum number of coins that can be collected from the top-left to the bottom-right corner. """ if not grid: return 0 N = len(grid) M = len(grid[0]) dp = [[0] * M for _ in range(N)] dp[0][0] = grid[0][0]...
def test_max_coins_simple(): grid = [ [1, 3, 1], [1, 5, 1], [4, 2, 1] ] assert max_coins(grid) == 12 def test_max_coins_single_row(): grid = [ [2, 1, 3] ] assert max_coins(grid) == 6 def test_max_coins_single_column(): grid = [ [2], [1], ...
[ { "docstring": "Given a grid of integers, returns the maximum number of coins\nthat can be collected from the top-left to the bottom-right corner.", "function_declaration": "def max_coins(grid):", "function_name": "max_coins", "parameter_list": "(grid)" }, { "docstring": "Parses the input st...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_coins_collected(grids):\n results = []\n for grid in grids:\n N, M = len(grid), len(grid[0])\n dp = [[0] * M for _ in range(N)]\n\n ...
trial_gpt4o_2
{ "original_instruction": "You are given an N x M grid where each cell contains a positive integer representing the number of coins in that cell. You start at the top-left corner (1, 1) and want to reach the bottom-right corner (N, M). You can move either to the cell directly to the right or directly below the curren...
0.62523
Taco_65492
C
[ "max_coins", "parse_input", "solve" ]
3
[ [ "solve", "max_coins" ], [ "solve", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
97deaff6bed00c5843a457c43866c6289022d7b8
71cc6bb8d7673a1d5f2e8679a56a92b6f4486b96
v1.0
complete
Taco
Taco_65560_C
def count_unique_trees(T: int, testcases: List[Tuple[int, List[int], List[Tuple[int, int]]]]) -> List[int]: """ Given a tree with N nodes and N-1 edges, where each node is associated with an integer value from 1 to N. You are allowed to perform the following operation as many times as you'd like: Select...
def count_unique_trees(T, testcases): MOD = 10**9 + 7 def find_components(n, edges): visited = [False] * n components = [] def dfs(node, component): stack = [node] while stack: curr = stack.pop() if not visited[curr]: ...
def test_count_unique_trees(): T = 2 testcases = [ (3, [1, 2, 3], [(1, 2), (2, 3)]), (4, [1, 2, 3, 4], [(1, 2), (1, 3), (1, 4)]), ] expected_output = [6, 24] # Adjusted as because for 4 nodes, it should be 24 -> 4 factorial (4!) assert count_unique_trees(T, testcases) == expected_out...
[ { "docstring": null, "function_declaration": "def count_unique_trees(T, testcases):", "function_name": "count_unique_trees", "parameter_list": "(T, testcases)" }, { "docstring": null, "function_declaration": "def factorial(x):", "function_name": "factorial", "parameter_list": "(x...
[ 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": "MOD = 10**9 + 7\n\ndef factorial(n):\n if n == 0 or n == 1:\n return 1\n result = 1\n for i in range(2, n + 1):\n result = result * i % MOD\...
trial_gpt4o_2
{ "original_instruction": "Given a tree with N nodes and N-1 edges, where each node is associated with an integer value from 1 to N. You are allowed to perform the following operation as many times as you'd like:\nSelect any two nodes u and v, and if u and v are directly connected, you can swap their values. You want...
0.586395
Taco_65560
C
[ "count_unique_trees", "factorial" ]
2
[ [ "count_unique_trees", "factorial" ] ]
1
[]
false
[]
false
pytest
false
[]
true
42c38e862cf238767e0898f060bc99058a1dd77b
ce455c5b4e0c7d6422412618bd4384468a6b12b4
v1.0
complete
Taco
Taco_65099_C
def total_travel_time_of_mst(n: int, m: int, roads: List[Tuple[int, int, int]]) -> int: """ Determine the total travel time of the minimum spanning tree (MST) of the given cities and roads. >>> total_travel_time_of_mst(4, 5, [(1, 2, 1), (1, 3, 4), (2, 3, 2), (2, 4, 3), (3, 4, 5)]) 6 >>> total_travel_tim...
def find(parent, i): while parent[i] != i: i = parent[i] return i def union(parent, rank, x, y): xroot = find(parent, x) yroot = find(parent, y) if rank[xroot] < rank[yroot]: parent[xroot] = yroot elif rank[xroot] > rank[yroot]: parent[yroot] = xroot else: ...
from solution import total_travel_time_of_mst def test_example_case(): n = 4 m = 5 roads = [(1, 2, 1), (1, 3, 4), (2, 3, 2), (2, 4, 3), (3, 4, 5)] assert total_travel_time_of_mst(n, m, roads) == 6 def test_two_cities(): n = 2 m = 1 roads = [(1, 2, 10)] assert total_travel_time_of_mst(n...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n else:\n return find(parent, parent[i])\n\ndef union(parent, rank, x, y):\n xroot = fi...
trial_gpt4o_2
{ "original_instruction": "In a kingdom, there are N cities connected by M bidirectional roads. Each road has a certain time required to travel through it. The king wants to make travelling as efficient as possible, so he has mandated that there should be exactly one path between any two cities with the minimum trave...
0.60626
Taco_65099
C
[ "find", "union", "kruskal_mst", "total_travel_time_of_mst", "main" ]
5
[ [ "kruskal_mst", "find" ], [ "kruskal_mst", "union" ], [ "total_travel_time_of_mst", "kruskal_mst" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
true
[]
true
69b77a55d8c7cbed05366379cab1605a08ecb882
f863078aa42d77d12f970a240fddf5d75b872c92
v1.0
complete
Taco
Taco_65843_C
from typing import List def num_paths(n: int, m: int, grid: List[List[int]]) -> int: """Calculate the number of distinct paths for a robot in a 2D grid from the top-left to the bottom-right corner. >>> num_paths(3, 3, [ ... [0, 0, 0], ... [0, 1, 0], ... [0, 0, 0] ... ]) 2 >>> num_...
def count_paths(grid): n = len(grid) m = len(grid[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] = 0 ...
from solution import num_paths def test_example_1(): grid = [ [0, 0, 0], [0, 1, 0], [0, 0, 0] ] assert num_paths(3, 3, grid) == 2 def test_example_2(): grid = [ [0, 1, 0], [0, 1, 0], [0, 0, 0] ] assert num_paths(3, 3, grid) == 1 def test_example...
[ { "docstring": null, "function_declaration": "def count_paths(grid):", "function_name": "count_paths", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def num_paths(n, m, grid):", "function_name": "num_paths", "parameter_list": "(n, m, grid)" } ]
[ 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 count_paths(grid):\n n = len(grid)\n m = len(grid[0])\n \n # If the starting point or the ending point is blocked, return 0\n if grid[0][0] == 1...
trial_gpt4o_2
{ "original_instruction": "You are given the task of simulating the movements of a robot in a 2D grid. The robot starts at the top-left corner of the grid (0,0) and can move either right or down. The goal is to find the number of distinct paths the robot can take to reach the bottom-right corner of the grid (n-1, m-1...
0.664399
Taco_65843
C
[ "count_paths", "num_paths" ]
2
[ [ "num_paths", "count_paths" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7bb510dd7f54e1ff4dd709877d63488734f8c0d2
bce69aa6d7425102c8a242207b57d439968daa7a
v1.0
complete
Taco
Taco_65165_C
from typing import List, Tuple def minimum_permutation(n: int) -> List[int]: """ Generate a permutation of the numbers from 1 to n that minimizes the sum of the absolute differences between consecutive elements. >>> minimum_permutation(5) [1, 2, 3, 4, 5] >>> minimum_permutation(3) [1, 2, 3] ...
def minimum_permutation(n): return list(range(1, n + 1)) def maximum_permutation(n): result = [] left = 1 right = n while left <= right: if len(result) % 2 == 0: result.append(left) left += 1 else: result.append(right) right -= 1 r...
from solution import minimum_permutation, maximum_permutation, solve def test_minimum_permutation(): assert minimum_permutation(5) == [1, 2, 3, 4, 5] assert minimum_permutation(3) == [1, 2, 3] assert minimum_permutation(4) == [1, 2, 3, 4] def test_maximum_permutation(): assert maximum_permutation(5) =...
[ { "docstring": null, "function_declaration": "def minimum_permutation(n):", "function_name": "minimum_permutation", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def maximum_permutation(n):", "function_name": "maximum_permutation", "parameter_list": "(n...
[ 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 min_max_permutations(t, test_cases):\n results = []\n for n in test_cases:\n min_perm = list(range(1, n+1))\n max_perm = []\n left =...
trial_gpt4o_2
{ "original_instruction": "Given an integer n, you are to construct a permutation of the numbers from 1 to n such that the sum of the absolute differences between consecutive elements is minimized and also the sum of the absolute differences between consecutive elements is maximized.\n\nA permutation of the numbers f...
0.676788
Taco_65165
C
[ "minimum_permutation", "maximum_permutation", "solve" ]
3
[ [ "solve", "maximum_permutation" ], [ "solve", "minimum_permutation" ] ]
2
[]
false
[]
false
pytest
true
[]
true
48320ae5e24950a067b7cf78f790cf2af09a7b64
5e3bc8dc553d65808891c4a698309b7bcc37b0f6
v1.0
complete
Taco
Taco_65573_C
def can_reach_treasure(S_init: int, S_max: int, grid: List[List[str]], trap_penalty: Dict[str, int], energy_drinks: List[int]) -> bool: """ Determines if the archaeologist can reach the treasure without his stamina dropping to zero or below. Args: - S_init: An integer representing the archaeologist's initia...
import heapq def can_reach_treasure(S_init, S_max, grid, trap_penalty, energy_drinks): rows, cols = len(grid), len(grid[0]) start = (0, 0) goal = (rows - 1, cols - 1) stamina_drinks = sorted(energy_drinks, reverse=True) movement = [(0, 1), (1, 0), (0, -1), (-1, 0)] def in_bounds(r, c): ...
def test_example_case(): input_data = [ "15 20", "4 4", ".A..", "....", "..B.", "..C.", "3", "A 5", "B 8", "C 12", "3", "10", "15", "5", "10 10", "5 5", ".....", ".#B#.", ...
[ { "docstring": null, "function_declaration": "def can_reach_treasure(S_init, S_max, grid, trap_penalty, energy_drinks):", "function_name": "can_reach_treasure", "parameter_list": "(S_init, S_max, grid, trap_penalty, energy_drinks)" }, { "docstring": null, "function_declaration": "def nav...
[ 0, 0, 0, 0, 0, 0, 0, 1, 0 ]
1
hard
0.111
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef can_reach_treasure(S_init, S_max, R, C, grid, trap_costs, drinks):\n dirs = [(0,1), (1,0), (0,-1), (-1,0)] # Right, Down, ...
trial_gpt4o_8
{ "original_instruction": "A famous archaeologist has discovered an ancient map leading to a treasure hidden in a jungle. The jungle is represented as a rectangular grid of cells, each of which either contains an obstacle or is free to pass through.\n\nThe map also shows the presence of traps in some cells, which dec...
0.563196
Taco_65573
C
[ "can_reach_treasure", "navigate_jungle", "process_input" ]
3
[ [ "navigate_jungle", "can_reach_treasure" ] ]
1
[ "process_input" ]
false
[]
false
pytest
false
[]
true
42ca9ef2510475f51373bc40cb1fe41498739e70
f01058dfc48ca2bf86f6145b0c5001fa9f386800
v1.0
complete
Taco
Taco_65640_C
def check_subsequence_sum_prime(T: int, test_cases: List[Tuple[Tuple[int, int], List[int]]]) -> List[str]: """ Check if there exists a non-empty subsequence sum that is a prime number >= P. >>> check_subsequence_sum_prime(2, [((5, 10), [2, 3, 5, 7, 11]), ((3, 20), [10, 15, 20])]) ["YES", "NO"] >>> check...
def is_prime(n): """Check if a number is prime.""" if n < 2: return False if n in (2, 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 ...
import pytest from solution import check_subsequence_sum_prime def test_example_case(): T = 2 test_cases = [ ((5, 10), [2, 3, 5, 7, 11]), ((3, 20), [10, 15, 20]) ] expected = ["YES", "NO"] assert check_subsequence_sum_prime(T, test_cases) == expected def test_all_elements_prime(): ...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Check if there exists a subsequence sum that is a prime number >= P.", "function_declaration": "def check_subsequence_sum_prim...
[ 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 itertools import combinations\n\ndef is_prime(n):\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:...
trial_gpt4o_2
{ "original_instruction": "Yuki is a computer science enthusiast who loves solving algorithmic puzzles. During a recent coding competition, she came across a fascinating problem involving sequences and prime numbers.\n\nYou are given a sequence `S` of `N` integers and an integer `P`. Yuki needs to determine if there ...
0.611686
Taco_65640
C
[ "is_prime", "check_subsequence_sum_prime" ]
2
[ [ "check_subsequence_sum_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
66324d73aa684c3e952b71e0f4c1afec450f77a2
5929e9f6d220b3b8917e1589bf4d2b2122d33230
v1.0
complete
Taco
Taco_65788_C
def find_mst_weight(n: int, m: int, graph_data: List[str]) -> int: """ You are given an undirected graph with N nodes and M edges. Each edge has a weight associated with it. Find the Minimum Spanning Tree (MST) of the graph using Kruskal’s algorithm and return the total weight of the MST. If the graph...
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[yr...
def test_minimum_spanning_tree_connected_graph(): graph_data = [ "1 2 1", "1 3 4", "2 3 2", "2 4 3", "3 4 5" ] assert find_mst_weight(4, 5, graph_data) == 6 def test_minimum_spanning_tree_disconnected_graph(): graph_data = [ "1 2 3", "3 4 4" ]...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 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 find(parent, u):\n if parent[u] != u:\n parent[u] = find(parent, parent[u])\n return parent[u]\n\ndef union(parent, rank, u, v):\n root_u = fin...
trial_gpt4o_2
{ "original_instruction": "You are given an undirected graph with N nodes and M edges. Each edge has a weight associated with it. Your task is to find the Minimum Spanning Tree (MST) of the graph using Kruskal’s algorithm and return the total weight of the MST. If the graph is not connected, return -1.\n\nConstraints...
0.752241
Taco_65788
C
[ "find", "union", "kruskal_mst", "find_mst_weight" ]
4
[ [ "find_mst_weight", "kruskal_mst" ], [ "kruskal_mst", "find" ], [ "kruskal_mst", "union" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
false
[]
true
5340e36ea1909b7588a3499e98b073d619eef766
dd718bc5d943b5b91c53e7651f26cfe9052b0c7b
v1.0
complete
Taco
Taco_65913_C
from typing import List, Tuple def minimum_cost_to_connect_cities(n: int, m: int, connections: List[Tuple[int, int, int]]) -> int: """ Find the minimum cost to construct a network of roads to connect all cities. If it's impossible to connect all cities, return "Impossible". Parameters: n (int): T...
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 root_x != root_y: if rank[root_x] > rank[root_y]: parent[root_y] = root_x elif rank[root_x] < rank...
def test_example_1(): n, m = 4, 5 connections = [(1, 2, 3), (2, 3, 4), (3, 4, 5), (4, 1, 2), (2, 4, 6)] assert minimum_cost_to_connect_cities(n, m, connections) == 9 def test_example_2(): n, m = 3, 3 connections = [(1, 2, 5), (1, 3, 6), (2, 3, 7)] assert minimum_cost_to_connect_cities(n, m, con...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n return find(parent, parent[i])\n\ndef union(parent, rank, x, y):\n root_x = find(parent, x)\...
trial_gpt4o_0
{ "original_instruction": "A country is planning to build a new network of highways to connect its cities. They have identified a set of cities and possible roads they could construct between pairs of cities, along with the cost of constructing each road. They want to ensure that every city is connected directly or i...
0.68475
Taco_65913
C
[ "find", "union", "kruskal", "minimum_cost_to_connect_cities" ]
4
[ [ "kruskal", "find" ], [ "kruskal", "union" ], [ "minimum_cost_to_connect_cities", "kruskal" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
false
[]
true
130b3f4cbeb0890ef0a73f716ba3c578c7b16f8b
a254d965f15db5688aa2ecad9dcaef7f9f777e27
v1.0
complete
Taco
Taco_66199_C
def solve_knapsack_problem(W: int, N: int, items: List[str]) -> int: """ Determines the maximum value of items that can be loaded into a container without exceeding the weight capacity. Parameters: W (int): Maximum weight capacity of the container N (int): Number of items items (list of str): List ...
def knapsack(W, items): """ Determines the maximum value of items that can be loaded into a container without exceeding the weight capacity. Parameters: W (int): Maximum weight capacity of the container items (list of tuples): List of tuples where each tuple contains (weight, value) of the item ...
from solution import solve_knapsack_problem def test_example(): W = 50 N = 3 items = ["10 60", "20 100", "30 120"] assert solve_knapsack_problem(W, N, items) == 220 def test_single_item_fits(): W = 50 N = 1 items = ["50 100"] assert solve_knapsack_problem(W, N, items) == 100 def test_...
[ { "docstring": "Determines the maximum value of items that can be loaded into a container without exceeding the weight capacity.\n\nParameters:\nW (int): Maximum weight capacity of the container\nitems (list of tuples): List of tuples where each tuple contains (weight, value) of the item\n\nReturns:\nint: Maxim...
[ 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 knapsack(W, items):\n \"\"\"\n Finds the maximum total value of items that can be loaded into the container \n without exceeding the weight capacity W...
trial_gpt4o_4
{ "original_instruction": "Maria operates a shipping company and wants to optimize the loading of cargo containers to maximize the total value of loaded goods. Each cargo container can carry a specific maximum weight, and you have a list of items, each with a specific weight and value. Maria needs a program to help h...
0.654618
Taco_66199
C
[ "knapsack", "solve_knapsack_problem" ]
2
[ [ "solve_knapsack_problem", "knapsack" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3e5620f5460632a746acf19369a60d5bda2975c7
9c519575b0688c329da4dcc45a018d6767457651
v1.0
complete
Taco
Taco_65983_C
class TreeNode: """ TreeNode represents a node in a binary tree. """ def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def build_tree(nodes): """ Build a binary tree from the nodes representation. """ pass def f...
class TreeNode: """ TreeNode represents a node in a binary tree. """ def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def build_tree(nodes): """ Build a binary tree from the nodes representation. """ if not node...
import pytest from solution import lca_in_binary_tree def test_lca_case_1(): T = 2 test_cases = [ (5, [(2, 3), (-1, -1), (4, 5), (-1, -1), (-1, -1)], 4, 5), (6, [(2, 3), (-1, -1), (4, 5), (-1, 6), (-1, -1), (-1, -1)], 1, 5) ] expected = [3, 1] assert lca_in_binary_tree(T, test_cases...
[]
[ 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": "class TreeNode:\n def __init__(self, key):\n self.key = key\n self.left = None\n self.right = None\n\ndef build_tr...
trial_gpt4o_2
{ "original_instruction": "-----Problem Statement-----\nBob is learning about binary trees in his data structures class. He is particularly interested in finding the lowest common ancestor (LCA) of two nodes in a binary tree. The LCA of two nodes p and q in a binary tree is defined as the lowest node in the tree that...
0.556987
Taco_65983
C
[ "build_tree", "find_lca", "lca_in_binary_tree" ]
3
[ [ "lca_in_binary_tree", "build_tree" ], [ "lca_in_binary_tree", "find_lca" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
47f78d8ff1974be263b09d030712599a2d35c7e7
b5baf4e105606c82caa7b1cd04a1cbce59bce48d
v1.0
complete
Taco
Taco_65903_C
from typing import List, Tuple def process_operations(n: int, m: int, q: int, initial_flower_beds: List[int], operations: List[Tuple[int, int, int]]) -> List[int]: """ Perform update and query operations on a linear garden with n flower beds. Args: n (int): Number of flower beds. m (int): Number of upd...
def update_flower_beds(flower_beds, i, x): flower_beds[i - 1] = x def query_flower_beds(flower_beds, l, r): return len(set(flower_beds[l - 1:r])) def process_operations(n, m, q, initial_flower_beds, operations): results = [] flower_beds = initial_flower_beds[:] for operation in operations: ...
from solution import process_operations def test_process_operations(): n = 5 m = 2 q = 3 initial_flower_beds = [1, 2, 3, 3, 2] operations = [ (2, 1, 5), (1, 3, 4), (2, 1, 5), (1, 2, 5), (2, 2, 4), ] expected_output = [3, 4, 3] assert process_opera...
[ { "docstring": null, "function_declaration": "def update_flower_beds(flower_beds, i, x):", "function_name": "update_flower_beds", "parameter_list": "(flower_beds, i, x)" }, { "docstring": null, "function_declaration": "def query_flower_beds(flower_beds, l, r):", "function_name": "que...
[ 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 process_garden_operations(n, m, q, initial_flowers, operations):\n from collections import defaultdict\n \n flower_beds = initial_flowers\n \n r...
trial_gpt4o_2
{ "original_instruction": "A gardener is working in a linear garden with `n` flower beds arranged in a straight line. Each flower bed has a certain number of flowers, represented by an integer. The gardener wants to know how many different types of flowers are in each segment of the garden before and after performing...
0.666828
Taco_65903
C
[ "update_flower_beds", "query_flower_beds", "process_operations" ]
3
[ [ "process_operations", "query_flower_beds" ], [ "process_operations", "update_flower_beds" ] ]
2
[]
false
[]
false
pytest
true
[]
true
f55dc5fe41b505117f7934117e9d053103388eb1
317153a4f8a913524a23bea7a0aa43fb7c0fb3c5
v1.0
complete
Taco
Taco_65599_C
from datetime import datetime, timedelta def synchronize_time(num_cases, cases): """ Synchronize all server times to GMT (Greenwich Mean Time). Args: num_cases (int): The number of test cases. cases (List[List]): A list containing the details of each test case. Each test case ...
from datetime import datetime, timedelta def synchronize_time(num_cases, cases): results = [] for case in cases: n = case[0] for i in range(n): local_time, timezone = case[1+i] time = datetime.strptime(local_time, '%H:%M:%S') adjusted_time = time - timedelta(...
def test_process_input(): input_str = """1 2 10:45:05 +5 23:59:59 -3""" expected_output = (1, [[2, ('10:45:05', 5), ('23:59:59', -3)]]) assert process_input(input_str) == expected_output def test_synchronize_time(): num_cases = 1 cases = [ [2, ('10:45:05', 5), ('23:59:59', -3)] ] ex...
[ { "docstring": null, "function_declaration": "def synchronize_time(num_cases, cases):", "function_name": "synchronize_time", "parameter_list": "(num_cases, cases)" }, { "docstring": null, "function_declaration": "def process_input(input_str):", "function_name": "process_input", "...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from datetime import datetime, timedelta\n\ndef convert_to_gmt(local_time, timezone_offset):\n \"\"\"\n Convert the given local time and timezone offset to G...
trial_gpt4o_2
{ "original_instruction": "A large-scale e-commerce company is preparing for its biggest sales event of the year. To avoid any potential system failures due to traffic spikes, the company's IT department wants to ensure the server's clock synchronization is accurate and precise. They have servers placed in different ...
0.65061
Taco_65599
C
[ "synchronize_time", "process_input", "synchronize_from_input" ]
3
[ [ "synchronize_from_input", "process_input" ], [ "synchronize_from_input", "synchronize_time" ] ]
2
[ "process_input" ]
false
[]
false
pytest
false
[]
true
d52c32bed1a6d1ba128116441db641b142549c86
09f3de84c0e2dadd7f995c2b160e385b3caed3cb
v1.0
complete
Taco
Taco_65809_C
def check_connected_component(n: int, matrix_input: List[str]) -> str: """ Determines if all the 1s in an n x n matrix form exactly one connected component. A connected component consists of 1s that are adjacent either horizontally or vertically. Args: n (int): The size of the matrix (n x n). m...
def is_connected_component(n, matrix): # Directions for moving up, right, down, and left directions = [(-1, 0), (0, 1), (1, 0), (0, -1)] # Helper function for Depth First Search def dfs(i, j): stack = [(i, j)] while stack: ci, cj = stack.pop() for di, dj in d...
from solution import check_connected_component def test_check_connected_component_single_component(): matrix_input = [ "1 0 0 1", "1 1 0 1", "0 1 1 0", "0 0 0 0" ] assert check_connected_component(4, matrix_input) == "NO" def test_check_connected_component_disconnected(): ...
[ { "docstring": null, "function_declaration": "def is_connected_component(n, matrix):", "function_name": "is_connected_component", "parameter_list": "(n, matrix)" }, { "docstring": null, "function_declaration": "def check_connected_component(n, matrix_input):", "function_name": "check...
[ 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_one_connected_component(matrix, n):\n \"\"\"\n Determines if all 1s in the given n x n matrix form exactly one connected component.\n \n Args:\n...
trial_gpt4o_2
{ "original_instruction": "You are given an integer `n` and an `n x n` matrix consisting of only the values 0 and 1. Your task is to determine if all the 1s in the matrix form exactly one connected component. Two cells containing 1 are considered connected if they are adjacent horizontally or vertically.\n\nInput\nIn...
0.427627
Taco_65809
C
[ "is_connected_component", "check_connected_component" ]
2
[ [ "check_connected_component", "is_connected_component" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9838d3e602c14f431f9016dd437d740cf624b0f9
8bc45360f1baec0d63f811b7a5e49f79a49131b3
v1.0
complete
Taco
Taco_66255_C
def fourSumCount(nums: List[int], target: int) -> int: """ Returns the count of unique quadruples that sum up to the target value. >>> fourSumCount([1, 0, -1, 0, -2, 2], 0) 3 >>> fourSumCount([1, 2, 3, 4], 100) 0 >>> fourSumCount([0, 0, 0, 0, 0], 0) 1 >>> fourSumCount([-1, -2, -3, -...
def fourSumCount(nums, target): """ Returns the count of unique quadruples that sum up to the target value. """ nums.sort() quadruples = set() n = len(nums) for i in range(n-3): for j in range(i+1, n-2): left, right = j+1, n-1 while left < right: ...
from solution import fourSumCount def test_fourSumCount_example_case(): assert fourSumCount([1, 0, -1, 0, -2, 2], 0) == 3 def test_fourSumCount_no_quadruple(): assert fourSumCount([1, 2, 3, 4], 100) == 0 def test_fourSumCount_all_zeros(): assert fourSumCount([0, 0, 0, 0, 0], 0) == 1 def test_fourSumCoun...
[ { "docstring": "Returns the count of unique quadruples that sum up to the target value.", "function_declaration": "def fourSumCount(nums, target):", "function_name": "fourSumCount", "parameter_list": "(nums, target)" }, { "docstring": null, "function_declaration": "def input_output_handl...
[ 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 four_sum_count(nums, target):\n \"\"\"\n Returns the count of unique quadruples that sum up to the target.\n \"\"\"\n nums.sort()\n quadruples =...
trial_gpt4o_4
{ "original_instruction": "Implement a function that takes an array of integers and a target sum. The function should return the number of unique quadruples (sets of four numbers) from the array that sum up to the target sum. The quadruples should not include duplicate sets, even if the numbers appear in a different ...
0.625071
Taco_66255
C
[ "fourSumCount", "input_output_handler" ]
2
[ [ "input_output_handler", "fourSumCount" ] ]
1
[]
false
[]
false
pytest
true
[]
true
79412eb60c91b7f1d96b36cd462bc4672e1b8715
1427a0d54319c6ecea61b332aba96a9c4ca14828
v1.0
complete
Taco
Taco_66341_C
from typing import List def largest_number(nums: List[int]) -> str: """ Form the largest possible number by concatenating a list of non-negative integers. Parameters: nums (List[int]): A list of non-negative integers. Returns: str: The largest possible number formed by concatenating t...
from functools import cmp_to_key def compare(x, y): # Custom comparison function to decide the order based on concatenation if x + y > y + x: return -1 elif x + y < y + x: return 1 else: return 0 def largest_number(nums): """ Returns the largest possible number formed b...
from solution import largest_number def test_single_element(): assert largest_number([1]) == "1" assert largest_number([0]) == "0" assert largest_number([999]) == "999" def test_all_zeros(): assert largest_number([0, 0, 0]) == "0" def test_sample_cases(): assert largest_number([10, 2]) == "210" ...
[ { "docstring": null, "function_declaration": "def compare(x, y):", "function_name": "compare", "parameter_list": "(x, y)" }, { "docstring": "Returns the largest possible number formed by concatenating\na list of non-negative integers.", "function_declaration": "def largest_number(nums):"...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from functools import cmp_to_key\n\ndef compare(x, y):\n if x + y > y + x:\n return -1\n elif x + y < y + x:\n return 1\n else:\n ret...
trial_gpt4o_2
{ "original_instruction": "You are provided with a list of non-negative integers. Your task is to form the largest possible number by concatenating the integers in the list.\n\nWrite a function `largest_number(nums)` that takes a list of non-negative integers and returns a string representing the largest number that ...
0.741591
Taco_66341
C
[ "compare", "largest_number" ]
2
[ [ "largest_number", "compare" ] ]
1
[]
false
[]
false
pytest
true
[]
true
232f93f52a4dbb189c2605397affd785b0bfcc69
c39e69ea12322c2e313faa8f974ddc573bac7cc0
v1.0
complete
Taco
Taco_65521_C
class Node: def __init__(self, key): self.data = key self.left = None self.right = None def build_binary_tree(elements): """Builds a binary tree from a level-ordered list of elements. Args: elements (List): A list of elements representing the tree in level order traversal. ...
class Node: def __init__(self, key): self.data = key self.left = None self.right = None def build_binary_tree(elements): if not elements or elements[0] == "NULL": return None root = Node(elements[0]) queue = [root] i = 1 while queue and i < len(elements): ...
import pytest from solution import process_input, solve_test_case, build_binary_tree, sum_of_leaf_nodes def test_sum_of_leaf_nodes(): tree_elements1 = [1, 2, 3, 4, 5, 6, 7] assert solve_test_case(tree_elements1) == 22 tree_elements2 = [10, 20, 30] assert solve_test_case(tree_elements2) == 50 def test...
[]
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, value):\n self.value = value\n self.left = None\n self.right = None\n \ndef build_tree(level_or...
trial_gpt4o_1
{ "original_instruction": "Given a binary tree, write a function to find the sum of all the leaf nodes. A leaf node is a node that does not have any child nodes.\n\nInput:\nThe first line of input contains an integer T denoting the number of test cases. The first line of each test case consists of an integer N, the n...
0.653486
Taco_65521
C
[ "build_binary_tree", "sum_of_leaf_nodes", "solve_test_case", "process_input" ]
4
[ [ "process_input", "solve_test_case" ], [ "solve_test_case", "build_binary_tree" ], [ "solve_test_case", "sum_of_leaf_nodes" ] ]
3
[ "solve_test_case", "process_input" ]
false
[ "Node" ]
true
pytest
true
[]
true
603fc6882c3cb7d6d520c949deb65bd993a21d01
3e1f75e89182494475004fc0eae0110cfaceef99
v1.0
complete
Taco
Taco_66207_C
from typing import List, Tuple def is_bipartite(graph: dict, f: int) -> Tuple[bool, List[int]]: """Determine if the graph is bipartite and return the color assignment if true. Args: graph (dict): A dictionary representing the adjacency list of the graph. f (int): Number of functionalities in the graph...
from collections import defaultdict, deque def is_bipartite(graph, f): color = [-1] * (f + 1) # Color -1 indicates unvisited nodes for i in range(1, f + 1): if color[i] == -1: # Not yet visited node queue = deque([i]) color[i] = 0 # Start coloring this component with col...
from solution import map_functionalities_to_teams, assign_teams def test_no_solution(): test_cases = [ (2, 3, [(1, 2), (2, 3), (3, 1)]) ] result = map_functionalities_to_teams(test_cases) assert result == ["NO"] def test_valid_assignment(): test_cases = [ (3, 2, [(1, 2), (2, 1)]) ...
[ { "docstring": null, "function_declaration": "def is_bipartite(graph, f):", "function_name": "is_bipartite", "parameter_list": "(graph, f)" }, { "docstring": null, "function_declaration": "def assign_teams(t, f, dependencies):", "function_name": "assign_teams", "parameter_list": ...
[ 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": "from collections import deque, defaultdict\n\ndef is_bipartite(graph, f):\n color = [-1] * (f + 1)\n \n for start in range(1, f+1...
trial_gpt4o_2
{ "original_instruction": "Functional Area Mapping\n\nYou are tasked with designing a system that maps several functionality components in a tech company to their respective teams. Each functionality component can only belong to one team. There are a fixed number of teams, and some functionality components have depen...
0.536289
Taco_66207
C
[ "is_bipartite", "assign_teams", "map_functionalities_to_teams" ]
3
[ [ "assign_teams", "is_bipartite" ], [ "map_functionalities_to_teams", "assign_teams" ] ]
2
[]
false
[]
false
pytest
true
[]
true
7287fcfe53eb1304d419acb145d1d20dc567fedc
0b8193d6b1e2fe7020a011fee23b532c4477e582
v1.0
complete
Taco
Taco_66048_C
from typing import List, Tuple def delivery_courses(N: int, M: int, roads: List[Tuple[int, int]], Q: int, queries: List[Tuple[int, int]]) -> List[int]: """Given a city with N intersections and M roads, determine the shortest path for each delivery route. Args: N (int): Number of intersections. M (...
from collections import deque def shortest_path_bfs(graph, start, end): """ Returns the shortest path length between start and end using BFS. If no path exists, returns -1. """ if start == end: return 0 visited = set() queue = deque([(start, 0)]) while queue: n...
from solution import delivery_courses def test_case_1(): N = 5 M = 6 roads = [(1, 2), (2, 3), (3, 4), (4, 5), (2, 4), (1, 5)] Q = 3 queries = [(1, 3), (2, 5), (1, 6)] expected_output = [2, 2, -1] assert delivery_courses(N, M, roads, Q, queries) == expected_output def test_case_2(): N =...
[ { "docstring": "Returns the shortest path length between start and end using BFS.\nIf no path exists, returns -1.", "function_declaration": "def shortest_path_bfs(graph, start, end):", "function_name": "shortest_path_bfs", "parameter_list": "(graph, start, end)" }, { "docstring": null, "...
[ 0, 0, 0, 0, 0, 1, 1, 0, 0, 0 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import sys\nfrom collections import deque\n\ndef find_shortest_paths(N, roads, queries):\n def bfs(start):\n dist = [-1] * (N + 1)\n dist[start] =...
trial_gpt4o_5
{ "original_instruction": "There is a city with N intersections, numbered 1 through N. The i-th of the M roads connects intersections u_i and v_i.\n\nThere are M courses available for delivery, and each course consists of starting at one intersection and ending at another. Delivery drivers need to know the shortest d...
0.728663
Taco_66048
C
[ "shortest_path_bfs", "delivery_courses" ]
2
[ [ "delivery_courses", "shortest_path_bfs" ] ]
1
[]
false
[]
false
pytest
true
[]
true
fb52aaa655c650803dd58c6c9b434977aa73c140
8cd47c7c3cd60b8c0bf1dd83834191d859d7f99f
v1.0
complete
Taco
Taco_66058_C
def find_new_highways(n: int, m: int, k: int, roads: List[Tuple[int, int, int]]) -> List[Tuple[int, int, int]]: """ Determine the optimal placement and length of k new highways to connect unconnected cities. Ensure each new highway's length is minimized, and the total length of new highways is as small as possi...
import heapq def prim_mst(graph, n): """ Use Prim's algorithm to find the MST of the connected components of the graph. """ in_mst = [False] * (n + 1) # Priority queue to pick the smallest edge pq = [(0, 1)] # Weight, start from node 1 total_cost = 0 mst_edges = [] while pq: ...
def test_find_new_highways(): roads = [ (1, 2, 5), (2, 3, 7), (3, 4, 8) ] assert find_new_highways(4, 3, 2, roads) == [(1, 3, 4), (1, 4, 5)] roads = [ (1, 2, 1), (4, 5, 2) ] assert find_new_highways(5, 2, 3, roads) == [(1, 3, 4), (1, 4, 5), (1, 5, 6)] ...
[ { "docstring": "Use Prim's algorithm to find the MST of the connected components of the graph.", "function_declaration": "def prim_mst(graph, n):", "function_name": "prim_mst", "parameter_list": "(graph, n)" }, { "docstring": null, "function_declaration": "def find_new_highways(n, m, k, ...
[ 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 heapq\n\ndef find_new_highways(n, m, k, roads):\n # Initialize the adjacency list for the graph\n adj = {i: [] for i in range(1, n + 1)}\n for a, b...
trial_gpt4o_1
{ "original_instruction": "Bertlandia is a vast country known for its extensive road network connecting all its cities. The country has n cities labeled from 1 to n and m bidirectional roads. Each road connects two distinct cities and has a distinct positive length. Recently, Bertlandia’s government has decided to bu...
0.749517
Taco_66058
C
[ "prim_mst", "find_new_highways" ]
2
[ [ "find_new_highways", "prim_mst" ] ]
1
[]
false
[]
false
pytest
false
[]
true
c2b4b9482d800cf060ee8329669e4bc488789519
90f4e9de41805e474b7eecf5e852953013464ef7
v1.0
complete
Taco
Taco_66209_C
def morse_to_number(morse_code: str) -> int: """ Convert a Morse code string to its corresponding number. >>> morse_to_number('.----') 1 >>> morse_to_number('..---') 2 """ pass def is_prime(number: int) -> bool: """ Check if a number is prime. >>> is_prime(2) True >>> is_prime(4) False ...
def morse_to_number(morse_code): morse_dict = { '.----': '1', '..---': '2', '...--': '3', '....-': '4', '.....': '5', '-....': '6', '--...': '7', '---..': '8', '----.': '9', '-----': '0' } if morse_code in morse_dict: return int(morse_dict[morse_code]) return None def is_prime(n...
from solution import morse_to_number, is_prime, is_morse_prime import pytest def test_morse_to_number(): assert morse_to_number('.----') == 1 assert morse_to_number('..---') == 2 assert morse_to_number('...--') == 3 assert morse_to_number('....-') == 4 assert morse_to_number('.....') == 5 asser...
[ { "docstring": null, "function_declaration": "def morse_to_number(morse_code):", "function_name": "morse_to_number", "parameter_list": "(morse_code)" }, { "docstring": null, "function_declaration": "def is_prime(number):", "function_name": "is_prime", "parameter_list": "(number)"...
[ 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": "# Define Morse code dictionary\nmorse_code_to_digit = {\n '.----': '1',\n '..---': '2',\n '...--': '3',\n '....-': '4',\n '.....': '5',\n '-....'...
trial_gpt4o_3
{ "original_instruction": "Aliens have now developed a liking for prime numbers encoded in Morse code. They want to know if a Morse code string represents a prime number. Write a program that receives a Morse code string and checks if the decoded number is prime. Use the same Morse code conventions provided: \n\n1 .-...
0.651402
Taco_66209
C
[ "morse_to_number", "is_prime", "is_morse_prime" ]
3
[ [ "is_morse_prime", "is_prime" ], [ "is_morse_prime", "morse_to_number" ] ]
2
[]
false
[]
false
pytest
true
[]
true
93a974d1b520defef5a97a035bfc96533cea2845
747ccda0636a687e04f2ca6a71631e9932678163
v1.0
complete
Taco
Taco_66770_C
from typing import List def is_prime(n: int) -> bool: """ Helper function to determine if a number is a prime. """ def filter_primes(nums: List[int]) -> List[int]: """ Given a list of integers, return a new list containing only the prime numbers from the original list. >>> filter_primes([...
from typing import List def is_prime(n: int) -> bool: """ Helper function to determine if a number is a prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False p = 3 while p * p <= n: if n % p == 0: return False ...
from solution import filter_primes, is_prime def test_single_element(): assert filter_primes([2]) == [2] assert filter_primes([4]) == [] assert filter_primes([1]) == [] def test_mixed_elements(): assert filter_primes([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [2, 3, 5, 7] assert filter_primes([10, 20, 30...
[ { "docstring": "Helper function to determine if a number is a prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list containing only the prime numbers from the original list.", "function_declaration": "d...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from typing import List\n\ndef filter_primes(nums: List[int]) -> List[int]:\n def is_prime(num: int) -> bool:\n if num <= 1:\n return False\n ...
trial_gpt4o_2
{ "original_instruction": "## Task\nGiven a list of integers, return a new list containing only the prime numbers from the original list. A prime number is defined as a number greater than 1 that has no positive divisors other than 1 and itself.\n\n## Function Signature\n`def filter_primes(nums: List[int]) -> List[in...
0.777208
Taco_66770
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
48a01ae84243d98bc227d01ab0a455f5cff596d5
e829bc7424e0e28f0fd45a974ef0d5fcfa92316e
v1.0
complete
Taco
Taco_66953_C
MOD = 10**9 + 7 def fibonacci_sum(n: int) -> int: """ Returns the sum of the first n Fibonacci numbers (F(1) to F(n)) modulo 10^9 + 7. The sum of Fibonacci sequence heights is calculated using matrix exponentiation to handle large numbers efficiently. >>> fibonacci_sum(1) 1 >>> fibonacci_...
MOD = 10**9 + 7 def matrix_mult(A, B): """ Multiplies two 2x2 matrices A and B under modulo MOD """ return [ [(A[0][0] * B[0][0] + A[0][1] * B[1][0]) % MOD, (A[0][0] * B[0][1] + A[0][1] * B[1][1]) % MOD], [(A[1][0] * B[0][0] + A[1][1] * B[1][0]) % MOD, (A[1][0] * B[0][1] + A[1][1] * B[1...
from solution import fibonacci_sum, MOD def test_fibonacci_sum(): assert fibonacci_sum(1) == 1 assert fibonacci_sum(2) == 2 assert fibonacci_sum(5) == 12 assert fibonacci_sum(10) == 143 def test_fibonacci_sum_large(): # For large values of n, we just want to ensure it runs and # the results ar...
[ { "docstring": "Multiplies two 2x2 matrices A and B under modulo MOD", "function_declaration": "def matrix_mult(A, B):", "function_name": "matrix_mult", "parameter_list": "(A, B)" }, { "docstring": "Raises a 2x2 matrix to the power of exponent under modulo MOD using exponentiation by squarin...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def fib_sum(n):\n MOD = 10**9 + 7\n \n def matrix_mult(A, B):\n return [\n [(A[0][0] * B[0][0] + A[0][1] * B[1][0]) % MOD, (A[0][0] * B[...
trial_gpt4o_9
{ "original_instruction": "In a mystical land, there is a special kind of forest called the Fibonacci Forest. This forest has magical trees that follow the Fibonacci sequence. The first two trees in the sequence have heights of 1 and 1. Each subsequent tree's height is the sum of the heights of the two preceding tree...
0.747111
Taco_66953
C
[ "matrix_mult", "matrix_pow", "fibonacci_sum" ]
3
[ [ "fibonacci_sum", "matrix_pow" ], [ "matrix_pow", "matrix_mult" ] ]
2
[]
false
[]
false
pytest
true
[]
true
81c50851ed850040fa4e56bf3cc218a8fe4e431a
75e202459aeb1032832de52237c84623708d19e3
v1.0
complete
Taco
Taco_66131_C
from typing import List def run_library_system(operations: List[str]) -> List[str]: """ Manage a library's book collection system by processing a series of operations and returning the final state of the library, sorted by book IDs in ascending order. Each operation is one of the following: 1. A...
def manage_library(operations): collection = {} for operation in operations: parts = operation.split() command = parts[0] if command == "ADD": book_id = int(parts[1]) shelf_number = int(parts[2]) position_on_shelf = int(parts[3]) ...
def test_run_library_system(): operations = [ "ADD 101 2 3", "ADD 102 1 1", "MOVE 101 2 5", "REMOVE 102", "ADD 103 1 2", ] expected_output = [ "101 (2, 5)", "103 (1, 2)", ] assert run_library_system(operations) == expected_output def test_run_...
[ { "docstring": null, "function_declaration": "def manage_library(operations):", "function_name": "manage_library", "parameter_list": "(operations)" }, { "docstring": null, "function_declaration": "def format_output(sorted_books):", "function_name": "format_output", "parameter_lis...
[ 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 manage_library(operations):\n \"\"\"\n Processes a series of operations to manage a library's book collection.\n \n :param operations: List of oper...
trial_gpt4o_2
{ "original_instruction": "You are managing a library's book collection system. The system tracks multiple books represented by unique IDs and their corresponding positions on the shelves. Each book has an ID and a position in the format (shelf_number, position_on_shelf), where shelf_number and position_on_shelf are ...
0.510569
Taco_66131
C
[ "manage_library", "format_output", "run_library_system" ]
3
[ [ "run_library_system", "format_output" ], [ "run_library_system", "manage_library" ] ]
2
[ "format_output" ]
false
[]
false
pytest
false
[]
true
4adb844b252ee7463fe4092e63c3c193ad7af005
4736c800fb96ed78199807b591bf1868e5ea8d68
v1.0
complete
Taco
Taco_66549_C
from typing import List, Tuple def is_perfect_square(n: int) -> bool: """ Check if the given number is a perfect square. >>> is_perfect_square(-1) False >>> is_perfect_square(0) True >>> is_perfect_square(1) True >>> is_perfect_square(2) False >>> is_perfect_square(4) True ...
def is_perfect_square(n): if n < 0: return False root = int(n ** 0.5) return root * root == n def perfect_square_subarray_exists(n, arr): for i in range(n): product = 1 for j in range(i, n): product *= arr[j] if is_perfect_square(product): ...
def test_is_perfect_square(): assert not is_perfect_square(-1) # Negative numbers assert is_perfect_square(0) # Zero assert is_perfect_square(1) # Smallest perfect square assert not is_perfect_square(2) # Non-perfect square assert is_perfect_square(4) # Small perfect square def test_perfect_square_...
[ { "docstring": null, "function_declaration": "def is_perfect_square(n):", "function_name": "is_perfect_square", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def perfect_square_subarray_exists(n, arr):", "function_name": "perfect_square_subarray_exists", ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_perfect_square(num):\n if num < 0:\n return False\n root = int(num**0.5)\n return root * root == num\n\ndef has_perfect_square_subarray(n, a...
trial_gpt4o_2
{ "original_instruction": "Given an array of integers, you need to determine if it is possible to select a contiguous subarray such that the product of its elements is a perfect square.\n\nA perfect square is an integer that is the square of some integer; thus, it can be written as $k^2$ where $k$ is an integer.\n\n-...
0.587023
Taco_66549
C
[ "is_perfect_square", "perfect_square_subarray_exists", "solve" ]
3
[ [ "perfect_square_subarray_exists", "is_perfect_square" ], [ "solve", "perfect_square_subarray_exists" ] ]
2
[]
false
[]
false
pytest
false
[]
true
d4199491273b540a865680570f2347c009bf5f7f
5986561a7bf5d7f9a03fed33d847be58729d270a
v1.0
complete
Taco
Taco_66762_C
def total_distance(warehouse, locations): """ Calculate the total Manhattan distance from the warehouse to all delivery locations. """ warehouse_x, warehouse_y = warehouse["x"], warehouse["y"] return sum(abs(warehouse_x - loc[0]) + abs(warehouse_y - loc[1]) for loc in locations) def find_optimal_wa...
def total_distance(warehouse, locations): """ Calculate the total Manhattan distance from the warehouse to all delivery locations. """ warehouse_x, warehouse_y = warehouse["x"], warehouse["y"] return sum(abs(warehouse_x - loc[0]) + abs(warehouse_y - loc[1]) for loc in locations) def find_optimal_wa...
from solution import find_optimal_warehouse def test_single_warehouse(): warehouses = [{"id": 1, "x": 3, "y": 2}] delivery_locations = {1: [[5,5],[3,6],[7,8]]} result = find_optimal_warehouse(warehouses, delivery_locations) assert result == "The optimal warehouse is number 1 with the coordinates x = 3 ...
[ { "docstring": "Calculate the total Manhattan distance from the warehouse to all delivery locations.", "function_declaration": "def total_distance(warehouse, locations):", "function_name": "total_distance", "parameter_list": "(warehouse, locations)" }, { "docstring": null, "function_decl...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def calculate_total_distance(warehouse, delivery_locations):\n \"\"\"\n Calculate the total travel distance from the given warehouse to all delivery location...
trial_gpt4o_3
{ "original_instruction": "### Preface\nA logistics company needs help optimizing its delivery routes. The company has multiple warehouses and each warehouse has its own distinct list of delivery locations for a day. All warehouses are connected through a grid layout of streets, where the delivery trucks can move hor...
0.569594
Taco_66762
C
[ "total_distance", "find_optimal_warehouse" ]
2
[ [ "find_optimal_warehouse", "total_distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d6c3692666a8b8cae80dea61eedb488f59888a91
06c8d3d13af30c3ef14cf649cf230bd132463bb7
v1.0
complete
Taco
Taco_67034_C
def preprocess_sieve(n): """ Preprocesses and returns the prime count up to n using the Sieve of Eratosthenes. """ pass def count_primes_in_range(l, r, prime_count): """ Returns the count of prime numbers in the range [l, r] using the precomputed prime count. """ pass def process_queri...
def preprocess_sieve(n): """ Preprocesses and returns the prime count up to n using the Sieve of Eratosthenes. """ is_prime = [True] * (n + 1) p = 2 while p * p <= n: if is_prime[p]: for i in range(p * p, n + 1, p): is_prime[i] = False p += 1 is_p...
import pytest from solution import process_queries def test_example_cases(): queries = [(2, 10), (11, 20), (1, 100)] expected = [4, 4, 25] assert process_queries(queries) == expected def test_single_value_range(): queries = [(5, 5), (10, 10)] expected = [1, 0] assert process_queries(queries) =...
[ { "docstring": "Preprocesses and returns the prime count up to n using the Sieve of Eratosthenes.", "function_declaration": "def preprocess_sieve(n):", "function_name": "preprocess_sieve", "parameter_list": "(n)" }, { "docstring": "Returns the count of prime numbers in the range [l, r] using...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sieve_of_eratosthenes(max_number):\n \"\"\"\n Function to use the Sieve of Eratosthenes algorithm to find all primes up to max_number.\n \"\"\"\n i...
trial_gpt4o_2
{ "original_instruction": "Aliens have landed, and they are huge fans of prime numbers! They want to know how many prime numbers exist within different ranges of natural numbers. Your task is to help them by creating a program that processes a series of queries to count the number of prime numbers within specific ran...
0.670129
Taco_67034
C
[ "preprocess_sieve", "count_primes_in_range", "process_queries" ]
3
[ [ "process_queries", "count_primes_in_range" ], [ "process_queries", "preprocess_sieve" ] ]
2
[ "process_queries" ]
false
[]
false
pytest
true
[]
true
498f2a87e457aebc9530d7c3288e4eaa8bec3983
f7a7308bee1f86e053b9f46e2245bfda8409b5d6
v1.0
complete
Taco
Taco_66607_C
from typing import List, Tuple MOD = 10**9 + 7 def count_ways(N: int, K: int) -> int: """ Given an integer N and maximum capacity K, find the number of ways to place N identical balls into N distinct bins such that no bin is left empty, modulo 10^9 + 7. >>> count_ways(3, 2) 6 >>> count_ways(4, 3) ...
MOD = 10**9 + 7 def factorial(n): if n == 0 or n == 1: return 1 result = 1 for i in range(2, n + 1): result = (result * i) % MOD return result def count_ways(N, K): if K <= 0: return 0 if K == 1: return 1 if N == 1 else 0 # Using Stirling numbers of the sec...
from solution import count_ways def test_small_cases(): assert count_ways(3, 2) == 6 assert count_ways(4, 3) == 24 assert count_ways(5, 1) == 0 def test_extreme_cases(): assert count_ways(1, 1) == 1 assert count_ways(1, 1000) == 1 assert count_ways(1000, 1000) > 0 def test_zero_capacity(): ...
[ { "docstring": null, "function_declaration": "def factorial(n):", "function_name": "factorial", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def count_ways(N, K):", "function_name": "count_ways", "parameter_list": "(N, K)" }, { "docstring": nul...
[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "MOD = 10**9 + 7\n\ndef solve_ball_distribution(N, K):\n # use a 2D DP array to store the number of ways\n dp = [[0] * (N + 1) for _ in range(N + 1)]\n dp[...
trial_gpt4o_8
{ "original_instruction": "Given an integer N, you are tasked with finding the number of ways to place N identical balls into N distinct bins such that no bin is left empty. But there's a twist: each bin has a maximum capacity K. Numz, the God of Numbers, challenges you to determine the number of valid distributions ...
0.628095
Taco_66607
C
[ "factorial", "count_ways", "solve", "main" ]
4
[ [ "count_ways", "factorial" ], [ "solve", "count_ways" ] ]
2
[]
false
[]
false
pytest
true
[]
true
2e86e1577baf2e70d56ea23ca7affb0c6709434a
487ef520c5c9a0fc66a6bf9cf241f0f1bd663b58
v1.0
complete
Taco
Taco_66894_C
def check_subsequence(S1: str, S2: str) -> str: """ Determine if S1 is a subsequence of S2. >>> check_subsequence("abc", "ahbgdc") == "YES" >>> check_subsequence("axc", "ahbgdc") == "NO" >>> check_subsequence("ace", "abcde") == "YES" >>> check_subsequence("aec", "abcde") == "NO" >>> check_subseq...
def is_subsequence(S1, S2): """ Determines if S1 is a subsequence of S2. """ iter_s2 = iter(S2) return all(char in iter_s2 for char in S1) def check_subsequence(S1, S2): if is_subsequence(S1, S2): return "YES" else: return "NO"
def test_check_subsequence(): assert check_subsequence("abc", "ahbgdc") == "YES" assert check_subsequence("axc", "ahbgdc") == "NO" assert check_subsequence("ace", "abcde") == "YES" assert check_subsequence("aec", "abcde") == "NO" assert check_subsequence("abc", "abc") == "YES" assert check_subse...
[ { "docstring": "Determines if S1 is a subsequence of S2.", "function_declaration": "def is_subsequence(S1, S2):", "function_name": "is_subsequence", "parameter_list": "(S1, S2)" }, { "docstring": null, "function_declaration": "def check_subsequence(S1, S2):", "function_name": "check_...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_subsequence(s1, s2):\n \"\"\"\n Determines if s1 is a subsequence of s2.\n \"\"\"\n iter_s2 = iter(s2)\n return all(char in iter_s2 for char ...
trial_gpt4o_2
{ "original_instruction": "You are given two strings, S1 and S2. Determine if S1 is a subsequence of S2. A subsequence is a sequence that appears in the same relative order, but not necessarily consecutively.\n\nConstraints\n\n* 1 <= len(S1), len(S2) <= 1000\n* S1 and S2 contain only lowercase English letters.\n\nInp...
0.692315
Taco_66894
C
[ "is_subsequence", "check_subsequence" ]
2
[ [ "check_subsequence", "is_subsequence" ] ]
1
[]
false
[]
false
pytest
false
[]
true
1dfa85ff1a1c79f1b936c1cebc81e1f8485b555b
6a72a44c87109fc4d2989e72ea0b964e3e3d0866
v1.0
complete
Taco
Taco_67037_C
from math import gcd from functools import reduce from typing import List, Tuple def lcm(a: int, b: int) -> int: """ Compute the Least Common Multiple of a and b. >>> lcm(4, 5) 20 >>> lcm(6, 8) 24 """ return a * b // gcd(a, b) def smallest_number_divisible_by_all_coins(q: int, queries: List[Tu...
from math import gcd from functools import reduce def lcm(a, b): """ Compute the Least Common Multiple of a and b """ return a * b // gcd(a, b) def smallest_number_divisible_by_all_coins(q, queries): results = [] for i in range(q): n = queries[i][0] coins = set(queries[i][1]) ...
import pytest from solution import lcm, smallest_number_divisible_by_all_coins def test_lcm(): assert lcm(4, 5) == 20 assert lcm(6, 8) == 24 assert lcm(21, 6) == 42 assert lcm(2, 3) == 6 def test_smallest_number_divisible_by_all_coins_case1(): result = smallest_number_divisible_by_all_coins(3, [ ...
[ { "docstring": "Compute the Least Common Multiple of a and b", "function_declaration": "def lcm(a, b):", "function_name": "lcm", "parameter_list": "(a, b)" }, { "docstring": null, "function_declaration": "def smallest_number_divisible_by_all_coins(q, queries):", "function_name": "sma...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\nfrom functools import reduce\n\ndef lcm(a, b):\n return abs(a * b) // math.gcd(a, b)\n\ndef smallest_divisible_number(coins):\n distinct_coins =...
trial_gpt4o_2
{ "original_instruction": "Alice loves to collect different types of coins. She has $n$ types of coins, each type has an infinite number of coins. The $i$-th type of coin has a value $v_i$. Bob wants to give Alice a present on her birthday. He knows that Alice loves numbers that are divisible by every coin value she ...
0.615926
Taco_67037
C
[ "lcm", "smallest_number_divisible_by_all_coins" ]
2
[ [ "smallest_number_divisible_by_all_coins", "lcm" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8d76acc5cdd6f8d91aeb2d8d3f3515fbd11fd686
ce299bdce4820644318c9e7665155724947958a5
v1.0
complete
Taco
Taco_66651_C
from typing import List, Tuple def optimal_pages_read(T: int, participants_data: List[Tuple[Tuple[int, int], List[int]]]) -> List[int]: """ Determine the total number of pages in the optimal subset of books that each participant can choose. >>> optimal_pages_read(3, [((3, 50), [10, 20, 30]), ((4, 100), [40, 1...
def knapsack(T, data): results = [] for case in data: N, P = case[0] pages = case[1] dp = [0] * (P + 1) for page in pages: for j in range(P, page - 1, -1): dp[j] = max(dp[j], dp[j - page] + page) results.append(d...
from solution import optimal_pages_read def test_sample_cases(): T = 3 participants_data = [ [(3, 50), [10, 20, 30]], [(4, 100), [40, 15,25,20]], [(5, 60), [10, 10, 10, 10, 10]] ] assert optimal_pages_read(T, participants_data) == [50, 100, 50] def test_single_book(): T = 1...
[ { "docstring": null, "function_declaration": "def knapsack(T, data):", "function_name": "knapsack", "parameter_list": "(T, data)" }, { "docstring": null, "function_declaration": "def optimal_pages_read(T, participants_data):", "function_name": "optimal_pages_read", "parameter_lis...
[ 0, 0, 0, 0, 1 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def optimal_book_subset(T, test_cases):\n \"\"\"\n Returns the total number of pages in the optimal subset for each participant.\n \n Each participant'...
trial_gpt4o_4
{ "original_instruction": "You are organizing a reading contest and each participant will be reading books from a common pool. There are $N$ books in the pool and you are given a list of integers, where the $i$-th integer denotes the number of pages in the $i$-th book.\n\nEach participant will select a subset of book...
0.631748
Taco_66651
C
[ "knapsack", "optimal_pages_read" ]
2
[ [ "optimal_pages_read", "knapsack" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9923755b510ffc50a8b57d49248b5b6f1694771a
3a755c5c91d26be336789160523692cce3619d5a
v1.0
complete
Taco
Taco_67093_C
from typing import List, Tuple def connected_kingdom(n: int, m: int, roads: List[Tuple[int, int]]) -> str: """ Determines if it's possible to dispatch a rescue team between every pair of cities using the existing roads. >>> connected_kingdom(5, 5, [(1, 2), (2, 3), (3, 4), (4, 5), (2, 4)]) 'YES' >>...
def is_connected(n, m, connections): from collections import defaultdict, deque # Create the adjacency list for the graph graph = defaultdict(list) for a, b in connections: graph[a].append(b) graph[b].append(a) # Use BFS to check if all nodes are reachable from node 1 v...
from solution import connected_kingdom def test_fully_connected(): assert connected_kingdom(5, 5, [(1, 2), (2, 3), (3, 4), (4, 5), (2, 4)]) == "YES" def test_not_fully_connected(): assert connected_kingdom(4, 2, [(1, 2), (3, 4)]) == "NO" def test_single_city(): assert connected_kingdom(1, 0, []) == "YES"...
[ { "docstring": null, "function_declaration": "def is_connected(n, m, connections):", "function_name": "is_connected", "parameter_list": "(n, m, connections)" }, { "docstring": null, "function_declaration": "def connected_kingdom(n, m, roads):", "function_name": "connected_kingdom", ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def are_cities_connected(n, m, roads):\n from collections import defaultdict, deque\n\n if n == 0:\n return 'NO'\n\n if m == 0:\n return 'YE...
trial_gpt4o_1
{ "original_instruction": "In a particular kingdom, there are n cities connected by m bidirectional roads. Every road is characterized by two integers a and b indicating that there is a road between city a and city b. The kingdom's rule is that each road can be safely traversed without passing through more than one o...
0.624121
Taco_67093
C
[ "is_connected", "connected_kingdom" ]
2
[ [ "connected_kingdom", "is_connected" ] ]
1
[]
false
[]
false
pytest
true
[]
true
588074e4f0dab71b1e9f45584b70f84148375dbe
2ae36a735d6926bd70a164e42bcb8cdac20383f1
v1.0
complete
Taco
Taco_66585_C
from typing import List def is_prime(n: int) -> bool: """ Returns True if n is a prime number, False otherwise. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(17) True >>> is_prime(18) False >>> is_prime(1) False """ pass def prime_coprime_count(t: int...
def is_prime(n): """ Returns True if n is a prime number, False otherwise. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False ...
from solution import is_prime, prime_coprime_count def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(18) == False assert is_prime(1) == False def test_prime_coprime_count(): assert prime_coprim...
[ { "docstring": "Returns True if n is a prime number, False otherwise.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "For each number in numbers, return \"Not prime\" if it's not a prime number.\nIf it is a prime number, r...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Returns True if n is a prime number, False otherwise.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n ...
trial_gpt4o_0
{ "original_instruction": "You are working with a new encryption scheme that involves some operations with prime numbers. The encryption and decryption operations depend on the following property: for any prime number $p$, there are exactly $p-1$ positive integers less than $p$ that are coprime with $p$. Given a list...
0.796899
Taco_66585
C
[ "is_prime", "prime_coprime_count" ]
2
[ [ "prime_coprime_count", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f2a858069c9bfd5768230d37c90a0be07c673bec
0ec8fce9558e4620e50d0774dd034314f044fab9
v1.0
complete
Taco
Taco_67203_C
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None def build_tree(node_values_list, edges_list): """Build and return the root of a binary tree from node values and edges.""" pass def is_balanced(root): """Check if a binary tree is balanced. ...
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None def build_tree(node_values_list, edges_list): if not node_values_list: return None nodes = {val: TreeNode(val) for val in node_values_list} for u, v, w in edges_list: if u in n...
from solution import check_balanced def test_balanced_tree(): assert check_balanced(3, [1, 2, 3], [(1, 2, 1), (1, 3, 1)]) == "Balanced" def test_not_balanced_tree(): # Tree structure: # 1 # / # 2 # / # 3 assert check_balanced(3, [1, 2, 3], [(1, 2, 1), (2, 3, 1)]) == "Not...
[]
[ 1, 0 ]
1
medium
0.5
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, x):\n self.val = x\n self.left = None\n self.right = None\n\ndef build_tree(node_values_list, edges_li...
trial_gpt4o_0
{ "original_instruction": "Sunny loves trees and coding. He is given a binary tree with nodes numbered 1 to N. Sunny needs to check if the binary tree is balanced or not. \n\nA binary tree is balanced if for every node in the tree, the height difference between its left and right subtrees is at most 1.\n\nWrite a fun...
0.759554
Taco_67203
C
[ "build_tree", "is_balanced", "check_balanced" ]
3
[ [ "check_balanced", "build_tree" ], [ "check_balanced", "is_balanced" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
0ca36f6db8647f40599d411b62b6712589b3a8b7
e7a7400601576ccac2b6f2a3f189f1cf96b4d6b7
v1.0
complete
Taco
Taco_67121_C
def sieve_of_eratosthenes(max_num): """ Returns a list of boolean values where the index represents the number. True means the index number is prime. """ pass # Write your code here def count_prime_pairs(N, primes): """ Returns the number of ways to split N into two prime parts. """ pa...
def sieve_of_eratosthenes(max_num): """ Returns a list of boolean values where the index represents the number. True means the index number is prime. """ is_prime = [True] * (max_num + 1) p = 2 while (p * p <= max_num): if is_prime[p]: for i in range(p * p, max_num + 1, p): ...
from solution import solve def test_example_cases(): T = 2 assert solve([10, 12]) == [2, 1] def test_single_case_odd_number(): assert solve([9]) == [1] def test_large_number_with_multiple_pairs(): assert solve([26]) == [3] def test_number_with_no_pairs(): assert solve([4]) == [1] # The only pai...
[ { "docstring": "Returns a list of boolean values where the index represents the number. True means the index number is prime.", "function_declaration": "def sieve_of_eratosthenes(max_num):", "function_name": "sieve_of_eratosthenes", "parameter_list": "(max_num)" }, { "docstring": "Returns th...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sieve_of_eratosthenes(max_num):\n prime = [True] * (max_num + 1)\n p = 2\n while (p * p <= max_num):\n if prime[p] == True:\n for i ...
trial_gpt4o_9
{ "original_instruction": "Taru and Chandu are playing another game. This time Taru gives Chandu a number and asks him to find the number of ways to split the number into two parts such that both parts are prime numbers and the sum of these primes equals the given number.\n\nFor example:\nFor N = 10, the prime pairs ...
0.62685
Taco_67121
C
[ "sieve_of_eratosthenes", "count_prime_pairs", "solve" ]
3
[ [ "solve", "count_prime_pairs" ], [ "solve", "sieve_of_eratosthenes" ] ]
2
[]
false
[]
false
pytest
true
[]
true
7c7a499cd7b295497774ce2ed8bf15a9c36b2029
13ce52e9c3f28dd75c7d9e165a0372f67c8f83f0
v1.0
complete
Taco
Taco_67240_C
import itertools import math from typing import List, Tuple def min_travel_distance(points: List[Tuple[int, int]]) -> float: """ Compute the shortest possible route that visits each delivery point exactly once and returns to the starting point, forming a cycle. >>> min_travel_distance([(0, 0), (1, 1), (1, 0), ...
import itertools import math def distance(point1, point2): """ Helper function to calculate Euclidean distance between two points. """ return math.sqrt((point2[0] - point1[0]) ** 2 + (point2[1] - point1[1]) ** 2) def min_travel_distance(points): """ Function to calculate the minimum travel dis...
from solution import min_travel_distance def test_min_travel_distance_example_case(): points = [(0, 0), (1, 1), (1, 0), (0, 1)] assert min_travel_distance(points) == 4.00 def test_min_travel_distance_two_points(): points = [(0, 0), (3, 4)] assert min_travel_distance(points) == 10.0 def test_min_trave...
[ { "docstring": "Helper function to calculate Euclidean distance between two points.", "function_declaration": "def distance(point1, point2):", "function_name": "distance", "parameter_list": "(point1, point2)" }, { "docstring": "Function to calculate the minimum travel distance for the Travel...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import itertools\nimport math\n\ndef euclidean_distance(point1, point2):\n return math.sqrt((point1[0] - point2[0]) ** 2 + (point1[1] - point2[1]) ** 2)\n\ndef ...
trial_gpt4o_1
{ "original_instruction": "You are the chief engineer working on a new artificial intelligence system for a parcel delivery service. The system needs to identify the best route for delivery vehicles to take, reducing the travel time and fuel consumption. One of the challenges you've encountered is determining the opt...
0.688674
Taco_67240
C
[ "distance", "min_travel_distance" ]
2
[ [ "min_travel_distance", "distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
44b9854c0de95bfc23ac2b7b8fed36437b06013a
ee18ad35ab5c3a597a13090656614aa21ae8fa3b
v1.0
complete
Taco
Taco_67569_C
def can_be_expressed_as_product_of_two_distinct_primes(T: int, cases: List[int]) -> List[str]: """ Given an integer N, determine if it can be expressed as a product of two distinct prime numbers. :param T: The number of test cases. :param cases: A list of N for each test case. :return: A list o...
def sieve_of_eratosthenes(limit): is_prime = [True] * (limit + 1) is_prime[0] = is_prime[1] = False for i in range(2, int(limit**0.5) + 1): if is_prime[i]: for j in range(i * i, limit + 1, i): is_prime[j] = False return [i for i in range(2, limit + 1) if is_prime[i]] ...
from solution import can_be_expressed_as_product_of_two_distinct_primes def test_sample_input(): assert can_be_expressed_as_product_of_two_distinct_primes(4, [10, 15, 21, 49]) == ["YES", "YES", "YES", "NO"] def test_single_prime(): assert can_be_expressed_as_product_of_two_distinct_primes(1, [7]) == ["NO"] d...
[ { "docstring": null, "function_declaration": "def sieve_of_eratosthenes(limit):", "function_name": "sieve_of_eratosthenes", "parameter_list": "(limit)" }, { "docstring": null, "function_declaration": "def can_be_product_of_two_distinct_primes(n, primes):", "function_name": "can_be_pr...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sieve(limit):\n \"\"\" Generate a list of prime numbers up to the given limit using the Sieve of Eratosthenes. \"\"\"\n is_prime = [True] * (limit + 1)\n...
trial_gpt4o_1
{ "original_instruction": "Given an integer N, determine if it can be expressed as a product of two distinct prime numbers.\n\n------ Input Format ------ \n\n- The first line of input contains a single integer T — the number of test cases. Then the T test cases follow.\n- Each of the next T lines contains a single in...
0.65314
Taco_67569
C
[ "sieve_of_eratosthenes", "can_be_product_of_two_distinct_primes", "can_be_expressed_as_product_of_two_distinct_primes" ]
3
[ [ "can_be_expressed_as_product_of_two_distinct_primes", "can_be_product_of_two_distinct_primes" ], [ "can_be_expressed_as_product_of_two_distinct_primes", "sieve_of_eratosthenes" ] ]
2
[]
false
[]
false
pytest
true
[]
true
170e0a41463fcb5769888cfbb2e988b8f83df52f
13abfa58e283a2aa091a6aed05cdda5b40ec957b
v1.0
complete
Taco
Taco_66903_C
import math from typing import List, Tuple def tsp_min_distance(n: int, coordinates: List[Tuple[int, int]]) -> float: """ Given a set of coordinates representing delivery locations, determine the minimum total distance that the trucks would have to travel if they visit every delivery location exactly onc...
import itertools import math def calculate_distance(point1, point2): """ Returns the Euclidean distance between two points. """ return math.sqrt((point1[0] - point2[0])**2 + (point1[1] - point2[1])**2) def tsp_min_distance(n, coordinates): """ Returns the minimum total travel distance for the ...
from solution import tsp_min_distance def test_tsp_min_distance_example(): coordinates = [(0, 0), (2, 0), (2, 2), (0, 2)] assert tsp_min_distance(4, coordinates) == 8.00 def test_tsp_min_distance_two_locations(): coordinates = [(0, 0), (3, 4)] assert tsp_min_distance(2, coordinates) == 10.00 # (0,0) ...
[ { "docstring": "Returns the Euclidean distance between two points.", "function_declaration": "def calculate_distance(point1, point2):", "function_name": "calculate_distance", "parameter_list": "(point1, point2)" }, { "docstring": "Returns the minimum total travel distance for the TSP problem...
[ 0, 0, 0, 0, 0, 0, 1, 0, 1, 1 ]
3
hard
0.3
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import itertools\nimport math\n\ndef calculate_distance(point1, point2):\n \"\"\"\n Calculate the Euclidean distance between two points.\n \"\"\"\n ret...
trial_gpt4o_9
{ "original_instruction": "Sam, a logistics manager, is tasked with optimizing the delivery routes for his company. The goal is to minimize the distance traveled by delivery trucks to ensure fuel efficiency and timely deliveries. Given a set of coordinates representing delivery locations, Sam wants to determine the m...
0.642558
Taco_66903
C
[ "calculate_distance", "tsp_min_distance" ]
2
[ [ "tsp_min_distance", "calculate_distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a7ebb7fa85703a5b0b16eb82e7ab74c25af39cb4
5e1bfb9b235bed437a2b8a10c03cde7802081adc
v1.0
complete
Taco
Taco_67575_C
import re def is_valid_palindrome(s: str) -> str: """ Checks if the given string is a valid palindrome considering only alphanumeric characters and ignoring case. >>> is_valid_palindrome("A man, a plan, a canal: Panama") "YES" >>> is_valid_palindrome("race a car") "NO" >>> is_valid_palindrome("...
import re def is_valid_palindrome(s): """ Checks if the given string is a valid palindrome considering only alphanumeric characters and ignoring case. :param s: The input string :return: "YES" if the string is a valid palindrome, "NO" otherwise """ # Remove non-alphanumeric characters and ...
from solution import is_valid_palindrome, palindrome_checker def test_is_valid_palindrome(): assert is_valid_palindrome("A man, a plan, a canal: Panama") == "YES" assert is_valid_palindrome("race a car") == "NO" assert is_valid_palindrome("Was it a car or a cat I saw?") == "YES" assert is_valid_palindr...
[ { "docstring": "Checks if the given string is a valid palindrome considering only alphanumeric characters and ignoring case.\n\n:param s: The input string\n:return: \"YES\" if the string is a valid palindrome, \"NO\" otherwise", "function_declaration": "def is_valid_palindrome(s):", "function_name": "is...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import re\n\ndef is_palindrome(s):\n \"\"\"\n Determines if the given string s is a palindrome, considering only alphanumeric characters and ignoring case.\n...
trial_gpt4o_2
{ "original_instruction": "John loves palindromes. A palindrome is a string that reads the same forward and backward. He has a list of strings and wants to check if each string in the list is a valid palindrome or not. To make this more challenging, John considers only alphanumeric characters and ignores cases while ...
0.85828
Taco_67575
C
[ "is_valid_palindrome", "palindrome_checker" ]
2
[ [ "palindrome_checker", "is_valid_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
fc2c40262a2868d2a3d0e46c025a4c286400eea6
1973552d96d717847cf371f139a8aad81033278e
v1.0
complete
Taco
Taco_67241_C
from typing import List, Tuple def preprocess_lca(n: int, adj: List[List[int]], root: int): """ Preprocesses the tree to enable fast LCA queries. Initializes the parent and depth matrices. """ pass def lca(node1: int, node2: int, parent: List[int], depth: List[int]) -> int: """ Finds the l...
from collections import deque def preprocess_lca(n, adj, root): """ Preprocesses the tree to enable fast LCA queries. Initializes the parent and depth matrices. """ parent = [-1] * (n + 1) depth = [0] * (n + 1) levels = [[] for _ in range(n + 1)] visited = [False] * (n + 1) def...
from solution import main def test_example_case(): n = 7 q = 3 edges = [(1, 2), (1, 3), (2, 4), (2, 5), (3, 6), (3, 7)] queries = [(4, 5), (4, 6), (6, 7)] assert main(n, q, edges, queries) == [2, 4, 2] def test_single_node(): n = 1 q = 1 edges = [] queries = [(1, 1)] assert mai...
[ { "docstring": "Preprocesses the tree to enable fast LCA queries.\nInitializes the parent and depth matrices.", "function_declaration": "def preprocess_lca(n, adj, root):", "function_name": "preprocess_lca", "parameter_list": "(n, adj, root)" }, { "docstring": "Finds the lowest common ancest...
[ 0, 0, 1, 0 ]
1
hard
0.25
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import defaultdict, deque\n\ndef preprocess_lca(n, edges):\n tree = defaultdict(list)\n for u, v in edges:\n tree[u].append(v)\n ...
trial_gpt4o_3
{ "original_instruction": "You are given a tree with n nodes. There are q queries. Each query asks you to compute the distance between two nodes u and v in the tree.\n\nThe tree is rooted at node 1. \n\nInput\n\nThe first line contains two integers n and q (1 ≤ n ≤ 10^5, 1 ≤ q ≤ 10^5) — the number of nodes in the tre...
0.59089
Taco_67241
C
[ "preprocess_lca", "lca", "distance_between_nodes", "main" ]
4
[ [ "distance_between_nodes", "lca" ] ]
1
[]
false
[]
false
pytest
true
[]
true
cc977e4ebcf2a330a6b39f60d7abc074f2fa9875
cb04ed0012ffafd7713f7501f602ab613b22f0e9
v1.0
complete
Taco
Taco_67317_C
def shortest_path_length(grid): """ Given a grid of size NxN where each cell is either empty (denoted by '.') or contains a wall (denoted by '#'), find the shortest path from the top-left cell to the bottom-right cell. You are only allowed to move to adjacent cells (up, down, left, right) and cannot mov...
from collections import deque def shortest_path_length(grid): N = len(grid) if grid[0][0] == '#' or grid[N-1][N-1] == '#': return -1 directions = [(0, 1), (1, 0), (0, -1), (-1, 0)] queue = deque([(0, 0, 1)]) visited = set((0, 0)) while queue: x, y, dist = queue.popleft() ...
from solution import solve, parse_input def test_example_cases(): input_string = "3\n4\n....\n.##.\n..#.\n....\n4\n.#..\n###.\n..#.\n...#\n2\n##\n..\n" test_cases = parse_input(input_string) assert solve(test_cases) == [7, -1, -1] def test_case_no_path_due_to_walls(): input_string = "1\n3\n###\n#.#\n#...
[ { "docstring": null, "function_declaration": "def shortest_path_length(grid):", "function_name": "shortest_path_length", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def solve(test_cases):", "function_name": "solve", "parameter_list": "(test_cases)"...
[ 0, 0, 0, 0, 0, 1, 0, 0, 1, 0 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef shortest_path_in_grid(grid):\n N = len(grid)\n if grid[0][0] == '#' or grid[N-1][N-1] == '#':\n return -1\n\n ...
trial_gpt4o_5
{ "original_instruction": "Given a grid of size NxN where each cell is either empty (denoted by '.') or contains a wall (denoted by '#'), find the shortest path from the top-left cell to the bottom-right cell. You are only allowed to move to adjacent cells (up, down, left, right) and cannot move through walls. You ne...
0.737173
Taco_67317
C
[ "shortest_path_length", "solve", "parse_input" ]
3
[ [ "solve", "shortest_path_length" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
f8ac017c259d9c6239a6f1754791a0a36690b4c6
b1444a039a30ee4549f2dedc999755037cd8eb15
v1.0
complete
Taco
Taco_67478_C
def maxRectangleArea(grid): """ Find the maximum area of a rectangle consisting entirely of empty cells in a grid. >>> maxRectangleArea([ ... [1, 0, 1, 0, 0], ... [1, 0, 0, 0, 1], ... [1, 1, 0, 0, 0] ... ]) 4 >>> maxRectangleArea([[0, 1, 0, 0]]) 2 >>> maxRe...
def maxRectangleArea(grid): if not grid: return 0 nrows = len(grid) ncols = len(grid[0]) max_area = 0 heights = [0] * ncols for row in grid: for col in range(ncols): if row[col] == 0: heights[col] += 1 else: heigh...
from solution import maxRectangleArea def test_single_row(): grid = [[0, 1, 0, 0]] assert maxRectangleArea(grid) == 2 def test_single_column(): grid = [[0], [1], [0], [0]] assert maxRectangleArea(grid) == 2 def test_small_grid(): grid = [ [1, 0, 1, 0, 0], [1, 0, 0, 0, 1], ...
[ { "docstring": null, "function_declaration": "def maxRectangleArea(grid):", "function_name": "maxRectangleArea", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def largestRectangleInHistogram(heights):", "function_name": "largestRectangleInHistogram", ...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def maxRectangleArea(grid):\n def largestRectangleArea(heights):\n stack = []\n max_area = 0\n heights.append(0) # Add a zero to handle th...
trial_gpt4o_2
{ "original_instruction": "## Task\nYou are given a grid with N rows and M columns of cells. Each cell can either be empty or contain an obstacle. Your task is to find the maximum area of a rectangle consisting entirely of empty cells. \n\nYou need to write a function `maxRectangleArea` that takes in a 2D list (grid)...
0.665747
Taco_67478
C
[ "maxRectangleArea", "largestRectangleInHistogram" ]
2
[ [ "maxRectangleArea", "largestRectangleInHistogram" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2408406ae14bbee06874b487971bb7c6aabdbbd7
c1c6584092974b3c7876a2532d8f8e6706cefb39
v1.0
complete
Taco
Taco_66863_C
from typing import List, Tuple def verify_donations(donations: List[Tuple[int, int, int, int]]) -> List[str]: """ Verifies if the calculated total donation value matches the provided total value for each donation. Parameters: donations (list): A list of tuples where each tuple contains (money,...
def verify_donations(donations): """ Verifies if the calculated total donation value matches the provided total value for each donation. Parameters: donations (list): A list of tuples where each tuple contains (money, item_quantity, item_value, provided_total_value) Returns: li...
from solution import verify_donations def test_correct_calculations(): donations = [ (100, 5, 20, 200), (200, 3, 50, 350), (150, 10, 10, 250), (300, 2, 75, 450) ] expected = ["CORRECT", "CORRECT", "CORRECT", "CORRECT"] assert verify_donations(donations) == expected def ...
[ { "docstring": "Verifies if the calculated total donation value matches the provided total value for each donation.\n\nParameters:\n donations (list): A list of tuples where each tuple contains (money, item_quantity, item_value, provided_total_value)\n\nReturns:\n list: A list containing \"CORRECT\" or \"...
[ 0, 0, 0, 0, 1 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def verify_donations(donations):\n \"\"\"\n Verifies if the calculated total value matches the provided total value for each donation.\n \n Args:\n ...
trial_gpt4o_4
{ "original_instruction": "John is organizing a charity event and he needs to manage the donations. Each donor contributes a certain amount of money and a certain number of items. John needs to verify that the total value of donations matches the recorded total sum provided in a list. As John's assistant, you are ass...
0.595725
Taco_66863
C
[ "verify_donations", "read_input_and_verify" ]
2
[ [ "read_input_and_verify", "verify_donations" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8844c82e26236ec34a2011e7ae69fde0f7ea1bd7
be6c4383456924d022a4a68eb34bba2aaea8c912
v1.0
complete
Taco
Taco_67422_C
def read_and_check_passcodes(input_data: str) -> List[str]: """ Reads multiple passcodes and determines if each passcode meets the minimum security requirements. Each passcode must contain at least one upper-case letter, one lower-case letter, one digit, and one special symbol. Parameters: input_da...
def check_passcode(passcodes): results = [] for passcode in passcodes: has_upper = any(c.isupper() for c in passcode) has_lower = any(c.islower() for c in passcode) has_digit = any(c.isdigit() for c in passcode) has_special = any(not c.isalnum() for c in passcode) ...
import pytest from solution import read_and_check_passcodes def test_single_valid_passcode(): input_data = "1\nA1a!" expected_output = ["PASS"] assert read_and_check_passcodes(input_data) == expected_output def test_single_invalid_passcode(): input_data = "1\nabc" expected_output = ["FAIL"] as...
[ { "docstring": null, "function_declaration": "def check_passcode(passcodes):", "function_name": "check_passcode", "parameter_list": "(passcodes)" }, { "docstring": null, "function_declaration": "def read_and_check_passcodes(input_data):", "function_name": "read_and_check_passcodes", ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def check_passcode(passcodes):\n results = []\n for passcode in passcodes:\n has_upper = any(c.isupper() for c in passcode)\n has_lower = any(c...
trial_gpt4o_0
{ "original_instruction": "In a high-security building, a computer system is used to control access through various doors using a series of passcodes. Each passcode consists of multiple characters, and each character could be one of four types: upper-case letter, lower-case letter, digit, or special symbol. System an...
0.557174
Taco_67422
C
[ "check_passcode", "read_and_check_passcodes" ]
2
[ [ "read_and_check_passcodes", "check_passcode" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8e256416d02e284fa1c3b9bc4020a7a9f6547729
1966529593bd56979a9723fde189a90fac2a280c
v1.0
complete
Taco
Taco_67329_C
from typing import List, Tuple def min_delivery_time(graph: List[List[Tuple[int, int]]], start: int, packages: List[int]) -> int: """ A courier company needs to deliver a series of packages to a number of cities organized in a network. Each city is connected to other cities via roads, and each road has an asso...
import heapq from typing import List, Tuple def dijkstra(graph: List[List[Tuple[int, int]]], start: int) -> List[int]: """Implementation of Dijkstra's algorithm to find shortest paths from start to all nodes.""" num_cities = len(graph) min_time = [float('inf')] * num_cities min_time[start] = 0 prio...
from solution import min_delivery_time def test_example_1(): graph = [ [(1, 2), (2, 4)], [(0, 2), (2, 1)], [(0, 4), (1, 1)] ] start = 0 packages = [1, 2] assert min_delivery_time(graph, start, packages) == 10 def test_example_2(): graph = [ [(1, 3), (2, 5)], ...
[ { "docstring": "Implementation of Dijkstra's algorithm to find shortest paths from start to all nodes.", "function_declaration": "def dijkstra(graph, start):", "function_name": "dijkstra", "parameter_list": "(graph, start)" }, { "docstring": "Returns the minimum time required to deliver all ...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\nfrom typing import List, Tuple\n\ndef dijkstra(graph: List[List[Tuple[int, int]]], start: int) -> List[int]:\n \"\"\"Implementation of Dijkstra's ...
trial_gpt4o_0
{ "original_instruction": "A courier company needs to deliver a series of packages to a number of cities organized in a network. Each city is connected to other cities via roads, and each road has an associated travel time. The company wants to determine the minimum time required to deliver all packages if it starts ...
0.676397
Taco_67329
C
[ "dijkstra", "min_delivery_time" ]
2
[ [ "min_delivery_time", "dijkstra" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3402f7d0d89954ade953277fe781100936437c8c
0d528f5919b8747741cbd9350166e778995167ac
v1.0
complete
Taco
Taco_66795_C
def find(parent, i): if parent[i] == i: return i else: return find(parent, parent[i]) def union(parent, rank, x, y): root_x = find(parent, x) root_y = find(parent, y) if root_x != root_y: if rank[root_x] > rank[root_y]: parent[root_y] = root_x elif r...
def find(parent, i): if parent[i] == i: return i else: return find(parent, parent[i]) def union(parent, rank, x, y): root_x = find(parent, x) root_y = find(parent, y) if root_x != root_y: if rank[root_x] > rank[root_y]: parent[root_y] = root_x elif r...
def test_sample_input(): from io import StringIO import sys input_str = "5 6\n1 2 5\n1 3 10\n2 3 3\n2 4 7\n3 5 9\n4 5 2\n" expected_output = "YES\n" sys.stdin = StringIO(input_str) try: main() finally: sys.stdin = sys.__stdin__ def test_no_safest_route(): from io im...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n else:\n return find(parent, parent[i])\n\ndef union(parent, rank, x, y):\n root_x = f...
trial_gpt4o_0
{ "original_instruction": "The Galaxy Explorers is a group of astronauts on an important mission. They have several missions, each involving travelling between planets connected by space routes. The safety of a route is judged by the number of asteroids frequently passing through it. Every route has a safety score re...
0.616457
Taco_66795
C
[ "find", "union", "can_form_safest_route_system", "main" ]
4
[ [ "can_form_safest_route_system", "find" ], [ "can_form_safest_route_system", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
false
[]
true
009ae1efddebf9c566ddc71e4b7e6e71f1fe75a2
dfc9d787d8dadf69a7aaaa3b143d598b016b4a2b
v1.0
complete
Taco
Taco_67083_C
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def insert_level_order(arr, root, i, n): if i < n: if arr[i] == -1: return None temp = TreeNode(arr[i]) root = temp root.left...
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def insert_level_order(arr, root, i, n): if i < n: if arr[i] == -1: return None temp = TreeNode(arr[i]) root = temp root.left...
from solution import is_height_balanced def test_balanced_tree(): assert is_height_balanced([3, 9, 20, -1, -1, 15, 7]) == True def test_unbalanced_tree(): assert is_height_balanced([1, 2, 2, 3, 3, -1, -1, 4, 4]) == False def test_empty_tree(): assert is_height_balanced([]) == True def test_single_node_t...
[]
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n self.left = left\n self.right = right\n\ndef level_o...
trial_gpt4o_1
{ "original_instruction": "A binary tree is given as a list of integers in level order, where null values are denoted by -1. Determine if the binary tree is height-balanced. A height-balanced binary tree is defined as a binary tree in which the left and right subtrees of every node differ in height by no more than 1....
0.70271
Taco_67083
C
[ "insert_level_order", "check_balanced", "is_height_balanced" ]
3
[ [ "is_height_balanced", "check_balanced" ], [ "is_height_balanced", "insert_level_order" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
4de349915ae86a54c7e24e5d0bbc7ba26901ea64
741b2e476b8ebacb35c04efb9ae813c80795d2b2
v1.0
complete
Taco
Taco_67423_C
def team_building_event(t: int, test_cases: List[Tuple[int, List[int]]]) -> str: """Mary is organizing a team-building event where participants will sit in a circular arrangement. She needs to ensure that there are no two participants seated next to each other such that their skills are directly related, to pr...
from math import gcd from itertools import permutations def is_valid_arrangement(arrangement): n = len(arrangement) for i in range(n): if gcd(arrangement[i], arrangement[(i + 1) % n]) > 1: return False return True def find_arrangement(t, test_cases): results = [] for case in te...
import pytest from solution import team_building_event def test_example_1(): assert team_building_event(2, [(4, [2, 3, 5, 7]), (4, [2, 4, 8, 16])]) == "YES\n2 3 5 7\nNO" def test_single_case_yes(): assert team_building_event(1, [(3, [1, 6, 5])]) == "YES\n1 6 5" def test_single_case_no(): assert team_buil...
[ { "docstring": null, "function_declaration": "def is_valid_arrangement(arrangement):", "function_name": "is_valid_arrangement", "parameter_list": "(arrangement)" }, { "docstring": null, "function_declaration": "def find_arrangement(t, test_cases):", "function_name": "find_arrangement...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from math import gcd\nfrom itertools import permutations\n\ndef can_be_arranged(n, skills):\n for perm in permutations(skills):\n valid = True\n f...
trial_gpt4o_2
{ "original_instruction": "Mary is organizing a team-building event where participants will sit in a circular arrangement. She needs to ensure that there are no two participants seated next to each other such that their skills are directly related, to promote better interaction. The skills of the participants are rep...
0.646324
Taco_67423
C
[ "is_valid_arrangement", "find_arrangement", "team_building_event" ]
3
[ [ "find_arrangement", "is_valid_arrangement" ], [ "team_building_event", "find_arrangement" ] ]
2
[]
false
[]
false
pytest
true
[]
true
0410c6c22ba85c729a31e7274191116ee31a8d68
ea57569be8de8d5705ebdcd772673d80453a2cf5
v1.0
complete
Taco
Taco_67564_C
from functools import cmp_to_key def custom_compare(x, y): """ Custom comparator for sorting numbers based on lexicographical order. """ if x + y > y + x: return -1 elif x + y < y + x: return 1 else: return 0 def largest_number(arr): """ Form the largest possible number...
from functools import cmp_to_key def custom_compare(x, y): # Convert numbers to string and compare combinations if x + y > y + x: return -1 elif x + y < y + x: return 1 else: return 0 def largest_number(arr): # Convert integers to strings for custom comparison arr = lis...
def test_custom_compare(): assert custom_compare("9", "34") == -1 assert custom_compare("34", "9") == 1 assert custom_compare("5", "50") == -1 assert custom_compare("50", "5") == 1 assert custom_compare("17", "171") == -1 def test_largest_number(): assert largest_number([10, 2, 9]) == '9210' ...
[ { "docstring": null, "function_declaration": "def custom_compare(x, y):", "function_name": "custom_compare", "parameter_list": "(x, y)" }, { "docstring": null, "function_declaration": "def largest_number(arr):", "function_name": "largest_number", "parameter_list": "(arr)" }, ...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from functools import cmp_to_key\n\ndef largest_number(nums):\n \"\"\"\n Forms the largest possible number by rearranging the given numbers.\n \"\"\"\n ...
trial_gpt4o_2
{ "original_instruction": "You are given $N$ integers in an array representing scores, and you have a task to form the largest possible number by rearranging these integers. As the input size can be large, the approach needs to consider efficiency in terms of both time and space complexity. \n\nWrite a program to sol...
0.678913
Taco_67564
C
[ "custom_compare", "largest_number", "solve", "main" ]
4
[ [ "largest_number", "custom_compare" ], [ "solve", "largest_number" ] ]
2
[]
false
[]
false
pytest
false
[]
true
c1231fbd4b1a28b840984336addb101029dd1b26
12d448941e0f0b6e78b37b8afa879bc0f77354e1
v1.0
complete
Taco
Taco_67561_C
def minimum_travel_cost(N: int, M: int, roads: List[Tuple[int, int, int]], K: int, queries: List[Tuple[int, int]]) -> List[int]: """ Calculate the minimum travel cost between given pairs of cities in a kingdom of N cities with M directed roads. >>> minimum_travel_cost(4, 4, [(1, 2, 100), (2, 3, 200), (3, 4, 300...
import sys def floyd_warshall(n, roads): # Initialize distances dist = [[sys.maxsize] * n for _ in range(n)] for i in range(n): dist[i][i] = 0 # Add the given edges for u, v, w in roads: dist[u-1][v-1] = w # Floyd Warshall Algorithm to find all pairs shortest paths for k i...
from solution import minimum_travel_cost def test_minimum_travel_cost(): N = 4 M = 4 roads = [ (1, 2, 100), (2, 3, 200), (3, 4, 300), (1, 4, 1000) ] K = 2 queries = [ (1, 4), (2, 4) ] assert minimum_travel_cost(N, M, roads, K, queries) == ...
[ { "docstring": null, "function_declaration": "def floyd_warshall(n, roads):", "function_name": "floyd_warshall", "parameter_list": "(n, roads)" }, { "docstring": null, "function_declaration": "def minimum_travel_cost(N, M, roads, K, queries):", "function_name": "minimum_travel_cost",...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef dijkstra(n, graph, start):\n \"\"\"\n Use Dijkstra's algorithm to find the minimum travel costs from the \n start city to all other ci...
trial_gpt4o_1
{ "original_instruction": "In a kingdom of N cities, the ruler plans to build a series of directed roads to connect the cities. Each road has a positive integer cost associated with it. However, due to budget constraints, the ruler wants to ensure that it's possible to travel between certain pairs of cities with mini...
0.741471
Taco_67561
C
[ "floyd_warshall", "minimum_travel_cost" ]
2
[ [ "minimum_travel_cost", "floyd_warshall" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3debe56f465114ad07a7ee874c3a3df0a30ebc3f
17785c49235f6db5eed0764fa09cd4716051a4d9
v1.0
complete
Taco
Taco_67740_C
def digit_root(n): """ Function to compute the digit root of a number. """ pass def process_and_sort(nums): """ Function to process the given list of numbers to their digit roots and sort the result. """ pass def main(input_list): """ Main function to read the list of numbers, ...
def digit_root(n): """ Function to compute the digit root of a number. """ while n >= 10: n = sum(int(digit) for digit in str(n)) return n def process_and_sort(nums): """ Function to process the given list of numbers to their digit roots and sort the result. """ digit_roots ...
from solution import digit_root, process_and_sort, main def test_digit_root(): assert digit_root(38) == 2 assert digit_root(15) == 6 assert digit_root(122) == 5 assert digit_root(4) == 4 assert digit_root(91) == 1 assert digit_root(9999) == 9 assert digit_root(0) == 0 def test_process_and...
[ { "docstring": "Function to compute the digit root of a number.", "function_declaration": "def digit_root(n):", "function_name": "digit_root", "parameter_list": "(n)" }, { "docstring": "Function to process the given list of numbers to their digit roots and sort the result.", "function_de...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def digit_root(n):\n \"\"\"\n Calculate the digit root of a given number n.\n \"\"\"\n while n > 9:\n n = sum(int(digit) for digit in str(n))\n ...
trial_gpt4o_3
{ "original_instruction": "Given an array of integers nums, you need to repeatedly sum the digits of each number in the array until each number becomes a single-digit integer. After all numbers in the array are reduced to single digits, return the array sorted in non-decreasing order.\n\nFirst line contains an intege...
0.680166
Taco_67740
C
[ "digit_root", "process_and_sort", "main" ]
3
[ [ "process_and_sort", "digit_root" ] ]
1
[]
false
[]
false
pytest
true
[]
true
fc8d68ed0d06c5c1b0514f589b5c93c97b4ff4bc
248133ab152cc08f9f134a8f3cd28c12ad8a4bff
v1.0
complete
Taco
Taco_67751_C
class Node: """ A binary tree node. """ def __init__(self, key): self.data = key self.left = None self.right = None def leftViewUtil(root, level, max_level, result): """ Utility function to get the left view of the binary tree. """ pass def leftView(root): ...
class Node: """ A binary tree node. """ def __init__(self, key): self.data = key self.left = None self.right = None def leftViewUtil(root, level, max_level, result): """ Utility function to get the left view of the binary tree. """ if root is None: return...
import pytest from solution import Node, leftView def test_left_view_example_1(): root = Node(1) root.left = Node(2) root.right = Node(3) root.right.left = Node(4) root.right.right = Node(5) assert leftView(root) == [1, 2, 4] def test_left_view_example_2(): root = Node(10) root.le...
[]
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class Node:\n def __init__(self, data):\n self.data = data\n self.left = None\n self.right = None\n\ndef leftViewUtil(root, level, max_leve...
trial_gpt4o_2
{ "original_instruction": "Given a Binary Tree, find the Left View of the tree. The Left View of a Binary Tree is a set of nodes visible when the tree is viewed from the left side.\n\nExample 1:\nInput:\n 1\n / \\\n2 3\n / \\\n 4 5\nOutput: 1 2 4\n\nExample 2:\nInput:\n 10\n / \\\n 20 30\n /...
0.565175
Taco_67751
C
[ "leftViewUtil", "leftView" ]
2
[ [ "leftView", "leftViewUtil" ] ]
1
[]
false
[ "Node" ]
true
pytest
true
[]
true
6f763ef02279efc50282632224920d66d1ba072a
ca161097f1e97f675a52454ca0ca141ebacbde74
v1.0
complete
Taco
Taco_67756_C
def count_inversions(arr): """ Count the number of inversions in the array. An inversion is a pair of indices (i, j) such that i < j and arr[i] > arr[j]. >>> count_inversions([2, 3, 8, 6, 1]) 5 >>> count_inversions([1, 2, 3, 4, 5]) 0 >>> count_inversions([5, 4, 3, 2, 1]) 10 >>> cou...
def count_inversions(arr): """ Count the number of inversions in the array. """ return count_inversions_and_sort(arr, 0, len(arr) - 1) def count_inversions_and_sort(arr, left, right): """ Helper function to count inversions and sort the array. """ if left >= right: return 0 ...
from solution import count_inversions def test_simple_case(): assert count_inversions([2, 3, 8, 6, 1]) == 5 def test_sorted(): assert count_inversions([1, 2, 3, 4, 5]) == 0 def test_reverse_sorted(): assert count_inversions([5, 4, 3, 2, 1]) == 10 def test_duplicate_elements(): assert count_inversion...
[ { "docstring": "Count the number of inversions in the array.", "function_declaration": "def count_inversions(arr):", "function_name": "count_inversions", "parameter_list": "(arr)" }, { "docstring": "Helper function to count inversions and sort the array.", "function_declaration": "def co...
[ 0, 0, 0, 1, 1 ]
2
medium
0.4
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def count_inversions(arr):\n \"\"\"\n Function to count the number of inversions in the given array.\n \"\"\"\n def merge_count_split_inv(arr, temp_arr...
trial_gpt4o_4
{ "original_instruction": "In this problem, you have to find the number of inversions in a given sequence of integers. An inversion is a pair of indices $(i, j)$ such that $i < j$ and $a[i] > a[j]$. For example, in the sequence\n\n2 3 8 6 1,\n\nthere are five inversions: $(0, 4), (1, 4), (2, 3), (2, 4), (3, 4)$.\n\nY...
0.902975
Taco_67756
C
[ "count_inversions", "count_inversions_and_sort", "merge_and_count" ]
3
[ [ "count_inversions", "count_inversions_and_sort" ], [ "count_inversions_and_sort", "merge_and_count" ] ]
2
[]
false
[]
false
pytest
true
[]
true
cb6f1635012891f2385c86f63e2b5fe563ddae52
fbc0f7469ee3f76b7e710e117c7d135a2da2fe95
v1.0
complete
Taco
Taco_67830_C
def preprocess_sums(energies): """ Precomputes the prefix sums for the given list of energies. """ pass def query_sum(prefix_sums, i, j): """ Returns the sum of the elements from index i to j using the prefix sums array. """ pass def generate_results(n, energies, queries): """ ...
def preprocess_sums(energies): """ Precomputes the prefix sums for the given list of energies. """ n = len(energies) prefix_sums = [0] * (n + 1) # prefix_sums[0] is 0, starting from prefix_sums[1] to prefix_sums[n] for i in range(1, n + 1): prefix_sums[i] = prefix_sums[i - 1] + energies...
import pytest from solution import preprocess_sums, query_sum, generate_results def test_preprocess_sums(): energies = [7, 3, 2, 5, 1] expected_prefix_sums = [0, 7, 10, 12, 17, 18] assert preprocess_sums(energies) == expected_prefix_sums def test_query_sum(): prefix_sums = [0, 7, 10, 12, 17, 18] a...
[ { "docstring": "Precomputes the prefix sums for the given list of energies.", "function_declaration": "def preprocess_sums(energies):", "function_name": "preprocess_sums", "parameter_list": "(energies)" }, { "docstring": "Returns the sum of the elements from index i to j using the prefix sum...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def preprocess_and_query(n, energies, queries):\n \"\"\"\n Preprocess the energies array to allow fast range queries.\n :param n: Number of riders\n :p...
trial_gpt4o_2
{ "original_instruction": "Roller Coaster Riders\n\nAlice loves to visit amusement parks and ride roller coasters. One day, she visited a new amusement park which had a very long roller coaster that can hold up to $n$ riders at a time. Riders line up in a row and are assigned numbers from $1$ to $n$.\n\nAlice observe...
0.520109
Taco_67830
C
[ "preprocess_sums", "query_sum", "generate_results" ]
3
[ [ "generate_results", "preprocess_sums" ], [ "generate_results", "query_sum" ] ]
2
[ "generate_results" ]
false
[]
false
pytest
true
[]
true
cdb4e1c699e93ea65527ba7cf46674c88e0f6d33
0c9eda0ce157f9f553d783265d6e6b48563f3c61
v1.0
complete
Taco
Taco_67781_C
def is_pythagorean_triple(a, b, c): """ Determines if the integers a, b, c form a Pythagorean triple. >>> is_pythagorean_triple(3, 4, 5) "VALID" >>> is_pythagorean_triple(5, 12, 13) "VALID" >>> is_pythagorean_triple(8, 15, 17) "VALID" >>> is_pythagorean_triple(1, 2, 3) "INVALID" """ def...
def is_pythagorean_triple(a, b, c): """ Determines if the integers a, b, c form a Pythagorean triple. """ # Sort a, b, c to ensure a <= b <= c a, b, c = sorted([a, b, c]) # Check if the given numbers satisfy the Pythagorean theorem if a ** 2 + b ** 2 == c ** 2: return "VALID" ...
from solution import is_pythagorean_triple, check_pythagorean_triples def test_is_pythagorean_triple(): assert is_pythagorean_triple(3, 4, 5) == "VALID" assert is_pythagorean_triple(5, 12, 13) == "VALID" assert is_pythagorean_triple(8, 15, 17) == "VALID" assert is_pythagorean_triple(1, 2, 3) == "INVALI...
[ { "docstring": "Determines if the integers a, b, c form a Pythagorean triple.", "function_declaration": "def is_pythagorean_triple(a, b, c):", "function_name": "is_pythagorean_triple", "parameter_list": "(a, b, c)" }, { "docstring": "Check a list of triples to determine if each forms a Pytha...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_pythagorean_triple(a, b, c):\n \"\"\"\n Returns 'VALID' if a, b, and c form a Pythagorean triple, otherwise 'INVALID'.\n \"\"\"\n a, b, c = sort...
trial_gpt4o_2
{ "original_instruction": "Problem description:\nA Pythagorean triple consists of three positive integers a, b, and c such that a^2 + b^2 = c^2. Given a list of sets of three integers, determine whether each set forms a Pythagorean triple.\n\nInput\n\nEach case is specified on a single line with three integers a, b, ...
0.63258
Taco_67781
C
[ "is_pythagorean_triple", "check_pythagorean_triples" ]
2
[ [ "check_pythagorean_triples", "is_pythagorean_triple" ] ]
1
[]
false
[]
false
pytest
true
[]
true
fda65cfc5f820cfb1c015959e48be72d5ca681c6
0222a8a7d0e0c0a5eb0e28e80db714508c6662cc
v1.0
complete
Taco
Taco_67884_C
from typing import Tuple def meeting_time(L: int, vA: int, vB: int, vC: int) -> float: """ Calculate the meeting time of three friends on a circular track given the total length of the track and their individual speeds. Args: L (int): Total distance around the track. vA (int): Speed of Friend ...
from math import gcd from functools import reduce def lcm(a, b): """ Helper function to calculate least common multiple of two numbers. """ return a * b // gcd(a, b) def meeting_time(L, vA, vB, vC): """ Calculate the meeting time of three friends on a circular track given the total length ...
from solution import meeting_time def test_meeting_time(): assert meeting_time(12, 3, 2, 1) == 12.0 def test_meeting_time_different_speeds(): # Friend A = 1, Friend B = 2, Friend C = 3, Track is 6 units # They will meet at every multiple of LCM(1, 2, 3) which is 6. assert meeting_time(6, 1, 2, 3) == 6...
[ { "docstring": "Helper function to calculate least common multiple of two numbers.", "function_declaration": "def lcm(a, b):", "function_name": "lcm", "parameter_list": "(a, b)" }, { "docstring": "Calculate the meeting time of three friends on a circular track given the total\nlength of the ...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from math import gcd\nfrom functools import reduce\n\ndef lcm(a, b):\n \"\"\"\n Helper function to calculate least common multiple of two numbers.\n \"\"\...
trial_gpt4o_0
{ "original_instruction": "Write a function that calculates the meeting time of three friends who are walking at different speeds towards each other on a circular track. Given the total distance around the track and their individual speeds, determine at what time they will all meet at a single point after they start ...
0.518863
Taco_67884
C
[ "lcm", "meeting_time" ]
2
[ [ "meeting_time", "lcm" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0abfbc0435e7bd2a77f7cdf2ef28c42abade004c
f3653e18115a6808f7e766a29eafa3f3447f93d9
v1.0
complete
Taco
Taco_67554_C
def can_form_k_teams(n, k, skills): """Helper function to determine if k teams can be formed with balanced skill sums.""" total_skill = sum(skills) min_team_sum = total_skill // k max_team_sum = min_team_sum + 1 num_teams_with_max_sum = total_skill % k return all(skill <= max_team_sum for s...
def can_form_k_teams(n, k, skills): total_skill = sum(skills) min_team_sum = total_skill // k max_team_sum = min_team_sum + 1 num_teams_with_max_sum = total_skill % k return all(skill <= max_team_sum for skill in skills) and num_teams_with_max_sum <= k def is_possible_to_form_teams(n, k, skill...
from solution import is_possible_to_form_teams def test_case_1(): assert is_possible_to_form_teams(5, 2, [1, 2, 3, 4, 5]) == "YES" def test_case_2(): assert is_possible_to_form_teams(5, 3, [1, 1, 1, 1, 6]) == "NO" def test_case_3(): assert is_possible_to_form_teams(8, 4, [10, 10, 10, 10, 10, 10, 10, 10])...
[ { "docstring": null, "function_declaration": "def can_form_k_teams(n, k, skills):", "function_name": "can_form_k_teams", "parameter_list": "(n, k, skills)" }, { "docstring": null, "function_declaration": "def is_possible_to_form_teams(n, k, skills):", "function_name": "is_possible_to...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_divide_teams(n, k, skills):\n \"\"\"\n Determines whether it is possible to form k teams with balanced skill sums.\n\n Parameters:\n n (int): T...
trial_gpt4o_2
{ "original_instruction": "Alice is organizing a community event and has decided to invite n friends. She wants to form k teams such that the skills within each team are well balanced. Every friend has a skill level represented by an integer, and Alice wants each team to have a similar skill level sum.\n\nDetermine w...
0.686491
Taco_67554
C
[ "can_form_k_teams", "is_possible_to_form_teams" ]
2
[ [ "is_possible_to_form_teams", "can_form_k_teams" ] ]
1
[]
false
[]
false
pytest
true
[]
true
33ffc5ba7e0f84086c65df8da4361ca34636b845
e01fcb4d05cb89ca52a9580d5dcf684bce674639
v1.0
complete
Taco
Taco_68022_C
def assign_team_colors(T, cases): """ Distribute participants into teams such that no two adjacent participants in the list end up in the same team. Return the minimum number of different team colors necessary and an appropriate assignment of colors to the participants. Parameters: T (int): The...
def assign_team_colors(T, cases): results = [] for N in cases: min_colors = 2 colors = [] for i in range(N): colors.append((i % 2) + 1) # Alternates between 1 and 2 results.append((min_colors, colors)) return results def solve(T, cases): results = assig...
from solution import assign_team_colors def test_single_participant_case(): T = 1 cases = [1] results = assign_team_colors(T, cases) assert results == [(2, [1])] def test_three_participants_case(): T = 1 cases = [3] results = assign_team_colors(T, cases) assert results == [(2, [1, 2, 1...
[ { "docstring": null, "function_declaration": "def assign_team_colors(T, cases):", "function_name": "assign_team_colors", "parameter_list": "(T, cases)" }, { "docstring": null, "function_declaration": "def solve(T, cases):", "function_name": "solve", "parameter_list": "(T, cases)"...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def assign_team_colors(n):\n \"\"\"\n Returns the minimum number of team colors needed and a list representing the team color assigned to each participant.\n...
trial_gpt4o_1
{ "original_instruction": "A marathon event is being organized, and participants are divided into teams. Each team has a uniform color. As an organizer, you need to distribute the participants into teams such that no two adjacent participants in the list end up in the same team.\n\nEach participant has a unique ID, a...
0.658488
Taco_68022
C
[ "assign_team_colors", "solve" ]
2
[ [ "solve", "assign_team_colors" ] ]
1
[]
false
[]
false
pytest
true
[]
true
eab57e37e0406310403d0c0e84bb0b9fed570441
ae2d50b9499aab32a15fc1a2fe69d56e1725becd